mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
Merge tsmith@bk-internal.mysql.com:/home/bk/mysql-5.0
into ramayana.hindu.god:/home/tsmith/m/bk/maint/50 sql/sql_table.cc: Auto merged
This commit is contained in:
commit
a4df22109c
20 changed files with 674 additions and 548 deletions
|
@ -550,16 +550,6 @@ unsigned long STDCALL mysql_real_escape_string(MYSQL *mysql,
|
|||
char *to,const char *from,
|
||||
unsigned long length);
|
||||
void STDCALL mysql_debug(const char *debug);
|
||||
char * STDCALL mysql_odbc_escape_string(MYSQL *mysql,
|
||||
char *to,
|
||||
unsigned long to_length,
|
||||
const char *from,
|
||||
unsigned long from_length,
|
||||
void *param,
|
||||
char *
|
||||
(*extend_buffer)
|
||||
(void *, char *to,
|
||||
unsigned long *length));
|
||||
void STDCALL myodbc_remove_escape(MYSQL *mysql,char *name);
|
||||
unsigned int STDCALL mysql_thread_safe(void);
|
||||
my_bool STDCALL mysql_embedded(void);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1617,78 +1617,6 @@ mysql_real_escape_string(MYSQL *mysql, char *to,const char *from,
|
|||
return escape_string_for_mysql(mysql->charset, to, 0, from, length);
|
||||
}
|
||||
|
||||
|
||||
char * STDCALL
|
||||
mysql_odbc_escape_string(MYSQL *mysql,
|
||||
char *to, ulong to_length,
|
||||
const char *from, ulong from_length,
|
||||
void *param,
|
||||
char * (*extend_buffer)
|
||||
(void *, char *, ulong *))
|
||||
{
|
||||
char *to_end=to+to_length-5;
|
||||
const char *end;
|
||||
#ifdef USE_MB
|
||||
my_bool use_mb_flag=use_mb(mysql->charset);
|
||||
#endif
|
||||
|
||||
for (end=from+from_length; from != end ; from++)
|
||||
{
|
||||
if (to >= to_end)
|
||||
{
|
||||
to_length = (ulong) (end-from)+512; /* We want this much more */
|
||||
if (!(to=(*extend_buffer)(param, to, &to_length)))
|
||||
return to;
|
||||
to_end=to+to_length-5;
|
||||
}
|
||||
#ifdef USE_MB
|
||||
{
|
||||
int l;
|
||||
if (use_mb_flag && (l = my_ismbchar(mysql->charset, from, end)))
|
||||
{
|
||||
while (l--)
|
||||
*to++ = *from++;
|
||||
from--;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
switch (*from) {
|
||||
case 0: /* Must be escaped for 'mysql' */
|
||||
*to++= '\\';
|
||||
*to++= '0';
|
||||
break;
|
||||
case '\n': /* Must be escaped for logs */
|
||||
*to++= '\\';
|
||||
*to++= 'n';
|
||||
break;
|
||||
case '\r':
|
||||
*to++= '\\';
|
||||
*to++= 'r';
|
||||
break;
|
||||
case '\\':
|
||||
*to++= '\\';
|
||||
*to++= '\\';
|
||||
break;
|
||||
case '\'':
|
||||
*to++= '\\';
|
||||
*to++= '\'';
|
||||
break;
|
||||
case '"': /* Better safe than sorry */
|
||||
*to++= '\\';
|
||||
*to++= '"';
|
||||
break;
|
||||
case '\032': /* This gives problems on Win32 */
|
||||
*to++= '\\';
|
||||
*to++= 'Z';
|
||||
break;
|
||||
default:
|
||||
*to++= *from;
|
||||
}
|
||||
}
|
||||
return to;
|
||||
}
|
||||
|
||||
void STDCALL
|
||||
myodbc_remove_escape(MYSQL *mysql,char *name)
|
||||
{
|
||||
|
|
|
@ -78,7 +78,6 @@ EXPORTS
|
|||
mysql_next_result
|
||||
mysql_num_fields
|
||||
mysql_num_rows
|
||||
mysql_odbc_escape_string
|
||||
mysql_options
|
||||
mysql_stmt_param_count
|
||||
mysql_stmt_param_metadata
|
||||
|
|
|
@ -71,7 +71,6 @@ EXPORTS
|
|||
mysql_next_result
|
||||
mysql_num_fields
|
||||
mysql_num_rows
|
||||
mysql_odbc_escape_string
|
||||
mysql_options
|
||||
mysql_ping
|
||||
mysql_query
|
||||
|
|
|
@ -55,3 +55,20 @@ flush tables with read lock;
|
|||
insert into t2 values(1);
|
||||
unlock tables;
|
||||
drop table t1, t2;
|
||||
drop table if exists t1, t2;
|
||||
set session low_priority_updates=1;
|
||||
create table t1 (a int);
|
||||
create table t2 (b int);
|
||||
lock tables t1 write;
|
||||
flush tables with read lock;
|
||||
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
|
||||
unlock tables;
|
||||
lock tables t1 read, t2 write;
|
||||
flush tables with read lock;
|
||||
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
|
||||
unlock tables;
|
||||
lock tables t1 read;
|
||||
flush tables with read lock;
|
||||
unlock tables;
|
||||
drop table t1, t2;
|
||||
set session low_priority_updates=default;
|
||||
|
|
|
@ -88,3 +88,14 @@ alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1
|
|||
alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; //
|
||||
unlock tables;
|
||||
drop table t1;
|
||||
drop table if exists t1;
|
||||
create table t1 (a int);
|
||||
connection: locker
|
||||
lock tables t1 read;
|
||||
connection: writer
|
||||
create table t2 like t1;;
|
||||
connection: default
|
||||
kill query
|
||||
ERROR 70100: Query execution was interrupted
|
||||
unlock tables;
|
||||
drop table t1;
|
||||
|
|
|
@ -133,4 +133,35 @@ disconnect con3;
|
|||
connection default;
|
||||
drop table t1, t2;
|
||||
|
||||
#
|
||||
# Bug#32528 Global read lock with a low priority write lock causes a server crash
|
||||
#
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1, t2;
|
||||
--enable_warnings
|
||||
|
||||
set session low_priority_updates=1;
|
||||
|
||||
create table t1 (a int);
|
||||
create table t2 (b int);
|
||||
|
||||
lock tables t1 write;
|
||||
--error ER_LOCK_OR_ACTIVE_TRANSACTION
|
||||
flush tables with read lock;
|
||||
unlock tables;
|
||||
|
||||
lock tables t1 read, t2 write;
|
||||
--error ER_LOCK_OR_ACTIVE_TRANSACTION
|
||||
flush tables with read lock;
|
||||
unlock tables;
|
||||
|
||||
lock tables t1 read;
|
||||
flush tables with read lock;
|
||||
unlock tables;
|
||||
|
||||
drop table t1, t2;
|
||||
|
||||
set session low_priority_updates=default;
|
||||
|
||||
# End of 5.0 tests
|
||||
|
|
|
@ -249,4 +249,36 @@ reap;
|
|||
connection locker;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# Bug#31479 Bad lock interaction if CREATE TABLE LIKE is killed
|
||||
#
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
create table t1 (a int);
|
||||
--echo connection: locker
|
||||
connection locker;
|
||||
lock tables t1 read;
|
||||
--echo connection: writer
|
||||
connection writer;
|
||||
let $ID= `select connection_id()`;
|
||||
--send create table t2 like t1;
|
||||
--echo connection: default
|
||||
connection default;
|
||||
let $show_type= open tables where in_use=2 and name_locked=1;
|
||||
let $show_pattern= '%t1%2%1';
|
||||
--source include/wait_show_pattern.inc
|
||||
--echo kill query
|
||||
disable_query_log;
|
||||
eval kill query $ID;
|
||||
enable_query_log;
|
||||
connection writer;
|
||||
--error ER_QUERY_INTERRUPTED
|
||||
--reap
|
||||
connection locker;
|
||||
unlock tables;
|
||||
connection default;
|
||||
drop table t1;
|
||||
|
||||
# End of 5.0 tests
|
||||
|
|
|
@ -1085,11 +1085,16 @@ void mysql_read_default_options(struct st_mysql_options *options,
|
|||
my_free(options->ssl_capath, MYF(MY_ALLOW_ZERO_PTR));
|
||||
options->ssl_capath = my_strdup(opt_arg, MYF(MY_WME));
|
||||
break;
|
||||
case 26: /* ssl_cipher */
|
||||
my_free(options->ssl_cipher, MYF(MY_ALLOW_ZERO_PTR));
|
||||
options->ssl_cipher= my_strdup(opt_arg, MYF(MY_WME));
|
||||
break;
|
||||
#else
|
||||
case 13: /* Ignore SSL options */
|
||||
case 14:
|
||||
case 15:
|
||||
case 16:
|
||||
case 26:
|
||||
break;
|
||||
#endif /* HAVE_OPENSSL */
|
||||
case 17: /* charset-lib */
|
||||
|
|
|
@ -3739,13 +3739,12 @@ longlong Item_func_sleep::val_int()
|
|||
break;
|
||||
error= 0;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&LOCK_user_locks);
|
||||
pthread_mutex_lock(&thd->mysys_var->mutex);
|
||||
thd->mysys_var->current_mutex= 0;
|
||||
thd->mysys_var->current_cond= 0;
|
||||
pthread_mutex_unlock(&thd->mysys_var->mutex);
|
||||
|
||||
pthread_mutex_unlock(&LOCK_user_locks);
|
||||
pthread_cond_destroy(&cond);
|
||||
|
||||
return test(!error); // Return 1 killed
|
||||
|
|
|
@ -2502,7 +2502,12 @@ static int my_message_sql(uint error, const char *str, myf MyFlags)
|
|||
thd->query_error= 1; // needed to catch query errors during replication
|
||||
|
||||
if (!thd->no_warnings_for_error)
|
||||
{
|
||||
thd->no_warnings_for_error= TRUE;
|
||||
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, error, str);
|
||||
thd->no_warnings_for_error= FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
thd->lex->current_select == 0 if lex structure is not inited
|
||||
(not query command (COM_QUERY))
|
||||
|
@ -4307,8 +4312,13 @@ pthread_handler_t handle_connections_sockets(void *arg __attribute__((unused)))
|
|||
sock == unix_sock ? VIO_LOCALHOST: 0)) ||
|
||||
my_net_init(&thd->net,vio_tmp))
|
||||
{
|
||||
if (vio_tmp)
|
||||
vio_delete(vio_tmp);
|
||||
/*
|
||||
Only delete the temporary vio if we didn't already attach it to the
|
||||
NET object. The destructor in THD will delete any initialized net
|
||||
structure.
|
||||
*/
|
||||
if (vio_tmp && thd->net.vio != vio_tmp)
|
||||
vio_delete(vio_tmp);
|
||||
else
|
||||
{
|
||||
(void) shutdown(new_sock, SHUT_RDWR);
|
||||
|
|
|
@ -437,14 +437,16 @@ check_routine_name(LEX_STRING ident)
|
|||
*/
|
||||
|
||||
void *
|
||||
sp_head::operator new(size_t size)
|
||||
sp_head::operator new(size_t size) throw()
|
||||
{
|
||||
DBUG_ENTER("sp_head::operator new");
|
||||
MEM_ROOT own_root;
|
||||
sp_head *sp;
|
||||
|
||||
init_alloc_root(&own_root, MEM_ROOT_BLOCK_SIZE, MEM_ROOT_PREALLOC);
|
||||
init_sql_alloc(&own_root, MEM_ROOT_BLOCK_SIZE, MEM_ROOT_PREALLOC);
|
||||
sp= (sp_head *) alloc_root(&own_root, size);
|
||||
if (sp == NULL)
|
||||
return NULL;
|
||||
sp->main_mem_root= own_root;
|
||||
DBUG_PRINT("info", ("mem_root 0x%lx", (ulong) &sp->mem_root));
|
||||
DBUG_RETURN(sp);
|
||||
|
@ -455,6 +457,10 @@ sp_head::operator delete(void *ptr, size_t size)
|
|||
{
|
||||
DBUG_ENTER("sp_head::operator delete");
|
||||
MEM_ROOT own_root;
|
||||
|
||||
if (ptr == NULL)
|
||||
DBUG_VOID_RETURN;
|
||||
|
||||
sp_head *sp= (sp_head *) ptr;
|
||||
|
||||
/* Make a copy of main_mem_root as free_root will free the sp */
|
||||
|
@ -498,6 +504,9 @@ sp_head::init(LEX *lex)
|
|||
|
||||
lex->spcont= m_pcont= new sp_pcontext();
|
||||
|
||||
if (!lex->spcont)
|
||||
DBUG_VOID_RETURN;
|
||||
|
||||
/*
|
||||
Altough trg_table_fields list is used only in triggers we init for all
|
||||
types of stored procedures to simplify reset_lex()/restore_lex() code.
|
||||
|
@ -999,7 +1008,7 @@ sp_head::execute(THD *thd)
|
|||
DBUG_RETURN(TRUE);
|
||||
|
||||
/* init per-instruction memroot */
|
||||
init_alloc_root(&execute_mem_root, MEM_ROOT_BLOCK_SIZE, 0);
|
||||
init_sql_alloc(&execute_mem_root, MEM_ROOT_BLOCK_SIZE, 0);
|
||||
|
||||
DBUG_ASSERT(!(m_flags & IS_INVOKED));
|
||||
m_flags|= IS_INVOKED;
|
||||
|
@ -1821,16 +1830,29 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
|
|||
}
|
||||
|
||||
|
||||
// Reset lex during parsing, before we parse a sub statement.
|
||||
void
|
||||
/**
|
||||
@brief Reset lex during parsing, before we parse a sub statement.
|
||||
|
||||
@param thd Thread handler.
|
||||
|
||||
@return Error state
|
||||
@retval true An error occurred.
|
||||
@retval false Success.
|
||||
*/
|
||||
|
||||
bool
|
||||
sp_head::reset_lex(THD *thd)
|
||||
{
|
||||
DBUG_ENTER("sp_head::reset_lex");
|
||||
LEX *sublex;
|
||||
LEX *oldlex= thd->lex;
|
||||
|
||||
sublex= new (thd->mem_root)st_lex_local;
|
||||
if (sublex == 0)
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
thd->lex= sublex;
|
||||
(void)m_lex.push_front(oldlex);
|
||||
thd->lex= sublex= new st_lex;
|
||||
|
||||
/* Reset most stuff. */
|
||||
lex_start(thd);
|
||||
|
@ -1853,7 +1875,7 @@ sp_head::reset_lex(THD *thd)
|
|||
sublex->interval_list.empty();
|
||||
sublex->type= 0;
|
||||
|
||||
DBUG_VOID_RETURN;
|
||||
DBUG_RETURN(FALSE);
|
||||
}
|
||||
|
||||
// Restore lex during parsing, after we have parsed a sub statement.
|
||||
|
@ -3729,7 +3751,7 @@ sp_add_to_query_tables(THD *thd, LEX *lex,
|
|||
|
||||
if (!(table= (TABLE_LIST *)thd->calloc(sizeof(TABLE_LIST))))
|
||||
{
|
||||
my_error(ER_OUTOFMEMORY, MYF(0), sizeof(TABLE_LIST));
|
||||
thd->fatal_error();
|
||||
return NULL;
|
||||
}
|
||||
table->db_length= strlen(db);
|
||||
|
|
|
@ -182,10 +182,10 @@ public:
|
|||
Security_context m_security_ctx;
|
||||
|
||||
static void *
|
||||
operator new(size_t size);
|
||||
operator new(size_t size) throw ();
|
||||
|
||||
static void
|
||||
operator delete(void *ptr, size_t size);
|
||||
operator delete(void *ptr, size_t size) throw ();
|
||||
|
||||
sp_head();
|
||||
|
||||
|
@ -245,7 +245,7 @@ public:
|
|||
}
|
||||
|
||||
// Resets lex in 'thd' and keeps a copy of the old one.
|
||||
void
|
||||
bool
|
||||
reset_lex(THD *thd);
|
||||
|
||||
// Restores lex in 'thd' from our copy, but keeps some status from the
|
||||
|
|
|
@ -80,7 +80,6 @@ bool Prelock_error_handler::safely_trapped_errors()
|
|||
return ((m_handled_errors > 0) && (m_unhandled_errors == 0));
|
||||
}
|
||||
|
||||
|
||||
TABLE *unused_tables; /* Used by mysql_test */
|
||||
HASH open_cache; /* Used by mysql_test */
|
||||
|
||||
|
@ -2653,7 +2652,7 @@ int open_tables(THD *thd, TABLE_LIST **start, uint *counter, uint flags)
|
|||
temporary mem_root for new .frm parsing.
|
||||
TODO: variables for size
|
||||
*/
|
||||
init_alloc_root(&new_frm_mem, 8024, 8024);
|
||||
init_sql_alloc(&new_frm_mem, 8024, 8024);
|
||||
|
||||
thd->current_tablenr= 0;
|
||||
restart:
|
||||
|
|
|
@ -1283,11 +1283,11 @@ typedef struct st_lex : public Query_tables_list
|
|||
|
||||
struct st_lex_local: public st_lex
|
||||
{
|
||||
static void *operator new(size_t size)
|
||||
static void *operator new(size_t size) throw()
|
||||
{
|
||||
return (void*) sql_alloc((uint) size);
|
||||
}
|
||||
static void *operator new(size_t size, MEM_ROOT *mem_root)
|
||||
static void *operator new(size_t size, MEM_ROOT *mem_root) throw()
|
||||
{
|
||||
return (void*) alloc_root(mem_root, (uint) size);
|
||||
}
|
||||
|
@ -1303,3 +1303,4 @@ extern void lex_start(THD *thd);
|
|||
extern void lex_end(LEX *lex);
|
||||
extern int MYSQLlex(void *arg, void *yythd);
|
||||
extern char *skip_rear_comments(CHARSET_INFO *cs, char *begin, char *end);
|
||||
|
||||
|
|
|
@ -7070,7 +7070,7 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables,
|
|||
|
||||
for (; lock_p < end_p; lock_p++)
|
||||
{
|
||||
if ((*lock_p)->type == TL_WRITE)
|
||||
if ((*lock_p)->type >= TL_WRITE_ALLOW_WRITE)
|
||||
{
|
||||
my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0));
|
||||
return 1;
|
||||
|
|
|
@ -2659,7 +2659,7 @@ Prepared_statement::Prepared_statement(THD *thd_arg, Protocol *protocol_arg)
|
|||
last_errno(0),
|
||||
flags((uint) IS_IN_USE)
|
||||
{
|
||||
init_alloc_root(&main_mem_root, thd_arg->variables.query_alloc_block_size,
|
||||
init_sql_alloc(&main_mem_root, thd_arg->variables.query_alloc_block_size,
|
||||
thd_arg->variables.query_prealloc_size);
|
||||
*last_error= '\0';
|
||||
}
|
||||
|
|
|
@ -2771,7 +2771,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST *src_table,
|
|||
operations on the target table.
|
||||
*/
|
||||
if (lock_and_wait_for_table_name(thd, src_table))
|
||||
goto err;
|
||||
DBUG_RETURN(res);
|
||||
|
||||
pthread_mutex_lock(&LOCK_open);
|
||||
|
||||
|
|
151
sql/sql_yacc.yy
151
sql/sql_yacc.yy
|
@ -1582,8 +1582,8 @@ sp_name:
|
|||
if ($$)
|
||||
$$->init_qname(YYTHD);
|
||||
}
|
||||
;
|
||||
|
||||
;
|
||||
|
||||
sp_a_chistics:
|
||||
/* Empty */ {}
|
||||
| sp_a_chistics sp_chistic {}
|
||||
|
@ -1811,7 +1811,8 @@ sp_decl:
|
|||
{
|
||||
LEX *lex= Lex;
|
||||
|
||||
lex->sphead->reset_lex(YYTHD);
|
||||
if (lex->sphead->reset_lex(YYTHD))
|
||||
MYSQL_YYABORT;
|
||||
lex->spcont->declare_var_boundary($2);
|
||||
}
|
||||
type
|
||||
|
@ -1819,6 +1820,10 @@ sp_decl:
|
|||
{
|
||||
LEX *lex= Lex;
|
||||
sp_pcontext *pctx= lex->spcont;
|
||||
if (pctx == 0)
|
||||
{
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
uint num_vars= pctx->context_var_count();
|
||||
enum enum_field_types var_type= (enum enum_field_types) $4;
|
||||
Item *dflt_value_item= $5;
|
||||
|
@ -1904,12 +1909,15 @@ sp_decl:
|
|||
{
|
||||
i= new sp_instr_hreturn(sp->instructions(), ctx,
|
||||
ctx->current_var_count());
|
||||
if (i == NULL )
|
||||
MYSQL_YYABORT;
|
||||
sp->add_instr(i);
|
||||
}
|
||||
else
|
||||
{ /* EXIT or UNDO handler, just jump to the end of the block */
|
||||
i= new sp_instr_hreturn(sp->instructions(), ctx, 0);
|
||||
|
||||
if (i == NULL)
|
||||
MYSQL_YYABORT;
|
||||
sp->add_instr(i);
|
||||
sp->push_backpatch(i, lex->spcont->last_label()); /* Block end */
|
||||
}
|
||||
|
@ -1937,7 +1945,9 @@ sp_decl:
|
|||
}
|
||||
i= new sp_instr_cpush(sp->instructions(), ctx, $5,
|
||||
ctx->current_cursor_count());
|
||||
sp->add_instr(i);
|
||||
if ( i==NULL )
|
||||
MYSQL_YYABORT;
|
||||
sp->add_instr(i);
|
||||
ctx->push_cursor(&$2);
|
||||
$$.vars= $$.conds= $$.hndlrs= 0;
|
||||
$$.curs= 1;
|
||||
|
@ -1946,7 +1956,8 @@ sp_decl:
|
|||
|
||||
sp_cursor_stmt:
|
||||
{
|
||||
Lex->sphead->reset_lex(YYTHD);
|
||||
if(Lex->sphead->reset_lex(YYTHD))
|
||||
MYSQL_YYABORT;
|
||||
|
||||
/* We use statement here just be able to get a better
|
||||
error message. Using 'select' works too, but will then
|
||||
|
@ -2112,7 +2123,8 @@ sp_proc_stmt:
|
|||
LEX *lex= thd->lex;
|
||||
Lex_input_stream *lip= thd->m_lip;
|
||||
|
||||
lex->sphead->reset_lex(thd);
|
||||
if (lex->sphead->reset_lex(thd))
|
||||
MYSQL_YYABORT;
|
||||
lex->sphead->m_tmp_query= lip->tok_start;
|
||||
}
|
||||
statement
|
||||
|
@ -2137,9 +2149,10 @@ sp_proc_stmt:
|
|||
lex->var_list.is_empty());
|
||||
if (lex->sql_command != SQLCOM_SET_OPTION)
|
||||
{
|
||||
sp_instr_stmt *i=new sp_instr_stmt(sp->instructions(),
|
||||
sp_instr_stmt *i= new sp_instr_stmt(sp->instructions(),
|
||||
lex->spcont, lex);
|
||||
|
||||
if (i == NULL)
|
||||
MYSQL_YYABORT;
|
||||
/*
|
||||
Extract the query statement from the tokenizer. The
|
||||
end is either lex->ptr, if there was no lookahead,
|
||||
|
@ -2157,7 +2170,10 @@ sp_proc_stmt:
|
|||
sp->restore_lex(thd);
|
||||
}
|
||||
| RETURN_SYM
|
||||
{ Lex->sphead->reset_lex(YYTHD); }
|
||||
{
|
||||
if(Lex->sphead->reset_lex(YYTHD))
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
expr
|
||||
{
|
||||
LEX *lex= Lex;
|
||||
|
@ -2174,6 +2190,8 @@ sp_proc_stmt:
|
|||
|
||||
i= new sp_instr_freturn(sp->instructions(), lex->spcont, $3,
|
||||
sp->m_return_field_def.sql_type, lex);
|
||||
if (i == NULL)
|
||||
MYSQL_YYABORT;
|
||||
sp->add_instr(i);
|
||||
sp->m_flags|= sp_head::HAS_RETURN;
|
||||
}
|
||||
|
@ -2216,12 +2234,23 @@ sp_proc_stmt:
|
|||
uint n;
|
||||
|
||||
n= ctx->diff_handlers(lab->ctx, TRUE); /* Exclusive the dest. */
|
||||
|
||||
if (n)
|
||||
sp->add_instr(new sp_instr_hpop(ip++, ctx, n));
|
||||
{
|
||||
sp_instr_hpop *hpop= new sp_instr_hpop(ip++, ctx, n);
|
||||
if (hpop == NULL)
|
||||
MYSQL_YYABORT;
|
||||
sp->add_instr(hpop);
|
||||
}
|
||||
n= ctx->diff_cursors(lab->ctx, TRUE); /* Exclusive the dest. */
|
||||
if (n)
|
||||
sp->add_instr(new sp_instr_cpop(ip++, ctx, n));
|
||||
{
|
||||
sp_instr_cpop *cpop= new sp_instr_cpop(ip++, ctx, n);
|
||||
sp->add_instr(cpop);
|
||||
}
|
||||
i= new sp_instr_jump(ip, ctx);
|
||||
if (i == NULL)
|
||||
MYSQL_YYABORT;
|
||||
sp->push_backpatch(i, lab); /* Jumping forward */
|
||||
sp->add_instr(i);
|
||||
}
|
||||
|
@ -2246,11 +2275,19 @@ sp_proc_stmt:
|
|||
|
||||
n= ctx->diff_handlers(lab->ctx, FALSE); /* Inclusive the dest. */
|
||||
if (n)
|
||||
sp->add_instr(new sp_instr_hpop(ip++, ctx, n));
|
||||
{
|
||||
sp_instr_hpop *hpop= new sp_instr_hpop(ip++, ctx, n);
|
||||
sp->add_instr(hpop);
|
||||
}
|
||||
n= ctx->diff_cursors(lab->ctx, FALSE); /* Inclusive the dest. */
|
||||
if (n)
|
||||
sp->add_instr(new sp_instr_cpop(ip++, ctx, n));
|
||||
{
|
||||
sp_instr_cpop *cpop= new sp_instr_cpop(ip++, ctx, n);
|
||||
sp->add_instr(cpop);
|
||||
}
|
||||
i= new sp_instr_jump(ip, ctx, lab->ip); /* Jump back */
|
||||
if (i == NULL)
|
||||
MYSQL_YYABORT;
|
||||
sp->add_instr(i);
|
||||
}
|
||||
}
|
||||
|
@ -2267,6 +2304,8 @@ sp_proc_stmt:
|
|||
MYSQL_YYABORT;
|
||||
}
|
||||
i= new sp_instr_copen(sp->instructions(), lex->spcont, offset);
|
||||
if (i == NULL)
|
||||
MYSQL_YYABORT;
|
||||
sp->add_instr(i);
|
||||
}
|
||||
| FETCH_SYM sp_opt_fetch_noise ident INTO
|
||||
|
@ -2282,6 +2321,8 @@ sp_proc_stmt:
|
|||
MYSQL_YYABORT;
|
||||
}
|
||||
i= new sp_instr_cfetch(sp->instructions(), lex->spcont, offset);
|
||||
if (i == NULL)
|
||||
MYSQL_YYABORT;
|
||||
sp->add_instr(i);
|
||||
}
|
||||
sp_fetch_list
|
||||
|
@ -2299,6 +2340,8 @@ sp_proc_stmt:
|
|||
MYSQL_YYABORT;
|
||||
}
|
||||
i= new sp_instr_cclose(sp->instructions(), lex->spcont, offset);
|
||||
if (i == NULL)
|
||||
MYSQL_YYABORT;
|
||||
sp->add_instr(i);
|
||||
}
|
||||
;
|
||||
|
@ -2354,7 +2397,10 @@ sp_fetch_list:
|
|||
;
|
||||
|
||||
sp_if:
|
||||
{ Lex->sphead->reset_lex(YYTHD); }
|
||||
{
|
||||
if (Lex->sphead->reset_lex(YYTHD))
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
expr THEN_SYM
|
||||
{
|
||||
LEX *lex= Lex;
|
||||
|
@ -2363,7 +2409,8 @@ sp_if:
|
|||
uint ip= sp->instructions();
|
||||
sp_instr_jump_if_not *i = new sp_instr_jump_if_not(ip, ctx,
|
||||
$2, lex);
|
||||
|
||||
if (i == NULL)
|
||||
MYSQL_YYABORT;
|
||||
sp->push_backpatch(i, ctx->push_label((char *)"", 0));
|
||||
sp->add_cont_backpatch(i);
|
||||
sp->add_instr(i);
|
||||
|
@ -2375,7 +2422,8 @@ sp_if:
|
|||
sp_pcontext *ctx= Lex->spcont;
|
||||
uint ip= sp->instructions();
|
||||
sp_instr_jump *i = new sp_instr_jump(ip, ctx);
|
||||
|
||||
if (i == NULL)
|
||||
MYSQL_YYABORT;
|
||||
sp->add_instr(i);
|
||||
sp->backpatch(ctx->pop_label());
|
||||
sp->push_backpatch(i, ctx->push_label((char *)"", 0));
|
||||
|
@ -2404,7 +2452,8 @@ simple_case_stmt:
|
|||
{
|
||||
LEX *lex= Lex;
|
||||
case_stmt_action_case(lex);
|
||||
lex->sphead->reset_lex(YYTHD); /* For expr $3 */
|
||||
if (lex->sphead->reset_lex(YYTHD))
|
||||
MYSQL_YYABORT; /* For expr $3 */
|
||||
}
|
||||
expr
|
||||
{
|
||||
|
@ -2453,7 +2502,8 @@ searched_when_clause_list:
|
|||
simple_when_clause:
|
||||
WHEN_SYM
|
||||
{
|
||||
Lex->sphead->reset_lex(YYTHD); /* For expr $3 */
|
||||
if (Lex->sphead->reset_lex(YYTHD))
|
||||
MYSQL_YYABORT; /* For expr $3 */
|
||||
}
|
||||
expr
|
||||
{
|
||||
|
@ -2474,7 +2524,8 @@ simple_when_clause:
|
|||
searched_when_clause:
|
||||
WHEN_SYM
|
||||
{
|
||||
Lex->sphead->reset_lex(YYTHD); /* For expr $3 */
|
||||
if (Lex->sphead->reset_lex(YYTHD))
|
||||
MYSQL_YYABORT; /* For expr $3 */
|
||||
}
|
||||
expr
|
||||
{
|
||||
|
@ -2498,6 +2549,8 @@ else_clause_opt:
|
|||
uint ip= sp->instructions();
|
||||
sp_instr_error *i= new sp_instr_error(ip, lex->spcont,
|
||||
ER_SP_CASE_NOT_FOUND);
|
||||
if (i == NULL)
|
||||
MYSQL_YYABORT;
|
||||
sp->add_instr(i);
|
||||
}
|
||||
| ELSE sp_proc_stmts1
|
||||
|
@ -2567,11 +2620,21 @@ sp_unlabeled_control:
|
|||
|
||||
sp->backpatch(ctx->last_label()); /* We always have a label */
|
||||
if ($3.hndlrs)
|
||||
sp->add_instr(new sp_instr_hpop(sp->instructions(), ctx,
|
||||
$3.hndlrs));
|
||||
{
|
||||
sp_instr_hpop *hpop= new sp_instr_hpop(sp->instructions(), ctx,
|
||||
$3.hndlrs);
|
||||
if (hpop == NULL)
|
||||
MYSQL_YYABORT;
|
||||
sp->add_instr(hpop);
|
||||
}
|
||||
if ($3.curs)
|
||||
sp->add_instr(new sp_instr_cpop(sp->instructions(), ctx,
|
||||
$3.curs));
|
||||
{
|
||||
sp_instr_cpop *cpop= new sp_instr_cpop(sp->instructions(), ctx,
|
||||
$3.curs);
|
||||
if (cpop == NULL)
|
||||
MYSQL_YYABORT;
|
||||
sp->add_instr(cpop);
|
||||
}
|
||||
lex->spcont= ctx->pop_context();
|
||||
}
|
||||
| LOOP_SYM
|
||||
|
@ -2581,11 +2644,15 @@ sp_unlabeled_control:
|
|||
uint ip= lex->sphead->instructions();
|
||||
sp_label_t *lab= lex->spcont->last_label(); /* Jumping back */
|
||||
sp_instr_jump *i = new sp_instr_jump(ip, lex->spcont, lab->ip);
|
||||
|
||||
if (i == NULL)
|
||||
MYSQL_YYABORT;
|
||||
lex->sphead->add_instr(i);
|
||||
}
|
||||
| WHILE_SYM
|
||||
{ Lex->sphead->reset_lex(YYTHD); }
|
||||
{
|
||||
if (Lex->sphead->reset_lex(YYTHD))
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
expr DO_SYM
|
||||
{
|
||||
LEX *lex= Lex;
|
||||
|
@ -2593,7 +2660,8 @@ sp_unlabeled_control:
|
|||
uint ip= sp->instructions();
|
||||
sp_instr_jump_if_not *i = new sp_instr_jump_if_not(ip, lex->spcont,
|
||||
$3, lex);
|
||||
|
||||
if (i == NULL)
|
||||
MYSQL_YYABORT;
|
||||
/* Jumping forward */
|
||||
sp->push_backpatch(i, lex->spcont->last_label());
|
||||
sp->new_cont_backpatch(i);
|
||||
|
@ -2606,12 +2674,16 @@ sp_unlabeled_control:
|
|||
uint ip= lex->sphead->instructions();
|
||||
sp_label_t *lab= lex->spcont->last_label(); /* Jumping back */
|
||||
sp_instr_jump *i = new sp_instr_jump(ip, lex->spcont, lab->ip);
|
||||
|
||||
if (i == NULL)
|
||||
MYSQL_YYABORT;
|
||||
lex->sphead->add_instr(i);
|
||||
lex->sphead->do_cont_backpatch();
|
||||
}
|
||||
| REPEAT_SYM sp_proc_stmts1 UNTIL_SYM
|
||||
{ Lex->sphead->reset_lex(YYTHD); }
|
||||
{
|
||||
if (Lex->sphead->reset_lex(YYTHD))
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
expr END REPEAT_SYM
|
||||
{
|
||||
LEX *lex= Lex;
|
||||
|
@ -2620,6 +2692,8 @@ sp_unlabeled_control:
|
|||
sp_instr_jump_if_not *i = new sp_instr_jump_if_not(ip, lex->spcont,
|
||||
$5, lab->ip,
|
||||
lex);
|
||||
if (i == NULL)
|
||||
MYSQL_YYABORT;
|
||||
lex->sphead->add_instr(i);
|
||||
lex->sphead->restore_lex(YYTHD);
|
||||
/* We can shortcut the cont_backpatch here */
|
||||
|
@ -4149,6 +4223,8 @@ select_init2:
|
|||
select_part2
|
||||
{
|
||||
LEX *lex= Lex;
|
||||
if (lex == NULL)
|
||||
MYSQL_YYABORT;
|
||||
SELECT_LEX * sel= lex->current_select;
|
||||
if (lex->current_select->set_braces(0))
|
||||
{
|
||||
|
@ -4508,6 +4584,8 @@ predicate:
|
|||
$7->push_front($5);
|
||||
$7->push_front($1);
|
||||
Item_func_in *item = new (YYTHD->mem_root) Item_func_in(*$7);
|
||||
if (item == NULL)
|
||||
MYSQL_YYABORT;
|
||||
item->negate();
|
||||
$$= item;
|
||||
}
|
||||
|
@ -4968,7 +5046,8 @@ simple_expr:
|
|||
{
|
||||
LEX *lex= Lex;
|
||||
sp_name *name= new sp_name($1, $3, true);
|
||||
|
||||
if (name == NULL)
|
||||
MYSQL_YYABORT;
|
||||
name->init_qname(YYTHD);
|
||||
sp_add_used_routine(lex, YYTHD, name, TYPE_ENUM_FUNCTION);
|
||||
if ($5)
|
||||
|
@ -5105,8 +5184,9 @@ simple_expr:
|
|||
as a last choice. This later can lead to ER_SP_DOES_NOT_EXIST.
|
||||
*/
|
||||
sp_name *name= new sp_name(db, $1, false);
|
||||
if (name)
|
||||
name->init_qname(thd);
|
||||
if (name == NULL)
|
||||
MYSQL_YYABORT;
|
||||
name->init_qname(thd);
|
||||
|
||||
sp_add_used_routine(lex, YYTHD, name, TYPE_ENUM_FUNCTION);
|
||||
if ($4)
|
||||
|
@ -8360,7 +8440,8 @@ option_type_value:
|
|||
|
||||
QQ: May be we should simply prohibit group assignments in SP?
|
||||
*/
|
||||
Lex->sphead->reset_lex(thd);
|
||||
if (Lex->sphead->reset_lex(thd))
|
||||
MYSQL_YYABORT;
|
||||
lex= thd->lex;
|
||||
|
||||
/* Set new LEX as if we at start of set rule. */
|
||||
|
@ -8525,6 +8606,8 @@ sys_option_value:
|
|||
it= spv->dflt;
|
||||
else
|
||||
it= new Item_null();
|
||||
if (it == NULL)
|
||||
MYSQL_YYABORT;
|
||||
sp_set= new sp_instr_set(lex->sphead->instructions(), ctx,
|
||||
spv->offset, it, spv->type, lex, TRUE);
|
||||
lex->sphead->add_instr(sp_set);
|
||||
|
@ -9900,6 +9983,8 @@ sp_tail:
|
|||
|
||||
/* Order is important here: new - reset - init */
|
||||
sp= new sp_head();
|
||||
if (sp == NULL)
|
||||
MYSQL_YYABORT;
|
||||
sp->reset_thd_mem_root(YYTHD);
|
||||
sp->init(lex);
|
||||
sp->m_type= TYPE_ENUM_PROCEDURE;
|
||||
|
|
Loading…
Reference in a new issue