ruby-binlog 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +28 -0
- data/ext/Makefile +157 -0
- data/ext/binlog.so +0 -0
- data/ext/extconf.rb +5 -0
- data/ext/mkmf.log +24 -0
- data/ext/ruby_binlog.cpp +276 -0
- data/ext/ruby_binlog.h +33 -0
- data/ext/ruby_binlog.o +0 -0
- data/ext/ruby_binlog_event.cpp +67 -0
- data/ext/ruby_binlog_event.h +163 -0
- data/ext/ruby_binlog_event.o +0 -0
- data/ext/ruby_binlog_format_event.cpp +74 -0
- data/ext/ruby_binlog_format_event.o +0 -0
- data/ext/ruby_binlog_incident_event.cpp +59 -0
- data/ext/ruby_binlog_incident_event.o +0 -0
- data/ext/ruby_binlog_int_var_event.cpp +59 -0
- data/ext/ruby_binlog_int_var_event.o +0 -0
- data/ext/ruby_binlog_query_event.cpp +95 -0
- data/ext/ruby_binlog_query_event.o +0 -0
- data/ext/ruby_binlog_rotate_event.cpp +59 -0
- data/ext/ruby_binlog_rotate_event.o +0 -0
- data/ext/ruby_binlog_row_event.cpp +118 -0
- data/ext/ruby_binlog_row_event.o +0 -0
- data/ext/ruby_binlog_table_map_event.cpp +118 -0
- data/ext/ruby_binlog_table_map_event.o +0 -0
- data/ext/ruby_binlog_unimplemented_event.cpp +44 -0
- data/ext/ruby_binlog_unimplemented_event.o +0 -0
- data/ext/ruby_binlog_user_var_event.cpp +80 -0
- data/ext/ruby_binlog_user_var_event.o +0 -0
- data/ext/ruby_binlog_xid_event.cpp +52 -0
- data/ext/ruby_binlog_xid_event.o +0 -0
- metadata +96 -0
Binary file
|
@@ -0,0 +1,95 @@
|
|
1
|
+
#include "ruby_binlog.h"
|
2
|
+
|
3
|
+
VALUE rb_cBinlogQueryEvent;
|
4
|
+
|
5
|
+
namespace ruby {
|
6
|
+
namespace binlog {
|
7
|
+
|
8
|
+
void QueryEvent::free(QueryEvent *p) {
|
9
|
+
if (p->m_event) {
|
10
|
+
delete p->m_event;
|
11
|
+
p->m_event = 0;
|
12
|
+
p->m_event_header = 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
delete p;
|
16
|
+
}
|
17
|
+
|
18
|
+
VALUE QueryEvent::alloc(VALUE klass) {
|
19
|
+
QueryEvent *p;
|
20
|
+
|
21
|
+
p = new QueryEvent();
|
22
|
+
p->m_event = 0;
|
23
|
+
p->m_event_header = 0;
|
24
|
+
|
25
|
+
return Data_Wrap_Struct(klass, 0, &free, p);
|
26
|
+
}
|
27
|
+
|
28
|
+
void QueryEvent::set_event(VALUE self, mysql::Binary_log_event *event) {
|
29
|
+
QueryEvent *p;
|
30
|
+
|
31
|
+
Data_Get_Struct(self, QueryEvent, p);
|
32
|
+
p->m_event = static_cast<Query_event*>(event);
|
33
|
+
p->m_event_header = event->header();
|
34
|
+
}
|
35
|
+
|
36
|
+
void QueryEvent::init() {
|
37
|
+
rb_cBinlogQueryEvent = rb_define_class_under(rb_mBinlog, "QueryEvent", rb_cBinlogEvent);
|
38
|
+
rb_define_alloc_func(rb_cBinlogQueryEvent, &alloc);
|
39
|
+
|
40
|
+
Event::init(rb_cBinlogQueryEvent);
|
41
|
+
|
42
|
+
rb_define_method(rb_cBinlogQueryEvent, "thread_id", __F(&get_thread_id), 0);
|
43
|
+
rb_define_method(rb_cBinlogQueryEvent, "exec_time", __F(&get_exec_time), 0);
|
44
|
+
rb_define_method(rb_cBinlogQueryEvent, "error_code", __F(&get_error_code), 0);
|
45
|
+
rb_define_method(rb_cBinlogQueryEvent, "variables", __F(&get_variables), 0);
|
46
|
+
rb_define_method(rb_cBinlogQueryEvent, "db_name", __F(&get_db_name), 0);
|
47
|
+
rb_define_method(rb_cBinlogQueryEvent, "query", __F(&get_query), 0);
|
48
|
+
}
|
49
|
+
|
50
|
+
VALUE QueryEvent::get_thread_id(VALUE self) {
|
51
|
+
QueryEvent *p;
|
52
|
+
Data_Get_Struct(self, QueryEvent, p);
|
53
|
+
return ULONG2NUM(p->m_event->thread_id);
|
54
|
+
}
|
55
|
+
|
56
|
+
VALUE QueryEvent::get_exec_time(VALUE self) {
|
57
|
+
QueryEvent *p;
|
58
|
+
Data_Get_Struct(self, QueryEvent, p);
|
59
|
+
return ULONG2NUM(p->m_event->exec_time);
|
60
|
+
}
|
61
|
+
|
62
|
+
VALUE QueryEvent::get_error_code(VALUE self) {
|
63
|
+
QueryEvent *p;
|
64
|
+
Data_Get_Struct(self, QueryEvent, p);
|
65
|
+
return ULONG2NUM(p->m_event->error_code);
|
66
|
+
}
|
67
|
+
|
68
|
+
VALUE QueryEvent::get_variables(VALUE self) {
|
69
|
+
QueryEvent *p;
|
70
|
+
VALUE retval = rb_ary_new();
|
71
|
+
|
72
|
+
Data_Get_Struct(self, QueryEvent, p);
|
73
|
+
|
74
|
+
for (std::vector<uint8_t>::iterator itor = p->m_event->variables.begin();
|
75
|
+
itor != p->m_event->variables.end(); itor++) {
|
76
|
+
rb_ary_push(retval, UINT2NUM(*itor));
|
77
|
+
}
|
78
|
+
|
79
|
+
return retval;
|
80
|
+
}
|
81
|
+
|
82
|
+
VALUE QueryEvent::get_db_name(VALUE self) {
|
83
|
+
QueryEvent *p;
|
84
|
+
Data_Get_Struct(self, QueryEvent, p);
|
85
|
+
return rb_str_new2(p->m_event->db_name.c_str());
|
86
|
+
}
|
87
|
+
|
88
|
+
VALUE QueryEvent::get_query(VALUE self) {
|
89
|
+
QueryEvent *p;
|
90
|
+
Data_Get_Struct(self, QueryEvent, p);
|
91
|
+
return rb_str_new2(p->m_event->query.c_str());
|
92
|
+
}
|
93
|
+
|
94
|
+
} // namespace binlog
|
95
|
+
} // namespace ruby
|
Binary file
|
@@ -0,0 +1,59 @@
|
|
1
|
+
#include "ruby_binlog.h"
|
2
|
+
|
3
|
+
VALUE rb_cBinlogRotateEvent;
|
4
|
+
|
5
|
+
namespace ruby {
|
6
|
+
namespace binlog {
|
7
|
+
|
8
|
+
void RotateEvent::free(RotateEvent *p) {
|
9
|
+
if (p->m_event) {
|
10
|
+
delete p->m_event;
|
11
|
+
p->m_event = 0;
|
12
|
+
p->m_event_header = 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
delete p;
|
16
|
+
}
|
17
|
+
|
18
|
+
VALUE RotateEvent::alloc(VALUE klass) {
|
19
|
+
RotateEvent *p;
|
20
|
+
|
21
|
+
p = new RotateEvent();
|
22
|
+
p->m_event = 0;
|
23
|
+
p->m_event_header = 0;
|
24
|
+
|
25
|
+
return Data_Wrap_Struct(klass, 0, &free, p);
|
26
|
+
}
|
27
|
+
|
28
|
+
void RotateEvent::set_event(VALUE self, mysql::Binary_log_event *event) {
|
29
|
+
RotateEvent *p;
|
30
|
+
|
31
|
+
Data_Get_Struct(self, RotateEvent, p);
|
32
|
+
p->m_event = static_cast<Rotate_event*>(event);
|
33
|
+
p->m_event_header = event->header();
|
34
|
+
}
|
35
|
+
|
36
|
+
void RotateEvent::init() {
|
37
|
+
rb_cBinlogRotateEvent = rb_define_class_under(rb_mBinlog, "RotateEvent", rb_cBinlogEvent);
|
38
|
+
rb_define_alloc_func(rb_cBinlogRotateEvent, &alloc);
|
39
|
+
|
40
|
+
Event::init(rb_cBinlogRotateEvent);
|
41
|
+
|
42
|
+
rb_define_method(rb_cBinlogRotateEvent, "binlog_file", __F(&get_binlog_file), 0);
|
43
|
+
rb_define_method(rb_cBinlogRotateEvent, "binlog_pos", __F(&get_binlog_pos), 0);
|
44
|
+
}
|
45
|
+
|
46
|
+
VALUE RotateEvent::get_binlog_file(VALUE self) {
|
47
|
+
RotateEvent *p;
|
48
|
+
Data_Get_Struct(self, RotateEvent, p);
|
49
|
+
return rb_str_new2(p->m_event->binlog_file.c_str());
|
50
|
+
}
|
51
|
+
|
52
|
+
VALUE RotateEvent::get_binlog_pos(VALUE self) {
|
53
|
+
RotateEvent *p;
|
54
|
+
Data_Get_Struct(self, RotateEvent, p);
|
55
|
+
return ULL2NUM(p->m_event->binlog_pos);
|
56
|
+
}
|
57
|
+
|
58
|
+
} // namespace binlog
|
59
|
+
} // namespace ruby
|
Binary file
|
@@ -0,0 +1,118 @@
|
|
1
|
+
#include "ruby_binlog.h"
|
2
|
+
|
3
|
+
VALUE rb_cBinlogRowEvent;
|
4
|
+
|
5
|
+
namespace ruby {
|
6
|
+
namespace binlog {
|
7
|
+
|
8
|
+
void RowEvent::free(RowEvent *p) {
|
9
|
+
if (p->m_event) {
|
10
|
+
delete p->m_event;
|
11
|
+
p->m_event = 0;
|
12
|
+
p->m_event_header = 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
delete p;
|
16
|
+
}
|
17
|
+
|
18
|
+
VALUE RowEvent::alloc(VALUE klass) {
|
19
|
+
RowEvent *p;
|
20
|
+
|
21
|
+
p = new RowEvent();
|
22
|
+
p->m_event = 0;
|
23
|
+
p->m_event_header = 0;
|
24
|
+
|
25
|
+
return Data_Wrap_Struct(klass, 0, &free, p);
|
26
|
+
}
|
27
|
+
|
28
|
+
void RowEvent::set_event(VALUE self, mysql::Binary_log_event *event) {
|
29
|
+
RowEvent *p;
|
30
|
+
|
31
|
+
Data_Get_Struct(self, RowEvent, p);
|
32
|
+
p->m_event = static_cast<Row_event*>(event);
|
33
|
+
p->m_event_header = event->header();
|
34
|
+
}
|
35
|
+
|
36
|
+
void RowEvent::init() {
|
37
|
+
rb_cBinlogRowEvent = rb_define_class_under(rb_mBinlog, "RowEvent", rb_cBinlogEvent);
|
38
|
+
rb_define_alloc_func(rb_cBinlogRowEvent, &alloc);
|
39
|
+
|
40
|
+
Event::init(rb_cBinlogRowEvent);
|
41
|
+
|
42
|
+
rb_define_method(rb_cBinlogRowEvent, "table_id", __F(&get_table_id), 0);
|
43
|
+
rb_define_method(rb_cBinlogRowEvent, "flags", __F(&get_flags), 0);
|
44
|
+
rb_define_method(rb_cBinlogRowEvent, "columns_len", __F(&get_columns_len), 0);
|
45
|
+
rb_define_method(rb_cBinlogRowEvent, "null_bits_len", __F(&get_null_bits_len), 0);
|
46
|
+
rb_define_method(rb_cBinlogRowEvent, "columns_before_image", __F(&get_columns_before_image), 0);
|
47
|
+
rb_define_method(rb_cBinlogRowEvent, "used_columns", __F(&get_used_columns), 0);
|
48
|
+
rb_define_method(rb_cBinlogRowEvent, "row", __F(&get_row), 0);
|
49
|
+
}
|
50
|
+
|
51
|
+
VALUE RowEvent::get_table_id(VALUE self) {
|
52
|
+
RowEvent *p;
|
53
|
+
Data_Get_Struct(self, RowEvent, p);
|
54
|
+
return ULL2NUM(p->m_event->table_id);
|
55
|
+
}
|
56
|
+
|
57
|
+
VALUE RowEvent::get_flags(VALUE self) {
|
58
|
+
RowEvent *p;
|
59
|
+
Data_Get_Struct(self, RowEvent, p);
|
60
|
+
return UINT2NUM(p->m_event->flags);
|
61
|
+
}
|
62
|
+
|
63
|
+
VALUE RowEvent::get_columns_len(VALUE self) {
|
64
|
+
RowEvent *p;
|
65
|
+
Data_Get_Struct(self, RowEvent, p);
|
66
|
+
return ULONG2NUM(p->m_event->columns_len);
|
67
|
+
}
|
68
|
+
|
69
|
+
VALUE RowEvent::get_null_bits_len(VALUE self) {
|
70
|
+
RowEvent *p;
|
71
|
+
Data_Get_Struct(self, RowEvent, p);
|
72
|
+
return UINT2NUM(p->m_event->null_bits_len);
|
73
|
+
}
|
74
|
+
|
75
|
+
VALUE RowEvent::get_columns_before_image(VALUE self) {
|
76
|
+
RowEvent *p;
|
77
|
+
VALUE retval = rb_ary_new();
|
78
|
+
|
79
|
+
Data_Get_Struct(self, RowEvent, p);
|
80
|
+
|
81
|
+
for (std::vector<uint8_t>::iterator itor = p->m_event->columns_before_image.begin();
|
82
|
+
itor != p->m_event->columns_before_image.end(); itor++) {
|
83
|
+
rb_ary_push(retval, UINT2NUM(*itor));
|
84
|
+
}
|
85
|
+
|
86
|
+
return retval;
|
87
|
+
}
|
88
|
+
|
89
|
+
VALUE RowEvent::get_used_columns(VALUE self) {
|
90
|
+
RowEvent *p;
|
91
|
+
VALUE retval = rb_ary_new();
|
92
|
+
|
93
|
+
Data_Get_Struct(self, RowEvent, p);
|
94
|
+
|
95
|
+
for (std::vector<uint8_t>::iterator itor = p->m_event->used_columns.begin();
|
96
|
+
itor != p->m_event->used_columns.end(); itor++) {
|
97
|
+
rb_ary_push(retval, UINT2NUM(*itor));
|
98
|
+
}
|
99
|
+
|
100
|
+
return retval;
|
101
|
+
}
|
102
|
+
|
103
|
+
VALUE RowEvent::get_row(VALUE self) {
|
104
|
+
RowEvent *p;
|
105
|
+
VALUE retval = rb_ary_new();
|
106
|
+
|
107
|
+
Data_Get_Struct(self, RowEvent, p);
|
108
|
+
|
109
|
+
for (std::vector<uint8_t>::iterator itor = p->m_event->row.begin();
|
110
|
+
itor != p->m_event->row.end(); itor++) {
|
111
|
+
rb_ary_push(retval, UINT2NUM(*itor));
|
112
|
+
}
|
113
|
+
|
114
|
+
return retval;
|
115
|
+
}
|
116
|
+
|
117
|
+
} // namespace binlog
|
118
|
+
} // namespace ruby
|
Binary file
|
@@ -0,0 +1,118 @@
|
|
1
|
+
#include "ruby_binlog.h"
|
2
|
+
|
3
|
+
VALUE rb_cBinlogTableMapEvent;
|
4
|
+
|
5
|
+
namespace ruby {
|
6
|
+
namespace binlog {
|
7
|
+
|
8
|
+
void TableMapEvent::free(TableMapEvent *p) {
|
9
|
+
if (p->m_event) {
|
10
|
+
delete p->m_event;
|
11
|
+
p->m_event = 0;
|
12
|
+
p->m_event_header = 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
delete p;
|
16
|
+
}
|
17
|
+
|
18
|
+
VALUE TableMapEvent::alloc(VALUE klass) {
|
19
|
+
TableMapEvent *p;
|
20
|
+
|
21
|
+
p = new TableMapEvent();
|
22
|
+
p->m_event = 0;
|
23
|
+
p->m_event_header = 0;
|
24
|
+
|
25
|
+
return Data_Wrap_Struct(klass, 0, &free, p);
|
26
|
+
}
|
27
|
+
|
28
|
+
void TableMapEvent::set_event(VALUE self, mysql::Binary_log_event *event) {
|
29
|
+
TableMapEvent *p;
|
30
|
+
|
31
|
+
Data_Get_Struct(self, TableMapEvent, p);
|
32
|
+
p->m_event = static_cast<Table_map_event*>(event);
|
33
|
+
p->m_event_header = event->header();
|
34
|
+
}
|
35
|
+
|
36
|
+
void TableMapEvent::init() {
|
37
|
+
rb_cBinlogTableMapEvent = rb_define_class_under(rb_mBinlog, "TableMapEvent", rb_cBinlogEvent);
|
38
|
+
rb_define_alloc_func(rb_cBinlogTableMapEvent, &alloc);
|
39
|
+
|
40
|
+
Event::init(rb_cBinlogTableMapEvent);
|
41
|
+
|
42
|
+
rb_define_method(rb_cBinlogTableMapEvent, "table_id", __F(&get_table_id), 0);
|
43
|
+
rb_define_method(rb_cBinlogTableMapEvent, "flags", __F(&get_flags), 0);
|
44
|
+
rb_define_method(rb_cBinlogTableMapEvent, "db_name", __F(&get_db_name), 0);
|
45
|
+
rb_define_method(rb_cBinlogTableMapEvent, "table_name", __F(&get_table_name), 0);
|
46
|
+
rb_define_method(rb_cBinlogTableMapEvent, "columns", __F(&get_columns), 0);
|
47
|
+
rb_define_method(rb_cBinlogTableMapEvent, "metadata", __F(&get_metadata), 0);
|
48
|
+
rb_define_method(rb_cBinlogTableMapEvent, "null_bits", __F(&get_null_bits), 0);
|
49
|
+
}
|
50
|
+
|
51
|
+
VALUE TableMapEvent::get_table_id(VALUE self) {
|
52
|
+
TableMapEvent *p;
|
53
|
+
Data_Get_Struct(self, TableMapEvent, p);
|
54
|
+
return ULL2NUM(p->m_event->table_id);
|
55
|
+
}
|
56
|
+
|
57
|
+
VALUE TableMapEvent::get_flags(VALUE self) {
|
58
|
+
TableMapEvent *p;
|
59
|
+
Data_Get_Struct(self, TableMapEvent, p);
|
60
|
+
return UINT2NUM(p->m_event->flags);
|
61
|
+
}
|
62
|
+
|
63
|
+
VALUE TableMapEvent::get_db_name(VALUE self) {
|
64
|
+
TableMapEvent *p;
|
65
|
+
Data_Get_Struct(self, TableMapEvent, p);
|
66
|
+
return rb_str_new2(p->m_event->db_name.c_str());
|
67
|
+
}
|
68
|
+
|
69
|
+
VALUE TableMapEvent::get_table_name(VALUE self) {
|
70
|
+
TableMapEvent *p;
|
71
|
+
Data_Get_Struct(self, TableMapEvent, p);
|
72
|
+
return rb_str_new2(p->m_event->table_name.c_str());
|
73
|
+
}
|
74
|
+
|
75
|
+
VALUE TableMapEvent::get_columns(VALUE self) {
|
76
|
+
TableMapEvent *p;
|
77
|
+
VALUE retval = rb_ary_new();
|
78
|
+
|
79
|
+
Data_Get_Struct(self, TableMapEvent, p);
|
80
|
+
|
81
|
+
for (std::vector<uint8_t>::iterator itor = p->m_event->columns.begin();
|
82
|
+
itor != p->m_event->columns.end(); itor++) {
|
83
|
+
rb_ary_push(retval, UINT2NUM(*itor));
|
84
|
+
}
|
85
|
+
|
86
|
+
return retval;
|
87
|
+
}
|
88
|
+
|
89
|
+
VALUE TableMapEvent::get_metadata(VALUE self) {
|
90
|
+
TableMapEvent *p;
|
91
|
+
VALUE retval = rb_ary_new();
|
92
|
+
|
93
|
+
Data_Get_Struct(self, TableMapEvent, p);
|
94
|
+
|
95
|
+
for (std::vector<uint8_t>::iterator itor = p->m_event->metadata.begin();
|
96
|
+
itor != p->m_event->metadata.end(); itor++) {
|
97
|
+
rb_ary_push(retval, UINT2NUM(*itor));
|
98
|
+
}
|
99
|
+
|
100
|
+
return retval;
|
101
|
+
}
|
102
|
+
|
103
|
+
VALUE TableMapEvent::get_null_bits(VALUE self) {
|
104
|
+
TableMapEvent *p;
|
105
|
+
VALUE retval = rb_ary_new();
|
106
|
+
|
107
|
+
Data_Get_Struct(self, TableMapEvent, p);
|
108
|
+
|
109
|
+
for (std::vector<uint8_t>::iterator itor = p->m_event->null_bits.begin();
|
110
|
+
itor != p->m_event->null_bits.end(); itor++) {
|
111
|
+
rb_ary_push(retval, UINT2NUM(*itor));
|
112
|
+
}
|
113
|
+
|
114
|
+
return retval;
|
115
|
+
}
|
116
|
+
|
117
|
+
} // namespace binlog
|
118
|
+
} // namespace ruby
|
Binary file
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#include "ruby_binlog.h"
|
2
|
+
|
3
|
+
VALUE rb_cBinlogUnimplementedEvent;
|
4
|
+
|
5
|
+
namespace ruby {
|
6
|
+
namespace binlog {
|
7
|
+
|
8
|
+
void UnimplementedEvent::free(QueryEvent *p) {
|
9
|
+
if (p->m_event) {
|
10
|
+
delete p->m_event;
|
11
|
+
p->m_event = 0;
|
12
|
+
p->m_event_header = 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
delete p;
|
16
|
+
}
|
17
|
+
|
18
|
+
VALUE UnimplementedEvent::alloc(VALUE klass) {
|
19
|
+
UnimplementedEvent *p;
|
20
|
+
|
21
|
+
p = new UnimplementedEvent();
|
22
|
+
p->m_event = 0;
|
23
|
+
p->m_event_header = 0;
|
24
|
+
|
25
|
+
return Data_Wrap_Struct(klass, 0, &free, p);
|
26
|
+
}
|
27
|
+
|
28
|
+
void UnimplementedEvent::set_event(VALUE self, mysql::Binary_log_event *event) {
|
29
|
+
UnimplementedEvent *p;
|
30
|
+
|
31
|
+
Data_Get_Struct(self, UnimplementedEvent, p);
|
32
|
+
p->m_event = event;
|
33
|
+
p->m_event_header = event->header();
|
34
|
+
}
|
35
|
+
|
36
|
+
void UnimplementedEvent::init() {
|
37
|
+
rb_cBinlogUnimplementedEvent = rb_define_class_under(rb_mBinlog, "UnimplementedEvent", rb_cBinlogEvent);
|
38
|
+
rb_define_alloc_func(rb_cBinlogUnimplementedEvent, &alloc);
|
39
|
+
|
40
|
+
Event::init(rb_cBinlogUnimplementedEvent);
|
41
|
+
}
|
42
|
+
|
43
|
+
} // namespace binlog
|
44
|
+
} // namespace ruby
|