Below is the list of changes that have just been committed into a local
5.0 repository of pem. When pem does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.1960 05/11/01 14:58:52 pem@stripped +5 -0
Fixed BUG#14376: MySQL crash on scoped variable (re)initialization
Added finer scope control for default clauses of local variable
declarations.
sql/sql_yacc.yy
1.439 05/11/01 14:58:45 pem@stripped +7 -1
Make the variables of the current DECLARE "invisible" to its DEFAULT clause.
sql/sp_pcontext.h
1.22 05/11/01 14:58:45 pem@stripped +16 -0
Added boundary variable for local parameters/variables,
for better scope control of default values.
sql/sp_pcontext.cc
1.25 05/11/01 14:58:45 pem@stripped +3 -2
Added boundary variable for local parameters/variables,
for better scope control of default values.
mysql-test/t/sp.test
1.162 05/11/01 14:58:45 pem@stripped +45 -0
New test case for BUG#14376.
mysql-test/r/sp.result
1.169 05/11/01 14:58:44 pem@stripped +29 -0
New test case for BUG#14376.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: pem
# Host: mysql.comhem.se
# Root: /usr/home/pem/bug14376/mysql-5.0
--- 1.438/sql/sql_yacc.yy 2005-10-28 12:11:24 +02:00
+++ 1.439/sql/sql_yacc.yy 2005-11-01 14:58:45 +01:00
@@ -1660,7 +1660,12 @@
sp_decl:
DECLARE_SYM sp_decl_idents type
- { Lex->sphead->reset_lex(YYTHD); }
+ {
+ LEX *lex= Lex;
+
+ lex->sphead->reset_lex(YYTHD);
+ lex->spcont->declare_var_boundary($2);
+ }
sp_opt_default
{
LEX *lex= Lex;
@@ -1690,6 +1695,7 @@
lex->sphead->add_instr(in);
ctx->set_default(i, it);
}
+ ctx->declare_var_boundary(0);
lex->sphead->restore_lex(YYTHD);
$$.vars= $2;
$$.conds= $$.hndlrs= $$.curs= 0;
--- 1.168/mysql-test/r/sp.result 2005-10-27 23:24:02 +02:00
+++ 1.169/mysql-test/r/sp.result 2005-11-01 14:58:44 +01:00
@@ -3575,4 +3575,33 @@
DROP PROCEDURE IF EXISTS bug13095;
DROP VIEW IF EXISTS bug13095_v1;
DROP TABLE IF EXISTS bug13095_t1;
+drop procedure if exists bug14376|
+create procedure bug14376()
+begin
+declare x int default x;
+end|
+call bug14376()|
+ERROR 42S22: Unknown column 'x' in 'field list'
+drop procedure bug14376|
+create procedure bug14376()
+begin
+declare x int default 42;
+begin
+declare x int default x;
+select x;
+end;
+end|
+call bug14376()|
+x
+42
+drop procedure bug14376|
+create procedure bug14376(x int)
+begin
+declare x int default x;
+select x;
+end|
+call bug14376(4711)|
+x
+4711
+drop procedure bug14376|
drop table t1,t2;
--- 1.161/mysql-test/t/sp.test 2005-10-24 22:53:55 +02:00
+++ 1.162/mysql-test/t/sp.test 2005-11-01 14:58:45 +01:00
@@ -4490,6 +4490,51 @@
#
+# BUG#14376: MySQL crash on scoped variable (re)initialization
+#
+--disable_warnings
+drop procedure if exists bug14376|
+--enable_warnings
+
+create procedure bug14376()
+begin
+ declare x int default x;
+end|
+
+# Not the error we want, but that's what we got for now...
+--error ER_BAD_FIELD_ERROR
+call bug14376()|
+drop procedure bug14376|
+
+create procedure bug14376()
+begin
+ declare x int default 42;
+
+ begin
+ declare x int default x;
+
+ select x;
+ end;
+end|
+
+call bug14376()|
+
+drop procedure bug14376|
+
+create procedure bug14376(x int)
+begin
+ declare x int default x;
+
+ select x;
+end|
+
+call bug14376(4711)|
+
+drop procedure bug14376|
+
+
+
+#
# BUG#NNNN: New bug synopsis
#
#--disable_warnings
--- 1.24/sql/sp_pcontext.cc 2005-09-13 12:50:11 +02:00
+++ 1.25/sql/sp_pcontext.cc 2005-11-01 14:58:45 +01:00
@@ -52,7 +52,7 @@
sp_pcontext::sp_pcontext(sp_pcontext *prev)
: Sql_alloc(), m_psubsize(0), m_csubsize(0), m_hsubsize(0),
- m_handlers(0), m_parent(prev)
+ m_handlers(0), m_parent(prev), m_pboundary(0)
{
VOID(my_init_dynamic_array(&m_pvar, sizeof(sp_pvar_t *), 16, 8));
VOID(my_init_dynamic_array(&m_cond, sizeof(sp_cond_type_t *), 16, 8));
@@ -150,7 +150,7 @@
sp_pvar_t *
sp_pcontext::find_pvar(LEX_STRING *name, my_bool scoped)
{
- uint i= m_pvar.elements;
+ uint i= m_pboundary;
while (i--)
{
@@ -186,6 +186,7 @@
p->offset= current_pvars();
p->dflt= NULL;
insert_dynamic(&m_pvar, (gptr)&p);
+ m_pboundary= m_pvar.elements;
}
}
--- 1.21/sql/sp_pcontext.h 2005-09-13 12:50:11 +02:00
+++ 1.22/sql/sp_pcontext.h 2005-11-01 14:58:45 +01:00
@@ -164,6 +164,7 @@
{
while (num--)
pop_dynamic(&m_pvar);
+ m_pboundary= m_pvar.elements;
}
// Find by name
@@ -183,6 +184,14 @@
return p;
}
+ // Set the current scope boundary (for default values)
+ // The argument is the number of variables to skip.
+ inline void
+ declare_var_boundary(uint n)
+ {
+ m_pboundary= m_pvar.elements-n;
+ }
+
//
// Labels
//
@@ -287,6 +296,13 @@
uint m_poffset; // Variable offset for this context
uint m_coffset; // Cursor offset for this context
+ /*
+ Boundary for finding variables in this in this context.
+ This is normally the same as m_pvar.elements, but differs during
+ parsing of DECLARE ... DEFAULT, to get the scope right for DEFAULT
+ values.
+ */
+ uint m_pboundary;
DYNAMIC_ARRAY m_pvar; // Parameters/variables
DYNAMIC_ARRAY m_cond; // Conditions
| Thread |
|---|
| • bk commit into 5.0 tree (pem:1.1960) BUG#14376 | pem | 1 Nov |