diff options
author | unknown <pem@mysql.com> | 2003-07-01 17:19:48 +0200 |
---|---|---|
committer | unknown <pem@mysql.com> | 2003-07-01 17:19:48 +0200 |
commit | 31a58c4068e28405a8b23722b39033eb175b5dcf (patch) | |
tree | a7c0b59acbef6d1a7936f138012b646d8f3be77c /sql | |
parent | 663ac86f6cd55b4a22a91c312ccc17fa4fdf158c (diff) | |
download | mariadb-git-31a58c4068e28405a8b23722b39033eb175b5dcf.tar.gz |
Bugfixes for the sp_head memroot stuff.
sql/sp.cc:
Bugfixes for the sp_head memroot stuff. (Do things in the correct order
at error clean-up.)
sql/sp_head.cc:
Bugfixes for the sp_head memroot stuff. Make sure everything goes to the
right memroot. Need separate post-reset-memroot init in sp_head.
sql/sp_head.h:
Need separate post-reset-memroot init method.
sql/sql_yacc.yy:
Bugfixes for the sp_head memroot stuff. Make sure everything goes to the
right memroot. Must do things in the correct order for this.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sp.cc | 13 | ||||
-rw-r--r-- | sql/sp_head.cc | 23 | ||||
-rw-r--r-- | sql/sp_head.h | 6 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 30 |
4 files changed, 46 insertions, 26 deletions
diff --git a/sql/sp.cc b/sql/sp.cc index 8fd0273fcce..79beb78e3e5 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -147,12 +147,15 @@ db_find_routine(THD *thd, int type, char *name, uint namelen, sp_head **sphp) lex_start(thd, (uchar*)defstr, strlen(defstr)); if (yyparse(thd) || thd->is_fatal_error || thd->lex->sphead == NULL) { - if (thd->lex->sphead) + LEX *newlex= thd->lex; + sp_head *sp= newlex->sphead; + + if (sp) { - if (oldlex != thd->lex) - thd->lex->sphead->restore_lex(thd); - delete thd->lex->sphead; - thd->lex= NULL; + if (oldlex != newlex) + sp->restore_lex(thd); + delete sp; + newlex->sphead= NULL; } ret= SP_PARSE_ERROR; } diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 51fc7b1ef94..b9360a35593 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -119,18 +119,27 @@ sp_head::operator delete(void *ptr, size_t size) DBUG_VOID_RETURN; } -sp_head::sp_head(LEX_STRING *name, LEX *lex, LEX_STRING *comment, char suid) - : Sql_alloc(), m_simple_case(FALSE), m_multi_query(FALSE) +sp_head::sp_head() + : Sql_alloc(), m_simple_case(FALSE), m_multi_query(FALSE), m_free_list(NULL) { DBUG_ENTER("sp_head::sp_head"); + + m_backpatch.empty(); + m_lex.empty(); + DBUG_VOID_RETURN; +} + +void +sp_head::init(LEX_STRING *name, LEX *lex, LEX_STRING *comment, char suid) +{ + DBUG_ENTER("sp_head::init"); const char *dstr = (const char*)lex->buf; - DBUG_PRINT("info", ("name: %s", name->str)); + DBUG_PRINT("info", ("name: %*s", name->length, name->str)); m_name.length= name->length; - m_name.str= name->str; + m_name.str= lex->thd->strmake(name->str, name->length); m_defstr.length= lex->end_of_query - lex->buf; m_defstr.str= lex->thd->strmake(dstr, m_defstr.length); - m_free_list= NULL; m_comment.length= 0; m_comment.str= 0; @@ -141,10 +150,8 @@ sp_head::sp_head(LEX_STRING *name, LEX *lex, LEX_STRING *comment, char suid) } m_suid= suid; - m_pcont= lex->spcont; + lex->spcont= m_pcont= new sp_pcontext(); my_init_dynamic_array(&m_instr, sizeof(sp_instr *), 16, 8); - m_backpatch.empty(); - m_lex.empty(); DBUG_VOID_RETURN; } diff --git a/sql/sp_head.h b/sql/sp_head.h index dc27da5c5b2..df551897fbb 100644 --- a/sql/sp_head.h +++ b/sql/sp_head.h @@ -60,7 +60,11 @@ public: static void operator delete(void *ptr, size_t size); - sp_head(LEX_STRING *name, LEX *lex, LEX_STRING *comment, char suid); + sp_head(); + + // Initialize after we have reset mem_root + void + init(LEX_STRING *name, LEX *lex, LEX_STRING *comment, char suid); int create(THD *thd); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 98270b93cb7..b4065a7d095 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -931,24 +931,27 @@ create: | CREATE PROCEDURE ident { LEX *lex= Lex; + sp_head *sp; if (lex->sphead) { net_printf(YYTHD, ER_SP_NO_RECURSIVE_CREATE, "PROCEDURE"); YYABORT; } - lex->spcont= new sp_pcontext(); - lex->sphead= new sp_head(&$3, lex, 0, 0); - lex->sphead->m_type= TYPE_ENUM_PROCEDURE; + /* Order is important here: new - reset - init */ + sp= new sp_head(); + sp->reset_thd_mem_root(YYTHD); + sp->init(&$3, lex, 0, 0); + + sp->m_type= TYPE_ENUM_PROCEDURE; + lex->sphead= sp; /* * We have to turn of CLIENT_MULTI_QUERIES while parsing a * stored procedure, otherwise yylex will chop it into pieces * at each ';'. */ - lex->sphead->m_old_cmq= - YYTHD->client_capabilities & CLIENT_MULTI_QUERIES; + sp->m_old_cmq= YYTHD->client_capabilities & CLIENT_MULTI_QUERIES; YYTHD->client_capabilities &= (~CLIENT_MULTI_QUERIES); - lex->sphead->reset_thd_mem_root(YYTHD); } '(' sp_pdparam_list ')' { @@ -982,24 +985,27 @@ create_function_tail: | '(' { LEX *lex= Lex; + sp_head *sp; if (lex->sphead) { net_printf(YYTHD, ER_SP_NO_RECURSIVE_CREATE, "FUNCTION"); YYABORT; } - lex->spcont= new sp_pcontext(); - lex->sphead= new sp_head(&lex->udf.name, lex, 0, 0); - lex->sphead->m_type= TYPE_ENUM_FUNCTION; + /* Order is important here: new - reset - init */ + sp= new sp_head(); + sp->reset_thd_mem_root(YYTHD); + sp->init(&lex->udf.name, lex, 0, 0); + + sp->m_type= TYPE_ENUM_FUNCTION; + lex->sphead= sp; /* * We have to turn of CLIENT_MULTI_QUERIES while parsing a * stored procedure, otherwise yylex will chop it into pieces * at each ';'. */ - lex->sphead->m_old_cmq= - YYTHD->client_capabilities & CLIENT_MULTI_QUERIES; + sp->m_old_cmq= YYTHD->client_capabilities & CLIENT_MULTI_QUERIES; YYTHD->client_capabilities &= ~CLIENT_MULTI_QUERIES; - lex->sphead->reset_thd_mem_root(YYTHD); } sp_fdparam_list ')' { |