diff options
-rw-r--r-- | Docs/mysqld_error.txt | 142 | ||||
-rw-r--r-- | client/mysqlcheck.c | 3 | ||||
-rw-r--r-- | libmysql/libmysql.c | 24 | ||||
-rw-r--r-- | mysql-test/r/analyse.result | 65 | ||||
-rw-r--r-- | mysql-test/r/bdb.result | 2 | ||||
-rw-r--r-- | mysql-test/r/ctype_ujis.result | 19 | ||||
-rw-r--r-- | mysql-test/r/func_str.result | 11 | ||||
-rw-r--r-- | mysql-test/r/isam.result | 6 | ||||
-rw-r--r-- | mysql-test/r/key.result | 16 | ||||
-rw-r--r-- | mysql-test/r/key_primary.result | 2 | ||||
-rw-r--r-- | mysql-test/r/null_key.result | 2 | ||||
-rw-r--r-- | mysql-test/r/repair.result | 2 | ||||
-rw-r--r-- | mysql-test/r/subselect.result | 8 | ||||
-rw-r--r-- | mysql-test/t/analyse.test | 23 | ||||
-rw-r--r-- | mysql-test/t/ctype_ujis.test | 12 | ||||
-rw-r--r-- | mysql-test/t/func_str.test | 18 | ||||
-rw-r--r-- | mysql-test/t/key.test | 12 | ||||
-rw-r--r-- | sql/item.cc | 5 | ||||
-rw-r--r-- | sql/sql_acl.cc | 3 | ||||
-rw-r--r-- | sql/sql_base.cc | 5 | ||||
-rw-r--r-- | sql/sql_load.cc | 6 | ||||
-rw-r--r-- | sql/sql_parse.cc | 1 | ||||
-rw-r--r-- | sql/sql_prepare.cc | 7 | ||||
-rw-r--r-- | sql/sql_select.cc | 20 | ||||
-rw-r--r-- | sql/sql_table.cc | 2 | ||||
-rw-r--r-- | sql/sql_update.cc | 4 | ||||
-rw-r--r-- | tests/client_test.c | 33 |
27 files changed, 343 insertions, 110 deletions
diff --git a/Docs/mysqld_error.txt b/Docs/mysqld_error.txt index e567d5676aa..c164e8bd3a0 100644 --- a/Docs/mysqld_error.txt +++ b/Docs/mysqld_error.txt @@ -142,11 +142,11 @@ character-set=latin1 #define ER_MULTIPLE_PRI_KEY 1068 "Multiple primary key defined", #define ER_TOO_MANY_KEYS 1069 -"Too many keys specified. Max %d keys allowed", +"Too many keys specified; max %d keys allowed", #define ER_TOO_MANY_KEY_PARTS 1070 "Too many key parts specified. Max %d parts allowed", #define ER_TOO_LONG_KEY 1071 -"Specified key was too long. Max key length is %d", +"Specified key was too long; max key length is %d bytes", #define ER_KEY_COLUMN_DOES_NOT_EXITS 1072 "Key column '%-.64s' doesn't exist in table", #define ER_BLOB_USED_AS_KEY 1073 @@ -406,7 +406,7 @@ character-set=latin1 #define ER_BAD_SLAVE 1200 "The server is not configured as slave, fix in config file or with CHANGE MASTER TO", #define ER_MASTER_INFO 1201 -"Could not initialize master info structure, check permisions on master.info", +"Could not initialize master info structure, more error messages can be found in the MySQL error log", #define ER_SLAVE_THREAD 1202 "Could not create slave thread, check system resources", #define ER_TOO_MANY_USER_CONNECTIONS 1203 @@ -460,7 +460,7 @@ character-set=latin1 #define ER_SPECIFIC_ACCESS_DENIED_ERROR 1227 "Access denied. You need the %-.128s privilege for this operation", #define ER_LOCAL_VARIABLE 1228 -"Variable '%-.64s' is a LOCAL variable and can't be used with SET GLOBAL", +"Variable '%-.64s' is a SESSION variable and can't be used with SET GLOBAL", #define ER_GLOBAL_VARIABLE 1229 "Variable '%-.64s' is a GLOBAL variable and should be set with SET GLOBAL", #define ER_NO_DEFAULT 1230 @@ -479,95 +479,119 @@ character-set=latin1 "Got fatal error %d: '%-.128s' from master when reading data from binary log", #define ER_SLAVE_IGNORED_TABLE 1237 "Slave SQL thread ignored the query because of replicate-*-table rules", -#define ER_WRONG_FK_DEF 1238 +#define ER_INCORRECT_GLOBAL_LOCAL_VAR 1238 +"Variable '%-.64s' is a %s variable", +#define ER_WRONG_FK_DEF 1239 "Wrong foreign key definition for '%-.64s': %s", -#define ER_KEY_REF_DO_NOT_MATCH_TABLE_REF 1239 +#define ER_KEY_REF_DO_NOT_MATCH_TABLE_REF 1240 "Key reference and table reference doesn't match", -#define ER_OPERAND_COLUMNS 1240 +#define ER_OPERAND_COLUMNS 1241 "Operand should contain %d column(s)", -#define ER_SUBQUERY_NO_1_ROW 1241 +#define ER_SUBQUERY_NO_1_ROW 1242 "Subquery returns more than 1 row", -#define ER_UNKNOWN_STMT_HANDLER 1242 +#define ER_UNKNOWN_STMT_HANDLER 1243 "Unknown prepared statement handler (%ld) given to %s", -#define ER_CORRUPT_HELP_DB 1243 +#define ER_CORRUPT_HELP_DB 1244 "Help database is corrupt or does not exist", -#define ER_CYCLIC_REFERENCE 1244 +#define ER_CYCLIC_REFERENCE 1245 "Cyclic reference on subqueries", -#define ER_AUTO_CONVERT 1245 +#define ER_AUTO_CONVERT 1246 "Converting column '%s' from %s to %s", -#define ER_ILLEGAL_REFERENCE 1246 +#define ER_ILLEGAL_REFERENCE 1247 "Reference '%-.64s' not supported (%s)", -#define ER_DERIVED_MUST_HAVE_ALIAS 1247 +#define ER_DERIVED_MUST_HAVE_ALIAS 1248 "Every derived table must have it's own alias", -#define ER_SELECT_REDUCED 1248 +#define ER_SELECT_REDUCED 1249 "Select %u was reduced during optimisation", -#define ER_TABLENAME_NOT_ALLOWED_HERE 1249 +#define ER_TABLENAME_NOT_ALLOWED_HERE 1250 "Table '%-.64s' from one of SELECT's can not be used in %-.32s", -#define ER_NOT_SUPPORTED_AUTH_MODE 1250 +#define ER_NOT_SUPPORTED_AUTH_MODE 1251 "Client does not support authentication protocol requested by server; consider upgrading MySQL client", -#define ER_SPATIAL_CANT_HAVE_NULL 1251 +#define ER_SPATIAL_CANT_HAVE_NULL 1252 "All parts of a SPATIAL KEY must be NOT NULL", -#define ER_COLLATION_CHARSET_MISMATCH 1252 +#define ER_COLLATION_CHARSET_MISMATCH 1253 "COLLATION '%s' is not valid for CHARACTER SET '%s'", -#define ER_SLAVE_WAS_RUNNING 1253 +#define ER_SLAVE_WAS_RUNNING 1254 "Slave is already running", -#define ER_SLAVE_WAS_NOT_RUNNING 1254 +#define ER_SLAVE_WAS_NOT_RUNNING 1255 "Slave has already been stopped", -#define ER_TOO_BIG_FOR_UNCOMPRESS 1255 +#define ER_TOO_BIG_FOR_UNCOMPRESS 1256 "Too big size of uncompressed data. The maximum size is %d. (probably, length of uncompressed data was corrupted)", -#define ER_ZLIB_Z_MEM_ERROR 1256 -"ZLIB: Not enough memory available for zlib", -#define ER_ZLIB_Z_BUF_ERROR 1257 -"ZLIB: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)", -#define ER_ZLIB_Z_DATA_ERROR 1258 -"ZLIB: Input data was corrupted for zlib", -#define ER_CUT_VALUE_GROUP_CONCAT 1259 +#define ER_ZLIB_Z_MEM_ERROR 1257 +"ZLIB: Not enough memory", +#define ER_ZLIB_Z_BUF_ERROR 1258 +"ZLIB: Not enough room in the output buffer (probably, length of uncompressed data was corrupted)", +#define ER_ZLIB_Z_DATA_ERROR 1259 +"ZLIB: Input data corrupted", +#define ER_CUT_VALUE_GROUP_CONCAT 1260 "%d line(s) was(were) cut by group_concat()", -#define ER_WARN_TOO_FEW_RECORDS 1260 -"Record count is fewer than the column count at row %ld"; -#define ER_WARN_TOO_MANY_RECORDS 1261 -"Record count is more than the column count at row %ld"; -#define ER_WARN_NULL_TO_NOTNULL 1262 -"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld"; -#define ER_WARN_DATA_OUT_OF_RANGE 1263 -"Data truncated, out of range for column '%s' at row %ld"; -#define ER_WARN_DATA_TRUNCATED 1264 +#define ER_WARN_TOO_FEW_RECORDS 1261 +"Row %ld doesn't contain data for all columns", +#define ER_WARN_TOO_MANY_RECORDS 1262 +"Row %ld was truncated; It contained more data than there were input columns", +#define ER_WARN_NULL_TO_NOTNULL 1263 +"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld", +#define ER_WARN_DATA_OUT_OF_RANGE 1264 +"Data truncated, out of range for column '%s' at row %ld", +#define ER_WARN_DATA_TRUNCATED 1265 "Data truncated for column '%s' at row %ld", -#define ER_WARN_USING_OTHER_HANDLER 1265 +#define ER_WARN_USING_OTHER_HANDLER 1266 "Using storage engine %s for table '%s'", -#define ER_CANT_AGGREGATE_2COLLATIONS 1266 +#define ER_CANT_AGGREGATE_2COLLATIONS 1267 "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", -#define ER_DROP_USER 1267 +#define ER_DROP_USER 1268 "Can't drop one or more of the requested users", -#define ER_REVOKE_GRANTS 1268 +#define ER_REVOKE_GRANTS 1269 "Can't revoke all privileges, grant for one or more of the requested users", -#define ER_CANT_AGGREGATE_3COLLATIONS 1269 +#define ER_CANT_AGGREGATE_3COLLATIONS 1270 "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", -#define ER_CANT_AGGREGATE_NCOLLATIONS 1270 +#define ER_CANT_AGGREGATE_NCOLLATIONS 1271 "Illegal mix of collations for operation '%s'", -#define ER_VARIABLE_IS_NOT_STRUCT 1271 +#define ER_VARIABLE_IS_NOT_STRUCT 1272 "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", -#define ER_UNKNOWN_COLLATION 1272 +#define ER_UNKNOWN_COLLATION 1273 "Unknown collation: '%-.64s'", -#define ER_SLAVE_IGNORED_SSL_PARAMS 1273 -"SSL parameters in CHANGE MASTER are ignored because this MySQL slave was compiled without SSL support. They can be used later when MySQL slave with SSL will be started.", -#define ER_SERVER_IS_IN_SECURE_AUTH_MODE 1274 -"Server is running in --secure-auth mode, but '%s@%s' has a password in the old format; please change the password to the new format", -#define ER_WARN_FIELD_RESOLVED 1275 +#define ER_SLAVE_IGNORED_SSL_PARAMS 1274 +"SSL parameters in CHANGE MASTER are ignored because this MySQL slave was compiled without SSL support; they can be used later when MySQL slave with SSL will be started", +#define ER_SERVER_IS_IN_SECURE_AUTH_MODE 1275 +"Server is running in --secure-auth mode, but '%s'@'%s' has a password in the old format; please change the password to the new format", +#define ER_WARN_FIELD_RESOLVED 1276 "Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d", -#define ER_BAD_SLAVE_UNTIL_COND 1276 +#define ER_BAD_SLAVE_UNTIL_COND 1277 "Wrong parameter or combination of parameters for START SLAVE UNTIL", -#define ER_MISSING_SKIP_SLAVE 1277 +#define ER_MISSING_SKIP_SLAVE 1278 "It is recommended to use --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL. Otherwise you will get problems if you get an unexpected slave's mysqld restart", -#define ER_UNTIL_COND_IGNORED 1278 +#define ER_UNTIL_COND_IGNORED 1279 "SQL thread is not to be started so UNTIL options are ignored", -#define ER_WRONG_NAME_FOR_INDEX 1279 +#define ER_WRONG_NAME_FOR_INDEX 1280 "Incorrect index name '%-.100s'", -#define ER_WRONG_NAME_FOR_CATALOG 1280 +#define ER_WRONG_NAME_FOR_CATALOG 1281 "Incorrect catalog name '%-.100s'", -#define ER_WARN_QC_RESIZE 1281 +#define ER_WARN_QC_RESIZE 1282 "Query cache failed to set size %lu, new query cache size is %lu", -#define ER_BAD_FT_COLUMN 1282 +#define ER_BAD_FT_COLUMN 1283 "Column '%-.64s' cannot be part of FULLTEXT index", -#define ER_UNKNOWN_KEY_CACHE 1283 +#define ER_UNKNOWN_KEY_CACHE 1284 "Unknown key cache '%-.100s'", +#define ER_WARN_HOSTNAME_WONT_WORK 1285 +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", +#define ER_UNKNOWN_STORAGE_ENGINE 1286 +"Unknown table engine '%s'", +#define ER_WARN_DEPRECATED_SYNTAX 1287 +"'%s' is deprecated, use '%s' instead", +#define ER_NON_UPDATABLE_TABLE 1288 +"The target table %-.100s of the %s is not updatable", +#define ER_FEATURE_DISABLED 1289 +"The '%s' feature was disabled; you need MySQL built with '%s' to have it working", +#define ER_OPTION_PREVENTS_STATEMENT 1290 +"The MySQL server is running with the %s option so it cannot execute this statement", +#define ER_DUPLICATED_VALUE_IN_TYPE 1291 +"Column '%-.100s' has duplicated value '%-.64s' in %s" +#define ER_TRUNCATED_WRONG_VALUE 1292 +"Truncated wrong %-.32s value: '%-.128s'" +#define ER_TOO_MUCH_AUTO_TIMESTAMP_COLS 1293 +"Incorrect table definition; There can only be one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause" +#define ER_INVALID_ON_UPDATE 1294 +"Invalid ON UPDATE clause for '%-.64s' field", +#define ER_UNSUPPORTED_PS 1295 +"This command is not supported in the prepared statement protocol yet", diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 03ab45957d4..aa4c1282cc1 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -576,7 +576,8 @@ static void print_result() else if (!status && changed) { printf("%s\n%-9s: %s", row[0], row[2], row[3]); - found_error=1; + if (strcmp(row[2],"note")) + found_error=1; } else printf("%-9s: %s", row[2], row[3]); diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 83346f46c5e..6ee2ba438bd 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -2929,10 +2929,12 @@ static uint read_binary_date(MYSQL_TIME *tm, uchar **pos) } /* Convert Numeric to buffer types */ -static void send_data_long(MYSQL_BIND *param, longlong value) +static void send_data_long(MYSQL_BIND *param, MYSQL_FIELD *field, + longlong value) { char *buffer= param->buffer; - + uint field_is_unsigned= (field->flags & UNSIGNED_FLAG); + switch (param->buffer_type) { case MYSQL_TYPE_NULL: /* do nothing */ break; @@ -2950,20 +2952,24 @@ static void send_data_long(MYSQL_BIND *param, longlong value) break; case MYSQL_TYPE_FLOAT: { - float data= (float)value; + float data= (field_is_unsigned ? (float) ulonglong2double(value) : + (float) value); float4store(buffer, data); break; } case MYSQL_TYPE_DOUBLE: { - double data= (double)value; + double data= (field_is_unsigned ? ulonglong2double(value) : + (double) value); float8store(buffer, data); break; } default: { char tmp[22]; /* Enough for longlong */ - uint length= (uint)(longlong10_to_str(value,(char *)tmp,10)-tmp); + uint length= (uint)(longlong10_to_str(value,(char *)tmp, + field_is_unsigned ? 10: -10) - + tmp); ulong copy_length= min((ulong)length-param->offset, param->buffer_length); if ((long) copy_length < 0) copy_length=0; @@ -3170,7 +3176,7 @@ static void fetch_results(MYSQL_BIND *param, MYSQL_FIELD *field, uchar **row) uint field_is_unsigned= (field->flags & UNSIGNED_FLAG); longlong data= ((field_is_unsigned) ? (longlong) (unsigned char) value: (longlong) value); - send_data_long(param,data); + send_data_long(param, field, data); length= 1; break; } @@ -3181,7 +3187,7 @@ static void fetch_results(MYSQL_BIND *param, MYSQL_FIELD *field, uchar **row) uint field_is_unsigned= (field->flags & UNSIGNED_FLAG); longlong data= ((field_is_unsigned) ? (longlong) (unsigned short) value: (longlong) value); - send_data_long(param,data); + send_data_long(param, field, data); length= 2; break; } @@ -3191,14 +3197,14 @@ static void fetch_results(MYSQL_BIND *param, MYSQL_FIELD *field, uchar **row) uint field_is_unsigned= (field->flags & UNSIGNED_FLAG); longlong data= ((field_is_unsigned) ? (longlong) (unsigned long) value: (longlong) value); - send_data_long(param,data); + send_data_long(param, field, data); length= 4; break; } case MYSQL_TYPE_LONGLONG: { longlong value= (longlong)sint8korr(*row); - send_data_long(param,value); + send_data_long(param, field, value); length= 8; break; } diff --git a/mysql-test/r/analyse.result b/mysql-test/r/analyse.result index f18b925460c..b51afab5b54 100644 --- a/mysql-test/r/analyse.result +++ b/mysql-test/r/analyse.result @@ -31,3 +31,68 @@ EXPLAIN SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY <derived2> system NULL NULL NULL NULL 1 2 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used +create table t1 (a int not null); +create table t2 select * from t1 where 0=1 procedure analyse(); +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `Field_name` char(255) NOT NULL default '', + `Min_value` char(255) default NULL, + `Max_value` char(255) default NULL, + `Min_length` bigint(11) NOT NULL default '0', + `Max_length` bigint(11) NOT NULL default '0', + `Empties_or_zeros` bigint(11) NOT NULL default '0', + `Nulls` bigint(11) NOT NULL default '0', + `Avg_value_or_avg_length` char(255) NOT NULL default '', + `Std` char(255) default NULL, + `Optimal_fieldtype` char(64) NOT NULL default '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select * from t1 where 0=1 procedure analyse(); +Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype +insert into t1 values(1); +drop table t2; +create table t2 select * from t1 where 0=1 procedure analyse(); +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `Field_name` char(255) NOT NULL default '', + `Min_value` char(255) default NULL, + `Max_value` char(255) default NULL, + `Min_length` bigint(11) NOT NULL default '0', + `Max_length` bigint(11) NOT NULL default '0', + `Empties_or_zeros` bigint(11) NOT NULL default '0', + `Nulls` bigint(11) NOT NULL default '0', + `Avg_value_or_avg_length` char(255) NOT NULL default '', + `Std` char(255) default NULL, + `Optimal_fieldtype` char(64) NOT NULL default '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select * from t2; +Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype +insert into t2 select * from t1 procedure analyse(); +select * from t2; +Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype +test.t1.a 1 1 1 1 0 0 1.0000 0.0000 ENUM('1') NOT NULL +insert into t1 values(2); +drop table t2; +create table t2 select * from t1 where 0=1 procedure analyse(); +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `Field_name` char(255) NOT NULL default '', + `Min_value` char(255) default NULL, + `Max_value` char(255) default NULL, + `Min_length` bigint(11) NOT NULL default '0', + `Max_length` bigint(11) NOT NULL default '0', + `Empties_or_zeros` bigint(11) NOT NULL default '0', + `Nulls` bigint(11) NOT NULL default '0', + `Avg_value_or_avg_length` char(255) NOT NULL default '', + `Std` char(255) default NULL, + `Optimal_fieldtype` char(64) NOT NULL default '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select * from t2; +Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype +insert into t2 select * from t1 procedure analyse(); +select * from t2; +Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype +test.t1.a 1 2 1 1 0 0 1.5000 0.5000 ENUM('1','2') NOT NULL +drop table t1,t2; diff --git a/mysql-test/r/bdb.result b/mysql-test/r/bdb.result index bee40eac30d..a544bbbf0b7 100644 --- a/mysql-test/r/bdb.result +++ b/mysql-test/r/bdb.result @@ -203,7 +203,7 @@ a 2 check table t1; Table Op Msg_type Msg_text -test.t1 check error The storage engine for the table doesn't support check +test.t1 check note The storage engine for the table doesn't support check drop table t1; create table t1 (a int,b varchar(20)) engine=bdb; insert into t1 values (1,""), (2,"testing"); diff --git a/mysql-test/r/ctype_ujis.result b/mysql-test/r/ctype_ujis.result index b66ede3bed4..cc062094535 100644 --- a/mysql-test/r/ctype_ujis.result +++ b/mysql-test/r/ctype_ujis.result @@ -92,3 +92,22 @@ select @ujis3 = CONVERT(@utf83 USING ujis); select @ujis4 = CONVERT(@utf84 USING ujis); @ujis4 = CONVERT(@utf84 USING ujis) 1 +drop table if exists t1; +Warnings: +Note 1051 Unknown table 't1' +create table t1 (c1 varchar(8)) default character set 'ujis'; +insert into t1 values (0xA4A2),(0xA2A2),(0xA4A2); +select c1 as 'no index' from t1 where c1 like cast(concat(0xA4A2, '%') as char character set ujis); +no index +あ +あ +create index idx_c1 on t1(c1); +select c1 as 'using index' from t1 where c1 like cast(concat(0xA4A2, '%') as char character set ujis); +using index +あ +あ +select c1 as 'no index' from t1 where c1 like cast(concat('%',0xA4A2, '%') as char character set ujis); +no index +あ +あ +drop table t1; diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index d3225679b3e..bdba9e4c3e4 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -639,3 +639,14 @@ name aaaaaaaaaaccccc bbbbbbbbbbddddd drop table t1, t2; +create table t1 (c1 INT); +insert into t1 (c1) values ('21474836461'); +Warnings: +Warning 1265 Data truncated for column 'c1' at row 1 +show warnings; +Level Code Message +Warning 1265 Data truncated for column 'c1' at row 1 +select * from t1; +c1 +2147483647 +drop table t1; diff --git a/mysql-test/r/isam.result b/mysql-test/r/isam.result index 4c698075150..2c7b3a4a568 100644 --- a/mysql-test/r/isam.result +++ b/mysql-test/r/isam.result @@ -49,14 +49,14 @@ test.t1 optimize status OK check table t1,t2; Table Op Msg_type Msg_text test.t1 check status OK -test.t2 check error The storage engine for the table doesn't support check +test.t2 check note The storage engine for the table doesn't support check repair table t1,t2; Table Op Msg_type Msg_text test.t1 repair status OK -test.t2 repair error The storage engine for the table doesn't support repair +test.t2 repair note The storage engine for the table doesn't support repair check table t2,t1; Table Op Msg_type Msg_text -test.t2 check error The storage engine for the table doesn't support check +test.t2 check note The storage engine for the table doesn't support check test.t1 check status OK lock tables t1 write; check table t2,t1; diff --git a/mysql-test/r/key.result b/mysql-test/r/key.result index 115f15bacb6..b8387389075 100644 --- a/mysql-test/r/key.result +++ b/mysql-test/r/key.result @@ -206,3 +206,19 @@ select i from t1 where b=repeat(_utf8 'b',310); i 1 drop table t1; +CREATE TABLE t1 (id int unsigned auto_increment, name char(50), primary key (id)) engine=myisam; +insert into t1 (name) values ('a'), ('b'),('c'),('d'),('e'),('f'),('g'); +explain select 1 from t1 where id =2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index +explain select 1 from t1 where id =2 or id=3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where; Using index +explain select name from t1 where id =2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 +ALTER TABLE t1 DROP PRIMARY KEY, ADD INDEX (id); +explain select 1 from t1 where id =2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref id id 4 const 1 Using where; Using index +drop table t1; diff --git a/mysql-test/r/key_primary.result b/mysql-test/r/key_primary.result index 14ca90b3dd2..7726a8e1d63 100644 --- a/mysql-test/r/key_primary.result +++ b/mysql-test/r/key_primary.result @@ -13,7 +13,7 @@ t1 AB% describe select * from t1 where t1="ABC"; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 const PRIMARY PRIMARY 3 const 1 +1 SIMPLE t1 const PRIMARY PRIMARY 3 const 1 Using index describe select * from t1 where t1="ABCD"; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables diff --git a/mysql-test/r/null_key.result b/mysql-test/r/null_key.result index 4dfd17991cc..e57ac321f46 100644 --- a/mysql-test/r/null_key.result +++ b/mysql-test/r/null_key.result @@ -12,7 +12,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref a,b a 9 const,const 1 Using where; Using index explain select * from t1 where a=2 and b = 2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 const a,b a 9 const,const 1 +1 SIMPLE t1 const a,b a 9 const,const 1 Using index explain select * from t1 where a<=>b limit 2; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL a 9 NULL 12 Using where; Using index diff --git a/mysql-test/r/repair.result b/mysql-test/r/repair.result index f81bbd063ea..dbca5c39a6c 100644 --- a/mysql-test/r/repair.result +++ b/mysql-test/r/repair.result @@ -7,7 +7,7 @@ test.t1 repair status OK alter table t1 ENGINE=HEAP; repair table t1 use_frm; Table Op Msg_type Msg_text -test.t1 repair error The storage engine for the table doesn't support repair +test.t1 repair note The storage engine for the table doesn't support repair drop table t1; create table t1(id int PRIMARY KEY, st varchar(10), KEY st_key(st)); insert into t1 values(1, "One"); diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 32770614221..a6e5d90b6c4 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -357,10 +357,10 @@ INSERT INTO t8 (pseudo,email) VALUES ('joce1','test1'); INSERT INTO t8 (pseudo,email) VALUES ('2joce1','2test1'); EXPLAIN EXTENDED SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce')) FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t8 const PRIMARY PRIMARY 35 const 1 -4 SUBQUERY t8 const PRIMARY PRIMARY 35 1 +1 PRIMARY t8 const PRIMARY PRIMARY 35 const 1 Using index +4 SUBQUERY t8 const PRIMARY PRIMARY 35 1 Using index 2 SUBQUERY t8 const PRIMARY PRIMARY 35 const 1 -3 SUBQUERY t8 const PRIMARY PRIMARY 35 1 +3 SUBQUERY t8 const PRIMARY PRIMARY 35 1 Using index Warnings: Note 1003 select high_priority test.t8.pseudo AS `pseudo`,(select test.t8.email AS `email` from test.t8 where (test.t8.pseudo = (select test.t8.pseudo AS `pseudo` from test.t8 where (test.t8.pseudo = _latin1'joce')))) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from test.t8 where (test.t8.pseudo = (select test.t8.pseudo AS `pseudo` from test.t8 where (test.t8.pseudo = _latin1'joce'))) SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM @@ -537,7 +537,7 @@ Warnings: Note 1003 select high_priority max(test.t1.numreponse) AS `MAX(numreponse)` from test.t1 where (test.t1.numeropost = _latin1'1') EXPLAIN EXTENDED SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT MAX(numreponse) FROM t1 WHERE numeropost='1'); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 +1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 Using index 2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away Warnings: Note 1003 select high_priority test.t1.numreponse AS `numreponse` from test.t1 where ((test.t1.numeropost = _latin1'1') and (test.t1.numreponse = 3)) diff --git a/mysql-test/t/analyse.test b/mysql-test/t/analyse.test index 6aca345b282..47f3473584b 100644 --- a/mysql-test/t/analyse.test +++ b/mysql-test/t/analyse.test @@ -15,3 +15,26 @@ select * from t2; drop table t1,t2; EXPLAIN SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(); + +# +# Test with impossible where +# +create table t1 (a int not null); +create table t2 select * from t1 where 0=1 procedure analyse(); +show create table t2; +select * from t1 where 0=1 procedure analyse(); +insert into t1 values(1); +drop table t2; +create table t2 select * from t1 where 0=1 procedure analyse(); +show create table t2; +select * from t2; +insert into t2 select * from t1 procedure analyse(); +select * from t2; +insert into t1 values(2); +drop table t2; +create table t2 select * from t1 where 0=1 procedure analyse(); +show create table t2; +select * from t2; +insert into t2 select * from t1 procedure analyse(); +select * from t2; +drop table t1,t2; diff --git a/mysql-test/t/ctype_ujis.test b/mysql-test/t/ctype_ujis.test index abfded5a6c2..6281f2a4249 100644 --- a/mysql-test/t/ctype_ujis.test +++ b/mysql-test/t/ctype_ujis.test @@ -61,3 +61,15 @@ select @ujis2 = CONVERT(@utf82 USING ujis); select @ujis3 = CONVERT(@utf83 USING ujis); select @ujis4 = CONVERT(@utf84 USING ujis); +# +# Testing with '%' and index (Bug #3438) +# + +drop table if exists t1; +create table t1 (c1 varchar(8)) default character set 'ujis'; +insert into t1 values (0xA4A2),(0xA2A2),(0xA4A2); +select c1 as 'no index' from t1 where c1 like cast(concat(0xA4A2, '%') as char character set ujis); +create index idx_c1 on t1(c1); +select c1 as 'using index' from t1 where c1 like cast(concat(0xA4A2, '%') as char character set ujis); +select c1 as 'no index' from t1 where c1 like cast(concat('%',0xA4A2, '%') as char character set ujis); +drop table t1; diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index 1c85f83baac..7efcac030af 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -358,21 +358,19 @@ select substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2),substring_index("1abcd explain extended select md5('hello'), sha('abc'), sha1('abc'), soundex(''), 'mood' sounds like 'mud', aes_decrypt(aes_encrypt('abc','1'),'1'),concat('*',space(5),'*'), reverse('abc'), rpad('a',4,'1'), lpad('a',4,'1'), concat_ws(',','',NULL,'a'),make_set(255,_latin2'a',_latin2'b',_latin2'c'),elt(2,1),locate("a","b",2),format(130,10),char(0),conv(130,16,10),hex(130),binary 'HE', export_set(255,_latin2'y',_latin2'n',_latin2' '),FIELD('b' COLLATE latin1_bin,'A','B'),FIND_IN_SET(_latin1'B',_latin1'a,b,c,d'),collation(conv(130,16,10)), coercibility(conv(130,16,10)),length('\n\t\r\b\0\_\%\\'),bit_length('\n\t\r\b\0\_\%\\'),bit_length('\n\t\r\b\0\_\%\\'),concat('monty',' was here ','again'),length('hello'),char(ascii('h')),ord('h'),quote(1/0),crc32("123"),replace('aaaa','a','b'),insert('txs',2,1,'hi'),left(_latin2'a',1),right(_latin2'a',1),lcase(_latin2'a'),ucase(_latin2'a'),SUBSTR('abcdefg',3,2),substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2),trim(_latin2' a '),ltrim(_latin2' a '),rtrim(_latin2' a '), decode(encode(repeat("a",100000),"monty"),"monty"); # -# Bug #2182 +# lpad returns incorrect result (Bug #2182) # SELECT lpad(12345, 5, "#"); # -# Bug #2972 +# Problem the the CONV() function (Bug #2972) # SELECT conv(71, 10, 36), conv('1Z', 36, 10); - - # -# Bug #3089 +# Bug in SUBSTRING when mixed with CONCAT and ORDER BY (Bug #3089) # create table t1 (id int(1), str varchar(10)) DEFAULT CHARSET=utf8; @@ -382,3 +380,13 @@ insert into t2 values (1,'cccccccccc'), (2,'dddddddddd'); select substring(concat(t1.str, t2.str), 1, 15) "name" from t1, t2 where t2.id=t1.id order by name; drop table t1, t2; + +# +# Test case for conversion of long string value to integer (Bug #3472) +# + +create table t1 (c1 INT); +insert into t1 (c1) values ('21474836461'); +show warnings; +select * from t1; +drop table t1; diff --git a/mysql-test/t/key.test b/mysql-test/t/key.test index cdaf6062771..4fa85477318 100644 --- a/mysql-test/t/key.test +++ b/mysql-test/t/key.test @@ -204,3 +204,15 @@ select i from t1 where a=repeat(_utf8 0xD0B1,200); select i from t1 where b=repeat(_utf8 'b',310); drop table t1; +# +# Test of key read with primary key (Bug #3497) +# + +CREATE TABLE t1 (id int unsigned auto_increment, name char(50), primary key (id)) engine=myisam; +insert into t1 (name) values ('a'), ('b'),('c'),('d'),('e'),('f'),('g'); +explain select 1 from t1 where id =2; +explain select 1 from t1 where id =2 or id=3; +explain select name from t1 where id =2; +ALTER TABLE t1 DROP PRIMARY KEY, ADD INDEX (id); +explain select 1 from t1 where id =2; +drop table t1; diff --git a/sql/item.cc b/sql/item.cc index 44a05c42526..e1cdfcf42c0 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1259,15 +1259,16 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table) void Item_field::make_field(Send_field *tmp_field) { field->make_field(tmp_field); + DBUG_ASSERT(tmp_field->table_name); if (name) tmp_field->col_name=name; // Use user supplied name } + /* -** Set a field:s value from a item + Set a field:s value from a item */ - void Item_field::save_org_in_field(Field *to) { if (field->is_null()) diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 72a68af54c0..f8dca1133cc 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1560,7 +1560,8 @@ end: { acl_cache->clear(1); // Clear privilege cache if (old_row_exists) - acl_update_user(combo.user.str, combo.host.str, password, password_len, + acl_update_user(combo.user.str, combo.host.str, + combo.password.str, password_len, thd->lex->ssl_type, thd->lex->ssl_cipher, thd->lex->x509_issuer, diff --git a/sql/sql_base.cc b/sql/sql_base.cc index d24b13ff96f..75c7a779180 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1029,14 +1029,15 @@ bool reopen_table(TABLE *table,bool locked) *table=tmp; table->file->change_table_ptr(table); + DBUG_ASSERT(table->table_name); for (field=table->field ; *field ; field++) { - (*field)->table=table; + (*field)->table= (*field)->orig_table= table; (*field)->table_name=table->table_name; } for (key=0 ; key < table->keys ; key++) for (part=0 ; part < table->key_info[key].usable_key_parts ; part++) - table->key_info[key].key_part[part].field->table=table; + table->key_info[key].key_part[part].field->table= table; VOID(pthread_cond_broadcast(&COND_refresh)); error=0; diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 3d9299ca05c..f72fab9ea3a 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -529,8 +529,8 @@ read_sep_field(THD *thd,COPY_INFO &info,TABLE *table, if (field->type() == FIELD_TYPE_TIMESTAMP) ((Field_timestamp*) field)->set_time(); else if (field != table->next_number_field) - field->set_warning((uint)MYSQL_ERROR::WARN_LEVEL_WARN, - ER_WARN_NULL_TO_NOTNULL); + field->set_warning((uint) MYSQL_ERROR::WARN_LEVEL_WARN, + ER_WARN_NULL_TO_NOTNULL); } continue; } @@ -1014,7 +1014,7 @@ bool READ_INFO::find_start_of_fields() { // Can't be line_start PUSH(chr); while (--ptr != line_start_ptr) - { // Restart with next char + { // Restart with next char PUSH((uchar) *ptr); } goto try_again; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index a69c048a918..0eb95f1cf64 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1424,6 +1424,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, } case COM_EXECUTE: { + thd->free_list= NULL; mysql_stmt_execute(thd, packet, packet_length); break; } diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 6e4a748a67a..d1cdbe56602 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1498,9 +1498,7 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length) thd->stmt_backup.set_statement(thd); thd->set_statement(stmt); - reset_stmt_for_execute(stmt); - #ifndef EMBEDDED_LIBRARY if (stmt->param_count) { @@ -1540,6 +1538,11 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length) reset_stmt_params(stmt); close_thread_tables(thd); // to close derived tables thd->set_statement(&thd->stmt_backup); + /* + Free Items that were created during this execution of the PS by query + optimizer. + */ + free_items(thd->free_list); DBUG_VOID_RETURN; set_params_data_err: diff --git a/sql/sql_select.cc b/sql/sql_select.cc index f850c2ac270..ffc52817322 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -3634,6 +3634,12 @@ make_join_readinfo(JOIN *join, uint options) table->status=STATUS_NO_RECORD; tab->read_first_record= join_read_const; tab->read_record.read_record= join_no_more_records; + if (table->used_keys.is_set(tab->index) && + !table->no_keyread) + { + table->key_read=1; + table->file->extra(HA_EXTRA_KEYREAD); + } break; case JT_EQ_REF: table->status=STATUS_NO_RECORD; @@ -4120,11 +4126,6 @@ return_zero_rows(JOIN *join, select_result *result,TABLE_LIST *tables, DBUG_RETURN(0); } - if (procedure) - { - if (result->prepare(fields, unit)) // This hasn't been done yet - DBUG_RETURN(-1); - } if (send_row) { for (TABLE_LIST *table=tables; table ; table=table->next) @@ -5962,6 +5963,12 @@ join_read_const_table(JOIN_TAB *tab, POSITION *pos) } else { + if (!table->key_read && table->used_keys.is_set(tab->index) && + !table->no_keyread) + { + table->key_read=1; + table->file->extra(HA_EXTRA_KEYREAD); + } if ((error=join_read_const(tab))) { tab->info="unique row not found"; @@ -9227,7 +9234,8 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, join->best_positions[i]. records_read, 21)); my_bool key_read=table->key_read; - if (tab->type == JT_NEXT && table->used_keys.is_set(tab->index)) + if ((tab->type == JT_NEXT || tab->type == JT_CONST) && + table->used_keys.is_set(tab->index)) key_read=1; if (tab->info) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index c46a9823a52..0d0be1b7e10 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1759,7 +1759,7 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables, char buf[ERRMSGSIZE+20]; uint length=my_snprintf(buf, ERRMSGSIZE, ER(ER_CHECK_NOT_IMPLEMENTED), operator_name); - protocol->store("error", 5, system_charset_info); + protocol->store("note", 4, system_charset_info); protocol->store(buf, length, system_charset_info); } break; diff --git a/sql/sql_update.cc b/sql/sql_update.cc index d985d2c2e78..3ae4ecad1e6 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -461,9 +461,7 @@ int mysql_multi_update(THD *thd, int res; multi_update *result; TABLE_LIST *tl; - TABLE_LIST *update_list= - (TABLE_LIST*)thd->lex->select_lex.table_list.first; - + TABLE_LIST *update_list= (TABLE_LIST*) thd->lex->select_lex.table_list.first; table_map item_tables= 0, derived_tables= 0; DBUG_ENTER("mysql_multi_update"); diff --git a/tests/client_test.c b/tests/client_test.c index e7f30526c84..30caa5f1505 100644 --- a/tests/client_test.c +++ b/tests/client_test.c @@ -9239,8 +9239,7 @@ static void test_bug3035() { MYSQL_STMT *stmt; int rc; - - MYSQL_BIND bind_array[8]; + MYSQL_BIND bind_array[12]; int8 int8_val; uint8 uint8_val; int16 int16_val; @@ -9249,6 +9248,8 @@ static void test_bug3035() uint32 uint32_val; longlong int64_val; ulonglong uint64_val; + double double_val, udouble_val; + char longlong_as_string[22],ulonglong_as_string[22]; /* mins and maxes */ const int8 int8_min= -128; @@ -9267,11 +9268,11 @@ static void test_bug3035() const uint32 uint32_max= 4294967295U; /* it might not work okay everyplace */ - const longlong int64_max= 9223372036854775807LL; + const longlong int64_max= LL(9223372036854775807); const longlong int64_min= -int64_max - 1; const ulonglong uint64_min= 0U; - const ulonglong uint64_max= 18446744073709551615ULL; + const ulonglong uint64_max= ULL(18446744073709551615); const char *stmt_text; @@ -9353,7 +9354,7 @@ static void test_bug3035() mysql_stmt_execute(stmt); check_execute(stmt, rc); - stmt_text= "SELECT i8, ui8, i16, ui16, i32, ui32, i64, ui64 " + stmt_text= "SELECT i8, ui8, i16, ui16, i32, ui32, i64, ui64, ui64, cast(ui64 as signed),ui64, cast(ui64 as signed)" "FROM t1 ORDER BY id ASC"; mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); @@ -9362,6 +9363,20 @@ static void test_bug3035() mysql_stmt_execute(stmt); check_execute(stmt, rc); + bind_array[8].buffer_type= MYSQL_TYPE_DOUBLE; + bind_array[8].buffer= (char*) &udouble_val; + + bind_array[9].buffer_type= MYSQL_TYPE_DOUBLE; + bind_array[9].buffer= (char*) &double_val; + + bind_array[10].buffer_type= MYSQL_TYPE_STRING; + bind_array[10].buffer= (char*) &ulonglong_as_string; + bind_array[10].buffer_length= sizeof(ulonglong_as_string); + + bind_array[11].buffer_type= MYSQL_TYPE_STRING; + bind_array[11].buffer= (char*) &longlong_as_string; + bind_array[11].buffer_length= sizeof(longlong_as_string); + mysql_stmt_bind_result(stmt, bind_array); rc= mysql_stmt_fetch(stmt); @@ -9375,6 +9390,10 @@ static void test_bug3035() assert(uint32_val == uint32_min); assert(int64_val == int64_min); assert(uint64_val == uint64_min); + assert(double_val == (longlong) uint64_min); + assert(udouble_val == ulonglong2double(uint64_val)); + assert(!strcmp(longlong_as_string, "0")); + assert(!strcmp(ulonglong_as_string, "0")); rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); @@ -9387,6 +9406,10 @@ static void test_bug3035() assert(uint32_val == uint32_max); assert(int64_val == int64_max); assert(uint64_val == uint64_max); + assert(double_val == (longlong) uint64_val); + assert(udouble_val == ulonglong2double(uint64_val)); + assert(!strcmp(longlong_as_string, "-1")); + assert(!strcmp(ulonglong_as_string, "18446744073709551615")); rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); |