Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PS-7745 - Stored procedure execution fails if contains a functional index #4854

Open
wants to merge 2 commits into
base: 8.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions mysql-test/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`;
16 changes: 16 additions & 0 deletions mysql-test/t/issue7745.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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