diff options
author | unknown <andrey@example.com> | 2006-08-25 15:51:29 +0200 |
---|---|---|
committer | unknown <andrey@example.com> | 2006-08-25 15:51:29 +0200 |
commit | 133d2aa599a65637b28e1d0634274015c49dc4e2 (patch) | |
tree | 4270ee7b2686fb9d852d358f355f58fb399d5840 /sql/sp_head.h | |
parent | 807ecdf43ae2c5f35c2f350e67242580618ff9a8 (diff) | |
download | mariadb-git-133d2aa599a65637b28e1d0634274015c49dc4e2.tar.gz |
Fix for bug#21795: SP: sp_head::is_not_allowed_in_function() contains
erroneous check
Problem: Actually there were two problems in the server code. The check
for SQLCOM_FLUSH in SF/Triggers were not according to the existing
architecture which uses sp_get_flags_for_command() from sp_head.cc .
This function was also missing a check for SQLCOM_FLUSH which has a
problem combined with prelocking. This changeset fixes both of these
deficiencies as well as the erroneous check in
sp_head::is_not_allowed_in_function() which was a copy&paste error.
mysql-test/r/sp-error.result:
update result
mysql-test/r/trigger.result:
update result
mysql-test/t/sp-error.test:
FLUSH can create a problem with prelocking, hence it's disabled.
There is a better way to check this than a check in the parser.
Now we use sp_get_flags_for_command() and the error returned is
different.
mysql-test/t/trigger.test:
FLUSH can create a problem with prelocking, hence it's disabled.
There is a better way to check this than a check in the parser.
Now we use sp_get_flags_for_command() and the error returned is
different.
sql/sp_head.cc:
FLUSH and RESET are not allowed inside a SF/Trigger.
Because they don't imply a COMMIT sp_head::HAS_COMMIT_OR_ROLLBACK
cannot be used. Two new flags were introduced for that reason.
sql/sp_head.h:
Don't check m_type as this check is erroneous. This is probably
a copy and paste error when moving code from somewhere else. Another
fact which supports this was prefixing the enum value with the name
of class sp_head.
Adding two new flags HAS_SQLCOM_RESET and HAS_SQLCOM_FLUSH. The values
are 2048 and 4096 because in the 5.1 branch there are already new flags
which are with values up-to 1024.
sql/sql_parse.cc:
FLUSH can cause a problem with prelocking in SF/Trigger and
therefore is already disabled. RESET is also disabled because
is handled by the same code as FLUSH. We won't allow RESET inside
SF/Trigger at that stage without thorough analysis. The check for
them is already done in the parser by calling
is_not_allowed_in_function()
sql/sql_yacc.yy:
By listing SQLCOM_FLUSH as command which implies COMMIT
in sp_get_flags_for_command() the check in sql_yacc.yy is
obsolete.
Diffstat (limited to 'sql/sp_head.h')
-rw-r--r-- | sql/sp_head.h | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/sql/sp_head.h b/sql/sp_head.h index 4cd34bc9e20..7f2da69aa0c 100644 --- a/sql/sp_head.h +++ b/sql/sp_head.h @@ -115,7 +115,9 @@ public: IS_INVOKED= 32, // Is set if this sp_head is being used HAS_SET_AUTOCOMMIT_STMT= 64,// Is set if a procedure with 'set autocommit' /* Is set if a procedure with COMMIT (implicit or explicit) | ROLLBACK */ - HAS_COMMIT_OR_ROLLBACK= 128 + HAS_COMMIT_OR_ROLLBACK= 128, + HAS_SQLCOM_RESET= 2048, + HAS_SQLCOM_FLUSH= 4096 }; /* TYPE_ENUM_FUNCTION, TYPE_ENUM_PROCEDURE or TYPE_ENUM_TRIGGER */ @@ -335,14 +337,16 @@ public: my_error(ER_SP_NO_RETSET, MYF(0), where); else if (m_flags & HAS_SET_AUTOCOMMIT_STMT) my_error(ER_SP_CANT_SET_AUTOCOMMIT, MYF(0)); - else if (m_type != TYPE_ENUM_PROCEDURE && - (m_flags & sp_head::HAS_COMMIT_OR_ROLLBACK)) - { + else if (m_flags & HAS_COMMIT_OR_ROLLBACK) my_error(ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG, MYF(0)); - return TRUE; - } + else if (m_flags & HAS_SQLCOM_RESET) + my_error(ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG, MYF(0), "RESET"); + else if (m_flags & HAS_SQLCOM_FLUSH) + my_error(ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG, MYF(0), "FLUSH"); + return test(m_flags & - (CONTAINS_DYNAMIC_SQL|MULTI_RESULTS|HAS_SET_AUTOCOMMIT_STMT)); + (CONTAINS_DYNAMIC_SQL|MULTI_RESULTS|HAS_SET_AUTOCOMMIT_STMT| + HAS_COMMIT_OR_ROLLBACK|HAS_SQLCOM_RESET|HAS_SQLCOM_FLUSH)); } #ifndef DBUG_OFF |