Merge lp://staging/~diego-fmpwizard/mysql-proxy/master_info into lp://staging/mysql-proxy
- master_info
- Merge into trunk
Proposed by
fmpwizard
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp://staging/~diego-fmpwizard/mysql-proxy/master_info |
Merge into: | lp://staging/mysql-proxy |
Diff against target: | None lines |
To merge this branch: | bzr merge lp://staging/~diego-fmpwizard/mysql-proxy/master_info |
Related bugs: | |
Related blueprints: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jan Kneschke (community) | Approve | ||
Review via email: mp+5520@code.staging.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
fmpwizard (diego-fmpwizard) wrote : | # |
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'lib/mysql-proto.c' | |||
2 | --- lib/mysql-proto.c 2009-02-07 03:59:23 +0000 | |||
3 | +++ lib/mysql-proto.c 2009-04-14 15:11:59 +0000 | |||
4 | @@ -181,7 +181,8 @@ | |||
5 | 181 | } | 181 | } |
6 | 182 | 182 | ||
7 | 183 | lua_newtable(L); | 183 | lua_newtable(L); |
9 | 184 | 184 | ||
10 | 185 | LUA_EXPORT_INT(info, master_lines); | ||
11 | 185 | LUA_EXPORT_STR(info, master_log_file); | 186 | LUA_EXPORT_STR(info, master_log_file); |
12 | 186 | LUA_EXPORT_INT(info, master_log_pos); | 187 | LUA_EXPORT_INT(info, master_log_pos); |
13 | 187 | LUA_EXPORT_STR(info, master_host); | 188 | LUA_EXPORT_STR(info, master_host); |
14 | @@ -190,7 +191,12 @@ | |||
15 | 190 | LUA_EXPORT_INT(info, master_port); | 191 | LUA_EXPORT_INT(info, master_port); |
16 | 191 | LUA_EXPORT_INT(info, master_connect_retry); | 192 | LUA_EXPORT_INT(info, master_connect_retry); |
17 | 192 | LUA_EXPORT_INT(info, master_ssl); | 193 | LUA_EXPORT_INT(info, master_ssl); |
19 | 193 | if (info->lines >= 15) { | 194 | LUA_EXPORT_STR(info, master_ssl_ca); |
20 | 195 | LUA_EXPORT_STR(info, master_ssl_capath); | ||
21 | 196 | LUA_EXPORT_STR(info, master_ssl_cert); | ||
22 | 197 | LUA_EXPORT_STR(info, master_ssl_cipher); | ||
23 | 198 | LUA_EXPORT_STR(info, master_ssl_key); | ||
24 | 199 | if (info->master_lines >= 15) { | ||
25 | 194 | LUA_EXPORT_INT(info, master_ssl_verify_server_cert); | 200 | LUA_EXPORT_INT(info, master_ssl_verify_server_cert); |
26 | 195 | } | 201 | } |
27 | 196 | 202 | ||
28 | @@ -199,6 +205,43 @@ | |||
29 | 199 | return 1; | 205 | return 1; |
30 | 200 | } | 206 | } |
31 | 201 | 207 | ||
32 | 208 | static int lua_proto_append_masterinfo_string (lua_State *L) { | ||
33 | 209 | GString *packet; | ||
34 | 210 | network_mysqld_masterinfo_t *info; | ||
35 | 211 | |||
36 | 212 | luaL_checktype(L, 1, LUA_TTABLE); | ||
37 | 213 | |||
38 | 214 | info = network_mysqld_masterinfo_new(); | ||
39 | 215 | |||
40 | 216 | LUA_IMPORT_INT(info, master_lines); | ||
41 | 217 | LUA_IMPORT_STR(info, master_log_file); | ||
42 | 218 | LUA_IMPORT_INT(info, master_log_pos); | ||
43 | 219 | LUA_IMPORT_STR(info, master_host); | ||
44 | 220 | LUA_IMPORT_STR(info, master_user); | ||
45 | 221 | LUA_IMPORT_STR(info, master_password); | ||
46 | 222 | LUA_IMPORT_INT(info, master_port); | ||
47 | 223 | LUA_IMPORT_INT(info, master_connect_retry); | ||
48 | 224 | LUA_IMPORT_INT(info, master_ssl); | ||
49 | 225 | LUA_IMPORT_STR(info, master_ssl_ca); | ||
50 | 226 | LUA_IMPORT_STR(info, master_ssl_capath); | ||
51 | 227 | LUA_IMPORT_STR(info, master_ssl_cert); | ||
52 | 228 | LUA_IMPORT_STR(info, master_ssl_cipher); | ||
53 | 229 | LUA_IMPORT_STR(info, master_ssl_key); | ||
54 | 230 | LUA_IMPORT_INT(info, master_ssl_verify_server_cert); | ||
55 | 231 | |||
56 | 232 | packet = g_string_new(NULL); | ||
57 | 233 | network_mysqld_masterinfo_append(packet, info); | ||
58 | 234 | |||
59 | 235 | lua_pushlstring(L, S(packet)); | ||
60 | 236 | |||
61 | 237 | network_mysqld_masterinfo_free(info); | ||
62 | 238 | |||
63 | 239 | g_string_free(packet, TRUE); | ||
64 | 240 | |||
65 | 241 | return 1; | ||
66 | 242 | } | ||
67 | 243 | |||
68 | 244 | |||
69 | 202 | static int lua_proto_append_ok_packet (lua_State *L) { | 245 | static int lua_proto_append_ok_packet (lua_State *L) { |
70 | 203 | GString *packet; | 246 | GString *packet; |
71 | 204 | network_mysqld_ok_packet_t *ok_packet; | 247 | network_mysqld_ok_packet_t *ok_packet; |
72 | @@ -446,6 +489,7 @@ | |||
73 | 446 | {"from_response_packet", lua_proto_get_response_packet}, | 489 | {"from_response_packet", lua_proto_get_response_packet}, |
74 | 447 | {"to_response_packet", lua_proto_append_response_packet}, | 490 | {"to_response_packet", lua_proto_append_response_packet}, |
75 | 448 | {"from_masterinfo_string", lua_proto_get_masterinfo_string}, | 491 | {"from_masterinfo_string", lua_proto_get_masterinfo_string}, |
76 | 492 | {"to_masterinfo_string", lua_proto_append_masterinfo_string}, | ||
77 | 449 | {NULL, NULL}, | 493 | {NULL, NULL}, |
78 | 450 | }; | 494 | }; |
79 | 451 | 495 | ||
80 | 452 | 496 | ||
81 | === modified file 'src/network-mysqld-masterinfo.c' | |||
82 | --- src/network-mysqld-masterinfo.c 2009-02-23 23:37:58 +0000 | |||
83 | +++ src/network-mysqld-masterinfo.c 2009-04-14 15:11:59 +0000 | |||
84 | @@ -118,9 +118,10 @@ | |||
85 | 118 | g_return_val_if_fail(info, -1); | 118 | g_return_val_if_fail(info, -1); |
86 | 119 | g_return_val_if_fail(packet, -1); | 119 | g_return_val_if_fail(packet, -1); |
87 | 120 | 120 | ||
91 | 121 | err = err || network_mysqld_masterinfo_get_int32(packet, &lines); | 121 | /*err = err || network_mysqld_masterinfo_get_int32(packet, &lines);*/ |
92 | 122 | info->lines = lines; | 122 | /*info->master_lines = lines;*/ |
93 | 123 | err = err || network_mysqld_masterinfo_get_string(packet, info->master_log_file); | 123 | err = err || network_mysqld_masterinfo_get_int32(packet, &(info->master_lines)); |
94 | 124 | err = err || network_mysqld_masterinfo_get_string(packet, info->master_log_file); | ||
95 | 124 | err = err || network_mysqld_masterinfo_get_int32(packet, &(info->master_log_pos)); | 125 | err = err || network_mysqld_masterinfo_get_int32(packet, &(info->master_log_pos)); |
96 | 125 | err = err || network_mysqld_masterinfo_get_string(packet, info->master_host); | 126 | err = err || network_mysqld_masterinfo_get_string(packet, info->master_host); |
97 | 126 | err = err || network_mysqld_masterinfo_get_string(packet, info->master_user); | 127 | err = err || network_mysqld_masterinfo_get_string(packet, info->master_user); |
98 | @@ -133,7 +134,7 @@ | |||
99 | 133 | err = err || network_mysqld_masterinfo_get_string(packet, info->master_ssl_cert); | 134 | err = err || network_mysqld_masterinfo_get_string(packet, info->master_ssl_cert); |
100 | 134 | err = err || network_mysqld_masterinfo_get_string(packet, info->master_ssl_cipher); | 135 | err = err || network_mysqld_masterinfo_get_string(packet, info->master_ssl_cipher); |
101 | 135 | err = err || network_mysqld_masterinfo_get_string(packet, info->master_ssl_key); | 136 | err = err || network_mysqld_masterinfo_get_string(packet, info->master_ssl_key); |
103 | 136 | if (lines >= 15) { | 137 | if (info->master_lines >= 15) { |
104 | 137 | err = err || network_mysqld_masterinfo_get_int32(packet, &(info->master_ssl_verify_server_cert)); | 138 | err = err || network_mysqld_masterinfo_get_int32(packet, &(info->master_ssl_verify_server_cert)); |
105 | 138 | } | 139 | } |
106 | 139 | return err ? -1 : 0; | 140 | return err ? -1 : 0; |
107 | @@ -159,8 +160,8 @@ | |||
108 | 159 | g_return_val_if_fail(info, -1); | 160 | g_return_val_if_fail(info, -1); |
109 | 160 | g_return_val_if_fail(packet, -1); | 161 | g_return_val_if_fail(packet, -1); |
110 | 161 | 162 | ||
113 | 162 | err = err || network_mysqld_masterinfo_append_int32(packet, 15); | 163 | err = err || network_mysqld_masterinfo_append_int32(packet, info->master_lines); |
114 | 163 | err = err || network_mysqld_masterinfo_append_string(packet, info->master_log_file); | 164 | err = err || network_mysqld_masterinfo_append_string(packet, info->master_log_file); |
115 | 164 | err = err || network_mysqld_masterinfo_append_int32(packet, info->master_log_pos); | 165 | err = err || network_mysqld_masterinfo_append_int32(packet, info->master_log_pos); |
116 | 165 | err = err || network_mysqld_masterinfo_append_string(packet, info->master_host); | 166 | err = err || network_mysqld_masterinfo_append_string(packet, info->master_host); |
117 | 166 | err = err || network_mysqld_masterinfo_append_string(packet, info->master_user); | 167 | err = err || network_mysqld_masterinfo_append_string(packet, info->master_user); |
118 | @@ -173,7 +174,9 @@ | |||
119 | 173 | err = err || network_mysqld_masterinfo_append_string(packet, info->master_ssl_cert); | 174 | err = err || network_mysqld_masterinfo_append_string(packet, info->master_ssl_cert); |
120 | 174 | err = err || network_mysqld_masterinfo_append_string(packet, info->master_ssl_cipher); | 175 | err = err || network_mysqld_masterinfo_append_string(packet, info->master_ssl_cipher); |
121 | 175 | err = err || network_mysqld_masterinfo_append_string(packet, info->master_ssl_key); | 176 | err = err || network_mysqld_masterinfo_append_string(packet, info->master_ssl_key); |
123 | 176 | err = err || network_mysqld_masterinfo_append_int32(packet, info->master_ssl_verify_server_cert); | 177 | if (info->master_lines >= 15) { |
124 | 178 | err = err || network_mysqld_masterinfo_append_int32(packet, info->master_ssl_verify_server_cert); | ||
125 | 179 | } | ||
126 | 177 | 180 | ||
127 | 178 | return err ? -1 : 0; | 181 | return err ? -1 : 0; |
128 | 179 | } | 182 | } |
129 | 180 | 183 | ||
130 | === modified file 'src/network-mysqld-masterinfo.h' | |||
131 | --- src/network-mysqld-masterinfo.h 2009-02-07 03:59:23 +0000 | |||
132 | +++ src/network-mysqld-masterinfo.h 2009-04-14 15:11:59 +0000 | |||
133 | @@ -24,7 +24,7 @@ | |||
134 | 24 | #include "network-mysqld-proto.h" | 24 | #include "network-mysqld-proto.h" |
135 | 25 | 25 | ||
136 | 26 | typedef struct { | 26 | typedef struct { |
138 | 27 | guint32 lines; | 27 | guint32 master_lines; |
139 | 28 | GString *master_log_file; | 28 | GString *master_log_file; |
140 | 29 | guint32 master_log_pos; | 29 | guint32 master_log_pos; |
141 | 30 | GString *master_host; | 30 | GString *master_host; |
142 | 31 | 31 | ||
143 | === modified file 'tests/unit/lua/mysql-proto.lua' | |||
144 | --- tests/unit/lua/mysql-proto.lua 2009-02-07 03:59:23 +0000 | |||
145 | +++ tests/unit/lua/mysql-proto.lua 2009-04-14 15:11:59 +0000 | |||
146 | @@ -184,25 +184,60 @@ | |||
147 | 184 | assert(tbl.database == "db", ("expected 'db', got %s"):format(tostring(tbl.database))) | 184 | assert(tbl.database == "db", ("expected 'db', got %s"):format(tostring(tbl.database))) |
148 | 185 | 185 | ||
149 | 186 | -- test 5.1 master.info format | 186 | -- test 5.1 master.info format |
151 | 187 | local masterinfofile = proto.from_masterinfo_string("15\nhostname-bin.000024\n2143897\n127.0.0.1\nroot\n123\n3306\n60\n0\n\n\n\n\n\n0\n") | 187 | local masterinfofile = proto.from_masterinfo_string( |
152 | 188 | "15\nhostname-bin.000024\n2143897\n127.0.0.1\nroot\n123\n3306\n60\n0\nca-cert.pem\n" | ||
153 | 189 | .. "/usr/local/mysql/ssl/ca/\nclient-cert.pem\nssl_cipher\nclient-key.pem\n0\n") | ||
154 | 190 | assert( masterinfofile["master_lines"] == 15) | ||
155 | 188 | assert( masterinfofile["master_host"] == "127.0.0.1") | 191 | assert( masterinfofile["master_host"] == "127.0.0.1") |
156 | 189 | assert( masterinfofile["master_ssl"] == 0) | ||
157 | 190 | assert( masterinfofile["master_log_pos"] == 2143897) | 192 | assert( masterinfofile["master_log_pos"] == 2143897) |
158 | 191 | assert( masterinfofile["master_user"] == "root") | 193 | assert( masterinfofile["master_user"] == "root") |
159 | 192 | assert( masterinfofile["master_connect_retry"] == 60) | 194 | assert( masterinfofile["master_connect_retry"] == 60) |
160 | 193 | assert( masterinfofile["master_log_file"] == "hostname-bin.000024") | 195 | assert( masterinfofile["master_log_file"] == "hostname-bin.000024") |
161 | 194 | assert( masterinfofile["master_port"] == 3306) | 196 | assert( masterinfofile["master_port"] == 3306) |
162 | 195 | assert( masterinfofile["master_password"] == "123") | 197 | assert( masterinfofile["master_password"] == "123") |
163 | 198 | assert( masterinfofile["master_ssl"] == 0) | ||
164 | 199 | assert( masterinfofile["master_ssl_ca"] == "ca-cert.pem") | ||
165 | 200 | assert( masterinfofile["master_ssl_capath"] == "/usr/local/mysql/ssl/ca/") | ||
166 | 201 | assert( masterinfofile["master_ssl_cert"] == "client-cert.pem") | ||
167 | 202 | assert( masterinfofile["master_ssl_cipher"] == "ssl_cipher") | ||
168 | 203 | assert( masterinfofile["master_ssl_key"] == "client-key.pem") | ||
169 | 196 | assert( masterinfofile["master_ssl_verify_server_cert"] == 0) | 204 | assert( masterinfofile["master_ssl_verify_server_cert"] == 0) |
170 | 197 | 205 | ||
171 | 198 | -- test 4.1 and 5.0 master.info format | 206 | -- test 4.1 and 5.0 master.info format |
173 | 199 | local masterinfofile = proto.from_masterinfo_string("14\nhostname-bin.000024\n2143897\n127.0.0.1\nroot\n123\n3306\n60\n0\n\n\n\n\n\n") | 207 | local masterinfofile = proto.from_masterinfo_string( |
174 | 208 | "14\nhostname-bin.000024\n2143897\n127.0.0.1\nroot\n123\n3306\n60\n0\nca-cert.pem\n" | ||
175 | 209 | .. "/usr/local/mysql/ssl/ca/\nclient-cert.pem\nssl_cipher\nclient-key.pem\n") | ||
176 | 210 | |||
177 | 211 | assert( masterinfofile["master_lines"] == 14) | ||
178 | 200 | assert( masterinfofile["master_host"] == "127.0.0.1") | 212 | assert( masterinfofile["master_host"] == "127.0.0.1") |
179 | 201 | assert( masterinfofile["master_ssl"] == 0) | ||
180 | 202 | assert( masterinfofile["master_log_pos"] == 2143897) | 213 | assert( masterinfofile["master_log_pos"] == 2143897) |
181 | 203 | assert( masterinfofile["master_user"] == "root") | 214 | assert( masterinfofile["master_user"] == "root") |
182 | 204 | assert( masterinfofile["master_connect_retry"] == 60) | 215 | assert( masterinfofile["master_connect_retry"] == 60) |
183 | 205 | assert( masterinfofile["master_log_file"] == "hostname-bin.000024") | 216 | assert( masterinfofile["master_log_file"] == "hostname-bin.000024") |
184 | 206 | assert( masterinfofile["master_port"] == 3306) | 217 | assert( masterinfofile["master_port"] == 3306) |
186 | 207 | assert( masterinfofile["master_password"] == "123") | 218 | assert( masterinfofile["master_password"] == "123") |
187 | 219 | assert( masterinfofile["master_ssl"] == 0) | ||
188 | 220 | assert( masterinfofile["master_ssl_ca"] == "ca-cert.pem") | ||
189 | 221 | assert( masterinfofile["master_ssl_capath"] == "/usr/local/mysql/ssl/ca/") | ||
190 | 222 | assert( masterinfofile["master_ssl_cert"] == "client-cert.pem") | ||
191 | 223 | assert( masterinfofile["master_ssl_cipher"] == "ssl_cipher") | ||
192 | 224 | assert( masterinfofile["master_ssl_key"] == "client-key.pem") | ||
193 | 208 | assert( masterinfofile["master_ssl_verify_server_cert"] == nil) | 225 | assert( masterinfofile["master_ssl_verify_server_cert"] == nil) |
194 | 226 | |||
195 | 227 | -- test proto.to_masterinfo_string() | ||
196 | 228 | |||
197 | 229 | local masterinfofile = proto.from_masterinfo_string( | ||
198 | 230 | "15\nhostname-bin.000024\n2143897\n127.0.0.1\nroot\n123\n3306\n60\n0\nca-cert.pem\n" | ||
199 | 231 | .. "/usr/local/mysql/ssl/ca/\nclient-cert.pem\nssl_cipher\nclient-key.pem\n0\n") | ||
200 | 232 | |||
201 | 233 | assert( proto.to_masterinfo_string(masterinfofile) == | ||
202 | 234 | "15\nhostname-bin.000024\n2143897\n127.0.0.1\nroot\n123\n3306\n60\n0\nca-cert.pem\n" | ||
203 | 235 | .. "/usr/local/mysql/ssl/ca/\nclient-cert.pem\nssl_cipher\nclient-key.pem\n0\n") | ||
204 | 236 | |||
205 | 237 | local masterinfofile = proto.from_masterinfo_string( | ||
206 | 238 | "14\nhostname-bin.000024\n2143897\n127.0.0.1\nroot\n123\n3306\n60\n0\nca-cert.pem\n" | ||
207 | 239 | .. "/usr/local/mysql/ssl/ca/\nclient-cert.pem\nssl_cipher\nclient-key.pem\n") | ||
208 | 240 | |||
209 | 241 | assert( proto.to_masterinfo_string(masterinfofile) == | ||
210 | 242 | "14\nhostname-bin.000024\n2143897\n127.0.0.1\nroot\n123\n3306\n60\n0\nca-cert.pem\n" | ||
211 | 243 | .. "/usr/local/mysql/ssl/ca/\nclient-cert.pem\nssl_cipher\nclient-key.pem\n") |
Here I added to_masterinfo_ string( ) to Lua so that you can create a master.info file from a lua script. It does the opposite to from_masterinfo _string( )
I also added some master_ssl_* fields that were missing from lua.