mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Fix for BUG#13549 "Server crash with nested stored procedures
if inner routine has more local variables than outer one, and one of its last variables was used as argument to NOT operator". THD::spcont was non-0 when we were parsing stored routine/trigger definition during execution of another stored routine. This confused methods of Item_splocal and forced them use wrong runtime context. Fix ensures that we always have THD::spcont equal to zero during routine/trigger body parsing. This also allows to avoid problems with errors which occur during parsing and SQL exception handlers.
This commit is contained in:
@ -494,7 +494,7 @@ void Protocol::init(THD *thd_arg)
|
||||
thd=thd_arg;
|
||||
packet= &thd->packet;
|
||||
convert= &thd->convert_buffer;
|
||||
#ifndef DEBUG_OFF
|
||||
#ifndef DBUG_OFF
|
||||
field_types= 0;
|
||||
#endif
|
||||
}
|
||||
@ -547,7 +547,7 @@ bool Protocol::send_fields(List<Item> *list, uint flags)
|
||||
(void) my_net_write(&thd->net, buff,(uint) (pos-buff));
|
||||
}
|
||||
|
||||
#ifndef DEBUG_OFF
|
||||
#ifndef DBUG_OFF
|
||||
field_types= (enum_field_types*) thd->alloc(sizeof(field_types) *
|
||||
list->elements);
|
||||
uint count= 0;
|
||||
@ -644,7 +644,7 @@ bool Protocol::send_fields(List<Item> *list, uint flags)
|
||||
item->send(&prot, &tmp); // Send default value
|
||||
if (prot.write())
|
||||
break; /* purecov: inspected */
|
||||
#ifndef DEBUG_OFF
|
||||
#ifndef DBUG_OFF
|
||||
field_types[count++]= field.type;
|
||||
#endif
|
||||
}
|
||||
@ -728,14 +728,14 @@ bool Protocol::store(I_List<i_string>* str_list)
|
||||
void Protocol_simple::prepare_for_resend()
|
||||
{
|
||||
packet->length(0);
|
||||
#ifndef DEBUG_OFF
|
||||
#ifndef DBUG_OFF
|
||||
field_pos= 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Protocol_simple::store_null()
|
||||
{
|
||||
#ifndef DEBUG_OFF
|
||||
#ifndef DBUG_OFF
|
||||
field_pos++;
|
||||
#endif
|
||||
char buff[1];
|
||||
@ -769,7 +769,7 @@ bool Protocol::store_string_aux(const char *from, uint length,
|
||||
bool Protocol_simple::store(const char *from, uint length,
|
||||
CHARSET_INFO *fromcs, CHARSET_INFO *tocs)
|
||||
{
|
||||
#ifndef DEBUG_OFF
|
||||
#ifndef DBUG_OFF
|
||||
DBUG_ASSERT(field_types == 0 ||
|
||||
field_types[field_pos] == MYSQL_TYPE_DECIMAL ||
|
||||
field_types[field_pos] == MYSQL_TYPE_BIT ||
|
||||
@ -786,7 +786,7 @@ bool Protocol_simple::store(const char *from, uint length,
|
||||
CHARSET_INFO *fromcs)
|
||||
{
|
||||
CHARSET_INFO *tocs= this->thd->variables.character_set_results;
|
||||
#ifndef DEBUG_OFF
|
||||
#ifndef DBUG_OFF
|
||||
DBUG_ASSERT(field_types == 0 ||
|
||||
field_types[field_pos] == MYSQL_TYPE_DECIMAL ||
|
||||
field_types[field_pos] == MYSQL_TYPE_BIT ||
|
||||
@ -801,7 +801,7 @@ bool Protocol_simple::store(const char *from, uint length,
|
||||
|
||||
bool Protocol_simple::store_tiny(longlong from)
|
||||
{
|
||||
#ifndef DEBUG_OFF
|
||||
#ifndef DBUG_OFF
|
||||
DBUG_ASSERT(field_types == 0 || field_types[field_pos] == MYSQL_TYPE_TINY);
|
||||
field_pos++;
|
||||
#endif
|
||||
@ -813,7 +813,7 @@ bool Protocol_simple::store_tiny(longlong from)
|
||||
|
||||
bool Protocol_simple::store_short(longlong from)
|
||||
{
|
||||
#ifndef DEBUG_OFF
|
||||
#ifndef DBUG_OFF
|
||||
DBUG_ASSERT(field_types == 0 ||
|
||||
field_types[field_pos] == MYSQL_TYPE_YEAR ||
|
||||
field_types[field_pos] == MYSQL_TYPE_SHORT);
|
||||
@ -827,7 +827,7 @@ bool Protocol_simple::store_short(longlong from)
|
||||
|
||||
bool Protocol_simple::store_long(longlong from)
|
||||
{
|
||||
#ifndef DEBUG_OFF
|
||||
#ifndef DBUG_OFF
|
||||
DBUG_ASSERT(field_types == 0 ||
|
||||
field_types[field_pos] == MYSQL_TYPE_INT24 ||
|
||||
field_types[field_pos] == MYSQL_TYPE_LONG);
|
||||
@ -841,7 +841,7 @@ bool Protocol_simple::store_long(longlong from)
|
||||
|
||||
bool Protocol_simple::store_longlong(longlong from, bool unsigned_flag)
|
||||
{
|
||||
#ifndef DEBUG_OFF
|
||||
#ifndef DBUG_OFF
|
||||
DBUG_ASSERT(field_types == 0 ||
|
||||
field_types[field_pos] == MYSQL_TYPE_LONGLONG);
|
||||
field_pos++;
|
||||
@ -856,7 +856,7 @@ bool Protocol_simple::store_longlong(longlong from, bool unsigned_flag)
|
||||
|
||||
bool Protocol_simple::store_decimal(const my_decimal *d)
|
||||
{
|
||||
#ifndef DEBUG_OFF
|
||||
#ifndef DBUG_OFF
|
||||
DBUG_ASSERT(field_types == 0 ||
|
||||
field_types[field_pos] == MYSQL_TYPE_NEWDECIMAL);
|
||||
field_pos++;
|
||||
@ -870,7 +870,7 @@ bool Protocol_simple::store_decimal(const my_decimal *d)
|
||||
|
||||
bool Protocol_simple::store(float from, uint32 decimals, String *buffer)
|
||||
{
|
||||
#ifndef DEBUG_OFF
|
||||
#ifndef DBUG_OFF
|
||||
DBUG_ASSERT(field_types == 0 ||
|
||||
field_types[field_pos] == MYSQL_TYPE_FLOAT);
|
||||
field_pos++;
|
||||
@ -882,7 +882,7 @@ bool Protocol_simple::store(float from, uint32 decimals, String *buffer)
|
||||
|
||||
bool Protocol_simple::store(double from, uint32 decimals, String *buffer)
|
||||
{
|
||||
#ifndef DEBUG_OFF
|
||||
#ifndef DBUG_OFF
|
||||
DBUG_ASSERT(field_types == 0 ||
|
||||
field_types[field_pos] == MYSQL_TYPE_DOUBLE);
|
||||
field_pos++;
|
||||
@ -896,7 +896,7 @@ bool Protocol_simple::store(Field *field)
|
||||
{
|
||||
if (field->is_null())
|
||||
return store_null();
|
||||
#ifndef DEBUG_OFF
|
||||
#ifndef DBUG_OFF
|
||||
field_pos++;
|
||||
#endif
|
||||
char buff[MAX_FIELD_WIDTH];
|
||||
@ -917,7 +917,7 @@ bool Protocol_simple::store(Field *field)
|
||||
|
||||
bool Protocol_simple::store(TIME *tm)
|
||||
{
|
||||
#ifndef DEBUG_OFF
|
||||
#ifndef DBUG_OFF
|
||||
DBUG_ASSERT(field_types == 0 ||
|
||||
field_types[field_pos] == MYSQL_TYPE_DATETIME ||
|
||||
field_types[field_pos] == MYSQL_TYPE_TIMESTAMP);
|
||||
@ -940,7 +940,7 @@ bool Protocol_simple::store(TIME *tm)
|
||||
|
||||
bool Protocol_simple::store_date(TIME *tm)
|
||||
{
|
||||
#ifndef DEBUG_OFF
|
||||
#ifndef DBUG_OFF
|
||||
DBUG_ASSERT(field_types == 0 ||
|
||||
field_types[field_pos] == MYSQL_TYPE_DATE);
|
||||
field_pos++;
|
||||
@ -959,7 +959,7 @@ bool Protocol_simple::store_date(TIME *tm)
|
||||
|
||||
bool Protocol_simple::store_time(TIME *tm)
|
||||
{
|
||||
#ifndef DEBUG_OFF
|
||||
#ifndef DBUG_OFF
|
||||
DBUG_ASSERT(field_types == 0 ||
|
||||
field_types[field_pos] == MYSQL_TYPE_TIME);
|
||||
field_pos++;
|
||||
@ -1084,7 +1084,7 @@ bool Protocol_prep::store_longlong(longlong from, bool unsigned_flag)
|
||||
|
||||
bool Protocol_prep::store_decimal(const my_decimal *d)
|
||||
{
|
||||
#ifndef DEBUG_OFF
|
||||
#ifndef DBUG_OFF
|
||||
DBUG_ASSERT(field_types == 0 ||
|
||||
field_types[field_pos] == MYSQL_TYPE_NEWDECIMAL);
|
||||
field_pos++;
|
||||
|
Reference in New Issue
Block a user