Commit graph

43 commits

Author SHA1 Message Date
Konstantin Osipov
4cff617c25 Backport of:
----------------------------------------------------------------------
ChangeSet@1.2571, 2008-04-08 12:30:06+02:00, vvaintroub@wva. +122 -0
  Bug#32082 : definition of VOID in my_global.h conflicts with Windows
  SDK headers
  
  VOID macro is now removed. Its usage is replaced with void cast.
  In some cases, where cast does not make much sense (pthread_*, printf, 
  hash_delete, my_seek), cast is ommited.
2009-11-24 16:54:59 +03:00
Marc Alff
d5fd452d7c WL#2110 (SIGNAL)
WL#2265 (RESIGNAL)

Manual merge of SIGNAL and RESIGNAL to mysql-trunk-signal,
plus required dependencies.
2009-09-10 03:18:29 -06:00
Alexey Botchkov
08690ef254 merging 2009-04-29 07:59:10 +05:00
Alexey Botchkov
52989c445f Bug#25058 ignored return codes in memory allocation functions
memory allocation error checks added for functions
   calling insert_dynamic()

per-file messages:
  myisam/mi_delete.c
Bug#25058 ignored return codes in memory allocation functions
    out-of-memory errors handled
  myisam/mi_write.c
Bug#25058 ignored return codes in memory allocation functions
    out-of-memory errors handled
  server-tools/instance-manager/instance_options.cc
Bug#25058 ignored return codes in memory allocation functions
    out-of-memory errors handled
  sql/slave.cc
Bug#25058 ignored return codes in memory allocation functions
    out-of-memory errors handled
  sql/sp_head.cc
Bug#25058 ignored return codes in memory allocation functions
    out-of-memory errors handled
  sql/sp_head.h
Bug#25058 ignored return codes in memory allocation functions
    out-of-memory errors handled
  sql/sp_pcontext.cc
Bug#25058 ignored return codes in memory allocation functions
    out-of-memory errors handled
  sql/sp_pcontext.h
Bug#25058 ignored return codes in memory allocation functions
    out-of-memory errors handled
  sql/sql_select.cc
Bug#25058 ignored return codes in memory allocation functions
    out-of-memory errors handled
  sql/sql_yacc.yy
Bug#25058 ignored return codes in memory allocation functions
    out-of-memory errors handled
2008-11-21 17:38:42 +04:00
malff@lambda.hsd1.co.comcast.net.
7da456ca01 Bug#8759 (Stored Procedures: SQLSTATE '00000' should be illegal)
Fixed the parser to reject SQLSTATE '00000',
since '00000' is the successful completion condition,
and can not be caught by an exception handler in SQL.
2008-03-21 12:08:04 -06:00
kostja@bodhi.(none)
6c352d16d9 Follow up after work on Bug 4968
Coding style: classes start with a capital letter.
Rename some classes related to parsing:
create_field -> Create_field
foreign_key -> Foreign_key
key_part_spec -> Key_part_spec
2007-06-10 14:43:57 +04:00
monty@mysql.com/narttu.mysql.fi
088e2395f1 WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:

- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t

Removed declaration of byte, gptr, my_string, my_size_t and size_s. 

Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
  instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
  as this requires fewer casts in the code and is more in line with how the
  standard functions work.
- Added extra length argument to dirname_part() to return the length of the
  created string.
- Changed (at least) following functions to take uchar* as argument:
  - db_dump()
  - my_net_write()
  - net_write_command()
  - net_store_data()
  - DBUG_DUMP()
  - decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
  argument to my_uncompress() from a pointer to a value as we only return
  one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
  the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
  casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.

Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
  needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
  explicitely as this conflict was often hided by casting the function to
  hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
  get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
  size_t. This was needed to properly detect errors (which are
  returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
  (portability fix)
- Removed windows specific code to restore cursor position as this
  causes slowdown on windows and we should not mix read() and pread()
  calls anyway as this is not thread safe. Updated function comment to
  reflect this. Changed function that depended on original behavior of
  my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
  m_size is the number of elements in the array, not a string/memory
  length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
  Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
  - Replaced some calls to alloc_root + memcpy to use
    strmake_root()/strdup_root().
  - Changed some calls from memdup() to strmake() (Safety fix)
  - Simpler loops in client-simple.c
2007-05-10 12:59:39 +03:00
malff/marcsql@weblab.(none)
bef323b1d6 Bug#26503 (Illegal SQL exception handler code causes the server to crash)
Before this fix, the parser would accept illegal code in SQL exceptions
handlers, that later causes the runtime to crash when executing the code,
due to memory violations in the exception handler stack.

The root cause of the problem is instructions within an exception handler
that jumps to code located outside of the handler. This is illegal according
to the SQL 2003 standard, since labels located outside the handler are not
supposed to be visible (they are "out of scope"), so any instruction that
jumps to these labels, like ITERATE or LEAVE, should not parse.

The section of the standard that is relevant for this is :
  SQL:2003 SQL/PSM (ISO/IEC 9075-4:2003)
  section 13.1 <compound statement>,
  syntax rule 4
<quote>
  The scope of the <beginning label> is CS excluding every <SQL schema
  statement> contained in CS and excluding every
  <local handler declaration list> contained in CS. <beginning label> shall
  not be equivalent to any other <beginning label>s within that scope.
</quote>

With this fix, the C++ class sp_pcontext, which represent the "parsing
context" tree (a.k.a symbol table) of a stored procedure, has been changed
as follows:
- constructors have been cleaned up, so that only building a root node for
the tree is public; building nodes inside a tree is not public.
- a new member, m_label_scope, indicates if a given syntactic context
belongs to a DECLARE HANDLER block,
- label resolution, in the method find_label(), has been changed to
implement the restriction of scope regarding labels used in a compound
statement.

The actions in the parser, when parsing the body of a SQL exception handler,
have been changed as follows:
- the implementation of an exception handler (DECLARE HANDLER) now creates
explicitly a new sp_pcontext, to isolate the code inside the handler from
the containing compound statement context.
- registering exception handlers as a result occurs in the parent context,
see the rule sp_hcond_element
- the code in sp_hcond_list has been cleaned up, to avoid code duplication

In addition, the flags IN_SIMPLE_CASE and IN_HANDLER, declared in sp_head.h
have been removed, since they are unused and broken by design (as seen with
Bug 19194 (Right recursion in parser for CASE causes excessive stack usage,
limitation), representing a stack in a single flag is not possible.

Tests in sp-error have been added to show that illegal constructs are now
rejected.

Tests in sp have been added for code coverage, to show that ITERATE or LEAVE
statements are legal when jumping to a label in scope, inside the body of
an exception handler.
2007-03-14 12:02:32 -06:00
kent@mysql.com/kent-amd64.(none)
226a5c833f Many files:
Changed header to GPL version 2 only
2006-12-23 20:17:15 +01:00
pem@mysql.com
a6fbde9db7 Fixed BUG#18949: Test case sp-goto is disabled
Removed sp-goto.test, sp-goto.result and all (disabled) GOTO code.
  Also removed some related code that's not needed any more (no possible
  unresolved label references any more, so no need to check for them).
  NB: Keeping the ER_SP_GOTO_IN_HNDLR in errmsg.txt; it might become useful
      in the future, and removing it (and thus re-enumerating error codes)
      might upset things. (Anything referring to explicit error codes.)
2006-04-18 11:07:34 +02:00
pem@mysql.com
bf548fb916 Renaming sp_pcontext members and methods; less cryptic and more consistent.
Also added comments, and fixing some coding style (mostly in comments too).
There are no functional changes, so no tests or documentation needed.
(This was originally part of a bugfix, but it was decided to not include this
 in that patch; instead it's done separately.)
2006-04-07 16:53:15 +02: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
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
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
pem@mysql.com
ed6e09a38c Post-review fixes for BUG#14376: MySQL crash on scoped variable (re)initialization 2005-12-02 14:30:42 +01:00
pem@mysql.com
3a832faafe Post-review fixes, mainly fixing all print() methods for sp_instr* classes.
Also added mysql-test files:
 include/is_debug_build.inc
 r/is_debug_build.require
 r/sp-code.result
 t/sp-code.test
2005-11-18 16:30:27 +01:00
pem@mysql.com
c518a2405f Background:
Since long, the compiled code of stored routines has been printed in the trace file
when starting mysqld with the "--debug" flag. (At creation time only, and only in
debug builds of course.) This has been helpful when debugging stored procedure
execution, but it's a bit awkward to use. Also, the printing of some of the
instructions is a bit terse, in particular for sp_instr_stmt where only the command
code was printed.

This improves the printout of several of the instructions, and adds the debugging-
only commands "show procedure code <name>" and "show function code <name>".
(In non-debug builds they are not available.)
2005-11-17 11:11:48 +01:00
pem@mysql.com
4e9e038ff9 Fixed BUG#14376: MySQL crash on scoped variable (re)initialization
Added finer scope control for default clauses of local variable
  declarations.
2005-11-01 14:58:52 +01:00
pem@mysql.com
c76d5768a7 Fixed BUG#13133: Local variables in stored procedures are not initialized correctly.
Have to init. all local variables in their frames, not just once at the beginning
  of invocation.
2005-09-13 12:50:21 +02:00
kent@mysql.com
b7696f414c sp_rcontext.cc, sp_pcontext.cc, sp_head.cc, sp_cache.cc, ha_federated.cc:
Include "mysql_priv.h" before testing USE_PRAGMA_IMPLEMENTATION
2005-06-05 16:20:22 +02:00
msvensson@neptunus.(none)
3490108235 Add USE_PRAGMA_INTERFACE and USE_PRAGMA_IMPLEMENTATION to files not existsing in 4.1 2005-05-27 12:03:37 +02:00
pem@mysql.comhem.se
2038ced40c Fixed BUG#9073: Able to declare two handlers for same condition in same scope 2005-04-08 19:58:04 +02:00
pem@mysql.comhem.se
54a2448bce Fixed BUG#8760: Stored Procedures: Invalid SQLSTATE is allowed in
a DECLARE ? HANDLER FOR stmt.
2005-02-28 18:07:06 +01:00
monty@mysql.com
f949f6a915 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/home/my/mysql-5.0
2005-02-25 19:51:29 +02:00
pem@mysql.comhem.se
2af86eafc7 Fixed BUG#8757: Stored Procedures: Scope of Begin and End Statements do not work properly. 2005-02-25 17:56:45 +01:00
monty@mysql.com
0a6b7aedb2 Remove compiler warnings and remove not used variables
(Found during build process)
2005-02-25 16:53:22 +02:00
pem@mysql.comhem.se
fee115adca Fixed BUG#5287: Stored procedure crash if leave outside loop.
Bug in diff_handlers and diff_cursors made it attempt to pop
the wrong number at jumps sometimes.
2004-09-02 17:24:25 +02:00
pem@mysql.comhem.se
c81b848d20 Major rehacking and cleanup of sp_pcontext.
This finishes (almost) WL#2002: Implement stored procedure GOTO.
Only the syntax issue for free labels remains ("label L;" vs "L:").
2004-08-26 12:54:30 +02:00
pem@mysql.comhem.se
38b4cbbbd5 WL#2002: Implement stored procedure GOTO.
Mostly done, it works, but the temporary LABEL syntax still to be fixed.
2004-08-17 20:20:58 +02:00
pem@mysql.comhem.se
4a6e6251e7 Fixed BUG#2776: Stored procedure crash if variable assigned to default.
Keep track on the default value and use it. (Or NULL, if not declared.)
2004-04-06 15:48:58 +02:00
pem@mysql.comhem.se
c38bb3d79d Various bug fixes:
- Duplicate parameters/variables, conditions and cursors (not allowed).
  - ITERATE in labelled BEGIN-END (not allowed).
  - Missing SQLSTATE [VALUE] keywords in CONDITION/HANDLER declaration (added).
  - Empty BEGIN-END (now allowed).
  - End label (now optional).
2003-11-13 19:34:56 +01:00
pem@mysql.telia.com
689bb84f72 WL#962: Added simple, read-only, non-scrolling, asensitive cursors in SPs, using the
(updated) Protocol_cursor class.
Also did some bug fixes.
2003-10-10 16:57:21 +02:00
pem@mysql.telia.com
04f0570fe8 Implemented SP CONDITIONs and HANDLERs, with the extension of handling
MySQL error codes as well.
(No UNDO HANDLERs yet, and no SIGNAL or RESIGNAL.)
WL#850
2003-09-16 14:26:08 +02:00
pem@mysql.com
462430ba55 Post merge fixes. 2003-04-04 15:47:43 +02:00
pem@mysql.com
c673fcb813 Getting rid of lots of memory leaks (but not quite all of them yet,
some will go away when temporary code is replaced).
2003-04-02 20:42:28 +02:00
pem@mysql.com
ac44a5f66e Replaced a couple of strcasecmps. 2003-03-27 17:35:27 +01:00
pem@mysql.com
2578564725 Added IF EXISTS to DROP PROCEDURE|FUNCTION.
Changed another unecessary use of Item_string into LEX_STRING (in sp_pcontext).
2003-03-26 12:29:58 +01:00
pem@mysql.com
0d95f36a12 Post post merge fix. Made the broken ip test work again. 2003-03-20 11:57:05 +01:00
pem@mysql.com
6822eb5ec0 Post-merge fixes. 2003-03-19 11:36:32 +01:00
pem@mysql.com
58d3dda33f Added parsing of CASE (both generic and "simple"). 2002-12-17 10:01:52 +01:00
pem@mysql.com
b1593c9a69 Fixed the broken backpatching implementation.
Implemented IF-THEN-ELSE.
2002-12-16 15:40:44 +01:00
pem@mysql.com
f0137bcd68 Fixed bugs in the parameter evaluation and modified the execution engine
for better jump support. Some flow control support added too (but not
complete).
2002-12-11 14:24:29 +01:00
pem@mysql.com
aae07a4d45 Simplistic, experimental framework for Stored Procedures (SPs).
Implements creation and dropping of PROCEDUREs, IN, OUT, and INOUT parameters,
single-statement procedures, rudimentary multi-statement (begin-end) prodedures
(when the client can handle it), and local variables.
Missing most of the embedded SQL language, all attributes, FUNCTIONs, error handling,
reparses procedures at each call (no caching), etc, etc.
Certainly buggy too, but procedures can actually be created and called....
2002-12-08 19:59:22 +01:00