Commit graph

177 commits

Author SHA1 Message Date
unknown
ef36e81b2a fixed items cleunup for SP (BUG#10136)
mysql-test/r/sp.result:
  test commented until bug#11394 fix
  test for bug#10136
mysql-test/t/sp.test:
  test commented until bug#11394 fix
  bug10136
sql/sp_head.cc:
  fixed items cleunup for SP
2005-06-22 00:17:08 +03:00
unknown
4b0264dffd Merge mysql.com:/usr/local/bk/mysql-5.0
into mysql.com:/home/pem/work/mysql-5.0


mysql-test/r/sp.result:
  Auto merged
mysql-test/t/sp.test:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sp_rcontext.cc:
  Auto merged
2005-06-10 16:56:34 +02:00
unknown
03949f8ce8 Post review and additional fix for BUG#10968: Stored procedures: crash if long loop.
Fixed valgrind complaints. This fixes the memory leak problems for
  procedured, and partially for functions. There's still a leak involving
  results from functions that turned out to be too involved, so it will be
  fixed separately.


mysql-test/r/sp.result:
  Fixed some minor mistake (spotted while debugging).
mysql-test/t/sp.test:
  Fixed some minor mistake (spotted while debugging).
sql/item_func.cc:
  Moved Item_func_sp::cleanup() from item_func.h to ease debugging,
  and made a debug output come out right.
sql/item_func.h:
  Moved Item_func_sp::cleanup() to item_func.cc to ease debugging.
sql/sp_head.cc:
  Fixed valgrind problems with the previous memory leak fix (unit cleanup and
  putting result field in a differen mem_root), and removed prealloc flag from
  init_alloc_root() calls.
sql/sp_rcontext.cc:
  New mem_root pointer used for return fields from functions.
sql/sp_rcontext.h:
  New mem_root pointer used for return fields from functions.
2005-06-10 16:14:01 +02:00
unknown
3b808af0fd sp.test, sp.result:
Added a test case for bug #6866.
sql_select.cc:
  Fixed bug #6866.
  Bug was due to the fact that on_expr was not backed up
  for the second execution of the stored procedure.


sql/sql_select.cc:
  Fixed bug #6866.
  Bug was due to the fact that on_expr was not backed up
  for the second execution of the stored procedure.
mysql-test/r/sp.result:
  Added a test case for bug #6866.
mysql-test/t/sp.test:
  Added a test case for bug #6866.
2005-06-06 06:05:11 -07:00
unknown
77bd9d36e6 Fixed BUG#10961: Stored procedures: crash if select * from dual
Have to catch errors from SELECT when opening a cursor.


mysql-test/r/sp.result:
  New test case for BUG#10961.
mysql-test/t/sp.test:
  New test case for BUG#10961.
sql/protocol.h:
  Init data in Protocol_cursor constructor, for error cases.
sql/sp_head.cc:
  Catch "hidden" errors during SELECT when opening a cursor.
2005-06-01 12:18:41 +02:00
unknown
d5f4c14b6e Fixed BUG#9559: Functions: Numeric Operations using -ve value gives incorrect
results.
  Actually a problem when converting decimal to int for user variables.


mysql-test/r/sp.result:
  New test case for BUG#9559.
mysql-test/t/sp.test:
  New test case for BUG#9559.
sql/item_func.cc:
  Don't set the unsigned flag when converting decimal user var to int.
2005-05-27 14:48:33 +02:00
unknown
d214d50160 merge
mysql-test/t/sp.test:
  Auto merged
sql/item.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
2005-05-09 02:06:18 +03:00
unknown
a6b1546676 Item::fix_field need correct pointer on item reference to chnge it if itis need, so support of correct item address added to SP commands (BUG#5963)
some optimisation of IF/NOT IF ptomised to Pem


mysql-test/r/sp.result:
  test for bug#5963
mysql-test/t/sp.test:
  test for bug#5963
sql/item.cc:
  new method which return reference on Item for SP variables support
sql/item.h:
  comment fixed
  method added
sql/sp_head.cc:
  preparation of item made separate function
  we do not need new constant Item to check IF/IF NOT
  support of passing correct address of item for fix_fields method
sql/sp_rcontext.cc:
  support of Item address passing to fix_fields
sql/sp_rcontext.h:
  support of correct address passing to fix_fields
sql/sql_class.cc:
  support of correct item address passing to fix_field
2005-05-09 01:59:10 +03:00
unknown
81a895f72c Corrections to test "sp", stored procedure "fib" (see entry 9937 in the bug DB).
mysql-test/r/sp.result:
  Correct the result file for the changed test.
mysql-test/t/sp.test:
  1) Correct the "fib" stored procedure and its initial data to be mathematical correct: fib(0) = 0
  2) Do a small run of "fib" first, that is not likely to hit a memory limit (see entry 9937 in the bug DB).
BitKeeper/etc/logging_ok:
  Logging to logging@openlogging.org accepted
2005-05-07 18:06:02 +02:00
unknown
e0313d67cf Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/home/dlenev/src/mysql-5.0-bg9841


mysql-test/r/sp.result:
  Auto merged
2005-05-06 11:18:37 +04:00
unknown
8a27426fcd Tests and results fixed with last precision/decimal related modifications
mysql-test/r/case.result:
  test result fixed
mysql-test/r/create.result:
  test result fixed
mysql-test/r/distinct.result:
  test result fixed
mysql-test/r/func_group.result:
  test result fixed
mysql-test/r/func_op.result:
  test result fixed
mysql-test/r/group_by.result:
  test result fixed
mysql-test/r/metadata.result:
  test result fixed
mysql-test/r/olap.result:
  test result fixed
mysql-test/r/ps_2myisam.result:
  test result fixed
mysql-test/r/ps_3innodb.result:
  test result fixed
mysql-test/r/ps_4heap.result:
  test result fixed
mysql-test/r/ps_5merge.result:
  test result fixed
mysql-test/r/ps_6bdb.result:
  test result fixed
mysql-test/r/ps_7ndb.result:
  test result fixed
mysql-test/r/select.result:
  test result fixed
mysql-test/r/sp.result:
  test result fixed
mysql-test/r/type_decimal.result:
  test result fixed
mysql-test/r/type_newdecimal.result:
  test result fixed
mysql-test/r/union.result:
  test result fixed
mysql-test/r/variables.result:
  test result fixed
mysql-test/t/func_group.test:
  test modified
mysql-test/t/olap.test:
  test modified
mysql-test/t/type_decimal.test:
  test modified
2005-05-06 01:01:39 +05:00
unknown
1e6193caa3 Fix for bug #9841 "Unexpected read lock when trying to update a view in
a stored procedure" (version 2).

To handle updates and inserts into view in SP properly we should set
lock types for tables of the view's main select when we are opening
view for prelocking purproses.


mysql-test/r/sp.result:
  Added test case for bug #9841 "Unexpected read lock when trying to update
  a view in a stored procedure"
mysql-test/t/sp.test:
  Added test case for bug #9841 "Unexpected read lock when trying to update
  a view in a stored procedure"
sql/sql_view.cc:
  mysql_make_view():
    To handle updates and inserts into view in SP properly we should set
    lock types for tables of the view's main select when we are opening
    view for prelocking purproses.
    Also it is more correct to use LEX::select_lex::get_table_list() 
    instead of 'view_tables' variable for obtaining list of those
    tables.
2005-05-05 19:49:15 +04:00
unknown
b318122ce6 Add regression test for calling SOUNDEX() within stored procedure.
The bug appears to have already been fixed. (Bug #7293)


mysql-test/r/sp.result:
  Add results for new test
mysql-test/t/sp.test:
  Add regression test for bug 7293
2005-04-28 14:46:54 -07:00
unknown
83a8ee38e0 Fixed BUG#9004: Inconsistent behaviour of SP re. warnings
mysql-test/r/sp.result:
  New test case for BUG#9004.
  Also updated some other results, since formerly "invisible" (but correct)
  warnings now are visible.
mysql-test/t/sp.test:
  New test case for BUG#9004.
sql/sql_error.cc:
  Don't reset warnings while executing a stored routine.
sql/sql_parse.cc:
  Don't reset warnings while executing a stored routine.
2005-04-22 12:53:48 +02:00
unknown
597f3dfa25 Merge
sql/mysql_priv.h:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
2005-04-21 13:34:39 +01:00
unknown
62556b0023 Bug#8861 - If Return is a YEAR data type, value is not shown in year format
Bug partially fixed by 9775/9102 work on SP function return.


mysql-test/r/sp.result:
  Bug#8861
    Test for bug
mysql-test/t/sp.test:
  Bug#8861
    Test for bug
sql/protocol.cc:
  Bug#8861
    Requires change in assertion
2005-04-21 13:22:47 +01:00
unknown
de8a3b3121 Bug#9775 - Stored procedures: crash if create function that returns enum or set
Fix bug and implement return type casting.


mysql-test/r/sp.result:
  Bug#9775
    Test for bug + feature
  Fix previous tests
mysql-test/t/sp.test:
  Bug#9775
    Test for bug + feature
  Fix previous tests
sql/item_func.cc:
  Bug#9775
    new method Item_func_sp::execute(Field **)
    some optimizations.
sql/item_func.h:
  Bug#9775
    results for Item_func_sp pass through a Field of the return type.
    new method Item_func_sp::execute(Field **)
sql/sp_head.cc:
  Bug#9775
    missing initialiation for type_lengths in sp_head::create_typelib()
2005-04-20 18:08:42 +01:00
unknown
5642bbd35e Fixed BUG#6898: Stored procedure crash if GOTO statements exist
Bug in the optimizer caused an infinite loop for weird code.


mysql-test/r/sp.result:
  New test case for BUG#6898.
mysql-test/t/sp.test:
  New test case for BUG#6898.
sql/sp_head.cc:
  Detect self referencing jumps in the optimizer.
2005-04-20 15:37:07 +02:00
unknown
f054047f02 Bug#7648 - Stored procedure crash when invoking a function that returns a bit
bugfix 9102 corrected the crashing, this corrects the result.


mysql-test/r/sp.result:
  Bug#7648
    New test for bug
mysql-test/t/sp.test:
  Bug#7648
    New test for bug
sql/item_func.h:
  Bug#7648
    Cannot cheat in Item_func_sp::val_int()
2005-04-19 10:51:11 +01:00
unknown
9bf92ed6fe Bug#9102 - Stored proccedures: function which returns blob causes crash
Initialization of fields for sp return type was not complete.


mysql-test/r/sp.result:
  Bug#9102
    Test for bug
mysql-test/t/sp.test:
  Bug#9102
    Test for bug
sql/mysql_priv.h:
  Bug#9102
    new function: sp_prepare_create_field()
sql/sp_head.cc:
  Strip spaces and do charset conversion for sp function typelibs
sql/sql_table.cc:
  Bug#9102
    new function - sp_prepare_create_field()
    prepares create_field in similar way to mysql_prepare_table()
sql/sql_yacc.yy:
  Bug#9102
2005-04-19 09:09:25 +01:00
unknown
53c095f083 Fixed BUG#9902: Crash with simple stored function using user defined variables
... actually, it was a query cache problem. (It shouldn't cache such queries)


mysql-test/r/sp.result:
  Added testcase for BUG#9902.
mysql-test/t/sp.test:
  Added testcase for BUG#9902.
sql/sql_yacc.yy:
  Don't cache queries which are calling stored functions.
2005-04-15 11:06:25 +02:00
unknown
e0fdbeba7e Fixed BUG#9598: stored procedure call within stored procedure
overwrites IN variable
  and added error checking of variables for [IN]OUT parameters while
  rewriting the out parameter handling.


mysql-test/r/sp-error.result:
  New test case for non-variable argument for [IN]OUT parameters.
  (And changed to qualified names in some other error messages.)
mysql-test/r/sp.result:
  New test case for BUG#9598.
mysql-test/t/sp-error.test:
  New test case for non-variable argument for [IN]OUT parameters.
mysql-test/t/sp.test:
  New test case for BUG#9598.
sql/item.h:
  Need to distinguish between SP local variable items and other items,
  for error checking and [IN]OUT parameter handling.
sql/share/errmsg.txt:
  New error message for non-variable arguments for [IN]OUT parameters in stored procedures.
sql/sp_head.cc:
  Rewrote the [IN]OUT parameter handling in procedure invokation, to make
  it work properly when using user variables in sub-calls.
  Also added error checking for non-variable arguments for such parameters
  (and changed to qualified names for wrong number of arg. errors).
sql/sp_rcontext.cc:
  No need to keep track on the out index for an [IN]OUT parameter any more.
sql/sp_rcontext.h:
  No need to keep track on the out index for an [IN]OUT parameter any more.
2005-04-14 14:52:35 +02:00
unknown
e2089cdd23 Fixed BUG#9674: Stored Procs: Using declared vars in algebric operation
causes system crash.


mysql-test/r/sp.result:
  Added test case for BUG#9674.
mysql-test/t/sp.test:
  Added test case for BUG#9674.
sql/item.cc:
  Returning a pointer to a local variable is not a good idea.
  Better to use parameter which is there for exactly this purpose.
2005-04-13 17:43:53 +02:00
unknown
d6c2a1e3d8 Fixed BUG#9856: Stored procedures: crash if handler for sqlexception, not found.
mysql-test/r/sp.result:
  Added test case for BUG#6129.
mysql-test/t/sp.test:
  Added test case for BUG#6129.
sql/sp_pcontext.h:
  Only need one handler counter.
sql/sql_yacc.yy:
  Count handlers correctly.
2005-04-13 16:57:49 +02:00
unknown
a3aed4d8dc Added test case for BUG#6129: Stored procedure won't display @@sql_mode value.
mysql-test/r/sp.result:
  Added testcase for BUG#6129: Check that sql_mode is really set in mysql.proc.
mysql-test/t/sp.test:
  Added testcase for BUG#6129: Check that sql_mode is really set in mysql.proc.
2005-04-13 16:09:28 +02:00
unknown
db40f4a57f Fixed BUG#7185: Stored procedure crash if identifier is AVG
mysql-test/r/sp.result:
  Added test case for BUG#7185.
mysql-test/t/sp.test:
  Added test case for BUG#7185.
sql/sql_yacc.yy:
  Allow non-reserved words as stored procedure names.
2005-04-12 15:43:24 +02:00
unknown
4215d120a3 Fixed BUG#6900: Stored procedure inner handler ignored
and BUG#9074: STORED PROC: The scope of every handler declared is not properly applied


mysql-test/r/sp.result:
  New test cases for BUG#6900 and BUG#9074 (duplicates).
mysql-test/t/sp.test:
  New test cases for BUG#6900 and BUG#9074 (duplicates).
sql/sp_rcontext.cc:
  Corrected logic for finding condition handlers - pick the innermost one.
2005-04-08 17:31:37 +02:00
unknown
b2ff4e9ce5 Moved test for bug #9566 "explicit LOCK TABLE and store procedures result in illegal
state" to sp-error.test.

According to Per-Erik all SP related tests which should result in error
should go into sp-error.test and not in sp.test, because we want to be
able to run sp.test using normal client.


mysql-test/r/sp-error.result:
  Moved test for bug #9566 "explicit LOCK TABLE and store procedures result in illegal
  state" to sp-error.test.
mysql-test/r/sp.result:
  Moved test for bug #9566 "explicit LOCK TABLE and store procedures result in illegal
  state" to sp-error.test.
mysql-test/t/sp-error.test:
  Moved test for bug #9566 "explicit LOCK TABLE and store procedures result in illegal
  state" to sp-error.test.
mysql-test/t/sp.test:
  Moved test for bug #9566 "explicit LOCK TABLE and store procedures result in illegal
  state" to sp-error.test.
2005-04-07 11:57:47 +04:00
unknown
188b8af60c Fix for bug #9566 "explicit LOCK TABLE and store procedures result in
illegal state".

We should not assume that mysql.proc table does not exist if we are
unable to open it under LOCK TABLES or in prelocked mode (and
remember this fact by setting mysql_proc_table_exists to zero).


mysql-test/r/sp.result:
  Added test for bug #9566 "explicit LOCK TABLE and store procedures result in illegal
  state"
mysql-test/t/sp.test:
  Added test for bug #9566 "explicit LOCK TABLE and store procedures result in illegal
  state"
sql/sp.cc:
  db_find_routine_aux():
    We should not assume that mysql.proc table does not exist if we are
    unable to open it under LOCK TABLES or in prelocked mode since this
    condition may be transient.
2005-04-07 01:40:29 +04:00
unknown
5cdec5d6ba Merge
mysql-test/r/create.result:
  Auto merged
mysql-test/r/ctype_latin1_de.result:
  Auto merged
mysql-test/r/grant.result:
  Auto merged
mysql-test/r/grant2.result:
  Auto merged
mysql-test/r/limit.result:
  Auto merged
mysql-test/r/order_by.result:
  Auto merged
mysql-test/r/rpl000001.result:
  Auto merged
mysql-test/r/sp.result:
  Auto merged
mysql-test/r/strict.result:
  Auto merged
mysql-test/r/type_blob.result:
  Auto merged
mysql-test/r/type_ranges.result:
  Auto merged
mysql-test/r/warnings.result:
  Auto merged
mysql-test/t/ctype_latin1_de.test:
  Auto merged
mysql-test/t/limit.test:
  Auto merged
mysql-test/t/order_by.test:
  Auto merged
mysql-test/t/show_check.test:
  Auto merged
mysql-test/t/sp.test:
  Auto merged
mysql-test/t/type_blob.test:
  Auto merged
mysql-test/t/type_ranges.test:
  Auto merged
sql/item.cc:
  Auto merged
sql/item.h:
  Auto merged
sql/sql_insert.cc:
  Auto merged
mysql-test/t/strict.test:
  SCCS merged
2005-04-05 19:45:34 -07:00
unknown
66b71ca378 Fixed BUG#6600: Stored procedure crash after repeated calls with check table.
Sedond attempt: Simply disallow CHECK in SPs, since it can't work.


mysql-test/r/sp-error.result:
  New test cast for BUG#6600
mysql-test/r/sp.result:
  Removed old test case for BUG#6600
mysql-test/t/sp-error.test:
  New test cast for BUG#6600
mysql-test/t/sp.test:
  Removed old test case for BUG#6600
sql/share/errmsg.txt:
  Made the SP bad statement error message more general.
sql/sp_head.cc:
  CHECK is not possible in stored procedures.
sql/sql_parse.cc:
  Undid attempt to fix CHECK in stored procedures, it didn't work.
sql/sql_yacc.yy:
  CHECK is not possible in stored procedures.
  (And updated error messages for LOCK/UNLOCK.)
2005-03-30 17:43:52 +02:00
unknown
d27a709f3d merged
BitKeeper/etc/logging_ok:
  auto-union
mysql-test/r/information_schema.result:
  Auto merged
mysql-test/r/ndb_autodiscover.result:
  Auto merged
mysql-test/r/ps_1general.result:
  Auto merged
mysql-test/r/show_check.result:
  Auto merged
mysql-test/r/sp.result:
  Auto merged
mysql-test/r/view.result:
  Auto merged
scripts/fill_func_tables.sh:
  Auto merged
scripts/mysql_create_system_tables.sh:
  Auto merged
scripts/mysql_fix_privilege_tables.sh:
  Auto merged
scripts/mysql_fix_privilege_tables.sql:
  Auto merged
sql/field.cc:
  Auto merged
sql/handler.cc:
  Auto merged
sql/item_sum.cc:
  Auto merged
sql/item_sum.h:
  Auto merged
sql/sql_acl.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/table.cc:
  Auto merged
2005-03-23 09:42:24 +01:00
unknown
30a2327848 sql_acl.cc, sql_acl.h, sql_parse.cc
New privilege CREATE USER (CREATE_USER_ACL, Create_user_priv) added
grant2.test:
  new tests (mostly backported from jani's patch)
system_mysql_db.result, sp.result, grant2.result, grant.result:
  results updated


mysql-test/r/grant.result:
  results updated
mysql-test/r/grant2.result:
  results updated
mysql-test/r/sp.result:
  results updated
mysql-test/r/system_mysql_db.result:
  results updated
mysql-test/t/grant2.test:
  new tests (mostly backported from jani's patch)
scripts/mysql_create_system_tables.sh:
  Create_user_priv added
scripts/mysql_fix_privilege_tables.sql:
  Create_user_priv added
sql/sql_acl.cc:
  Create_user_priv added
sql/sql_acl.h:
  Create_user_priv added
sql/sql_parse.cc:
  Create_user_priv added
sql/sql_show.cc:
  Create_user_priv added
sql/sql_yacc.yy:
  Create_user_priv added
BitKeeper/etc/logging_ok:
  Logging to logging@openlogging.org accepted
2005-03-22 15:54:18 +01:00
unknown
6c621bbd7f Fixed BUG#6600: Stored procedure crash after repeated calls with check table
mysql-test/r/sp.result:
  New test case for BUG#6600.
mysql-test/t/sp.test:
  New test case for BUG#6600.
sql/sp_head.cc:
  Added yet another multiple result set statement to the list.
sql/sql_parse.cc:
  Have to invalidate SP caches in CHECK TABLE, or it will produce very
  strange results when called in SPs.
2005-03-18 16:52:41 +01:00
unknown
cc9e66f565 sp.test, sp.result:
transactional test removed
sp_trans.test, sp_trans.result:
  new file


mysql-test/r/sp.result:
  transactional test removed
mysql-test/t/sp.test:
  transactional test removed
2005-03-17 22:15:23 +01:00
unknown
1defb94df7 Updated tests results for BUG#8510 2005-03-15 10:27:44 +03:00
unknown
dd2306839a Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into pcgem.rdg.cyberkinetica.com:/var/db/bk/work-acurtis/bug3788.4


mysql-test/r/sp.result:
  Auto merged
mysql-test/t/sp.test:
  Auto merged
sql/sql_parse.cc:
  Auto merged
2005-03-09 01:15:42 +00:00
unknown
ce16c895c2 Merge in fix Bug#3788
mysql-test/r/information_schema.result:
  Auto merged
mysql-test/t/sp.test:
  Auto merged
sql/item.cc:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/item_func.h:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/sp.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sp_head.h:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
mysql-test/r/sp.result:
  Merge
BitKeeper/etc/logging_ok:
  Logging to logging@openlogging.org accepted
2005-03-08 22:32:09 +00:00
unknown
1250899c0d Fixing post-merge errors 2005-03-09 00:09:18 +02:00
unknown
12c6eb3b08 post merge fixes
sql/sql_parse.cc:
  Auto merged
2005-03-08 22:59:21 +02:00
unknown
39c32324d6 making a better test case for bug #8850
mysql-test/r/sp.result:
  fixing results for new test
mysql-test/t/sp.test:
  making a new test with autocommit set to 0 and 1.
  Second CALL is in autocommit mode to prove that the relevant bug 
  (bug #8550) is fixed.
2005-03-08 22:44:35 +02:00
unknown
25f8623fff Fixed BUG#8937: Stored Procedure: AVG() works as SUM() in SELECT ... INTO statement
mysql-test/r/sp.result:
  New test case for BUG#8937.
mysql-test/t/sp.test:
  New test case for BUG#8937.
sql/item_sum.h:
  Added val_int() method for Item_sum_avg for forced int types (in SPs for instance),
  otherwise Item_sum_sum::val_int() is used.
2005-03-07 18:09:53 +01:00
unknown
804a2a8cdf Reorganized sp.test (all bugs at the end now).
mysql-test/r/sp.result:
  Reorganized tests (all bugs at the end now) and made some tests adopt to the file's style.
mysql-test/t/sp.test:
  Reorganized tests (all bugs at the end now) and made some tests adopt to the file's style.
2005-03-07 17:16:37 +01:00
unknown
2fc5d274e8 Fixing bug #8850 in such a way that when TRUNCATE is called within
stored  procedure,  it  is converted  to DELETE.


mysql-test/r/sp.result:
  A result for  the  test  case  for bug #8850
mysql-test/t/sp.test:
  A test  case  for the bug #8850
sql/sql_delete.cc:
  A fix for bug  #8850, plus adding a missing call  to mysql_init_select(),
  which  caused mem_root corruption.
sql/sql_parse.cc:
  A fix for the bug #8850
BitKeeper/etc/ignore:
  Added acinclude.m4 to the ignore list
2005-03-05 21:44:15 +02:00
unknown
1220069c53 Bug#3788
Crashes with stored procedure return non-string values
  Also fixes Bug#2773


mysql-test/r/information_schema.result:
  Bug#3788
    Fix results for bugfix
mysql-test/r/sp.result:
  Bug#3788
    Tests for Bug
    Fix results for bugfix
mysql-test/t/sp.test:
  Bug#3788
    New tests for bug
sql/item.cc:
  Fix unrelated crash in view test with --ps-protocol.
sql/item_func.cc:
  Bug#3788
    Alter how SP function result types are handled.
sql/item_func.h:
  Bug#3788
    Alter how SP function result types are handled.
sql/mysql_priv.h:
  Bug#3788
    Prototypes for new global functions
sql/sp.cc:
  Bug#3788
    Alter how function return type is reported
sql/sp_head.cc:
  Bug#3788
    Change how function return types are stored for SPs
sql/sp_head.h:
  Bug#3788
    Change how function return types are stored for SPs
sql/sql_parse.cc:
  Bug#3788
    Split out field construction into its own function
sql/sql_table.cc:
  Bug#3788
    Split out field preparation code into its own function
sql/sql_yacc.yy:
  Bug#3788
    Change how function return types are stored for SPs
sql/unireg.cc:
  Bug#3788
    Add assertion check
2005-03-04 21:14:35 +00:00
unknown
b1095fb0cd Manual merge SP-locking improvements patch with current tree.
mysql-test/r/mysqldump.result:
  Auto merged
mysql-test/r/sp.result:
  Auto merged
mysql-test/t/mysqldump.test:
  Auto merged
mysql-test/t/sp.test:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/sp.cc:
  Auto merged
sql/sp_rcontext.cc:
  Auto merged
sql/sql_acl.cc:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_lex.cc:
  Auto merged
sql/sql_lex.h:
  Auto merged
sql/sql_prepare.cc:
  Auto merged
sql/sql_update.cc:
  Auto merged
sql/sql_view.cc:
  Auto merged
sql/table.h:
  Auto merged
sql/sp_head.cc:
  Manual merge.
sql/sql_class.cc:
  Manual merge.
sql/sql_parse.cc:
  Manual merge.
sql/sql_yacc.yy:
  Manual merge.
2005-03-04 17:46:45 +03:00
unknown
ac9f68b9fa Better approach for prelocking of tables for stored routines execution
and some SP-related cleanups.

- We don't have separate stage for calculation of list of tables
  to be prelocked and doing implicit LOCK/UNLOCK any more.
  Instead we calculate this list at open_tables() and do implicit
  LOCK in lock_tables() (and UNLOCK in close_thread_tables()).
  Also now we support cases when same table (with same alias) is
  used several times in the same query in SP.

- Cleaned up execution of SP. Moved all common code which handles
  LEX and does preparations before statement execution or complex
  expression evaluation to auxilary sp_lex_keeper class. Now 
  all statements in SP (and corresponding instructions) that
  evaluate expression which can contain subquery have their
  own LEX.


mysql-test/r/lock.result:
  Replaced wrong error code with the correct one after fixing bug in
  SP-locking.
mysql-test/r/mysqldump.result:
  Added dropping of view which is used in test to its beginning.
mysql-test/r/sp.result:
  Added tests for improved SP-locking.
  Temporarily disabled tests for SHOW PROCEDURE STATUS and alike
  (Until Monty will allow to open mysql.proc under LOCK TABLES without
  mentioning it in lock list).
  Replaced wrong results of test for bug #5240 with correct results after
  fixing bug in handling of cursors.
mysql-test/t/lock.test:
  Replaced wrong error code with the correct one after fixing bug in
  SP-locking.
mysql-test/t/mysqldump.test:
  Added dropping of view which is used in test to its beginning.
mysql-test/t/sp.test:
  Added tests for improved SP-locking.
  Temporarily disabled tests for SHOW PROCEDURE STATUS and alike
  (Until Monty will allow to open mysql.proc under LOCK TABLES without
  mentioning it in lock list).
  Removed test for bug #1654 since we already test exactly this function
  in one of SP-locking tests.
  Removed comment about cursor's wrong behavior in test for bug #5240
  after fixing bug which was its cause.
sql/item_func.cc:
  Removed comment which is no longer true.
sql/mysql_priv.h:
  Changed open_tables() signature.
  Now its 2nd parameter is in/out since it can add elements to table list.
sql/sp.cc:
  sp_find_procedure():
   Added one more parameter which enforces cache only lookup.
  
  sp_merge_hash():
   Now uses its return value to indicate that first of two hashes changed
   as result of merge.
  
  sp_cache_routines():
   This function caches all stored routines used in query now.
sql/sp.h:
  - sp_find_procedure() now has one more parameter which enforces cache only
    lookup.
  - sp_merge_hash() now uses its return value to indicate that first of two
    hashes changed as result of merge.
  - sp_cache_routines() caches all stored routines now. So it does not need
    third argument any more.
sql/sp_head.cc:
  sp_head::sp_head():
   Added initialization of new m_spfuns and m_spprocs members.
  
  sp_head::execute():
   Let us save/restore part of thread context which can be damaged by
   execution of instructions.
  sp_head::execute_function()/execute_procedure():
   Now it is responsibility of caller to close tables used in
   subqueries which are passed as routine parameters.
  
  sp_head::restore_lex():
   Let us accumulate information about routines used by this one
   in new m_spfuns, m_spprocs hashes.
  
  sp_lex_keeper::reset_lex_and_exec_core()
   Main method of new auxilary sp_lex_keeper class to which instructions 
   delegate responsibility for handling LEX and preparations before
   executing statement or calculating complex expression.
  
  Since all instructions which calculate complex expression or execute
  command now use sp_lex_keeper they have to implement
  sp_instr::exec_core() method. Most of instruction specific logic
  has moved from sp_instr::execute() to this new method.
  
  Removed sp_instr_set_user_var class which is no longer used, because
  nowdays we allow execution of statements in stored functions and
  triggers.
  
  sp_merge_table_list() became sp_head::merge_table_list() method. It
  also treats sp_head::m_sptabs as multi-set of tables now.
  
  sp_hash_to_table_list() became sp_head::add_used_tables_to_table_list().
  It takes into account that sp_head::m_sptabs is multi-set and allocates
  object into persistent arena of PS.
  
  Removed sp_merge_table_hash(), sp_open_and_lock_tables(),
  sp_unlock_tables(), sp_merge_routine_tables() methods since they are not
  used by new prelocking mechanism.
  
  Added sp_add_sp_tables_to_table_list() which serves for adding tables needed
  by routines used in query to the query table list for prelocking.
sql/sp_head.h:
  class sp_head:
  - Added m_spfuns, m_spprocs members for storing names of routines used
    by this routine.
  - Added add_used_tables_to_table_list() method which allows to add
    tables needed by this routine to query's table list.
  - Converted sp_merge_table_list() to sp_head::merge_table_list() method.
  - Changed semantics of THD::m_sptabs. Now it is multi-set which contains
    only tables which are used by this routine and not routines that are
    called from this one.
  
  Removed sp_merge_routine_tables(), sp_merge_table_hash(),
  sp_open_and_lock_tables(), sp_unlock_tables() calls since they are not
  used for our prelocking list calculation.
  
  Added auxilary sp_lex_keeper class to which instructions delegate
  responsibility for handling LEX and preparations before executing
  statement or calculating complex expression. This class uses
  new sp_instr::exec_core() method which is responsible for executing
  instruction's core function after all preparations were made.
  
  All instructions which hold and calculate complex expression now have
  their own LEX (by aggregating sp_lex_keeper instance). sp_instr_stmt
  now uses sp_lex_keeper too.
  
  Removed sp_instr_set_user_var class which is no longer used, because
  nowdays we allow execution of statements in stored functions and
  triggers.
sql/sp_rcontext.cc:
  Now sp_cursor holds pointer to sp_lex_keeper instead of LEX.
sql/sp_rcontext.h:
  Now sp_cursor holds pointer to sp_lex_keeper instead of LEX.
sql/sql_acl.cc:
  acl_init(), grant_init():
    Now we use simple_open_n_lock_tables() instead of explicit
    calls to open_tables() and mysql_lock_tables().
sql/sql_base.cc:
  Implemented support for execution of statements in "prelocked" mode.
  
  When we have statement which uses stored routines explicitly or
  implicitly (via views or triggers) we have to open and lock all tables
  for these routines at the same time as tables for the main statement.
  In fact we have to do implicit LOCK TABLES at the begining of such
  statement and implict UNLOCK TABLES at its end. We call such mode
  "prelocked".
  
  When open_tables() is called for the statement tables which are needed
  for execution of routines used by it are added to its tables list
  (this process also caches all routines used). Implicit use of routines
  is discovered when we open view or table with trigger and apropriate
  tables are added to the table list at this moment. Statement which has
  such extra tables in its list (well actually any that uses functions)
  is marked as requiring prelocked mode for its execution.
  
  When lock_tables() sees such statement it will issue implicit LOCK TABLES
  for this extended table list instead of doing usual locking, it will also
  set THD::prelocked_mode to indicate that we are in prelocked mode.
  
  When open_tables()/lock_tables() are called for statement of stored
  routine (substatement), they notice that we are running in prelocked mode
  and use one of prelocked tables from those that are not used by upper
  levels of execution.
  
  close_thread_tables() for substatement won't really close tables used
  but will mark them as free for reuse instead.
  
  Finally when close_thread_tables() is called for the main statement it
  really unlocks and closes all tables used.
  
  Everything will work even if one uses such statement under real LOCK
  TABLES (we are simply not doing implicit LOCK/UNLOCK in this case).
sql/sql_class.cc:
  Added initialization of THD::prelocked_mode member.
sql/sql_class.h:
  - Added prelocked_mode_type enum and THD::prelocked_mode member
    which are used for indication whenever "prelocked mode" is on 
    (i.e. that statement uses stored routines and is executed under
     implicit LOCK TABLES).
  - Removed THD::shortcut_make_view which is no longer needed.
    We use TABLE_LIST::prelocking_placeholder for the same purprose
    now.
sql/sql_handler.cc:
  Changed open_tables() invocation.
  Now its 2nd parameter is in/out since it can add elements to table list.
sql/sql_lex.cc:
  lex_start():
    Added initialization of LEX::query_tables_own_last.
    Unused LEX::sptabs member was removed.
  st_lex::unlink_first_table()/link_first_table_back():
    We should update LEX::query_tables_last properly if table list
    contains(ed) only one element.
sql/sql_lex.h:
  LEX:
  - Removed sptabs member since it is no longer used.
  - Added query_tables_own_last member, which if non-0 indicates that
    statement requires prelocking (implicit LOCK TABLES) for its execution
    and points to last own element in query table list. If it is zero
    then this query does not need prelocking.
  - Added requires_prelocking(), mark_as_requiring_prelocking(),
    first_not_own_table() inline methods to incapsulate and simplify
    usage of this new member.
sql/sql_parse.cc:
  dispatch_command():
    To properly leave prelocked mode when needed we should call
    close_thread_tables() even if there are no open tables.
  mysql_execute_command():
  - Removed part of function which were responsible for doing implicit
    LOCK TABLES before statement execution if statement used stored 
    routines (and doing UNLOCK TABLES at the end).
    Now we do all this in open_tables()/lock_tables()/close_thread_tables()
    instead.
  - It is also sensible to reset errors before execution of statement
    which uses routines.
  - SQLCOM_DO, SQLCOM_SET_OPTION, SQLCOM_CALL
    We should always try to open tables because even if statement has empty
    table list, it can call routines using tables, which should be preopened
    before statement execution.
  - SQLCOM_CALL
    We should not look up routine called in mysql.proc, since it should be
    already cached by this moment by open_tables() call.
  - SQLCOM_LOCK_TABLES
    it is better to use simple_open_n_lock_tables() since we want to avoid
    materialization of derived tables for this command.
sql/sql_prepare.cc:
  mysql_test_update():
    Changed open_tables() invocations. Now its 2nd parameter is in/out
    since it can add elements to table list.
  check_prepared_statement():
    Since now we cache all routines used by statement in open_tables() we 
    don't need to do it explicitly.
  mysql_stmt_prepare():
    Now we should call close_thread_tables() when THD::lex points to the
    LEX of statement which opened tables.
  reset_stmt_for_execute():
    Commented why we are resetting all tables in table list.
sql/sql_trigger.h:
  Table_triggers_list::process_triggers():
    We should surpress sending of ok packet when we are calling trigger's
    routine, since now we allow statements in them.
sql/sql_update.cc:
  Changed open_tables() invocations.
  Now its 2nd parameter is in/out since it can add elements to table list.
sql/sql_view.cc:
  mysql_make_view():
  - Removed handling of routines used in view. Instead we add tables which
    are needed for their execution to statement's table list in 
    open_tables().
  - Now we use TABLE_LIST::prelocking_placeholder instead of 
    THD::shortcut_make_view for indicating that view is opened
    only to discover which tables and routines it uses (this happens
    when we build extended table list for prelocking). Also now we try
    to avoid to modify main LEX in this case (except of its table list).
  - Corrected small error we added tables to the table list of the main
    LEX without updating its query_tables_last member properly.
sql/sql_yacc.yy:
  Now each expression which is used in SP statements and can contain
  subquery has its own LEX. This LEX is stored in corresponding sp_instr
  object and used along with Item tree for expression calculation.
  
  We don't need sp_instr_set_user_var() anymore since now we allow
  execution of statements in stored functions and triggers.
sql/table.h:
  Added TABLE_LIST::prelocking_placeholder member for distinguishing
  elements of table list which does not belong to the statement itself
  and added there only for prelocking (as they are to be used by routines
  called by this statement).
sql/tztime.cc:
  my_tz_init():
    Now we use more simplier simple_open_n_lock_tables() call instead of 
    open_tables()/lock_tables() pair.
2005-03-04 16:35:28 +03:00
unknown
2860a7723e Fixes for bug#8115 "Server Crash with prepared statement"
and bug#8849 "problem with insert statement with table alias's": 
make equality propagation work in stored procedures and prepared 
statements.
Equality propagation can change AND/OR structure of ON expressions,
so the fix is to provide each execution of PS/SP with it's own
copy of AND/OR tree. We have been doing that already for WHERE clauses,
now ON clauses are also copied.


mysql-test/r/ps.result:
  Bug#8115: test results fixed.
mysql-test/r/sp.result:
  Bug#8849: test results fixed.
mysql-test/t/ps.test:
  A test case for Bug#8115 "Server Crash with prepared statement".
mysql-test/t/sp.test:
  A test case for Bug#8849 "problem with insert statement with table 
  alias's".
sql/item_cmpfunc.cc:
  Comment a parse tree transformation.
sql/item_cmpfunc.h:
  Comment how Item_equal works with PS/SP.
sql/mysql_priv.h:
  Add declaration for init_stmt_after_parse.
sql/sp_head.cc:
  Call init_stmt_after_parse in restore_lex(), which is used to
  grab TABLE_LIST and SELECT_LEX list of a parsed substatement of
  stored procedure. This is a necessary post-init step which 
  must be done for any statement which can be executed many times.
sql/sql_prepare.cc:
  Implement init_stmt_after_parse() which prepares AND/OR
  structure of all ON expressions and WHERE clauses of a statement
  for copying.
sql/sql_select.cc:
  Implementation of equality propagation inspected with regard to 
  prepared statements and stored procedures. We now restore
  AND/OR structure of every ON expression in addition to AND/OR
  structure of WHERE clauses when reexecuting a PS/SP.
sql/table.h:
  Add declaration for TABLE::prep_on_expr.
2005-03-03 17:38:59 +03:00
unknown
5699934fe0 Fixed BUG#8762: Stored Procedures: Inconsistent behavior
of DROP PROCEDURE IF EXISTS statement.


mysql-test/r/sp.result:
  New test case for BUG#8757
mysql-test/t/sp.test:
  New test case for BUG#8757
sql/sp.cc:
  Don't zap lex->found_semicolon. (For compound statements)
2005-03-02 17:25:58 +01:00
unknown
3d8aed6d83 Fixed BUG#8757: Stored Procedures: Scope of Begin and End Statements do not work properly.
mysql-test/r/sp.result:
  New test case for BUG#8757.
mysql-test/t/sp.test:
  New test case for BUG#8757.
sql/sp_pcontext.cc:
  Return the correct scope offset to cursors during parsing.
2005-02-25 17:56:45 +01:00