You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1894 lines
54 KiB

WL#1622 "SQL Syntax for Prepared Statements": Post-review fixes (1 of 2) mysql-test/r/ps.result: Added tests for PREPARE stmt1 FROM @var syntax mysql-test/t/ps.test: Added tests for PREPARE stmt1 FROM @var syntax mysys/my_error.c: Added support for "%.*s" format sql/item.cc: Removed one redundant Item_param::set_value function sql/item.h: Removed one redundant Item_param::set_value function sql/mysqld.cc: Reformmated the code sql/share/czech/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/dutch/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/english/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/estonian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/french/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/german/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/greek/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/hungarian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/italian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/japanese/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/korean/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/norwegian-ny/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/norwegian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/polish/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/portuguese/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/romanian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/russian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/slovak/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/spanish/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/swedish/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/ukrainian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/sql_class.h: SQL Prepared statements now can't be used by binary protocol commands sql/sql_lex.h: Added support for PREPARE stmt1 FROM @var syntax. sql/sql_parse.cc: Added support for PREPARE stmt1 FROM @var syntax. sql/sql_prepare.cc: Code cleanup sql/sql_yacc.yy: Added support for PREPARE stmt1 FROM @var syntax.
22 years ago
WL#1622 "SQL Syntax for Prepared Statements": Post-review fixes (1 of 2) mysql-test/r/ps.result: Added tests for PREPARE stmt1 FROM @var syntax mysql-test/t/ps.test: Added tests for PREPARE stmt1 FROM @var syntax mysys/my_error.c: Added support for "%.*s" format sql/item.cc: Removed one redundant Item_param::set_value function sql/item.h: Removed one redundant Item_param::set_value function sql/mysqld.cc: Reformmated the code sql/share/czech/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/dutch/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/english/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/estonian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/french/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/german/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/greek/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/hungarian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/italian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/japanese/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/korean/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/norwegian-ny/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/norwegian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/polish/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/portuguese/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/romanian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/russian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/slovak/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/spanish/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/swedish/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/ukrainian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/sql_class.h: SQL Prepared statements now can't be used by binary protocol commands sql/sql_lex.h: Added support for PREPARE stmt1 FROM @var syntax. sql/sql_parse.cc: Added support for PREPARE stmt1 FROM @var syntax. sql/sql_prepare.cc: Code cleanup sql/sql_yacc.yy: Added support for PREPARE stmt1 FROM @var syntax.
22 years ago
WL#1622 "SQL Syntax for Prepared Statements": Post-review fixes (1 of 2) mysql-test/r/ps.result: Added tests for PREPARE stmt1 FROM @var syntax mysql-test/t/ps.test: Added tests for PREPARE stmt1 FROM @var syntax mysys/my_error.c: Added support for "%.*s" format sql/item.cc: Removed one redundant Item_param::set_value function sql/item.h: Removed one redundant Item_param::set_value function sql/mysqld.cc: Reformmated the code sql/share/czech/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/dutch/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/english/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/estonian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/french/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/german/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/greek/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/hungarian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/italian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/japanese/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/korean/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/norwegian-ny/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/norwegian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/polish/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/portuguese/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/romanian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/russian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/slovak/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/spanish/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/swedish/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/ukrainian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/sql_class.h: SQL Prepared statements now can't be used by binary protocol commands sql/sql_lex.h: Added support for PREPARE stmt1 FROM @var syntax. sql/sql_parse.cc: Added support for PREPARE stmt1 FROM @var syntax. sql/sql_prepare.cc: Code cleanup sql/sql_yacc.yy: Added support for PREPARE stmt1 FROM @var syntax.
22 years ago
WL#1622 "SQL Syntax for Prepared Statements": Post-review fixes (1 of 2) mysql-test/r/ps.result: Added tests for PREPARE stmt1 FROM @var syntax mysql-test/t/ps.test: Added tests for PREPARE stmt1 FROM @var syntax mysys/my_error.c: Added support for "%.*s" format sql/item.cc: Removed one redundant Item_param::set_value function sql/item.h: Removed one redundant Item_param::set_value function sql/mysqld.cc: Reformmated the code sql/share/czech/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/dutch/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/english/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/estonian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/french/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/german/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/greek/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/hungarian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/italian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/japanese/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/korean/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/norwegian-ny/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/norwegian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/polish/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/portuguese/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/romanian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/russian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/slovak/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/spanish/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/swedish/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/ukrainian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/sql_class.h: SQL Prepared statements now can't be used by binary protocol commands sql/sql_lex.h: Added support for PREPARE stmt1 FROM @var syntax. sql/sql_parse.cc: Added support for PREPARE stmt1 FROM @var syntax. sql/sql_prepare.cc: Code cleanup sql/sql_yacc.yy: Added support for PREPARE stmt1 FROM @var syntax.
22 years ago
bug#10466: Datatype "timestamp" displays "YYYYMMDDHHMMSS" irrespective of display sizes. - Print warning that says display width is not supported for datatype TIMESTAMP, if user tries to create a TIMESTAMP column with display width. - Use display width for TIMESTAMP only in type_timestamp test to make sure warning is displayed correctly. mysql-test/include/ps_create.inc: Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test. mysql-test/r/alias.result: Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test. mysql-test/r/func_date_add.result: Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test. mysql-test/r/func_str.result: Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test. mysql-test/r/func_time.result: Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test. mysql-test/r/group_by.result: Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test. mysql-test/r/innodb.result: Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test. mysql-test/r/ps.result: Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test. mysql-test/r/ps_1general.result: Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test. mysql-test/r/ps_2myisam.result: Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test. mysql-test/r/ps_3innodb.result: Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test. mysql-test/r/ps_4heap.result: Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test. mysql-test/r/ps_5merge.result: Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test. mysql-test/r/ps_6bdb.result: Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test. mysql-test/r/ps_7ndb.result: Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test. mysql-test/r/select.result: Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test. mysql-test/r/type_timestamp.result: When display width is used for a TIMESTAMP column a warning is printed that the display width will be ignored. mysql-test/r/update.result: Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test. mysql-test/t/alias.test: Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test. mysql-test/t/func_date_add.test: Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test. mysql-test/t/func_str.test: Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test. mysql-test/t/func_time.test: Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test. mysql-test/t/group_by.test: Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test. mysql-test/t/innodb.test: Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test. mysql-test/t/ps.test: Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test. mysql-test/t/ps_4heap.test: Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test. mysql-test/t/ps_5merge.test: Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test. mysql-test/t/select.test: Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test. mysql-test/t/update.test: Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test. sql/share/errmsg.txt: Correct swedish error message sql/sql_parse.cc: Print warning if datatype is TIMESTAMP and display width is used.
21 years ago
Add support for up to VARCHAR (size up to 65535) Renamed HA_VAR_LENGTH to HA_VAR_LENGTH_PART Renamed in all files FIELD_TYPE_STRING and FIELD_TYPE_VAR_STRING to MYSQL_TYPE_STRING and MYSQL_TYPE_VAR_STRING to make it easy to catch all possible errors Added support for VARCHAR KEYS to heap Removed support for ISAM Now only long VARCHAR columns are changed to TEXT on demand (not CHAR) Internal temporary files can now use fixed length tables if the used VARCHAR columns are short BitKeeper/deleted/.del-ha_isam.cc~4dce65904db2675e: Delete: sql/ha_isam.cc BitKeeper/deleted/.del-_cache.c~b5d80b5c3ae233b1: Delete: isam/_cache.c BitKeeper/deleted/.del-_dbug.c~88d7964ae5e3c9bd: Delete: isam/_dbug.c BitKeeper/deleted/.del-_dynrec.c~48dd758f5a5450df: Delete: isam/_dynrec.c BitKeeper/deleted/.del-_key.c~ce62d47a6c681084: Delete: isam/_key.c BitKeeper/deleted/.del-_locking.c~dea4cdc6ea425c67: Delete: isam/_locking.c BitKeeper/deleted/.del-_packrec.c~47ae1b16c007e9be: Delete: isam/_packrec.c BitKeeper/deleted/.del-_page.c~148b1a613d052ee8: Delete: isam/_page.c BitKeeper/deleted/.del-_search.c~f509292aa1ff18ff: Delete: isam/_search.c BitKeeper/deleted/.del-_statrec.c~58d9263b3475d58b: Delete: isam/_statrec.c BitKeeper/deleted/.del-changed.c~d075de80a314b02d: Delete: isam/changed.c BitKeeper/deleted/.del-close.c~fd62629496ee5bcc: Delete: isam/close.c BitKeeper/deleted/.del-create.c~96cecc433c0c2242: Delete: isam/create.c BitKeeper/deleted/.del-delete.c~65ee8daaa75a14b6: Delete: isam/delete.c BitKeeper/deleted/.del-extra.c~706f29d72beb2565: Delete: isam/extra.c BitKeeper/deleted/.del-info.c~96cfb747af8da0d: Delete: isam/info.c BitKeeper/deleted/.del-isamchk.c~c0f59c2687d2248f: Delete: isam/isamchk.c BitKeeper/deleted/.del-isamlog.c~85b6b31c6e2b8519: Delete: isam/isamlog.c BitKeeper/deleted/.del-log.c~55a973013d55cade: Delete: isam/log.c BitKeeper/deleted/.del-open.c~95b3b75042fae00a: Delete: isam/open.c BitKeeper/deleted/.del-pack_isam.c~43801f0df7504834: Delete: isam/pack_isam.c BitKeeper/deleted/.del-panic.c~f7fd71605324f8f3: Delete: isam/panic.c BitKeeper/deleted/.del-range.c~142f1f8ac4948082: Delete: isam/range.c BitKeeper/deleted/.del-rfirst.c~66f494291dc005d3: Delete: isam/rfirst.c BitKeeper/deleted/.del-rkey.c~cc54c6498352f999: Delete: isam/rkey.c BitKeeper/deleted/.del-rlast.c~d1fe1866139e9866: Delete: isam/rlast.c BitKeeper/deleted/.del-rnext.c~b308eaa1e11ea7de: Delete: isam/rnext.c BitKeeper/deleted/.del-rprev.c~b359f71fdea4bbce: Delete: isam/rprev.c BitKeeper/deleted/.del-rrnd.c~7fcfcce88d4a5200: Delete: isam/rrnd.c BitKeeper/deleted/.del-rsame.c~75a62d5548103a15: Delete: isam/rsame.c BitKeeper/deleted/.del-rsamepos.c~5b5652dd2cda6d5d: Delete: isam/rsamepos.c BitKeeper/deleted/.del-sort.c~e2e56b5a37ce86f4: Delete: isam/sort.c BitKeeper/deleted/.del-static.c~3a1354b84f4a9cc7: Delete: isam/static.c BitKeeper/deleted/.del-test1.c~64d52e9412d457ed: Delete: isam/test1.c BitKeeper/deleted/.del-test2.c~2f9a632cab572958: Delete: isam/test2.c BitKeeper/deleted/.del-test3.c~e8a7a4afe8a087: Delete: isam/test3.c BitKeeper/deleted/.del-isamdef.h~ac8d49e7e2201c66: Delete: isam/isamdef.h BitKeeper/deleted/.del-update.c~670264f51dc44934: Delete: isam/update.c BitKeeper/deleted/.del-write.c~8f1918b1f6770e54: Delete: isam/write.c BitKeeper/deleted/.del-Makefile.am~6cfa0db5e7778d09: Delete: isam/Makefile.am BitKeeper/deleted/.del-make-ccc~3ee55391eda0b0ab: Delete: isam/make-ccc BitKeeper/deleted/.del-ChangeLog~208984fb7a51e568: Delete: isam/ChangeLog BitKeeper/deleted/.del-test_all.res~c2aafb49a3a77db7: Delete: isam/test_all.res BitKeeper/deleted/.del-test_all~93c701e44a9c5b65: Delete: isam/test_all BitKeeper/deleted/.del-.cvsignore~54f6f0f2d5012561: Delete: isam/.cvsignore BitKeeper/deleted/.del-ha_isammrg.cc~dc682e4755d77a2e: Delete: sql/ha_isammrg.cc BitKeeper/deleted/.del-ha_isam.h~bf53d533be3d3927: Delete: sql/ha_isam.h BitKeeper/deleted/.del-ha_isammrg.h~66fd2e5bfe7207dc: Delete: sql/ha_isammrg.h acinclude.m4: Remove ISAM client/mysqldump.c: FIELD_TYPE -> MYSQL_TYPE client/mysqltest.c: Add missing DBUG_RETURN configure.in: Remove ISAM heap/heapdef.h: Add support for VARCHAR heap/hp_create.c: Add support for VARCHAR heap/hp_delete.c: Add support for VARCHAR heap/hp_hash.c: Add support for VARCHAR (VARCHAR keys was not supported before) heap/hp_rkey.c: Add support for VARCHAR heap/hp_update.c: Add support for VARCHAR heap/hp_write.c: Add support for VARCHAR (Added flag SEARCH_UPDATE to mark that this is an update) include/decimal.h: Remove not needed my_global.h include/m_ctype.h: Add support for VARCHAR include/my_base.h: Add support for VARCHAR include/my_handler.h: Moved general purpose macro from MyISAM code include/mysql_com.h: Add support for VARCHAR libmysql/libmysql.c: Add support for VARCHAR libmysqld/Makefile.am: Removed ISAM myisam/ft_static.c: Add support for VARCHAR myisam/ft_test1.c: Add support for VARCHAR myisam/ft_update.c: Add support for VARCHAR myisam/mi_check.c: Add support for VARCHAR myisam/mi_create.c: Add support for VARCHAR - VARCHAR key segments are marked with HA_VAR_LENGTH_PART myisam/mi_key.c: Add support for VARCHAR Fixed bug in old VARCHAR code when reading index-only myisam/mi_range.c: Fixed comment style myisam/mi_rnext_same.c: Handle case where equal keys can be of different length myisam/mi_search.c: Add support for VARCHAR myisam/mi_test1.c: Add support for VARCHAR myisam/mi_unique.c: Add support for VARCHAR (Some new code to handle keys that are equal but have different lengths) myisam/mi_write.c: Fixed comment myisam/myisamchk.c: Better infotext if wrong type mysql-test/r/bdb.result: Updated old result and new results for VARCHAR mysql-test/r/create.result: Updated old result and new results for VARCHAR mysql-test/r/ctype_tis620.result: Updated old result and new results for VARCHAR (Old code sorted tis620 wrong) mysql-test/r/ctype_ucs.result: Updated old result and new results for VARCHAR mysql-test/r/endspace.result: Updated old result and new results for VARCHAR mysql-test/r/func_like.result: Updated old result and new results for VARCHAR mysql-test/r/heap.result: Updated old result and new results for VARCHAR mysql-test/r/innodb.result: Updated old result. This will change a bit when also InnoDB supports VARCHAR mysql-test/r/merge.result: Updated old result and new results for VARCHAR mysql-test/r/myisam.result: Updated old result and new results for VARCHAR mysql-test/r/mysqldump.result: Updated old result and new results for VARCHAR mysql-test/r/order_by.result: Updated old result and new results for VARCHAR (Key length is different for VARCHAR) mysql-test/r/ps.result: Updated old result and new results for VARCHAR mysql-test/r/ps_1general.result: Updated results for new .frm version Don't print seconds in show full process list as this may change mysql-test/r/ps_2myisam.result: Updated old result and new results for VARCHAR mysql-test/r/ps_3innodb.result: Updated old result and new results for VARCHAR mysql-test/r/ps_4heap.result: Updated old result and new results for VARCHAR mysql-test/r/ps_5merge.result: Updated old result and new results for VARCHAR mysql-test/r/ps_6bdb.result: Updated old result and new results for VARCHAR mysql-test/r/select.result.es: Updated results by hand mysql-test/r/select.result: Updated old result and new results for VARCHAR mysql-test/r/select_found.result: Updated old result and new results for VARCHAR mysql-test/r/show_check.result: Updated old result and new results for VARCHAR mysql-test/r/strict.result: Updated old result and new results for VARCHAR mysql-test/r/subselect.result: Updated old result and new results for VARCHAR mysql-test/r/system_mysql_db.result: Updated old result and new results for VARCHAR mysql-test/r/type_blob.result: Updated old result and new results for VARCHAR mysql-test/r/type_ranges.result: Updated old result and new results for VARCHAR mysql-test/r/type_ranges.result.es: Updated some results by hand mysql-test/t/bdb.test: Test VARCHAR mysql-test/t/ctype_ucs.test: Some fixes related to VARCHAR mysql-test/t/endspace.test: Fixes to make it easier to compare columns with end space mysql-test/t/heap.test: Test VARCHAR mysql-test/t/innodb.test: Prepare for testing VARCHAR mysql-test/t/myisam.test: Test VARCHAR mysql-test/t/ps_1general.test: Don't show seconds for show processlist mysql-test/t/ps_4heap.test: Update for VARCHAR mysql-test/t/strict.test: Fix test for VARCHAR mysql-test/t/type_blob.test: Update test for VARCHAR Note that now you can't store 'a' and 'a ' in an unique varchar/text index if the column is not binary mysys/my_handler.c: Add support for VARCHAR ndb/src/common/util/NdbSqlUtil.cpp: Fix for usage of strnncollsp scripts/mysql_fix_privilege_tables.sh: Simple fix so that my_print_defaults works sql/Makefile.am: Remove ISAM sql/field.cc: Add support for VARCHAR Fixed the keys for blob's are compared with strnncollsp Ensure that old tables from MySQL 4.0 works as they did before. (Old VARCHAR will be converted to new VARCHAR on ALTER TABLE) sql/field.h: Add support for VARCHAR sql/field_conv.cc: Change FIELD_TYPE_VAR_STRING -> MYSQL_TYPE_VARCHAR Added usage of HA_KEY_BLOB_LENGTH sql/ha_berkeley.cc: Add support for VARCHAR Added usage of table->insert_or_update if we would ever want to know in key_cmp if we are changing keys sql/ha_heap.cc: Add support for VARCHAR sql/ha_innodb.cc: Changed MYSQL_TYPE_VAR_STRING to MYSQL_TYPE_VARCHAR. Waiting for Heikki to add full VARCHAR support sql/ha_innodb.h: InnoDB doesn't support full VARCHAR yet sql/ha_myisam.cc: Add support for VARCHAR sql/ha_ndbcluster.cc: Add support for VARCHAR sql/handler.h: Added HA_NO_VARCHAR for table handler that doesn't support VARCHAR. In this case MySQL will create a normal CHAR instead sql/item.cc: Fixed access of already freed memory Added support of VARCHAR - varchar length is now checked in mysql_prepare sql/item_cmpfunc.cc: Added new parameter to strncollsp sql/item_sum.cc: Added new parameter to strncollsp FIELD_TYPE -> MYSQL_TYPE sql/key.cc: Add support for VARCHAR sql/opt_range.cc: Remove character set parameter from set_key_image() sql/opt_sum.cc: Remove character set parameter from set_key_image() sql/protocol.cc: Return MYSQL_TYPE_VAR_STRING instead of MYSQL_TYPE_VARCHAR to clients (to not cause compatiblity problems) sql/sql_acl.cc: Change key handling code so that we can use CHAR or VARCHAR for the user table columns sql/sql_base.cc: Remove old, not used code sql/sql_help.cc: Remove charset from get_key_image sql/sql_parse.cc: Ensure that OPTION_TABLE_LOCK is cleared ASAP; This fixed a problem in BDB transaction code when one used LOCK TABLES on a BDB table Added support for VARCHAR Moved field length checking and VARCHAR -> TEXT convert to mysql_prepare (as we need the know the character set for the column) sql/sql_select.cc: Added support of VARCHAR Added heuristic to use fixed size rows for tmp tables if we are using only a few short VARCHAR's sql/sql_string.cc: Added extra argument to strnncollsp sql/sql_table.cc: Add support for VARCHAR Automaticly convert (with warning) big VARCHAR (but not CHAR) to TEXT If handler doesn't support VARCHAR convert VARCHAR to CHAR sql/sql_update.cc: Fixed compiler warning sql/sql_yacc.yy: Add support for VARCHAR sql/strfunc.cc: Fixed valgrind warning sql/structs.h: Added 'table' to KEY structure to make life easier for some handler functions sql/table.cc: Add support for VARCHAR - New .frm version - FIELD_TYPE -> MYSQL_TYPE sql/table.h: Added insert_or_update; A bool flag a handler can set/reset if needed (for handler internal usage) sql/unireg.h: Add support for VARCHAR strings/ctype-big5.c: Added new argument to strnncollsp() to allow one to define if end space are significant or not Changed my_like_range... to correctly calculate min_length & max_length strings/ctype-bin.c: Added new argument to strnncollsp() to allow one to define if end space are significant or not strings/ctype-czech.c: Changed my_like_range... to correctly calculate min_length & max_length strings/ctype-gbk.c: Added new argument to strnncollsp() to allow one to define if end space are significant or not Changed my_like_range... to correctly calculate min_length & max_length strings/ctype-latin1.c: Added new argument to strnncollsp() to allow one to define if end space are significant or not strings/ctype-mb.c: Added new argument to strnncollsp() to allow one to define if end space are significant or not Changed my_like_range... to correctly calculate min_length & max_length strings/ctype-simple.c: Added new argument to strnncollsp() to allow one to define if end space are significant or not Changed my_like_range... to correctly calculate min_length & max_length strings/ctype-sjis.c: Added new argument to strnncollsp() to allow one to define if end space are significant or not Changed my_like_range... to correctly calculate min_length & max_length strings/ctype-tis620.c: Added new argument to strnncollsp() to allow one to define if end space are significant or not Changed my_like_range... to correctly calculate min_length & max_length strings/ctype-uca.c: Added new argument to strnncollsp() to allow one to define if end space are significant or not strings/ctype-ucs2.c: Changed my_like_range... to correctly calculate min_length & max_length strings/ctype-utf8.c: Added new argument to strnncollsp() to allow one to define if end space are significant or not strings/ctype-win1250ch.c: Changed my_like_range... to correctly calculate min_length & max_length strings/decimal.c: Fixed include files usage Fixed some compiler warnings tests/client_test.c: Ensure tests works with VARCHAR
21 years ago
Add support for up to VARCHAR (size up to 65535) Renamed HA_VAR_LENGTH to HA_VAR_LENGTH_PART Renamed in all files FIELD_TYPE_STRING and FIELD_TYPE_VAR_STRING to MYSQL_TYPE_STRING and MYSQL_TYPE_VAR_STRING to make it easy to catch all possible errors Added support for VARCHAR KEYS to heap Removed support for ISAM Now only long VARCHAR columns are changed to TEXT on demand (not CHAR) Internal temporary files can now use fixed length tables if the used VARCHAR columns are short BitKeeper/deleted/.del-ha_isam.cc~4dce65904db2675e: Delete: sql/ha_isam.cc BitKeeper/deleted/.del-_cache.c~b5d80b5c3ae233b1: Delete: isam/_cache.c BitKeeper/deleted/.del-_dbug.c~88d7964ae5e3c9bd: Delete: isam/_dbug.c BitKeeper/deleted/.del-_dynrec.c~48dd758f5a5450df: Delete: isam/_dynrec.c BitKeeper/deleted/.del-_key.c~ce62d47a6c681084: Delete: isam/_key.c BitKeeper/deleted/.del-_locking.c~dea4cdc6ea425c67: Delete: isam/_locking.c BitKeeper/deleted/.del-_packrec.c~47ae1b16c007e9be: Delete: isam/_packrec.c BitKeeper/deleted/.del-_page.c~148b1a613d052ee8: Delete: isam/_page.c BitKeeper/deleted/.del-_search.c~f509292aa1ff18ff: Delete: isam/_search.c BitKeeper/deleted/.del-_statrec.c~58d9263b3475d58b: Delete: isam/_statrec.c BitKeeper/deleted/.del-changed.c~d075de80a314b02d: Delete: isam/changed.c BitKeeper/deleted/.del-close.c~fd62629496ee5bcc: Delete: isam/close.c BitKeeper/deleted/.del-create.c~96cecc433c0c2242: Delete: isam/create.c BitKeeper/deleted/.del-delete.c~65ee8daaa75a14b6: Delete: isam/delete.c BitKeeper/deleted/.del-extra.c~706f29d72beb2565: Delete: isam/extra.c BitKeeper/deleted/.del-info.c~96cfb747af8da0d: Delete: isam/info.c BitKeeper/deleted/.del-isamchk.c~c0f59c2687d2248f: Delete: isam/isamchk.c BitKeeper/deleted/.del-isamlog.c~85b6b31c6e2b8519: Delete: isam/isamlog.c BitKeeper/deleted/.del-log.c~55a973013d55cade: Delete: isam/log.c BitKeeper/deleted/.del-open.c~95b3b75042fae00a: Delete: isam/open.c BitKeeper/deleted/.del-pack_isam.c~43801f0df7504834: Delete: isam/pack_isam.c BitKeeper/deleted/.del-panic.c~f7fd71605324f8f3: Delete: isam/panic.c BitKeeper/deleted/.del-range.c~142f1f8ac4948082: Delete: isam/range.c BitKeeper/deleted/.del-rfirst.c~66f494291dc005d3: Delete: isam/rfirst.c BitKeeper/deleted/.del-rkey.c~cc54c6498352f999: Delete: isam/rkey.c BitKeeper/deleted/.del-rlast.c~d1fe1866139e9866: Delete: isam/rlast.c BitKeeper/deleted/.del-rnext.c~b308eaa1e11ea7de: Delete: isam/rnext.c BitKeeper/deleted/.del-rprev.c~b359f71fdea4bbce: Delete: isam/rprev.c BitKeeper/deleted/.del-rrnd.c~7fcfcce88d4a5200: Delete: isam/rrnd.c BitKeeper/deleted/.del-rsame.c~75a62d5548103a15: Delete: isam/rsame.c BitKeeper/deleted/.del-rsamepos.c~5b5652dd2cda6d5d: Delete: isam/rsamepos.c BitKeeper/deleted/.del-sort.c~e2e56b5a37ce86f4: Delete: isam/sort.c BitKeeper/deleted/.del-static.c~3a1354b84f4a9cc7: Delete: isam/static.c BitKeeper/deleted/.del-test1.c~64d52e9412d457ed: Delete: isam/test1.c BitKeeper/deleted/.del-test2.c~2f9a632cab572958: Delete: isam/test2.c BitKeeper/deleted/.del-test3.c~e8a7a4afe8a087: Delete: isam/test3.c BitKeeper/deleted/.del-isamdef.h~ac8d49e7e2201c66: Delete: isam/isamdef.h BitKeeper/deleted/.del-update.c~670264f51dc44934: Delete: isam/update.c BitKeeper/deleted/.del-write.c~8f1918b1f6770e54: Delete: isam/write.c BitKeeper/deleted/.del-Makefile.am~6cfa0db5e7778d09: Delete: isam/Makefile.am BitKeeper/deleted/.del-make-ccc~3ee55391eda0b0ab: Delete: isam/make-ccc BitKeeper/deleted/.del-ChangeLog~208984fb7a51e568: Delete: isam/ChangeLog BitKeeper/deleted/.del-test_all.res~c2aafb49a3a77db7: Delete: isam/test_all.res BitKeeper/deleted/.del-test_all~93c701e44a9c5b65: Delete: isam/test_all BitKeeper/deleted/.del-.cvsignore~54f6f0f2d5012561: Delete: isam/.cvsignore BitKeeper/deleted/.del-ha_isammrg.cc~dc682e4755d77a2e: Delete: sql/ha_isammrg.cc BitKeeper/deleted/.del-ha_isam.h~bf53d533be3d3927: Delete: sql/ha_isam.h BitKeeper/deleted/.del-ha_isammrg.h~66fd2e5bfe7207dc: Delete: sql/ha_isammrg.h acinclude.m4: Remove ISAM client/mysqldump.c: FIELD_TYPE -> MYSQL_TYPE client/mysqltest.c: Add missing DBUG_RETURN configure.in: Remove ISAM heap/heapdef.h: Add support for VARCHAR heap/hp_create.c: Add support for VARCHAR heap/hp_delete.c: Add support for VARCHAR heap/hp_hash.c: Add support for VARCHAR (VARCHAR keys was not supported before) heap/hp_rkey.c: Add support for VARCHAR heap/hp_update.c: Add support for VARCHAR heap/hp_write.c: Add support for VARCHAR (Added flag SEARCH_UPDATE to mark that this is an update) include/decimal.h: Remove not needed my_global.h include/m_ctype.h: Add support for VARCHAR include/my_base.h: Add support for VARCHAR include/my_handler.h: Moved general purpose macro from MyISAM code include/mysql_com.h: Add support for VARCHAR libmysql/libmysql.c: Add support for VARCHAR libmysqld/Makefile.am: Removed ISAM myisam/ft_static.c: Add support for VARCHAR myisam/ft_test1.c: Add support for VARCHAR myisam/ft_update.c: Add support for VARCHAR myisam/mi_check.c: Add support for VARCHAR myisam/mi_create.c: Add support for VARCHAR - VARCHAR key segments are marked with HA_VAR_LENGTH_PART myisam/mi_key.c: Add support for VARCHAR Fixed bug in old VARCHAR code when reading index-only myisam/mi_range.c: Fixed comment style myisam/mi_rnext_same.c: Handle case where equal keys can be of different length myisam/mi_search.c: Add support for VARCHAR myisam/mi_test1.c: Add support for VARCHAR myisam/mi_unique.c: Add support for VARCHAR (Some new code to handle keys that are equal but have different lengths) myisam/mi_write.c: Fixed comment myisam/myisamchk.c: Better infotext if wrong type mysql-test/r/bdb.result: Updated old result and new results for VARCHAR mysql-test/r/create.result: Updated old result and new results for VARCHAR mysql-test/r/ctype_tis620.result: Updated old result and new results for VARCHAR (Old code sorted tis620 wrong) mysql-test/r/ctype_ucs.result: Updated old result and new results for VARCHAR mysql-test/r/endspace.result: Updated old result and new results for VARCHAR mysql-test/r/func_like.result: Updated old result and new results for VARCHAR mysql-test/r/heap.result: Updated old result and new results for VARCHAR mysql-test/r/innodb.result: Updated old result. This will change a bit when also InnoDB supports VARCHAR mysql-test/r/merge.result: Updated old result and new results for VARCHAR mysql-test/r/myisam.result: Updated old result and new results for VARCHAR mysql-test/r/mysqldump.result: Updated old result and new results for VARCHAR mysql-test/r/order_by.result: Updated old result and new results for VARCHAR (Key length is different for VARCHAR) mysql-test/r/ps.result: Updated old result and new results for VARCHAR mysql-test/r/ps_1general.result: Updated results for new .frm version Don't print seconds in show full process list as this may change mysql-test/r/ps_2myisam.result: Updated old result and new results for VARCHAR mysql-test/r/ps_3innodb.result: Updated old result and new results for VARCHAR mysql-test/r/ps_4heap.result: Updated old result and new results for VARCHAR mysql-test/r/ps_5merge.result: Updated old result and new results for VARCHAR mysql-test/r/ps_6bdb.result: Updated old result and new results for VARCHAR mysql-test/r/select.result.es: Updated results by hand mysql-test/r/select.result: Updated old result and new results for VARCHAR mysql-test/r/select_found.result: Updated old result and new results for VARCHAR mysql-test/r/show_check.result: Updated old result and new results for VARCHAR mysql-test/r/strict.result: Updated old result and new results for VARCHAR mysql-test/r/subselect.result: Updated old result and new results for VARCHAR mysql-test/r/system_mysql_db.result: Updated old result and new results for VARCHAR mysql-test/r/type_blob.result: Updated old result and new results for VARCHAR mysql-test/r/type_ranges.result: Updated old result and new results for VARCHAR mysql-test/r/type_ranges.result.es: Updated some results by hand mysql-test/t/bdb.test: Test VARCHAR mysql-test/t/ctype_ucs.test: Some fixes related to VARCHAR mysql-test/t/endspace.test: Fixes to make it easier to compare columns with end space mysql-test/t/heap.test: Test VARCHAR mysql-test/t/innodb.test: Prepare for testing VARCHAR mysql-test/t/myisam.test: Test VARCHAR mysql-test/t/ps_1general.test: Don't show seconds for show processlist mysql-test/t/ps_4heap.test: Update for VARCHAR mysql-test/t/strict.test: Fix test for VARCHAR mysql-test/t/type_blob.test: Update test for VARCHAR Note that now you can't store 'a' and 'a ' in an unique varchar/text index if the column is not binary mysys/my_handler.c: Add support for VARCHAR ndb/src/common/util/NdbSqlUtil.cpp: Fix for usage of strnncollsp scripts/mysql_fix_privilege_tables.sh: Simple fix so that my_print_defaults works sql/Makefile.am: Remove ISAM sql/field.cc: Add support for VARCHAR Fixed the keys for blob's are compared with strnncollsp Ensure that old tables from MySQL 4.0 works as they did before. (Old VARCHAR will be converted to new VARCHAR on ALTER TABLE) sql/field.h: Add support for VARCHAR sql/field_conv.cc: Change FIELD_TYPE_VAR_STRING -> MYSQL_TYPE_VARCHAR Added usage of HA_KEY_BLOB_LENGTH sql/ha_berkeley.cc: Add support for VARCHAR Added usage of table->insert_or_update if we would ever want to know in key_cmp if we are changing keys sql/ha_heap.cc: Add support for VARCHAR sql/ha_innodb.cc: Changed MYSQL_TYPE_VAR_STRING to MYSQL_TYPE_VARCHAR. Waiting for Heikki to add full VARCHAR support sql/ha_innodb.h: InnoDB doesn't support full VARCHAR yet sql/ha_myisam.cc: Add support for VARCHAR sql/ha_ndbcluster.cc: Add support for VARCHAR sql/handler.h: Added HA_NO_VARCHAR for table handler that doesn't support VARCHAR. In this case MySQL will create a normal CHAR instead sql/item.cc: Fixed access of already freed memory Added support of VARCHAR - varchar length is now checked in mysql_prepare sql/item_cmpfunc.cc: Added new parameter to strncollsp sql/item_sum.cc: Added new parameter to strncollsp FIELD_TYPE -> MYSQL_TYPE sql/key.cc: Add support for VARCHAR sql/opt_range.cc: Remove character set parameter from set_key_image() sql/opt_sum.cc: Remove character set parameter from set_key_image() sql/protocol.cc: Return MYSQL_TYPE_VAR_STRING instead of MYSQL_TYPE_VARCHAR to clients (to not cause compatiblity problems) sql/sql_acl.cc: Change key handling code so that we can use CHAR or VARCHAR for the user table columns sql/sql_base.cc: Remove old, not used code sql/sql_help.cc: Remove charset from get_key_image sql/sql_parse.cc: Ensure that OPTION_TABLE_LOCK is cleared ASAP; This fixed a problem in BDB transaction code when one used LOCK TABLES on a BDB table Added support for VARCHAR Moved field length checking and VARCHAR -> TEXT convert to mysql_prepare (as we need the know the character set for the column) sql/sql_select.cc: Added support of VARCHAR Added heuristic to use fixed size rows for tmp tables if we are using only a few short VARCHAR's sql/sql_string.cc: Added extra argument to strnncollsp sql/sql_table.cc: Add support for VARCHAR Automaticly convert (with warning) big VARCHAR (but not CHAR) to TEXT If handler doesn't support VARCHAR convert VARCHAR to CHAR sql/sql_update.cc: Fixed compiler warning sql/sql_yacc.yy: Add support for VARCHAR sql/strfunc.cc: Fixed valgrind warning sql/structs.h: Added 'table' to KEY structure to make life easier for some handler functions sql/table.cc: Add support for VARCHAR - New .frm version - FIELD_TYPE -> MYSQL_TYPE sql/table.h: Added insert_or_update; A bool flag a handler can set/reset if needed (for handler internal usage) sql/unireg.h: Add support for VARCHAR strings/ctype-big5.c: Added new argument to strnncollsp() to allow one to define if end space are significant or not Changed my_like_range... to correctly calculate min_length & max_length strings/ctype-bin.c: Added new argument to strnncollsp() to allow one to define if end space are significant or not strings/ctype-czech.c: Changed my_like_range... to correctly calculate min_length & max_length strings/ctype-gbk.c: Added new argument to strnncollsp() to allow one to define if end space are significant or not Changed my_like_range... to correctly calculate min_length & max_length strings/ctype-latin1.c: Added new argument to strnncollsp() to allow one to define if end space are significant or not strings/ctype-mb.c: Added new argument to strnncollsp() to allow one to define if end space are significant or not Changed my_like_range... to correctly calculate min_length & max_length strings/ctype-simple.c: Added new argument to strnncollsp() to allow one to define if end space are significant or not Changed my_like_range... to correctly calculate min_length & max_length strings/ctype-sjis.c: Added new argument to strnncollsp() to allow one to define if end space are significant or not Changed my_like_range... to correctly calculate min_length & max_length strings/ctype-tis620.c: Added new argument to strnncollsp() to allow one to define if end space are significant or not Changed my_like_range... to correctly calculate min_length & max_length strings/ctype-uca.c: Added new argument to strnncollsp() to allow one to define if end space are significant or not strings/ctype-ucs2.c: Changed my_like_range... to correctly calculate min_length & max_length strings/ctype-utf8.c: Added new argument to strnncollsp() to allow one to define if end space are significant or not strings/ctype-win1250ch.c: Changed my_like_range... to correctly calculate min_length & max_length strings/decimal.c: Fixed include files usage Fixed some compiler warnings tests/client_test.c: Ensure tests works with VARCHAR
21 years ago
Fix for bug#4912 "mysqld crashs in case a statement is executed a second time". The bug was caused by incompatibility of negations elimination algorithm and PS: during first statement execute a subtree with negation was replaced with equivalent subtree without NOTs. The problem was that although this transformation was permanent, items of the new subtree were created in execute-local memory. The patch adds means to check if it is the first execute of a prepared statement, and if this is the case, to allocate items in memory of the prepared statement. The implementation: - backports Item_arena from 5.0 - adds Item_arena::is_stmt_prepare(), Item_arena::is_first_stmt_execute(). - deletes THD::allocate_temporary_pool_for_ps_preparing(), THD::free_temporary_pool_for_ps_preparing(); they were redundant. and adds a few invariants: - thd->free_list never contains junk (= freed items) - thd->current_arena is never null. If there is no prepared statement, it points at the thd. The rest of the patch contains mainly mechanical changes and cleanups. mysql-test/r/ps.result: Test results updated (test case for Bug#4912) mysql-test/t/ps.test: A test case for Bug#4912 "mysqld crashs in case a statement is executed a second time" sql/item_cmpfunc.cc: current_statement -> current_arena sql/item_subselect.cc: Statement -> Item_arena, current_statement -> current_arena sql/item_subselect.h: Item_subselect does not need to save thd->current_statement. sql/item_sum.cc: Statement -> Item_arena sql/item_sum.h: Statement -> Item_arena sql/mysql_priv.h: Statement -> Item_arena sql/sql_base.cc: current_statement -> current_arena sql/sql_class.cc: - Item_arena - convenient set_n_backup_statement, restore_backup_statement (nice idea, Sanja) sql/sql_class.h: - Item_arena: backport from 5.0 - allocate_temporary_pool_for_ps_preparing, free_temporary_pool_for_ps_preparing removed. sql/sql_derived.cc: current_statement -> current_arena sql/sql_lex.cc: current_statement -> current_arena sql/sql_parse.cc: Deploy invariant that thd->free_list never contains junk items (backport from 5.0). sql/sql_prepare.cc: - backporting Item_arena - no need to allocate_temporary_pool_for_ps_preparing(). sql/sql_select.cc: Fix for bug#4912 "mysqld crashs in case a statement is executed a second time": if this is the first execute of a prepared statement, negation elimination is done in memory of the prepared statement. sql/sql_union.cc: Backporting Item_arena from 5.0.
22 years ago
Fix for Bug#5034 "prepared "select 1 into @arg15", second execute crashes server": we were deleting lex->result after each execute, but prepared statements assumed that it's left intact. The fix adds cleanup() method to select_result hierarchy, so that result objects can be reused. Plus we now need to delete result objects more wisely. mysql-test/r/ps.result: Test results fixed: test case for bug#5034 mysql-test/t/ps.test: A test case for bug#5034, few followups sql/sql_class.cc: - fix warning in THD::THD - implementation of cleanup() for select_result hierarchy - select_export::send_eof was identical to select_dump::send_eof: moved to the base class select_to_file. - Statement::end_statement() to end lex, free items, and delete possible select_result sql/sql_class.h: - select_result::cleanup() declaration - sql/sql_insert.cc: - implementation of select_insert::cleanup(): currently we always create a new instance of select_insert/ select_create on each execute. sql/sql_lex.cc: - with more complicated logic of freeing lex->result it's easier to have it non-zero only if it points to a valid result. sql/sql_lex.h: Now st_lex::st_lex is not empty. sql/sql_parse.cc: mysql_execute_command(): - delete select_result *result only if it was created in this function. - use end_statement() to cleanup lex and thd in the end of each statement. - no need to save THD::lock if this is explain. This save apparently left from times when derived tables were materialized here, not in open_and_lock_tables. sql/sql_prepare.cc: - call result->cleanup() in reset_stmt_for_execute - now Statement is responsible for freeing its lex->result. sql/sql_select.cc: handle_select(): - don't delete result, it might be needed for next executions - result is never null
22 years ago
A fix for Bug#5748 "Prepared statement with BETWEEN and bigint values crashes mysqld": implementation for a generic item tree modifications registry. Every item tree modification which should be rolled back for subsequent execution of a prepared statement or stored procedure should be saved in the registry. All such modifications are rolled back at once during cleanup stage of PS. Actual fix for the bug just adds a call to register modifications to convert_constant_item. Post review fixes implemented. mysql-test/r/ps.result: A fix for bug#5748, test results fixed. mysql-test/t/ps.test: A test case for Bug#5748 "Prepared statement with BETWEEN and bigint values crashes mysqld" sql/item.cc: Fix for Bug#5748 "Prepared statement with BETWEEN and bigint values crashes mysqld": First step in removing up item-specific cleanups: now all such tree modifications should be done using the genericm mechanism implemented in this changeset. sql/item.h: Fix for Bug#5748 "Prepared statement with BETWEEN and bigint values crashes mysqld": no need for an item-specific change record any more. sql/item_cmpfunc.cc: A fix for Bug#5748 "Prepared statement with BETWEEN and bigint values crashes mysqld": register item tree transformation performed by convert_constant_item. sql/sql_class.cc: Implementation for item tree transformations registry. sql/sql_class.h: Declarations, necessary for the tree transformations registry. sql/sql_parse.cc: Assert that the item tree transformations registry is not used for conventional execution. sql/sql_prepare.cc: Use of the item tree modifications registry in prepared statements: rollback all modifications in the end of statement prepare and execute. Also we now always set thd->current_arena to be able to determine that this is an execution of prepared statement inside the registry code. tests/client_test.c: A typo fixed.
21 years ago
A fix and test case for Bug#5987 "subselect in bool function crashes server (prepared statements)": the bug was that all boolean items always recovered its original arguments at statement cleanup stage. This collided with Item_subselect::select_transformer, which tries to permanently change the item tree to use a transformed subselect instead of original one. So we had this call sequence for prepare: mysql_stmt_prepare -> JOIN::prepare -> Item_subselect::fix_fields -> the item tree gets transformed -> Item_bool_rowready_func2::cleanup, item tree is recovered to original state, while it shouldn't have been; mysql_stmt_execute -> attempts to execute a broken tree -> crash. Now instead of bluntly recovering all arguments of bool functions in Item_bool_rowready_func2::cleanup, we recover only those which were changed, and do it in one place. There still would exist a possibility for a collision with subselect tranformation, if permanent and temporary changes were performed at the same stage. But fortunately subselect transformation is always done first, so it doesn't conflict with the optimization done by propogate_cond_constants. Now we have: mysql_stmt_prepare -> JOIN::prepare -> subselect transformation permanently changes the tree -> cleanup doesn't recover anything, because nothing was registered for recovery. mysql_stmt_execute -> JOIN::prepare (the tree is already transformed, so it doesn't change), JOIN::optimize -> propogate_cond_constants -> temporary changes the item tree with constants -> JOIN::execute -> cleanup -> the changes done by propogate_cond_constants are recovered, as they were registered for recovery. mysql-test/r/ps.result: Bug#5987: test results fixed. mysql-test/t/ps.test: A test for bug#5987 "subselect in bool function crashes server (prepared statements)" sql/item.cc: resolve_const_item is now responsible to register all changes of the item tree for recovery sql/item.h: resolve_const_item signagture changed sql/item_cmpfunc.h: Arguments of boolean functions are now recovered using the centralized registry of THD. sql/sql_class.cc: It's crucial to add new items to the beginning of the recovery list, so that the recovery is performed in LIFO mode: otherwise if we change one node of a tree twice, it will be recovered to some intermediate state. sql/sql_select.cc: change_cond_ref_to_const and propogate_cond_constants are now responsible to register all changes of the item tree for recovery. The recovery is done using the centralized THD registry of changed tree items.
21 years ago
A fix and test case for Bug#5985 ""prepare stmt from "select rand(?)" crashes server." The fix makes Item_func_rand prepared-statements aware plus it fixes the case when RAND is used in prepared statements and replication is on (as well as several similar issues). Until now we did not reset THD before every execution of a prepared statement, so if some execution had set thd->time_zone_used or thd->rand_used they would not be reset until next mysql_parse. Some of post-review fixes done. mysql-test/r/ps.result: A test case for Bug#5985: test results fixed. mysql-test/t/ps.test: A test case for Bug#5985 "prepare stmt from "select rand(?)" crashes server." sql/item_func.cc: Actual fix for Bug#5985: Item_func_rand rewritten to be prepared statements aware. sql/item_func.h: Actual fix for Bug#5985: Item_func_rand rewritten to be prepared statements aware. sql/mysql_priv.h: We need a separate call to reset THD state before every execute of a prepared statement. Otherwise things like THD->user_var_events are never cleaned up and bloat binary log (as the list of events grows from execution to execution). sql/sql_class.cc: Statement::end_statement -> THD::end_statement() (a leftover from some design change which is not to pushed now, but the leftover is to be pushed). sql/sql_class.h: Statement::end_statement -> THD::end_statement() (a leftover from some design change which is not to pushed now, but the leftover is to be pushed). sql/sql_lex.cc: Move the part responsible for initializing LEX from mysql_init_query to lex_start. sql/sql_lex.h: All lex-related initialization is now in lex_start. Move thd->select_number to lex->select_number to be able to use it easily in lex_start. sql/sql_parse.cc: Split mysql_init_query into two functions: mysql_reset_thd_for_next_query, which is used in PS and conventional execution, and lex_start, used only when we want to parse something. Fix init_connect to use initialized THD. sql/sql_prepare.cc: Deploy mysql_reset_thd_for_next_query to reset THD state before execution of a prepared statement. Normally this should have been added to just one place, but we have to reset thd before assigning placeholders from variables, thus we can't do that in execute_stmt (yuck).
21 years ago
A fix and test case for Bug#5985 ""prepare stmt from "select rand(?)" crashes server." The fix makes Item_func_rand prepared-statements aware plus it fixes the case when RAND is used in prepared statements and replication is on (as well as several similar issues). Until now we did not reset THD before every execution of a prepared statement, so if some execution had set thd->time_zone_used or thd->rand_used they would not be reset until next mysql_parse. Some of post-review fixes done. mysql-test/r/ps.result: A test case for Bug#5985: test results fixed. mysql-test/t/ps.test: A test case for Bug#5985 "prepare stmt from "select rand(?)" crashes server." sql/item_func.cc: Actual fix for Bug#5985: Item_func_rand rewritten to be prepared statements aware. sql/item_func.h: Actual fix for Bug#5985: Item_func_rand rewritten to be prepared statements aware. sql/mysql_priv.h: We need a separate call to reset THD state before every execute of a prepared statement. Otherwise things like THD->user_var_events are never cleaned up and bloat binary log (as the list of events grows from execution to execution). sql/sql_class.cc: Statement::end_statement -> THD::end_statement() (a leftover from some design change which is not to pushed now, but the leftover is to be pushed). sql/sql_class.h: Statement::end_statement -> THD::end_statement() (a leftover from some design change which is not to pushed now, but the leftover is to be pushed). sql/sql_lex.cc: Move the part responsible for initializing LEX from mysql_init_query to lex_start. sql/sql_lex.h: All lex-related initialization is now in lex_start. Move thd->select_number to lex->select_number to be able to use it easily in lex_start. sql/sql_parse.cc: Split mysql_init_query into two functions: mysql_reset_thd_for_next_query, which is used in PS and conventional execution, and lex_start, used only when we want to parse something. Fix init_connect to use initialized THD. sql/sql_prepare.cc: Deploy mysql_reset_thd_for_next_query to reset THD state before execution of a prepared statement. Normally this should have been added to just one place, but we have to reset thd before assigning placeholders from variables, thus we can't do that in execute_stmt (yuck).
21 years ago
A fix and test case for Bug#5985 ""prepare stmt from "select rand(?)" crashes server." The fix makes Item_func_rand prepared-statements aware plus it fixes the case when RAND is used in prepared statements and replication is on (as well as several similar issues). Until now we did not reset THD before every execution of a prepared statement, so if some execution had set thd->time_zone_used or thd->rand_used they would not be reset until next mysql_parse. Some of post-review fixes done. mysql-test/r/ps.result: A test case for Bug#5985: test results fixed. mysql-test/t/ps.test: A test case for Bug#5985 "prepare stmt from "select rand(?)" crashes server." sql/item_func.cc: Actual fix for Bug#5985: Item_func_rand rewritten to be prepared statements aware. sql/item_func.h: Actual fix for Bug#5985: Item_func_rand rewritten to be prepared statements aware. sql/mysql_priv.h: We need a separate call to reset THD state before every execute of a prepared statement. Otherwise things like THD->user_var_events are never cleaned up and bloat binary log (as the list of events grows from execution to execution). sql/sql_class.cc: Statement::end_statement -> THD::end_statement() (a leftover from some design change which is not to pushed now, but the leftover is to be pushed). sql/sql_class.h: Statement::end_statement -> THD::end_statement() (a leftover from some design change which is not to pushed now, but the leftover is to be pushed). sql/sql_lex.cc: Move the part responsible for initializing LEX from mysql_init_query to lex_start. sql/sql_lex.h: All lex-related initialization is now in lex_start. Move thd->select_number to lex->select_number to be able to use it easily in lex_start. sql/sql_parse.cc: Split mysql_init_query into two functions: mysql_reset_thd_for_next_query, which is used in PS and conventional execution, and lex_start, used only when we want to parse something. Fix init_connect to use initialized THD. sql/sql_prepare.cc: Deploy mysql_reset_thd_for_next_query to reset THD state before execution of a prepared statement. Normally this should have been added to just one place, but we have to reset thd before assigning placeholders from variables, thus we can't do that in execute_stmt (yuck).
21 years ago
A fix and test case for Bug#5985 ""prepare stmt from "select rand(?)" crashes server." The fix makes Item_func_rand prepared-statements aware plus it fixes the case when RAND is used in prepared statements and replication is on (as well as several similar issues). Until now we did not reset THD before every execution of a prepared statement, so if some execution had set thd->time_zone_used or thd->rand_used they would not be reset until next mysql_parse. Some of post-review fixes done. mysql-test/r/ps.result: A test case for Bug#5985: test results fixed. mysql-test/t/ps.test: A test case for Bug#5985 "prepare stmt from "select rand(?)" crashes server." sql/item_func.cc: Actual fix for Bug#5985: Item_func_rand rewritten to be prepared statements aware. sql/item_func.h: Actual fix for Bug#5985: Item_func_rand rewritten to be prepared statements aware. sql/mysql_priv.h: We need a separate call to reset THD state before every execute of a prepared statement. Otherwise things like THD->user_var_events are never cleaned up and bloat binary log (as the list of events grows from execution to execution). sql/sql_class.cc: Statement::end_statement -> THD::end_statement() (a leftover from some design change which is not to pushed now, but the leftover is to be pushed). sql/sql_class.h: Statement::end_statement -> THD::end_statement() (a leftover from some design change which is not to pushed now, but the leftover is to be pushed). sql/sql_lex.cc: Move the part responsible for initializing LEX from mysql_init_query to lex_start. sql/sql_lex.h: All lex-related initialization is now in lex_start. Move thd->select_number to lex->select_number to be able to use it easily in lex_start. sql/sql_parse.cc: Split mysql_init_query into two functions: mysql_reset_thd_for_next_query, which is used in PS and conventional execution, and lex_start, used only when we want to parse something. Fix init_connect to use initialized THD. sql/sql_prepare.cc: Deploy mysql_reset_thd_for_next_query to reset THD state before execution of a prepared statement. Normally this should have been added to just one place, but we have to reset thd before assigning placeholders from variables, thus we can't do that in execute_stmt (yuck).
21 years ago
A fix and test case for Bug#5985 ""prepare stmt from "select rand(?)" crashes server." The fix makes Item_func_rand prepared-statements aware plus it fixes the case when RAND is used in prepared statements and replication is on (as well as several similar issues). Until now we did not reset THD before every execution of a prepared statement, so if some execution had set thd->time_zone_used or thd->rand_used they would not be reset until next mysql_parse. Some of post-review fixes done. mysql-test/r/ps.result: A test case for Bug#5985: test results fixed. mysql-test/t/ps.test: A test case for Bug#5985 "prepare stmt from "select rand(?)" crashes server." sql/item_func.cc: Actual fix for Bug#5985: Item_func_rand rewritten to be prepared statements aware. sql/item_func.h: Actual fix for Bug#5985: Item_func_rand rewritten to be prepared statements aware. sql/mysql_priv.h: We need a separate call to reset THD state before every execute of a prepared statement. Otherwise things like THD->user_var_events are never cleaned up and bloat binary log (as the list of events grows from execution to execution). sql/sql_class.cc: Statement::end_statement -> THD::end_statement() (a leftover from some design change which is not to pushed now, but the leftover is to be pushed). sql/sql_class.h: Statement::end_statement -> THD::end_statement() (a leftover from some design change which is not to pushed now, but the leftover is to be pushed). sql/sql_lex.cc: Move the part responsible for initializing LEX from mysql_init_query to lex_start. sql/sql_lex.h: All lex-related initialization is now in lex_start. Move thd->select_number to lex->select_number to be able to use it easily in lex_start. sql/sql_parse.cc: Split mysql_init_query into two functions: mysql_reset_thd_for_next_query, which is used in PS and conventional execution, and lex_start, used only when we want to parse something. Fix init_connect to use initialized THD. sql/sql_prepare.cc: Deploy mysql_reset_thd_for_next_query to reset THD state before execution of a prepared statement. Normally this should have been added to just one place, but we have to reset thd before assigning placeholders from variables, thus we can't do that in execute_stmt (yuck).
21 years ago
21 years ago
20 years ago
21 years ago
20 years ago
Bug#31177: Server variables can't be set to their current values Default values of variables were not subject to upper/lower bounds and step, while setting variables was. Bounds and step are also applied to defaults now; defaults are corrected quietly, values given by the user are corrected, and a correction-warning is thrown as needed. Lastly, very large values could wrap around, starting from 0 again. They are bounded at the maximum value for the respective data-type now if no lower maximum is specified in the variable's definition. client/mysql.cc: correct maxima in options array client/mysqltest.c: adjust minimum for "sleep" option so default value is no longer out of bounds. include/m_string.h: ullstr() - the unsigned brother of llstr() include/my_getopt.h: Flag if we bounded the value (that is, correct anything aside from making value a multiple of block-size) mysql-test/r/delayed.result: We throw a warning now when we adjust out of range parameters. mysql-test/r/index_merge.result: We throw a warning now when we adjust out of range parameters. mysql-test/r/innodb.result: We throw a warning now when we adjust out of range parameters. mysql-test/r/innodb_mysql.result: We throw a warning now when we adjust out of range parameters. mysql-test/r/key_cache.result: We throw a warning now when we adjust out of range parameters. mysql-test/r/packet.result: We throw a warning now when we adjust out of range parameters. mysql-test/r/ps.result: We throw a warning now when we adjust out of range parameters. mysql-test/r/subselect.result: We throw a warning now when we adjust out of range parameters. mysql-test/r/type_bit.result: We throw a warning now when we adjust out of range parameters. mysql-test/r/type_bit_innodb.result: We throw a warning now when we adjust out of range parameters. mysql-test/r/variables.result: correct results: bounds and step apply to variables' default values, too mysql-test/t/variables.test: correct results: bounds and step apply to variables' default values, too mysys/my_getopt.c: - apply bounds/step to default values of variables (based on work by serg) - print complaints about incorrect values for variables (truncation etc., by requestion of consulting) - if no lower maximum is specified in variable definition, bound unsigned values at their maximum to prevent wrap-around - some calls to error_reporter had a \n, some didn't. remove \n from calls, let reporter-function handle it, so the default reporter behaves like that in mysqld sql/mysql_priv.h: correct RANGE_ALLOC_BLOCK_SIZE (cleared with monty) sql/mysqld.cc: correct maxima to correct data-type. correct minima where higher than default. correct range-alloc-block-size. correct inno variables so GET_* corresponds to actual variable's type. sql/set_var.cc: When the new value for a variable is out of bounds, we'll send the client a warning (but not if the value was simply not a multiple of 'blocksize'). sys_var_thd_ulong had this, sys_var_long_ptr_global didn't; broken out and streamlined to avoid duplication of code. strings/llstr.c: ullstr() - the unsigned brother of llstr()
18 years ago
A fix and a test case for Bug#16365 "Prepared Statements: DoS with too many open statements". The patch adds a new global variable @@max_prepared_stmt_count. This variable limits the total number of prepared statements in the server. The default value of @@max_prepared_stmt_count is 16382. 16382 small statements (a select against 3 tables with GROUP, ORDER and LIMIT) consume 100MB of RAM. Once this limit has been reached, the server will refuse to prepare a new statement and return ER_UNKNOWN_ERROR (unfortunately, we can't add new errors to 4.1 without breaking 5.0). The limit is changeable after startup and can accept any value from 0 to 1 million. In case the new value of the limit is less than the current statement count, no new statements can be added, while the old still can be used. Additionally, the current count of prepared statements is now available through a global read-only variable @@prepared_stmt_count. mysql-test/r/ps.result: Test results fixed (a test case for Bug#16365) mysql-test/t/ps.test: A test case for Bug#16365 "Prepared Statements: DoS with too many open statements". Also fix statement leaks in other tests. sql/mysql_priv.h: Add declarations for new global variables. sql/mysqld.cc: Add definitions of max_prepared_stmt_count, prepared_stmt_count. sql/set_var.cc: Implement support for @@prepared_stmt_count and @@max_prepared_stmt_count. Currently these variables are queried without acquiring LOCK_prepared_stmt_count due to limitations of the set_var/sys_var class design. Updates are, however, protected with a lock. sql/set_var.h: New declarations to add support for @@max_prepared_stmt_count. Implement a new class, where the lock to be used when updating a variable is a parameter. sql/sql_class.cc: Add accounting of the total number of prepared statements in the server to the methods of Statement_map. sql/sql_class.h: Add accounting of the total number of prepared statements in the server to the methods of Statement_map. sql/sql_prepare.cc: Statement_map::insert will now send a message in case of an error.
20 years ago
A fix and test cases for Bug#4968 "Stored procedure crash if cursor opened on altered table" Bug#19733 "Repeated alter, or repeated create/drop, fails" Bug#19182 "CREATE TABLE bar (m INT) SELECT n FROM foo; doesn't work from stored procedure." Bug#6895 "Prepared Statements: ALTER TABLE DROP COLUMN does nothing" Bug#22060 "ALTER TABLE x AUTO_INCREMENT=y in SP crashes server" Test cases for bugs 4968, 19733, 6895 will be added in 5.0. Re-execution of CREATE DATABASE, CREATE TABLE and ALTER TABLE statements in stored routines or as prepared statements caused incorrect results (and crashes in versions prior to 5.0.25). In 5.1 the problem occured only for CREATE DATABASE, CREATE TABLE SELECT and CREATE TABLE with INDEX/DATA DIRECTOY options). The problem of bugs 4968, 19733, 19282 and 6895 was that functions mysql_prepare_table, mysql_create_table and mysql_alter_table were not re-execution friendly: during their operation they used to modify contents of LEX (members create_info, alter_info, key_list, create_list), thus making the LEX unusable for the next execution. In particular, these functions removed processed columns and keys from create_list, key_list and drop_list. Search the code in sql_table.cc for drop_it.remove() and similar patterns to find evidence. The fix is to supply to these functions a usable copy of each of the above structures at every re-execution of an SQL statement. To simplify memory management, LEX::key_list and LEX::create_list were added to LEX::alter_info, a fresh copy of which is created for every execution. The problem of crashing bug 22060 stemmed from the fact that the above metnioned functions were not only modifying HA_CREATE_INFO structure in LEX, but also were changing it to point to areas in volatile memory of the execution memory root. The patch solves this problem by creating and using an on-stack copy of HA_CREATE_INFO (note that code in 5.1 already creates and uses a copy of this structure in mysql_create_table()/alter_table(), but this approach didn't work well for CREATE TABLE SELECT statement). mysql-test/r/ps.result: Update test results (Bug#19182, Bug#22060) mysql-test/t/ps.test: Add a test case for Bug#19182, Bug#22060 (4.1-only parts) sql/mysql_priv.h: LEX::key_list and LEX::create_list were moved to LEX::alter_info. Update declarations to use LEX::alter_info instead of these two members. sql/sql_class.h: Replace pair<columns, keys> with an instance of Alter_info in select_create constructor. We create a new copy of Alter_info each time we re-execute SELECT .. CREATE prepared statement. sql/sql_insert.cc: Adjust to a new signature of create_table_from_items. sql/sql_lex.cc: Implement Alter_info::Alter_info that would make a "deep" copy of all definition lists (keys, columns). sql/sql_lex.h: Move key_list and create_list to class Alter_info. Implement Alter_info::Alter_info that can be used with PS and SP. sql/sql_list.h: Implement a copy constructor of class List that makes a deep copy of all list nodes. sql/sql_parse.cc: Adjust to new signatures of mysql_create_table, mysql_alter_table, select_create. Functions mysql_create_index and mysql_drop_index has become identical after initialization of alter_info was moved to the parser, and were merged. Flag enable_slow_log was not updated for SQLCOM_DROP_INDEX, which is a bug. Just like CREATE INDEX, DROP INDEX is currently done via complete table rebuild and is rightfully a slow administrative statement. sql/sql_show.cc: Adjust mysqld_show_create_db to a new signature. sql/sql_table.cc: Adjust mysql_alter_table, mysql_recreate_table, mysql_create_table, mysql_prepare_table to new signatures. sql/sql_yacc.yy: LEX::key_list and LEX::create_list moved to class Alter_info
19 years ago
A fix and test cases for Bug#4968 "Stored procedure crash if cursor opened on altered table" Bug#19733 "Repeated alter, or repeated create/drop, fails" Bug#19182 "CREATE TABLE bar (m INT) SELECT n FROM foo; doesn't work from stored procedure." Bug#6895 "Prepared Statements: ALTER TABLE DROP COLUMN does nothing" Bug#22060 "ALTER TABLE x AUTO_INCREMENT=y in SP crashes server" Test cases for bugs 4968, 19733, 6895 will be added in 5.0. Re-execution of CREATE DATABASE, CREATE TABLE and ALTER TABLE statements in stored routines or as prepared statements caused incorrect results (and crashes in versions prior to 5.0.25). In 5.1 the problem occured only for CREATE DATABASE, CREATE TABLE SELECT and CREATE TABLE with INDEX/DATA DIRECTOY options). The problem of bugs 4968, 19733, 19282 and 6895 was that functions mysql_prepare_table, mysql_create_table and mysql_alter_table were not re-execution friendly: during their operation they used to modify contents of LEX (members create_info, alter_info, key_list, create_list), thus making the LEX unusable for the next execution. In particular, these functions removed processed columns and keys from create_list, key_list and drop_list. Search the code in sql_table.cc for drop_it.remove() and similar patterns to find evidence. The fix is to supply to these functions a usable copy of each of the above structures at every re-execution of an SQL statement. To simplify memory management, LEX::key_list and LEX::create_list were added to LEX::alter_info, a fresh copy of which is created for every execution. The problem of crashing bug 22060 stemmed from the fact that the above metnioned functions were not only modifying HA_CREATE_INFO structure in LEX, but also were changing it to point to areas in volatile memory of the execution memory root. The patch solves this problem by creating and using an on-stack copy of HA_CREATE_INFO (note that code in 5.1 already creates and uses a copy of this structure in mysql_create_table()/alter_table(), but this approach didn't work well for CREATE TABLE SELECT statement). mysql-test/r/ps.result: Update test results (Bug#19182, Bug#22060) mysql-test/t/ps.test: Add a test case for Bug#19182, Bug#22060 (4.1-only parts) sql/mysql_priv.h: LEX::key_list and LEX::create_list were moved to LEX::alter_info. Update declarations to use LEX::alter_info instead of these two members. sql/sql_class.h: Replace pair<columns, keys> with an instance of Alter_info in select_create constructor. We create a new copy of Alter_info each time we re-execute SELECT .. CREATE prepared statement. sql/sql_insert.cc: Adjust to a new signature of create_table_from_items. sql/sql_lex.cc: Implement Alter_info::Alter_info that would make a "deep" copy of all definition lists (keys, columns). sql/sql_lex.h: Move key_list and create_list to class Alter_info. Implement Alter_info::Alter_info that can be used with PS and SP. sql/sql_list.h: Implement a copy constructor of class List that makes a deep copy of all list nodes. sql/sql_parse.cc: Adjust to new signatures of mysql_create_table, mysql_alter_table, select_create. Functions mysql_create_index and mysql_drop_index has become identical after initialization of alter_info was moved to the parser, and were merged. Flag enable_slow_log was not updated for SQLCOM_DROP_INDEX, which is a bug. Just like CREATE INDEX, DROP INDEX is currently done via complete table rebuild and is rightfully a slow administrative statement. sql/sql_show.cc: Adjust mysqld_show_create_db to a new signature. sql/sql_table.cc: Adjust mysql_alter_table, mysql_recreate_table, mysql_create_table, mysql_prepare_table to new signatures. sql/sql_yacc.yy: LEX::key_list and LEX::create_list moved to class Alter_info
19 years ago
A fix and test cases for Bug#4968 "Stored procedure crash if cursor opened on altered table" Bug#19733 "Repeated alter, or repeated create/drop, fails" Bug#19182 "CREATE TABLE bar (m INT) SELECT n FROM foo; doesn't work from stored procedure." Bug#6895 "Prepared Statements: ALTER TABLE DROP COLUMN does nothing" Bug#22060 "ALTER TABLE x AUTO_INCREMENT=y in SP crashes server" Test cases for bugs 4968, 19733, 6895 will be added in 5.0. Re-execution of CREATE DATABASE, CREATE TABLE and ALTER TABLE statements in stored routines or as prepared statements caused incorrect results (and crashes in versions prior to 5.0.25). In 5.1 the problem occured only for CREATE DATABASE, CREATE TABLE SELECT and CREATE TABLE with INDEX/DATA DIRECTOY options). The problem of bugs 4968, 19733, 19282 and 6895 was that functions mysql_prepare_table, mysql_create_table and mysql_alter_table were not re-execution friendly: during their operation they used to modify contents of LEX (members create_info, alter_info, key_list, create_list), thus making the LEX unusable for the next execution. In particular, these functions removed processed columns and keys from create_list, key_list and drop_list. Search the code in sql_table.cc for drop_it.remove() and similar patterns to find evidence. The fix is to supply to these functions a usable copy of each of the above structures at every re-execution of an SQL statement. To simplify memory management, LEX::key_list and LEX::create_list were added to LEX::alter_info, a fresh copy of which is created for every execution. The problem of crashing bug 22060 stemmed from the fact that the above metnioned functions were not only modifying HA_CREATE_INFO structure in LEX, but also were changing it to point to areas in volatile memory of the execution memory root. The patch solves this problem by creating and using an on-stack copy of HA_CREATE_INFO (note that code in 5.1 already creates and uses a copy of this structure in mysql_create_table()/alter_table(), but this approach didn't work well for CREATE TABLE SELECT statement). mysql-test/r/ps.result: Update test results (Bug#19182, Bug#22060) mysql-test/t/ps.test: Add a test case for Bug#19182, Bug#22060 (4.1-only parts) sql/mysql_priv.h: LEX::key_list and LEX::create_list were moved to LEX::alter_info. Update declarations to use LEX::alter_info instead of these two members. sql/sql_class.h: Replace pair<columns, keys> with an instance of Alter_info in select_create constructor. We create a new copy of Alter_info each time we re-execute SELECT .. CREATE prepared statement. sql/sql_insert.cc: Adjust to a new signature of create_table_from_items. sql/sql_lex.cc: Implement Alter_info::Alter_info that would make a "deep" copy of all definition lists (keys, columns). sql/sql_lex.h: Move key_list and create_list to class Alter_info. Implement Alter_info::Alter_info that can be used with PS and SP. sql/sql_list.h: Implement a copy constructor of class List that makes a deep copy of all list nodes. sql/sql_parse.cc: Adjust to new signatures of mysql_create_table, mysql_alter_table, select_create. Functions mysql_create_index and mysql_drop_index has become identical after initialization of alter_info was moved to the parser, and were merged. Flag enable_slow_log was not updated for SQLCOM_DROP_INDEX, which is a bug. Just like CREATE INDEX, DROP INDEX is currently done via complete table rebuild and is rightfully a slow administrative statement. sql/sql_show.cc: Adjust mysqld_show_create_db to a new signature. sql/sql_table.cc: Adjust mysql_alter_table, mysql_recreate_table, mysql_create_table, mysql_prepare_table to new signatures. sql/sql_yacc.yy: LEX::key_list and LEX::create_list moved to class Alter_info
19 years ago
19 years ago
18 years ago
BUG#26976 - Missing table in merge not noted in related error msg + SHOW CREATE TABLE fails Underlying table names, that merge engine fails to open were not reported. With this fix CHECK TABLE issued against merge table reports all underlying table names that it fails to open. Other statements are unaffected, that is underlying table names are not included into error message. This fix doesn't solve SHOW CREATE TABLE issue. myisammrg/myrg_def.h: Added myrg_print_wrong_table declaration. myisammrg/myrg_open.c: If HA_OPEN_FOR_REPAIR is passed to merge engine open function, report names of tables that we fail to open. mysql-test/r/backup.result: Updated test result. mysql-test/r/key_cache.result: Updated test result - removed duplicate error. mysql-test/r/lock.result: Updated test result - added summary row. mysql-test/r/merge.result: A test case for BUG#26976. mysql-test/r/preload.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/ps.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/repair.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/rpl_failed_optimize.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/sp.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/view.result: Updated test result - removed duplicate error, added summary row. mysql-test/t/merge.test: A test case for BUG#26976. sql/ha_myisam.cc: Do not report same error twice. sql/ha_myisammrg.cc: If HA_OPEN_FOR_REPAIR is passed to merge engine open function, report names of tables that we fail to open. Added dummy ha_myisammrg::check to not confuse users with "not implemented" error in case all underlying tables are fine. sql/ha_myisammrg.h: Added ha_myisammrg::check declaration. sql/share/errmsg.txt: Added ER_ADMIN_WRONG_MRG_TABLE errno. It is used instead of ER_WRONG_MRG_TABLE in case HA_OPEN_FOR_REPAIR is passed to merge engine handler open function. sql/sql_error.cc: warning_level_* are now public. It is required by mysql_admin_table to report message level. sql/sql_error.h: warning_level_* are now public. It is required by mysql_admin_table to report message level. sql/sql_table.cc: Reorder mysql_admin_table arguments to meet it's definition. Report errors that are pending in thd->warn_list as results of admin function.
19 years ago
BUG#26976 - Missing table in merge not noted in related error msg + SHOW CREATE TABLE fails Underlying table names, that merge engine fails to open were not reported. With this fix CHECK TABLE issued against merge table reports all underlying table names that it fails to open. Other statements are unaffected, that is underlying table names are not included into error message. This fix doesn't solve SHOW CREATE TABLE issue. myisammrg/myrg_def.h: Added myrg_print_wrong_table declaration. myisammrg/myrg_open.c: If HA_OPEN_FOR_REPAIR is passed to merge engine open function, report names of tables that we fail to open. mysql-test/r/backup.result: Updated test result. mysql-test/r/key_cache.result: Updated test result - removed duplicate error. mysql-test/r/lock.result: Updated test result - added summary row. mysql-test/r/merge.result: A test case for BUG#26976. mysql-test/r/preload.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/ps.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/repair.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/rpl_failed_optimize.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/sp.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/view.result: Updated test result - removed duplicate error, added summary row. mysql-test/t/merge.test: A test case for BUG#26976. sql/ha_myisam.cc: Do not report same error twice. sql/ha_myisammrg.cc: If HA_OPEN_FOR_REPAIR is passed to merge engine open function, report names of tables that we fail to open. Added dummy ha_myisammrg::check to not confuse users with "not implemented" error in case all underlying tables are fine. sql/ha_myisammrg.h: Added ha_myisammrg::check declaration. sql/share/errmsg.txt: Added ER_ADMIN_WRONG_MRG_TABLE errno. It is used instead of ER_WRONG_MRG_TABLE in case HA_OPEN_FOR_REPAIR is passed to merge engine handler open function. sql/sql_error.cc: warning_level_* are now public. It is required by mysql_admin_table to report message level. sql/sql_error.h: warning_level_* are now public. It is required by mysql_admin_table to report message level. sql/sql_table.cc: Reorder mysql_admin_table arguments to meet it's definition. Report errors that are pending in thd->warn_list as results of admin function.
19 years ago
BUG#26976 - Missing table in merge not noted in related error msg + SHOW CREATE TABLE fails Underlying table names, that merge engine fails to open were not reported. With this fix CHECK TABLE issued against merge table reports all underlying table names that it fails to open. Other statements are unaffected, that is underlying table names are not included into error message. This fix doesn't solve SHOW CREATE TABLE issue. myisammrg/myrg_def.h: Added myrg_print_wrong_table declaration. myisammrg/myrg_open.c: If HA_OPEN_FOR_REPAIR is passed to merge engine open function, report names of tables that we fail to open. mysql-test/r/backup.result: Updated test result. mysql-test/r/key_cache.result: Updated test result - removed duplicate error. mysql-test/r/lock.result: Updated test result - added summary row. mysql-test/r/merge.result: A test case for BUG#26976. mysql-test/r/preload.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/ps.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/repair.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/rpl_failed_optimize.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/sp.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/view.result: Updated test result - removed duplicate error, added summary row. mysql-test/t/merge.test: A test case for BUG#26976. sql/ha_myisam.cc: Do not report same error twice. sql/ha_myisammrg.cc: If HA_OPEN_FOR_REPAIR is passed to merge engine open function, report names of tables that we fail to open. Added dummy ha_myisammrg::check to not confuse users with "not implemented" error in case all underlying tables are fine. sql/ha_myisammrg.h: Added ha_myisammrg::check declaration. sql/share/errmsg.txt: Added ER_ADMIN_WRONG_MRG_TABLE errno. It is used instead of ER_WRONG_MRG_TABLE in case HA_OPEN_FOR_REPAIR is passed to merge engine handler open function. sql/sql_error.cc: warning_level_* are now public. It is required by mysql_admin_table to report message level. sql/sql_error.h: warning_level_* are now public. It is required by mysql_admin_table to report message level. sql/sql_table.cc: Reorder mysql_admin_table arguments to meet it's definition. Report errors that are pending in thd->warn_list as results of admin function.
19 years ago
BUG#26976 - Missing table in merge not noted in related error msg + SHOW CREATE TABLE fails Underlying table names, that merge engine fails to open were not reported. With this fix CHECK TABLE issued against merge table reports all underlying table names that it fails to open. Other statements are unaffected, that is underlying table names are not included into error message. This fix doesn't solve SHOW CREATE TABLE issue. myisammrg/myrg_def.h: Added myrg_print_wrong_table declaration. myisammrg/myrg_open.c: If HA_OPEN_FOR_REPAIR is passed to merge engine open function, report names of tables that we fail to open. mysql-test/r/backup.result: Updated test result. mysql-test/r/key_cache.result: Updated test result - removed duplicate error. mysql-test/r/lock.result: Updated test result - added summary row. mysql-test/r/merge.result: A test case for BUG#26976. mysql-test/r/preload.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/ps.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/repair.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/rpl_failed_optimize.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/sp.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/view.result: Updated test result - removed duplicate error, added summary row. mysql-test/t/merge.test: A test case for BUG#26976. sql/ha_myisam.cc: Do not report same error twice. sql/ha_myisammrg.cc: If HA_OPEN_FOR_REPAIR is passed to merge engine open function, report names of tables that we fail to open. Added dummy ha_myisammrg::check to not confuse users with "not implemented" error in case all underlying tables are fine. sql/ha_myisammrg.h: Added ha_myisammrg::check declaration. sql/share/errmsg.txt: Added ER_ADMIN_WRONG_MRG_TABLE errno. It is used instead of ER_WRONG_MRG_TABLE in case HA_OPEN_FOR_REPAIR is passed to merge engine handler open function. sql/sql_error.cc: warning_level_* are now public. It is required by mysql_admin_table to report message level. sql/sql_error.h: warning_level_* are now public. It is required by mysql_admin_table to report message level. sql/sql_table.cc: Reorder mysql_admin_table arguments to meet it's definition. Report errors that are pending in thd->warn_list as results of admin function.
19 years ago
BUG#26976 - Missing table in merge not noted in related error msg + SHOW CREATE TABLE fails Underlying table names, that merge engine fails to open were not reported. With this fix CHECK TABLE issued against merge table reports all underlying table names that it fails to open. Other statements are unaffected, that is underlying table names are not included into error message. This fix doesn't solve SHOW CREATE TABLE issue. myisammrg/myrg_def.h: Added myrg_print_wrong_table declaration. myisammrg/myrg_open.c: If HA_OPEN_FOR_REPAIR is passed to merge engine open function, report names of tables that we fail to open. mysql-test/r/backup.result: Updated test result. mysql-test/r/key_cache.result: Updated test result - removed duplicate error. mysql-test/r/lock.result: Updated test result - added summary row. mysql-test/r/merge.result: A test case for BUG#26976. mysql-test/r/preload.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/ps.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/repair.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/rpl_failed_optimize.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/sp.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/view.result: Updated test result - removed duplicate error, added summary row. mysql-test/t/merge.test: A test case for BUG#26976. sql/ha_myisam.cc: Do not report same error twice. sql/ha_myisammrg.cc: If HA_OPEN_FOR_REPAIR is passed to merge engine open function, report names of tables that we fail to open. Added dummy ha_myisammrg::check to not confuse users with "not implemented" error in case all underlying tables are fine. sql/ha_myisammrg.h: Added ha_myisammrg::check declaration. sql/share/errmsg.txt: Added ER_ADMIN_WRONG_MRG_TABLE errno. It is used instead of ER_WRONG_MRG_TABLE in case HA_OPEN_FOR_REPAIR is passed to merge engine handler open function. sql/sql_error.cc: warning_level_* are now public. It is required by mysql_admin_table to report message level. sql/sql_error.h: warning_level_* are now public. It is required by mysql_admin_table to report message level. sql/sql_table.cc: Reorder mysql_admin_table arguments to meet it's definition. Report errors that are pending in thd->warn_list as results of admin function.
19 years ago
BUG#26976 - Missing table in merge not noted in related error msg + SHOW CREATE TABLE fails Underlying table names, that merge engine fails to open were not reported. With this fix CHECK TABLE issued against merge table reports all underlying table names that it fails to open. Other statements are unaffected, that is underlying table names are not included into error message. This fix doesn't solve SHOW CREATE TABLE issue. myisammrg/myrg_def.h: Added myrg_print_wrong_table declaration. myisammrg/myrg_open.c: If HA_OPEN_FOR_REPAIR is passed to merge engine open function, report names of tables that we fail to open. mysql-test/r/backup.result: Updated test result. mysql-test/r/key_cache.result: Updated test result - removed duplicate error. mysql-test/r/lock.result: Updated test result - added summary row. mysql-test/r/merge.result: A test case for BUG#26976. mysql-test/r/preload.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/ps.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/repair.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/rpl_failed_optimize.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/sp.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/view.result: Updated test result - removed duplicate error, added summary row. mysql-test/t/merge.test: A test case for BUG#26976. sql/ha_myisam.cc: Do not report same error twice. sql/ha_myisammrg.cc: If HA_OPEN_FOR_REPAIR is passed to merge engine open function, report names of tables that we fail to open. Added dummy ha_myisammrg::check to not confuse users with "not implemented" error in case all underlying tables are fine. sql/ha_myisammrg.h: Added ha_myisammrg::check declaration. sql/share/errmsg.txt: Added ER_ADMIN_WRONG_MRG_TABLE errno. It is used instead of ER_WRONG_MRG_TABLE in case HA_OPEN_FOR_REPAIR is passed to merge engine handler open function. sql/sql_error.cc: warning_level_* are now public. It is required by mysql_admin_table to report message level. sql/sql_error.h: warning_level_* are now public. It is required by mysql_admin_table to report message level. sql/sql_table.cc: Reorder mysql_admin_table arguments to meet it's definition. Report errors that are pending in thd->warn_list as results of admin function.
19 years ago
A fix and a test case for Bug#19022 "Memory bug when switching db during trigger execution" Bug#17199 "Problem when view calls function from another database." Bug#18444 "Fully qualified stored function names don't work correctly in SELECT statements" Documentation note: this patch introduces a change in behaviour of prepared statements. This patch adds a few new invariants with regard to how THD::db should be used. These invariants should be preserved in future: - one should never refer to THD::db by pointer and always make a deep copy (strmake, strdup) - one should never compare two databases by pointer, but use strncmp or my_strncasecmp - TABLE_LIST object table->db should be always initialized in the parser or by creator of the object. For prepared statements it means that if the current database is changed after a statement is prepared, the database that was current at prepare remains active. This also means that you can not prepare a statement that implicitly refers to the current database if the latter is not set. This is not documented, and therefore needs documentation. This is NOT a change in behavior for almost all SQL statements except: - ALTER TABLE t1 RENAME t2 - OPTIMIZE TABLE t1 - ANALYZE TABLE t1 - TRUNCATE TABLE t1 -- until this patch t1 or t2 could be evaluated at the first execution of prepared statement. CURRENT_DATABASE() still works OK and is evaluated at every execution of prepared statement. Note, that in stored routines this is not an issue as the default database is the database of the stored procedure and "use" statement is prohibited in stored routines. This patch makes obsolete the use of check_db_used (it was never used in the old code too) and all other places that check for table->db and assign it from THD::db if it's NULL, except the parser. How this patch was created: THD::{db,db_length} were replaced with a LEX_STRING, THD::db. All the places that refer to THD::{db,db_length} were manually checked and: - if the place uses thd->db by pointer, it was fixed to make a deep copy - if a place compared two db pointers, it was fixed to compare them by value (via strcmp/my_strcasecmp, whatever was approproate) Then this intermediate patch was used to write a smaller patch that does the same thing but without a rename. TODO in 5.1: - remove check_db_used - deploy THD::set_db in mysql_change_db See also comments to individual files. mysql-test/r/create.result: Modify the result file: a database can never be NULL. mysql-test/r/ps.result: Update test results (Bug#17199 et al) mysql-test/r/sp.result: Update test results (Bug#17199 et al) mysql-test/t/create.test: Update the id of the returned error. mysql-test/t/ps.test: Add test coverage for prepared statements and current database. In scope of work on Bug#17199 "Problem when view calls function from another database." mysql-test/t/sp.test: Add a test case for Bug#17199 "Problem when view calls function from another database." and Bug#18444 "Fully qualified stored function names don't work correctly in SELECT statements". Test a complementary problem. sql/item_strfunc.cc: Touch the code that reads thd->db (cleanup). sql/log_event.cc: While we are at it, replace direct access to thd->db with a method. Should simplify future conversion of THD::db to LEX_STRING. sql/slave.cc: While we are at it, replace direct access to thd->db with a method. Should simplify future conversion of THD::db to LEX_STRING. sql/slave.h: Remove a declaration for a method that is used only in one module. sql/sp.cc: Rewrite sp_use_new_db: this is a cleanup that I needed in order to understand this function and ensure that it has no bugs. sql/sp.h: Add a new declaration for sp_use_new_db (uses LEX_STRINGs) and a comment. sql/sp_head.cc: - drop sp_name_current_db_new - a creator of sp_name class that was used when sp_name was created for an identifier without an explicitly initialized database. Now we pass thd->db to constructor of sp_name right in the parser. - rewrite sp_head::init_strings: name->m_db is always set now - use the new variant of sp_use_new_db - we don't need to update thd->db with SP MEM_ROOT pointer anymore when parsing a stored procedure, as noone will refer to it (yes!) sql/sp_head.h: - remove unneded methods and members sql/sql_class.h: - introduce 3 THD methods to work with THD::db: .set_db to assign the current database .reset_db to reset the current database (temporarily) or set it to NULL .opt_copy_db_to - to deep-copy thd->db to a pointer if it's not NULL sql/sql_db.cc: While we are at it, replace direct access to thd->db with a method. Should simplify future conversion of THD::db to LEX_STRING. sql/sql_insert.cc: - replace checks with asserts: table_list->db must be always set in the parser. sql/sql_lex.h: - add a comment sql/sql_parse.cc: - implement the invariant described in the changeset comment. - remove juggling with lex->sphead in SQLCOM_CREATE_PROCEDURE: now db_load_routine uses its own LEX object and doesn't damage the main LEX. - add DBUG_ASSERT(0) to unused "check_db_used" sql/sql_table.cc: - replace a check with an assert (table_ident->db) sql/sql_trigger.cc: While we are at it, replace direct access to thd->db with a method. Should simplify future conversion of THD::db to LEX_STRING. sql/sql_udf.cc: - use thd->set_db instead of direct modification of to thd->db sql/sql_view.cc: - replace a check with an assert (view->db) sql/sql_yacc.yy: - make sure that we always copy table->db or name->db or ident->db or select_lex->db from thd->db if the former is not set. If thd->db is not set but is accessed, return an error. sql/tztime.cc: - be nice, never copy thd->db by pointer.
20 years ago
BUG#21856: Prepared Statements: crash if bad create When statement to be prepared contained CREATE PROCEDURE, CREATE FUNCTION or CREATE TRIGGER statements with a syntax error in it, the preparation would fail with syntax error message, but the memory could be corrupted. The problem occurred because we switch memroot when parse stored routine or trigger definitions, and on parse error we restored the original memroot only after performing some memory operations. In more detail: - prepared statement would activate its own memory root to parse the definition of the stored procedure. - SP would reset this memory root with its own memory root to parse SP statements - a syntax error would happen - prepared statement would restore the original memory root - stored procedure would restore what it thinks was the original memory root, but actually was the statement memory root. That led to double free - in destruction of the statement and in a next call to mysql_parse(). The solution is to restore memroot right after the failed parsing. mysql-test/r/ps.result: Add result for bug#21856: Prepared Statements: crash if bad create. mysql-test/t/ps.test: Add test case for bug#21856: Prepared Statements: crash if bad create. sql/sql_parse.cc: On parse error if thd->lex->sphead is set we have to free sp_head object to restore statement memroot, if it was switched during parsing. The change here is for safety, currently query_cache_abort() and lex->unit.cleanup() calls do not use current memroot. sql/sql_prepare.cc: On parse error if thd->lex->sphead is set we have to free sp_head object to restore statement memroot, if it was switched during parsing.
19 years ago
Proposed fix for bug#24491 "using alias from source table in insert ... on duplicate key". INSERT ... SELECT ... ON DUPLICATE KEY UPDATE which was used in stored routine or as prepared statement and which in its ON DUPLICATE KEY clause erroneously tried to assign value to a column mentioned only in its SELECT part was properly emitting error on the first execution but succeeded on the second and following executions. Code which is responsible for name resolution of fields mentioned in UPDATE clause (e.g. see select_insert::prepare()) modifies table list and Name_resolution_context used in this process. It uses Name_resolution_context_state::save_state/restore_state() to revert these modifications. Unfortunately those two methods failed to revert properly modifications to TABLE_LIST::next_name_resolution_table and this broke name resolution process for successive executions. This patch fixes Name_resolution_context_state::save_state/restore_state() in such way that it properly handles TABLE_LIST::next_name_resolution_table. mysql-test/r/ps.result: Added test case for bug#24491 "using alias from source table in insert ... on duplicate key" mysql-test/r/sp-error.result: Added test case for bug#24491 "using alias from source table in insert ... on duplicate key" mysql-test/t/ps.test: Added test case for bug#24491 "using alias from source table in insert ... on duplicate key" mysql-test/t/sp-error.test: Added test case for bug#24491 "using alias from source table in insert ... on duplicate key" sql/item.h: Name_resolution_context::save_state/restore_state(): At the moment these methods are used only by code implementing INSERT and INSERT ... SELECT statements. This code doesn't modify 'next_name_resolution_table' member of table list element corresponding to the first table of SELECT clause (pointed by 'first_name_resolution_table'). But it modifies table list element corresponding to the target table of INSERT (pointed by 'table_list') So these methods were changed to reflect this.
19 years ago
  1. drop table if exists t1,t2;
  2. drop database if exists client_test_db;
  3. create table t1
  4. (
  5. a int primary key,
  6. b char(10)
  7. );
  8. insert into t1 values (1,'one');
  9. insert into t1 values (2,'two');
  10. insert into t1 values (3,'three');
  11. insert into t1 values (4,'four');
  12. set @a=2;
  13. prepare stmt1 from 'select * from t1 where a <= ?';
  14. execute stmt1 using @a;
  15. a b
  16. 1 one
  17. 2 two
  18. set @a=3;
  19. execute stmt1 using @a;
  20. a b
  21. 1 one
  22. 2 two
  23. 3 three
  24. deallocate prepare no_such_statement;
  25. ERROR HY000: Unknown prepared statement handler (no_such_statement) given to DEALLOCATE PREPARE
  26. execute stmt1;
  27. ERROR HY000: Incorrect arguments to EXECUTE
  28. prepare stmt2 from 'prepare nested_stmt from "select 1"';
  29. ERROR HY000: This command is not supported in the prepared statement protocol yet
  30. prepare stmt2 from 'execute stmt1';
  31. ERROR HY000: This command is not supported in the prepared statement protocol yet
  32. prepare stmt2 from 'deallocate prepare z';
  33. ERROR HY000: This command is not supported in the prepared statement protocol yet
  34. prepare stmt3 from 'insert into t1 values (?,?)';
  35. set @arg1=5, @arg2='five';
  36. execute stmt3 using @arg1, @arg2;
  37. select * from t1 where a>3;
  38. a b
  39. 4 four
  40. 5 five
  41. prepare stmt4 from 'update t1 set a=? where b=?';
  42. set @arg1=55, @arg2='five';
  43. execute stmt4 using @arg1, @arg2;
  44. select * from t1 where a>3;
  45. a b
  46. 4 four
  47. 55 five
  48. prepare stmt4 from 'create table t2 (a int)';
  49. execute stmt4;
  50. prepare stmt4 from 'drop table t2';
  51. execute stmt4;
  52. execute stmt4;
  53. ERROR 42S02: Unknown table 't2'
  54. prepare stmt5 from 'select ? + a from t1';
  55. set @a=1;
  56. execute stmt5 using @a;
  57. ? + a
  58. 2
  59. 3
  60. 4
  61. 5
  62. 56
  63. execute stmt5 using @no_such_var;
  64. ? + a
  65. NULL
  66. NULL
  67. NULL
  68. NULL
  69. NULL
  70. set @nullvar=1;
  71. set @nullvar=NULL;
  72. execute stmt5 using @nullvar;
  73. ? + a
  74. NULL
  75. NULL
  76. NULL
  77. NULL
  78. NULL
  79. set @nullvar2=NULL;
  80. execute stmt5 using @nullvar2;
  81. ? + a
  82. NULL
  83. NULL
  84. NULL
  85. NULL
  86. NULL
  87. prepare stmt6 from 'select 1; select2';
  88. ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select2' at line 1
  89. prepare stmt6 from 'insert into t1 values (5,"five"); select2';
  90. ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select2' at line 1
  91. explain prepare stmt6 from 'insert into t1 values (5,"five"); select2';
  92. ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from 'insert into t1 values (5,"five"); select2'' at line 1
  93. create table t2
  94. (
  95. a int
  96. );
  97. insert into t2 values (0);
  98. set @arg00=NULL ;
  99. prepare stmt1 from 'select 1 FROM t2 where a=?' ;
  100. execute stmt1 using @arg00 ;
  101. 1
  102. prepare stmt1 from @nosuchvar;
  103. ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULL' at line 1
  104. set @ivar= 1234;
  105. prepare stmt1 from @ivar;
  106. ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1234' at line 1
  107. set @fvar= 123.4567;
  108. prepare stmt1 from @fvar;
  109. ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '123.4567' at line 1
  110. drop table t1,t2;
  111. deallocate prepare stmt3;
  112. deallocate prepare stmt4;
  113. deallocate prepare stmt5;
  114. PREPARE stmt1 FROM "select _utf8 'A' collate utf8_bin = ?";
  115. set @var='A';
  116. EXECUTE stmt1 USING @var;
  117. _utf8 'A' collate utf8_bin = ?
  118. 1
  119. DEALLOCATE PREPARE stmt1;
  120. create table t1 (id int);
  121. prepare stmt1 from "select FOUND_ROWS()";
  122. select SQL_CALC_FOUND_ROWS * from t1;
  123. id
  124. execute stmt1;
  125. FOUND_ROWS()
  126. 0
  127. insert into t1 values (1);
  128. select SQL_CALC_FOUND_ROWS * from t1;
  129. id
  130. 1
  131. execute stmt1;
  132. FOUND_ROWS()
  133. 1
  134. execute stmt1;
  135. FOUND_ROWS()
  136. 1
  137. deallocate prepare stmt1;
  138. drop table t1;
  139. create table t1
  140. (
  141. c1 tinyint, c2 smallint, c3 mediumint, c4 int,
  142. c5 integer, c6 bigint, c7 float, c8 double,
  143. c9 double precision, c10 real, c11 decimal(7, 4), c12 numeric(8, 4),
  144. c13 date, c14 datetime, c15 timestamp, c16 time,
  145. c17 year, c18 bit, c19 bool, c20 char,
  146. c21 char(10), c22 varchar(30), c23 tinyblob, c24 tinytext,
  147. c25 blob, c26 text, c27 mediumblob, c28 mediumtext,
  148. c29 longblob, c30 longtext, c31 enum('one', 'two', 'three'),
  149. c32 set('monday', 'tuesday', 'wednesday')
  150. ) engine = MYISAM ;
  151. create table t2 like t1;
  152. set @stmt= ' explain SELECT (SELECT SUM(c1 + c12 + 0.0) FROM t2 where (t1.c2 - 0e-3) = t2.c2 GROUP BY t1.c15 LIMIT 1) as scalar_s, exists (select 1.0e+0 from t2 where t2.c3 * 9.0000000000 = t1.c4) as exists_s, c5 * 4 in (select c6 + 0.3e+1 from t2) as in_s, (c7 - 4, c8 - 4) in (select c9 + 4.0, c10 + 40e-1 from t2) as in_row_s FROM t1, (select c25 x, c32 y from t2) tt WHERE x * 1 = c25 ' ;
  153. prepare stmt1 from @stmt ;
  154. execute stmt1 ;
  155. id select_type table type possible_keys key key_len ref rows Extra
  156. 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
  157. 6 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table
  158. 5 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
  159. 4 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
  160. 3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
  161. 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
  162. execute stmt1 ;
  163. id select_type table type possible_keys key key_len ref rows Extra
  164. 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
  165. 6 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table
  166. 5 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
  167. 4 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
  168. 3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
  169. 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
  170. explain SELECT (SELECT SUM(c1 + c12 + 0.0) FROM t2 where (t1.c2 - 0e-3) = t2.c2 GROUP BY t1.c15 LIMIT 1) as scalar_s, exists (select 1.0e+0 from t2 where t2.c3 * 9.0000000000 = t1.c4) as exists_s, c5 * 4 in (select c6 + 0.3e+1 from t2) as in_s, (c7 - 4, c8 - 4) in (select c9 + 4.0, c10 + 40e-1 from t2) as in_row_s FROM t1, (select c25 x, c32 y from t2) tt WHERE x * 1 = c25;
  171. id select_type table type possible_keys key key_len ref rows Extra
  172. 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
  173. 6 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table
  174. 5 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
  175. 4 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
  176. 3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
  177. 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
  178. deallocate prepare stmt1;
  179. drop tables t1,t2;
  180. set @arg00=1;
  181. prepare stmt1 from ' create table t1 (m int) as select 1 as m ' ;
  182. execute stmt1 ;
  183. select m from t1;
  184. m
  185. 1
  186. drop table t1;
  187. prepare stmt1 from ' create table t1 (m int) as select ? as m ' ;
  188. execute stmt1 using @arg00;
  189. select m from t1;
  190. m
  191. 1
  192. deallocate prepare stmt1;
  193. drop table t1;
  194. create table t1 (id int(10) unsigned NOT NULL default '0',
  195. name varchar(64) NOT NULL default '',
  196. PRIMARY KEY (id), UNIQUE KEY `name` (`name`));
  197. insert into t1 values (1,'1'),(2,'2'),(3,'3'),(4,'4'),(5,'5'),(6,'6'),(7,'7');
  198. prepare stmt1 from 'select name from t1 where id=? or id=?';
  199. set @id1=1,@id2=6;
  200. execute stmt1 using @id1, @id2;
  201. name
  202. 1
  203. 6
  204. select name from t1 where id=1 or id=6;
  205. name
  206. 1
  207. 6
  208. deallocate prepare stmt1;
  209. drop table t1;
  210. create table t1 ( a int primary key, b varchar(30)) engine = MYISAM ;
  211. prepare stmt1 from ' show table status from test like ''t1%'' ';
  212. execute stmt1;
  213. 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
  214. t1 MyISAM 10 Dynamic 0 0 0 4294967295 1024 0 NULL # # # latin1_swedish_ci NULL
  215. show table status from test like 't1%' ;
  216. 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
  217. t1 MyISAM 10 Dynamic 0 0 0 4294967295 1024 0 NULL # # # latin1_swedish_ci NULL
  218. deallocate prepare stmt1 ;
  219. drop table t1;
  220. create table t1(a varchar(2), b varchar(3));
  221. prepare stmt1 from "select a, b from t1 where (not (a='aa' and b < 'zzz'))";
  222. execute stmt1;
  223. a b
  224. execute stmt1;
  225. a b
  226. deallocate prepare stmt1;
  227. drop table t1;
  228. prepare stmt1 from "select 1 into @var";
  229. execute stmt1;
  230. execute stmt1;
  231. prepare stmt1 from "create table t1 select 1 as i";
  232. execute stmt1;
  233. drop table t1;
  234. execute stmt1;
  235. prepare stmt1 from "insert into t1 select i from t1";
  236. execute stmt1;
  237. execute stmt1;
  238. prepare stmt1 from "select * from t1 into outfile 'f1.txt'";
  239. execute stmt1;
  240. deallocate prepare stmt1;
  241. drop table t1;
  242. prepare stmt1 from 'select 1';
  243. prepare STMT1 from 'select 2';
  244. execute sTmT1;
  245. 2
  246. 2
  247. deallocate prepare StMt1;
  248. deallocate prepare Stmt1;
  249. ERROR HY000: Unknown prepared statement handler (Stmt1) given to DEALLOCATE PREPARE
  250. set names utf8;
  251. prepare `ü` from 'select 1234';
  252. execute `ü` ;
  253. 1234
  254. 1234
  255. set names latin1;
  256. execute `�`;
  257. 1234
  258. 1234
  259. deallocate prepare `�`;
  260. set names default;
  261. create table t1 (a varchar(10)) charset=utf8;
  262. insert into t1 (a) values ('yahoo');
  263. set character_set_connection=latin1;
  264. prepare stmt from 'select a from t1 where a like ?';
  265. set @var='google';
  266. execute stmt using @var;
  267. a
  268. execute stmt using @var;
  269. a
  270. deallocate prepare stmt;
  271. drop table t1;
  272. create table t1 (a bigint(20) not null primary key auto_increment);
  273. insert into t1 (a) values (null);
  274. select * from t1;
  275. a
  276. 1
  277. prepare stmt from "insert into t1 (a) values (?)";
  278. set @var=null;
  279. execute stmt using @var;
  280. select * from t1;
  281. a
  282. 1
  283. 2
  284. drop table t1;
  285. create table t1 (a timestamp not null);
  286. prepare stmt from "insert into t1 (a) values (?)";
  287. execute stmt using @var;
  288. select * from t1;
  289. deallocate prepare stmt;
  290. drop table t1;
  291. prepare stmt from "select 'abc' like convert('abc' using utf8)";
  292. execute stmt;
  293. 'abc' like convert('abc' using utf8)
  294. 1
  295. execute stmt;
  296. 'abc' like convert('abc' using utf8)
  297. 1
  298. deallocate prepare stmt;
  299. create table t1 ( a bigint );
  300. prepare stmt from 'select a from t1 where a between ? and ?';
  301. set @a=1;
  302. execute stmt using @a, @a;
  303. a
  304. execute stmt using @a, @a;
  305. a
  306. execute stmt using @a, @a;
  307. a
  308. drop table t1;
  309. deallocate prepare stmt;
  310. create table t1 (a int);
  311. prepare stmt from "select * from t1 where 1 > (1 in (SELECT * FROM t1))";
  312. execute stmt;
  313. a
  314. execute stmt;
  315. a
  316. execute stmt;
  317. a
  318. drop table t1;
  319. deallocate prepare stmt;
  320. create table t1 (a int, b int);
  321. insert into t1 (a, b) values (1,1), (1,2), (2,1), (2,2);
  322. prepare stmt from
  323. "explain select * from t1 where t1.a=2 and t1.a=t1.b and t1.b > 1 + ?";
  324. set @v=5;
  325. execute stmt using @v;
  326. id select_type table type possible_keys key key_len ref rows Extra
  327. - - - - - - - - NULL Impossible WHERE
  328. set @v=0;
  329. execute stmt using @v;
  330. id select_type table type possible_keys key key_len ref rows Extra
  331. - - - - - - - - 4 Using where
  332. set @v=5;
  333. execute stmt using @v;
  334. id select_type table type possible_keys key key_len ref rows Extra
  335. - - - - - - - - NULL Impossible WHERE
  336. drop table t1;
  337. deallocate prepare stmt;
  338. create table t1 (a int);
  339. insert into t1 (a) values (1), (2), (3), (4);
  340. set @precision=10000000000;
  341. select rand(),
  342. cast(rand(10)*@precision as unsigned integer) from t1;
  343. rand() cast(rand(10)*@precision as unsigned integer)
  344. - 6570515220
  345. - 1282061302
  346. - 6698761160
  347. - 9647622201
  348. prepare stmt from
  349. "select rand(),
  350. cast(rand(10)*@precision as unsigned integer),
  351. cast(rand(?)*@precision as unsigned integer) from t1";
  352. set @var=1;
  353. execute stmt using @var;
  354. rand() cast(rand(10)*@precision as unsigned integer) cast(rand(?)*@precision as unsigned integer)
  355. - 6570515220 -
  356. - 1282061302 -
  357. - 6698761160 -
  358. - 9647622201 -
  359. set @var=2;
  360. execute stmt using @var;
  361. rand() cast(rand(10)*@precision as unsigned integer) cast(rand(?)*@precision as unsigned integer)
  362. - 6570515220 6555866465
  363. - 1282061302 1223466193
  364. - 6698761160 6449731874
  365. - 9647622201 8578261098
  366. set @var=3;
  367. execute stmt using @var;
  368. rand() cast(rand(10)*@precision as unsigned integer) cast(rand(?)*@precision as unsigned integer)
  369. - 6570515220 9057697560
  370. - 1282061302 3730790581
  371. - 6698761160 1480860535
  372. - 9647622201 6211931236
  373. drop table t1;
  374. deallocate prepare stmt;
  375. create database mysqltest1;
  376. create table t1 (a int);
  377. create table mysqltest1.t1 (a int);
  378. select * from t1, mysqltest1.t1;
  379. a a
  380. prepare stmt from "select * from t1, mysqltest1.t1";
  381. execute stmt;
  382. a a
  383. execute stmt;
  384. a a
  385. execute stmt;
  386. a a
  387. drop table t1;
  388. drop table mysqltest1.t1;
  389. drop database mysqltest1;
  390. deallocate prepare stmt;
  391. select '1.1' as a, '1.2' as a UNION SELECT '2.1', '2.2';
  392. a a
  393. 1.1 1.2
  394. 2.1 2.2
  395. prepare stmt from
  396. "select '1.1' as a, '1.2' as a UNION SELECT '2.1', '2.2'";
  397. execute stmt;
  398. a a
  399. 1.1 1.2
  400. 2.1 2.2
  401. execute stmt;
  402. a a
  403. 1.1 1.2
  404. 2.1 2.2
  405. execute stmt;
  406. a a
  407. 1.1 1.2
  408. 2.1 2.2
  409. deallocate prepare stmt;
  410. create table t1 (a int);
  411. insert into t1 values (1),(2),(3);
  412. create table t2 select * from t1;
  413. prepare stmt FROM 'create table t2 select * from t1';
  414. drop table t2;
  415. execute stmt;
  416. drop table t2;
  417. execute stmt;
  418. execute stmt;
  419. ERROR 42S01: Table 't2' already exists
  420. drop table t2;
  421. execute stmt;
  422. drop table t1,t2;
  423. deallocate prepare stmt;
  424. create table t1 (a int);
  425. insert into t1 (a) values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
  426. prepare stmt from "select sql_calc_found_rows * from t1 limit 2";
  427. execute stmt;
  428. a
  429. 1
  430. 2
  431. select found_rows();
  432. found_rows()
  433. 10
  434. execute stmt;
  435. a
  436. 1
  437. 2
  438. select found_rows();
  439. found_rows()
  440. 10
  441. execute stmt;
  442. a
  443. 1
  444. 2
  445. select found_rows();
  446. found_rows()
  447. 10
  448. deallocate prepare stmt;
  449. drop table t1;
  450. CREATE TABLE t1 (N int, M tinyint);
  451. INSERT INTO t1 VALUES (1,0),(1,0),(2,0),(2,0),(3,0);
  452. PREPARE stmt FROM 'UPDATE t1 AS P1 INNER JOIN (SELECT N FROM t1 GROUP BY N HAVING COUNT(M) > 1) AS P2 ON P1.N = P2.N SET P1.M = 2';
  453. EXECUTE stmt;
  454. DEALLOCATE PREPARE stmt;
  455. DROP TABLE t1;
  456. prepare stmt from "select ? is null, ? is not null, ?";
  457. select @no_such_var is null, @no_such_var is not null, @no_such_var;
  458. @no_such_var is null @no_such_var is not null @no_such_var
  459. 1 0 NULL
  460. execute stmt using @no_such_var, @no_such_var, @no_such_var;
  461. ? is null ? is not null ?
  462. 1 0 NULL
  463. set @var='abc';
  464. select @var is null, @var is not null, @var;
  465. @var is null @var is not null @var
  466. 0 1 abc
  467. execute stmt using @var, @var, @var;
  468. ? is null ? is not null ?
  469. 0 1 abc
  470. set @var=null;
  471. select @var is null, @var is not null, @var;
  472. @var is null @var is not null @var
  473. 1 0 NULL
  474. execute stmt using @var, @var, @var;
  475. ? is null ? is not null ?
  476. 1 0 NULL
  477. create table t1 (pnum char(3));
  478. create table t2 (pnum char(3));
  479. prepare stmt from "select pnum from t2 having pnum in (select 'p1' from t1)";
  480. execute stmt;
  481. pnum
  482. execute stmt;
  483. pnum
  484. execute stmt;
  485. pnum
  486. deallocate prepare stmt;
  487. drop table t1, t2;
  488. drop table if exists t1;
  489. create temporary table if not exists t1 (a1 int);
  490. prepare stmt from "delete t1 from t1 where (cast(a1/3 as unsigned) * 3) = a1";
  491. drop temporary table t1;
  492. create temporary table if not exists t1 (a1 int);
  493. execute stmt;
  494. drop temporary table t1;
  495. create temporary table if not exists t1 (a1 int);
  496. execute stmt;
  497. drop temporary table t1;
  498. create temporary table if not exists t1 (a1 int);
  499. execute stmt;
  500. drop temporary table t1;
  501. deallocate prepare stmt;
  502. create table t1 (a varchar(20));
  503. insert into t1 values ('foo');
  504. prepare stmt FROM 'SELECT char_length (a) FROM t1';
  505. ERROR 42000: FUNCTION test.char_length does not exist
  506. drop table t1;
  507. prepare stmt from "SELECT SQL_CALC_FOUND_ROWS 'foo' UNION SELECT 'bar' LIMIT 0";
  508. execute stmt;
  509. foo
  510. SELECT FOUND_ROWS();
  511. FOUND_ROWS()
  512. 2
  513. execute stmt;
  514. foo
  515. SELECT FOUND_ROWS();
  516. FOUND_ROWS()
  517. 2
  518. deallocate prepare stmt;
  519. drop table if exists t1;
  520. Warnings:
  521. Note 1051 Unknown table 't1'
  522. create table t1 (c1 int(11) not null, c2 int(11) not null,
  523. primary key (c1,c2), key c2 (c2), key c1 (c1));
  524. insert into t1 values (200887, 860);
  525. insert into t1 values (200887, 200887);
  526. select * from t1 where (c1=200887 and c2=200887) or c2=860;
  527. c1 c2
  528. 200887 860
  529. 200887 200887
  530. prepare stmt from
  531. "select * from t1 where (c1=200887 and c2=200887) or c2=860";
  532. execute stmt;
  533. c1 c2
  534. 200887 860
  535. 200887 200887
  536. prepare stmt from
  537. "select * from t1 where (c1=200887 and c2=?) or c2=?";
  538. set @a=200887, @b=860;
  539. execute stmt using @a, @b;
  540. c1 c2
  541. 200887 860
  542. 200887 200887
  543. deallocate prepare stmt;
  544. drop table t1;
  545. create table t1 (
  546. id bigint(20) not null auto_increment,
  547. code varchar(20) character set utf8 collate utf8_bin not null default '',
  548. company_name varchar(250) character set utf8 collate utf8_bin default null,
  549. setup_mode tinyint(4) default null,
  550. start_date datetime default null,
  551. primary key (id), unique key code (code)
  552. );
  553. create table t2 (
  554. id bigint(20) not null auto_increment,
  555. email varchar(250) character set utf8 collate utf8_bin default null,
  556. name varchar(250) character set utf8 collate utf8_bin default null,
  557. t1_id bigint(20) default null,
  558. password varchar(250) character set utf8 collate utf8_bin default null,
  559. primary_contact tinyint(4) not null default '0',
  560. email_opt_in tinyint(4) not null default '1',
  561. primary key (id), unique key email (email), key t1_id (t1_id),
  562. constraint t2_fk1 foreign key (t1_id) references t1 (id)
  563. );
  564. insert into t1 values
  565. (1, 'demo', 'demo s', 0, current_date()),
  566. (2, 'code2', 'name 2', 0, current_date()),
  567. (3, 'code3', 'name 3', 0, current_date());
  568. insert into t2 values
  569. (2, 'email1', 'name1', 3, 'password1', 0, 0),
  570. (3, 'email2', 'name1', 1, 'password2', 1, 0),
  571. (5, 'email3', 'name3', 2, 'password3', 0, 0);
  572. prepare stmt from 'select t2.id from t2, t1 where (t1.id=? and t2.t1_id=t1.id)';
  573. set @a=1;
  574. execute stmt using @a;
  575. id
  576. 3
  577. select t2.id from t2, t1 where (t1.id=1 and t2.t1_id=t1.id);
  578. id
  579. 3
  580. deallocate prepare stmt;
  581. drop table t1, t2;
  582. create table t1 (id int);
  583. prepare stmt from "insert into t1 (id) select id from t1 union select id from t1";
  584. execute stmt;
  585. execute stmt;
  586. deallocate prepare stmt;
  587. drop table t1;
  588. create table t1 (
  589. id int(11) unsigned not null primary key auto_increment,
  590. partner_id varchar(35) not null,
  591. t1_status_id int(10) unsigned
  592. );
  593. insert into t1 values ("1", "partner1", "10"), ("2", "partner2", "10"),
  594. ("3", "partner3", "10"), ("4", "partner4", "10");
  595. create table t2 (
  596. id int(11) unsigned not null default '0',
  597. t1_line_id int(11) unsigned not null default '0',
  598. article_id varchar(20),
  599. sequence int(11) not null default '0',
  600. primary key (id,t1_line_id)
  601. );
  602. insert into t2 values ("1", "1", "sup", "0"), ("2", "1", "sup", "1"),
  603. ("2", "2", "sup", "2"), ("2", "3", "sup", "3"),
  604. ("2", "4", "imp", "4"), ("3", "1", "sup", "0"),
  605. ("4", "1", "sup", "0");
  606. create table t3 (
  607. id int(11) not null default '0',
  608. preceeding_id int(11) not null default '0',
  609. primary key (id,preceeding_id)
  610. );
  611. create table t4 (
  612. user_id varchar(50) not null,
  613. article_id varchar(20) not null,
  614. primary key (user_id,article_id)
  615. );
  616. insert into t4 values("nicke", "imp");
  617. prepare stmt from
  618. 'select distinct t1.partner_id
  619. from t1 left join t3 on t1.id = t3.id
  620. left join t1 pp on pp.id = t3.preceeding_id
  621. where
  622. exists (
  623. select *
  624. from t2 as pl_inner
  625. where pl_inner.id = t1.id
  626. and pl_inner.sequence <= (
  627. select min(sequence) from t2 pl_seqnr
  628. where pl_seqnr.id = t1.id
  629. )
  630. and exists (
  631. select * from t4
  632. where t4.article_id = pl_inner.article_id
  633. and t4.user_id = ?
  634. )
  635. )
  636. and t1.id = ?
  637. group by t1.id
  638. having count(pp.id) = 0';
  639. set @user_id = 'nicke';
  640. set @id = '2';
  641. execute stmt using @user_id, @id;
  642. partner_id
  643. execute stmt using @user_id, @id;
  644. partner_id
  645. deallocate prepare stmt;
  646. drop table t1, t2, t3, t4;
  647. prepare stmt from 'select ?=?';
  648. set @a='CHRISTINE ';
  649. set @b='CHRISTINE';
  650. execute stmt using @a, @b;
  651. ?=?
  652. 1
  653. execute stmt using @a, @b;
  654. ?=?
  655. 1
  656. set @a=1, @b=2;
  657. execute stmt using @a, @b;
  658. ?=?
  659. 0
  660. set @a='CHRISTINE ';
  661. set @b='CHRISTINE';
  662. execute stmt using @a, @b;
  663. ?=?
  664. 1
  665. deallocate prepare stmt;
  666. create table t1 (a int);
  667. prepare stmt from "select ??";
  668. ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 1
  669. prepare stmt from "select ?FROM t1";
  670. ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?FROM t1' at line 1
  671. prepare stmt from "select FROM t1 WHERE?=1";
  672. ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM t1 WHERE?=1' at line 1
  673. prepare stmt from "update t1 set a=a+?WHERE 1";
  674. ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?WHERE 1' at line 1
  675. select ?;
  676. ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 1
  677. select ??;
  678. ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '??' at line 1
  679. select ? from t1;
  680. ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? from t1' at line 1
  681. drop table t1;
  682. prepare stmt from "select @@time_zone";
  683. execute stmt;
  684. @@time_zone
  685. SYSTEM
  686. set @@time_zone:='Japan';
  687. execute stmt;
  688. @@time_zone
  689. Japan
  690. prepare stmt from "select @@tx_isolation";
  691. execute stmt;
  692. @@tx_isolation
  693. REPEATABLE-READ
  694. set transaction isolation level read committed;
  695. execute stmt;
  696. @@tx_isolation
  697. READ-COMMITTED
  698. set transaction isolation level serializable;
  699. execute stmt;
  700. @@tx_isolation
  701. SERIALIZABLE
  702. set @@tx_isolation=default;
  703. execute stmt;
  704. @@tx_isolation
  705. REPEATABLE-READ
  706. deallocate prepare stmt;
  707. prepare stmt from "create temporary table t1 (letter enum('','a','b','c')
  708. not null)";
  709. execute stmt;
  710. drop table t1;
  711. execute stmt;
  712. drop table t1;
  713. execute stmt;
  714. drop table t1;
  715. set names latin1;
  716. prepare stmt from "create table t1 (a enum('test') default 'test')
  717. character set utf8";
  718. execute stmt;
  719. drop table t1;
  720. execute stmt;
  721. drop table t1;
  722. execute stmt;
  723. drop table t1;
  724. set names default;
  725. deallocate prepare stmt;
  726. create table t1 (
  727. word_id mediumint(8) unsigned not null default '0',
  728. formatted varchar(20) not null default ''
  729. );
  730. insert into t1 values
  731. (80,'pendant'), (475,'pretendants'), (989,'tendances'),
  732. (1019,'cependant'),(1022,'abondance'),(1205,'independants'),
  733. (13,'lessiver'),(25,'lambiner'),(46,'situer'),(71,'terminer'),
  734. (82,'decrocher');
  735. select count(*) from t1 where formatted like '%NDAN%';
  736. count(*)
  737. 6
  738. select count(*) from t1 where formatted like '%ER';
  739. count(*)
  740. 5
  741. prepare stmt from "select count(*) from t1 where formatted like ?";
  742. set @like="%NDAN%";
  743. execute stmt using @like;
  744. count(*)
  745. 6
  746. set @like="%ER";
  747. execute stmt using @like;
  748. count(*)
  749. 5
  750. set @like="%NDAN%";
  751. execute stmt using @like;
  752. count(*)
  753. 6
  754. set @like="%ER";
  755. execute stmt using @like;
  756. count(*)
  757. 5
  758. deallocate prepare stmt;
  759. drop table t1;
  760. prepare stmt from 'create table t1 (a varchar(10) character set utf8)';
  761. execute stmt;
  762. insert into t1 (a) values (repeat('a', 20));
  763. select length(a) from t1;
  764. length(a)
  765. 10
  766. drop table t1;
  767. execute stmt;
  768. insert into t1 (a) values (repeat('a', 20));
  769. select length(a) from t1;
  770. length(a)
  771. 10
  772. drop table t1;
  773. deallocate prepare stmt;
  774. create table t1 (col1 integer, col2 integer);
  775. insert into t1 values(100,100),(101,101),(102,102),(103,103);
  776. prepare stmt from 'select col1, col2 from t1 where (col1, col2) in ((?,?))';
  777. set @a=100, @b=100;
  778. execute stmt using @a,@b;
  779. col1 col2
  780. 100 100
  781. set @a=101, @b=101;
  782. execute stmt using @a,@b;
  783. col1 col2
  784. 101 101
  785. set @a=102, @b=102;
  786. execute stmt using @a,@b;
  787. col1 col2
  788. 102 102
  789. set @a=102, @b=103;
  790. execute stmt using @a,@b;
  791. col1 col2
  792. deallocate prepare stmt;
  793. drop table t1;
  794. set @old_max_prepared_stmt_count= @@max_prepared_stmt_count;
  795. show variables like 'max_prepared_stmt_count';
  796. Variable_name Value
  797. max_prepared_stmt_count 16382
  798. show status like 'prepared_stmt_count';
  799. Variable_name Value
  800. Prepared_stmt_count 0
  801. select @@max_prepared_stmt_count;
  802. @@max_prepared_stmt_count
  803. 16382
  804. set global max_prepared_stmt_count=-1;
  805. select @@max_prepared_stmt_count;
  806. @@max_prepared_stmt_count
  807. 0
  808. set global max_prepared_stmt_count=10000000000000000;
  809. Warnings:
  810. Warning 1292 Truncated incorrect max_prepared_stmt_count value: '10000000000000000'
  811. select @@max_prepared_stmt_count;
  812. @@max_prepared_stmt_count
  813. 1048576
  814. set global max_prepared_stmt_count=default;
  815. select @@max_prepared_stmt_count;
  816. @@max_prepared_stmt_count
  817. 16382
  818. set @@max_prepared_stmt_count=1;
  819. ERROR HY000: Variable 'max_prepared_stmt_count' is a GLOBAL variable and should be set with SET GLOBAL
  820. set max_prepared_stmt_count=1;
  821. ERROR HY000: Variable 'max_prepared_stmt_count' is a GLOBAL variable and should be set with SET GLOBAL
  822. set local max_prepared_stmt_count=1;
  823. ERROR HY000: Variable 'max_prepared_stmt_count' is a GLOBAL variable and should be set with SET GLOBAL
  824. set global max_prepared_stmt_count=1;
  825. select @@max_prepared_stmt_count;
  826. @@max_prepared_stmt_count
  827. 1
  828. set global max_prepared_stmt_count=0;
  829. select @@max_prepared_stmt_count;
  830. @@max_prepared_stmt_count
  831. 0
  832. show status like 'prepared_stmt_count';
  833. Variable_name Value
  834. Prepared_stmt_count 0
  835. prepare stmt from "select 1";
  836. ERROR 42000: Can't create more than max_prepared_stmt_count statements (current value: 0)
  837. show status like 'prepared_stmt_count';
  838. Variable_name Value
  839. Prepared_stmt_count 0
  840. set global max_prepared_stmt_count=1;
  841. prepare stmt from "select 1";
  842. show status like 'prepared_stmt_count';
  843. Variable_name Value
  844. Prepared_stmt_count 1
  845. prepare stmt1 from "select 1";
  846. ERROR 42000: Can't create more than max_prepared_stmt_count statements (current value: 1)
  847. show status like 'prepared_stmt_count';
  848. Variable_name Value
  849. Prepared_stmt_count 1
  850. deallocate prepare stmt;
  851. show status like 'prepared_stmt_count';
  852. Variable_name Value
  853. Prepared_stmt_count 0
  854. prepare stmt from "select 1";
  855. show status like 'prepared_stmt_count';
  856. Variable_name Value
  857. Prepared_stmt_count 1
  858. prepare stmt from "select 2";
  859. show status like 'prepared_stmt_count';
  860. Variable_name Value
  861. Prepared_stmt_count 1
  862. show status like 'prepared_stmt_count';
  863. Variable_name Value
  864. Prepared_stmt_count 1
  865. select @@max_prepared_stmt_count;
  866. @@max_prepared_stmt_count
  867. 1
  868. set global max_prepared_stmt_count=0;
  869. prepare stmt from "select 1";
  870. ERROR 42000: Can't create more than max_prepared_stmt_count statements (current value: 0)
  871. execute stmt;
  872. ERROR HY000: Unknown prepared statement handler (stmt) given to EXECUTE
  873. show status like 'prepared_stmt_count';
  874. Variable_name Value
  875. Prepared_stmt_count 0
  876. prepare stmt from "select 1";
  877. ERROR 42000: Can't create more than max_prepared_stmt_count statements (current value: 0)
  878. show status like 'prepared_stmt_count';
  879. Variable_name Value
  880. Prepared_stmt_count 0
  881. set global max_prepared_stmt_count=3;
  882. select @@max_prepared_stmt_count;
  883. @@max_prepared_stmt_count
  884. 3
  885. show status like 'prepared_stmt_count';
  886. Variable_name Value
  887. Prepared_stmt_count 0
  888. prepare stmt from "select 1";
  889. prepare stmt from "select 2";
  890. prepare stmt1 from "select 3";
  891. prepare stmt2 from "select 4";
  892. ERROR 42000: Can't create more than max_prepared_stmt_count statements (current value: 3)
  893. prepare stmt2 from "select 4";
  894. ERROR 42000: Can't create more than max_prepared_stmt_count statements (current value: 3)
  895. select @@max_prepared_stmt_count;
  896. @@max_prepared_stmt_count
  897. 3
  898. show status like 'prepared_stmt_count';
  899. Variable_name Value
  900. Prepared_stmt_count 3
  901. deallocate prepare stmt;
  902. set global max_prepared_stmt_count= @old_max_prepared_stmt_count;
  903. drop table if exists t1;
  904. create temporary table if not exists t1 (a1 int);
  905. prepare stmt from "delete t1 from t1 where (cast(a1/3 as unsigned) * 3) = a1";
  906. drop temporary table t1;
  907. create temporary table if not exists t1 (a1 int);
  908. execute stmt;
  909. drop temporary table t1;
  910. create temporary table if not exists t1 (a1 int);
  911. execute stmt;
  912. drop temporary table t1;
  913. create temporary table if not exists t1 (a1 int);
  914. execute stmt;
  915. drop temporary table t1;
  916. deallocate prepare stmt;
  917. CREATE TABLE t1(
  918. ID int(10) unsigned NOT NULL auto_increment,
  919. Member_ID varchar(15) NOT NULL default '',
  920. Action varchar(12) NOT NULL,
  921. Action_Date datetime NOT NULL,
  922. Track varchar(15) default NULL,
  923. User varchar(12) default NULL,
  924. Date_Updated timestamp NOT NULL default CURRENT_TIMESTAMP on update
  925. CURRENT_TIMESTAMP,
  926. PRIMARY KEY (ID),
  927. KEY Action (Action),
  928. KEY Action_Date (Action_Date)
  929. );
  930. INSERT INTO t1(Member_ID, Action, Action_Date, Track) VALUES
  931. ('111111', 'Disenrolled', '2006-03-01', 'CAD' ),
  932. ('111111', 'Enrolled', '2006-03-01', 'CAD' ),
  933. ('111111', 'Disenrolled', '2006-07-03', 'CAD' ),
  934. ('222222', 'Enrolled', '2006-03-07', 'CAD' ),
  935. ('222222', 'Enrolled', '2006-03-07', 'CHF' ),
  936. ('222222', 'Disenrolled', '2006-08-02', 'CHF' ),
  937. ('333333', 'Enrolled', '2006-03-01', 'CAD' ),
  938. ('333333', 'Disenrolled', '2006-03-01', 'CAD' ),
  939. ('444444', 'Enrolled', '2006-03-01', 'CAD' ),
  940. ('555555', 'Disenrolled', '2006-03-01', 'CAD' ),
  941. ('555555', 'Enrolled', '2006-07-21', 'CAD' ),
  942. ('555555', 'Disenrolled', '2006-03-01', 'CHF' ),
  943. ('666666', 'Enrolled', '2006-02-09', 'CAD' ),
  944. ('666666', 'Enrolled', '2006-05-12', 'CHF' ),
  945. ('666666', 'Disenrolled', '2006-06-01', 'CAD' );
  946. PREPARE STMT FROM
  947. "SELECT GROUP_CONCAT(Track SEPARATOR ', ') FROM t1
  948. WHERE Member_ID=? AND Action='Enrolled' AND
  949. (Track,Action_Date) IN (SELECT Track, MAX(Action_Date) FROM t1
  950. WHERE Member_ID=?
  951. GROUP BY Track
  952. HAVING Track>='CAD' AND
  953. MAX(Action_Date)>'2006-03-01')";
  954. SET @id='111111';
  955. EXECUTE STMT USING @id,@id;
  956. GROUP_CONCAT(Track SEPARATOR ', ')
  957. NULL
  958. SET @id='222222';
  959. EXECUTE STMT USING @id,@id;
  960. GROUP_CONCAT(Track SEPARATOR ', ')
  961. CAD
  962. DEALLOCATE PREPARE STMT;
  963. DROP TABLE t1;
  964. DROP TABLE IF EXISTS t1;
  965. CREATE TABLE t1 (i INT, INDEX(i));
  966. INSERT INTO t1 VALUES (1);
  967. PREPARE stmt FROM "SELECT (COUNT(i) = 1), COUNT(i) FROM t1 WHERE i = ?";
  968. SET @a = 0;
  969. EXECUTE stmt USING @a;
  970. (COUNT(i) = 1) COUNT(i)
  971. 0 0
  972. SET @a = 1;
  973. EXECUTE stmt USING @a;
  974. (COUNT(i) = 1) COUNT(i)
  975. 1 1
  976. SET @a = 0;
  977. EXECUTE stmt USING @a;
  978. (COUNT(i) = 1) COUNT(i)
  979. 0 0
  980. PREPARE stmt FROM "SELECT (AVG(i) = 1), AVG(i) FROM t1 WHERE i = ?";
  981. SET @a = 0;
  982. EXECUTE stmt USING @a;
  983. (AVG(i) = 1) AVG(i)
  984. NULL NULL
  985. SET @a = 1;
  986. EXECUTE stmt USING @a;
  987. (AVG(i) = 1) AVG(i)
  988. 1 1.0000
  989. SET @a = 0;
  990. EXECUTE stmt USING @a;
  991. (AVG(i) = 1) AVG(i)
  992. NULL NULL
  993. PREPARE stmt FROM "SELECT (VARIANCE(i) = 1), VARIANCE(i) FROM t1 WHERE i = ?";
  994. SET @a = 0;
  995. EXECUTE stmt USING @a;
  996. (VARIANCE(i) = 1) VARIANCE(i)
  997. NULL NULL
  998. SET @a = 1;
  999. EXECUTE stmt USING @a;
  1000. (VARIANCE(i) = 1) VARIANCE(i)
  1001. 0 0.0000
  1002. SET @a = 0;
  1003. EXECUTE stmt USING @a;
  1004. (VARIANCE(i) = 1) VARIANCE(i)
  1005. NULL NULL
  1006. PREPARE stmt FROM "SELECT (STDDEV(i) = 1), STDDEV(i) FROM t1 WHERE i = ?";
  1007. SET @a = 0;
  1008. EXECUTE stmt USING @a;
  1009. (STDDEV(i) = 1) STDDEV(i)
  1010. NULL NULL
  1011. SET @a = 1;
  1012. EXECUTE stmt USING @a;
  1013. (STDDEV(i) = 1) STDDEV(i)
  1014. 0 0.0000
  1015. SET @a = 0;
  1016. EXECUTE stmt USING @a;
  1017. (STDDEV(i) = 1) STDDEV(i)
  1018. NULL NULL
  1019. PREPARE stmt FROM "SELECT (BIT_OR(i) = 1), BIT_OR(i) FROM t1 WHERE i = ?";
  1020. SET @a = 0;
  1021. EXECUTE stmt USING @a;
  1022. (BIT_OR(i) = 1) BIT_OR(i)
  1023. 0 0
  1024. SET @a = 1;
  1025. EXECUTE stmt USING @a;
  1026. (BIT_OR(i) = 1) BIT_OR(i)
  1027. 1 1
  1028. SET @a = 0;
  1029. EXECUTE stmt USING @a;
  1030. (BIT_OR(i) = 1) BIT_OR(i)
  1031. 0 0
  1032. PREPARE stmt FROM "SELECT (BIT_AND(i) = 1), BIT_AND(i) FROM t1 WHERE i = ?";
  1033. SET @a = 0;
  1034. EXECUTE stmt USING @a;
  1035. (BIT_AND(i) = 1) BIT_AND(i)
  1036. 0 18446744073709551615
  1037. SET @a = 1;
  1038. EXECUTE stmt USING @a;
  1039. (BIT_AND(i) = 1) BIT_AND(i)
  1040. 1 1
  1041. SET @a = 0;
  1042. EXECUTE stmt USING @a;
  1043. (BIT_AND(i) = 1) BIT_AND(i)
  1044. 0 18446744073709551615
  1045. PREPARE stmt FROM "SELECT (BIT_XOR(i) = 1), BIT_XOR(i) FROM t1 WHERE i = ?";
  1046. SET @a = 0;
  1047. EXECUTE stmt USING @a;
  1048. (BIT_XOR(i) = 1) BIT_XOR(i)
  1049. 0 0
  1050. SET @a = 1;
  1051. EXECUTE stmt USING @a;
  1052. (BIT_XOR(i) = 1) BIT_XOR(i)
  1053. 1 1
  1054. SET @a = 0;
  1055. EXECUTE stmt USING @a;
  1056. (BIT_XOR(i) = 1) BIT_XOR(i)
  1057. 0 0
  1058. DEALLOCATE PREPARE stmt;
  1059. DROP TABLE t1;
  1060. DROP TABLE IF EXISTS t1, t2;
  1061. CREATE TABLE t1 (i INT);
  1062. PREPARE st_19182
  1063. FROM "CREATE TABLE t2 (i INT, j INT, KEY (i), KEY(j)) SELECT i FROM t1";
  1064. EXECUTE st_19182;
  1065. DESC t2;
  1066. Field Type Null Key Default Extra
  1067. j int(11) YES MUL NULL
  1068. i int(11) YES MUL NULL
  1069. DROP TABLE t2;
  1070. EXECUTE st_19182;
  1071. DESC t2;
  1072. Field Type Null Key Default Extra
  1073. j int(11) YES MUL NULL
  1074. i int(11) YES MUL NULL
  1075. DEALLOCATE PREPARE st_19182;
  1076. DROP TABLE t2, t1;
  1077. drop database if exists mysqltest;
  1078. drop table if exists t1, t2;
  1079. create database mysqltest character set utf8;
  1080. prepare stmt1 from "create table mysqltest.t1 (c char(10))";
  1081. prepare stmt2 from "create table mysqltest.t2 select 'test'";
  1082. execute stmt1;
  1083. execute stmt2;
  1084. show create table mysqltest.t1;
  1085. Table Create Table
  1086. t1 CREATE TABLE `t1` (
  1087. `c` char(10) default NULL
  1088. ) ENGINE=MyISAM DEFAULT CHARSET=utf8
  1089. show create table mysqltest.t2;
  1090. Table Create Table
  1091. t2 CREATE TABLE `t2` (
  1092. `test` varchar(4) character set latin1 NOT NULL default ''
  1093. ) ENGINE=MyISAM DEFAULT CHARSET=utf8
  1094. drop table mysqltest.t1;
  1095. drop table mysqltest.t2;
  1096. alter database mysqltest character set latin1;
  1097. execute stmt1;
  1098. execute stmt2;
  1099. show create table mysqltest.t1;
  1100. Table Create Table
  1101. t1 CREATE TABLE `t1` (
  1102. `c` char(10) character set utf8 default NULL
  1103. ) ENGINE=MyISAM DEFAULT CHARSET=latin1
  1104. show create table mysqltest.t2;
  1105. Table Create Table
  1106. t2 CREATE TABLE `t2` (
  1107. `test` varchar(4) NOT NULL default ''
  1108. ) ENGINE=MyISAM DEFAULT CHARSET=latin1
  1109. drop database mysqltest;
  1110. deallocate prepare stmt1;
  1111. deallocate prepare stmt2;
  1112. execute stmt;
  1113. show create table t1;
  1114. drop table t1;
  1115. execute stmt;
  1116. show create table t1;
  1117. drop table t1;
  1118. deallocate prepare stmt;
  1119. CREATE TABLE t1(a int);
  1120. INSERT INTO t1 VALUES (2), (3), (1);
  1121. PREPARE st1 FROM
  1122. '(SELECT a FROM t1) UNION (SELECT a+10 FROM t1) ORDER BY RAND()*0+a';
  1123. EXECUTE st1;
  1124. a
  1125. 1
  1126. 2
  1127. 3
  1128. 11
  1129. 12
  1130. 13
  1131. EXECUTE st1;
  1132. a
  1133. 1
  1134. 2
  1135. 3
  1136. 11
  1137. 12
  1138. 13
  1139. DEALLOCATE PREPARE st1;
  1140. DROP TABLE t1;
  1141. create table t1 (a int, b tinyint);
  1142. prepare st1 from 'update t1 set b= (str_to_date(a, a))';
  1143. execute st1;
  1144. deallocate prepare st1;
  1145. drop table t1;
  1146. End of 4.1 tests.
  1147. create table t1 (a varchar(20));
  1148. insert into t1 values ('foo');
  1149. prepare stmt FROM 'SELECT char_length (a) FROM t1';
  1150. ERROR 42000: FUNCTION test.char_length does not exist
  1151. drop table t1;
  1152. create table t1 (a char(3) not null, b char(3) not null,
  1153. c char(3) not null, primary key (a, b, c));
  1154. create table t2 like t1;
  1155. prepare stmt from
  1156. "select t1.a from (t1 left outer join t2 on t2.a=1 and t1.b=t2.b)
  1157. where t1.a=1";
  1158. execute stmt;
  1159. a
  1160. execute stmt;
  1161. a
  1162. execute stmt;
  1163. a
  1164. prepare stmt from
  1165. "select t1.a, t1.b, t1.c, t2.a, t2.b, t2.c from
  1166. (t1 left outer join t2 on t2.a=? and t1.b=t2.b)
  1167. left outer join t2 t3 on t3.a=? where t1.a=?";
  1168. set @a:=1, @b:=1, @c:=1;
  1169. execute stmt using @a, @b, @c;
  1170. a b c a b c
  1171. execute stmt using @a, @b, @c;
  1172. a b c a b c
  1173. execute stmt using @a, @b, @c;
  1174. a b c a b c
  1175. deallocate prepare stmt;
  1176. drop table t1,t2;
  1177. SET @aux= "SELECT COUNT(*)
  1178. FROM INFORMATION_SCHEMA.COLUMNS A,
  1179. INFORMATION_SCHEMA.COLUMNS B
  1180. WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA
  1181. AND A.TABLE_NAME = B.TABLE_NAME
  1182. AND A.COLUMN_NAME = B.COLUMN_NAME AND
  1183. A.TABLE_NAME = 'user'";
  1184. prepare my_stmt from @aux;
  1185. execute my_stmt;
  1186. COUNT(*)
  1187. 37
  1188. execute my_stmt;
  1189. COUNT(*)
  1190. 37
  1191. execute my_stmt;
  1192. COUNT(*)
  1193. 37
  1194. deallocate prepare my_stmt;
  1195. drop procedure if exists p1|
  1196. drop table if exists t1|
  1197. create table t1 (id int)|
  1198. insert into t1 values(1)|
  1199. create procedure p1(a int, b int)
  1200. begin
  1201. declare c int;
  1202. select max(id)+1 into c from t1;
  1203. insert into t1 select a+b;
  1204. insert into t1 select a-b;
  1205. insert into t1 select a-c;
  1206. end|
  1207. set @a= 3, @b= 4|
  1208. prepare stmt from "call p1(?, ?)"|
  1209. execute stmt using @a, @b|
  1210. execute stmt using @a, @b|
  1211. select * from t1|
  1212. id
  1213. 1
  1214. 7
  1215. -1
  1216. 1
  1217. 7
  1218. -1
  1219. -5
  1220. deallocate prepare stmt|
  1221. drop procedure p1|
  1222. drop table t1|
  1223. create table t1 (a int);
  1224. insert into t1 (a) values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
  1225. prepare stmt from "select * from t1 limit ?, ?";
  1226. set @offset=0, @limit=1;
  1227. execute stmt using @offset, @limit;
  1228. a
  1229. 1
  1230. select * from t1 limit 0, 1;
  1231. a
  1232. 1
  1233. set @offset=3, @limit=2;
  1234. execute stmt using @offset, @limit;
  1235. a
  1236. 4
  1237. 5
  1238. select * from t1 limit 3, 2;
  1239. a
  1240. 4
  1241. 5
  1242. prepare stmt from "select * from t1 limit ?";
  1243. execute stmt using @limit;
  1244. a
  1245. 1
  1246. 2
  1247. prepare stmt from "select * from t1 where a in (select a from t1 limit ?)";
  1248. ERROR 42000: This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
  1249. prepare stmt from "select * from t1 union all select * from t1 limit ?, ?";
  1250. set @offset=9;
  1251. set @limit=2;
  1252. execute stmt using @offset, @limit;
  1253. a
  1254. 10
  1255. 1
  1256. prepare stmt from "(select * from t1 limit ?, ?) union all
  1257. (select * from t1 limit ?, ?) order by a limit ?";
  1258. execute stmt using @offset, @limit, @offset, @limit, @limit;
  1259. a
  1260. 10
  1261. 10
  1262. drop table t1;
  1263. deallocate prepare stmt;
  1264. CREATE TABLE b12651_T1(a int) ENGINE=MYISAM;
  1265. CREATE TABLE b12651_T2(b int) ENGINE=MYISAM;
  1266. CREATE VIEW b12651_V1 as SELECT b FROM b12651_T2;
  1267. PREPARE b12651 FROM 'SELECT 1 FROM b12651_T1 WHERE a IN (SELECT b FROM b12651_V1)';
  1268. EXECUTE b12651;
  1269. 1
  1270. DROP VIEW b12651_V1;
  1271. DROP TABLE b12651_T1, b12651_T2;
  1272. DEALLOCATE PREPARE b12651;
  1273. create table t1 (id int);
  1274. prepare ins_call from "insert into t1 (id) values (1)";
  1275. execute ins_call;
  1276. select row_count();
  1277. row_count()
  1278. 1
  1279. drop table t1;
  1280. create table t1 (a int, b int);
  1281. insert into t1 (a,b) values (2,8),(1,9),(3,7);
  1282. prepare stmt from "select * from t1 order by ?";
  1283. set @a=NULL;
  1284. execute stmt using @a;
  1285. a b
  1286. 2 8
  1287. 1 9
  1288. 3 7
  1289. set @a=1;
  1290. execute stmt using @a;
  1291. a b
  1292. 1 9
  1293. 2 8
  1294. 3 7
  1295. set @a=2;
  1296. execute stmt using @a;
  1297. a b
  1298. 3 7
  1299. 2 8
  1300. 1 9
  1301. deallocate prepare stmt;
  1302. select * from t1 order by 1;
  1303. a b
  1304. 1 9
  1305. 2 8
  1306. 3 7
  1307. prepare stmt from "select * from t1 order by ?+1";
  1308. set @a=0;
  1309. execute stmt using @a;
  1310. a b
  1311. 2 8
  1312. 1 9
  1313. 3 7
  1314. set @a=1;
  1315. execute stmt using @a;
  1316. a b
  1317. 2 8
  1318. 1 9
  1319. 3 7
  1320. deallocate prepare stmt;
  1321. select * from t1 order by 1+1;
  1322. a b
  1323. 2 8
  1324. 1 9
  1325. 3 7
  1326. drop table t1;
  1327. create table t1 (a int);
  1328. create table t2 like t1;
  1329. create table t3 like t2;
  1330. prepare stmt from "repair table t1";
  1331. execute stmt;
  1332. Table Op Msg_type Msg_text
  1333. test.t1 repair status OK
  1334. execute stmt;
  1335. Table Op Msg_type Msg_text
  1336. test.t1 repair status OK
  1337. prepare stmt from "optimize table t1";
  1338. execute stmt;
  1339. Table Op Msg_type Msg_text
  1340. test.t1 optimize status OK
  1341. execute stmt;
  1342. Table Op Msg_type Msg_text
  1343. test.t1 optimize status Table is already up to date
  1344. prepare stmt from "analyze table t1";
  1345. execute stmt;
  1346. Table Op Msg_type Msg_text
  1347. test.t1 analyze status Table is already up to date
  1348. execute stmt;
  1349. Table Op Msg_type Msg_text
  1350. test.t1 analyze status Table is already up to date
  1351. prepare stmt from "repair table t1, t2, t3";
  1352. execute stmt;
  1353. Table Op Msg_type Msg_text
  1354. test.t1 repair status OK
  1355. test.t2 repair status OK
  1356. test.t3 repair status OK
  1357. execute stmt;
  1358. Table Op Msg_type Msg_text
  1359. test.t1 repair status OK
  1360. test.t2 repair status OK
  1361. test.t3 repair status OK
  1362. prepare stmt from "optimize table t1, t2, t3";
  1363. execute stmt;
  1364. Table Op Msg_type Msg_text
  1365. test.t1 optimize status OK
  1366. test.t2 optimize status OK
  1367. test.t3 optimize status OK
  1368. execute stmt;
  1369. Table Op Msg_type Msg_text
  1370. test.t1 optimize status Table is already up to date
  1371. test.t2 optimize status Table is already up to date
  1372. test.t3 optimize status Table is already up to date
  1373. prepare stmt from "analyze table t1, t2, t3";
  1374. execute stmt;
  1375. Table Op Msg_type Msg_text
  1376. test.t1 analyze status Table is already up to date
  1377. test.t2 analyze status Table is already up to date
  1378. test.t3 analyze status Table is already up to date
  1379. execute stmt;
  1380. Table Op Msg_type Msg_text
  1381. test.t1 analyze status Table is already up to date
  1382. test.t2 analyze status Table is already up to date
  1383. test.t3 analyze status Table is already up to date
  1384. prepare stmt from "repair table t1, t4, t3";
  1385. execute stmt;
  1386. Table Op Msg_type Msg_text
  1387. test.t1 repair status OK
  1388. test.t4 repair Error Table 'test.t4' doesn't exist
  1389. test.t4 repair error Corrupt
  1390. test.t3 repair status OK
  1391. execute stmt;
  1392. Table Op Msg_type Msg_text
  1393. test.t1 repair status OK
  1394. test.t4 repair Error Table 'test.t4' doesn't exist
  1395. test.t4 repair error Corrupt
  1396. test.t3 repair status OK
  1397. prepare stmt from "optimize table t1, t3, t4";
  1398. execute stmt;
  1399. Table Op Msg_type Msg_text
  1400. test.t1 optimize status OK
  1401. test.t3 optimize status OK
  1402. test.t4 optimize Error Table 'test.t4' doesn't exist
  1403. test.t4 optimize error Corrupt
  1404. execute stmt;
  1405. Table Op Msg_type Msg_text
  1406. test.t1 optimize status Table is already up to date
  1407. test.t3 optimize status Table is already up to date
  1408. test.t4 optimize Error Table 'test.t4' doesn't exist
  1409. test.t4 optimize error Corrupt
  1410. prepare stmt from "analyze table t4, t1";
  1411. execute stmt;
  1412. Table Op Msg_type Msg_text
  1413. test.t4 analyze Error Table 'test.t4' doesn't exist
  1414. test.t4 analyze error Corrupt
  1415. test.t1 analyze status Table is already up to date
  1416. execute stmt;
  1417. Table Op Msg_type Msg_text
  1418. test.t4 analyze Error Table 'test.t4' doesn't exist
  1419. test.t4 analyze error Corrupt
  1420. test.t1 analyze status Table is already up to date
  1421. deallocate prepare stmt;
  1422. drop table t1, t2, t3;
  1423. create database mysqltest_long_database_name_to_thrash_heap;
  1424. use test;
  1425. create table t1 (i int);
  1426. prepare stmt from "alter table test.t1 rename t1";
  1427. use mysqltest_long_database_name_to_thrash_heap;
  1428. execute stmt;
  1429. show tables like 't1';
  1430. Tables_in_mysqltest_long_database_name_to_thrash_heap (t1)
  1431. prepare stmt from "alter table test.t1 rename t1";
  1432. use test;
  1433. execute stmt;
  1434. show tables like 't1';
  1435. Tables_in_test (t1)
  1436. use mysqltest_long_database_name_to_thrash_heap;
  1437. show tables like 't1';
  1438. Tables_in_mysqltest_long_database_name_to_thrash_heap (t1)
  1439. t1
  1440. deallocate prepare stmt;
  1441. use mysqltest_long_database_name_to_thrash_heap;
  1442. prepare stmt_create from "create table t1 (i int)";
  1443. prepare stmt_insert from "insert into t1 (i) values (1)";
  1444. prepare stmt_update from "update t1 set i=2";
  1445. prepare stmt_delete from "delete from t1 where i=2";
  1446. prepare stmt_select from "select * from t1";
  1447. prepare stmt_alter from "alter table t1 add column (b int)";
  1448. prepare stmt_alter1 from "alter table t1 drop column b";
  1449. prepare stmt_analyze from "analyze table t1";
  1450. prepare stmt_optimize from "optimize table t1";
  1451. prepare stmt_show from "show tables like 't1'";
  1452. prepare stmt_truncate from "truncate table t1";
  1453. prepare stmt_drop from "drop table t1";
  1454. drop table t1;
  1455. use test;
  1456. execute stmt_create;
  1457. show tables like 't1';
  1458. Tables_in_test (t1)
  1459. use mysqltest_long_database_name_to_thrash_heap;
  1460. show tables like 't1';
  1461. Tables_in_mysqltest_long_database_name_to_thrash_heap (t1)
  1462. t1
  1463. use test;
  1464. execute stmt_insert;
  1465. select * from mysqltest_long_database_name_to_thrash_heap.t1;
  1466. i
  1467. 1
  1468. execute stmt_update;
  1469. select * from mysqltest_long_database_name_to_thrash_heap.t1;
  1470. i
  1471. 2
  1472. execute stmt_delete;
  1473. execute stmt_select;
  1474. i
  1475. execute stmt_alter;
  1476. show columns from mysqltest_long_database_name_to_thrash_heap.t1;
  1477. Field Type Null Key Default Extra
  1478. i int(11) YES NULL
  1479. b int(11) YES NULL
  1480. execute stmt_alter1;
  1481. show columns from mysqltest_long_database_name_to_thrash_heap.t1;
  1482. Field Type Null Key Default Extra
  1483. i int(11) YES NULL
  1484. execute stmt_analyze;
  1485. Table Op Msg_type Msg_text
  1486. mysqltest_long_database_name_to_thrash_heap.t1 analyze status Table is already up to date
  1487. execute stmt_optimize;
  1488. Table Op Msg_type Msg_text
  1489. mysqltest_long_database_name_to_thrash_heap.t1 optimize status Table is already up to date
  1490. execute stmt_show;
  1491. Tables_in_mysqltest_long_database_name_to_thrash_heap (t1)
  1492. t1
  1493. execute stmt_truncate;
  1494. execute stmt_drop;
  1495. show tables like 't1';
  1496. Tables_in_test (t1)
  1497. use mysqltest_long_database_name_to_thrash_heap;
  1498. show tables like 't1';
  1499. Tables_in_mysqltest_long_database_name_to_thrash_heap (t1)
  1500. drop database mysqltest_long_database_name_to_thrash_heap;
  1501. prepare stmt_create from "create table t1 (i int)";
  1502. ERROR 3D000: No database selected
  1503. prepare stmt_insert from "insert into t1 (i) values (1)";
  1504. ERROR 3D000: No database selected
  1505. prepare stmt_update from "update t1 set i=2";
  1506. ERROR 3D000: No database selected
  1507. prepare stmt_delete from "delete from t1 where i=2";
  1508. ERROR 3D000: No database selected
  1509. prepare stmt_select from "select * from t1";
  1510. ERROR 3D000: No database selected
  1511. prepare stmt_alter from "alter table t1 add column (b int)";
  1512. ERROR 3D000: No database selected
  1513. prepare stmt_alter1 from "alter table t1 drop column b";
  1514. ERROR 3D000: No database selected
  1515. prepare stmt_analyze from "analyze table t1";
  1516. ERROR 3D000: No database selected
  1517. prepare stmt_optimize from "optimize table t1";
  1518. ERROR 3D000: No database selected
  1519. prepare stmt_show from "show tables like 't1'";
  1520. ERROR 3D000: No database selected
  1521. prepare stmt_truncate from "truncate table t1";
  1522. ERROR 3D000: No database selected
  1523. prepare stmt_drop from "drop table t1";
  1524. ERROR 3D000: No database selected
  1525. create temporary table t1 (i int);
  1526. ERROR 3D000: No database selected
  1527. use test;
  1528. DROP TABLE IF EXISTS t1, t2, t3;
  1529. CREATE TABLE t1 (i BIGINT, j BIGINT);
  1530. CREATE TABLE t2 (i BIGINT);
  1531. CREATE TABLE t3 (i BIGINT, j BIGINT);
  1532. PREPARE stmt FROM "SELECT * FROM t1 JOIN t2 ON (t2.i = t1.i)
  1533. LEFT JOIN t3 ON ((t3.i, t3.j) = (t1.i, t1.j))
  1534. WHERE t1.i = ?";
  1535. SET @a= 1;
  1536. EXECUTE stmt USING @a;
  1537. i j i i j
  1538. EXECUTE stmt USING @a;
  1539. i j i i j
  1540. DEALLOCATE PREPARE stmt;
  1541. DROP TABLE IF EXISTS t1, t2, t3;
  1542. DROP TABLE IF EXISTS t1, t2;
  1543. CREATE TABLE t1 (i INT KEY);
  1544. CREATE TABLE t2 (i INT);
  1545. INSERT INTO t1 VALUES (1), (2);
  1546. INSERT INTO t2 VALUES (1);
  1547. PREPARE stmt FROM "SELECT t2.i FROM t1 LEFT JOIN t2 ON t2.i = t1.i
  1548. WHERE t1.i = ?";
  1549. SET @arg= 1;
  1550. EXECUTE stmt USING @arg;
  1551. i
  1552. 1
  1553. SET @arg= 2;
  1554. EXECUTE stmt USING @arg;
  1555. i
  1556. NULL
  1557. SET @arg= 1;
  1558. EXECUTE stmt USING @arg;
  1559. i
  1560. 1
  1561. DEALLOCATE PREPARE stmt;
  1562. DROP TABLE t1, t2;
  1563. CREATE TABLE t1 (i INT);
  1564. CREATE VIEW v1 AS SELECT * FROM t1;
  1565. INSERT INTO t1 VALUES (1), (2);
  1566. SELECT t1.i FROM t1 JOIN v1 ON t1.i = v1.i
  1567. WHERE EXISTS (SELECT * FROM t1 WHERE v1.i = 1);
  1568. i
  1569. 1
  1570. PREPARE stmt FROM "SELECT t1.i FROM t1 JOIN v1 ON t1.i = v1.i
  1571. WHERE EXISTS (SELECT * FROM t1 WHERE v1.i = 1)";
  1572. EXECUTE stmt;
  1573. i
  1574. 1
  1575. EXECUTE stmt;
  1576. i
  1577. 1
  1578. DEALLOCATE PREPARE stmt;
  1579. DROP VIEW v1;
  1580. DROP TABLE t1;
  1581. DROP PROCEDURE IF EXISTS p1;
  1582. flush status;
  1583. prepare sq from 'show status like "slow_queries"';
  1584. execute sq;
  1585. Variable_name Value
  1586. Slow_queries 0
  1587. prepare no_index from 'select 1 from information_schema.tables limit 1';
  1588. execute sq;
  1589. Variable_name Value
  1590. Slow_queries 0
  1591. execute no_index;
  1592. 1
  1593. 1
  1594. execute sq;
  1595. Variable_name Value
  1596. Slow_queries 1
  1597. deallocate prepare no_index;
  1598. deallocate prepare sq;
  1599. CREATE TABLE t1 (a int);
  1600. INSERT INTO t1 VALUES (1), (2);
  1601. CREATE TABLE t2 (b int);
  1602. INSERT INTO t2 VALUES (NULL);
  1603. SELECT a FROM t1 WHERE (SELECT b FROM t2) IS NULL;
  1604. a
  1605. 1
  1606. 2
  1607. PREPARE stmt FROM 'SELECT a FROM t1 WHERE (SELECT b FROM t2) IS NULL';
  1608. EXECUTE stmt;
  1609. a
  1610. 1
  1611. 2
  1612. DEALLOCATE PREPARE stmt;
  1613. PREPARE stmt FROM 'SELECT a FROM t1 WHERE (SELECT b FROM t2 limit ?) IS NULL';
  1614. SET @arg=1;
  1615. EXECUTE stmt USING @arg;
  1616. a
  1617. 1
  1618. 2
  1619. DEALLOCATE PREPARE stmt;
  1620. DROP TABLE t1,t2;
  1621. drop table if exists t1;
  1622. create table t1 (s1 char(20));
  1623. prepare stmt from "alter table t1 modify s1 int";
  1624. execute stmt;
  1625. execute stmt;
  1626. drop table t1;
  1627. deallocate prepare stmt;
  1628. drop table if exists t1;
  1629. create table t1 (a int, b int);
  1630. prepare s_6895 from "alter table t1 drop column b";
  1631. execute s_6895;
  1632. show columns from t1;
  1633. Field Type Null Key Default Extra
  1634. a int(11) YES NULL
  1635. drop table t1;
  1636. create table t1 (a int, b int);
  1637. execute s_6895;
  1638. show columns from t1;
  1639. Field Type Null Key Default Extra
  1640. a int(11) YES NULL
  1641. drop table t1;
  1642. create table t1 (a int, b int);
  1643. execute s_6895;
  1644. show columns from t1;
  1645. Field Type Null Key Default Extra
  1646. a int(11) YES NULL
  1647. deallocate prepare s_6895;
  1648. drop table t1;
  1649. create table t1 (i int primary key auto_increment) comment='comment for table t1';
  1650. create table t2 (i int, j int, k int);
  1651. prepare stmt from "alter table t1 auto_increment=100";
  1652. execute stmt;
  1653. show create table t1;
  1654. Table Create Table
  1655. t1 CREATE TABLE `t1` (
  1656. `i` int(11) NOT NULL auto_increment,
  1657. PRIMARY KEY (`i`)
  1658. ) ENGINE=MyISAM AUTO_INCREMENT=100 DEFAULT CHARSET=latin1 COMMENT='comment for table t1'
  1659. flush tables;
  1660. select * from t2;
  1661. i j k
  1662. execute stmt;
  1663. show create table t1;
  1664. Table Create Table
  1665. t1 CREATE TABLE `t1` (
  1666. `i` int(11) NOT NULL auto_increment,
  1667. PRIMARY KEY (`i`)
  1668. ) ENGINE=MyISAM AUTO_INCREMENT=100 DEFAULT CHARSET=latin1 COMMENT='comment for table t1'
  1669. deallocate prepare stmt;
  1670. drop table t1, t2;
  1671. drop tables if exists t1;
  1672. create table t1 (id int primary key auto_increment, value varchar(10));
  1673. insert into t1 (id, value) values (1, 'FIRST'), (2, 'SECOND'), (3, 'THIRD');
  1674. prepare stmt from "insert into t1 (id, value) select * from (select 4 as i, 'FOURTH' as v) as y on duplicate key update v = 'DUP'";
  1675. execute stmt;
  1676. ERROR 42S22: Unknown column 'v' in 'field list'
  1677. execute stmt;
  1678. ERROR 42S22: Unknown column 'v' in 'field list'
  1679. deallocate prepare stmt;
  1680. prepare stmt from "insert into t1 (id, value) select * from (select 4 as id, 'FOURTH' as value) as y on duplicate key update y.value = 'DUP'";
  1681. execute stmt;
  1682. ERROR 42S22: Unknown column 'y.value' in 'field list'
  1683. execute stmt;
  1684. ERROR 42S22: Unknown column 'y.value' in 'field list'
  1685. deallocate prepare stmt;
  1686. drop tables t1;
  1687. prepare stmt from "create table t1 select ?";
  1688. set @a=1.0;
  1689. execute stmt using @a;
  1690. show create table t1;
  1691. Table Create Table
  1692. t1 CREATE TABLE `t1` (
  1693. `?` decimal(2,1) default NULL
  1694. ) ENGINE=MyISAM DEFAULT CHARSET=latin1
  1695. drop table t1;
  1696. drop table if exists t1;
  1697. create table t1 (a bigint unsigned, b bigint(20) unsigned);
  1698. prepare stmt from "insert into t1 values (?,?)";
  1699. set @a= 9999999999999999;
  1700. set @b= 14632475938453979136;
  1701. insert into t1 values (@a, @b);
  1702. select * from t1 where a = @a and b = @b;
  1703. a b
  1704. 9999999999999999 14632475938453979136
  1705. execute stmt using @a, @b;
  1706. select * from t1 where a = @a and b = @b;
  1707. a b
  1708. 9999999999999999 14632475938453979136
  1709. 9999999999999999 14632475938453979136
  1710. deallocate prepare stmt;
  1711. drop table t1;
  1712. drop view if exists v1;
  1713. drop table if exists t1;
  1714. create table t1 (a int, b int);
  1715. insert into t1 values (1,1), (2,2), (3,3);
  1716. insert into t1 values (3,1), (1,2), (2,3);
  1717. prepare stmt from "create view v1 as select * from t1";
  1718. execute stmt;
  1719. drop table t1;
  1720. create table t1 (a int, b int);
  1721. drop view v1;
  1722. execute stmt;
  1723. show create view v1;
  1724. View Create View
  1725. v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1`
  1726. drop view v1;
  1727. prepare stmt from "create view v1 (c,d) as select a,b from t1";
  1728. execute stmt;
  1729. show create view v1;
  1730. View Create View
  1731. v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `c`,`t1`.`b` AS `d` from `t1`
  1732. select * from v1;
  1733. c d
  1734. drop view v1;
  1735. execute stmt;
  1736. deallocate prepare stmt;
  1737. show create view v1;
  1738. View Create View
  1739. v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `c`,`t1`.`b` AS `d` from `t1`
  1740. select * from v1;
  1741. c d
  1742. drop view v1;
  1743. prepare stmt from "create view v1 (c) as select b+1 from t1";
  1744. execute stmt;
  1745. show create view v1;
  1746. View Create View
  1747. v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (`t1`.`b` + 1) AS `c` from `t1`
  1748. select * from v1;
  1749. c
  1750. drop view v1;
  1751. execute stmt;
  1752. deallocate prepare stmt;
  1753. show create view v1;
  1754. View Create View
  1755. v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (`t1`.`b` + 1) AS `c` from `t1`
  1756. select * from v1;
  1757. c
  1758. drop view v1;
  1759. prepare stmt from "create view v1 (c,d,e,f) as select a,b,a in (select a+2 from t1), a = all (select a from t1) from t1";
  1760. execute stmt;
  1761. show create view v1;
  1762. View Create View
  1763. v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `c`,`t1`.`b` AS `d`,`t1`.`a` in (select (`t1`.`a` + 2) AS `a+2` from `t1`) AS `e`,`t1`.`a` = all (select `t1`.`a` AS `a` from `t1`) AS `f` from `t1`
  1764. select * from v1;
  1765. c d e f
  1766. drop view v1;
  1767. execute stmt;
  1768. deallocate prepare stmt;
  1769. show create view v1;
  1770. View Create View
  1771. v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `c`,`t1`.`b` AS `d`,`t1`.`a` in (select (`t1`.`a` + 2) AS `a+2` from `t1`) AS `e`,`t1`.`a` = all (select `t1`.`a` AS `a` from `t1`) AS `f` from `t1`
  1772. select * from v1;
  1773. c d e f
  1774. drop view v1;
  1775. prepare stmt from "create or replace view v1 as select 1";
  1776. execute stmt;
  1777. show create view v1;
  1778. View Create View
  1779. v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 AS `1`
  1780. select * from v1;
  1781. 1
  1782. 1
  1783. execute stmt;
  1784. show create view v1;
  1785. View Create View
  1786. v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 AS `1`
  1787. deallocate prepare stmt;
  1788. show create view v1;
  1789. View Create View
  1790. v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 AS `1`
  1791. select * from v1;
  1792. 1
  1793. 1
  1794. drop view v1;
  1795. prepare stmt from "create view v1 as select 1, 1";
  1796. execute stmt;
  1797. show create view v1;
  1798. View Create View
  1799. v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 AS `1`,1 AS `My_exp_1`
  1800. select * from v1;
  1801. 1 My_exp_1
  1802. 1 1
  1803. drop view v1;
  1804. execute stmt;
  1805. deallocate prepare stmt;
  1806. show create view v1;
  1807. View Create View
  1808. v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 AS `1`,1 AS `My_exp_1`
  1809. select * from v1;
  1810. 1 My_exp_1
  1811. 1 1
  1812. drop view v1;
  1813. prepare stmt from "create view v1 (x) as select a from t1 where a > 1";
  1814. execute stmt;
  1815. show create view v1;
  1816. View Create View
  1817. v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `x` from `t1` where (`t1`.`a` > 1)
  1818. select * from v1;
  1819. x
  1820. drop view v1;
  1821. execute stmt;
  1822. deallocate prepare stmt;
  1823. show create view v1;
  1824. View Create View
  1825. v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `x` from `t1` where (`t1`.`a` > 1)
  1826. select * from v1;
  1827. x
  1828. drop view v1;
  1829. prepare stmt from "create view v1 as select * from `t1` `b`";
  1830. execute stmt;
  1831. show create view v1;
  1832. View Create View
  1833. v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `b`.`a` AS `a`,`b`.`b` AS `b` from `t1` `b`
  1834. select * from v1;
  1835. a b
  1836. drop view v1;
  1837. execute stmt;
  1838. deallocate prepare stmt;
  1839. show create view v1;
  1840. View Create View
  1841. v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `b`.`a` AS `a`,`b`.`b` AS `b` from `t1` `b`
  1842. select * from v1;
  1843. a b
  1844. drop view v1;
  1845. prepare stmt from "create view v1 (a,b,c) as select * from t1";
  1846. execute stmt;
  1847. ERROR HY000: View's SELECT and view's field list have different column counts
  1848. execute stmt;
  1849. ERROR HY000: View's SELECT and view's field list have different column counts
  1850. deallocate prepare stmt;
  1851. drop table t1;
  1852. create temporary table t1 (a int, b int);
  1853. prepare stmt from "create view v1 as select * from t1";
  1854. execute stmt;
  1855. ERROR HY000: View's SELECT refers to a temporary table 't1'
  1856. execute stmt;
  1857. ERROR HY000: View's SELECT refers to a temporary table 't1'
  1858. deallocate prepare stmt;
  1859. drop table t1;
  1860. prepare stmt from "create view v1 as select * from t1";
  1861. ERROR 42S02: Table 'test.t1' doesn't exist
  1862. prepare stmt from "create view v1 as select * from `t1` `b`";
  1863. ERROR 42S02: Table 'test.t1' doesn't exist
  1864. prepare stmt from "select ?";
  1865. set @arg= 123456789.987654321;
  1866. select @arg;
  1867. @arg
  1868. 123456789.987654321
  1869. execute stmt using @arg;
  1870. ?
  1871. 123456789.987654321
  1872. set @arg= "string";
  1873. select @arg;
  1874. @arg
  1875. string
  1876. execute stmt using @arg;
  1877. ?
  1878. string
  1879. set @arg= 123456;
  1880. select @arg;
  1881. @arg
  1882. 123456
  1883. execute stmt using @arg;
  1884. ?
  1885. 123456
  1886. set @arg= cast(-12345.54321 as decimal(20, 10));
  1887. select @arg;
  1888. @arg
  1889. -12345.5432100000
  1890. execute stmt using @arg;
  1891. ?
  1892. -12345.5432100000
  1893. deallocate prepare stmt;
  1894. End of 5.0 tests.