From 3e1a47070518a1995cc48e28c36b7c817d5f6008 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov <Georgi.Kodinov@Oracle.com> Date: Fri, 25 Jun 2010 15:59:44 +0300 Subject: Bug #53095: SELECT column_name FROM INFORMATION_SCHEMA.STATISTICS returns nothing When looking for table or database names inside INFORMATION_SCHEMA we must convert the table and database names to lowercase (just as it's done in the rest of the server) when lowercase_table_names is non-zero. This will allow us to find the same tables that we would find if there is no condition. Fixed by converting to lower case when extracting the database and table name conditions. Test case added. --- sql/sql_show.cc | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) (limited to 'sql/sql_show.cc') diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 33abf356718..0eeb333f278 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2690,36 +2690,54 @@ bool get_lookup_field_values(THD *thd, COND *cond, TABLE_LIST *tables, { LEX *lex= thd->lex; const char *wild= lex->wild ? lex->wild->ptr() : NullS; + bool rc= 0; + bzero((char*) lookup_field_values, sizeof(LOOKUP_FIELD_VALUES)); switch (lex->sql_command) { case SQLCOM_SHOW_DATABASES: if (wild) { - lookup_field_values->db_value.str= (char*) wild; - lookup_field_values->db_value.length= strlen(wild); + thd->make_lex_string(&lookup_field_values->db_value, + wild, strlen(wild), 0); lookup_field_values->wild_db_value= 1; } - return 0; + break; case SQLCOM_SHOW_TABLES: case SQLCOM_SHOW_TABLE_STATUS: case SQLCOM_SHOW_TRIGGERS: case SQLCOM_SHOW_EVENTS: - lookup_field_values->db_value.str= lex->select_lex.db; - lookup_field_values->db_value.length=strlen(lex->select_lex.db); + thd->make_lex_string(&lookup_field_values->db_value, + lex->select_lex.db, strlen(lex->select_lex.db), 0); if (wild) { - lookup_field_values->table_value.str= (char*)wild; - lookup_field_values->table_value.length= strlen(wild); + thd->make_lex_string(&lookup_field_values->table_value, + wild, strlen(wild), 0); lookup_field_values->wild_table_value= 1; } - return 0; + break; default: /* The "default" is for queries over I_S. All previous cases handle SHOW commands. */ - return calc_lookup_values_from_cond(thd, cond, tables, lookup_field_values); + rc= calc_lookup_values_from_cond(thd, cond, tables, lookup_field_values); + break; } + + if (lower_case_table_names && !rc) + { + /* + We can safely do in-place upgrades here since all of the above cases + are allocating a new memory buffer for these strings. + */ + if (lookup_field_values->db_value.str && lookup_field_values->db_value.str[0]) + my_casedn_str(system_charset_info, lookup_field_values->db_value.str); + if (lookup_field_values->table_value.str && + lookup_field_values->table_value.str[0]) + my_casedn_str(system_charset_info, lookup_field_values->table_value.str); + } + + return rc; } @@ -3324,6 +3342,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) error= 0; goto err; } + DBUG_PRINT("INDEX VALUES",("db_name='%s', table_name='%s'", STR_OR_NIL(lookup_field_vals.db_value.str), STR_OR_NIL(lookup_field_vals.table_value.str))); -- cgit v1.2.1 From d9e7c4efb6bfebf625af629b3ca878f1d0dc7e02 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov <Georgi.Kodinov@Oracle.com> Date: Wed, 7 Jul 2010 12:15:58 +0300 Subject: Addendum to the fix for bug #53095 (failing information_schema.test on windows) Since the original fix for this bug lowercases the search pattern it's not a good idea to copy the search pattern to the output instead of the real table name found (since, depending on the case mode these two names may differ in case). Fixed the infrmation_schema.test failure by making sure the actual table name of an inoformation schema table is passed instead of the lookup pattern even when the pattern doesn't contain wildcards. --- sql/sql_show.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'sql/sql_show.cc') diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 0eeb333f278..17fbf62b097 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2939,11 +2939,15 @@ make_table_name_list(THD *thd, List<LEX_STRING> *table_names, LEX *lex, { if (with_i_schema) { + LEX_STRING *name; ST_SCHEMA_TABLE *schema_table= find_schema_table(thd, lookup_field_vals->table_value.str); if (schema_table && !schema_table->hidden) { - if (table_names->push_back(&lookup_field_vals->table_value)) + if (!(name= + thd->make_lex_string(NULL, schema_table->table_name, + strlen(schema_table->table_name), TRUE)) || + table_names->push_back(name)) return 1; } } -- cgit v1.2.1 From 11fae04527098cb6c266eae41188504bd22a5b52 Mon Sep 17 00:00:00 2001 From: Davi Arnaut <Davi.Arnaut@Sun.COM> Date: Fri, 9 Jul 2010 09:00:17 -0300 Subject: Bug#45288: pb2 returns a lot of compilation warnings on linux Although the C standard mandates that sprintf return the number of bytes written, some very ancient systems (i.e. SunOS 4) returned a pointer to the buffer instead. Since these systems are not supported anymore and are hopefully long dead by now, simply remove the portability wrapper that dealt with this discrepancy. The autoconf check was causing trouble with GCC. --- sql/sql_show.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/sql_show.cc') diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 17fbf62b097..ca0d16697cd 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2278,7 +2278,7 @@ static bool show_status_array(THD *thd, const char *wild, value= ((char *) status_var + (ulong) value); /* fall through */ case SHOW_DOUBLE: - end= buff + my_sprintf(buff, (buff, "%f", *(double*) value)); + end= buff + sprintf(buff, "%f", *(double*) value); break; case SHOW_LONG_STATUS: value= ((char *) status_var + (ulong) value); -- cgit v1.2.1 From f317d3a6fb413cfc04c1ed005df8e859664e41d5 Mon Sep 17 00:00:00 2001 From: Davi Arnaut <Davi.Arnaut@Sun.COM> Date: Wed, 14 Jul 2010 09:27:13 -0300 Subject: Bug#42733: Type-punning warnings when compiling MySQL -- strict aliasing violations. Another rather noisy violation of strict aliasing rules is the spatial code which makes use of stack-based memory (of type Geometry_buffer) to provide placement for Geometry objects. Although a placement new is allowed to dynamically change the type of a object, the object returned by the new placement was being ignored and the original stack-based object was being casted to the new type, thus violating strict aliasing rules. The solution is to reorganize the code so that the object returned by the new placement is used instead of casting the original object. Also, to ensure that the stack-based object is properly aligned with respect to the objects it provides placement for, a set of compiler-dependent macros and types are introduced so that the alignment of objects can be inquired and specified. include/Makefile.am: Add new header. include/my_compiler.h: Add new header. include/my_global.h: Remove now-unnecessary macros. sql/spatial.cc: Make object creation functions return the object whose type was dynamically changed by the new placement. Move static method from the header in order to avoid having to access a forward declaration. sql/spatial.h: Object creation callbacks now take a array of chars as the storage area. Move create_by_typeid to a source file as to not access the forward declaration of Geometry_buffer. Ensure that Geometry_buffer is properly aligned. sql/sql_show.cc: Use newly added aligned storage helper. --- sql/sql_show.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sql/sql_show.cc') diff --git a/sql/sql_show.cc b/sql/sql_show.cc index ca0d16697cd..091bd09aa25 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2202,8 +2202,8 @@ static bool show_status_array(THD *thd, const char *wild, bool ucase_names, COND *cond) { - MY_ALIGNED_BYTE_ARRAY(buff_data, SHOW_VAR_FUNC_BUFF_SIZE, long); - char * const buff= (char *) &buff_data; + my_aligned_storage<SHOW_VAR_FUNC_BUFF_SIZE, MY_ALIGNOF(long)> buffer; + char * const buff= buffer.data; char *prefix_end; /* the variable name should not be longer than 64 characters */ char name_buffer[64]; -- cgit v1.2.1 From 25bfbf684c0fefe658f6244e1f2cf23dd0246eae Mon Sep 17 00:00:00 2001 From: Georgi Kodinov <Georgi.Kodinov@Oracle.com> Date: Wed, 23 Jun 2010 19:25:31 +0300 Subject: Bug #53814: NUMERIC_PRECISION for unsigned bigint field is 19, should be 20 Fixed the numeric precision of the unsigned BIGINT column to be 20 instead of 19. --- sql/sql_show.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sql/sql_show.cc') diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 091bd09aa25..d0e76e501e2 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -3965,10 +3965,13 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables, case MYSQL_TYPE_TINY: case MYSQL_TYPE_SHORT: case MYSQL_TYPE_LONG: - case MYSQL_TYPE_LONGLONG: case MYSQL_TYPE_INT24: field_length= field->max_display_length() - 1; break; + case MYSQL_TYPE_LONGLONG: + field_length= field->max_display_length() - + ((field->flags & UNSIGNED_FLAG) ? 0 : 1); + break; case MYSQL_TYPE_BIT: field_length= field->max_display_length(); decimals= -1; // return NULL -- cgit v1.2.1 From 9a5fa17fd3c4885262e31bf14cf495d02e5f6b27 Mon Sep 17 00:00:00 2001 From: Davi Arnaut <davi.arnaut@oracle.com> Date: Tue, 20 Jul 2010 15:07:36 -0300 Subject: Bug#45288: pb2 returns a lot of compilation warnings on linux Fix warnings flagged by the new warning option -Wunused-but-set-variable that was added to GCC 4.6 and that is enabled by -Wunused and -Wall. The option causes a warning whenever a local variable is assigned to but is later unused. It also warns about meaningless pointer dereferences. client/mysql.cc: Meaningless pointer dereferences. client/mysql_upgrade.c: Check whether reading from the file succeeded. extra/comp_err.c: Unused. extra/yassl/src/yassl_imp.cpp: Skip instead of reading data that is discarded. include/my_pthread.h: Variable is only used in debug builds. include/mysys_err.h: Add new error messages. mysys/errors.c: Add new error message for permission related functions. mysys/mf_iocache.c: Variable is only checked under THREAD. mysys/my_copy.c: Raise a error if chmod or chown fails. mysys/my_redel.c: Raise a error if chmod or chown fails. regex/engine.c: Use a equivalent variable for the assert. server-tools/instance-manager/instance_options.cc: Unused. sql/field.cc: Unused. sql/item.cc: Unused. sql/log.cc: Do not ignore the return value of freopen: only set buffer if reopening succeeds. Adjust doxygen comment to the right function. Pass message lenght to log function. sql/mysqld.cc: Do not ignore the return value of freopen: only set buffer if reopening succeeds. sql/partition_info.cc: Unused. sql/slave.cc: No need to set pointer to the address of '\0'. sql/spatial.cc: Unused. Left for historical purposes. sql/sql_acl.cc: Unused. sql/sql_base.cc: Pointers are always set to the same variables. sql/sql_parse.cc: End statement if reading fails. Store the buffer after it has actually been updated. sql/sql_repl.cc: No need to set pointer to the address of '\0'. sql/sql_show.cc: Put variable under the same ifdef block. sql/udf_example.c: Set null pointer flag appropriately. storage/csv/ha_tina.cc: Meaningless dereferences. storage/example/ha_example.cc: Return the error since it's available. storage/myisam/mi_locking.c: Remove unused and dead code. --- sql/sql_show.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'sql/sql_show.cc') diff --git a/sql/sql_show.cc b/sql/sql_show.cc index d0e76e501e2..eb5d3a1965d 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -3868,7 +3868,6 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables, uint flags=field->flags; char tmp[MAX_FIELD_WIDTH]; String type(tmp,sizeof(tmp), system_charset_info); - char *end; int decimals, field_length; if (wild && wild[0] && @@ -3889,7 +3888,7 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables, field->field_name) & COL_ACLS; if (!tables->schema_table && !col_access) continue; - end= tmp; + char *end= tmp; for (uint bitnr=0; col_access ; col_access>>=1,bitnr++) { if (col_access & 1) @@ -4015,7 +4014,6 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables, table->field[15]->store((const char*) pos, strlen((const char*) pos), cs); - end= tmp; if (field->unireg_check == Field::NEXT_NUMBER) table->field[16]->store(STRING_WITH_LEN("auto_increment"), cs); if (show_table->timestamp_field == field && -- cgit v1.2.1 From e24abd9091ce28a27f27073ab70aed94851362bc Mon Sep 17 00:00:00 2001 From: Georgi Kodinov <Georgi.Kodinov@Oracle.com> Date: Wed, 21 Jul 2010 18:05:57 +0300 Subject: Addendum #4 to bug #53095 SHOW DATABASES LIKE ... was not converting to lowercase on comparison as the documentation is suggesting. Fixed it to behave similarly to SHOW TABLES LIKE ... and updated the failing on MacOSX lowercase_table2 test case. --- sql/sql_show.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'sql/sql_show.cc') diff --git a/sql/sql_show.cc b/sql/sql_show.cc index eb5d3a1965d..616bced8f4a 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -521,8 +521,19 @@ find_files(THD *thd, List<LEX_STRING> *files, const char *db, continue; file_name_len= filename_to_tablename(file->name, uname, sizeof(uname)); - if (wild && wild_compare(uname, wild, 0)) - continue; + if (wild) + { + if (lower_case_table_names) + { + if (my_wildcmp(files_charset_info, + uname, uname + file_name_len, + wild, wild + wild_length, + wild_prefix, wild_one,wild_many)) + continue; + } + else if (wild_compare(uname, wild, 0)) + continue; + } if (!(file_name= thd->make_lex_string(file_name, uname, file_name_len, TRUE))) { -- cgit v1.2.1 From e9a52f962f2d89fe1938145105bcb35f970a2414 Mon Sep 17 00:00:00 2001 From: unknown <kevin.lewis@oracle.com> Date: Thu, 22 Jul 2010 11:15:15 -0500 Subject: Bug#49542 - Do as the comment suggests and downgrade directory errors from find_file() to a warning unless they happen during a SHOW command. --- sql/sql_show.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'sql/sql_show.cc') diff --git a/sql/sql_show.cc b/sql/sql_show.cc index eb5d3a1965d..c979d44dc1c 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1,4 +1,4 @@ -/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. +/* Copyright 2000, 2010 Oracle and/or its affiliates. All rights reserved. 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 @@ -9,9 +9,9 @@ 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 */ + 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., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* Function with list databases, tables or fields */ @@ -2986,7 +2986,7 @@ make_table_name_list(THD *thd, List<LEX_STRING> *table_names, LEX *lex, */ if (res == FIND_FILES_DIR) { - if (lex->sql_command != SQLCOM_SELECT) + if (sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND) return 1; thd->clear_error(); return 2; -- cgit v1.2.1