summaryrefslogtreecommitdiff
path: root/sql/sp_head.h
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2005-11-16 14:09:06 +0200
committerunknown <bell@sanja.is.com.ua>2005-11-16 14:09:06 +0200
commit8a661e77ea3759eb0bdc0fd1a0caecc708593732 (patch)
treefe1c6b02c2ae434166a082a3fde2e18204127da0 /sql/sp_head.h
parent9de8e3b0ef774c97093e54fca7ad451b03e165c5 (diff)
downloadmariadb-git-8a661e77ea3759eb0bdc0fd1a0caecc708593732.tar.gz
Issuing error about presence of commit/rollback statements in stored functions and triggers added to SP parsing procedure (BUG#13627)
The crash mentioned in original bug report is already prevented by one of previous patches (fix for bug #13343 "CREATE|etc TRIGGER|VIEW|USER don't commit the transaction (inconsistency)"), this patch only improve error returning. mysql-test/r/sp-error.result: Test that statements which implicitly commit transaction mysql-test/t/sp-error.test: Test that statements which implicitly commit transaction sql/sp_head.cc: We set the new flag about commit/rollback statements presence sql/sp_head.h: The new flag about commit/rollback presence added A comment fixed sql/sql_yacc.yy: Removed commit/rollback-statement-present errors spread by this file, only one check left which check flags of a SP
Diffstat (limited to 'sql/sp_head.h')
-rw-r--r--sql/sp_head.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/sql/sp_head.h b/sql/sp_head.h
index d1a122fd410..8c2d58a696e 100644
--- a/sql/sp_head.h
+++ b/sql/sp_head.h
@@ -115,10 +115,13 @@ public:
MULTI_RESULTS= 8, // Is set if a procedure with SELECT(s)
CONTAINS_DYNAMIC_SQL= 16, // Is set if a procedure with PREPARE/EXECUTE
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'
+ 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
};
- int m_type; // TYPE_ENUM_FUNCTION or TYPE_ENUM_PROCEDURE
+ /* TYPE_ENUM_FUNCTION, TYPE_ENUM_PROCEDURE or TYPE_ENUM_TRIGGER */
+ int m_type;
uint m_flags; // Boolean attributes of a stored routine
enum enum_field_types m_returns; // For FUNCTIONs only
Field::geometry_type m_geom_returns;
@@ -292,6 +295,12 @@ 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))
+ {
+ my_error(ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG, MYF(0));
+ return TRUE;
+ }
return test(m_flags &
(CONTAINS_DYNAMIC_SQL|MULTI_RESULTS|HAS_SET_AUTOCOMMIT_STMT));
}