Skip to content

Commit

Permalink
Fixed(PS-7745) - (Stored procedure execution fails if contains a func…
Browse files Browse the repository at this point in the history
…tional index)

The issue happens when checks are performed again during a query
and column index of the functional index is not available.

This solutiom disables some checks if a column index is not available
in `pre_validate_value_generator_expr()`.
It is safe because these checks were already performed during the first query
that included this index in the function `validate_value_generator_expr()`.
  • Loading branch information
Daniel R. Fiala committed Aug 28, 2022
1 parent ab38037 commit 60b158f
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
20 changes: 20 additions & 0 deletions mysql-test/suite/rocksdb/r/issue7745.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
CREATE PROCEDURE `sproc`()
BEGIN
DROP TEMPORARY TABLE IF EXISTS `t1`;
CREATE TEMPORARY TABLE `t1`(
`c1` INT,
KEY ( ( `c1` > 0 ) )
);
SELECT 1 FROM ( SELECT 1 `c2` ) `t2`;
END|
CALL `sproc`();
1
1
CALL `sproc`();
1
1
CALL `sproc`();
1
1
DROP PROCEDURE `sproc`;
DROP TEMPORARY TABLE `t1`;
18 changes: 18 additions & 0 deletions mysql-test/suite/rocksdb/t/issue7745.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--source include/have_rocksdb.inc

DELIMITER |;
CREATE PROCEDURE `sproc`()
BEGIN
DROP TEMPORARY TABLE IF EXISTS `t1`;
CREATE TEMPORARY TABLE `t1`(
`c1` INT,
KEY ( ( `c1` > 0 ) )
);
SELECT 1 FROM ( SELECT 1 `c2` ) `t2`;
END|
DELIMITER ;|

CALL `sproc`(); CALL `sproc`(); CALL `sproc`();

DROP PROCEDURE `sproc`;
DROP TEMPORARY TABLE `t1`;
3 changes: 1 addition & 2 deletions sql/item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,6 @@ bool Item_field::check_function_as_value_generator(uchar *checker_args) {
}

int fld_idx = func_args->col_index;
assert(fld_idx > -1);

/*
Don't allow the GC (or default expression) to refer itself or another GC
Expand All @@ -1046,7 +1045,7 @@ bool Item_field::check_function_as_value_generator(uchar *checker_args) {
if ((func_args->source != VGS_CHECK_CONSTRAINT) &&
(field->is_gcol() ||
field->has_insert_default_general_value_expression()) &&
field->field_index() >= fld_idx) {
(fld_idx >= 0 && field->field_index() >= fld_idx)) {
func_args->err_code = (func_args->source == VGS_GENERATED_COLUMN)
? ER_GENERATED_COLUMN_NON_PRIOR
: ER_DEFAULT_VAL_GENERATED_NON_PRIOR;
Expand Down

0 comments on commit 60b158f

Please sign in to comment.