Commit 66eca1c2 authored by Joerg Bruehe's avatar Joerg Bruehe

Merge main 5.0 into 5.0-build

parents 014f112a f1761fba
--require r/have_archive.require --require r/have_archive.require
--disable_query_log --disable_query_log
show variables like "have_archive"; show variables like 'have_archive';
--enable_query_log --enable_query_log
-- require r/have_bdb.require -- require r/have_bdb.require
disable_query_log; disable_query_log;
show variables like "have_bdb"; show variables like 'have_bdb';
enable_query_log; enable_query_log;
-- require r/have_big5.require -- require r/have_big5.require
disable_query_log; disable_query_log;
show collation like "big5_chinese_ci"; show collation like 'big5_chinese_ci';
enable_query_log; enable_query_log;
-- require r/have_blackhole.require -- require r/have_blackhole.require
disable_query_log; disable_query_log;
show variables like "have_blackhole_engine"; show variables like 'have_blackhole_engine';
enable_query_log; enable_query_log;
--require r/case_sensitive_file_system.require --require r/case_sensitive_file_system.require
--disable_query_log --disable_query_log
show variables like "lower_case_file_system"; show variables like 'lower_case_file_system';
--enable_query_log --enable_query_log
-- require r/have_compress.require -- require r/have_compress.require
disable_query_log; disable_query_log;
show variables like "have_compress"; show variables like 'have_compress';
enable_query_log; enable_query_log;
-- require r/have_cp1250_ch.require -- require r/have_cp1250_ch.require
disable_query_log; disable_query_log;
show collation like "cp1250_czech_cs"; show collation like 'cp1250_czech_cs';
enable_query_log; enable_query_log;
-- require r/have_cp932.require -- require r/have_cp932.require
disable_query_log; disable_query_log;
show collation like "cp932_japanese_ci"; show collation like 'cp932_japanese_ci';
enable_query_log; enable_query_log;
-- require r/have_crypt.require -- require r/have_crypt.require
disable_query_log; disable_query_log;
show variables like "have_crypt"; show variables like 'have_crypt';
enable_query_log; enable_query_log;
-- require r/have_csv.require -- require r/have_csv.require
disable_query_log; disable_query_log;
show variables like "have_csv"; show variables like 'have_csv';
enable_query_log; enable_query_log;
-- require r/have_eucjpms.require -- require r/have_eucjpms.require
disable_query_log; disable_query_log;
show collation like "eucjpms_japanese_ci"; show collation like 'eucjpms_japanese_ci';
enable_query_log; enable_query_log;
-- require r/have_euckr.require -- require r/have_euckr.require
disable_query_log; disable_query_log;
show collation like "euckr_korean_ci"; show collation like 'euckr_korean_ci';
enable_query_log; enable_query_log;
-- require r/have_exampledb.require -- require r/have_exampledb.require
disable_query_log; disable_query_log;
show variables like "have_example_engine"; show variables like 'have_example_engine';
enable_query_log; enable_query_log;
-- require r/have_federated_db.require -- require r/have_federated_db.require
disable_query_log; disable_query_log;
show variables like "have_federated_engine"; show variables like 'have_federated_engine';
enable_query_log; enable_query_log;
-- require r/have_gb2312.require -- require r/have_gb2312.require
disable_query_log; disable_query_log;
show collation like "gb2312_chinese_ci"; show collation like 'gb2312_chinese_ci';
enable_query_log; enable_query_log;
-- require r/have_gbk.require -- require r/have_gbk.require
disable_query_log; disable_query_log;
show collation like "gbk_chinese_ci"; show collation like 'gbk_chinese_ci';
enable_query_log; enable_query_log;
--require r/have_geometry.require --require r/have_geometry.require
--disable_query_log --disable_query_log
show variables like "have_geometry"; show variables like 'have_geometry';
--enable_query_log --enable_query_log
-- require r/have_innodb.require -- require r/have_innodb.require
disable_query_log; disable_query_log;
show variables like "have_innodb"; show variables like 'have_innodb';
enable_query_log; enable_query_log;
-- require r/have_latin2_ch.require -- require r/have_latin2_ch.require
disable_query_log; disable_query_log;
show collation like "latin2_czech_cs"; show collation like 'latin2_czech_cs';
enable_query_log; enable_query_log;
-- require r/have_log_bin.require -- require r/have_log_bin.require
disable_query_log; disable_query_log;
show variables like "log_bin"; show variables like 'log_bin';
enable_query_log; enable_query_log;
--require r/lowercase0.require --require r/lowercase0.require
--disable_query_log --disable_query_log
show variables like "lower_case_%"; show variables like 'lower_case_%';
--enable_query_log --enable_query_log
...@@ -10,7 +10,7 @@ drop table if exists t1, t2; ...@@ -10,7 +10,7 @@ drop table if exists t1, t2;
--enable_warnings --enable_warnings
flush tables; flush tables;
--require r/have_ndb.require --require r/have_ndb.require
show variables like "have_ndbcluster"; show variables like 'have_ndbcluster';
enable_query_log; enable_query_log;
# Check that server2 has NDB support # Check that server2 has NDB support
...@@ -21,7 +21,7 @@ drop table if exists t1, t2; ...@@ -21,7 +21,7 @@ drop table if exists t1, t2;
--enable_warnings --enable_warnings
flush tables; flush tables;
--require r/have_ndb.require --require r/have_ndb.require
show variables like "have_ndbcluster"; show variables like 'have_ndbcluster';
enable_query_log; enable_query_log;
# Set the default connection to 'server1' # Set the default connection to 'server1'
......
# Check that server is compiled and started with support for NDB # Check that server is compiled and started with support for NDB
-- require r/have_ndb.require -- require r/have_ndb.require
disable_query_log; disable_query_log;
show variables like "have_ndbcluster"; show variables like 'have_ndbcluster';
enable_query_log; enable_query_log;
# Check that NDB is installed and known to be working # Check that NDB is installed and known to be working
......
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
# of query cache hits # of query cache hits
-- disable_ps_protocol -- disable_ps_protocol
disable_query_log; disable_query_log;
show variables like "have_query_cache"; show variables like 'have_query_cache';
enable_query_log; enable_query_log;
-- require r/have_sjis.require -- require r/have_sjis.require
disable_query_log; disable_query_log;
show collation like "sjis_japanese_ci"; show collation like 'sjis_japanese_ci';
enable_query_log; enable_query_log;
-- require r/have_ssl.require -- require r/have_ssl.require
disable_query_log; disable_query_log;
show variables like "have_ssl"; show variables like 'have_ssl';
enable_query_log; enable_query_log;
-- require r/have_tis620.require -- require r/have_tis620.require
disable_query_log; disable_query_log;
show collation like "tis620_thai_ci"; show collation like 'tis620_thai_ci';
enable_query_log; enable_query_log;
-- require r/have_ucs2.require -- require r/have_ucs2.require
disable_query_log; disable_query_log;
show collation like "ucs2_general_ci"; show collation like 'ucs2_general_ci';
enable_query_log; enable_query_log;
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# #
--require r/have_udf.require --require r/have_udf.require
disable_query_log; disable_query_log;
show variables like "have_dynamic_loading"; show variables like 'have_dynamic_loading';
enable_query_log; enable_query_log;
# #
......
-- require r/have_ujis.require -- require r/have_ujis.require
disable_query_log; disable_query_log;
show collation like "ujis_japanese_ci"; show collation like 'ujis_japanese_ci';
enable_query_log; enable_query_log;
...@@ -35,7 +35,7 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp ...@@ -35,7 +35,7 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
prepare bar from "DELETE FROM table_28779 WHERE a = 7 OR 1=1/*! AND 2=2;"; prepare bar from "DELETE FROM table_28779 WHERE a = 7 OR 1=1/*! AND 2=2;";
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 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
prepare bar from "DELETE FROM table_28779 WHERE a = 7 OR 1=1/*! AND 2=2;*"; prepare bar from "DELETE FROM table_28779 WHERE a = 7 OR 1=1/*! AND 2=2;*";
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 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
prepare bar from "DELETE FROM table_28779 WHERE a = 7 OR 1=1/*!98765' AND b = 'bar';"; prepare bar from "DELETE FROM table_28779 WHERE a = 7 OR 1=1/*!98765' AND b = 'bar';";
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 '/*!98765' AND b = 'bar'' at line 1 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 '/*!98765' AND b = 'bar'' at line 1
prepare bar from "DELETE FROM table_28779 WHERE a = 7 OR 1=1/*!98765' AND b = 'bar';*"; prepare bar from "DELETE FROM table_28779 WHERE a = 7 OR 1=1/*!98765' AND b = 'bar';*";
......
...@@ -305,4 +305,18 @@ drop table t1; ...@@ -305,4 +305,18 @@ drop table t1;
SELECT NAME_CONST('var', 'value') COLLATE latin1_general_cs; SELECT NAME_CONST('var', 'value') COLLATE latin1_general_cs;
NAME_CONST('var', 'value') COLLATE latin1_general_cs NAME_CONST('var', 'value') COLLATE latin1_general_cs
value value
select @@session.time_zone into @save_tz;
set @@session.time_zone='UTC';
select uuid() into @my_uuid;
select mid(@my_uuid,15,1);
mid(@my_uuid,15,1)
1
select 24 * 60 * 60 * 1000 * 1000 * 10 into @my_uuid_one_day;
select concat('0',mid(@my_uuid,16,3),mid(@my_uuid,10,4),left(@my_uuid,8)) into @my_uuidate;
select floor(conv(@my_uuidate,16,10)/@my_uuid_one_day) into @my_uuid_date;
select 141427 + datediff(curdate(),'1970-01-01') into @my_uuid_synthetic;
select @my_uuid_date - @my_uuid_synthetic;
@my_uuid_date - @my_uuid_synthetic
0
set @@session.time_zone=@save_tz;
End of 5.0 tests End of 5.0 tests
DROP PROCEDURE IF EXISTS p26030;
select "non terminated"$$
non terminated
non terminated
select "terminated";$$
terminated
terminated
select "non terminated, space" $$
non terminated, space
non terminated, space
select "terminated, space"; $$
terminated, space
terminated, space
select "non terminated, comment" /* comment */$$
non terminated, comment
non terminated, comment
select "terminated, comment"; /* comment */$$
terminated, comment
terminated, comment
select "stmt 1";select "stmt 2 non terminated"$$
stmt 1
stmt 1
stmt 2 non terminated
stmt 2 non terminated
select "stmt 1";select "stmt 2 terminated";$$
stmt 1
stmt 1
stmt 2 terminated
stmt 2 terminated
select "stmt 1";select "stmt 2 non terminated, space" $$
stmt 1
stmt 1
stmt 2 non terminated, space
stmt 2 non terminated, space
select "stmt 1";select "stmt 2 terminated, space"; $$
stmt 1
stmt 1
stmt 2 terminated, space
stmt 2 terminated, space
select "stmt 1";select "stmt 2 non terminated, comment" /* comment */$$
stmt 1
stmt 1
stmt 2 non terminated, comment
stmt 2 non terminated, comment
select "stmt 1";select "stmt 2 terminated, comment"; /* comment */$$
stmt 1
stmt 1
stmt 2 terminated, comment
stmt 2 terminated, comment
select "stmt 1"; select "space, stmt 2"$$
stmt 1
stmt 1
space, stmt 2
space, stmt 2
select "stmt 1";/* comment */select "comment, stmt 2"$$
stmt 1
stmt 1
comment, stmt 2
comment, stmt 2
DROP PROCEDURE IF EXISTS p26030; CREATE PROCEDURE p26030() BEGIN SELECT 1; END; CALL p26030()
$$
1
1
DROP PROCEDURE IF EXISTS p26030; CREATE PROCEDURE p26030() SELECT 1; CALL p26030()
$$
1
1
DROP PROCEDURE p26030;
...@@ -85,9 +85,9 @@ NULL ...@@ -85,9 +85,9 @@ NULL
NULL NULL
NULL NULL
prepare stmt6 from 'select 1; select2'; prepare stmt6 from 'select 1; select2';
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 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
prepare stmt6 from 'insert into t1 values (5,"five"); select2'; prepare stmt6 from 'insert into t1 values (5,"five"); select2';
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 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
explain prepare stmt6 from 'insert into t1 values (5,"five"); select2'; explain prepare stmt6 from 'insert into t1 values (5,"five"); select2';
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 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
create table t2 create table t2
......
...@@ -78,3 +78,34 @@ alter table t1 modify a varchar(255); ...@@ -78,3 +78,34 @@ alter table t1 modify a varchar(255);
select length(a) from t1; select length(a) from t1;
length(a) length(a)
6 6
select 0b01000001;
0b01000001
A
select 0x41;
0x41
A
select b'01000001';
b'01000001'
A
select x'41', 0+x'41';
x'41' 0+x'41'
A 65
select N'abc', length(N'abc');
abc length(N'abc')
abc 3
select N'', length(N'');
length(N'')
0
select '', length('');
length('')
0
select b'', 0+b'';
b'' 0+b''
0
select x'', 0+x'';
x'' 0+x''
0
select 0x;
ERROR 42S22: Unknown column '0x' in 'field list'
select 0b;
ERROR 42S22: Unknown column '0b' in 'field list'
...@@ -10,11 +10,6 @@ ...@@ -10,11 +10,6 @@
# 2008-06-06 mleich Create this this variant for the embedded server. # 2008-06-06 mleich Create this this variant for the embedded server.
# #
let $value= query_get_value(SHOW VARIABLES LIKE 'version_compile_os',Value,1);
if (`SELECT '$value' LIKE 'apple-darwin%'`)
{
skip Bug#37380 Test funcs_1.is_columns_myisam_embedded fails on OS X;
}
if (`SELECT VERSION() NOT LIKE '%embedded%'`) if (`SELECT VERSION() NOT LIKE '%embedded%'`)
{ {
--skip Test requires: embedded server --skip Test requires: embedded server
......
################################################################################# #################################################################################
# Author: Serge Kozlov # # Author: Serge Kozlov #
# Date: 09/21/2005 # # Date: 2005-09-21 #
# Purpose: used by ../t/*_charset.test # # Purpose: used by ../t/*_charset.test #
# Require: set $engine_type= [NDB,MyISAM,InnoDB,etc] before calling # # Require: set $engine_type= [NDB,MyISAM,InnoDB,etc] before calling #
# #
# Last modification: Matthias Leich #
# Date: 2008-07-02 #
# Purpose: Fix Bug#37160 funcs_2: The tests do not check if optional character #
# sets exist. #
# Add checking of prerequisites + minor cleanup #
################################################################################# #################################################################################
# #
# #
# #
# Check that all character sets needed are available
# Note(mleich):
# It is intentional that the common solution with
# "--source include/have_<character set>.inc"
# is not applied.
# - We currently do not have such a prerequisite test for every character set
# /collation needed.
# - There is also no real value in mentioning the first missing character set
# /collation within the "skip message" because it is most probably only
# one of many.
#
# Hint: 5 character_set_names per source line if possible
if (`SELECT COUNT(*) <> 36 FROM information_schema.character_sets
WHERE CHARACTER_SET_NAME IN (
'armscii8', 'ascii' , 'big5' , 'binary' , 'cp1250',
'cp1251' , 'cp1256' , 'cp1257' , 'cp850' , 'cp852' ,
'cp866' , 'cp932' , 'dec8' , 'eucjpms', 'euckr' ,
'gb2312' , 'gbk' , 'geostd8', 'greek' , 'hebrew',
'hp8' , 'keybcs2', 'koi8r' , 'koi8u' , 'latin1',
'latin2' , 'latin5' , 'latin7' , 'macce' , 'macroman',
'sjis' , 'swe7' , 'tis620' , 'ucs2' , 'ujis',
'utf8'
)`)
{
--skip Not all character sets required for this test are present
}
# Check that all collations needed are available
# Hint: 4 collation_names per source line if possible
if (`SELECT COUNT(*) <> 123 FROM information_schema.collations
WHERE collation_name IN (
'armscii8_bin', 'armscii8_general_ci', 'ascii_bin', 'ascii_general_ci',
'big5_bin', 'big5_chinese_ci', 'cp1250_bin', 'cp1250_croatian_ci',
'cp1250_czech_cs', 'cp1250_general_ci', 'cp1251_bin', 'cp1251_bulgarian_ci',
'cp1251_general_ci', 'cp1251_general_cs', 'cp1251_ukrainian_ci', 'cp1256_bin',
'cp1256_general_ci', 'cp1257_bin', 'cp1257_general_ci', 'cp1257_lithuanian_ci',
'cp850_bin', 'cp850_general_ci', 'cp852_bin', 'cp852_general_ci',
'cp866_bin', 'cp866_general_ci', 'cp932_bin', 'cp932_japanese_ci',
'dec8_bin', 'dec8_swedish_ci', 'eucjpms_bin', 'eucjpms_japanese_ci',
'euckr_bin', 'euckr_korean_ci', 'gb2312_bin', 'gb2312_chinese_ci',
'gbk_bin', 'gbk_chinese_ci', 'geostd8_bin', 'geostd8_general_ci',
'greek_bin', 'greek_general_ci', 'hebrew_bin', 'hebrew_general_ci',
'hp8_bin', 'hp8_english_ci', 'keybcs2_bin', 'keybcs2_general_ci',
'koi8r_bin', 'koi8r_general_ci', 'koi8u_bin', 'koi8u_general_ci',
'latin1_bin', 'latin1_danish_ci', 'latin1_general_ci', 'latin1_general_cs',
'latin1_german1_ci', 'latin1_german2_ci', 'latin1_spanish_ci', 'latin1_swedish_ci',
'latin2_bin', 'latin2_croatian_ci', 'latin2_czech_cs', 'latin2_general_ci',
'latin2_hungarian_ci', 'latin5_bin', 'latin5_turkish_ci', 'latin7_bin',
'latin7_estonian_cs', 'latin7_general_ci', 'latin7_general_cs', 'macce_bin',
'macce_general_ci', 'macroman_bin', 'macroman_general_ci', 'sjis_bin',
'sjis_japanese_ci', 'swe7_bin', 'swe7_swedish_ci', 'tis620_bin',
'tis620_thai_ci', 'ucs2_bin', 'ucs2_czech_ci', 'ucs2_danish_ci',
'ucs2_estonian_ci', 'ucs2_general_ci', 'ucs2_hungarian_ci', 'ucs2_icelandic_ci',
'ucs2_latvian_ci', 'ucs2_lithuanian_ci', 'ucs2_persian_ci', 'ucs2_polish_ci',
'ucs2_roman_ci', 'ucs2_romanian_ci', 'ucs2_slovak_ci', 'ucs2_slovenian_ci',
'ucs2_spanish2_ci', 'ucs2_spanish_ci', 'ucs2_swedish_ci', 'ucs2_turkish_ci',
'ucs2_unicode_ci', 'ujis_bin', 'ujis_japanese_ci', 'utf8_bin',
'utf8_czech_ci', 'utf8_danish_ci', 'utf8_estonian_ci', 'utf8_general_ci',
'utf8_hungarian_ci', 'utf8_icelandic_ci', 'utf8_latvian_ci', 'utf8_lithuanian_ci',
'utf8_persian_ci', 'utf8_polish_ci', 'utf8_roman_ci', 'utf8_romanian_ci',
'utf8_slovak_ci', 'utf8_slovenian_ci', 'utf8_spanish2_ci', 'utf8_spanish_ci',
'utf8_swedish_ci', 'utf8_turkish_ci', 'utf8_unicode_ci'
)`)
{
--skip Not all collations required for this test are present
}
################################
let $check_std_csets= 1;
let $check_ucs2_csets= 1;
let $check_utf8_csets= 1;
#
# Check all charsets/collation combinations
#
################################
let $check_std_csets= 1; let $check_std_csets= 1;
let $check_ucs2_csets= 1; let $check_ucs2_csets= 1;
let $check_utf8_csets= 1; let $check_utf8_csets= 1;
......
################################################################################# ################################################################################
# Author: Serge Kozlov # # Author: Serge Kozlov #
# Date: 09/21/2005 # # Date: 2005-09-21 #
# Purpose: Testing the charsets for InnoDB engine # # Purpose: Testing the charsets for InnoDB engine #
################################################################################# # #
# Checking of other prerequisites is in charset_master.test #
################################################################################
--source include/have_innodb.inc --source include/have_innodb.inc
......
################################################################################# ################################################################################
# Author: Serge Kozlov # # Author: Serge Kozlov #
# Date: 09/21/2005 # # Date: 2005-09-21 #
# Purpose: Testing the charsets for Memory engine # # Purpose: Testing the charsets for Memory engine #
################################################################################# # #
# Checking of other prerequisites is in charset_master.test #
################################################################################
let $engine_type= Memory; let $engine_type= Memory;
--source suite/funcs_2/charset/charset_master.test --source suite/funcs_2/charset/charset_master.test
......
################################################################################# ################################################################################
# Author: Serge Kozlov # # Author: Serge Kozlov #
# Date: 09/21/2005 # # Date: 2005-09-21 #
# Purpose: Testing the charsets for MyISAM engine # # Purpose: Testing the charsets for MyISAM engine #
################################################################################# # #
# Checking of other prerequisites is in charset_master.test #
################################################################################
let $engine_type= MyISAM; let $engine_type= MyISAM;
--source suite/funcs_2/charset/charset_master.test --source suite/funcs_2/charset/charset_master.test
......
################################################################################# ################################################################################
# Author: Serge Kozlov # # Author: Serge Kozlov #
# Date: 09/21/2005 # # Date: 09/21/2005 #
# Purpose: Testing the charsets for NDB engine # # Purpose: Testing the charsets for NDB engine #
################################################################################# # #
# Checking of other prerequisites is in charset_master.test #
################################################################################
--source include/have_ndb.inc --source include/have_ndb.inc
--source include/not_embedded.inc --source include/not_embedded.inc
......
...@@ -417,5 +417,24 @@ drop table t1; ...@@ -417,5 +417,24 @@ drop table t1;
# #
SELECT NAME_CONST('var', 'value') COLLATE latin1_general_cs; SELECT NAME_CONST('var', 'value') COLLATE latin1_general_cs;
#
# Bug #35848: UUID() returns UUIDs with the wrong time
#
select @@session.time_zone into @save_tz;
# make sure all times are UTC so the DayNr won't differ
set @@session.time_zone='UTC';
select uuid() into @my_uuid;
# if version nibble isn't 1, the following calculations will be rubbish
select mid(@my_uuid,15,1);
select 24 * 60 * 60 * 1000 * 1000 * 10 into @my_uuid_one_day;
select concat('0',mid(@my_uuid,16,3),mid(@my_uuid,10,4),left(@my_uuid,8)) into @my_uuidate;
select floor(conv(@my_uuidate,16,10)/@my_uuid_one_day) into @my_uuid_date;
select 141427 + datediff(curdate(),'1970-01-01') into @my_uuid_synthetic;
# these should be identical; date part of UUID should be current date
select @my_uuid_date - @my_uuid_synthetic;
set @@session.time_zone=@save_tz;
--echo End of 5.0 tests --echo End of 5.0 tests
#
# This file contains tests covering the parser
#
#=============================================================================
# LEXICAL PARSER (lex)
#=============================================================================
#
# Maintainer: these tests are for the lexical parser, so every character,
# even whitespace or comments, is significant here.
#
#
# Bug#26030 (Parsing fails for stored routine w/multi-statement execution
# enabled)
#
--disable_warnings
DROP PROCEDURE IF EXISTS p26030;
--enable_warnings
delimiter $$;
select "non terminated"$$
select "terminated";$$
select "non terminated, space" $$
select "terminated, space"; $$
select "non terminated, comment" /* comment */$$
select "terminated, comment"; /* comment */$$
# Multi queries can not be used in --ps-protocol test mode
--disable_ps_protocol
select "stmt 1";select "stmt 2 non terminated"$$
select "stmt 1";select "stmt 2 terminated";$$
select "stmt 1";select "stmt 2 non terminated, space" $$
select "stmt 1";select "stmt 2 terminated, space"; $$
select "stmt 1";select "stmt 2 non terminated, comment" /* comment */$$
select "stmt 1";select "stmt 2 terminated, comment"; /* comment */$$
select "stmt 1"; select "space, stmt 2"$$
select "stmt 1";/* comment */select "comment, stmt 2"$$
DROP PROCEDURE IF EXISTS p26030; CREATE PROCEDURE p26030() BEGIN SELECT 1; END; CALL p26030()
$$
DROP PROCEDURE IF EXISTS p26030; CREATE PROCEDURE p26030() SELECT 1; CALL p26030()
$$
--enable_ps_protocol
delimiter ;$$
DROP PROCEDURE p26030;
#============================================================================r
# SYNTACTIC PARSER (bison)
#=============================================================================
...@@ -84,3 +84,31 @@ select length(a) from t1; ...@@ -84,3 +84,31 @@ select length(a) from t1;
alter table t1 modify a varchar(255); alter table t1 modify a varchar(255);
select length(a) from t1; select length(a) from t1;
#
# Bug#35658 (An empty binary value leads to mysqld crash)
#
select 0b01000001;
select 0x41;
select b'01000001';
select x'41', 0+x'41';
select N'abc', length(N'abc');
select N'', length(N'');
select '', length('');
select b'', 0+b'';
select x'', 0+x'';
--error ER_BAD_FIELD_ERROR
select 0x;
--error ER_BAD_FIELD_ERROR
select 0b;
This diff is collapsed.
...@@ -5013,21 +5013,28 @@ Item_bin_string::Item_bin_string(const char *str, uint str_length) ...@@ -5013,21 +5013,28 @@ Item_bin_string::Item_bin_string(const char *str, uint str_length)
if (!ptr) if (!ptr)
return; return;
str_value.set(ptr, max_length, &my_charset_bin); str_value.set(ptr, max_length, &my_charset_bin);
ptr+= max_length - 1;
ptr[1]= 0; // Set end null for string if (max_length > 0)
for (; end >= str; end--)
{ {
if (power == 256) ptr+= max_length - 1;
ptr[1]= 0; // Set end null for string
for (; end >= str; end--)
{ {
power= 1; if (power == 256)
*ptr--= bits; {
bits= 0; power= 1;
*ptr--= bits;
bits= 0;
}
if (*end == '1')
bits|= power;
power<<= 1;
} }
if (*end == '1') *ptr= (char) bits;
bits|= power;
power<<= 1;
} }
*ptr= (char) bits; else
ptr[0]= 0;
collation.set(&my_charset_bin, DERIVATION_COERCIBLE); collation.set(&my_charset_bin, DERIVATION_COERCIBLE);
fixed= 1; fixed= 1;
} }
......
...@@ -3258,7 +3258,8 @@ static char clock_seq_and_node_str[]="-0000-000000000000"; ...@@ -3258,7 +3258,8 @@ static char clock_seq_and_node_str[]="-0000-000000000000";
/* number of 100-nanosecond intervals between /* number of 100-nanosecond intervals between
1582-10-15 00:00:00.00 and 1970-01-01 00:00:00.00 */ 1582-10-15 00:00:00.00 and 1970-01-01 00:00:00.00 */
#define UUID_TIME_OFFSET ((ulonglong) 141427 * 24 * 60 * 60 * 1000 * 10 ) #define UUID_TIME_OFFSET ((ulonglong) 141427 * 24 * 60 * 60 * \
1000 * 1000 * 10)
#define UUID_VERSION 0x1000 #define UUID_VERSION 0x1000
#define UUID_VARIANT 0x8000 #define UUID_VARIANT 0x8000
...@@ -3317,24 +3318,64 @@ String *Item_func_uuid::val_str(String *str) ...@@ -3317,24 +3318,64 @@ String *Item_func_uuid::val_str(String *str)
set_clock_seq_str(); set_clock_seq_str();
} }
ulonglong tv=my_getsystime() + UUID_TIME_OFFSET + nanoseq; ulonglong tv= my_getsystime() + UUID_TIME_OFFSET + nanoseq;
if (unlikely(tv < uuid_time))
set_clock_seq_str(); if (likely(tv > uuid_time))
else if (unlikely(tv == uuid_time))
{ {
/* special protection from low-res system clocks */ /*
nanoseq++; Current time is ahead of last timestamp, as it should be.
tv++; If we "borrowed time", give it back, just as long as we
stay ahead of the previous timestamp.
*/
if (nanoseq)
{
DBUG_ASSERT((tv > uuid_time) && (nanoseq > 0));
/*
-1 so we won't make tv= uuid_time for nanoseq >= (tv - uuid_time)
*/
ulong delta= min(nanoseq, (ulong) (tv - uuid_time -1));
tv-= delta;
nanoseq-= delta;
}
} }
else else
{ {
if (nanoseq) if (unlikely(tv == uuid_time))
{ {
tv-=nanoseq; /*
nanoseq=0; For low-res system clocks. If several requests for UUIDs
end up on the same tick, we add a nano-second to make them
different.
( current_timestamp + nanoseq * calls_in_this_period )
may end up > next_timestamp; this is OK. Nonetheless, we'll
try to unwind nanoseq when we get a chance to.
If nanoseq overflows, we'll start over with a new numberspace
(so the if() below is needed so we can avoid the ++tv and thus
match the follow-up if() if nanoseq overflows!).
*/
if (likely(++nanoseq))
++tv;
}
if (unlikely(tv <= uuid_time))
{
/*
If the admin changes the system clock (or due to Daylight
Saving Time), the system clock may be turned *back* so we
go through a period once more for which we already gave out
UUIDs. To avoid duplicate UUIDs despite potentially identical
times, we make a new random component.
We also come here if the nanoseq "borrowing" overflows.
In either case, we throw away any nanoseq borrowing since it's
irrelevant in the new numberspace.
*/
set_clock_seq_str();
tv= my_getsystime() + UUID_TIME_OFFSET;
nanoseq= 0;
DBUG_PRINT("uuid",("making new numberspace"));
} }
DBUG_ASSERT(tv > uuid_time);
} }
uuid_time=tv; uuid_time=tv;
pthread_mutex_unlock(&LOCK_uuid_generator); pthread_mutex_unlock(&LOCK_uuid_generator);
......
...@@ -4154,8 +4154,14 @@ int User_var_log_event::exec_event(struct st_relay_log_info* rli) ...@@ -4154,8 +4154,14 @@ int User_var_log_event::exec_event(struct st_relay_log_info* rli)
/* /*
Item_func_set_user_var can't substitute something else on its place => Item_func_set_user_var can't substitute something else on its place =>
0 can be passed as last argument (reference on item) 0 can be passed as last argument (reference on item)
Fix_fields() can fail, in which case a call of update_hash() might
crash the server, so if fix fields fails, we just return with an
error.
*/ */
e.fix_fields(thd, 0); if (e.fix_fields(thd, 0))
return 1;
/* /*
A variable can just be considered as a table with A variable can just be considered as a table with
a single record and with a single column. Thus, like a single record and with a single column. Thus, like
......
...@@ -117,7 +117,6 @@ class sp_head :private Query_arena ...@@ -117,7 +117,6 @@ class sp_head :private Query_arena
create_field m_return_field_def; /* This is used for FUNCTIONs only. */ create_field m_return_field_def; /* This is used for FUNCTIONs only. */
const char *m_tmp_query; // Temporary pointer to sub query string const char *m_tmp_query; // Temporary pointer to sub query string
uint m_old_cmq; // Old CLIENT_MULTI_QUERIES value
st_sp_chistics *m_chistics; st_sp_chistics *m_chistics;
ulong m_sql_mode; // For SHOW CREATE and execution ulong m_sql_mode; // For SHOW CREATE and execution
LEX_STRING m_qname; // db.name LEX_STRING m_qname; // db.name
......
...@@ -1010,21 +1010,8 @@ int MYSQLlex(void *arg, void *yythd) ...@@ -1010,21 +1010,8 @@ int MYSQLlex(void *arg, void *yythd)
yySkip(); yySkip();
return (SET_VAR); return (SET_VAR);
case MY_LEX_SEMICOLON: // optional line terminator case MY_LEX_SEMICOLON: // optional line terminator
if (yyPeek()) state= MY_LEX_CHAR; // Return ';'
{ break;
if ((thd->client_capabilities & CLIENT_MULTI_STATEMENTS) &&
!lip->stmt_prepare_mode)
{
lex->safe_to_cache_query= 0;
lip->found_semicolon= lip->ptr;
thd->server_status|= SERVER_MORE_RESULTS_EXISTS;
lip->next_state= MY_LEX_END;
return (END_OF_INPUT);
}
state= MY_LEX_CHAR; // Return ';'
break;
}
/* fall true */
case MY_LEX_EOL: case MY_LEX_EOL:
if (lip->ptr >= lip->end_of_query) if (lip->ptr >= lip->end_of_query)
{ {
...@@ -1039,7 +1026,7 @@ int MYSQLlex(void *arg, void *yythd) ...@@ -1039,7 +1026,7 @@ int MYSQLlex(void *arg, void *yythd)
case MY_LEX_END: case MY_LEX_END:
lip->next_state=MY_LEX_END; lip->next_state=MY_LEX_END;
return(0); // We found end of input last time return(0); // We found end of input last time
/* Actually real shouldn't start with . but allow them anyhow */ /* Actually real shouldn't start with . but allow them anyhow */
case MY_LEX_REAL_OR_POINT: case MY_LEX_REAL_OR_POINT:
if (my_isdigit(cs,yyPeek())) if (my_isdigit(cs,yyPeek()))
......
...@@ -6169,6 +6169,11 @@ void mysql_parse(THD *thd, const char *inBuf, uint length, ...@@ -6169,6 +6169,11 @@ void mysql_parse(THD *thd, const char *inBuf, uint length,
(thd->query_length= (ulong)(lip.found_semicolon - thd->query))) (thd->query_length= (ulong)(lip.found_semicolon - thd->query)))
thd->query_length--; thd->query_length--;
/* Actually execute the query */ /* Actually execute the query */
if (*found_semicolon)
{
lex->safe_to_cache_query= 0;
thd->server_status|= SERVER_MORE_RESULTS_EXISTS;
}
lex->set_trg_event_type_for_tables(); lex->set_trg_event_type_for_tables();
mysql_execute_command(thd); mysql_execute_command(thd);
query_cache_end_of_result(thd); query_cache_end_of_result(thd);
......
...@@ -1203,21 +1203,54 @@ END_OF_INPUT ...@@ -1203,21 +1203,54 @@ END_OF_INPUT
query: query:
END_OF_INPUT END_OF_INPUT
{ {
THD *thd= YYTHD; THD *thd= YYTHD;
if (!thd->bootstrap && if (!thd->bootstrap &&
(!(thd->lex->select_lex.options & OPTION_FOUND_COMMENT))) (!(thd->lex->select_lex.options & OPTION_FOUND_COMMENT)))
{ {
my_message(ER_EMPTY_QUERY, ER(ER_EMPTY_QUERY), MYF(0)); my_message(ER_EMPTY_QUERY, ER(ER_EMPTY_QUERY), MYF(0));
MYSQL_YYABORT; MYSQL_YYABORT;
} }
else thd->lex->sql_command= SQLCOM_EMPTY_QUERY;
{ thd->m_lip->found_semicolon= NULL;
thd->lex->sql_command= SQLCOM_EMPTY_QUERY; }
} | verb_clause
} {
| verb_clause END_OF_INPUT {}; Lex_input_stream *lip = YYTHD->m_lip;
if ((YYTHD->client_capabilities & CLIENT_MULTI_QUERIES) &&
! lip->stmt_prepare_mode &&
! (lip->ptr >= lip->end_of_query))
{
/*
We found a well formed query, and multi queries are allowed:
- force the parser to stop after the ';'
- mark the start of the next query for the next invocation
of the parser.
*/
lip->next_state= MY_LEX_END;
lip->found_semicolon= lip->ptr;
}
else
{
/* Single query, terminated. */
lip->found_semicolon= NULL;
}
}
';'
opt_end_of_input
| verb_clause END_OF_INPUT
{
/* Single query, not terminated. */
YYTHD->m_lip->found_semicolon= NULL;
}
;
opt_end_of_input:
/* empty */
| END_OF_INPUT
;
verb_clause: verb_clause:
statement statement
...@@ -9867,13 +9900,6 @@ trigger_tail: ...@@ -9867,13 +9900,6 @@ trigger_tail:
lex->sphead= sp; lex->sphead= sp;
lex->spname= $3; lex->spname= $3;
/*
We have to turn of CLIENT_MULTI_QUERIES while parsing a
stored procedure, otherwise yylex will chop it into pieces
at each ';'.
*/
sp->m_old_cmq= thd->client_capabilities & CLIENT_MULTI_QUERIES;
thd->client_capabilities &= ~CLIENT_MULTI_QUERIES;
bzero((char *)&lex->sp_chistics, sizeof(st_sp_chistics)); bzero((char *)&lex->sp_chistics, sizeof(st_sp_chistics));
lex->sphead->m_chistics= &lex->sp_chistics; lex->sphead->m_chistics= &lex->sp_chistics;
...@@ -9888,9 +9914,6 @@ trigger_tail: ...@@ -9888,9 +9914,6 @@ trigger_tail:
lex->sql_command= SQLCOM_CREATE_TRIGGER; lex->sql_command= SQLCOM_CREATE_TRIGGER;
sp->init_strings(YYTHD, lex); sp->init_strings(YYTHD, lex);
/* Restore flag if it was cleared above */
if (sp->m_old_cmq)
YYTHD->client_capabilities |= CLIENT_MULTI_QUERIES;
sp->restore_thd_mem_root(YYTHD); sp->restore_thd_mem_root(YYTHD);
if (sp->is_not_allowed_in_function("trigger")) if (sp->is_not_allowed_in_function("trigger"))
...@@ -9968,13 +9991,6 @@ sf_tail: ...@@ -9968,13 +9991,6 @@ sf_tail:
sp->m_type= TYPE_ENUM_FUNCTION; sp->m_type= TYPE_ENUM_FUNCTION;
lex->sphead= sp; lex->sphead= sp;
/*
* We have to turn of CLIENT_MULTI_QUERIES while parsing a
* stored procedure, otherwise yylex will chop it into pieces
* at each ';'.
*/
sp->m_old_cmq= thd->client_capabilities & CLIENT_MULTI_QUERIES;
thd->client_capabilities &= ~CLIENT_MULTI_QUERIES;
lex->sphead->m_param_begin= lip->tok_start+1; lex->sphead->m_param_begin= lip->tok_start+1;
} }
sp_fdparam_list /* $6 */ sp_fdparam_list /* $6 */
...@@ -10030,9 +10046,6 @@ sf_tail: ...@@ -10030,9 +10046,6 @@ sf_tail:
my_error(ER_SP_NORETURN, MYF(0), sp->m_qname.str); my_error(ER_SP_NORETURN, MYF(0), sp->m_qname.str);
MYSQL_YYABORT; MYSQL_YYABORT;
} }
/* Restore flag if it was cleared above */
if (sp->m_old_cmq)
YYTHD->client_capabilities |= CLIENT_MULTI_QUERIES;
sp->restore_thd_mem_root(YYTHD); sp->restore_thd_mem_root(YYTHD);
} }
; ;
...@@ -10062,13 +10075,6 @@ sp_tail: ...@@ -10062,13 +10075,6 @@ sp_tail:
sp->init_sp_name(YYTHD, $3); sp->init_sp_name(YYTHD, $3);
lex->sphead= sp; lex->sphead= sp;
/*
* We have to turn of CLIENT_MULTI_QUERIES while parsing a
* stored procedure, otherwise yylex will chop it into pieces
* at each ';'.
*/
sp->m_old_cmq= YYTHD->client_capabilities & CLIENT_MULTI_QUERIES;
YYTHD->client_capabilities &= (~CLIENT_MULTI_QUERIES);
} }
'(' '('
{ {
...@@ -10104,9 +10110,6 @@ sp_tail: ...@@ -10104,9 +10110,6 @@ sp_tail:
sp->init_strings(YYTHD, lex); sp->init_strings(YYTHD, lex);
lex->sql_command= SQLCOM_CREATE_PROCEDURE; lex->sql_command= SQLCOM_CREATE_PROCEDURE;
/* Restore flag if it was cleared above */
if (sp->m_old_cmq)
YYTHD->client_capabilities |= CLIENT_MULTI_QUERIES;
sp->restore_thd_mem_root(YYTHD); sp->restore_thd_mem_root(YYTHD);
} }
; ;
......
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