summaryrefslogtreecommitdiff
path: root/sql/sql_prepare.cc
diff options
context:
space:
mode:
authorunknown <kostja@bodhi.(none)>2008-05-20 11:29:16 +0400
committerunknown <kostja@bodhi.(none)>2008-05-20 11:29:16 +0400
commit37b2c32d95200f91c6bd427783867e0d0d295c5c (patch)
treeaa69b884f7e82cd03745af3a77cf7d18e6236410 /sql/sql_prepare.cc
parent1c12291b2f39641d283590b528dc3ce63a687928 (diff)
downloadmariadb-git-37b2c32d95200f91c6bd427783867e0d0d295c5c.tar.gz
Bug#27430 "Crash in subquery code when in PS and table DDL changed after
PREPARE": rename members, methods, classes to follow the spec (a code review request) sql/mysql_priv.h: enum_metadata_type -> enum_table_ref_type sql/sp_head.cc: Metadata_version_observer -> Reprepare_observer sql/sql_base.cc: metadata -> table_ref sql/sql_class.cc: Replace an abstract interface with a concrete implementation. sql/sql_class.h: enum_metadata_type -> enum_table_ref_type sql/sql_prepare.cc: Move implementation of Execute_observer to sql_class.cc and rename the class to Reprepare_observer. Use getters instead of direct access to the members. sql/table.h: metadata -> table_ref
Diffstat (limited to 'sql/sql_prepare.cc')
-rw-r--r--sql/sql_prepare.cc43
1 files changed, 6 insertions, 37 deletions
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 005ee4e52ef..3036b36f8fa 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -116,37 +116,6 @@ public:
#endif
};
-/**
- If a metadata changed, report a respective error to trigger
- re-prepare of a prepared statement.
-*/
-
-class Execute_observer: public Metadata_version_observer
-{
-public:
- virtual bool report_error(THD *thd);
- /** Set to TRUE if metadata of some used table has changed since prepare */
- bool m_invalidated;
-};
-
-/**
- Push an error to the error stack and return TRUE for now.
- In future we must take special care of statements like CREATE
- TABLE ... SELECT. Should we re-prepare such statements every
- time?
-*/
-
-bool
-Execute_observer::report_error(THD *thd)
-{
- DBUG_ENTER("Execute_observer::report_error");
-
- my_error(ER_NEED_REPREPARE, MYF(ME_NO_WARNING_FOR_ERROR|ME_NO_SP_HANDLER));
-
- m_invalidated= TRUE;
- DBUG_RETURN(TRUE);
-}
-
/****************************************************************************/
/**
@@ -3219,7 +3188,7 @@ Prepared_statement::execute_loop(String *expanded_query,
uchar *packet_end)
{
const int MAX_REPREPARE_ATTEMPTS= 3;
- Execute_observer execute_observer;
+ Reprepare_observer reprepare_observer;
bool error;
int reprepare_attempt= 0;
@@ -3227,7 +3196,7 @@ Prepared_statement::execute_loop(String *expanded_query,
return TRUE;
reexecute:
- execute_observer.m_invalidated= FALSE;
+ reprepare_observer.reset_reprepare_observer();
/*
If the free_list is not empty, we'll wrongly free some externally
@@ -3245,8 +3214,8 @@ reexecute:
if (sql_command_flags[lex->sql_command] &
CF_REEXECUTION_FRAGILE)
{
- DBUG_ASSERT(thd->m_metadata_observer == NULL);
- thd->m_metadata_observer= &execute_observer;
+ DBUG_ASSERT(thd->m_reprepare_observer == NULL);
+ thd->m_reprepare_observer = &reprepare_observer;
}
if (!(specialflag & SPECIAL_NO_PRIOR))
@@ -3257,10 +3226,10 @@ reexecute:
if (!(specialflag & SPECIAL_NO_PRIOR))
my_pthread_setprio(pthread_self(), WAIT_PRIOR);
- thd->m_metadata_observer= NULL;
+ thd->m_reprepare_observer= NULL;
if (error && !thd->is_fatal_error && !thd->killed &&
- execute_observer.m_invalidated &&
+ reprepare_observer.is_invalidated() &&
reprepare_attempt++ < MAX_REPREPARE_ATTEMPTS)
{
DBUG_ASSERT(thd->main_da.sql_errno() == ER_NEED_REPREPARE);