diff options
author | unknown <hf@deer.(none)> | 2004-08-20 10:50:23 +0500 |
---|---|---|
committer | unknown <hf@deer.(none)> | 2004-08-20 10:50:23 +0500 |
commit | 2e09e96b05777bf186c2fbdfaff703c71af0f28a (patch) | |
tree | 82d49439300c8a1f8f117da173ad6cb7c49748aa | |
parent | 1d3a929ec97b791394060e84f809f1dd8cd28f26 (diff) | |
parent | 83e6ea37be8b25cdfe34dc6aa198e780ecab1057 (diff) | |
download | mariadb-git-2e09e96b05777bf186c2fbdfaff703c71af0f28a.tar.gz |
Merge abotchkov@bk-internal.mysql.com:/home/bk/mysql-4.1
into deer.(none):/home/hf/work/mysql-4.1.emb
include/mysql.h:
Auto merged
libmysql/libmysql.c:
Auto merged
-rw-r--r-- | .bzrignore | 187 | ||||
-rw-r--r-- | cmd-line-utils/libedit/history.c | 2 | ||||
-rw-r--r-- | include/my_global.h | 30 | ||||
-rw-r--r-- | include/mysql.h | 2 | ||||
-rw-r--r-- | include/mysql_com.h | 12 | ||||
-rw-r--r-- | libmysql/libmysql.c | 2 | ||||
-rw-r--r-- | mysql-test/r/rpl_heap.result | 12 | ||||
-rw-r--r-- | mysql-test/r/subselect.result | 13 | ||||
-rw-r--r-- | mysql-test/r/type_float.result | 3 | ||||
-rw-r--r-- | mysql-test/t/rpl_heap.test | 6 | ||||
-rw-r--r-- | mysql-test/t/subselect.test | 13 | ||||
-rw-r--r-- | mysql-test/t/type_float.test | 8 | ||||
-rw-r--r-- | mysys/mf_tempfile.c | 4 | ||||
-rw-r--r-- | sql/Makefile.am | 1 | ||||
-rw-r--r-- | sql/field.cc | 20 | ||||
-rw-r--r-- | sql/ha_innodb.cc | 27 | ||||
-rw-r--r-- | sql/log.cc | 13 | ||||
-rw-r--r-- | sql/mysql_priv.h | 3 | ||||
-rw-r--r-- | sql/sql_class.h | 20 | ||||
-rw-r--r-- | sql/sql_parse.cc | 6 | ||||
-rw-r--r-- | sql/sql_select.cc | 10 | ||||
-rw-r--r-- | sql/sql_table.cc | 31 |
22 files changed, 263 insertions, 162 deletions
diff --git a/.bzrignore b/.bzrignore index 9542cfe8754..1a756801461 100644 --- a/.bzrignore +++ b/.bzrignore @@ -77,6 +77,7 @@ Docs/mysql.xml Docs/safe-mysql.xml Docs/tex.fmt Docs/texi2dvi.out +EXCEPTIONS-CLIENT INSTALL-SOURCE INSTALL-WIN-SOURCE Logs/* @@ -272,11 +273,13 @@ emacs.h extra/comp_err extra/my_print_defaults extra/mysql_install +extra/mysql_tzinfo_to_sql extra/mysql_waitpid extra/perror extra/replace extra/resolve_stack_dump extra/resolveip +extra/tztime.cc fcns.c fcns.h gmon.out @@ -316,6 +319,7 @@ isam/test3 libmysql/*.c libmysql/conf_to_src libmysql/my_static.h +libmysql/my_time.c libmysql/mysys_priv.h libmysql/net.c libmysql/vio_priv.h @@ -382,6 +386,7 @@ libmysqld/log_event.cc libmysqld/md5.c libmysqld/mf_iocache.cc libmysqld/mini_client.cc +libmysqld/my_time.c libmysqld/net_pkg.cc libmysqld/net_serv.cc libmysqld/opt_ft.cc @@ -644,7 +649,71 @@ ndb/lib/libREP_API.so ndb/lib/libndbclient.so ndb/lib/libndbclient_extra.so ndb/src/common/mgmcommon/printConfig/*.d +ndb/src/cw/cpcd/ndb_cpcd +ndb/src/kernel/blocks/backup/restore/ndb_restore +ndb/src/kernel/ndbd +ndb/src/mgmclient/ndb_mgm ndb/src/mgmclient/test_cpcd/*.d +ndb/src/mgmsrv/ndb_mgmd +ndb/test/ndbapi/bank/bankCreator +ndb/test/ndbapi/bank/bankMakeGL +ndb/test/ndbapi/bank/bankSumAccounts +ndb/test/ndbapi/bank/bankTimer +ndb/test/ndbapi/bank/bankTransactionMaker +ndb/test/ndbapi/bank/bankValidateAllGLs +ndb/test/ndbapi/bank/testBank +ndb/test/ndbapi/create_all_tabs +ndb/test/ndbapi/create_tab +ndb/test/ndbapi/drop_all_tabs +ndb/test/ndbapi/flexAsynch +ndb/test/ndbapi/flexBench +ndb/test/ndbapi/flexHammer +ndb/test/ndbapi/flexTT +ndb/test/ndbapi/testBackup +ndb/test/ndbapi/testBasic +ndb/test/ndbapi/testBasicAsynch +ndb/test/ndbapi/testBlobs +ndb/test/ndbapi/testDataBuffers +ndb/test/ndbapi/testDeadlock +ndb/test/ndbapi/testDict +ndb/test/ndbapi/testIndex +ndb/test/ndbapi/testMgm +ndb/test/ndbapi/testNdbApi +ndb/test/ndbapi/testNodeRestart +ndb/test/ndbapi/testOIBasic +ndb/test/ndbapi/testOperations +ndb/test/ndbapi/testRestartGci +ndb/test/ndbapi/testScan +ndb/test/ndbapi/testScanInterpreter +ndb/test/ndbapi/testScanPerf +ndb/test/ndbapi/testSystemRestart +ndb/test/ndbapi/testTimeout +ndb/test/ndbapi/testTransactions +ndb/test/ndbapi/test_event +ndb/test/run-test/atrt +ndb/test/tools/copy_tab +ndb/test/tools/create_index +ndb/test/tools/hugoCalculator +ndb/test/tools/hugoFill +ndb/test/tools/hugoLoad +ndb/test/tools/hugoLockRecords +ndb/test/tools/hugoPkDelete +ndb/test/tools/hugoPkRead +ndb/test/tools/hugoPkReadRecord +ndb/test/tools/hugoPkUpdate +ndb/test/tools/hugoScanRead +ndb/test/tools/hugoScanUpdate +ndb/test/tools/ndb_cpcc +ndb/test/tools/restart +ndb/test/tools/verify_index +ndb/tools/ndb_delete_all +ndb/tools/ndb_desc +ndb/tools/ndb_drop_index +ndb/tools/ndb_drop_table +ndb/tools/ndb_select_all +ndb/tools/ndb_select_count +ndb/tools/ndb_show_tables +ndb/tools/ndb_waiter pull.log regex/re repl-tests/test-repl-ts/repl-timestamp.master.reject @@ -715,7 +784,10 @@ sql/gen_lex_hash sql/gmon.out sql/lex_hash.h sql/mini_client_errors.c +sql/my_time.c sql/mysql_tzinfo_to_sql +sql/mysql_tzinfo_to_sql.cc +sql/mysql_tzinfo_to_sql_tztime.cc sql/mysqlbinlog sql/mysqld sql/mysqld-purecov @@ -770,41 +842,13 @@ support-files/mysql-log-rotate support-files/mysql.server support-files/mysql.spec tags -test_xml -tests/client_test -tests/connect_test -thread_test -tmp/* -tools/my_vsnprintf.c -tools/mysqlmanager -tools/mysqlmngd -tools/mysys_priv.h -vi.h -vio/test-ssl -vio/test-sslclient -vio/test-sslserver -vio/viotest-ssl -extra/tztime.cc -extra/mysql_tzinfo_to_sql -sql/mysql_tzinfo_to_sql_tztime.cc -sql/my_time.c -libmysql/my_time.c -libmysqld/my_time.c -sql/mysql_tzinfo_to_sql -sql/mysql_tzinfo_to_sql.cc -ndb/src/cw/cpcd/ndb_cpcd -ndb/src/kernel/ndbd -ndb/src/kernel/blocks/backup/restore/ndb_restore -ndb/src/mgmclient/ndb_mgm -ndb/src/mgmsrv/ndb_mgmd -ndb/tools/ndb_delete_all -ndb/tools/ndb_desc -ndb/tools/ndb_drop_index -ndb/tools/ndb_drop_table -ndb/tools/ndb_select_all -ndb/tools/ndb_select_count -ndb/tools/ndb_show_tables -ndb/tools/ndb_waiter +test/ndbapi/bank/bankCreator +test/ndbapi/bank/bankMakeGL +test/ndbapi/bank/bankSumAccounts +test/ndbapi/bank/bankTimer +test/ndbapi/bank/bankTransactionMaker +test/ndbapi/bank/bankValidateAllGLs +test/ndbapi/bank/testBank test/ndbapi/create_all_tabs test/ndbapi/create_tab test/ndbapi/drop_all_tabs @@ -833,13 +877,6 @@ test/ndbapi/testSystemRestart test/ndbapi/testTimeout test/ndbapi/testTransactions test/ndbapi/test_event -test/ndbapi/bank/bankCreator -test/ndbapi/bank/bankMakeGL -test/ndbapi/bank/bankSumAccounts -test/ndbapi/bank/bankTimer -test/ndbapi/bank/bankTransactionMaker -test/ndbapi/bank/bankValidateAllGLs -test/ndbapi/bank/testBank test/run-test/atrt test/tools/copy_tab test/tools/create_index @@ -856,55 +893,17 @@ test/tools/hugoScanUpdate test/tools/ndb_cpcc test/tools/restart test/tools/verify_index -ndb/test/ndbapi/create_all_tabs -ndb/test/ndbapi/create_tab -ndb/test/ndbapi/drop_all_tabs -ndb/test/ndbapi/flexAsynch -ndb/test/ndbapi/flexBench -ndb/test/ndbapi/flexHammer -ndb/test/ndbapi/flexTT -ndb/test/ndbapi/testBackup -ndb/test/ndbapi/testBasic -ndb/test/ndbapi/testBasicAsynch -ndb/test/ndbapi/testBlobs -ndb/test/ndbapi/testDataBuffers -ndb/test/ndbapi/testDeadlock -ndb/test/ndbapi/testDict -ndb/test/ndbapi/testIndex -ndb/test/ndbapi/testMgm -ndb/test/ndbapi/testNdbApi -ndb/test/ndbapi/testNodeRestart -ndb/test/ndbapi/testOIBasic -ndb/test/ndbapi/testOperations -ndb/test/ndbapi/testRestartGci -ndb/test/ndbapi/testScan -ndb/test/ndbapi/testScanInterpreter -ndb/test/ndbapi/testScanPerf -ndb/test/ndbapi/testSystemRestart -ndb/test/ndbapi/testTimeout -ndb/test/ndbapi/testTransactions -ndb/test/ndbapi/test_event -ndb/test/ndbapi/bank/bankCreator -ndb/test/ndbapi/bank/bankMakeGL -ndb/test/ndbapi/bank/bankSumAccounts -ndb/test/ndbapi/bank/bankTimer -ndb/test/ndbapi/bank/bankTransactionMaker -ndb/test/ndbapi/bank/bankValidateAllGLs -ndb/test/ndbapi/bank/testBank -ndb/test/run-test/atrt -ndb/test/tools/copy_tab -ndb/test/tools/create_index -ndb/test/tools/hugoCalculator -ndb/test/tools/hugoFill -ndb/test/tools/hugoLoad -ndb/test/tools/hugoLockRecords -ndb/test/tools/hugoPkDelete -ndb/test/tools/hugoPkRead -ndb/test/tools/hugoPkReadRecord -ndb/test/tools/hugoPkUpdate -ndb/test/tools/hugoScanRead -ndb/test/tools/hugoScanUpdate -ndb/test/tools/ndb_cpcc -ndb/test/tools/restart -ndb/test/tools/verify_index -EXCEPTIONS-CLIENT +test_xml +tests/client_test +tests/connect_test +thread_test +tmp/* +tools/my_vsnprintf.c +tools/mysqlmanager +tools/mysqlmngd +tools/mysys_priv.h +vi.h +vio/test-ssl +vio/test-sslclient +vio/test-sslserver +vio/viotest-ssl diff --git a/cmd-line-utils/libedit/history.c b/cmd-line-utils/libedit/history.c index 90d94e7fc18..457c8f4a768 100644 --- a/cmd-line-utils/libedit/history.c +++ b/cmd-line-utils/libedit/history.c @@ -649,7 +649,7 @@ history_save(History *h, const char *fname) retval = HPREV(h, &ev), i++) { len = strlen(ev.str) * 4; if (len >= max_size) { - max_size = (len + 1023) & 1023; + max_size = (len + 1023) & ~1023; ptr = h_realloc(ptr, max_size); } (void) strvis(ptr, ev.str, VIS_WHITE); diff --git a/include/my_global.h b/include/my_global.h index a9ca5416c88..89a5363dc4b 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -644,29 +644,17 @@ typedef SOCKET_SIZE_TYPE size_socket; #endif #endif /* defined (HAVE_LONG_LONG) && !defined(ULONGLONG_MAX)*/ -#if SIZEOF_LONG == 4 -#define INT_MIN32 ((long) 0x80000000L) -#define INT_MAX32 ((long) 0x7FFFFFFFL) -#define UINT_MAX32 ((long) 0xFFFFFFFFL) -#define INT_MIN24 ((long) 0xFF800000L) -#define INT_MAX24 0x007FFFFFL -#define UINT_MAX24 0x00FFFFFFL -#define INT_MIN16 ((short int) 0x8000) +#define INT_MIN32 (~0x7FFFFFFFL) +#define INT_MAX32 0x7FFFFFFFL +#define UINT_MAX32 0xFFFFFFFFL +#define INT_MIN24 (~0x007FFFFF) +#define INT_MAX24 0x007FFFFF +#define UINT_MAX24 0x00FFFFFF +#define INT_MIN16 (~0x7FFF) #define INT_MAX16 0x7FFF #define UINT_MAX16 0xFFFF -#define INT_MIN8 ((char) 0x80) -#define INT_MAX8 ((char) 0x7F) -#else /* Probably Alpha */ -#define INT_MIN32 ((long) (int) 0x80000000) -#define INT_MAX32 ((long) (int) 0x7FFFFFFF) -#define UINT_MAX32 ((long) (int) 0xFFFFFFFF) -#define INT_MIN24 ((long) (int) 0xFF800000) -#define INT_MAX24 ((long) (int) 0x007FFFFF) -#define UINT_MAX24 ((long) (int) 0x00FFFFFF) -#define INT_MIN16 ((short int) 0xFFFF8000) -#define INT_MAX16 ((short int) 0x00007FFF) -#define UINT_MAX16 ((short int) 0x0000FFFF) -#endif +#define INT_MIN8 (~0x7F) +#define INT_MAX8 0x7F /* From limits.h instead */ #ifndef DBL_MIN diff --git a/include/mysql.h b/include/mysql.h index b339b839ab3..e2ed3ab59af 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -454,7 +454,7 @@ int STDCALL mysql_add_slave(MYSQL* mysql, const char* host, const char* passwd); int STDCALL mysql_shutdown(MYSQL *mysql, - enum enum_shutdown_level + enum mysql_enum_shutdown_level shutdown_level); int STDCALL mysql_dump_debug_info(MYSQL *mysql); int STDCALL mysql_refresh(MYSQL *mysql, diff --git a/include/mysql_com.h b/include/mysql_com.h index 36d41b2964a..3b65d6f3fbc 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -238,17 +238,17 @@ enum mysql_enum_shutdown_level { comparisons). Note that DEFAULT does not respect the growing property, but it's ok. */ - DEFAULT= 0, + SHUTDOWN_DEFAULT = 0, /* wait for existing connections to finish */ - WAIT_CONNECTIONS= MYSQL_SHUTDOWN_KILLABLE_CONNECT, + SHUTDOWN_WAIT_CONNECTIONS= MYSQL_SHUTDOWN_KILLABLE_CONNECT, /* wait for existing trans to finish */ - WAIT_TRANSACTIONS= MYSQL_SHUTDOWN_KILLABLE_TRANS, + SHUTDOWN_WAIT_TRANSACTIONS= MYSQL_SHUTDOWN_KILLABLE_TRANS, /* wait for existing updates to finish (=> no partial MyISAM update) */ - WAIT_UPDATES= MYSQL_SHUTDOWN_KILLABLE_UPDATE, + SHUTDOWN_WAIT_UPDATES= MYSQL_SHUTDOWN_KILLABLE_UPDATE, /* flush InnoDB buffers and other storage engines' buffers*/ - WAIT_ALL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1), + SHUTDOWN_WAIT_ALL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1), /* don't flush InnoDB buffers, flush other storage engines' buffers*/ - WAIT_CRITICAL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1) + 1, + SHUTDOWN_WAIT_CRITICAL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1) + 1, /* Now the 2 levels of the KILL command */ #if MYSQL_VERSION_ID >= 50000 KILL_QUERY= 254, diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 2a4530cab48..cea8ce3a499 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -1291,7 +1291,7 @@ mysql_drop_db(MYSQL *mysql, const char *db) int STDCALL -mysql_shutdown(MYSQL *mysql, enum enum_shutdown_level shutdown_level) +mysql_shutdown(MYSQL *mysql, enum mysql_enum_shutdown_level shutdown_level) { uchar level[1]; DBUG_ENTER("mysql_shutdown"); diff --git a/mysql-test/r/rpl_heap.result b/mysql-test/r/rpl_heap.result index 1556bcd5f25..1facbcb7676 100644 --- a/mysql-test/r/rpl_heap.result +++ b/mysql-test/r/rpl_heap.result @@ -1,22 +1,22 @@ reset master; drop table if exists t1; -create table t1 (a int) type=HEAP; -insert into t1 values(10); +create table t1 type=HEAP select 10 as a; +insert into t1 values(11); show binlog events from 79; Log_name Pos Event_type Server_id Orig_log_pos Info -master-bin.001 79 Query 1 79 use `test`; create table t1 (a int) type=HEAP -master-bin.001 147 Query 1 147 use `test`; DELETE FROM `test`.`t1` -master-bin.001 205 Query 1 205 use `test`; insert into t1 values(10) +master-bin.001 79 Query 1 79 use `test`; create table t1 type=HEAP select 10 as a +master-bin.001 154 Query 1 154 use `test`; insert into t1 values(11) reset slave; start slave; show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` int(11) default NULL + `a` bigint(2) NOT NULL default '0' ) TYPE=HEAP select * from t1; a 10 +11 select * from t1; a select * from t1 limit 10; diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 77339473142..fe7ffa9b661 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -1899,3 +1899,16 @@ select t000.a, count(*) `C` FROM t1 t000 GROUP BY t000.a HAVING count(*) > ALL ( a C 1 1 drop table t1,t2; +create table t1 (a int not null auto_increment primary key, b varchar(40), fulltext(b)); +insert into t1 (b) values ('ball'),('ball games'), ('games'), ('foo'), ('foobar'), ('Serg'), ('Sergei'),('Georg'), ('Patrik'),('Hakan'); +create table t2 (a int); +insert into t2 values (1),(3),(2),(7); +select a,b from t1 where match(b) against ('Ball') > 0; +a b +1 ball +2 ball games +select a from t2 where a in (select a from t1 where match(b) against ('Ball') > 0); +a +1 +2 +drop table t1,t2; diff --git a/mysql-test/r/type_float.result b/mysql-test/r/type_float.result index f6a19a861a1..843bdc2bdc5 100644 --- a/mysql-test/r/type_float.result +++ b/mysql-test/r/type_float.result @@ -135,6 +135,9 @@ t1 CREATE TABLE `t1` ( `b` double(200,30) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; +create table t1 (c20 char); +insert into t1 values (5000.0); +drop table t1; create table t1 (f float(54)); ERROR 42000: Incorrect column specifier for column 'f' drop table if exists t1; diff --git a/mysql-test/t/rpl_heap.test b/mysql-test/t/rpl_heap.test index 15f61918034..0bc71eaf30c 100644 --- a/mysql-test/t/rpl_heap.test +++ b/mysql-test/t/rpl_heap.test @@ -13,8 +13,10 @@ connect (slave,localhost,root,,test,0,slave.sock); connection master; reset master; drop table if exists t1; -create table t1 (a int) type=HEAP; -insert into t1 values(10); +# we use CREATE SELECT to verify that DELETE does not get into binlog +# before CREATE SELECT +create table t1 type=HEAP select 10 as a; +insert into t1 values(11); save_master_pos; show binlog events from 79; connection slave; diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index eb4b1f33b14..02a570b1db3 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -1222,3 +1222,16 @@ CREATE TABLE `t2` ( `b` int(11) default NULL, `a` int(11) default NULL) ENGINE=M insert into t2 values (1,2); select t000.a, count(*) `C` FROM t1 t000 GROUP BY t000.a HAVING count(*) > ALL (SELECT count(*) FROM t2 t001 WHERE t001.a=1); drop table t1,t2; + +# +# BUG#4769 - fulltext in subselect +# +create table t1 (a int not null auto_increment primary key, b varchar(40), fulltext(b)); +insert into t1 (b) values ('ball'),('ball games'), ('games'), ('foo'), ('foobar'), ('Serg'), ('Sergei'),('Georg'), ('Patrik'),('Hakan'); +create table t2 (a int); +insert into t2 values (1),(3),(2),(7); +select a,b from t1 where match(b) against ('Ball') > 0; +select a from t2 where a in (select a from t1 where match(b) against ('Ball') > 0); +drop table t1,t2; + + diff --git a/mysql-test/t/type_float.test b/mysql-test/t/type_float.test index cfaa5d611f2..4b627ea9b99 100644 --- a/mysql-test/t/type_float.test +++ b/mysql-test/t/type_float.test @@ -72,6 +72,13 @@ select * from t1; show create table t1; drop table t1; +# +# float in a char(1) field +# +create table t1 (c20 char); +insert into t1 values (5000.0); +drop table t1; + # Errors --error 1063 @@ -79,3 +86,4 @@ create table t1 (f float(54)); # Should give an error --disable_warnings drop table if exists t1; --enable_warnings + diff --git a/mysys/mf_tempfile.c b/mysys/mf_tempfile.c index 0b337a74c19..af9ff0d6711 100644 --- a/mysys/mf_tempfile.c +++ b/mysys/mf_tempfile.c @@ -98,7 +98,7 @@ File create_temp_file(char *to, const char *dir, const char *prefix, if (strlen(dir)+ pfx_len > FN_REFLEN-2) { errno=my_errno= ENAMETOOLONG; - return 1; + DBUG_RETURN(file); } strmov(convert_dirname(to,dir,NullS),prefix_buff); org_file=mkstemp(to); @@ -124,7 +124,7 @@ File create_temp_file(char *to, const char *dir, const char *prefix, #ifdef OS2 /* changing environ variable doesn't work with VACPP */ char buffer[256], *end; - buffer[sizeof[buffer)-1]= 0; + buffer[sizeof(buffer)-1]= 0; end= strxnmov(buffer, sizeof(buffer)-1, (char*) "TMP=", dir, NullS); /* remove ending backslash */ if (end[-1] == '\\') diff --git a/sql/Makefile.am b/sql/Makefile.am index d1dfbfb390e..ec4e729bedb 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -45,7 +45,6 @@ mysqld_LDADD = @MYSQLD_EXTRA_LDFLAGS@ \ @innodb_system_libs@ \ @ndbcluster_libs@ @ndbcluster_system_libs@ \ $(LDADD) $(CXXLDFLAGS) $(WRAPLIBS) @LIBDL@ @openssl_libs@ -mysqld_DEPENDENCIES = @ndbcluster_libs@ @ndbcluster_system_libs@ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \ item_strfunc.h item_timefunc.h item_uniq.h \ item_create.h item_subselect.h item_row.h \ diff --git a/sql/field.cc b/sql/field.cc index 522daa9e2cd..96f4fa8fd86 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4279,7 +4279,7 @@ int Field_str::store(double nr) { bool use_scientific_notation=TRUE; char buff[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE]; - int length; + uint length; if (field_length < 32 && nr > 1) // TODO: negative numbers { if (ceiling == 0) @@ -4295,11 +4295,19 @@ int Field_str::store(double nr) } use_scientific_notation= (ceiling < nr); } - length= sprintf(buff, "%-.*g", - use_scientific_notation ? max(0,field_length-5) : field_length, - nr); - DBUG_ASSERT(length <= field_length); - return store((const char *)buff, (uint) length, charset()); + length= (uint)sprintf(buff, "%-.*g", + use_scientific_notation ? max(0,(int)field_length-5) : field_length, + nr); + /* + +1 below is because "precision" in %g above means the + max. number of significant digits, not the output width. + Thus the width can be larger than number of significant digits by 1 + (for decimal point) + the test for field_length < 5 is for extreme cases, + like inserting 500.0 in char(1) + */ + DBUG_ASSERT(field_length < 5 || length <= field_length+1); + return store((const char *)buff, min(length, field_length), charset()); } int Field_string::store(longlong nr) diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index b1e5a16bc32..5aa7c02fcc0 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -40,6 +40,7 @@ have disables the InnoDB inlining in this file. */ #include <m_ctype.h> #include <hash.h> #include <myisampack.h> +#include <mysys_err.h> #define MAX_ULONG_BIT ((ulong) 1 << (sizeof(ulong)*8-1)) @@ -433,6 +434,7 @@ innobase_mysql_tmpfile(void) /* out: temporary file descriptor, or < 0 on error */ { char filename[FN_REFLEN]; + int fd2 = -1; File fd = create_temp_file(filename, NullS, "ib", #ifdef __WIN__ O_BINARY | O_TRUNC | O_SEQUENTIAL | @@ -440,12 +442,31 @@ innobase_mysql_tmpfile(void) #endif /* __WIN__ */ O_CREAT | O_EXCL | O_RDWR, MYF(MY_WME)); -#ifndef __WIN__ if (fd >= 0) { +#ifndef __WIN__ + /* On Windows, open files cannot be removed, but files can be + created with the O_TEMPORARY flag to the same effect + ("delete on close"). */ unlink(filename); - } #endif /* !__WIN__ */ - return(fd); + /* Copy the file descriptor, so that the additional resources + allocated by create_temp_file() can be freed by invoking + my_close(). + + Because the file descriptor returned by this function + will be passed to fdopen(), it will be closed by invoking + fclose(), which in turn will invoke close() instead of + my_close(). */ + fd2 = dup(fd); + if (fd2 < 0) { + DBUG_PRINT("error",("Got error %d on dup",fd2)); + my_errno=errno; + my_error(EE_OUT_OF_FILERESOURCES, + MYF(ME_BELL+ME_WAITTANG), filename, my_errno); + } + my_close(fd, MYF(MY_WME)); + } + return(fd2); } /************************************************************************* diff --git a/sql/log.cc b/sql/log.cc index ac412f2de9a..240965fdca3 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1877,6 +1877,19 @@ void MYSQL_LOG::set_max_size(ulong max_size_arg) } +Disable_binlog::Disable_binlog(THD *thd_arg) : + thd(thd_arg), save_options(thd_arg->options) +{ + thd_arg->options&= ~OPTION_BIN_LOG; +} + + +Disable_binlog::~Disable_binlog() +{ + thd->options= save_options; +} + + /* Check if a string is a valid number diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 9ada2fba164..031f021e261 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -518,7 +518,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, int mysql_create_table(THD *thd,const char *db, const char *table_name, HA_CREATE_INFO *create_info, List<create_field> &fields, List<Key> &keys, - bool tmp_table, bool no_log, uint select_field_count); + bool tmp_table, uint select_field_count); + TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, const char *db, const char *name, List<create_field> *extra_fields, diff --git a/sql/sql_class.h b/sql/sql_class.h index 59ac8ff0483..875f60d6806 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1018,6 +1018,26 @@ public: #define SYSTEM_THREAD_SLAVE_SQL 4 /* + Disables binary logging for one thread, and resets it back to what it was + before being disabled. + Some functions (like the internal mysql_create_table() when it's called by + mysql_alter_table()) must NOT write to the binlog (binlogging is done at the + at a later stage of the command already, and must be, for locking reasons); + so we internally disable it temporarily by creating the Disable_binlog + object and reset the state by destroying the object (don't forget that! or + write code so that the object gets automatically destroyed when leaving a + block, see example in sql_table.cc). +*/ +class Disable_binlog { +private: + THD *thd; + ulong save_options; +public: + Disable_binlog(THD *thd_arg); + ~Disable_binlog(); +}; + +/* Used to hold information about file and file structure in exchainge via non-DB file (...INTO OUTFILE..., ...LOAD DATA...) */ diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 57e4022719e..41d7c471fe5 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1643,8 +1643,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd, SHUTDOWN_DEFAULT is 0. If client is >= 4.1.3, the shutdown level is in packet[0]. */ - enum enum_shutdown_level level= - (enum enum_shutdown_level) (uchar) packet[0]; + enum mysql_enum_shutdown_level level= + (enum mysql_enum_shutdown_level) (uchar) packet[0]; DBUG_PRINT("quit",("Got shutdown command for level %u", level)); if (level == SHUTDOWN_DEFAULT) level= SHUTDOWN_WAIT_ALL_BUFFERS; // soon default will be configurable @@ -2379,7 +2379,7 @@ mysql_execute_command(THD *thd) res= mysql_create_table(thd,create_table->db, create_table->real_name, &lex->create_info, lex->create_list, - lex->key_list,0,0,0); // do logging + lex->key_list,0,0); } if (!res) send_ok(thd); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index c56645e06b9..3a0ae219e81 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -729,6 +729,10 @@ JOIN::optimize() (select_lex->ftfunc_list->elements ? SELECT_NO_JOIN_CACHE : 0)); + /* Perform FULLTEXT search before all regular searches */ + if (!(select_options & SELECT_DESCRIBE)) + init_ftfuncs(thd, select_lex, test(order)); + /* is this simple IN subquery? */ @@ -784,7 +788,7 @@ JOIN::optimize() join_tab->info= "Using index; Using where"; else join_tab->info= "Using index"; - + DBUG_RETURN(unit->item-> change_engine(new subselect_indexsubquery_engine(thd, join_tab, @@ -849,8 +853,6 @@ JOIN::optimize() } having= 0; - /* Perform FULLTEXT search before all regular searches */ - init_ftfuncs(thd, select_lex, test(order)); /* Create a tmp table if distinct or if the sort is too complicated */ if (need_tmp) { @@ -858,7 +860,7 @@ JOIN::optimize() thd->proc_info="Creating tmp table"; init_items_ref_array(); - + tmp_table_param.hidden_field_count= (all_fields.elements - fields_list.elements); if (!(exec_tmp_table1 = diff --git a/sql/sql_table.cc b/sql/sql_table.cc index c82bff05412..9ff46f219b1 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1090,7 +1090,6 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, keys List of keys to create tmp_table Set to 1 if this is an internal temporary table (From ALTER TABLE) - no_log Don't log the query to binary log. DESCRIPTION If one creates a temporary table, this is automaticly opened @@ -1108,7 +1107,7 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, int mysql_create_table(THD *thd,const char *db, const char *table_name, HA_CREATE_INFO *create_info, List<create_field> &fields, - List<Key> &keys,bool tmp_table,bool no_log, + List<Key> &keys,bool tmp_table, uint select_field_count) { char path[FN_REFLEN]; @@ -1277,7 +1276,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, } thd->tmp_table_used= 1; } - if (!tmp_table && !no_log) + if (!tmp_table) { // Must be written before unlock mysql_update_log.write(thd,thd->query, thd->query_length); @@ -1352,6 +1351,7 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, TABLE *table; tmp_table.table_name=0; uint select_field_count= items->elements; + Disable_binlog disable_binlog(thd); DBUG_ENTER("create_table_from_items"); /* Add selected items to field list */ @@ -1382,9 +1382,17 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, } /* create and lock table */ /* QQ: This should be done atomic ! */ + /* We don't log the statement, it will be logged later */ if (mysql_create_table(thd,db,name,create_info,*extra_fields, - *keys,0,1,select_field_count)) // no logging + *keys,0,select_field_count)) DBUG_RETURN(0); + /* + If this is a HEAP table, the automatic DELETE FROM which is written to the + binlog when a HEAP table is opened for the first time since startup, must + not be written: 1) it would be wrong (imagine we're in CREATE SELECT: we + don't want to delete from it) 2) it would be written before the CREATE + TABLE, which is a wrong order. So we keep binary logging disabled. + */ if (!(table=open_table(thd,db,name,name,(bool*) 0))) { quick_rm_table(create_info->db_type,db,table_case_name(create_info,name)); @@ -1401,6 +1409,7 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, } table->file->extra(HA_EXTRA_WRITE_CACHE); DBUG_RETURN(table); + /* Note that leaving the function resets binlogging properties */ } @@ -3008,12 +3017,14 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, } else create_info->data_file_name=create_info->index_file_name=0; - - if ((error=mysql_create_table(thd, new_db, tmp_name, - create_info, - create_list,key_list,1,1,0))) // no logging - DBUG_RETURN(error); - + { + /* We don't log the statement, it will be logged later */ + Disable_binlog disable_binlog(thd); + if ((error=mysql_create_table(thd, new_db, tmp_name, + create_info, + create_list,key_list,1,0))) + DBUG_RETURN(error); + } if (table->tmp_table) new_table=open_table(thd,new_db,tmp_name,tmp_name,0); else |