2007-12-04 23:23:42 +02:00
|
|
|
#
|
|
|
|
# Test 'old' mode
|
|
|
|
#
|
|
|
|
|
|
|
|
create table t1 (a int, b varchar(200), c text not null) checksum=1;
|
|
|
|
create table t2 (a int, b varchar(200), c text not null) checksum=0;
|
|
|
|
insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
|
|
|
|
insert t2 select * from t1;
|
|
|
|
checksum table t1, t2;
|
2008-06-28 15:45:15 +03:00
|
|
|
checksum table t1, t2 quick;
|
2007-12-04 23:23:42 +02:00
|
|
|
checksum table t1, t2 extended;
|
|
|
|
drop table t1,t2;
|
2011-07-01 15:08:30 +03:00
|
|
|
|
|
|
|
#
|
|
|
|
# Test that SHOW PROCESSLIST doesn't have the Progress column
|
|
|
|
#
|
|
|
|
|
2012-10-07 22:12:39 +02:00
|
|
|
--replace_column 1 <Id> 3 <Host> 6 <Time> 7 <State>
|
2011-07-01 15:08:30 +03:00
|
|
|
# Embedded server is hardcoded to show "Writing to net" as STATE.
|
MDEV-15945 --ps-protocol does not test some queries
Make mysqltest to use --ps-protocol more
use prepared statements for everything that server supports
with the exception of CALL (for now).
Fix discovered test failures and bugs.
tests:
* PROCESSLIST shows Execute state, not Query
* SHOW STATUS increments status variables more than in text protocol
* multi-statements should be avoided (see tests with a wrong delimiter)
* performance_schema events have different names in --ps-protocol
* --enable_prepare_warnings
mysqltest.cc:
* make sure run_query_stmt() doesn't crash if there's
no active connection (in wait_until_connected_again.inc)
* prepare all statements that server supports
protocol.h
* Protocol_discard::send_result_set_metadata() should not send
anything to the client.
sql_acl.cc:
* extract the functionality of getting the user for SHOW GRANTS
from check_show_access(), so that mysql_test_show_grants() could
generate the correct column names in the prepare step
sql_class.cc:
* result->prepare() can fail, don't ignore its return value
* use correct number of decimals for EXPLAIN columns
sql_parse.cc:
* discard profiling for SHOW PROFILE. In text protocol it's done in
prepare_schema_table(), but in --ps it is called on prepare only,
so nothing was discarding profiling during execute.
* move the permission checking code for SHOW CREATE VIEW to
mysqld_show_create_get_fields(), so that it would be called during
prepare step too.
* only set sel_result when it was created here and needs to be
destroyed in the same block. Avoid destroying lex->result.
* use the correct number of tables in check_show_access(). Saying
"as many as possible" doesn't work when first_not_own_table isn't
set yet.
sql_prepare.cc:
* use correct user name for SHOW GRANTS columns
* don't ignore verbose flag for SHOW SLAVE STATUS
* support preparing REVOKE ALL and ROLLBACK TO SAVEPOINT
* don't ignore errors from thd->prepare_explain_fields()
* use select_send result for sending ANALYZE and EXPLAIN, but don't
overwrite lex->result, because it might be needed to issue execute-time
errors (select_dumpvar - too many rows)
sql_show.cc:
* check grants for SHOW CREATE VIEW here, not in mysql_execute_command
sql_view.cc:
* use the correct function to check privileges. Old code was doing
check_access() for thd->security_ctx, which is invoker's sctx,
not definer's sctx. Hide various view related errors from the invoker.
sql_yacc.yy:
* initialize lex->select_lex for LOAD, otherwise it'll contain garbage
data that happen to fail tests with views in --ps (but not otherwise).
2019-03-10 23:59:50 +01:00
|
|
|
# ps-protocol will have Execute not Query
|
|
|
|
--replace_result "Writing to net" "NULL" "Execute" "Query"
|
2011-07-01 15:08:30 +03:00
|
|
|
--replace_regex /localhost[:0-9]*/localhost/
|
|
|
|
SHOW PROCESSLIST;
|
2014-03-07 00:21:25 +04:00
|
|
|
|
|
|
|
--echo #
|
|
|
|
--echo # MDEV-5372 Make "CAST(time_expr AS DATETIME)" compatible with the SQL Standard)
|
|
|
|
--echo #
|
2014-03-07 21:05:28 +01:00
|
|
|
set @@old_mode=zero_date_time_cast;
|
2014-03-07 00:21:25 +04:00
|
|
|
SELECT CAST(TIME'-10:30:30' AS DATETIME);
|
|
|
|
SELECT CAST(TIME'10:20:30' AS DATETIME);
|
|
|
|
SELECT CAST(TIME'830:20:30' AS DATETIME);
|
|
|
|
CREATE TABLE t1 (a DATETIME);
|
2017-02-08 15:28:00 -05:00
|
|
|
INSERT IGNORE INTO t1 VALUES (TIME'-10:20:30');
|
2014-03-07 00:21:25 +04:00
|
|
|
INSERT INTO t1 VALUES (TIME'10:20:30');
|
|
|
|
INSERT INTO t1 VALUES (TIME'830:20:30');
|
|
|
|
SELECT * FROM t1;
|
|
|
|
DROP TABLE t1;
|
|
|
|
CREATE TABLE t1 (a TIMESTAMP);
|
2017-02-08 15:28:00 -05:00
|
|
|
INSERT IGNORE INTO t1 VALUES (TIME'-10:20:30');
|
|
|
|
INSERT IGNORE INTO t1 VALUES (TIME'10:20:30');
|
|
|
|
INSERT IGNORE INTO t1 VALUES (TIME'830:20:30');
|
2014-03-07 00:21:25 +04:00
|
|
|
SELECT * FROM t1;
|
|
|
|
DROP TABLE t1;
|
|
|
|
CREATE TABLE t1 (a TIME);
|
|
|
|
INSERT INTO t1 VALUES (TIME'-10:20:30');
|
|
|
|
INSERT INTO t1 VALUES (TIME'10:20:30');
|
|
|
|
INSERT INTO t1 VALUES (TIME'830:20:30');
|
|
|
|
SELECT a, CAST(a AS DATETIME), TO_DAYS(a) FROM t1;
|
|
|
|
DROP TABLE t1;
|
|
|
|
# Note, it was actually a bug that TO_DAYS('830:20:30') returned NULL
|
|
|
|
# for a column, while 3 for an expression. We won't fix this,
|
2014-03-07 21:05:28 +01:00
|
|
|
# it's "old_mode" anyway.
|
2014-03-07 00:21:25 +04:00
|
|
|
SELECT TO_DAYS(TIME'-10:20:30');
|
|
|
|
SELECT TO_DAYS(TIME'10:20:30');
|
|
|
|
SELECT TO_DAYS(TIME'830:20:30');
|
|
|
|
|
2014-03-07 21:05:28 +01:00
|
|
|
# This is to cover Item_temporal_hybrid_func::fix_temporal_type in old_mode:
|
2014-03-07 00:21:25 +04:00
|
|
|
CREATE TABLE t1 (a DATETIME, b TIME);
|
|
|
|
INSERT INTO t1 VALUES (NULL, '00:20:12');
|
|
|
|
INSERT INTO t1 VALUES (NULL, '-00:20:12');
|
|
|
|
SELECT IF(1,ADDDATE(IFNULL(a,b),0),1) FROM t1;
|
|
|
|
DROP TABLE t1;
|
2014-11-03 19:05:16 +04:00
|
|
|
|
|
|
|
--echo #
|
|
|
|
--echo # MDEV-6649 Different warnings for TIME and TIME(N) when @@old_mode=zero_date_time_cast
|
|
|
|
--echo #
|
2014-11-03 21:45:06 +04:00
|
|
|
SET @@global.mysql56_temporal_format=true;
|
2014-11-03 19:05:16 +04:00
|
|
|
SET @@old_mode=zero_date_time_cast;
|
|
|
|
CREATE TABLE t1 (a TIME,b TIME(1));
|
|
|
|
INSERT INTO t1 VALUES (TIME'830:20:30',TIME'830:20:30');
|
|
|
|
SELECT TO_DAYS(a), TO_DAYS(b) FROM t1;
|
|
|
|
DROP TABLE t1;
|
2014-12-02 22:25:16 +01:00
|
|
|
|
2014-11-03 21:45:06 +04:00
|
|
|
SET @@global.mysql56_temporal_format=false;
|
|
|
|
SET @@old_mode=zero_date_time_cast;
|
|
|
|
CREATE TABLE t1 (a TIME,b TIME(1));
|
|
|
|
INSERT INTO t1 VALUES (TIME'830:20:30',TIME'830:20:30');
|
|
|
|
SELECT TO_DAYS(a), TO_DAYS(b) FROM t1;
|
|
|
|
DROP TABLE t1;
|
|
|
|
SET @@global.mysql56_temporal_format=DEFAULT;
|
|
|
|
|
2017-09-19 11:18:45 +02:00
|
|
|
#
|
|
|
|
# MDEV-12672 Replicated TIMESTAMP fields given wrong value near DST change
|
|
|
|
#
|
2017-09-19 23:50:32 +02:00
|
|
|
|
|
|
|
# Copy_field
|
2017-09-19 11:18:45 +02:00
|
|
|
set time_zone='Europe/Moscow';
|
|
|
|
set global mysql56_temporal_format=false;
|
2022-06-12 22:01:56 +02:00
|
|
|
create table t1 (a timestamp not null default now());
|
2017-09-19 11:18:45 +02:00
|
|
|
set timestamp=1288477526;
|
|
|
|
insert t1 values (null);
|
2017-09-22 01:12:00 +02:00
|
|
|
insert t1 values ();
|
2017-09-19 11:18:45 +02:00
|
|
|
set timestamp=1288481126;
|
|
|
|
insert t1 values (null);
|
2017-09-22 01:12:00 +02:00
|
|
|
insert t1 values ();
|
2017-09-19 11:18:45 +02:00
|
|
|
select a, unix_timestamp(a) from t1;
|
|
|
|
set global mysql56_temporal_format=true;
|
|
|
|
select a, unix_timestamp(a) from t1;
|
|
|
|
alter table t1 modify a timestamp;
|
|
|
|
select a, unix_timestamp(a) from t1;
|
|
|
|
drop table t1;
|
2017-09-19 23:50:32 +02:00
|
|
|
|
|
|
|
# field_conv_incompatible()
|
|
|
|
set global mysql56_temporal_format=false;
|
2022-06-12 22:01:56 +02:00
|
|
|
create table t1 (a timestamp not null default now());
|
2017-09-19 23:50:32 +02:00
|
|
|
set timestamp=1288477526;
|
|
|
|
insert t1 values (null);
|
|
|
|
set timestamp=1288481126;
|
|
|
|
insert t1 values (null);
|
|
|
|
select a, unix_timestamp(a) from t1;
|
|
|
|
set global mysql56_temporal_format=true;
|
|
|
|
select a, unix_timestamp(a) from t1;
|
|
|
|
create table t2 (a timestamp);
|
|
|
|
insert t2 select a from t1;
|
|
|
|
select a, unix_timestamp(a) from t2;
|
|
|
|
drop table t1, t2;
|
2017-09-19 11:18:45 +02:00
|
|
|
set time_zone=DEFAULT;
|
2018-12-08 19:39:23 +04:00
|
|
|
|
|
|
|
|
|
|
|
--echo #
|
|
|
|
--echo # MDEV-13995 MAX(timestamp) returns a wrong result near DST change
|
|
|
|
--echo #
|
|
|
|
|
|
|
|
# This tests:
|
|
|
|
# Field_timestamp::val_native()
|
|
|
|
# Field_timestamp_hires::val_native()
|
|
|
|
# Type_handler_timestamp_common::type_handler_for_native_format()
|
|
|
|
|
|
|
|
SET global mysql56_temporal_format=false;
|
|
|
|
SET time_zone='+00:00';
|
|
|
|
CREATE TABLE t1 (a TIMESTAMP(0));
|
|
|
|
INSERT INTO t1 VALUES (FROM_UNIXTIME(1288477526) /*summer time in Moscow*/);
|
|
|
|
INSERT INTO t1 VALUES (FROM_UNIXTIME(1288477526+3599) /*winter time in Moscow*/);
|
|
|
|
SET time_zone='Europe/Moscow';
|
|
|
|
SELECT a, COALESCE(a), UNIX_TIMESTAMP(a) FROM t1;
|
|
|
|
SELECT MIN(a), UNIX_TIMESTAMP(MIN(a)) AS a FROM t1;
|
|
|
|
SELECT MAX(a), UNIX_TIMESTAMP(MAX(a)) AS a FROM t1;
|
|
|
|
SELECT t1.a, UNIX_TIMESTAMP(t1.a), t2.a, UNIX_TIMESTAMP(t2.a) FROM t1 t1, t1 t2 WHERE t1.a=t2.a;
|
|
|
|
ALTER TABLE t1 MODIFY a TIMESTAMP(1);
|
|
|
|
SELECT a, COALESCE(a), UNIX_TIMESTAMP(a) FROM t1;
|
|
|
|
SELECT MIN(a), UNIX_TIMESTAMP(MIN(a)) AS a FROM t1;
|
|
|
|
SELECT MAX(a), UNIX_TIMESTAMP(MAX(a)) AS a FROM t1;
|
|
|
|
SELECT t1.a, UNIX_TIMESTAMP(t1.a), t2.a, UNIX_TIMESTAMP(t2.a) FROM t1 t1, t1 t2 WHERE t1.a=t2.a;
|
|
|
|
DROP TABLE t1;
|
|
|
|
SET time_zone=DEFAULT;
|
|
|
|
SET global mysql56_temporal_format=true;
|
2023-03-29 11:56:44 +04:00
|
|
|
|
|
|
|
|
|
|
|
--echo #
|
|
|
|
--echo # MDEV-26765 UNIX_TIMESTAMP(CURRENT_TIME()) return null ?!?
|
|
|
|
--echo #
|
|
|
|
|
|
|
|
SET old_mode=zero_date_time_cast;
|
|
|
|
SET @@time_zone='+00:00';
|
|
|
|
SET timestamp=1234567;
|
|
|
|
SELECT CURRENT_TIMESTAMP;
|
|
|
|
SELECT UNIX_TIMESTAMP(CURRENT_TIME());
|
|
|
|
SELECT UNIX_TIMESTAMP(TIME'06:56:07');
|
|
|
|
SELECT UNIX_TIMESTAMP(TIME'10:20:30');
|
|
|
|
CREATE OR REPLACE TABLE t1 (a TIME);
|
|
|
|
INSERT INTO t1 VALUES (TIME'06:56:07'),('10:20:30');
|
|
|
|
SELECT UNIX_TIMESTAMP(a) FROM t1 ORDER BY a;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
SET @@time_zone=DEFAULT;
|
|
|
|
SET TIMESTAMP=DEFAULT;
|
2023-10-06 22:36:32 +02:00
|
|
|
|
|
|
|
--echo #
|
|
|
|
--echo # MDEV-31608 - Connector/NET fails to connect since 10.10
|
|
|
|
--echo #
|
|
|
|
select count(*) > 0 from information_schema.collations where id IS NULL;
|
|
|
|
SET old_mode=no_null_collation_ids;
|
|
|
|
select count(*) > 0 from information_schema.collations where id IS NULL;
|
|
|
|
|