diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:00:34 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:00:34 +0000 |
commit | 3f619478f796eddbba6e39502fe941b285dd97b1 (patch) | |
tree | e2c7b5777f728320e5b5542b6213fd3591ba51e2 /mysql-test/include/empty_string_literal.inc | |
parent | Initial commit. (diff) | |
download | mariadb-3f619478f796eddbba6e39502fe941b285dd97b1.tar.xz mariadb-3f619478f796eddbba6e39502fe941b285dd97b1.zip |
Adding upstream version 1:10.11.6.upstream/1%10.11.6upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'mysql-test/include/empty_string_literal.inc')
-rw-r--r-- | mysql-test/include/empty_string_literal.inc | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/mysql-test/include/empty_string_literal.inc b/mysql-test/include/empty_string_literal.inc new file mode 100644 index 00000000..5857c26d --- /dev/null +++ b/mysql-test/include/empty_string_literal.inc @@ -0,0 +1,135 @@ +SET SESSION character_set_connection=latin2; +SET SESSION character_set_client=cp1250; + +--disable_service_connection + +--echo # +--echo # Test litteral +--echo # + +#enable view protocol after fix MDEV-27871 and +# it is necessary that the view protocol uses the same connection, +# not util connection +--disable_view_protocol + +SET sql_mode=@mode; +select @@sql_mode; +SELECT '',CHARSET(''), null, CHARSET(null), CAST(null as char(10)), CHARSET(CAST(null as char(10))), 'x', CHARSET('x'); +SELECT CHARSET(NULLIF('','')),NULLIF('',''); +SET sql_mode=default; +SELECT '',CHARSET(''), null, CHARSET(null), CAST(null as char(10)), CHARSET(CAST(null as char(10))), 'x', CHARSET('x'); +SELECT CHARSET(NULLIF('','')),NULLIF('',''); + + + +--echo # +--echo # Test NCHAR litteral +--echo # +SET sql_mode=@mode; +SELECT N'',CHARSET(N''), N'x', CHARSET(N'x'); +SELECT CHARSET(NULLIF(N'',N'')),NULLIF(N'',N''); +SET sql_mode=default; +SELECT N'',CHARSET(N''), N'x', CHARSET(N'x'); +SELECT CHARSET(NULLIF(N'',N'')),NULLIF(N'',N''); + + + +--echo # +--echo # Test CHARSET prefix litteral +--echo # +SET sql_mode=@mode; +SELECT _cp1250 '',CHARSET(_cp1250 ''), _cp1250 'x', CHARSET(_cp1250 'x'); +SELECT CHARSET(NULLIF(_cp1250 '',_cp1250 '')),NULLIF(_cp1250 '',_cp1250 ''); +SET sql_mode=default; +SELECT _cp1250 '',CHARSET(_cp1250 ''), _cp1250 'x', CHARSET(_cp1250 'x'); +SELECT CHARSET(NULLIF(_cp1250 '',_cp1250 '')),NULLIF(_cp1250 '',_cp1250 ''); + + +SET sql_mode=@mode; + +--echo # +--echo # Test litteral concat +--echo # +SELECT 'a' 'b'; +SELECT 'a' ''; +SELECT '' 'b'; +SELECT '' ''; +SELECT '' 'b' 'c'; +SELECT '' '' 'c'; +SELECT 'a' '' 'c'; +SELECT 'a' '' ''; +SELECT '' '' ''; + +SELECT '' '' '',CHARSET('' '' ''); +SELECT _latin1'' '' '',CHARSET(_latin1'' '' ''); +SELECT N'' '' '',CHARSET(N'' '' ''); + +--enable_view_protocol + +--echo # +--echo # UNION - implicit group by +--echo # +SELECT 1, null +UNION +SELECT 1 , '' +ORDER BY 1; + +SELECT 1, null +UNION +SELECT 1 , N'' +ORDER BY 1; + +SELECT 1, null +UNION +SELECT 1 , _cp1250 '' +ORDER BY 1; + +# it is necessary that the view protocol uses the same connection, +# not util connection +--disable_view_protocol + +SELECT NULLIF(_cp1250 '',_cp1250 '') +UNION +SELECT NULLIF(N'',N''); + +--enable_view_protocol + +--error ER_CANT_AGGREGATE_2COLLATIONS +SELECT 1 , _latin2 '' +UNION +SELECT 1 , _cp1250 ''; + +SELECT 1, null +UNION +SELECT 1 , '' +UNION +SELECT 1 , N''; + +CREATE TABLE t1 (c1 INT,c2 VARCHAR(10)); +INSERT INTO t1 VALUES (1,'one'); +INSERT INTO t1 VALUES (1,''); +INSERT INTO t1 VALUES (1,null); + +--echo # +--echo # Test in a view +--echo # +CREATE VIEW v1 + AS SELECT c1, c2 + FROM t1 + UNION + SELECT c1 , '' + FROM t1 + ORDER BY 1,2; +SELECT * FROM v1; + +SHOW CREATE VIEW v1; + +DROP VIEW v1; +DROP TABLE t1; + +EXPLAIN EXTENDED SELECT ''; +EXPLAIN EXTENDED SELECT _latin1''; +EXPLAIN EXTENDED SELECT N''; +EXPLAIN EXTENDED SELECT '' ''; + +--enable_service_connection |