summaryrefslogtreecommitdiff
path: root/sql/sp_head.cc
diff options
context:
space:
mode:
authorunknown <dlenev@mysql.com>2006-01-13 01:56:57 +0300
committerunknown <dlenev@mysql.com>2006-01-13 01:56:57 +0300
commit3bf3bb20080bc81f705ba99aef9b98cec9a06fb0 (patch)
tree5f5194ef9d8fb564abc0f73c377e80b14ba4fffa /sql/sp_head.cc
parent0f4962c338716bbc72ba8dd7102052fcbcfd4f80 (diff)
parentc12a3dfefd29b3bb4a93fee4778e0e94b1e00871 (diff)
downloadmariadb-git-3bf3bb20080bc81f705ba99aef9b98cec9a06fb0.tar.gz
Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/home/dlenev/src/mysql-5.0-bg12198-2 mysql-test/r/sp.result: Auto merged mysql-test/t/sp.test: Auto merged sql/sp_head.cc: Auto merged
Diffstat (limited to 'sql/sp_head.cc')
-rw-r--r--sql/sp_head.cc31
1 files changed, 23 insertions, 8 deletions
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index d3045467f91..96bf2c51b02 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -3131,7 +3131,14 @@ sp_restore_security_context(THD *thd, Security_context *backup)
typedef struct st_sp_table
{
- LEX_STRING qname; /* Multi-set key: db_name\0table_name\0alias\0 */
+ /*
+ Multi-set key:
+ db_name\0table_name\0alias\0 - for normal tables
+ db_name\0table_name\0 - for temporary tables
+ Note that in both cases we don't take last '\0' into account when
+ we count length of key.
+ */
+ LEX_STRING qname;
uint db_length, table_name_length;
bool temp; /* true if corresponds to a temporary table */
thr_lock_type lock_type; /* lock type used for prelocking */
@@ -3201,10 +3208,14 @@ sp_head::merge_table_list(THD *thd, TABLE_LIST *table, LEX *lex_for_tmp_check)
tname[tlen]= '\0';
/*
- It is safe to store pointer to table list elements in hash,
- since they are supposed to have the same lifetime.
+ We ignore alias when we check if table was already marked as temporary
+ (and therefore should not be prelocked). Otherwise we will erroneously
+ treat table with same name but with different alias as non-temporary.
*/
- if ((tab= (SP_TABLE *)hash_search(&m_sptabs, (byte *)tname, tlen)))
+ if ((tab= (SP_TABLE *)hash_search(&m_sptabs, (byte *)tname, tlen)) ||
+ ((tab= (SP_TABLE *)hash_search(&m_sptabs, (byte *)tname,
+ tlen - alen - 1)) &&
+ tab->temp))
{
if (tab->lock_type < table->lock_type)
tab->lock_type= table->lock_type; // Use the table with the highest lock type
@@ -3216,14 +3227,18 @@ sp_head::merge_table_list(THD *thd, TABLE_LIST *table, LEX *lex_for_tmp_check)
{
if (!(tab= (SP_TABLE *)thd->calloc(sizeof(SP_TABLE))))
return FALSE;
- tab->qname.length= tlen;
- tab->qname.str= (char*) thd->memdup(tname, tab->qname.length + 1);
- if (!tab->qname.str)
- return FALSE;
if (lex_for_tmp_check->sql_command == SQLCOM_CREATE_TABLE &&
lex_for_tmp_check->query_tables == table &&
lex_for_tmp_check->create_info.options & HA_LEX_CREATE_TMP_TABLE)
+ {
tab->temp= TRUE;
+ tab->qname.length= tlen - alen - 1;
+ }
+ else
+ tab->qname.length= tlen;
+ tab->qname.str= (char*) thd->memdup(tname, tab->qname.length + 1);
+ if (!tab->qname.str)
+ return FALSE;
tab->table_name_length= table->table_name_length;
tab->db_length= table->db_length;
tab->lock_type= table->lock_type;