Commit graph

293 commits

Author SHA1 Message Date
anozdrin@mysql.com
65b87b86a3 Fix for BUG#18587: Function that accepts and returns TEXT
garbles data if longer than 766 chars.

The problem is that a stored routine returns BLOBs to the previous
caller, BLOBs are shallow-copied (i.e. only pointers to the data are
copied). The fix is to also copy data of BLOBs.
2006-05-10 23:16:30 +04:00
dlenev@mysql.com
b9d49ee894 Merge bk-internal.mysql.com:/home/bk/mysql-5.0-runtime
into  mysql.com:/home/dlenev/mysql-5.0-bg12472
2006-05-09 16:48:23 +04:00
dlenev@mysql.com
589daad10f Fix for bugs#12472/#15137 'CREATE TABLE ... SELECT ... which explicitly
or implicitly uses stored function gives "Table not locked" error'

CREATE TABLE ... SELECT ... statement which was explicitly or implicitly
(through view) using stored function gave "Table not locked" error.

The actual bug resides in the current locking scheme of CREATE TABLE SELECT
code, which first opens and locks tables of the SELECT statement itself,
and then, having SELECT tables locked, creates the .FRM, opens the .FRM and
acquires lock on it. This scheme opens a possibility for a deadlock, which
was present and ignored since version 3.23 or earlier. This scheme also
conflicts with the invariant of the prelocking algorithm -- no table can
be open and locked while there are tables locked in prelocked mode.

The patch makes an exception for this invariant when doing CREATE TABLE ...
SELECT, thus extending the possibility of a deadlock to the prelocked mode.
We can't supply a better fix in 5.0.
2006-05-09 16:39:11 +04:00
kroki@mysql.com
b0c1e49a11 Bug#15728: LAST_INSERT_ID function inside a stored function returns 0
Do not reset value of LAST_INSERT_ID() in sub-statement.
2006-04-21 18:55:04 +04:00
pem@mysql.com
9eb230f9bd Fixed BUG#18344: DROP DATABASE does not drop associated routines
We must use the db key length in sp_drop_db_routines (and not the
  number of characters), or long db names will be truncated in the key.
2006-04-18 16:01:01 +02:00
pem@mysql.com
868ffcca86 Merge mysql.com:/extern/mysql/bk/mysql-5.0-runtime
into  mysql.com:/extern/mysql/5.0/bug18787/mysql-5.0-runtime
2006-04-18 11:20:18 +02:00
pem@mysql.com
57107fc975 Fixed BUG#18787: Server crashed when calling a stored procedure containing
a misnamed function
  ... in the presence of a continue handler. The problem was that with a
  handler, it continued to execute as if function existed and had set a
  useful return value (which it hadn't).
  The fix is to set a null return value and do an error return when a function
  wasn't found.
2006-04-11 12:17:57 +02:00
svoj@april.(none)
209682e051 Fix for bug#14945 "Truncate table doesn't reset the auto_increment
counter".

When TRUNCATE TABLE was called within an stored procedure the
auto_increment counter was not reset to 0 even if straight
TRUNCATE for this table did this.

This fix makes TRUNCATE in stored procedures to be handled exactly
in the same way as straight TRUNCATE. We achieve this by rolling
back the fix for bug 8850, which is no longer needed since stored
procedures don't require prelocked mode anymore (and TRUNCATE is
not allowed in stored functions or triggers).
2006-04-06 15:19:01 +05:00
pem@mysql.com
1a1da0e3ef Merge mysql.com:/extern/mysql/bk/mysql-5.0-runtime
into  mysql.com:/extern/mysql/5.0/bug16474/mysql-5.0-runtime
2006-03-28 14:18:47 +02:00
pem@mysql.com
b310d4fb4d Post review fixes for BUG#16474: SP crashed MySQL. 2006-03-28 14:16:21 +02:00
pem@mysql.com
61f2dc713b Fixed BUG#16474: SP crashed MySQL
fix_fields() was not called for "order by" variables if the type was a
  "constant integer", and thus interpreted as a column index.
  However, a local variable is an expression and should not be interpreted
  as a column index. Instead it behaves just like when using a user variable
  for instance (i.e. it will not affect the ordering).
2006-03-10 14:04:56 +01:00
evgen@moonbone.local
c5493b6316 Fixed bug#13575: SP funcs in select with distinct/group and order by can
produce wrong data

By default Item_sp_func::val_str() returns string from it's result_field 
internal buffer. When grouping is present Item_copy_string is used to 
store SP function result, but it doesn't additionally buffer the result.
When the next record is read, internal buffer is overwritten, due to
this Item_copy_string::val_str() will have wrong data. Thus producing
weird query result.

The Item_func_sp::val_str() now makes a copy of returned value to prevent
occasional corruption.
2006-03-10 13:53:00 +03:00
msvensson@neptunus.(none)
e28000c201 Merge neptunus.(none):/home/msvensson/mysql/bug10656/my50-bug10656
into  neptunus.(none):/home/msvensson/mysql/mysql-5.0
2006-03-09 13:11:40 +01:00
msvensson@neptunus.(none)
a7b954447f Bug#10656 Stored Procedure - Create index and Truncate table command error
-Add test case
Move testcase that needs innodb from sp.test => sp_trans.test
2006-03-09 12:08:23 +01:00
anozdrin@mysql.com
d9d4dc5ef8 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/home/alik/Documents/AllProgs/MySQL/devel/5.0-rt
2006-03-07 14:28:09 +03:00
pem@mysql.com
2b6f510350 Merge mysql.com:/extern/mysql/5.0/bug16887/mysql-5.0-runtime
into  mysql.com:/extern/mysql/5.0/bug16887/mysql-5.0
2006-03-03 19:18:17 +01:00
ramil@mysql.com
1a07140515 Merge rkalimullin@bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/usr/home/ram/work/5.0.b17615
2006-03-03 09:35:25 +04:00
pem@mysql.com
d85e929547 Fixed BUG#17476: Stored procedure not returning data when it is called first
time per connection
  Removed const_string() method from Item_string (it was only used in one
  place, in a bad way). Defer possible SP variable, and access data directly
  instead, in date_format item.
2006-03-02 14:54:04 +01:00
anozdrin@mysql.com
fbb5920399 Implementation of WL#2897: Complete definer support in the stored routines.
The idea is to add DEFINER-clause in CREATE PROCEDURE and CREATE FUNCTION
statements. Almost all support of definer in stored routines had been already
done before this patch.

NOTE: this patch changes behaviour of dumping stored routines in mysqldump.
Before this patch, mysqldump did not dump DEFINER-clause for stored routines
and this was documented behaviour. In order to get full information about stored
routines, one should have dumped mysql.proc table. This patch changes this
behaviour, so that DEFINER-clause is dumped.

Since DEFINER-clause is not supported in CREATE PROCEDURE | FUNCTION statements
before this patch, the clause is covered by additional version-specific comments.
2006-03-02 15:18:49 +03:00
ramil@mysql.com
72da0c6091 Fix for bug #17615: invalid handling of function results in UPDATE...SET statement. 2006-03-02 15:05:55 +04:00
monty@mysql.com
82b77cdd90 Fixes to embedded server to be able to run tests with it
(Needed for "list of pushes" web page and autopush)
2006-02-24 18:34:15 +02:00
msvensson@neptunus.(none)
71ef9102c1 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  neptunus.(none):/home/msvensson/mysql/mysql-5.0
2006-02-23 10:45:39 +01:00
msvensson@neptunus.(none)
40fe710394 Merge neptunus.(none):/home/msvensson/mysql/mysqltest_replace/my50-mysqltest_replace
into  neptunus.(none):/home/msvensson/mysql/mysql-5.0
2006-02-21 09:40:18 +01:00
msvensson@neptunus.(none)
340598a3ba Use the tmp dir of MYSQLTEST_VARDIR 2006-02-16 22:10:25 +01:00
pem@mysql.com
f5035faf51 Additional tests for nested handlers added to sp.test.
A follow-up to BUG#15011 (already fixed).
2006-02-15 17:28:34 +01:00
pem@mysql.com
cfba31dd46 Fixed BUG#16887: Cursor causes server segfault
The problem was a code generation bug: cpop instructions were not generated
  when using ITERATE back to an outer block from a context with a declared
  cursor; this would make it push a new cursor without popping in-between,
  eventually overrunning the cursor stack with a crash as the result.
  Fixed the calculation of how many cursors to pop (in sp_pcontext.cc:
  diff_cursors()), and also corrected diff_cursors() and diff_handlers()
  to when doing a "leave"; don't include the last context we're leaving
  (we are then jumping to the appropriate pop instructions).
2006-02-15 12:11:29 +01:00
pem@mysql.com
2d340a875c Merge mysql.com:/extern/mysql/bk/mysql-5.0
into  mysql.com:/extern/mysql/work/bug16568/mysql-5.0
2006-02-06 14:09:14 +01:00
pem@mysql.com
ff4e2892b7 Fixed on BUG#16568: Continue handler with simple CASE not working correctly
After trying multiple inheritance (to messy and hard make it work) and
  sublassing jump_if_not (worked, but ugly), decided to on this solution
  instead:
  Inserting an abstract sp_instr_opt_meta class as parent for all instructions
  with destinations makes it possible to handle a continuation pointer for
  sp_instr_set_case_expr too.
  Note: No special test case; the fix is captured by the changed behaviour of
  bug14643_2, and bug14498_4 (formerly disabled), in sp.test.
2006-01-26 17:26:25 +01:00
pem@mysql.com
998f0c0aa3 Fixed BUGS#15011: error handler for mysql errno in nested block not activated
For nested sql errno handlers (unlike sqlexception and other), we didn't stop
  searching when the innermost handler was found - now make sure we do.
2006-01-25 17:19:54 +01:00
pem@mysql.com
2c6ea2d2df Fix of fix for BUG#15866. (Actually change the fib() call in sp.test) 2006-01-20 08:32:22 +01:00
pem@mysql.com
28f3989c8a Fixed BUG#15866: Thread stack limit insufficient for recursive call "fib(20)"
Lowered the parameter to 10, and also renamed non-standard table names to t3.
2006-01-19 17:55:54 +01:00
konstantin@mysql.com
8d6c98ed90 Bug#15206: "Misleading message "No data to FETCH":
reword the misleading message.
2006-01-17 21:10:47 +03:00
pem@mysql.com
7817b99857 Merge mysql.com:/extern/mysql/bk/mysql-5.0
into  mysql.com:/extern/mysql/work/bug15231/mysql-5.0
2006-01-17 12:44:51 +01:00
pem@mysql.com
559a243686 Merge mysql.com:/extern/mysql/bk/mysql-5.0
into  mysql.com:/extern/mysql/work/bug14498/mysql-5.0
2006-01-16 15:37:25 +01:00
dlenev@mysql.com
f9ea947bdc Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/home/dlenev/src/mysql-5.0-bg12198-2
2006-01-13 01:56:57 +03:00
dlenev@mysql.com
d14e701446 Fix for bug #12198 "Temporary table aliasing does not work inside stored
functions".

We should ignore alias when we check if table was already marked as temporary
when we calculate set of tables to be prelocked. Otherwise we will erroneously
treat tables which are used in same routine and have same name but different
alias as non-temporary.
2006-01-13 01:51:56 +03:00
pem@mysql.com
9945144499 Fixed BUG#15231: Stored procedure bug with not found condition handler
Make the distinction between "exception conditions" and "completion
  conditions" (warning and "no data") as defined by the standard. The latter
  should not terminate a routine if no handler is found in the lexical scope.
2005-12-13 13:12:42 +01:00
konstantin@mysql.com
bbf3a593c9 A fix and a test case for Bug#15441 "Running SP causes Server
to Crash": the bug was that due to non-standard name
resolution precedence in stored procedures (See Bug#5967)
a stored procedure variable took precedence over a table column
when the arguments for VALUES() function were resolved.
The implementation of VALUES() function was not designed to work
with Item_splocal and crashed.
VALUES() function is non-standard. It can refer to, and
is meaningful for, table columns only. The patch disables SP 
variables as possible arguments of VALUES() function.
2005-12-09 00:58:59 +03:00
anozdrin@mysql.com
5b981a4844 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/home/alik/Documents/AllProgs/MySQL/devel/5.0-sp-vars-merge-2
2005-12-07 17:17:42 +03:00
anozdrin@mysql.com
0ff8f60b45 Patch for WL#2894: Make stored routine variables work
according to the standard.

The idea is to use Field-classes to implement stored routines
variables. Also, we should provide facade to Item-hierarchy
by Item_field class (it is necessary, since SRVs take part
in expressions).

The patch fixes the following bugs:
  - BUG#8702: Stored Procedures: No Error/Warning shown for inappropriate data 
    type matching; 
 
  - BUG#8768: Functions: For any unsigned data type, -ve values can be passed 
    and returned; 
 
  - BUG#8769: Functions: For Int datatypes, out of range values can be passed 
    and returned; 
 
  - BUG#9078: STORED PROCDURE: Decimal digits are not displayed when we use 
    DECIMAL datatype; 
 
  - BUG#9572: Stored procedures: variable type declarations ignored; 
 
  - BUG#12903: upper function does not work inside a function; 
 
  - BUG#13705: parameters to stored procedures are not verified; 
 
  - BUG#13808: ENUM type stored procedure parameter accepts non-enumerated
    data; 
 
  - BUG#13909: Varchar Stored Procedure Parameter always BINARY string (ignores 
    CHARACTER SET); 
 
  - BUG#14161: Stored procedure cannot retrieve bigint unsigned;

  - BUG#14188: BINARY variables have no 0x00 padding;

  - BUG#15148: Stored procedure variables accept non-scalar values;
2005-12-07 17:01:17 +03:00
serg@serg.mylan
e4821e3e9d merged 2005-12-07 08:50:14 +01:00
konstantin@mysql.com
712385568f A fix and a test case for Bug#15392 "Server crashes during
prepared statement execute
2005-12-07 00:57:15 +03:00
serg@serg.mylan
719089a819 better error for optimize/repair/etc a view 2005-12-05 12:08:30 +01:00
serg@serg.mylan
9c0a8bbd17 this has nothing to do with the bug#13012.
it's about mysql_admin_commands not being reexecution-safe
(and CHECK still isn't)
2005-12-03 15:02:09 +01:00
serg@serg.mylan
b3b72c6329 Bug#13012: REPAIR/BACKUP/RESTORE TABLE cause "packet out of order" in SP.
Mark them properly as result-returning statements
2005-12-02 22:59:45 +01:00
konstantin@mysql.com
6f63650d72 Add a test case for Bug#5967 "Stored procedure declared variable
used instead of column", the bug is to be fixed later.
2005-12-02 22:43:56 +03:00
pem@mysql.com
035c24beeb Merge mysql.com:/usr/local/bk/mysql-5.0
into  mysql.com:/usr/home/pem/bug14376/mysql-5.0
2005-12-02 15:04:50 +01:00
ramil@mysql.com
37cfade0b4 Fix for bug #14304: auto_increment field incorrect set from within stored procedure (insert select). 2005-12-01 14:26:46 +04:00
pem@mysql.com
df553710df Merge mysql.com:/usr/local/bk/mysql-5.0
into  mysql.com:/usr/home/pem/bug14643/mysql-5.0
2005-11-28 13:20:15 +01:00
dlenev@mysql.com
ca8c984e50 Enabled back bunch of tests for stored routines which were disabled
earlier because of various features/checks missing (these features/checks
are now implemented).
2005-11-26 19:15:17 +03:00