Commit 848235f7 authored by unknown's avatar unknown

Merge BUG#15110 from 5.0 into 5.1.

Merge mysql.com:/home/alik/MySQL/devel/5.0-bug15110
into  mysql.com:/home/alik/MySQL/devel/5.1-bug15110


BitKeeper/etc/ignore:
  auto-union
client/mysqldump.c:
  Auto merged
include/mysql_com.h:
  Auto merged
mysql-test/r/mysqldump.result:
  Auto merged
mysql-test/r/type_time.result:
  Auto merged
sql/Makefile.am:
  Auto merged
sql/sp.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sql_acl.cc:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_show.cc:
  Auto merged
sql/sql_trigger.cc:
  Auto merged
client/Makefile.am:
  Add my_user.c
include/Makefile.am:
  Add my_user.c
libmysqld/Makefile.am:
  Add my_user.c
mysql-test/t/disabled.def:
  Enable type_time.test
sql/sql_parse.cc:
  Merge.
parents 4a114543 9d2def68
......@@ -133,107 +133,6 @@ autom4te.cache/*
autom4te.cache/output.0
autom4te.cache/requests
autom4te.cache/traces.0
storage/bdb/*.ds?
storage/bdb/*.vcproj
storage/bdb/README
storage/bdb/btree/btree_auto.c
storage/bdb/build_unix/*
storage/bdb/build_vxworks/db.h
storage/bdb/build_vxworks/db_int.h
storage/bdb/build_win32/db.h
storage/bdb/build_win32/db_archive.dsp
storage/bdb/build_win32/db_checkpoint.dsp
storage/bdb/build_win32/db_config.h
storage/bdb/build_win32/db_cxx.h
storage/bdb/build_win32/db_deadlock.dsp
storage/bdb/build_win32/db_dll.dsp
storage/bdb/build_win32/db_dump.dsp
storage/bdb/build_win32/db_int.h
storage/bdb/build_win32/db_java.dsp
storage/bdb/build_win32/db_load.dsp
storage/bdb/build_win32/db_perf.dsp
storage/bdb/build_win32/db_printlog.dsp
storage/bdb/build_win32/db_recover.dsp
storage/bdb/build_win32/db_stat.dsp
storage/bdb/build_win32/db_static.dsp
storage/bdb/build_win32/db_tcl.dsp
storage/bdb/build_win32/db_test.dsp
storage/bdb/build_win32/db_upgrade.dsp
storage/bdb/build_win32/db_verify.dsp
storage/bdb/build_win32/ex_access.dsp
storage/bdb/build_win32/ex_btrec.dsp
storage/bdb/build_win32/ex_env.dsp
storage/bdb/build_win32/ex_lock.dsp
storage/bdb/build_win32/ex_mpool.dsp
storage/bdb/build_win32/ex_tpcb.dsp
storage/bdb/build_win32/excxx_access.dsp
storage/bdb/build_win32/excxx_btrec.dsp
storage/bdb/build_win32/excxx_env.dsp
storage/bdb/build_win32/excxx_lock.dsp
storage/bdb/build_win32/excxx_mpool.dsp
storage/bdb/build_win32/excxx_tpcb.dsp
storage/bdb/build_win32/include.tcl
storage/bdb/build_win32/libdb.def
storage/bdb/build_win32/libdb.rc
storage/bdb/db/crdel_auto.c
storage/bdb/db/db_auto.c
storage/bdb/dbinc_auto/*.*
storage/bdb/dbreg/dbreg_auto.c
storage/bdb/dist/autom4te-2.53.cache/*
storage/bdb/dist/autom4te-2.53.cache/output.0
storage/bdb/dist/autom4te-2.53.cache/requests
storage/bdb/dist/autom4te-2.53.cache/traces.0
storage/bdb/dist/autom4te.cache/*
storage/bdb/dist/autom4te.cache/output.0
storage/bdb/dist/autom4te.cache/requests
storage/bdb/dist/autom4te.cache/traces.0
storage/bdb/dist/config.hin
storage/bdb/dist/configure
storage/bdb/dist/tags
storage/bdb/dist/template/db_server_proc
storage/bdb/dist/template/gen_client_ret
storage/bdb/dist/template/rec_btree
storage/bdb/dist/template/rec_crdel
storage/bdb/dist/template/rec_db
storage/bdb/dist/template/rec_dbreg
storage/bdb/dist/template/rec_fileops
storage/bdb/dist/template/rec_hash
storage/bdb/dist/template/rec_log
storage/bdb/dist/template/rec_qam
storage/bdb/dist/template/rec_txn
storage/bdb/fileops/fileops_auto.c
storage/bdb/hash/hash_auto.c
storage/bdb/include/btree_auto.h
storage/bdb/include/btree_ext.h
storage/bdb/include/clib_ext.h
storage/bdb/include/common_ext.h
storage/bdb/include/crdel_auto.h
storage/bdb/include/db_auto.h
storage/bdb/include/db_ext.h
storage/bdb/include/db_server.h
storage/bdb/include/env_ext.h
storage/bdb/include/gen_client_ext.h
storage/bdb/include/gen_server_ext.h
storage/bdb/include/hash_auto.h
storage/bdb/include/hash_ext.h
storage/bdb/include/lock_ext.h
storage/bdb/include/log_auto.h
storage/bdb/include/log_ext.h
storage/bdb/include/mp_ext.h
storage/bdb/include/mutex_ext.h
storage/bdb/include/os_ext.h
storage/bdb/include/qam_auto.h
storage/bdb/include/qam_ext.h
storage/bdb/include/rpc_client_ext.h
storage/bdb/include/rpc_server_ext.h
storage/bdb/include/tcl_ext.h
storage/bdb/include/txn_auto.h
storage/bdb/include/txn_ext.h
storage/bdb/include/xa_ext.h
storage/bdb/log/log_auto.c
storage/bdb/qam/qam_auto.c
storage/bdb/txn/txn_auto.c
storage/bdb/txn/txn_autop.c
binary/*
bkpull.log
bkpull.log*
......@@ -257,6 +156,7 @@ client/mf_iocache.c
client/mf_iocache.cc
client/my_decimal.cc
client/my_decimal.h
client/my_user.c
client/mysql
client/mysql.cpp
client/mysqladmin
......@@ -270,6 +170,7 @@ client/mysqlimport
client/mysqlmanager-pwgen
client/mysqlmanagerc
client/mysqlshow
client/mysqlslap
client/mysqltest
client/mysqltestmanager-pwgen
client/mysqltestmanagerc
......@@ -386,6 +287,7 @@ isam/test2
isam/test3
isamchk/*.ds?
isamchk/*.vcproj
item_xmlfunc.cc
lib_debug/*
lib_release/*
libmysql/*.c
......@@ -415,6 +317,9 @@ libmysqld/derror.cc
libmysqld/discover.cc
libmysqld/emb_qcache.cpp
libmysqld/errmsg.c
libmysqld/event.cc
libmysqld/event_executor.cc
libmysqld/event_timed.cc
libmysqld/examples/client_test.c
libmysqld/examples/client_test.cc
libmysqld/examples/completion_hash.cc
......@@ -450,6 +355,7 @@ libmysqld/ha_isammrg.cc
libmysqld/ha_myisam.cc
libmysqld/ha_myisammrg.cc
libmysqld/ha_ndbcluster.cc
libmysqld/ha_ndbcluster_binlog.cc
libmysqld/ha_partition.cc
libmysqld/ha_tina.cc
libmysqld/handler.cc
......@@ -480,6 +386,7 @@ libmysqld/mf_iocache.cc
libmysqld/mini_client.cc
libmysqld/my_decimal.cc
libmysqld/my_time.c
libmysqld/my_user.c
libmysqld/net_pkg.cc
libmysqld/net_serv.cc
libmysqld/opt_ft.cc
......@@ -494,6 +401,7 @@ libmysqld/protocol_cursor.cc
libmysqld/records.cc
libmysqld/repl_failsafe.cc
libmysqld/rpl_filter.cc
libmysqld/rpl_injector.cc
libmysqld/set_var.cc
libmysqld/simple-test
libmysqld/slave.cc
......@@ -1102,6 +1010,7 @@ sql/message.mc
sql/message.rc
sql/mini_client_errors.c
sql/my_time.c
sql/my_user.c
sql/mysql_tzinfo_to_sql
sql/mysql_tzinfo_to_sql.cc
sql/mysql_tzinfo_to_sql_tztime.cc
......@@ -1137,6 +1046,9 @@ stamp-h2.in
stamp-h3
stamp-h4
start_mysqld.sh
storage/archive/archive_test
storage/bdb/*.ds?
storage/bdb/*.vcproj
storage/bdb/README
storage/bdb/btree/btree_auto.c
storage/bdb/btree/btree_autop.c
......@@ -1156,6 +1068,38 @@ storage/bdb/build_vxworks/dbdemo/dbdemo20.wpj
storage/bdb/build_vxworks/dbdemo/dbdemo22.wpj
storage/bdb/build_win32/*.dsp
storage/bdb/build_win32/*.h
storage/bdb/build_win32/db.h
storage/bdb/build_win32/db_archive.dsp
storage/bdb/build_win32/db_checkpoint.dsp
storage/bdb/build_win32/db_config.h
storage/bdb/build_win32/db_cxx.h
storage/bdb/build_win32/db_deadlock.dsp
storage/bdb/build_win32/db_dll.dsp
storage/bdb/build_win32/db_dump.dsp
storage/bdb/build_win32/db_int.h
storage/bdb/build_win32/db_java.dsp
storage/bdb/build_win32/db_load.dsp
storage/bdb/build_win32/db_perf.dsp
storage/bdb/build_win32/db_printlog.dsp
storage/bdb/build_win32/db_recover.dsp
storage/bdb/build_win32/db_stat.dsp
storage/bdb/build_win32/db_static.dsp
storage/bdb/build_win32/db_tcl.dsp
storage/bdb/build_win32/db_test.dsp
storage/bdb/build_win32/db_upgrade.dsp
storage/bdb/build_win32/db_verify.dsp
storage/bdb/build_win32/ex_access.dsp
storage/bdb/build_win32/ex_btrec.dsp
storage/bdb/build_win32/ex_env.dsp
storage/bdb/build_win32/ex_lock.dsp
storage/bdb/build_win32/ex_mpool.dsp
storage/bdb/build_win32/ex_tpcb.dsp
storage/bdb/build_win32/excxx_access.dsp
storage/bdb/build_win32/excxx_btrec.dsp
storage/bdb/build_win32/excxx_env.dsp
storage/bdb/build_win32/excxx_lock.dsp
storage/bdb/build_win32/excxx_mpool.dsp
storage/bdb/build_win32/excxx_tpcb.dsp
storage/bdb/build_win32/include.tcl
storage/bdb/build_win32/libdb.def
storage/bdb/build_win32/libdb.rc
......@@ -1473,6 +1417,8 @@ storage/ndb/src/mgmclient/test_cpcd/*.d
storage/ndb/src/mgmsrv/ndb_mgmd
storage/ndb/src/mgmsrv/ndb_mgmd.dsp
storage/ndb/src/ndbapi/libndbapi.dsp
storage/ndb/test/ndbapi/DbAsyncGenerator
storage/ndb/test/ndbapi/DbCreate
storage/ndb/test/ndbapi/bank/bankCreator
storage/ndb/test/ndbapi/bank/bankMakeGL
storage/ndb/test/ndbapi/bank/bankSumAccounts
......@@ -1488,21 +1434,26 @@ storage/ndb/test/ndbapi/flexBench
storage/ndb/test/ndbapi/flexBench.dsp
storage/ndb/test/ndbapi/flexHammer
storage/ndb/test/ndbapi/flexTT
storage/ndb/test/ndbapi/ndbapi_slow_select
storage/ndb/test/ndbapi/testBackup
storage/ndb/test/ndbapi/testBasic
storage/ndb/test/ndbapi/testBasic.dsp
storage/ndb/test/ndbapi/testBasicAsynch
storage/ndb/test/ndbapi/testBitfield
storage/ndb/test/ndbapi/testBlobs
storage/ndb/test/ndbapi/testBlobs.dsp
storage/ndb/test/ndbapi/testDataBuffers
storage/ndb/test/ndbapi/testDeadlock
storage/ndb/test/ndbapi/testDict
storage/ndb/test/ndbapi/testIndex
storage/ndb/test/ndbapi/testLcp
storage/ndb/test/ndbapi/testMgm
storage/ndb/test/ndbapi/testNdbApi
storage/ndb/test/ndbapi/testNodeRestart
storage/ndb/test/ndbapi/testOIBasic
storage/ndb/test/ndbapi/testOperations
storage/ndb/test/ndbapi/testPartitioning
storage/ndb/test/ndbapi/testReadPerf
storage/ndb/test/ndbapi/testRestartGci
storage/ndb/test/ndbapi/testSRBank
storage/ndb/test/ndbapi/testScan
......@@ -1513,6 +1464,7 @@ storage/ndb/test/ndbapi/testSystemRestart
storage/ndb/test/ndbapi/testTimeout
storage/ndb/test/ndbapi/testTransactions
storage/ndb/test/ndbapi/test_event
storage/ndb/test/ndbapi/test_event_merge
storage/ndb/test/run-test/atrt
storage/ndb/test/src/libNDBT.dsp
storage/ndb/test/tools/copy_tab
......@@ -1527,6 +1479,7 @@ storage/ndb/test/tools/hugoPkReadRecord
storage/ndb/test/tools/hugoPkUpdate
storage/ndb/test/tools/hugoScanRead
storage/ndb/test/tools/hugoScanUpdate
storage/ndb/test/tools/listen_event
storage/ndb/test/tools/ndb_cpcc
storage/ndb/test/tools/restart
storage/ndb/test/tools/verify_index
......@@ -1658,20 +1611,3 @@ vio/viotest-sslconnect.cpp
vio/viotest.cpp
zlib/*.ds?
zlib/*.vcproj
client/mysqlslap
storage/archive/archive_test
item_xmlfunc.cc
storage/ndb/test/ndbapi/DbAsyncGenerator
storage/ndb/test/ndbapi/DbCreate
storage/ndb/test/ndbapi/ndbapi_slow_select
storage/ndb/test/ndbapi/testBitfield
storage/ndb/test/ndbapi/testLcp
storage/ndb/test/ndbapi/testPartitioning
storage/ndb/test/ndbapi/testReadPerf
storage/ndb/test/ndbapi/test_event_merge
storage/ndb/test/tools/listen_event
libmysqld/ha_ndbcluster_binlog.cc
libmysqld/rpl_injector.cc
libmysqld/event.cc
libmysqld/event_executor.cc
libmysqld/event_timed.cc
......@@ -56,7 +56,7 @@ mysqlshow_SOURCES= mysqlshow.c $(yassl_dummy_link_fix)
mysqlslap_SOURCES= mysqlslap.c $(top_srcdir)/mysys/my_lock.c \
$(top_srcdir)/mysys/my_alarm.c \
$(yassl_dummy_link_fix)
mysqldump_SOURCES= mysqldump.c $(yassl_dummy_link_fix)
mysqldump_SOURCES= mysqldump.c my_user.c $(yassl_dummy_link_fix)
mysqlimport_SOURCES= mysqlimport.c $(yassl_dummy_link_fix)
sql_src=log_event.h mysql_priv.h log_event.cc my_decimal.h my_decimal.cc
strings_src=decimal.c
......@@ -72,7 +72,10 @@ link_sources:
for f in $(strings_src) ; do \
rm -f $(srcdir)/$$f; \
@LN_CP_F@ $(top_srcdir)/strings/$$f $$f; \
done;
done; \
rm -f $(srcdir)/my_user.c; \
@LN_CP_F@ $(top_srcdir)/sql-common/my_user.c my_user.c;
# Don't update the files from bitkeeper
%::SCCS/s.%
......@@ -41,6 +41,7 @@
#include <my_global.h>
#include <my_sys.h>
#include <my_user.h>
#include <m_string.h>
#include <m_ctype.h>
#include <hash.h>
......@@ -1850,9 +1851,37 @@ static void dump_triggers_for_table (char *table, char *db)
DELIMITER ;;\n");
while ((row= mysql_fetch_row(result)))
{
fprintf(sql_file, "/*!50003 SET SESSION SQL_MODE=\"%s\" */;;\n\
/*!50003 CREATE TRIGGER %s %s %s ON %s FOR EACH ROW%s%s */;;\n\n",
row[6], /* sql_mode */
fprintf(sql_file,
"/*!50003 SET SESSION SQL_MODE=\"%s\" */;;\n"
"/*!50003 CREATE */ ",
row[6] /* sql_mode */);
if (mysql_num_fields(result) > 7)
{
/*
mysqldump can be run against the server, that does not support definer
in triggers (there is no DEFINER column in SHOW TRIGGERS output). So,
we should check if we have this column before accessing it.
*/
uint user_name_len;
char user_name_str[USERNAME_LENGTH + 1];
char quoted_user_name_str[USERNAME_LENGTH * 2 + 3];
uint host_name_len;
char host_name_str[HOSTNAME_LENGTH + 1];
char quoted_host_name_str[HOSTNAME_LENGTH * 2 + 3];
parse_user(row[7], strlen(row[7]), user_name_str, &user_name_len,
host_name_str, &host_name_len);
fprintf(sql_file,
"/*!50017 DEFINER=%s@%s */ ",
quote_name(user_name_str, quoted_user_name_str, FALSE),
quote_name(host_name_str, quoted_host_name_str, FALSE));
}
fprintf(sql_file,
"/*!50003 TRIGGER %s %s %s ON %s FOR EACH ROW%s%s */;;\n\n",
quote_name(row[0], name_buff, 0), /* Trigger */
row[4], /* Timing */
row[1], /* Event */
......
......@@ -31,7 +31,7 @@ noinst_HEADERS = config-win.h config-os2.h config-netware.h \
my_aes.h my_tree.h my_trie.h hash.h thr_alarm.h \
thr_lock.h t_ctype.h violite.h md5.h base64.h \
mysql_version.h.in my_handler.h my_time.h decimal.h \
my_vle.h
my_vle.h my_user.h
# mysql_version.h are generated
CLEANFILES = mysql_version.h my_config.h readline openssl
......
/* Copyright (C) 2005 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*
This is a header for libraries containing functions used in both server and
only some of clients (but not in libmysql)...
*/
#ifndef _my_user_h_
#define _my_user_h_
#include <my_global.h>
C_MODE_START
void parse_user(const char *user_id_str, uint user_id_len,
char *user_name_str, uint *user_name_len,
char *host_name_str, uint *host_name_len);
C_MODE_END
#endif /* _my_user_h_ */
......@@ -27,6 +27,14 @@
#define SERVER_VERSION_LENGTH 60
#define SQLSTATE_LENGTH 5
/*
USER_HOST_BUFF_SIZE -- length of string buffer, that is enough to contain
username and hostname parts of the user identifier with trailing zero in
MySQL standard format:
user_name_part@host_name_part\0
*/
#define USER_HOST_BUFF_SIZE HOSTNAME_LENGTH + USERNAME_LENGTH + 2
#define LOCAL_HOST "localhost"
#define LOCAL_HOST_NAMEDPIPE "."
......
......@@ -67,7 +67,7 @@ sqlsources = derror.cc field.cc field_conv.cc strfunc.cc filesort.cc \
event_executor.cc event.cc event_timed.cc \
rpl_filter.cc sql_partition.cc handlerton.cc sql_plugin.cc \
sql_tablespace.cc \
rpl_injector.cc
rpl_injector.cc my_user.c
libmysqld_int_a_SOURCES= $(libmysqld_sources) $(libmysqlsources) $(sqlsources)
EXTRA_libmysqld_a_SOURCES = ha_innodb.cc ha_berkeley.cc ha_archive.cc \
......
......@@ -2055,7 +2055,7 @@ UNLOCK TABLES;
/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;
DELIMITER ;;
/*!50003 SET SESSION SQL_MODE="" */;;
/*!50003 CREATE TRIGGER `trg1` BEFORE INSERT ON `t1` FOR EACH ROW
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `trg1` BEFORE INSERT ON `t1` FOR EACH ROW
begin
if new.a > 10 then
set new.a := 10;
......@@ -2064,12 +2064,12 @@ end if;
end */;;
/*!50003 SET SESSION SQL_MODE="" */;;
/*!50003 CREATE TRIGGER `trg2` BEFORE UPDATE ON `t1` FOR EACH ROW begin
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `trg2` BEFORE UPDATE ON `t1` FOR EACH ROW begin
if old.a % 2 = 0 then set new.b := 12; end if;
end */;;
/*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER" */;;
/*!50003 CREATE TRIGGER `trg3` AFTER UPDATE ON `t1` FOR EACH ROW
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `trg3` AFTER UPDATE ON `t1` FOR EACH ROW
begin
if new.a = -1 then
set @fired:= "Yes";
......@@ -2092,7 +2092,7 @@ UNLOCK TABLES;
/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;
DELIMITER ;;
/*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER" */;;
/*!50003 CREATE TRIGGER `trg4` BEFORE INSERT ON `t2` FOR EACH ROW
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `trg4` BEFORE INSERT ON `t2` FOR EACH ROW
begin
if new.a > 10 then
set @fired:= "No";
......@@ -2445,7 +2445,7 @@ UNLOCK TABLES;
/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;
DELIMITER ;;
/*!50003 SET SESSION SQL_MODE="" */;;
/*!50003 CREATE TRIGGER `test trig` BEFORE INSERT ON `t1 test` FOR EACH ROW BEGIN
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `test trig` BEFORE INSERT ON `t1 test` FOR EACH ROW BEGIN
INSERT INTO `t2 test` SET a2 = NEW.a1; END */;;
DELIMITER ;
......@@ -2640,7 +2640,7 @@ UNLOCK TABLES;
/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;
DELIMITER ;;
/*!50003 SET SESSION SQL_MODE="IGNORE_SPACE" */;;
/*!50003 CREATE TRIGGER `tr1` BEFORE INSERT ON `t1` FOR EACH ROW BEGIN
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `tr1` BEFORE INSERT ON `t1` FOR EACH ROW BEGIN
SET new.a = 0;
END */;;
......
......@@ -85,27 +85,3 @@ sec_to_time(time_to_sec(t))
13:00:00
09:00:00
drop table t1;
SELECT CAST(235959.123456 AS TIME);
CAST(235959.123456 AS TIME)
23:59:59.123456
SELECT CAST(0.235959123456e+6 AS TIME);
CAST(0.235959123456e+6 AS TIME)
23:59:59.123456
SELECT CAST(235959123456e-6 AS TIME);
CAST(235959123456e-6 AS TIME)
23:59:59.123456
SELECT CAST(235959.1234567 AS TIME);
CAST(235959.1234567 AS TIME)
23:59:59.123456
Warnings:
Warning 1292 Truncated incorrect time value: '235959.1234567'
SELECT CAST(0.2359591234567e6 AS TIME);
CAST(0.2359591234567e6 AS TIME)
23:59:59.123456
Warnings:
Warning 1292 Truncated incorrect time value: '235959.1234567'
SELECT CAST(0.2359591234567e+30 AS TIME);
CAST(0.2359591234567e+30 AS TIME)
NULL
Warnings:
Warning 1292 Truncated incorrect time value: '2.359591234567e+29'
......@@ -17,7 +17,6 @@ func_math : Bug #15448
group_min_max : Bug #15448
innodb_concurrent : Results are not deterministic, Elliot will fix (BUG#3300)
subselect : Bug#15706
type_time : Bug#15805
ps_7ndb : dbug assert in RBR mode when executing test suite
rpl_ddl : Bug#15963 SBR does not show "Definer" correctly
events : Affects flush test case. A table lock not released somewhere
......
......@@ -26,13 +26,17 @@ drop table t1;
# long fraction part and/or large exponent part.
#
# These must return normal result:
SELECT CAST(235959.123456 AS TIME);
SELECT CAST(0.235959123456e+6 AS TIME);
SELECT CAST(235959123456e-6 AS TIME);
# ##########################################################
# To be uncommented after fix BUG #15805
# ##########################################################
# SELECT CAST(235959.123456 AS TIME);
# SELECT CAST(0.235959123456e+6 AS TIME);
# SELECT CAST(235959123456e-6 AS TIME);
# These must cut fraction part and produce warning:
SELECT CAST(235959.1234567 AS TIME);
SELECT CAST(0.2359591234567e6 AS TIME);
# SELECT CAST(235959.1234567 AS TIME);
# SELECT CAST(0.2359591234567e6 AS TIME);
# This must return NULL and produce warning:
SELECT CAST(0.2359591234567e+30 AS TIME);
# SELECT CAST(0.2359591234567e+30 AS TIME);
# ##########################################################
# End of 4.1 tests
......@@ -15,7 +15,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
## Process this file with automake to create Makefile.in
EXTRA_DIST = client.c pack.c my_time.c
EXTRA_DIST = client.c pack.c my_time.c my_user.c
# Don't update the files from bitkeeper
%::SCCS/s.%
/* Copyright (C) 2005 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <my_user.h>
#include <m_string.h>
/*
Parse user value to user name and host name parts.
SYNOPSIS
user_id_str [IN] User value string (the source).
user_id_len [IN] Length of the user value.
user_name_str [OUT] Buffer to store user name part.
Must be not less than USERNAME_LENGTH + 1.
user_name_len [OUT] A place to store length of the user name part.
host_name_str [OUT] Buffer to store host name part.
Must be not less than HOSTNAME_LENGTH + 1.
host_name_len [OUT] A place to store length of the host name part.
*/
void parse_user(const char *user_id_str, uint user_id_len,
char *user_name_str, uint *user_name_len,
char *host_name_str, uint *host_name_len)
{
char *p= strrchr(user_id_str, '@');
if (!p)
{
*user_name_len= 0;
*host_name_len= 0;
}
else
{
*user_name_len= p - user_id_str;
*host_name_len= user_id_len - *user_name_len - 1;
memcpy(user_name_str, user_id_str, *user_name_len);
memcpy(host_name_str, p + 1, *host_name_len);
}
user_name_str[*user_name_len]= 0;
host_name_str[*host_name_len]= 0;
}
......@@ -96,7 +96,7 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc sql_partition.cc \
stacktrace.c repl_failsafe.h repl_failsafe.cc \
sql_olap.cc sql_view.cc \
gstream.cc spatial.cc sql_help.cc sql_cursor.cc \
tztime.cc my_time.c my_decimal.cc\
tztime.cc my_time.c my_user.c my_decimal.cc\
sp_head.cc sp_pcontext.cc sp_rcontext.cc sp.cc \
sp_cache.cc parse_file.cc sql_trigger.cc \
event_executor.cc event.cc event_timed.cc \
......@@ -140,6 +140,8 @@ link_sources: mysql_tzinfo_to_sql.cc
@LN_CP_F@ $(top_srcdir)/sql-common/client.c client.c
rm -f my_time.c
@LN_CP_F@ $(top_srcdir)/sql-common/my_time.c my_time.c
rm -f my_user.c
@LN_CP_F@ $(top_srcdir)/sql-common/my_user.c my_user.c
mysql_tzinfo_to_sql.o: $(mysql_tzinfo_to_sql_SOURCES)
$(CXXCOMPILE) -c $(INCLUDES) -DTZINFO2SQL $<
......
......@@ -481,7 +481,7 @@ db_create_routine(THD *thd, int type, sp_head *sp)
{
int ret;
TABLE *table;
char definer[HOSTNAME_LENGTH+USERNAME_LENGTH+2];
char definer[USER_HOST_BUFF_SIZE];
char olddb[128];
bool dbchanged;
DBUG_ENTER("db_create_routine");
......@@ -941,7 +941,7 @@ sp_find_routine(THD *thd, int type, sp_name *name, sp_cache **cp,
ulong level;
sp_head *new_sp;
const char *returns= "";
char definer[HOSTNAME_LENGTH+USERNAME_LENGTH+2];
char definer[USER_HOST_BUFF_SIZE];
String retstr(64);
DBUG_PRINT("info", ("found: 0x%lx", (ulong)sp));
......
......@@ -31,6 +31,8 @@
#define SP_STMT_PRINT_MAXLEN 40
#include <my_user.h>
Item_result
sp_map_result_type(enum enum_field_types type)
{
......@@ -1767,29 +1769,21 @@ sp_head::set_info(longlong created, longlong modified,
void
sp_head::set_definer(const char *definer, uint definerlen)
{
const char *p= strrchr(definer, '@');
uint user_name_len;
char user_name_str[USERNAME_LENGTH + 1];
uint host_name_len;
char host_name_str[HOSTNAME_LENGTH + 1];
if (!p)
{
m_definer_user.str= (char*) "";
m_definer_user.length= 0;
m_definer_host.str= (char*) "";
m_definer_host.length= 0;
}
else
{
const uint user_name_len= p - definer;
const uint host_name_len= definerlen - user_name_len - 1;
parse_user(definer, definerlen, user_name_str, &user_name_len,
host_name_str, &host_name_len);
m_definer_user.str= strmake_root(mem_root, definer, user_name_len);
m_definer_user.length= user_name_len;
m_definer_user.str= strmake_root(mem_root, user_name_str, user_name_len);
m_definer_user.length= user_name_len;
m_definer_host.str= strmake_root(mem_root, p + 1, host_name_len);
m_definer_host.length= host_name_len;
}
m_definer_host.str= strmake_root(mem_root, host_name_str, host_name_len);
m_definer_host.length= host_name_len;
}
......
......@@ -2497,7 +2497,7 @@ static int replace_table_table(THD *thd, GRANT_TABLE *grant_table,
ulong rights, ulong col_rights,
bool revoke_grant)
{
char grantor[HOSTNAME_LENGTH+USERNAME_LENGTH+2];
char grantor[USER_HOST_BUFF_SIZE];
int old_row_exists = 1;
int error=0;
ulong store_table_rights, store_col_rights;
......@@ -2615,7 +2615,7 @@ static int replace_routine_table(THD *thd, GRANT_NAME *grant_name,
const char *db, const char *routine_name,
bool is_proc, ulong rights, bool revoke_grant)
{
char grantor[HOSTNAME_LENGTH+USERNAME_LENGTH+2];
char grantor[USER_HOST_BUFF_SIZE];
int old_row_exists= 1;
int error=0;
ulong store_proc_rights;
......
......@@ -455,7 +455,12 @@ THD::~THD()
/*
Add to one status variable another status variable
Add all status variables to another status variable array
SYNOPSIS
add_to_status()
to_var add to this array
from_var from this array
NOTES
This function assumes that all variables are long/ulong.
......
......@@ -67,7 +67,7 @@ static void decrease_user_connections(USER_CONN *uc);
static bool check_db_used(THD *thd,TABLE_LIST *tables);
static bool check_multi_update_lock(THD *thd);
static void remove_escape(char *name);
static void refresh_status(void);
static void refresh_status(THD *thd);
static bool append_file_to_dir(THD *thd, const char **filename_ptr,
const char *table_name);
......@@ -209,7 +209,7 @@ static int get_or_create_user_conn(THD *thd, const char *user,
{
int return_val= 0;
uint temp_len, user_len;
char temp_user[USERNAME_LENGTH+HOSTNAME_LENGTH+2];
char temp_user[USER_HOST_BUFF_SIZE];
struct user_conn *uc;
DBUG_ASSERT(user != 0);
......@@ -741,7 +741,7 @@ static void reset_mqh(LEX_USER *lu, bool get_them= 0)
{
USER_CONN *uc;
uint temp_len=lu->user.length+lu->host.length+2;
char temp_user[USERNAME_LENGTH+HOSTNAME_LENGTH+2];
char temp_user[USER_HOST_BUFF_SIZE];
memcpy(temp_user,lu->user.str,lu->user.length);
memcpy(temp_user+lu->user.length+1,lu->host.str,lu->host.length);
......@@ -6625,7 +6625,7 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables,
if (options & REFRESH_HOSTS)
hostname_cache_refresh();
if (thd && (options & REFRESH_STATUS))
refresh_status();
refresh_status(thd);
if (options & REFRESH_THREADS)
flush_thread_cache();
#ifdef HAVE_REPLICATION
......@@ -6713,18 +6713,18 @@ void kill_one_thread(THD *thd, ulong id, bool only_kill_query)
/* Clear most status variables */
static void refresh_status(void)
static void refresh_status(THD *thd)
{
pthread_mutex_lock(&LOCK_status);
for (SHOW_VAR *ptr= status_vars; ptr->name; ptr++)
if (ptr->type == SHOW_LONG) // note that SHOW_LONG_NOFLUSH variables are not reset
*(ulong*) ptr->value= 0;
/* We must update the global status before cleaning up the thread */
THD *thd= current_thd;
add_to_status(&global_status_var, &thd->status_var);
bzero((char*) &thd->status_var, sizeof(thd->status_var));
for (SHOW_VAR *ptr= status_vars; ptr->name; ptr++)
if (ptr->type == SHOW_LONG) // note that SHOW_LONG_NOFLUSH variables are not reset
*(ulong*) ptr->value= 0;
/* Reset the counters of all key caches (default and named). */
process_key_caches(reset_key_cache_counters);
pthread_mutex_unlock(&LOCK_status);
......
......@@ -3038,7 +3038,7 @@ int fill_schema_proc(THD *thd, TABLE_LIST *tables, COND *cond)
int res= 0;
TABLE *table= tables->table;
bool full_access;
char definer[HOSTNAME_LENGTH+USERNAME_LENGTH+2];
char definer[USER_HOST_BUFF_SIZE];
Open_tables_state open_tables_state_backup;
DBUG_ENTER("fill_schema_proc");
......@@ -3180,7 +3180,7 @@ static int get_schema_views_record(THD *thd, struct st_table_list *tables,
{
CHARSET_INFO *cs= system_charset_info;
DBUG_ENTER("get_schema_views_record");
char definer[HOSTNAME_LENGTH + USERNAME_LENGTH + 2];
char definer[USER_HOST_BUFF_SIZE];
uint definer_len;
if (tables->view)
......@@ -3364,7 +3364,7 @@ static int get_schema_triggers_record(THD *thd, struct st_table_list *tables,
LEX_STRING trigger_name;
LEX_STRING trigger_stmt;
ulong sql_mode;
char definer_holder[HOSTNAME_LENGTH + USERNAME_LENGTH + 2];
char definer_holder[USER_HOST_BUFF_SIZE];
LEX_STRING definer_buffer;
definer_buffer.str= definer_holder;
if (triggers->get_trigger_info(thd, (enum trg_event_type) event,
......
......@@ -317,7 +317,7 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables,
LEX_STRING file, trigname_file;
LEX_STRING *trg_def, *name;
ulonglong *trg_sql_mode;
char trg_definer_holder[HOSTNAME_LENGTH + USERNAME_LENGTH + 2];
char trg_definer_holder[USER_HOST_BUFF_SIZE];
LEX_STRING *trg_definer;
Item_trigger_field *trg_field;
struct st_trigname trigname;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment