Merge lp:~brianaker/drizzle/regression-622465 into lp:drizzle/7.0

Proposed by Brian Aker
Status: Merged
Approved by: Brian Aker
Approved revision: 2081
Merged at revision: 2093
Proposed branch: lp:~brianaker/drizzle/regression-622465
Merge into: lp:drizzle/7.0
Diff against target: 402 lines (+120/-77) (has conflicts)
10 files modified
drizzled/cursor.h (+5/-5)
drizzled/error.cc (+1/-0)
drizzled/error_t.h (+11/-0)
drizzled/sql_table.cc (+59/-59)
drizzled/sql_table.h (+3/-3)
drizzled/statement/create_table.cc (+4/-3)
tests/r/create.result (+5/-5)
tests/suite/regression/r/622465.result (+12/-0)
tests/suite/regression/t/622465.test (+10/-0)
tests/t/create.test (+10/-2)
Text conflict in drizzled/error_t.h
To merge this branch: bzr merge lp:~brianaker/drizzle/regression-622465
Reviewer Review Type Date Requested Status
Lee Bieber (community) Needs Fixing
Review via email: mp+46217@code.launchpad.net

Description of the change

We need to modify the names of the FK toward the name of the new table.

To post a comment you must log in.
Revision history for this message
Lee Bieber (kalebral-deactivatedaccount) wrote :

Getting test failures - regression.592690 microtime_type.decimal microtime_type.max

--- .././tests/suite/microtime_type/r/decimal.result 2011-01-14 05:58:28.446261000 +0300
+++ .././tests/suite/microtime_type/r/decimal.reject 2011-01-14 21:34:44.103791539 +0300
@@ -14,6 +14,6 @@
 SELECT _value FROM t2;
 _value
 2003-01-01 00:00:00.000000
-2003-01-01 00:00:00.125000
-2003-01-01 00:00:00.898437
+2003-01-01 00:00:00.123456
+2003-01-01 00:00:00.900000
 DROP TABLE t1,t2;

microtime_type.max [ fail ]
drizzletest: At line 6: query 'INSERT into t2 VALUES ("20660101000000.00000")' failed: 1685: Received an invalid value '20660101000000.00000' for a UNIX timestamp.

The result from queries just before the failure was:
CREATE TABLE t2 (
_value TIMESTAMP(6)
);
INSERT into t2 VALUES ("20660101000000.00000");

mysql_compatibility.zerofill [ pass ] 2
regression.592690 [ fail ]
--- .././tests/suite/regression/r/592690.result 2011-01-14 05:58:28.446261000 +0300
+++ .././tests/suite/regression/r/592690.reject 2011-01-14 21:34:30.083175783 +0300
@@ -1,3 +1,5 @@
 select from_unixtime(1272945599.90000), from_unixtime(1272945599), from_unixtime("1272945599.90000");
 from_unixtime(1272945599.90000) from_unixtime(1272945599) from_unixtime("1272945599.90000")
-2010-05-04 03:59:59.900000 2010-05-04 03:59:59 2010-05-04 03:59:59.900000
+2010-05-04 04:00:00 2010-05-04 03:59:59 2010-05-04 03:59:59
+Warnings:
+Warning 1292 Truncated incorrect INTEGER value: '1272945599.90000'

microtime_type.decimal [ fail ]
--- .././tests/suite/microtime_type/r/decimal.result 2011-01-14 05:58:28.446261000 +0300
+++ .././tests/suite/microtime_type/r/decimal.reject 2011-01-14 21:34:44.103791539 +0300
@@ -14,6 +14,6 @@
 SELECT _value FROM t2;
 _value
 2003-01-01 00:00:00.000000
-2003-01-01 00:00:00.125000
-2003-01-01 00:00:00.898437
+2003-01-01 00:00:00.123456
+2003-01-01 00:00:00.900000
 DROP TABLE t1,t2;

review: Needs Fixing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'drizzled/cursor.h'
2--- drizzled/cursor.h 2011-01-07 04:13:17 +0000
3+++ drizzled/cursor.h 2011-01-14 01:53:54 +0000
4@@ -681,11 +681,11 @@
5 bool is_if_not_exists);
6
7 bool create_like_table(Session* session,
8- const TableIdentifier &destination_identifier,
9- TableList* table, TableList* src_table,
10- message::Table &create_table_proto,
11- bool is_if_not_exists,
12- bool is_engine_set);
13+ TableIdentifier::const_reference destination_identifier,
14+ TableIdentifier::const_reference source_identifier,
15+ message::Table &create_table_proto,
16+ bool is_if_not_exists,
17+ bool is_engine_set);
18
19 bool rename_table(Session &session,
20 plugin::StorageEngine *base,
21
22=== modified file 'drizzled/error.cc'
23--- drizzled/error.cc 2011-01-13 09:25:42 +0000
24+++ drizzled/error.cc 2011-01-14 01:53:54 +0000
25@@ -482,6 +482,7 @@
26 ADD_ERROR_MESSAGE(ER_TABLE_DROP, N_("Cannot drop table '%s'"));
27 ADD_ERROR_MESSAGE(ER_TABLE_DROP_ERROR_OCCURRED, N_("Error occurred while dropping table '%s'"));
28 ADD_ERROR_MESSAGE(ER_TABLE_PERMISSION_DENIED, N_("Permission denied to create '%s'"));
29+ ADD_ERROR_MESSAGE(ER_TABLE_UNKNOWN, N_("Unknown table '%s'"));
30
31 ADD_ERROR_MESSAGE(ER_SCHEMA_DOES_NOT_EXIST, N_("Schema does not exist: %s"));
32 ADD_ERROR_MESSAGE(ER_ALTER_SCHEMA, N_("Error altering schema: %s"));
33
34=== modified file 'drizzled/error_t.h'
35--- drizzled/error_t.h 2011-01-13 09:25:42 +0000
36+++ drizzled/error_t.h 2011-01-14 01:53:54 +0000
37@@ -844,17 +844,28 @@
38 ER_INVALID_BOOLEAN_VALUE,
39 ER_ASSERT,
40 ER_ASSERT_NULL,
41+<<<<<<< TREE
42 ER_TABLE_DROP,
43+=======
44+>>>>>>> MERGE-SOURCE
45 ER_CATALOG_CANNOT_CREATE,
46 ER_CATALOG_CANNOT_CREATE_PERMISSION,
47 ER_CATALOG_CANNOT_DROP,
48+<<<<<<< TREE
49 ER_CATALOG_CANNOT_DROP_PERMISSION,
50 ER_CATALOG_DOES_NOT_EXIST,
51 ER_CATALOG_NO_DROP_LOCAL,
52+=======
53+ ER_CATALOG_DOES_NOT_EXIST,
54+ ER_CATALOG_NO_DROP_LOCAL,
55+>>>>>>> MERGE-SOURCE
56 ER_CATALOG_NO_LOCK,
57 ER_CORRUPT_CATALOG_DEFINITION,
58+ ER_TABLE_DROP,
59 ER_TABLE_DROP_ERROR_OCCURRED,
60 ER_TABLE_PERMISSION_DENIED,
61+ ER_TABLE_UNKNOWN,
62+
63 ER_INVALID_CAST_TO_BOOLEAN,
64
65 // Leave ER_INVALID_BOOLEAN_VALUE as LAST, and force people to use tags
66
67=== modified file 'drizzled/sql_table.cc'
68--- drizzled/sql_table.cc 2011-01-13 07:24:48 +0000
69+++ drizzled/sql_table.cc 2011-01-14 01:53:54 +0000
70@@ -1999,48 +1999,63 @@
71 during the call to plugin::StorageEngine::createTable().
72 See bug #28614 for more info.
73 */
74-static bool create_table_wrapper(Session &session, const message::Table& create_table_proto,
75- const TableIdentifier &destination_identifier,
76- const TableIdentifier &src_table,
77+static bool create_table_wrapper(Session &session,
78+ const message::Table& create_table_proto,
79+ TableIdentifier::const_reference destination_identifier,
80+ TableIdentifier::const_reference source_identifier,
81 bool is_engine_set)
82 {
83- int protoerr;
84- message::Table new_proto;
85- message::table::shared_ptr src_proto;
86-
87- protoerr= plugin::StorageEngine::getTableDefinition(session,
88- src_table,
89- src_proto);
90- new_proto.CopyFrom(*src_proto);
91+ // We require an additional table message because during parsing we used
92+ // a "new" message and it will not have all of the information that the
93+ // source table message would have.
94+ message::Table new_table_message;
95+ drizzled::error_t error;
96+
97+ message::table::shared_ptr source_table_message= plugin::StorageEngine::getTableMessage(session, source_identifier, error);
98+
99+ if (not source_table_message)
100+ {
101+ my_error(ER_TABLE_UNKNOWN, source_identifier);
102+ return false;
103+ }
104+
105+ new_table_message.CopyFrom(*source_table_message);
106
107 if (destination_identifier.isTmp())
108 {
109- new_proto.set_type(message::Table::TEMPORARY);
110+ new_table_message.set_type(message::Table::TEMPORARY);
111 }
112 else
113 {
114- new_proto.set_type(message::Table::STANDARD);
115+ new_table_message.set_type(message::Table::STANDARD);
116 }
117
118 if (is_engine_set)
119 {
120- new_proto.mutable_engine()->set_name(create_table_proto.engine().name());
121+ new_table_message.mutable_engine()->set_name(create_table_proto.engine().name());
122 }
123
124 { // We now do a selective copy of elements on to the new table.
125- new_proto.set_name(create_table_proto.name());
126- new_proto.set_schema(create_table_proto.schema());
127- new_proto.set_catalog(create_table_proto.catalog());
128+ new_table_message.set_name(create_table_proto.name());
129+ new_table_message.set_schema(create_table_proto.schema());
130+ new_table_message.set_catalog(create_table_proto.catalog());
131 }
132
133- if (protoerr && protoerr != EEXIST)
134+ /* Fix names of foreign keys being added */
135+ for (int32_t j= 0; j < new_table_message.fk_constraint_size(); j++)
136 {
137- if (errno == ENOENT)
138- my_error(ER_BAD_DB_ERROR,MYF(0), destination_identifier.getSchemaName().c_str());
139- else
140- my_error(ER_CANT_CREATE_FILE, MYF(0), destination_identifier.getPath().c_str(), errno);
141-
142- return false;
143+ if (new_table_message.fk_constraint(j).has_name())
144+ {
145+ std::string name(new_table_message.name());
146+ char number[20];
147+
148+ name.append("_ibfk_");
149+ snprintf(number, sizeof(number), "%d", j+1);
150+ name.append(number);
151+
152+ message::Table::ForeignKeyConstraint *pfkey= new_table_message.mutable_fk_constraint(j);
153+ pfkey->set_name(name);
154+ }
155 }
156
157 /*
158@@ -2049,12 +2064,12 @@
159 */
160 bool success= plugin::StorageEngine::createTable(session,
161 destination_identifier,
162- new_proto);
163+ new_table_message);
164
165 if (success && not destination_identifier.isTmp())
166 {
167 TransactionServices &transaction_services= TransactionServices::singleton();
168- transaction_services.createTable(&session, new_proto);
169+ transaction_services.createTable(&session, new_table_message);
170 }
171
172 return success;
173@@ -2076,31 +2091,14 @@
174 */
175
176 bool create_like_table(Session* session,
177- const TableIdentifier &destination_identifier,
178- TableList* table, TableList* src_table,
179+ TableIdentifier::const_reference destination_identifier,
180+ TableIdentifier::const_reference source_identifier,
181 message::Table &create_table_proto,
182 bool is_if_not_exists,
183 bool is_engine_set)
184 {
185 bool res= true;
186- uint32_t not_used;
187-
188- /*
189- By opening source table we guarantee that it exists and no concurrent
190- DDL operation will mess with it. Later we also take an exclusive
191- name-lock on target table name, which makes copying of .frm cursor,
192- call to plugin::StorageEngine::createTable() and binlogging atomic
193- against concurrent DML and DDL operations on target table.
194- Thus by holding both these "locks" we ensure that our statement is
195- properly isolated from all concurrent operations which matter.
196- */
197- if (session->open_tables_from_list(&src_table, &not_used))
198- return true;
199-
200- TableIdentifier src_identifier(src_table->table->getShare()->getSchemaName(),
201- src_table->table->getShare()->getTableName(), src_table->table->getShare()->getType());
202-
203-
204+ bool table_exists= false;
205
206 /*
207 Check that destination tables does not exist. Note that its name
208@@ -2108,7 +2106,6 @@
209
210 For temporary tables we don't aim to grab locks.
211 */
212- bool table_exists= false;
213 if (destination_identifier.isTmp())
214 {
215 if (session->find_temporary_table(destination_identifier))
216@@ -2117,8 +2114,11 @@
217 }
218 else
219 {
220- bool was_created= create_table_wrapper(*session, create_table_proto, destination_identifier,
221- src_identifier, is_engine_set);
222+ bool was_created= create_table_wrapper(*session,
223+ create_table_proto,
224+ destination_identifier,
225+ source_identifier,
226+ is_engine_set);
227 if (not was_created) // This is pretty paranoid, but we assume something might not clean up after itself
228 {
229 (void) session->rm_temporary_table(destination_identifier, true);
230@@ -2163,7 +2163,7 @@
231 {
232 boost_unique_lock_t lock(table::Cache::singleton().mutex()); /* We lock for CREATE TABLE LIKE to copy table definition */
233 was_created= create_table_wrapper(*session, create_table_proto, destination_identifier,
234- src_identifier, is_engine_set);
235+ source_identifier, is_engine_set);
236 }
237
238 // So we blew the creation of the table, and we scramble to clean up
239@@ -2191,18 +2191,18 @@
240 {
241 char warn_buff[DRIZZLE_ERRMSG_SIZE];
242 snprintf(warn_buff, sizeof(warn_buff),
243- ER(ER_TABLE_EXISTS_ERROR), table->getTableName());
244+ ER(ER_TABLE_EXISTS_ERROR), destination_identifier.getTableName().c_str());
245 push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_NOTE,
246- ER_TABLE_EXISTS_ERROR,warn_buff);
247- res= false;
248- }
249- else
250- {
251- my_error(ER_TABLE_EXISTS_ERROR, MYF(0), table->getTableName());
252- }
253+ ER_TABLE_EXISTS_ERROR, warn_buff);
254+ return false;
255+ }
256+
257+ my_error(ER_TABLE_EXISTS_ERROR, destination_identifier);
258+
259+ return true;
260 }
261
262- return(res);
263+ return res;
264 }
265
266
267
268=== modified file 'drizzled/sql_table.h'
269--- drizzled/sql_table.h 2010-12-24 07:15:43 +0000
270+++ drizzled/sql_table.h 2011-01-14 01:53:54 +0000
271@@ -50,11 +50,11 @@
272 enum ha_extra_function function);
273
274 bool check_table(Session* session, TableList* table_list,
275- HA_CHECK_OPT* check_opt);
276+ HA_CHECK_OPT* check_opt);
277 bool analyze_table(Session* session, TableList* table_list,
278- HA_CHECK_OPT* check_opt);
279+ HA_CHECK_OPT* check_opt);
280 bool optimize_table(Session* session, TableList* table_list,
281- HA_CHECK_OPT* check_opt);
282+ HA_CHECK_OPT* check_opt);
283
284 void write_bin_log(Session *session, const std::string &query);
285
286
287=== modified file 'drizzled/statement/create_table.cc'
288--- drizzled/statement/create_table.cc 2011-01-09 22:15:22 +0000
289+++ drizzled/statement/create_table.cc 2011-01-14 01:53:54 +0000
290@@ -129,7 +129,8 @@
291 Select_Lex *select_lex= &session->lex->select_lex;
292 TableList *select_tables= session->lex->query_tables;
293
294- do {
295+ do
296+ {
297 if (select_lex->item_list.elements) // With select
298 {
299 Select_Lex_Unit *unit= &session->lex->unit;
300@@ -201,8 +202,8 @@
301 {
302 res= create_like_table(session,
303 new_table_identifier,
304- create_table_list,
305- select_tables,
306+ TableIdentifier(select_tables->getSchemaName(),
307+ select_tables->getTableName()),
308 createTableMessage(),
309 session->getLex()->exists(),
310 is_engine_set);
311
312=== modified file 'tests/r/create.result'
313--- tests/r/create.result 2011-01-11 05:13:54 +0000
314+++ tests/r/create.result 2011-01-14 01:53:54 +0000
315@@ -362,15 +362,15 @@
316 select * from t2;
317 id name
318 create table t3 like t1;
319-ERROR 42S01: Table 't3' already exists
320+ERROR 42S01: Table 'test.t3' already exists
321 create table t3 like mysqltest.t3;
322-ERROR 42S01: Table 't3' already exists
323+ERROR 42S01: Table 'test.t3' already exists
324 create table non_existing_database.t1 like t1;
325 ERROR 42000: Unknown schema 'non_existing_database'
326-create table t3 like non_existing_table;
327-ERROR 42S02: Table 'test.non_existing_table' doesn't exist
328+create table t4 like non_existing_table;
329+ERROR HY000: Unknown table 'test.non_existing_table'
330 create temporary table t3 like t1;
331-ERROR 42S01: Table 't3' already exists
332+ERROR 42S01: Table 'test.#t3' already exists
333 drop table t1, t2, t3;
334 drop database mysqltest;
335 SET SESSION storage_engine="MEMORY";
336
337=== added file 'tests/suite/regression/r/622465.result'
338--- tests/suite/regression/r/622465.result 1970-01-01 00:00:00 +0000
339+++ tests/suite/regression/r/622465.result 2011-01-14 01:53:54 +0000
340@@ -0,0 +1,12 @@
341+CREATE TABLE t1 (id INT PRIMARY KEY);
342+CREATE TABLE `t2` LIKE `t1`;
343+ALTER TABLE `t2` ADD FOREIGN KEY (`id`) REFERENCES `t1`(`id`);
344+CREATE TABLE `t3` LIKE `t2`;
345+SHOW CREATE TABLE t3;
346+Table Create Table
347+t3 CREATE TABLE `t3` (
348+ `id` INT NOT NULL,
349+ PRIMARY KEY (`id`),
350+ CONSTRAINT `t3_ibfk_1` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
351+) ENGINE=InnoDB COLLATE = utf8_general_ci
352+DROP TABLE t2, t3, t1;
353
354=== added file 'tests/suite/regression/t/622465.test'
355--- tests/suite/regression/t/622465.test 1970-01-01 00:00:00 +0000
356+++ tests/suite/regression/t/622465.test 2011-01-14 01:53:54 +0000
357@@ -0,0 +1,10 @@
358+# Make sure that foreign keys transfer with CREATE TABLE LIKE
359+CREATE TABLE t1 (id INT PRIMARY KEY);
360+
361+CREATE TABLE `t2` LIKE `t1`;
362+ALTER TABLE `t2` ADD FOREIGN KEY (`id`) REFERENCES `t1`(`id`);
363+
364+CREATE TABLE `t3` LIKE `t2`;
365+SHOW CREATE TABLE t3;
366+
367+DROP TABLE t2, t3, t1;
368
369=== modified file 'tests/t/create.test'
370--- tests/t/create.test 2011-01-11 05:13:54 +0000
371+++ tests/t/create.test 2011-01-14 01:53:54 +0000
372@@ -314,20 +314,28 @@
373 create database mysqltest;
374 create table mysqltest.t3 like t1;
375 create temporary table t3 like mysqltest.t3;
376+
377 --replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
378 show create table t3;
379+
380 create table t2 like t3;
381+
382 --replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
383 show create table t2;
384 select * from t2;
385+
386 --error ER_TABLE_EXISTS_ERROR
387 create table t3 like t1;
388+
389 --error ER_TABLE_EXISTS_ERROR
390 create table t3 like mysqltest.t3;
391+
392 --error ER_BAD_DB_ERROR
393 create table non_existing_database.t1 like t1;
394---error ER_NO_SUCH_TABLE
395-create table t3 like non_existing_table;
396+
397+--error ER_TABLE_UNKNOWN
398+create table t4 like non_existing_table;
399+
400 --error ER_TABLE_EXISTS_ERROR
401 create temporary table t3 like t1;
402 drop table t1, t2, t3;

Subscribers

People subscribed via source and target branches