summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2005-02-05 16:05:46 +0200
committerunknown <monty@mysql.com>2005-02-05 16:05:46 +0200
commit5cf29b3b609f7c3789cb433fc4819b350aad8409 (patch)
treefbf56df2842302d089f0dff84cdfc29a8203bf16
parentc1d06b3cfaa64036de0de4907bc74a7faa4074f1 (diff)
downloadmariadb-git-5cf29b3b609f7c3789cb433fc4819b350aad8409.tar.gz
Fixed bug detected by sp-tests
Cleanup during reviews of new pushed code BUILD/compile-pentium-debug-max: Use --debug=full as default BUILD/compile-pentium-debug: Use --debug=full as default mysys/my_alloc.c: More debugging sql/item_func.cc: Cleanup new code Don't call insert_id() for last_insert_id(value) to avoid side effects sql/item_subselect.cc: Fixed DBUG output sql/sp_head.cc: Simple cleanup sql/sql_lex.cc: Moved usage of arguments first in lex_start to make their usage clearer Remove sl->expr_list.deleete_elements() becasue: - It didn't do anything (delete_elements on a list of list is a no-op operation) - The deleted for loop used SELECT_LEX elements that was allocated in mysql_new_select() in sp-head, but freed when sphead->mem_root was freed. (delete sphead doesn't remove used SELECT_LEX elements from the global all_selects_list) sql/sql_parse.cc: More DBUG entries
-rwxr-xr-xBUILD/compile-pentium-debug2
-rwxr-xr-xBUILD/compile-pentium-debug-max2
-rw-r--r--mysys/my_alloc.c6
-rw-r--r--sql/item_func.cc13
-rw-r--r--sql/item_subselect.cc2
-rw-r--r--sql/sp_head.cc4
-rw-r--r--sql/sql_lex.cc14
-rw-r--r--sql/sql_parse.cc14
8 files changed, 31 insertions, 26 deletions
diff --git a/BUILD/compile-pentium-debug b/BUILD/compile-pentium-debug
index 4a9d0e74599..7957caead29 100755
--- a/BUILD/compile-pentium-debug
+++ b/BUILD/compile-pentium-debug
@@ -1,7 +1,7 @@
#! /bin/sh
path=`dirname $0`
-. "$path/SETUP.sh"
+. "$path/SETUP.sh" $@ --with-debug=full
extra_flags="$pentium_cflags $debug_cflags"
c_warnings="$c_warnings $debug_extra_warnings"
diff --git a/BUILD/compile-pentium-debug-max b/BUILD/compile-pentium-debug-max
index 420657e0b73..7a11ad24c44 100755
--- a/BUILD/compile-pentium-debug-max
+++ b/BUILD/compile-pentium-debug-max
@@ -1,7 +1,7 @@
#! /bin/sh
path=`dirname $0`
-. "$path/SETUP.sh"
+. "$path/SETUP.sh" $@ --with-debug=full
extra_flags="$pentium_cflags $debug_cflags $max_cflags"
c_warnings="$c_warnings $debug_extra_warnings"
diff --git a/mysys/my_alloc.c b/mysys/my_alloc.c
index c14b2899b4b..e0d6288f76b 100644
--- a/mysys/my_alloc.c
+++ b/mysys/my_alloc.c
@@ -166,7 +166,8 @@ gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size)
gptr point;
reg1 USED_MEM *next= 0;
reg2 USED_MEM **prev;
-
+ DBUG_ENTER("alloc_root");
+ DBUG_PRINT("enter",("root: 0x%lx", mem_root));
DBUG_ASSERT(alloc_root_inited(mem_root));
Size= ALIGN_SIZE(Size);
@@ -213,7 +214,8 @@ gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size)
mem_root->used= next;
mem_root->first_block_usage= 0;
}
- return(point);
+ DBUG_PRINT("exit",("ptr: 0x%lx", (ulong) point));
+ DBUG_RETURN(point);
#endif
}
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 8ee1891eafd..134fb3be0e6 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -2377,16 +2377,17 @@ longlong Item_func_release_lock::val_int()
longlong Item_func_last_insert_id::val_int()
{
+ THD *thd= current_thd;
DBUG_ASSERT(fixed == 1);
if (arg_count)
{
- longlong value=args[0]->val_int();
- current_thd->insert_id(value);
- null_value=args[0]->null_value;
+ longlong value= args[0]->val_int();
+ thd->insert_id(value);
+ null_value= args[0]->null_value;
+ return value; // Avoid side effect of insert_id()
}
- else
- current_thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
- return current_thd->insert_id();
+ thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
+ return thd->insert_id();
}
/* This function is just used to test speed of different functions */
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 3ac75bfdd30..b5cb01494fa 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -53,7 +53,7 @@ void Item_subselect::init(st_select_lex *select_lex,
{
DBUG_ENTER("Item_subselect::init");
- DBUG_PRINT("subs", ("select_lex 0x%xl", (ulong) select_lex));
+ DBUG_PRINT("enter", ("select_lex: 0x%x", (ulong) select_lex));
unit= select_lex->master_unit();
if (unit->item)
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 3f2969768c5..d52474998a8 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -424,10 +424,10 @@ sp_head::~sp_head()
void
sp_head::destroy()
{
- DBUG_ENTER("sp_head::destroy");
- DBUG_PRINT("info", ("name: %s", m_name.str));
sp_instr *i;
LEX *lex;
+ DBUG_ENTER("sp_head::destroy");
+ DBUG_PRINT("info", ("name: %s", m_name.str));
for (uint ip = 0 ; (i = get_instr(ip)) ; ip++)
delete i;
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 06e271333bf..0644ca5af68 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -115,9 +115,14 @@ void lex_free(void)
void lex_start(THD *thd, uchar *buf,uint length)
{
LEX *lex= thd->lex;
+ DBUG_ENTER("lex_start");
+
+ lex->thd= lex->unit.thd= thd;
+ lex->buf= lex->ptr= buf;
+ lex->end_of_query= buf+length;
+
lex->unit.init_query();
lex->unit.init_select();
- lex->thd= lex->unit.thd= thd;
lex->select_lex.init_query();
lex->value_list.empty();
lex->update_list.empty();
@@ -150,8 +155,6 @@ void lex_start(THD *thd, uchar *buf,uint length)
lex->empty_field_list_on_rset= 0;
lex->select_lex.select_number= 1;
lex->next_state=MY_LEX_START;
- lex->buf= lex->ptr= buf;
- lex->end_of_query=buf+length;
lex->yylineno = 1;
lex->in_comment=0;
lex->length=0;
@@ -173,14 +176,11 @@ void lex_start(THD *thd, uchar *buf,uint length)
if (lex->spfuns.records)
my_hash_reset(&lex->spfuns);
+ DBUG_VOID_RETURN;
}
void lex_end(LEX *lex)
{
- for (SELECT_LEX *sl= lex->all_selects_list;
- sl;
- sl= sl->next_select_in_list())
- sl->expr_list.delete_elements(); // If error when parsing sql-varargs
x_free(lex->yacc_yyss);
x_free(lex->yacc_yyvs);
}
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index d309f58a37c..2fb90502863 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -4719,19 +4719,21 @@ bool
mysql_new_select(LEX *lex, bool move_down)
{
SELECT_LEX *select_lex;
+ DBUG_ENTER("mysql_new_select");
+
if (!(select_lex= new(lex->thd->mem_root) SELECT_LEX()))
- return 1;
+ DBUG_RETURN(1);
select_lex->select_number= ++lex->thd->select_number;
select_lex->init_query();
select_lex->init_select();
select_lex->parent_lex= lex;
if (move_down)
{
+ SELECT_LEX_UNIT *unit;
lex->subqueries= TRUE;
/* first select_lex of subselect or derived table */
- SELECT_LEX_UNIT *unit;
if (!(unit= new(lex->thd->mem_root) SELECT_LEX_UNIT()))
- return 1;
+ DBUG_RETURN(1);
unit->init_query();
unit->init_select();
@@ -4748,7 +4750,7 @@ mysql_new_select(LEX *lex, bool move_down)
if (lex->current_select->order_list.first && !lex->current_select->braces)
{
my_error(ER_WRONG_USAGE, MYF(0), "UNION", "ORDER BY");
- return 1;
+ DBUG_RETURN(1);
}
select_lex->include_neighbour(lex->current_select);
SELECT_LEX_UNIT *unit= select_lex->master_unit();
@@ -4760,7 +4762,7 @@ mysql_new_select(LEX *lex, bool move_down)
fake SELECT_LEX for UNION processing
*/
if (!(fake= unit->fake_select_lex= new(lex->thd->mem_root) SELECT_LEX()))
- return 1;
+ DBUG_RETURN(1);
fake->include_standalone(unit,
(SELECT_LEX_NODE**)&unit->fake_select_lex);
fake->select_number= INT_MAX;
@@ -4774,7 +4776,7 @@ mysql_new_select(LEX *lex, bool move_down)
select_lex->include_global((st_select_lex_node**)&lex->all_selects_list);
lex->current_select= select_lex;
select_lex->resolve_mode= SELECT_LEX::SELECT_MODE;
- return 0;
+ DBUG_RETURN(0);
}
/*