diff options
Diffstat (limited to 'mysql-test/suite/funcs_1/storedproc')
-rw-r--r-- | mysql-test/suite/funcs_1/storedproc/cleanup_sp_tb.inc | 5 | ||||
-rw-r--r-- | mysql-test/suite/funcs_1/storedproc/load_sp_tb.inc | 121 | ||||
-rw-r--r-- | mysql-test/suite/funcs_1/storedproc/storedproc_02.inc | 348 | ||||
-rw-r--r-- | mysql-test/suite/funcs_1/storedproc/storedproc_03.inc | 86 | ||||
-rw-r--r-- | mysql-test/suite/funcs_1/storedproc/storedproc_06.inc | 69 | ||||
-rw-r--r-- | mysql-test/suite/funcs_1/storedproc/storedproc_10.inc | 109 |
6 files changed, 495 insertions, 243 deletions
diff --git a/mysql-test/suite/funcs_1/storedproc/cleanup_sp_tb.inc b/mysql-test/suite/funcs_1/storedproc/cleanup_sp_tb.inc index 493c4373d20..bd41f2dcb16 100644 --- a/mysql-test/suite/funcs_1/storedproc/cleanup_sp_tb.inc +++ b/mysql-test/suite/funcs_1/storedproc/cleanup_sp_tb.inc @@ -1,5 +1,6 @@ -let $message= --source suite/funcs_1/storedproc/cleanup_sp_tb.inc; ---source include/show_msg80.inc +--echo +--echo --source suite/funcs_1/storedproc/cleanup_sp_tb.inc +--echo -------------------------------------------------------------------------------- # called both to cleanup possibly existing data before and after the SP tests diff --git a/mysql-test/suite/funcs_1/storedproc/load_sp_tb.inc b/mysql-test/suite/funcs_1/storedproc/load_sp_tb.inc index b7f7b2cae02..5224860925c 100644 --- a/mysql-test/suite/funcs_1/storedproc/load_sp_tb.inc +++ b/mysql-test/suite/funcs_1/storedproc/load_sp_tb.inc @@ -1,11 +1,12 @@ -let $message= --source suite/funcs_1/storedproc/load_sp_tb.inc; ---source include/show_msg80.inc +--echo +--echo --source suite/funcs_1/storedproc/load_sp_tb.inc +--echo -------------------------------------------------------------------------------- # ============================================================================== # -# this load script can be called multiple times inside a test script because it +# This load script can be called multiple times inside a test script because it # first cleans up all objects that will be created. -# therefore the same script is used as it will be used at the end of a test. +# Therefore the same script is used as it will be used at the end of a test. # # ============================================================================== @@ -20,46 +21,84 @@ CREATE DATABASE db_storedproc_1; USE db_storedproc; -eval create table t1(f1 char(20),f2 char(25),f3 date,f4 int,f5 char(25),f6 int) engine = $engine_type; ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR -eval load data infile '$MYSQL_TEST_DIR/suite/funcs_1/data/t4.txt' into table t1; - -eval create table t2(f1 char(20),f2 char(25),f3 date,f4 int,f5 char(25),f6 int) engine = $engine_type; ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR -eval load data infile '$MYSQL_TEST_DIR/suite/funcs_1/data/t4.txt' into table t2; - -eval create table t3(f1 char(20),f2 char(20),f3 integer) engine = $engine_type; ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR -eval load data infile '$MYSQL_TEST_DIR/suite/funcs_1/data/t3.txt' into table t3; - -eval create table t4(f1 char(20),f2 char(25),f3 date,f4 int,f5 char(25),f6 int) engine = $engine_type; ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR -eval load data infile '$MYSQL_TEST_DIR/suite/funcs_1/data/t4.txt' into table t4; +--replace_result $engine_type <engine_to_be_tested> +eval +create table t1(f1 char(20),f2 char(25),f3 date,f4 int,f5 char(25),f6 int) +engine = $engine_type; +--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR> +eval +load data infile '$MYSQLTEST_VARDIR/std_data_ln/funcs_1/t4.txt' into table t1; + +--replace_result $engine_type <engine_to_be_tested> +eval +create table t2(f1 char(20),f2 char(25),f3 date,f4 int,f5 char(25),f6 int) +engine = $engine_type; +--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR> +eval +load data infile '$MYSQLTEST_VARDIR/std_data_ln/funcs_1/t4.txt' into table t2; + +--replace_result $engine_type <engine_to_be_tested> +eval +create table t3(f1 char(20),f2 char(20),f3 integer) engine = $engine_type; +--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR> +eval +load data infile '$MYSQLTEST_VARDIR/std_data_ln/funcs_1/t3.txt' into table t3; + +--replace_result $engine_type <engine_to_be_tested> +eval +create table t4(f1 char(20),f2 char(25),f3 date,f4 int,f5 char(25),f6 int) +engine = $engine_type; +--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR> +eval +load data infile '$MYSQLTEST_VARDIR/std_data_ln/funcs_1/t4.txt' into table t4; USE db_storedproc_1; -eval create table t6(f1 char(20),f2 char(25),f3 date,f4 int,f5 char(25),f6 int) engine = $engine_type; ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR -eval load data infile '$MYSQL_TEST_DIR/suite/funcs_1/data/t4.txt' into table t6; +--replace_result $engine_type <engine_to_be_tested> +eval +create table t6(f1 char(20),f2 char(25),f3 date,f4 int,f5 char(25),f6 int) +engine = $engine_type; +--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR> +eval +load data infile '$MYSQLTEST_VARDIR/std_data_ln/funcs_1/t4.txt' into table t6; USE db_storedproc; -eval create table t7 (f1 char(20), f2 char(25), f3 date, f4 int) engine = $engine_type; ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR -eval load data infile '$MYSQL_TEST_DIR/suite/funcs_1/data/t7.txt' into table t7; - -eval create table t8 (f1 char(20), f2 char(25), f3 date, f4 int) engine = $engine_type; ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR -eval load data infile '$MYSQL_TEST_DIR/suite/funcs_1/data/t7.txt' into table t8; - -eval create table t9(f1 int, f2 char(25), f3 int) engine = $engine_type; ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR -eval load data infile '$MYSQL_TEST_DIR/suite/funcs_1/data/t9.txt' into table t9; - -eval create table t10(f1 char(20),f2 char(25),f3 date,f4 int,f5 char(25),f6 int) engine = $engine_type; ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR -eval load data infile '$MYSQL_TEST_DIR/suite/funcs_1/data/t4.txt' into table t10; - -eval create table t11(f1 char(20),f2 char(25),f3 date,f4 int,f5 char(25),f6 int) engine = $engine_type; ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR -eval load data infile '$MYSQL_TEST_DIR/suite/funcs_1/data/t4.txt' into table t11; +--replace_result $engine_type <engine_to_be_tested> +eval +create table t7 (f1 char(20), f2 char(25), f3 date, f4 int) +engine = $engine_type; +--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR> +eval +load data infile '$MYSQLTEST_VARDIR/std_data_ln/funcs_1/t7.txt' into table t7; + +--replace_result $engine_type <engine_to_be_tested> +eval +create table t8 (f1 char(20), f2 char(25), f3 date, f4 int) +engine = $engine_type; +--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR> +eval +load data infile '$MYSQLTEST_VARDIR/std_data_ln/funcs_1/t7.txt' into table t8; + +--replace_result $engine_type <engine_to_be_tested> +eval +create table t9(f1 int, f2 char(25), f3 int) engine = $engine_type; +--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR> +eval +load data infile '$MYSQLTEST_VARDIR/std_data_ln/funcs_1/t9.txt' into table t9; + +--replace_result $engine_type <engine_to_be_tested> +eval +create table t10(f1 char(20),f2 char(25),f3 date,f4 int,f5 char(25),f6 int) +engine = $engine_type; +--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR> +eval +load data infile '$MYSQLTEST_VARDIR/std_data_ln/funcs_1/t4.txt' into table t10; + +--replace_result $engine_type <engine_to_be_tested> +eval +create table t11(f1 char(20),f2 char(25),f3 date,f4 int,f5 char(25),f6 int) +engine = $engine_type; +--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR> +eval +load data infile '$MYSQLTEST_VARDIR/std_data_ln/funcs_1/t4.txt' into table t11; diff --git a/mysql-test/suite/funcs_1/storedproc/storedproc_02.inc b/mysql-test/suite/funcs_1/storedproc/storedproc_02.inc index a8d52fee0b5..0f62a559985 100644 --- a/mysql-test/suite/funcs_1/storedproc/storedproc_02.inc +++ b/mysql-test/suite/funcs_1/storedproc/storedproc_02.inc @@ -5,85 +5,192 @@ # ============================================================================== # (numbering from requirement document TP v1.0, Last updated: 25 Jan 2005 01:00) # -# 3.1.2 Syntax checks for the stored procedure-specific programming statements BEGIN/END, DECLARE, SET, SELECT/INTO, OPEN, FETCH, CLOSE: +# 3.1.2 Syntax checks for the stored procedure-specific programming statements +# BEGIN/END, DECLARE, SET, SELECT/INTO, OPEN, FETCH, CLOSE: # #- 1. Ensure that all subclauses that should be supported are supported. -#- 2. Ensure that all subclauses that should not be supported are disallowed with an appropriate error message. -#- 3. Ensure that all supported subclauses are supported only in the correct order. -#- 4. Ensure that an appropriate error message is returned if a subclause is out-of-order in a stored procedure definition. -#- 5. Ensure that all subclauses that are defined to be mandatory are indeed required to be mandatory by the MySQL server and tools. -#- 6. Ensure that any subclauses that are defined to be optional are indeed treated as optional by the MySQL server and tools. -#- 7. Ensure that every BEGIN statement is coupled with a terminating END statement. -## 8. Ensure that the scope of each BEGIN/END compound statement within a stored procedure definition is properly applied. -#- 9. Ensure that the labels enclosing each BEGIN/END compound statement must match. -#- 10. Ensure that it is possible to put a beginning label at the start of a BEGIN/END compound statement without also requiring an ending label at the end of the same statement. -#- 11. Ensure that it is not possible to put an ending label at the end of a BEGIN/END compound statement without also requiring a matching beginning label at the start of the same statement. +#- 2. Ensure that all subclauses that should not be supported are disallowed +# with an appropriate error message. +#- 3. Ensure that all supported subclauses are supported only in the +# correct order. +#- 4. Ensure that an appropriate error message is returned if a subclause is +# out-of-order in a stored procedure definition. +#- 5. Ensure that all subclauses that are defined to be mandatory are indeed +# required to be mandatory by the MySQL server and tools. +#- 6. Ensure that any subclauses that are defined to be optional are indeed +# treated as optional by the MySQL server and tools. +#- 7. Ensure that every BEGIN statement is coupled with a terminating +# END statement. +## 8. Ensure that the scope of each BEGIN/END compound statement within a +# stored procedure definition is properly applied. +#- 9. Ensure that the labels enclosing each BEGIN/END compound statement +# must match. +#- 10. Ensure that it is possible to put a beginning label at the start of +# a BEGIN/END compound statement without also requiring an ending label +# at the end of the same statement. +#- 11. Ensure that it is not possible to put an ending label at the end of +# a BEGIN/END compound statement without also requiring a matching +# beginning label at the start of the same statement. #- 12. Ensure that every beginning label must end with a colon (:). #- 13. Ensure that every beginning label with the same scope must be unique. -#- 14. Ensure that the variables, cursors, conditions, and handlers declared for a stored procedure (with the DECLARE statement) may only be properly defined. -#- 15. Ensure that the variables, cursors, conditions, and handlers declared for a stored procedure (with the DECLARE statement) may only be defined in the correct order. -#- 16. Ensure that every possible type of variable -- utilizing every data type definition supported by the MySQL server in combination with both no DEFAULT subclause and with DEFAULT subclauses that set the variable’s default value to a range of appropriate values -- may be declared for a stored procedure. -#- 17. Ensure that the DECLARE statement can declare multiple variables both separately and all at once from a variable list. -#- 18. Ensure that invalid variable declarations are rejected, with an appropriate error message. -#- 19. Ensure that every possible type of cursor may be declared for a stored procedure. -#- 20. Ensure that invalid cursor declarations are rejected, with an appropriate error message. -#- 21. Ensure that every possible type of condition may be declared for a stored procedure. -# -22. Ensure that invalid condition declarations are rejected, with an appropriate error message. -#- 23. Ensure that every possible type of handler may be declared for a stored procedure. -#- 24. Ensure that invalid handler declarations are rejected, with an appropriate error message. -#- 25. Ensure that the scope of every variable, cursor, condition, and handler declared for a stored procedure (with the DECLARE statement) is properly applied. -## 26. Ensure that the initial value of every variable declared for a stored procedure is either NULL or its DEFAULT value, as appropriate. -#- 27. Ensure that the SET statement can assign a value to every local variable declared within a stored procedure’s definition, as well as to every appropriate global server variable. -#- 28. Ensure that the SET statement can assign values to variables either separately or to multiple variables in a list. -#- 29. Ensure that the SET statement may assign only those values to a variable that are appropriate for that variable’s data type definition. -## 30. Ensure that, when a stored procedure is called/executed, every variable always uses the correct value: either the value with which it is initialized or the value to which it is subsequently SET or otherwise assigned, as appropriate. -## 31. Ensure that the SELECT ... INTO statement properly assigns values to the variables in its variable list. -## 32. Ensure that a SELECT ... INTO statement that retrieves multiple rows is rejected, with an appropriate error message. -## 33. Ensure that a SELECT ... INTO statement that retrieves too many columns for the number of variables in its variable list is rejected, with an appropriate error message. -## 34. Ensure that a SELECT ... INTO statement that retrieves too few columns for the number of variables in its variable list is rejected, with an appropriate error message. -#- 35. Ensure that a SELECT ... INTO statement that retrieves column values with inappropriate data types for the matching variables in its variable list is rejected, with an appropriate error message. -#- 36. Ensure that the DECLARE ... CONDITION FOR statement can declare a properly-named condition for every possible SQLSTATE and MySQL-specific error code. -#- 37. Ensure that no two conditions declared with the same scope may have the same condition name. +#- 14. Ensure that the variables, cursors, conditions, and handlers declared +# for a stored procedure (with the DECLARE statement) may only be +# properly defined. +#- 15. Ensure that the variables, cursors, conditions, and handlers declared for +# a stored procedure (with the DECLARE statement) may only be defined in +# the correct order. +#- 16. Ensure that every possible type of variable -- utilizing every data type +# definition supported by the MySQL server in combination with both no +# DEFAULT subclause and with DEFAULT subclauses that set the variableÂ’s +# default value to a range of appropriate values -- may be declared for +# a stored procedure. +#- 17. Ensure that the DECLARE statement can declare multiple variables both +# separately and all at once from a variable list. +#- 18. Ensure that invalid variable declarations are rejected, with an +# appropriate error message. +#- 19. Ensure that every possible type of cursor may be declared for a +# stored procedure. +#- 20. Ensure that invalid cursor declarations are rejected, with an appropriate +# error message. +#- 21. Ensure that every possible type of condition may be declared for +# a stored procedure. +# -22. Ensure that invalid condition declarations are rejected, with an +# appropriate error message. +#- 23. Ensure that every possible type of handler may be declared for a +# stored procedure. +#- 24. Ensure that invalid handler declarations are rejected, with an +# appropriate error message. +#- 25. Ensure that the scope of every variable, cursor, condition, and handler +# declared for a stored procedure (with the DECLARE statement) is +# properly applied. +## 26. Ensure that the initial value of every variable declared for a stored +# procedure is either NULL or its DEFAULT value, as appropriate. +#- 27. Ensure that the SET statement can assign a value to every local variable +# declared within a stored procedureÂ’s definition, as well as to every +# appropriate global server variable. +#- 28. Ensure that the SET statement can assign values to variables either +# separately or to multiple variables in a list. +#- 29. Ensure that the SET statement may assign only those values to a variable +# that are appropriate for that variableÂ’s data type definition. +## 30. Ensure that, when a stored procedure is called/executed, every variable +# always uses the correct value: either the value with which it is +# initialized or the value to which it is subsequently SET or otherwise +# assigned, as appropriate. +## 31. Ensure that the SELECT ... INTO statement properly assigns values to the +# variables in its variable list. +## 32. Ensure that a SELECT ... INTO statement that retrieves multiple rows is +# rejected, with an appropriate error message. +## 33. Ensure that a SELECT ... INTO statement that retrieves too many columns +# for the number of variables in its variable list is rejected, with an +# appropriate error message. +## 34. Ensure that a SELECT ... INTO statement that retrieves too few columns +# for the number of variables in its variable list is rejected, with an +# appropriate error message. +#- 35. Ensure that a SELECT ... INTO statement that retrieves column values +# with inappropriate data types for the matching variables in its variable +# list is rejected, with an appropriate error message. +#- 36. Ensure that the DECLARE ... CONDITION FOR statement can declare a +# properly-named condition for every possible SQLSTATE and MySQL-specific +# error code. +#- 37. Ensure that no two conditions declared with the same scope may have the +# same condition name. ## 38. Ensure that the scope of every condition declared is properly applied. -#- 39. Ensure that every SQLSTATE value declared with a DECLARE ... CONDITION FOR statement is a character string that is 5 characters long. -#- 40. Ensure that the DECLARE ... CONDITION FOR statement cannot declare a condition for an invalid SQLSTATE. -#- 41. Ensure that the DECLARE ... CONDITION FOR statement cannot declare a condition for the “successful completion SQLSTATE: “00000“. -#- 42. Ensure that the DECLARE ... HANDLER FOR statement can declare a CONTINUE, EXIT, and UNDO handler for every condition declared (with a DECLARE ... CONDITION FOR statement), within the scope of the handler, for a stored procedure, as well as for every possible SQLSTATE and MySQL-specific error code, as well as for the predefined conditions SQLWARNING, NOT FOUND, and SQLEXCEPTION. -## 43. Ensure that the DECLARE ... HANDLER FOR statement can not declare any handler for a condition declared outside of the scope of the handler. -## 44. Ensure that the DECLARE ... HANDLER FOR statement cannot declare a handler for any invalid, or undeclared, condition. +#- 39. Ensure that every SQLSTATE value declared with a DECLARE ... CONDITION +# FOR statement is a character string that is 5 characters long. +#- 40. Ensure that the DECLARE ... CONDITION FOR statement cannot declare a +# condition for an invalid SQLSTATE. +#- 41. Ensure that the DECLARE ... CONDITION FOR statement cannot declare a +# condition for the “successful completion SQLSTATE: “00000“. +#- 42. Ensure that the DECLARE ... HANDLER FOR statement can declare a CONTINUE, +# EXIT, and UNDO handler for every condition declared (with a DECLARE ... +# CONDITION FOR statement), within the scope of the handler, for a stored +# procedure, as well as for every possible SQLSTATE and MySQL-specific +# error code, as well as for the predefined conditions SQLWARNING, +# NOT FOUND, and SQLEXCEPTION. +## 43. Ensure that the DECLARE ... HANDLER FOR statement can not declare any +# handler for a condition declared outside of the scope of the handler. +## 44. Ensure that the DECLARE ... HANDLER FOR statement cannot declare a +# handler for any invalid, or undeclared, condition. ## 45. Ensure that the scope of every handler declared is properly applied. -#- 46. Ensure that, within the same scope, no two handlers may be declared for the same condition. -#- 47. Ensure that every SQLSTATE value declared with a DECLARE ... HANDLER FOR statement is a character string that is 5 characters long. -#- 48. Ensure that the DECLARE ... HANDLER FOR statement cannot declare a condition for an invalid SQLSTATE. -#- 49. Ensure that the DECLARE ... HANDLER FOR statement cannot declare a condition for the “successful completion SQLSTATE: “00000“. -## 50. Ensure that a CONTINUE handler allows the execution of the stored procedure to continue once the handler statement has completed its own execution (that is, once the handler action statement has been executed). -## 51. Ensure that an EXIT handler causes the execution of the stored procedure to terminate, within its scope, once the handler action statement has been executed. -## 52. Ensure that an EXIT handler does not cause the execution of the stored procedure to terminate outside of its scope. -#- 53. Ensure that a handler condition of SQLWARNING takes the same action as a handler condition defined with an SQLSTATE that begins with “01“. -## 54. Ensure that a handler with a condition defined with an SQLSTATE that begins with “01“ is always exactly equivalent in action to a handler with an SQLWARNING condition. -#- 55. Ensure that a handler condition of NOT FOUND takes the same action as a handler condition defined with an SQLSTATE that begins with “02“. -## 56. Ensure that a handler with a condition defined with an SQLSTATE that begins with “02“ is always exactly equivalent in action to a handler with a NOT FOUND condition. -#- 57. Ensure that a handler condition of SQLEXCEPTION takes the same action as a handler condition defined with an SQLSTATE that begins with anything other that “01“ or “02“. -## 58. Ensure that a handler with a condition defined with an SQLSTATE that begins with anything other that “01“ or “02“ is always exactly equivalent in action to a handler with an SQLEXCEPTION condition. +#- 46. Ensure that, within the same scope, no two handlers may be declared for +# the same condition. +#- 47. Ensure that every SQLSTATE value declared with a DECLARE ... HANDLER FOR +# statement is a character string that is 5 characters long. +#- 48. Ensure that the DECLARE ... HANDLER FOR statement cannot declare a +# condition for an invalid SQLSTATE. +#- 49. Ensure that the DECLARE ... HANDLER FOR statement cannot declare a +# condition for the “successful completion SQLSTATE: “00000“. +## 50. Ensure that a CONTINUE handler allows the execution of the stored +# procedure to continue once the handler statement has completed its +# own execution (that is, once the handler action statement has been +# executed). +## 51. Ensure that an EXIT handler causes the execution of the stored procedure +# to terminate, within its scope, once the handler action statement has +# been executed. +## 52. Ensure that an EXIT handler does not cause the execution of the stored +# procedure to terminate outside of its scope. +#- 53. Ensure that a handler condition of SQLWARNING takes the same action as +# a handler condition defined with an SQLSTATE that begins with “01“. +## 54. Ensure that a handler with a condition defined with an SQLSTATE that +# begins with “01“ is always exactly equivalent in action to a +# handler with an SQLWARNING condition. +#- 55. Ensure that a handler condition of NOT FOUND takes the same action as a +# handler condition defined with an SQLSTATE that begins with “02“. +## 56. Ensure that a handler with a condition defined with an SQLSTATE that +# begins with “02“ is always exactly equivalent in action to a +# handler with a NOT FOUND condition. +#- 57. Ensure that a handler condition of SQLEXCEPTION takes the same action +# as a handler condition defined with an SQLSTATE that begins with +# anything other that “01“ or “02“. +## 58. Ensure that a handler with a condition defined with an SQLSTATE that +# begins with anything other that “01“ or “02“ is always +# exactly equivalent in action to a handler with an SQLEXCEPTION condition. #- 59. Ensure that no two cursors in a stored procedure can have the same name. -#- 60. Ensure that a cursor declaration may not include a SELECT ... INTO statement. -#- 61. Ensure that a cursor declaration that includes an ORDER BY clause may not be an updatable cursor. -#- 62. Ensure that OPEN <cursor name> fails unless a cursor with the same name has already been declared. -#- 63. Ensure that OPEN <cursor name> fails if the same cursor is currently already open. -#- 64. Ensure that FETCH <cursor name> fails unless a cursor with the same name is already open. -## 65. Ensure that FETCH <cursor name> returns the first row of the cursor’s result set the first time FETCH is executed, that it returns each subsequent row of the cursor’s result set each of the subsequent times FETCH is executed, and that it returns a NOT FOUND warning if it is executed after the last row of the cursor’s result set has already been fetched. -#- 66. Ensure that FETCH <cursor name> fails with an appropriate error message if it is executed before the cursor has been opened. -#- 67. Ensure that FETCH <cursor name> fails with an appropriate error message if it is executed after the cursor has been closed. -## 68. Ensure that FETCH <cursor name> fails with an appropriate error message if the number of columns to be fetched does not match the number of variables specified by the FETCH statement. -#- 69. Ensure that FETCH <cursor name> fails with an appropriate error message if the data type of the column values being fetched are not appropriate for the matching FETCH variables to which the data is being assigned. -#- 70. Ensure that CLOSE <cursor name> fails unless a cursor with the same name is already open. -#- 71. Ensure that all cursors are closed when a transaction terminates with a COMMIT statement. -#- 72. Ensure that all cursors are closed when a transaction terminates with a ROLLBACK statement. -#- 73. Ensure that the result set of a cursor that has been closed is not longer available to the FETCH statement. -#- 74. Ensure that every cursor declared within a compound statement is closed when that compound statement ends. -## 75. Ensure that, for nested compound statements, a cursor that was declared and opened during an outer level of the statement is not closed when an inner level of a compound statement ends. -## 76. Ensure that all cursors operate asensitively, so that there is no concurrency conflict between cursors operating on the same, or similar, sets of results during execution of one or more stored procedures. -# 77. Ensure that multiple cursors, nested within multiple compound statements within a stored procedure, always act correctly and return the expected result. +#- 60. Ensure that a cursor declaration may not include a SELECT ... INTO +# statement. +#- 61. Ensure that a cursor declaration that includes an ORDER BY clause may +# not be an updatable cursor. +#- 62. Ensure that OPEN <cursor name> fails unless a cursor with the same name +# has already been declared. +#- 63. Ensure that OPEN <cursor name> fails if the same cursor is currently +# already open. +#- 64. Ensure that FETCH <cursor name> fails unless a cursor with the same name +# is already open. +## 65. Ensure that FETCH <cursor name> returns the first row of the cursorÂ’s +# result set the first time FETCH is executed, that it returns each +# subsequent row of the cursorÂ’s result set each of the subsequent +# times FETCH is executed, and that it returns a NOT FOUND warning if it +# is executed after the last row of the cursorÂ’s result set has already +# been fetched. +#- 66. Ensure that FETCH <cursor name> fails with an appropriate error message +# if it is executed before the cursor has been opened. +#- 67. Ensure that FETCH <cursor name> fails with an appropriate error message +# if it is executed after the cursor has been closed. +## 68. Ensure that FETCH <cursor name> fails with an appropriate error message +# if the number of columns to be fetched does not match the number of +# variables specified by the FETCH statement. +#- 69. Ensure that FETCH <cursor name> fails with an appropriate error message +# if the data type of the column values being fetched are not appropriate +# for the matching FETCH variables to which the data is being assigned. +#- 70. Ensure that CLOSE <cursor name> fails unless a cursor with the same name +# is already open. +#- 71. Ensure that all cursors are closed when a transaction terminates with +# a COMMIT statement. +#- 72. Ensure that all cursors are closed when a transaction terminates with +# a ROLLBACK statement. +#- 73. Ensure that the result set of a cursor that has been closed is not +# longer available to the FETCH statement. +#- 74. Ensure that every cursor declared within a compound statement is closed +# when that compound statement ends. +## 75. Ensure that, for nested compound statements, a cursor that was declared +# and opened during an outer level of the statement is not closed when an +# inner level of a compound statement ends. +## 76. Ensure that all cursors operate asensitively, so that there is no +# concurrency conflict between cursors operating on the same, or similar, +# sets of results during execution of one or more stored procedures. +# 77. Ensure that multiple cursors, nested within multiple compound statements +# within a stored procedure, always act correctly and return the +# expected result. # # ============================================================================== let $message= Section 3.1.2 - Syntax checks for the stored procedure-specific @@ -209,7 +316,7 @@ BEGIN set @x = x; set @y = y; set @z = 234; - SELECT f1, f2 into @x, @y from t2 limit 1; + SELECT f1, f2 into @x, @y from t2 where f1='a`' and f2='a`' limit 1; SELECT @x, @y, @z, invar; BEGIN set @x = 2; @@ -257,7 +364,7 @@ BEGIN declare x integer; declare y integer; set @x=x; set @y=y; - SELECT f4, f3 into @x, @y from t2 limit 1; + SELECT f4, f3 into @x, @y from t2 where f4=-5000 and f3='1000-01-01' limit 1; SELECT @x, @y; END// delimiter ;// @@ -290,8 +397,9 @@ BEGIN END// delimiter ;// -#Error: 1172 SQLSTATE: 42000 (ER_TOO_MANY_ROWS) Message: Result consisted of more than one row ---error 1172 +# Error: SQLSTATE: 42000 (ER_TOO_MANY_ROWS) +# Message: Result consisted of more than one row +--error ER_TOO_MANY_ROWS CALL sp1(); # cleanup 3.1.2.32 @@ -321,7 +429,7 @@ BEGIN END// delimiter ;// ---error 1222 +--error ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT CALL sp1(); # cleanup 3.1.2.33 @@ -352,7 +460,7 @@ BEGIN END// delimiter ;// ---error 1222 +--error ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT CALL sp1(); # cleanup 3.1.2.34 @@ -375,8 +483,10 @@ create table res_t1(w char unique, x char); insert into res_t1 values('a', 'b'); -# Error: 1339 SQLSTATE: 20000 (ER_SP_CASE_NOT_FOUND) Message: Case not found for CASE statement -# Error: 1022 SQLSTATE: 23000 (ER_DUP_KEY) Message: Can't write; duplicate key in table '%s' +# Error: SQLSTATE: 20000 (ER_SP_CASE_NOT_FOUND) +# Message: Case not found for CASE statement +# Error: SQLSTATE: 23000 (ER_DUP_KEY) +# Message: Can't write; duplicate key in table '%s' delimiter //; CREATE PROCEDURE h1 () @@ -472,7 +582,7 @@ create table res_t1(w char unique, x char); insert into res_t1 values ('a', 'b'); delimiter //; ---error 1319 +--error ER_SP_COND_MISMATCH CREATE PROCEDURE h1 () BEGIN declare x1, x2, x3, x4, x5, x6 int default 0; @@ -561,8 +671,9 @@ DROP PROCEDURE IF EXISTS h1; --enable_warnings delimiter //; -#Error: 1319 SQLSTATE: 42000 (ER_SP_COND_MISMATCH) Message: Undefined CONDITION: %s ---error 1319 +# Error: SQLSTATE: 42000 (ER_SP_COND_MISMATCH) +# Message: Undefined CONDITION: %s +--error ER_SP_COND_MISMATCH CREATE PROCEDURE h1 () BEGIN declare x1, x2, x3, x4, x5, x6 int default 0; @@ -582,8 +693,9 @@ BEGIN END; END// -#Error: 1064 SQLSTATE: 42000 (ER_PARSE_ERROR) Message: %s near '%s' at line %d ---error 1064 +# Error: SQLSTATE: 42000 (ER_PARSE_ERROR) +# Message: %s near '%s' at line %d +--error ER_PARSE_ERROR CREATE PROCEDURE h1 () BEGIN DECLARE x1 INT DEFAULT 0; @@ -593,8 +705,9 @@ BEGIN DECLARE CONTINUE HANDLER FOR condname1 SET x1 = 1; END// -#Error: 1407 SQLSTATE: 42000 (ER_SP_BAD_SQLSTATE) Message: Bad SQLSTATE: '%s' ---error 1407 +# Error: SQLSTATE: 42000 (ER_SP_BAD_SQLSTATE) +# Message: Bad SQLSTATE: '%s' +--error ER_SP_BAD_SQLSTATE CREATE PROCEDURE h1 () BEGIN DECLARE x1 INT DEFAULT 0; @@ -632,7 +745,7 @@ drop table IF EXISTS res_t1; --echo ==> 'UNDO' is still not supported. delimiter //; ---error 1064 +--error ER_PARSE_ERROR create procedure p1undo () begin declare undo handler for sqlexception select '1'; @@ -723,7 +836,7 @@ DROP TABLE res_t1; let $message= Testcase 3.1.2.50:; --source include/show_msg.inc -# testcase: ensure that a continue handler allows the execution of the stored procedure +# Testcase: Ensure that a continue handler allows the execution of the stored procedure # to continue once the handler statement has completed its own execution # (that is, once the handler action statement has been executed). @@ -794,8 +907,9 @@ BEGIN END// delimiter ;// -# Error: 1318 SQLSTATE: 42000 (ER_SP_WRONG_NO_OF_ARGS) Message: Incorrect number of arguments for %s %s; expected %u, got %u ---error 1318 +# Error: SQLSTATE: 42000 (ER_SP_WRONG_NO_OF_ARGS) +# Message: Incorrect number of arguments for %s %s; expected %u, got %u +--error ER_SP_WRONG_NO_OF_ARGS CALL sp1(1); CALL sp2(); SELECT '-3-', @x2, @x; @@ -858,7 +972,7 @@ let $message= Testcase 3.1.2.54:; --source include/show_msg.inc let $message= Ensure that a handler with a condition defined with an SQLSTATE that begins with -“01“ is always exactly equivalent in action to a handler with an SQLWARNING +“01“ is always exactly equivalent in action to a handler with an SQLWARNING condition.; --source include/show_msg80.inc @@ -959,7 +1073,7 @@ let $message= Testcase 3.1.2.56:; --source include/show_msg.inc let $message= Ensure that a handler with a condition defined with an SQLSTATE that begins with -“02“ is always exactly equivalent in action to a handler with a NOT FOUND +“02“ is always exactly equivalent in action to a handler with a NOT FOUND condition.; --source include/show_msg80.inc @@ -1052,7 +1166,7 @@ BEGIN END// delimiter ;// ---error 1329 +--error ER_SP_FETCH_NO_DATA CALL sp0(); SELECT @done, @x; @@ -1081,13 +1195,16 @@ let $message= Testcase 3.1.2.58:; --source include/show_msg.inc let $message= Ensure that a handler with a condition defined with an SQLSTATE that begins with -anything other that “01“ or “02“ is always exactly equivalent in action to a +anything other that “01“ or “02“ is always exactly equivalent in action to a handler with an SQLEXCEPTION condition.; --source include/show_msg80.inc -# Error: 1339 SQLSTATE: 20000 (ER_SP_CASE_NOT_FOUND) Message: Case not found for CASE statement -# Error: 1222 SQLSTATE: 21000 (ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT) Message: The used SELECT statements have a different number of columns -# Error: 1326 SQLSTATE: 24000 (ER_SP_CURSOR_NOT_OPEN) Message: Cursor is not open +# Error: SQLSTATE: 20000 (ER_SP_CASE_NOT_FOUND) +# Message: Case not found for CASE statement +# Error: SQLSTATE: 21000 (ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT) +# Message: The used SELECT statements have a different number of columns +# Error: SQLSTATE: 24000 (ER_SP_CURSOR_NOT_OPEN) +# Message: Cursor is not open --disable_warnings DROP PROCEDURE IF EXISTS sp0; @@ -1271,7 +1388,8 @@ BEGIN declare f5_value char(20); declare f4_value integer; declare f6_value integer; - declare cur1 cursor for SELECT f1, f2, f4, f5, f6 from t2 limit 3; + declare cur1 cursor for SELECT f1, f2, f4, f5, f6 from t2 + where f4 >=-5000 order by f4 limit 3; open cur1; while proceed do SELECT count AS 'loop'; @@ -1282,7 +1400,7 @@ BEGIN END// delimiter ;// ---error 1329 +--error ER_SP_FETCH_NO_DATA CALL sp1(); SELECT * FROM temp; @@ -1338,11 +1456,11 @@ END// delimiter ;// --echo --> not enough columns in FETCH statement ---error 1328 +--error ER_SP_WRONG_NO_OF_FETCH_ARGS CALL sp1(); --echo --> too many columns in FETCH statement ---error 1328 +--error ER_SP_WRONG_NO_OF_FETCH_ARGS CALL sp2(); # cleanup 3.1.2.68 @@ -1366,9 +1484,10 @@ DROP PROCEDURE IF EXISTS sp1; create table temp1( f0 char(20), f1 char(20), f2 char(20), f3 int, f4 char(20) ); -#Error: 1329 SQLSTATE: 02000 (ER_SP_FETCH_NO_DATA) Message: No data to FETCH +# Error: SQLSTATE: 02000 (ER_SP_FETCH_NO_DATA) +# Message: No data to FETCH -SELECT f1, f2, f4, f5 from t2; +SELECT f1, f2, f4, f5 from t2 order by f4; delimiter //; CREATE PROCEDURE sp1( ) @@ -1379,8 +1498,8 @@ BEGIN declare newf2 char(20); declare newf5 char(20); declare newf4 integer; - declare cur1 cursor for SELECT f1, f2, f4, f5 from t2 limit 5; - declare cur2 cursor for SELECT f1, f2, f4, f5 from t2 limit 5; + declare cur1 cursor for SELECT f1, f2, f4, f5 from t2 where f4 >= -5000 order by f4 limit 5; + declare cur2 cursor for SELECT f1, f2, f4, f5 from t2 where f4 >= -5000 order by f4 limit 5; open cur1; open cur2; BEGIN @@ -1453,8 +1572,10 @@ BEGIN declare i_newf12 char(20); declare i_newf13 date; declare i_newf14 integer; - declare cur1 cursor for SELECT f1, f2, f3, f4 from t2 limit 4; - declare cur2 cursor for SELECT f1, f2, f3, f4 from t2 limit 3; + declare cur1 cursor for SELECT f1, f2, f3, f4 from t2 + where f4>=-5000 order by f4 limit 4; + declare cur2 cursor for SELECT f1, f2, f3, f4 from t2 + where f4>=-5000 order by f4 limit 3; declare continue handler for sqlstate '02000' set proceed=0; open cur1; open cur2; @@ -1486,8 +1607,10 @@ BEGIN DECLARE o_newf12 CHAR(20); DECLARE o_newf13 DATE; DECLARE o_newf14 INTEGER; - DECLARE cur1 CURSOR FOR SELECT f1, f2, f3, f4 FROM t2 LIMIT 5; - DECLARE cur2 CURSOR FOR SELECT f1, f2, f3, f4 FROM t2 LIMIT 5; + DECLARE cur1 CURSOR FOR SELECT f1, f2, f3, f4 FROM t2 + WHERE f4>=-5000 ORDER BY f4 LIMIT 5; + DECLARE cur2 CURSOR FOR SELECT f1, f2, f3, f4 FROM t2 + WHERE f4>=-5000 ORDER BY f4 LIMIT 5; DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET proceed=0; OPEN cur1; OPEN cur2; @@ -1526,6 +1649,7 @@ DROP TABLE temp2; --source suite/funcs_1/storedproc/cleanup_sp_tb.inc # ============================================================================== -let $message= . +++ END OF SCRIPT +++; ---source include/show_msg80.inc +--echo +--echo . +++ END OF SCRIPT +++ +--echo -------------------------------------------------------------------------------- # ============================================================================== diff --git a/mysql-test/suite/funcs_1/storedproc/storedproc_03.inc b/mysql-test/suite/funcs_1/storedproc/storedproc_03.inc index 9ffa7d7f66c..01810390a92 100644 --- a/mysql-test/suite/funcs_1/storedproc/storedproc_03.inc +++ b/mysql-test/suite/funcs_1/storedproc/storedproc_03.inc @@ -5,38 +5,67 @@ # ============================================================================== # (numbering from requirement document TP v1.0, Last updated: 25 Jan 2005 01:00) # -# 3.1.3 Syntax checks for the stored procedure-specific flow control statements IF, CASE, LOOP, LEAVE, ITERATE, REPEAT, WHILE: +# 3.1.3 Syntax checks for the stored procedure-specific flow control statements +# IF, CASE, LOOP, LEAVE, ITERATE, REPEAT, WHILE: # #- 1. Ensure that all subclauses that should be supported are supported. -#- 2. Ensure that all subclauses that should not be supported are disallowed with an appropriate error message. -#- 3. Ensure that all supported subclauses are supported only in the correct order. -#- 4. Ensure that an appropriate error message is returned if a subclause is out-of-order in a stored procedure definition. -#- 5. Ensure that all subclauses that are defined to be mandatory are indeed required to be mandatory by the MySQL server and tools. -#- 6. Ensure that any subclauses that are defined to be optional are indeed treated as optional by the MySQL server and tools. -## 7. Ensure that the IF statement acts correctly for all variants, including cases where statements are nested. -## 8. Ensure that the CASE statement acts correctly for all variants, including cases where statements are nested. -## 9. Ensure that the LOOP statement acts correctly for all variants, including cases where statements are nested. +#- 2. Ensure that all subclauses that should not be supported are disallowed +# with an appropriate error message. +#- 3. Ensure that all supported subclauses are supported only in the +# correct order. +#- 4. Ensure that an appropriate error message is returned if a subclause is +# out-of-order in a stored procedure definition. +#- 5. Ensure that all subclauses that are defined to be mandatory are indeed +# required to be mandatory by the MySQL server and tools. +#- 6. Ensure that any subclauses that are defined to be optional are indeed +# treated as optional by the MySQL server and tools. +## 7. Ensure that the IF statement acts correctly for all variants, including +# cases where statements are nested. +## 8. Ensure that the CASE statement acts correctly for all variants, +# including cases where statements are nested. +## 9. Ensure that the LOOP statement acts correctly for all variants, +# including cases where statements are nested. #- 10. Ensure that the labels enclosing each LOOP statement must match. -#- 11. Ensure that it is possible to put a beginning label at the start of a LOOP statement without also requiring an ending label at the end of the same statement. -#- 12. Ensure that it is not possible to put an ending label at the end of a LOOP statement without also requiring a matching beginning label at the start of the same statement. +#- 11. Ensure that it is possible to put a beginning label at the start of +# a LOOP statement without also requiring an ending label at the end of +# the same statement. +#- 12. Ensure that it is not possible to put an ending label at the end of +# a LOOP statement without also requiring a matching beginning label +# at the start of the same statement. #- 13. Ensure that every beginning label must end with a colon (:). #- 14. Ensure that every beginning label with the same scope must be unique. -## 15. Ensure that the LEAVE statement acts correctly for all variants, including cases where statements are nested. -## 16. Ensure that the ITERATE statement acts correctly for all variants, including cases where statements are nested. -#- 17. Ensure that the ITERATE statement fails, with an appropriate error message, if it appears in any context other than within LOOP, REPEAT, or WHILE statements. -## 18. Ensure that the REPEAT statement acts correctly for all variants, including cases where statements are nested. +## 15. Ensure that the LEAVE statement acts correctly for all variants, +# including cases where statements are nested. +## 16. Ensure that the ITERATE statement acts correctly for all variants, +# including cases where statements are nested. +#- 17. Ensure that the ITERATE statement fails, with an appropriate error +# message, if it appears in any context other than within LOOP, REPEAT, +# or WHILE statements. +## 18. Ensure that the REPEAT statement acts correctly for all variants, +# including cases where statements are nested. #- 19. Ensure that the labels enclosing each REPEAT statement must match. -#- 20. Ensure that it is possible to put a beginning label at the start of a REPEAT statement without also requiring an ending label at the end of the same statement. -#- 21. Ensure that it is not possible to put an ending label at the end of a REPEAT statement without also requiring a matching beginning label at the start of the same statement. +#- 20. Ensure that it is possible to put a beginning label at the start of +# a REPEAT statement without also requiring an ending label at the end +# of the same statement. +#- 21. Ensure that it is not possible to put an ending label at the end of +# a REPEAT statement without also requiring a matching beginning label +# at the start of the same statement. #- 22. Ensure that every beginning label must end with a colon (:). #- 23. Ensure that every beginning label with the same scope must be unique. -## 24. Ensure that the WHILE statement acts correctly for all variants, including cases where statements are nested. +## 24. Ensure that the WHILE statement acts correctly for all variants, +# including cases where statements are nested. #- 25. Ensure that the labels enclosing each WHILE statement must match. -#- 26. Ensure that it is possible to put a beginning label at the start of a WHILE statement without also requiring an ending label at the end of the same statement. -#- 27. Ensure that it is not possible to put an ending label at the end of a WHILE statement without also requiring a matching beginning label at the start of the same statement. +#- 26. Ensure that it is possible to put a beginning label at the start of +# a WHILE statement without also requiring an ending label at the end +# of the same statement. +#- 27. Ensure that it is not possible to put an ending label at the end of +# a WHILE statement without also requiring a matching beginning label +# at the start of the same statement. #- 28. Ensure that every beginning label must end with a colon (:). #- 29. Ensure that every beginning label with the same scope must be unique. -## 30. Ensure that multiple cases of all possible combinations of the control flow statements, nested within multiple compound statements within a stored procedure, always act correctly and return the expected result. +## 30. Ensure that multiple cases of all possible combinations of the control +# flow statements, nested within multiple compound statements within +# a stored procedure, always act correctly and return the expected result. # # ============================================================================== let $message= Section 3.1.3 - Syntax checks for the stored procedure-specific flow @@ -237,8 +266,9 @@ DROP PROCEDURE IF EXISTS sp31316; delimiter //; # wrong label at iterate -#Error: 1308 SQLSTATE: 42000 (ER_SP_LILABEL_MISMATCH) Message: %s with no matching label: %s ---error 1308 +# Error: SQLSTATE: 42000 (ER_SP_LILABEL_MISMATCH) +# Message: %s with no matching label: %s +--error ER_SP_LILABEL_MISMATCH CREATE PROCEDURE sp31316( ) BEGIN declare count1 integer default 1; @@ -436,8 +466,9 @@ BEGIN END// delimiter ;// -#Error: 1318 SQLSTATE: 42000 (ER_SP_WRONG_NO_OF_ARGS) Message: Incorrect number of arguments for %s %s; expected %u, got %u ---error 1318 +# Error: SQLSTATE: 42000 (ER_SP_WRONG_NO_OF_ARGS) +# Message: Incorrect number of arguments for %s %s; expected %u, got %u +--error ER_SP_WRONG_NO_OF_ARGS CALL sp31330(); CALL sp31330(1); @@ -459,6 +490,7 @@ drop table res_tbl; --source suite/funcs_1/storedproc/cleanup_sp_tb.inc # ============================================================================== -let $message= . +++ END OF SCRIPT +++; ---source include/show_msg80.inc +--echo +--echo . +++ END OF SCRIPT +++ +--echo -------------------------------------------------------------------------------- # ============================================================================== diff --git a/mysql-test/suite/funcs_1/storedproc/storedproc_06.inc b/mysql-test/suite/funcs_1/storedproc/storedproc_06.inc index e2b9e846b97..1a4dd9ff327 100644 --- a/mysql-test/suite/funcs_1/storedproc/storedproc_06.inc +++ b/mysql-test/suite/funcs_1/storedproc/storedproc_06.inc @@ -7,20 +7,29 @@ # # 3.1.6 Privilege checks: # -# 1. Ensure that no user may create a stored procedure without the GRANT CREATE ROUTINE privilege. +# 1. Ensure that no user may create a stored procedure without the +# GRANT CREATE ROUTINE privilege. # 2. Ensure that root always has the GRANT CREATE ROUTINE privilege. -# 3. Ensure that a user with the GRANT CREATE ROUTINE privilege can always create both a procedure and a function, on any appropriate database. -# 4. Ensure that the default security provision of a stored procedure is SQL SECURITY DEFINER. -# 5. Ensure that a stored procedure defined with SQL SECURITY DEFINER can be called/executed by any user, using only the privileges (including database access privileges) associated with the user who created the stored procedure. -# 6. Ensure that a stored procedure defined with SQL SECURITY INVOKER can be called/executed by any user, using only the privileges (including database access privileges) associated with the user executing the stored procedure. +# 3. Ensure that a user with the GRANT CREATE ROUTINE privilege can always +# create both a procedure and a function, on any appropriate database. +# 4. Ensure that the default security provision of a stored procedure is +# SQL SECURITY DEFINER. +# 5. Ensure that a stored procedure defined with SQL SECURITY DEFINER can be +# called/executed by any user, using only the privileges (including +# database access privileges) associated with the user who created +# the stored procedure. +# 6. Ensure that a stored procedure defined with SQL SECURITY INVOKER can be +# called/executed by any user, using only the privileges (including +# database access privileges) associated with the user executing +# the stored procedure. # # ============================================================================== let $message= Section 3.1.6 - Privilege Checks:; --source include/show_msg80.inc -USE db_storedproc_1; connection default; +USE db_storedproc_1; --source suite/funcs_1/include/show_connection.inc # ------------------------------------------------------------------------------ @@ -47,7 +56,7 @@ connect (user1a, localhost, user_1, , db_storedproc_1); USE db_storedproc_1; delimiter //; ---error 1044 +--error ER_DBACCESS_DENIED_ERROR CREATE PROCEDURE sp1(v1 char(20)) BEGIN SELECT * from db_storedproc_1.t6 where t6.f2= 'xyz'; @@ -58,6 +67,7 @@ disconnect user1a; # add privilege again and check connection default; +USE db_storedproc_1; --source suite/funcs_1/include/show_connection.inc GRANT CREATE ROUTINE ON db_storedproc_1.* TO 'user_1'@'localhost'; @@ -77,6 +87,7 @@ disconnect user1b; # cleanup connection default; +USE db_storedproc_1; --source suite/funcs_1/include/show_connection.inc DROP USER 'user_1'@'localhost'; @@ -132,6 +143,7 @@ disconnect user2; # cleanup connection default; +USE db_storedproc_1; --source suite/funcs_1/include/show_connection.inc drop user 'user_1'@'localhost'; @@ -242,33 +254,33 @@ disconnect user5_1; connect (user5_2, localhost, user_2, , db_storedproc_1); --source suite/funcs_1/include/show_connection.inc ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR CALL sp5_s_i(); ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR CALL sp5_ins(); ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR CALL sp5_sel(); # now 'add' INSERT to DEFINER connection default; --source suite/funcs_1/include/show_connection.inc ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR CALL sp5_sel(); grant insert on db_storedproc_1.* to 'user_1'@'localhost'; flush privileges; connection user5_2; --source suite/funcs_1/include/show_connection.inc ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR CALL sp5_s_i(); CALL sp5_ins(); ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR CALL sp5_sel(); # now 'add' SELECT to DEFINER connection default; --source suite/funcs_1/include/show_connection.inc ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR CALL sp5_sel(); grant SELECT on db_storedproc_1.* to 'user_1'@'localhost'; #grant execute on db_storedproc_1.* to 'user_2'@'localhost'; @@ -288,9 +300,9 @@ flush privileges; connection user5_2; --source suite/funcs_1/include/show_connection.inc ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR CALL sp5_s_i(); ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR CALL sp5_ins(); CALL sp5_sel(); @@ -302,11 +314,11 @@ flush privileges; connection user5_2; --source suite/funcs_1/include/show_connection.inc ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR CALL sp5_s_i(); ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR CALL sp5_ins(); ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR CALL sp5_sel(); # cleanup @@ -373,9 +385,9 @@ disconnect user6_1; connect (user6_2, localhost, user_2, , db_storedproc_1); --source suite/funcs_1/include/show_connection.inc ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR CALL sp3166_s_i(); ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR CALL sp3166_ins(); CALL sp3166_sel(); @@ -405,10 +417,10 @@ FLUSH PRIVILEGES; --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK connect (user6_4, localhost, user_2, , db_storedproc_1); --source suite/funcs_1/include/show_connection.inc ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR CALL sp3166_s_i(); CALL sp3166_ins(); ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR CALL sp3166_sel(); disconnect user6_4; @@ -422,11 +434,11 @@ FLUSH PRIVILEGES; --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK connect (user6_5, localhost, user_2, , db_storedproc_1); --source suite/funcs_1/include/show_connection.inc ---error 1370 +--error ER_PROCACCESS_DENIED_ERROR CALL sp3166_s_i(); ---error 1370 +--error ER_PROCACCESS_DENIED_ERROR CALL sp3166_ins(); ---error 1370 +--error ER_PROCACCESS_DENIED_ERROR CALL sp3166_sel(); disconnect user6_5; @@ -447,6 +459,7 @@ DROP USER 'user_2'@'localhost'; --source suite/funcs_1/storedproc/cleanup_sp_tb.inc # ============================================================================== -let $message= . +++ END OF SCRIPT +++; ---source include/show_msg80.inc +--echo +--echo . +++ END OF SCRIPT +++ +--echo -------------------------------------------------------------------------------- # ============================================================================== diff --git a/mysql-test/suite/funcs_1/storedproc/storedproc_10.inc b/mysql-test/suite/funcs_1/storedproc/storedproc_10.inc index d7b0a370a82..8e32a43e18f 100644 --- a/mysql-test/suite/funcs_1/storedproc/storedproc_10.inc +++ b/mysql-test/suite/funcs_1/storedproc/storedproc_10.inc @@ -7,14 +7,21 @@ # # 3.1.10 CALL checks: # -## 1. Ensure that a properly defined procedure can always be called, assuming the appropriate privileges exist. -#- 2. Ensure that a procedure cannot be called if the appropriate privileges do not exist. +## 1. Ensure that a properly defined procedure can always be called, assuming +# the appropriate privileges exist. +#- 2. Ensure that a procedure cannot be called if the appropriate privileges +# do not exist. ## 3. Ensure that a function can never be called. -## 4. Ensure that a properly defined function can always be executed, assuming the appropriate privileges exist. -#- 5. Ensure that a function cannot be executed if the appropriate privileges do not exist. +## 4. Ensure that a properly defined function can always be executed, assuming +# the appropriate privileges exist. +#- 5. Ensure that a function cannot be executed if the appropriate privileges +# do not exist. ## 6. Ensure that a procedure can never be executed. -## 7. Ensure that the ROW_COUNT() SQL function always returns the correct number of rows affected by the execution of a stored procedure. -## 8. Ensure that the mysql_affected_rows() C API function always returns the correct number of rows affected by the execution of a stored procedure. +## 7. Ensure that the ROW_COUNT() SQL function always returns the correct +# number of rows affected by the execution of a stored procedure. +## 8. Ensure that the mysql_affected_rows() C API function always returns +# the correct number of rows affected by the execution of a +# stored procedure. # # ============================================================================== let $message= Section 3.1.10 - CALL checks:; @@ -54,7 +61,7 @@ connect (user2_1, localhost, user_1, , db_storedproc); delimiter //; CREATE PROCEDURE sp31102 () SQL SECURITY INVOKER BEGIN - SELECT * FROM db_storedproc.t1 LIMIT 1; + SELECT * FROM db_storedproc.t1 WHERE f4=-5000 LIMIT 1; END// delimiter ;// @@ -74,12 +81,14 @@ connect (user2_2, localhost, user_2, , db_storedproc); --source suite/funcs_1/include/show_connection.inc # no privileges exist ---error 1370 +--error ER_PROCACCESS_DENIED_ERROR CALL sp31102(); SELECT fn31105( 9 ); # now 'add' EXECUTE to INVOKER +--echo connection default; connection default; +USE db_storedproc; --source suite/funcs_1/include/show_connection.inc # root can execute ... CALL sp31102(); @@ -97,7 +106,9 @@ SELECT fn31105( 9 ); disconnect user2_3; # now 'remove' SELECT from INVOKER +--echo connection default; connection default; +USE db_storedproc; --source suite/funcs_1/include/show_connection.inc REVOKE EXECUTE ON db_storedproc.* FROM 'user_2'@'localhost'; FLUSH PRIVILEGES; @@ -115,6 +126,7 @@ disconnect user2_4; # cleanup connection default; +USE db_storedproc; --source suite/funcs_1/include/show_connection.inc DROP PROCEDURE sp31102; @@ -142,7 +154,7 @@ BEGIN END// delimiter ;// ---error 1305 +--error ER_SP_DOES_NOT_EXIST CALL fn1(); # cleanup @@ -168,7 +180,7 @@ BEGIN END// delimiter ;// ---error 1305 +--error ER_SP_DOES_NOT_EXIST SELECT sp1(); # cleanup @@ -182,26 +194,32 @@ let $message= Ensure that the ROW_COUNT() SQL function always returns the correct number of rows affected by the execution of a stored procedure.; --source include/show_msg80.inc +# Note(mleich): Information taken from a comments in +# Bug#21818 Return value of ROW_COUNT() is incorrect for +# ALTER TABLE, LOAD DATA +# ROW_COUNT() is -1 following any statement which is not DELETE, INSERT +# or UPDATE. +# Also, after a CALL statement, ROW_COUNT() will return the value of the +# last statement in the stored procedure. --disable_warnings DROP PROCEDURE IF EXISTS sp_ins_1; DROP PROCEDURE IF EXISTS sp_ins_3; DROP PROCEDURE IF EXISTS sp_upd; DROP PROCEDURE IF EXISTS sp_ins_upd; +DROP PROCEDURE IF EXISTS sp_del; +DROP PROCEDURE IF EXISTS sp_with_rowcount; --enable_warnings CREATE TABLE temp(f1 CHAR(20),f2 CHAR(25),f3 DATE,f4 INT,f5 CHAR(25),f6 INT); INSERT INTO temp SELECT * FROM t10; delimiter //; -#FIXME: add to proc: SELECT row_count() 'ins'; CREATE PROCEDURE sp_ins_1() BEGIN INSERT INTO temp VALUES ('abc', 'abc', '20051003', 100, 'uvw', 1000); END// - -#FIXME: add to proc: SELECT row_count() 'ins_3'; CREATE PROCEDURE sp_ins_3() BEGIN INSERT INTO temp VALUES ('abc', 'xyz', '19490523', 100, 'uvw', 1000); @@ -209,26 +227,11 @@ BEGIN INSERT INTO temp VALUES ('abc', 'xyz', '2005-10-24', 100, 'uvw', 1000); END// -# FIXME: add to proc: SELECT row_count() AS 'updated'; CREATE PROCEDURE sp_upd() BEGIN UPDATE temp SET temp.f1 = 'updated' WHERE temp.f1 ='abc'; END// -# FIXME: use commented proc -# CREATE PROCEDURE sp_ins_upd() -# BEGIN -# BEGIN -# INSERT INTO temp VALUES ('qwe', 'abc', '1989-11-09', 100, 'uvw', 1000); -# INSERT INTO temp VALUES ('qwe', 'xyz', '1998-03-26', 100, 'uvw', 1000); -# INSERT INTO temp VALUES ('qwe', 'abc', '2000-11-09', 100, 'uvw', 1000); -# INSERT INTO temp VALUES ('qwe', 'abc', '2005-11-07', 100, 'uvw', 1000); -# END; -# SELECT row_count() AS 'insert "qwe"'; -# SELECT COUNT( f1 ), f1 FROM temp GROUP BY f1; -# UPDATE temp SET temp.f1 = 'updated_2' WHERE temp.f1 ='qwe' AND temp.f2 = 'abc'; -# SELECT row_count() AS 'update "qwe" AND "abc"'; -# END// CREATE PROCEDURE sp_ins_upd() BEGIN BEGIN @@ -240,31 +243,70 @@ BEGIN SELECT COUNT( f1 ), f1 FROM temp GROUP BY f1; UPDATE temp SET temp.f1 = 'updated_2' WHERE temp.f1 ='qwe' AND temp.f2 = 'abc'; END// + +CREATE PROCEDURE sp_del() +BEGIN + DELETE FROM temp WHERE temp.f1 ='qwe' OR temp.f1 = 'updated_2'; +END// + +CREATE PROCEDURE sp_with_rowcount() +BEGIN + BEGIN + INSERT INTO temp VALUES ('qwe', 'abc', '1989-11-09', 100, 'uvw', 1000), + ('qwe', 'xyz', '1998-03-26', 100, 'uvw', 1000), + ('qwe', 'abc', '2000-11-09', 100, 'uvw', 1000), + ('qwe', 'xyz', '2005-11-07', 100, 'uvw', 1000); + END; + SELECT row_count() AS 'row_count() after insert'; + SELECT row_count() AS 'row_count() after select row_count()'; + SELECT f1,f2,f3 FROM temp ORDER BY f1,f2,f3; + UPDATE temp SET temp.f1 = 'updated_2' WHERE temp.f2 = 'abc'; + SELECT row_count() AS 'row_count() after update'; + SELECT f1,f2,f3 FROM temp ORDER BY f1,f2,f3; + DELETE FROM temp WHERE temp.f1 = 'updated_2'; + SELECT row_count() AS 'row_count() after delete'; +END// delimiter ;// CALL sp_ins_1(); SELECT row_count(); +--sorted_result SELECT * FROM temp; CALL sp_ins_3(); -#FIXME: check is 1 correct here? I expect 3 for 3 inserted rows inside the procedure SELECT row_count(); +--sorted_result SELECT * FROM temp; CALL sp_upd(); SELECT row_count(); +--sorted_result SELECT * FROM temp; -#FIXME: check is 3 correct here? I expect 7 for 4 inserted and then 3 updated rows inside the procedure CALL sp_ins_upd(); SELECT row_count(); +--sorted_result +SELECT * FROM temp; + +CALL sp_del(); +SELECT row_count(); +--sorted_result SELECT * FROM temp; +DELETE FROM temp; +CALL sp_with_rowcount(); +SELECT row_count(); +--sorted_result +SELECT * FROM temp; + + # cleanup DROP PROCEDURE sp_ins_1; DROP PROCEDURE sp_ins_3; DROP PROCEDURE sp_upd; DROP PROCEDURE sp_ins_upd; +DROP PROCEDURE sp_del; +DROP PROCEDURE sp_with_rowcount; DROP TABLE temp; @@ -272,7 +314,7 @@ DROP TABLE temp; let $message= Testcase 3.1.10.8:; --source include/show_msg.inc let $message= -Ensure that the mysql_affected_rows() C API function always returns the correct +Ensure that the mysql_affected_rows() C API function always returns the correct number of rows affected by the execution of a stored procedure.; --source include/show_msg80.inc @@ -283,6 +325,7 @@ number of rows affected by the execution of a stored procedure.; --source suite/funcs_1/storedproc/cleanup_sp_tb.inc # ============================================================================== -let $message= . +++ END OF SCRIPT +++; ---source include/show_msg80.inc +--echo +--echo . +++ END OF SCRIPT +++ +--echo -------------------------------------------------------------------------------- # ============================================================================== |