summaryrefslogtreecommitdiff
path: root/sql/sp.h
Commit message (Collapse)AuthorAgeFilesLines
* BUG#41166 stored function requires "deterministic" if binlog_format is ↵Alfranio Correia2009-07-281-0/+3
| | | | | | | | | | | | | "statement" If the log_bin_trust_function_creators option is not defined, creating a stored function requires either one of the modifiers DETERMINISTIC, NO SQL, or READS SQL DATA. Executing a stored function should also follows the same rules if in STATEMENT mode. However, this was not happening and a wrong error was being printed out: ER_BINLOG_ROW_RBR_TO_SBR. The patch makes the creation and execution compatible and prints out the correct error ER_BINLOG_UNSAFE_ROUTINE when a stored function without one of the modifiers above is executed in STATEMENT mode.
* Bug#44658 Create procedure makes server crash when user does not have ALL ↵Kristofer Pettersson2009-05-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | privilege MySQL crashes if a user without proper privileges attempts to create a procedure. The crash happens because more than one error state is pushed onto the Diagnostic area. In this particular case the user is denied to implicitly create a new user account with the implicitly granted privileges ALTER- and EXECUTE ROUTINE. The new account is needed if the original user account contained a host mask. A user account with a host mask is a distinct user account in this context. An alternative would be to first get the most permissive user account which include the current user connection and then assign privileges to that account. This behavior change is considered out of scope for this bug patch. The implicit assignment of privileges when a user creates a stored routine is a considered to be a feature for user convenience and as such it is not a critical operation. Any failure to complete this operation is thus considered non-fatal (an error becomes a warning). The patch back ports a stack implementation of the internal error handler interface. This enables the use of multiple error handlers so that it is possible to intercept and cancel errors thrown by lower layers. This is needed as a error handler already is used in the call stack emitting the errors which needs to be converted.
* Remove dead code.kostja@dipika.(none)2008-04-081-3/+0
|
* Fix for BUG#24923: Functions with ENUM issues.anozdrin/alik@station.2007-10-171-0/+1
| | | | | | | | | The problem was that the RETURNS column in the mysql.proc was of CHAR(64). That was not enough for storing long-named datatypes. The fix is to change CHAR(64) to LONGBLOB, and to throw warnings at the time a stored routine is created if some data is truncated during writing into mysql.proc.
* Fix for BUG#25843: changing default database between PREPARE and EXECUTEanozdrin/alik@ibm.opbmk2007-08-311-11/+0
| | | | | | | | | | | | | | | | | | of statement breaks binlog. There were two problems discovered by this bug: 1. Default (current) database is not fixed at the creation time. That leads to wrong output of DATABASE() function. 2. Database attributes (@@collation_database) are not fixed at the creation time. That leads to wrong resultset. Binlog breakage and Query Cache wrong output happened because of the first problem. The fix is to remember the current database at the PREPARE-time and set it each time at EXECUTE.
* Merge bk-internal.mysql.com:/home/bk/mysql-5.1kostja@bodhi.(none)2007-06-011-1/+2
|\ | | | | | | into bodhi.(none):/opt/local/work/mysql-5.1-runtime
| * WL#3817: Simplify string / memory area types and make things more consistent ↵monty@mysql.com/narttu.mysql.fi2007-05-101-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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
* | Refactoring patch:anozdrin/alik@ibm.2007-05-291-23/+6
|/ | | | | | 1. Refactor sp_show_create_function() and sp_show_create_procedure() into show_create_routine(). 2. Code cleanup: eliminate proxy functions.
* BUG#9953: CONVERT_TZ requires mysql.time_zone_name to be lockedkroki/tomash@moonlight.home2007-03-091-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The problem was that some facilities (like CONVERT_TZ() function or server HELP statement) may require implicit access to some tables in 'mysql' database. This access was done by ordinary means of adding such tables to the list of tables the query is going to open. However, if we issued LOCK TABLES before that, we would get "table was not locked" error trying to open such implicit tables. The solution is to treat certain tables as MySQL system tables, like we already do for mysql.proc. Such tables may be opened for reading at any moment regardless of any locks in effect. The cost of this is that system table may be locked for writing only together with other system tables, it is disallowed to lock system tables for writing and have any other lock on any other table. After this patch the following tables are treated as MySQL system tables: mysql.help_category mysql.help_keyword mysql.help_relation mysql.help_topic mysql.proc (it already was) mysql.time_zone mysql.time_zone_leap_second mysql.time_zone_name mysql.time_zone_transition mysql.time_zone_transition_type These tables are now opened with open_system_tables_for_read() and closed with close_system_tables(), or one table may be opened with open_system_table_for_update() and closed with close_thread_tables() (the latter is used for mysql.proc table, which is updated as part of normal MySQL server operation). These functions may be used when some tables were opened and locked already. NOTE: online update of time zone tables is not possible during replication, because there's no time zone cache flush neither on LOCK TABLES, nor on FLUSH TABLES, so the master may serve stale time zone data from cache, while on slave updated data will be loaded from the time zone tables.
* Merge mysql.com:/home/kent/bk/main/mysql-5.0kent@kent-amd64.(none)2006-12-231-2/+1
|\ | | | | | | into mysql.com:/home/kent/bk/main/mysql-5.1
| * Many files:kent@mysql.com/kent-amd64.(none)2006-12-231-2/+1
| | | | | | | | Changed header to GPL version 2 only
* | Bug#21039 Transaction cache not flushed after SELECT CREATEmsvensson@shellback.(none)2006-07-261-2/+1
|/ | | | | | - Add prelocking for stored procedures that uses sp or sf - Update test result for sp_error(reported as bug#21294) - Make note about new error message from sp-error(bug#17244)
* A fix and a test case forkonstantin@mysql.com2006-06-271-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug#19022 "Memory bug when switching db during trigger execution" Bug#17199 "Problem when view calls function from another database." Bug#18444 "Fully qualified stored function names don't work correctly in SELECT statements" Documentation note: this patch introduces a change in behaviour of prepared statements. This patch adds a few new invariants with regard to how THD::db should be used. These invariants should be preserved in future: - one should never refer to THD::db by pointer and always make a deep copy (strmake, strdup) - one should never compare two databases by pointer, but use strncmp or my_strncasecmp - TABLE_LIST object table->db should be always initialized in the parser or by creator of the object. For prepared statements it means that if the current database is changed after a statement is prepared, the database that was current at prepare remains active. This also means that you can not prepare a statement that implicitly refers to the current database if the latter is not set. This is not documented, and therefore needs documentation. This is NOT a change in behavior for almost all SQL statements except: - ALTER TABLE t1 RENAME t2 - OPTIMIZE TABLE t1 - ANALYZE TABLE t1 - TRUNCATE TABLE t1 -- until this patch t1 or t2 could be evaluated at the first execution of prepared statement. CURRENT_DATABASE() still works OK and is evaluated at every execution of prepared statement. Note, that in stored routines this is not an issue as the default database is the database of the stored procedure and "use" statement is prohibited in stored routines. This patch makes obsolete the use of check_db_used (it was never used in the old code too) and all other places that check for table->db and assign it from THD::db if it's NULL, except the parser. How this patch was created: THD::{db,db_length} were replaced with a LEX_STRING, THD::db. All the places that refer to THD::{db,db_length} were manually checked and: - if the place uses thd->db by pointer, it was fixed to make a deep copy - if a place compared two db pointers, it was fixed to compare them by value (via strcmp/my_strcasecmp, whatever was approproate) Then this intermediate patch was used to write a smaller patch that does the same thing but without a rename. TODO in 5.1: - remove check_db_used - deploy THD::set_db in mysql_change_db See also comments to individual files.
* Fixed BUG#16303: erroneus stored procedures and functions should be droppablepem@mysql.com2006-01-261-1/+4
| | | | | Use a special lookup function for DROP, which doesn't attempt to parse the definition.
* Merge bk-internal.mysql.com:/home/bk/mysql-5.0dlenev@mysql.com2005-12-071-4/+5
|\ | | | | | | into mysql.com:/home/dlenev/src/mysql-5.0-bg11555-2
| * Fix for bug #11555 "Stored procedures: current SP tables locking makedlenev@mysql.com2005-12-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | impossible view security". We should not expose names of tables which are explicitly or implicitly (via routine or trigger) used by view even if we find that they are missing. So during building of list of prelocked tables for statement we track which routines (and therefore tables for these routines) are used from views. We mark elements of LEX::routines set which correspond to routines used in views by setting Sroutine_hash_entry::belong_to_view member to point to TABLE_LIST object for topmost view which uses routine. We propagate this mark to all routines which are used by this routine and which we add to this set. We also mark tables used by such routine which we add to the list of tables for prelocking as belonging to this view.
* | Merge mysql.com:/usr/local/bk/mysql-5.0pem@mysql.com2005-12-061-5/+5
|\ \ | |/ |/| | | into mysql.com:/usr/home/pem/bug14233/mysql-5.0
| * Fixed BUG#14233: Crash after tampering with the mysql.proc tablepem@mysql.com2005-10-261-5/+5
| | | | | | | | | | | | Added error checking for errors when attempting to use stored procedures after the mysql.proc table has been dropped, corrupted, or tampered with. Test cases were put in a separate file (sp-destruct.test).
* | Recursion support made for SP (BUG#10100).bell@sanja.is.com.ua2005-11-231-4/+2
|/
* Fix for bug #12704 "Server crashes during trigger execution".dlenev@mysql.com2005-09-151-0/+1
| | | | | | | | | | | This bug occurs when some trigger for table used by DML statement is created or changed while statement was waiting in lock_tables(). In this situation prelocking set which we have calculated becames invalid which can easily lead to errors and even in some cases to crashes. With proposed patch we no longer silently reopen tables in lock_tables(), instead caller of lock_tables() becomes responsible for reopening tables and recalculation of prelocking set.
* Avoid spurious error when restoring INFORMATION_SCHEMA as the current jimw@mysql.com2005-08-111-4/+0
| | | | | database after failing to execute a stored procedure in an inaccessible database. (Bug #12318)
* Merge bk-internal.mysql.com:/home/bk/mysql-5.0dlenev@mysql.com2005-08-091-0/+7
|\ | | | | | | into mysql.com:/home/dlenev/src/mysql-5.0-is
| * Fix for bug #10055 "Using stored function with information_schema causes emptydlenev@mysql.com2005-08-081-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | result set". To enable full access to contents of I_S tables from stored functions or statements that use them, we manipulate with thread's open tables state and ensure that we won't cause deadlock when we open tables by ignoring flushes and name-locks. Building of contents of I_S.TABLES no longer requires locking of tables since we use use handler::info() method with HA_STATUS_AUTO flag instead of handler::update_auto_increment() for obtaining information about auto-increment values. But this also means that handlers have to implement support for HA_STATUS_AUTO flag (particularly InnoDB needs it).
* | Merge spetrunia@bk-internal.mysql.com:/home/bk/mysql-5.0sergefp@mysql.com2005-08-031-1/+4
|\ \ | | | | | | | | | into mysql.com:/home/psergey/mysql-5.0-sp-no-lock-r7
| * | Prelocking-free SPs, post-review fixes:sergefp@mysql.com2005-08-031-2/+2
| | | | | | | | | | | | | | | | | | * Don't activate prelocking mode for evaluating procedure arguments when it is not necessary. * Code structure simplification and cleanup. * Cleanup in .test files
| * | Added Non-prelocked SP execution: Now a PROCEDURE doesn't enter/leave ↵sergefp@mysql.com2005-07-301-1/+4
| |/ | | | | | | | | | | | | | | prelocked mode for its body, but lets each statement to get/release its own locks. This allows a broader set of statements to be executed inside PROCEDUREs (but breaks replication) This patch should fix BUG#8072, BUG#8766, BUG#9563, BUG#11126
* | Increase allowed size of stored procedure bodies to 4GB, and jimw@mysql.com2005-07-261-0/+1
|/ | | | produce a sensible error when that limit is exceeded. (Bug #11602)
* Merge bk-internal.mysql.com:/home/bk/mysql-5.0dlenev@mysql.com2005-07-131-3/+0
|\ | | | | | | into mysql.com:/home/dlenev/src/mysql-5.0-mysqlproc
| * Implementation of Monty's idea: Now we can open mysql.proc table for lookupdlenev@mysql.com2005-07-131-3/+0
| | | | | | | | | | | | | | | | | | | | of stored routines definitions even if we already have some tables open and locked. To avoid deadlocks in this case we have to put certain restrictions on locking of mysql.proc table. This allows to use stored routines safely under LOCK TABLES without explicitly mentioning mysql.proc in the list of locked tables. It also fixes bug #11554 "Server crashes on statement indirectly using non-cached function".
* | Manual fixes after merging patch for bug #8406 "Triggers crash if referencingdlenev@mysql.com2005-07-091-1/+1
| | | | | | | | a table" with main tree.
* | Enable support of access to tables from triggers. Thus fix bug #8406 "Triggersdlenev@mysql.com2005-07-091-9/+13
|/ | | | | | | | | | | | crash if referencing a table" and several other related bugs. Fix for bug #11834 "Re-execution of prepared statement with dropped function crashes server." which was spotted during work on previous bugs. Also couple of nice cleanups: - Replaced two separate hashes for stored routines used by statement with one. - Now instead of doing one pass through all routines used in statement for caching them and then doing another pass for adding their tables to table list, we do only one pass during which do both things.
* Fixed BUG#9529: Stored Procedures: No Warning on truncation of procedure namepem@mysql.comhem.se2005-05-311-0/+1
| | | | | | during creation. Although it returns an error, consistent with the behaviour for other objects. (Unclear why we would allow the creation of SPs with truncated names.)
* Better approach for prelocking of tables for stored routines executiondlenev@brandersnatch.localdomain2005-03-041-4/+4
| | | | | | | | | | | | | | | | | | 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.
* WL#2130: Table locking for stored FUNCTIONspem@mysql.comhem.se2005-02-081-6/+7
| | | | | | | Collect all tables and SPs refered by a statement, and open all tables with an implicit LOCK TABLES. Do find things refered by triggers and views, we open them first (and then repeat this until nothing new is found), before doing the actual lock tables.
* WL#925 - Privileges for stored routinesacurtis@pcgem.rdg.cyberkinetica.com2004-12-231-0/+3
| | | | | | Implement fine-grained control over access to stored procedures Privileges are cached (same way as existing table/column privs)
* Fixed BUG#6027: Stored procedures can be renamed.pem@mysql.comhem.se2004-10-221-6/+2
| | | | | Removed the support for renaming SPs. It's non-standard, conflicted with a standard syntax, and was a bit broken anyway.
* Fixed BUG#3339: Stored procedures in nonexistent schemas are uncallable.pem@mysql.comhem.se2004-06-151-0/+1
| | | | Also added some related security tests and corrected related error messages.
* Fixed proper restoring of current db on errors.pem@mysql.comhem.se2004-06-081-1/+2
| | | | This fixes part of BUG#3229: Stored procedure comment causes packets out of order.
* WL#1366: Use the schema (db) associated with an SP.pem@mysql.comhem.se2004-03-221-0/+4
| | | | Phase 4 (final): Remove associated stored procedures when a database is dropped.
* WL#1366: Use the schema (db) associated with an SP.pem@mysql.comhem.se2004-03-111-1/+16
| | | | | | Phase 2: Make SPs belong to a DB, and use qualified names. As a side effect, using USE in an SP is no longer allowed. (It just doesn't work otherwise.)
* WL#1366: Use the schema (db) associated with an SP.pem@mysql.comhem.se2004-02-171-10/+9
| | | | Phase 1: Introduced sp_name class, for qualified name support.
* In order to make ALTER PROCEDURE|FUNCTION work correctly, and in general topem@mysql.comhem.se2003-12-121-4/+2
| | | | | | | | | make characteristics (and SHOW) work right, we had to separate the old definition blob in the mysql.proc table into separate fields for parameters, return type, and body, and handle the characteristics (like SQL SECURITY) separately... and then reassemble the CREATE string for parsing, of course. This is rather ugly, mostly the parser bit. (Hopefully that will be better with the new parser.)
* WL#1363: Update the mysql.proc table and add new fields.pem@mysql.comhem.se2003-12-101-4/+4
| | | | | Also made the parsing and handling of SP characteristics more general and extendable, and added a few ch:istics.
* Bugfixes in SHOW CREATE PROCEDURE/FUNCTION and SHOW PROCEDURE/FUNCTION STATUS;pem@mysql.comhem.se2003-11-201-3/+4
| | | | | | | - dropped routines should not show up in status - error handling for non-existing routines + some cleanup.
* WL#1241: SHOW PROCEDURE/FUNCTIONgluh@gluh.mysql.r18.ru2003-11-171-0/+22
| | | | | WL#1263: Support for the attributes COMMENT and SUID in CREATE/ALTER PROCEDURE/FUNCTION
* SP cache (WL#730). (Mostly by vva, additions by pem.)pem@mysql.com2003-07-011-4/+2
|
* Expand the mysql.proc tablegluh@gluh.mysql.r18.ru2003-05-061-2/+4
|
* Made FUNCTIONs work in insert and select queries, as well as nested function ↵pem@mysql.com2003-03-021-0/+12
| | | | | | | invocations. Had to add a cahing mechanism which is in parts an ugly kludge, but it will be reworked once the real SP caching is implemented.
* Made stored FUNCTION invokation work almost always. Still buggy and ↵pem@mysql.com2003-02-261-0/+4
| | | | | | unstable, and various known problems, but good enough for a checkpoint commit.
* Most of the groundwork for sprint task 729 (implement FUNCTIONs).pem@mysql.com2003-02-211-7/+12
| | | | | | | | | Expanded the mysql.proc table, reworked the find/create/drop functions completely, added new functions for FUNCTIONs (lotta functions here :), got rid of some unnecessary use of Item_strings while at it. Extended the parser correspondingly, and fiddled around a bit to make SP FUNCTIONs coexist with UDFs. Can now CREATE and DROP FUNCTIONs. Invoking yet to come...