MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:Alexander Nozdrin Date:October 25 2005 9:02am
Subject:bk commit into 5.0 tree (anozdrin:1.2026) BUG#13037
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of alik. When alik 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.2026 05/10/25 13:02:48 anozdrin@stripped +5 -0
  Fix for BUG#13037: undefined variable in IF cause erroneous error-message.

  sql/sql_class.h
    1.271 05/10/25 13:02:41 anozdrin@stripped +8 -0
    Introduce a constant for the default value of THD::where.

  sql/sql_class.cc
    1.217 05/10/25 13:02:41 anozdrin@stripped +5 -1
    Reset THD::where in THD::cleanup_after_query();
    Polishing: use the constant (THD::DEFAULT_WHERE).

  sql/sql_base.cc
    1.312 05/10/25 13:02:41 anozdrin@stripped +1 -1
    Polishing: use constant.

  mysql-test/t/sp-error.test
    1.92 05/10/25 13:02:41 anozdrin@stripped +54 -0
    Test case for BUG#13037.

  mysql-test/r/sp-error.result
    1.88 05/10/25 13:02:41 anozdrin@stripped +35 -2
    Results for the test case for BUG#13037.

# 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:	anozdrin
# Host:	station.home
# Root:	/home/alik/Documents/AllProgs/MySQL/devel/5.0-bug13037

--- 1.311/sql/sql_base.cc	2005-10-17 22:47:29 +04:00
+++ 1.312/sql/sql_base.cc	2005-10-25 13:02:41 +04:00
@@ -4272,7 +4272,7 @@
 
   thd->set_query_id=set_query_id;
   thd->allow_sum_func= allow_sum_func;
-  thd->where="field list";
+  thd->where= THD::DEFAULT_WHERE;
 
   /*
     To prevent fail on forward lookup we fill it with zerows,

--- 1.216/sql/sql_class.cc	2005-10-19 01:52:02 +04:00
+++ 1.217/sql/sql_class.cc	2005-10-25 13:02:41 +04:00
@@ -44,6 +44,8 @@
 */
 char internal_table_name[2]= "*";
 
+const char * const THD::DEFAULT_WHERE= "field list";
+
 
 /*****************************************************************************
 ** Instansiate templates
@@ -234,7 +236,7 @@
 
   /* Variables with default values */
   proc_info="login";
-  where="field list";
+  where= THD::DEFAULT_WHERE;
   server_id = ::server_id;
   slave_net = 0;
   command=COM_CONNECT;
@@ -545,6 +547,8 @@
   }
   /* Free Items that were created during this execution */
   free_items();
+  /* Reset where. */
+  where= THD::DEFAULT_WHERE;
 }
 
 /*

--- 1.270/sql/sql_class.h	2005-10-17 19:08:56 +04:00
+++ 1.271/sql/sql_class.h	2005-10-25 13:02:41 +04:00
@@ -1109,6 +1109,14 @@
            public Open_tables_state
 {
 public:
+  /*
+    Constant for THD::where initialization in the beginning of every query.
+
+    It's needed because we do not save/restore THD::where normally during
+    primary (non subselect) query execution.
+  */
+  static const char * const DEFAULT_WHERE;
+
 #ifdef EMBEDDED_LIBRARY
   struct st_mysql  *mysql;
   struct st_mysql_data *data;

--- 1.87/mysql-test/r/sp-error.result	2005-10-19 14:45:59 +04:00
+++ 1.88/mysql-test/r/sp-error.result	2005-10-25 13:02:41 +04:00
@@ -444,9 +444,9 @@
 end if;
 end|
 call bug2653_1(1, @b)|
-ERROR 42S22: Unknown column 'aa' in 'order clause'
+ERROR 42S22: Unknown column 'aa' in 'field list'
 call bug2653_2(2, @b)|
-ERROR 42S22: Unknown column 'aa' in 'order clause'
+ERROR 42S22: Unknown column 'aa' in 'field list'
 drop procedure bug2653_1|
 drop procedure bug2653_2|
 create procedure bug4344() drop procedure bug4344|
@@ -883,3 +883,36 @@
 end|
 ERROR 3D000: No database selected
 use test;
+DROP PROCEDURE IF EXISTS bug13037_p1;
+DROP PROCEDURE IF EXISTS bug13037_p2;
+DROP PROCEDURE IF EXISTS bug13037_p3;
+CREATE PROCEDURE bug13037_p1()
+BEGIN
+IF bug13037_foo THEN
+SELECT 1;
+END IF;
+END|
+CREATE PROCEDURE bug13037_p2()
+BEGIN
+SET @bug13037_foo = bug13037_bar;
+END|
+CREATE PROCEDURE bug13037_p3()
+BEGIN
+SELECT bug13037_foo;
+END|
+
+CALL bug13037_p1();
+ERROR 42S22: Unknown column 'bug13037_foo' in 'field list'
+CALL bug13037_p2();
+ERROR 42S22: Unknown column 'bug13037_bar' in 'field list'
+CALL bug13037_p3();
+ERROR 42S22: Unknown column 'bug13037_foo' in 'field list'
+CALL bug13037_p1();
+ERROR 42S22: Unknown column 'bug13037_foo' in 'field list'
+CALL bug13037_p2();
+ERROR 42S22: Unknown column 'bug13037_bar' in 'field list'
+CALL bug13037_p3();
+ERROR 42S22: Unknown column 'bug13037_foo' in 'field list'
+DROP PROCEDURE bug13037_p1;
+DROP PROCEDURE bug13037_p2;
+DROP PROCEDURE bug13037_p3;

--- 1.91/mysql-test/t/sp-error.test	2005-10-19 14:45:59 +04:00
+++ 1.92/mysql-test/t/sp-error.test	2005-10-25 13:02:41 +04:00
@@ -1284,6 +1284,60 @@
 end|
 delimiter ;|
 use test;
+
+
+#
+# BUG#13037: undefined variable in IF cause erroneous error-message
+#
+
+--disable_warnings
+DROP PROCEDURE IF EXISTS bug13037_p1;
+DROP PROCEDURE IF EXISTS bug13037_p2;
+DROP PROCEDURE IF EXISTS bug13037_p3;
+--enable_warnings
+
+delimiter |;
+
+CREATE PROCEDURE bug13037_p1()
+BEGIN
+  IF bug13037_foo THEN
+    SELECT 1;
+  END IF;
+END|
+
+CREATE PROCEDURE bug13037_p2()
+BEGIN
+  SET @bug13037_foo = bug13037_bar;
+END|
+
+CREATE PROCEDURE bug13037_p3()
+BEGIN
+  SELECT bug13037_foo;
+END|
+
+delimiter ;|
+
+--echo
+
+--error 1054
+CALL bug13037_p1();
+--error 1054
+CALL bug13037_p2();
+--error 1054
+CALL bug13037_p3();
+
+--error 1054
+CALL bug13037_p1();
+--error 1054
+CALL bug13037_p2();
+--error 1054
+CALL bug13037_p3();
+
+DROP PROCEDURE bug13037_p1;
+DROP PROCEDURE bug13037_p2;
+DROP PROCEDURE bug13037_p3;
+
+
 # BUG#NNNN: New bug synopsis
 #
 #--disable_warnings
Thread
bk commit into 5.0 tree (anozdrin:1.2026) BUG#13037Alexander Nozdrin25 Oct