Merge lp:~jaypipes/drizzle/replication-raw-sql into lp:~drizzle-trunk/drizzle/development
- replication-raw-sql
- Merge into development
Proposed by
Jay Pipes
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp:~jaypipes/drizzle/replication-raw-sql |
Merge into: | lp:~drizzle-trunk/drizzle/development |
Diff against target: |
3923 lines (+1753/-860) 56 files modified
drizzled/cursor.cc (+12/-0) drizzled/db.cc (+2/-2) drizzled/join.cc (+6/-0) drizzled/message/statement_transform.cc (+803/-267) drizzled/message/statement_transform.h (+161/-13) drizzled/message/table.proto (+1/-1) drizzled/message/table_reader.cc (+5/-242) drizzled/message/transaction.proto (+1/-0) drizzled/replication_services.cc (+124/-4) drizzled/replication_services.h (+44/-3) drizzled/sql_insert.cc (+7/-22) drizzled/sql_table.cc (+15/-13) drizzled/table_proto_write.cc (+7/-4) drizzled/table_share.cc (+27/-0) drizzled/table_share.h (+6/-0) plugin/transaction_log/tests/r/alter.result (+3/-3) plugin/transaction_log/tests/r/auto_commit.result (+23/-23) plugin/transaction_log/tests/r/blob.result (+3/-3) plugin/transaction_log/tests/r/create_schema.result (+13/-0) plugin/transaction_log/tests/r/create_select.result (+18/-14) plugin/transaction_log/tests/r/create_table.result (+54/-0) plugin/transaction_log/tests/r/database.result (+1/-1) plugin/transaction_log/tests/r/delete.result (+7/-7) plugin/transaction_log/tests/r/filtered_replicator.result (+77/-79) plugin/transaction_log/tests/r/insert.result (+2/-2) plugin/transaction_log/tests/r/insert_multi.result (+2/-2) plugin/transaction_log/tests/r/insert_on_duplicate_update.result (+3/-3) plugin/transaction_log/tests/r/insert_select.result (+8/-8) plugin/transaction_log/tests/r/multi_column_primary_key.result (+55/-0) plugin/transaction_log/tests/r/no_modification.result (+2/-2) plugin/transaction_log/tests/r/no_primary_key.result (+7/-7) plugin/transaction_log/tests/r/rand.result (+3/-3) plugin/transaction_log/tests/r/rename.result (+7/-7) plugin/transaction_log/tests/r/replace.result (+16/-16) plugin/transaction_log/tests/r/rollback.result (+7/-7) plugin/transaction_log/tests/r/schema.result (+13/-0) plugin/transaction_log/tests/r/select_for_update.result (+3/-3) plugin/transaction_log/tests/r/temp_tables.result (+3/-3) plugin/transaction_log/tests/r/truncate.result (+2/-2) plugin/transaction_log/tests/r/truncate_log.result (+1/-1) plugin/transaction_log/tests/r/update.result (+9/-9) plugin/transaction_log/tests/t/create_table-master.opt (+1/-0) plugin/transaction_log/tests/t/create_table.inc (+53/-0) plugin/transaction_log/tests/t/create_table.test (+9/-0) plugin/transaction_log/tests/t/database.inc (+0/-12) plugin/transaction_log/tests/t/database.test (+0/-13) plugin/transaction_log/tests/t/filtered_replicator.test (+1/-1) plugin/transaction_log/tests/t/multi_column_primary_key-master.opt (+1/-0) plugin/transaction_log/tests/t/multi_column_primary_key.inc (+36/-0) plugin/transaction_log/tests/t/multi_column_primary_key.test (+9/-0) plugin/transaction_log/tests/t/schema-master.opt (+1/-0) plugin/transaction_log/tests/t/schema.inc (+12/-0) plugin/transaction_log/tests/t/schema.test (+9/-0) tests/r/innodb.result (+18/-18) tests/r/mix2_myisam.result (+24/-24) tests/r/myisam.result (+16/-16) |
To merge this branch: | bzr merge lp:~jaypipes/drizzle/replication-raw-sql |
Related bugs: | |
Related blueprints: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Brian Aker | Pending | ||
Drizzle Developers | Pending | ||
Review via email: mp+20489@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Jay Pipes (jaypipes) wrote : | # |
Revision history for this message
Brian Aker (brianaker) wrote : | # |
Hi!
Looks fine, but I may want to revisit how we are doing the
transformation messages at a later point (namely the API/etc).
I need to take a look at SHOW CREATE TABLE/SCHEMA and transform those
in functions. Then use the message output you have in transform.
Cheers,
-Brian
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'drizzled/cursor.cc' | |||
2 | --- drizzled/cursor.cc 2010-02-23 18:09:22 +0000 | |||
3 | +++ drizzled/cursor.cc 2010-03-02 21:04:16 +0000 | |||
4 | @@ -1353,6 +1353,18 @@ | |||
5 | 1353 | 1353 | ||
6 | 1354 | switch (session->lex->sql_command) | 1354 | switch (session->lex->sql_command) |
7 | 1355 | { | 1355 | { |
8 | 1356 | case SQLCOM_CREATE_TABLE: | ||
9 | 1357 | /* | ||
10 | 1358 | * We are in a CREATE TABLE ... SELECT statement | ||
11 | 1359 | * and the kernel has already created the table | ||
12 | 1360 | * and put a CreateTableStatement in the active | ||
13 | 1361 | * Transaction message. Here, we add a new InsertRecord | ||
14 | 1362 | * to a new Transaction message (because the above | ||
15 | 1363 | * CREATE TABLE will commit the transaction containing | ||
16 | 1364 | * it). | ||
17 | 1365 | */ | ||
18 | 1366 | result= replication_services.insertRecord(session, table); | ||
19 | 1367 | break; | ||
20 | 1356 | case SQLCOM_REPLACE: | 1368 | case SQLCOM_REPLACE: |
21 | 1357 | case SQLCOM_REPLACE_SELECT: | 1369 | case SQLCOM_REPLACE_SELECT: |
22 | 1358 | /* | 1370 | /* |
23 | 1359 | 1371 | ||
24 | === modified file 'drizzled/db.cc' | |||
25 | --- drizzled/db.cc 2010-03-01 23:42:31 +0000 | |||
26 | +++ drizzled/db.cc 2010-03-02 21:04:16 +0000 | |||
27 | @@ -129,7 +129,7 @@ | |||
28 | 129 | } | 129 | } |
29 | 130 | else // Created ! | 130 | else // Created ! |
30 | 131 | { | 131 | { |
32 | 132 | replication_services.rawStatement(session, session->query); | 132 | replication_services.createSchema(session, schema_message); |
33 | 133 | session->my_ok(1); | 133 | session->my_ok(1); |
34 | 134 | } | 134 | } |
35 | 135 | 135 | ||
36 | @@ -275,7 +275,7 @@ | |||
37 | 275 | assert(! session->query.empty()); | 275 | assert(! session->query.empty()); |
38 | 276 | 276 | ||
39 | 277 | ReplicationServices &replication_services= ReplicationServices::singleton(); | 277 | ReplicationServices &replication_services= ReplicationServices::singleton(); |
41 | 278 | replication_services.rawStatement(session, session->getQueryString()); | 278 | replication_services.dropSchema(session, schema_name); |
42 | 279 | session->clear_error(); | 279 | session->clear_error(); |
43 | 280 | session->server_status|= SERVER_STATUS_DB_DROPPED; | 280 | session->server_status|= SERVER_STATUS_DB_DROPPED; |
44 | 281 | session->my_ok((uint32_t) deleted); | 281 | session->my_ok((uint32_t) deleted); |
45 | 282 | 282 | ||
46 | === modified file 'drizzled/join.cc' | |||
47 | --- drizzled/join.cc 2010-02-11 20:01:37 +0000 | |||
48 | +++ drizzled/join.cc 2010-03-02 21:04:16 +0000 | |||
49 | @@ -337,6 +337,12 @@ | |||
50 | 337 | if (error) | 337 | if (error) |
51 | 338 | goto err; | 338 | goto err; |
52 | 339 | 339 | ||
53 | 340 | /* | ||
54 | 341 | * The below will create the new table for | ||
55 | 342 | * CREATE TABLE ... SELECT | ||
56 | 343 | * | ||
57 | 344 | * @see create_table_from_items() in drizzled/sql_insert.cc | ||
58 | 345 | */ | ||
59 | 340 | if (result && result->prepare(fields_list, unit_arg)) | 346 | if (result && result->prepare(fields_list, unit_arg)) |
60 | 341 | goto err; | 347 | goto err; |
61 | 342 | 348 | ||
62 | 343 | 349 | ||
63 | === modified file 'drizzled/message/statement_transform.cc' | |||
64 | --- drizzled/message/statement_transform.cc 2010-02-08 01:10:03 +0000 | |||
65 | +++ drizzled/message/statement_transform.cc 2010-03-02 21:04:16 +0000 | |||
66 | @@ -2,10 +2,11 @@ | |||
67 | 2 | * vim:expandtab:shiftwidth=2:tabstop=2:smarttab: | 2 | * vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
68 | 3 | * | 3 | * |
69 | 4 | * Copyright (C) 2009 Sun Microsystems | 4 | * Copyright (C) 2009 Sun Microsystems |
70 | 5 | * Copyright (c) 2010 Jay Pipes | ||
71 | 5 | * | 6 | * |
72 | 6 | * Authors: | 7 | * Authors: |
73 | 7 | * | 8 | * |
75 | 8 | * Jay Pipes <joinfu@sun.com> | 9 | * Jay Pipes <jaypipes@gmail.com> |
76 | 9 | * | 10 | * |
77 | 10 | * This program is free software; you can redistribute it and/or modify | 11 | * This program is free software; you can redistribute it and/or modify |
78 | 11 | * it under the terms of the GNU General Public License as published by | 12 | * it under the terms of the GNU General Public License as published by |
79 | @@ -36,23 +37,27 @@ | |||
80 | 36 | 37 | ||
81 | 37 | #include <string> | 38 | #include <string> |
82 | 38 | #include <vector> | 39 | #include <vector> |
83 | 40 | #include <sstream> | ||
84 | 39 | 41 | ||
85 | 40 | using namespace std; | 42 | using namespace std; |
86 | 41 | 43 | ||
87 | 42 | namespace drizzled | 44 | namespace drizzled |
88 | 43 | { | 45 | { |
89 | 44 | 46 | ||
97 | 45 | enum message::TransformSqlError | 47 | namespace message |
98 | 46 | message::transformStatementToSql(const message::Statement &source, | 48 | { |
99 | 47 | vector<string> &sql_strings, | 49 | |
100 | 48 | enum message::TransformSqlVariant sql_variant, | 50 | enum TransformSqlError |
101 | 49 | bool already_in_transaction) | 51 | transformStatementToSql(const Statement &source, |
102 | 50 | { | 52 | vector<string> &sql_strings, |
103 | 51 | message::TransformSqlError error= NONE; | 53 | enum TransformSqlVariant sql_variant, |
104 | 54 | bool already_in_transaction) | ||
105 | 55 | { | ||
106 | 56 | TransformSqlError error= NONE; | ||
107 | 52 | 57 | ||
108 | 53 | switch (source.type()) | 58 | switch (source.type()) |
109 | 54 | { | 59 | { |
111 | 55 | case message::Statement::INSERT: | 60 | case Statement::INSERT: |
112 | 56 | { | 61 | { |
113 | 57 | if (! source.has_insert_header()) | 62 | if (! source.has_insert_header()) |
114 | 58 | { | 63 | { |
115 | @@ -65,8 +70,8 @@ | |||
116 | 65 | return error; | 70 | return error; |
117 | 66 | } | 71 | } |
118 | 67 | 72 | ||
121 | 68 | const message::InsertHeader &insert_header= source.insert_header(); | 73 | const InsertHeader &insert_header= source.insert_header(); |
122 | 69 | const message::InsertData &insert_data= source.insert_data(); | 74 | const InsertData &insert_data= source.insert_data(); |
123 | 70 | size_t num_keys= insert_data.record_size(); | 75 | size_t num_keys= insert_data.record_size(); |
124 | 71 | size_t x; | 76 | size_t x; |
125 | 72 | 77 | ||
126 | @@ -79,7 +84,7 @@ | |||
127 | 79 | 84 | ||
128 | 80 | error= transformInsertRecordToSql(insert_header, | 85 | error= transformInsertRecordToSql(insert_header, |
129 | 81 | insert_data.record(x), | 86 | insert_data.record(x), |
131 | 82 | &destination, | 87 | destination, |
132 | 83 | sql_variant); | 88 | sql_variant); |
133 | 84 | if (error != NONE) | 89 | if (error != NONE) |
134 | 85 | break; | 90 | break; |
135 | @@ -96,7 +101,7 @@ | |||
136 | 96 | } | 101 | } |
137 | 97 | } | 102 | } |
138 | 98 | break; | 103 | break; |
140 | 99 | case message::Statement::UPDATE: | 104 | case Statement::UPDATE: |
141 | 100 | { | 105 | { |
142 | 101 | if (! source.has_update_header()) | 106 | if (! source.has_update_header()) |
143 | 102 | { | 107 | { |
144 | @@ -109,8 +114,8 @@ | |||
145 | 109 | return error; | 114 | return error; |
146 | 110 | } | 115 | } |
147 | 111 | 116 | ||
150 | 112 | const message::UpdateHeader &update_header= source.update_header(); | 117 | const UpdateHeader &update_header= source.update_header(); |
151 | 113 | const message::UpdateData &update_data= source.update_data(); | 118 | const UpdateData &update_data= source.update_data(); |
152 | 114 | size_t num_keys= update_data.record_size(); | 119 | size_t num_keys= update_data.record_size(); |
153 | 115 | size_t x; | 120 | size_t x; |
154 | 116 | 121 | ||
155 | @@ -123,7 +128,7 @@ | |||
156 | 123 | 128 | ||
157 | 124 | error= transformUpdateRecordToSql(update_header, | 129 | error= transformUpdateRecordToSql(update_header, |
158 | 125 | update_data.record(x), | 130 | update_data.record(x), |
160 | 126 | &destination, | 131 | destination, |
161 | 127 | sql_variant); | 132 | sql_variant); |
162 | 128 | if (error != NONE) | 133 | if (error != NONE) |
163 | 129 | break; | 134 | break; |
164 | @@ -140,7 +145,7 @@ | |||
165 | 140 | } | 145 | } |
166 | 141 | } | 146 | } |
167 | 142 | break; | 147 | break; |
169 | 143 | case message::Statement::DELETE: | 148 | case Statement::DELETE: |
170 | 144 | { | 149 | { |
171 | 145 | if (! source.has_delete_header()) | 150 | if (! source.has_delete_header()) |
172 | 146 | { | 151 | { |
173 | @@ -153,8 +158,8 @@ | |||
174 | 153 | return error; | 158 | return error; |
175 | 154 | } | 159 | } |
176 | 155 | 160 | ||
179 | 156 | const message::DeleteHeader &delete_header= source.delete_header(); | 161 | const DeleteHeader &delete_header= source.delete_header(); |
180 | 157 | const message::DeleteData &delete_data= source.delete_data(); | 162 | const DeleteData &delete_data= source.delete_data(); |
181 | 158 | size_t num_keys= delete_data.record_size(); | 163 | size_t num_keys= delete_data.record_size(); |
182 | 159 | size_t x; | 164 | size_t x; |
183 | 160 | 165 | ||
184 | @@ -167,7 +172,7 @@ | |||
185 | 167 | 172 | ||
186 | 168 | error= transformDeleteRecordToSql(delete_header, | 173 | error= transformDeleteRecordToSql(delete_header, |
187 | 169 | delete_data.record(x), | 174 | delete_data.record(x), |
189 | 170 | &destination, | 175 | destination, |
190 | 171 | sql_variant); | 176 | sql_variant); |
191 | 172 | if (error != NONE) | 177 | if (error != NONE) |
192 | 173 | break; | 178 | break; |
193 | @@ -184,27 +189,67 @@ | |||
194 | 184 | } | 189 | } |
195 | 185 | } | 190 | } |
196 | 186 | break; | 191 | break; |
198 | 187 | case message::Statement::TRUNCATE_TABLE: | 192 | case Statement::CREATE_TABLE: |
199 | 193 | { | ||
200 | 194 | assert(source.has_create_table_statement()); | ||
201 | 195 | string destination; | ||
202 | 196 | error= transformCreateTableStatementToSql(source.create_table_statement(), | ||
203 | 197 | destination, | ||
204 | 198 | sql_variant); | ||
205 | 199 | sql_strings.push_back(destination); | ||
206 | 200 | } | ||
207 | 201 | break; | ||
208 | 202 | case Statement::TRUNCATE_TABLE: | ||
209 | 188 | { | 203 | { |
210 | 189 | assert(source.has_truncate_table_statement()); | 204 | assert(source.has_truncate_table_statement()); |
211 | 190 | string destination; | 205 | string destination; |
219 | 191 | error= message::transformTruncateTableStatementToSql(source.truncate_table_statement(), | 206 | error= transformTruncateTableStatementToSql(source.truncate_table_statement(), |
220 | 192 | &destination, | 207 | destination, |
221 | 193 | sql_variant); | 208 | sql_variant); |
222 | 194 | sql_strings.push_back(destination); | 209 | sql_strings.push_back(destination); |
223 | 195 | } | 210 | } |
224 | 196 | break; | 211 | break; |
225 | 197 | case message::Statement::SET_VARIABLE: | 212 | case Statement::DROP_TABLE: |
226 | 213 | { | ||
227 | 214 | assert(source.has_drop_table_statement()); | ||
228 | 215 | string destination; | ||
229 | 216 | error= transformDropTableStatementToSql(source.drop_table_statement(), | ||
230 | 217 | destination, | ||
231 | 218 | sql_variant); | ||
232 | 219 | sql_strings.push_back(destination); | ||
233 | 220 | } | ||
234 | 221 | break; | ||
235 | 222 | case Statement::CREATE_SCHEMA: | ||
236 | 223 | { | ||
237 | 224 | assert(source.has_create_schema_statement()); | ||
238 | 225 | string destination; | ||
239 | 226 | error= transformCreateSchemaStatementToSql(source.create_schema_statement(), | ||
240 | 227 | destination, | ||
241 | 228 | sql_variant); | ||
242 | 229 | sql_strings.push_back(destination); | ||
243 | 230 | } | ||
244 | 231 | break; | ||
245 | 232 | case Statement::DROP_SCHEMA: | ||
246 | 233 | { | ||
247 | 234 | assert(source.has_drop_schema_statement()); | ||
248 | 235 | string destination; | ||
249 | 236 | error= transformDropSchemaStatementToSql(source.drop_schema_statement(), | ||
250 | 237 | destination, | ||
251 | 238 | sql_variant); | ||
252 | 239 | sql_strings.push_back(destination); | ||
253 | 240 | } | ||
254 | 241 | break; | ||
255 | 242 | case Statement::SET_VARIABLE: | ||
256 | 198 | { | 243 | { |
257 | 199 | assert(source.has_set_variable_statement()); | 244 | assert(source.has_set_variable_statement()); |
258 | 200 | string destination; | 245 | string destination; |
262 | 201 | error= message::transformSetVariableStatementToSql(source.set_variable_statement(), | 246 | error= transformSetVariableStatementToSql(source.set_variable_statement(), |
263 | 202 | &destination, | 247 | destination, |
264 | 203 | sql_variant); | 248 | sql_variant); |
265 | 204 | sql_strings.push_back(destination); | 249 | sql_strings.push_back(destination); |
266 | 205 | } | 250 | } |
267 | 206 | break; | 251 | break; |
269 | 207 | case message::Statement::RAW_SQL: | 252 | case Statement::RAW_SQL: |
270 | 208 | default: | 253 | default: |
271 | 209 | sql_strings.push_back(source.sql()); | 254 | sql_strings.push_back(source.sql()); |
272 | 210 | break; | 255 | break; |
273 | @@ -212,24 +257,24 @@ | |||
274 | 212 | return error; | 257 | return error; |
275 | 213 | } | 258 | } |
276 | 214 | 259 | ||
281 | 215 | enum message::TransformSqlError | 260 | enum TransformSqlError |
282 | 216 | message::transformInsertHeaderToSql(const message::InsertHeader &header, | 261 | transformInsertHeaderToSql(const InsertHeader &header, |
283 | 217 | std::string *destination, | 262 | string &destination, |
284 | 218 | enum message::TransformSqlVariant sql_variant) | 263 | enum TransformSqlVariant sql_variant) |
285 | 219 | { | 264 | { |
286 | 220 | char quoted_identifier= '`'; | 265 | char quoted_identifier= '`'; |
287 | 221 | if (sql_variant == ANSI) | 266 | if (sql_variant == ANSI) |
288 | 222 | quoted_identifier= '"'; | 267 | quoted_identifier= '"'; |
289 | 223 | 268 | ||
299 | 224 | destination->assign("INSERT INTO ", 12); | 269 | destination.assign("INSERT INTO ", 12); |
300 | 225 | destination->push_back(quoted_identifier); | 270 | destination.push_back(quoted_identifier); |
301 | 226 | destination->append(header.table_metadata().schema_name()); | 271 | destination.append(header.table_metadata().schema_name()); |
302 | 227 | destination->push_back(quoted_identifier); | 272 | destination.push_back(quoted_identifier); |
303 | 228 | destination->push_back('.'); | 273 | destination.push_back('.'); |
304 | 229 | destination->push_back(quoted_identifier); | 274 | destination.push_back(quoted_identifier); |
305 | 230 | destination->append(header.table_metadata().table_name()); | 275 | destination.append(header.table_metadata().table_name()); |
306 | 231 | destination->push_back(quoted_identifier); | 276 | destination.push_back(quoted_identifier); |
307 | 232 | destination->append(" (", 2); | 277 | destination.append(" (", 2); |
308 | 233 | 278 | ||
309 | 234 | /* Add field list to SQL string... */ | 279 | /* Add field list to SQL string... */ |
310 | 235 | size_t num_fields= header.field_metadata_size(); | 280 | size_t num_fields= header.field_metadata_size(); |
311 | @@ -237,33 +282,33 @@ | |||
312 | 237 | 282 | ||
313 | 238 | for (x= 0; x < num_fields; ++x) | 283 | for (x= 0; x < num_fields; ++x) |
314 | 239 | { | 284 | { |
316 | 240 | const message::FieldMetadata &field_metadata= header.field_metadata(x); | 285 | const FieldMetadata &field_metadata= header.field_metadata(x); |
317 | 241 | if (x != 0) | 286 | if (x != 0) |
319 | 242 | destination->push_back(','); | 287 | destination.push_back(','); |
320 | 243 | 288 | ||
324 | 244 | destination->push_back(quoted_identifier); | 289 | destination.push_back(quoted_identifier); |
325 | 245 | destination->append(field_metadata.name()); | 290 | destination.append(field_metadata.name()); |
326 | 246 | destination->push_back(quoted_identifier); | 291 | destination.push_back(quoted_identifier); |
327 | 247 | } | 292 | } |
328 | 248 | 293 | ||
329 | 249 | return NONE; | 294 | return NONE; |
330 | 250 | } | 295 | } |
331 | 251 | 296 | ||
337 | 252 | enum message::TransformSqlError | 297 | enum TransformSqlError |
338 | 253 | message::transformInsertRecordToSql(const message::InsertHeader &header, | 298 | transformInsertRecordToSql(const InsertHeader &header, |
339 | 254 | const message::InsertRecord &record, | 299 | const InsertRecord &record, |
340 | 255 | std::string *destination, | 300 | string &destination, |
341 | 256 | enum message::TransformSqlVariant sql_variant) | 301 | enum TransformSqlVariant sql_variant) |
342 | 257 | { | 302 | { |
346 | 258 | enum message::TransformSqlError error= transformInsertHeaderToSql(header, | 303 | enum TransformSqlError error= transformInsertHeaderToSql(header, |
347 | 259 | destination, | 304 | destination, |
348 | 260 | sql_variant); | 305 | sql_variant); |
349 | 261 | 306 | ||
350 | 262 | char quoted_identifier= '`'; | 307 | char quoted_identifier= '`'; |
351 | 263 | if (sql_variant == ANSI) | 308 | if (sql_variant == ANSI) |
352 | 264 | quoted_identifier= '"'; | 309 | quoted_identifier= '"'; |
353 | 265 | 310 | ||
355 | 266 | destination->append(") VALUES ("); | 311 | destination.append(") VALUES ("); |
356 | 267 | 312 | ||
357 | 268 | /* Add insert values */ | 313 | /* Add insert values */ |
358 | 269 | size_t num_fields= header.field_metadata_size(); | 314 | size_t num_fields= header.field_metadata_size(); |
359 | @@ -273,16 +318,16 @@ | |||
360 | 273 | for (x= 0; x < num_fields; ++x) | 318 | for (x= 0; x < num_fields; ++x) |
361 | 274 | { | 319 | { |
362 | 275 | if (x != 0) | 320 | if (x != 0) |
368 | 276 | destination->push_back(','); | 321 | destination.push_back(','); |
369 | 277 | 322 | ||
370 | 278 | const message::FieldMetadata &field_metadata= header.field_metadata(x); | 323 | const FieldMetadata &field_metadata= header.field_metadata(x); |
371 | 279 | 324 | ||
372 | 280 | should_quote_field_value= message::shouldQuoteFieldValue(field_metadata.type()); | 325 | should_quote_field_value= shouldQuoteFieldValue(field_metadata.type()); |
373 | 281 | 326 | ||
374 | 282 | if (should_quote_field_value) | 327 | if (should_quote_field_value) |
376 | 283 | destination->push_back('\''); | 328 | destination.push_back('\''); |
377 | 284 | 329 | ||
379 | 285 | if (field_metadata.type() == message::Table::Field::BLOB) | 330 | if (field_metadata.type() == Table::Field::BLOB) |
380 | 286 | { | 331 | { |
381 | 287 | /* | 332 | /* |
382 | 288 | * We do this here because BLOB data is returned | 333 | * We do this here because BLOB data is returned |
383 | @@ -291,36 +336,36 @@ | |||
384 | 291 | * up to a \0 being output here. | 336 | * up to a \0 being output here. |
385 | 292 | */ | 337 | */ |
386 | 293 | string raw_data(record.insert_value(x)); | 338 | string raw_data(record.insert_value(x)); |
388 | 294 | destination->append(raw_data.c_str(), raw_data.size()); | 339 | destination.append(raw_data.c_str(), raw_data.size()); |
389 | 295 | } | 340 | } |
390 | 296 | else | 341 | else |
391 | 297 | { | 342 | { |
393 | 298 | destination->append(record.insert_value(x)); | 343 | destination.append(record.insert_value(x)); |
394 | 299 | } | 344 | } |
395 | 300 | 345 | ||
396 | 301 | if (should_quote_field_value) | 346 | if (should_quote_field_value) |
398 | 302 | destination->push_back('\''); | 347 | destination.push_back('\''); |
399 | 303 | } | 348 | } |
401 | 304 | destination->push_back(')'); | 349 | destination.push_back(')'); |
402 | 305 | 350 | ||
403 | 306 | return error; | 351 | return error; |
404 | 307 | } | 352 | } |
405 | 308 | 353 | ||
411 | 309 | enum message::TransformSqlError | 354 | enum TransformSqlError |
412 | 310 | message::transformInsertStatementToSql(const message::InsertHeader &header, | 355 | transformInsertStatementToSql(const InsertHeader &header, |
413 | 311 | const message::InsertData &data, | 356 | const InsertData &data, |
414 | 312 | std::string *destination, | 357 | string &destination, |
415 | 313 | enum message::TransformSqlVariant sql_variant) | 358 | enum TransformSqlVariant sql_variant) |
416 | 314 | { | 359 | { |
420 | 315 | enum message::TransformSqlError error= transformInsertHeaderToSql(header, | 360 | enum TransformSqlError error= transformInsertHeaderToSql(header, |
421 | 316 | destination, | 361 | destination, |
422 | 317 | sql_variant); | 362 | sql_variant); |
423 | 318 | 363 | ||
424 | 319 | char quoted_identifier= '`'; | 364 | char quoted_identifier= '`'; |
425 | 320 | if (sql_variant == ANSI) | 365 | if (sql_variant == ANSI) |
426 | 321 | quoted_identifier= '"'; | 366 | quoted_identifier= '"'; |
427 | 322 | 367 | ||
429 | 323 | destination->append(") VALUES (", 10); | 368 | destination.append(") VALUES (", 10); |
430 | 324 | 369 | ||
431 | 325 | /* Add insert values */ | 370 | /* Add insert values */ |
432 | 326 | size_t num_records= data.record_size(); | 371 | size_t num_records= data.record_size(); |
433 | @@ -331,21 +376,21 @@ | |||
434 | 331 | for (x= 0; x < num_records; ++x) | 376 | for (x= 0; x < num_records; ++x) |
435 | 332 | { | 377 | { |
436 | 333 | if (x != 0) | 378 | if (x != 0) |
438 | 334 | destination->append("),(", 3); | 379 | destination.append("),(", 3); |
439 | 335 | 380 | ||
440 | 336 | for (y= 0; y < num_fields; ++y) | 381 | for (y= 0; y < num_fields; ++y) |
441 | 337 | { | 382 | { |
442 | 338 | if (y != 0) | 383 | if (y != 0) |
444 | 339 | destination->push_back(','); | 384 | destination.push_back(','); |
445 | 340 | 385 | ||
447 | 341 | const message::FieldMetadata &field_metadata= header.field_metadata(y); | 386 | const FieldMetadata &field_metadata= header.field_metadata(y); |
448 | 342 | 387 | ||
450 | 343 | should_quote_field_value= message::shouldQuoteFieldValue(field_metadata.type()); | 388 | should_quote_field_value= shouldQuoteFieldValue(field_metadata.type()); |
451 | 344 | 389 | ||
452 | 345 | if (should_quote_field_value) | 390 | if (should_quote_field_value) |
454 | 346 | destination->push_back('\''); | 391 | destination.push_back('\''); |
455 | 347 | 392 | ||
457 | 348 | if (field_metadata.type() == message::Table::Field::BLOB) | 393 | if (field_metadata.type() == Table::Field::BLOB) |
458 | 349 | { | 394 | { |
459 | 350 | /* | 395 | /* |
460 | 351 | * We do this here because BLOB data is returned | 396 | * We do this here because BLOB data is returned |
461 | @@ -354,53 +399,53 @@ | |||
462 | 354 | * up to a \0 being output here. | 399 | * up to a \0 being output here. |
463 | 355 | */ | 400 | */ |
464 | 356 | string raw_data(data.record(x).insert_value(y)); | 401 | string raw_data(data.record(x).insert_value(y)); |
466 | 357 | destination->append(raw_data.c_str(), raw_data.size()); | 402 | destination.append(raw_data.c_str(), raw_data.size()); |
467 | 358 | } | 403 | } |
468 | 359 | else | 404 | else |
469 | 360 | { | 405 | { |
471 | 361 | destination->append(data.record(x).insert_value(y)); | 406 | destination.append(data.record(x).insert_value(y)); |
472 | 362 | } | 407 | } |
473 | 363 | 408 | ||
474 | 364 | if (should_quote_field_value) | 409 | if (should_quote_field_value) |
476 | 365 | destination->push_back('\''); | 410 | destination.push_back('\''); |
477 | 366 | } | 411 | } |
478 | 367 | } | 412 | } |
480 | 368 | destination->push_back(')'); | 413 | destination.push_back(')'); |
481 | 369 | 414 | ||
482 | 370 | return error; | 415 | return error; |
483 | 371 | } | 416 | } |
484 | 372 | 417 | ||
489 | 373 | enum message::TransformSqlError | 418 | enum TransformSqlError |
490 | 374 | message::transformUpdateHeaderToSql(const message::UpdateHeader &header, | 419 | transformUpdateHeaderToSql(const UpdateHeader &header, |
491 | 375 | std::string *destination, | 420 | string &destination, |
492 | 376 | enum message::TransformSqlVariant sql_variant) | 421 | enum TransformSqlVariant sql_variant) |
493 | 377 | { | 422 | { |
494 | 378 | char quoted_identifier= '`'; | 423 | char quoted_identifier= '`'; |
495 | 379 | if (sql_variant == ANSI) | 424 | if (sql_variant == ANSI) |
496 | 380 | quoted_identifier= '"'; | 425 | quoted_identifier= '"'; |
497 | 381 | 426 | ||
507 | 382 | destination->assign("UPDATE ", 7); | 427 | destination.assign("UPDATE ", 7); |
508 | 383 | destination->push_back(quoted_identifier); | 428 | destination.push_back(quoted_identifier); |
509 | 384 | destination->append(header.table_metadata().schema_name()); | 429 | destination.append(header.table_metadata().schema_name()); |
510 | 385 | destination->push_back(quoted_identifier); | 430 | destination.push_back(quoted_identifier); |
511 | 386 | destination->push_back('.'); | 431 | destination.push_back('.'); |
512 | 387 | destination->push_back(quoted_identifier); | 432 | destination.push_back(quoted_identifier); |
513 | 388 | destination->append(header.table_metadata().table_name()); | 433 | destination.append(header.table_metadata().table_name()); |
514 | 389 | destination->push_back(quoted_identifier); | 434 | destination.push_back(quoted_identifier); |
515 | 390 | destination->append(" SET ", 5); | 435 | destination.append(" SET ", 5); |
516 | 391 | 436 | ||
517 | 392 | return NONE; | 437 | return NONE; |
518 | 393 | } | 438 | } |
519 | 394 | 439 | ||
525 | 395 | enum message::TransformSqlError | 440 | enum TransformSqlError |
526 | 396 | message::transformUpdateRecordToSql(const message::UpdateHeader &header, | 441 | transformUpdateRecordToSql(const UpdateHeader &header, |
527 | 397 | const message::UpdateRecord &record, | 442 | const UpdateRecord &record, |
528 | 398 | std::string *destination, | 443 | string &destination, |
529 | 399 | enum message::TransformSqlVariant sql_variant) | 444 | enum TransformSqlVariant sql_variant) |
530 | 400 | { | 445 | { |
534 | 401 | enum message::TransformSqlError error= transformUpdateHeaderToSql(header, | 446 | enum TransformSqlError error= transformUpdateHeaderToSql(header, |
535 | 402 | destination, | 447 | destination, |
536 | 403 | sql_variant); | 448 | sql_variant); |
537 | 404 | 449 | ||
538 | 405 | char quoted_identifier= '`'; | 450 | char quoted_identifier= '`'; |
539 | 406 | if (sql_variant == ANSI) | 451 | if (sql_variant == ANSI) |
540 | @@ -413,21 +458,21 @@ | |||
541 | 413 | 458 | ||
542 | 414 | for (x= 0; x < num_set_fields; ++x) | 459 | for (x= 0; x < num_set_fields; ++x) |
543 | 415 | { | 460 | { |
545 | 416 | const message::FieldMetadata &field_metadata= header.set_field_metadata(x); | 461 | const FieldMetadata &field_metadata= header.set_field_metadata(x); |
546 | 417 | if (x != 0) | 462 | if (x != 0) |
548 | 418 | destination->push_back(','); | 463 | destination.push_back(','); |
549 | 419 | 464 | ||
554 | 420 | destination->push_back(quoted_identifier); | 465 | destination.push_back(quoted_identifier); |
555 | 421 | destination->append(field_metadata.name()); | 466 | destination.append(field_metadata.name()); |
556 | 422 | destination->push_back(quoted_identifier); | 467 | destination.push_back(quoted_identifier); |
557 | 423 | destination->push_back('='); | 468 | destination.push_back('='); |
558 | 424 | 469 | ||
560 | 425 | should_quote_field_value= message::shouldQuoteFieldValue(field_metadata.type()); | 470 | should_quote_field_value= shouldQuoteFieldValue(field_metadata.type()); |
561 | 426 | 471 | ||
562 | 427 | if (should_quote_field_value) | 472 | if (should_quote_field_value) |
564 | 428 | destination->push_back('\''); | 473 | destination.push_back('\''); |
565 | 429 | 474 | ||
567 | 430 | if (field_metadata.type() == message::Table::Field::BLOB) | 475 | if (field_metadata.type() == Table::Field::BLOB) |
568 | 431 | { | 476 | { |
569 | 432 | /* | 477 | /* |
570 | 433 | * We do this here because BLOB data is returned | 478 | * We do this here because BLOB data is returned |
571 | @@ -436,39 +481,39 @@ | |||
572 | 436 | * up to a \0 being output here. | 481 | * up to a \0 being output here. |
573 | 437 | */ | 482 | */ |
574 | 438 | string raw_data(record.after_value(x)); | 483 | string raw_data(record.after_value(x)); |
576 | 439 | destination->append(raw_data.c_str(), raw_data.size()); | 484 | destination.append(raw_data.c_str(), raw_data.size()); |
577 | 440 | } | 485 | } |
578 | 441 | else | 486 | else |
579 | 442 | { | 487 | { |
581 | 443 | destination->append(record.after_value(x)); | 488 | destination.append(record.after_value(x)); |
582 | 444 | } | 489 | } |
583 | 445 | 490 | ||
584 | 446 | if (should_quote_field_value) | 491 | if (should_quote_field_value) |
586 | 447 | destination->push_back('\''); | 492 | destination.push_back('\''); |
587 | 448 | } | 493 | } |
588 | 449 | 494 | ||
589 | 450 | size_t num_key_fields= header.key_field_metadata_size(); | 495 | size_t num_key_fields= header.key_field_metadata_size(); |
590 | 451 | 496 | ||
592 | 452 | destination->append(" WHERE ", 7); | 497 | destination.append(" WHERE ", 7); |
593 | 453 | for (x= 0; x < num_key_fields; ++x) | 498 | for (x= 0; x < num_key_fields; ++x) |
594 | 454 | { | 499 | { |
596 | 455 | const message::FieldMetadata &field_metadata= header.key_field_metadata(x); | 500 | const FieldMetadata &field_metadata= header.key_field_metadata(x); |
597 | 456 | 501 | ||
598 | 457 | if (x != 0) | 502 | if (x != 0) |
608 | 458 | destination->append(" AND ", 5); /* Always AND condition with a multi-column PK */ | 503 | destination.append(" AND ", 5); /* Always AND condition with a multi-column PK */ |
609 | 459 | 504 | ||
610 | 460 | destination->push_back(quoted_identifier); | 505 | destination.push_back(quoted_identifier); |
611 | 461 | destination->append(field_metadata.name()); | 506 | destination.append(field_metadata.name()); |
612 | 462 | destination->push_back(quoted_identifier); | 507 | destination.push_back(quoted_identifier); |
613 | 463 | 508 | ||
614 | 464 | destination->push_back('='); | 509 | destination.push_back('='); |
615 | 465 | 510 | ||
616 | 466 | should_quote_field_value= message::shouldQuoteFieldValue(field_metadata.type()); | 511 | should_quote_field_value= shouldQuoteFieldValue(field_metadata.type()); |
617 | 467 | 512 | ||
618 | 468 | if (should_quote_field_value) | 513 | if (should_quote_field_value) |
620 | 469 | destination->push_back('\''); | 514 | destination.push_back('\''); |
621 | 470 | 515 | ||
623 | 471 | if (field_metadata.type() == message::Table::Field::BLOB) | 516 | if (field_metadata.type() == Table::Field::BLOB) |
624 | 472 | { | 517 | { |
625 | 473 | /* | 518 | /* |
626 | 474 | * We do this here because BLOB data is returned | 519 | * We do this here because BLOB data is returned |
627 | @@ -477,52 +522,50 @@ | |||
628 | 477 | * up to a \0 being output here. | 522 | * up to a \0 being output here. |
629 | 478 | */ | 523 | */ |
630 | 479 | string raw_data(record.key_value(x)); | 524 | string raw_data(record.key_value(x)); |
632 | 480 | destination->append(raw_data.c_str(), raw_data.size()); | 525 | destination.append(raw_data.c_str(), raw_data.size()); |
633 | 481 | } | 526 | } |
634 | 482 | else | 527 | else |
635 | 483 | { | 528 | { |
637 | 484 | destination->append(record.key_value(x)); | 529 | destination.append(record.key_value(x)); |
638 | 485 | } | 530 | } |
639 | 486 | 531 | ||
640 | 487 | if (should_quote_field_value) | 532 | if (should_quote_field_value) |
642 | 488 | destination->push_back('\''); | 533 | destination.push_back('\''); |
643 | 489 | } | 534 | } |
644 | 490 | if (num_key_fields > 1) | ||
645 | 491 | destination->push_back(')'); | ||
646 | 492 | 535 | ||
647 | 493 | return error; | 536 | return error; |
648 | 494 | } | 537 | } |
649 | 495 | 538 | ||
654 | 496 | enum message::TransformSqlError | 539 | enum TransformSqlError |
655 | 497 | message::transformDeleteHeaderToSql(const message::DeleteHeader &header, | 540 | transformDeleteHeaderToSql(const DeleteHeader &header, |
656 | 498 | std::string *destination, | 541 | string &destination, |
657 | 499 | enum message::TransformSqlVariant sql_variant) | 542 | enum TransformSqlVariant sql_variant) |
658 | 500 | { | 543 | { |
659 | 501 | char quoted_identifier= '`'; | 544 | char quoted_identifier= '`'; |
660 | 502 | if (sql_variant == ANSI) | 545 | if (sql_variant == ANSI) |
661 | 503 | quoted_identifier= '"'; | 546 | quoted_identifier= '"'; |
662 | 504 | 547 | ||
671 | 505 | destination->assign("DELETE FROM ", 12); | 548 | destination.assign("DELETE FROM ", 12); |
672 | 506 | destination->push_back(quoted_identifier); | 549 | destination.push_back(quoted_identifier); |
673 | 507 | destination->append(header.table_metadata().schema_name()); | 550 | destination.append(header.table_metadata().schema_name()); |
674 | 508 | destination->push_back(quoted_identifier); | 551 | destination.push_back(quoted_identifier); |
675 | 509 | destination->push_back('.'); | 552 | destination.push_back('.'); |
676 | 510 | destination->push_back(quoted_identifier); | 553 | destination.push_back(quoted_identifier); |
677 | 511 | destination->append(header.table_metadata().table_name()); | 554 | destination.append(header.table_metadata().table_name()); |
678 | 512 | destination->push_back(quoted_identifier); | 555 | destination.push_back(quoted_identifier); |
679 | 513 | 556 | ||
680 | 514 | return NONE; | 557 | return NONE; |
681 | 515 | } | 558 | } |
682 | 516 | 559 | ||
688 | 517 | enum message::TransformSqlError | 560 | enum TransformSqlError |
689 | 518 | message::transformDeleteRecordToSql(const message::DeleteHeader &header, | 561 | transformDeleteRecordToSql(const DeleteHeader &header, |
690 | 519 | const message::DeleteRecord &record, | 562 | const DeleteRecord &record, |
691 | 520 | std::string *destination, | 563 | string &destination, |
692 | 521 | enum message::TransformSqlVariant sql_variant) | 564 | enum TransformSqlVariant sql_variant) |
693 | 522 | { | 565 | { |
697 | 523 | enum message::TransformSqlError error= transformDeleteHeaderToSql(header, | 566 | enum TransformSqlError error= transformDeleteHeaderToSql(header, |
698 | 524 | destination, | 567 | destination, |
699 | 525 | sql_variant); | 568 | sql_variant); |
700 | 526 | char quoted_identifier= '`'; | 569 | char quoted_identifier= '`'; |
701 | 527 | if (sql_variant == ANSI) | 570 | if (sql_variant == ANSI) |
702 | 528 | quoted_identifier= '"'; | 571 | quoted_identifier= '"'; |
703 | @@ -532,26 +575,26 @@ | |||
704 | 532 | uint32_t x; | 575 | uint32_t x; |
705 | 533 | bool should_quote_field_value= false; | 576 | bool should_quote_field_value= false; |
706 | 534 | 577 | ||
708 | 535 | destination->append(" WHERE ", 7); | 578 | destination.append(" WHERE ", 7); |
709 | 536 | for (x= 0; x < num_key_fields; ++x) | 579 | for (x= 0; x < num_key_fields; ++x) |
710 | 537 | { | 580 | { |
712 | 538 | const message::FieldMetadata &field_metadata= header.key_field_metadata(x); | 581 | const FieldMetadata &field_metadata= header.key_field_metadata(x); |
713 | 539 | 582 | ||
714 | 540 | if (x != 0) | 583 | if (x != 0) |
724 | 541 | destination->append(" AND ", 5); /* Always AND condition with a multi-column PK */ | 584 | destination.append(" AND ", 5); /* Always AND condition with a multi-column PK */ |
725 | 542 | 585 | ||
726 | 543 | destination->push_back(quoted_identifier); | 586 | destination.push_back(quoted_identifier); |
727 | 544 | destination->append(field_metadata.name()); | 587 | destination.append(field_metadata.name()); |
728 | 545 | destination->push_back(quoted_identifier); | 588 | destination.push_back(quoted_identifier); |
729 | 546 | 589 | ||
730 | 547 | destination->push_back('='); | 590 | destination.push_back('='); |
731 | 548 | 591 | ||
732 | 549 | should_quote_field_value= message::shouldQuoteFieldValue(field_metadata.type()); | 592 | should_quote_field_value= shouldQuoteFieldValue(field_metadata.type()); |
733 | 550 | 593 | ||
734 | 551 | if (should_quote_field_value) | 594 | if (should_quote_field_value) |
736 | 552 | destination->push_back('\''); | 595 | destination.push_back('\''); |
737 | 553 | 596 | ||
739 | 554 | if (field_metadata.type() == message::Table::Field::BLOB) | 597 | if (field_metadata.type() == Table::Field::BLOB) |
740 | 555 | { | 598 | { |
741 | 556 | /* | 599 | /* |
742 | 557 | * We do this here because BLOB data is returned | 600 | * We do this here because BLOB data is returned |
743 | @@ -560,29 +603,29 @@ | |||
744 | 560 | * up to a \0 being output here. | 603 | * up to a \0 being output here. |
745 | 561 | */ | 604 | */ |
746 | 562 | string raw_data(record.key_value(x)); | 605 | string raw_data(record.key_value(x)); |
748 | 563 | destination->append(raw_data.c_str(), raw_data.size()); | 606 | destination.append(raw_data.c_str(), raw_data.size()); |
749 | 564 | } | 607 | } |
750 | 565 | else | 608 | else |
751 | 566 | { | 609 | { |
753 | 567 | destination->append(record.key_value(x)); | 610 | destination.append(record.key_value(x)); |
754 | 568 | } | 611 | } |
755 | 569 | 612 | ||
756 | 570 | if (should_quote_field_value) | 613 | if (should_quote_field_value) |
758 | 571 | destination->push_back('\''); | 614 | destination.push_back('\''); |
759 | 572 | } | 615 | } |
760 | 573 | 616 | ||
761 | 574 | return error; | 617 | return error; |
762 | 575 | } | 618 | } |
763 | 576 | 619 | ||
769 | 577 | enum message::TransformSqlError | 620 | enum TransformSqlError |
770 | 578 | message::transformDeleteStatementToSql(const message::DeleteHeader &header, | 621 | transformDeleteStatementToSql(const DeleteHeader &header, |
771 | 579 | const message::DeleteData &data, | 622 | const DeleteData &data, |
772 | 580 | std::string *destination, | 623 | string &destination, |
773 | 581 | enum message::TransformSqlVariant sql_variant) | 624 | enum TransformSqlVariant sql_variant) |
774 | 582 | { | 625 | { |
778 | 583 | enum message::TransformSqlError error= transformDeleteHeaderToSql(header, | 626 | enum TransformSqlError error= transformDeleteHeaderToSql(header, |
779 | 584 | destination, | 627 | destination, |
780 | 585 | sql_variant); | 628 | sql_variant); |
781 | 586 | char quoted_identifier= '`'; | 629 | char quoted_identifier= '`'; |
782 | 587 | if (sql_variant == ANSI) | 630 | if (sql_variant == ANSI) |
783 | 588 | quoted_identifier= '"'; | 631 | quoted_identifier= '"'; |
784 | @@ -593,34 +636,34 @@ | |||
785 | 593 | uint32_t x, y; | 636 | uint32_t x, y; |
786 | 594 | bool should_quote_field_value= false; | 637 | bool should_quote_field_value= false; |
787 | 595 | 638 | ||
789 | 596 | destination->append(" WHERE ", 7); | 639 | destination.append(" WHERE ", 7); |
790 | 597 | for (x= 0; x < num_key_records; ++x) | 640 | for (x= 0; x < num_key_records; ++x) |
791 | 598 | { | 641 | { |
792 | 599 | if (x != 0) | 642 | if (x != 0) |
794 | 600 | destination->append(" OR ", 4); /* Always OR condition for multiple key records */ | 643 | destination.append(" OR ", 4); /* Always OR condition for multiple key records */ |
795 | 601 | 644 | ||
796 | 602 | if (num_key_fields > 1) | 645 | if (num_key_fields > 1) |
798 | 603 | destination->push_back('('); | 646 | destination.push_back('('); |
799 | 604 | 647 | ||
800 | 605 | for (y= 0; y < num_key_fields; ++y) | 648 | for (y= 0; y < num_key_fields; ++y) |
801 | 606 | { | 649 | { |
803 | 607 | const message::FieldMetadata &field_metadata= header.key_field_metadata(y); | 650 | const FieldMetadata &field_metadata= header.key_field_metadata(y); |
804 | 608 | 651 | ||
805 | 609 | if (y != 0) | 652 | if (y != 0) |
815 | 610 | destination->append(" AND ", 5); /* Always AND condition with a multi-column PK */ | 653 | destination.append(" AND ", 5); /* Always AND condition with a multi-column PK */ |
816 | 611 | 654 | ||
817 | 612 | destination->push_back(quoted_identifier); | 655 | destination.push_back(quoted_identifier); |
818 | 613 | destination->append(field_metadata.name()); | 656 | destination.append(field_metadata.name()); |
819 | 614 | destination->push_back(quoted_identifier); | 657 | destination.push_back(quoted_identifier); |
820 | 615 | 658 | ||
821 | 616 | destination->push_back('='); | 659 | destination.push_back('='); |
822 | 617 | 660 | ||
823 | 618 | should_quote_field_value= message::shouldQuoteFieldValue(field_metadata.type()); | 661 | should_quote_field_value= shouldQuoteFieldValue(field_metadata.type()); |
824 | 619 | 662 | ||
825 | 620 | if (should_quote_field_value) | 663 | if (should_quote_field_value) |
827 | 621 | destination->push_back('\''); | 664 | destination.push_back('\''); |
828 | 622 | 665 | ||
830 | 623 | if (field_metadata.type() == message::Table::Field::BLOB) | 666 | if (field_metadata.type() == Table::Field::BLOB) |
831 | 624 | { | 667 | { |
832 | 625 | /* | 668 | /* |
833 | 626 | * We do this here because BLOB data is returned | 669 | * We do this here because BLOB data is returned |
834 | @@ -629,114 +672,607 @@ | |||
835 | 629 | * up to a \0 being output here. | 672 | * up to a \0 being output here. |
836 | 630 | */ | 673 | */ |
837 | 631 | string raw_data(data.record(x).key_value(y)); | 674 | string raw_data(data.record(x).key_value(y)); |
839 | 632 | destination->append(raw_data.c_str(), raw_data.size()); | 675 | destination.append(raw_data.c_str(), raw_data.size()); |
840 | 633 | } | 676 | } |
841 | 634 | else | 677 | else |
842 | 635 | { | 678 | { |
844 | 636 | destination->append(data.record(x).key_value(y)); | 679 | destination.append(data.record(x).key_value(y)); |
845 | 637 | } | 680 | } |
846 | 638 | 681 | ||
847 | 639 | if (should_quote_field_value) | 682 | if (should_quote_field_value) |
849 | 640 | destination->push_back('\''); | 683 | destination.push_back('\''); |
850 | 641 | } | 684 | } |
851 | 642 | if (num_key_fields > 1) | 685 | if (num_key_fields > 1) |
853 | 643 | destination->push_back(')'); | 686 | destination.push_back(')'); |
854 | 644 | } | 687 | } |
855 | 645 | return error; | 688 | return error; |
856 | 646 | } | 689 | } |
857 | 647 | 690 | ||
885 | 648 | enum message::TransformSqlError | 691 | enum TransformSqlError |
886 | 649 | message::transformTruncateTableStatementToSql(const message::TruncateTableStatement &statement, | 692 | transformDropSchemaStatementToSql(const DropSchemaStatement &statement, |
887 | 650 | std::string *destination, | 693 | string &destination, |
888 | 651 | enum message::TransformSqlVariant sql_variant) | 694 | enum TransformSqlVariant sql_variant) |
889 | 652 | { | 695 | { |
890 | 653 | char quoted_identifier= '`'; | 696 | char quoted_identifier= '`'; |
891 | 654 | if (sql_variant == ANSI) | 697 | if (sql_variant == ANSI) |
892 | 655 | quoted_identifier= '"'; | 698 | quoted_identifier= '"'; |
893 | 656 | 699 | ||
894 | 657 | const message::TableMetadata &table_metadata= statement.table_metadata(); | 700 | destination.append("DROP SCHEMA ", 12); |
895 | 658 | 701 | destination.push_back(quoted_identifier); | |
896 | 659 | destination->append("TRUNCATE TABLE ", 15); | 702 | destination.append(statement.schema_name()); |
897 | 660 | destination->push_back(quoted_identifier); | 703 | destination.push_back(quoted_identifier); |
898 | 661 | destination->append(table_metadata.schema_name()); | 704 | |
899 | 662 | destination->push_back(quoted_identifier); | 705 | return NONE; |
900 | 663 | destination->push_back('.'); | 706 | } |
901 | 664 | destination->push_back(quoted_identifier); | 707 | |
902 | 665 | destination->append(table_metadata.table_name()); | 708 | enum TransformSqlError |
903 | 666 | destination->push_back(quoted_identifier); | 709 | transformCreateSchemaStatementToSql(const CreateSchemaStatement &statement, |
904 | 667 | 710 | string &destination, | |
905 | 668 | return NONE; | 711 | enum TransformSqlVariant sql_variant) |
906 | 669 | } | 712 | { |
907 | 670 | 713 | char quoted_identifier= '`'; | |
908 | 671 | enum message::TransformSqlError | 714 | if (sql_variant == ANSI) |
909 | 672 | message::transformSetVariableStatementToSql(const message::SetVariableStatement &statement, | 715 | quoted_identifier= '"'; |
910 | 673 | std::string *destination, | 716 | |
911 | 674 | enum message::TransformSqlVariant sql_variant) | 717 | const Schema &schema= statement.schema(); |
912 | 718 | |||
913 | 719 | destination.append("CREATE SCHEMA ", 14); | ||
914 | 720 | destination.push_back(quoted_identifier); | ||
915 | 721 | destination.append(schema.name()); | ||
916 | 722 | destination.push_back(quoted_identifier); | ||
917 | 723 | |||
918 | 724 | if (schema.has_collation()) | ||
919 | 725 | { | ||
920 | 726 | destination.append(" COLLATE ", 9); | ||
921 | 727 | destination.append(schema.collation()); | ||
922 | 728 | } | ||
923 | 729 | |||
924 | 730 | return NONE; | ||
925 | 731 | } | ||
926 | 732 | |||
927 | 733 | enum TransformSqlError | ||
928 | 734 | transformDropTableStatementToSql(const DropTableStatement &statement, | ||
929 | 735 | string &destination, | ||
930 | 736 | enum TransformSqlVariant sql_variant) | ||
931 | 737 | { | ||
932 | 738 | char quoted_identifier= '`'; | ||
933 | 739 | if (sql_variant == ANSI) | ||
934 | 740 | quoted_identifier= '"'; | ||
935 | 741 | |||
936 | 742 | const TableMetadata &table_metadata= statement.table_metadata(); | ||
937 | 743 | |||
938 | 744 | destination.append("DROP TABLE ", 11); | ||
939 | 745 | |||
940 | 746 | /* Add the IF EXISTS clause if necessary */ | ||
941 | 747 | if (statement.has_if_exists_clause() && | ||
942 | 748 | statement.if_exists_clause() == true) | ||
943 | 749 | { | ||
944 | 750 | destination.append("IF EXISTS ", 10); | ||
945 | 751 | } | ||
946 | 752 | |||
947 | 753 | destination.push_back(quoted_identifier); | ||
948 | 754 | destination.append(table_metadata.schema_name()); | ||
949 | 755 | destination.push_back(quoted_identifier); | ||
950 | 756 | destination.push_back('.'); | ||
951 | 757 | destination.push_back(quoted_identifier); | ||
952 | 758 | destination.append(table_metadata.table_name()); | ||
953 | 759 | destination.push_back(quoted_identifier); | ||
954 | 760 | |||
955 | 761 | return NONE; | ||
956 | 762 | } | ||
957 | 763 | |||
958 | 764 | enum TransformSqlError | ||
959 | 765 | transformTruncateTableStatementToSql(const TruncateTableStatement &statement, | ||
960 | 766 | string &destination, | ||
961 | 767 | enum TransformSqlVariant sql_variant) | ||
962 | 768 | { | ||
963 | 769 | char quoted_identifier= '`'; | ||
964 | 770 | if (sql_variant == ANSI) | ||
965 | 771 | quoted_identifier= '"'; | ||
966 | 772 | |||
967 | 773 | const TableMetadata &table_metadata= statement.table_metadata(); | ||
968 | 774 | |||
969 | 775 | destination.append("TRUNCATE TABLE ", 15); | ||
970 | 776 | destination.push_back(quoted_identifier); | ||
971 | 777 | destination.append(table_metadata.schema_name()); | ||
972 | 778 | destination.push_back(quoted_identifier); | ||
973 | 779 | destination.push_back('.'); | ||
974 | 780 | destination.push_back(quoted_identifier); | ||
975 | 781 | destination.append(table_metadata.table_name()); | ||
976 | 782 | destination.push_back(quoted_identifier); | ||
977 | 783 | |||
978 | 784 | return NONE; | ||
979 | 785 | } | ||
980 | 786 | |||
981 | 787 | enum TransformSqlError | ||
982 | 788 | transformSetVariableStatementToSql(const SetVariableStatement &statement, | ||
983 | 789 | string &destination, | ||
984 | 790 | enum TransformSqlVariant sql_variant) | ||
985 | 675 | { | 791 | { |
986 | 676 | (void) sql_variant; | 792 | (void) sql_variant; |
1006 | 677 | const message::FieldMetadata &variable_metadata= statement.variable_metadata(); | 793 | const FieldMetadata &variable_metadata= statement.variable_metadata(); |
1007 | 678 | bool should_quote_field_value= message::shouldQuoteFieldValue(variable_metadata.type()); | 794 | bool should_quote_field_value= shouldQuoteFieldValue(variable_metadata.type()); |
1008 | 679 | 795 | ||
1009 | 680 | destination->append("SET GLOBAL ", 11); /* Only global variables are replicated */ | 796 | destination.append("SET GLOBAL ", 11); /* Only global variables are replicated */ |
1010 | 681 | destination->append(variable_metadata.name()); | 797 | destination.append(variable_metadata.name()); |
1011 | 682 | destination->push_back('='); | 798 | destination.push_back('='); |
1012 | 683 | 799 | ||
1013 | 684 | if (should_quote_field_value) | 800 | if (should_quote_field_value) |
1014 | 685 | destination->push_back('\''); | 801 | destination.push_back('\''); |
1015 | 686 | 802 | ||
1016 | 687 | destination->append(statement.variable_value()); | 803 | destination.append(statement.variable_value()); |
1017 | 688 | 804 | ||
1018 | 689 | if (should_quote_field_value) | 805 | if (should_quote_field_value) |
1019 | 690 | destination->push_back('\''); | 806 | destination.push_back('\''); |
1020 | 691 | 807 | ||
1021 | 692 | return NONE; | 808 | return NONE; |
1022 | 693 | } | 809 | } |
1023 | 694 | 810 | ||
1024 | 695 | bool message::shouldQuoteFieldValue(message::Table::Field::FieldType in_type) | 811 | enum TransformSqlError |
1025 | 812 | transformCreateTableStatementToSql(const CreateTableStatement &statement, | ||
1026 | 813 | string &destination, | ||
1027 | 814 | enum TransformSqlVariant sql_variant) | ||
1028 | 815 | { | ||
1029 | 816 | return transformTableDefinitionToSql(statement.table(), destination, sql_variant); | ||
1030 | 817 | } | ||
1031 | 818 | |||
1032 | 819 | enum TransformSqlError | ||
1033 | 820 | transformTableDefinitionToSql(const Table &table, | ||
1034 | 821 | string &destination, | ||
1035 | 822 | enum TransformSqlVariant sql_variant) | ||
1036 | 823 | { | ||
1037 | 824 | char quoted_identifier= '`'; | ||
1038 | 825 | if (sql_variant == ANSI) | ||
1039 | 826 | quoted_identifier= '"'; | ||
1040 | 827 | |||
1041 | 828 | destination.append("CREATE ", 7); | ||
1042 | 829 | |||
1043 | 830 | if (table.type() == Table::TEMPORARY) | ||
1044 | 831 | destination.append("TEMPORARY ", 10); | ||
1045 | 832 | |||
1046 | 833 | destination.append("TABLE ", 6); | ||
1047 | 834 | destination.push_back(quoted_identifier); | ||
1048 | 835 | destination.append(table.name()); | ||
1049 | 836 | destination.push_back(quoted_identifier); | ||
1050 | 837 | destination.append(" (\n", 3); | ||
1051 | 838 | |||
1052 | 839 | enum TransformSqlError result= NONE; | ||
1053 | 840 | size_t num_fields= table.field_size(); | ||
1054 | 841 | for (size_t x= 0; x < num_fields; ++x) | ||
1055 | 842 | { | ||
1056 | 843 | const Table::Field &field= table.field(x); | ||
1057 | 844 | |||
1058 | 845 | if (x != 0) | ||
1059 | 846 | destination.append(",\n", 2); | ||
1060 | 847 | |||
1061 | 848 | result= transformFieldDefinitionToSql(field, destination, sql_variant); | ||
1062 | 849 | |||
1063 | 850 | if (result != NONE) | ||
1064 | 851 | return result; | ||
1065 | 852 | } | ||
1066 | 853 | |||
1067 | 854 | size_t num_indexes= table.indexes_size(); | ||
1068 | 855 | |||
1069 | 856 | if (num_indexes > 0) | ||
1070 | 857 | destination.append(",\n", 2); | ||
1071 | 858 | |||
1072 | 859 | for (size_t x= 0; x < num_indexes; ++x) | ||
1073 | 860 | { | ||
1074 | 861 | const message::Table::Index &index= table.indexes(x); | ||
1075 | 862 | |||
1076 | 863 | if (x != 0) | ||
1077 | 864 | destination.append(",\n", 2); | ||
1078 | 865 | |||
1079 | 866 | result= transformIndexDefinitionToSql(index, table, destination, sql_variant); | ||
1080 | 867 | |||
1081 | 868 | if (result != NONE) | ||
1082 | 869 | return result; | ||
1083 | 870 | } | ||
1084 | 871 | destination.append("\n)", 2); | ||
1085 | 872 | |||
1086 | 873 | /* Add ENGINE = " clause */ | ||
1087 | 874 | if (table.has_engine()) | ||
1088 | 875 | { | ||
1089 | 876 | const Table::StorageEngine &engine= table.engine(); | ||
1090 | 877 | destination.append("\nENGINE = ", 10); | ||
1091 | 878 | destination.append(engine.name()); | ||
1092 | 879 | |||
1093 | 880 | size_t num_engine_options= engine.option_size(); | ||
1094 | 881 | for (size_t x= 0; x < num_engine_options; ++x) | ||
1095 | 882 | { | ||
1096 | 883 | const Table::StorageEngine::EngineOption &option= engine.option(x); | ||
1097 | 884 | destination.push_back('\n'); | ||
1098 | 885 | destination.append(option.option_name()); | ||
1099 | 886 | destination.append(" = ", 3); | ||
1100 | 887 | destination.append(option.option_value()); | ||
1101 | 888 | destination.push_back('\n'); | ||
1102 | 889 | } | ||
1103 | 890 | } | ||
1104 | 891 | |||
1105 | 892 | if (table.has_options()) | ||
1106 | 893 | (void) transformTableOptionsToSql(table.options(), destination, sql_variant); | ||
1107 | 894 | |||
1108 | 895 | return NONE; | ||
1109 | 896 | } | ||
1110 | 897 | |||
1111 | 898 | enum TransformSqlError | ||
1112 | 899 | transformTableOptionsToSql(const Table::TableOptions &options, | ||
1113 | 900 | string &destination, | ||
1114 | 901 | enum TransformSqlVariant sql_variant) | ||
1115 | 902 | { | ||
1116 | 903 | if (sql_variant == ANSI) | ||
1117 | 904 | return NONE; /* ANSI does not support table options... */ | ||
1118 | 905 | |||
1119 | 906 | stringstream ss; | ||
1120 | 907 | |||
1121 | 908 | if (options.has_comment()) | ||
1122 | 909 | { | ||
1123 | 910 | destination.append("\nCOMMENT = '", 12); | ||
1124 | 911 | destination.append(options.comment()); | ||
1125 | 912 | destination.push_back('\''); | ||
1126 | 913 | } | ||
1127 | 914 | |||
1128 | 915 | if (options.has_collation()) | ||
1129 | 916 | { | ||
1130 | 917 | destination.append("\nCOLLATE = ", 11); | ||
1131 | 918 | destination.append(options.collation()); | ||
1132 | 919 | } | ||
1133 | 920 | |||
1134 | 921 | if (options.has_auto_increment()) | ||
1135 | 922 | { | ||
1136 | 923 | ss << options.auto_increment(); | ||
1137 | 924 | destination.append("\nAUTOINCREMENT_OFFSET = ", 24); | ||
1138 | 925 | destination.append(ss.str()); | ||
1139 | 926 | ss.clear(); | ||
1140 | 927 | } | ||
1141 | 928 | |||
1142 | 929 | if (options.has_row_type()) | ||
1143 | 930 | { | ||
1144 | 931 | ss << options.row_type(); | ||
1145 | 932 | destination.append("\nROW_TYPE = ", 12); | ||
1146 | 933 | destination.append(ss.str()); | ||
1147 | 934 | ss.clear(); | ||
1148 | 935 | } | ||
1149 | 936 | |||
1150 | 937 | if (options.has_data_file_name()) | ||
1151 | 938 | { | ||
1152 | 939 | destination.append("\nDATA_FILE_NAME = '", 19); | ||
1153 | 940 | destination.append(options.data_file_name()); | ||
1154 | 941 | destination.push_back('\''); | ||
1155 | 942 | } | ||
1156 | 943 | |||
1157 | 944 | if (options.has_index_file_name()) | ||
1158 | 945 | { | ||
1159 | 946 | destination.append("\nINDEX_FILE_NAME = '", 20); | ||
1160 | 947 | destination.append(options.index_file_name()); | ||
1161 | 948 | destination.push_back('\''); | ||
1162 | 949 | } | ||
1163 | 950 | |||
1164 | 951 | if (options.has_max_rows()) | ||
1165 | 952 | { | ||
1166 | 953 | ss << options.max_rows(); | ||
1167 | 954 | destination.append("\nMAX_ROWS = ", 12); | ||
1168 | 955 | destination.append(ss.str()); | ||
1169 | 956 | ss.clear(); | ||
1170 | 957 | } | ||
1171 | 958 | |||
1172 | 959 | if (options.has_min_rows()) | ||
1173 | 960 | { | ||
1174 | 961 | ss << options.min_rows(); | ||
1175 | 962 | destination.append("\nMIN_ROWS = ", 12); | ||
1176 | 963 | destination.append(ss.str()); | ||
1177 | 964 | ss.clear(); | ||
1178 | 965 | } | ||
1179 | 966 | |||
1180 | 967 | if (options.has_auto_increment_value()) | ||
1181 | 968 | { | ||
1182 | 969 | ss << options.auto_increment_value(); | ||
1183 | 970 | destination.append("\nAUTO_INCREMENT = ", 18); | ||
1184 | 971 | destination.append(ss.str()); | ||
1185 | 972 | ss.clear(); | ||
1186 | 973 | } | ||
1187 | 974 | |||
1188 | 975 | if (options.has_avg_row_length()) | ||
1189 | 976 | { | ||
1190 | 977 | ss << options.avg_row_length(); | ||
1191 | 978 | destination.append("\nAVG_ROW_LENGTH = ", 18); | ||
1192 | 979 | destination.append(ss.str()); | ||
1193 | 980 | ss.clear(); | ||
1194 | 981 | } | ||
1195 | 982 | |||
1196 | 983 | if (options.has_key_block_size()) | ||
1197 | 984 | { | ||
1198 | 985 | ss << options.key_block_size(); | ||
1199 | 986 | destination.append("\nKEY_BLOCK_SIZE = ", 18); | ||
1200 | 987 | destination.append(ss.str()); | ||
1201 | 988 | ss.clear(); | ||
1202 | 989 | } | ||
1203 | 990 | |||
1204 | 991 | if (options.has_block_size()) | ||
1205 | 992 | { | ||
1206 | 993 | ss << options.block_size(); | ||
1207 | 994 | destination.append("\nBLOCK_SIZE = ", 14); | ||
1208 | 995 | destination.append(ss.str()); | ||
1209 | 996 | ss.clear(); | ||
1210 | 997 | } | ||
1211 | 998 | |||
1212 | 999 | if (options.has_pack_keys() && | ||
1213 | 1000 | options.pack_keys()) | ||
1214 | 1001 | destination.append("\nPACK_KEYS = TRUE", 17); | ||
1215 | 1002 | if (options.has_pack_record() && | ||
1216 | 1003 | options.pack_record()) | ||
1217 | 1004 | destination.append("\nPACK_RECORD = TRUE", 19); | ||
1218 | 1005 | if (options.has_checksum() && | ||
1219 | 1006 | options.checksum()) | ||
1220 | 1007 | destination.append("\nCHECKSUM = TRUE", 16); | ||
1221 | 1008 | if (options.has_page_checksum() && | ||
1222 | 1009 | options.page_checksum()) | ||
1223 | 1010 | destination.append("\nPAGE_CHECKSUM = TRUE", 21); | ||
1224 | 1011 | |||
1225 | 1012 | return NONE; | ||
1226 | 1013 | } | ||
1227 | 1014 | |||
1228 | 1015 | enum TransformSqlError | ||
1229 | 1016 | transformIndexDefinitionToSql(const Table::Index &index, | ||
1230 | 1017 | const Table &table, | ||
1231 | 1018 | string &destination, | ||
1232 | 1019 | enum TransformSqlVariant sql_variant) | ||
1233 | 1020 | { | ||
1234 | 1021 | char quoted_identifier= '`'; | ||
1235 | 1022 | if (sql_variant == ANSI) | ||
1236 | 1023 | quoted_identifier= '"'; | ||
1237 | 1024 | |||
1238 | 1025 | if (index.is_primary()) | ||
1239 | 1026 | destination.append("PRIMARY ", 8); | ||
1240 | 1027 | else if (index.is_unique()) | ||
1241 | 1028 | destination.append("UNIQUE ", 7); | ||
1242 | 1029 | |||
1243 | 1030 | destination.append("KEY ", 4); | ||
1244 | 1031 | destination.push_back(quoted_identifier); | ||
1245 | 1032 | destination.append(index.name()); | ||
1246 | 1033 | destination.push_back(quoted_identifier); | ||
1247 | 1034 | destination.append(" (", 2); | ||
1248 | 1035 | |||
1249 | 1036 | size_t num_parts= index.index_part_size(); | ||
1250 | 1037 | for (size_t x= 0; x < num_parts; ++x) | ||
1251 | 1038 | { | ||
1252 | 1039 | const Table::Index::IndexPart &part= index.index_part(x); | ||
1253 | 1040 | const Table::Field &field= table.field(part.fieldnr()); | ||
1254 | 1041 | |||
1255 | 1042 | if (x != 0) | ||
1256 | 1043 | destination.push_back(','); | ||
1257 | 1044 | |||
1258 | 1045 | destination.push_back(quoted_identifier); | ||
1259 | 1046 | destination.append(field.name()); | ||
1260 | 1047 | destination.push_back(quoted_identifier); | ||
1261 | 1048 | |||
1262 | 1049 | /* | ||
1263 | 1050 | * If the index part's field type is VARCHAR or TEXT | ||
1264 | 1051 | * then check for a prefix length then is different | ||
1265 | 1052 | * from the field's full length... | ||
1266 | 1053 | */ | ||
1267 | 1054 | if (field.type() == Table::Field::VARCHAR || | ||
1268 | 1055 | field.type() == Table::Field::BLOB) | ||
1269 | 1056 | { | ||
1270 | 1057 | if (part.has_compare_length()) | ||
1271 | 1058 | { | ||
1272 | 1059 | size_t compare_length_in_chars= part.compare_length(); | ||
1273 | 1060 | |||
1274 | 1061 | /* hack: compare_length() is bytes, not chars, but | ||
1275 | 1062 | * only for VARCHAR. Ass. */ | ||
1276 | 1063 | if (field.type() == Table::Field::VARCHAR) | ||
1277 | 1064 | compare_length_in_chars/= 4; | ||
1278 | 1065 | |||
1279 | 1066 | if (compare_length_in_chars != field.string_options().length()) | ||
1280 | 1067 | { | ||
1281 | 1068 | stringstream ss; | ||
1282 | 1069 | destination.push_back('('); | ||
1283 | 1070 | ss << compare_length_in_chars; | ||
1284 | 1071 | destination.append(ss.str()); | ||
1285 | 1072 | destination.push_back(')'); | ||
1286 | 1073 | } | ||
1287 | 1074 | } | ||
1288 | 1075 | } | ||
1289 | 1076 | } | ||
1290 | 1077 | destination.push_back(')'); | ||
1291 | 1078 | |||
1292 | 1079 | return NONE; | ||
1293 | 1080 | } | ||
1294 | 1081 | |||
1295 | 1082 | enum TransformSqlError | ||
1296 | 1083 | transformFieldDefinitionToSql(const Table::Field &field, | ||
1297 | 1084 | string &destination, | ||
1298 | 1085 | enum TransformSqlVariant sql_variant) | ||
1299 | 1086 | { | ||
1300 | 1087 | char quoted_identifier= '`'; | ||
1301 | 1088 | if (sql_variant == ANSI) | ||
1302 | 1089 | quoted_identifier= '"'; | ||
1303 | 1090 | |||
1304 | 1091 | destination.push_back(quoted_identifier); | ||
1305 | 1092 | destination.append(field.name()); | ||
1306 | 1093 | destination.push_back(quoted_identifier); | ||
1307 | 1094 | |||
1308 | 1095 | Table::Field::FieldType field_type= field.type(); | ||
1309 | 1096 | |||
1310 | 1097 | switch (field_type) | ||
1311 | 1098 | { | ||
1312 | 1099 | case Table::Field::DOUBLE: | ||
1313 | 1100 | destination.append(" DOUBLE", 7); | ||
1314 | 1101 | break; | ||
1315 | 1102 | case Table::Field::VARCHAR: | ||
1316 | 1103 | { | ||
1317 | 1104 | destination.append(" VARCHAR(", 9); | ||
1318 | 1105 | stringstream ss; | ||
1319 | 1106 | ss << field.string_options().length() << ")"; | ||
1320 | 1107 | destination.append(ss.str()); | ||
1321 | 1108 | } | ||
1322 | 1109 | break; | ||
1323 | 1110 | case Table::Field::BLOB: | ||
1324 | 1111 | destination.append(" BLOB", 5); | ||
1325 | 1112 | break; | ||
1326 | 1113 | case Table::Field::ENUM: | ||
1327 | 1114 | { | ||
1328 | 1115 | size_t num_field_values= field.set_options().field_value_size(); | ||
1329 | 1116 | destination.append(" ENUM(", 6); | ||
1330 | 1117 | for (size_t x= 0; x < num_field_values; ++x) | ||
1331 | 1118 | { | ||
1332 | 1119 | const string &type= field.set_options().field_value(x); | ||
1333 | 1120 | |||
1334 | 1121 | if (x != 0) | ||
1335 | 1122 | destination.push_back(','); | ||
1336 | 1123 | |||
1337 | 1124 | destination.push_back('\''); | ||
1338 | 1125 | destination.append(type); | ||
1339 | 1126 | destination.push_back('\''); | ||
1340 | 1127 | } | ||
1341 | 1128 | destination.push_back(')'); | ||
1342 | 1129 | break; | ||
1343 | 1130 | } | ||
1344 | 1131 | case Table::Field::INTEGER: | ||
1345 | 1132 | destination.append(" INT", 4); | ||
1346 | 1133 | break; | ||
1347 | 1134 | case Table::Field::BIGINT: | ||
1348 | 1135 | destination.append(" BIGINT", 7); | ||
1349 | 1136 | break; | ||
1350 | 1137 | case Table::Field::DECIMAL: | ||
1351 | 1138 | { | ||
1352 | 1139 | destination.append(" DECIMAL(", 9); | ||
1353 | 1140 | stringstream ss; | ||
1354 | 1141 | ss << field.numeric_options().precision() << ","; | ||
1355 | 1142 | ss << field.numeric_options().scale() << ")"; | ||
1356 | 1143 | destination.append(ss.str()); | ||
1357 | 1144 | } | ||
1358 | 1145 | break; | ||
1359 | 1146 | case Table::Field::DATE: | ||
1360 | 1147 | destination.append(" DATE", 5); | ||
1361 | 1148 | break; | ||
1362 | 1149 | case Table::Field::TIMESTAMP: | ||
1363 | 1150 | destination.append(" TIMESTAMP", 10); | ||
1364 | 1151 | break; | ||
1365 | 1152 | case Table::Field::DATETIME: | ||
1366 | 1153 | destination.append(" DATETIME", 9); | ||
1367 | 1154 | break; | ||
1368 | 1155 | } | ||
1369 | 1156 | |||
1370 | 1157 | if (field.type() == Table::Field::INTEGER || | ||
1371 | 1158 | field.type() == Table::Field::BIGINT) | ||
1372 | 1159 | { | ||
1373 | 1160 | if (field.has_constraints() && | ||
1374 | 1161 | field.constraints().has_is_unsigned() && | ||
1375 | 1162 | field.constraints().is_unsigned()) | ||
1376 | 1163 | { | ||
1377 | 1164 | destination.append(" UNSIGNED", 9); | ||
1378 | 1165 | } | ||
1379 | 1166 | } | ||
1380 | 1167 | |||
1381 | 1168 | |||
1382 | 1169 | if (! (field.has_constraints() && | ||
1383 | 1170 | field.constraints().is_nullable())) | ||
1384 | 1171 | { | ||
1385 | 1172 | destination.append(" NOT", 4); | ||
1386 | 1173 | } | ||
1387 | 1174 | destination.append(" NULL", 5); | ||
1388 | 1175 | |||
1389 | 1176 | if (field.type() == Table::Field::INTEGER || | ||
1390 | 1177 | field.type() == Table::Field::BIGINT) | ||
1391 | 1178 | { | ||
1392 | 1179 | /* AUTO_INCREMENT must be after NOT NULL */ | ||
1393 | 1180 | if (field.has_numeric_options() && | ||
1394 | 1181 | field.numeric_options().is_autoincrement()) | ||
1395 | 1182 | { | ||
1396 | 1183 | destination.append(" AUTO_INCREMENT", 15); | ||
1397 | 1184 | } | ||
1398 | 1185 | } | ||
1399 | 1186 | |||
1400 | 1187 | if (field.type() == Table::Field::BLOB || | ||
1401 | 1188 | field.type() == Table::Field::VARCHAR) | ||
1402 | 1189 | { | ||
1403 | 1190 | if (field.string_options().has_collation()) | ||
1404 | 1191 | { | ||
1405 | 1192 | destination.append(" COLLATE ", 9); | ||
1406 | 1193 | destination.append(field.string_options().collation()); | ||
1407 | 1194 | } | ||
1408 | 1195 | } | ||
1409 | 1196 | |||
1410 | 1197 | if (field.options().has_default_value()) | ||
1411 | 1198 | { | ||
1412 | 1199 | destination.append(" DEFAULT ", 9); | ||
1413 | 1200 | destination.push_back(quoted_identifier); | ||
1414 | 1201 | destination.append(field.options().default_value()); | ||
1415 | 1202 | destination.push_back(quoted_identifier); | ||
1416 | 1203 | } | ||
1417 | 1204 | |||
1418 | 1205 | if (field.options().has_default_bin_value()) | ||
1419 | 1206 | { | ||
1420 | 1207 | const string &v= field.options().default_bin_value(); | ||
1421 | 1208 | destination.append(" DEFAULT 0x", 11); | ||
1422 | 1209 | for (size_t x= 0; x < v.length(); x++) | ||
1423 | 1210 | { | ||
1424 | 1211 | printf("%.2x", *(v.c_str() + x)); | ||
1425 | 1212 | } | ||
1426 | 1213 | } | ||
1427 | 1214 | |||
1428 | 1215 | if (field.type() == Table::Field::TIMESTAMP) | ||
1429 | 1216 | if (field.timestamp_options().has_auto_updates() && | ||
1430 | 1217 | field.timestamp_options().auto_updates()) | ||
1431 | 1218 | destination.append(" ON UPDATE CURRENT_TIMESTAMP", 28); | ||
1432 | 1219 | |||
1433 | 1220 | if (field.has_comment()) | ||
1434 | 1221 | { | ||
1435 | 1222 | destination.append(" COMMENT ", 9); | ||
1436 | 1223 | destination.push_back(quoted_identifier); | ||
1437 | 1224 | destination.append(field.comment()); | ||
1438 | 1225 | destination.push_back(quoted_identifier); | ||
1439 | 1226 | } | ||
1440 | 1227 | return NONE; | ||
1441 | 1228 | } | ||
1442 | 1229 | |||
1443 | 1230 | bool shouldQuoteFieldValue(Table::Field::FieldType in_type) | ||
1444 | 696 | { | 1231 | { |
1445 | 697 | switch (in_type) | 1232 | switch (in_type) |
1446 | 698 | { | 1233 | { |
1452 | 699 | case message::Table::Field::DOUBLE: | 1234 | case Table::Field::DOUBLE: |
1453 | 700 | case message::Table::Field::DECIMAL: | 1235 | case Table::Field::DECIMAL: |
1454 | 701 | case message::Table::Field::INTEGER: | 1236 | case Table::Field::INTEGER: |
1455 | 702 | case message::Table::Field::BIGINT: | 1237 | case Table::Field::BIGINT: |
1456 | 703 | case message::Table::Field::ENUM: | 1238 | case Table::Field::ENUM: |
1457 | 704 | return false; | 1239 | return false; |
1458 | 705 | default: | 1240 | default: |
1459 | 706 | return true; | 1241 | return true; |
1460 | 707 | } | 1242 | } |
1461 | 708 | } | 1243 | } |
1462 | 709 | 1244 | ||
1464 | 710 | drizzled::message::Table::Field::FieldType message::internalFieldTypeToFieldProtoType(enum enum_field_types type) | 1245 | Table::Field::FieldType internalFieldTypeToFieldProtoType(enum enum_field_types type) |
1465 | 711 | { | 1246 | { |
1466 | 712 | switch (type) { | 1247 | switch (type) { |
1467 | 713 | case DRIZZLE_TYPE_LONG: | 1248 | case DRIZZLE_TYPE_LONG: |
1469 | 714 | return message::Table::Field::INTEGER; | 1249 | return Table::Field::INTEGER; |
1470 | 715 | case DRIZZLE_TYPE_DOUBLE: | 1250 | case DRIZZLE_TYPE_DOUBLE: |
1472 | 716 | return message::Table::Field::DOUBLE; | 1251 | return Table::Field::DOUBLE; |
1473 | 717 | case DRIZZLE_TYPE_NULL: | 1252 | case DRIZZLE_TYPE_NULL: |
1474 | 718 | assert(false); /* Not a user definable type */ | 1253 | assert(false); /* Not a user definable type */ |
1476 | 719 | return message::Table::Field::INTEGER; /* unreachable */ | 1254 | return Table::Field::INTEGER; /* unreachable */ |
1477 | 720 | case DRIZZLE_TYPE_TIMESTAMP: | 1255 | case DRIZZLE_TYPE_TIMESTAMP: |
1479 | 721 | return message::Table::Field::TIMESTAMP; | 1256 | return Table::Field::TIMESTAMP; |
1480 | 722 | case DRIZZLE_TYPE_LONGLONG: | 1257 | case DRIZZLE_TYPE_LONGLONG: |
1482 | 723 | return message::Table::Field::BIGINT; | 1258 | return Table::Field::BIGINT; |
1483 | 724 | case DRIZZLE_TYPE_DATETIME: | 1259 | case DRIZZLE_TYPE_DATETIME: |
1485 | 725 | return message::Table::Field::DATETIME; | 1260 | return Table::Field::DATETIME; |
1486 | 726 | case DRIZZLE_TYPE_DATE: | 1261 | case DRIZZLE_TYPE_DATE: |
1488 | 727 | return message::Table::Field::DATE; | 1262 | return Table::Field::DATE; |
1489 | 728 | case DRIZZLE_TYPE_VARCHAR: | 1263 | case DRIZZLE_TYPE_VARCHAR: |
1491 | 729 | return message::Table::Field::VARCHAR; | 1264 | return Table::Field::VARCHAR; |
1492 | 730 | case DRIZZLE_TYPE_DECIMAL: | 1265 | case DRIZZLE_TYPE_DECIMAL: |
1494 | 731 | return message::Table::Field::DECIMAL; | 1266 | return Table::Field::DECIMAL; |
1495 | 732 | case DRIZZLE_TYPE_ENUM: | 1267 | case DRIZZLE_TYPE_ENUM: |
1497 | 733 | return message::Table::Field::ENUM; | 1268 | return Table::Field::ENUM; |
1498 | 734 | case DRIZZLE_TYPE_BLOB: | 1269 | case DRIZZLE_TYPE_BLOB: |
1500 | 735 | return message::Table::Field::BLOB; | 1270 | return Table::Field::BLOB; |
1501 | 736 | } | 1271 | } |
1502 | 737 | 1272 | ||
1503 | 738 | assert(false); | 1273 | assert(false); |
1505 | 739 | return message::Table::Field::INTEGER; /* unreachable */ | 1274 | return Table::Field::INTEGER; /* unreachable */ |
1506 | 740 | } | 1275 | } |
1507 | 741 | 1276 | ||
1508 | 1277 | } /* namespace message */ | ||
1509 | 742 | } /* namespace drizzled */ | 1278 | } /* namespace drizzled */ |
1510 | 743 | 1279 | ||
1511 | === modified file 'drizzled/message/statement_transform.h' | |||
1512 | --- drizzled/message/statement_transform.h 2010-02-08 01:10:03 +0000 | |||
1513 | +++ drizzled/message/statement_transform.h 2010-03-02 21:04:16 +0000 | |||
1514 | @@ -2,10 +2,11 @@ | |||
1515 | 2 | * vim:expandtab:shiftwidth=2:tabstop=2:smarttab: | 2 | * vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
1516 | 3 | * | 3 | * |
1517 | 4 | * Copyright (C) 2009 Sun Microsystems | 4 | * Copyright (C) 2009 Sun Microsystems |
1518 | 5 | * Copyright (c) 2010 Jay Pipes <jayjpipes@gmail.com> | ||
1519 | 5 | * | 6 | * |
1520 | 6 | * Authors: | 7 | * Authors: |
1521 | 7 | * | 8 | * |
1523 | 8 | * Jay Pipes <joinfu@sun.com> | 9 | * Jay Pipes <jaypipes@gmail.com> |
1524 | 9 | * | 10 | * |
1525 | 10 | * This program is free software; you can redistribute it and/or modify | 11 | * This program is free software; you can redistribute it and/or modify |
1526 | 11 | * it under the terms of the GNU General Public License as published by | 12 | * it under the terms of the GNU General Public License as published by |
1527 | @@ -52,7 +53,11 @@ | |||
1528 | 52 | class DeleteHeader; | 53 | class DeleteHeader; |
1529 | 53 | class DeleteData; | 54 | class DeleteData; |
1530 | 54 | class DeleteRecord; | 55 | class DeleteRecord; |
1531 | 56 | class DropTableStatement; | ||
1532 | 57 | class CreateTableStatement; | ||
1533 | 55 | class TruncateTableStatement; | 58 | class TruncateTableStatement; |
1534 | 59 | class CreateSchemaStatement; | ||
1535 | 60 | class DropSchemaStatement; | ||
1536 | 56 | class SetVariableStatement; | 61 | class SetVariableStatement; |
1537 | 57 | 62 | ||
1538 | 58 | /** A Variation of SQL to be output during transformation */ | 63 | /** A Variation of SQL to be output during transformation */ |
1539 | @@ -117,7 +122,7 @@ | |||
1540 | 117 | enum TransformSqlError | 122 | enum TransformSqlError |
1541 | 118 | transformInsertStatementToSql(const InsertHeader &header, | 123 | transformInsertStatementToSql(const InsertHeader &header, |
1542 | 119 | const InsertData &data, | 124 | const InsertData &data, |
1544 | 120 | std::string *destination, | 125 | std::string &destination, |
1545 | 121 | enum TransformSqlVariant sql_variant= DRIZZLE); | 126 | enum TransformSqlVariant sql_variant= DRIZZLE); |
1546 | 122 | 127 | ||
1547 | 123 | /** | 128 | /** |
1548 | @@ -138,7 +143,7 @@ | |||
1549 | 138 | enum TransformSqlError | 143 | enum TransformSqlError |
1550 | 139 | transformInsertRecordToSql(const InsertHeader &header, | 144 | transformInsertRecordToSql(const InsertHeader &header, |
1551 | 140 | const InsertRecord &record, | 145 | const InsertRecord &record, |
1553 | 141 | std::string *destination, | 146 | std::string &destination, |
1554 | 142 | enum TransformSqlVariant sql_variant= DRIZZLE); | 147 | enum TransformSqlVariant sql_variant= DRIZZLE); |
1555 | 143 | 148 | ||
1556 | 144 | /** | 149 | /** |
1557 | @@ -156,7 +161,7 @@ | |||
1558 | 156 | */ | 161 | */ |
1559 | 157 | enum TransformSqlError | 162 | enum TransformSqlError |
1560 | 158 | transformInsertHeaderToSql(const InsertHeader &header, | 163 | transformInsertHeaderToSql(const InsertHeader &header, |
1562 | 159 | std::string *destination, | 164 | std::string &destination, |
1563 | 160 | enum TransformSqlVariant sql_variant= DRIZZLE); | 165 | enum TransformSqlVariant sql_variant= DRIZZLE); |
1564 | 161 | 166 | ||
1565 | 162 | /** | 167 | /** |
1566 | @@ -174,7 +179,7 @@ | |||
1567 | 174 | */ | 179 | */ |
1568 | 175 | enum TransformSqlError | 180 | enum TransformSqlError |
1569 | 176 | transformUpdateHeaderToSql(const UpdateHeader &header, | 181 | transformUpdateHeaderToSql(const UpdateHeader &header, |
1571 | 177 | std::string *destination, | 182 | std::string &destination, |
1572 | 178 | enum TransformSqlVariant sql_variant= DRIZZLE); | 183 | enum TransformSqlVariant sql_variant= DRIZZLE); |
1573 | 179 | 184 | ||
1574 | 180 | /** | 185 | /** |
1575 | @@ -195,7 +200,7 @@ | |||
1576 | 195 | enum TransformSqlError | 200 | enum TransformSqlError |
1577 | 196 | transformUpdateRecordToSql(const UpdateHeader &header, | 201 | transformUpdateRecordToSql(const UpdateHeader &header, |
1578 | 197 | const UpdateRecord &record, | 202 | const UpdateRecord &record, |
1580 | 198 | std::string *destination, | 203 | std::string &destination, |
1581 | 199 | enum TransformSqlVariant sql_variant= DRIZZLE); | 204 | enum TransformSqlVariant sql_variant= DRIZZLE); |
1582 | 200 | 205 | ||
1583 | 201 | /** | 206 | /** |
1584 | @@ -221,7 +226,7 @@ | |||
1585 | 221 | enum TransformSqlError | 226 | enum TransformSqlError |
1586 | 222 | transformDeleteStatementToSql(const DeleteHeader &header, | 227 | transformDeleteStatementToSql(const DeleteHeader &header, |
1587 | 223 | const DeleteData &data, | 228 | const DeleteData &data, |
1589 | 224 | std::string *destination, | 229 | std::string &destination, |
1590 | 225 | enum TransformSqlVariant sql_variant= DRIZZLE); | 230 | enum TransformSqlVariant sql_variant= DRIZZLE); |
1591 | 226 | 231 | ||
1592 | 227 | /** | 232 | /** |
1593 | @@ -242,7 +247,7 @@ | |||
1594 | 242 | enum TransformSqlError | 247 | enum TransformSqlError |
1595 | 243 | transformDeleteRecordToSql(const DeleteHeader &header, | 248 | transformDeleteRecordToSql(const DeleteHeader &header, |
1596 | 244 | const DeleteRecord &record, | 249 | const DeleteRecord &record, |
1598 | 245 | std::string *destination, | 250 | std::string &destination, |
1599 | 246 | enum TransformSqlVariant sql_variant= DRIZZLE); | 251 | enum TransformSqlVariant sql_variant= DRIZZLE); |
1600 | 247 | 252 | ||
1601 | 248 | /** | 253 | /** |
1602 | @@ -260,10 +265,29 @@ | |||
1603 | 260 | */ | 265 | */ |
1604 | 261 | enum TransformSqlError | 266 | enum TransformSqlError |
1605 | 262 | transformDeleteHeaderToSql(const DeleteHeader &header, | 267 | transformDeleteHeaderToSql(const DeleteHeader &header, |
1607 | 263 | std::string *destination, | 268 | std::string &destination, |
1608 | 264 | enum TransformSqlVariant sql_variant= DRIZZLE); | 269 | enum TransformSqlVariant sql_variant= DRIZZLE); |
1609 | 265 | 270 | ||
1610 | 266 | /** | 271 | /** |
1611 | 272 | * This function looks at a supplied DropTableStatement | ||
1612 | 273 | * and constructs a correctly-formatted SQL | ||
1613 | 274 | * statement to the supplied destination string. | ||
1614 | 275 | * | ||
1615 | 276 | * @param DropTableStatement message to transform | ||
1616 | 277 | * @param Destination string to append SQL to | ||
1617 | 278 | * @param Variation of SQL to generate | ||
1618 | 279 | * | ||
1619 | 280 | * @retval | ||
1620 | 281 | * NONE if successful transformation | ||
1621 | 282 | * @retval | ||
1622 | 283 | * Error code (see enum TransformSqlError definition) if failure | ||
1623 | 284 | */ | ||
1624 | 285 | enum TransformSqlError | ||
1625 | 286 | transformDropTableStatementToSql(const DropTableStatement &statement, | ||
1626 | 287 | std::string &destination, | ||
1627 | 288 | enum TransformSqlVariant sql_variant= DRIZZLE); | ||
1628 | 289 | |||
1629 | 290 | /** | ||
1630 | 267 | * This function looks at a supplied TruncateTableStatement | 291 | * This function looks at a supplied TruncateTableStatement |
1631 | 268 | * and constructs a correctly-formatted SQL | 292 | * and constructs a correctly-formatted SQL |
1632 | 269 | * statement to the supplied destination string. | 293 | * statement to the supplied destination string. |
1633 | @@ -279,10 +303,48 @@ | |||
1634 | 279 | */ | 303 | */ |
1635 | 280 | enum TransformSqlError | 304 | enum TransformSqlError |
1636 | 281 | transformTruncateTableStatementToSql(const TruncateTableStatement &statement, | 305 | transformTruncateTableStatementToSql(const TruncateTableStatement &statement, |
1638 | 282 | std::string *destination, | 306 | std::string &destination, |
1639 | 283 | enum TransformSqlVariant sql_variant= DRIZZLE); | 307 | enum TransformSqlVariant sql_variant= DRIZZLE); |
1640 | 284 | 308 | ||
1641 | 285 | /** | 309 | /** |
1642 | 310 | * This function looks at a supplied CreateSchemaStatement | ||
1643 | 311 | * and constructs a correctly-formatted SQL | ||
1644 | 312 | * statement to the supplied destination string. | ||
1645 | 313 | * | ||
1646 | 314 | * @param CreateSchemaStatement message to transform | ||
1647 | 315 | * @param Destination string to append SQL to | ||
1648 | 316 | * @param Variation of SQL to generate | ||
1649 | 317 | * | ||
1650 | 318 | * @retval | ||
1651 | 319 | * NONE if successful transformation | ||
1652 | 320 | * @retval | ||
1653 | 321 | * Error code (see enum TransformSqlError definition) if failure | ||
1654 | 322 | */ | ||
1655 | 323 | enum TransformSqlError | ||
1656 | 324 | transformCreateSchemaStatementToSql(const CreateSchemaStatement &statement, | ||
1657 | 325 | std::string &destination, | ||
1658 | 326 | enum TransformSqlVariant sql_variant= DRIZZLE); | ||
1659 | 327 | |||
1660 | 328 | /** | ||
1661 | 329 | * This function looks at a supplied DropSchemaStatement | ||
1662 | 330 | * and constructs a correctly-formatted SQL | ||
1663 | 331 | * statement to the supplied destination string. | ||
1664 | 332 | * | ||
1665 | 333 | * @param DropSchemaStatement message to transform | ||
1666 | 334 | * @param Destination string to append SQL to | ||
1667 | 335 | * @param Variation of SQL to generate | ||
1668 | 336 | * | ||
1669 | 337 | * @retval | ||
1670 | 338 | * NONE if successful transformation | ||
1671 | 339 | * @retval | ||
1672 | 340 | * Error code (see enum TransformSqlError definition) if failure | ||
1673 | 341 | */ | ||
1674 | 342 | enum TransformSqlError | ||
1675 | 343 | transformDropSchemaStatementToSql(const DropSchemaStatement &statement, | ||
1676 | 344 | std::string &destination, | ||
1677 | 345 | enum TransformSqlVariant sql_variant= DRIZZLE); | ||
1678 | 346 | |||
1679 | 347 | /** | ||
1680 | 286 | * This function looks at a supplied SetVariableStatement | 348 | * This function looks at a supplied SetVariableStatement |
1681 | 287 | * and constructs a correctly-formatted SQL | 349 | * and constructs a correctly-formatted SQL |
1682 | 288 | * statement to the supplied destination string. | 350 | * statement to the supplied destination string. |
1683 | @@ -298,9 +360,95 @@ | |||
1684 | 298 | */ | 360 | */ |
1685 | 299 | enum TransformSqlError | 361 | enum TransformSqlError |
1686 | 300 | transformSetVariableStatementToSql(const SetVariableStatement &statement, | 362 | transformSetVariableStatementToSql(const SetVariableStatement &statement, |
1690 | 301 | std::string *destination, | 363 | std::string &destination, |
1691 | 302 | enum TransformSqlVariant sql_variant= DRIZZLE); | 364 | enum TransformSqlVariant sql_variant= DRIZZLE); |
1692 | 303 | 365 | ||
1693 | 366 | /** | ||
1694 | 367 | * Appends to supplied string an SQL expression | ||
1695 | 368 | * containing the supplied CreateTableStatement's | ||
1696 | 369 | * appropriate CREATE TABLE SQL statement. | ||
1697 | 370 | */ | ||
1698 | 371 | enum TransformSqlError | ||
1699 | 372 | transformCreateTableStatementToSql(const CreateTableStatement &statement, | ||
1700 | 373 | std::string &destination, | ||
1701 | 374 | enum TransformSqlVariant sql_variant= DRIZZLE); | ||
1702 | 375 | |||
1703 | 376 | /** | ||
1704 | 377 | * Appends to the supplied string an SQL expression | ||
1705 | 378 | * representing the table for a CREATE TABLE expression. | ||
1706 | 379 | * | ||
1707 | 380 | * @param[in] Table message | ||
1708 | 381 | * @param[out] String to append to | ||
1709 | 382 | * | ||
1710 | 383 | * @retval | ||
1711 | 384 | * NONE if successful transformation | ||
1712 | 385 | * @retval | ||
1713 | 386 | * Error code (see enum TransformSqlError definition) if failure | ||
1714 | 387 | */ | ||
1715 | 388 | enum TransformSqlError | ||
1716 | 389 | transformTableDefinitionToSql(const Table &table, | ||
1717 | 390 | std::string &destination, | ||
1718 | 391 | enum TransformSqlVariant sql_variant= DRIZZLE); | ||
1719 | 392 | |||
1720 | 393 | /** | ||
1721 | 394 | * Appends to the supplied string an SQL expression | ||
1722 | 395 | * representing the table's optional attributes. | ||
1723 | 396 | * | ||
1724 | 397 | * @note | ||
1725 | 398 | * | ||
1726 | 399 | * This function will eventually be a much simpler | ||
1727 | 400 | * listing of key/value pairs. | ||
1728 | 401 | * | ||
1729 | 402 | * @param[in] TableOptions message | ||
1730 | 403 | * @param[out] String to append to | ||
1731 | 404 | * | ||
1732 | 405 | * @retval | ||
1733 | 406 | * NONE if successful transformation | ||
1734 | 407 | * @retval | ||
1735 | 408 | * Error code (see enum TransformSqlError definition) if failure | ||
1736 | 409 | */ | ||
1737 | 410 | enum TransformSqlError | ||
1738 | 411 | transformTableOptionsToSql(const Table::TableOptions &table_options, | ||
1739 | 412 | std::string &destination, | ||
1740 | 413 | enum TransformSqlVariant sql_variant= DRIZZLE); | ||
1741 | 414 | |||
1742 | 415 | /** | ||
1743 | 416 | * Appends to the supplied string an SQL expression | ||
1744 | 417 | * representing the index's attributes. The built string | ||
1745 | 418 | * corresponds to the SQL in a CREATE INDEX statement. | ||
1746 | 419 | * | ||
1747 | 420 | * @param[in] Index message | ||
1748 | 421 | * @param[in] Table containing this index (used to get field names...) | ||
1749 | 422 | * @param[out] String to append to | ||
1750 | 423 | * | ||
1751 | 424 | * @retval | ||
1752 | 425 | * NONE if successful transformation | ||
1753 | 426 | * @retval | ||
1754 | 427 | * Error code (see enum TransformSqlError definition) if failure | ||
1755 | 428 | */ | ||
1756 | 429 | enum TransformSqlError | ||
1757 | 430 | transformIndexDefinitionToSql(const Table::Index &index, | ||
1758 | 431 | const Table &table, | ||
1759 | 432 | std::string &destination, | ||
1760 | 433 | enum TransformSqlVariant sql_variant= DRIZZLE); | ||
1761 | 434 | |||
1762 | 435 | /** | ||
1763 | 436 | * Appends to the supplied string an SQL expression | ||
1764 | 437 | * representing the field's attributes. The built string | ||
1765 | 438 | * corresponds to the SQL in a CREATE TABLE statement. | ||
1766 | 439 | * | ||
1767 | 440 | * @param[in] Field message | ||
1768 | 441 | * @param[out] String to append to | ||
1769 | 442 | * | ||
1770 | 443 | * @retval | ||
1771 | 444 | * NONE if successful transformation | ||
1772 | 445 | * @retval | ||
1773 | 446 | * Error code (see enum TransformSqlError definition) if failure | ||
1774 | 447 | */ | ||
1775 | 448 | enum TransformSqlError | ||
1776 | 449 | transformFieldDefinitionToSql(const Table::Field &field, | ||
1777 | 450 | std::string &destination, | ||
1778 | 451 | enum TransformSqlVariant sql_variant= DRIZZLE); | ||
1779 | 304 | 452 | ||
1780 | 305 | /** | 453 | /** |
1781 | 306 | * Returns true if the supplied message::Table::Field::FieldType | 454 | * Returns true if the supplied message::Table::Field::FieldType |
1782 | 307 | 455 | ||
1783 | === modified file 'drizzled/message/table.proto' | |||
1784 | --- drizzled/message/table.proto 2010-02-16 01:28:56 +0000 | |||
1785 | +++ drizzled/message/table.proto 2010-03-02 21:04:16 +0000 | |||
1786 | @@ -157,7 +157,7 @@ | |||
1787 | 157 | 157 | ||
1788 | 158 | message IndexPart { | 158 | message IndexPart { |
1789 | 159 | required uint32 fieldnr = 1; | 159 | required uint32 fieldnr = 1; |
1791 | 160 | optional int32 compare_length = 2; | 160 | optional uint32 compare_length = 2; |
1792 | 161 | optional bool in_reverse_order = 3 [default = false]; | 161 | optional bool in_reverse_order = 3 [default = false]; |
1793 | 162 | 162 | ||
1794 | 163 | optional uint32 key_type = 101; /* THIS MUST DIE. Along with pack_flag*/ | 163 | optional uint32 key_type = 101; /* THIS MUST DIE. Along with pack_flag*/ |
1795 | 164 | 164 | ||
1796 | === modified file 'drizzled/message/table_reader.cc' | |||
1797 | --- drizzled/message/table_reader.cc 2010-02-16 01:28:56 +0000 | |||
1798 | +++ drizzled/message/table_reader.cc 2010-03-02 21:04:16 +0000 | |||
1799 | @@ -30,7 +30,7 @@ | |||
1800 | 30 | 30 | ||
1801 | 31 | #include <iostream> | 31 | #include <iostream> |
1802 | 32 | #include <string> | 32 | #include <string> |
1804 | 33 | #include <drizzled/message/table.pb.h> | 33 | #include <drizzled/message/statement_transform.h> |
1805 | 34 | #include <google/protobuf/io/zero_copy_stream.h> | 34 | #include <google/protobuf/io/zero_copy_stream.h> |
1806 | 35 | #include <google/protobuf/io/zero_copy_stream_impl.h> | 35 | #include <google/protobuf/io/zero_copy_stream_impl.h> |
1807 | 36 | 36 | ||
1808 | @@ -42,246 +42,6 @@ | |||
1809 | 42 | Written from Google proto example | 42 | Written from Google proto example |
1810 | 43 | */ | 43 | */ |
1811 | 44 | 44 | ||
1812 | 45 | static void print_field(const message::Table::Field &field) | ||
1813 | 46 | { | ||
1814 | 47 | cout << "\t`" << field.name() << "`"; | ||
1815 | 48 | |||
1816 | 49 | message::Table::Field::FieldType field_type= field.type(); | ||
1817 | 50 | |||
1818 | 51 | switch (field_type) | ||
1819 | 52 | { | ||
1820 | 53 | case message::Table::Field::DOUBLE: | ||
1821 | 54 | cout << " DOUBLE "; | ||
1822 | 55 | break; | ||
1823 | 56 | case message::Table::Field::VARCHAR: | ||
1824 | 57 | cout << " VARCHAR(" << field.string_options().length() << ")"; | ||
1825 | 58 | break; | ||
1826 | 59 | case message::Table::Field::BLOB: | ||
1827 | 60 | cout << " BLOB "; /* FIXME: or text, depends on collation */ | ||
1828 | 61 | if(field.string_options().has_collation_id()) | ||
1829 | 62 | cout << "COLLATION=" << field.string_options().collation_id() << " "; | ||
1830 | 63 | break; | ||
1831 | 64 | case message::Table::Field::ENUM: | ||
1832 | 65 | { | ||
1833 | 66 | int x; | ||
1834 | 67 | |||
1835 | 68 | cout << " ENUM("; | ||
1836 | 69 | for (x= 0; x < field.set_options().field_value_size() ; x++) | ||
1837 | 70 | { | ||
1838 | 71 | const string type= field.set_options().field_value(x); | ||
1839 | 72 | |||
1840 | 73 | if (x != 0) | ||
1841 | 74 | cout << ","; | ||
1842 | 75 | cout << "'" << type << "'"; | ||
1843 | 76 | } | ||
1844 | 77 | cout << ") "; | ||
1845 | 78 | break; | ||
1846 | 79 | } | ||
1847 | 80 | case message::Table::Field::INTEGER: | ||
1848 | 81 | cout << " INT" ; | ||
1849 | 82 | break; | ||
1850 | 83 | case message::Table::Field::BIGINT: | ||
1851 | 84 | cout << " BIGINT "; | ||
1852 | 85 | break; | ||
1853 | 86 | case message::Table::Field::DECIMAL: | ||
1854 | 87 | cout << " DECIMAL(" << field.numeric_options().precision() << "," << field.numeric_options().scale() << ") "; | ||
1855 | 88 | break; | ||
1856 | 89 | case message::Table::Field::DATE: | ||
1857 | 90 | cout << " DATE "; | ||
1858 | 91 | break; | ||
1859 | 92 | case message::Table::Field::TIMESTAMP: | ||
1860 | 93 | cout << " TIMESTAMP "; | ||
1861 | 94 | break; | ||
1862 | 95 | case message::Table::Field::DATETIME: | ||
1863 | 96 | cout << " DATETIME "; | ||
1864 | 97 | break; | ||
1865 | 98 | } | ||
1866 | 99 | |||
1867 | 100 | if (field.type() == message::Table::Field::INTEGER | ||
1868 | 101 | || field.type() == message::Table::Field::BIGINT) | ||
1869 | 102 | { | ||
1870 | 103 | if (field.has_constraints() | ||
1871 | 104 | && field.constraints().has_is_unsigned()) | ||
1872 | 105 | if (field.constraints().is_unsigned()) | ||
1873 | 106 | cout << " UNSIGNED"; | ||
1874 | 107 | |||
1875 | 108 | if (field.has_numeric_options() && | ||
1876 | 109 | field.numeric_options().is_autoincrement()) | ||
1877 | 110 | cout << " AUTOINCREMENT "; | ||
1878 | 111 | } | ||
1879 | 112 | |||
1880 | 113 | if (!( field.has_constraints() | ||
1881 | 114 | && field.constraints().is_nullable())) | ||
1882 | 115 | cout << " NOT NULL "; | ||
1883 | 116 | |||
1884 | 117 | if (field.type() == message::Table::Field::BLOB | ||
1885 | 118 | || field.type() == message::Table::Field::VARCHAR) | ||
1886 | 119 | { | ||
1887 | 120 | if (field.string_options().has_collation()) | ||
1888 | 121 | cout << " COLLATE " << field.string_options().collation(); | ||
1889 | 122 | } | ||
1890 | 123 | |||
1891 | 124 | if (field.options().has_default_value()) | ||
1892 | 125 | cout << " DEFAULT `" << field.options().default_value() << "` " ; | ||
1893 | 126 | |||
1894 | 127 | if (field.options().has_default_bin_value()) | ||
1895 | 128 | { | ||
1896 | 129 | string v= field.options().default_bin_value(); | ||
1897 | 130 | cout << " DEFAULT 0x"; | ||
1898 | 131 | for(unsigned int i=0; i< v.length(); i++) | ||
1899 | 132 | { | ||
1900 | 133 | printf("%.2x", *(v.c_str()+i)); | ||
1901 | 134 | } | ||
1902 | 135 | } | ||
1903 | 136 | |||
1904 | 137 | if (field.type() == message::Table::Field::TIMESTAMP) | ||
1905 | 138 | if (field.timestamp_options().has_auto_updates() | ||
1906 | 139 | && field.timestamp_options().auto_updates()) | ||
1907 | 140 | cout << " ON UPDATE CURRENT_TIMESTAMP"; | ||
1908 | 141 | |||
1909 | 142 | if (field.has_comment()) | ||
1910 | 143 | cout << " COMMENT `" << field.comment() << "` "; | ||
1911 | 144 | } | ||
1912 | 145 | |||
1913 | 146 | static void print_engine(const message::Table::StorageEngine &engine) | ||
1914 | 147 | { | ||
1915 | 148 | int32_t x; | ||
1916 | 149 | |||
1917 | 150 | cout << " ENGINE = " << engine.name() << endl; | ||
1918 | 151 | |||
1919 | 152 | for (x= 0; x < engine.option_size(); ++x) { | ||
1920 | 153 | const message::Table::StorageEngine::EngineOption option= engine.option(x); | ||
1921 | 154 | cout << "\t" << option.option_name() << " = " | ||
1922 | 155 | << option.option_value() << endl; | ||
1923 | 156 | } | ||
1924 | 157 | } | ||
1925 | 158 | |||
1926 | 159 | static void print_index(const message::Table::Index &index) | ||
1927 | 160 | { | ||
1928 | 161 | |||
1929 | 162 | if (index.is_primary()) | ||
1930 | 163 | cout << " PRIMARY"; | ||
1931 | 164 | else if (index.is_unique()) | ||
1932 | 165 | cout << " UNIQUE"; | ||
1933 | 166 | cout << " KEY `" << index.name() << "` ("; | ||
1934 | 167 | { | ||
1935 | 168 | int32_t x; | ||
1936 | 169 | |||
1937 | 170 | for (x= 0; x < index.index_part_size() ; x++) | ||
1938 | 171 | { | ||
1939 | 172 | const message::Table::Index::IndexPart part= index.index_part(x); | ||
1940 | 173 | |||
1941 | 174 | if (x != 0) | ||
1942 | 175 | cout << ","; | ||
1943 | 176 | cout << "`" << part.fieldnr() << "`"; /* FIXME */ | ||
1944 | 177 | if (part.has_compare_length()) | ||
1945 | 178 | cout << "(" << part.compare_length() << ")"; | ||
1946 | 179 | } | ||
1947 | 180 | cout << ")"; | ||
1948 | 181 | } | ||
1949 | 182 | cout << "\t"; | ||
1950 | 183 | } | ||
1951 | 184 | |||
1952 | 185 | static void print_table_options(const message::Table::TableOptions &options) | ||
1953 | 186 | { | ||
1954 | 187 | if (options.has_comment()) | ||
1955 | 188 | cout << " COMMENT = '" << options.comment() << "' " << endl; | ||
1956 | 189 | |||
1957 | 190 | if (options.has_collation()) | ||
1958 | 191 | cout << " COLLATE = '" << options.collation() << "' " << endl; | ||
1959 | 192 | |||
1960 | 193 | if (options.has_auto_increment()) | ||
1961 | 194 | cout << " AUTOINCREMENT_OFFSET = " << options.auto_increment() << endl; | ||
1962 | 195 | |||
1963 | 196 | if (options.has_collation_id()) | ||
1964 | 197 | cout << "-- collation_id = " << options.collation_id() << endl; | ||
1965 | 198 | |||
1966 | 199 | if (options.has_row_type()) | ||
1967 | 200 | cout << " ROW_TYPE = " << options.row_type() << endl; | ||
1968 | 201 | |||
1969 | 202 | if (options.has_data_file_name()) | ||
1970 | 203 | cout << " DATA_FILE_NAME = '" << options.data_file_name() << "'" << endl; | ||
1971 | 204 | |||
1972 | 205 | if (options.has_index_file_name()) | ||
1973 | 206 | cout << " INDEX_FILE_NAME = '" << options.index_file_name() << "'" << endl; | ||
1974 | 207 | |||
1975 | 208 | if (options.has_max_rows()) | ||
1976 | 209 | cout << " MAX_ROWS = " << options.max_rows() << endl; | ||
1977 | 210 | |||
1978 | 211 | if (options.has_min_rows()) | ||
1979 | 212 | cout << " MIN_ROWS = " << options.min_rows() << endl; | ||
1980 | 213 | |||
1981 | 214 | if (options.has_auto_increment_value()) | ||
1982 | 215 | cout << " AUTO_INCREMENT = " << options.auto_increment_value() << endl; | ||
1983 | 216 | |||
1984 | 217 | if (options.has_avg_row_length()) | ||
1985 | 218 | cout << " AVG_ROW_LENGTH = " << options.avg_row_length() << endl; | ||
1986 | 219 | |||
1987 | 220 | if (options.has_key_block_size()) | ||
1988 | 221 | cout << " KEY_BLOCK_SIZE = " << options.key_block_size() << endl; | ||
1989 | 222 | |||
1990 | 223 | if (options.has_block_size()) | ||
1991 | 224 | cout << " BLOCK_SIZE = " << options.block_size() << endl; | ||
1992 | 225 | |||
1993 | 226 | if (options.has_comment()) | ||
1994 | 227 | cout << " COMMENT = '" << options.comment() << "'" << endl; | ||
1995 | 228 | |||
1996 | 229 | if (options.has_pack_keys()) | ||
1997 | 230 | cout << " PACK_KEYS = " << options.pack_keys() << endl; | ||
1998 | 231 | if (options.has_pack_record()) | ||
1999 | 232 | cout << " PACK_RECORD = " << options.pack_record() << endl; | ||
2000 | 233 | if (options.has_checksum()) | ||
2001 | 234 | cout << " CHECKSUM = " << options.checksum() << endl; | ||
2002 | 235 | if (options.has_page_checksum()) | ||
2003 | 236 | cout << " PAGE_CHECKSUM = " << options.page_checksum() << endl; | ||
2004 | 237 | } | ||
2005 | 238 | |||
2006 | 239 | |||
2007 | 240 | static void print_table(const message::Table &table) | ||
2008 | 241 | { | ||
2009 | 242 | int32_t x; | ||
2010 | 243 | |||
2011 | 244 | cout << "CREATE "; | ||
2012 | 245 | |||
2013 | 246 | if (table.type() == message::Table::TEMPORARY) | ||
2014 | 247 | cout << "TEMPORARY "; | ||
2015 | 248 | |||
2016 | 249 | cout << "TABLE `" << table.name() << "` (" << endl; | ||
2017 | 250 | |||
2018 | 251 | for (x= 0; x < table.field_size() ; x++) | ||
2019 | 252 | { | ||
2020 | 253 | const message::Table::Field field = table.field(x); | ||
2021 | 254 | |||
2022 | 255 | if (x != 0) | ||
2023 | 256 | cout << "," << endl; | ||
2024 | 257 | |||
2025 | 258 | print_field(field); | ||
2026 | 259 | } | ||
2027 | 260 | |||
2028 | 261 | for (x= 0; x < table.indexes_size() ; x++) | ||
2029 | 262 | { | ||
2030 | 263 | const message::Table::Index index= table.indexes(x); | ||
2031 | 264 | |||
2032 | 265 | if (x != 0) | ||
2033 | 266 | cout << "," << endl;; | ||
2034 | 267 | |||
2035 | 268 | print_index(index); | ||
2036 | 269 | |||
2037 | 270 | } | ||
2038 | 271 | cout << endl; | ||
2039 | 272 | |||
2040 | 273 | cout << ") " << endl; | ||
2041 | 274 | |||
2042 | 275 | print_engine(table.engine()); | ||
2043 | 276 | |||
2044 | 277 | if (table.has_options()) | ||
2045 | 278 | print_table_options(table.options()); | ||
2046 | 279 | /* | ||
2047 | 280 | if (table->has_stats()) | ||
2048 | 281 | print_table_stats(&table->stats()); | ||
2049 | 282 | */ | ||
2050 | 283 | } | ||
2051 | 284 | |||
2052 | 285 | int main(int argc, char* argv[]) | 45 | int main(int argc, char* argv[]) |
2053 | 286 | { | 46 | { |
2054 | 287 | GOOGLE_PROTOBUF_VERIFY_VERSION; | 47 | GOOGLE_PROTOBUF_VERIFY_VERSION; |
2055 | @@ -315,7 +75,10 @@ | |||
2056 | 315 | close(fd); | 75 | close(fd); |
2057 | 316 | } | 76 | } |
2058 | 317 | 77 | ||
2060 | 318 | print_table(table); | 78 | string output; |
2061 | 79 | (void) message::transformTableDefinitionToSql(table, output); | ||
2062 | 80 | |||
2063 | 81 | cout << output << endl; | ||
2064 | 319 | 82 | ||
2065 | 320 | return 0; | 83 | return 0; |
2066 | 321 | } | 84 | } |
2067 | 322 | 85 | ||
2068 | === modified file 'drizzled/message/transaction.proto' | |||
2069 | --- drizzled/message/transaction.proto 2009-11-03 18:49:13 +0000 | |||
2070 | +++ drizzled/message/transaction.proto 2010-03-02 21:04:16 +0000 | |||
2071 | @@ -499,6 +499,7 @@ | |||
2072 | 499 | message DropTableStatement | 499 | message DropTableStatement |
2073 | 500 | { | 500 | { |
2074 | 501 | required TableMetadata table_metadata = 1; /* Minimal metadata about the table to be dropped */ | 501 | required TableMetadata table_metadata = 1; /* Minimal metadata about the table to be dropped */ |
2075 | 502 | optional bool if_exists_clause = 2; /* Did the user specify an IF EXISTS clause? */ | ||
2076 | 502 | } | 503 | } |
2077 | 503 | 504 | ||
2078 | 504 | /* | 505 | /* |
2079 | 505 | 506 | ||
2080 | === modified file 'drizzled/replication_services.cc' | |||
2081 | --- drizzled/replication_services.cc 2010-02-11 03:49:10 +0000 | |||
2082 | +++ drizzled/replication_services.cc 2010-03-02 21:04:16 +0000 | |||
2083 | @@ -508,7 +508,7 @@ | |||
2084 | 508 | * We add the "key field metadata" -- i.e. the fields which is | 508 | * We add the "key field metadata" -- i.e. the fields which is |
2085 | 509 | * the primary key for the table. | 509 | * the primary key for the table. |
2086 | 510 | */ | 510 | */ |
2088 | 511 | if (in_table->s->primary_key == current_field->field_index) | 511 | if (in_table->s->fieldInPrimaryKey(current_field)) |
2089 | 512 | { | 512 | { |
2090 | 513 | field_metadata= header->add_key_field_metadata(); | 513 | field_metadata= header->add_key_field_metadata(); |
2091 | 514 | field_metadata->set_name(current_field->field_name); | 514 | field_metadata->set_name(current_field->field_name); |
2092 | @@ -602,7 +602,7 @@ | |||
2093 | 602 | * primary key field value. Replication only supports tables | 602 | * primary key field value. Replication only supports tables |
2094 | 603 | * with a primary key. | 603 | * with a primary key. |
2095 | 604 | */ | 604 | */ |
2097 | 605 | if (in_table->s->primary_key == current_field->field_index) | 605 | if (in_table->s->fieldInPrimaryKey(current_field)) |
2098 | 606 | { | 606 | { |
2099 | 607 | /** | 607 | /** |
2100 | 608 | * To say the below is ugly is an understatement. But it works. | 608 | * To say the below is ugly is an understatement. But it works. |
2101 | @@ -682,7 +682,7 @@ | |||
2102 | 682 | * primary key field value. Replication only supports tables | 682 | * primary key field value. Replication only supports tables |
2103 | 683 | * with a primary key. | 683 | * with a primary key. |
2104 | 684 | */ | 684 | */ |
2106 | 685 | if (in_table->s->primary_key == current_field->field_index) | 685 | if (in_table->s->fieldInPrimaryKey(current_field)) |
2107 | 686 | { | 686 | { |
2108 | 687 | field_metadata= header->add_key_field_metadata(); | 687 | field_metadata= header->add_key_field_metadata(); |
2109 | 688 | field_metadata->set_name(current_field->field_name); | 688 | field_metadata->set_name(current_field->field_name); |
2110 | @@ -715,7 +715,7 @@ | |||
2111 | 715 | * primary key field value. Replication only supports tables | 715 | * primary key field value. Replication only supports tables |
2112 | 716 | * with a primary key. | 716 | * with a primary key. |
2113 | 717 | */ | 717 | */ |
2115 | 718 | if (in_table->s->primary_key == current_field->field_index) | 718 | if (in_table->s->fieldInPrimaryKey(current_field)) |
2116 | 719 | { | 719 | { |
2117 | 720 | string_value= current_field->val_str(string_value); | 720 | string_value= current_field->val_str(string_value); |
2118 | 721 | record->add_key_value(string_value->c_ptr(), string_value->length()); | 721 | record->add_key_value(string_value->c_ptr(), string_value->length()); |
2119 | @@ -727,6 +727,126 @@ | |||
2120 | 727 | } | 727 | } |
2121 | 728 | } | 728 | } |
2122 | 729 | 729 | ||
2123 | 730 | void ReplicationServices::createTable(Session *in_session, | ||
2124 | 731 | const message::Table &table) | ||
2125 | 732 | { | ||
2126 | 733 | if (! is_active) | ||
2127 | 734 | return; | ||
2128 | 735 | |||
2129 | 736 | message::Transaction *transaction= getActiveTransaction(in_session); | ||
2130 | 737 | message::Statement *statement= transaction->add_statement(); | ||
2131 | 738 | |||
2132 | 739 | initStatement(*statement, message::Statement::CREATE_TABLE, in_session); | ||
2133 | 740 | |||
2134 | 741 | /* | ||
2135 | 742 | * Construct the specialized CreateTableStatement message and attach | ||
2136 | 743 | * it to the generic Statement message | ||
2137 | 744 | */ | ||
2138 | 745 | message::CreateTableStatement *create_table_statement= statement->mutable_create_table_statement(); | ||
2139 | 746 | message::Table *new_table_message= create_table_statement->mutable_table(); | ||
2140 | 747 | *new_table_message= table; | ||
2141 | 748 | |||
2142 | 749 | finalizeStatement(*statement, in_session); | ||
2143 | 750 | |||
2144 | 751 | finalizeTransaction(*transaction, in_session); | ||
2145 | 752 | |||
2146 | 753 | push(*transaction); | ||
2147 | 754 | |||
2148 | 755 | cleanupTransaction(transaction, in_session); | ||
2149 | 756 | |||
2150 | 757 | } | ||
2151 | 758 | |||
2152 | 759 | void ReplicationServices::createSchema(Session *in_session, | ||
2153 | 760 | const message::Schema &schema) | ||
2154 | 761 | { | ||
2155 | 762 | if (! is_active) | ||
2156 | 763 | return; | ||
2157 | 764 | |||
2158 | 765 | message::Transaction *transaction= getActiveTransaction(in_session); | ||
2159 | 766 | message::Statement *statement= transaction->add_statement(); | ||
2160 | 767 | |||
2161 | 768 | initStatement(*statement, message::Statement::CREATE_SCHEMA, in_session); | ||
2162 | 769 | |||
2163 | 770 | /* | ||
2164 | 771 | * Construct the specialized CreateSchemaStatement message and attach | ||
2165 | 772 | * it to the generic Statement message | ||
2166 | 773 | */ | ||
2167 | 774 | message::CreateSchemaStatement *create_schema_statement= statement->mutable_create_schema_statement(); | ||
2168 | 775 | message::Schema *new_schema_message= create_schema_statement->mutable_schema(); | ||
2169 | 776 | *new_schema_message= schema; | ||
2170 | 777 | |||
2171 | 778 | finalizeStatement(*statement, in_session); | ||
2172 | 779 | |||
2173 | 780 | finalizeTransaction(*transaction, in_session); | ||
2174 | 781 | |||
2175 | 782 | push(*transaction); | ||
2176 | 783 | |||
2177 | 784 | cleanupTransaction(transaction, in_session); | ||
2178 | 785 | |||
2179 | 786 | } | ||
2180 | 787 | |||
2181 | 788 | void ReplicationServices::dropSchema(Session *in_session, const string &schema_name) | ||
2182 | 789 | { | ||
2183 | 790 | if (! is_active) | ||
2184 | 791 | return; | ||
2185 | 792 | |||
2186 | 793 | message::Transaction *transaction= getActiveTransaction(in_session); | ||
2187 | 794 | message::Statement *statement= transaction->add_statement(); | ||
2188 | 795 | |||
2189 | 796 | initStatement(*statement, message::Statement::DROP_SCHEMA, in_session); | ||
2190 | 797 | |||
2191 | 798 | /* | ||
2192 | 799 | * Construct the specialized DropSchemaStatement message and attach | ||
2193 | 800 | * it to the generic Statement message | ||
2194 | 801 | */ | ||
2195 | 802 | message::DropSchemaStatement *drop_schema_statement= statement->mutable_drop_schema_statement(); | ||
2196 | 803 | |||
2197 | 804 | drop_schema_statement->set_schema_name(schema_name); | ||
2198 | 805 | |||
2199 | 806 | finalizeStatement(*statement, in_session); | ||
2200 | 807 | |||
2201 | 808 | finalizeTransaction(*transaction, in_session); | ||
2202 | 809 | |||
2203 | 810 | push(*transaction); | ||
2204 | 811 | |||
2205 | 812 | cleanupTransaction(transaction, in_session); | ||
2206 | 813 | } | ||
2207 | 814 | |||
2208 | 815 | void ReplicationServices::dropTable(Session *in_session, | ||
2209 | 816 | const string &schema_name, | ||
2210 | 817 | const string &table_name, | ||
2211 | 818 | bool if_exists) | ||
2212 | 819 | { | ||
2213 | 820 | if (! is_active) | ||
2214 | 821 | return; | ||
2215 | 822 | |||
2216 | 823 | message::Transaction *transaction= getActiveTransaction(in_session); | ||
2217 | 824 | message::Statement *statement= transaction->add_statement(); | ||
2218 | 825 | |||
2219 | 826 | initStatement(*statement, message::Statement::DROP_TABLE, in_session); | ||
2220 | 827 | |||
2221 | 828 | /* | ||
2222 | 829 | * Construct the specialized DropTableStatement message and attach | ||
2223 | 830 | * it to the generic Statement message | ||
2224 | 831 | */ | ||
2225 | 832 | message::DropTableStatement *drop_table_statement= statement->mutable_drop_table_statement(); | ||
2226 | 833 | |||
2227 | 834 | drop_table_statement->set_if_exists_clause(if_exists); | ||
2228 | 835 | |||
2229 | 836 | message::TableMetadata *table_metadata= drop_table_statement->mutable_table_metadata(); | ||
2230 | 837 | |||
2231 | 838 | table_metadata->set_schema_name(schema_name); | ||
2232 | 839 | table_metadata->set_table_name(table_name); | ||
2233 | 840 | |||
2234 | 841 | finalizeStatement(*statement, in_session); | ||
2235 | 842 | |||
2236 | 843 | finalizeTransaction(*transaction, in_session); | ||
2237 | 844 | |||
2238 | 845 | push(*transaction); | ||
2239 | 846 | |||
2240 | 847 | cleanupTransaction(transaction, in_session); | ||
2241 | 848 | } | ||
2242 | 849 | |||
2243 | 730 | void ReplicationServices::truncateTable(Session *in_session, Table *in_table) | 850 | void ReplicationServices::truncateTable(Session *in_session, Table *in_table) |
2244 | 731 | { | 851 | { |
2245 | 732 | if (! is_active) | 852 | if (! is_active) |
2246 | 733 | 853 | ||
2247 | === modified file 'drizzled/replication_services.h' | |||
2248 | --- drizzled/replication_services.h 2010-02-11 03:29:52 +0000 | |||
2249 | +++ drizzled/replication_services.h 2010-03-02 21:04:16 +0000 | |||
2250 | @@ -2,10 +2,11 @@ | |||
2251 | 2 | * vim:expandtab:shiftwidth=2:tabstop=2:smarttab: | 2 | * vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
2252 | 3 | * | 3 | * |
2253 | 4 | * Copyright (C) 2008-2009 Sun Microsystems | 4 | * Copyright (C) 2008-2009 Sun Microsystems |
2254 | 5 | * Copyright (c) 2009-2010 Jay Pipes <jaypipes@gmail.com> | ||
2255 | 5 | * | 6 | * |
2256 | 6 | * Authors: | 7 | * Authors: |
2257 | 7 | * | 8 | * |
2259 | 8 | * Jay Pipes <joinfu@sun.com> | 9 | * Jay Pipes <jaypipes@gmail.com> |
2260 | 9 | * | 10 | * |
2261 | 10 | * This program is free software; you can redistribute it and/or modify | 11 | * This program is free software; you can redistribute it and/or modify |
2262 | 11 | * it under the terms of the GNU General Public License as published by | 12 | * it under the terms of the GNU General Public License as published by |
2263 | @@ -30,7 +31,6 @@ | |||
2264 | 30 | 31 | ||
2265 | 31 | #include <vector> | 32 | #include <vector> |
2266 | 32 | 33 | ||
2267 | 33 | |||
2268 | 34 | namespace drizzled | 34 | namespace drizzled |
2269 | 35 | { | 35 | { |
2270 | 36 | 36 | ||
2271 | @@ -323,7 +323,48 @@ | |||
2272 | 323 | */ | 323 | */ |
2273 | 324 | void deleteRecord(Session *in_session, Table *in_table); | 324 | void deleteRecord(Session *in_session, Table *in_table); |
2274 | 325 | /** | 325 | /** |
2276 | 326 | * Creates a TruncateTable Statement GPB message and add it | 326 | * Creates a CreateSchema Statement GPB message and adds it |
2277 | 327 | * to the Session's active Transaction GPB message for pushing | ||
2278 | 328 | * out to the replicator streams. | ||
2279 | 329 | * | ||
2280 | 330 | * @param[in] Pointer to the Session which issued the statement | ||
2281 | 331 | * @param[in] message::Schema message describing new schema | ||
2282 | 332 | */ | ||
2283 | 333 | void createSchema(Session *in_session, const message::Schema &schema); | ||
2284 | 334 | /** | ||
2285 | 335 | * Creates a DropSchema Statement GPB message and adds it | ||
2286 | 336 | * to the Session's active Transaction GPB message for pushing | ||
2287 | 337 | * out to the replicator streams. | ||
2288 | 338 | * | ||
2289 | 339 | * @param[in] Pointer to the Session which issued the statement | ||
2290 | 340 | * @param[in] message::Schema message describing new schema | ||
2291 | 341 | */ | ||
2292 | 342 | void dropSchema(Session *in_session, const std::string &schema_name); | ||
2293 | 343 | /** | ||
2294 | 344 | * Creates a CreateTable Statement GPB message and adds it | ||
2295 | 345 | * to the Session's active Transaction GPB message for pushing | ||
2296 | 346 | * out to the replicator streams. | ||
2297 | 347 | * | ||
2298 | 348 | * @param[in] Pointer to the Session which issued the statement | ||
2299 | 349 | * @param[in] message::Table message describing new schema | ||
2300 | 350 | */ | ||
2301 | 351 | void createTable(Session *in_session, const message::Table &table); | ||
2302 | 352 | /** | ||
2303 | 353 | * Creates a DropTable Statement GPB message and adds it | ||
2304 | 354 | * to the Session's active Transaction GPB message for pushing | ||
2305 | 355 | * out to the replicator streams. | ||
2306 | 356 | * | ||
2307 | 357 | * @param[in] Pointer to the Session which issued the statement | ||
2308 | 358 | * @param[in] The schema of the table being dropped | ||
2309 | 359 | * @param[in] The table name of the table being dropped | ||
2310 | 360 | * @param[in] Did the user specify an IF EXISTS clause? | ||
2311 | 361 | */ | ||
2312 | 362 | void dropTable(Session *in_session, | ||
2313 | 363 | const std::string &schema_name, | ||
2314 | 364 | const std::string &table_name, | ||
2315 | 365 | bool if_exists); | ||
2316 | 366 | /** | ||
2317 | 367 | * Creates a TruncateTable Statement GPB message and adds it | ||
2318 | 327 | * to the Session's active Transaction GPB message for pushing | 368 | * to the Session's active Transaction GPB message for pushing |
2319 | 328 | * out to the replicator streams. | 369 | * out to the replicator streams. |
2320 | 329 | * | 370 | * |
2321 | 330 | 371 | ||
2322 | === modified file 'drizzled/sql_insert.cc' | |||
2323 | --- drizzled/sql_insert.cc 2010-02-14 20:26:43 +0000 | |||
2324 | +++ drizzled/sql_insert.cc 2010-03-02 21:04:16 +0000 | |||
2325 | @@ -1615,32 +1615,17 @@ | |||
2326 | 1615 | 1615 | ||
2327 | 1616 | DRIZZLE_LOCK *extra_lock= NULL; | 1616 | DRIZZLE_LOCK *extra_lock= NULL; |
2328 | 1617 | /* | 1617 | /* |
2345 | 1618 | For row-based replication, the CREATE-SELECT statement is written | 1618 | For replication, the CREATE-SELECT statement is written |
2346 | 1619 | in two pieces: the first one contain the CREATE TABLE statement | 1619 | in two pieces: the first transaction messsage contains |
2347 | 1620 | necessary to create the table and the second part contain the rows | 1620 | the CREATE TABLE statement as a CreateTableStatement message |
2348 | 1621 | that should go into the table. | 1621 | necessary to create the table. |
2349 | 1622 | 1622 | ||
2350 | 1623 | For non-temporary tables, the start of the CREATE-SELECT | 1623 | The second transaction message contains all the InsertStatement |
2351 | 1624 | implicitly commits the previous transaction, and all events | 1624 | and associated InsertRecords that should go into the table. |
2336 | 1625 | forming the statement will be stored the transaction cache. At end | ||
2337 | 1626 | of the statement, the entire statement is committed as a | ||
2338 | 1627 | transaction, and all events are written to the binary log. | ||
2339 | 1628 | |||
2340 | 1629 | On the master, the table is locked for the duration of the | ||
2341 | 1630 | statement, but since the CREATE part is replicated as a simple | ||
2342 | 1631 | statement, there is no way to lock the table for accesses on the | ||
2343 | 1632 | slave. Hence, we have to hold on to the CREATE part of the | ||
2344 | 1633 | statement until the statement has finished. | ||
2352 | 1634 | */ | 1625 | */ |
2353 | 1635 | 1626 | ||
2354 | 1636 | unit= u; | 1627 | unit= u; |
2355 | 1637 | 1628 | ||
2356 | 1638 | /* | ||
2357 | 1639 | Start a statement transaction before the create if we are using | ||
2358 | 1640 | row-based replication for the statement. If we are creating a | ||
2359 | 1641 | temporary table, we need to start a statement transaction. | ||
2360 | 1642 | */ | ||
2361 | 1643 | |||
2362 | 1644 | if (!(table= create_table_from_items(session, create_info, create_table, | 1629 | if (!(table= create_table_from_items(session, create_info, create_table, |
2363 | 1645 | table_proto, | 1630 | table_proto, |
2364 | 1646 | alter_info, &values, | 1631 | alter_info, &values, |
2365 | 1647 | 1632 | ||
2366 | === modified file 'drizzled/sql_table.cc' | |||
2367 | --- drizzled/sql_table.cc 2010-03-02 02:17:49 +0000 | |||
2368 | +++ drizzled/sql_table.cc 2010-03-02 21:04:16 +0000 | |||
2369 | @@ -54,6 +54,7 @@ | |||
2370 | 54 | namespace drizzled | 54 | namespace drizzled |
2371 | 55 | { | 55 | { |
2372 | 56 | 56 | ||
2373 | 57 | extern plugin::StorageEngine *myisam_engine; | ||
2374 | 57 | extern pid_t current_pid; | 58 | extern pid_t current_pid; |
2375 | 58 | 59 | ||
2376 | 59 | bool is_primary_key(KEY *key_info) | 60 | bool is_primary_key(KEY *key_info) |
2377 | @@ -249,7 +250,7 @@ | |||
2378 | 249 | 250 | ||
2379 | 250 | if ((error == ENOENT || error == HA_ERR_NO_SUCH_TABLE) && if_exists) | 251 | if ((error == ENOENT || error == HA_ERR_NO_SUCH_TABLE) && if_exists) |
2380 | 251 | { | 252 | { |
2382 | 252 | error= 0; | 253 | error= 0; |
2383 | 253 | session->clear_error(); | 254 | session->clear_error(); |
2384 | 254 | } | 255 | } |
2385 | 255 | 256 | ||
2386 | @@ -261,7 +262,10 @@ | |||
2387 | 261 | } | 262 | } |
2388 | 262 | 263 | ||
2389 | 263 | if (error == 0 || (if_exists && foreign_key_error == false)) | 264 | if (error == 0 || (if_exists && foreign_key_error == false)) |
2391 | 264 | write_bin_log_drop_table(session, if_exists, db, table->table_name); | 265 | { |
2392 | 266 | ReplicationServices &replication_services= ReplicationServices::singleton(); | ||
2393 | 267 | replication_services.dropTable(session, string(db), string(table->table_name), if_exists); | ||
2394 | 268 | } | ||
2395 | 265 | 269 | ||
2396 | 266 | if (error) | 270 | if (error) |
2397 | 267 | { | 271 | { |
2398 | @@ -757,9 +761,11 @@ | |||
2399 | 757 | } | 761 | } |
2400 | 758 | } | 762 | } |
2401 | 759 | } | 763 | } |
2405 | 760 | /* Don't pack rows in old tables if the user has requested this */ | 764 | |
2406 | 761 | if ((sql_field->flags & BLOB_FLAG) || | 765 | /** @todo Get rid of this MyISAM-specific crap. */ |
2407 | 762 | (sql_field->sql_type == DRIZZLE_TYPE_VARCHAR && create_info->row_type != ROW_TYPE_FIXED)) | 766 | if (create_info->db_type == myisam_engine && |
2408 | 767 | ((sql_field->flags & BLOB_FLAG) || | ||
2409 | 768 | (sql_field->sql_type == DRIZZLE_TYPE_VARCHAR && create_info->row_type != ROW_TYPE_FIXED))) | ||
2410 | 763 | (*db_options)|= HA_OPTION_PACK_RECORD; | 769 | (*db_options)|= HA_OPTION_PACK_RECORD; |
2411 | 764 | it2.rewind(); | 770 | it2.rewind(); |
2412 | 765 | } | 771 | } |
2413 | @@ -1451,15 +1457,11 @@ | |||
2414 | 1451 | } | 1457 | } |
2415 | 1452 | } | 1458 | } |
2416 | 1453 | 1459 | ||
2417 | 1454 | /* | ||
2418 | 1455 | Don't write statement if: | ||
2419 | 1456 | - It is an internal temporary table, | ||
2420 | 1457 | - Row-based logging is used and it we are creating a temporary table, or | ||
2421 | 1458 | - The binary log is not open. | ||
2422 | 1459 | Otherwise, the statement shall be binlogged. | ||
2423 | 1460 | */ | ||
2424 | 1461 | if (not internal_tmp_table && not lex_identified_temp_table) | 1460 | if (not internal_tmp_table && not lex_identified_temp_table) |
2426 | 1462 | write_bin_log(session, session->query.c_str()); | 1461 | { |
2427 | 1462 | ReplicationServices &replication_services= ReplicationServices::singleton(); | ||
2428 | 1463 | replication_services.createTable(session, *table_proto); | ||
2429 | 1464 | } | ||
2430 | 1463 | error= false; | 1465 | error= false; |
2431 | 1464 | unlock_and_end: | 1466 | unlock_and_end: |
2432 | 1465 | pthread_mutex_unlock(&LOCK_open); | 1467 | pthread_mutex_unlock(&LOCK_open); |
2433 | 1466 | 1468 | ||
2434 | === modified file 'drizzled/table_proto_write.cc' | |||
2435 | --- drizzled/table_proto_write.cc 2010-02-24 00:18:38 +0000 | |||
2436 | +++ drizzled/table_proto_write.cc 2010-03-02 21:04:16 +0000 | |||
2437 | @@ -309,7 +309,7 @@ | |||
2438 | 309 | switch(create_info->row_type) | 309 | switch(create_info->row_type) |
2439 | 310 | { | 310 | { |
2440 | 311 | case ROW_TYPE_DEFAULT: | 311 | case ROW_TYPE_DEFAULT: |
2442 | 312 | table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_DEFAULT); | 312 | /* No use setting a default row type... just adds redundant info to message */ |
2443 | 313 | break; | 313 | break; |
2444 | 314 | case ROW_TYPE_FIXED: | 314 | case ROW_TYPE_FIXED: |
2445 | 315 | table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_FIXED); | 315 | table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_FIXED); |
2446 | @@ -333,8 +333,8 @@ | |||
2447 | 333 | abort(); | 333 | abort(); |
2448 | 334 | } | 334 | } |
2449 | 335 | 335 | ||
2452 | 336 | table_options->set_pack_record(create_info->table_options | 336 | if (create_info->table_options & HA_OPTION_PACK_RECORD) |
2453 | 337 | & HA_OPTION_PACK_RECORD); | 337 | table_options->set_pack_record(true); |
2454 | 338 | 338 | ||
2455 | 339 | if (table_options->has_comment()) | 339 | if (table_options->has_comment()) |
2456 | 340 | { | 340 | { |
2457 | @@ -447,7 +447,10 @@ | |||
2458 | 447 | 447 | ||
2459 | 448 | idx->set_comment(key_info[i].comment.str); | 448 | idx->set_comment(key_info[i].comment.str); |
2460 | 449 | } | 449 | } |
2462 | 450 | if(key_info[i].flags & ~(HA_NOSAME | HA_PACK_KEY | HA_USES_BLOCK_SIZE | HA_BINARY_PACK_KEY | HA_VAR_LENGTH_PART | HA_NULL_PART_KEY | HA_KEY_HAS_PART_KEY_SEG | HA_GENERATED_KEY | HA_USES_COMMENT)) | 450 | if (key_info[i].flags & |
2463 | 451 | ~(HA_NOSAME | HA_PACK_KEY | HA_USES_BLOCK_SIZE | | ||
2464 | 452 | HA_BINARY_PACK_KEY | HA_VAR_LENGTH_PART | HA_NULL_PART_KEY | | ||
2465 | 453 | HA_KEY_HAS_PART_KEY_SEG | HA_GENERATED_KEY | HA_USES_COMMENT)) | ||
2466 | 451 | abort(); // Invalid (unknown) index flag. | 454 | abort(); // Invalid (unknown) index flag. |
2467 | 452 | 455 | ||
2468 | 453 | for(unsigned int j=0; j< key_info[i].key_parts; j++) | 456 | for(unsigned int j=0; j< key_info[i].key_parts; j++) |
2469 | 454 | 457 | ||
2470 | === modified file 'drizzled/table_share.cc' | |||
2471 | --- drizzled/table_share.cc 2010-02-04 08:14:46 +0000 | |||
2472 | +++ drizzled/table_share.cc 2010-03-02 21:04:16 +0000 | |||
2473 | @@ -273,4 +273,31 @@ | |||
2474 | 273 | } | 273 | } |
2475 | 274 | } | 274 | } |
2476 | 275 | 275 | ||
2477 | 276 | /** | ||
2478 | 277 | * @todo | ||
2479 | 278 | * | ||
2480 | 279 | * Precache this stuff.... | ||
2481 | 280 | */ | ||
2482 | 281 | bool TableShare::fieldInPrimaryKey(Field *in_field) const | ||
2483 | 282 | { | ||
2484 | 283 | assert(table_proto != NULL); | ||
2485 | 284 | |||
2486 | 285 | size_t num_indexes= table_proto->indexes_size(); | ||
2487 | 286 | |||
2488 | 287 | for (size_t x= 0; x < num_indexes; ++x) | ||
2489 | 288 | { | ||
2490 | 289 | const message::Table::Index &index= table_proto->indexes(x); | ||
2491 | 290 | if (index.is_primary()) | ||
2492 | 291 | { | ||
2493 | 292 | size_t num_parts= index.index_part_size(); | ||
2494 | 293 | for (size_t y= 0; y < num_parts; ++y) | ||
2495 | 294 | { | ||
2496 | 295 | if (index.index_part(y).fieldnr() == in_field->field_index) | ||
2497 | 296 | return true; | ||
2498 | 297 | } | ||
2499 | 298 | } | ||
2500 | 299 | } | ||
2501 | 300 | return false; | ||
2502 | 301 | } | ||
2503 | 302 | |||
2504 | 276 | } /* namespace drizzled */ | 303 | } /* namespace drizzled */ |
2505 | 277 | 304 | ||
2506 | === modified file 'drizzled/table_share.h' | |||
2507 | --- drizzled/table_share.h 2010-02-23 01:14:53 +0000 | |||
2508 | +++ drizzled/table_share.h 2010-03-02 21:04:16 +0000 | |||
2509 | @@ -260,6 +260,12 @@ | |||
2510 | 260 | max_rows= arg; | 260 | max_rows= arg; |
2511 | 261 | } | 261 | } |
2512 | 262 | 262 | ||
2513 | 263 | /** | ||
2514 | 264 | * Returns true if the supplied Field object | ||
2515 | 265 | * is part of the table's primary key. | ||
2516 | 266 | */ | ||
2517 | 267 | bool fieldInPrimaryKey(Field *field) const; | ||
2518 | 268 | |||
2519 | 263 | plugin::StorageEngine *storage_engine; /* storage engine plugin */ | 269 | plugin::StorageEngine *storage_engine; /* storage engine plugin */ |
2520 | 264 | inline plugin::StorageEngine *db_type() const /* table_type for handler */ | 270 | inline plugin::StorageEngine *db_type() const /* table_type for handler */ |
2521 | 265 | { | 271 | { |
2522 | 266 | 272 | ||
2523 | === modified file 'plugin/transaction_log/tests/r/alter.result' | |||
2524 | --- plugin/transaction_log/tests/r/alter.result 2009-12-23 14:24:22 +0000 | |||
2525 | +++ plugin/transaction_log/tests/r/alter.result 2010-03-02 21:04:16 +0000 | |||
2526 | @@ -10,10 +10,10 @@ | |||
2527 | 10 | ALTER TABLE t1 ADD INDEX ix_padding (padding(20)); | 10 | ALTER TABLE t1 ADD INDEX ix_padding (padding(20)); |
2528 | 11 | DROP TABLE t1; | 11 | DROP TABLE t1; |
2529 | 12 | START TRANSACTION; | 12 | START TRANSACTION; |
2531 | 13 | DROP TABLE IF EXISTS `t1`; | 13 | DROP TABLE IF EXISTS `test`.`t1`; |
2532 | 14 | COMMIT; | 14 | COMMIT; |
2533 | 15 | START TRANSACTION; | 15 | START TRANSACTION; |
2535 | 16 | CREATE TABLE t1 ( id INT NOT NULL , padding VARCHAR(200) NOT NULL , PRIMARY KEY (id) ); | 16 | CREATE TABLE `t1` ( `id` INT NOT NULL, `padding` VARCHAR(200) NOT NULL COLLATE utf8_general_ci, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
2536 | 17 | COMMIT; | 17 | COMMIT; |
2537 | 18 | START TRANSACTION; | 18 | START TRANSACTION; |
2538 | 19 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); | 19 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); |
2539 | @@ -28,6 +28,6 @@ | |||
2540 | 28 | ALTER TABLE t1 ADD INDEX ix_padding (padding(20)); | 28 | ALTER TABLE t1 ADD INDEX ix_padding (padding(20)); |
2541 | 29 | COMMIT; | 29 | COMMIT; |
2542 | 30 | START TRANSACTION; | 30 | START TRANSACTION; |
2544 | 31 | DROP TABLE `t1`; | 31 | DROP TABLE `test`.`t1`; |
2545 | 32 | COMMIT; | 32 | COMMIT; |
2546 | 33 | SET GLOBAL transaction_log_truncate_debug= true; | 33 | SET GLOBAL transaction_log_truncate_debug= true; |
2547 | 34 | 34 | ||
2548 | === modified file 'plugin/transaction_log/tests/r/auto_commit.result' | |||
2549 | --- plugin/transaction_log/tests/r/auto_commit.result 2009-12-23 14:24:22 +0000 | |||
2550 | +++ plugin/transaction_log/tests/r/auto_commit.result 2010-03-02 21:04:16 +0000 | |||
2551 | @@ -16,28 +16,28 @@ | |||
2552 | 16 | INSERT INTO t1 VALUES (2, "I hate testing."); | 16 | INSERT INTO t1 VALUES (2, "I hate testing."); |
2553 | 17 | DROP TABLE t1; | 17 | DROP TABLE t1; |
2554 | 18 | START TRANSACTION; | 18 | START TRANSACTION; |
2578 | 19 | DROP TABLE IF EXISTS `t1`; | 19 | DROP TABLE IF EXISTS `test`.`t1`; |
2579 | 20 | COMMIT; | 20 | COMMIT; |
2580 | 21 | START TRANSACTION; | 21 | START TRANSACTION; |
2581 | 22 | CREATE TABLE t1 ( id INT NOT NULL PRIMARY KEY , padding VARCHAR(200) NOT NULL ); | 22 | CREATE TABLE `t1` ( `id` INT NOT NULL, `padding` VARCHAR(200) NOT NULL COLLATE utf8_general_ci, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
2582 | 23 | COMMIT; | 23 | COMMIT; |
2583 | 24 | START TRANSACTION; | 24 | START TRANSACTION; |
2584 | 25 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); | 25 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); |
2585 | 26 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (2,'I hate testing.'); | 26 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (2,'I hate testing.'); |
2586 | 27 | COMMIT; | 27 | COMMIT; |
2587 | 28 | START TRANSACTION; | 28 | START TRANSACTION; |
2588 | 29 | DROP TABLE `t1`; | 29 | DROP TABLE `test`.`t1`; |
2589 | 30 | COMMIT; | 30 | COMMIT; |
2590 | 31 | START TRANSACTION; | 31 | START TRANSACTION; |
2591 | 32 | CREATE TABLE t1 ( id INT NOT NULL PRIMARY KEY , padding VARCHAR(200) NOT NULL ); | 32 | CREATE TABLE `t1` ( `id` INT NOT NULL, `padding` VARCHAR(200) NOT NULL COLLATE utf8_general_ci, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
2592 | 33 | COMMIT; | 33 | COMMIT; |
2593 | 34 | START TRANSACTION; | 34 | START TRANSACTION; |
2594 | 35 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); | 35 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); |
2595 | 36 | COMMIT; | 36 | COMMIT; |
2596 | 37 | START TRANSACTION; | 37 | START TRANSACTION; |
2597 | 38 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (2,'I hate testing.'); | 38 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (2,'I hate testing.'); |
2598 | 39 | COMMIT; | 39 | COMMIT; |
2599 | 40 | START TRANSACTION; | 40 | START TRANSACTION; |
2600 | 41 | DROP TABLE `t1`; | 41 | DROP TABLE `test`.`t1`; |
2601 | 42 | COMMIT; | 42 | COMMIT; |
2602 | 43 | SET GLOBAL transaction_log_truncate_debug= true; | 43 | SET GLOBAL transaction_log_truncate_debug= true; |
2603 | 44 | 44 | ||
2604 | === modified file 'plugin/transaction_log/tests/r/blob.result' | |||
2605 | --- plugin/transaction_log/tests/r/blob.result 2009-12-23 14:24:22 +0000 | |||
2606 | +++ plugin/transaction_log/tests/r/blob.result 2010-03-02 21:04:16 +0000 | |||
2607 | @@ -10,10 +10,10 @@ | |||
2608 | 10 | DELETE FROM t1 WHERE padding = 'test\0you'; | 10 | DELETE FROM t1 WHERE padding = 'test\0you'; |
2609 | 11 | DROP TABLE t1; | 11 | DROP TABLE t1; |
2610 | 12 | START TRANSACTION; | 12 | START TRANSACTION; |
2612 | 13 | DROP TABLE IF EXISTS `t1`; | 13 | DROP TABLE IF EXISTS `test`.`t1`; |
2613 | 14 | COMMIT; | 14 | COMMIT; |
2614 | 15 | START TRANSACTION; | 15 | START TRANSACTION; |
2616 | 16 | CREATE TABLE t1 ( id INT NOT NULL , padding BLOB NOT NULL , PRIMARY KEY (id) ); | 16 | CREATE TABLE `t1` ( `id` INT NOT NULL, `padding` BLOB NOT NULL COLLATE binary, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
2617 | 17 | COMMIT; | 17 | COMMIT; |
2618 | 18 | START TRANSACTION; | 18 | START TRANSACTION; |
2619 | 19 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'test\0me'); | 19 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'test\0me'); |
2620 | @@ -29,6 +29,6 @@ | |||
2621 | 29 | DELETE FROM `test`.`t1` WHERE `id`=2; | 29 | DELETE FROM `test`.`t1` WHERE `id`=2; |
2622 | 30 | COMMIT; | 30 | COMMIT; |
2623 | 31 | START TRANSACTION; | 31 | START TRANSACTION; |
2625 | 32 | DROP TABLE `t1`; | 32 | DROP TABLE `test`.`t1`; |
2626 | 33 | COMMIT; | 33 | COMMIT; |
2627 | 34 | SET GLOBAL transaction_log_truncate_debug= true; | 34 | SET GLOBAL transaction_log_truncate_debug= true; |
2628 | 35 | 35 | ||
2629 | === added file 'plugin/transaction_log/tests/r/create_schema.result' | |||
2630 | --- plugin/transaction_log/tests/r/create_schema.result 1970-01-01 00:00:00 +0000 | |||
2631 | +++ plugin/transaction_log/tests/r/create_schema.result 2010-03-02 21:04:16 +0000 | |||
2632 | @@ -0,0 +1,13 @@ | |||
2633 | 1 | DROP SCHEMA IF EXISTS my_new_schema; | ||
2634 | 2 | CREATE SCHEMA my_new_warnings; | ||
2635 | 3 | DROP SCHEMA my_new_warnings; | ||
2636 | 4 | START TRANSACTION; | ||
2637 | 5 | DROP SCHEMA IF EXISTS my_new_schema; | ||
2638 | 6 | COMMIT; | ||
2639 | 7 | START TRANSACTION; | ||
2640 | 8 | CREATE SCHEMA `my_new_warnings` COLLATE utf8_general_ci; | ||
2641 | 9 | COMMIT; | ||
2642 | 10 | START TRANSACTION; | ||
2643 | 11 | DROP SCHEMA my_new_warnings; | ||
2644 | 12 | COMMIT; | ||
2645 | 13 | SET GLOBAL transaction_log_truncate_debug= true; | ||
2646 | 0 | 14 | ||
2647 | === modified file 'plugin/transaction_log/tests/r/create_select.result' | |||
2648 | --- plugin/transaction_log/tests/r/create_select.result 2009-12-23 14:24:22 +0000 | |||
2649 | +++ plugin/transaction_log/tests/r/create_select.result 2010-03-02 21:04:16 +0000 | |||
2650 | @@ -12,13 +12,13 @@ | |||
2651 | 12 | ) SELECT * FROM t1; | 12 | ) SELECT * FROM t1; |
2652 | 13 | DROP TABLE t1, t2; | 13 | DROP TABLE t1, t2; |
2653 | 14 | START TRANSACTION; | 14 | START TRANSACTION; |
2661 | 15 | DROP TABLE IF EXISTS `t1`; | 15 | DROP TABLE IF EXISTS `test`.`t1`; |
2662 | 16 | COMMIT; | 16 | COMMIT; |
2663 | 17 | START TRANSACTION; | 17 | START TRANSACTION; |
2664 | 18 | DROP TABLE IF EXISTS `t2`; | 18 | DROP TABLE IF EXISTS `test`.`t2`; |
2665 | 19 | COMMIT; | 19 | COMMIT; |
2666 | 20 | START TRANSACTION; | 20 | START TRANSACTION; |
2667 | 21 | CREATE TABLE t1 ( id INT NOT NULL PRIMARY KEY , padding VARCHAR(200) NOT NULL ); | 21 | CREATE TABLE `t1` ( `id` INT NOT NULL, `padding` VARCHAR(200) NOT NULL COLLATE utf8_general_ci, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
2668 | 22 | COMMIT; | 22 | COMMIT; |
2669 | 23 | START TRANSACTION; | 23 | START TRANSACTION; |
2670 | 24 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); | 24 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); |
2671 | @@ -27,12 +27,16 @@ | |||
2672 | 27 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (2,'I hate testing.'); | 27 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (2,'I hate testing.'); |
2673 | 28 | COMMIT; | 28 | COMMIT; |
2674 | 29 | START TRANSACTION; | 29 | START TRANSACTION; |
2682 | 30 | CREATE TABLE t2 ( id INT NOT NULL PRIMARY KEY , padding VARCHAR(200) NOT NULL ) SELECT * FROM t1; | 30 | CREATE TABLE `t2` ( `id` INT NOT NULL, `padding` VARCHAR(200) NOT NULL COLLATE utf8_general_ci, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
2683 | 31 | COMMIT; | 31 | COMMIT; |
2684 | 32 | START TRANSACTION; | 32 | START TRANSACTION; |
2685 | 33 | DROP TABLE `t1`; | 33 | INSERT INTO `test`.`t2` (`id`,`padding`) VALUES (1,'I love testing.'); |
2686 | 34 | COMMIT; | 34 | INSERT INTO `test`.`t2` (`id`,`padding`) VALUES (2,'I hate testing.'); |
2687 | 35 | START TRANSACTION; | 35 | COMMIT; |
2688 | 36 | DROP TABLE `t2`; | 36 | START TRANSACTION; |
2689 | 37 | DROP TABLE `test`.`t1`; | ||
2690 | 38 | COMMIT; | ||
2691 | 39 | START TRANSACTION; | ||
2692 | 40 | DROP TABLE `test`.`t2`; | ||
2693 | 37 | COMMIT; | 41 | COMMIT; |
2694 | 38 | SET GLOBAL transaction_log_truncate_debug= true; | 42 | SET GLOBAL transaction_log_truncate_debug= true; |
2695 | 39 | 43 | ||
2696 | === added file 'plugin/transaction_log/tests/r/create_table.result' | |||
2697 | --- plugin/transaction_log/tests/r/create_table.result 1970-01-01 00:00:00 +0000 | |||
2698 | +++ plugin/transaction_log/tests/r/create_table.result 2010-03-02 21:04:16 +0000 | |||
2699 | @@ -0,0 +1,54 @@ | |||
2700 | 1 | DROP TABLE IF EXISTS t1; | ||
2701 | 2 | CREATE TABLE t1 ( | ||
2702 | 3 | autoinc_int_field INT NOT NULL AUTO_INCREMENT | ||
2703 | 4 | , null_int_field INT NULL | ||
2704 | 5 | , not_null_bigint_field BIGINT NOT NULL | ||
2705 | 6 | , null_bigint_field BIGINT NULL | ||
2706 | 7 | , not_null_int_field INT NOT NULL | ||
2707 | 8 | , null_varchar_field VARCHAR(100) NULL | ||
2708 | 9 | , not_null_varchar_field VARCHAR(100) NOT NULL | ||
2709 | 10 | , null_enum_field ENUM ('val1', 'val2') NULL | ||
2710 | 11 | , not_null_enum_field ENUM ('val1', 'val2') NOT NULL | ||
2711 | 12 | , null_date_field DATE NULL | ||
2712 | 13 | , not_null_date_field DATE NOT NULL | ||
2713 | 14 | , null_datetime_field DATETIME NULL | ||
2714 | 15 | , not_null_datetime_field DATETIME NOT NULL | ||
2715 | 16 | , null_blob_field BLOB NULL | ||
2716 | 17 | , not_null_blob_field BLOB NOT NULL | ||
2717 | 18 | , null_text_field TEXT NULL | ||
2718 | 19 | , not_null_text_field TEXT NOT NULL | ||
2719 | 20 | , null_timestamp_field TIMESTAMP NULL | ||
2720 | 21 | , not_null_timestamp_field TIMESTAMP NOT NULL | ||
2721 | 22 | , null_double_field DOUBLE NULL | ||
2722 | 23 | , not_null_double_field DOUBLE NOT NULL | ||
2723 | 24 | , null_decimal_field DECIMAL(10,2) NULL | ||
2724 | 25 | , not_null_decimal_field DECIMAL(10,2) NOT NULL | ||
2725 | 26 | , PRIMARY KEY (autoinc_int_field) | ||
2726 | 27 | ); | ||
2727 | 28 | DROP TABLE t1; | ||
2728 | 29 | CREATE TABLE t1 ( | ||
2729 | 30 | id INT NOT NULL AUTO_INCREMENT PRIMARY KEY | ||
2730 | 31 | , key1 VARCHAR(10) NOT NULL | ||
2731 | 32 | , key2 DOUBLE NOT NULL | ||
2732 | 33 | , key3 BLOB NOT NULL | ||
2733 | 34 | , UNIQUE KEY (key1) | ||
2734 | 35 | , KEY named_key (key2) | ||
2735 | 36 | , KEY partial_key (key3(30)) | ||
2736 | 37 | ); | ||
2737 | 38 | DROP TABLE t1; | ||
2738 | 39 | START TRANSACTION; | ||
2739 | 40 | DROP TABLE IF EXISTS `test`.`t1`; | ||
2740 | 41 | COMMIT; | ||
2741 | 42 | START TRANSACTION; | ||
2742 | 43 | CREATE TABLE `t1` ( `autoinc_int_field` INT NOT NULL AUTO_INCREMENT, `null_int_field` INT NULL, `not_null_bigint_field` BIGINT NOT NULL, `null_bigint_field` BIGINT NULL, `not_null_int_field` INT NOT NULL, `null_varchar_field` VARCHAR(100) NULL COLLATE utf8_general_ci, `not_null_varchar_field` VARCHAR(100) NOT NULL COLLATE utf8_general_ci, `null_enum_field` ENUM('val1','val2') NULL, `not_null_enum_field` ENUM('val1','val2') NOT NULL, `null_date_field` DATE NULL, `not_null_date_field` DATE NOT NULL, `null_datetime_field` DATETIME NULL, `not_null_datetime_field` DATETIME NOT NULL, `null_blob_field` BLOB NULL COLLATE binary, `not_null_blob_field` BLOB NOT NULL COLLATE binary, `null_text_field` BLOB NULL COLLATE utf8_general_ci, `not_null_text_field` BLOB NOT NULL COLLATE utf8_general_ci, `null_timestamp_field` TIMESTAMP NULL, `not_null_timestamp_field` TIMESTAMP NOT NULL, `null_double_field` DOUBLE NULL, `not_null_double_field` DOUBLE NOT NULL, `null_decimal_field` DECIMAL(10,2) NULL, `not_null_decimal_field` DECIMAL(10,2) NOT NULL, PRIMARY KEY `PRIMARY` (`autoinc_int_field`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; | ||
2743 | 44 | COMMIT; | ||
2744 | 45 | START TRANSACTION; | ||
2745 | 46 | DROP TABLE `test`.`t1`; | ||
2746 | 47 | COMMIT; | ||
2747 | 48 | START TRANSACTION; | ||
2748 | 49 | CREATE TABLE `t1` ( `id` INT NOT NULL AUTO_INCREMENT, `key1` VARCHAR(10) NOT NULL COLLATE utf8_general_ci, `key2` DOUBLE NOT NULL, `key3` BLOB NOT NULL COLLATE binary, PRIMARY KEY `PRIMARY` (`id`), UNIQUE KEY `key1` (`key1`), KEY `named_key` (`key2`), KEY `partial_key` (`key3`(30)) ) ENGINE = InnoDB COLLATE = utf8_general_ci; | ||
2749 | 50 | COMMIT; | ||
2750 | 51 | START TRANSACTION; | ||
2751 | 52 | DROP TABLE `test`.`t1`; | ||
2752 | 53 | COMMIT; | ||
2753 | 54 | SET GLOBAL transaction_log_truncate_debug= true; | ||
2754 | 0 | 55 | ||
2755 | === modified file 'plugin/transaction_log/tests/r/database.result' | |||
2756 | --- plugin/transaction_log/tests/r/database.result 2009-12-23 14:24:22 +0000 | |||
2757 | +++ plugin/transaction_log/tests/r/database.result 2010-03-02 21:04:16 +0000 | |||
2758 | @@ -1,7 +1,7 @@ | |||
2759 | 1 | CREATE DATABASE test1; | 1 | CREATE DATABASE test1; |
2760 | 2 | DROP DATABASE test1; | 2 | DROP DATABASE test1; |
2761 | 3 | START TRANSACTION; | 3 | START TRANSACTION; |
2763 | 4 | CREATE DATABASE test1; | 4 | CREATE SCHEMA `test1` COLLATE utf8_general_ci; |
2764 | 5 | COMMIT; | 5 | COMMIT; |
2765 | 6 | START TRANSACTION; | 6 | START TRANSACTION; |
2766 | 7 | DROP DATABASE test1; | 7 | DROP DATABASE test1; |
2767 | 8 | 8 | ||
2768 | === modified file 'plugin/transaction_log/tests/r/delete.result' | |||
2769 | --- plugin/transaction_log/tests/r/delete.result 2009-12-23 14:24:22 +0000 | |||
2770 | +++ plugin/transaction_log/tests/r/delete.result 2010-03-02 21:04:16 +0000 | |||
2771 | @@ -37,10 +37,10 @@ | |||
2772 | 37 | DROP TABLE t1; | 37 | DROP TABLE t1; |
2773 | 38 | End Test of LP Bug #496101 | 38 | End Test of LP Bug #496101 |
2774 | 39 | START TRANSACTION; | 39 | START TRANSACTION; |
2776 | 40 | DROP TABLE IF EXISTS `t1`; | 40 | DROP TABLE IF EXISTS `test`.`t1`; |
2777 | 41 | COMMIT; | 41 | COMMIT; |
2778 | 42 | START TRANSACTION; | 42 | START TRANSACTION; |
2780 | 43 | CREATE TABLE t1 ( id INT NOT NULL , padding VARCHAR(200) NOT NULL , PRIMARY KEY (id) ); | 43 | CREATE TABLE `t1` ( `id` INT NOT NULL, `padding` VARCHAR(200) NOT NULL COLLATE utf8_general_ci, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
2781 | 44 | COMMIT; | 44 | COMMIT; |
2782 | 45 | START TRANSACTION; | 45 | START TRANSACTION; |
2783 | 46 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); | 46 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); |
2784 | @@ -52,10 +52,10 @@ | |||
2785 | 52 | DELETE FROM `test`.`t1` WHERE `id`=1; | 52 | DELETE FROM `test`.`t1` WHERE `id`=1; |
2786 | 53 | COMMIT; | 53 | COMMIT; |
2787 | 54 | START TRANSACTION; | 54 | START TRANSACTION; |
2789 | 55 | DROP TABLE `t1`; | 55 | DROP TABLE `test`.`t1`; |
2790 | 56 | COMMIT; | 56 | COMMIT; |
2791 | 57 | START TRANSACTION; | 57 | START TRANSACTION; |
2793 | 58 | CREATE TABLE t1 ( id INT NOT NULL , other INT NOT NULL , PRIMARY KEY (id) ); | 58 | CREATE TABLE `t1` ( `id` INT NOT NULL, `other` INT NOT NULL, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
2794 | 59 | COMMIT; | 59 | COMMIT; |
2795 | 60 | START TRANSACTION; | 60 | START TRANSACTION; |
2796 | 61 | INSERT INTO `test`.`t1` (`id`,`other`) VALUES (1,1); | 61 | INSERT INTO `test`.`t1` (`id`,`other`) VALUES (1,1); |
2797 | @@ -92,10 +92,10 @@ | |||
2798 | 92 | DELETE FROM `test`.`t1` WHERE `id`=8; | 92 | DELETE FROM `test`.`t1` WHERE `id`=8; |
2799 | 93 | COMMIT; | 93 | COMMIT; |
2800 | 94 | START TRANSACTION; | 94 | START TRANSACTION; |
2802 | 95 | DROP TABLE `t1`; | 95 | DROP TABLE `test`.`t1`; |
2803 | 96 | COMMIT; | 96 | COMMIT; |
2804 | 97 | START TRANSACTION; | 97 | START TRANSACTION; |
2806 | 98 | CREATE TABLE t1 ( id INT NOT NULL , padding VARCHAR(200) NOT NULL , PRIMARY KEY (id) ); | 98 | CREATE TABLE `t1` ( `id` INT NOT NULL, `padding` VARCHAR(200) NOT NULL COLLATE utf8_general_ci, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
2807 | 99 | COMMIT; | 99 | COMMIT; |
2808 | 100 | START TRANSACTION; | 100 | START TRANSACTION; |
2809 | 101 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); | 101 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); |
2810 | @@ -103,6 +103,6 @@ | |||
2811 | 103 | DELETE FROM `test`.`t1` WHERE `id`=1; | 103 | DELETE FROM `test`.`t1` WHERE `id`=1; |
2812 | 104 | COMMIT; | 104 | COMMIT; |
2813 | 105 | START TRANSACTION; | 105 | START TRANSACTION; |
2815 | 106 | DROP TABLE `t1`; | 106 | DROP TABLE `test`.`t1`; |
2816 | 107 | COMMIT; | 107 | COMMIT; |
2817 | 108 | SET GLOBAL transaction_log_truncate_debug= true; | 108 | SET GLOBAL transaction_log_truncate_debug= true; |
2818 | 109 | 109 | ||
2819 | === modified file 'plugin/transaction_log/tests/r/filtered_replicator.result' | |||
2820 | --- plugin/transaction_log/tests/r/filtered_replicator.result 2009-12-23 14:24:22 +0000 | |||
2821 | +++ plugin/transaction_log/tests/r/filtered_replicator.result 2010-03-02 21:04:16 +0000 | |||
2822 | @@ -36,8 +36,9 @@ | |||
2823 | 36 | ALTER TABLE t1 ADD dummy INT; | 36 | ALTER TABLE t1 ADD dummy INT; |
2824 | 37 | ALTER TABLE t1 ADD INDEX ix_padding (padding(20)); | 37 | ALTER TABLE t1 ADD INDEX ix_padding (padding(20)); |
2825 | 38 | DROP TABLE t1; | 38 | DROP TABLE t1; |
2828 | 39 | CREATE DATABASE test1; | 39 | DROP SCHEMA IF EXISTS my_new_schema; |
2829 | 40 | DROP DATABASE test1; | 40 | CREATE SCHEMA my_new_warnings; |
2830 | 41 | DROP SCHEMA my_new_warnings; | ||
2831 | 41 | DROP TABLE IF EXISTS t1, t2; | 42 | DROP TABLE IF EXISTS t1, t2; |
2832 | 42 | CREATE TABLE t1 ( | 43 | CREATE TABLE t1 ( |
2833 | 43 | id INT NOT NULL | 44 | id INT NOT NULL |
2834 | @@ -121,47 +122,44 @@ | |||
2835 | 121 | UPDATE t1 SET id = 4 WHERE id = 2; | 122 | UPDATE t1 SET id = 4 WHERE id = 2; |
2836 | 122 | DROP TABLE t1; | 123 | DROP TABLE t1; |
2837 | 123 | START TRANSACTION; | 124 | START TRANSACTION; |
2879 | 124 | DROP TABLE IF EXISTS `t1`; | 125 | DROP TABLE IF EXISTS `test`.`t1`; |
2880 | 125 | COMMIT; | 126 | COMMIT; |
2881 | 126 | START TRANSACTION; | 127 | START TRANSACTION; |
2882 | 127 | CREATE TABLE t1 ( id INT NOT NULL PRIMARY KEY , padding VARCHAR(200) NOT NULL ); | 128 | CREATE TABLE `t1` ( `id` INT NOT NULL, `padding` VARCHAR(200) NOT NULL COLLATE utf8_general_ci, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
2883 | 128 | COMMIT; | 129 | COMMIT; |
2884 | 129 | START TRANSACTION; | 130 | START TRANSACTION; |
2885 | 130 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); | 131 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); |
2886 | 131 | COMMIT; | 132 | COMMIT; |
2887 | 132 | START TRANSACTION; | 133 | START TRANSACTION; |
2888 | 133 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (2,'I hate testing.'); | 134 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (2,'I hate testing.'); |
2889 | 134 | COMMIT; | 135 | COMMIT; |
2890 | 135 | START TRANSACTION; | 136 | START TRANSACTION; |
2891 | 136 | DROP TABLE IF EXISTS `t1`; | 137 | DROP TABLE IF EXISTS `test`.`t1`; |
2892 | 137 | COMMIT; | 138 | COMMIT; |
2893 | 138 | START TRANSACTION; | 139 | START TRANSACTION; |
2894 | 139 | CREATE TABLE t1 ( id INT NOT NULL PRIMARY KEY , padding VARCHAR(200) NOT NULL ); | 140 | CREATE TABLE `t1` ( `id` INT NOT NULL, `padding` VARCHAR(200) NOT NULL COLLATE utf8_general_ci, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
2895 | 140 | COMMIT; | 141 | COMMIT; |
2896 | 141 | START TRANSACTION; | 142 | START TRANSACTION; |
2897 | 142 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); | 143 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); |
2898 | 143 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (2,'I hate testing.'); | 144 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (2,'I hate testing.'); |
2899 | 144 | COMMIT; | 145 | COMMIT; |
2900 | 145 | START TRANSACTION; | 146 | START TRANSACTION; |
2901 | 146 | DROP TABLE IF EXISTS `t1`; | 147 | DROP TABLE IF EXISTS `test`.`t1`; |
2902 | 147 | COMMIT; | 148 | COMMIT; |
2903 | 148 | START TRANSACTION; | 149 | START TRANSACTION; |
2904 | 149 | DROP TABLE IF EXISTS `t2`; | 150 | CREATE TABLE `t1` ( `id` INT NOT NULL, `padding` VARCHAR(200) NOT NULL COLLATE utf8_general_ci, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
2905 | 150 | COMMIT; | 151 | COMMIT; |
2906 | 151 | START TRANSACTION; | 152 | START TRANSACTION; |
2907 | 152 | CREATE TABLE t1 ( id INT NOT NULL PRIMARY KEY , padding VARCHAR(200) NOT NULL ); | 153 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); |
2908 | 153 | COMMIT; | 154 | COMMIT; |
2909 | 154 | START TRANSACTION; | 155 | START TRANSACTION; |
2910 | 155 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); | 156 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (2,'I hate testing.'); |
2911 | 156 | COMMIT; | 157 | COMMIT; |
2912 | 157 | START TRANSACTION; | 158 | START TRANSACTION; |
2913 | 158 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (2,'I hate testing.'); | 159 | DROP TABLE IF EXISTS `test`.`t1`; |
2914 | 159 | COMMIT; | 160 | COMMIT; |
2915 | 160 | START TRANSACTION; | 161 | START TRANSACTION; |
2916 | 161 | DROP TABLE IF EXISTS `t1`; | 162 | CREATE TABLE `t1` ( `id` INT NOT NULL, `padding` VARCHAR(200) NOT NULL COLLATE utf8_general_ci, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
2876 | 162 | COMMIT; | ||
2877 | 163 | START TRANSACTION; | ||
2878 | 164 | CREATE TABLE t1 ( id INT NOT NULL , padding VARCHAR(200) NOT NULL , PRIMARY KEY (id) ); | ||
2917 | 165 | COMMIT; | 163 | COMMIT; |
2918 | 166 | START TRANSACTION; | 164 | START TRANSACTION; |
2919 | 167 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); | 165 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); |
2920 | @@ -176,31 +174,31 @@ | |||
2921 | 176 | ALTER TABLE t1 ADD INDEX ix_padding (padding(20)); | 174 | ALTER TABLE t1 ADD INDEX ix_padding (padding(20)); |
2922 | 177 | COMMIT; | 175 | COMMIT; |
2923 | 178 | START TRANSACTION; | 176 | START TRANSACTION; |
2940 | 179 | DROP TABLE `t1`; | 177 | DROP TABLE `test`.`t1`; |
2941 | 180 | COMMIT; | 178 | COMMIT; |
2942 | 181 | START TRANSACTION; | 179 | START TRANSACTION; |
2943 | 182 | CREATE DATABASE test1; | 180 | DROP SCHEMA `my_new_schema`; |
2944 | 183 | COMMIT; | 181 | COMMIT; |
2945 | 184 | START TRANSACTION; | 182 | START TRANSACTION; |
2946 | 185 | DROP DATABASE test1; | 183 | CREATE SCHEMA `my_new_warnings` COLLATE utf8_general_ci; |
2947 | 186 | COMMIT; | 184 | COMMIT; |
2948 | 187 | START TRANSACTION; | 185 | START TRANSACTION; |
2949 | 188 | DROP TABLE IF EXISTS `t1`; | 186 | DROP SCHEMA `my_new_warnings`; |
2950 | 189 | COMMIT; | 187 | COMMIT; |
2951 | 190 | START TRANSACTION; | 188 | START TRANSACTION; |
2952 | 191 | DROP TABLE IF EXISTS `t2`; | 189 | DROP TABLE IF EXISTS `test`.`t1`; |
2953 | 192 | COMMIT; | 190 | COMMIT; |
2954 | 193 | START TRANSACTION; | 191 | START TRANSACTION; |
2955 | 194 | CREATE TABLE t1 ( id INT NOT NULL , padding VARCHAR(200) NOT NULL , PRIMARY KEY (id) ); | 192 | CREATE TABLE `t1` ( `id` INT NOT NULL, `padding` VARCHAR(200) NOT NULL COLLATE utf8_general_ci, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
2956 | 195 | COMMIT; | 193 | COMMIT; |
2957 | 196 | START TRANSACTION; | 194 | START TRANSACTION; |
2958 | 197 | RENAME TABLE t1 TO t2; | 195 | RENAME TABLE t1 TO t2; |
2959 | 198 | COMMIT; | 196 | COMMIT; |
2960 | 199 | START TRANSACTION; | 197 | START TRANSACTION; |
2962 | 200 | DROP TABLE IF EXISTS `t1`; | 198 | DROP TABLE IF EXISTS `test`.`t1`; |
2963 | 201 | COMMIT; | 199 | COMMIT; |
2964 | 202 | START TRANSACTION; | 200 | START TRANSACTION; |
2966 | 203 | CREATE TABLE t1 ( id INT NOT NULL , padding VARCHAR(200) NOT NULL , PRIMARY KEY (id) ); | 201 | CREATE TABLE `t1` ( `id` INT NOT NULL, `padding` VARCHAR(200) NOT NULL COLLATE utf8_general_ci, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
2967 | 204 | COMMIT; | 202 | COMMIT; |
2968 | 205 | START TRANSACTION; | 203 | START TRANSACTION; |
2969 | 206 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); | 204 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); |
2970 | @@ -212,10 +210,10 @@ | |||
2971 | 212 | DELETE FROM `test`.`t1` WHERE `id`=1; | 210 | DELETE FROM `test`.`t1` WHERE `id`=1; |
2972 | 213 | COMMIT; | 211 | COMMIT; |
2973 | 214 | START TRANSACTION; | 212 | START TRANSACTION; |
2975 | 215 | DROP TABLE `t1`; | 213 | DROP TABLE `test`.`t1`; |
2976 | 216 | COMMIT; | 214 | COMMIT; |
2977 | 217 | START TRANSACTION; | 215 | START TRANSACTION; |
2979 | 218 | CREATE TABLE t1 ( id INT NOT NULL , other INT NOT NULL , PRIMARY KEY (id) ); | 216 | CREATE TABLE `t1` ( `id` INT NOT NULL, `other` INT NOT NULL, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
2980 | 219 | COMMIT; | 217 | COMMIT; |
2981 | 220 | START TRANSACTION; | 218 | START TRANSACTION; |
2982 | 221 | INSERT INTO `test`.`t1` (`id`,`other`) VALUES (1,1); | 219 | INSERT INTO `test`.`t1` (`id`,`other`) VALUES (1,1); |
2983 | @@ -252,10 +250,10 @@ | |||
2984 | 252 | DELETE FROM `test`.`t1` WHERE `id`=8; | 250 | DELETE FROM `test`.`t1` WHERE `id`=8; |
2985 | 253 | COMMIT; | 251 | COMMIT; |
2986 | 254 | START TRANSACTION; | 252 | START TRANSACTION; |
2988 | 255 | DROP TABLE `t1`; | 253 | DROP TABLE `test`.`t1`; |
2989 | 256 | COMMIT; | 254 | COMMIT; |
2990 | 257 | START TRANSACTION; | 255 | START TRANSACTION; |
2992 | 258 | CREATE TABLE t1 ( id INT NOT NULL , padding VARCHAR(200) NOT NULL , PRIMARY KEY (id) ); | 256 | CREATE TABLE `t1` ( `id` INT NOT NULL, `padding` VARCHAR(200) NOT NULL COLLATE utf8_general_ci, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
2993 | 259 | COMMIT; | 257 | COMMIT; |
2994 | 260 | START TRANSACTION; | 258 | START TRANSACTION; |
2995 | 261 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); | 259 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); |
2996 | @@ -263,13 +261,13 @@ | |||
2997 | 263 | DELETE FROM `test`.`t1` WHERE `id`=1; | 261 | DELETE FROM `test`.`t1` WHERE `id`=1; |
2998 | 264 | COMMIT; | 262 | COMMIT; |
2999 | 265 | START TRANSACTION; | 263 | START TRANSACTION; |
3007 | 266 | DROP TABLE `t1`; | 264 | DROP TABLE `test`.`t1`; |
3008 | 267 | COMMIT; | 265 | COMMIT; |
3009 | 268 | START TRANSACTION; | 266 | START TRANSACTION; |
3010 | 269 | DROP TABLE IF EXISTS `t1`; | 267 | DROP TABLE IF EXISTS `test`.`t1`; |
3011 | 270 | COMMIT; | 268 | COMMIT; |
3012 | 271 | START TRANSACTION; | 269 | START TRANSACTION; |
3013 | 272 | CREATE TABLE t1 ( id INT NOT NULL , padding VARCHAR(200) NOT NULL , PRIMARY KEY (id) ); | 270 | CREATE TABLE `t1` ( `id` INT NOT NULL, `padding` VARCHAR(200) NOT NULL COLLATE utf8_general_ci, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
3014 | 273 | COMMIT; | 271 | COMMIT; |
3015 | 274 | START TRANSACTION; | 272 | START TRANSACTION; |
3016 | 275 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); | 273 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); |
3017 | @@ -285,10 +283,10 @@ | |||
3018 | 285 | UPDATE `test`.`t1` SET `padding`='AAA' WHERE `id`=2; | 283 | UPDATE `test`.`t1` SET `padding`='AAA' WHERE `id`=2; |
3019 | 286 | COMMIT; | 284 | COMMIT; |
3020 | 287 | START TRANSACTION; | 285 | START TRANSACTION; |
3022 | 288 | DROP TABLE `t1`; | 286 | DROP TABLE `test`.`t1`; |
3023 | 289 | COMMIT; | 287 | COMMIT; |
3024 | 290 | START TRANSACTION; | 288 | START TRANSACTION; |
3026 | 291 | CREATE TABLE t1 ( id int AUTO_INCREMENT NOT NULL PRIMARY KEY , name varchar(1024) , alias varchar(1024) ); | 289 | CREATE TABLE `t1` ( `id` INT NOT NULL AUTO_INCREMENT, `name` VARCHAR(1024) NOT NULL COLLATE utf8_general_ci, `alias` VARCHAR(1024) NOT NULL COLLATE utf8_general_ci, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
3027 | 292 | COMMIT; | 290 | COMMIT; |
3028 | 293 | START TRANSACTION; | 291 | START TRANSACTION; |
3029 | 294 | INSERT INTO `test`.`t1` (`id`,`name`,`alias`) VALUES (1,'jeff lebowski','dude'); | 292 | INSERT INTO `test`.`t1` (`id`,`name`,`alias`) VALUES (1,'jeff lebowski','dude'); |
3030 | @@ -297,10 +295,10 @@ | |||
3031 | 297 | UPDATE `test`.`t1` SET `alias`='the dude' WHERE `id`=1; | 295 | UPDATE `test`.`t1` SET `alias`='the dude' WHERE `id`=1; |
3032 | 298 | COMMIT; | 296 | COMMIT; |
3033 | 299 | START TRANSACTION; | 297 | START TRANSACTION; |
3035 | 300 | DROP TABLE `t1`; | 298 | DROP TABLE `test`.`t1`; |
3036 | 301 | COMMIT; | 299 | COMMIT; |
3037 | 302 | START TRANSACTION; | 300 | START TRANSACTION; |
3039 | 303 | CREATE TABLE t1 ( id INT NOT NULL , counter INT NOT NULL , PRIMARY KEY (id) ); | 301 | CREATE TABLE `t1` ( `id` INT NOT NULL, `counter` INT NOT NULL, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
3040 | 304 | COMMIT; | 302 | COMMIT; |
3041 | 305 | START TRANSACTION; | 303 | START TRANSACTION; |
3042 | 306 | INSERT INTO `test`.`t1` (`id`,`counter`) VALUES (1,1); | 304 | INSERT INTO `test`.`t1` (`id`,`counter`) VALUES (1,1); |
3043 | @@ -315,10 +313,10 @@ | |||
3044 | 315 | UPDATE `test`.`t1` SET `counter`=4 WHERE `id`=3; | 313 | UPDATE `test`.`t1` SET `counter`=4 WHERE `id`=3; |
3045 | 316 | COMMIT; | 314 | COMMIT; |
3046 | 317 | START TRANSACTION; | 315 | START TRANSACTION; |
3048 | 318 | DROP TABLE `t1`; | 316 | DROP TABLE `test`.`t1`; |
3049 | 319 | COMMIT; | 317 | COMMIT; |
3050 | 320 | START TRANSACTION; | 318 | START TRANSACTION; |
3052 | 321 | CREATE TABLE t1 ( id INT NOT NULL , padding VARCHAR(200) NOT NULL , PRIMARY KEY (id) ); | 319 | CREATE TABLE `t1` ( `id` INT NOT NULL, `padding` VARCHAR(200) NOT NULL COLLATE utf8_general_ci, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
3053 | 322 | COMMIT; | 320 | COMMIT; |
3054 | 323 | START TRANSACTION; | 321 | START TRANSACTION; |
3055 | 324 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); | 322 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); |
3056 | @@ -330,6 +328,6 @@ | |||
3057 | 330 | UPDATE `test`.`t1` SET `id`=4 WHERE `id`=2; | 328 | UPDATE `test`.`t1` SET `id`=4 WHERE `id`=2; |
3058 | 331 | COMMIT; | 329 | COMMIT; |
3059 | 332 | START TRANSACTION; | 330 | START TRANSACTION; |
3061 | 333 | DROP TABLE `t1`; | 331 | DROP TABLE `test`.`t1`; |
3062 | 334 | COMMIT; | 332 | COMMIT; |
3063 | 335 | SET GLOBAL transaction_log_truncate_debug= true; | 333 | SET GLOBAL transaction_log_truncate_debug= true; |
3064 | 336 | 334 | ||
3065 | === modified file 'plugin/transaction_log/tests/r/insert.result' | |||
3066 | --- plugin/transaction_log/tests/r/insert.result 2009-12-23 14:24:22 +0000 | |||
3067 | +++ plugin/transaction_log/tests/r/insert.result 2010-03-02 21:04:16 +0000 | |||
3068 | @@ -6,10 +6,10 @@ | |||
3069 | 6 | INSERT INTO t1 VALUES (1, "I love testing."); | 6 | INSERT INTO t1 VALUES (1, "I love testing."); |
3070 | 7 | INSERT INTO t1 VALUES (2, "I hate testing."); | 7 | INSERT INTO t1 VALUES (2, "I hate testing."); |
3071 | 8 | START TRANSACTION; | 8 | START TRANSACTION; |
3073 | 9 | DROP TABLE IF EXISTS `t1`; | 9 | DROP TABLE IF EXISTS `test`.`t1`; |
3074 | 10 | COMMIT; | 10 | COMMIT; |
3075 | 11 | START TRANSACTION; | 11 | START TRANSACTION; |
3077 | 12 | CREATE TABLE t1 ( id INT NOT NULL PRIMARY KEY , padding VARCHAR(200) NOT NULL ); | 12 | CREATE TABLE `t1` ( `id` INT NOT NULL, `padding` VARCHAR(200) NOT NULL COLLATE utf8_general_ci, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
3078 | 13 | COMMIT; | 13 | COMMIT; |
3079 | 14 | START TRANSACTION; | 14 | START TRANSACTION; |
3080 | 15 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); | 15 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); |
3081 | 16 | 16 | ||
3082 | === modified file 'plugin/transaction_log/tests/r/insert_multi.result' | |||
3083 | --- plugin/transaction_log/tests/r/insert_multi.result 2009-12-23 14:24:22 +0000 | |||
3084 | +++ plugin/transaction_log/tests/r/insert_multi.result 2010-03-02 21:04:16 +0000 | |||
3085 | @@ -5,10 +5,10 @@ | |||
3086 | 5 | ); | 5 | ); |
3087 | 6 | INSERT INTO t1 VALUES (1, "I love testing."), (2, "I hate testing."); | 6 | INSERT INTO t1 VALUES (1, "I love testing."), (2, "I hate testing."); |
3088 | 7 | START TRANSACTION; | 7 | START TRANSACTION; |
3090 | 8 | DROP TABLE IF EXISTS `t1`; | 8 | DROP TABLE IF EXISTS `test`.`t1`; |
3091 | 9 | COMMIT; | 9 | COMMIT; |
3092 | 10 | START TRANSACTION; | 10 | START TRANSACTION; |
3094 | 11 | CREATE TABLE t1 ( id INT NOT NULL PRIMARY KEY , padding VARCHAR(200) NOT NULL ); | 11 | CREATE TABLE `t1` ( `id` INT NOT NULL, `padding` VARCHAR(200) NOT NULL COLLATE utf8_general_ci, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
3095 | 12 | COMMIT; | 12 | COMMIT; |
3096 | 13 | START TRANSACTION; | 13 | START TRANSACTION; |
3097 | 14 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); | 14 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); |
3098 | 15 | 15 | ||
3099 | === modified file 'plugin/transaction_log/tests/r/insert_on_duplicate_update.result' | |||
3100 | --- plugin/transaction_log/tests/r/insert_on_duplicate_update.result 2009-12-23 14:24:22 +0000 | |||
3101 | +++ plugin/transaction_log/tests/r/insert_on_duplicate_update.result 2010-03-02 21:04:16 +0000 | |||
3102 | @@ -9,10 +9,10 @@ | |||
3103 | 9 | ON DUPLICATE KEY UPDATE padding="I love testing"; | 9 | ON DUPLICATE KEY UPDATE padding="I love testing"; |
3104 | 10 | DROP TABLE t1; | 10 | DROP TABLE t1; |
3105 | 11 | START TRANSACTION; | 11 | START TRANSACTION; |
3107 | 12 | DROP TABLE IF EXISTS `t1`; | 12 | DROP TABLE IF EXISTS `test`.`t1`; |
3108 | 13 | COMMIT; | 13 | COMMIT; |
3109 | 14 | START TRANSACTION; | 14 | START TRANSACTION; |
3111 | 15 | CREATE TABLE t1 ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY , padding VARCHAR(200) NOT NULL ); | 15 | CREATE TABLE `t1` ( `id` INT NOT NULL AUTO_INCREMENT, `padding` VARCHAR(200) NOT NULL COLLATE utf8_general_ci, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
3112 | 16 | COMMIT; | 16 | COMMIT; |
3113 | 17 | START TRANSACTION; | 17 | START TRANSACTION; |
3114 | 18 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); | 18 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); |
3115 | @@ -24,6 +24,6 @@ | |||
3116 | 24 | UPDATE `test`.`t1` SET `padding`='I love testing' WHERE `id`=2; | 24 | UPDATE `test`.`t1` SET `padding`='I love testing' WHERE `id`=2; |
3117 | 25 | COMMIT; | 25 | COMMIT; |
3118 | 26 | START TRANSACTION; | 26 | START TRANSACTION; |
3120 | 27 | DROP TABLE `t1`; | 27 | DROP TABLE `test`.`t1`; |
3121 | 28 | COMMIT; | 28 | COMMIT; |
3122 | 29 | SET GLOBAL transaction_log_truncate_debug= true; | 29 | SET GLOBAL transaction_log_truncate_debug= true; |
3123 | 30 | 30 | ||
3124 | === modified file 'plugin/transaction_log/tests/r/insert_select.result' | |||
3125 | --- plugin/transaction_log/tests/r/insert_select.result 2009-12-23 14:24:22 +0000 | |||
3126 | +++ plugin/transaction_log/tests/r/insert_select.result 2010-03-02 21:04:16 +0000 | |||
3127 | @@ -12,13 +12,13 @@ | |||
3128 | 12 | ); | 12 | ); |
3129 | 13 | INSERT INTO t2 SELECT * FROM t1; | 13 | INSERT INTO t2 SELECT * FROM t1; |
3130 | 14 | START TRANSACTION; | 14 | START TRANSACTION; |
3138 | 15 | DROP TABLE IF EXISTS `t1`; | 15 | DROP TABLE IF EXISTS `test`.`t1`; |
3139 | 16 | COMMIT; | 16 | COMMIT; |
3140 | 17 | START TRANSACTION; | 17 | START TRANSACTION; |
3141 | 18 | DROP TABLE IF EXISTS `t2`; | 18 | DROP TABLE IF EXISTS `test`.`t2`; |
3142 | 19 | COMMIT; | 19 | COMMIT; |
3143 | 20 | START TRANSACTION; | 20 | START TRANSACTION; |
3144 | 21 | CREATE TABLE t1 ( id INT NOT NULL PRIMARY KEY , padding VARCHAR(200) NOT NULL ); | 21 | CREATE TABLE `t1` ( `id` INT NOT NULL, `padding` VARCHAR(200) NOT NULL COLLATE utf8_general_ci, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
3145 | 22 | COMMIT; | 22 | COMMIT; |
3146 | 23 | START TRANSACTION; | 23 | START TRANSACTION; |
3147 | 24 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); | 24 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); |
3148 | @@ -27,7 +27,7 @@ | |||
3149 | 27 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (2,'I hate testing.'); | 27 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (2,'I hate testing.'); |
3150 | 28 | COMMIT; | 28 | COMMIT; |
3151 | 29 | START TRANSACTION; | 29 | START TRANSACTION; |
3153 | 30 | CREATE TABLE t2 ( id INT NOT NULL PRIMARY KEY , padding VARCHAR(200) NOT NULL ); | 30 | CREATE TABLE `t2` ( `id` INT NOT NULL, `padding` VARCHAR(200) NOT NULL COLLATE utf8_general_ci, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
3154 | 31 | COMMIT; | 31 | COMMIT; |
3155 | 32 | START TRANSACTION; | 32 | START TRANSACTION; |
3156 | 33 | INSERT INTO `test`.`t2` (`id`,`padding`) VALUES (1,'I love testing.'); | 33 | INSERT INTO `test`.`t2` (`id`,`padding`) VALUES (1,'I love testing.'); |
3157 | 34 | 34 | ||
3158 | === added file 'plugin/transaction_log/tests/r/multi_column_primary_key.result' | |||
3159 | --- plugin/transaction_log/tests/r/multi_column_primary_key.result 1970-01-01 00:00:00 +0000 | |||
3160 | +++ plugin/transaction_log/tests/r/multi_column_primary_key.result 2010-03-02 21:04:16 +0000 | |||
3161 | @@ -0,0 +1,55 @@ | |||
3162 | 1 | DROP TABLE IF EXISTS t1; | ||
3163 | 2 | CREATE TABLE t1 ( | ||
3164 | 3 | k1 INT NOT NULL | ||
3165 | 4 | , k2 INT NOT NULL | ||
3166 | 5 | , padding VARCHAR(200) NOT NULL | ||
3167 | 6 | , PRIMARY KEY (k1, k2) | ||
3168 | 7 | ); | ||
3169 | 8 | INSERT INTO t1 VALUES (1, 1, "I love testing."); | ||
3170 | 9 | INSERT INTO t1 VALUES (2, 2, "I hate testing."); | ||
3171 | 10 | INSERT INTO t1 VALUES (2, 3, "I hate and love testing."); | ||
3172 | 11 | INSERT INTO t1 VALUES (3, 3, "I adore testing."); | ||
3173 | 12 | UPDATE t1 SET padding= "XXX" WHERE k1= 1 AND k2= 1; | ||
3174 | 13 | UPDATE t1 SET padding= "YYY" WHERE k1= 2; | ||
3175 | 14 | UPDATE t1 SET padding= "ZZZ" WHERE k2= 3; | ||
3176 | 15 | UPDATE t1 SET padding= "AAA"; | ||
3177 | 16 | DROP TABLE t1; | ||
3178 | 17 | START TRANSACTION; | ||
3179 | 18 | DROP TABLE IF EXISTS `test`.`t1`; | ||
3180 | 19 | COMMIT; | ||
3181 | 20 | START TRANSACTION; | ||
3182 | 21 | CREATE TABLE `t1` ( `k1` INT NOT NULL, `k2` INT NOT NULL, `padding` VARCHAR(200) NOT NULL COLLATE utf8_general_ci, PRIMARY KEY `PRIMARY` (`k1`,`k2`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; | ||
3183 | 22 | COMMIT; | ||
3184 | 23 | START TRANSACTION; | ||
3185 | 24 | INSERT INTO `test`.`t1` (`k1`,`k2`,`padding`) VALUES (1,1,'I love testing.'); | ||
3186 | 25 | COMMIT; | ||
3187 | 26 | START TRANSACTION; | ||
3188 | 27 | INSERT INTO `test`.`t1` (`k1`,`k2`,`padding`) VALUES (2,2,'I hate testing.'); | ||
3189 | 28 | COMMIT; | ||
3190 | 29 | START TRANSACTION; | ||
3191 | 30 | INSERT INTO `test`.`t1` (`k1`,`k2`,`padding`) VALUES (2,3,'I hate and love testing.'); | ||
3192 | 31 | COMMIT; | ||
3193 | 32 | START TRANSACTION; | ||
3194 | 33 | INSERT INTO `test`.`t1` (`k1`,`k2`,`padding`) VALUES (3,3,'I adore testing.'); | ||
3195 | 34 | COMMIT; | ||
3196 | 35 | START TRANSACTION; | ||
3197 | 36 | UPDATE `test`.`t1` SET `padding`='XXX' WHERE `k1`=1 AND `k2`=1; | ||
3198 | 37 | COMMIT; | ||
3199 | 38 | START TRANSACTION; | ||
3200 | 39 | UPDATE `test`.`t1` SET `padding`='YYY' WHERE `k1`=2 AND `k2`=2; | ||
3201 | 40 | UPDATE `test`.`t1` SET `padding`='YYY' WHERE `k1`=2 AND `k2`=3; | ||
3202 | 41 | COMMIT; | ||
3203 | 42 | START TRANSACTION; | ||
3204 | 43 | UPDATE `test`.`t1` SET `padding`='ZZZ' WHERE `k1`=2 AND `k2`=3; | ||
3205 | 44 | UPDATE `test`.`t1` SET `padding`='ZZZ' WHERE `k1`=3 AND `k2`=3; | ||
3206 | 45 | COMMIT; | ||
3207 | 46 | START TRANSACTION; | ||
3208 | 47 | UPDATE `test`.`t1` SET `padding`='AAA' WHERE `k1`=1 AND `k2`=1; | ||
3209 | 48 | UPDATE `test`.`t1` SET `padding`='AAA' WHERE `k1`=2 AND `k2`=2; | ||
3210 | 49 | UPDATE `test`.`t1` SET `padding`='AAA' WHERE `k1`=2 AND `k2`=3; | ||
3211 | 50 | UPDATE `test`.`t1` SET `padding`='AAA' WHERE `k1`=3 AND `k2`=3; | ||
3212 | 51 | COMMIT; | ||
3213 | 52 | START TRANSACTION; | ||
3214 | 53 | DROP TABLE `test`.`t1`; | ||
3215 | 54 | COMMIT; | ||
3216 | 55 | SET GLOBAL transaction_log_truncate_debug= true; | ||
3217 | 0 | 56 | ||
3218 | === modified file 'plugin/transaction_log/tests/r/no_modification.result' | |||
3219 | --- plugin/transaction_log/tests/r/no_modification.result 2009-12-23 14:24:22 +0000 | |||
3220 | +++ plugin/transaction_log/tests/r/no_modification.result 2010-03-02 21:04:16 +0000 | |||
3221 | @@ -15,10 +15,10 @@ | |||
3222 | 15 | 2 I hate testing. | 15 | 2 I hate testing. |
3223 | 16 | COMMIT; | 16 | COMMIT; |
3224 | 17 | START TRANSACTION; | 17 | START TRANSACTION; |
3226 | 18 | DROP TABLE IF EXISTS `t1`; | 18 | DROP TABLE IF EXISTS `test`.`t1`; |
3227 | 19 | COMMIT; | 19 | COMMIT; |
3228 | 20 | START TRANSACTION; | 20 | START TRANSACTION; |
3230 | 21 | CREATE TABLE t1 ( id INT NOT NULL PRIMARY KEY , padding VARCHAR(200) NOT NULL ); | 21 | CREATE TABLE `t1` ( `id` INT NOT NULL, `padding` VARCHAR(200) NOT NULL COLLATE utf8_general_ci, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
3231 | 22 | COMMIT; | 22 | COMMIT; |
3232 | 23 | START TRANSACTION; | 23 | START TRANSACTION; |
3233 | 24 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); | 24 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); |
3234 | 25 | 25 | ||
3235 | === modified file 'plugin/transaction_log/tests/r/no_primary_key.result' | |||
3236 | --- plugin/transaction_log/tests/r/no_primary_key.result 2009-12-23 14:24:22 +0000 | |||
3237 | +++ plugin/transaction_log/tests/r/no_primary_key.result 2010-03-02 21:04:16 +0000 | |||
3238 | @@ -7,12 +7,12 @@ | |||
3239 | 7 | ERROR HY000: Tables which are replicated require a primary key. | 7 | ERROR HY000: Tables which are replicated require a primary key. |
3240 | 8 | DROP TABLE t1; | 8 | DROP TABLE t1; |
3241 | 9 | START TRANSACTION; | 9 | START TRANSACTION; |
3249 | 10 | DROP TABLE IF EXISTS `t1`; | 10 | DROP TABLE IF EXISTS `test`.`t1`; |
3250 | 11 | COMMIT; | 11 | COMMIT; |
3251 | 12 | START TRANSACTION; | 12 | START TRANSACTION; |
3252 | 13 | CREATE TABLE t1 ( id INT NOT NULL , padding VARCHAR(200) NOT NULL ); | 13 | CREATE TABLE `t1` ( `id` INT NOT NULL, `padding` VARCHAR(200) NOT NULL COLLATE utf8_general_ci ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
3253 | 14 | COMMIT; | 14 | COMMIT; |
3254 | 15 | START TRANSACTION; | 15 | START TRANSACTION; |
3255 | 16 | DROP TABLE `t1`; | 16 | DROP TABLE `test`.`t1`; |
3256 | 17 | COMMIT; | 17 | COMMIT; |
3257 | 18 | SET GLOBAL transaction_log_truncate_debug= true; | 18 | SET GLOBAL transaction_log_truncate_debug= true; |
3258 | 19 | 19 | ||
3259 | === modified file 'plugin/transaction_log/tests/r/rand.result' | |||
3260 | --- plugin/transaction_log/tests/r/rand.result 2009-12-23 14:24:22 +0000 | |||
3261 | +++ plugin/transaction_log/tests/r/rand.result 2010-03-02 21:04:16 +0000 | |||
3262 | @@ -7,10 +7,10 @@ | |||
3263 | 7 | INSERT INTO t1 SELECT RAND(100)*100 FROM t1; | 7 | INSERT INTO t1 SELECT RAND(100)*100 FROM t1; |
3264 | 8 | DROP TABLE t1; | 8 | DROP TABLE t1; |
3265 | 9 | START TRANSACTION; | 9 | START TRANSACTION; |
3267 | 10 | DROP TABLE IF EXISTS `t1`; | 10 | DROP TABLE IF EXISTS `test`.`t1`; |
3268 | 11 | COMMIT; | 11 | COMMIT; |
3269 | 12 | START TRANSACTION; | 12 | START TRANSACTION; |
3271 | 13 | CREATE TABLE t1 ( id INT NOT NULL , PRIMARY KEY (id) ); | 13 | CREATE TABLE `t1` ( `id` INT NOT NULL, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
3272 | 14 | COMMIT; | 14 | COMMIT; |
3273 | 15 | START TRANSACTION; | 15 | START TRANSACTION; |
3274 | 16 | INSERT INTO `test`.`t1` (`id`) VALUES (1); | 16 | INSERT INTO `test`.`t1` (`id`) VALUES (1); |
3275 | @@ -19,6 +19,6 @@ | |||
3276 | 19 | INSERT INTO `test`.`t1` (`id`) VALUES (17); | 19 | INSERT INTO `test`.`t1` (`id`) VALUES (17); |
3277 | 20 | COMMIT; | 20 | COMMIT; |
3278 | 21 | START TRANSACTION; | 21 | START TRANSACTION; |
3280 | 22 | DROP TABLE `t1`; | 22 | DROP TABLE `test`.`t1`; |
3281 | 23 | COMMIT; | 23 | COMMIT; |
3282 | 24 | SET GLOBAL transaction_log_truncate_debug= true; | 24 | SET GLOBAL transaction_log_truncate_debug= true; |
3283 | 25 | 25 | ||
3284 | === modified file 'plugin/transaction_log/tests/r/rename.result' | |||
3285 | --- plugin/transaction_log/tests/r/rename.result 2009-12-23 14:24:22 +0000 | |||
3286 | +++ plugin/transaction_log/tests/r/rename.result 2010-03-02 21:04:16 +0000 | |||
3287 | @@ -6,13 +6,13 @@ | |||
3288 | 6 | ); | 6 | ); |
3289 | 7 | RENAME TABLE t1 TO t2; | 7 | RENAME TABLE t1 TO t2; |
3290 | 8 | START TRANSACTION; | 8 | START TRANSACTION; |
3298 | 9 | DROP TABLE IF EXISTS `t1`; | 9 | DROP TABLE IF EXISTS `test`.`t1`; |
3299 | 10 | COMMIT; | 10 | COMMIT; |
3300 | 11 | START TRANSACTION; | 11 | START TRANSACTION; |
3301 | 12 | DROP TABLE IF EXISTS `t2`; | 12 | DROP TABLE IF EXISTS `test`.`t2`; |
3302 | 13 | COMMIT; | 13 | COMMIT; |
3303 | 14 | START TRANSACTION; | 14 | START TRANSACTION; |
3304 | 15 | CREATE TABLE t1 ( id INT NOT NULL , padding VARCHAR(200) NOT NULL , PRIMARY KEY (id) ); | 15 | CREATE TABLE `t1` ( `id` INT NOT NULL, `padding` VARCHAR(200) NOT NULL COLLATE utf8_general_ci, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
3305 | 16 | COMMIT; | 16 | COMMIT; |
3306 | 17 | START TRANSACTION; | 17 | START TRANSACTION; |
3307 | 18 | RENAME TABLE t1 TO t2; | 18 | RENAME TABLE t1 TO t2; |
3308 | 19 | 19 | ||
3309 | === modified file 'plugin/transaction_log/tests/r/replace.result' | |||
3310 | --- plugin/transaction_log/tests/r/replace.result 2009-12-23 14:24:22 +0000 | |||
3311 | +++ plugin/transaction_log/tests/r/replace.result 2010-03-02 21:04:16 +0000 | |||
3312 | @@ -21,13 +21,13 @@ | |||
3313 | 21 | REPLACE INTO t1 VALUE (2, "I love testing."); | 21 | REPLACE INTO t1 VALUE (2, "I love testing."); |
3314 | 22 | DROP TABLE t2, t1; | 22 | DROP TABLE t2, t1; |
3315 | 23 | START TRANSACTION; | 23 | START TRANSACTION; |
3323 | 24 | DROP TABLE IF EXISTS `t1`; | 24 | DROP TABLE IF EXISTS `test`.`t1`; |
3324 | 25 | COMMIT; | 25 | COMMIT; |
3325 | 26 | START TRANSACTION; | 26 | START TRANSACTION; |
3326 | 27 | DROP TABLE IF EXISTS `t2`; | 27 | DROP TABLE IF EXISTS `test`.`t2`; |
3327 | 28 | COMMIT; | 28 | COMMIT; |
3328 | 29 | START TRANSACTION; | 29 | START TRANSACTION; |
3329 | 30 | CREATE TABLE t1 ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY , padding VARCHAR(200) NOT NULL ) ENGINE=InnoDB; | 30 | CREATE TABLE `t1` ( `id` INT NOT NULL AUTO_INCREMENT, `padding` VARCHAR(200) NOT NULL COLLATE utf8_general_ci, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
3330 | 31 | COMMIT; | 31 | COMMIT; |
3331 | 32 | START TRANSACTION; | 32 | START TRANSACTION; |
3332 | 33 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); | 33 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); |
3333 | @@ -39,13 +39,13 @@ | |||
3334 | 39 | UPDATE `test`.`t1` SET `padding`='I love testing.' WHERE `id`=2; | 39 | UPDATE `test`.`t1` SET `padding`='I love testing.' WHERE `id`=2; |
3335 | 40 | COMMIT; | 40 | COMMIT; |
3336 | 41 | START TRANSACTION; | 41 | START TRANSACTION; |
3344 | 42 | DROP TABLE `t1`; | 42 | DROP TABLE `test`.`t1`; |
3345 | 43 | COMMIT; | 43 | COMMIT; |
3346 | 44 | START TRANSACTION; | 44 | START TRANSACTION; |
3347 | 45 | CREATE TABLE t1 ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY , padding VARCHAR(200) NOT NULL ) ENGINE=InnoDB; | 45 | CREATE TABLE `t1` ( `id` INT NOT NULL AUTO_INCREMENT, `padding` VARCHAR(200) NOT NULL COLLATE utf8_general_ci, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
3348 | 46 | COMMIT; | 46 | COMMIT; |
3349 | 47 | START TRANSACTION; | 47 | START TRANSACTION; |
3350 | 48 | CREATE TABLE t2 ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY , fk_id INT NOT NULL , CONSTRAINT fk_t1 FOREIGN KEY (fk_id) REFERENCES t1 (id) ON DELETE CASCADE ) ENGINE=InnoDB; | 48 | CREATE TABLE `t2` ( `id` INT NOT NULL AUTO_INCREMENT, `fk_id` INT NOT NULL, PRIMARY KEY `PRIMARY` (`id`), KEY `fk_t1` (`fk_id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
3351 | 49 | COMMIT; | 49 | COMMIT; |
3352 | 50 | START TRANSACTION; | 50 | START TRANSACTION; |
3353 | 51 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); | 51 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); |
3354 | @@ -58,9 +58,9 @@ | |||
3355 | 58 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (2,'I love testing.'); | 58 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (2,'I love testing.'); |
3356 | 59 | COMMIT; | 59 | COMMIT; |
3357 | 60 | START TRANSACTION; | 60 | START TRANSACTION; |
3359 | 61 | DROP TABLE `t2`; | 61 | DROP TABLE `test`.`t2`; |
3360 | 62 | COMMIT; | 62 | COMMIT; |
3361 | 63 | START TRANSACTION; | 63 | START TRANSACTION; |
3363 | 64 | DROP TABLE `t1`; | 64 | DROP TABLE `test`.`t1`; |
3364 | 65 | COMMIT; | 65 | COMMIT; |
3365 | 66 | SET GLOBAL transaction_log_truncate_debug= true; | 66 | SET GLOBAL transaction_log_truncate_debug= true; |
3366 | 67 | 67 | ||
3367 | === modified file 'plugin/transaction_log/tests/r/rollback.result' | |||
3368 | --- plugin/transaction_log/tests/r/rollback.result 2009-12-23 14:24:22 +0000 | |||
3369 | +++ plugin/transaction_log/tests/r/rollback.result 2010-03-02 21:04:16 +0000 | |||
3370 | @@ -13,12 +13,12 @@ | |||
3371 | 13 | ROLLBACK; | 13 | ROLLBACK; |
3372 | 14 | DROP TABLE t1; | 14 | DROP TABLE t1; |
3373 | 15 | START TRANSACTION; | 15 | START TRANSACTION; |
3381 | 16 | DROP TABLE IF EXISTS `t1`; | 16 | DROP TABLE IF EXISTS `test`.`t1`; |
3382 | 17 | COMMIT; | 17 | COMMIT; |
3383 | 18 | START TRANSACTION; | 18 | START TRANSACTION; |
3384 | 19 | CREATE TABLE t1 ( id INT NOT NULL PRIMARY KEY , padding VARCHAR(200) NOT NULL ); | 19 | CREATE TABLE `t1` ( `id` INT NOT NULL, `padding` VARCHAR(200) NOT NULL COLLATE utf8_general_ci, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
3385 | 20 | COMMIT; | 20 | COMMIT; |
3386 | 21 | START TRANSACTION; | 21 | START TRANSACTION; |
3387 | 22 | DROP TABLE `t1`; | 22 | DROP TABLE `test`.`t1`; |
3388 | 23 | COMMIT; | 23 | COMMIT; |
3389 | 24 | SET GLOBAL transaction_log_truncate_debug= true; | 24 | SET GLOBAL transaction_log_truncate_debug= true; |
3390 | 25 | 25 | ||
3391 | === added file 'plugin/transaction_log/tests/r/schema.result' | |||
3392 | --- plugin/transaction_log/tests/r/schema.result 1970-01-01 00:00:00 +0000 | |||
3393 | +++ plugin/transaction_log/tests/r/schema.result 2010-03-02 21:04:16 +0000 | |||
3394 | @@ -0,0 +1,13 @@ | |||
3395 | 1 | DROP SCHEMA IF EXISTS my_new_schema; | ||
3396 | 2 | CREATE SCHEMA my_new_warnings; | ||
3397 | 3 | DROP SCHEMA my_new_warnings; | ||
3398 | 4 | START TRANSACTION; | ||
3399 | 5 | DROP SCHEMA `my_new_schema`; | ||
3400 | 6 | COMMIT; | ||
3401 | 7 | START TRANSACTION; | ||
3402 | 8 | CREATE SCHEMA `my_new_warnings` COLLATE utf8_general_ci; | ||
3403 | 9 | COMMIT; | ||
3404 | 10 | START TRANSACTION; | ||
3405 | 11 | DROP SCHEMA `my_new_warnings`; | ||
3406 | 12 | COMMIT; | ||
3407 | 13 | SET GLOBAL transaction_log_truncate_debug= true; | ||
3408 | 0 | 14 | ||
3409 | === modified file 'plugin/transaction_log/tests/r/select_for_update.result' | |||
3410 | --- plugin/transaction_log/tests/r/select_for_update.result 2009-12-23 14:24:22 +0000 | |||
3411 | +++ plugin/transaction_log/tests/r/select_for_update.result 2010-03-02 21:04:16 +0000 | |||
3412 | @@ -19,10 +19,10 @@ | |||
3413 | 19 | COMMIT; | 19 | COMMIT; |
3414 | 20 | DROP TABLE t1; | 20 | DROP TABLE t1; |
3415 | 21 | START TRANSACTION; | 21 | START TRANSACTION; |
3417 | 22 | DROP TABLE IF EXISTS `t1`; | 22 | DROP TABLE IF EXISTS `test`.`t1`; |
3418 | 23 | COMMIT; | 23 | COMMIT; |
3419 | 24 | START TRANSACTION; | 24 | START TRANSACTION; |
3421 | 25 | CREATE TABLE t1 ( id INT NOT NULL , padding VARCHAR(200) NOT NULL , PRIMARY KEY (id) ); | 25 | CREATE TABLE `t1` ( `id` INT NOT NULL, `padding` VARCHAR(200) NOT NULL COLLATE utf8_general_ci, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
3422 | 26 | COMMIT; | 26 | COMMIT; |
3423 | 27 | START TRANSACTION; | 27 | START TRANSACTION; |
3424 | 28 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); | 28 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); |
3425 | @@ -39,6 +39,6 @@ | |||
3426 | 39 | UPDATE `test`.`t1` SET `id`=6 WHERE `id`=5; | 39 | UPDATE `test`.`t1` SET `id`=6 WHERE `id`=5; |
3427 | 40 | COMMIT; | 40 | COMMIT; |
3428 | 41 | START TRANSACTION; | 41 | START TRANSACTION; |
3430 | 42 | DROP TABLE `t1`; | 42 | DROP TABLE `test`.`t1`; |
3431 | 43 | COMMIT; | 43 | COMMIT; |
3432 | 44 | SET GLOBAL transaction_log_truncate_debug= true; | 44 | SET GLOBAL transaction_log_truncate_debug= true; |
3433 | 45 | 45 | ||
3434 | === modified file 'plugin/transaction_log/tests/r/temp_tables.result' | |||
3435 | --- plugin/transaction_log/tests/r/temp_tables.result 2009-12-23 14:24:22 +0000 | |||
3436 | +++ plugin/transaction_log/tests/r/temp_tables.result 2010-03-02 21:04:16 +0000 | |||
3437 | @@ -10,10 +10,10 @@ | |||
3438 | 10 | DROP TABLE t1; | 10 | DROP TABLE t1; |
3439 | 11 | DROP TABLE t2; | 11 | DROP TABLE t2; |
3440 | 12 | START TRANSACTION; | 12 | START TRANSACTION; |
3442 | 13 | DROP TABLE IF EXISTS `t1`; | 13 | DROP TABLE IF EXISTS `test`.`t1`; |
3443 | 14 | COMMIT; | 14 | COMMIT; |
3444 | 15 | START TRANSACTION; | 15 | START TRANSACTION; |
3446 | 16 | DROP TABLE IF EXISTS `t2`; | 16 | DROP TABLE IF EXISTS `test`.`t2`; |
3447 | 17 | COMMIT; | 17 | COMMIT; |
3448 | 18 | START TRANSACTION; | 18 | START TRANSACTION; |
3449 | 19 | CREATE TABLE `t2` ( `id` int NOT NULL, `padding` varchar(200) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB; | 19 | CREATE TABLE `t2` ( `id` int NOT NULL, `padding` varchar(200) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB; |
3450 | @@ -23,6 +23,6 @@ | |||
3451 | 23 | INSERT INTO `test`.`t2` (`id`,`padding`) VALUES (2,'I hate testing.'); | 23 | INSERT INTO `test`.`t2` (`id`,`padding`) VALUES (2,'I hate testing.'); |
3452 | 24 | COMMIT; | 24 | COMMIT; |
3453 | 25 | START TRANSACTION; | 25 | START TRANSACTION; |
3455 | 26 | DROP TABLE `t2`; | 26 | DROP TABLE `test`.`t2`; |
3456 | 27 | COMMIT; | 27 | COMMIT; |
3457 | 28 | SET GLOBAL transaction_log_truncate_debug= true; | 28 | SET GLOBAL transaction_log_truncate_debug= true; |
3458 | 29 | 29 | ||
3459 | === modified file 'plugin/transaction_log/tests/r/truncate.result' | |||
3460 | --- plugin/transaction_log/tests/r/truncate.result 2009-12-23 14:24:22 +0000 | |||
3461 | +++ plugin/transaction_log/tests/r/truncate.result 2010-03-02 21:04:16 +0000 | |||
3462 | @@ -7,10 +7,10 @@ | |||
3463 | 7 | INSERT INTO t1 VALUES (2, "I hate testing."); | 7 | INSERT INTO t1 VALUES (2, "I hate testing."); |
3464 | 8 | TRUNCATE TABLE t1; | 8 | TRUNCATE TABLE t1; |
3465 | 9 | START TRANSACTION; | 9 | START TRANSACTION; |
3467 | 10 | DROP TABLE IF EXISTS `t1`; | 10 | DROP TABLE IF EXISTS `test`.`t1`; |
3468 | 11 | COMMIT; | 11 | COMMIT; |
3469 | 12 | START TRANSACTION; | 12 | START TRANSACTION; |
3471 | 13 | CREATE TABLE t1 ( id INT NOT NULL PRIMARY KEY , padding VARCHAR(200) NOT NULL ); | 13 | CREATE TABLE `t1` ( `id` INT NOT NULL, `padding` VARCHAR(200) NOT NULL COLLATE utf8_general_ci, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
3472 | 14 | COMMIT; | 14 | COMMIT; |
3473 | 15 | START TRANSACTION; | 15 | START TRANSACTION; |
3474 | 16 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); | 16 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); |
3475 | 17 | 17 | ||
3476 | === modified file 'plugin/transaction_log/tests/r/truncate_log.result' | |||
3477 | --- plugin/transaction_log/tests/r/truncate_log.result 2009-12-11 19:08:29 +0000 | |||
3478 | +++ plugin/transaction_log/tests/r/truncate_log.result 2010-03-02 21:04:16 +0000 | |||
3479 | @@ -5,6 +5,6 @@ | |||
3480 | 5 | ); | 5 | ); |
3481 | 6 | INSERT INTO t1 VALUES (1, "I love testing."); | 6 | INSERT INTO t1 VALUES (1, "I love testing."); |
3482 | 7 | INSERT INTO t1 VALUES (2, "I hate testing."); | 7 | INSERT INTO t1 VALUES (2, "I hate testing."); |
3484 | 8 | 17var/master-data/transaction.log | 8 | 24var/master-data/transaction.log |
3485 | 9 | SET GLOBAL transaction_log_truncate_debug= true; | 9 | SET GLOBAL transaction_log_truncate_debug= true; |
3486 | 10 | 0var/master-data/transaction.log | 10 | 0var/master-data/transaction.log |
3487 | 11 | 11 | ||
3488 | === modified file 'plugin/transaction_log/tests/r/update.result' | |||
3489 | --- plugin/transaction_log/tests/r/update.result 2009-12-23 14:24:22 +0000 | |||
3490 | +++ plugin/transaction_log/tests/r/update.result 2010-03-02 21:04:16 +0000 | |||
3491 | @@ -36,10 +36,10 @@ | |||
3492 | 36 | UPDATE t1 SET id = 4 WHERE id = 2; | 36 | UPDATE t1 SET id = 4 WHERE id = 2; |
3493 | 37 | DROP TABLE t1; | 37 | DROP TABLE t1; |
3494 | 38 | START TRANSACTION; | 38 | START TRANSACTION; |
3496 | 39 | DROP TABLE IF EXISTS `t1`; | 39 | DROP TABLE IF EXISTS `test`.`t1`; |
3497 | 40 | COMMIT; | 40 | COMMIT; |
3498 | 41 | START TRANSACTION; | 41 | START TRANSACTION; |
3500 | 42 | CREATE TABLE t1 ( id INT NOT NULL , padding VARCHAR(200) NOT NULL , PRIMARY KEY (id) ); | 42 | CREATE TABLE `t1` ( `id` INT NOT NULL, `padding` VARCHAR(200) NOT NULL COLLATE utf8_general_ci, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
3501 | 43 | COMMIT; | 43 | COMMIT; |
3502 | 44 | START TRANSACTION; | 44 | START TRANSACTION; |
3503 | 45 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); | 45 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); |
3504 | @@ -55,10 +55,10 @@ | |||
3505 | 55 | UPDATE `test`.`t1` SET `padding`='AAA' WHERE `id`=2; | 55 | UPDATE `test`.`t1` SET `padding`='AAA' WHERE `id`=2; |
3506 | 56 | COMMIT; | 56 | COMMIT; |
3507 | 57 | START TRANSACTION; | 57 | START TRANSACTION; |
3509 | 58 | DROP TABLE `t1`; | 58 | DROP TABLE `test`.`t1`; |
3510 | 59 | COMMIT; | 59 | COMMIT; |
3511 | 60 | START TRANSACTION; | 60 | START TRANSACTION; |
3513 | 61 | CREATE TABLE t1 ( id int AUTO_INCREMENT NOT NULL PRIMARY KEY , name varchar(1024) , alias varchar(1024) ); | 61 | CREATE TABLE `t1` ( `id` INT NOT NULL AUTO_INCREMENT, `name` VARCHAR(1024) NOT NULL COLLATE utf8_general_ci, `alias` VARCHAR(1024) NOT NULL COLLATE utf8_general_ci, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
3514 | 62 | COMMIT; | 62 | COMMIT; |
3515 | 63 | START TRANSACTION; | 63 | START TRANSACTION; |
3516 | 64 | INSERT INTO `test`.`t1` (`id`,`name`,`alias`) VALUES (1,'jeff lebowski','dude'); | 64 | INSERT INTO `test`.`t1` (`id`,`name`,`alias`) VALUES (1,'jeff lebowski','dude'); |
3517 | @@ -67,10 +67,10 @@ | |||
3518 | 67 | UPDATE `test`.`t1` SET `alias`='the dude' WHERE `id`=1; | 67 | UPDATE `test`.`t1` SET `alias`='the dude' WHERE `id`=1; |
3519 | 68 | COMMIT; | 68 | COMMIT; |
3520 | 69 | START TRANSACTION; | 69 | START TRANSACTION; |
3522 | 70 | DROP TABLE `t1`; | 70 | DROP TABLE `test`.`t1`; |
3523 | 71 | COMMIT; | 71 | COMMIT; |
3524 | 72 | START TRANSACTION; | 72 | START TRANSACTION; |
3526 | 73 | CREATE TABLE t1 ( id INT NOT NULL , counter INT NOT NULL , PRIMARY KEY (id) ); | 73 | CREATE TABLE `t1` ( `id` INT NOT NULL, `counter` INT NOT NULL, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
3527 | 74 | COMMIT; | 74 | COMMIT; |
3528 | 75 | START TRANSACTION; | 75 | START TRANSACTION; |
3529 | 76 | INSERT INTO `test`.`t1` (`id`,`counter`) VALUES (1,1); | 76 | INSERT INTO `test`.`t1` (`id`,`counter`) VALUES (1,1); |
3530 | @@ -85,10 +85,10 @@ | |||
3531 | 85 | UPDATE `test`.`t1` SET `counter`=4 WHERE `id`=3; | 85 | UPDATE `test`.`t1` SET `counter`=4 WHERE `id`=3; |
3532 | 86 | COMMIT; | 86 | COMMIT; |
3533 | 87 | START TRANSACTION; | 87 | START TRANSACTION; |
3535 | 88 | DROP TABLE `t1`; | 88 | DROP TABLE `test`.`t1`; |
3536 | 89 | COMMIT; | 89 | COMMIT; |
3537 | 90 | START TRANSACTION; | 90 | START TRANSACTION; |
3539 | 91 | CREATE TABLE t1 ( id INT NOT NULL , padding VARCHAR(200) NOT NULL , PRIMARY KEY (id) ); | 91 | CREATE TABLE `t1` ( `id` INT NOT NULL, `padding` VARCHAR(200) NOT NULL COLLATE utf8_general_ci, PRIMARY KEY `PRIMARY` (`id`) ) ENGINE = InnoDB COLLATE = utf8_general_ci; |
3540 | 92 | COMMIT; | 92 | COMMIT; |
3541 | 93 | START TRANSACTION; | 93 | START TRANSACTION; |
3542 | 94 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); | 94 | INSERT INTO `test`.`t1` (`id`,`padding`) VALUES (1,'I love testing.'); |
3543 | @@ -100,6 +100,6 @@ | |||
3544 | 100 | UPDATE `test`.`t1` SET `id`=4 WHERE `id`=2; | 100 | UPDATE `test`.`t1` SET `id`=4 WHERE `id`=2; |
3545 | 101 | COMMIT; | 101 | COMMIT; |
3546 | 102 | START TRANSACTION; | 102 | START TRANSACTION; |
3548 | 103 | DROP TABLE `t1`; | 103 | DROP TABLE `test`.`t1`; |
3549 | 104 | COMMIT; | 104 | COMMIT; |
3550 | 105 | SET GLOBAL transaction_log_truncate_debug= true; | 105 | SET GLOBAL transaction_log_truncate_debug= true; |
3551 | 106 | 106 | ||
3552 | === added file 'plugin/transaction_log/tests/t/create_table-master.opt' | |||
3553 | --- plugin/transaction_log/tests/t/create_table-master.opt 1970-01-01 00:00:00 +0000 | |||
3554 | +++ plugin/transaction_log/tests/t/create_table-master.opt 2010-03-02 21:04:16 +0000 | |||
3555 | @@ -0,0 +1,1 @@ | |||
3556 | 1 | --default-replicator-enable --transaction-log-enable --scheduler=multi_thread | ||
3557 | 0 | 2 | ||
3558 | === added file 'plugin/transaction_log/tests/t/create_table.inc' | |||
3559 | --- plugin/transaction_log/tests/t/create_table.inc 1970-01-01 00:00:00 +0000 | |||
3560 | +++ plugin/transaction_log/tests/t/create_table.inc 2010-03-02 21:04:16 +0000 | |||
3561 | @@ -0,0 +1,53 @@ | |||
3562 | 1 | # | ||
3563 | 2 | # Tests tons of different CREATE TABLE | ||
3564 | 3 | # variations and the replication stream | ||
3565 | 4 | # | ||
3566 | 5 | |||
3567 | 6 | --disable_warnings | ||
3568 | 7 | DROP TABLE IF EXISTS t1; | ||
3569 | 8 | --enable_warnings | ||
3570 | 9 | |||
3571 | 10 | # Test the field generation | ||
3572 | 11 | |||
3573 | 12 | CREATE TABLE t1 ( | ||
3574 | 13 | autoinc_int_field INT NOT NULL AUTO_INCREMENT | ||
3575 | 14 | , null_int_field INT NULL | ||
3576 | 15 | , not_null_bigint_field BIGINT NOT NULL | ||
3577 | 16 | , null_bigint_field BIGINT NULL | ||
3578 | 17 | , not_null_int_field INT NOT NULL | ||
3579 | 18 | , null_varchar_field VARCHAR(100) NULL | ||
3580 | 19 | , not_null_varchar_field VARCHAR(100) NOT NULL | ||
3581 | 20 | , null_enum_field ENUM ('val1', 'val2') NULL | ||
3582 | 21 | , not_null_enum_field ENUM ('val1', 'val2') NOT NULL | ||
3583 | 22 | , null_date_field DATE NULL | ||
3584 | 23 | , not_null_date_field DATE NOT NULL | ||
3585 | 24 | , null_datetime_field DATETIME NULL | ||
3586 | 25 | , not_null_datetime_field DATETIME NOT NULL | ||
3587 | 26 | , null_blob_field BLOB NULL | ||
3588 | 27 | , not_null_blob_field BLOB NOT NULL | ||
3589 | 28 | , null_text_field TEXT NULL | ||
3590 | 29 | , not_null_text_field TEXT NOT NULL | ||
3591 | 30 | , null_timestamp_field TIMESTAMP NULL | ||
3592 | 31 | , not_null_timestamp_field TIMESTAMP NOT NULL | ||
3593 | 32 | , null_double_field DOUBLE NULL | ||
3594 | 33 | , not_null_double_field DOUBLE NOT NULL | ||
3595 | 34 | , null_decimal_field DECIMAL(10,2) NULL | ||
3596 | 35 | , not_null_decimal_field DECIMAL(10,2) NOT NULL | ||
3597 | 36 | , PRIMARY KEY (autoinc_int_field) | ||
3598 | 37 | ); | ||
3599 | 38 | |||
3600 | 39 | DROP TABLE t1; | ||
3601 | 40 | |||
3602 | 41 | # Test the index generation | ||
3603 | 42 | |||
3604 | 43 | CREATE TABLE t1 ( | ||
3605 | 44 | id INT NOT NULL AUTO_INCREMENT PRIMARY KEY | ||
3606 | 45 | , key1 VARCHAR(10) NOT NULL | ||
3607 | 46 | , key2 DOUBLE NOT NULL | ||
3608 | 47 | , key3 BLOB NOT NULL | ||
3609 | 48 | , UNIQUE KEY (key1) | ||
3610 | 49 | , KEY named_key (key2) | ||
3611 | 50 | , KEY partial_key (key3(30)) | ||
3612 | 51 | ); | ||
3613 | 52 | |||
3614 | 53 | DROP TABLE t1; | ||
3615 | 0 | 54 | ||
3616 | === added file 'plugin/transaction_log/tests/t/create_table.test' | |||
3617 | --- plugin/transaction_log/tests/t/create_table.test 1970-01-01 00:00:00 +0000 | |||
3618 | +++ plugin/transaction_log/tests/t/create_table.test 2010-03-02 21:04:16 +0000 | |||
3619 | @@ -0,0 +1,9 @@ | |||
3620 | 1 | # Populate log with some records... | ||
3621 | 2 | --source ../plugin/transaction_log/tests/t/create_table.inc | ||
3622 | 3 | |||
3623 | 4 | # Read in the transaction.log. | ||
3624 | 5 | |||
3625 | 6 | --exec ../drizzled/message/transaction_reader var/master-data/transaction.log | ||
3626 | 7 | |||
3627 | 8 | # Truncate the log file to reset for the next test | ||
3628 | 9 | --source ../plugin/transaction_log/tests/t/truncate_log.inc | ||
3629 | 0 | 10 | ||
3630 | === removed file 'plugin/transaction_log/tests/t/database.inc' | |||
3631 | --- plugin/transaction_log/tests/t/database.inc 2009-07-02 05:08:33 +0000 | |||
3632 | +++ plugin/transaction_log/tests/t/database.inc 1970-01-01 00:00:00 +0000 | |||
3633 | @@ -1,12 +0,0 @@ | |||
3634 | 1 | # | ||
3635 | 2 | # Simple test of the serial event log for CREATE DATABASE and | ||
3636 | 3 | # DROP DATABASE | ||
3637 | 4 | # | ||
3638 | 5 | # Create a database then drop a database | ||
3639 | 6 | # | ||
3640 | 7 | # We then use the transaction_reader in drizzled/message/ to read the events. | ||
3641 | 8 | # | ||
3642 | 9 | |||
3643 | 10 | # CREATE DATABASE | ||
3644 | 11 | CREATE DATABASE test1; | ||
3645 | 12 | DROP DATABASE test1; | ||
3646 | 13 | 0 | ||
3647 | === removed file 'plugin/transaction_log/tests/t/database.test' | |||
3648 | --- plugin/transaction_log/tests/t/database.test 2009-12-04 18:50:04 +0000 | |||
3649 | +++ plugin/transaction_log/tests/t/database.test 1970-01-01 00:00:00 +0000 | |||
3650 | @@ -1,13 +0,0 @@ | |||
3651 | 1 | # | ||
3652 | 2 | # Tests simple CREATE DATABASE and DROP DATABASE statements and the transaction log | ||
3653 | 3 | # | ||
3654 | 4 | |||
3655 | 5 | # Populate log with some records... | ||
3656 | 6 | --source ../plugin/transaction_log/tests/t/database.inc | ||
3657 | 7 | |||
3658 | 8 | # Read in the transaction.log. | ||
3659 | 9 | |||
3660 | 10 | --exec ../drizzled/message/transaction_reader var/master-data/transaction.log | ||
3661 | 11 | |||
3662 | 12 | # Truncate the log file to reset for the next test | ||
3663 | 13 | --source ../plugin/transaction_log/tests/t/truncate_log.inc | ||
3664 | 14 | 0 | ||
3665 | === modified file 'plugin/transaction_log/tests/t/filtered_replicator.test' | |||
3666 | --- plugin/transaction_log/tests/t/filtered_replicator.test 2009-12-04 18:50:04 +0000 | |||
3667 | +++ plugin/transaction_log/tests/t/filtered_replicator.test 2010-03-02 21:04:16 +0000 | |||
3668 | @@ -16,7 +16,7 @@ | |||
3669 | 16 | --source ../plugin/transaction_log/tests/t/insert_multi.inc | 16 | --source ../plugin/transaction_log/tests/t/insert_multi.inc |
3670 | 17 | --source ../plugin/transaction_log/tests/t/insert_select.inc | 17 | --source ../plugin/transaction_log/tests/t/insert_select.inc |
3671 | 18 | --source ../plugin/transaction_log/tests/t/alter.inc | 18 | --source ../plugin/transaction_log/tests/t/alter.inc |
3673 | 19 | --source ../plugin/transaction_log/tests/t/database.inc | 19 | --source ../plugin/transaction_log/tests/t/schema.inc |
3674 | 20 | --source ../plugin/transaction_log/tests/t/rename.inc | 20 | --source ../plugin/transaction_log/tests/t/rename.inc |
3675 | 21 | --source ../plugin/transaction_log/tests/t/delete.inc | 21 | --source ../plugin/transaction_log/tests/t/delete.inc |
3676 | 22 | --source ../plugin/transaction_log/tests/t/update.inc | 22 | --source ../plugin/transaction_log/tests/t/update.inc |
3677 | 23 | 23 | ||
3678 | === added file 'plugin/transaction_log/tests/t/multi_column_primary_key-master.opt' | |||
3679 | --- plugin/transaction_log/tests/t/multi_column_primary_key-master.opt 1970-01-01 00:00:00 +0000 | |||
3680 | +++ plugin/transaction_log/tests/t/multi_column_primary_key-master.opt 2010-03-02 21:04:16 +0000 | |||
3681 | @@ -0,0 +1,1 @@ | |||
3682 | 1 | --default-replicator-enable --transaction-log-enable --scheduler=multi_thread | ||
3683 | 0 | 2 | ||
3684 | === added file 'plugin/transaction_log/tests/t/multi_column_primary_key.inc' | |||
3685 | --- plugin/transaction_log/tests/t/multi_column_primary_key.inc 1970-01-01 00:00:00 +0000 | |||
3686 | +++ plugin/transaction_log/tests/t/multi_column_primary_key.inc 2010-03-02 21:04:16 +0000 | |||
3687 | @@ -0,0 +1,36 @@ | |||
3688 | 1 | # | ||
3689 | 2 | # Test that tables with multi-column primary keys | ||
3690 | 3 | # are handled properly in replication | ||
3691 | 4 | # | ||
3692 | 5 | |||
3693 | 6 | --disable_warnings | ||
3694 | 7 | DROP TABLE IF EXISTS t1; | ||
3695 | 8 | --enable_warnings | ||
3696 | 9 | |||
3697 | 10 | CREATE TABLE t1 ( | ||
3698 | 11 | k1 INT NOT NULL | ||
3699 | 12 | , k2 INT NOT NULL | ||
3700 | 13 | , padding VARCHAR(200) NOT NULL | ||
3701 | 14 | , PRIMARY KEY (k1, k2) | ||
3702 | 15 | ); | ||
3703 | 16 | |||
3704 | 17 | INSERT INTO t1 VALUES (1, 1, "I love testing."); | ||
3705 | 18 | INSERT INTO t1 VALUES (2, 2, "I hate testing."); | ||
3706 | 19 | INSERT INTO t1 VALUES (2, 3, "I hate and love testing."); | ||
3707 | 20 | INSERT INTO t1 VALUES (3, 3, "I adore testing."); | ||
3708 | 21 | |||
3709 | 22 | # Simple PK update on both columns | ||
3710 | 23 | UPDATE t1 SET padding= "XXX" WHERE k1= 1 AND k2= 1; | ||
3711 | 24 | |||
3712 | 25 | # UPDATE all records in table matching first column | ||
3713 | 26 | # in primary key | ||
3714 | 27 | UPDATE t1 SET padding= "YYY" WHERE k1= 2; | ||
3715 | 28 | |||
3716 | 29 | # UPDATE all records in table matching second column | ||
3717 | 30 | # in primary key | ||
3718 | 31 | UPDATE t1 SET padding= "ZZZ" WHERE k2= 3; | ||
3719 | 32 | |||
3720 | 33 | # UPDATE all records in table | ||
3721 | 34 | UPDATE t1 SET padding= "AAA"; | ||
3722 | 35 | |||
3723 | 36 | DROP TABLE t1; | ||
3724 | 0 | 37 | ||
3725 | === added file 'plugin/transaction_log/tests/t/multi_column_primary_key.test' | |||
3726 | --- plugin/transaction_log/tests/t/multi_column_primary_key.test 1970-01-01 00:00:00 +0000 | |||
3727 | +++ plugin/transaction_log/tests/t/multi_column_primary_key.test 2010-03-02 21:04:16 +0000 | |||
3728 | @@ -0,0 +1,9 @@ | |||
3729 | 1 | # Populate log with some records... | ||
3730 | 2 | --source ../plugin/transaction_log/tests/t/multi_column_primary_key.inc | ||
3731 | 3 | |||
3732 | 4 | # Read in the transaction.log. | ||
3733 | 5 | |||
3734 | 6 | --exec ../drizzled/message/transaction_reader var/master-data/transaction.log | ||
3735 | 7 | |||
3736 | 8 | # Truncate the log file to reset for the next test | ||
3737 | 9 | --source ../plugin/transaction_log/tests/t/truncate_log.inc | ||
3738 | 0 | 10 | ||
3739 | === added file 'plugin/transaction_log/tests/t/schema-master.opt' | |||
3740 | --- plugin/transaction_log/tests/t/schema-master.opt 1970-01-01 00:00:00 +0000 | |||
3741 | +++ plugin/transaction_log/tests/t/schema-master.opt 2010-03-02 21:04:16 +0000 | |||
3742 | @@ -0,0 +1,1 @@ | |||
3743 | 1 | --default-replicator-enable --transaction-log-enable --scheduler=multi_thread | ||
3744 | 0 | 2 | ||
3745 | === added file 'plugin/transaction_log/tests/t/schema.inc' | |||
3746 | --- plugin/transaction_log/tests/t/schema.inc 1970-01-01 00:00:00 +0000 | |||
3747 | +++ plugin/transaction_log/tests/t/schema.inc 2010-03-02 21:04:16 +0000 | |||
3748 | @@ -0,0 +1,12 @@ | |||
3749 | 1 | # | ||
3750 | 2 | # Test CREATE SCHEMA, DROP SCHEMA, ALTER SCHEMA | ||
3751 | 3 | # and the replication stream | ||
3752 | 4 | # | ||
3753 | 5 | |||
3754 | 6 | --disable_warnings | ||
3755 | 7 | DROP SCHEMA IF EXISTS my_new_schema; | ||
3756 | 8 | --enable_warnings | ||
3757 | 9 | |||
3758 | 10 | CREATE SCHEMA my_new_warnings; | ||
3759 | 11 | |||
3760 | 12 | DROP SCHEMA my_new_warnings; | ||
3761 | 0 | 13 | ||
3762 | === added file 'plugin/transaction_log/tests/t/schema.test' | |||
3763 | --- plugin/transaction_log/tests/t/schema.test 1970-01-01 00:00:00 +0000 | |||
3764 | +++ plugin/transaction_log/tests/t/schema.test 2010-03-02 21:04:16 +0000 | |||
3765 | @@ -0,0 +1,9 @@ | |||
3766 | 1 | # Populate log with some records... | ||
3767 | 2 | --source ../plugin/transaction_log/tests/t/schema.inc | ||
3768 | 3 | |||
3769 | 4 | # Read in the transaction.log. | ||
3770 | 5 | |||
3771 | 6 | --exec ../drizzled/message/transaction_reader var/master-data/transaction.log | ||
3772 | 7 | |||
3773 | 8 | # Truncate the log file to reset for the next test | ||
3774 | 9 | --source ../plugin/transaction_log/tests/t/truncate_log.inc | ||
3775 | 0 | 10 | ||
3776 | === modified file 'tests/r/innodb.result' | |||
3777 | --- tests/r/innodb.result 2010-03-01 22:24:10 +0000 | |||
3778 | +++ tests/r/innodb.result 2010-03-02 21:04:16 +0000 | |||
3779 | @@ -1130,24 +1130,24 @@ | |||
3780 | 1130 | checksum table t1, t2, t3, t4; | 1130 | checksum table t1, t2, t3, t4; |
3781 | 1131 | Table Checksum | 1131 | Table Checksum |
3782 | 1132 | test.t1 2948697075 | 1132 | test.t1 2948697075 |
3801 | 1133 | test.t2 2948697075 | 1133 | test.t2 3505595080 |
3802 | 1134 | test.t3 2948697075 | 1134 | test.t3 3505595080 |
3803 | 1135 | test.t4 NULL | 1135 | test.t4 NULL |
3804 | 1136 | Warnings: | 1136 | Warnings: |
3805 | 1137 | Error 1146 Table 'test.t4' doesn't exist | 1137 | Error 1146 Table 'test.t4' doesn't exist |
3806 | 1138 | checksum table t1, t2, t3, t4; | 1138 | checksum table t1, t2, t3, t4; |
3807 | 1139 | Table Checksum | 1139 | Table Checksum |
3808 | 1140 | test.t1 2948697075 | 1140 | test.t1 2948697075 |
3809 | 1141 | test.t2 2948697075 | 1141 | test.t2 3505595080 |
3810 | 1142 | test.t3 2948697075 | 1142 | test.t3 3505595080 |
3811 | 1143 | test.t4 NULL | 1143 | test.t4 NULL |
3812 | 1144 | Warnings: | 1144 | Warnings: |
3813 | 1145 | Error 1146 Table 'test.t4' doesn't exist | 1145 | Error 1146 Table 'test.t4' doesn't exist |
3814 | 1146 | checksum table t1, t2, t3, t4; | 1146 | checksum table t1, t2, t3, t4; |
3815 | 1147 | Table Checksum | 1147 | Table Checksum |
3816 | 1148 | test.t1 2948697075 | 1148 | test.t1 2948697075 |
3817 | 1149 | test.t2 2948697075 | 1149 | test.t2 3505595080 |
3818 | 1150 | test.t3 2948697075 | 1150 | test.t3 3505595080 |
3819 | 1151 | test.t4 NULL | 1151 | test.t4 NULL |
3820 | 1152 | Warnings: | 1152 | Warnings: |
3821 | 1153 | Error 1146 Table 'test.t4' doesn't exist | 1153 | Error 1146 Table 'test.t4' doesn't exist |
3822 | 1154 | 1154 | ||
3823 | === modified file 'tests/r/mix2_myisam.result' | |||
3824 | --- tests/r/mix2_myisam.result 2010-02-19 19:04:24 +0000 | |||
3825 | +++ tests/r/mix2_myisam.result 2010-03-02 21:04:16 +0000 | |||
3826 | @@ -898,30 +898,30 @@ | |||
3827 | 898 | Table Checksum | 898 | Table Checksum |
3828 | 899 | test.t1 2948697075 | 899 | test.t1 2948697075 |
3829 | 900 | test.t2 2948697075 | 900 | test.t2 2948697075 |
3854 | 901 | test.t3 2948697075 | 901 | test.t3 3505595080 |
3855 | 902 | test.t4 2948697075 | 902 | test.t4 3505595080 |
3856 | 903 | test.t5 2948697075 | 903 | test.t5 2948697075 |
3857 | 904 | test.t6 2948697075 | 904 | test.t6 2948697075 |
3858 | 905 | test.t7 NULL | 905 | test.t7 NULL |
3859 | 906 | Warnings: | 906 | Warnings: |
3860 | 907 | Error 1146 Table 'test.t7' doesn't exist | 907 | Error 1146 Table 'test.t7' doesn't exist |
3861 | 908 | checksum table t1, t2, t3, t4, t5, t6, t7; | 908 | checksum table t1, t2, t3, t4, t5, t6, t7; |
3862 | 909 | Table Checksum | 909 | Table Checksum |
3863 | 910 | test.t1 2948697075 | 910 | test.t1 2948697075 |
3864 | 911 | test.t2 2948697075 | 911 | test.t2 2948697075 |
3865 | 912 | test.t3 2948697075 | 912 | test.t3 3505595080 |
3866 | 913 | test.t4 2948697075 | 913 | test.t4 3505595080 |
3867 | 914 | test.t5 2948697075 | 914 | test.t5 2948697075 |
3868 | 915 | test.t6 2948697075 | 915 | test.t6 2948697075 |
3869 | 916 | test.t7 NULL | 916 | test.t7 NULL |
3870 | 917 | Warnings: | 917 | Warnings: |
3871 | 918 | Error 1146 Table 'test.t7' doesn't exist | 918 | Error 1146 Table 'test.t7' doesn't exist |
3872 | 919 | checksum table t1, t2, t3, t4, t5, t6, t7; | 919 | checksum table t1, t2, t3, t4, t5, t6, t7; |
3873 | 920 | Table Checksum | 920 | Table Checksum |
3874 | 921 | test.t1 2948697075 | 921 | test.t1 2948697075 |
3875 | 922 | test.t2 2948697075 | 922 | test.t2 2948697075 |
3876 | 923 | test.t3 2948697075 | 923 | test.t3 3505595080 |
3877 | 924 | test.t4 2948697075 | 924 | test.t4 3505595080 |
3878 | 925 | test.t5 2948697075 | 925 | test.t5 2948697075 |
3879 | 926 | test.t6 2948697075 | 926 | test.t6 2948697075 |
3880 | 927 | test.t7 NULL | 927 | test.t7 NULL |
3881 | 928 | 928 | ||
3882 | === modified file 'tests/r/myisam.result' | |||
3883 | --- tests/r/myisam.result 2010-03-01 22:24:10 +0000 | |||
3884 | +++ tests/r/myisam.result 2010-03-02 21:04:16 +0000 | |||
3885 | @@ -490,22 +490,22 @@ | |||
3886 | 490 | insert t2 select * from t1; | 490 | insert t2 select * from t1; |
3887 | 491 | checksum table t1, t2, t3; | 491 | checksum table t1, t2, t3; |
3888 | 492 | Table Checksum | 492 | Table Checksum |
3905 | 493 | test.t1 2948697075 | 493 | test.t1 3505595080 |
3906 | 494 | test.t2 2948697075 | 494 | test.t2 3505595080 |
3907 | 495 | test.t3 NULL | 495 | test.t3 NULL |
3908 | 496 | Warnings: | 496 | Warnings: |
3909 | 497 | Error 1146 Table 'test.t3' doesn't exist | 497 | Error 1146 Table 'test.t3' doesn't exist |
3910 | 498 | checksum table t1, t2, t3; | 498 | checksum table t1, t2, t3; |
3911 | 499 | Table Checksum | 499 | Table Checksum |
3912 | 500 | test.t1 2948697075 | 500 | test.t1 3505595080 |
3913 | 501 | test.t2 2948697075 | 501 | test.t2 3505595080 |
3914 | 502 | test.t3 NULL | 502 | test.t3 NULL |
3915 | 503 | Warnings: | 503 | Warnings: |
3916 | 504 | Error 1146 Table 'test.t3' doesn't exist | 504 | Error 1146 Table 'test.t3' doesn't exist |
3917 | 505 | checksum table t1, t2, t3; | 505 | checksum table t1, t2, t3; |
3918 | 506 | Table Checksum | 506 | Table Checksum |
3919 | 507 | test.t1 2948697075 | 507 | test.t1 3505595080 |
3920 | 508 | test.t2 2948697075 | 508 | test.t2 3505595080 |
3921 | 509 | test.t3 NULL | 509 | test.t3 NULL |
3922 | 510 | Warnings: | 510 | Warnings: |
3923 | 511 | Error 1146 Table 'test.t3' doesn't exist | 511 | Error 1146 Table 'test.t3' doesn't exist |
Hi!
This patch removes 4 places where we were still using statement-based replication:
DROP SCHEMA
CREATE SCHEMA
DROP TABLE
CREATE TABLE
Now, all of the above are written to the replication stream as specific message::Statement subclasses describing the changes to be made to the server's state.
This also fixes Bug#527992 (Multi-column Primary Key not handled in replication)
Cheers,
Jay