Giter VIP home page Giter VIP logo

mysql-binlog-events's Introduction

The MySQL Binlog Events Library is a C++ library for reading MySQL replication events, either by connecting to a server or by reading from a file. To handle reading from a server, it includes a very simple client.

Dependencies

You need to have CMake version 2.8 or later and MySQL-5.7.x .

Now to get the libmysqlclient and the necessary include files you will have to do this:

  1. Download the source code of mysql-5.7.x (http://dev.mysql.com/downloads/mysql/) from the tab Development Releases.

  2. Download the binaries of the same version. There are few header files which are needed for mysql-binlog compilation and they only come as part of the source file. To make these files available during compilation please set the environment variable MYSQL_SOURCE_INCLUDE_DIR=<mysql-5.7.x source code>/include.

To be able to run the unit tests, you have to have Google Test installed. Google Test will be automatically installed if cmake is called as:

cmake . -DENABLE_DOWNLOADS=1

Directory structure

.
|-- bindings            Files for transport
|   |-- include         Include files
|   |-- src             Source files for library
|-- examples            Examples
|   |-- binlog-browser  Example application to browse the binary log
|-- libbinlogevents     Files to decode binlog events
|   |-- include         Include files
|   |-- src             Source files for library
|-- tests               Unit test files and directories

Building

To build the entire package, it is first necessary to run CMake to build all the makefiles. Before running CMake set this environment variable MYSQL_DIR to point to the MySQL binaries and then you can figure out where to find the right files in the cmake code.

We are using the statically linked version of libmysqlclient, so we need to pass -DMYSQLCLIENT_STATIC_LINKING:BOOL=TRUE along with the cmake command

    export MYSQL_DIR=<path of mysql directory or libmysql>
    cmake . -DMYSQLCLIENT_STATIC_LINKING:BOOL=TRUE
    make -j4

Some of the examples are using third-party software, which can require extra parameters to be given to CMake.

If you want to perform an out-of-source build, you can just create a build directory and execute CMake there.

  mkdir build
  cd build
  cmake <source directory>
  make -j4

About Value Convert

Any value that not implement yet in mysql-binlog-events/bindings/src/value.cpp, you can look in mysql-source-code/sql/log_event.cc and find function log_event_print_value.

mysql-binlog-events's People

Contributors

guweigang avatar ideal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mysql-binlog-events's Issues

Row_event_iterator unusable in for loop

EXAMPLE:

Row_event_set::iterator rows_itr = rowset.begin();
for (; rows_itr != rowset.end(); ++rows_itr) {
    // never reach here
    Row_of_fields rof(*rows_itr);
    std::cout << "\ncurrent row change:";
    //...
}

CAUSE:
Row_event_set::begin() & Row_event_set::end() returns nontrivially constructed and trivially constructed Row_event_iterator respectively.
However nontrivially constructed Row_event_iterator compares the same as trivially constructed one, making the first for loop exit directly as inequality test fails.
WORKAROUND:
Row_event_iterator is usable in do..while loop, as the first star operator call modifies its internal state and make it compare different from trivially constructed one.

Row_event_set::iterator rows_itr = rowset.begin();
do {
    Row_of_fields rof(*rows_itr);
    std::cout << "\ncurrent row change:";
    //...
} while (++rows_itr != rowset.end());

Compiling issues

Hi
I'm having issues compiling this library, did most what was told ,

root@redis06:~/jayme/mysql-binlog-events# cmake . -DMYSQLCLIENT_STATIC_LINKING:BOOL=TRUE
-- You will link statically to the MySQL client library (set with -DMYSQLCLIENT_STATIC_LINKING=<bool>)
-- Searching for static libraries with the base name(s) "libmysqlclient_r.a libmysqlclient.a"
-- mysql_config was found /usr/bin/mysql_config
-- MySQL client environment/cmake variables set that the user can override
--   MYSQL_DIR                   : /usr/lib/x86_64-linux-gnu
--   MYSQL_INCLUDE_DIR           : /usr/include/mysql
--   MYSQL_LIB_DIR               : /usr/lib/x86_64-linux-gnu
--   MYSQL_CONFIG_EXECUTABLE     : /usr/bin/mysql_config
--   MYSQL_CXX_LINKAGE           : 1
--   MYSQL_CFLAGS                : -I/usr/include/mysql
--   MYSQL_CXXFLAGS              : -I/usr/include/mysql
--   MYSQLCLIENT_STATIC_LINKING  : TRUE
--   MYSQLCLIENT_NO_THREADS      :
-- MySQL client optional environment/cmake variables set by the user
--   MYSQL_EXTRA_LIBRARIES       :
--   MYSQL_LINK_FLAGS            :
-- MySQL client settings that the user can't override
--   MYSQL_VERSION               : 5.7.19
--   MYSQL_NUM_VERSION           : 50719
--   MYSQL_LIB                   : /usr/lib/x86_64-linux-gnu/libmysqlclient.a
--   MYSQL_LIBRARIES             : /usr/lib/x86_64-linux-gnu/libmysqlclient.a;pthread;z;m;rt;dl;rt
-- Configuring done
-- Generating done
-- Build files have been written to: /root/jayme/mysql-binlog-events
root@redis06:~/jayme/mysql-binlog-events# echo $MYSQL_SOURCE_INCLUDE_DIR
/root/jayme/mysql-5.7.19/include
root@redis06:~/jayme/mysql-binlog-events# make
[ 20%] Built target binlogevents_static
[ 40%] Built target binlogevents_shared
[ 42%] Building CXX object bindings/src/CMakeFiles/replication_static.dir/access_method_factory.cpp.o
In file included from /root/jayme/mysql-binlog-events/bindings/include/field_iterator.h:20:0,
                 from /root/jayme/mysql-binlog-events/bindings/include/binlog.h:35,
                 from /root/jayme/mysql-binlog-events/bindings/include/tcp_driver.h:24,
                 from /root/jayme/mysql-binlog-events/bindings/src/access_method_factory.cpp:21:
/root/jayme/mysql-binlog-events/bindings/include/value.h:21:21: fatal error: my_time.h: No such file or directory
compilation terminated.
bindings/src/CMakeFiles/replication_static.dir/build.make:62: recipe for target 'bindings/src/CMakeFiles/replication_static.dir/access_method_factory.cpp.o' failed
make[2]: *** [bindings/src/CMakeFiles/replication_static.dir/access_method_factory.cpp.o] Error 1
CMakeFiles/Makefile2:217: recipe for target 'bindings/src/CMakeFiles/replication_static.dir/all' failed
make[1]: *** [bindings/src/CMakeFiles/replication_static.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2

when trying to make I get an error that a certain mysql header file can't be found..
but it's in the MYSQL_SOURCE_INCLUDE_DIR folder,/root/jayme/mysql-5.7.19/include.. /root/jayme/mysql-5.7.19/include/my_time.h file exists

What should I adjust?
(As a fix I also tried doing export MYSQL_INCLUDE_DIR=/root/jayme/mysql-5.7.19/include" but that gave other compiler issues, as that expects the compiled version of mysql_version.h etc.

Thx!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.