From 296e12233c6ed3342bce37535c6d6b3a4f5aa264 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 13 Jan 2005 13:03:05 -0800 Subject: [PATCH 01/54] change to have_<> variable for federated engine sql/set_var.cc: changed 'have_federated_db' to 'have_federated_engine' for consitency, per Paul Dubois --- sql/set_var.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/set_var.cc b/sql/set_var.cc index 957cacc91ac..1c380f6f0f9 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -732,7 +732,7 @@ struct show_var_st init_vars[]= { {"have_crypt", (char*) &have_crypt, SHOW_HAVE}, {"have_csv", (char*) &have_csv_db, SHOW_HAVE}, {"have_example_engine", (char*) &have_example_db, SHOW_HAVE}, - {"have_federated_db", (char*) &have_federated_db, SHOW_HAVE}, + {"have_federated_engine", (char*) &have_federated_db, SHOW_HAVE}, {"have_geometry", (char*) &have_geometry, SHOW_HAVE}, {"have_innodb", (char*) &have_innodb, SHOW_HAVE}, {"have_isam", (char*) &have_isam, SHOW_HAVE}, From 9aaa87e909484a9c12b2a5e8913da45f8b7d0e9d Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 13 Jan 2005 18:21:54 -0800 Subject: [PATCH 02/54] progress in fixing multi-key, two-byte prefix keys. sql/ha_federated.cc: added code to handle multi-keys (per monty). This code still fails to compile because sql_analyse.cc's method, append_escaped only accepts two string pointers. I don't know if append_escaped will be overloaded to accept string pointer, byte/char pointer, and length, as is being passed in this example. Need to talk to devs/monty about this. sql/ha_federated.h: added method declaration of create_where_from_key --- sql/ha_federated.cc | 152 ++++++++++++++++++++++++++++++++++++++++---- sql/ha_federated.h | 1 + 2 files changed, 140 insertions(+), 13 deletions(-) diff --git a/sql/ha_federated.cc b/sql/ha_federated.cc index abd33f2eaef..0feccc94334 100644 --- a/sql/ha_federated.cc +++ b/sql/ha_federated.cc @@ -586,6 +586,103 @@ uint ha_federated::convert_row_to_internal_format(byte *record, MYSQL_ROW row) DBUG_RETURN(0); } +bool ha_federated::create_where_from_key( + String *to, + KEY *key_info, + const byte *key, + uint key_length + ) +{ + uint second_loop= 0; + KEY_PART_INFO *key_part; + + DBUG_ENTER("ha_federated::create_where_from_key"); + for (key_part= key_info->key_part ; (int) key_length > 0 ; key_part++) + { + Field *field= key_part->field; + uint length= key_part->length; + + if (second_loop++ && to->append(" AND ",5)) + DBUG_RETURN(1); + if (to->append('`') || to->append(field->field_name) || + to->append("` ",2)) + DBUG_RETURN(1); // Out of memory + + if (key_part->null_bit) + { + if (*key++) + { + if (to->append("IS NULL",7)) + DBUG_RETURN(1); + key_length-= key_part->store_length; + key+= key_part->store_length-1; + continue; + } + key_length--; + } + if (to->append('=')) + DBUG_RETURN(1); + if (key_part->type == HA_KEYTYPE_BIT) + { + /* This is can be threated as a hex string */ + Field_bit *field= (Field_bit *) (key_part->field); + char buff[64+2], *ptr; + byte *end= key + length; + + buff[0]='0'; + buff[1]='x'; + for (ptr= buff+2 ; key < end ; key++) + { + uint tmp= (uint) (uchar) *key; + *ptr++=_dig_vec_upper[tmp >> 4]; + *ptr++=_dig_vec_upper[tmp & 15]; + } + if (to->append(buff, (uint) (ptr-buff))) + DBUG_RETURN(1); + key_length-= length; + continue; + } + if (key_part->key_part_flag & HA_BLOB_PART) + { + uint blob_length= uint2korr(key); + key+= HA_KEY_BLOB_LENGTH; + key_length-= HA_KEY_BLOB_LENGTH; + if (append_escaped(to, key, blob_length)) + DBUG_RETURN(1); + length= key_part->length; + } + else if (key_part->key_part_flag & HA_VAR_LENGTH_PART) + { + key_length-= HA_KEY_BLOB_LENGTH; + length= key_part->length; + key+= HA_KEY_BLOB_LENGTH; + if (append_escaped(to, key, length)) + DBUG_RETURN(1); + } + else + { + //bool need_quotes= field->needs_quotes(); + bool needs_quotes= type_quote(field->type()); + char buff[MAX_FIELD_WIDTH]; + String str(buff, sizeof(buff), field->charset()), *res; + + if (needs_quotes && to->append('=')) + DBUG_RETURN(1); + res= field->val_str(&str, (char *)(key)); + if (field->result_type() == STRING_RESULT) + { + if (append_escaped(to, res->ptr(), res->length())) + DBUG_RETURN(1); + } + else if (to->append(res->ptr(), res->length())) + DBUG_RETURN(1); + if (needs_quotes && to->append('=')) + DBUG_RETURN(1); + } + key+= length; + key_length-= length; + } +} /* SYNOPSIS quote_data() @@ -612,13 +709,13 @@ void ha_federated::quote_data(String *unquoted_string, Field *field ) int quote_flag; DBUG_ENTER("ha_federated::quote_data"); + DBUG_PRINT("ha_federated::quote_data", + ("unescaped %s", unquoted_string->c_ptr_quick())); // this is the same call that mysql_real_escape_string() calls - escape_string_for_mysql(&my_charset_bin, (char *)escaped_string, + escape_string_for_mysql(&my_charset_bin, (char *)escaped_string, unquoted_string->c_ptr_quick(), unquoted_string->length()); - DBUG_PRINT("ha_federated::quote_data", - ("escape_string_for_mysql unescaped %s escaped %s", - unquoted_string->c_ptr_quick(), escaped_string)); + DBUG_PRINT("ha_federated::quote_data",("escaped %s",escaped_string)); if (field->is_null()) { @@ -630,6 +727,9 @@ void ha_federated::quote_data(String *unquoted_string, Field *field ) quote_flag= type_quote(field->type()); + DBUG_PRINT("ha_federated::quote_data", + ("quote flag %d type %d", quote_flag, field->type())); + if (quote_flag == 0) { DBUG_PRINT("ha_federated::quote_data", @@ -1067,9 +1167,10 @@ int ha_federated::write_row(byte * buf) // append commas between both fields and fieldnames insert_string.append(','); values_string.append(','); - DBUG_PRINT("ha_federated::write_row", - ("insert_string %s values_string %s insert_field_value_string %s", - insert_string.c_ptr_quick(), values_string.c_ptr_quick(), insert_field_value_string.c_ptr_quick())); + DBUG_PRINT("ha_federated::write_row", + ("insert_string %s values_string %s insert_field_value_string %s", + insert_string.c_ptr_quick(), values_string.c_ptr_quick(), + insert_field_value_string.c_ptr_quick())); } } @@ -1365,30 +1466,55 @@ int ha_federated::index_read_idx(byte * buf, uint index, const byte * key, __attribute__((unused))) { char index_value[IO_SIZE]; + char key_value[IO_SIZE]; + char test_value[IO_SIZE]; String index_string(index_value, sizeof(index_value), &my_charset_bin); + String test_string(test_value, sizeof(test_value), &my_charset_bin); index_string.length(0); + test_string.length(0); + uint keylen; char sql_query_buffer[IO_SIZE]; + String tmp_string; String sql_query(sql_query_buffer, sizeof(sql_query_buffer), &my_charset_bin); sql_query.length(0); DBUG_ENTER("ha_federated::index_read_idx"); statistic_increment(table->in_use->status_var.ha_read_key_count,&LOCK_status); - index_string.length(0); - sql_query.length(0); - sql_query.append(share->select_query); sql_query.append(" WHERE "); sql_query.append(table->key_info[index].key_part->field->field_name); sql_query.append(" = "); - table->key_info[index].key_part->field->val_str(&index_string, (char *)(key)); + if (table->key_info[index].key_part->field->type() == MYSQL_TYPE_VARCHAR) + { + //keylen= uint2korr(key); + keylen= key[0]; + create_where_from_key(&tmp_string, &table->key_info[index], key, keylen); + memcpy(key_value, key + HA_KEY_BLOB_LENGTH, keylen); + key_value[keylen]= 0; + DBUG_PRINT("ha_federated::index_read_idx", + ("key_value %s len %d", key_value, keylen)); + index_string.append(key_value); + } + else + { + //table->key_info[index].key_part->field->val_str(&index_string, (char + //*)(key)); + index_string.append((char *)(key)); + } + DBUG_PRINT("ha_federated::index_read_idx", + ("current key %d key value %s index_string value %s length %d", index, (char *)(key),index_string.c_ptr_quick(), + index_string.length())); + + //table->key_info[index].key_part->field->val_str(&index_string); quote_data(&index_string, table->key_info[index].key_part->field); sql_query.append(index_string); DBUG_PRINT("ha_federated::index_read_idx", - ("sql_query %s", sql_query.c_ptr_quick())); + ("current position %d sql_query %s", current_position, + sql_query.c_ptr_quick())); if (mysql_real_query(mysql, sql_query.c_ptr_quick(), sql_query.length())) { @@ -1539,7 +1665,7 @@ int ha_federated::rnd_pos(byte * buf, byte *pos) { DBUG_ENTER("ha_federated::rnd_pos"); statistic_increment(table->in_use->status_var.ha_read_rnd_count,&LOCK_status); - memcpy(current_position, pos, sizeof(MYSQL_ROW_OFFSET)); // pos is not aligned + memcpy_fixed(¤t_position, pos, sizeof(MYSQL_ROW_OFFSET)); // pos is not aligned result->current_row= 0; result->data_cursor= current_position; DBUG_RETURN(rnd_next(buf)); diff --git a/sql/ha_federated.h b/sql/ha_federated.h index c11960a836f..ce35ce96828 100755 --- a/sql/ha_federated.h +++ b/sql/ha_federated.h @@ -75,6 +75,7 @@ private: uint convert_row_to_internal_format(byte *buf, MYSQL_ROW row); uint type_quote(int type); void quote_data(String *string1, Field *field); + bool ha_federated::create_where_from_key(String *to, KEY *key_info, const byte *key, uint key_length); public: ha_federated(TABLE *table): handler(table), From 353bc07096fae7fd74cb315e445bc4b253cea5b5 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 19 Jan 2005 21:13:30 +0100 Subject: [PATCH 03/54] BUG#6034 - Error code 124: Wrong medium type. Version for 4.0. Committed for merge. If the result table is one of the select tables in INSERT SELECT, we must not disable the result tables indexes before selecting. mysql_execute_command() detects the match for other reasons and adds the flag OPTION_BUFFER_RESULT to the 'select_options'. In this case the result is put into a temporary table first. Hence, we can defer the preparation of the insert table until the result is to be used. mysql-test/r/insert_select.result: BUG#6034 - Error code 124: Wrong medium type. The test results. mysql-test/t/insert_select.test: BUG#6034 - Error code 124: Wrong medium type. The test case. sql/sql_select.cc: BUG#6034 - Error code 124: Wrong medium type. With OPTION_BUFFER_RESULT in the 'select_options', defer the preparation of the insert table until the result is to be used. Unfortunately, this happens at several places. --- mysql-test/r/insert_select.result | 12 ++++++++++++ mysql-test/t/insert_select.test | 15 +++++++++++++++ sql/sql_select.cc | 26 +++++++++++++++++++++++++- 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/insert_select.result b/mysql-test/r/insert_select.result index ecd26f2d9fb..506f95f61bb 100644 --- a/mysql-test/r/insert_select.result +++ b/mysql-test/r/insert_select.result @@ -632,3 +632,15 @@ No Field Count 0 1 100 0 2 100 drop table t1, t2; +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +NO int(11) NOT NULL default '0', +SEQ int(11) NOT NULL default '0', +PRIMARY KEY (ID), +KEY t1$NO (SEQ,NO) +) TYPE=MyISAM; +INSERT INTO t1 (SEQ, NO) SELECT "1" AS SEQ, IF(MAX(NO) IS NULL, 0, MAX(NO)) + 1 AS NO FROM t1 WHERE (SEQ = 1); +select SQL_BUFFER_RESULT * from t1 WHERE (SEQ = 1); +ID NO SEQ +1 1 1 +drop table t1; diff --git a/mysql-test/t/insert_select.test b/mysql-test/t/insert_select.test index deb80dbcdbf..a54f8c4bfb5 100644 --- a/mysql-test/t/insert_select.test +++ b/mysql-test/t/insert_select.test @@ -176,3 +176,18 @@ insert into t2 Select null, Field, Count From t1 Where Month=20030901 and Type=2 select * from t2; drop table t1, t2; + +# +# BUG#6034 - Error code 124: Wrong medium type +# +CREATE TABLE t1 ( + ID int(11) NOT NULL auto_increment, + NO int(11) NOT NULL default '0', + SEQ int(11) NOT NULL default '0', + PRIMARY KEY (ID), + KEY t1$NO (SEQ,NO) +) TYPE=MyISAM; +INSERT INTO t1 (SEQ, NO) SELECT "1" AS SEQ, IF(MAX(NO) IS NULL, 0, MAX(NO)) + 1 AS NO FROM t1 WHERE (SEQ = 1); +select SQL_BUFFER_RESULT * from t1 WHERE (SEQ = 1); +drop table t1; + diff --git a/sql/sql_select.cc b/sql/sql_select.cc index eda4ce73186..0d7ee1eb125 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -223,6 +223,8 @@ mysql_select(THD *thd,TABLE_LIST *tables,List &fields,COND *conds, bool no_order; /* Is set if we have a GROUP BY and we have ORDER BY on a constant. */ bool skip_sort_order; + /* We cannot always prepare the result before selecting. */ + bool is_result_prepared; ha_rows select_limit; Item::cond_result cond_value; SQL_SELECT *select; @@ -360,7 +362,17 @@ mysql_select(THD *thd,TABLE_LIST *tables,List &fields,COND *conds, DBUG_RETURN(-1); } #endif - if (!procedure && result->prepare(fields)) + /* + We must not yet prepare the result table if it is the same as one of the + source tables (INSERT SELECT). This is checked in mysql_execute_command() + and OPTION_BUFFER_RESULT is added to the select_options. A temporary + table is then used to hold the result. The preparation may disable + indexes on the result table, which may be used during the select, if it + is the same table (Bug #6034). Do the preparation after the select phase. + */ + if ((is_result_prepared= (! procedure && + ! test(select_options & OPTION_BUFFER_RESULT))) && + result->prepare(fields)) { /* purecov: inspected */ DBUG_RETURN(-1); /* purecov: inspected */ } @@ -392,6 +404,8 @@ mysql_select(THD *thd,TABLE_LIST *tables,List &fields,COND *conds, } if (cond_value == Item::COND_FALSE || !thd->select_limit) { /* Impossible cond */ + if (! is_result_prepared && ! procedure && result->prepare(fields)) + goto err; error=return_zero_rows(&join, result, tables, fields, join.tmp_table_param.sum_func_count != 0 && !group, select_options,"Impossible WHERE",having, @@ -417,6 +431,8 @@ mysql_select(THD *thd,TABLE_LIST *tables,List &fields,COND *conds, } if (res < 0) { + if (! is_result_prepared && ! procedure && result->prepare(fields)) + goto err; error=return_zero_rows(&join, result, tables, fields, !group, select_options,"No matching min/max row", having,procedure); @@ -439,6 +455,8 @@ mysql_select(THD *thd,TABLE_LIST *tables,List &fields,COND *conds, describe_info(&join, "No tables used"); else { + if (! is_result_prepared && ! procedure && result->prepare(fields)) + goto err; result->send_fields(fields,1); if (!having || having->val_int()) { @@ -474,6 +492,8 @@ mysql_select(THD *thd,TABLE_LIST *tables,List &fields,COND *conds, if (join.const_table_map != join.found_const_table_map && !(select_options & SELECT_DESCRIBE)) { + if (! is_result_prepared && ! procedure && result->prepare(fields)) + goto err; error=return_zero_rows(&join,result,tables,fields, join.tmp_table_param.sum_func_count != 0 && !group,0,"no matching row in const table",having, @@ -520,6 +540,8 @@ mysql_select(THD *thd,TABLE_LIST *tables,List &fields,COND *conds, } if (make_join_select(&join,select,conds)) { + if (! is_result_prepared && ! procedure && result->prepare(fields)) + goto err; error=return_zero_rows(&join, result, tables, fields, join.tmp_table_param.sum_func_count != 0 && !group, select_options, @@ -926,6 +948,8 @@ mysql_select(THD *thd,TABLE_LIST *tables,List &fields,COND *conds, goto err; count_field_types(&join.tmp_table_param,all_fields,0); } + else if (! is_result_prepared && result->prepare(fields)) + goto err; if (join.group || join.tmp_table_param.sum_func_count || (procedure && (procedure->flags & PROC_GROUP))) { From 699a530a0a7915a50ed2e042ff7e5f088f9d359a Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 19 Jan 2005 21:16:27 +0100 Subject: [PATCH 04/54] BUG#6034 - Error code 124: Wrong medium type. Version for 4.1. Committed for merge. If the result table is one of the select tables in INSERT SELECT, we must not disable the result tables indexes before selecting. mysql_execute_command() detects the match for other reasons and adds the flag OPTION_BUFFER_RESULT to the 'select_options'. In this case the result is put into a temporary table first. Hence, we can defer the preparation of the insert table until the result is to be used. mysql-test/r/insert_select.result: BUG#6034 - Error code 124: Wrong medium type. The test results. mysql-test/t/insert_select.test: BUG#6034 - Error code 124: Wrong medium type. The test case. sql/sql_select.cc: BUG#6034 - Error code 124: Wrong medium type. With OPTION_BUFFER_RESULT in the 'select_options', defer the preparation of the insert table until the result is to be used. --- mysql-test/r/insert_select.result | 12 ++++++++++++ mysql-test/t/insert_select.test | 15 +++++++++++++++ sql/sql_select.cc | 18 +++++++++++++++++- 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/insert_select.result b/mysql-test/r/insert_select.result index 0a6a34f9a58..f5ad0c87881 100644 --- a/mysql-test/r/insert_select.result +++ b/mysql-test/r/insert_select.result @@ -638,3 +638,15 @@ No Field Count 0 1 100 0 2 100 drop table t1, t2; +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +NO int(11) NOT NULL default '0', +SEQ int(11) NOT NULL default '0', +PRIMARY KEY (ID), +KEY t1$NO (SEQ,NO) +) ENGINE=MyISAM; +INSERT INTO t1 (SEQ, NO) SELECT "1" AS SEQ, IF(MAX(NO) IS NULL, 0, MAX(NO)) + 1 AS NO FROM t1 WHERE (SEQ = 1); +select SQL_BUFFER_RESULT * from t1 WHERE (SEQ = 1); +ID NO SEQ +1 1 1 +drop table t1; diff --git a/mysql-test/t/insert_select.test b/mysql-test/t/insert_select.test index e1459310bb9..39b8bfcaaaa 100644 --- a/mysql-test/t/insert_select.test +++ b/mysql-test/t/insert_select.test @@ -182,3 +182,18 @@ insert into t2 Select null, Field, Count From t1 Where Month=20030901 and Type=2 select * from t2; drop table t1, t2; + +# +# BUG#6034 - Error code 124: Wrong medium type +# +CREATE TABLE t1 ( + ID int(11) NOT NULL auto_increment, + NO int(11) NOT NULL default '0', + SEQ int(11) NOT NULL default '0', + PRIMARY KEY (ID), + KEY t1$NO (SEQ,NO) +) ENGINE=MyISAM; +INSERT INTO t1 (SEQ, NO) SELECT "1" AS SEQ, IF(MAX(NO) IS NULL, 0, MAX(NO)) + 1 AS NO FROM t1 WHERE (SEQ = 1); +select SQL_BUFFER_RESULT * from t1 WHERE (SEQ = 1); +drop table t1; + diff --git a/sql/sql_select.cc b/sql/sql_select.cc index aea7cb9ed6d..7e48374a8e6 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -398,7 +398,16 @@ JOIN::prepare(Item ***rref_pointer_array, goto err; } #endif - if (!procedure && result && result->prepare(fields_list, unit_arg)) + /* + We must not yet prepare the result table if it is the same as one of the + source tables (INSERT SELECT). This is checked in mysql_execute_command() + and OPTION_BUFFER_RESULT is added to the select_options. A temporary + table is then used to hold the result. The preparation may disable + indexes on the result table, which may be used during the select, if it + is the same table (Bug #6034). Do the preparation after the select phase. + */ + if (! procedure && ! test(select_options & OPTION_BUFFER_RESULT) && + result && result->prepare(fields_list, unit_arg)) goto err; /* purecov: inspected */ if (select_lex->olap == ROLLUP_TYPE && rollup_init()) @@ -1043,6 +1052,13 @@ JOIN::exec() DBUG_VOID_RETURN; } } + else if (test(select_options & OPTION_BUFFER_RESULT) && + result && result->prepare(fields_list, unit)) + { + error= 1; + thd->limit_found_rows= thd->examined_row_count= 0; + DBUG_VOID_RETURN; + } if (!tables_list) { // Only test of functions From ab7f56e36559d0ad234ad5760f0c4628a3c408ea Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 19 Jan 2005 21:20:55 +0100 Subject: [PATCH 05/54] BUG#6034 - Error code 124: Wrong medium type. Version for 5.0. Committed for merge. If the result table is one of the select tables in INSERT SELECT, we must not disable the result tables indexes before selecting. Now the preparation is split into two prepare methods. The first detects the situation and defers some preparations until the second phase. mysql-test/r/insert_select.result: BUG#6034 - Error code 124: Wrong medium type. The test results. mysql-test/t/insert_select.test: BUG#6034 - Error code 124: Wrong medium type. The test case. sql/sql_class.h: BUG#6034 - Error code 124: Wrong medium type. Added a new method for deferred preparation actions. sql/sql_insert.cc: BUG#6034 - Error code 124: Wrong medium type. If the insert table is one of the select tables, a part of the result table preparations like disabling indexes has to be done after the select phase. This is now done in the new method select_insert::prepare2(). sql/sql_select.cc: BUG#6034 - Error code 124: Wrong medium type. The result table preparation is now split into prepare() and prepare2(). Disabling indexes and other preparation stuff is deferred until after the selection phase. --- mysql-test/r/insert_select.result | 12 ++++++++ mysql-test/t/insert_select.test | 15 ++++++++++ sql/sql_class.h | 2 ++ sql/sql_insert.cc | 47 ++++++++++++++++++++++++++++--- sql/sql_select.cc | 4 ++- 5 files changed, 75 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/insert_select.result b/mysql-test/r/insert_select.result index 94d33f8090b..8882b95f2d8 100644 --- a/mysql-test/r/insert_select.result +++ b/mysql-test/r/insert_select.result @@ -638,3 +638,15 @@ No Field Count 0 1 100 0 2 100 drop table t1, t2; +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +NO int(11) NOT NULL default '0', +SEQ int(11) NOT NULL default '0', +PRIMARY KEY (ID), +KEY t1$NO (SEQ,NO) +) ENGINE=MyISAM; +INSERT INTO t1 (SEQ, NO) SELECT "1" AS SEQ, IF(MAX(NO) IS NULL, 0, MAX(NO)) + 1 AS NO FROM t1 WHERE (SEQ = 1); +select SQL_BUFFER_RESULT * from t1 WHERE (SEQ = 1); +ID NO SEQ +1 1 1 +drop table t1; diff --git a/mysql-test/t/insert_select.test b/mysql-test/t/insert_select.test index 15509b06679..a5b163b3533 100644 --- a/mysql-test/t/insert_select.test +++ b/mysql-test/t/insert_select.test @@ -180,3 +180,18 @@ insert into t2 Select null, Field, Count From t1 Where Month=20030901 and Type=2 select * from t2; drop table t1, t2; + +# +# BUG#6034 - Error code 124: Wrong medium type +# +CREATE TABLE t1 ( + ID int(11) NOT NULL auto_increment, + NO int(11) NOT NULL default '0', + SEQ int(11) NOT NULL default '0', + PRIMARY KEY (ID), + KEY t1$NO (SEQ,NO) +) ENGINE=MyISAM; +INSERT INTO t1 (SEQ, NO) SELECT "1" AS SEQ, IF(MAX(NO) IS NULL, 0, MAX(NO)) + 1 AS NO FROM t1 WHERE (SEQ = 1); +select SQL_BUFFER_RESULT * from t1 WHERE (SEQ = 1); +drop table t1; + diff --git a/sql/sql_class.h b/sql/sql_class.h index ca65f011b9d..8e6204ab3a3 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1280,6 +1280,7 @@ public: unit= u; return 0; } + virtual int prepare2(void) { return 0; } /* Because of peculiarities of prepared statements protocol we need to know number of columns in the result set (if @@ -1379,6 +1380,7 @@ class select_insert :public select_result_interceptor { enum_duplicates duplic, bool ignore); ~select_insert(); int prepare(List &list, SELECT_LEX_UNIT *u); + int prepare2(void); bool send_data(List &items); virtual void store_values(List &values); void send_error(uint errcode,const char *err); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index ceb31f76953..4cb62d5e9d7 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1802,13 +1802,22 @@ select_insert::prepare(List &values, SELECT_LEX_UNIT *u) thd->lex->current_select->options|= OPTION_BUFFER_RESULT; thd->lex->current_select->join->select_options|= OPTION_BUFFER_RESULT; } - + else + { + /* + We must not yet prepare the result table if it is the same as one of the + source tables (INSERT SELECT). The preparation may disable + indexes on the result table, which may be used during the select, if it + is the same table (Bug #6034). Do the preparation after the select phase + in select_insert::prepare2(). + */ + if (info.ignore || info.handle_duplicates != DUP_ERROR) + table->file->extra(HA_EXTRA_IGNORE_DUP_KEY); + table->file->start_bulk_insert((ha_rows) 0); + } restore_record(table,s->default_values); // Get empty record table->next_number_field=table->found_next_number_field; thd->cuted_fields=0; - if (info.ignore || info.handle_duplicates != DUP_ERROR) - table->file->extra(HA_EXTRA_IGNORE_DUP_KEY); - table->file->start_bulk_insert((ha_rows) 0); thd->no_trans_update= 0; thd->abort_on_warning= (!info.ignore && (thd->variables.sql_mode & @@ -1819,6 +1828,36 @@ select_insert::prepare(List &values, SELECT_LEX_UNIT *u) } +/* + Finish the preparation of the result table. + + SYNOPSIS + select_insert::prepare2() + void + + DESCRIPTION + If the result table is the same as one of the source tables (INSERT SELECT), + the result table is not finally prepared at the join prepair phase. + Do the final preparation now. + + RETURN + 0 OK +*/ + +int select_insert::prepare2(void) +{ + DBUG_ENTER("select_insert::prepare2"); + + if (thd->lex->current_select->options & OPTION_BUFFER_RESULT) + { + if (info.ignore || info.handle_duplicates != DUP_ERROR) + table->file->extra(HA_EXTRA_IGNORE_DUP_KEY); + table->file->start_bulk_insert((ha_rows) 0); + } + return 0; +} + + void select_insert::cleanup() { /* select_insert/select_create are never re-used in prepared statement */ diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 94a2390324c..0fc4616749c 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1164,6 +1164,7 @@ JOIN::exec() DBUG_VOID_RETURN; } } + (void) result->prepare2(); // Currently, this cannot fail. if (!tables_list) { // Only test of functions @@ -13149,7 +13150,8 @@ bool JOIN::change_result(select_result *res) { DBUG_ENTER("JOIN::change_result"); result= res; - if (!procedure && result->prepare(fields_list, select_lex->master_unit())) + if (!procedure && (result->prepare(fields_list, select_lex->master_unit()) || + result->prepare2())) { DBUG_RETURN(TRUE); } From 1f6070a4b992a9e09ced0e3ec495e05f9e989fd5 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 20 Jan 2005 00:54:01 +0300 Subject: [PATCH 06/54] Fix for bug #7637: "Test failure: 'user_limits' on QNX and 64-bit systems" Made user_limits.test scheduling independant (this solves failure on QNX). Made sys_var_max_user_conn variable int sized. Changed max_user_connections from ulong to uint to be able to use it in sys_var_max_user_conn::value_ptr() (solves failures on 64-bit platforms). mysql-test/r/user_limits.result: Made test scheduling independant. mysql-test/t/user_limits.test: Made test scheduling independant. sql/mysql_priv.h: Made max_user_connections to be the same size as USER_RESOURCES::user_conn (to be able to use them in sys_var_max_user_conn::value_ptr()). sql/mysqld.cc: Made max_user_connections to be the same size as USER_RESOURCES::user_conn (to be able to use them in sys_var_max_user_conn::value_ptr()). sql/set_var.cc: sys_var::item(): Added support for int system variables. sql/set_var.h: Made sys_var_max_user_conn to be int sized variable. --- mysql-test/r/user_limits.result | 7 +++++++ mysql-test/t/user_limits.test | 8 ++++++++ sql/mysql_priv.h | 2 +- sql/mysqld.cc | 7 ++++--- sql/set_var.cc | 8 ++++++++ sql/set_var.h | 2 +- 6 files changed, 29 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/user_limits.result b/mysql-test/r/user_limits.result index b374b05e3f0..75062e97200 100644 --- a/mysql-test/r/user_limits.result +++ b/mysql-test/r/user_limits.result @@ -6,6 +6,7 @@ delete from mysql.tables_priv where user like 'mysqltest\_%'; delete from mysql.columns_priv where user like 'mysqltest\_%'; flush privileges; grant usage on *.* to mysqltest_1@localhost with max_queries_per_hour 2; +flush user_resources; select * from t1; i select * from t1; @@ -16,6 +17,7 @@ select * from t1; ERROR 42000: User 'mysqltest_1' has exceeded the 'max_questions' resource (current value: 2) drop user mysqltest_1@localhost; grant usage on *.* to mysqltest_1@localhost with max_updates_per_hour 2; +flush user_resources; select * from t1; i select * from t1; @@ -34,6 +36,7 @@ select * from t1; i drop user mysqltest_1@localhost; grant usage on *.* to mysqltest_1@localhost with max_connections_per_hour 2; +flush user_resources; select * from t1; i select * from t1; @@ -47,6 +50,7 @@ ERROR 42000: User 'mysqltest_1' has exceeded the 'max_connections' resource (cur drop user mysqltest_1@localhost; flush privileges; grant usage on *.* to mysqltest_1@localhost with max_user_connections 2; +flush user_resources; select * from t1; i select * from t1; @@ -56,6 +60,7 @@ ERROR 42000: User 'mysqltest_1' has exceeded the 'max_user_connections' resource select * from t1; i grant usage on *.* to mysqltest_1@localhost with max_user_connections 3; +flush user_resources; select * from t1; i connect(localhost,mysqltest_1,,test,MYSQL_PORT,MYSQL_SOCK); @@ -71,6 +76,7 @@ select @@session.max_user_connections, @@global.max_user_connections; @@session.max_user_connections @@global.max_user_connections 2 2 grant usage on *.* to mysqltest_1@localhost; +flush user_resources; select @@session.max_user_connections, @@global.max_user_connections; @@session.max_user_connections @@global.max_user_connections 2 2 @@ -79,6 +85,7 @@ i connect(localhost,mysqltest_1,,test,MYSQL_PORT,MYSQL_SOCK); ERROR 42000: User mysqltest_1 already has more than 'max_user_connections' active connections grant usage on *.* to mysqltest_1@localhost with max_user_connections 3; +flush user_resources; select @@session.max_user_connections, @@global.max_user_connections; @@session.max_user_connections @@global.max_user_connections 3 2 diff --git a/mysql-test/t/user_limits.test b/mysql-test/t/user_limits.test index 50c16e5e114..729894a588a 100644 --- a/mysql-test/t/user_limits.test +++ b/mysql-test/t/user_limits.test @@ -19,6 +19,8 @@ flush privileges; # Test of MAX_QUERIES_PER_HOUR limit grant usage on *.* to mysqltest_1@localhost with max_queries_per_hour 2; +# This ensures that counters are reset and makes test scheduling independent +flush user_resources; connect (mqph, localhost, mysqltest_1,,); connection mqph; select * from t1; @@ -37,6 +39,7 @@ disconnect mqph2; # Test of MAX_UPDATES_PER_HOUR limit grant usage on *.* to mysqltest_1@localhost with max_updates_per_hour 2; +flush user_resources; connect (muph, localhost, mysqltest_1,,); connection muph; select * from t1; @@ -60,6 +63,7 @@ disconnect muph2; # Test of MAX_CONNECTIONS_PER_HOUR limit grant usage on *.* to mysqltest_1@localhost with max_connections_per_hour 2; +flush user_resources; connect (mcph1, localhost, mysqltest_1,,); connection mcph1; select * from t1; @@ -86,6 +90,7 @@ drop user mysqltest_1@localhost; # We need this to reset internal mqh_used variable flush privileges; grant usage on *.* to mysqltest_1@localhost with max_user_connections 2; +flush user_resources; connect (muc1, localhost, mysqltest_1,,); connection muc1; select * from t1; @@ -102,6 +107,7 @@ select * from t1; # Changing of limit should also help (and immediately) connection default; grant usage on *.* to mysqltest_1@localhost with max_user_connections 3; +flush user_resources; connect (muc4, localhost, mysqltest_1,,); connection muc4; select * from t1; @@ -127,6 +133,7 @@ set global max_user_connections= 2; select @@session.max_user_connections, @@global.max_user_connections; # Let us check that global limit works grant usage on *.* to mysqltest_1@localhost; +flush user_resources; connect (muca1, localhost, mysqltest_1,,); connection muca1; select @@session.max_user_connections, @@global.max_user_connections; @@ -139,6 +146,7 @@ connect (muca3, localhost, mysqltest_1,,); # Now we are testing that per-account limit prevails over gloabl limit connection default; grant usage on *.* to mysqltest_1@localhost with max_user_connections 3; +flush user_resources; connect (muca3, localhost, mysqltest_1,,); connection muca3; select @@session.max_user_connections, @@global.max_user_connections; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 322b38abe13..9d20dc267d5 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1001,7 +1001,7 @@ extern ulong ha_read_count, ha_discover_count; extern ulong table_cache_size; extern ulong max_connections,max_connect_errors, connect_timeout; extern ulong slave_net_timeout; -extern ulong max_user_connections; +extern uint max_user_connections; extern my_bool timed_mutexes; extern ulong what_to_log,flush_time; extern ulong query_buff_size, thread_stack,thread_stack_min; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 35eddb0734f..3e7db0b5fd5 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -333,7 +333,8 @@ ulong delayed_insert_errors,flush_time, thread_created; ulong specialflag=0; ulong binlog_cache_use= 0, binlog_cache_disk_use= 0; ulong max_connections,max_used_connections, - max_connect_errors, max_user_connections = 0; + max_connect_errors; +uint max_user_connections= 0; ulong thread_id=1L,current_pid; my_bool timed_mutexes= 0; ulong slow_launch_threads = 0, sync_binlog_period; @@ -5246,8 +5247,8 @@ The minimum value for this variable is 4096.", REQUIRED_ARG, 32, 1, ~0L, 0, 1, 0}, {"max_user_connections", OPT_MAX_USER_CONNECTIONS, "The maximum number of active connections for a single user (0 = no limit).", - (gptr*) &max_user_connections, (gptr*) &max_user_connections, 0, GET_ULONG, - REQUIRED_ARG, 0, 1, ~0L, 0, 1, 0}, + (gptr*) &max_user_connections, (gptr*) &max_user_connections, 0, GET_UINT, + REQUIRED_ARG, 0, 1, ~0, 0, 1, 0}, {"max_write_lock_count", OPT_MAX_WRITE_LOCK_COUNT, "After this many write locks, allow some read locks to run in between.", (gptr*) &max_write_lock_count, (gptr*) &max_write_lock_count, 0, GET_ULONG, diff --git a/sql/set_var.cc b/sql/set_var.cc index 957cacc91ac..deb33cf389b 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -1599,6 +1599,14 @@ Item *sys_var::item(THD *thd, enum_var_type var_type, LEX_STRING *base) var_type= OPT_GLOBAL; } switch (type()) { + case SHOW_INT: + { + uint value; + pthread_mutex_lock(&LOCK_global_system_variables); + value= *(uint*) value_ptr(thd, var_type, base); + pthread_mutex_unlock(&LOCK_global_system_variables); + return new Item_uint((int32) value); + } case SHOW_LONG: { ulong value; diff --git a/sql/set_var.h b/sql/set_var.h index 7c9f11041c8..0f30f764ed5 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -740,7 +740,7 @@ public: return type != OPT_GLOBAL || !option_limits; } void set_default(THD *thd, enum_var_type type); - SHOW_TYPE type() { return SHOW_LONG; } + SHOW_TYPE type() { return SHOW_INT; } byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); }; From 66b62e051930dbcd9dc1d38f0cac574692932834 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 20 Jan 2005 18:36:40 -0800 Subject: [PATCH 07/54] -Added quote_data and needs_quotes (moved from federated handler. -New tests and results logging_ok: Logging to logging@openlogging.org accepted ha_federated.h: removed quote_data and type_quote (now in the Field class) ha_federated.cc: moved quote_data and type_quote to field class field.h: new methods quote_data and needs_quotes declared field.cc: new field class methods quote_data and needs_quotes (per Monty's request) federated.test: more tests, joins, index tests have_federated_db.require: new name of federated system var federated.result: new test results for federated handler have_federated_db.inc: changed name of variable in test due to change in vars sql_analyse.cc: over-ridden append_escaped to take (String *, char *, uint) per requirements of 'create_where_from_key' method in federated handler. mysql_priv.h: define over-ridden append_escaped to take arguments from 'create_where_from_key' method in federated handler ha_federated.cc: implemented "create_where_from_key" to deal properly with two-byte prefix and multi keys. Initial testing shows it works, but I still need to move quoting to field class and also look at changes per Segei's suggestions. sql/mysql_priv.h: define over-ridden append_escaped to take arguments from 'create_where_from_key' method in federated handler sql/sql_analyse.cc: over-ridden append_escaped to take (String *, char *, uint) per requirements of 'create_where_from_key' method in federated handler. mysql-test/include/have_federated_db.inc: changed name of variable in test due to change in vars mysql-test/r/federated.result: new test results for federated handler mysql-test/r/have_federated_db.require: new name of federated system var mysql-test/t/federated.test: more tests, joins, index tests sql/field.cc: new field class methods quote_data and needs_quotes (per Monty's request) sql/field.h: new methods quote_data and needs_quotes declared sql/ha_federated.cc: moved quote_data and type_quote to field class sql/ha_federated.h: removed quote_data and type_quote (now in the Field class) BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- BitKeeper/etc/logging_ok | 1 + mysql-test/include/have_federated_db.inc | 2 +- mysql-test/r/federated.result | 119 +++++++++++- mysql-test/r/have_federated_db.require | 2 +- mysql-test/t/federated.test | 104 ++++++++++- sql/field.cc | 109 +++++++++++ sql/field.h | 2 + sql/ha_federated.cc | 221 +++++------------------ sql/ha_federated.h | 5 +- sql/mysql_priv.h | 4 + sql/sql_analyse.cc | 40 +++- 11 files changed, 412 insertions(+), 197 deletions(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 02e65271dbe..5a78a0e21a6 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -172,6 +172,7 @@ nick@nick.leippe.com papa@gbichot.local patg@krsna.patg.net patg@patrick-galbraiths-computer.local +patg@pc248.lfp.kcls.org paul@central.snake.net paul@frost.snake.net paul@ice.local diff --git a/mysql-test/include/have_federated_db.inc b/mysql-test/include/have_federated_db.inc index 7247c5db4b2..e4cf1366fda 100644 --- a/mysql-test/include/have_federated_db.inc +++ b/mysql-test/include/have_federated_db.inc @@ -1,4 +1,4 @@ -- require r/have_federated_db.require disable_query_log; -show variables like "have_federated_db"; +show variables like "have_federated_engine"; enable_query_log; diff --git a/mysql-test/r/federated.result b/mysql-test/r/federated.result index 8cadb120c2e..4ed0b45a4c5 100644 --- a/mysql-test/r/federated.result +++ b/mysql-test/r/federated.result @@ -130,9 +130,9 @@ delete from federated.t1; select * from federated.t1 where id = 5; id name other created drop table if exists federated.t1; -CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`) ) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1'; -drop table if exists federated.t1; CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`) ); +drop table if exists federated.t1; +CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`) ) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1'; insert into federated.t1 (name, other) values ('First Name', 11111); insert into federated.t1 (name, other) values ('Second Name', NULL); insert into federated.t1 (name, other) values ('Third Name', 33333); @@ -162,7 +162,7 @@ id name other 7 Seventh Name NULL 10 NULL fee fie foe fum update federated.t1 set name = 'Fourth Name', other = 'four four four' where name IS NULL and other IS NULL; -update federated.t1 set other = 'two two two two' where name = 'Secend Name'; +update federated.t1 set other = 'two two two two' where name = 'Second Name'; update federated.t1 set other = 'seven seven' where name like 'Sec%'; update federated.t1 set other = 'seven seven' where name = 'Seventh Name'; update federated.t1 set name = 'Tenth Name' where other like 'fee fie%'; @@ -181,6 +181,85 @@ id name other 9 Ninth Name 99999 10 Tenth Name fee fie foe fum drop table if exists federated.t1; +CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name` +varchar(32) NOT NULL DEFAULT '', `other` varchar(20) NOT NULL DEFAULT '', PRIMARY KEY (`id`), key nameoth (name, other) ); +drop table if exists federated.t1; +CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name` varchar(32) NOT NULL DEFAULT '', `other` varchar(20) NOT NULL DEFAULT '', PRIMARY KEY (`id`), key nameoth (name, other)) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1'; +insert into federated.t1 (name, other) values ('First Name', '1111'); +insert into federated.t1 (name, other) values ('Second Name', '2222'); +insert into federated.t1 (name, other) values ('Third Name', '3333'); +select * from federated.t1 where name = 'Second Name'; +id name other +2 Second Name 2222 +select * from federated.t1 where other = '2222'; +id name other +2 Second Name 2222 +select * from federated.t1 where name = 'Third Name'; +id name other +3 Third Name 3333 +select * from federated.t1 where name = 'Third Name' and other = '3333'; +id name other +3 Third Name 3333 +drop table if exists federated.t1; +CREATE TABLE federated.t1 +(id int NOT NULL auto_increment, +name char(32) NOT NULL DEFAULT '', +bincol binary(4) NOT NULL, +floatval decimal(5,2) NOT NULL DEFAULT 0.0, +other int NOT NULL DEFAULT 0, +primary key(id), +key nameoth(name, other), +key bincol(bincol), +key floatval(floatval)); +drop table if exists federated.t1; +CREATE TABLE federated.t1 +(id int NOT NULL auto_increment, +name char(32) NOT NULL DEFAULT '', +bincol binary(4) NOT NULL, +floatval decimal(5,2) NOT NULL DEFAULT 0.0, +other int NOT NULL DEFAULT 0, +primary key(id), +key nameoth(name,other), +key bincol(bincol), +key floatval(floatval)) +ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1'; +insert into federated.t1 (name, bincol, floatval, other) values ('first', 0x65, 11.11, 1111); +insert into federated.t1 (name, bincol, floatval, other) values ('second', 0x66, 22.22, 2222); +insert into federated.t1 (name, bincol, floatval, other) values ('third', 'g', 22.22, 2222); +select * from federated.t1; +id name bincol floatval other +1 first e 11.11 1111 +2 second f 22.22 2222 +3 third g 22.22 2222 +select * from federated.t1 where name = 'second'; +id name bincol floatval other +2 second f 22.22 2222 +select * from federated.t1 where bincol= 'f'; +id name bincol floatval other +2 second f 22.22 2222 +select * from federated.t1 where bincol= 0x66; +id name bincol floatval other +2 second f 22.22 2222 +select * from federated.t1 where bincol= 0x67; +id name bincol floatval other +3 third g 22.22 2222 +select * from federated.t1 where bincol= 'g'; +id name bincol floatval other +3 third g 22.22 2222 +select * from federated.t1 where floatval=11.11; +id name bincol floatval other +1 first e 11.11 1111 +select * from federated.t1 where name='third'; +id name bincol floatval other +3 third g 22.22 2222 +select * from federated.t1 where other=2222; +id name bincol floatval other +2 second f 22.22 2222 +3 third g 22.22 2222 +select * from federated.t1 where name='third' and other=2222; +id name bincol floatval other +3 third g 22.22 2222 +drop table if exists federated.t1; CREATE TABLE federated.t1 (id int, name varchar(32), floatval float, other int) DEFAULT CHARSET=latin1; drop table if exists federated.t1; CREATE TABLE federated.t1 (id int, name varchar(32), floatval float, other int) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1'; @@ -550,16 +629,46 @@ delete from federated.t1 where i50=20; select * from federated.t1; i1 i2 i3 i4 i5 i6 i7 i8 i9 i10 i11 i12 i13 i14 i15 i16 i17 i18 i19 i20 i21 i22 i23 i24 i25 i26 i27 i28 i29 i30 i31 i32 i33 i34 i35 i36 i37 i38 i39 i40 i41 i42 i43 i44 i45 i46 i47 i48 i49 i50 i51 i52 i53 i54 i55 i56 i57 i58 i59 i60 i61 i62 i63 i64 i65 i66 i67 i68 i69 i70 i71 i72 i73 i74 i75 i76 i77 i78 i79 i80 i81 i82 i83 i84 i85 i86 i87 i88 i89 i90 i91 i92 i93 i94 i95 i96 i97 i98 i99 i100 i101 i102 i103 i104 i105 i106 i107 i108 i109 i110 i111 i112 i113 i114 i115 i116 i117 i118 i119 i120 i121 i122 i123 i124 i125 i126 i127 i128 i129 i130 i131 i132 i133 i134 i135 i136 i137 i138 i139 i140 i141 i142 i143 i144 i145 i146 i147 i148 i149 i150 i151 i152 i153 i154 i155 i156 i157 i158 i159 i160 i161 i162 i163 i164 i165 i166 i167 i168 i169 i170 i171 i172 i173 i174 i175 i176 i177 i178 i179 i180 i181 i182 i183 i184 i185 i186 i187 i188 i189 i190 i191 i192 i193 i194 i195 i196 i197 i198 i199 i200 i201 i202 i203 i204 i205 i206 i207 i208 i209 i210 i211 i212 i213 i214 i215 i216 i217 i218 i219 i220 i221 i222 i223 i224 i225 i226 i227 i228 i229 i230 i231 i232 i233 i234 i235 i236 i237 i238 i239 i240 i241 i242 i243 i244 i245 i246 i247 i248 i249 i250 i251 i252 i253 i254 i255 i256 i257 i258 i259 i260 i261 i262 i263 i264 i265 i266 i267 i268 i269 i270 i271 i272 i273 i274 i275 i276 i277 i278 i279 i280 i281 i282 i283 i284 i285 i286 i287 i288 i289 i290 i291 i292 i293 i294 i295 i296 i297 i298 i299 i300 i301 i302 i303 i304 i305 i306 i307 i308 i309 i310 i311 i312 i313 i314 i315 i316 i317 i318 i319 i320 i321 i322 i323 i324 i325 i326 i327 i328 i329 i330 i331 i332 i333 i334 i335 i336 i337 i338 i339 i340 i341 i342 i343 i344 i345 i346 i347 i348 i349 i350 i351 i352 i353 i354 i355 i356 i357 i358 i359 i360 i361 i362 i363 i364 i365 i366 i367 i368 i369 i370 i371 i372 i373 i374 i375 i376 i377 i378 i379 i380 i381 i382 i383 i384 i385 i386 i387 i388 i389 i390 i391 i392 i393 i394 i395 i396 i397 i398 i399 i400 i401 i402 i403 i404 i405 i406 i407 i408 i409 i410 i411 i412 i413 i414 i415 i416 i417 i418 i419 i420 i421 i422 i423 i424 i425 i426 i427 i428 i429 i430 i431 i432 i433 i434 i435 i436 i437 i438 i439 i440 i441 i442 i443 i444 i445 i446 i447 i448 i449 i450 i451 i452 i453 i454 i455 i456 i457 i458 i459 i460 i461 i462 i463 i464 i465 i466 i467 i468 i469 i470 i471 i472 i473 i474 i475 i476 i477 i478 i479 i480 i481 i482 i483 i484 i485 i486 i487 i488 i489 i490 i491 i492 i493 i494 i495 i496 i497 i498 i499 i500 i501 i502 i503 i504 i505 i506 i507 i508 i509 i510 i511 i512 i513 i514 i515 i516 i517 i518 i519 i520 i521 i522 i523 i524 i525 i526 i527 i528 i529 i530 i531 i532 i533 i534 i535 i536 i537 i538 i539 i540 i541 i542 i543 i544 i545 i546 i547 i548 i549 i550 i551 i552 i553 i554 i555 i556 i557 i558 i559 i560 i561 i562 i563 i564 i565 i566 i567 i568 i569 i570 i571 i572 i573 i574 i575 i576 i577 i578 i579 i580 i581 i582 i583 i584 i585 i586 i587 i588 i589 i590 i591 i592 i593 i594 i595 i596 i597 i598 i599 i600 i601 i602 i603 i604 i605 i606 i607 i608 i609 i610 i611 i612 i613 i614 i615 i616 i617 i618 i619 i620 i621 i622 i623 i624 i625 i626 i627 i628 i629 i630 i631 i632 i633 i634 i635 i636 i637 i638 i639 i640 i641 i642 i643 i644 i645 i646 i647 i648 i649 i650 i651 i652 i653 i654 i655 i656 i657 i658 i659 i660 i661 i662 i663 i664 i665 i666 i667 i668 i669 i670 i671 i672 i673 i674 i675 i676 i677 i678 i679 i680 i681 i682 i683 i684 i685 i686 i687 i688 i689 i690 i691 i692 i693 i694 i695 i696 i697 i698 i699 i700 i701 i702 i703 i704 i705 i706 i707 i708 i709 i710 i711 i712 i713 i714 i715 i716 i717 i718 i719 i720 i721 i722 i723 i724 i725 i726 i727 i728 i729 i730 i731 i732 i733 i734 i735 i736 i737 i738 i739 i740 i741 i742 i743 i744 i745 i746 i747 i748 i749 i750 i751 i752 i753 i754 i755 i756 i757 i758 i759 i760 i761 i762 i763 i764 i765 i766 i767 i768 i769 i770 i771 i772 i773 i774 i775 i776 i777 i778 i779 i780 i781 i782 i783 i784 i785 i786 i787 i788 i789 i790 i791 i792 i793 i794 i795 i796 i797 i798 i799 i800 i801 i802 i803 i804 i805 i806 i807 i808 i809 i810 i811 i812 i813 i814 i815 i816 i817 i818 i819 i820 i821 i822 i823 i824 i825 i826 i827 i828 i829 i830 i831 i832 i833 i834 i835 i836 i837 i838 i839 i840 i841 i842 i843 i844 i845 i846 i847 i848 i849 i850 i851 i852 i853 i854 i855 i856 i857 i858 i859 i860 i861 i862 i863 i864 i865 i866 i867 i868 i869 i870 i871 i872 i873 i874 i875 i876 i877 i878 i879 i880 i881 i882 i883 i884 i885 i886 i887 i888 i889 i890 i891 i892 i893 i894 i895 i896 i897 i898 i899 i900 i901 i902 i903 i904 i905 i906 i907 i908 i909 i910 i911 i912 i913 i914 i915 i916 i917 i918 i919 i920 i921 i922 i923 i924 i925 i926 i927 i928 i929 i930 i931 i932 i933 i934 i935 i936 i937 i938 i939 i940 i941 i942 i943 i944 i945 i946 i947 i948 i949 i950 i951 i952 i953 i954 i955 i956 i957 i958 i959 i960 i961 i962 i963 i964 i965 i966 i967 i968 i969 i970 i971 i972 i973 i974 i975 i976 i977 i978 i979 i980 i981 i982 i983 i984 i985 i986 i987 i988 i989 i990 i991 i992 i993 i994 i995 i996 i997 i998 i999 i1000 b drop table if exists federated.t1; -create table federated.t1 (id int NOT NULL auto_increment, code char(20) NOT NULL, fileguts blob, creation_date datetime, entered_time datetime default '2004-04-04 04:04:04', primary key(id), index(code)) DEFAULT CHARSET=latin1; +create table federated.t1 (id int NOT NULL auto_increment, code char(20) NOT NULL, fileguts blob NOT NULL, creation_date datetime, entered_time datetime default '2004-04-04 04:04:04', primary key(id), index(code), index(fileguts(10))) DEFAULT CHARSET=latin1; drop table if exists federated.t1; -create table federated.t1 (id int NOT NULL auto_increment, code char(20) NOT NULL, fileguts blob, creation_date datetime, entered_time datetime default '2004-04-04 04:04:04', primary key(id), index(code)) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1'; +create table federated.t1 (id int NOT NULL auto_increment, code char(20) NOT NULL, fileguts blob NOT NULL, creation_date datetime, entered_time datetime default '2004-04-04 04:04:04', primary key(id), index(code), index(fileguts(10))) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1'; insert into federated.t1 (code, fileguts, creation_date) values ('ASDFWERQWETWETAWETA', '*()w*09*$()*#)(*09*^90*d)(*s()d8g)(s*ned)(*)(s*d)(*hn(d*)(*sbn)D((#$*(#*%%&#&^$#&#&#&#&^&#*&*#$*&^*(&#(&Q*&&(*!&!(*&*(#&*(%&#*###[[', '2003-03-03 03:03:03'); insert into federated.t1 (code, fileguts, creation_date) values ('DEUEUEUEUEUEUEUEUEU', '*()w*09*$()*#)(*09*^90*d)(*s()d8g)(s*ned)(*)(s*d)(*hn(d*)(*sbn)D((#$*(#*%%&#&^$#&#&#&#&^&#*&*#$*&^*(&#(&Q*&&(*!&!(*&*(#&*(%&#*###[[', '2004-04-04 04:04:04'); +insert into federated.t1 (code, fileguts, creation_date) values ('DEUEUEUEUEUEUEUEUEU', 'jimbob', '2004-04-04 04:04:04'); select * from federated.t1; id code fileguts creation_date entered_time 1 ASDFWERQWETWETAWETA *()w*09*$()*#)(*09*^90*d)(*s()d8g)(s*ned)(*)(s*d)(*hn(d*)(*sbn)D((#$*(#*%%&#&^$#&#&#&#&^&#*&*#$*&^*(&#(&Q*&&(*!&!(*&*(#&*(%&#*###[[ 2003-03-03 03:03:03 2004-04-04 04:04:04 2 DEUEUEUEUEUEUEUEUEU *()w*09*$()*#)(*09*^90*d)(*s()d8g)(s*ned)(*)(s*d)(*hn(d*)(*sbn)D((#$*(#*%%&#&^$#&#&#&#&^&#*&*#$*&^*(&#(&Q*&&(*!&!(*&*(#&*(%&#*###[[ 2004-04-04 04:04:04 2004-04-04 04:04:04 +3 DEUEUEUEUEUEUEUEUEU jimbob 2004-04-04 04:04:04 2004-04-04 04:04:04 +select * from federated.t1 where fileguts = 'jimbob'; +id code fileguts creation_date entered_time +3 DEUEUEUEUEUEUEUEUEU jimbob 2004-04-04 04:04:04 2004-04-04 04:04:04 drop table if exists federated.t1; +CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `country_id` int(20) NOT NULL DEFAULT 0, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`), key (country_id)); +drop table if exists federated.t1; +CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `country_id` int(20) NOT NULL DEFAULT 0, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`), key (country_id) ) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1'; +insert into federated.t1 (name, country_id, other) values ('Kumar', 1, 11111); +insert into federated.t1 (name, country_id, other) values ('Lenz', 2, 22222); +insert into federated.t1 (name, country_id, other) values ('Marizio', 3, 33333); +insert into federated.t1 (name, country_id, other) values ('Monty', 4, 33333); +insert into federated.t1 (name, country_id, other) values ('Sanja', 5, 33333); +drop table if exists federated.countries; +Warnings: +Note 1051 Unknown table 'countries' +CREATE TABLE federated.countries ( `id` int(20) NOT NULL auto_increment, `country` varchar(32), primary key (id)); +insert into federated.countries (country) values ('India'); +insert into federated.countries (country) values ('Germany'); +insert into federated.countries (country) values ('Italy'); +insert into federated.countries (country) values ('Finland'); +insert into federated.countries (country) values ('Ukraine'); +select federated.t1.*, federated.countries.country from federated.t1 left join federated.countries on federated.t1.country_id = federated.countries.id; +id country_id name other country +1 1 Kumar 11111 India +2 2 Lenz 22222 Germany +3 3 Marizio 33333 Italy +4 4 Monty 33333 Finland +5 5 Sanja 33333 Ukraine +drop table federated.countries; drop table if exists federated.t1; drop database if exists federated; drop table if exists federated.t1; diff --git a/mysql-test/r/have_federated_db.require b/mysql-test/r/have_federated_db.require index dda556a2974..f4c521a8f35 100644 --- a/mysql-test/r/have_federated_db.require +++ b/mysql-test/r/have_federated_db.require @@ -1,2 +1,2 @@ Variable_name Value -have_federated_db YES +have_federated_engine YES diff --git a/mysql-test/t/federated.test b/mysql-test/t/federated.test index aa62377be64..413509a0a6a 100644 --- a/mysql-test/t/federated.test +++ b/mysql-test/t/federated.test @@ -68,12 +68,14 @@ select * from federated.t1 where id = 5; delete from federated.t1; select * from federated.t1 where id = 5; -drop table if exists federated.t1; -CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`) ) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1'; - connection slave; drop table if exists federated.t1; CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`) ); + +connection master; +drop table if exists federated.t1; +CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`) ) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1'; + insert into federated.t1 (name, other) values ('First Name', 11111); insert into federated.t1 (name, other) values ('Second Name', NULL); insert into federated.t1 (name, other) values ('Third Name', 33333); @@ -90,19 +92,78 @@ select * from federated.t1 where name IS NULL; select * from federated.t1 where name IS NULL and other IS NULL; select * from federated.t1 where name IS NULL or other IS NULL; update federated.t1 set name = 'Fourth Name', other = 'four four four' where name IS NULL and other IS NULL; -update federated.t1 set other = 'two two two two' where name = 'Secend Name'; +update federated.t1 set other = 'two two two two' where name = 'Second Name'; update federated.t1 set other = 'seven seven' where name like 'Sec%'; update federated.t1 set other = 'seven seven' where name = 'Seventh Name'; update federated.t1 set name = 'Tenth Name' where other like 'fee fie%'; select * from federated.t1 where name IS NULL or other IS NULL ; select * from federated.t1; +# test multi-keys +connection slave; +drop table if exists federated.t1; +CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name` +varchar(32) NOT NULL DEFAULT '', `other` varchar(20) NOT NULL DEFAULT '', PRIMARY KEY (`id`), key nameoth (name, other) ); + +connection master; +drop table if exists federated.t1; +CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name` varchar(32) NOT NULL DEFAULT '', `other` varchar(20) NOT NULL DEFAULT '', PRIMARY KEY (`id`), key nameoth (name, other)) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1'; +insert into federated.t1 (name, other) values ('First Name', '1111'); +insert into federated.t1 (name, other) values ('Second Name', '2222'); +insert into federated.t1 (name, other) values ('Third Name', '3333'); +select * from federated.t1 where name = 'Second Name'; +select * from federated.t1 where other = '2222'; +select * from federated.t1 where name = 'Third Name'; +select * from federated.t1 where name = 'Third Name' and other = '3333'; + +connection slave; +drop table if exists federated.t1; +CREATE TABLE federated.t1 + (id int NOT NULL auto_increment, + name char(32) NOT NULL DEFAULT '', + bincol binary(4) NOT NULL, + floatval decimal(5,2) NOT NULL DEFAULT 0.0, + other int NOT NULL DEFAULT 0, + primary key(id), + key nameoth(name, other), + key bincol(bincol), + key floatval(floatval)); + +# test other types of indexes +connection master; +drop table if exists federated.t1; +CREATE TABLE federated.t1 + (id int NOT NULL auto_increment, + name char(32) NOT NULL DEFAULT '', + bincol binary(4) NOT NULL, + floatval decimal(5,2) NOT NULL DEFAULT 0.0, + other int NOT NULL DEFAULT 0, + primary key(id), + key nameoth(name,other), + key bincol(bincol), + key floatval(floatval)) + ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1'; + +insert into federated.t1 (name, bincol, floatval, other) values ('first', 0x65, 11.11, 1111); +insert into federated.t1 (name, bincol, floatval, other) values ('second', 0x66, 22.22, 2222); +insert into federated.t1 (name, bincol, floatval, other) values ('third', 'g', 22.22, 2222); +select * from federated.t1; +select * from federated.t1 where name = 'second'; +select * from federated.t1 where bincol= 'f'; +select * from federated.t1 where bincol= 0x66; +select * from federated.t1 where bincol= 0x67; +select * from federated.t1 where bincol= 'g'; +select * from federated.t1 where floatval=11.11; +select * from federated.t1 where name='third'; +select * from federated.t1 where other=2222; +select * from federated.t1 where name='third' and other=2222; + +# test NULLs connection slave; drop table if exists federated.t1; CREATE TABLE federated.t1 (id int, name varchar(32), floatval float, other int) DEFAULT CHARSET=latin1; connection master; -# test NULLs drop table if exists federated.t1; CREATE TABLE federated.t1 (id int, name varchar(32), floatval float, other int) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1'; # these both should be the same @@ -452,15 +513,17 @@ select * from federated.t1; connection slave; drop table if exists federated.t1; -create table federated.t1 (id int NOT NULL auto_increment, code char(20) NOT NULL, fileguts blob, creation_date datetime, entered_time datetime default '2004-04-04 04:04:04', primary key(id), index(code)) DEFAULT CHARSET=latin1; +create table federated.t1 (id int NOT NULL auto_increment, code char(20) NOT NULL, fileguts blob NOT NULL, creation_date datetime, entered_time datetime default '2004-04-04 04:04:04', primary key(id), index(code), index(fileguts(10))) DEFAULT CHARSET=latin1; connection master; drop table if exists federated.t1; -create table federated.t1 (id int NOT NULL auto_increment, code char(20) NOT NULL, fileguts blob, creation_date datetime, entered_time datetime default '2004-04-04 04:04:04', primary key(id), index(code)) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1'; +create table federated.t1 (id int NOT NULL auto_increment, code char(20) NOT NULL, fileguts blob NOT NULL, creation_date datetime, entered_time datetime default '2004-04-04 04:04:04', primary key(id), index(code), index(fileguts(10))) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1'; insert into federated.t1 (code, fileguts, creation_date) values ('ASDFWERQWETWETAWETA', '*()w*09*$()*#)(*09*^90*d)(*s()d8g)(s*ned)(*)(s*d)(*hn(d*)(*sbn)D((#$*(#*%%&#&^$#&#&#&#&^&#*&*#$*&^*(&#(&Q*&&(*!&!(*&*(#&*(%&#*###[[', '2003-03-03 03:03:03'); insert into federated.t1 (code, fileguts, creation_date) values ('DEUEUEUEUEUEUEUEUEU', '*()w*09*$()*#)(*09*^90*d)(*s()d8g)(s*ned)(*)(s*d)(*hn(d*)(*sbn)D((#$*(#*%%&#&^$#&#&#&#&^&#*&*#$*&^*(&#(&Q*&&(*!&!(*&*(#&*(%&#*###[[', '2004-04-04 04:04:04'); +insert into federated.t1 (code, fileguts, creation_date) values ('DEUEUEUEUEUEUEUEUEU', 'jimbob', '2004-04-04 04:04:04'); select * from federated.t1; -drop table if exists federated.t1; +select * from federated.t1 where fileguts = 'jimbob'; +# test blob indexes # TODO # @@ -490,11 +553,36 @@ drop table if exists federated.t1; # drop table if exists federated.t1; # +# test joins with non-federated table connection slave; drop table if exists federated.t1; +CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `country_id` int(20) NOT NULL DEFAULT 0, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`), key (country_id)); + +connection master; +drop table if exists federated.t1; +CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `country_id` int(20) NOT NULL DEFAULT 0, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`), key (country_id) ) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1'; +insert into federated.t1 (name, country_id, other) values ('Kumar', 1, 11111); +insert into federated.t1 (name, country_id, other) values ('Lenz', 2, 22222); +insert into federated.t1 (name, country_id, other) values ('Marizio', 3, 33333); +insert into federated.t1 (name, country_id, other) values ('Monty', 4, 33333); +insert into federated.t1 (name, country_id, other) values ('Sanja', 5, 33333); + + +drop table if exists federated.countries; +CREATE TABLE federated.countries ( `id` int(20) NOT NULL auto_increment, `country` varchar(32), primary key (id)); +insert into federated.countries (country) values ('India'); +insert into federated.countries (country) values ('Germany'); +insert into federated.countries (country) values ('Italy'); +insert into federated.countries (country) values ('Finland'); +insert into federated.countries (country) values ('Ukraine'); + +select federated.t1.*, federated.countries.country from federated.t1 left join federated.countries on federated.t1.country_id = federated.countries.id; + +drop table federated.countries; connection master; --disable_warnings +drop table if exists federated.t1; drop database if exists federated; --enable_warnings diff --git a/sql/field.cc b/sql/field.cc index 41b6eba695c..b1212025d30 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -524,6 +524,115 @@ Field *Field::new_key_field(MEM_ROOT *root, struct st_table *new_table, return tmp; } +/* + SYNOPSIS + Field::quote_data() + unquoted_string Pointer pointing to the value of a field + + DESCRIPTION + Simple method that passes the field type to the method "type_quote" + To get a true/false value as to whether the value in string1 needs + to be enclosed with quotes. This ensures that values in the final + sql statement to be passed to the remote server will be quoted properly + + RETURN_VALUE + void Immediately - if string doesn't need quote + void Upon prepending/appending quotes on each side of variable + +*/ +bool Field::quote_data(String *unquoted_string) +{ + char escaped_string[IO_SIZE]; + char *unquoted_string_buffer= (char *)(unquoted_string->ptr()); + uint need_quotes; + + DBUG_ENTER("Field::quote_data"); + // this is the same call that mysql_real_escape_string() calls + escape_string_for_mysql(&my_charset_bin, (char *)escaped_string, + unquoted_string->ptr(), unquoted_string->length()); + + + if (is_null()) + DBUG_RETURN(0); + + need_quotes= needs_quotes(); + + if (need_quotes == 0) + { + DBUG_RETURN(0); + } + else + { + // reset string, then re-append with quotes and escaped values + unquoted_string->length(0); + if (unquoted_string->append("'")) + DBUG_RETURN(1); + if (unquoted_string->append((char *)escaped_string)) + DBUG_RETURN(1); + if (unquoted_string->append("'")) + DBUG_RETURN(1); + } + //DBUG_PRINT("Field::quote_data", + // ("FINAL quote_flag %d unquoted_string %s escaped_string %s", + //needs_quotes, unquoted_string->c_ptr_quick(), escaped_string)); + DBUG_RETURN(0); +} + +/* + Quote a field type if needed + + SYNOPSIS + Field::type_quote + + DESCRIPTION + Simple method to give true/false whether a field should be quoted. + Used when constructing INSERT and UPDATE queries to the remote server + see write_row and update_row + + RETURN VALUE + 0 if value is of type NOT needing quotes + 1 if value is of type needing quotes +*/ +bool Field::needs_quotes(void) +{ + DBUG_ENTER("Field::type_quote"); + + switch(type()) { + //FIX this when kernel is fixed + case MYSQL_TYPE_VARCHAR : + case FIELD_TYPE_STRING : + case FIELD_TYPE_VAR_STRING : + case FIELD_TYPE_YEAR : + case FIELD_TYPE_NEWDATE : + case FIELD_TYPE_TIME : + case FIELD_TYPE_TIMESTAMP : + case FIELD_TYPE_DATE : + case FIELD_TYPE_DATETIME : + case FIELD_TYPE_TINY_BLOB : + case FIELD_TYPE_BLOB : + case FIELD_TYPE_MEDIUM_BLOB : + case FIELD_TYPE_LONG_BLOB : + case FIELD_TYPE_GEOMETRY : + DBUG_RETURN(1); + + case FIELD_TYPE_DECIMAL : + case FIELD_TYPE_TINY : + case FIELD_TYPE_SHORT : + case FIELD_TYPE_INT24 : + case FIELD_TYPE_LONG : + case FIELD_TYPE_FLOAT : + case FIELD_TYPE_DOUBLE : + case FIELD_TYPE_LONGLONG : + case FIELD_TYPE_NULL : + case FIELD_TYPE_SET : + case FIELD_TYPE_ENUM : + DBUG_RETURN(0); + + default: DBUG_RETURN(0); + } + DBUG_RETURN(0); + +} /**************************************************************************** Field_null, a field that always return NULL diff --git a/sql/field.h b/sql/field.h index ab911822c2c..af7019f28bf 100644 --- a/sql/field.h +++ b/sql/field.h @@ -227,6 +227,8 @@ public: ptr= old_ptr; return str; } + bool quote_data(String *unquoted_string); + bool needs_quotes(void); virtual bool send_binary(Protocol *protocol); virtual char *pack(char* to, const char *from, uint max_length=~(uint) 0) { diff --git a/sql/ha_federated.cc b/sql/ha_federated.cc index 0feccc94334..72dd448b06f 100644 --- a/sql/ha_federated.cc +++ b/sql/ha_federated.cc @@ -123,8 +123,8 @@ ha_federated::write_row - ha_federated::quote_data - ha_federated::quote_data + Field::quote_data + Field::quote_data ha_federated::reset @@ -136,18 +136,18 @@ ha_federated::index_init ha_federated::index_read ha_federated::index_read_idx - ha_federated::quote_data + Field::quote_data ha_federated::rnd_next ha_federated::convert_row_to_internal_format ha_federated::update_row - ha_federated::extra @@ -595,11 +595,15 @@ bool ha_federated::create_where_from_key( { uint second_loop= 0; KEY_PART_INFO *key_part; + bool needs_quotes; DBUG_ENTER("ha_federated::create_where_from_key"); for (key_part= key_info->key_part ; (int) key_length > 0 ; key_part++) { Field *field= key_part->field; + needs_quotes= field->needs_quotes(); + //bool needs_quotes= type_quote(field->type()); + DBUG_PRINT("ha_federated::create_where_from_key", ("key name %s type %d", field->field_name, field->type())); uint length= key_part->length; if (second_loop++ && to->append(" AND ",5)) @@ -613,6 +617,7 @@ bool ha_federated::create_where_from_key( if (*key++) { if (to->append("IS NULL",7)) + DBUG_PRINT("ha_federated::create_where_from_key", ("NULL type %s", to->c_ptr_quick())); DBUG_RETURN(1); key_length-= key_part->store_length; key+= key_part->store_length-1; @@ -620,14 +625,16 @@ bool ha_federated::create_where_from_key( } key_length--; } - if (to->append('=')) + if (to->append("= ")) + DBUG_RETURN(1); + if (needs_quotes && to->append("'")) DBUG_RETURN(1); if (key_part->type == HA_KEYTYPE_BIT) { /* This is can be threated as a hex string */ Field_bit *field= (Field_bit *) (key_part->field); char buff[64+2], *ptr; - byte *end= key + length; + byte *end= (byte *)(key) + length; buff[0]='0'; buff[1]='x'; @@ -639,6 +646,8 @@ bool ha_federated::create_where_from_key( } if (to->append(buff, (uint) (ptr-buff))) DBUG_RETURN(1); + + DBUG_PRINT("ha_federated::create_where_from_key", ("bit type %s", to->c_ptr_quick())); key_length-= length; continue; } @@ -647,165 +656,46 @@ bool ha_federated::create_where_from_key( uint blob_length= uint2korr(key); key+= HA_KEY_BLOB_LENGTH; key_length-= HA_KEY_BLOB_LENGTH; - if (append_escaped(to, key, blob_length)) + if (append_escaped(to, (char *)(key), blob_length)) DBUG_RETURN(1); + + DBUG_PRINT("ha_federated::create_where_from_key", ("blob type %s", to->c_ptr_quick())); length= key_part->length; } else if (key_part->key_part_flag & HA_VAR_LENGTH_PART) { - key_length-= HA_KEY_BLOB_LENGTH; - length= key_part->length; + length= uint2korr(key); key+= HA_KEY_BLOB_LENGTH; - if (append_escaped(to, key, length)) + if (append_escaped(to, (char *)(key), length)) DBUG_RETURN(1); + + DBUG_PRINT("ha_federated::create_where_from_key", ("varchar type %s", to->c_ptr_quick())); } else { - //bool need_quotes= field->needs_quotes(); - bool needs_quotes= type_quote(field->type()); + DBUG_PRINT("ha_federated::create_where_from_key", ("else block, unknown type so far")); char buff[MAX_FIELD_WIDTH]; String str(buff, sizeof(buff), field->charset()), *res; - if (needs_quotes && to->append('=')) - DBUG_RETURN(1); res= field->val_str(&str, (char *)(key)); if (field->result_type() == STRING_RESULT) { - if (append_escaped(to, res->ptr(), res->length())) + if (append_escaped(to, (char *) res->ptr(), res->length())) DBUG_RETURN(1); + res= field->val_str(&str, (char *)(key)); + + DBUG_PRINT("ha_federated::create_where_from_key", ("else block, string type", to->c_ptr_quick())); } else if (to->append(res->ptr(), res->length())) DBUG_RETURN(1); - if (needs_quotes && to->append('=')) - DBUG_RETURN(1); } + if (needs_quotes && to->append("'")) + DBUG_RETURN(1); + DBUG_PRINT("ha_federated::create_where_from_key", ("final value for 'to' %s", to->c_ptr_quick())); key+= length; key_length-= length; - } -} -/* - SYNOPSIS - quote_data() - unquoted_string Pointer pointing to the value of a field - field MySQL Field pointer to field being checked for type - - DESCRIPTION - Simple method that passes the field type to the method "type_quote" - To get a true/false value as to whether the value in string1 needs - to be enclosed with quotes. This ensures that values in the final - sql statement to be passed to the remote server will be quoted properly - - RETURN_VALUE - void Immediately - if string doesn't need quote - void Upon prepending/appending quotes on each side of variable - -*/ -void ha_federated::quote_data(String *unquoted_string, Field *field ) -{ - char escaped_string[IO_SIZE]; - char *unquoted_string_buffer; - - unquoted_string_buffer= unquoted_string->c_ptr_quick(); - - int quote_flag; - DBUG_ENTER("ha_federated::quote_data"); - DBUG_PRINT("ha_federated::quote_data", - ("unescaped %s", unquoted_string->c_ptr_quick())); - // this is the same call that mysql_real_escape_string() calls - escape_string_for_mysql(&my_charset_bin, (char *)escaped_string, - unquoted_string->c_ptr_quick(), unquoted_string->length()); - - DBUG_PRINT("ha_federated::quote_data",("escaped %s",escaped_string)); - - if (field->is_null()) - { - DBUG_PRINT("ha_federated::quote_data", - ("NULL, no quoted needed for unquoted_string %s, returning.", - unquoted_string->c_ptr_quick())); - DBUG_VOID_RETURN; - } - - quote_flag= type_quote(field->type()); - - DBUG_PRINT("ha_federated::quote_data", - ("quote flag %d type %d", quote_flag, field->type())); - - if (quote_flag == 0) - { - DBUG_PRINT("ha_federated::quote_data", - ("quote flag 0 no quoted needed for unquoted_string %s, returning.", - unquoted_string->c_ptr_quick())); - DBUG_VOID_RETURN; - } - else - { - // reset string, then re-append with quotes and escaped values - unquoted_string->length(0); - unquoted_string->append("'"); - unquoted_string->append((char *)escaped_string); - unquoted_string->append("'"); - } - DBUG_PRINT("ha_federated::quote_data", - ("FINAL quote_flag %d unquoted_string %s escaped_string %s", - quote_flag, unquoted_string->c_ptr_quick(), escaped_string)); - DBUG_VOID_RETURN; -} - -/* - Quote a field type if needed - - SYNOPSIS - ha_federated::type_quote - int field Enumerated field type number - - DESCRIPTION - Simple method to give true/false whether a field should be quoted. - Used when constructing INSERT and UPDATE queries to the remote server - see write_row and update_row - - RETURN VALUE - 0 if value is of type NOT needing quotes - 1 if value is of type needing quotes -*/ -uint ha_federated::type_quote(int type) -{ - DBUG_ENTER("ha_federated::type_quote"); - DBUG_PRINT("ha_federated::type_quote", ("field type %d", type)); - - switch(type) { - //FIX this is a bug, fix when kernel is fixed - case MYSQL_TYPE_VARCHAR : - case FIELD_TYPE_STRING : - case FIELD_TYPE_VAR_STRING : - case FIELD_TYPE_YEAR : - case FIELD_TYPE_NEWDATE : - case FIELD_TYPE_TIME : - case FIELD_TYPE_TIMESTAMP : - case FIELD_TYPE_DATE : - case FIELD_TYPE_DATETIME : - case FIELD_TYPE_TINY_BLOB : - case FIELD_TYPE_BLOB : - case FIELD_TYPE_MEDIUM_BLOB : - case FIELD_TYPE_LONG_BLOB : - case FIELD_TYPE_GEOMETRY : - DBUG_RETURN(1); - - case FIELD_TYPE_DECIMAL : - case FIELD_TYPE_TINY : - case FIELD_TYPE_SHORT : - case FIELD_TYPE_INT24 : - case FIELD_TYPE_LONG : - case FIELD_TYPE_FLOAT : - case FIELD_TYPE_DOUBLE : - case FIELD_TYPE_LONGLONG : - case FIELD_TYPE_NULL : - case FIELD_TYPE_SET : - case FIELD_TYPE_ENUM : DBUG_RETURN(0); - - default: DBUG_RETURN(0); } - DBUG_RETURN(0); } int load_conn_info(FEDERATED_SHARE *share, TABLE *table) @@ -1159,7 +1049,8 @@ int ha_federated::write_row(byte * buf) insert_string.append((*field)->field_name); // quote these fields if they require it - quote_data(&insert_field_value_string, *field); + + (*field)->quote_data(&insert_field_value_string); // append the value values_string.append(insert_field_value_string); insert_field_value_string.length(0); @@ -1305,7 +1196,7 @@ int ha_federated::update_row( { // otherwise = (*field)->val_str(&new_field_value); - quote_data(&new_field_value, *field); + (*field)->quote_data(&new_field_value); if ( has_a_primary_key ) { @@ -1323,7 +1214,7 @@ int ha_federated::update_row( { (*field)->val_str(&old_field_value, (char *)(old_data + (*field)->offset())); - quote_data(&old_field_value, *field); + (*field)->quote_data(&old_field_value); where_string.append(old_field_value); } } @@ -1335,7 +1226,7 @@ int ha_federated::update_row( { (*field)->val_str(&old_field_value, (char *)(old_data + (*field)->offset())); - quote_data(&old_field_value, *field); + (*field)->quote_data(&old_field_value); where_string.append(old_field_value); } } @@ -1412,7 +1303,7 @@ int ha_federated::delete_row(const byte * buf) { delete_string.append("="); (*field)->val_str(&data_string); - quote_data(&data_string, *field); + (*field)->quote_data(&data_string); } delete_string.append(data_string); @@ -1469,13 +1360,10 @@ int ha_federated::index_read_idx(byte * buf, uint index, const byte * key, char key_value[IO_SIZE]; char test_value[IO_SIZE]; String index_string(index_value, sizeof(index_value), &my_charset_bin); - String test_string(test_value, sizeof(test_value), &my_charset_bin); index_string.length(0); - test_string.length(0); uint keylen; char sql_query_buffer[IO_SIZE]; - String tmp_string; String sql_query(sql_query_buffer, sizeof(sql_query_buffer), &my_charset_bin); sql_query.length(0); @@ -1484,34 +1372,15 @@ int ha_federated::index_read_idx(byte * buf, uint index, const byte * key, sql_query.append(share->select_query); sql_query.append(" WHERE "); - sql_query.append(table->key_info[index].key_part->field->field_name); - sql_query.append(" = "); - if (table->key_info[index].key_part->field->type() == MYSQL_TYPE_VARCHAR) - { - //keylen= uint2korr(key); - keylen= key[0]; - create_where_from_key(&tmp_string, &table->key_info[index], key, keylen); - memcpy(key_value, key + HA_KEY_BLOB_LENGTH, keylen); - key_value[keylen]= 0; - DBUG_PRINT("ha_federated::index_read_idx", - ("key_value %s len %d", key_value, keylen)); - index_string.append(key_value); - } - else - { - //table->key_info[index].key_part->field->val_str(&index_string, (char - //*)(key)); - index_string.append((char *)(key)); - } + keylen= strlen((char *)(key)); + create_where_from_key(&index_string, &table->key_info[index], key, keylen); + sql_query.append(index_string); + DBUG_PRINT("ha_federated::index_read_idx", ("current key %d key value %s index_string value %s length %d", index, (char *)(key),index_string.c_ptr_quick(), index_string.length())); - //table->key_info[index].key_part->field->val_str(&index_string); - quote_data(&index_string, table->key_info[index].key_part->field); - sql_query.append(index_string); - DBUG_PRINT("ha_federated::index_read_idx", ("current position %d sql_query %s", current_position, sql_query.c_ptr_quick())); diff --git a/sql/ha_federated.h b/sql/ha_federated.h index ce35ce96828..b44ad937650 100755 --- a/sql/ha_federated.h +++ b/sql/ha_federated.h @@ -71,10 +71,7 @@ private: return 0 on success return errorcode otherwise */ - //FIX uint convert_row_to_internal_format(byte *buf, MYSQL_ROW row); - uint type_quote(int type); - void quote_data(String *string1, Field *field); bool ha_federated::create_where_from_key(String *to, KEY *key_info, const byte *key, uint key_length); public: @@ -105,7 +102,7 @@ public: { return (HA_TABLE_SCAN_ON_INDEX | HA_NOT_EXACT_COUNT | HA_PRIMARY_KEY_IN_READ_INDEX | HA_FILE_BASED | HA_AUTO_PART_KEY | - HA_TABLE_SCAN_ON_INDEX); + HA_TABLE_SCAN_ON_INDEX | HA_CAN_INDEX_BLOBS); } /* This is a bitmap of flags that says how the storage engine diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 6f569ea3ef4..b8dfc0d3876 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -712,6 +712,10 @@ void free_des_key_file(); /* sql_do.cc */ bool mysql_do(THD *thd, List &values); +/* sql_analyse.h */ +bool append_escaped(String *to_str, String *from_str); +bool append_escaped(String *to_str, char *from, uint from_len); + /* sql_show.cc */ bool mysqld_show_open_tables(THD *thd,const char *wild); bool mysqld_show_logs(THD *thd); diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index 6a9a9e51231..8a74d9709dd 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -59,7 +59,8 @@ int compare_ulonglong2(void* cmp_arg __attribute__((unused)), return compare_ulonglong(s,t); } -static bool append_escaped(String *to_str, String *from_str); +bool append_escaped(String *to_str, String *from_str); +bool append_escaped(String *to_str, char *from, uint from_len); Procedure * proc_analyse_init(THD *thd, ORDER *param, select_result *result, @@ -1047,7 +1048,7 @@ uint check_ulonglong(const char *str, uint length) 1 Out of memory */ -static bool append_escaped(String *to_str, String *from_str) +bool append_escaped(String *to_str, String *from_str) { char *from, *end, c; @@ -1081,3 +1082,38 @@ static bool append_escaped(String *to_str, String *from_str) } return 0; } + +bool append_escaped(String *to_str, char *from, uint from_len) +{ + char *end, c; + + if (to_str->realloc(to_str->length() + from_len)) + return 1; + + end= from + from_len; + + for (; from < end; from++) + { + c= *from; + switch (c) { + case '\0': + c= '0'; + break; + case '\032': + c= 'Z'; + break; + case '\\': + case '\'': + break; + default: + goto normal_character; + } + if (to_str->append('\\')) + return 1; + + normal_character: + if (to_str->append(c)) + return 1; + } + return 0; +} From 56b1a854698e98412746164e764bf29bb435e55d Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 21 Jan 2005 17:51:24 +0400 Subject: [PATCH 08/54] A fix (Bug #8015: server refuses to start with long basedir path). --- sql/mysql_priv.h | 2 +- sql/mysqld.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 4b785aafc5f..85a54c69467 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -852,7 +852,7 @@ extern Gt_creator gt_creator; extern Lt_creator lt_creator; extern Ge_creator ge_creator; extern Le_creator le_creator; -extern char language[LIBLEN],reg_ext[FN_EXTLEN]; +extern char language[FN_REFLEN], reg_ext[FN_EXTLEN]; extern char glob_hostname[FN_REFLEN], mysql_home[FN_REFLEN]; extern char pidfile_name[FN_REFLEN], system_time_zone[30], *opt_init_file; extern char log_error_file[FN_REFLEN]; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index d1fef3519bf..4c30ad51751 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -340,7 +340,7 @@ char *default_tz_name; char log_error_file[FN_REFLEN], glob_hostname[FN_REFLEN]; char* log_error_file_ptr= log_error_file; char mysql_real_data_home[FN_REFLEN], - language[LIBLEN],reg_ext[FN_EXTLEN], mysql_charsets_dir[FN_REFLEN], + language[FN_REFLEN], reg_ext[FN_EXTLEN], mysql_charsets_dir[FN_REFLEN], *mysqld_user,*mysqld_chroot, *opt_init_file, *opt_init_connect, *opt_init_slave, def_ft_boolean_syntax[sizeof(ft_boolean_syntax)]; From 8d8e0cb539ff21509acc5e519a4e37eb29b9e380 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 21 Jan 2005 17:38:46 +0100 Subject: [PATCH 09/54] WL#2126 - Multi_read_range. Addendum for correct multi_range_count system variable handling. Fixed a typo. Added to sys_variables. Added to init_vars. --- sql/set_var.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sql/set_var.cc b/sql/set_var.cc index 957cacc91ac..bd4e496e082 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -28,7 +28,7 @@ - If the variable is thread specific, add it to 'system_variables' struct. If not, add it to mysqld.cc and an declaration in 'mysql_priv.h' - If the variable should be changed from the command line, add a definition - of it in the my_option structure list in mysqld.dcc + of it in the my_option structure list in mysqld.cc - Don't forget to initialize new fields in global_system_variables and max_system_variables! - If the variable should show up in 'show variables' add it to the @@ -584,6 +584,7 @@ sys_var *sys_variables[]= &sys_max_tmp_tables, &sys_max_user_connections, &sys_max_write_lock_count, + &sys_multi_range_count, &sys_myisam_data_pointer_size, &sys_myisam_max_extra_sort_file_size, &sys_myisam_max_sort_file_size, @@ -828,6 +829,7 @@ struct show_var_st init_vars[]= { {sys_max_tmp_tables.name, (char*) &sys_max_tmp_tables, SHOW_SYS}, {sys_max_user_connections.name,(char*) &sys_max_user_connections, SHOW_SYS}, {sys_max_write_lock_count.name, (char*) &sys_max_write_lock_count,SHOW_SYS}, + {sys_multi_range_count.name, (char*) &sys_multi_range_count, SHOW_SYS}, {sys_myisam_data_pointer_size.name, (char*) &sys_myisam_data_pointer_size, SHOW_SYS}, {sys_myisam_max_extra_sort_file_size.name, (char*) &sys_myisam_max_extra_sort_file_size, From fd5ea70eed911d5b1bcac1d887bb10b5937664fa Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 24 Jan 2005 13:04:52 +0400 Subject: [PATCH 10/54] Stick FN_REFLEN to PATH_MAX. --- include/my_global.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/my_global.h b/include/my_global.h index ff59f7bfc55..5b363addef2 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -530,7 +530,11 @@ typedef SOCKET_SIZE_TYPE size_socket; #define FN_LEN 256 /* Max file name len */ #define FN_HEADLEN 253 /* Max length of filepart of file name */ #define FN_EXTLEN 20 /* Max length of extension (part of FN_LEN) */ +#ifdef PATH_MAX +#define FN_REFLEN PATH_MAX/* Max length of full path-name */ +#else #define FN_REFLEN 512 /* Max length of full path-name */ +#endif #define FN_EXTCHAR '.' #define FN_HOMELIB '~' /* ~/ is used as abbrev for home dir */ #define FN_CURLIB '.' /* ./ is used as abbrev for current dir */ From 2ade7521b572e4f1b71f66a4d0d80c10b50c6229 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 25 Jan 2005 14:00:35 +0200 Subject: [PATCH 11/54] Add flags for Intel 64 bit --- BUILD/SETUP.sh | 3 +++ BUILD/compile-pentium64-debug | 13 +++++++++++++ 2 files changed, 16 insertions(+) create mode 100755 BUILD/compile-pentium64-debug diff --git a/BUILD/SETUP.sh b/BUILD/SETUP.sh index 5f4233b8371..d378276a0a3 100644 --- a/BUILD/SETUP.sh +++ b/BUILD/SETUP.sh @@ -1,3 +1,5 @@ +#!/bin/sh + if ! test -f sql/mysqld.cc then echo "You must run this script from the MySQL top-level directory" @@ -43,6 +45,7 @@ cxx_warnings="$global_warnings -Woverloaded-virtual -Wsign-promo -Wreorder -Wcto alpha_cflags="-mcpu=ev6 -Wa,-mev6" # Not used yet pentium_cflags="-mcpu=pentiumpro" +pentium64_cflags="-mcpu=nocona -m64" ppc_cflags="-mpowerpc -mcpu=powerpc" sparc_cflags="" diff --git a/BUILD/compile-pentium64-debug b/BUILD/compile-pentium64-debug new file mode 100755 index 00000000000..1bbca36d851 --- /dev/null +++ b/BUILD/compile-pentium64-debug @@ -0,0 +1,13 @@ +#! /bin/sh + +path=`dirname $0` +. "$path/SETUP.sh" + +extra_flags="$pentium64_cflags $debug_cflags" +c_warnings="$c_warnings $debug_extra_warnings" +cxx_warnings="$cxx_warnings $debug_extra_warnings" +extra_configs="$pentium_configs $debug_configs $static_link" + +extra_configs="$extra_configs " + +. "$path/FINISH.sh" From f332605b1fea680dd6d7fa1ee55d35395baa6083 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 25 Jan 2005 16:42:16 +0400 Subject: [PATCH 12/54] tT replaced with T1 to be more predictable. --- mysql-test/r/lowercase_table2.result | 14 +++++++------- mysql-test/t/lowercase_table2.test | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/mysql-test/r/lowercase_table2.result b/mysql-test/r/lowercase_table2.result index cfd8f78a77c..a79b6b04063 100644 --- a/mysql-test/r/lowercase_table2.result +++ b/mysql-test/r/lowercase_table2.result @@ -1,4 +1,4 @@ -DROP TABLE IF EXISTS t1,t2,T1,T2,t3,T3,tT; +DROP TABLE IF EXISTS t1,t2,T1,T2,t3,T3; DROP DATABASE IF EXISTS `TEST_$1`; DROP DATABASE IF EXISTS `test_$1`; CREATE TABLE T1 (a int); @@ -131,13 +131,13 @@ show tables like 't1%'; Tables_in_test (t1%) t1 drop table t1; -create temporary table tT(a int(11), b varchar(8)); -insert into tT values (1, 'abc'); -select * from tT; +create temporary table T1(a int(11), b varchar(8)); +insert into T1 values (1, 'abc'); +select * from T1; a b 1 abc -alter table tT add index (a); -select * from tT; +alter table T1 add index (a); +select * from T1; a b 1 abc -drop table tT; +drop table T1; diff --git a/mysql-test/t/lowercase_table2.test b/mysql-test/t/lowercase_table2.test index 237dcd29950..a766e39abab 100644 --- a/mysql-test/t/lowercase_table2.test +++ b/mysql-test/t/lowercase_table2.test @@ -10,7 +10,7 @@ show variables like "lower_case_table_names"; enable_query_log; --disable_warnings -DROP TABLE IF EXISTS t1,t2,T1,T2,t3,T3,tT; +DROP TABLE IF EXISTS t1,t2,T1,T2,t3,T3; DROP DATABASE IF EXISTS `TEST_$1`; DROP DATABASE IF EXISTS `test_$1`; --enable_warnings @@ -105,9 +105,9 @@ drop table t1; # Bug #7261: Alter table loses temp table # -create temporary table tT(a int(11), b varchar(8)); -insert into tT values (1, 'abc'); -select * from tT; -alter table tT add index (a); -select * from tT; -drop table tT; +create temporary table T1(a int(11), b varchar(8)); +insert into T1 values (1, 'abc'); +select * from T1; +alter table T1 add index (a); +select * from T1; +drop table T1; From 984e7d29b2503b8d4a0a61c45beab07625da8ffa Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 25 Jan 2005 13:46:40 +0100 Subject: [PATCH 13/54] changed from using column names to column id in ndb setBound in ha_ndbcluster --- sql/ha_ndbcluster.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index c2d12ddd316..c5bb4984f40 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -1476,10 +1476,7 @@ int ha_ndbcluster::set_bounds(NdbIndexScanOperation *op, // Set bound if not cancelled via type -1 if (p.bound_type != -1) { - char truncated_field_name[NDB_MAX_ATTR_NAME_SIZE]; - strnmov(truncated_field_name,field->field_name,sizeof(truncated_field_name)); - truncated_field_name[sizeof(truncated_field_name)-1]= '\0'; - if (op->setBound(truncated_field_name, p.bound_type, p.bound_ptr)) + if (op->setBound(i, p.bound_type, p.bound_ptr)) ERR_RETURN(op->getNdbError()); } } From c2a2f5afb847b489cfddc88d8eb4b6309e298fe2 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 25 Jan 2005 21:27:51 +0200 Subject: [PATCH 14/54] Cleanups during review BitKeeper/etc/ignore: added libmysqld/examples/mysqltest_embedded client/mysqlbinlog.cc: Call mysql_close() before die() innobase/include/eval0eval.ic: Remove assert that fails on 64 bit machines (Tested with BUILD/compile-pentium64-valgrind-max on 64 bit Intel CPU) sql/mysqld.cc: Force lower_case_table_names to 0 if set to 2 on case insensitive file name sql/sql_select.cc: Remove #if 0 --- .bzrignore | 3 +++ client/mysqlbinlog.cc | 17 +++++++++++++---- innobase/include/eval0eval.ic | 2 -- sql/mysqld.cc | 9 ++++----- sql/sql_select.cc | 7 ------- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/.bzrignore b/.bzrignore index 40b7668cb64..199da0dd558 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1004,3 +1004,6 @@ vio/test-sslserver vio/viotest-ssl tests/mysql_client_test tests/mysql_client_test +libmysqld/examples/mysql_client_test.c +libmysqld/examples/mysql_client_test_embedded +libmysqld/examples/mysqltest_embedded diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 7ddb01d9ec8..0b15ad893e2 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -687,7 +687,7 @@ static int parse_args(int *argc, char*** argv) static MYSQL* safe_connect() { - MYSQL *local_mysql = mysql_init(NULL); + MYSQL *local_mysql= mysql_init(NULL); if (!local_mysql) die("Failed on mysql_init"); @@ -695,8 +695,12 @@ static MYSQL* safe_connect() if (opt_protocol) mysql_options(local_mysql, MYSQL_OPT_PROTOCOL, (char*) &opt_protocol); if (!mysql_real_connect(local_mysql, host, user, pass, 0, port, sock, 0)) - die("failed on connect: %s", mysql_error(local_mysql)); - + { + char errmsg[256]; + strmake(errmsg, mysql_error(local_mysql), sizeof(errmsg)-1); + mysql_close(local_mysql); + die("failed on connect: %s", errmsg); + } return local_mysql; } @@ -717,7 +721,12 @@ static int check_master_version(MYSQL* mysql) if (mysql_query(mysql, "SELECT VERSION()") || !(res = mysql_store_result(mysql))) - die("Error checking master version: %s", mysql_error(mysql)); + { + char errmsg[256]; + strmake(errmsg, mysql_error(mysql), sizeof(errmsg)-1); + mysql_close(mysql); + die("Error checking master version: %s", errmsg); + } if (!(row = mysql_fetch_row(res))) { mysql_free_result(res); diff --git a/innobase/include/eval0eval.ic b/innobase/include/eval0eval.ic index 2530c869206..069cbfe5f37 100644 --- a/innobase/include/eval0eval.ic +++ b/innobase/include/eval0eval.ic @@ -205,8 +205,6 @@ eval_node_copy_and_alloc_val( { byte* data; - ut_ad(UNIV_SQL_NULL > ULINT_MAX); - if (len == UNIV_SQL_NULL) { dfield_set_len(que_node_get_val(node), len); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 6d647b6edf0..c5ed516570a 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2915,12 +2915,11 @@ You should consider changing lower_case_table_names to 1 or 2", (test_if_case_insensitive(mysql_real_data_home) == 1))) { if (global_system_variables.log_warnings) - sql_print_warning("\ -You have forced lower_case_table_names to 2 through a command-line \ -option, even though your file system '%s' is case sensitive. This means \ -that you can create a table that you can then no longer access. \ -You should consider changing lower_case_table_names to 0.", + sql_print_warning("lower_case_table_names was set to 2, even though your " + "the file system '%s' is case sensitive. Now setting " + "lower_case_table_names to 0 to avoid future problems.", mysql_real_data_home); + lower_case_table_names= 0; } select_thread=pthread_self(); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index a53b878cf6c..e956d71a4be 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2828,16 +2828,9 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count, x = used key parts (1 <= x <= c) */ double rec_per_key; -#if 0 - if (!(rec_per_key=(double) - keyinfo->rec_per_key[keyinfo->key_parts-1])) - rec_per_key=(double) s->records/rec+1; -#else rec_per_key= keyinfo->rec_per_key[keyinfo->key_parts-1] ? (double) keyinfo->rec_per_key[keyinfo->key_parts-1] : (double) s->records/rec+1; -#endif - if (!s->records) tmp=0; else if (rec_per_key/(double) s->records >= 0.01) From 8deafa8037b289d089ffeb8d6bdaee812113a9b0 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 25 Jan 2005 14:30:38 -0800 Subject: [PATCH 15/54] order_by.result, order_by.test: Added a test case for bug #7672. sql_yacc.yy: Fixed bug #7672. Made queries of the form (SELECT ...) ORDER BY ... to be equivalent to SELECT ... ORDER BY ... sql/sql_yacc.yy: Fixed bug #7672. Made queries of the form (SELECT ...) ORDER BY ... to be equivalent to SELECT ... ORDER BY ... mysql-test/t/order_by.test: Added a test case for bug #7672. mysql-test/r/order_by.result: Added a test case for bug #7672. --- mysql-test/r/order_by.result | 17 +++++++++++++++++ mysql-test/t/order_by.test | 13 ++++++++++++- sql/sql_yacc.yy | 13 ++++++++----- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result index 859d9d4cab0..4ea638dbc19 100644 --- a/mysql-test/r/order_by.result +++ b/mysql-test/r/order_by.result @@ -554,3 +554,20 @@ explain select id,t from t1 force index (primary) order by id; table type possible_keys key key_len ref rows Extra t1 index NULL PRIMARY 4 NULL 1000 drop table t1; +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (2), (1), (1), (2), (1); +SELECT a FROM t1 ORDER BY a; +a +1 +1 +1 +2 +2 +(SELECT a FROM t1) ORDER BY a; +a +1 +1 +1 +2 +2 +DROP TABLE t1; diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test index 86ecc4aa70d..d65b2c257a1 100644 --- a/mysql-test/t/order_by.test +++ b/mysql-test/t/order_by.test @@ -363,4 +363,15 @@ while ($1) enable_query_log; explain select id,t from t1 order by id; explain select id,t from t1 force index (primary) order by id; -drop table t1; \ No newline at end of file +drop table t1; + +# +# Bug #7672 - a wrong result for a select query in braces followed by order by +# + +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (2), (1), (1), (2), (1); +SELECT a FROM t1 ORDER BY a; +(SELECT a FROM t1) ORDER BY a; +DROP TABLE t1; + diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 7b72c73a915..6d0237f5615 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -4033,11 +4033,14 @@ optional_order_or_limit: send_error(&lex->thd->net, ER_SYNTAX_ERROR); YYABORT; } - if (mysql_new_select(lex)) - YYABORT; - mysql_init_select(lex); - lex->select->linkage=NOT_A_SELECT; - lex->select->select_limit=lex->thd->variables.select_limit; + if (lex->select != &lex->select_lex) + { + if (mysql_new_select(lex)) + YYABORT; + mysql_init_select(lex); + lex->select->linkage=NOT_A_SELECT; + lex->select->select_limit=lex->thd->variables.select_limit; + } } opt_order_clause limit_clause ; From 235edc214452a870745264adc3841fed12925d4b Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 25 Jan 2005 23:13:36 -0800 Subject: [PATCH 16/54] order_by.result, order_by.test: Added test case for bug #7672 that existed only in 4.0. mysql-test/t/order_by.test: Added test case for bug #7672 that existed only in 4.0. mysql-test/r/order_by.result: Added test case for bug #7672 that existed only in 4.0. --- mysql-test/r/order_by.result | 17 +++++++++++++++++ mysql-test/t/order_by.test | 10 ++++++++++ 2 files changed, 27 insertions(+) diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result index ab71a6b53e6..ee8ca5f0328 100644 --- a/mysql-test/r/order_by.result +++ b/mysql-test/r/order_by.result @@ -771,3 +771,20 @@ sid wnid 39560 01019090000 37994 01019090000 drop table t1; +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (2), (1), (1), (2), (1); +SELECT a FROM t1 ORDER BY a; +a +1 +1 +1 +2 +2 +(SELECT a FROM t1) ORDER BY a; +a +1 +1 +1 +2 +2 +DROP TABLE t1; diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test index ab5e93603e4..c6a77c71b2f 100644 --- a/mysql-test/t/order_by.test +++ b/mysql-test/t/order_by.test @@ -534,3 +534,13 @@ explain select * from t1 where wnid like '0101%' order by wnid; select * from t1 where wnid like '0101%' order by wnid; drop table t1; + +# +# Bug #7672 - a wrong result for a select query in braces followed by order by +# + +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (2), (1), (1), (2), (1); +SELECT a FROM t1 ORDER BY a; +(SELECT a FROM t1) ORDER BY a; +DROP TABLE t1; From ea2795025e4172437f69e6c5819671c5b93c8aae Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 26 Jan 2005 08:57:43 +0100 Subject: [PATCH 17/54] innobase/include/univ.i remove a change that broke the test innobase/include/univ.i: remove a change that broke the test sql/item_create.cc: better fix --- innobase/include/univ.i | 6 ++---- sql/item_create.cc | 5 +++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/innobase/include/univ.i b/innobase/include/univ.i index c6ab258d3b7..625978ffc38 100644 --- a/innobase/include/univ.i +++ b/innobase/include/univ.i @@ -80,10 +80,8 @@ memory is read outside the allocated blocks. */ /* Make a non-inline debug version */ -#ifdef DBUG_ON -# define UNIV_DEBUG -#endif /* DBUG_ON */ /* +#define UNIV_DEBUG #define UNIV_MEM_DEBUG #define UNIV_IBUF_DEBUG #define UNIV_SYNC_DEBUG @@ -121,7 +119,7 @@ by one. */ /* Definition for inline version */ #ifdef __WIN__ -#define UNIV_INLINE __inline +#define UNIV_INLINE __inline #else /* config.h contains the right def for 'inline' for the current compiler */ #if (__GNUC__ == 2) diff --git a/sql/item_create.cc b/sql/item_create.cc index 99db184e71f..d959a6f393a 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -377,13 +377,14 @@ Item *create_func_space(Item *a) { uint dummy_errors; sp= new Item_string("",0,cs); - sp->str_value.copy(" ", 1, &my_charset_latin1, cs, &dummy_errors); + if (sp) + sp->str_value.copy(" ", 1, &my_charset_latin1, cs, &dummy_errors); } else { sp= new Item_string(" ",1,cs); } - return new Item_func_repeat(sp, a); + return sp ? new Item_func_repeat(sp, a) : 0; } Item *create_func_soundex(Item* a) From d42fbb43fd19946b1efe4b8ae960716730828494 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 26 Jan 2005 10:19:28 +0100 Subject: [PATCH 18/54] WL#1420 convert NIST test for mysql Test cases using common object (database,user,table,..) names could probably destroy customer data, when connecting to an already running server. This Changeset contains an auxiliary routine include/testdb_only.inc" which should be sourced by tests doing such dangerous things. The test case will get a "[skipped]" when the environment variable USE_RUNNING_SERVER is not 0 . The modified mysql-test-run.sh sets USE_RUNNING_SERVER to 0, when the "mysql-test-run" starts its own server, aka there was no "--extern" option. mysql-test/mysql-test-run.sh: If mysql-test-run spawns the server by itself, USE_RUNNING_SERVER will be set to 0 instead of "". If the option "--extern" was detected, USE_RUNNING_SERVER will be set to 1 instead of "1". Several comparisons have to be changed [ -z "$USE_RUNNING_SERVER" ] --> [ $USE_RUNNING_SERVER -eq 0 ] [ -n "$USE_RUNNING_SERVER" ] --> [ $USE_RUNNING_SERVER -eq 1 ] USE_RUNNING_SERVER will be exported. --- mysql-test/include/testdb_only.inc | 30 ++++++++++++++++++++++++ mysql-test/mysql-test-run.sh | 37 ++++++++++++++++-------------- mysql-test/r/testdb_only.require | 2 ++ 3 files changed, 52 insertions(+), 17 deletions(-) create mode 100644 mysql-test/include/testdb_only.inc create mode 100644 mysql-test/r/testdb_only.require diff --git a/mysql-test/include/testdb_only.inc b/mysql-test/include/testdb_only.inc new file mode 100644 index 00000000000..ddc3f123d45 --- /dev/null +++ b/mysql-test/include/testdb_only.inc @@ -0,0 +1,30 @@ +#################### include/testdb_only.inc ###################### +# # +# We must prevent to work on databases created by customers, # +# because we DROP/CREATE/MODIFY objects with sometimes common # +# names like STAFF, EMPLOYEE etc. # +# # +# Therefore we check the environment variable USE_RUNNING_SERVER. # +# USE_RUNNING_SERVER is exported by "mysql-test-run" and could # +# contain the following values: # +# 0 -- mysql-test-run was started without the --extern option # +# That means the test will be performed within the test # +# area 'mysql-test/var/...' . # +# 1 -- mysql-test-run was started with the --extern option # +# That means the test will be performed by an already # +# running server and data modifications will most probably # +# outside of the common test area 'mysql-test/var/...' . # +# # +# If USE_RUNNING_SERVER is not 0 the test will be skipped. # +# # +################################################################### + +--disable_query_log +eval set @USE_RUNNING_SERVER= '$USE_RUNNING_SERVER'; +--require r/testdb_only.require +SELECT 'use extern server' + AS "Variable_name ", + IF(@USE_RUNNING_SERVER= '1','YES', + IF(@USE_RUNNING_SERVER= '0','NO','UNEXPECTED')) + AS "Value" ; +--enable_query_log diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index 1e3052de8e8..73f10fca5cf 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -224,7 +224,7 @@ EXTRA_MASTER_OPT="" EXTRA_MYSQL_TEST_OPT="" EXTRA_MYSQLDUMP_OPT="" EXTRA_MYSQLBINLOG_OPT="" -USE_RUNNING_SERVER="" +USE_RUNNING_SERVER=0 USE_NDBCLUSTER="" USE_RUNNING_NDBCLUSTER="" DO_GCOV="" @@ -255,7 +255,7 @@ NDBD_EXTRA_OPTS= while test $# -gt 0; do case "$1" in --embedded-server) USE_EMBEDDED_SERVER=1 USE_MANAGER=0 NO_SLAVE=1 ; \ - USE_RUNNING_SERVER="" RESULT_EXT=".es" TEST_MODE="embedded" ;; + USE_RUNNING_SERVER=0 RESULT_EXT=".es" TEST_MODE="embedded" ;; --user=*) DBUSER=`$ECHO "$1" | $SED -e "s;--user=;;"` ;; --force) FORCE=1 ;; --timer) USE_TIMER=1 ;; @@ -265,8 +265,8 @@ while test $# -gt 0; do MASTER_MYSQLD=`$ECHO "$1" | $SED -e "s;--master-binary=;;"` ;; --slave-binary=*) SLAVE_MYSQLD=`$ECHO "$1" | $SED -e "s;--slave-binary=;;"` ;; - --local) USE_RUNNING_SERVER="" ;; - --extern) USE_RUNNING_SERVER="1" ;; + --local) USE_RUNNING_SERVER=0 ;; + --extern) USE_RUNNING_SERVER=1 ;; --with-ndbcluster) USE_NDBCLUSTER="--ndbcluster" ;; --ndb-connectstring=*) @@ -303,7 +303,7 @@ while test $# -gt 0; do --no-manager | --skip-manager) USE_MANAGER=0 ;; --manager) USE_MANAGER=1 - USE_RUNNING_SERVER= + USE_RUNNING_SERVER=0 ;; --start-and-exit) START_AND_EXIT=1 @@ -372,7 +372,7 @@ while test $# -gt 0; do EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --gdb" # This needs to be checked properly # USE_MANAGER=1 - USE_RUNNING_SERVER="" + USE_RUNNING_SERVER=0 ;; --client-gdb ) if [ x$BINARY_DIST = x1 ] ; then @@ -385,7 +385,7 @@ while test $# -gt 0; do --manual-gdb ) DO_GDB=1 MANUAL_GDB=1 - USE_RUNNING_SERVER="" + USE_RUNNING_SERVER=0 EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --gdb" EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --gdb" ;; @@ -394,7 +394,7 @@ while test $# -gt 0; do $ECHO "Note: you will get more meaningful output on a source distribution compiled with debugging option when running tests with --ddd option" fi DO_DDD=1 - USE_RUNNING_SERVER="" + USE_RUNNING_SERVER=0 EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --gdb" EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --gdb" ;; @@ -412,7 +412,7 @@ while test $# -gt 0; do EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --skip-safemalloc --skip-bdb" SLEEP_TIME_AFTER_RESTART=10 SLEEP_TIME_FOR_DELETE=60 - USE_RUNNING_SERVER="" + USE_RUNNING_SERVER=0 if test "$1" = "--valgrind-all" then VALGRIND="$VALGRIND -v --show-reachable=yes" @@ -627,9 +627,9 @@ fi if [ -z "$1" ] then - USE_RUNNING_SERVER="" + USE_RUNNING_SERVER=0 fi -if [ -n "$USE_RUNNING_SERVER" ] +if [ $USE_RUNNING_SERVER -eq 1 ] then MASTER_MYSOCK=$LOCAL_SOCKET; DBUSER=${DBUSER:-test} @@ -801,7 +801,7 @@ report_stats () { $ECHO "http://www.mysql.com/doc/en/MySQL_test_suite.html" fi - if test -z "$USE_RUNNING_SERVER" + if [ $USE_RUNNING_SERVER -eq 0 ] then # Report if there was any fatal warnings/errors in the log files @@ -1511,7 +1511,7 @@ run_testcase () done fi - if [ -z "$USE_RUNNING_SERVER" ] ; + if [ $USE_RUNNING_SERVER -eq 0 ] ; then if [ -f $master_opt_file ] ; then @@ -1655,7 +1655,7 @@ run_testcase () if [ x$FORCE != x1 ] ; then $ECHO "Aborting: $tname failed in $TEST_MODE mode. To continue, re-run with '--force'." $ECHO - if [ -z "$DO_GDB" ] && [ -z "$USE_RUNNING_SERVER" ] && \ + if [ -z "$DO_GDB" ] && [ $USE_RUNNING_SERVER -eq 0 ] && \ [ -z "$DO_DDD" ] && [ -z "$USE_EMBEDDED_SERVER" ] then mysql_stop @@ -1664,7 +1664,7 @@ run_testcase () exit 1 fi FAILED_CASES="$FAILED_CASES $tname" - if [ -z "$DO_GDB" ] && [ -z "$USE_RUNNING_SERVER" ] && \ + if [ -z "$DO_GDB" ] && [ $USE_RUNNING_SERVER -eq 0 ] && \ [ -z "$DO_DDD" ] && [ -z "$USE_EMBEDDED_SERVER" ] then mysql_restart @@ -1683,7 +1683,7 @@ run_testcase () [ "$DO_GCOV" ] && gcov_prepare [ "$DO_GPROF" ] && gprof_prepare -if [ -z "$USE_RUNNING_SERVER" ] +if [ $USE_RUNNING_SERVER -eq 0 ] then if [ -z "$FAST_START" ] then @@ -1744,6 +1744,9 @@ fi $ECHO "Starting Tests" +# Some test cases need USE_RUNNING_SERVER +export USE_RUNNING_SERVER + # # This can probably be deleted # @@ -1816,7 +1819,7 @@ fi $ECHO $DASH72 $ECHO -if [ -z "$DO_GDB" ] && [ -z "$USE_RUNNING_SERVER" ] && [ -z "$DO_DDD" ] +if [ -z "$DO_GDB" ] && [ $USE_RUNNING_SERVER -eq 0 ] && [ -z "$DO_DDD" ] then mysql_stop fi diff --git a/mysql-test/r/testdb_only.require b/mysql-test/r/testdb_only.require new file mode 100644 index 00000000000..e717418fdb6 --- /dev/null +++ b/mysql-test/r/testdb_only.require @@ -0,0 +1,2 @@ +Variable_name Value +use extern server NO From d041ed2d8cddc67fe9dacbf2060927b84139f3f4 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 26 Jan 2005 11:31:46 +0100 Subject: [PATCH 19/54] Bug#8101 unique indexes which attribute are _not_ specified in the order of the table does not work --- mysql-test/r/ndb_index_unique.result | 14 ++++++++ mysql-test/t/ndb_index_unique.test | 21 +++++++++++ sql/ha_ndbcluster.cc | 54 +++++++++++++++++++++++++--- sql/ha_ndbcluster.h | 1 + 4 files changed, 85 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/ndb_index_unique.result b/mysql-test/r/ndb_index_unique.result index f9cc89ee4cc..598b9dcccf7 100644 --- a/mysql-test/r/ndb_index_unique.result +++ b/mysql-test/r/ndb_index_unique.result @@ -612,3 +612,17 @@ a b c 3 NULL NULL 4 4 NULL drop table t1, t8; +create table t1( +id integer not null auto_increment, +month integer not null, +year integer not null, +code varchar( 2) not null, +primary key ( id), +unique idx_t1( month, code, year) +) engine=ndb; +INSERT INTO t1 (month, year, code) VALUES (4,2004,'12'); +INSERT INTO t1 (month, year, code) VALUES (5,2004,'12'); +select * from t1 where code = '12' and month = 4 and year = 2004 ; +id month year code +1 4 2004 12 +drop table t1; diff --git a/mysql-test/t/ndb_index_unique.test b/mysql-test/t/ndb_index_unique.test index f235d1ffc30..9bbea75028b 100644 --- a/mysql-test/t/ndb_index_unique.test +++ b/mysql-test/t/ndb_index_unique.test @@ -286,3 +286,24 @@ select * from t8 order by a; select * from t1 order by a; drop table t1, t8; +############################### +# Bug 8101 +# +# Unique index not specified in the same order as in table +# + +create table t1( + id integer not null auto_increment, + month integer not null, + year integer not null, + code varchar( 2) not null, + primary key ( id), + unique idx_t1( month, code, year) +) engine=ndb; + +INSERT INTO t1 (month, year, code) VALUES (4,2004,'12'); +INSERT INTO t1 (month, year, code) VALUES (5,2004,'12'); + +select * from t1 where code = '12' and month = 4 and year = 2004 ; + +drop table t1; diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index c5bb4984f40..437b5ebcdf7 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -765,6 +765,42 @@ int ha_ndbcluster::get_metadata(const char *path) DBUG_RETURN(build_index_list(table, ILBP_OPEN)); } +static int fix_unique_index_attr_order(NDB_INDEX_DATA &data, + const NDBINDEX *index, + KEY *key_info) +{ + DBUG_ENTER("fix_unique_index_attr_order"); + unsigned sz= index->getNoOfIndexColumns(); + + if (data.unique_index_attrid_map) + my_free((char*)data.unique_index_attrid_map, MYF(0)); + data.unique_index_attrid_map= (unsigned char*)my_malloc(sz,MYF(MY_WME)); + + KEY_PART_INFO* key_part= key_info->key_part; + KEY_PART_INFO* end= key_part+key_info->key_parts; + DBUG_ASSERT(key_info->key_parts == sz); + for (unsigned i= 0; key_part != end; key_part++, i++) + { + const char *field_name= key_part->field->field_name; + unsigned name_sz= strlen(field_name); + if (name_sz >= NDB_MAX_ATTR_NAME_SIZE) + name_sz= NDB_MAX_ATTR_NAME_SIZE-1; +#ifndef DBUG_OFF + data.unique_index_attrid_map[i]= 255; +#endif + for (unsigned j= 0; j < sz; j++) + { + const NdbDictionary::Column *c= index->getColumn(j); + if (strncmp(field_name, c->getName(), name_sz) == 0) + { + data.unique_index_attrid_map[i]= j; + break; + } + } + DBUG_ASSERT(data.unique_index_attrid_map[i] != 255); + } + DBUG_RETURN(0); +} int ha_ndbcluster::build_index_list(TABLE *tab, enum ILBP phase) { @@ -839,7 +875,8 @@ int ha_ndbcluster::build_index_list(TABLE *tab, enum ILBP phase) const NDBINDEX *index= dict->getIndex(unique_index_name, m_tabname); if (!index) DBUG_RETURN(1); m_index[i].unique_index= (void *) index; - } + error= fix_unique_index_attr_order(m_index[i], index, key_info); + } } DBUG_RETURN(error); @@ -897,6 +934,11 @@ void ha_ndbcluster::release_metadata() { m_index[i].unique_index= NULL; m_index[i].index= NULL; + if (m_index[i].unique_index_attrid_map) + { + my_free((char *)m_index[i].unique_index_attrid_map, MYF(0)); + m_index[i].unique_index_attrid_map= NULL; + } } DBUG_VOID_RETURN; @@ -1209,7 +1251,8 @@ int ha_ndbcluster::unique_index_read(const byte *key, for (i= 0; key_part != end; key_part++, i++) { - if (set_ndb_key(op, key_part->field, i, + if (set_ndb_key(op, key_part->field, + m_index[active_index].unique_index_attrid_map[i], key_part->null_bit ? key_ptr + 1 : key_ptr)) ERR_RETURN(trans->getNdbError()); key_ptr+= key_part->store_length; @@ -3836,9 +3879,10 @@ ha_ndbcluster::ha_ndbcluster(TABLE *table_arg): for (i= 0; i < MAX_KEY; i++) { - m_index[i].type= UNDEFINED_INDEX; - m_index[i].unique_index= NULL; - m_index[i].index= NULL; + m_index[i].type= UNDEFINED_INDEX; + m_index[i].unique_index= NULL; + m_index[i].index= NULL; + m_index[i].unique_index_attrid_map= NULL; } DBUG_VOID_RETURN; diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h index 15e61a93574..07b305bad3e 100644 --- a/sql/ha_ndbcluster.h +++ b/sql/ha_ndbcluster.h @@ -52,6 +52,7 @@ typedef struct ndb_index_data { NDB_INDEX_TYPE type; void *index; void *unique_index; + unsigned char *unique_index_attrid_map; } NDB_INDEX_DATA; typedef struct st_ndbcluster_share { From d9274b337c4c1acf36c500df590b66e2fa30fafb Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 26 Jan 2005 12:55:35 +0200 Subject: [PATCH 20/54] Added -DDBUG_ON to CXXFLAGS when compiling with debugging This fixes a memory allocation bug in Innobase as structs was defined differently in .c and .cc files --- configure.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index cc845a7bb8d..3e9ea6eebe7 100644 --- a/configure.in +++ b/configure.in @@ -1681,12 +1681,12 @@ if test "$with_debug" = "yes" then # Medium debug. CFLAGS="$DEBUG_CFLAGS $DEBUG_OPTIMIZE_CC -DDBUG_ON -DSAFE_MUTEX $CFLAGS" - CXXFLAGS="$DEBUG_CXXFLAGS $DEBUG_OPTIMIZE_CXX -DSAFE_MUTEX $CXXFLAGS" + CXXFLAGS="$DEBUG_CXXFLAGS $DEBUG_OPTIMIZE_CXX -DDBUG_ON -DSAFE_MUTEX $CXXFLAGS" elif test "$with_debug" = "full" then # Full debug. Very slow in some cases CFLAGS="$DEBUG_CFLAGS -DDBUG_ON -DSAFE_MUTEX -DSAFEMALLOC $CFLAGS" - CXXFLAGS="$DEBUG_CXXFLAGS -DSAFE_MUTEX -DSAFEMALLOC $CXXFLAGS" + CXXFLAGS="$DEBUG_CXXFLAGS -DDBUG_ON -DSAFE_MUTEX -DSAFEMALLOC $CXXFLAGS" else # Optimized version. No debug CFLAGS="$OPTIMIZE_CFLAGS -DDBUG_OFF $CFLAGS" From 54a1e372e13035cb22453f0bfb9102ee9e4297ea Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 26 Jan 2005 15:11:55 +0400 Subject: [PATCH 21/54] a fix (bug #8129: help.test fails using --ps-protocol) sql/sql_help.cc: a fix (bug #8129: help.test fails using --ps-protocol) In case of 'range' we have to call quick->reset(). --- sql/sql_help.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/sql_help.cc b/sql/sql_help.cc index 7bf28a439b6..ff2f5bf4992 100644 --- a/sql/sql_help.cc +++ b/sql/sql_help.cc @@ -559,7 +559,8 @@ SQL_SELECT *prepare_simple_select(THD *thd, Item *cond, TABLE_LIST *tables, if (!cond->fixed) cond->fix_fields(thd, tables, &cond); // can never fail SQL_SELECT *res= make_select(table,0,0,cond,error); - if (*error || (res && res->check_quick(thd, 0, HA_POS_ERROR))) + if (*error || (res && res->check_quick(thd, 0, HA_POS_ERROR)) || + (res->quick && res->quick->reset())) { delete res; res=0; From 662823c2097654f6bc92deef0d2777ab9d8a20ac Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 26 Jan 2005 16:02:19 +0400 Subject: [PATCH 22/54] after review fixup (bug #8129: help.test fails using --ps-protocol) --- sql/sql_help.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sql/sql_help.cc b/sql/sql_help.cc index ff2f5bf4992..759b535da53 100644 --- a/sql/sql_help.cc +++ b/sql/sql_help.cc @@ -558,6 +558,10 @@ SQL_SELECT *prepare_simple_select(THD *thd, Item *cond, TABLE_LIST *tables, { if (!cond->fixed) cond->fix_fields(thd, tables, &cond); // can never fail + + /* Assume that no indexes cover all required fields */ + table->used_keys.clear_all(); + SQL_SELECT *res= make_select(table,0,0,cond,error); if (*error || (res && res->check_quick(thd, 0, HA_POS_ERROR)) || (res->quick && res->quick->reset())) From 9bb464487d6c1c0359dba9aa79e88f927cd24c93 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 26 Jan 2005 16:34:09 +0400 Subject: [PATCH 23/54] CSC#4385: slow sorting for UTF8 large table: my_strnxfrm_utf8 now requires 2 bytes per character in filesort key, instead of 3 bytes per character. Shorter filesort keys make sorting faster. --- include/m_ctype.h | 4 +++- sql/filesort.cc | 4 ++-- strings/ctype-big5.c | 1 + strings/ctype-bin.c | 2 ++ strings/ctype-cp932.c | 1 + strings/ctype-czech.c | 1 + strings/ctype-euc_kr.c | 1 + strings/ctype-eucjpms.c | 1 + strings/ctype-gb2312.c | 1 + strings/ctype-gbk.c | 1 + strings/ctype-latin1.c | 1 + strings/ctype-mb.c | 1 + strings/ctype-simple.c | 10 ++++++++++ strings/ctype-sjis.c | 1 + strings/ctype-tis620.c | 1 + strings/ctype-uca.c | 2 ++ strings/ctype-ucs2.c | 2 ++ strings/ctype-ujis.c | 1 + strings/ctype-utf8.c | 37 ++++++++++++++++++++++++------------- strings/ctype-win1250ch.c | 1 + 20 files changed, 58 insertions(+), 16 deletions(-) diff --git a/include/m_ctype.h b/include/m_ctype.h index c2354c7feff..c41c7385b3d 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -110,6 +110,7 @@ typedef struct my_collation_handler_st my_bool diff_if_only_endspace_difference); int (*strnxfrm)(struct charset_info_st *, uchar *, uint, const uchar *, uint); + uint (*strnxfrmlen)(struct charset_info_st *, uint); my_bool (*like_range)(struct charset_info_st *, const char *s, uint s_length, pchar w_prefix, pchar w_one, pchar w_many, @@ -259,7 +260,8 @@ extern CHARSET_INFO my_charset_cp1250_czech_ci; /* declarations for simple charsets */ extern int my_strnxfrm_simple(CHARSET_INFO *, uchar *, uint, const uchar *, - uint); + uint); +uint my_strnxfrmlen_simple(CHARSET_INFO *, uint); extern int my_strnncoll_simple(CHARSET_INFO *, const uchar *, uint, const uchar *, uint, my_bool); diff --git a/sql/filesort.cc b/sql/filesort.cc index 0e9fa8c79ed..1665358dbf0 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -1187,7 +1187,7 @@ sortlength(SORT_FIELD *sortorder, uint s_length, bool *multi_byte_charset) { sortorder->need_strxnfrm= 1; *multi_byte_charset= 1; - sortorder->length= sortorder->length*cs->strxfrm_multiply; + sortorder->length= cs->coll->strnxfrmlen(cs, sortorder->length); } } if (sortorder->field->maybe_null()) @@ -1200,7 +1200,7 @@ sortlength(SORT_FIELD *sortorder, uint s_length, bool *multi_byte_charset) sortorder->length=sortorder->item->max_length; if (use_strnxfrm((cs=sortorder->item->collation.collation))) { - sortorder->length= sortorder->length*cs->strxfrm_multiply; + sortorder->length= cs->coll->strnxfrmlen(cs, sortorder->length); sortorder->need_strxnfrm= 1; *multi_byte_charset= 1; } diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c index a2db7de244e..70c5ec633be 100644 --- a/strings/ctype-big5.c +++ b/strings/ctype-big5.c @@ -6293,6 +6293,7 @@ static MY_COLLATION_HANDLER my_collation_big5_chinese_ci_handler = my_strnncoll_big5, my_strnncollsp_big5, my_strnxfrm_big5, + my_strnxfrmlen_simple, my_like_range_big5, my_wildcmp_mb, my_strcasecmp_mb, diff --git a/strings/ctype-bin.c b/strings/ctype-bin.c index 401605a462f..50c66a63e97 100644 --- a/strings/ctype-bin.c +++ b/strings/ctype-bin.c @@ -447,6 +447,7 @@ MY_COLLATION_HANDLER my_collation_8bit_bin_handler = my_strnncoll_8bit_bin, my_strnncollsp_8bit_bin, my_strnxfrm_8bit_bin, + my_strnxfrmlen_simple, my_like_range_simple, my_wildcmp_bin, my_strcasecmp_bin, @@ -461,6 +462,7 @@ static MY_COLLATION_HANDLER my_collation_binary_handler = my_strnncoll_binary, my_strnncollsp_binary, my_strnxfrm_bin, + my_strnxfrmlen_simple, my_like_range_simple, my_wildcmp_bin, my_strcasecmp_bin, diff --git a/strings/ctype-cp932.c b/strings/ctype-cp932.c index 804f87b2a5b..c47f2c2d8ce 100644 --- a/strings/ctype-cp932.c +++ b/strings/ctype-cp932.c @@ -5454,6 +5454,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncoll_cp932, my_strnncollsp_cp932, my_strnxfrm_cp932, + my_strnxfrmlen_simple, my_like_range_cp932, my_wildcmp_mb, /* wildcmp */ my_strcasecmp_8bit, diff --git a/strings/ctype-czech.c b/strings/ctype-czech.c index 2834dbb28ff..f5a410afc50 100644 --- a/strings/ctype-czech.c +++ b/strings/ctype-czech.c @@ -593,6 +593,7 @@ static MY_COLLATION_HANDLER my_collation_latin2_czech_ci_handler = my_strnncoll_czech, my_strnncollsp_czech, my_strnxfrm_czech, + my_strnxfrmlen_simple, my_like_range_czech, my_wildcmp_8bit, my_strcasecmp_8bit, diff --git a/strings/ctype-euc_kr.c b/strings/ctype-euc_kr.c index ee792d9c3e4..289b7309ea0 100644 --- a/strings/ctype-euc_kr.c +++ b/strings/ctype-euc_kr.c @@ -8641,6 +8641,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncoll_simple, /* strnncoll */ my_strnncollsp_simple, my_strnxfrm_simple, /* strnxfrm */ + my_strnxfrmlen_simple, my_like_range_simple, /* like_range */ my_wildcmp_mb, /* wildcmp */ my_strcasecmp_mb, diff --git a/strings/ctype-eucjpms.c b/strings/ctype-eucjpms.c index 5b108d24f4b..8c8d237cf48 100644 --- a/strings/ctype-eucjpms.c +++ b/strings/ctype-eucjpms.c @@ -8636,6 +8636,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncoll_simple,/* strnncoll */ my_strnncollsp_simple, my_strnxfrm_simple, /* strnxfrm */ + my_strnxfrmlen_simple, my_like_range_simple,/* like_range */ my_wildcmp_mb, /* wildcmp */ my_strcasecmp_mb, diff --git a/strings/ctype-gb2312.c b/strings/ctype-gb2312.c index f17cc94723f..73e4132dd7f 100644 --- a/strings/ctype-gb2312.c +++ b/strings/ctype-gb2312.c @@ -5692,6 +5692,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncoll_simple, /* strnncoll */ my_strnncollsp_simple, my_strnxfrm_simple, /* strnxfrm */ + my_strnxfrmlen_simple, my_like_range_simple, /* like_range */ my_wildcmp_mb, /* wildcmp */ my_strcasecmp_mb, /* instr */ diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c index dc4aea60096..6b47b537fb9 100644 --- a/strings/ctype-gbk.c +++ b/strings/ctype-gbk.c @@ -9939,6 +9939,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncoll_gbk, my_strnncollsp_gbk, my_strnxfrm_gbk, + my_strnxfrmlen_simple, my_like_range_gbk, my_wildcmp_mb, my_strcasecmp_mb, diff --git a/strings/ctype-latin1.c b/strings/ctype-latin1.c index b5da99a7452..043645684cf 100644 --- a/strings/ctype-latin1.c +++ b/strings/ctype-latin1.c @@ -693,6 +693,7 @@ static MY_COLLATION_HANDLER my_collation_german2_ci_handler= my_strnncoll_latin1_de, my_strnncollsp_latin1_de, my_strnxfrm_latin1_de, + my_strnxfrmlen_simple, my_like_range_simple, my_wildcmp_8bit, my_strcasecmp_8bit, diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c index 4be21599fef..e902730d65a 100644 --- a/strings/ctype-mb.c +++ b/strings/ctype-mb.c @@ -912,6 +912,7 @@ MY_COLLATION_HANDLER my_collation_mb_bin_handler = my_strnncoll_mb_bin, my_strnncollsp_mb_bin, my_strnxfrm_mb_bin, + my_strnxfrmlen_simple, my_like_range_simple, my_wildcmp_mb_bin, my_strcasecmp_mb_bin, diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index bb623ef66f1..e436d5f8702 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -21,6 +21,15 @@ #include "stdarg.h" +/* + Returns the number of bytes required for strnxfrm(). +*/ +uint my_strnxfrmlen_simple(CHARSET_INFO *cs, uint len) +{ + return len * (cs->strxfrm_multiply ? cs->strxfrm_multiply : 1); +} + + /* Converts a string into its sort key. @@ -1365,6 +1374,7 @@ MY_COLLATION_HANDLER my_collation_8bit_simple_ci_handler = my_strnncoll_simple, my_strnncollsp_simple, my_strnxfrm_simple, + my_strnxfrmlen_simple, my_like_range_simple, my_wildcmp_8bit, my_strcasecmp_8bit, diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c index c1e41dc2d94..22cc8d9818d 100644 --- a/strings/ctype-sjis.c +++ b/strings/ctype-sjis.c @@ -4627,6 +4627,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncoll_sjis, my_strnncollsp_sjis, my_strnxfrm_sjis, + my_strnxfrmlen_simple, my_like_range_sjis, my_wildcmp_mb, /* wildcmp */ my_strcasecmp_8bit, diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index c6bdd106ad4..9ba35e1c8ec 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -927,6 +927,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncoll_tis620, my_strnncollsp_tis620, my_strnxfrm_tis620, + my_strnxfrmlen_simple, my_like_range_tis620, my_wildcmp_8bit, /* wildcmp */ my_strcasecmp_8bit, diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c index 2353c9397a2..8345d0474f2 100644 --- a/strings/ctype-uca.c +++ b/strings/ctype-uca.c @@ -8024,6 +8024,7 @@ MY_COLLATION_HANDLER my_collation_ucs2_uca_handler = my_strnncoll_ucs2_uca, my_strnncollsp_ucs2_uca, my_strnxfrm_ucs2_uca, + my_strnxfrmlen_simple, my_like_range_ucs2, my_wildcmp_uca, NULL, @@ -8504,6 +8505,7 @@ MY_COLLATION_HANDLER my_collation_any_uca_handler = my_strnncoll_any_uca, my_strnncollsp_any_uca, my_strnxfrm_any_uca, + my_strnxfrmlen_simple, my_like_range_mb, my_wildcmp_uca, NULL, diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index adfd4794e36..0d45cceb64d 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -1499,6 +1499,7 @@ static MY_COLLATION_HANDLER my_collation_ucs2_general_ci_handler = my_strnncoll_ucs2, my_strnncollsp_ucs2, my_strnxfrm_ucs2, + my_strnxfrmlen_simple, my_like_range_ucs2, my_wildcmp_ucs2_ci, my_strcasecmp_ucs2, @@ -1513,6 +1514,7 @@ static MY_COLLATION_HANDLER my_collation_ucs2_bin_handler = my_strnncoll_ucs2_bin, my_strnncollsp_ucs2_bin, my_strnxfrm_ucs2_bin, + my_strnxfrmlen_simple, my_like_range_simple, my_wildcmp_ucs2_bin, my_strcasecmp_ucs2_bin, diff --git a/strings/ctype-ujis.c b/strings/ctype-ujis.c index fc1496df280..deaddcc76f6 100644 --- a/strings/ctype-ujis.c +++ b/strings/ctype-ujis.c @@ -8501,6 +8501,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncoll_simple,/* strnncoll */ my_strnncollsp_simple, my_strnxfrm_simple, /* strnxfrm */ + my_strnxfrmlen_simple, my_like_range_simple,/* like_range */ my_wildcmp_mb, /* wildcmp */ my_strcasecmp_mb, diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index 1f9f158a73d..e17e7587e85 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -2238,6 +2238,12 @@ int my_wildcmp_utf8(CHARSET_INFO *cs, } +static +uint my_strnxfrmlen_utf8(CHARSET_INFO *cs __attribute__((unused)), uint len) +{ + return (len * 2 + 2) / 3; +} + static int my_strnxfrm_utf8(CHARSET_INFO *cs, uchar *dst, uint dstlen, const uchar *src, uint srclen) @@ -2245,29 +2251,33 @@ static int my_strnxfrm_utf8(CHARSET_INFO *cs, my_wc_t wc; int res; int plane; - uchar *de = dst + dstlen; + uchar *de= dst + dstlen; + uchar *de_beg= de - 1; const uchar *se = src + srclen; - while( src < se && dst < de ) + while (dst < de_beg) { - if ((res=my_utf8_uni(cs,&wc, src, se))<0) - { + if ((res=my_utf8_uni(cs,&wc, src, se)) <= 0) break; - } src+=res; - srclen-=res; plane=(wc>>8) & 0xFF; wc = uni_plane[plane] ? uni_plane[plane][wc & 0xFF].sort : wc; - if ((res=my_uni_utf8(cs,wc,dst,de)) <0) - { - break; - } - dst+=res; + *dst++= wc >> 8; + *dst++= wc & 0xFF; + } - if (dst < de) - bfill(dst, de - dst, ' '); + + while (dst < de_beg) /* Fill the tail with keys for space character */ + { + *dst++= 0x00; + *dst++= 0x20; + } + + if (dst < de) /* Clear the last byte, if "dstlen" was an odd number */ + *de= 0x00; + return dstlen; } @@ -2306,6 +2316,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncoll_utf8, my_strnncollsp_utf8, my_strnxfrm_utf8, + my_strnxfrmlen_utf8, my_like_range_mb, my_wildcmp_utf8, my_strcasecmp_utf8, diff --git a/strings/ctype-win1250ch.c b/strings/ctype-win1250ch.c index b58a8f0f1e5..37611a5bd20 100644 --- a/strings/ctype-win1250ch.c +++ b/strings/ctype-win1250ch.c @@ -626,6 +626,7 @@ static MY_COLLATION_HANDLER my_collation_czech_ci_handler = my_strnncoll_win1250ch, my_strnncollsp_win1250ch, my_strnxfrm_win1250ch, + my_strnxfrmlen_simple, my_like_range_win1250ch, my_wildcmp_8bit, my_strcasecmp_8bit, From ddad73b3762f0f5485b0b60afa2ed5f8e7d26fd8 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 26 Jan 2005 14:38:13 +0100 Subject: [PATCH 24/54] added check in ndb tests that require "default" cluster running i.e. ndb_restore --- mysql-test/include/ndb_default_cluster.inc | 4 ++++ mysql-test/r/ndb_default_cluster.require | 2 ++ mysql-test/t/ndb_restore.test | 1 + 3 files changed, 7 insertions(+) create mode 100644 mysql-test/include/ndb_default_cluster.inc create mode 100644 mysql-test/r/ndb_default_cluster.require diff --git a/mysql-test/include/ndb_default_cluster.inc b/mysql-test/include/ndb_default_cluster.inc new file mode 100644 index 00000000000..2f900b6a0b4 --- /dev/null +++ b/mysql-test/include/ndb_default_cluster.inc @@ -0,0 +1,4 @@ +-- require r/ndb_default_cluster.require +disable_query_log; +show status like "Ndb_connected_host"; +enable_query_log; diff --git a/mysql-test/r/ndb_default_cluster.require b/mysql-test/r/ndb_default_cluster.require new file mode 100644 index 00000000000..aa4988cdca3 --- /dev/null +++ b/mysql-test/r/ndb_default_cluster.require @@ -0,0 +1,2 @@ +Variable_name Value +Ndb_connected_host localhost diff --git a/mysql-test/t/ndb_restore.test b/mysql-test/t/ndb_restore.test index 09939ec119d..3a77289a8fb 100644 --- a/mysql-test/t/ndb_restore.test +++ b/mysql-test/t/ndb_restore.test @@ -1,4 +1,5 @@ -- source include/have_ndb.inc +-- source include/ndb_default_cluster.inc --disable_warnings use test; From fbba239004e378c122993deb0208274ded7e4b64 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 26 Jan 2005 15:07:39 +0100 Subject: [PATCH 25/54] updated show table status usage in ndb tests to become independent on ndb cluster run --- mysql-test/r/ndb_alter_table.result | 8 ++++---- mysql-test/r/ndb_autodiscover.result | 4 ++-- mysql-test/t/ndb_alter_table.test | 4 ++++ mysql-test/t/ndb_autodiscover.test | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/ndb_alter_table.result b/mysql-test/r/ndb_alter_table.result index 2857a4b5cc7..2aab46014a9 100644 --- a/mysql-test/r/ndb_alter_table.result +++ b/mysql-test/r/ndb_alter_table.result @@ -34,13 +34,13 @@ col5 enum('PENDING', 'ACTIVE', 'DISABLED') not null, col6 int not null, to_be_deleted int) ENGINE=ndbcluster; show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 ndbcluster 10 Dynamic 0 0 0 0 0 0 1 NULL NULL NULL latin1_swedish_ci NULL number_of_replicas: 2 +t1 ndbcluster 10 Dynamic 0 0 # # 0 # 1 # # # latin1_swedish_ci NULL # SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO; insert into t1 values (0,4,3,5,"PENDING",1,7),(NULL,4,3,5,"PENDING",1,7),(31,4,3,5,"PENDING",1,7), (7,4,3,5,"PENDING",1,7), (NULL,4,3,5,"PENDING",1,7), (100,4,3,5,"PENDING",1,7), (99,4,3,5,"PENDING",1,7), (8,4,3,5,"PENDING",1,7), (NULL,4,3,5,"PENDING",1,7); show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 ndbcluster 10 Dynamic 9 96 131072 0 0 0 101 NULL NULL NULL latin1_swedish_ci NULL number_of_replicas: 2 +t1 ndbcluster 10 Dynamic 9 96 # # 0 # 101 # # # latin1_swedish_ci NULL # select * from t1 order by col1; col1 col2 col3 col4 col5 col6 to_be_deleted 0 4 3 5 PENDING 1 7 @@ -60,7 +60,7 @@ change column col2 fourth varchar(30) not null after col3, modify column col6 int not null first; show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 ndbcluster 10 Dynamic 9 152 131072 0 0 0 102 NULL NULL NULL latin1_swedish_ci NULL number_of_replicas: 2 +t1 ndbcluster 10 Dynamic 9 152 # # 0 # 102 # # # latin1_swedish_ci NULL # select * from t1 order by col1; col6 col1 col3 fourth col4 col4_5 col5 col7 col8 1 0 3 4 5 PENDING 0000-00-00 00:00:00 @@ -75,7 +75,7 @@ col6 col1 col3 fourth col4 col4_5 col5 col7 col8 insert into t1 values (2, NULL,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00'); show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 ndbcluster 10 Dynamic 10 152 131072 0 0 0 103 NULL NULL NULL latin1_swedish_ci NULL number_of_replicas: 2 +t1 ndbcluster 10 Dynamic 10 152 # # 0 # 103 # # # latin1_swedish_ci NULL # select * from t1 order by col1; col6 col1 col3 fourth col4 col4_5 col5 col7 col8 1 0 3 4 5 PENDING 0000-00-00 00:00:00 diff --git a/mysql-test/r/ndb_autodiscover.result b/mysql-test/r/ndb_autodiscover.result index b89b4ce1f21..ba21483a9b0 100644 --- a/mysql-test/r/ndb_autodiscover.result +++ b/mysql-test/r/ndb_autodiscover.result @@ -144,8 +144,8 @@ Handler_discover 1 flush tables; show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t6 MyISAM 9 Fixed 1 260 # # # 0 NULL # # NULL # NULL -t7 ndbcluster 9 Fixed 1 276 # # # 0 NULL # # NULL # NULL number_of_replicas: 2 +t6 MyISAM 9 Fixed 1 260 # # # 0 NULL # # NULL # NULL # +t7 ndbcluster 9 Fixed 1 276 # # # 0 NULL # # NULL # NULL # show status like 'handler_discover%'; Variable_name Value Handler_discover 2 diff --git a/mysql-test/t/ndb_alter_table.test b/mysql-test/t/ndb_alter_table.test index 892443a1407..3544a50c3e1 100644 --- a/mysql-test/t/ndb_alter_table.test +++ b/mysql-test/t/ndb_alter_table.test @@ -47,10 +47,12 @@ col3 varchar (20) not null, col4 varchar(4) not null, col5 enum('PENDING', 'ACTIVE', 'DISABLED') not null, col6 int not null, to_be_deleted int) ENGINE=ndbcluster; +--replace_column 7 # 8 # 10 # 12 # 13 # 14 # 18 # show table status; SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO; insert into t1 values (0,4,3,5,"PENDING",1,7),(NULL,4,3,5,"PENDING",1,7),(31,4,3,5,"PENDING",1,7), (7,4,3,5,"PENDING",1,7), (NULL,4,3,5,"PENDING",1,7), (100,4,3,5,"PENDING",1,7), (99,4,3,5,"PENDING",1,7), (8,4,3,5,"PENDING",1,7), (NULL,4,3,5,"PENDING",1,7); +--replace_column 7 # 8 # 10 # 12 # 13 # 14 # 18 # show table status; select * from t1 order by col1; alter table t1 @@ -59,9 +61,11 @@ add column col7 varchar(30) not null after col5, add column col8 datetime not null, drop column to_be_deleted, change column col2 fourth varchar(30) not null after col3, modify column col6 int not null first; +--replace_column 7 # 8 # 10 # 12 # 13 # 14 # 18 # show table status; select * from t1 order by col1; insert into t1 values (2, NULL,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00'); +--replace_column 7 # 8 # 10 # 12 # 13 # 14 # 18 # show table status; select * from t1 order by col1; delete from t1; diff --git a/mysql-test/t/ndb_autodiscover.test b/mysql-test/t/ndb_autodiscover.test index 2159e6b6e62..713aa326e4d 100644 --- a/mysql-test/t/ndb_autodiscover.test +++ b/mysql-test/t/ndb_autodiscover.test @@ -176,7 +176,7 @@ show status like 'handler_discover%'; flush tables; system rm var/master-data/test/t7.frm ; ---replace_column 7 # 8 # 9 # 12 # 13 # 15 # +--replace_column 7 # 8 # 9 # 12 # 13 # 15 # 18 # show table status; show status like 'handler_discover%'; From 3c3ca269ec47566ed9a588c52c3671ca4225e53a Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 26 Jan 2005 16:07:53 +0200 Subject: [PATCH 26/54] Only enable Innodb extra debugging when using the --debug=full configure option BUILD/SETUP.sh: Abort if wrong options BUILD/compile-pentium64-debug: Always use full debugging innobase/fil/fil0fil.c: Fixed wrong printf() format --- BUILD/SETUP.sh | 8 ++++++-- BUILD/compile-pentium64-debug | 2 +- configure.in | 4 ++-- innobase/fil/fil0fil.c | 6 +++--- innobase/include/univ.i | 4 ++++ 5 files changed, 16 insertions(+), 8 deletions(-) mode change 100644 => 100755 BUILD/SETUP.sh diff --git a/BUILD/SETUP.sh b/BUILD/SETUP.sh old mode 100644 new mode 100755 index 5fe898878b9..77fab948121 --- a/BUILD/SETUP.sh +++ b/BUILD/SETUP.sh @@ -25,7 +25,10 @@ Any other options will be passed directly to configure. Note: this script is intended for internal use by MySQL developers. EOF --with-debug=full ) full_debug="=full"; shift ;; - * ) break ;; + * ) + echo "Unknown option '$1'" + exit 1 + break ;; esac done @@ -62,6 +65,7 @@ fast_cflags="-O3 -fno-omit-frame-pointer" reckless_cflags="-O3 -fomit-frame-pointer " debug_cflags="-DUNIV_MUST_NOT_INLINE -DEXTRA_DEBUG -DFORCE_INIT_OF_VARS -DSAFEMALLOC -DPEDANTIC_SAFEMALLOC -DSAFE_MUTEX" +debug_extra_cflags="-O1 -Wuninitialized" base_cxxflags="-felide-constructors -fno-exceptions -fno-rtti" amd64_cxxflags="-DBIG_TABLES" @@ -80,7 +84,7 @@ local_infile_configs="--enable-local-infile" debug_configs="--with-debug$full_debug" if [ -z "$full_debug" ] then - debug_cflags="$debug_cflags -O1 -Wuninitialized" + debug_cflags="$debug_cflags $debug_extra_cflags" fi if gmake --version > /dev/null 2>&1 diff --git a/BUILD/compile-pentium64-debug b/BUILD/compile-pentium64-debug index 1bbca36d851..0299669f79a 100755 --- a/BUILD/compile-pentium64-debug +++ b/BUILD/compile-pentium64-debug @@ -1,7 +1,7 @@ #! /bin/sh path=`dirname $0` -. "$path/SETUP.sh" +. "$path/SETUP.sh" $@ --with-debug=full extra_flags="$pentium64_cflags $debug_cflags" c_warnings="$c_warnings $debug_extra_warnings" diff --git a/configure.in b/configure.in index 3e9ea6eebe7..985b5923c5c 100644 --- a/configure.in +++ b/configure.in @@ -1685,8 +1685,8 @@ then elif test "$with_debug" = "full" then # Full debug. Very slow in some cases - CFLAGS="$DEBUG_CFLAGS -DDBUG_ON -DSAFE_MUTEX -DSAFEMALLOC $CFLAGS" - CXXFLAGS="$DEBUG_CXXFLAGS -DDBUG_ON -DSAFE_MUTEX -DSAFEMALLOC $CXXFLAGS" + CFLAGS="$DEBUG_CFLAGS -DDBUG_ON -DSAFE_MUTEX -DSAFEMALLOC -DUNIV_DEBUG $CFLAGS" + CXXFLAGS="$DEBUG_CXXFLAGS -DDBUG_ON -DSAFE_MUTEX -DSAFEMALLOC -DUNIV_DEBUG $CXXFLAGS" else # Optimized version. No debug CFLAGS="$OPTIMIZE_CFLAGS -DDBUG_OFF $CFLAGS" diff --git a/innobase/fil/fil0fil.c b/innobase/fil/fil0fil.c index 5f71c00aea6..cc1c4a22983 100644 --- a/innobase/fil/fil0fil.c +++ b/innobase/fil/fil0fil.c @@ -685,9 +685,9 @@ fil_try_to_close_file_in_LRU( fputs("InnoDB: cannot close file ", stderr); ut_print_filename(stderr, node->name); fprintf(stderr, - ", because mod_count %lld != fl_count %lld\n", - node->modification_counter, - node->flush_counter); + ", because mod_count %ld != fl_count %ld\n", + (ulong) node->modification_counter, + (ulong) node->flush_counter); } node = UT_LIST_GET_PREV(LRU, node); diff --git a/innobase/include/univ.i b/innobase/include/univ.i index 625978ffc38..6ae4fe1c2ce 100644 --- a/innobase/include/univ.i +++ b/innobase/include/univ.i @@ -80,6 +80,10 @@ memory is read outside the allocated blocks. */ /* Make a non-inline debug version */ +#ifdef DBUG_ON +#define UNIV_DEBUG +#endif /* DBUG_ON */ + /* #define UNIV_DEBUG #define UNIV_MEM_DEBUG From 86016aeb45cee7182a3de818d9598aa9ebafe568 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 26 Jan 2005 15:19:20 +0100 Subject: [PATCH 27/54] Fixes for windows compilation bugs (After review of cs georg:1.1800 by Monty) VC++Files/libmysqld/libmysqld.dsp: removed ha_isammrg.cpp (doesn't exist anymore) VC++Files/mysqldemb/mysqldemb.dsp: removed ha_isammrg.cpp (doesn't exist anymore) extra/comp_err.c: renamed DATADIR to DATADIRECTORY (DATADIR is a windows internal enumeration type) innobase/ut/ut0ut.c: gettimeofday is not available under Windows. Added conditional define which uses GetLocalTime for windows libmysql/libmysql.c: fixed prototype for setup_one_fetch_function which differed from function declaration. Fixed not supported unsigned __int64 to double conversion sql/field.h: fixed typecast error (windows) sql/item_sum.cc: fixed typecast errors (windows) sql/key.cc: fixed typecast errors (windows) sql/opt_range.cc: fixed not supported unsigned __int64 to double conversion sql/sql_acl.cc: fixed typecast errors (windows) sql/table.cc: fixed typecast errors (windows) --- VC++Files/libmysqld/libmysqld.dsp | 4 ---- VC++Files/mysqldemb/mysqldemb.dsp | 4 ---- extra/comp_err.c | 8 ++++---- innobase/ut/ut0ut.c | 7 +++++++ libmysql/libmysql.c | 4 ++-- sql/field.h | 2 +- sql/item_sum.cc | 6 +++--- sql/key.cc | 4 ++-- sql/opt_range.cc | 2 +- sql/sql_acl.cc | 4 ++-- sql/table.cc | 6 +++--- 11 files changed, 25 insertions(+), 26 deletions(-) diff --git a/VC++Files/libmysqld/libmysqld.dsp b/VC++Files/libmysqld/libmysqld.dsp index 99912228445..019589289cd 100644 --- a/VC++Files/libmysqld/libmysqld.dsp +++ b/VC++Files/libmysqld/libmysqld.dsp @@ -228,10 +228,6 @@ SOURCE=..\sql\ha_innodb.cpp # End Source File # Begin Source File -SOURCE=..\sql\ha_isammrg.cpp -# End Source File -# Begin Source File - SOURCE=..\sql\ha_myisam.cpp # End Source File # Begin Source File diff --git a/VC++Files/mysqldemb/mysqldemb.dsp b/VC++Files/mysqldemb/mysqldemb.dsp index a8207d436a0..61a745ff7e8 100644 --- a/VC++Files/mysqldemb/mysqldemb.dsp +++ b/VC++Files/mysqldemb/mysqldemb.dsp @@ -169,10 +169,6 @@ SOURCE=..\sql\ha_innodb.cpp # End Source File # Begin Source File -SOURCE=..\sql\ha_isammrg.cpp -# End Source File -# Begin Source File - SOURCE=..\sql\ha_myisam.cpp # End Source File # Begin Source File diff --git a/extra/comp_err.c b/extra/comp_err.c index baed28a0350..a554fc2437e 100644 --- a/extra/comp_err.c +++ b/extra/comp_err.c @@ -41,7 +41,7 @@ static char *HEADERFILE= (char*) "mysqld_error.h"; static char *NAMEFILE= (char*) "mysqld_ername.h"; static char *STATEFILE= (char*) "sql_state.h"; static char *TXTFILE= (char*) "../sql/share/errmsg.txt"; -static char *DATADIR= (char*) "../sql/share/"; +static char *DATADIRECTORY= (char*) "../sql/share/"; static char *default_dbug_option= (char*) "d:t:O,/tmp/comp_err.trace"; /* Header for errmsg.sys files */ @@ -112,8 +112,8 @@ static struct my_option my_long_options[]= 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"in_file", 'F', "Input file", (gptr *) & TXTFILE, (gptr *) & TXTFILE, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"out_dir", 'D', "Output base directory", (gptr *) & DATADIR, - (gptr *) & DATADIR, + {"out_dir", 'D', "Output base directory", (gptr *) & DATADIRECTORY, + (gptr *) & DATADIRECTORY, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"out_file", 'O', "Output filename (errmsg.sys)", (gptr *) & OUTFILE, (gptr *) & OUTFILE, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, @@ -281,7 +281,7 @@ static int create_sys_files(struct languages *lang_head, DBUG_RETURN(1); } - outfile_end= strxmov(outfile, DATADIR, + outfile_end= strxmov(outfile, DATADIRECTORY, tmp_lang->lang_long_name, NullS); if (!my_stat(outfile, &stat_info,MYF(0))) { diff --git a/innobase/ut/ut0ut.c b/innobase/ut/ut0ut.c index f35b4dea5e0..6f2aa0957d8 100644 --- a/innobase/ut/ut0ut.c +++ b/innobase/ut/ut0ut.c @@ -82,10 +82,17 @@ ut_usectime( ulint* sec, /* out: seconds since the Epoch */ ulint* ms) /* out: microseconds since the Epoch+*sec */ { +#ifdef __WIN__ + SYSTEMTIME st; + GetLocalTime(&st); + *sec = (ulint) st.wSecond; + *ms = (ulint) st.wMilliseconds; +#else struct timeval tv; gettimeofday(&tv,NULL); *sec = (ulint) tv.tv_sec; *ms = (ulint) tv.tv_usec; +#endif } /************************************************************** diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index c6815d2a5ce..258391ac899 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -1740,7 +1740,7 @@ static int stmt_read_row_no_data(MYSQL_STMT *stmt, unsigned char **row); STMT_ATTR_UPDATE_MAX_LENGTH attribute is set. */ static void stmt_update_metadata(MYSQL_STMT *stmt, MYSQL_ROWS *data); -static bool setup_one_fetch_function(MYSQL_BIND *bind, MYSQL_FIELD *field); +static my_bool setup_one_fetch_function(MYSQL_BIND *bind, MYSQL_FIELD *field); /* Maximum sizes of MYSQL_TYPE_DATE, MYSQL_TYPE_TIME, MYSQL_TYPE_DATETIME @@ -3718,7 +3718,7 @@ static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, longlongstore(buffer, data); } *param->error= value != (param->is_unsigned ? - (double) (*(ulonglong*) buffer) : + ulonglong2double(*(ulonglong*) buffer) : (double) (*(longlong*) buffer)); break; case MYSQL_TYPE_FLOAT: diff --git a/sql/field.h b/sql/field.h index fd1ef09d14f..84d71afcd6f 100644 --- a/sql/field.h +++ b/sql/field.h @@ -1228,7 +1228,7 @@ public: int cmp(const char *a, const char *b) { return cmp_binary(a, b); } int key_cmp(const byte *a, const byte *b) - { return cmp_binary(a, b); } + { return cmp_binary((char *) a, (char *) b); } int key_cmp(const byte *str, uint length); int cmp_offset(uint row_offset); void get_key_image(char *buff, uint length, imagetype type); diff --git a/sql/item_sum.cc b/sql/item_sum.cc index be89aa3f86d..29837c3afbd 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1234,7 +1234,7 @@ int composite_key_cmp(void* arg, byte* key1, byte* key2) { Field* f = *field; int len = *lengths++; - int res = f->cmp(key1, key2); + int res = f->cmp((char *) key1, (char *) key2); if (res) return res; key1 += len; @@ -1688,7 +1688,7 @@ int group_concat_key_cmp_with_distinct(void* arg, byte* key1, { int res; uint offset= (uint) (field->ptr - record); - if ((res= field->cmp(key1 + offset, key2 + offset))) + if ((res= field->cmp((char *) key1 + offset, (char *) key2 + offset))) return res; } } @@ -1722,7 +1722,7 @@ int group_concat_key_cmp_with_order(void* arg, byte* key1, byte* key2) { int res; uint offset= (uint) (field->ptr - record); - if ((res= field->cmp(key1 + offset, key2 + offset))) + if ((res= field->cmp((char *) key1 + offset, (char *) key2 + offset))) return (*order_item)->asc ? res : -res; } } diff --git a/sql/key.cc b/sql/key.cc index aec294e370a..c5ed60b129c 100644 --- a/sql/key.cc +++ b/sql/key.cc @@ -135,7 +135,7 @@ void key_copy(byte *to_key, byte *from_record, KEY *key_info, uint key_length) { key_length-= HA_KEY_BLOB_LENGTH; length= min(key_length, key_part->length); - key_part->field->get_key_image(to_key, length, Field::itRAW); + key_part->field->get_key_image((char *) to_key, length, Field::itRAW); to_key+= HA_KEY_BLOB_LENGTH; } else @@ -217,7 +217,7 @@ void key_restore(byte *to_record, byte *from_key, KEY *key_info, { key_length-= HA_KEY_BLOB_LENGTH; length= min(key_length, key_part->length); - key_part->field->set_key_image(from_key, length); + key_part->field->set_key_image((char *) from_key, length); from_key+= HA_KEY_BLOB_LENGTH; } else diff --git a/sql/opt_range.cc b/sql/opt_range.cc index c3b84564504..e5799bfd509 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -1891,7 +1891,7 @@ double get_sweep_read_cost(const PARAM *param, ha_rows records) else { double n_blocks= - ceil((double)param->table->file->data_file_length / IO_SIZE); + ceil(ulonglong2double(param->table->file->data_file_length) / IO_SIZE); double busy_blocks= n_blocks * (1.0 - pow(1.0 - 1.0/n_blocks, rows2double(records))); if (busy_blocks < 1.0) diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index f9d95b2cde5..71d042eda02 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1494,12 +1494,12 @@ static bool update_user_table(THD *thd, const char *host, const char *user, DBUG_RETURN(1); /* purecov: deadcode */ table->field[0]->store(host,(uint) strlen(host), system_charset_info); table->field[1]->store(user,(uint) strlen(user), system_charset_info); - key_copy(user_key, table->record[0], table->key_info, + key_copy((byte *) user_key, table->record[0], table->key_info, table->key_info->key_length); table->file->extra(HA_EXTRA_RETRIEVE_ALL_COLS); if (table->file->index_read_idx(table->record[0], 0, - user_key, table->key_info->key_length, + (byte *) user_key, table->key_info->key_length, HA_READ_KEY_EXACT)) { my_message(ER_PASSWORD_NO_MATCH, ER(ER_PASSWORD_NO_MATCH), diff --git a/sql/table.cc b/sql/table.cc index 82ad32341c0..69a132329c0 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -305,7 +305,7 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat, if (!(record= (char *) alloc_root(&outparam->mem_root, rec_buff_length * records))) goto err; /* purecov: inspected */ - share->default_values= record; + share->default_values= (byte *) record; if (my_pread(file,(byte*) record, (uint) share->reclength, (ulong) (uint2korr(head+6)+ ((uint2korr(head+14) == 0xffff ? @@ -320,9 +320,9 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat, } else { - outparam->record[0]= record+ rec_buff_length; + outparam->record[0]= (byte *) record+ rec_buff_length; if (records > 2) - outparam->record[1]= record+ rec_buff_length*2; + outparam->record[1]= (byte *) record+ rec_buff_length*2; else outparam->record[1]= outparam->record[0]; // Safety } From b6e00331717eebcb6a48960db6b860c4c73c7054 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 26 Jan 2005 15:27:31 +0100 Subject: [PATCH 28/54] Test Bug: Memory leaks in the archive handler. Moved initialization code into a new init function. Added a new cleanup function. Added a call to close the meta file. mysql-test/t/archive.test: Test Bug: Memory leaks in the archive handler. Fixed a typo. sql/examples/ha_archive.h: Test Bug: Memory leaks in the archive handler. Added declarations for the new init/cleanup functions. sql/handler.cc: Test Bug: Memory leaks in the archive handler. Added calls of the new init/cleanup functions. --- mysql-test/t/archive.test | 2 +- sql/examples/ha_archive.cc | 59 ++++++++++++++++++++++++++------------ sql/examples/ha_archive.h | 4 +++ sql/handler.cc | 14 +++++++++ 4 files changed, 60 insertions(+), 19 deletions(-) diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test index f55aea6e104..ee78b53f9c8 100644 --- a/mysql-test/t/archive.test +++ b/mysql-test/t/archive.test @@ -1,6 +1,6 @@ # # Simple test for archive example -# Taken fromm the select test +# Taken from the select test # -- source include/have_archive.inc diff --git a/sql/examples/ha_archive.cc b/sql/examples/ha_archive.cc index ef609513489..e8d07a99048 100644 --- a/sql/examples/ha_archive.cc +++ b/sql/examples/ha_archive.cc @@ -116,7 +116,6 @@ /* Variables for archive share methods */ pthread_mutex_t archive_mutex; static HASH archive_open_tables; -static int archive_init= 0; /* The file extension */ #define ARZ ".ARZ" // The data file @@ -142,6 +141,46 @@ static byte* archive_get_key(ARCHIVE_SHARE *share,uint *length, return (byte*) share->table_name; } + +/* + Initialize the archive handler. + + SYNOPSIS + archive_db_init() + void + + RETURN + FALSE OK + TRUE Error +*/ + +bool archive_db_init() +{ + VOID(pthread_mutex_init(&archive_mutex, MY_MUTEX_INIT_FAST)); + return (hash_init(&archive_open_tables, system_charset_info, 32, 0, 0, + (hash_get_key) archive_get_key, 0, 0)); +} + + +/* + Release the archive handler. + + SYNOPSIS + archive_db_end() + void + + RETURN + FALSE OK +*/ + +bool archive_db_end() +{ + hash_free(&archive_open_tables); + VOID(pthread_mutex_destroy(&archive_mutex)); + return FALSE; +} + + /* This method reads the header of a datafile and returns whether or not it was successful. */ @@ -269,23 +308,6 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, TABLE *table) uint length; char *tmp_name; - if (!archive_init) - { - /* Hijack a mutex for init'ing the storage engine */ - pthread_mutex_lock(&LOCK_mysql_create_db); - if (!archive_init) - { - VOID(pthread_mutex_init(&archive_mutex,MY_MUTEX_INIT_FAST)); - if (hash_init(&archive_open_tables,system_charset_info,32,0,0, - (hash_get_key) archive_get_key,0,0)) - { - pthread_mutex_unlock(&LOCK_mysql_create_db); - return NULL; - } - archive_init++; - } - pthread_mutex_unlock(&LOCK_mysql_create_db); - } pthread_mutex_lock(&archive_mutex); length=(uint) strlen(table_name); @@ -379,6 +401,7 @@ int ha_archive::free_share(ARCHIVE_SHARE *share) (void)write_meta_file(share->meta_file, share->rows_recorded, FALSE); if (gzclose(share->archive_write) == Z_ERRNO) rc= 1; + my_close(share->meta_file,MYF(0)); my_free((gptr) share, MYF(0)); } pthread_mutex_unlock(&archive_mutex); diff --git a/sql/examples/ha_archive.h b/sql/examples/ha_archive.h index b619de5f6c1..855d756368d 100644 --- a/sql/examples/ha_archive.h +++ b/sql/examples/ha_archive.h @@ -125,3 +125,7 @@ public: THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to, enum thr_lock_type lock_type); }; + +bool archive_db_init(void); +bool archive_db_end(void); + diff --git a/sql/handler.cc b/sql/handler.cc index 3200c6932e9..70ba236a5d5 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -277,6 +277,16 @@ int ha_init() else opt_using_transactions=1; } +#endif +#ifdef HAVE_ARCHIVE_DB + if (have_archive_db == SHOW_OPTION_YES) + { + if (archive_db_init()) + { + have_archive_db= SHOW_OPTION_DISABLED; + error= 1; + } + } #endif return error; } @@ -308,6 +318,10 @@ int ha_panic(enum ha_panic_function flag) #ifdef HAVE_NDBCLUSTER_DB if (have_ndbcluster == SHOW_OPTION_YES) error|=ndbcluster_end(); +#endif +#ifdef HAVE_ARCHIVE_DB + if (have_archive_db == SHOW_OPTION_YES) + error|= archive_db_end(); #endif return error; } /* ha_panic */ From 193650b8d9f88910d763c6c593912a4e83dd9643 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 26 Jan 2005 18:37:49 +0400 Subject: [PATCH 29/54] timed_mutexes moved to include/my_sys.h and mysys/my_static.c to avoid linking problems referring to the variable from .c programs. --- include/my_sys.h | 2 ++ mysys/my_static.c | 2 ++ sql/mysql_priv.h | 1 - sql/mysqld.cc | 1 - 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/my_sys.h b/include/my_sys.h index d11dc4a3e46..72d4bec74b1 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -259,6 +259,8 @@ extern char wild_many,wild_one,wild_prefix; extern const char *charsets_dir; extern char *defaults_extra_file; +extern my_bool timed_mutexes; + typedef struct wild_file_pack /* Struct to hold info when selecting files */ { uint wilds; /* How many wildcards */ diff --git a/mysys/my_static.c b/mysys/my_static.c index 57d41676390..8207463ea50 100644 --- a/mysys/my_static.c +++ b/mysys/my_static.c @@ -25,6 +25,8 @@ #include "my_alarm.h" #endif +my_bool timed_mutexes= 0; + /* from my_init */ my_string home_dir=0,my_progname=0; char NEAR curr_dir[FN_REFLEN]= {0}, diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 5a222a1ce10..0349d9a635f 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1002,7 +1002,6 @@ extern ulong table_cache_size; extern ulong max_connections,max_connect_errors, connect_timeout; extern ulong slave_net_timeout; extern ulong max_user_connections; -extern my_bool timed_mutexes; extern ulong what_to_log,flush_time; extern ulong query_buff_size, thread_stack,thread_stack_min; extern ulong binlog_cache_size, max_binlog_cache_size, open_files_limit; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 94eb34954ba..e99acd7ed82 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -335,7 +335,6 @@ ulong binlog_cache_use= 0, binlog_cache_disk_use= 0; ulong max_connections,max_used_connections, max_connect_errors, max_user_connections = 0; ulong thread_id=1L,current_pid; -my_bool timed_mutexes= 0; ulong slow_launch_threads = 0, sync_binlog_period; ulong expire_logs_days = 0; ulong rpl_recovery_rank=0; From 1cd8eaa777f40bda00567cf7f9a0d68e2f064967 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 26 Jan 2005 16:42:52 +0100 Subject: [PATCH 30/54] Makefile.am: updated doxygen Makefile for changed examples directory .del-demos.tar~8e6dfbc510a6e323: Delete: ndb/ndbapi-examples/configurations/demos.tar Many files: mvdir ndb/ndbapi-examples/Makefile: mvdir ndb/ndbapi-examples/mgmapi_logevent_example/Makefile: mvdir ndb/ndbapi-examples/mgmapi_logevent_example/mgmapi_logevent.cpp: mvdir ndb/ndbapi-examples/ndbapi_async_example/Makefile: mvdir ndb/ndbapi-examples/ndbapi_async_example/ndbapi_async.cpp: mvdir ndb/ndbapi-examples/ndbapi_async_example/readme.txt: mvdir ndb/ndbapi-examples/ndbapi_async_example1/Makefile: mvdir ndb/ndbapi-examples/ndbapi_async_example1/ndbapi_async1.cpp: mvdir ndb/ndbapi-examples/ndbapi_event_example/Makefile: mvdir ndb/ndbapi-examples/ndbapi_event_example/ndbapi_event.cpp: mvdir ndb/ndbapi-examples/ndbapi_retries_example/Makefile: mvdir ndb/ndbapi-examples/ndbapi_retries_example/ndbapi_retries.cpp: mvdir ndb/ndbapi-examples/ndbapi_scan_example/Makefile: mvdir ndb/ndbapi-examples/ndbapi_scan_example/ndbapi_scan.cpp: mvdir ndb/ndbapi-examples/ndbapi_scan_example/readme.txt: mvdir ndb/ndbapi-examples/ndbapi_simple_example/Makefile: mvdir ndb/ndbapi-examples/ndbapi_simple_example/ndbapi_simple.cpp: mvdir ndb/ndbapi-examples/ndbapi_simple_index_example/Makefile: mvdir ndb/ndbapi-examples/ndbapi_simple_index_example/ndbapi_simple_index.cpp: mvdir BitKeeper/deleted/.del-demos.tar~8e6dfbc510a6e323: Delete: ndb/ndbapi-examples/configurations/demos.tar ndb/docs/Makefile.am: updated doxygen Makefile for changed examples directory --- ndb/docs/Makefile.am | 2 +- ndb/examples/configurations/demos.tar | Bin 40960 -> 0 bytes ndb/{examples => ndbapi-examples}/Makefile | 0 .../mgmapi_logevent_example/Makefile | 0 .../mgmapi_logevent_example/mgmapi_logevent.cpp | 0 .../ndbapi_async_example/Makefile | 0 .../ndbapi_async_example/ndbapi_async.cpp | 0 .../ndbapi_async_example/readme.txt | 0 .../ndbapi_async_example1/Makefile | 0 .../ndbapi_async_example1/ndbapi_async1.cpp | 0 .../ndbapi_event_example/Makefile | 0 .../ndbapi_event_example/ndbapi_event.cpp | 0 .../ndbapi_retries_example/Makefile | 0 .../ndbapi_retries_example/ndbapi_retries.cpp | 0 .../ndbapi_scan_example/Makefile | 0 .../ndbapi_scan_example/ndbapi_scan.cpp | 0 .../ndbapi_scan_example/readme.txt | 0 .../ndbapi_simple_example/Makefile | 0 .../ndbapi_simple_example/ndbapi_simple.cpp | 0 .../ndbapi_simple_index_example/Makefile | 0 .../ndbapi_simple_index.cpp | 0 21 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 ndb/examples/configurations/demos.tar rename ndb/{examples => ndbapi-examples}/Makefile (100%) rename ndb/{examples => ndbapi-examples}/mgmapi_logevent_example/Makefile (100%) rename ndb/{examples => ndbapi-examples}/mgmapi_logevent_example/mgmapi_logevent.cpp (100%) rename ndb/{examples => ndbapi-examples}/ndbapi_async_example/Makefile (100%) rename ndb/{examples => ndbapi-examples}/ndbapi_async_example/ndbapi_async.cpp (100%) rename ndb/{examples => ndbapi-examples}/ndbapi_async_example/readme.txt (100%) rename ndb/{examples => ndbapi-examples}/ndbapi_async_example1/Makefile (100%) rename ndb/{examples => ndbapi-examples}/ndbapi_async_example1/ndbapi_async1.cpp (100%) rename ndb/{examples => ndbapi-examples}/ndbapi_event_example/Makefile (100%) rename ndb/{examples => ndbapi-examples}/ndbapi_event_example/ndbapi_event.cpp (100%) rename ndb/{examples => ndbapi-examples}/ndbapi_retries_example/Makefile (100%) rename ndb/{examples => ndbapi-examples}/ndbapi_retries_example/ndbapi_retries.cpp (100%) rename ndb/{examples => ndbapi-examples}/ndbapi_scan_example/Makefile (100%) rename ndb/{examples => ndbapi-examples}/ndbapi_scan_example/ndbapi_scan.cpp (100%) rename ndb/{examples => ndbapi-examples}/ndbapi_scan_example/readme.txt (100%) rename ndb/{examples => ndbapi-examples}/ndbapi_simple_example/Makefile (100%) rename ndb/{examples => ndbapi-examples}/ndbapi_simple_example/ndbapi_simple.cpp (100%) rename ndb/{examples => ndbapi-examples}/ndbapi_simple_index_example/Makefile (100%) rename ndb/{examples => ndbapi-examples}/ndbapi_simple_index_example/ndbapi_simple_index.cpp (100%) diff --git a/ndb/docs/Makefile.am b/ndb/docs/Makefile.am index 6d4cdc12cf6..ca826d7e178 100644 --- a/ndb/docs/Makefile.am +++ b/ndb/docs/Makefile.am @@ -48,7 +48,7 @@ ndbapi.html: $(noinst_HEADERS) @RM@ -rf $(DOXYTMP) $(DOXYOUT); \ mkdir -p $(DOXYTMP) $(DOXYOUT); \ @CP@ $(top_srcdir)/ndb/include/ndbapi/* $(DOXYTMP); \ - @CP@ $(top_srcdir)/ndb/examples/*/*.[ch]pp $(DOXYTMP); \ + @CP@ $(top_srcdir)/ndb/ndbapi-examples/*/*.[ch]pp $(DOXYTMP); \ @PERL@ $(DOXYDIR)/predoxy.pl; \ mv footer.html $(DOXYTMP); \ (cd $(DOXYTMP) ; @DOXYGEN@ ../$(DOXYDIR)/Doxyfile.ndbapi); \ diff --git a/ndb/examples/configurations/demos.tar b/ndb/examples/configurations/demos.tar deleted file mode 100644 index d8cae90ec5bdfe756078a5d50664e6aef780e149..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 40960 zcmeHQTW{OA63(-J1-D%+&H?H~q;B2doW&-N+Zu>3Cw5U3yNf`!7)OXD8IqjKKAhja zL&+E2d`T+HPCL#+Y-u#4z9DBg6#2>Gju)I9?ertds%#kAku1whrn>kqQ&o-ri|_C` z0s&oDRHjq-PAP-aMB8btX3D2QX!?X4g`Q&uYYLnO++TNo&83HY%8KkyYp!SUT{VNq z{@NDy2fJ&k0rqE#Lec(Jw40RuY0aG2HKpu!u$}#NMh#WbWN0T;Q4EIm-<$p0*5G(} zGb*cmnaZ*r`}<=5uRxzSlJ-|MO*tZRSru5P=Lh%yod>t;dqW-sO^YZJWyY}#f0TgD zWLa8=9G?3Q5Xks{YfxilyMGwx!T4{h_|G&5{lfn<2m?6&tDt=q+5g5K^WZ56xl>M4 z*xvrs&=fKL*AxTC{}ovO=%~p4C5L~o=X2seSM^ixliudu`CnvuM3!tB=q00nzQlWX6U^m4c{IH0bF`M4Qv-uRVcvq?qhXC6!?V? zPRYZ=!?77%ay;}LxXdx_@hJ(WlZoetzb{V-?d5(X=?}P>i^hku&zJqbq_)?&x#E+t zJv4(;LZwS@c-J*YJZQQt({@{Mlm62w`6~57Z_;razVG?sXUlvPm)1RZIQ4z*hMftI zQ4?xprsgI3zUc<$P#`;(5h|Ll#UG<0;X(}(d2#T<49(dwI3!Db+u`RteBj)L8k*z! zEg#-ZJlhRH6-%A}IQ9k^frZ)+zBzKBvX|cIgUB3C$$RPC9NtYQ^BYxLvjd_A=hK@T z?)U7!ITSKK0oN8D|Ki&rk7X5h2Qb$=t?uW3~6(kCwn z+ol8B$Ks}L;U`?z`q-LZ(s<;f0B4$LW z6q!0!#iT-20)$?aK6TCT_LO|NYW5q~-Lw9u>wf3@L-VrH``YU_TG#CQQ{$=u3eURD zSff&`5t{e~5A2a^hTI~pr{4cANss&Y&~e~WBIfRiZ6)+jx+DzJ^eGB9@z zW|k9YOK~M9u1MQJ0shA2QJ2WpC7~Q3T3R?VE*#n5EWg9kh4H`S1n_zJpLqVGYC6pS z?qnQ8g9`VB}p|Jli$N&E?qqdvI|5QBl72|(+{3}P#|1?d7`Csh+WuU)a zN4eu*7+B-@AIJYV{x5m_|LTYB>zxpu-5UaN{AUNS{%f}WgU0K>7(D;M^?$o>7AgC) zX#JPEpZWi}{i&G$$Ms*kH+@t>q5b!n|5IUqT>n*(`Hxchzl!;PRk$BYIR*V++pqs; zvH!>QKb16*Li_L4{|ozr|Ht{CO6;HV{~G%LNIDL{eTK7=>Nuk{Xee%tg?9&+JCS9U)Uekf584(>-2XS9|Bv>6GoXRM=RXxRl_LA^b^jl1{Db{}s*L$x1=gSM z|C>GkWwogPmmL1Vp3m6-M@9cv6$9gcCH7Cnf87693Fe1XNZ$XKPXDsy{{MOW7wbP1 zMuGnW*MIE3r4-qJpYdM@!$l-uM4gApQ{h|0%BjsHCM7+JCwKr<6Ku$p2J@E%*P&_SY1k3&8o`QqW(ow&4?L3wAt7E!gODLvNDv$3#noJ865?u>20_-=iEBA=eVw?T6F1h08#(d!IdNr4 z5RtF@uj|Bfb*Fi@iiGxD-GLw?Yt@8!uI?0C!4}QwrEC@7%7u}rdI1*(w3*WCo}>Ms z(8Rt;d$R6%?fMVM;G0;tlTrH`5)x}C>PvU zpsld~FZ2KM_&-+jzr(v8V9tNe{{h4wF#nJI9~HG7%>T4atimXTLKNVH%|HJ41<=Y~w@$FA11KT|bZl$Rk z@KBI4U)MYBcB9_!^{<-kkBQ@-I<1Dp9|fCoBzMthb^iNv>nqUF)-OK;rR^0E+;&e~ zYj6@ZD`{wvpM^ppC}w;bmL10Y&ogG|2@vE;l5OfxyWtNt0=CYh^S^kH9qSkXoO-xrj)vQ~cLJPfP?&E}?HoZNxo?hyD|JFF#UQ z+%ljN2L8QIYQuRQfSjHDB2B!BwXBK-^vVM>;4vd`t{wt`_0<3p>!=p2uohrgQp=Yb z-!w*0v|7uE7qigkz4W)ntVK17Vpd#>`Ku#d6tjvW zWwKPI_};UnLWC*`*egQihGIo%RM(fg2#snUbPSEpbbcs~2p|H803v`0AOeU0B7g`W z0*C-2fCwN0hyWsh2p|H803v`0AOeU0B7g`W0*C-2fCwN0hyWsh2p|H8z$-@JAEoZv AlmGw# diff --git a/ndb/examples/Makefile b/ndb/ndbapi-examples/Makefile similarity index 100% rename from ndb/examples/Makefile rename to ndb/ndbapi-examples/Makefile diff --git a/ndb/examples/mgmapi_logevent_example/Makefile b/ndb/ndbapi-examples/mgmapi_logevent_example/Makefile similarity index 100% rename from ndb/examples/mgmapi_logevent_example/Makefile rename to ndb/ndbapi-examples/mgmapi_logevent_example/Makefile diff --git a/ndb/examples/mgmapi_logevent_example/mgmapi_logevent.cpp b/ndb/ndbapi-examples/mgmapi_logevent_example/mgmapi_logevent.cpp similarity index 100% rename from ndb/examples/mgmapi_logevent_example/mgmapi_logevent.cpp rename to ndb/ndbapi-examples/mgmapi_logevent_example/mgmapi_logevent.cpp diff --git a/ndb/examples/ndbapi_async_example/Makefile b/ndb/ndbapi-examples/ndbapi_async_example/Makefile similarity index 100% rename from ndb/examples/ndbapi_async_example/Makefile rename to ndb/ndbapi-examples/ndbapi_async_example/Makefile diff --git a/ndb/examples/ndbapi_async_example/ndbapi_async.cpp b/ndb/ndbapi-examples/ndbapi_async_example/ndbapi_async.cpp similarity index 100% rename from ndb/examples/ndbapi_async_example/ndbapi_async.cpp rename to ndb/ndbapi-examples/ndbapi_async_example/ndbapi_async.cpp diff --git a/ndb/examples/ndbapi_async_example/readme.txt b/ndb/ndbapi-examples/ndbapi_async_example/readme.txt similarity index 100% rename from ndb/examples/ndbapi_async_example/readme.txt rename to ndb/ndbapi-examples/ndbapi_async_example/readme.txt diff --git a/ndb/examples/ndbapi_async_example1/Makefile b/ndb/ndbapi-examples/ndbapi_async_example1/Makefile similarity index 100% rename from ndb/examples/ndbapi_async_example1/Makefile rename to ndb/ndbapi-examples/ndbapi_async_example1/Makefile diff --git a/ndb/examples/ndbapi_async_example1/ndbapi_async1.cpp b/ndb/ndbapi-examples/ndbapi_async_example1/ndbapi_async1.cpp similarity index 100% rename from ndb/examples/ndbapi_async_example1/ndbapi_async1.cpp rename to ndb/ndbapi-examples/ndbapi_async_example1/ndbapi_async1.cpp diff --git a/ndb/examples/ndbapi_event_example/Makefile b/ndb/ndbapi-examples/ndbapi_event_example/Makefile similarity index 100% rename from ndb/examples/ndbapi_event_example/Makefile rename to ndb/ndbapi-examples/ndbapi_event_example/Makefile diff --git a/ndb/examples/ndbapi_event_example/ndbapi_event.cpp b/ndb/ndbapi-examples/ndbapi_event_example/ndbapi_event.cpp similarity index 100% rename from ndb/examples/ndbapi_event_example/ndbapi_event.cpp rename to ndb/ndbapi-examples/ndbapi_event_example/ndbapi_event.cpp diff --git a/ndb/examples/ndbapi_retries_example/Makefile b/ndb/ndbapi-examples/ndbapi_retries_example/Makefile similarity index 100% rename from ndb/examples/ndbapi_retries_example/Makefile rename to ndb/ndbapi-examples/ndbapi_retries_example/Makefile diff --git a/ndb/examples/ndbapi_retries_example/ndbapi_retries.cpp b/ndb/ndbapi-examples/ndbapi_retries_example/ndbapi_retries.cpp similarity index 100% rename from ndb/examples/ndbapi_retries_example/ndbapi_retries.cpp rename to ndb/ndbapi-examples/ndbapi_retries_example/ndbapi_retries.cpp diff --git a/ndb/examples/ndbapi_scan_example/Makefile b/ndb/ndbapi-examples/ndbapi_scan_example/Makefile similarity index 100% rename from ndb/examples/ndbapi_scan_example/Makefile rename to ndb/ndbapi-examples/ndbapi_scan_example/Makefile diff --git a/ndb/examples/ndbapi_scan_example/ndbapi_scan.cpp b/ndb/ndbapi-examples/ndbapi_scan_example/ndbapi_scan.cpp similarity index 100% rename from ndb/examples/ndbapi_scan_example/ndbapi_scan.cpp rename to ndb/ndbapi-examples/ndbapi_scan_example/ndbapi_scan.cpp diff --git a/ndb/examples/ndbapi_scan_example/readme.txt b/ndb/ndbapi-examples/ndbapi_scan_example/readme.txt similarity index 100% rename from ndb/examples/ndbapi_scan_example/readme.txt rename to ndb/ndbapi-examples/ndbapi_scan_example/readme.txt diff --git a/ndb/examples/ndbapi_simple_example/Makefile b/ndb/ndbapi-examples/ndbapi_simple_example/Makefile similarity index 100% rename from ndb/examples/ndbapi_simple_example/Makefile rename to ndb/ndbapi-examples/ndbapi_simple_example/Makefile diff --git a/ndb/examples/ndbapi_simple_example/ndbapi_simple.cpp b/ndb/ndbapi-examples/ndbapi_simple_example/ndbapi_simple.cpp similarity index 100% rename from ndb/examples/ndbapi_simple_example/ndbapi_simple.cpp rename to ndb/ndbapi-examples/ndbapi_simple_example/ndbapi_simple.cpp diff --git a/ndb/examples/ndbapi_simple_index_example/Makefile b/ndb/ndbapi-examples/ndbapi_simple_index_example/Makefile similarity index 100% rename from ndb/examples/ndbapi_simple_index_example/Makefile rename to ndb/ndbapi-examples/ndbapi_simple_index_example/Makefile diff --git a/ndb/examples/ndbapi_simple_index_example/ndbapi_simple_index.cpp b/ndb/ndbapi-examples/ndbapi_simple_index_example/ndbapi_simple_index.cpp similarity index 100% rename from ndb/examples/ndbapi_simple_index_example/ndbapi_simple_index.cpp rename to ndb/ndbapi-examples/ndbapi_simple_index_example/ndbapi_simple_index.cpp From 13ec3ef6c76639f88abc25c7bad3c5dce1fbc340 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 26 Jan 2005 11:47:28 -0800 Subject: [PATCH 31/54] changes to get rid of compile warnings in both ha_federated.cc and ha_federated.h sql/ha_federated.cc: changes to get rid of compile warnings sql/ha_federated.h: changes to get rid of compile warnings --- sql/ha_federated.cc | 27 ++++++++++++++------------- sql/ha_federated.h | 2 +- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/sql/ha_federated.cc b/sql/ha_federated.cc index 1f7c089d60a..5185e0bbe9a 100644 --- a/sql/ha_federated.cc +++ b/sql/ha_federated.cc @@ -415,7 +415,7 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table, uint table_create_fla share->scheme= my_strdup(table->s->comment, MYF(0)); - if (share->username= strstr(share->scheme, "://")) + if ((share->username= strstr(share->scheme, "://"))) { share->scheme[share->username - share->scheme] = '\0'; if (strcmp(share->scheme, "mysql") != 0) @@ -429,18 +429,18 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table, uint table_create_fla } share->username+= 3; - if (share->hostname= strchr(share->username, '@')) + if ((share->hostname= strchr(share->username, '@'))) { share->username[share->hostname - share->username]= '\0'; share->hostname++; - if (share->password= strchr(share->username, ':')) + if ((share->password= strchr(share->username, ':'))) { share->username[share->password - share->username]= '\0'; share->password++; share->username= share->username; // make sure there isn't an extra / or @ - if (strchr(share->password, '/') || strchr(share->hostname, '@')) + if ((strchr(share->password, '/') || strchr(share->hostname, '@'))) { DBUG_PRINT("ha_federated::parse_url", ("this connection string is not in the correct format!!!\n")); @@ -453,14 +453,14 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table, uint table_create_fla user:@hostname:port/database/table Then password is a null string, so set to NULL */ - if (share->password[0] == '\0') + if ((share->password[0] == '\0')) share->password= NULL; } else share->username= share->username; // make sure there isn't an extra / or @ - if (strchr(share->username, '/') || strchr(share->hostname, '@')) + if ((strchr(share->username, '/')) || (strchr(share->hostname, '@'))) { DBUG_PRINT("ha_federated::parse_url", ("this connection string is not in the correct format!!!\n")); @@ -469,12 +469,12 @@ Then password is a null string, so set to NULL DBUG_RETURN(-1); } - if (share->database= strchr(share->hostname, '/')) + if ((share->database= strchr(share->hostname, '/'))) { share->hostname[share->database - share->hostname]= '\0'; share->database++; - if (share->sport= strchr(share->hostname, ':')) + if ((share->sport= strchr(share->hostname, ':'))) { share->hostname[share->sport - share->hostname]= '\0'; share->sport++; @@ -484,7 +484,7 @@ Then password is a null string, so set to NULL share->port= atoi(share->sport); } - if (share->table_base_name= strchr(share->database, '/')) + if ((share->table_base_name= strchr(share->database, '/'))) { share->database[share->table_base_name - share->database]= '\0'; share->table_base_name++; @@ -507,7 +507,7 @@ Then password is a null string, so set to NULL DBUG_RETURN(-1); } // make sure there's not an extra / - if (strchr(share->table_base_name, '/')) + if ((strchr(share->table_base_name, '/'))) { DBUG_PRINT("ha_federated::parse_url", ("this connection string is not in the correct format!!!\n")); @@ -696,6 +696,7 @@ bool ha_federated::create_where_from_key( key_length-= length; DBUG_RETURN(0); } + DBUG_RETURN(1); } int load_conn_info(FEDERATED_SHARE *share, TABLE *table) @@ -965,7 +966,7 @@ int ha_federated::write_row(byte * buf) int x= 0, num_fields= 0; Field **field; ulong current_query_id= 1; - ulong tmp_query_id; + ulong tmp_query_id= 1; int all_fields_have_same_query_id= 1; char insert_buffer[IO_SIZE]; @@ -1129,8 +1130,8 @@ int ha_federated::update_row( byte * new_data ) { - uint x= 0; - uint has_a_primary_key; + int x= 0; + uint has_a_primary_key= 0; int primary_key_field_num; char old_field_value_buffer[IO_SIZE], new_field_value_buffer[IO_SIZE]; char update_buffer[IO_SIZE], where_buffer[IO_SIZE]; diff --git a/sql/ha_federated.h b/sql/ha_federated.h index b44ad937650..56f5e6de4b7 100755 --- a/sql/ha_federated.h +++ b/sql/ha_federated.h @@ -130,7 +130,7 @@ public: /* The next method will never be called if you do not implement indexes. */ - virtual double read_time(ha_rows rows) { return (double) rows / 20.0+1; } + virtual double read_time(uint index, uint ranges, ha_rows rows) { return (double) rows / 20.0+1; } /* Everything below are methods that we implment in ha_federated.cc. From f50a65b0f18f47bcc105168d686a3b0c507ea3e0 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 26 Jan 2005 22:31:42 +0100 Subject: [PATCH 32/54] Test bug: Memory leak in archive handler. Added a call to close the meta file after a repair. --- sql/examples/ha_archive.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/examples/ha_archive.cc b/sql/examples/ha_archive.cc index f0d0f617a5d..436c72702a0 100644 --- a/sql/examples/ha_archive.cc +++ b/sql/examples/ha_archive.cc @@ -810,6 +810,7 @@ int ha_archive::repair(THD* thd, HA_CHECK_OPT* check_opt) goto error; } (void)write_meta_file(meta_file, rows_recorded, TRUE); + my_close(meta_file,MYF(0)); rc= 0; } From d22c0005166e48e5e84d903900dfedda1ab41405 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 27 Jan 2005 09:05:55 +0100 Subject: [PATCH 33/54] - added "../extra" to the include path of mysqltest.dsp (Windows compile failed to find the newly introduced extra/mysqld_ername.h header file) VC++Files/client/mysqltest.dsp: - added "../extra" to the include path (Windows compile failed to find the newly introduced extra/mysqld_ername.h header file) --- VC++Files/client/mysqltest.dsp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/VC++Files/client/mysqltest.dsp b/VC++Files/client/mysqltest.dsp index d04dc5bfce8..1ebd7a59b0c 100644 --- a/VC++Files/client/mysqltest.dsp +++ b/VC++Files/client/mysqltest.dsp @@ -42,8 +42,8 @@ RSC=rc.exe # PROP Output_Dir ".\debug" # PROP Intermediate_Dir ".\debug" # PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /I "../include" /I "../regex" /I "../" /Z7 /W3 /Od /G6 /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_CONSOLE" /D "_WINDOWS" /D "_MBCS" /Fp".\debug/mysqltest.pch" /Fo".\debug/" /Fd".\debug/" /GZ /c /GX -# ADD CPP /nologo /MTd /I "../include" /I "../regex" /I "../" /Z7 /W3 /Od /G6 /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_CONSOLE" /D "_WINDOWS" /D "_MBCS" /Fp".\debug/mysqltest.pch" /Fo".\debug/" /Fd".\debug/" /GZ /c /GX +# ADD BASE CPP /nologo /MTd /I "../extra" /I "../include" /I "../regex" /I "../" /Z7 /W3 /Od /G6 /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_CONSOLE" /D "_WINDOWS" /D "_MBCS" /Fp".\debug/mysqltest.pch" /Fo".\debug/" /Fd".\debug/" /GZ /c /GX +# ADD CPP /nologo /MTd /I "../extra" /I "../include" /I "../regex" /I "../" /Z7 /W3 /Od /G6 /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_CONSOLE" /D "_WINDOWS" /D "_MBCS" /Fp".\debug/mysqltest.pch" /Fo".\debug/" /Fd".\debug/" /GZ /c /GX # ADD BASE MTL /nologo /tlb".\debug\mysqltest.tlb" /win32 # ADD MTL /nologo /tlb".\debug\mysqltest.tlb" /win32 # ADD BASE RSC /l 1033 /d "_DEBUG" @@ -67,8 +67,8 @@ LINK32=link.exe # PROP Output_Dir ".\classic" # PROP Intermediate_Dir ".\classic" # PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /I "../include" /I "../regex" /I "../" /W3 /Ob1 /G6 /D "_CONSOLE" /D "_WINDOWS" /D "LICENSE=Commercial" /D "DBUG_OFF" /D "NDEBUG" /D "_MBCS" /GF /Gy /Fp".\classic/mysqltest.pch" /Fo".\classic/" /Fd".\classic/" /c /GX -# ADD CPP /nologo /MT /I "../include" /I "../regex" /I "../" /W3 /Ob1 /G6 /D "_CONSOLE" /D "_WINDOWS" /D "LICENSE=Commercial" /D "DBUG_OFF" /D "NDEBUG" /D "_MBCS" /GF /Gy /Fp".\classic/mysqltest.pch" /Fo".\classic/" /Fd".\classic/" /c /GX +# ADD BASE CPP /nologo /MT /I "../extra" /I "../include" /I "../regex" /I "../" /W3 /Ob1 /G6 /D "_CONSOLE" /D "_WINDOWS" /D "LICENSE=Commercial" /D "DBUG_OFF" /D "NDEBUG" /D "_MBCS" /GF /Gy /Fp".\classic/mysqltest.pch" /Fo".\classic/" /Fd".\classic/" /c /GX +# ADD CPP /nologo /MT /I "../extra" /I "../include" /I "../regex" /I "../" /W3 /Ob1 /G6 /D "_CONSOLE" /D "_WINDOWS" /D "LICENSE=Commercial" /D "DBUG_OFF" /D "NDEBUG" /D "_MBCS" /GF /Gy /Fp".\classic/mysqltest.pch" /Fo".\classic/" /Fd".\classic/" /c /GX # ADD BASE MTL /nologo /tlb".\classic\mysqltest.tlb" /win32 # ADD MTL /nologo /tlb".\classic\mysqltest.tlb" /win32 # ADD BASE RSC /l 1033 /d "NDEBUG" @@ -92,8 +92,8 @@ LINK32=link.exe # PROP Output_Dir ".\release" # PROP Intermediate_Dir ".\release" # PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /I "../include" /I "../regex" /I "../" /W3 /Ob1 /G6 /D "DBUG_OFF" /D "_CONSOLE" /D "_WINDOWS" /D "NDEBUG" /D "_MBCS" /GF /Gy /Fp".\release/mysqltest.pch" /Fo".\release/" /Fd".\release/" /c /GX -# ADD CPP /nologo /MT /I "../include" /I "../regex" /I "../" /W3 /Ob1 /G6 /D "DBUG_OFF" /D "_CONSOLE" /D "_WINDOWS" /D "NDEBUG" /D "_MBCS" /GF /Gy /Fp".\release/mysqltest.pch" /Fo".\release/" /Fd".\release/" /c /GX +# ADD BASE CPP /nologo /MT /I "../extra" /I "../include" /I "../regex" /I "../" /W3 /Ob1 /G6 /D "DBUG_OFF" /D "_CONSOLE" /D "_WINDOWS" /D "NDEBUG" /D "_MBCS" /GF /Gy /Fp".\release/mysqltest.pch" /Fo".\release/" /Fd".\release/" /c /GX +# ADD CPP /nologo /MT /I "../extra" /I "../include" /I "../regex" /I "../" /W3 /Ob1 /G6 /D "DBUG_OFF" /D "_CONSOLE" /D "_WINDOWS" /D "NDEBUG" /D "_MBCS" /GF /Gy /Fp".\release/mysqltest.pch" /Fo".\release/" /Fd".\release/" /c /GX # ADD BASE MTL /nologo /tlb".\release\mysqltest.tlb" /win32 # ADD MTL /nologo /tlb".\release\mysqltest.tlb" /win32 # ADD BASE RSC /l 1033 /d "NDEBUG" From 8d35dbaf1c7fa5f5fb0f45f0dbef2aa22a7d1730 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 27 Jan 2005 10:44:47 +0100 Subject: [PATCH 34/54] moved sorting and duplicate check for unique indexes from api to kernel ndb/Makefile.am: added ndbapi-examples directory to src distibution --- ndb/Makefile.am | 3 +- ndb/include/kernel/signaldata/CreateIndx.hpp | 2 +- ndb/src/kernel/blocks/dbdict/Dbdict.cpp | 58 +++++++++++++------- ndb/src/ndbapi/NdbDictionaryImpl.cpp | 20 ------- 4 files changed, 40 insertions(+), 43 deletions(-) diff --git a/ndb/Makefile.am b/ndb/Makefile.am index 32c821383e6..3aac54b38ee 100644 --- a/ndb/Makefile.am +++ b/ndb/Makefile.am @@ -1,12 +1,13 @@ SUBDIRS = src tools . include @ndb_opt_subdirs@ DIST_SUBDIRS = src tools include test docs -EXTRA_DIST = config +EXTRA_DIST = config ndbapi-examples include $(top_srcdir)/ndb/config/common.mk.am dist-hook: -rm -rf `find $(distdir) -type d -name SCCS` -rm -rf `find $(distdir) -type d -name old_files` + -rm -rf `find $(distdir)/ndbapi-examples -name '*.o'` list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" != "." -a "$$subdir" != "include"; then \ files="`find $$subdir -name '*\.h'` `find $$subdir -name '*\.hpp'`"; \ diff --git a/ndb/include/kernel/signaldata/CreateIndx.hpp b/ndb/include/kernel/signaldata/CreateIndx.hpp index 3e277b38dea..7d6c0f756dc 100644 --- a/ndb/include/kernel/signaldata/CreateIndx.hpp +++ b/ndb/include/kernel/signaldata/CreateIndx.hpp @@ -207,7 +207,7 @@ public: NotUnique = 4251, AllocationError = 4252, CreateIndexTableFailed = 4253, - InvalidAttributeOrder = 4255 + DuplicateAttributes = 4258 }; private: diff --git a/ndb/src/kernel/blocks/dbdict/Dbdict.cpp b/ndb/src/kernel/blocks/dbdict/Dbdict.cpp index 30b3e88bd82..6301c95d1e4 100644 --- a/ndb/src/kernel/blocks/dbdict/Dbdict.cpp +++ b/ndb/src/kernel/blocks/dbdict/Dbdict.cpp @@ -6301,6 +6301,7 @@ Dbdict::createIndex_slavePrepare(Signal* signal, OpCreateIndexPtr opPtr) void Dbdict::createIndex_toCreateTable(Signal* signal, OpCreateIndexPtr opPtr) { + Uint32 attrid_map[MAX_ATTRIBUTES_IN_INDEX]; Uint32 k; jam(); const CreateIndxReq* const req = &opPtr.p->m_request; @@ -6369,39 +6370,49 @@ Dbdict::createIndex_toCreateTable(Signal* signal, OpCreateIndexPtr opPtr) // tree node size in words (make configurable later) indexPtr.p->tupKeyLength = MAX_TTREE_NODE_SIZE; } - // hash index attributes must currently be in table order - Uint32 prevAttrId = RNIL; + + AttributeMask mask; + mask.clear(); for (k = 0; k < opPtr.p->m_attrList.sz; k++) { jam(); - bool found = false; - for (Uint32 tAttr = tablePtr.p->firstAttribute; tAttr != RNIL; ) { - AttributeRecord* aRec = c_attributeRecordPool.getPtr(tAttr); - tAttr = aRec->nextAttrInTable; - if (aRec->attributeId != opPtr.p->m_attrList.id[k]) + unsigned current_id= opPtr.p->m_attrList.id[k]; + AttributeRecord* aRec= NULL; + Uint32 tAttr= tablePtr.p->firstAttribute; + for (; tAttr != RNIL; tAttr= aRec->nextAttrInTable) + { + aRec = c_attributeRecordPool.getPtr(tAttr); + if (aRec->attributeId != current_id) continue; jam(); - found = true; - const Uint32 a = aRec->attributeDescriptor; - if (indexPtr.p->isHashIndex()) { - const Uint32 s1 = AttributeDescriptor::getSize(a); - const Uint32 s2 = AttributeDescriptor::getArraySize(a); - indexPtr.p->tupKeyLength += ((1 << s1) * s2 + 31) >> 5; - } + break; } - if (! found) { + if (tAttr == RNIL) { jam(); opPtr.p->m_errorCode = CreateIndxRef::BadRequestType; opPtr.p->m_errorLine = __LINE__; return; } - if (indexPtr.p->isHashIndex() && - k > 0 && prevAttrId >= opPtr.p->m_attrList.id[k]) { + if (mask.get(current_id)) + { jam(); - opPtr.p->m_errorCode = CreateIndxRef::InvalidAttributeOrder; + opPtr.p->m_errorCode = CreateIndxRef::DuplicateAttributes; opPtr.p->m_errorLine = __LINE__; return; } - prevAttrId = opPtr.p->m_attrList.id[k]; + mask.set(current_id); + + const Uint32 a = aRec->attributeDescriptor; + unsigned kk= k; + if (indexPtr.p->isHashIndex()) { + const Uint32 s1 = AttributeDescriptor::getSize(a); + const Uint32 s2 = AttributeDescriptor::getArraySize(a); + indexPtr.p->tupKeyLength += ((1 << s1) * s2 + 31) >> 5; + // reorder the attributes according to the tableid order + // for unque indexes + for (; kk > 0 && current_id < attrid_map[kk-1]>>16; kk--) + attrid_map[kk]= attrid_map[kk-1]; + } + attrid_map[kk]= k | (current_id << 16); } indexPtr.p->noOfPrimkey = indexPtr.p->noOfAttributes; // plus concatenated primary table key attribute @@ -6421,12 +6432,17 @@ Dbdict::createIndex_toCreateTable(Signal* signal, OpCreateIndexPtr opPtr) // write index key attributes AttributeRecordPtr aRecPtr; c_attributeRecordPool.getPtr(aRecPtr, tablePtr.p->firstAttribute); - for (k = 0; k < opPtr.p->m_attrList.sz; k++) { + for (unsigned k = 0; k < opPtr.p->m_attrList.sz; k++) { + // insert the attributes in the order decided above in attrid_map + // k is new order, current_id is in previous order + // ToDo: make sure "current_id" is stored with the table and + // passed up to NdbDictionary + unsigned current_id= opPtr.p->m_attrList.id[attrid_map[k] & 0xffff]; jam(); for (Uint32 tAttr = tablePtr.p->firstAttribute; tAttr != RNIL; ) { AttributeRecord* aRec = c_attributeRecordPool.getPtr(tAttr); tAttr = aRec->nextAttrInTable; - if (aRec->attributeId != opPtr.p->m_attrList.id[k]) + if (aRec->attributeId != current_id) continue; jam(); const Uint32 a = aRec->attributeDescriptor; diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/ndb/src/ndbapi/NdbDictionaryImpl.cpp index 498c5716c73..b86a7ada380 100644 --- a/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -2148,26 +2148,6 @@ NdbDictInterface::createIndex(Ndb & ndb, } attributeList.id[i] = col->m_attrId; } - if (it == DictTabInfo::UniqueHashIndex) { - // Sort index attributes according to primary table (using insertion sort) - for(i = 1; i < attributeList.sz; i++) { - unsigned int temp = attributeList.id[i]; - unsigned int j = i; - while((j > 0) && (attributeList.id[j - 1] > temp)) { - attributeList.id[j] = attributeList.id[j - 1]; - j--; - } - attributeList.id[j] = temp; - } - // Check for illegal duplicate attributes - for(i = 0; i Date: Thu, 27 Jan 2005 11:10:20 +0100 Subject: [PATCH 35/54] ndb - Make sure to install 16-node tests ndb/test/run-test/Makefile.am: Make sure to instal 16 -node tests --- ndb/test/run-test/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ndb/test/run-test/Makefile.am b/ndb/test/run-test/Makefile.am index 83dcb3dbbcf..a0033d7e838 100644 --- a/ndb/test/run-test/Makefile.am +++ b/ndb/test/run-test/Makefile.am @@ -6,7 +6,7 @@ include $(top_srcdir)/ndb/config/type_util.mk.am include $(top_srcdir)/ndb/config/type_mgmapiclient.mk.am test_PROGRAMS = atrt -test_DATA=daily-basic-tests.txt daily-devel-tests.txt +test_DATA=daily-basic-tests.txt daily-devel-tests.txt 16node-tests.txt test_SCRIPTS=atrt-analyze-result.sh atrt-gather-result.sh atrt-setup.sh \ atrt-clear-result.sh make-config.sh make-index.sh make-html-reports.sh From 79414bb3d0f17047c38e4dac4344364a5f9c938a Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 27 Jan 2005 13:16:51 +0300 Subject: [PATCH 36/54] A fix: information_schema test fails on Mac OSX --- mysql-test/r/information_schema.result | 7 +++++-- mysql-test/t/information_schema.test | 2 +- sql/sql_parse.cc | 1 + sql/sql_show.cc | 17 +++++++++++++---- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index 9bf4ee28b3b..eed3132c195 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -571,8 +571,11 @@ where table_schema='information_schema' limit 2; TABLE_NAME TABLE_TYPE ENGINE SCHEMATA TEMPORARY MyISAM TABLES TEMPORARY MyISAM -show tables from information_schema like "t%"; -Tables_in_information_schema (t%) +show tables from information_schema like "T%"; +Tables_in_information_schema (T%) +TABLES +TABLE_PRIVILEGES +TABLE_CONSTRAINTS create database information_schema; ERROR HY000: Can't create database 'information_schema'; database exists use information_schema; diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index a4886fd8245..177867f5205 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -281,7 +281,7 @@ drop view vo; select TABLE_NAME,TABLE_TYPE,ENGINE from information_schema.tables where table_schema='information_schema' limit 2; -show tables from information_schema like "t%"; +show tables from information_schema like "T%"; --error 1007 create database information_schema; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index c0bcaf771a5..7205baae59e 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -5339,6 +5339,7 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, ptr->table_name, information_schema_name.str); DBUG_RETURN(0); } + ptr->schema_table_name= ptr->table_name; ptr->schema_table= schema_table; } ptr->select_lex= lex->current_select; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index b909e9cec1b..defa99f3a36 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1802,7 +1802,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) res= open_and_lock_tables(thd, show_table_list); if (schema_table->process_table(thd, show_table_list, table, res, show_table_list->db, - show_table_list->table_name)) + show_table_list->alias)) { DBUG_RETURN(1); } @@ -1911,7 +1911,8 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) show_table_list->lock_type= lock_type; res= open_and_lock_tables(thd, show_table_list); if (schema_table->process_table(thd, show_table_list, table, - res, base_name, file_name)) + res, base_name, + show_table_list->alias)) { DBUG_RETURN(1); } @@ -3183,8 +3184,16 @@ int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list) } table->s->tmp_table= TMP_TABLE; table->grant.privilege= SELECT_ACL; - table->alias_name_used= 0; - table_list->schema_table_name= table_list->table_name; + /* + This test is necessary to make + case insensitive file systems + + upper case table names(information schema tables) + + views + working correctly + */ + table->alias_name_used= my_strcasecmp(table_alias_charset, + table_list->schema_table_name, + table_list->alias); table_list->table_name= (char*) table->s->table_name; table_list->table= table; table->next= thd->derived_tables; From 199a139da1cbbb8846c21e634fb9e4242372b67c Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 27 Jan 2005 14:51:16 +0400 Subject: [PATCH 37/54] item_timefunc.cc: CAST now always return a well-formed character string. sql/item_timefunc.cc: CAST now always return a well-formed character string. --- sql/item_timefunc.cc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 39c88c8b0a3..bc80131e4ad 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -2115,7 +2115,6 @@ String *Item_char_typecast::val_str(String *str) String *res; uint32 length; -#if 0 if (!charset_conversion) { if (!(res= args[0]->val_str(str))) @@ -2125,7 +2124,6 @@ String *Item_char_typecast::val_str(String *str) } } else -#endif { // Convert character set if differ uint dummy_errors; @@ -2163,9 +2161,18 @@ String *Item_char_typecast::val_str(String *str) void Item_char_typecast::fix_length_and_dec() { uint32 char_length; - charset_conversion= !my_charset_same(args[0]->collation.collation, cast_cs) && - args[0]->collation.collation != &my_charset_bin && - cast_cs != &my_charset_bin; + /* + We always force character set conversion if cast_cs + is a multi-byte character set. It garantees that the + result of CAST is a well-formed string. + For single-byte character sets we allow just to copy + from the argument. A single-byte character sets string + is always well-formed. + */ + charset_conversion= (cast_cs->mbmaxlen > 1) || + !my_charset_same(args[0]->collation.collation, cast_cs) && + args[0]->collation.collation != &my_charset_bin && + cast_cs != &my_charset_bin; collation.set(cast_cs, DERIVATION_IMPLICIT); char_length= (cast_length >= 0) ? cast_length : args[0]->max_length/args[0]->collation.collation->mbmaxlen; From a271a6c878ffe8245bd631888bfeee3cb5055005 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 27 Jan 2005 12:13:35 +0100 Subject: [PATCH 38/54] Re-enabled the use of --prefix. Adjusted the "Usage:" string. Ordered the option recognition in reverse order from "Usage:". --- BUILD/SETUP.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/BUILD/SETUP.sh b/BUILD/SETUP.sh index 77fab948121..e048ad723ab 100755 --- a/BUILD/SETUP.sh +++ b/BUILD/SETUP.sh @@ -6,12 +6,15 @@ then exit 1 fi +prefix_configs="--prefix=/usr/local/mysql" just_print= just_configure= full_debug= while test $# -gt 0 do case "$1" in + --prefix=* ) prefix_configs="$1"; shift ;; + --with-debug=full ) full_debug="=full"; shift ;; -c | --just-configure ) just_configure=1; shift ;; -n | --just-print | --print ) just_print=1; shift ;; -h | --help ) cat < Date: Thu, 27 Jan 2005 17:33:35 +0100 Subject: [PATCH 39/54] ndb - make YEAR and TIMESTAMP into ndb types mysql-test/r/ndb_index_ordered.result: make YEAR and TIMESTAMP into ndb types mysql-test/t/ndb_index_ordered.test: make YEAR and TIMESTAMP into ndb types ndb/include/kernel/signaldata/DictTabInfo.hpp: make YEAR and TIMESTAMP into ndb types ndb/include/ndbapi/NdbDictionary.hpp: make YEAR and TIMESTAMP into ndb types ndb/include/util/NdbSqlUtil.hpp: make YEAR and TIMESTAMP into ndb types ndb/src/common/util/NdbSqlUtil.cpp: make YEAR and TIMESTAMP into ndb types ndb/src/ndbapi/NdbDictionary.cpp: make YEAR and TIMESTAMP into ndb types ndb/src/ndbapi/NdbDictionaryImpl.cpp: make YEAR and TIMESTAMP into ndb types ndb/src/ndbapi/NdbRecAttr.cpp: make YEAR and TIMESTAMP into ndb types ndb/test/include/NdbSchemaOp.hpp: make YEAR and TIMESTAMP into ndb types sql/ha_ndbcluster.cc: make YEAR and TIMESTAMP into ndb types --- mysql-test/r/ndb_index_ordered.result | 44 +++++++--- mysql-test/t/ndb_index_ordered.test | 30 ++++--- ndb/include/kernel/signaldata/DictTabInfo.hpp | 14 ++- ndb/include/ndbapi/NdbDictionary.hpp | 4 +- ndb/include/util/NdbSqlUtil.hpp | 6 +- ndb/src/common/util/NdbSqlUtil.cpp | 36 ++++++++ ndb/src/ndbapi/NdbDictionary.cpp | 6 ++ ndb/src/ndbapi/NdbDictionaryImpl.cpp | 4 + ndb/src/ndbapi/NdbRecAttr.cpp | 85 +++++++++++++++++-- ndb/test/include/NdbSchemaOp.hpp | 4 - sql/ha_ndbcluster.cc | 19 +++-- 11 files changed, 209 insertions(+), 43 deletions(-) diff --git a/mysql-test/r/ndb_index_ordered.result b/mysql-test/r/ndb_index_ordered.result index 943571aa524..12438f247c3 100644 --- a/mysql-test/r/ndb_index_ordered.result +++ b/mysql-test/r/ndb_index_ordered.result @@ -323,16 +323,16 @@ index(ye), index(ti), index(ts) ) engine=ndb; -insert into t1 (pk,dt,da,ye,ti) values -(1, '1901-05-05 23:00:59', '1901-05-05', '1901', '23:00:59'), -(2, '1912-09-05 13:00:59', '1912-09-05', '1912', '13:00:59'), -(3, '1945-12-31 00:00:00', '1945-12-31', '1945', '00:00:00'), -(4, '1955-12-31 00:00:00', '1955-12-31', '1955', '00:00:00'), -(5, '1963-06-06 06:06:06', '1963-06-06', '1963', '06:06:06'), -(6, '1993-06-06 06:06:06', '1993-06-06', '1993', '06:06:06'), -(7, '2001-01-01 10:11:10', '2001-01-01', '2001', '10:11:10'), -(8, '2001-01-01 10:11:11', '2001-01-01', '2001', '10:11:11'), -(9, '2005-01-31 23:59:59', '2005-01-31', '2005', '23:59:59'); +insert into t1 (pk,dt,da,ye,ti,ts) values +(1, '1901-05-05 23:00:59', '1901-05-05', '1901', '23:00:59', '2001-01-01 23:00:59'), +(2, '1912-09-05 13:00:59', '1912-09-05', '1912', '13:00:59', '2001-01-01 13:00:59'), +(3, '1945-12-31 00:00:00', '1945-12-31', '1945', '00:00:00', '2001-01-01 00:00:00'), +(4, '1955-12-31 00:00:00', '1955-12-31', '1955', '00:00:00', '2001-01-01 00:00:00'), +(5, '1963-06-06 06:06:06', '1963-06-06', '1963', '06:06:06', '2001-01-01 06:06:06'), +(6, '1993-06-06 06:06:06', '1993-06-06', '1993', '06:06:06', '2001-01-01 06:06:06'), +(7, '2001-01-01 10:11:10', '2001-01-01', '2001', '10:11:10', '2001-01-01 10:11:10'), +(8, '2001-01-01 10:11:11', '2001-01-01', '2001', '10:11:11', '2001-01-01 10:11:11'), +(9, '2005-01-31 23:59:59', '2005-01-31', '2005', '23:59:59', '2001-01-01 23:59:59'); select count(*)-9 from t1 use index (dt) where dt > '1900-01-01 00:00:00'; count(*)-9 0 @@ -420,6 +420,30 @@ count(*)-8 select count(*)-9 from t1 use index (ti) where ti <= '23:59:59'; count(*)-9 0 +select count(*)-9 from t1 use index (ts) where ts >= '2001-01-01 00:00:00'; +count(*)-9 +0 +select count(*)-7 from t1 use index (ts) where ts > '2001-01-01 00:00:00'; +count(*)-7 +0 +select count(*)-7 from t1 use index (ts) where ts > '2001-01-01 05:05:05'; +count(*)-7 +0 +select count(*)-5 from t1 use index (ts) where ts > '2001-01-01 06:06:06'; +count(*)-5 +0 +select count(*)-5 from t1 use index (ts) where ts < '2001-01-01 10:11:11'; +count(*)-5 +0 +select count(*)-6 from t1 use index (ts) where ts <= '2001-01-01 10:11:11'; +count(*)-6 +0 +select count(*)-8 from t1 use index (ts) where ts < '2001-01-01 23:59:59'; +count(*)-8 +0 +select count(*)-9 from t1 use index (ts) where ts <= '2001-01-01 23:59:59'; +count(*)-9 +0 drop table t1; create table t1(a int primary key, b int not null, index(b)); insert into t1 values (1,1), (2,2); diff --git a/mysql-test/t/ndb_index_ordered.test b/mysql-test/t/ndb_index_ordered.test index 89f1e5b7e9f..47e6b93eb81 100644 --- a/mysql-test/t/ndb_index_ordered.test +++ b/mysql-test/t/ndb_index_ordered.test @@ -189,16 +189,16 @@ create table t1 ( index(ts) ) engine=ndb; -insert into t1 (pk,dt,da,ye,ti) values - (1, '1901-05-05 23:00:59', '1901-05-05', '1901', '23:00:59'), - (2, '1912-09-05 13:00:59', '1912-09-05', '1912', '13:00:59'), - (3, '1945-12-31 00:00:00', '1945-12-31', '1945', '00:00:00'), - (4, '1955-12-31 00:00:00', '1955-12-31', '1955', '00:00:00'), - (5, '1963-06-06 06:06:06', '1963-06-06', '1963', '06:06:06'), - (6, '1993-06-06 06:06:06', '1993-06-06', '1993', '06:06:06'), - (7, '2001-01-01 10:11:10', '2001-01-01', '2001', '10:11:10'), - (8, '2001-01-01 10:11:11', '2001-01-01', '2001', '10:11:11'), - (9, '2005-01-31 23:59:59', '2005-01-31', '2005', '23:59:59'); +insert into t1 (pk,dt,da,ye,ti,ts) values + (1, '1901-05-05 23:00:59', '1901-05-05', '1901', '23:00:59', '2001-01-01 23:00:59'), + (2, '1912-09-05 13:00:59', '1912-09-05', '1912', '13:00:59', '2001-01-01 13:00:59'), + (3, '1945-12-31 00:00:00', '1945-12-31', '1945', '00:00:00', '2001-01-01 00:00:00'), + (4, '1955-12-31 00:00:00', '1955-12-31', '1955', '00:00:00', '2001-01-01 00:00:00'), + (5, '1963-06-06 06:06:06', '1963-06-06', '1963', '06:06:06', '2001-01-01 06:06:06'), + (6, '1993-06-06 06:06:06', '1993-06-06', '1993', '06:06:06', '2001-01-01 06:06:06'), + (7, '2001-01-01 10:11:10', '2001-01-01', '2001', '10:11:10', '2001-01-01 10:11:10'), + (8, '2001-01-01 10:11:11', '2001-01-01', '2001', '10:11:11', '2001-01-01 10:11:11'), + (9, '2005-01-31 23:59:59', '2005-01-31', '2005', '23:59:59', '2001-01-01 23:59:59'); # datetime select count(*)-9 from t1 use index (dt) where dt > '1900-01-01 00:00:00'; @@ -237,6 +237,16 @@ select count(*)-6 from t1 use index (ti) where ti <= '10:11:11'; select count(*)-8 from t1 use index (ti) where ti < '23:59:59'; select count(*)-9 from t1 use index (ti) where ti <= '23:59:59'; +# timestamp +select count(*)-9 from t1 use index (ts) where ts >= '2001-01-01 00:00:00'; +select count(*)-7 from t1 use index (ts) where ts > '2001-01-01 00:00:00'; +select count(*)-7 from t1 use index (ts) where ts > '2001-01-01 05:05:05'; +select count(*)-5 from t1 use index (ts) where ts > '2001-01-01 06:06:06'; +select count(*)-5 from t1 use index (ts) where ts < '2001-01-01 10:11:11'; +select count(*)-6 from t1 use index (ts) where ts <= '2001-01-01 10:11:11'; +select count(*)-8 from t1 use index (ts) where ts < '2001-01-01 23:59:59'; +select count(*)-9 from t1 use index (ts) where ts <= '2001-01-01 23:59:59'; + drop table t1; # bug#7798 diff --git a/ndb/include/kernel/signaldata/DictTabInfo.hpp b/ndb/include/kernel/signaldata/DictTabInfo.hpp index 3e73ae67ebe..ade6c22a5bd 100644 --- a/ndb/include/kernel/signaldata/DictTabInfo.hpp +++ b/ndb/include/kernel/signaldata/DictTabInfo.hpp @@ -311,7 +311,9 @@ public: ExtDate = NdbSqlUtil::Type::Date, ExtBlob = NdbSqlUtil::Type::Blob, ExtText = NdbSqlUtil::Type::Text, - ExtTime = NdbSqlUtil::Type::Time + ExtTime = NdbSqlUtil::Type::Time, + ExtYear = NdbSqlUtil::Type::Year, + ExtTimestamp = NdbSqlUtil::Type::Timestamp }; // Attribute data interpretation @@ -446,6 +448,16 @@ public: AttributeSize = DictTabInfo::an8Bit; AttributeArraySize = 3 * AttributeExtLength; return true; + case DictTabInfo::ExtYear: + AttributeType = DictTabInfo::StringType; + AttributeSize = DictTabInfo::an8Bit; + AttributeArraySize = 1 * AttributeExtLength; + return true; + case DictTabInfo::ExtTimestamp: + AttributeType = DictTabInfo::StringType; + AttributeSize = DictTabInfo::an8Bit; + AttributeArraySize = 4 * AttributeExtLength; + return true; }; return false; } diff --git a/ndb/include/ndbapi/NdbDictionary.hpp b/ndb/include/ndbapi/NdbDictionary.hpp index 454b267d1b0..0dca1c0f106 100644 --- a/ndb/include/ndbapi/NdbDictionary.hpp +++ b/ndb/include/ndbapi/NdbDictionary.hpp @@ -188,7 +188,9 @@ public: Date, ///< Precision down to 1 day(sizeof(Date) == 4 bytes ) Blob, ///< Binary large object (see NdbBlob) Text, ///< Text blob - Time = 25 ///< Time without date + Time = 25, ///< Time without date + Year = 26, ///< Year 1901-2155 (1 byte) + Timestamp = 27 ///< Unix time }; /** diff --git a/ndb/include/util/NdbSqlUtil.hpp b/ndb/include/util/NdbSqlUtil.hpp index 10024d9b616..3787814052a 100644 --- a/ndb/include/util/NdbSqlUtil.hpp +++ b/ndb/include/util/NdbSqlUtil.hpp @@ -84,7 +84,9 @@ public: Date, // Precision down to 1 day (size 4 bytes) Blob, // Blob Text, // Text blob - Time = 25 // Time without date + Time = 25, // Time without date + Year = 26, // Year (size 1 byte) + Timestamp = 27 // Unix seconds (uint32) }; Enum m_typeId; Cmp* m_cmp; // comparison method @@ -137,6 +139,8 @@ private: static Cmp cmpBlob; static Cmp cmpText; static Cmp cmpTime; + static Cmp cmpYear; + static Cmp cmpTimestamp; }; #endif diff --git a/ndb/src/common/util/NdbSqlUtil.cpp b/ndb/src/common/util/NdbSqlUtil.cpp index 233698ae52b..6b23da774af 100644 --- a/ndb/src/common/util/NdbSqlUtil.cpp +++ b/ndb/src/common/util/NdbSqlUtil.cpp @@ -179,6 +179,14 @@ NdbSqlUtil::m_typeList[] = { { Type::Time, cmpTime + }, + { + Type::Year, + cmpYear + }, + { + Type::Timestamp, + cmpTimestamp } }; @@ -592,6 +600,34 @@ NdbSqlUtil::cmpTime(const void* info, const Uint32* p1, const Uint32* p2, Uint32 return 0; } +int +NdbSqlUtil::cmpYear(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size) +{ + assert(full >= size && size > 0); + union { const Uint32* p; const unsigned char* v; } u1, u2; + u1.p = p1; + u2.p = p2; + if (u1.v[0] < u2.v[0]) + return -1; + if (u1.v[0] > u2.v[0]) + return +1; + return 0; +} + +int +NdbSqlUtil::cmpTimestamp(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size) +{ + assert(full >= size && size > 0); + union { Uint32 p[1]; Uint32 v; } u1, u2; + u1.v = p1[0]; + u2.v = p2[0]; + if (u1.v < u2.v) + return -1; + if (u1.v > u2.v) + return +1; + return 0; +} + // check charset bool diff --git a/ndb/src/ndbapi/NdbDictionary.cpp b/ndb/src/ndbapi/NdbDictionary.cpp index 0508d8bf277..58b35c6c306 100644 --- a/ndb/src/ndbapi/NdbDictionary.cpp +++ b/ndb/src/ndbapi/NdbDictionary.cpp @@ -950,6 +950,12 @@ operator<<(NdbOut& out, const NdbDictionary::Column& col) case NdbDictionary::Column::Time: out << "Time"; break; + case NdbDictionary::Column::Year: + out << "Year"; + break; + case NdbDictionary::Column::Timestamp: + out << "Timestamp"; + break; case NdbDictionary::Column::Undefined: out << "Undefined"; break; diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/ndb/src/ndbapi/NdbDictionaryImpl.cpp index 59474943f3b..9f6ed144fb0 100644 --- a/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -149,6 +149,8 @@ NdbColumnImpl::init(Type t) m_cs = default_cs; break; case Time: + case Year: + case Timestamp: m_precision = 0; m_scale = 0; m_length = 1; @@ -1184,6 +1186,8 @@ columnTypeMapping[] = { { DictTabInfo::ExtBlob, NdbDictionary::Column::Blob }, { DictTabInfo::ExtText, NdbDictionary::Column::Text }, { DictTabInfo::ExtTime, NdbDictionary::Column::Time }, + { DictTabInfo::ExtYear, NdbDictionary::Column::Year }, + { DictTabInfo::ExtTimestamp, NdbDictionary::Column::Timestamp }, { -1, -1 } }; diff --git a/ndb/src/ndbapi/NdbRecAttr.cpp b/ndb/src/ndbapi/NdbRecAttr.cpp index f2427fb32e8..6749a0f04d9 100644 --- a/ndb/src/ndbapi/NdbRecAttr.cpp +++ b/ndb/src/ndbapi/NdbRecAttr.cpp @@ -156,10 +156,11 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r) return out; } - if (r.arraySize() > 1) + uint length = r.getColumn()->getLength(); + if (length > 1) out << "["; - for (Uint32 j = 0; j < r.arraySize(); j++) + for (Uint32 j = 0; j < length; j++) { if (j > 0) out << " "; @@ -192,14 +193,14 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r) break; case NdbDictionary::Column::Char: out.print("%.*s", r.arraySize(), r.aRef()); - j = r.arraySize(); + j = length; break; case NdbDictionary::Column::Varchar: { short len = ntohs(r.u_short_value()); out.print("%.*s", len, r.aRef()+2); } - j = r.arraySize(); + j = length; break; case NdbDictionary::Column::Float: out << r.float_value(); @@ -207,6 +208,74 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r) case NdbDictionary::Column::Double: out << r.double_value(); break; + // for dates cut-and-paste from field.cc + case NdbDictionary::Column::Datetime: + { + ulonglong tmp=r.u_64_value(); + long part1,part2,part3; + part1=(long) (tmp/LL(1000000)); + part2=(long) (tmp - (ulonglong) part1*LL(1000000)); + char buf[40]; + char* pos=(char*) buf+19; + *pos--=0; + *pos--= (char) ('0'+(char) (part2%10)); part2/=10; + *pos--= (char) ('0'+(char) (part2%10)); part3= (int) (part2 / 10); + *pos--= ':'; + *pos--= (char) ('0'+(char) (part3%10)); part3/=10; + *pos--= (char) ('0'+(char) (part3%10)); part3/=10; + *pos--= ':'; + *pos--= (char) ('0'+(char) (part3%10)); part3/=10; + *pos--= (char) ('0'+(char) part3); + *pos--= '/'; + *pos--= (char) ('0'+(char) (part1%10)); part1/=10; + *pos--= (char) ('0'+(char) (part1%10)); part1/=10; + *pos--= '-'; + *pos--= (char) ('0'+(char) (part1%10)); part1/=10; + *pos--= (char) ('0'+(char) (part1%10)); part3= (int) (part1/10); + *pos--= '-'; + *pos--= (char) ('0'+(char) (part3%10)); part3/=10; + *pos--= (char) ('0'+(char) (part3%10)); part3/=10; + *pos--= (char) ('0'+(char) (part3%10)); part3/=10; + *pos=(char) ('0'+(char) part3); + out << buf; + } + break; + case NdbDictionary::Column::Date: + { + uint tmp=uint3korr(r.aRef()); + int year=(int) ((uint32) tmp/10000L % 10000); + int month=(int) ((uint32) tmp/100 % 100); + int day=(int) ((uint32) tmp % 100); + char buf[40]; + sprintf(buf, "%04d-%02d-%02d", year, month, day); + out << buf; + } + break; + case NdbDictionary::Column::Time: + { + long tmp=(long) sint3korr(r.aRef()); + int hour=(uint) (tmp/10000); + int minute=(uint) (tmp/100 % 100); + int second=(uint) (tmp % 100); + char buf[40]; + sprintf(buf, "%02d:%02d:%02d", hour, minute, second); + out << buf; + } + break; + case NdbDictionary::Column::Year: + { + uint year = 1900 + r.u_char_value(); + char buf[40]; + sprintf(buf, "%04d", year); + out << buf; + } + break; + case NdbDictionary::Column::Timestamp: + { + time_t time = r.u_32_value(); + out << (uint)time; + } + break; case NdbDictionary::Column::Blob: { const NdbBlob::Head* h = (const NdbBlob::Head*)r.aRef(); @@ -215,7 +284,7 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r) unsigned n = r.arraySize() - sizeof(*h); for (unsigned k = 0; k < n && k < h->length; k++) out.print("%02X", (int)p[k]); - j = r.arraySize(); + j = length; } break; case NdbDictionary::Column::Text: @@ -226,19 +295,19 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r) unsigned n = r.arraySize() - sizeof(*h); for (unsigned k = 0; k < n && k < h->length; k++) out.print("%c", (int)p[k]); - j = r.arraySize(); + j = length; } break; default: /* no print functions for the rest, just print type */ out << (int) r.getType(); - j = r.arraySize(); + j = length; if (j > 1) out << " " << j << " times"; break; } } - if (r.arraySize() > 1) + if (length > 1) { out << "]"; } diff --git a/ndb/test/include/NdbSchemaOp.hpp b/ndb/test/include/NdbSchemaOp.hpp index e2fb4015b88..77e704c0e5c 100644 --- a/ndb/test/include/NdbSchemaOp.hpp +++ b/ndb/test/include/NdbSchemaOp.hpp @@ -575,10 +575,6 @@ convertColumnTypeToAttrType(NdbDictionary::Column::Type _type) case NdbDictionary::Column::Binary: case NdbDictionary::Column::Varbinary: return String; - case NdbDictionary::Column::Datetime: - case NdbDictionary::Column::Date: - case NdbDictionary::Column::Time: - case NdbDictionary::Column::Undefined: default: return NoAttrTypeDef; } diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 437b5ebcdf7..a959cbaf434 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -3360,14 +3360,14 @@ static int create_ndb_column(NDBCOL &col, col.setLength(1); break; // Date types - case MYSQL_TYPE_TIMESTAMP: - col.setType(NDBCOL::Unsigned); - col.setLength(1); - break; case MYSQL_TYPE_DATETIME: col.setType(NDBCOL::Datetime); col.setLength(1); break; + case MYSQL_TYPE_DATE: // ? + col.setType(NDBCOL::Char); + col.setLength(field->pack_length()); + break; case MYSQL_TYPE_NEWDATE: col.setType(NDBCOL::Date); col.setLength(1); @@ -3376,10 +3376,13 @@ static int create_ndb_column(NDBCOL &col, col.setType(NDBCOL::Time); col.setLength(1); break; - case MYSQL_TYPE_DATE: // ? - case MYSQL_TYPE_YEAR: - col.setType(NDBCOL::Char); - col.setLength(field->pack_length()); + case MYSQL_TYPE_YEAR: + col.setType(NDBCOL::Year); + col.setLength(1); + break; + case MYSQL_TYPE_TIMESTAMP: + col.setType(NDBCOL::Timestamp); + col.setLength(1); break; // Char types case MYSQL_TYPE_STRING: From 563ebb432882891b9aab845ebb4e96ac363c1270 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 27 Jan 2005 18:53:59 +0200 Subject: [PATCH 40/54] ut0mem.c: Add a note to the error message that is printed when memory allocation fails: 32-bit computers usually have at most 2 GB or 4 GB process memory space innobase/ut/ut0mem.c: Add a note to the error message that is printed when memory allocation fails: 32-bit computers usually have at most 2 GB or 4 GB process memory space --- innobase/ut/ut0mem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/innobase/ut/ut0mem.c b/innobase/ut/ut0mem.c index 6ed61b0b5de..9e026ed0011 100644 --- a/innobase/ut/ut0mem.c +++ b/innobase/ut/ut0mem.c @@ -88,7 +88,9 @@ ut_malloc_low( "InnoDB: Check if you should increase the swap file or\n" "InnoDB: ulimits of your operating system.\n" "InnoDB: On FreeBSD check you have compiled the OS with\n" - "InnoDB: a big enough maximum process size.\n", + "InnoDB: a big enough maximum process size.\n" + "InnoDB: Note that in most 32-bit computers the process\n" + "InnoDB: memory space is limited to 2 GB or 4 GB.\n", (ulong) n, (ulong) ut_total_allocated_memory, #ifdef __WIN__ (ulong) GetLastError() From 1c49d54894aec778efa3fef6da5ae992f21b8d1d Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 27 Jan 2005 18:54:00 +0200 Subject: [PATCH 41/54] os0file.c: Add includes for the _stat() call to compile on Windows in Hot Backup build innobase/os/os0file.c: Add includes for the _stat() call to compile on Windows in Hot Backup build --- innobase/os/os0file.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c index 64d80350275..a2c5365993c 100644 --- a/innobase/os/os0file.c +++ b/innobase/os/os0file.c @@ -15,6 +15,13 @@ Created 10/21/1995 Heikki Tuuri #include "fil0fil.h" #include "buf0buf.h" +#if defined(UNIV_HOTBACKUP) && defined(__WIN__) +/* Add includes for the _stat() call to compile on Windows */ +#include +#include +#include +#endif /* UNIV_HOTBACKUP */ + #undef HAVE_FDATASYNC #ifdef POSIX_ASYNC_IO From fce978c717eb26e0c31c27fec56106ae46ed4aac Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 27 Jan 2005 21:23:21 +0100 Subject: [PATCH 42/54] ndb - post-merge fix ndb/include/ndb_constants.h: post-merge fix --- ndb/include/ndb_constants.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ndb/include/ndb_constants.h b/ndb/include/ndb_constants.h index a04afe1bd72..da3fc2cbdd8 100644 --- a/ndb/include/ndb_constants.h +++ b/ndb/include/ndb_constants.h @@ -61,7 +61,9 @@ #define NDB_TYPE_LONG_VARCHAR 23 #define NDB_TYPE_LONG_VARBINARY 24 #define NDB_TYPE_TIME 25 +#define NDB_TYPE_YEAR 26 +#define NDB_TYPE_TIMESTAMP 27 -#define NDB_TYPE_MAX 26 +#define NDB_TYPE_MAX 28 #endif From b485ed7b49f25617efc7070032187335216b7a9c Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Jan 2005 01:23:06 +0300 Subject: [PATCH 43/54] Remove unused configure.in name TOOLS_LIBS. configure.in: Remove unused TOOLS_LIBS: LIBS and CLIENT_LIBS should be enough for the global configure.in --- configure.in | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/configure.in b/configure.in index 985b5923c5c..98d060e660c 100644 --- a/configure.in +++ b/configure.in @@ -1536,14 +1536,11 @@ then fi fi -TOOLS_LIBS="$NON_THREADED_CLIENT_LIBS" - # Should we use named pthread library ? AC_MSG_CHECKING("named thread libs:") if test "$with_named_thread" != "no" then LIBS="$with_named_thread $LIBS $with_named_thread" - TOOLS_LIBS="$with_named_thread $TOOLS_LIBS $with_named_thread" with_posix_threads="yes" with_mit_threads="no" AC_MSG_RESULT("$with_named_thread") @@ -1562,9 +1559,7 @@ else then AC_MSG_CHECKING("for pthread_create in -lpthread"); ac_save_LIBS="$LIBS" - ac_save_TOOLS_LIBS="$TOOLS_LIBS" LIBS="$LIBS -lpthread" - TOOLS_LIBS="$TOOLS_LIBS -lpthread" AC_TRY_LINK( [#include ], [ (void) pthread_create((pthread_t*) 0,(pthread_attr_t*) 0, 0, 0); ], @@ -1573,7 +1568,6 @@ else if test "$with_posix_threads" = "no" then LIBS=" $ac_save_LIBS -lpthreads" - TOOLS_LIBS=" $ac_save_TOOLS_LIBS -lpthreads" AC_MSG_CHECKING("for pthread_create in -lpthreads"); AC_TRY_LINK( [#include ], @@ -1584,7 +1578,6 @@ else then # This is for FreeBSD LIBS="$ac_save_LIBS -pthread" - TOOLS_LIBS="$ac_save_TOOLS_LIBS -pthread" AC_MSG_CHECKING("for pthread_create in -pthread"); AC_TRY_LINK( [#include ], @@ -1595,7 +1588,6 @@ else then with_mit_threads="yes" LIBS="$ac_save_LIBS" - TOOLS_LIBS="$ac_save_TOOLS_LIBS" fi fi fi @@ -3037,8 +3029,6 @@ AC_SUBST(sql_union_dirs) # Some usefull subst AC_SUBST(CC) AC_SUBST(GXX) -#Remove TOOLS_LIBS, because this is included in LIBRARIES -#AC_SUBST(TOOLS_LIBS) # Set configuration options for make_binary_distribution case $SYSTEM_TYPE in From df7bb879cdbbf61e4c879cc6f13126a0be69dff7 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Jan 2005 00:42:41 +0100 Subject: [PATCH 44/54] Bug#8167 signal usage clash between mysql server and ndb shared memory added shared memory config parameter, signum for use in signalling added global variable for holdign signum to be used for shared memory connection only fiddle with signals if it is set simplified common ndb client option handling ndb/include/Makefile.am: added common defaults file ndb/include/mgmapi/mgmapi_config_parameters.h: added shared memory config parameter, signum for use in signalling ndb/include/transporter/TransporterDefinitions.hpp: added shared memory config parameter, signum for use in signalling ndb/include/util/ndb_opts.h: simplified common ndb client option handling ndb/src/common/mgmcommon/IPCConfig.cpp: added shared memory config parameter, signum for use in signalling ndb/src/common/portlib/NdbThread.c: added global variable for holdign signum to be used for shared memory connection only block signals if shared memory is used ndb/src/common/transporter/SHM_Transporter.cpp: use signum in new global variable for shared memory signalling ndb/src/common/transporter/TransporterRegistry.cpp: use signum in new global variable for shared memory signalling only fiddle with signals if it is set ndb/src/cw/cpcd/main.cpp: ndb_opts not really used ndb/src/kernel/vm/Configuration.cpp: simplified common ndb client option handling ndb/src/mgmclient/main.cpp: simplified common ndb client option handling ndb/src/mgmsrv/ConfigInfo.cpp: added shared memory config parameter, signum for use in signalling ndb/src/mgmsrv/main.cpp: simplified common ndb client option handling ndb/tools/delete_all.cpp: simplified common ndb client option handling ndb/tools/desc.cpp: simplified common ndb client option handling ndb/tools/drop_index.cpp: simplified common ndb client option handling ndb/tools/drop_tab.cpp: simplified common ndb client option handling ndb/tools/listTables.cpp: simplified common ndb client option handling ndb/tools/restore/restore_main.cpp: simplified common ndb client option handling ndb/tools/select_all.cpp: simplified common ndb client option handling ndb/tools/select_count.cpp: simplified common ndb client option handling ndb/tools/waiter.cpp: simplified common ndb client option handling --- ndb/include/Makefile.am | 1 + ndb/include/mgmapi/mgmapi_config_parameters.h | 1 + ndb/include/ndbapi/ndb_opt_defaults.h | 27 +++++++ .../transporter/TransporterDefinitions.hpp | 1 + ndb/include/util/ndb_opts.h | 59 ++++++++++++--- ndb/src/common/mgmcommon/IPCConfig.cpp | 11 ++- ndb/src/common/portlib/NdbThread.c | 19 +++-- .../common/transporter/SHM_Transporter.cpp | 8 +- .../transporter/TransporterRegistry.cpp | 74 ++++++++++++------- ndb/src/cw/cpcd/main.cpp | 5 +- ndb/src/kernel/vm/Configuration.cpp | 23 +----- ndb/src/mgmclient/main.cpp | 23 +----- ndb/src/mgmsrv/ConfigInfo.cpp | 42 ++++++++--- ndb/src/mgmsrv/main.cpp | 32 ++------ ndb/tools/delete_all.cpp | 23 +----- ndb/tools/desc.cpp | 25 +------ ndb/tools/drop_index.cpp | 23 +----- ndb/tools/drop_tab.cpp | 23 +----- ndb/tools/listTables.cpp | 27 ++----- ndb/tools/restore/restore_main.cpp | 20 +---- ndb/tools/select_all.cpp | 23 +----- ndb/tools/select_count.cpp | 23 +----- ndb/tools/waiter.cpp | 25 ++----- 23 files changed, 236 insertions(+), 302 deletions(-) create mode 100644 ndb/include/ndbapi/ndb_opt_defaults.h diff --git a/ndb/include/Makefile.am b/ndb/include/Makefile.am index 38b9d870fbc..ef4e9552566 100644 --- a/ndb/include/Makefile.am +++ b/ndb/include/Makefile.am @@ -8,6 +8,7 @@ ndb_version.h ndbapiinclude_HEADERS = \ ndbapi/ndbapi_limits.h \ +ndbapi/ndb_opt_defaults.h \ ndbapi/Ndb.hpp \ ndbapi/NdbApi.hpp \ ndbapi/NdbConnection.hpp \ diff --git a/ndb/include/mgmapi/mgmapi_config_parameters.h b/ndb/include/mgmapi/mgmapi_config_parameters.h index 406bdb1a110..8a04ee2fe37 100644 --- a/ndb/include/mgmapi/mgmapi_config_parameters.h +++ b/ndb/include/mgmapi/mgmapi_config_parameters.h @@ -121,6 +121,7 @@ #define CFG_SHM_CHECKSUM 501 #define CFG_SHM_KEY 502 #define CFG_SHM_BUFFER_MEM 503 +#define CFG_SHM_SIGNUM 504 #define CFG_SCI_HOST1_ID_0 550 #define CFG_SCI_HOST1_ID_1 551 diff --git a/ndb/include/ndbapi/ndb_opt_defaults.h b/ndb/include/ndbapi/ndb_opt_defaults.h new file mode 100644 index 00000000000..63b673ed60d --- /dev/null +++ b/ndb/include/ndbapi/ndb_opt_defaults.h @@ -0,0 +1,27 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#ifndef NDB_OPT_DEFAULTS_H +#define NDB_OPT_DEFAULTS_H + +#ifdef SIGRTMIN +#define OPT_NDB_SHM_SIGNUM_DEFAULT SIGRTMIN+2 +#else +#define OPT_NDB_SHM_SIGNUM_DEFAULT 0 +#endif +#define OPT_NDB_SHM_DEFAULT 0 + +#endif diff --git a/ndb/include/transporter/TransporterDefinitions.hpp b/ndb/include/transporter/TransporterDefinitions.hpp index 4ff6b2073eb..d4763ba4c37 100644 --- a/ndb/include/transporter/TransporterDefinitions.hpp +++ b/ndb/include/transporter/TransporterDefinitions.hpp @@ -77,6 +77,7 @@ struct SHM_TransporterConfiguration { Uint32 shmKey; Uint32 shmSize; + int signum; }; /** diff --git a/ndb/include/util/ndb_opts.h b/ndb/include/util/ndb_opts.h index dc95149f706..aa7a02f58ae 100644 --- a/ndb/include/util/ndb_opts.h +++ b/ndb/include/util/ndb_opts.h @@ -22,24 +22,16 @@ #include #include #include +#include #define NDB_STD_OPTS_VARS \ const char *opt_connect_str= 0;\ -my_bool opt_ndb_shm;\ my_bool opt_ndb_optimized_node_selection -#define NDB_STD_OPTS_OPTIONS \ -OPT_NDB_SHM= 256,\ -OPT_NDB_OPTIMIZED_NODE_SELECTION +my_bool opt_ndb_shm; #define OPT_NDB_CONNECTSTRING 'c' -#if defined(NDB_SHM_TRANSPORTER) && MYSQL_VERSION_ID >= 50000 -#define OPT_NDB_SHM_DEFAULT 1 -#else -#define OPT_NDB_SHM_DEFAULT 0 -#endif - #define NDB_STD_OPTS_COMMON \ { "usage", '?', "Display this help and exit.", \ 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, \ @@ -75,4 +67,51 @@ OPT_NDB_OPTIMIZED_NODE_SELECTION #define NDB_STD_OPTS(prog_name) NDB_STD_OPTS_COMMON #endif +static void ndb_std_print_version() +{ + printf("MySQL distrib %s, for %s (%s)\n", + MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); +} + +static void usage(); + +enum ndb_std_options { + OPT_NDB_SHM= 256, + OPT_NDB_SHM_SIGNUM, + OPT_NDB_OPTIMIZED_NODE_SELECTION, + NDB_STD_OPTIONS_LAST /* should always be last in this enum */ +}; + +static my_bool +ndb_std_get_one_option(int optid, + const struct my_option *opt __attribute__((unused)), + const char *argument) +{ + switch (optid) { + case '#': + if (argument) + { + DBUG_PUSH(argument); + } + break; + case 'V': + ndb_std_print_version(); + exit(0); + case '?': + usage(); + exit(0); + case OPT_NDB_SHM: + if (opt_ndb_shm) + { +#ifndef NDB_SHM_TRANSPORTER + printf("Warning: binary not compiled with shared memory support,\n" + "Tcp connections will now be used instead\n"); + opt_ndb_shm= 0; +#endif + } + break; + } + return 0; +} + #endif /*_NDB_OPTS_H */ diff --git a/ndb/src/common/mgmcommon/IPCConfig.cpp b/ndb/src/common/mgmcommon/IPCConfig.cpp index 1da03e3eaf2..86791490863 100644 --- a/ndb/src/common/mgmcommon/IPCConfig.cpp +++ b/ndb/src/common/mgmcommon/IPCConfig.cpp @@ -14,7 +14,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "IPCConfig.hpp" +#include +#include +#include #include #include @@ -381,7 +383,12 @@ IPCConfig::configureTransporters(Uint32 nodeId, if(iter.get(CFG_SHM_KEY, &conf.shmKey)) break; if(iter.get(CFG_SHM_BUFFER_MEM, &conf.shmSize)) break; - + { + Uint32 tmp; + if(iter.get(CFG_SHM_SIGNUM, &tmp)) break; + conf.signum= tmp; + } + conf.port= server_port; conf.localHostName = localHostName; conf.remoteHostName = remoteHostName; diff --git a/ndb/src/common/portlib/NdbThread.c b/ndb/src/common/portlib/NdbThread.c index 8cd6c306514..d05fca7aeed 100644 --- a/ndb/src/common/portlib/NdbThread.c +++ b/ndb/src/common/portlib/NdbThread.c @@ -24,6 +24,10 @@ /*#define USE_PTHREAD_EXTRAS*/ +#ifdef NDB_SHM_TRANSPORTER +int g_ndb_shm_signum= 0; +#endif + struct NdbThread { pthread_t thread; @@ -35,16 +39,21 @@ struct NdbThread static void* ndb_thread_wrapper(void* _ss){ + DBUG_ENTER("ndb_thread_wrapper"); void * ret; struct NdbThread * ss = (struct NdbThread *)_ss; #ifdef NDB_SHM_TRANSPORTER - sigset_t mask; - sigemptyset(&mask); - sigaddset(&mask, SIGUSR1); - pthread_sigmask(SIG_BLOCK, &mask, 0); + if (g_ndb_shm_signum) + { + DBUG_PRINT("info",("Block signum %d",g_ndb_shm_signum)); + sigset_t mask; + sigemptyset(&mask); + sigaddset(&mask, g_ndb_shm_signum); + pthread_sigmask(SIG_BLOCK, &mask, 0); + } #endif ret= (* ss->func)(ss->object); - return ret; + DBUG_RETURN(ret); } diff --git a/ndb/src/common/transporter/SHM_Transporter.cpp b/ndb/src/common/transporter/SHM_Transporter.cpp index f0cbf822e53..eed3ad77be6 100644 --- a/ndb/src/common/transporter/SHM_Transporter.cpp +++ b/ndb/src/common/transporter/SHM_Transporter.cpp @@ -26,6 +26,8 @@ #include #include +extern int g_ndb_shm_signum; + SHM_Transporter::SHM_Transporter(TransporterRegistry &t_reg, const char *lHostName, const char *rHostName, @@ -62,7 +64,9 @@ SHM_Transporter::~SHM_Transporter(){ bool SHM_Transporter::initTransporter(){ - return true; + if (g_ndb_shm_signum) + return true; + return false; } void @@ -355,6 +359,6 @@ SHM_Transporter::doSend() if(m_last_signal) { m_last_signal = 0; - kill(m_remote_pid, SIGUSR1); + kill(m_remote_pid, g_ndb_shm_signum); } } diff --git a/ndb/src/common/transporter/TransporterRegistry.cpp b/ndb/src/common/transporter/TransporterRegistry.cpp index ddc01454205..462cde76740 100644 --- a/ndb/src/common/transporter/TransporterRegistry.cpp +++ b/ndb/src/common/transporter/TransporterRegistry.cpp @@ -38,6 +38,7 @@ #ifdef NDB_SHM_TRANSPORTER #include "SHM_Transporter.hpp" +extern int g_ndb_shm_signum; #endif #include "TransporterCallback.hpp" @@ -148,22 +149,13 @@ TransporterRegistry::disconnectAll(){ bool TransporterRegistry::init(NodeId nodeId) { + DBUG_ENTER("TransporterRegistry::init"); nodeIdSpecified = true; localNodeId = nodeId; DEBUG("TransporterRegistry started node: " << localNodeId); -#ifdef NDB_SHM_TRANSPORTER - /** - * Make sure to block SIGUSR1 - * TransporterRegistry::init is run from "main" thread - */ - sigset_t mask; - sigemptyset(&mask); - sigaddset(&mask, SIGUSR1); - pthread_sigmask(SIG_BLOCK, &mask, 0); -#endif -return true; + DBUG_RETURN(true); } bool @@ -402,6 +394,7 @@ TransporterRegistry::createTransporter(SCI_TransporterConfiguration *config) { bool TransporterRegistry::createTransporter(SHM_TransporterConfiguration *config) { + DBUG_ENTER("TransporterRegistry::createTransporter SHM"); #ifdef NDB_SHM_TRANSPORTER if(!nodeIdSpecified){ init(config->localNodeId); @@ -410,6 +403,22 @@ TransporterRegistry::createTransporter(SHM_TransporterConfiguration *config) { if(config->localNodeId != localNodeId) return false; + if (!g_ndb_shm_signum) { + g_ndb_shm_signum= config->signum; + DBUG_PRINT("info",("Block signum %d",g_ndb_shm_signum)); + /** + * Make sure to block g_ndb_shm_signum + * TransporterRegistry::init is run from "main" thread + */ + sigset_t mask; + sigemptyset(&mask); + sigaddset(&mask, g_ndb_shm_signum); + pthread_sigmask(SIG_BLOCK, &mask, 0); + } + + if(config->signum != g_ndb_shm_signum) + return false; + if(theTransporters[config->remoteNodeId] != NULL) return false; @@ -439,9 +448,9 @@ TransporterRegistry::createTransporter(SHM_TransporterConfiguration *config) { nTransporters++; nSHMTransporters++; - return true; + DBUG_RETURN(true); #else - return false; + DBUG_RETURN(false); #endif } @@ -1311,6 +1320,7 @@ shm_sig_handler(int signo) void TransporterRegistry::startReceiving() { + DBUG_ENTER("TransporterRegistry::startReceiving"); #ifdef NDB_OSE_TRANSPORTER if(theOSEReceiver != NULL){ theOSEReceiver->createPhantom(); @@ -1329,26 +1339,34 @@ TransporterRegistry::startReceiving() #ifdef NDB_SHM_TRANSPORTER m_shm_own_pid = getpid(); - struct sigaction sa; - sigemptyset(&sa.sa_mask); - sigaddset(&sa.sa_mask, SIGUSR1); - pthread_sigmask(SIG_UNBLOCK, &sa.sa_mask, 0); - sa.sa_handler = shm_sig_handler; - sigemptyset(&sa.sa_mask); - sa.sa_flags = 0; - int ret; - while((ret = sigaction(SIGUSR1, &sa, 0)) == -1 && errno == EINTR); - if(ret != 0) + if (g_ndb_shm_signum) { - g_eventLogger.error("Failed to install signal handler for SHM transporter" - " errno: %d (%s)", errno, + DBUG_PRINT("info",("Install signal handler for signum %d", + g_ndb_shm_signum)); + struct sigaction sa; + sigemptyset(&sa.sa_mask); + sigaddset(&sa.sa_mask, g_ndb_shm_signum); + pthread_sigmask(SIG_UNBLOCK, &sa.sa_mask, 0); + sa.sa_handler = shm_sig_handler; + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + int ret; + while((ret = sigaction(g_ndb_shm_signum, &sa, 0)) == -1 && errno == EINTR); + if(ret != 0) + { + DBUG_PRINT("error",("Install failed")); + g_eventLogger.error("Failed to install signal handler for" + " SHM transporter errno: %d (%s)", errno, #ifdef HAVE_STRERROR - strerror(errno)); + strerror(errno) #else - ""); + "" #endif + ); + } } -#endif +#endif // NDB_SHM_TRANSPORTER + DBUG_VOID_RETURN; } void diff --git a/ndb/src/cw/cpcd/main.cpp b/ndb/src/cw/cpcd/main.cpp index 300b51d7b5a..25632f132e9 100644 --- a/ndb/src/cw/cpcd/main.cpp +++ b/ndb/src/cw/cpcd/main.cpp @@ -15,7 +15,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include /* Needed for mkdir(2) */ -#include +#include +#include +#include +#include #include "CPCD.hpp" #include "APIService.hpp" diff --git a/ndb/src/kernel/vm/Configuration.cpp b/ndb/src/kernel/vm/Configuration.cpp index 4ad7050ce63..f35a5859ff8 100644 --- a/ndb/src/kernel/vm/Configuration.cpp +++ b/ndb/src/kernel/vm/Configuration.cpp @@ -47,8 +47,7 @@ extern "C" { extern EventLogger g_eventLogger; enum ndbd_options { - NDB_STD_OPTS_OPTIONS, - OPT_INITIAL, + OPT_INITIAL = NDB_STD_OPTIONS_LAST, OPT_NODAEMON }; @@ -82,14 +81,10 @@ static void short_usage_sub(void) { printf("Usage: %s [OPTIONS]\n", my_progname); } -static void print_version() -{ - printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); -} static void usage() { short_usage_sub(); - print_version(); + ndb_std_print_version(); my_print_help(my_long_options); my_print_variables(my_long_options); } @@ -97,18 +92,8 @@ static my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *argument) { - switch (optid) { - case '#': - DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndbd.trace"); - break; - case 'V': - print_version(); - exit(0); - case '?': - usage(); - exit(0); - } - return 0; + return ndb_std_get_one_option(optid, opt, + argument ? argument : "d:t:O,/tmp/ndbd.trace"); } bool diff --git a/ndb/src/mgmclient/main.cpp b/ndb/src/mgmclient/main.cpp index 9417c03805f..73f0bad86c0 100644 --- a/ndb/src/mgmclient/main.cpp +++ b/ndb/src/mgmclient/main.cpp @@ -56,9 +56,6 @@ handler(int sig){ } } -enum ndb_mgm_options { - NDB_STD_OPTS_OPTIONS -}; NDB_STD_OPTS_VARS; static const char default_prompt[]= "ndb_mgm> "; @@ -83,14 +80,10 @@ static void short_usage_sub(void) { printf("Usage: %s [OPTIONS] [hostname [port]]\n", my_progname); } -static void print_version() -{ - printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); -} static void usage() { short_usage_sub(); - print_version(); + ndb_std_print_version(); my_print_help(my_long_options); my_print_variables(my_long_options); } @@ -98,18 +91,8 @@ static my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *argument) { - switch (optid) { - case '#': - DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_mgm.trace"); - break; - case 'V': - print_version(); - exit(0); - case '?': - usage(); - exit(0); - } - return 0; + return ndb_std_get_one_option(optid, opt, argument ? argument : + "d:t:O,/tmp/ndb_mgm.trace"); } static int diff --git a/ndb/src/mgmsrv/ConfigInfo.cpp b/ndb/src/mgmsrv/ConfigInfo.cpp index fa77bc14762..9be4af1b9b5 100644 --- a/ndb/src/mgmsrv/ConfigInfo.cpp +++ b/ndb/src/mgmsrv/ConfigInfo.cpp @@ -15,6 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include +#include #include #include "ConfigInfo.hpp" @@ -1753,6 +1754,18 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "0", STR_VALUE(MAX_INT_RNIL) }, + { + CFG_SHM_SIGNUM, + "Signum", + "SHM", + "Signum to be used for signalling", + ConfigInfo::CI_USED, + false, + ConfigInfo::CI_INT, + UNDEFINED, + "0", + STR_VALUE(MAX_INT_RNIL) }, + { CFG_CONNECTION_NODE_1, "NodeId1", @@ -3178,18 +3191,27 @@ bool fixShmKey(InitConfigFileParser::Context & ctx, const char *) { DBUG_ENTER("fixShmKey"); - Uint32 id1= 0, id2= 0, key= 0; - require(ctx.m_currentSection->get("NodeId1", &id1)); - require(ctx.m_currentSection->get("NodeId2", &id2)); - if(ctx.m_currentSection->get("ShmKey", &key)) { - DBUG_RETURN(true); + Uint32 signum; + if(!ctx.m_currentSection->get("Signum", &signum)) + { + signum= OPT_NDB_SHM_SIGNUM_DEFAULT; + ctx.m_currentSection->put("Signum", signum); + DBUG_PRINT("info",("Added Signum=%u", signum)); + } + } + { + Uint32 id1= 0, id2= 0, key= 0; + require(ctx.m_currentSection->get("NodeId1", &id1)); + require(ctx.m_currentSection->get("NodeId2", &id2)); + if(!ctx.m_currentSection->get("ShmKey", &key)) + { + require(ctx.m_userProperties.get("ShmUniqueId", &key)); + key= key << 16 | (id1 > id2 ? id1 << 8 | id2 : id2 << 8 | id1); + ctx.m_currentSection->put("ShmKey", key); + DBUG_PRINT("info",("Added ShmKey=0x%x", key)); + } } - - require(ctx.m_userProperties.get("ShmUniqueId", &key)); - key= key << 16 | (id1 > id2 ? id1 << 8 | id2 : id2 << 8 | id1); - ctx.m_currentSection->put("ShmKey", key); - DBUG_PRINT("info",("Added ShmKey=0x%x", key)); DBUG_RETURN(true); } diff --git a/ndb/src/mgmsrv/main.cpp b/ndb/src/mgmsrv/main.cpp index ce79ccb732b..61b83b86538 100644 --- a/ndb/src/mgmsrv/main.cpp +++ b/ndb/src/mgmsrv/main.cpp @@ -91,8 +91,7 @@ extern EventLogger g_eventLogger; extern int global_mgmt_server_check; enum ndb_mgmd_options { - NDB_STD_OPTS_OPTIONS, - OPT_INTERACTIVE, + OPT_INTERACTIVE = NDB_STD_OPTIONS_LAST, OPT_NO_NODEID_CHECKS, OPT_NO_DAEMON }; @@ -139,14 +138,10 @@ static void short_usage_sub(void) { printf("Usage: %s [OPTIONS]\n", my_progname); } -static void print_version() -{ - printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); -} static void usage() { short_usage_sub(); - print_version(); + ndb_std_print_version(); my_print_help(my_long_options); my_print_variables(my_long_options); } @@ -154,30 +149,15 @@ static my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *argument) { - switch (optid) { - case '#': - DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_mgmd.trace"); - break; - case 'V': - print_version(); - exit(0); + ndb_std_get_one_option(optid, opt, argument ? argument : + "d:t:O,/tmp/ndb_mgmd.trace"); #if NDB_VERSION_MAJOR <= 4 + switch (optid) { case 'c': printf("Warning: -c will be removed in 5.0, use -f instead\n"); break; -#endif - case OPT_NDB_SHM: -#ifndef NDB_SHM_TRANSPORTER - printf("Warning: binary not compiled with shared memory support,\n" - "use configure option --with-ndb-shm to enable support.\n" - "Tcp connections will now be used instead\n"); - opt_ndb_shm= 0; -#endif - break; - case '?': - usage(); - exit(0); } +#endif return 0; } diff --git a/ndb/tools/delete_all.cpp b/ndb/tools/delete_all.cpp index cdfaf2134ff..21e0c2ac089 100644 --- a/ndb/tools/delete_all.cpp +++ b/ndb/tools/delete_all.cpp @@ -24,9 +24,6 @@ static int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, int parallelism=240); -enum ndb_delete_all { - NDB_STD_OPTS_OPTIONS -}; NDB_STD_OPTS_VARS; static const char* _dbname = "TEST_DB"; @@ -38,16 +35,12 @@ static struct my_option my_long_options[] = GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; -static void print_version() -{ - printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); -} static void usage() { char desc[] = "tabname\n"\ "This program will delete all records in the specified table using scan delete.\n"; - print_version(); + ndb_std_print_version(); my_print_help(my_long_options); my_print_variables(my_long_options); } @@ -55,18 +48,8 @@ static my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *argument) { - switch (optid) { - case '#': - DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_delete_all.trace"); - break; - case 'V': - print_version(); - exit(0); - case '?': - usage(); - exit(0); - } - return 0; + return ndb_std_get_one_option(optid, opt, argument ? argument : + "d:t:O,/tmp/ndb_delete_all.trace"); } int main(int argc, char** argv){ diff --git a/ndb/tools/desc.cpp b/ndb/tools/desc.cpp index 4bca51ee903..4287a771694 100644 --- a/ndb/tools/desc.cpp +++ b/ndb/tools/desc.cpp @@ -19,9 +19,6 @@ #include #include -enum ndb_desc_options { - NDB_STD_OPTS_OPTIONS -}; NDB_STD_OPTS_VARS; static const char* _dbname = "TEST_DB"; @@ -37,17 +34,13 @@ static struct my_option my_long_options[] = GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; -static void print_version() -{ - printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); -} static void usage() { char desc[] = "tabname\n"\ "This program list all properties of table(s) in NDB Cluster.\n"\ - " ex: desc T1 T2 T4\n"; - print_version(); + " ex: desc T1 T2 T4\n"; + ndb_std_print_version(); my_print_help(my_long_options); my_print_variables(my_long_options); } @@ -55,18 +48,8 @@ static my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *argument) { - switch (optid) { - case '#': - DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_desc.trace"); - break; - case 'V': - print_version(); - exit(0); - case '?': - usage(); - exit(0); - } - return 0; + return ndb_std_get_one_option(optid, opt, argument ? argument : + "d:t:O,/tmp/ndb_desc.trace"); } int main(int argc, char** argv){ diff --git a/ndb/tools/drop_index.cpp b/ndb/tools/drop_index.cpp index 2b7f8c1bce9..2fcba41bd11 100644 --- a/ndb/tools/drop_index.cpp +++ b/ndb/tools/drop_index.cpp @@ -21,9 +21,6 @@ #include #include -enum ndb_drop_index_options { - NDB_STD_OPTS_OPTIONS -}; NDB_STD_OPTS_VARS; static const char* _dbname = "TEST_DB"; @@ -35,16 +32,12 @@ static struct my_option my_long_options[] = GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; -static void print_version() -{ - printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); -} static void usage() { char desc[] = "+\n"\ "This program will drop index(es) in Ndb\n"; - print_version(); + ndb_std_print_version(); my_print_help(my_long_options); my_print_variables(my_long_options); } @@ -52,18 +45,8 @@ static my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *argument) { - switch (optid) { - case '#': - DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_drop_index.trace"); - break; - case 'V': - print_version(); - exit(0); - case '?': - usage(); - exit(0); - } - return 0; + return ndb_std_get_one_option(optid, opt, argument ? argument : + "d:t:O,/tmp/ndb_drop_index.trace"); } int main(int argc, char** argv){ diff --git a/ndb/tools/drop_tab.cpp b/ndb/tools/drop_tab.cpp index 2b0b6908449..091db5cc4b7 100644 --- a/ndb/tools/drop_tab.cpp +++ b/ndb/tools/drop_tab.cpp @@ -21,9 +21,6 @@ #include #include -enum ndb_drop_table_options { - NDB_STD_OPTS_OPTIONS -}; NDB_STD_OPTS_VARS; static const char* _dbname = "TEST_DB"; @@ -35,16 +32,12 @@ static struct my_option my_long_options[] = GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; -static void print_version() -{ - printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); -} static void usage() { char desc[] = "tabname\n"\ "This program will drop one table in Ndb\n"; - print_version(); + ndb_std_print_version(); my_print_help(my_long_options); my_print_variables(my_long_options); } @@ -52,18 +45,8 @@ static my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *argument) { - switch (optid) { - case '#': - DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_drop_table.trace"); - break; - case 'V': - print_version(); - exit(0); - case '?': - usage(); - exit(0); - } - return 0; + return ndb_std_get_one_option(optid, opt, argument ? argument : + "d:t:O,/tmp/ndb_drop_table.trace"); } int main(int argc, char** argv){ diff --git a/ndb/tools/listTables.cpp b/ndb/tools/listTables.cpp index 710af66f4de..064ec299ef9 100644 --- a/ndb/tools/listTables.cpp +++ b/ndb/tools/listTables.cpp @@ -161,9 +161,6 @@ list(const char * tabname, } } -enum ndb_show_tables_options { - NDB_STD_OPTS_OPTIONS -}; NDB_STD_OPTS_VARS; static const char* _dbname = "TEST_DB"; @@ -186,20 +183,16 @@ static struct my_option my_long_options[] = GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; -static void print_version() -{ - printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); -} static void usage() { char desc[] = "tabname\n"\ "This program list all system objects in NDB Cluster.\n"\ "Type of objects to display can be limited with -t option\n"\ - " ex: list_tables -t 2 would show all UserTables\n"\ + " ex: ndb_show_tables -t 2 would show all UserTables\n"\ "To show all indexes for a table write table name as final argument\n"\ - " ex: list_tables T1\n"; - print_version(); + " ex: ndb_show_tables T1\n"; + ndb_std_print_version(); my_print_help(my_long_options); my_print_variables(my_long_options); } @@ -207,18 +200,8 @@ static my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *argument) { - switch (optid) { - case '#': - DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_show_tables.trace"); - break; - case 'V': - print_version(); - exit(0); - case '?': - usage(); - exit(0); - } - return 0; + return ndb_std_get_one_option(optid, opt, argument ? argument : + "d:t:O,/tmp/ndb_show_tables.trace"); } int main(int argc, char** argv){ diff --git a/ndb/tools/restore/restore_main.cpp b/ndb/tools/restore/restore_main.cpp index c24ed620b71..84f9511fe2f 100644 --- a/ndb/tools/restore/restore_main.cpp +++ b/ndb/tools/restore/restore_main.cpp @@ -36,9 +36,6 @@ static Vector g_consumers; static const char* ga_backupPath = "." DIR_SEPARATOR; -enum ndb_restore_options { - NDB_STD_OPTS_OPTIONS -}; NDB_STD_OPTS_VARS; /** @@ -101,14 +98,10 @@ static void short_usage_sub(void) { printf("Usage: %s [OPTIONS] []\n", my_progname); } -static void print_version() -{ - printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); -} static void usage() { short_usage_sub(); - print_version(); + ndb_std_print_version(); my_print_help(my_long_options); my_print_variables(my_long_options); } @@ -116,13 +109,9 @@ static my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *argument) { + ndb_std_get_one_option(optid, opt, argument ? argument : + "d:t:O,/tmp/ndb_restore.trace"); switch (optid) { - case '#': - DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_restore.trace"); - break; - case 'V': - print_version(); - exit(0); case 'n': if (ga_nodeId == 0) { @@ -137,9 +126,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), exit(1); } break; - case '?': - usage(); - exit(0); } return 0; } diff --git a/ndb/tools/select_all.cpp b/ndb/tools/select_all.cpp index 9c65750094b..23fd2290349 100644 --- a/ndb/tools/select_all.cpp +++ b/ndb/tools/select_all.cpp @@ -36,9 +36,6 @@ int scanReadRecords(Ndb*, char delim, bool orderby); -enum ndb_select_all_options { - NDB_STD_OPTS_OPTIONS -}; NDB_STD_OPTS_VARS; static const char* _dbname = "TEST_DB"; @@ -72,10 +69,6 @@ static struct my_option my_long_options[] = GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; -static void print_version() -{ - printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); -} static void usage() { char desc[] = @@ -85,7 +78,7 @@ static void usage() "(It only print error messages if it encounters a permanent error.)\n"\ "It can also be used to dump the content of a table to file \n"\ " ex: select_all --no-header --delimiter=';' T4 > T4.data\n"; - print_version(); + ndb_std_print_version(); my_print_help(my_long_options); my_print_variables(my_long_options); } @@ -93,18 +86,8 @@ static my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *argument) { - switch (optid) { - case '#': - DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_select_all.trace"); - break; - case 'V': - print_version(); - exit(0); - case '?': - usage(); - exit(0); - } - return 0; + return ndb_std_get_one_option(optid, opt, argument ? argument : + "d:t:O,/tmp/ndb_select_all.trace"); } int main(int argc, char** argv){ diff --git a/ndb/tools/select_count.cpp b/ndb/tools/select_count.cpp index 516eebda91d..a9a3e71da67 100644 --- a/ndb/tools/select_count.cpp +++ b/ndb/tools/select_count.cpp @@ -32,9 +32,6 @@ select_count(Ndb* pNdb, const NdbDictionary::Table* pTab, int* count_rows, UtilTransactions::ScanLock lock); -enum ndb_select_count_options { - NDB_STD_OPTS_OPTIONS -}; NDB_STD_OPTS_VARS; static const char* _dbname = "TEST_DB"; @@ -54,16 +51,12 @@ static struct my_option my_long_options[] = GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; -static void print_version() -{ - printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); -} static void usage() { char desc[] = "tabname1 ... tabnameN\n"\ "This program will count the number of records in tables\n"; - print_version(); + ndb_std_print_version(); my_print_help(my_long_options); my_print_variables(my_long_options); } @@ -71,18 +64,8 @@ static my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *argument) { - switch (optid) { - case '#': - DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_select_count.trace"); - break; - case 'V': - print_version(); - exit(0); - case '?': - usage(); - exit(0); - } - return 0; + return ndb_std_get_one_option(optid, opt, argument ? argument : + "d:t:O,/tmp/ndb_select_count.trace"); } int main(int argc, char** argv){ diff --git a/ndb/tools/waiter.cpp b/ndb/tools/waiter.cpp index dfdb11524e3..cc6a21428c8 100644 --- a/ndb/tools/waiter.cpp +++ b/ndb/tools/waiter.cpp @@ -31,8 +31,7 @@ waitClusterStatus(const char* _addr, ndb_mgm_node_status _status, unsigned int _timeout); enum ndb_waiter_options { - NDB_STD_OPTS_OPTIONS, - OPT_WAIT_STATUS_NOT_STARTED + OPT_WAIT_STATUS_NOT_STARTED = NDB_STD_OPTIONS_LAST }; NDB_STD_OPTS_VARS; @@ -53,32 +52,20 @@ static struct my_option my_long_options[] = GET_INT, REQUIRED_ARG, 120, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; -static void print_version() -{ - printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); -} + static void usage() { - print_version(); + ndb_std_print_version(); my_print_help(my_long_options); my_print_variables(my_long_options); } + static my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *argument) { - switch (optid) { - case '#': - DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_drop_table.trace"); - break; - case 'V': - print_version(); - exit(0); - case '?': - usage(); - exit(0); - } - return 0; + return ndb_std_get_one_option(optid, opt, argument ? argument : + "d:t:O,/tmp/ndb_drop_table.trace"); } int main(int argc, char** argv){ From 418a06308b6abe8462f5942e0dcf4455fb2073b5 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Jan 2005 02:06:27 +0100 Subject: [PATCH 45/54] Do-compile: ndbcluster requires more ports, this is the reason why builds will not start on multiple builds Build-tools/Do-compile: ndbcluster requires more ports, this is the reason why builds will not start on multiple builds --- Build-tools/Do-compile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Build-tools/Do-compile b/Build-tools/Do-compile index b431f9fc1c5..4034533f2eb 100755 --- a/Build-tools/Do-compile +++ b/Build-tools/Do-compile @@ -155,7 +155,7 @@ $ENV{'MYSQL_TCP_PORT'}= $mysql_tcp_port= 3334 + $opt_build_thread*2; $ENV{'MYSQL_UNIX_PORT'}=$mysql_unix_port="$opt_tmp/mysql$opt_suffix.build"; $ENV{"PERL5LIB"}="$pwd/$host/perl5:$pwd/$host/perl5/site_perl"; $slave_port=$mysql_tcp_port+16; -$ndbcluster_port= 9350 + $opt_build_thread*2; +$ndbcluster_port= 9350 + $opt_build_thread*4; $manager_port=$mysql_tcp_port+1; $mysqladmin_args="--no-defaults -u root --connect_timeout=5 --shutdown_timeout=20"; From bd556f0d709a324f7d33e2ae561164a90b0f04c9 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Jan 2005 09:15:01 +0100 Subject: [PATCH 46/54] NdbThread.c: wrong order in c-file ndb/src/common/portlib/NdbThread.c: wrong order in c-file --- ndb/src/common/portlib/NdbThread.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ndb/src/common/portlib/NdbThread.c b/ndb/src/common/portlib/NdbThread.c index d05fca7aeed..5f2e6021c43 100644 --- a/ndb/src/common/portlib/NdbThread.c +++ b/ndb/src/common/portlib/NdbThread.c @@ -39,14 +39,14 @@ struct NdbThread static void* ndb_thread_wrapper(void* _ss){ - DBUG_ENTER("ndb_thread_wrapper"); void * ret; struct NdbThread * ss = (struct NdbThread *)_ss; + DBUG_ENTER("ndb_thread_wrapper"); #ifdef NDB_SHM_TRANSPORTER if (g_ndb_shm_signum) { - DBUG_PRINT("info",("Block signum %d",g_ndb_shm_signum)); sigset_t mask; + DBUG_PRINT("info",("Block signum %d",g_ndb_shm_signum)); sigemptyset(&mask); sigaddset(&mask, g_ndb_shm_signum); pthread_sigmask(SIG_BLOCK, &mask, 0); From 9b3bfa5f142d412e593134ceac184ededf990e97 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Jan 2005 10:51:30 +0100 Subject: [PATCH 47/54] ndb - fix DATE printout ndb/src/ndbapi/NdbRecAttr.cpp: fix DATE printout --- ndb/src/ndbapi/NdbRecAttr.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/ndb/src/ndbapi/NdbRecAttr.cpp b/ndb/src/ndbapi/NdbRecAttr.cpp index 6749a0f04d9..9c9a9cea8da 100644 --- a/ndb/src/ndbapi/NdbRecAttr.cpp +++ b/ndb/src/ndbapi/NdbRecAttr.cpp @@ -242,12 +242,24 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r) break; case NdbDictionary::Column::Date: { - uint tmp=uint3korr(r.aRef()); - int year=(int) ((uint32) tmp/10000L % 10000); - int month=(int) ((uint32) tmp/100 % 100); - int day=(int) ((uint32) tmp % 100); + uint32 tmp=(uint32) uint3korr(r.aRef()); + int part; char buf[40]; - sprintf(buf, "%04d-%02d-%02d", year, month, day); + char *pos=(char*) buf+10; + *pos--=0; + part=(int) (tmp & 31); + *pos--= (char) ('0'+part%10); + *pos--= (char) ('0'+part/10); + *pos--= '-'; + part=(int) (tmp >> 5 & 15); + *pos--= (char) ('0'+part%10); + *pos--= (char) ('0'+part/10); + *pos--= '-'; + part=(int) (tmp >> 9); + *pos--= (char) ('0'+part%10); part/=10; + *pos--= (char) ('0'+part%10); part/=10; + *pos--= (char) ('0'+part%10); part/=10; + *pos= (char) ('0'+part); out << buf; } break; From 264f83f07612d34c53d3d4e7478d441989997bab Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Jan 2005 12:18:33 +0200 Subject: [PATCH 48/54] InnoDB: Allow concurrent TRUNCATE and INSERT on a table. (Bug #8144) innobase/include/rem0rec.ic: Improve formatting of comments innobase/include/trx0trx.h: dict_operation: document the effect of setting the flag innobase/row/row0mysql.c: Do not set the dict_operation flag. (Bug #8144) Allow MySQL to have open handles to the table being truncated. sql/ha_innodb.cc: store_lock(): Do not weaken TL_WRITE locks taken by TRUNCATE TABLE. --- innobase/include/rem0rec.ic | 4 ++-- innobase/include/trx0trx.h | 4 +++- innobase/row/row0mysql.c | 12 ------------ sql/ha_innodb.cc | 5 +++-- 4 files changed, 8 insertions(+), 17 deletions(-) diff --git a/innobase/include/rem0rec.ic b/innobase/include/rem0rec.ic index ca69b9ca871..366f1c3f77d 100644 --- a/innobase/include/rem0rec.ic +++ b/innobase/include/rem0rec.ic @@ -526,7 +526,7 @@ bits of a record. (Only compact records have status bits.) */ UNIV_INLINE ulint rec_get_info_and_status_bits( -/*==============*/ +/*=========================*/ /* out: info bits */ rec_t* rec, /* in: physical record */ ibool comp) /* in: TRUE=compact page format */ @@ -550,7 +550,7 @@ bits of a record. (Only compact records have status bits.) */ UNIV_INLINE void rec_set_info_and_status_bits( -/*==============*/ +/*=========================*/ rec_t* rec, /* in: physical record */ ibool comp, /* in: TRUE=compact page format */ ulint bits) /* in: info bits */ diff --git a/innobase/include/trx0trx.h b/innobase/include/trx0trx.h index 76b051105de..b63afdd526c 100644 --- a/innobase/include/trx0trx.h +++ b/innobase/include/trx0trx.h @@ -383,7 +383,9 @@ struct trx_struct{ dulint commit_lsn; /* lsn at the time of the commit */ ibool dict_operation; /* TRUE if the trx is used to create a table, create an index, or drop a - table */ + table. This is a hint that the table + may need to be dropped in crash + recovery. */ dulint table_id; /* table id if the preceding field is TRUE */ /*------------------------------*/ diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c index 6aaa0cbcf1b..2c4eebedaf7 100644 --- a/innobase/row/row0mysql.c +++ b/innobase/row/row0mysql.c @@ -2561,17 +2561,6 @@ do not allow the TRUNCATE. We also reserve the data dictionary latch. */ goto funct_exit; } - if (table->n_mysql_handles_opened > 1) { - ut_print_timestamp(stderr); -fputs(" InnoDB: Warning: MySQL is trying to truncate table ", stderr); - ut_print_name(stderr, trx, table->name); - fputs("\n" -"InnoDB: though there are still open handles to it.\n", stderr); - err = DB_ERROR; - - goto funct_exit; - } - /* TODO: could we replace the counter n_foreign_key_checks_running with lock checks on the table? Acquire here an exclusive lock on the table, and rewrite lock0lock.c and the lock wait in srv0srv.c so that @@ -2594,7 +2583,6 @@ fputs(" InnoDB: Warning: MySQL is trying to truncate table ", stderr); lock_reset_all_on_table(table); - trx->dict_operation = TRUE; trx->table_id = table->id; /* scan SYS_INDEXES for all indexes of the table */ diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 18ab6f42d28..01580586bf6 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -5787,11 +5787,12 @@ ha_innobase::store_lock( if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK) { /* If we are not doing a LOCK TABLE or DISCARD/IMPORT - TABLESPACE, then allow multiple writers */ + TABLESPACE or TRUNCATE TABLE, then allow multiple writers */ if ((lock_type >= TL_WRITE_CONCURRENT_INSERT && lock_type <= TL_WRITE) && !thd->in_lock_tables - && !thd->tablespace_op) { + && !thd->tablespace_op + && thd->lex->sql_command != SQLCOM_TRUNCATE) { lock_type = TL_WRITE_ALLOW_WRITE; } From 90904daf139beed0b7636668d40161f0abba783d Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Jan 2005 13:01:00 +0100 Subject: [PATCH 49/54] NdbScanFilter.hpp: added docs ndb/include/ndbapi/NdbScanFilter.hpp: added docs --- ndb/include/ndbapi/NdbScanFilter.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ndb/include/ndbapi/NdbScanFilter.hpp b/ndb/include/ndbapi/NdbScanFilter.hpp index 5f214451321..7c575169dc1 100644 --- a/ndb/include/ndbapi/NdbScanFilter.hpp +++ b/ndb/include/ndbapi/NdbScanFilter.hpp @@ -53,7 +53,7 @@ public: COND_GE = 2, ///< upper bound COND_GT = 3, ///< upper bound, strict COND_EQ = 4, ///< equality - COND_NE = 5 + COND_NE = 5 ///< not equal }; /** From 085f70728768abc2f25ad46a329a6659c17088bc Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Jan 2005 13:49:42 +0100 Subject: [PATCH 50/54] fixed automake problem in dbug/Makefile.am --- dbug/Makefile.am | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dbug/Makefile.am b/dbug/Makefile.am index f8ddf0e6567..a951aff6094 100644 --- a/dbug/Makefile.am +++ b/dbug/Makefile.am @@ -26,6 +26,7 @@ EXTRA_DIST = example1.c example2.c example3.c \ NROFF_INC = example1.r example2.r example3.r main.r \ factorial.r output1.r output2.r output3.r \ output4.r output5.r +CLEANFILES = $(NROFF_INC) user.t user.ps # Must be linked with libs that are not compiled yet @@ -59,8 +60,5 @@ output5.r: factorial @RM@ -f $@ @SED@ -e 's!\\!\\\\!g' $< > $@ -clean: - @RM@ -f $(NROFF_INC) user.t user.ps - # Don't update the files from bitkeeper %::SCCS/s.% From 3c94200db2655ecdbdf434dc853ed539867b53a8 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Jan 2005 19:08:27 +0300 Subject: [PATCH 51/54] A fix: 'information_schema' test with ps-protocol option fails table_list->schema_table_name may be 0 in this case and 'strcasecmp' is not necessary in this case. --- sql/sql_show.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index defa99f3a36..e9126871045 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -3191,9 +3191,10 @@ int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list) views working correctly */ - table->alias_name_used= my_strcasecmp(table_alias_charset, - table_list->schema_table_name, - table_list->alias); + if (table_list->schema_table_name) + table->alias_name_used= my_strcasecmp(table_alias_charset, + table_list->schema_table_name, + table_list->alias); table_list->table_name= (char*) table->s->table_name; table_list->table= table; table->next= thd->derived_tables; From 5c3c40798dce878bd6561b8da6a5e1cbd9f16279 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Jan 2005 17:14:03 +0100 Subject: [PATCH 52/54] small Makefile.am cleanup clean: targets removed generated *.h files moved to include/ Docs/Images/Makefile.am: no clean: targets please! client/Makefile.am: generated *.h files moved to include/ extra/Makefile.am: generated *.h files moved to include/ include/Makefile.am: no clean: targets please! libmysql/Makefile.am: generated *.h files moved to include/ libmysql_r/Makefile.am: generated *.h files moved to include/ libmysqld/Makefile.am: generated *.h files moved to include/ libmysqld/examples/Makefile.am: generated *.h files moved to include/ no clean: target please! ndb/docs/Makefile.am: no clean: targets please! scripts/Makefile.am: SUPERCLEANFILES means nothing server-tools/instance-manager/Makefile.am: generated *.h files moved to include/ sql/Makefile.am: generated *.h files moved to include/ sql/share/Makefile.am: instead of (incorrectly) duplicating comp_err command line, call do make in extra/ tools/Makefile.am: generated *.h files moved to include/ BitKeeper/etc/ignore: Added include/mysqld_ername.h include/mysqld_error.h include/sql_state.h to the ignore list --- .bzrignore | 3 +++ Docs/Images/Makefile.am | 4 ---- client/Makefile.am | 2 +- extra/Makefile.am | 29 ++++++++++++----------- include/Makefile.am | 9 ++----- libmysql/Makefile.am | 2 +- libmysql_r/Makefile.am | 2 +- libmysqld/Makefile.am | 2 +- libmysqld/examples/Makefile.am | 15 +++++------- ndb/docs/Makefile.am | 2 +- scripts/Makefile.am | 2 +- server-tools/instance-manager/Makefile.am | 2 +- sql/Makefile.am | 6 ++--- sql/share/Makefile.am | 5 ++-- tools/Makefile.am | 2 +- 15 files changed, 39 insertions(+), 48 deletions(-) diff --git a/.bzrignore b/.bzrignore index 8a947d63b75..bb1cdb1c0c3 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1052,3 +1052,6 @@ vio/test-ssl vio/test-sslclient vio/test-sslserver vio/viotest-ssl +include/mysqld_ername.h +include/mysqld_error.h +include/sql_state.h diff --git a/Docs/Images/Makefile.am b/Docs/Images/Makefile.am index b57d701d8a0..8ba1ff7382c 100644 --- a/Docs/Images/Makefile.am +++ b/Docs/Images/Makefile.am @@ -27,9 +27,5 @@ EXTRA_DIST = all: : -# Nothing to cleanup in this dummy directory. -clean: - : - # Don't update the files from bitkeeper %::SCCS/s.% diff --git a/client/Makefile.am b/client/Makefile.am index 9b62d698e38..2721953629e 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -18,7 +18,7 @@ #AUTOMAKE_OPTIONS = nostdinc INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/regex \ - $(openssl_includes) -I$(top_srcdir)/extra + $(openssl_includes) -I$(top_builddir)/include LIBS = @CLIENT_LIBS@ LDADD= @CLIENT_EXTRA_LDFLAGS@ \ $(top_builddir)/libmysql/libmysqlclient.la diff --git a/extra/Makefile.am b/extra/Makefile.am index 9f18cbf96e6..43981753515 100644 --- a/extra/Makefile.am +++ b/extra/Makefile.am @@ -16,25 +16,26 @@ INCLUDES = @MT_INCLUDES@ -I$(top_srcdir)/include \ @ndbcluster_includes@ -I$(top_srcdir)/sql \ - -I$(top_srcdir)/extra + -I$(top_builddir)/include LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.a \ ../dbug/libdbug.a ../strings/libmystrings.a -BUILT_SOURCES= mysqld_error.h sql_state.h mysqld_ername.h +BUILT_SOURCES= $(top_builddir)/include/mysqld_error.h \ + $(top_builddir)/include/sql_state.h \ + $(top_builddir)/include/mysqld_ername.h pkginclude_HEADERS= $(BUILT_SOURCES) -created_sources = created_include_files -CLEANFILES = $(created_sources) -SUPERCLEANFILES = $(BUILT_SOURCES) - -all: $(created_sources) +CLEANFILES = $(BUILT_SOURCES) # This will build mysqld_error.h and sql_state.h -mysqld_error.h: created_include_files -mysqld_ername.h: created_include_files -sql_state.h: created_include_files - -created_include_files: comp_err - $(top_builddir)/extra/comp_err --charset=$(srcdir)/../sql/share/charsets --out-dir=$(top_builddir)/sql/share/ --header_file=$(top_builddir)/extra/mysqld_error.h --name_file=$(top_builddir)/extra/mysqld_ername.h --state_file=$(top_builddir)/extra/sql_state.h --in_file=$(srcdir)/../sql/share/errmsg.txt - touch created_include_files +$(top_builddir)/include/mysqld_error.h: comp_err + $(top_builddir)/extra/comp_err \ + --charset=$(top_srcdir)/sql/share/charsets \ + --out-dir=$(top_builddir)/sql/share/ \ + --header_file=$(top_builddir)/include/mysqld_error.h \ + --name_file=$(top_builddir)/include/mysqld_ername.h \ + --state_file=$(top_builddir)/include/sql_state.h \ + --in_file=$(top_srcdir)/sql/share/errmsg.txt +$(top_builddir)/include/mysqld_ername.h: $(top_builddir)/include/mysqld_error.h +$(top_builddir)/include/sql_state.h: $(top_builddir)/include/mysqld_error.h bin_PROGRAMS = replace comp_err perror resolveip my_print_defaults \ resolve_stack_dump mysql_waitpid diff --git a/include/Makefile.am b/include/Makefile.am index e11ca2b4647..08beb4b7236 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -33,15 +33,10 @@ noinst_HEADERS = config-win.h config-os2.h config-netware.h \ mysql_version.h.in my_handler.h my_time.h decimal.h # mysql_version.h are generated -SUPERCLEANFILES = mysql_version.h my_config.h +CLEANFILES = mysql_version.h my_config.h readline # Some include files that may be moved and patched by configure -DISTCLEANFILES = sched.h $(SUPERCLEANFILES) - -clean: - $(RM) -fr readline -distclean: - $(RM) -fr readline +DISTCLEANFILES = sched.h $(CLEANFILES) all-local: my_config.h diff --git a/libmysql/Makefile.am b/libmysql/Makefile.am index 91ee5e66c83..0670a0befa8 100644 --- a/libmysql/Makefile.am +++ b/libmysql/Makefile.am @@ -24,7 +24,7 @@ target = libmysqlclient.la target_defs = -DUNDEF_THREADS_HACK -DDONT_USE_RAID @LIB_EXTRA_CCFLAGS@ LIBS = @CLIENT_LIBS@ INCLUDES = -I$(top_srcdir)/include $(openssl_includes) @ZLIB_INCLUDES@ \ - -I$(top_srcdir)/extra + -I$(top_builddir)/include include $(srcdir)/Makefile.shared diff --git a/libmysql_r/Makefile.am b/libmysql_r/Makefile.am index e8c576ca2b1..b83ee36dd39 100644 --- a/libmysql_r/Makefile.am +++ b/libmysql_r/Makefile.am @@ -26,7 +26,7 @@ LIBS = @LIBS@ @ZLIB_LIBS@ @openssl_libs@ INCLUDES = @MT_INCLUDES@ \ -I$(top_srcdir)/include $(openssl_includes) @ZLIB_INCLUDES@ \ - -I$(top_srcdir)/extra + -I$(top_builddir)/include ## automake barfs if you don't use $(srcdir) or $(top_srcdir) in include include $(top_srcdir)/libmysql/Makefile.shared diff --git a/libmysqld/Makefile.am b/libmysqld/Makefile.am index 4cd53216434..2f90d22f990 100644 --- a/libmysqld/Makefile.am +++ b/libmysqld/Makefile.am @@ -28,7 +28,7 @@ DEFS = -DEMBEDDED_LIBRARY -DMYSQL_SERVER \ INCLUDES= @MT_INCLUDES@ @bdb_includes@ -I$(top_srcdir)/include \ -I$(top_srcdir)/sql -I$(top_srcdir)/sql/examples \ -I$(top_srcdir)/regex \ - -I$(top_srcdir)/extra \ + -I$(top_builddir)/include \ $(openssl_includes) @ZLIB_INCLUDES@ noinst_LIBRARIES = libmysqld_int.a diff --git a/libmysqld/examples/Makefile.am b/libmysqld/examples/Makefile.am index d70d7330e55..bd18e7154aa 100644 --- a/libmysqld/examples/Makefile.am +++ b/libmysqld/examples/Makefile.am @@ -1,7 +1,8 @@ -noinst_PROGRAMS = mysql -bin_PROGRAMS = mysqltest_embedded mysql_client_test_embedded -client_sources = $(mysqltest_embedded_SOURCES) $(mysql_SOURCES) -tests_sources= $(mysql_client_test_embedded_SOURCES) +noinst_PROGRAMS = mysql +bin_PROGRAMS = mysqltest_embedded mysql_client_test_embedded +client_sources = $(mysqltest_embedded_SOURCES) $(mysql_SOURCES) +tests_sources = $(mysql_client_test_embedded_SOURCES) +CLEANFILES = $(client_sources) $(tests_sources) link_sources: for f in $(client_sources); do \ @@ -16,7 +17,7 @@ link_sources: DEFS = -DEMBEDDED_LIBRARY INCLUDES = @MT_INCLUDES@ -I$(top_srcdir)/include -I$(srcdir) \ -I$(top_srcdir) -I$(top_srcdir)/client -I$(top_srcdir)/regex \ - -I$(top_srcdir)/extra $(openssl_includes) + -I$(top_builddir)/include $(openssl_includes) LIBS = @LIBS@ @WRAPLIBS@ @CLIENT_LIBS@ LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysqld.a @innodb_system_libs@ @LIBDL@ $(CXXLDFLAGS) @@ -31,9 +32,5 @@ mysql_LDADD = @readline_link@ @TERMCAP_LIB@ $(LDADD) mysql_client_test_embedded_LINK = $(CXXLINK) mysql_client_test_embedded_SOURCES = mysql_client_test.c -clean: - rm -f $(client_sources) - rm -f $(tests_sources) - # Don't update the files from bitkeeper %::SCCS/s.% diff --git a/ndb/docs/Makefile.am b/ndb/docs/Makefile.am index 6d4cdc12cf6..1f00d463f08 100644 --- a/ndb/docs/Makefile.am +++ b/ndb/docs/Makefile.am @@ -9,7 +9,7 @@ DOXYOUT = .doxyout NDB_RELEASE = @NDB_VERSION_MAJOR@.@NDB_VERSION_MINOR@.@NDB_VERSION_BUILD@-@NDB_VERSION_STATUS@ -clean: +clean-local: rm -rf ndbapi.pdf ndbapi.html mgmapi.pdf mgmapi.html rm -rf $(DOXYTMP) $(DOXYOUT) diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 71b70fc0e4a..221fab13635 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -90,7 +90,7 @@ CLEANFILES = @server_scripts@ \ fill_help_tables \ mysql_create_system_tables -SUPERCLEANFILES = mysqlbug +DISTCLEANFILES = mysqlbug # We want the right version and configure comand line in mysqlbug mysqlbug: ${top_builddir}/config.status mysqlbug.sh diff --git a/server-tools/instance-manager/Makefile.am b/server-tools/instance-manager/Makefile.am index c2bf501eca7..c9c9009a8ec 100644 --- a/server-tools/instance-manager/Makefile.am +++ b/server-tools/instance-manager/Makefile.am @@ -14,7 +14,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -INCLUDES= -I$(top_srcdir)/include -I$(top_srcdir)/extra +INCLUDES= -I$(top_srcdir)/include -I$(top_builddir)/include DEFS= -DMYSQL_INSTANCE_MANAGER -DMYSQL_SERVER diff --git a/sql/Makefile.am b/sql/Makefile.am index 8ff55898ba4..3c520ac971c 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -22,7 +22,7 @@ MYSQLBASEdir= $(prefix) INCLUDES = @MT_INCLUDES@ @ZLIB_INCLUDES@ \ @bdb_includes@ @innodb_includes@ @ndbcluster_includes@ \ -I$(top_srcdir)/include -I$(top_srcdir)/regex \ - -I$(srcdir) $(openssl_includes) -I$(top_srcdir)/extra + -I$(srcdir) $(openssl_includes) -I$(top_builddir)/include WRAPLIBS= @WRAPLIBS@ SUBDIRS = share libexec_PROGRAMS = mysqld @@ -115,6 +115,7 @@ DEFS = -DMYSQL_SERVER \ # Don't put lex_hash.h in BUILT_SOURCES as this will give infinite recursion BUILT_SOURCES = sql_yacc.cc sql_yacc.h EXTRA_DIST = udf_example.cc $(BUILT_SOURCES) +DISTCLEANFILES = lex_hash.h AM_YFLAGS = -d mysql_tzinfo_to_sql.cc: @@ -160,8 +161,5 @@ sql_lex.o: lex_hash.h udf_example.so: udf_example.cc $(CXXCOMPILE) -shared -o $@ $< -distclean: - rm -f lex_hash.h - # Don't update the files from bitkeeper %::SCCS/s.% diff --git a/sql/share/Makefile.am b/sql/share/Makefile.am index cfbbb36c489..608bbdb7ae6 100644 --- a/sql/share/Makefile.am +++ b/sql/share/Makefile.am @@ -14,10 +14,11 @@ dist-hook: all: english/errmsg.sys # Use the english errmsg.sys as a flag that all errmsg.sys needs to be -# created. Normally these are created by extra/Makefile.am +# created. Normally these are created by extra/Makefile english/errmsg.sys: errmsg.txt - $(top_builddir)/extra/comp_err --charset=$(srcdir)/charsets --out-dir=$(top_builddir)/sql/share/ --header_file=$(top_builddir)/extra/mysqld_error.h --state_file=$(top_builddir)/extra/sql_state.h --in_file=errmsg.txt + rm $(top_builddir)/include/mysqld_error.h + (cd $(top_builddir)/extra && $(MAKE)) install-data-local: for lang in @AVAILABLE_LANGUAGES@; \ diff --git a/tools/Makefile.am b/tools/Makefile.am index 55801c22c48..1cb07f85e5a 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -16,7 +16,7 @@ # Process this file with automake to create Makefile.in INCLUDES=@MT_INCLUDES@ -I$(top_srcdir)/include $(openssl_includes) \ - -I$(top_srcdir)/extra + -I$(top_builddir)/include LDADD= @CLIENT_EXTRA_LDFLAGS@ @openssl_libs@ \ $(top_builddir)/libmysql_r/libmysqlclient_r.la @ZLIB_LIBS@ bin_PROGRAMS= mysqlmanager From 158020b79651e47fff47887442793bf319a85e57 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Jan 2005 19:03:07 +0100 Subject: [PATCH 53/54] there's no need to define UNIV_DEBUG explicitly anymore --- configure.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index 124e1ce3dcc..b2d8d65439d 100644 --- a/configure.in +++ b/configure.in @@ -1674,8 +1674,8 @@ then elif test "$with_debug" = "full" then # Full debug. Very slow in some cases - CFLAGS="$DEBUG_CFLAGS -DDBUG_ON -DSAFE_MUTEX -DSAFEMALLOC -DUNIV_DEBUG $CFLAGS" - CXXFLAGS="$DEBUG_CXXFLAGS -DDBUG_ON -DSAFE_MUTEX -DSAFEMALLOC -DUNIV_DEBUG $CXXFLAGS" + CFLAGS="$DEBUG_CFLAGS -DDBUG_ON -DSAFE_MUTEX -DSAFEMALLOC $CFLAGS" + CXXFLAGS="$DEBUG_CXXFLAGS -DDBUG_ON -DSAFE_MUTEX -DSAFEMALLOC $CXXFLAGS" else # Optimized version. No debug CFLAGS="$OPTIMIZE_CFLAGS -DDBUG_OFF $CFLAGS" From dde53fbb96b70090b5b7cd44026be577a94dc100 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Jan 2005 19:28:14 +0100 Subject: [PATCH 54/54] ndb_opt_defaults.h: removed usage of SIGRTMIN temorarilly as it causes problems on some platforms ndb/include/ndbapi/ndb_opt_defaults.h: removed usage of SIGRTMIN temorarilly as it causes problems on some platforms BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- BitKeeper/etc/logging_ok | 1 + ndb/include/ndbapi/ndb_opt_defaults.h | 4 ---- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index fe2a38f29bf..6f99987bd9b 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -241,6 +241,7 @@ tonu@x153.internalnet tonu@x3.internalnet tsmith@build.mysql.com tulin@build.mysql.com +tulin@mysql.com ulli@morbus.(none) venu@hundin.mysql.fi venu@myvenu.com diff --git a/ndb/include/ndbapi/ndb_opt_defaults.h b/ndb/include/ndbapi/ndb_opt_defaults.h index 63b673ed60d..d03a9dcc36f 100644 --- a/ndb/include/ndbapi/ndb_opt_defaults.h +++ b/ndb/include/ndbapi/ndb_opt_defaults.h @@ -17,11 +17,7 @@ #ifndef NDB_OPT_DEFAULTS_H #define NDB_OPT_DEFAULTS_H -#ifdef SIGRTMIN -#define OPT_NDB_SHM_SIGNUM_DEFAULT SIGRTMIN+2 -#else #define OPT_NDB_SHM_SIGNUM_DEFAULT 0 -#endif #define OPT_NDB_SHM_DEFAULT 0 #endif