From 8fceadc73b00306f1f94024e26723aa6e4f260f2 Mon Sep 17 00:00:00 2001 From: Andrew McDonnell Date: Sun, 11 Aug 2013 00:30:55 +0930 Subject: [PATCH 1/2] Updated regression test to force repeat of 1134355. A 'fix' in sql_table, causes assertion in ha_oqgraph --- mysql-test/suite/oqgraph/regression_1134355.test | 15 ++++++++++++--- sql/sql_table.cc | 15 +++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/mysql-test/suite/oqgraph/regression_1134355.test b/mysql-test/suite/oqgraph/regression_1134355.test index 95054308b43..e0a3ba5ba7b 100644 --- a/mysql-test/suite/oqgraph/regression_1134355.test +++ b/mysql-test/suite/oqgraph/regression_1134355.test @@ -9,6 +9,8 @@ DROP TABLE IF EXISTS graph; CREATE TABLE graph_base ( from_id INT UNSIGNED NOT NULL, to_id INT UNSIGNED NOT NULL, + another_id INT UNSIGNED NOT NULL DEFAULT 1, + w DOUBLE NOT NULL DEFAULT 1, PRIMARY KEY (from_id,to_id), INDEX (to_id) ) ENGINE=MyISAM; @@ -23,7 +25,7 @@ CREATE TABLE graph ( linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH - ) ENGINE=OQGRAPH DATA_TABLE='graph_base' ORIGID='from_id', DESTID='to_id'; + ) ENGINE=OQGRAPH DATA_TABLE='graph_base' ORIGID='from_id', DESTID='to_id', WEIGHT='w'; # -- do some stuff @@ -35,8 +37,15 @@ INSERT INTO graph_base(from_id, to_id) VALUES (3,4), (4,3); SELECT * from graph; SELECT * FROM graph WHERE destid=2 and origid=1; -# -- trigger bug -# --error 1296 # commented out at the moment because the message is corrupted +# We cant do this anyway because of read onlyness of table.... 1036 == read only +--error 1036 +alter table graph ORIGID = 'another_id'; + +# But we need that to hold even in an invalid situation! +# -- bug was: the following alter table would crash, instead of returning error 1296 +# -- currently following may not crash, but does with the previous error 1036 causing statement present +# 'attribute not set to a valid column of 'xxx' - note currently truncating to graph_b instead of graph_base for some reason... +--error 1296 alter table graph ORIGID = 'something_else'; DELETE FROM graph_base; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 3c094e1740e..423b4bc1b5a 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -6093,6 +6093,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, uint *index_add_buffer= NULL; uint candidate_key_count= 0; bool no_pk; + engine_option_value *undo_option_list = NULL; ulong explicit_used_fields= 0; enum ha_extra_function extra_func= thd->locked_tables_mode ? HA_EXTRA_NOT_USED @@ -6500,6 +6501,16 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, if (is_index_maintenance_unique (table, alter_info)) need_copy_table= ALTER_TABLE_DATA_CHANGED; + + // This modifies the options list of table + // we need to save the current end of list so we can de-link if + // there is a failure to copy_data_between_tables() (and posibly other cases?) + if (table->s->option_list) { + engine_option_value *end; + for (end= table->s->option_list; end->next; end= end->next) { undo_option_list = end; } + } + + if (mysql_prepare_alter_table(thd, table, create_info, alter_info)) goto err; @@ -6898,6 +6909,10 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, order_num, order, &copied, &deleted, alter_info->keys_onoff, alter_info->error_if_not_empty); + + if (error && undo_option_list) { + undo_option_list->next = NULL; // delink create_options, which will still get freed (which was causing a segfault on subsequent alter) + } } else { From 6bcf87db73edbbc8d5dd88859945433584f68882 Mon Sep 17 00:00:00 2001 From: Andrew McDonnell Date: Thu, 15 Aug 2013 23:04:10 +0930 Subject: [PATCH 2/2] Change table option struct to use const as per ha_example.cc --- storage/oqgraph/ha_oqgraph.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/storage/oqgraph/ha_oqgraph.cc b/storage/oqgraph/ha_oqgraph.cc index 77e22aa4033..935015cd52a 100644 --- a/storage/oqgraph/ha_oqgraph.cc +++ b/storage/oqgraph/ha_oqgraph.cc @@ -109,11 +109,11 @@ static const char *latchToCode(int latch) { struct oqgraph_table_option_struct { - char *table_name; + const char *table_name; - char *origid; // name of the origin id column - char *destid; // name of the target id column - char *weight; // name of the weight column (optional) + const char *origid; // name of the origin id column + const char *destid; // name of the target id column + const char *weight; // name of the weight column (optional) }; #define ha_table_option_struct oqgraph_table_option_struct