mirror of
https://github.com/MariaDB/server.git
synced 2025-01-20 05:52:27 +01:00
Merge mleich@bk-internal.mysql.com:/home/bk/mysql-4.1
into three.local.lan:/home/matthias/Arbeit/mysql-4.1/src
This commit is contained in:
commit
a00cb55dae
5 changed files with 6273 additions and 0 deletions
330
mysql-test/include/patchwork-check.inc
Normal file
330
mysql-test/include/patchwork-check.inc
Normal file
|
@ -0,0 +1,330 @@
|
|||
###################### patchwork-check.inc #############################
|
||||
# #
|
||||
# Basic routine for the generation and execution of prepared and non #
|
||||
# prepared SQL statements. #
|
||||
# #
|
||||
# Purpose: Simplify the check of complex statements with different #
|
||||
# sets of parameters (data type, value) #
|
||||
# #
|
||||
########################################################################
|
||||
|
||||
#
|
||||
# NOTE: PLEASE BE VERY CAREFULL, WHEN CHANGING OR USING ;-) THIS ROUTINE.
|
||||
#
|
||||
# Please be aware, that this routine
|
||||
# - will be sourced by several test case files stored within the
|
||||
# directory 'mysql-test/t'. So every change here will affect
|
||||
# several test cases.
|
||||
# - does not check its own prequisites
|
||||
# - modifies the content and the data type of the
|
||||
# uservariables @var_1 ... @var_<n>
|
||||
#
|
||||
# Please preserve the '__<name>_' naming of the the auxiliary variables.
|
||||
# These names should avoid that a test case writer accidently creates a
|
||||
# variable with the same name.
|
||||
#
|
||||
|
||||
# naming conventions:
|
||||
# stmt_c_ --> statement with constants like "select 1 "
|
||||
# stmt_uv_ --> statement with uservariables like "select @var_1 "
|
||||
# stmt_ph_ --> prepared statement with placeholders like "select ? "
|
||||
|
||||
|
||||
#
|
||||
# Explanation how to use this routine by an example:
|
||||
#
|
||||
# Content of the caller script:
|
||||
# ....
|
||||
# set @stmt_part1= 'SELECT f1 + '
|
||||
# set @stmt_part2= ' from t1 where f2= ' ;
|
||||
# set @stmt_part3= '' ;
|
||||
# set @string_1= "1"; set @type_1= "BIGINT";
|
||||
# set @string_2= "-2.3E-4"; set @type_2= "DOUBLE";
|
||||
# set @max_var_number= 2;
|
||||
# --source include/patchwork-check.inc
|
||||
#
|
||||
# # The next testing rounds could start with
|
||||
# set @string_1= "NULL"; set @type_1= "BIGINT";
|
||||
# set @string_2= "-2.3E-4"; set @type_2= "DOUBLE";
|
||||
# --source include/patchwork-check.inc
|
||||
#
|
||||
# set @string_1= "1"; set @type_1= "BIGINT";
|
||||
# set @string_2= "NULL"; set @type_2= "LONGTEXT";
|
||||
# --source include/patchwork-check.inc
|
||||
#
|
||||
# Statements and uservariables to be produced and executed by this routine
|
||||
# 1. Statements with constants
|
||||
# 1.1 stmt1= SELECT f1 + 1 from t1 where f2= -2.3E-4 ;
|
||||
# 1.2 stmt1 as prepared statement
|
||||
# 2. Statements with uservariables
|
||||
# @var_n should be of data type @type_n (if possible) and have the
|
||||
# content @string_n .
|
||||
# 2.1 stmt2= SELECT f1 + @var_1 from t1 where f2= @var_2
|
||||
# 2.2 stmt2 as prepared statement
|
||||
# 3. prepared statement with placeholders
|
||||
# prepare stmt1 from 'SELECT f1 + ? from t1 where f2= ?'
|
||||
# execute stmt1 using @var_1, @var_2
|
||||
#
|
||||
# Every prepared statement variant of the "patchwork" is 3 times executed.
|
||||
#
|
||||
#
|
||||
# Please have also also a look into
|
||||
# - t/tooltest.test , which checks or
|
||||
# - t/ps_12func.test , which contains test cases using
|
||||
# this routine.
|
||||
#
|
||||
|
||||
|
||||
##############
|
||||
#
|
||||
# Prerequisites:
|
||||
#
|
||||
# The caller script must set the following uservariables:
|
||||
#
|
||||
# The statement pieces: @stmt_part1, @stmt_part2, ... , @stmt_part<n>
|
||||
#
|
||||
# The parameter values: @string_1, ... , @string_<n - 1>
|
||||
# The parameter value should fit to the data type !
|
||||
# UPPER(@stmt_part1) = 'NULL' will cause (SQL) NULL as content.
|
||||
#
|
||||
# The parameter data types: @type_1, ... , @type_<n - 1>
|
||||
# valid types are: BIGINT, DOUBLE, LONGTEXT, LONGBLOB
|
||||
#
|
||||
# Attention: All other type assignments will lead to a
|
||||
# uservariable of type LONGTEXT !!
|
||||
#
|
||||
# The number of parameter values must be published via
|
||||
# set @max_var_number= <n - 1> ;
|
||||
#
|
||||
# Attention: This routine does not perform any check of the content
|
||||
# of these variables.
|
||||
#
|
||||
|
||||
##############
|
||||
#
|
||||
# How is intended uservariable generated:
|
||||
#
|
||||
# Step 1: generate a uservariable of the intended type
|
||||
#
|
||||
# UPPER(@type_<n>) statement
|
||||
# BIGINT set @var_<n>= 0
|
||||
# DOUBLE' set @var_<n>idx_= 0.0
|
||||
# LONGTEXT' set @var_<n>= "INIT"
|
||||
# LONGBLOB' set @var_<n>= CAST("INIT" AS BINARY)
|
||||
# <all other> set @var_<n>= "INIT"
|
||||
#
|
||||
# Step 2: assign the value to the uservariable
|
||||
#
|
||||
# IF ( UPPER(@string_<n>) != 'NULL')
|
||||
# UPPER(@type_<n>)
|
||||
# BIGINT set @var_<n>= CEIL(@string_<n>)
|
||||
# DOUBLE set @var_<n>= @string_<n> + 0.0
|
||||
# LONGTEXT set @var_<n>= @string_<n>
|
||||
# LONGBLOB set @var_<n>= CAST(@string_<n> AS BINARY)
|
||||
# <all other> set @var_<n>= @string_<n>
|
||||
# ELSE
|
||||
# set @var_<n>= NULL
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# How to debug this routine if something goes wrong:
|
||||
#
|
||||
# 1. Put the line '--disable_abort_on_error' into the caller script
|
||||
# --> There will be no abort of mysqltest, if a statement fails.
|
||||
# You will get a protocol (in most cases).
|
||||
# 2. Put the line 'set $__debug_= 1 ;' into the caller script .
|
||||
# The next call of patchwork-check.inc will print
|
||||
# the type and content of generated uservariables and statements.
|
||||
# 3. disable the '--disable_query_log' option some lines below
|
||||
#
|
||||
# and please be patient towards this routine, it is far away from being perfect.
|
||||
#
|
||||
|
||||
|
||||
# Suppress the majority of the huge output concerning the statement and
|
||||
# uservariable generation
|
||||
--disable_query_log
|
||||
|
||||
let $__idx_= 1 ;
|
||||
eval set @__stmt_c_= @stmt_part_$__idx_ ;
|
||||
# If the number of variables is greater 0, we need also
|
||||
# - the statement with uservariables (stmt_uv) and
|
||||
# - the prepared statement with placeholders (stmt_ph) and
|
||||
# - the execute for the prepared statement with placeholders (execute_stmt_ph)
|
||||
let $__with_var_= `select @max_var_number > 0`;
|
||||
while ($__with_var_)
|
||||
{
|
||||
eval set @__stmt_uv_= @stmt_part_$__idx_ ;
|
||||
eval set @__stmt_ph_= @stmt_part_$__idx_ ;
|
||||
set @__execute_stmt_ph= 'execute __stmt_ph_ using ' ;
|
||||
let $__num_= `select @max_var_number`;
|
||||
while ($__num_)
|
||||
{
|
||||
##### Generate the Uservariables
|
||||
eval set @__my_init_= CASE UPPER(@type_$__idx_)
|
||||
WHEN 'BIGINT' THEN 'set @var_$__idx_= 0'
|
||||
WHEN 'DOUBLE' THEN 'set @var_$__idx_= 0.0'
|
||||
WHEN 'LONGTEXT' THEN 'set @var_$__idx_= "INIT"'
|
||||
WHEN 'LONGBLOB' THEN 'set @var_$__idx_= CAST("INIT" AS BINARY)'
|
||||
ELSE 'set @var_$__idx_= "INIT"' END;
|
||||
# select @__my_init_ as "@__my_init_ is: " ;
|
||||
let $__my_init_= `select @__my_init_`;
|
||||
eval $__my_init_ ;
|
||||
|
||||
eval set @__my_init_= CASE UPPER(@type_$__idx_)
|
||||
WHEN 'BIGINT' THEN
|
||||
"set @var_$__idx_= IF(UPPER(@string_$__idx_)!='NULL',CEIL(@string_$__idx_),NULL)"
|
||||
WHEN 'DOUBLE' THEN
|
||||
"set @var_$__idx_= IF(UPPER(@string_$__idx_)!='NULL',@string_$__idx_ + 0.0,NULL)"
|
||||
WHEN 'LONGTEXT' THEN
|
||||
"set @var_$__idx_= IF(UPPER(@string_$__idx_)!='NULL',@string_$__idx_,NULL)"
|
||||
WHEN 'LONGBLOB' THEN
|
||||
"set @var_$__idx_= IF(UPPER(@string_$__idx_)!='NULL',CAST(@string_$__idx_ AS BINARY),NULL)"
|
||||
ELSE
|
||||
"set @var_$__idx_= IF(UPPER(@string_$__idx_)!='NULL',@string_$__idx_,NULL)" END;
|
||||
let $__my_init_= `select @__my_init_`;
|
||||
eval $__my_init_ ;
|
||||
|
||||
##### concat the variable to the statements
|
||||
## with Constants
|
||||
# 1. replace ugly NULLs like 'NuLl' with 'NULL' for better readability
|
||||
# 2. Strings to be inserted into the statement must be quoted
|
||||
eval set @__stmt_c_= concat(
|
||||
@__stmt_c_,
|
||||
IF(UPPER(@string_$__idx_)='NULL','NULL',
|
||||
IF(UPPER(@type_$__idx_)='LONGTEXT' or UPPER(@type_$__idx_)='LONGBLOB',
|
||||
concat('''',@string_$__idx_,''''), @string_$__idx_
|
||||
))) ;
|
||||
## with Uservariables
|
||||
eval set @__stmt_uv_= concat(@__stmt_uv_, '@var_$__idx_') ;
|
||||
## with placeholders
|
||||
eval set @__stmt_ph_= concat(@__stmt_ph_, '?') ;
|
||||
|
||||
##### complete the execute for the prepared statement with placeholders
|
||||
eval set @__execute_stmt_ph= concat(@__execute_stmt_ph, '@var_$__idx_,') ;
|
||||
|
||||
inc $__idx_ ;
|
||||
##### concat the next part of the statement to the statements
|
||||
eval set @__stmt_c_= concat(@__stmt_c_, @stmt_part_$__idx_ );
|
||||
eval set @__stmt_uv_= concat(@__stmt_uv_, @stmt_part_$__idx_ );
|
||||
eval set @__stmt_ph_= concat(@__stmt_ph_, @stmt_part_$__idx_ );
|
||||
|
||||
dec $__num_ ;
|
||||
}
|
||||
# @__execute_stmt_ph contains a trailing ',' which must be cut away
|
||||
set @__execute_stmt_ph= substr(@__execute_stmt_ph,1,length(@__execute_stmt_ph) - 1);
|
||||
dec $__with_var_ ;
|
||||
}
|
||||
|
||||
while ($__debug_)
|
||||
{
|
||||
### Print debug informations for patchwork with variables
|
||||
let $__with_var_= `select @max_var_number > 0`;
|
||||
while ($__with_var_)
|
||||
{
|
||||
### Print out the content of the statement variables
|
||||
eval select "--------------------------------------"
|
||||
as "the content of the statement variables"
|
||||
union select concat('@__stmt_c_ is: ',@__stmt_c_)
|
||||
union select concat('@__stmt_uv_ is: ',@__stmt_uv_)
|
||||
union select concat('@__stmt_ph_ is: ',@__stmt_ph_)
|
||||
union select concat('@__execute_stmt_ph is: ',@__execute_stmt_ph);
|
||||
|
||||
|
||||
### Print out the content of the uservariables
|
||||
select '--------------------------------------'
|
||||
as "the content of the parameter variables";
|
||||
set @__parameter_= 'select ';
|
||||
let $__num_= `select @max_var_number`;
|
||||
let $__idx_= 1 ;
|
||||
while ($__num_)
|
||||
{
|
||||
eval select @type_$__idx_ as type,
|
||||
@string_$__idx_ as string,
|
||||
@var_$__idx_ as uservariable ;
|
||||
eval set @__parameter_= concat(@__parameter_, '@var_$__idx_ ,');
|
||||
inc $__idx_ ;
|
||||
|
||||
dec $__num_ ;
|
||||
}
|
||||
# @__parameter_ contains a trailing ',' which must be cut away
|
||||
set @__parameter_= substr(@__parameter_,1,length(@__parameter_) - 1);
|
||||
let $__aux_= `select @__parameter_` ;
|
||||
eval $__aux_ ;
|
||||
|
||||
|
||||
### Create a table from the uservariables and print out the column types
|
||||
let $__aux_= `select concat('CREATE TABLE t9 AS ',@__parameter_)` ;
|
||||
--disable_warnings
|
||||
drop table if exists t9;
|
||||
--enable_warnings
|
||||
eval $__aux_ ;
|
||||
show create table t9;
|
||||
drop table t9;
|
||||
|
||||
dec $__with_var_ ;
|
||||
}
|
||||
### Print debug informations for patchwork without variables
|
||||
### stmt_uv, stmt_ph, execute_stmt_ph and uservariables do NOT exist
|
||||
let $__with_var_= `select @max_var_number = 0`;
|
||||
while ($__with_var_)
|
||||
{
|
||||
### Print out the content of the statement variables
|
||||
eval select "--------------------------------------"
|
||||
as "the content of the statement variable"
|
||||
union select concat('@__stmt_c_ is: ',@__stmt_c_) ;
|
||||
|
||||
dec $__with_var_ ;
|
||||
}
|
||||
|
||||
|
||||
dec $__debug_ ;
|
||||
}
|
||||
|
||||
## copy the statements and the execute into $variables
|
||||
# (__stmt_ph_ is not needed)
|
||||
## + generate the prepared statements
|
||||
--enable_query_log
|
||||
let $__stmt_c_= `select @__stmt_c_`;
|
||||
eval prepare __stmt_c_ from @__stmt_c_ ;
|
||||
let $__with_var_= `select @max_var_number > 0`;
|
||||
while ($__with_var_)
|
||||
{
|
||||
let $__stmt_uv_= `select @__stmt_uv_`;
|
||||
eval prepare __stmt_uv_ from @__stmt_uv_ ;
|
||||
let $__execute_ph= `select @__execute_stmt_ph`;
|
||||
eval prepare __stmt_ph_ from @__stmt_ph_ ;
|
||||
dec $__with_var_ ;
|
||||
}
|
||||
|
||||
|
||||
##### The execution of all statements
|
||||
## statement with Constants
|
||||
eval $__stmt_c_ ;
|
||||
## prepared statement with Constants
|
||||
execute __stmt_c_ ;
|
||||
# Try to detect if the prior executes damaged the parse tree by
|
||||
# two additional executes .
|
||||
execute __stmt_c_ ;
|
||||
execute __stmt_c_ ;
|
||||
let $__with_var_= `select @max_var_number > 0`;
|
||||
while ($__with_var_)
|
||||
{
|
||||
## statement with Uservariables
|
||||
eval $__stmt_uv_ ;
|
||||
## prepared statement with Uservariables
|
||||
execute __stmt_uv_ ;
|
||||
# Try to detect if the prior executes damaged the parse tree by
|
||||
# two additional executes .
|
||||
execute __stmt_uv_ ;
|
||||
execute __stmt_uv_ ;
|
||||
## prepared statement with placeholders
|
||||
eval $__execute_ph ;
|
||||
# Try to detect if the prior executes damaged the parse tree by
|
||||
# two additional executes .
|
||||
eval $__execute_ph ;
|
||||
eval $__execute_ph ;
|
||||
|
||||
dec $__with_var_ ;
|
||||
}
|
4748
mysql-test/r/ps_12func.result
Normal file
4748
mysql-test/r/ps_12func.result
Normal file
File diff suppressed because it is too large
Load diff
223
mysql-test/r/tool_test.result
Normal file
223
mysql-test/r/tool_test.result
Normal file
|
@ -0,0 +1,223 @@
|
|||
use test ;
|
||||
set @stmt_part_1= 'SELECT 1 as "my_fine_statement"' ;
|
||||
set @max_var_number= 0;
|
||||
the content of the statement variable
|
||||
--------------------------------------
|
||||
@__stmt_c_ is: SELECT 1 as "my_fine_statement"
|
||||
prepare __stmt_c_ from @__stmt_c_ ;
|
||||
SELECT 1 as "my_fine_statement" ;
|
||||
my_fine_statement
|
||||
1
|
||||
execute __stmt_c_ ;
|
||||
my_fine_statement
|
||||
1
|
||||
execute __stmt_c_ ;
|
||||
my_fine_statement
|
||||
1
|
||||
execute __stmt_c_ ;
|
||||
my_fine_statement
|
||||
1
|
||||
set @stmt_part_1= 'SELECT ' ;
|
||||
set @stmt_part_2= ' + ' ;
|
||||
set @stmt_part_3= ' + ' ;
|
||||
set @stmt_part_4= ' + ' ;
|
||||
set @stmt_part_5= ' + ' ;
|
||||
set @stmt_part_6= ' + ' ;
|
||||
set @stmt_part_7= ' + ' ;
|
||||
set @stmt_part_8= ' + ' ;
|
||||
set @stmt_part_9= ' as "my_fine_statement"' ;
|
||||
set @max_var_number= 8;
|
||||
set @string_1= '1' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
set @string_2= 'nULL' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= '2.0' ;
|
||||
set @type_3= 'DOUBLE' ;
|
||||
set @string_4= 'NuLL' ;
|
||||
set @type_4= 'DOUBLE' ;
|
||||
set @string_5= 'TEXT' ;
|
||||
set @type_5= 'LONGTEXT' ;
|
||||
set @string_6= 'NUlL' ;
|
||||
set @type_6= 'LONGTEXT' ;
|
||||
set @string_7= 'BLOB' ;
|
||||
set @type_7= 'LONGBLOB' ;
|
||||
set @string_8= 'NULl' ;
|
||||
set @type_8= 'LONGBLOB' ;
|
||||
set @var_1= 'YYYYYYYY' ;
|
||||
set @var_2= 'YYYYYYYY' ;
|
||||
set @var_3= 'YYYYYYYY' ;
|
||||
set @var_4= 'YYYYYYYY' ;
|
||||
set @var_5= 'YYYYYYYY' ;
|
||||
set @var_6= 'YYYYYYYY' ;
|
||||
set @var_7= 'YYYYYYYY' ;
|
||||
set @var_8= 'YYYYYYYY' ;
|
||||
the content of the statement variables
|
||||
--------------------------------------
|
||||
@__stmt_c_ is: SELECT 1 + NULL + 2.0 + NULL + 'TEXT' + NULL + 'BLOB' + NULL as "my_fine_statement"
|
||||
@__stmt_uv_ is: SELECT @var_1 + @var_2 + @var_3 + @var_4 + @var_5 + @var_6 + @var_7 + @var_8 as "my_fine_statement"
|
||||
@__stmt_ph_ is: SELECT ? + ? + ? + ? + ? + ? + ? + ? as "my_fine_statement"
|
||||
@__execute_stmt_ph is: execute __stmt_ph_ using @var_1 ,@var_2,@var_3,@var_4,@var_5,@var_6,@var_7,@var_8
|
||||
the content of the parameter variables
|
||||
--------------------------------------
|
||||
type string uservariable
|
||||
BIGINT 1 1
|
||||
type string uservariable
|
||||
BIGINT nULL NULL
|
||||
type string uservariable
|
||||
DOUBLE 2.0 2
|
||||
type string uservariable
|
||||
DOUBLE NuLL NULL
|
||||
type string uservariable
|
||||
LONGTEXT TEXT TEXT
|
||||
type string uservariable
|
||||
LONGTEXT NUlL NULL
|
||||
type string uservariable
|
||||
LONGBLOB BLOB BLOB
|
||||
type string uservariable
|
||||
LONGBLOB NULl NULL
|
||||
@var_1 @var_2 @var_3 @var_4 @var_5 @var_6 @var_7 @var_8
|
||||
1 NULL 2 NULL TEXT NULL BLOB NULL
|
||||
Table Create Table
|
||||
t9 CREATE TABLE `t9` (
|
||||
`@var_1` bigint(20) default NULL,
|
||||
`@var_2` bigint(20) default NULL,
|
||||
`@var_3` double default NULL,
|
||||
`@var_4` double default NULL,
|
||||
`@var_5` longtext,
|
||||
`@var_6` longtext,
|
||||
`@var_7` longblob,
|
||||
`@var_8` longblob
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
prepare __stmt_c_ from @__stmt_c_ ;
|
||||
prepare __stmt_uv_ from @__stmt_uv_ ;
|
||||
prepare __stmt_ph_ from @__stmt_ph_ ;
|
||||
SELECT 1 + NULL + 2.0 + NULL + 'TEXT' + NULL + 'BLOB' + NULL as "my_fine_statement" ;
|
||||
my_fine_statement
|
||||
NULL
|
||||
execute __stmt_c_ ;
|
||||
my_fine_statement
|
||||
NULL
|
||||
execute __stmt_c_ ;
|
||||
my_fine_statement
|
||||
NULL
|
||||
execute __stmt_c_ ;
|
||||
my_fine_statement
|
||||
NULL
|
||||
SELECT @var_1 + @var_2 + @var_3 + @var_4 + @var_5 + @var_6 + @var_7 + @var_8 as "my_fine_statement" ;
|
||||
my_fine_statement
|
||||
NULL
|
||||
execute __stmt_uv_ ;
|
||||
my_fine_statement
|
||||
NULL
|
||||
execute __stmt_uv_ ;
|
||||
my_fine_statement
|
||||
NULL
|
||||
execute __stmt_uv_ ;
|
||||
my_fine_statement
|
||||
NULL
|
||||
execute __stmt_ph_ using @var_1 ,@var_2,@var_3,@var_4,@var_5,@var_6,@var_7,@var_8 ;
|
||||
my_fine_statement
|
||||
NULL
|
||||
execute __stmt_ph_ using @var_1 ,@var_2,@var_3,@var_4,@var_5,@var_6,@var_7,@var_8 ;
|
||||
my_fine_statement
|
||||
NULL
|
||||
execute __stmt_ph_ using @var_1 ,@var_2,@var_3,@var_4,@var_5,@var_6,@var_7,@var_8 ;
|
||||
my_fine_statement
|
||||
NULL
|
||||
set @string_1= '1.0' ;
|
||||
set @type_1= 'DOUBLE' ;
|
||||
set @string_2= '3.0' ;
|
||||
set @type_2= 'DOUBLE' ;
|
||||
set @string_3= '2' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
set @string_4= '4' ;
|
||||
set @type_4= 'BIGINT' ;
|
||||
set @string_5= '5' ;
|
||||
set @type_5= 'BIGINT' ;
|
||||
set @string_6= '6' ;
|
||||
set @type_6= 'DOUBLE' ;
|
||||
set @string_7= '7' ;
|
||||
set @type_7= 'DOUBLE' ;
|
||||
set @string_8= '8' ;
|
||||
set @type_8= 'DOUBLE' ;
|
||||
set @var_1= 'YYYYYYYY' ;
|
||||
set @var_2= 'YYYYYYYY' ;
|
||||
set @var_3= 'YYYYYYYY' ;
|
||||
set @var_4= 'YYYYYYYY' ;
|
||||
set @var_5= 'YYYYYYYY' ;
|
||||
set @var_6= 'YYYYYYYY' ;
|
||||
set @var_7= 'YYYYYYYY' ;
|
||||
set @var_8= 'YYYYYYYY' ;
|
||||
the content of the statement variables
|
||||
--------------------------------------
|
||||
@__stmt_c_ is: SELECT 1.0 + 3.0 + 2 + 4 + 5 + 6 + 7 + 8 as "my_fine_statement"
|
||||
@__stmt_uv_ is: SELECT @var_1 + @var_2 + @var_3 + @var_4 + @var_5 + @var_6 + @var_7 + @var_8 as "my_fine_statement"
|
||||
@__stmt_ph_ is: SELECT ? + ? + ? + ? + ? + ? + ? + ? as "my_fine_statement"
|
||||
@__execute_stmt_ph is: execute __stmt_ph_ using @var_1 ,@var_2,@var_3,@var_4,@var_5,@var_6,@var_7,@var_8
|
||||
the content of the parameter variables
|
||||
--------------------------------------
|
||||
type string uservariable
|
||||
DOUBLE 1.0 1
|
||||
type string uservariable
|
||||
DOUBLE 3.0 3
|
||||
type string uservariable
|
||||
BIGINT 2 2
|
||||
type string uservariable
|
||||
BIGINT 4 4
|
||||
type string uservariable
|
||||
BIGINT 5 5
|
||||
type string uservariable
|
||||
DOUBLE 6 6
|
||||
type string uservariable
|
||||
DOUBLE 7 7
|
||||
type string uservariable
|
||||
DOUBLE 8 8
|
||||
@var_1 @var_2 @var_3 @var_4 @var_5 @var_6 @var_7 @var_8
|
||||
1 3 2 4 5 6 7 8
|
||||
Table Create Table
|
||||
t9 CREATE TABLE `t9` (
|
||||
`@var_1` double default NULL,
|
||||
`@var_2` double default NULL,
|
||||
`@var_3` bigint(20) default NULL,
|
||||
`@var_4` bigint(20) default NULL,
|
||||
`@var_5` bigint(20) default NULL,
|
||||
`@var_6` double default NULL,
|
||||
`@var_7` double default NULL,
|
||||
`@var_8` double default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
prepare __stmt_c_ from @__stmt_c_ ;
|
||||
prepare __stmt_uv_ from @__stmt_uv_ ;
|
||||
prepare __stmt_ph_ from @__stmt_ph_ ;
|
||||
SELECT 1.0 + 3.0 + 2 + 4 + 5 + 6 + 7 + 8 as "my_fine_statement" ;
|
||||
my_fine_statement
|
||||
36.0
|
||||
execute __stmt_c_ ;
|
||||
my_fine_statement
|
||||
36.0
|
||||
execute __stmt_c_ ;
|
||||
my_fine_statement
|
||||
36.0
|
||||
execute __stmt_c_ ;
|
||||
my_fine_statement
|
||||
36.0
|
||||
SELECT @var_1 + @var_2 + @var_3 + @var_4 + @var_5 + @var_6 + @var_7 + @var_8 as "my_fine_statement" ;
|
||||
my_fine_statement
|
||||
36
|
||||
execute __stmt_uv_ ;
|
||||
my_fine_statement
|
||||
36
|
||||
execute __stmt_uv_ ;
|
||||
my_fine_statement
|
||||
36
|
||||
execute __stmt_uv_ ;
|
||||
my_fine_statement
|
||||
36
|
||||
execute __stmt_ph_ using @var_1 ,@var_2,@var_3,@var_4,@var_5,@var_6,@var_7,@var_8 ;
|
||||
my_fine_statement
|
||||
36
|
||||
execute __stmt_ph_ using @var_1 ,@var_2,@var_3,@var_4,@var_5,@var_6,@var_7,@var_8 ;
|
||||
my_fine_statement
|
||||
36
|
||||
execute __stmt_ph_ using @var_1 ,@var_2,@var_3,@var_4,@var_5,@var_6,@var_7,@var_8 ;
|
||||
my_fine_statement
|
||||
36
|
867
mysql-test/t/ps_12func.test
Normal file
867
mysql-test/t/ps_12func.test
Normal file
|
@ -0,0 +1,867 @@
|
|||
##################### ps_12func.test #####################
|
||||
# #
|
||||
# Prepared Statement tests of functions #
|
||||
# #
|
||||
# Non prepared variants are also checked #
|
||||
# #
|
||||
# Checked functions: #
|
||||
# #
|
||||
# ROUND(X,D) and ROUND(X) #
|
||||
# CONCAT_WS(separator,str1,str2,...) #
|
||||
# CHAR(N,...) #
|
||||
# CHAR_LENGTH(str) #
|
||||
# FIELD(str,str1,str2,str3,...) #
|
||||
# INSERT(str,pos,len,newstr) #
|
||||
# BIN(N) #
|
||||
# BIT_LENGTH(str) #
|
||||
# CONV(N,from_base,to_base) #
|
||||
# #
|
||||
##########################################################
|
||||
|
||||
use test;
|
||||
|
||||
# "--disable_abort_on_error" is definitely needed, because there are some tests
|
||||
# which intentional produce statements with wrong syntax and it is not
|
||||
# possible to put a "--error <whatever>" just before the execution calls
|
||||
# within patchwork-test.inc .
|
||||
--disable_abort_on_error
|
||||
|
||||
##### ROUND(X,D)
|
||||
--disable_query_log
|
||||
select concat('###### Variations on ROUND(X,D) ######') as ''
|
||||
union select '';
|
||||
--enable_query_log
|
||||
set @stmt_part_1= 'select ROUND(' ;
|
||||
set @stmt_part_2= ',' ;
|
||||
set @stmt_part_3= ') as my_col' ;
|
||||
set @max_var_number= 2;
|
||||
|
||||
|
||||
#------------------------------------------------------------------
|
||||
# first parameter 11.298 (DOUBLE) , ROUND( m.n , p ) m = 2 ; n = 3
|
||||
# Variations on parameter2
|
||||
#------------------------------------------------------------------
|
||||
set @string_1= '11.298' ;
|
||||
set @type_1= 'DOUBLE' ;
|
||||
## data type BIGINT, if possible
|
||||
set @type_2= 'BIGINT' ;
|
||||
# p < n
|
||||
set @string_2= '1' ;
|
||||
--source include/patchwork-check.inc
|
||||
# p = n
|
||||
set @string_2= '3' ;
|
||||
--source include/patchwork-check.inc
|
||||
# p > n
|
||||
set @string_2= '4' ;
|
||||
--source include/patchwork-check.inc
|
||||
# p = 0
|
||||
set @string_2= '0' ;
|
||||
--source include/patchwork-check.inc
|
||||
# -p < m
|
||||
set @string_2= '-1' ;
|
||||
--source include/patchwork-check.inc
|
||||
# -p = m
|
||||
set @string_2= '-2' ;
|
||||
--source include/patchwork-check.inc
|
||||
# -p > m
|
||||
set @string_2= '-3' ;
|
||||
--source include/patchwork-check.inc
|
||||
# -p = NULL
|
||||
set @string_2= 'NULL' ;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
## data type DOUBLE, if possible
|
||||
set @type_2= 'DOUBLE' ;
|
||||
# p < n
|
||||
set @string_2= '1.0' ;
|
||||
--source include/patchwork-check.inc
|
||||
# p = n
|
||||
set @string_2= '3.0' ;
|
||||
--source include/patchwork-check.inc
|
||||
# p > n
|
||||
set @string_2= '4.0' ;
|
||||
--source include/patchwork-check.inc
|
||||
# p = 0
|
||||
set @string_2= '0.0' ;
|
||||
--source include/patchwork-check.inc
|
||||
# -p < m
|
||||
set @string_2= '-1.0' ;
|
||||
--source include/patchwork-check.inc
|
||||
# -p = m
|
||||
set @string_2= '-2.0' ;
|
||||
--source include/patchwork-check.inc
|
||||
# -p > m
|
||||
set @string_2= '-3.0' ;
|
||||
--source include/patchwork-check.inc
|
||||
# ugly values
|
||||
set @string_2= '1.1' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_2= '1.9' ;
|
||||
--source include/patchwork-check.inc
|
||||
# -p = NULL
|
||||
set @string_2= 'NULL' ;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
## data type LONGBLOB, content NULL
|
||||
set @type_2= 'LONGBLOB' ;
|
||||
set @string_2= 'NULL' ;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
|
||||
#------------------------------------------------------------------
|
||||
# first parameter data type BIGINT, content NULL
|
||||
# Variations on parameter2
|
||||
#------------------------------------------------------------------
|
||||
set @string_1= 'NULL' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_2= '2' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_2= '-2' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_2= 'NULL' ;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
set @type_2= 'DOUBLE' ;
|
||||
set @string_2= '2.0' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_2= '-2.0' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_2= 'NULL' ;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
set @type_2= 'LONGBLOB' ;
|
||||
set @string_2= 'NULL' ;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
|
||||
#------------------------------------------------------------------
|
||||
# first parameter data type DOUBLE, content NULL
|
||||
# Variations on parameter2
|
||||
#------------------------------------------------------------------
|
||||
set @string_1= 'NULL' ;
|
||||
set @type_1= 'DOUBLE' ;
|
||||
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_2= '2' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_2= '-2' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_2= 'NULL' ;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
set @type_2= 'DOUBLE' ;
|
||||
set @string_2= '2.0' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_2= '-2.0' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_2= 'NULL' ;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
set @type_2= 'LONGBLOB' ;
|
||||
set @string_2= 'NULL' ;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
|
||||
#------------------------------------------------------------------
|
||||
# first parameter data type LONGBLOB, content NULL
|
||||
# Variations on parameter2
|
||||
#------------------------------------------------------------------
|
||||
set @string_1= 'NULL' ;
|
||||
set @type_1= 'LONGBLOB' ;
|
||||
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_2= '2' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_2= '-2' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_2= 'NULL' ;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
set @type_2= 'DOUBLE' ;
|
||||
set @string_2= '2.0' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_2= '-2.0' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_2= 'NULL' ;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
set @type_2= 'LONGBLOB' ;
|
||||
set @string_2= 'NULL' ;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
#------------------------------------------------------------------
|
||||
# ROUND(D) Returns the argument X, rounded to the nearest integer.
|
||||
#------------------------------------------------------------------
|
||||
set @stmt_part_1= 'select ROUND(' ;
|
||||
set @stmt_part_2= ') as my_col' ;
|
||||
set @max_var_number= 1;
|
||||
## test cases with BIGINT
|
||||
set @string_1= '11' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_1= '-11' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_1= '0' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_1= 'NULL' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
## test cases with BIGINT
|
||||
set @string_1= '11.49' ;
|
||||
set @type_1= 'DOUBLE' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_1= '10.51' ;
|
||||
set @type_1= 'DOUBLE' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_1= '0.0' ;
|
||||
set @type_1= 'DOUBLE' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_1= 'NULL' ;
|
||||
set @type_1= 'DOUBLE' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_1= '-11.49' ;
|
||||
set @type_1= 'DOUBLE' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_1= '-10.51' ;
|
||||
set @type_1= 'DOUBLE' ;
|
||||
--source include/patchwork-check.inc
|
||||
## Incomplete statement
|
||||
set @stmt_part_2= 'select ROUND() as my_col' ;
|
||||
set @max_var_number= 0;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
##### CONCAT_WS(separator,str1,str2,...)
|
||||
# Example: CONCAT_WS('S','My','QL')
|
||||
--disable_query_log
|
||||
select concat('###### Variations on CONCAT_WS(separator,str1,str2,...) ######')
|
||||
as '' union select '';
|
||||
--enable_query_log
|
||||
set @stmt_part_1= 'select CONCAT_WS(' ;
|
||||
set @stmt_part_2= ',' ;
|
||||
set @stmt_part_3= ',' ;
|
||||
set @stmt_part_4= ') as my_col' ;
|
||||
set @max_var_number= 3;
|
||||
|
||||
### common case
|
||||
set @string_1= 'S' ;
|
||||
set @type_1= 'LONGTEXT' ;
|
||||
set @string_2= 'My' ;
|
||||
set @type_2= 'LONGTEXT' ;
|
||||
set @string_3= 'QL' ;
|
||||
set @type_3= 'LONGTEXT' ;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
#------------------------------------------------------------------
|
||||
# NULL at different parameter positions
|
||||
#------------------------------------------------------------------
|
||||
### The separator (first parameter) is NULL.
|
||||
set @string_1= 'NULL' ;
|
||||
set @type_1= 'LONGBLOB' ;
|
||||
set @string_2= 'My' ;
|
||||
set @type_2= 'LONGTEXT' ;
|
||||
set @string_3= 'QL' ;
|
||||
set @type_3= 'LONGTEXT' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @type_1= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @type_1= 'DOUBLE' ;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
### The first string (second parameter) is NULL.
|
||||
set @string_1= 'S' ;
|
||||
set @type_1= 'LONGTEXT' ;
|
||||
set @string_2= 'NULL' ;
|
||||
set @type_2= 'LONGBLOB' ;
|
||||
set @string_3= 'QL' ;
|
||||
set @type_3= 'LONGTEXT' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @type_2= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @type_2= 'DOUBLE' ;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
### The second string (third parameter) is NULL.
|
||||
set @string_1= 'S' ;
|
||||
set @type_1= 'LONGTEXT' ;
|
||||
set @string_2= 'My' ;
|
||||
set @type_2= 'LONGTEXT' ;
|
||||
set @string_3= 'NULL' ;
|
||||
set @type_3= 'LONGTEXT' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @type_3= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @type_3= 'DOUBLE' ;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
#------------------------------------------------------------------
|
||||
# some complicated things
|
||||
#------------------------------------------------------------------
|
||||
# select concat_ws('S',IF(parameter1=NULL,parameter2,parameter3),'QL')
|
||||
set @stmt_part_1= "select CONCAT_WS('S',IF(" ;
|
||||
set @stmt_part_2= ' IS NULL, ' ;
|
||||
set @stmt_part_3= ' , ' ;
|
||||
set @stmt_part_4= "),'QL') as my_col" ;
|
||||
set @max_var_number= 3;
|
||||
|
||||
# common case
|
||||
set @string_1= 'My' ;
|
||||
set @type_1= 'LONGTEXT' ;
|
||||
set @string_2= 'X' ;
|
||||
set @type_2= 'LONGTEXT' ;
|
||||
set @string_3= 'My' ;
|
||||
set @type_3= 'LONGTEXT' ;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
set @string_1= 'NULL' ;
|
||||
set @type_1= 'LONGBLOB' ;
|
||||
set @string_2= 'X' ;
|
||||
set @type_2= 'LONGTEXT' ;
|
||||
set @string_3= 'My' ;
|
||||
set @type_3= 'LONGTEXT' ;
|
||||
# deactivated because of
|
||||
# Bug#6297 : prepared statement, wrong handling of <parameter> IS NULL
|
||||
# let $__debug_= 1;
|
||||
# --source include/patchwork-check.inc
|
||||
|
||||
##### CHAR(N,...)
|
||||
# Example(Manual): SELECT CHAR(77,121,83,81,'76');
|
||||
--disable_query_log
|
||||
select concat('###### Variations on CHAR(N,...) ######') as ''
|
||||
union select '';
|
||||
--enable_query_log
|
||||
set @stmt_part_1= 'select CHAR(' ;
|
||||
set @stmt_part_2= ',' ;
|
||||
set @stmt_part_3= ',' ;
|
||||
set @stmt_part_4= ',' ;
|
||||
set @stmt_part_5= ',' ;
|
||||
set @stmt_part_6= ') as my_col' ;
|
||||
set @max_var_number= 5;
|
||||
|
||||
### common case
|
||||
set @string_1= '77' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
set @string_2= '121' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= '83' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
set @string_4= '81' ;
|
||||
set @type_4= 'BIGINT' ;
|
||||
set @string_5= '76' ;
|
||||
set @type_5= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
#------------------------------------------------------------------
|
||||
# NULL at different parameter positions
|
||||
#------------------------------------------------------------------
|
||||
# Only the first parameter is NULL.
|
||||
set @string_1= 'NULL' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
##### ugly maybe wrong result
|
||||
# Bug#6317: string function CHAR, parameter is NULL, wrong result
|
||||
#--source include/patchwork-check.inc
|
||||
|
||||
## Only one non first/last parameter is NULL.
|
||||
set @string_1= '77' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
set @string_2= '121' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= 'NULL' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
set @string_4= '81' ;
|
||||
set @type_4= 'BIGINT' ;
|
||||
set @string_5= '76' ;
|
||||
set @type_5= 'BIGINT' ;
|
||||
# Bug#6317: string function CHAR, parameter is NULL, wrong result
|
||||
#--source include/patchwork-check.inc
|
||||
|
||||
## Two neighbour parameters in the middle are NULL.
|
||||
set @string_1= '77' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
set @string_2= '121' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= 'NULL' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
set @string_4= 'NULL' ;
|
||||
set @type_4= 'BIGINT' ;
|
||||
set @string_5= '76' ;
|
||||
set @type_5= 'BIGINT' ;
|
||||
# Bug#6317: string function CHAR, parameter is NULL, wrong result
|
||||
#--source include/patchwork-check.inc
|
||||
|
||||
## Only the last parameter is NULL.
|
||||
set @string_1= '77' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
set @string_2= '121' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= '83' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
set @string_4= '81' ;
|
||||
set @type_4= 'BIGINT' ;
|
||||
set @string_5= 'NULL' ;
|
||||
set @type_5= 'BIGINT' ;
|
||||
# Bug#6317: string function CHAR, parameter is NULL, wrong result
|
||||
#--source include/patchwork-check.inc
|
||||
|
||||
## The first parameter is NULL with bad type.
|
||||
set @string_1= 'NULL' ;
|
||||
set @type_1= 'LONGBLOB' ;
|
||||
set @string_2= '121' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= '83' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
set @string_4= '81' ;
|
||||
set @type_4= 'BIGINT' ;
|
||||
set @string_5= '76' ;
|
||||
set @type_5= 'BIGINT' ;
|
||||
# Bug#6317: string function CHAR, parameter is NULL, wrong result
|
||||
#--source include/patchwork-check.inc
|
||||
|
||||
|
||||
##### CHAR_LENGTH(str)
|
||||
--disable_query_log
|
||||
select concat('###### Variations on CHAR_LENGTH ######') as ''
|
||||
union select '';
|
||||
--enable_query_log
|
||||
set @stmt_part_1= 'select CHAR_LENGTH(' ;
|
||||
set @stmt_part_2= ') as my_col' ;
|
||||
set @max_var_number= 1;
|
||||
|
||||
### common case
|
||||
set @string_1= 'MySQL' ;
|
||||
set @type_1= 'LONGTEXT' ;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
#------------------------------------------------------------------
|
||||
# NULL at different parameter positions
|
||||
#------------------------------------------------------------------
|
||||
set @string_1= 'NULL' ;
|
||||
set @type_1= 'LONGTEXT' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @type_1= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @type_1= 'DOUBLE' ;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
|
||||
##### FIELD(str,str1,str2,str3,...)
|
||||
--disable_query_log
|
||||
select concat('###### Variations on FIELD(str,str1,str2,str3,...) ######') as ''
|
||||
union select '';
|
||||
--enable_query_log
|
||||
set @stmt_part_1= 'select FIELD(' ;
|
||||
set @stmt_part_2= ',' ;
|
||||
set @stmt_part_3= ',' ;
|
||||
set @stmt_part_4= ',' ;
|
||||
set @stmt_part_5= ') as my_col' ;
|
||||
set @max_var_number= 4;
|
||||
|
||||
### common case
|
||||
set @string_1= 'Hit' ;
|
||||
set @type_1= 'LONGTEXT' ;
|
||||
set @string_2= '1it' ;
|
||||
set @type_2= 'LONGTEXT' ;
|
||||
set @string_3= 'Hit' ;
|
||||
set @type_3= 'LONGTEXT' ;
|
||||
set @string_4= '3it' ;
|
||||
set @type_4= 'LONGTEXT' ;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
#------------------------------------------------------------------
|
||||
# NULL at different parameter positions
|
||||
#------------------------------------------------------------------
|
||||
# string to search for is NULL, all other strings not NULL
|
||||
set @string_1= 'NULL' ;
|
||||
# Bug#6321: strange error, string function FIELD(<uservariable content NULL>, ..
|
||||
--source include/patchwork-check.inc
|
||||
# string to search for and one of the other is NULL
|
||||
set @string_3= 'NULL' ;
|
||||
# Bug#6321: strange error, string function FIELD(<uservariable content NULL>, ..
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
|
||||
##### INSERT(str,pos,len,newstr)
|
||||
# Manual Example: SELECT INSERT('Quadratic', 3, 4, 'What') -> 'QuWhattic'
|
||||
--disable_query_log
|
||||
select concat('###### Variations on INSERT(str,pos,len,newstr) ######') as ''
|
||||
union select '';
|
||||
--enable_query_log
|
||||
set @stmt_part_1= "select INSERT(" ;
|
||||
set @stmt_part_2= ',' ;
|
||||
set @stmt_part_3= ',' ;
|
||||
set @stmt_part_4= ',' ;
|
||||
set @stmt_part_5= ") as my_col" ;
|
||||
set @max_var_number= 4;
|
||||
|
||||
### common case (modified manual example)
|
||||
set @string_1= 'ABCDEFGHI' ;
|
||||
set @type_1= 'LONGTEXT' ;
|
||||
set @string_2= '3' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= '4' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
set @string_4= '1234' ;
|
||||
set @type_4= 'LONGTEXT' ;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
#------------------------------------------------------------------
|
||||
# Try DOUBLE instead of BIGINT for pos and len
|
||||
#------------------------------------------------------------------
|
||||
set @string_2= '+30.0E-1' ;
|
||||
set @type_2= 'DOUBLE' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_2= '3' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= '+40.0E-1' ;
|
||||
set @type_3= 'DOUBLE' ;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
#------------------------------------------------------------------
|
||||
# NULL at different parameter positions
|
||||
#------------------------------------------------------------------
|
||||
set @string_1= 'NULL' ;
|
||||
set @type_1= 'LONGTEXT' ;
|
||||
set @string_2= '3' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= '4' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
set @string_4= '1234' ;
|
||||
set @type_4= 'LONGTEXT' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_1= 'ABCDEFGHI' ;
|
||||
set @type_1= 'LONGTEXT' ;
|
||||
set @string_2= 'NULL' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_2= '3' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= 'NULL' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_3= '4' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
set @string_4= 'NULL' ;
|
||||
set @type_4= 'LONGTEXT' ;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
#------------------------------------------------------------------
|
||||
# Variations on the second parameter (start position)
|
||||
#------------------------------------------------------------------
|
||||
set @string_1= 'ABCDEFGHI' ;
|
||||
set @type_1= 'LONGTEXT' ;
|
||||
set @string_2= '3' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= '4' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
set @string_4= '1234' ;
|
||||
set @type_4= 'LONGTEXT' ;
|
||||
# start position > length of the first string (9)
|
||||
set @string_2= '15' ;
|
||||
--source include/patchwork-check.inc
|
||||
# start position = 0
|
||||
set @string_2= '0' ;
|
||||
--source include/patchwork-check.inc
|
||||
# start position < 0
|
||||
set @string_2= '-1' ;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
#------------------------------------------------------------------
|
||||
# Variations on the third parameter (# of chars of string one to be replaced)
|
||||
#------------------------------------------------------------------
|
||||
set @string_1= 'ABCDEFGHI' ;
|
||||
set @type_1= 'LONGTEXT' ;
|
||||
set @string_2= '3' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= '4' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
set @string_4= '1234' ;
|
||||
set @type_4= 'LONGTEXT' ;
|
||||
## chars to be replaced > length of the second string
|
||||
# start pos (3) + replace length(10) > length of first string(9)
|
||||
set @string_3= '10' ;
|
||||
--source include/patchwork-check.inc
|
||||
# start pos (3) + chars to be replaced (5) < length of first string(9)
|
||||
set @string_3= '5' ;
|
||||
--source include/patchwork-check.inc
|
||||
# chars to be replaced = 0
|
||||
set @string_3= '0' ;
|
||||
--source include/patchwork-check.inc
|
||||
# chars to be replaced < 0
|
||||
set @string_3= '-1' ;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
|
||||
##### BIN(N)
|
||||
# manual example: SELECT BIN(12); -> '1100'
|
||||
--disable_query_log
|
||||
select concat('###### Variations on BIN(N) ######') as ''
|
||||
union select '';
|
||||
--enable_query_log
|
||||
set @stmt_part_1= "select BIN(" ;
|
||||
set @stmt_part_2= ") as my_col" ;
|
||||
set @max_var_number= 1;
|
||||
|
||||
set @string_1= '12' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
#### Variations on the parameter
|
||||
set @string_1= 'NULL' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_1= '2147483648' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_1= '0' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_1= '-1' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_1= '9000000000000000000' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_1= '12.9E-0' ;
|
||||
set @type_1= 'DOUBLE' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_1= '0.129E+2' ;
|
||||
set @type_1= 'DOUBLE' ;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
##### BIT_LENGTH(str)
|
||||
# Manual example: SELECT BIT_LENGTH('text'); -> 32
|
||||
--disable_query_log
|
||||
select concat('###### Variations on BIT_LENGT(str) ######') as ''
|
||||
union select '';
|
||||
--enable_query_log
|
||||
set @stmt_part_1= "select BIT_LENGTH(" ;
|
||||
set @stmt_part_2= ") as my_col" ;
|
||||
set @max_var_number= 1;
|
||||
|
||||
set @string_1= 'text' ;
|
||||
set @type_1= 'LONGTEXT' ;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
# try NULL
|
||||
set @string_1= 'NULL' ;
|
||||
set @type_1= 'LONGTEXT' ;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
|
||||
##### CONV(N,from_base,to_base)
|
||||
# Manual example: SELECT CONV(-17,10,-18); -> '-H'
|
||||
--disable_query_log
|
||||
select concat('###### Variations on CONV(N,from_base,to_base) ######') as ''
|
||||
union select '';
|
||||
--enable_query_log
|
||||
set @stmt_part_1= "select CONV(" ;
|
||||
set @stmt_part_2= "," ;
|
||||
set @stmt_part_3= "," ;
|
||||
set @stmt_part_4= ") as my_col" ;
|
||||
set @max_var_number= 3;
|
||||
|
||||
#------------------------------------------------------------------
|
||||
# Manual: If to_base is a negative number, N is regarded as a signed number.
|
||||
# Otherwise, N is treated as unsigned.
|
||||
# Experiments with positive/negative number/to_base
|
||||
#------------------------------------------------------------------
|
||||
# number positive written, to_base positive
|
||||
set @string_1= '37' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
set @string_2= '10' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= '10' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
# number negative written, to_base positive
|
||||
set @string_1= '-37' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
set @string_2= '10' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= '10' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
# The last result (unsigned) BIGINT 18446744073709551579 might be surprising.
|
||||
# The next statements could give an explanation.
|
||||
set @string_1= CAST(CAST(-37 AS unsigned INTEGER) AS CHAR);
|
||||
set @type_1= 'LONGTEXT' ;
|
||||
set @string_2= '10' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= '10' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
# number positive written, to_base negative
|
||||
set @string_1= '37' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
set @string_2= '10' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= '-10' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
# number negative written, to_base negative
|
||||
set @string_1= '-37' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
set @string_2= '10' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= '-10' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
#------------------------------------------------------------------
|
||||
# conversions to and from the exotic 11 based number system
|
||||
#------------------------------------------------------------------
|
||||
set @string_1= '9' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
set @string_2= '10' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= '11' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_1= '9' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
set @string_2= '11' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= '10' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_1= '10' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
set @string_2= '10' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= '11' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_1= 'A' ;
|
||||
set @type_1= 'LONGTEXT' ;
|
||||
set @string_2= '11' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= '10' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_1= '11' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
set @string_2= '10' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= '11' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_1= '10' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
set @string_2= '11' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= '10' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
#------------------------------------------------------------------
|
||||
# Try the maximum base value 36
|
||||
#------------------------------------------------------------------
|
||||
set @string_1= '37' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
set @string_2= '10' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= '36' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_1= '11' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
set @string_2= '36' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= '10' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
#------------------------------------------------------------------
|
||||
# NULL at different parameter positions
|
||||
#------------------------------------------------------------------
|
||||
set @string_1= 'NULL' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
set @string_2= '10' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= '10' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_1= '37' ;
|
||||
set @string_2= 'NULL' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_2= '10' ;
|
||||
set @string_3= 'NULL' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_3= '10' ;
|
||||
|
||||
#------------------------------------------------------------------
|
||||
# The rule for from_base is: 2 <= from_base <= 36
|
||||
# Try values outside of this range.
|
||||
#------------------------------------------------------------------
|
||||
set @string_1= '9' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
set @string_2= '37' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= '10' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_1= '9' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
set @string_2= '1' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= '10' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_1= '9' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
set @string_2= '0' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= '10' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_1= '9' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
set @string_2= '-1' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= '10' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
#------------------------------------------------------------------
|
||||
# The rule for to_base is: 2<= ABS(to_base) <= 36
|
||||
# Try values outside of this range.
|
||||
#------------------------------------------------------------------
|
||||
set @string_1= '9' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
set @string_2= '10' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= '37' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_1= '9' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
set @string_2= '10' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= '1' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_1= '9' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
set @string_2= '0' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= '0' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_1= '9' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
set @string_2= '10' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= '-1' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
set @string_1= '9' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
set @string_2= '10' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= '-37' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
|
105
mysql-test/t/tool_test.test
Normal file
105
mysql-test/t/tool_test.test
Normal file
|
@ -0,0 +1,105 @@
|
|||
########################### tool_test.test #############################
|
||||
# #
|
||||
# Test sequences for the check of mysqltest based test tools #
|
||||
# #
|
||||
# Checked routines: #
|
||||
# include/patchwork-check.inc #
|
||||
# #
|
||||
########################################################################
|
||||
|
||||
##### Check of include/patchwork-check.inc
|
||||
#
|
||||
use test ;
|
||||
--disable_abort_on_error
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Simple test (special case):
|
||||
# The statement is made of only one piece and does not contain variables.
|
||||
#-----------------------------------------------------------------------
|
||||
set @stmt_part_1= 'SELECT 1 as "my_fine_statement"' ;
|
||||
set @max_var_number= 0;
|
||||
# switch debug output on (Attention: patchwork-check.inc will switch it off)
|
||||
let $__debug_= 1;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Test case with many statement pieces and variables of all in
|
||||
# include/patchwork-check.inc available data types.
|
||||
#-----------------------------------------------------------------------
|
||||
set @stmt_part_1= 'SELECT ' ;
|
||||
set @stmt_part_2= ' + ' ;
|
||||
set @stmt_part_3= ' + ' ;
|
||||
set @stmt_part_4= ' + ' ;
|
||||
set @stmt_part_5= ' + ' ;
|
||||
set @stmt_part_6= ' + ' ;
|
||||
set @stmt_part_7= ' + ' ;
|
||||
set @stmt_part_8= ' + ' ;
|
||||
set @stmt_part_9= ' as "my_fine_statement"' ;
|
||||
set @max_var_number= 8;
|
||||
|
||||
set @string_1= '1' ;
|
||||
set @type_1= 'BIGINT' ;
|
||||
set @string_2= 'nULL' ;
|
||||
set @type_2= 'BIGINT' ;
|
||||
set @string_3= '2.0' ;
|
||||
set @type_3= 'DOUBLE' ;
|
||||
set @string_4= 'NuLL' ;
|
||||
set @type_4= 'DOUBLE' ;
|
||||
set @string_5= 'TEXT' ;
|
||||
set @type_5= 'LONGTEXT' ;
|
||||
set @string_6= 'NUlL' ;
|
||||
set @type_6= 'LONGTEXT' ;
|
||||
set @string_7= 'BLOB' ;
|
||||
set @type_7= 'LONGBLOB' ;
|
||||
set @string_8= 'NULl' ;
|
||||
set @type_8= 'LONGBLOB' ;
|
||||
|
||||
# Initialization of all uservariables to the data type LONGTEXT and content,
|
||||
# which will not be repeated within the following tests.
|
||||
# 'include/patchwork-check.inc' MUST destroy all these settings.
|
||||
# That is why this initialization is NOT needed within test cases
|
||||
# calling include/patchwork-check.inc .
|
||||
set @var_1= 'YYYYYYYY' ;
|
||||
set @var_2= 'YYYYYYYY' ;
|
||||
set @var_3= 'YYYYYYYY' ;
|
||||
set @var_4= 'YYYYYYYY' ;
|
||||
set @var_5= 'YYYYYYYY' ;
|
||||
set @var_6= 'YYYYYYYY' ;
|
||||
set @var_7= 'YYYYYYYY' ;
|
||||
set @var_8= 'YYYYYYYY' ;
|
||||
|
||||
# switch debug output on (Attention: patchwork-check.inc will switch it off)
|
||||
let $__debug_= 1;
|
||||
--source include/patchwork-check.inc
|
||||
|
||||
### Execute the statement with more useful content of the variables.
|
||||
set @string_1= '1.0' ;
|
||||
set @type_1= 'DOUBLE' ;
|
||||
set @string_2= '3.0' ;
|
||||
set @type_2= 'DOUBLE' ;
|
||||
set @string_3= '2' ;
|
||||
set @type_3= 'BIGINT' ;
|
||||
set @string_4= '4' ;
|
||||
set @type_4= 'BIGINT' ;
|
||||
set @string_5= '5' ;
|
||||
set @type_5= 'BIGINT' ;
|
||||
set @string_6= '6' ;
|
||||
set @type_6= 'DOUBLE' ;
|
||||
set @string_7= '7' ;
|
||||
set @type_7= 'DOUBLE' ;
|
||||
set @string_8= '8' ;
|
||||
set @type_8= 'DOUBLE' ;
|
||||
|
||||
# Initialization
|
||||
set @var_1= 'YYYYYYYY' ;
|
||||
set @var_2= 'YYYYYYYY' ;
|
||||
set @var_3= 'YYYYYYYY' ;
|
||||
set @var_4= 'YYYYYYYY' ;
|
||||
set @var_5= 'YYYYYYYY' ;
|
||||
set @var_6= 'YYYYYYYY' ;
|
||||
set @var_7= 'YYYYYYYY' ;
|
||||
set @var_8= 'YYYYYYYY' ;
|
||||
|
||||
# switch debug output on (Attention: include/patchwork-check.inc switches it off)
|
||||
let $__debug_= 1;
|
||||
--source include/patchwork-check.inc
|
Loading…
Reference in a new issue