summaryrefslogtreecommitdiff
path: root/sql/sql_prepare.cc
Commit message (Collapse)AuthorAgeFilesLines
* Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-optgkodinov/kgeorge@magare.gmz2007-03-161-1/+1
|\ | | | | | | into magare.gmz:/home/kgeorge/mysql/autopush/B26261-5.0-opt
| * Bug #26261: gkodinov/kgeorge@macbook.gmz2007-03-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | INSERT uses query_id to verify what fields are mentioned in the fields list of the INSERT command. However the check for that is made after the ON DUPLICATE KEY is processed. This causes all the fields mentioned in ON DUPLICATE KEY to be considered as mentioned in the fields list of INSERT. Moved the check up, right after processing the fields list.
* | A fix for Bug#26750 "valgrind leak in sp_head" (and post-reviewkostja@bodhi.local2007-03-071-18/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fixes). The legend: on a replication slave, in case a trigger creation was filtered out because of application of replicate-do-table/ replicate-ignore-table rule, the parsed definition of a trigger was not cleaned up properly. LEX::sphead member was left around and leaked memory. Until the actual implementation of support of replicate-ignore-table rules for triggers by the patch for Bug 24478 it was never the case that "case SQLCOM_CREATE_TRIGGER" was not executed once a trigger was parsed, so the deletion of lex->sphead there worked and the memory did not leak. The fix: The real cause of the bug is that there is no 1 or 2 places where we can clean up the main LEX after parse. And the reason we can not have just one or two places where we clean up the LEX is asymmetric behaviour of MYSQLparse in case of success or error. One of the root causes of this behaviour is the code in Item::Item() constructor. There, a newly created item adds itself to THD::free_list - a single-linked list of Items used in a statement. Yuck. This code is unaware that we may have more than one statement active at a time, and always assumes that the free_list of the current statement is located in THD::free_list. One day we need to be able to explicitly allocate an item in a given Query_arena. Thus, when parsing a definition of a stored procedure, like CREATE PROCEDURE p1() BEGIN SELECT a FROM t1; SELECT b FROM t1; END; we actually need to reset THD::mem_root, THD::free_list and THD::lex to parse the nested procedure statement (SELECT *). The actual reset and restore is implemented in semantic actions attached to sp_proc_stmt grammar rule. The problem is that in case of a parsing error inside a nested statement Bison generated parser would abort immediately, without executing the restore part of the semantic action. This would leave THD in an in-the-middle-of-parsing state. This is why we couldn't have had a single place where we clean up the LEX after MYSQLparse - in case of an error we needed to do a clean up immediately, in case of success a clean up could have been delayed. This left the door open for a memory leak. One of the following possibilities were considered when working on a fix: - patch the replication logic to do the clean up. Rejected as breaks module borders, replication code should not need to know the gory details of clean up procedure after CREATE TRIGGER. - wrap MYSQLparse with a function that would do a clean up. Rejected as ideally we should fix the problem when it happens, not adjust for it outside of the problematic code. - make sure MYSQLparse cleans up after itself by invoking the clean up functionality in the appropriate places before return. Implemented in this patch. - use %destructor rule for sp_proc_stmt to restore THD - cleaner than the prevoius approach, but rejected because needs a careful analysis of the side effects, and this patch is for 5.0, and long term we need to use the next alternative anyway - make sure that sp_proc_stmt doesn't juggle with THD - this is a large work that will affect many modules. Cleanup: move main_lex and main_mem_root from Statement to its only two descendants Prepared_statement and THD. This ensures that when a Statement instance was created for purposes of statement backup, we do not involve LEX constructor/destructor, which is fairly expensive. In order to track that the transformation produces equivalent functionality please check the respective constructors and destructors of Statement, Prepared_statement and THD - these members were used only there. This cleanup is unrelated to the patch.
* | Merge mysql.com:/home/gluh/MySQL/Merge/5.0gluh@mysql.com/eagle.(none)2007-02-261-13/+8
|\ \ | |/ | | | | into mysql.com:/home/gluh/MySQL/Merge/5.0-opt
| * Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-optgkodinov/kgeorge@rakia.gmz2007-02-191-13/+8
| |\ | | | | | | | | | into rakia.gmz:/home/kgeorge/mysql/autopush/B25831-5.0-opt
| | * Bug #25831: Deficiencies in INSERT ... SELECT ... field name resolving.gkodinov/kgeorge@macbook.gmz2007-02-191-13/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Several problems fixed: 1. There was a "catch-all" context initialization in setup_tables() that was causing the table that we insert into to be visible in the SELECT part of an INSERT .. SELECT .. statement with no tables in its FROM clause. This was making sure all the under-initialized contexts in various parts of the code are not left uninitialized. Fixed by removing the "catch-all" statement and initializing the context in the parser. 2. Incomplete name resolution context when resolving the right-hand values in the ON DUPLICATE KEY UPDATE ... part of an INSERT ... SELECT ... caused columns from NATURAL JOIN/JOIN USING table references in the FROM clause of the select to be unavailable. Fixed by establishing a proper name resolution context. 3. When setting up the special name resolution context for problem 2 there was no check for cases where an aggregate function without a GROUP BY effectively takes the column from the SELECT part of an INSERT ... SELECT unavailable for ON DUPLICATE KEY UPDATE. Fixed by checking for that condition when setting up the name resolution context.
* | | Fixed compiler warnings (for linux and win32 and win64)monty@mysql.com/narttu.mysql.fi2007-02-221-0/+1
| | | | | | | | | | | | Fixed a couple of usage of not initialized warnings (unlikely cases)
* | | Merge bk-internal.mysql.com:/home/bk/mysql-5.0monty@mysql.com/narttu.mysql.fi2007-02-211-7/+8
|\ \ \ | |/ / |/| | | | | into mysql.com:/home/my/mysql-5.0
| * | Fixed unsafe define of uint4korr()monty@mysql.com/narttu.mysql.fi2007-02-211-2/+2
| | | | | | | | | | | | | | | Fixed that --extern works with mysql-test-run.pl Small trivial cleanups
| * | Merge bk-internal.mysql.com:/home/bk/mysql-5.0monty@mysql.com/narttu.mysql.fi2007-01-221-6/+7
| |\ \ | | | | | | | | | | | | into mysql.com:/home/my/mysql-5.0
| | * | Fixed compiler warnings detected by option -Wshadow and -Wunused:monty@mysql.com/narttu.mysql.fi2006-12-151-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Removed not used variables and functions - Added #ifdef around code that is not used - Renamed variables and functions to avoid conflicts - Removed some not used arguments Fixed some class/struct warnings in ndb Added define IS_LONGDATA() to simplify code in libmysql.c I did run gcov on the changes and added 'purecov' comments on almost all lines that was not just variable name changes
* | | | Merge pilot.mysql.com:/home/msvensson/mysql/mysql-4.1-maintmsvensson@pilot.mysql.com2007-02-131-1/+1
|\ \ \ \ | | | | | | | | | | | | | | | into pilot.mysql.com:/home/msvensson/mysql/mysql-5.0-maint
| * \ \ \ Merge siva.hindu.god:/home/tsmith/m/bk/41tsmith@siva.hindu.god2007-02-081-4/+4
| |\ \ \ \ | | | | | | | | | | | | | | | | | | into siva.hindu.god:/home/tsmith/m/bk/maint/41
| * | | | | Test and bug fixes and removed unneccessary files.jani@a88-113-38-195.elisa-laajakaista.fi2007-02-051-1/+2
| | | | | |
* | | | | | Merge pilot.mysql.com:/home/msvensson/mysql/mysql-4.1-maintmsvensson@pilot.mysql.com2007-02-061-5/+5
|\ \ \ \ \ \ | | |/ / / / | |/| | | / | |_|_|_|/ |/| | | | into pilot.mysql.com:/home/msvensson/mysql/mysql-5.0-maint
| * | | | Merge neptunus.(none):/home/msvensson/mysql/my41-nmjmsvensson@neptunus.(none)2007-02-061-5/+6
| |\ \ \ \ | | |/ / / | |/| | | | | | | | into neptunus.(none):/home/msvensson/mysql/mysql-4.1-maint
| | * | | Bug#8983 one place that isn't strict-aliasing-safemsvensson@neptunus.(none)2007-02-061-5/+6
| | | | | | | | | | | | | | | | | | | | - Backport fix from 5.0
* | | | | Merge mysql.com:/home/gluh/MySQL/Merge/5.0gluh@mysql.com/eagle.(none)2007-01-231-1/+1
|\ \ \ \ \ | |_|_|/ / |/| | | | | | | | | into mysql.com:/home/gluh/MySQL/Merge/5.0-opt
| * | | | sql_prepare.cc:evgen@moonbone.local2007-01-221-1/+1
| | | | | | | | | | | | | | | | | | | | Post fix for bug#25123.
* | | | | Merge bk-internal.mysql.com:/home/bk/mysql-5.0kostja@bodhi.local2007-01-111-2/+1
|\ \ \ \ \ | |/ / / / |/| | | | | | | | | into bodhi.local:/opt/local/work/mysql-5.0-runtime
| * | | | A fix and a test case for Bug#24179 "select b into $var" fails with kostja@bodhi.local2006-12-011-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | --cursor_protocol": fix a misleading error message in case of SELECT .. INTO.
* | | | | Merge mysql.com:/d2/hf/common/my41-commonholyfoot/hf@mysql.com/hfmain.(none)2007-01-021-2/+0
|\ \ \ \ \ | | |/ / / | |/| | | | | | | | into mysql.com:/d2/hf/common/my50-common
| * | | | embedded-server related fixesholyfoot/hf@mysql.com/hfmain.(none)2007-01-021-2/+0
| | |/ / | |/| |
* | | | Many files:kent@mysql.com/kent-amd64.(none)2006-12-231-2/+1
| |_|/ |/| | | | | | | | Changed header to GPL version 2 only
* | | Fixed portability issue in my_thr_init.c (was added in my last push)monty@mysql.com/narttu.mysql.fi2006-11-301-1/+0
| |/ |/| | | | | | | | | | | | | | | | | Fixed compiler warnings (detected by VC++): - Removed not used variables - Added casts - Fixed wrong assignments to bool - Fixed wrong calls with bool arguments - Added missing argument to store(longlong), which caused wrong store method to be called.
* | Remove compiler warningsmonty@mysql.com/nosik.monty.fi2006-11-201-3/+9
| | | | | | | | | | | | | | (Mostly in DBUG_PRINT() and unused arguments) Fixed bug in query cache when used with traceing (--with-debug) Fixed memory leak in mysqldump Removed warnings from mysqltest scripts (replaced -- with #)
* | Merge bk-internal.mysql.com:/home/bk/mysql-5.0cmiller@zippy.cornsilk.net2006-11-021-6/+33
|\ \ | | | | | | | | | into zippy.cornsilk.net:/home/cmiller/work/mysql/mysql-5.0-maint
| * \ Merge siva.hindu.god:/usr/home/tim/m/bk/b19764/50tsmith/tim@siva.hindu.god2006-10-161-0/+6
| |\ \ | | | | | | | | | | | | into siva.hindu.god:/usr/home/tim/m/bk/tmp/mrgOct16/50
| | * | Bug #19764: SHOW commands end up in the slow log as table scanstsmith/tim@siva.hindu.god2006-10-121-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | Do not consider SHOW commands slow queries, just because they don't use proper indexes. This bug fix is not needed in 5.1, and the code changes will be null merged. However, the test cases will be propogated up to 5.1.
| * | | Bug#19356: Assert on undefined @uservar in prepared statement executecmiller@zippy.cornsilk.net2006-10-041-6/+27
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The executing code had a safety assertion so that it refused to free Items that it didn't create. However, there is a case, undefined user variables, which would put Items into the list to be freed. Instead, do something that is more risky in expectation that the code will be refactored soon, as Kostja wants to do: Remove the assertions from prepare() and execute(). Put one assertion at a higher level, before stmt->set_params_from_vars(), which may then create new to-be-freed Items .
* | | BUG#21856: Prepared Statements: crash if bad createkroki/tomash@moonlight.intranet2006-10-191-0/+11
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When statement to be prepared contained CREATE PROCEDURE, CREATE FUNCTION or CREATE TRIGGER statements with a syntax error in it, the preparation would fail with syntax error message, but the memory could be corrupted. The problem occurred because we switch memroot when parse stored routine or trigger definitions, and on parse error we restored the original memroot only after performing some memory operations. In more detail: - prepared statement would activate its own memory root to parse the definition of the stored procedure. - SP would reset this memory root with its own memory root to parse SP statements - a syntax error would happen - prepared statement would restore the original memory root - stored procedure would restore what it thinks was the original memory root, but actually was the statement memory root. That led to double free - in destruction of the statement and in a next call to mysql_parse(). The solution is to restore memroot right after the failed parsing.
* | Bug#21813 An attacker has the opportunity to bypass query logging, part2msvensson@neptunus.(none)2006-08-301-2/+4
| | | | | | | | | | | | | | - Use the "%.*b" format when printing prepared and exeuted prepared statements to the log. - Add test case to check that also prepared statements end up in the query log Bug#14346 Prepared statements corrupting general log/server memory - Use "stmt->query" when logging the newly prepared query instead of "packet"
* | Merge bk-internal.mysql.com:/home/bk/mysql-5.0kostja@bodhi.local2006-08-021-22/+14
|\ \ | | | | | | | | | into bodhi.local:/opt/local/work/mysql-5.0-runtime-merge
| * | Post-merge fixes for Bug#19399 "Stored Procedures 'Lost Connection' kostja@bodhi.local2006-07-111-2/+2
| | | | | | | | | | | | when dropping/creating tables"
| * | Merge bodhi.local:/opt/local/work/tmp_mergekostja@bodhi.local2006-07-111-21/+14
| |\ \ | | |/ | | | | | | into bodhi.local:/opt/local/work/mysql-5.0-runtime-merge-41
* | | 4.1 -> 5.0 mergeigreenhoe/greenman@anubis.greendragongames.com2006-07-131-1/+2
|\ \ \ | |/ / |/| / | |/
| * A fix and a test case for Bug#19399 "res 'Lost Connection' when konstantin@bodhi.netgear2006-07-061-7/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | dropping/creating tables". The bug could lead to a crash when multi-delete statements were prepared and used with temporary tables. The bug was caused by lack of clean-up of multi-delete tables before re-execution of a prepared statement. In a statement like DELETE t1 FROM t1, t2 WHERE ... the first table list (t1) is moved to lex->auxilliary_table_list and excluded from lex->query_tables or select_lex->tables. Thus it was unaccessible to reinit_stmt_before_use and not cleaned up before re-execution of a prepared statement.
* | Post-merge fixes.igor@rurik.mysql.com2006-05-071-12/+15
| |
* | Merge rurik.mysql.com:/home/igor/dev/mysql-4.1-0igor@rurik.mysql.com2006-05-071-2/+0
|\ \ | |/ | | | | into rurik.mysql.com:/home/igor/dev/mysql-5.0-0
| * Fixed bug #14927.igor@rurik.mysql.com2006-05-061-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | A query with a group by and having clauses could return a wrong result set if the having condition contained a constant conjunct evaluated to FALSE. It happened because the pushdown condition for table with grouping columns lost its constant conjuncts. Pushdown conditions are always built by the function make_cond_for_table that ignores constant conjuncts. This is apparently not correct when constant false conjuncts are present.
* | A fix and a test case for Bug#19308 "REPAIR/OPTIMIZE/ANALYZE konstantin@mysql.com2006-04-251-0/+3
| | | | | | | | | | | | supported in SP but not in PS": just enable them in prepared statements, the supporting functionality was implemented when they were enabled in stored procedures.
* | Post-merge fixes. Add a new error message for max_prepared_stmt_countkonstantin@mysql.com2006-04-131-5/+6
| | | | | | | | limit.
* | Merge mysql.com:/opt/local/work/mysql-4.1-16365konstantin@mysql.com2006-04-121-4/+12
|\ \ | |/ | | | | into mysql.com:/opt/local/work/mysql-5.0-merge
| * A fix and a test case for Bug#16365 "Prepared Statements: DoS with konstantin@mysql.com2006-04-071-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | too many open statements". The patch adds a new global variable @@max_prepared_stmt_count. This variable limits the total number of prepared statements in the server. The default value of @@max_prepared_stmt_count is 16382. 16382 small statements (a select against 3 tables with GROUP, ORDER and LIMIT) consume 100MB of RAM. Once this limit has been reached, the server will refuse to prepare a new statement and return ER_UNKNOWN_ERROR (unfortunately, we can't add new errors to 4.1 without breaking 5.0). The limit is changeable after startup and can accept any value from 0 to 1 million. In case the new value of the limit is less than the current statement count, no new statements can be added, while the old still can be used. Additionally, the current count of prepared statements is now available through a global read-only variable @@prepared_stmt_count.
* | Fixed bug #18279: crash in the cases when on conditions are moved igor@rurik.mysql.com2006-03-291-3/+9
| | | | | | | | | | | | | | | | | | out of a nested join to the on conditions for the nest. The bug happened due to: 1. The function simplify_joins could change on expressions for nested joins. Yet modified on expressions were not saved in prep_on_expr. 2. On expressions were not restored for nested joins in reinit_stmt_before_use.
* | This patch does 1) fix my build breakage 2) Complete the removal of all ↵brian@zim.(none)2006-03-091-1/+1
| | | | | | | | symbols which could clash with another parser.
* | Fixes to embedded server to be able to run tests with itmonty@mysql.com2006-02-241-2/+9
| | | | | | | | (Needed for "list of pushes" web page and autopush)
* | Merge bk-internal.mysql.com:/home/bk/mysql-5.0-runtimedlenev@mysql.com2006-02-161-1/+1
|\ \ | | | | | | | | | into mysql.com:/home/dlenev/src/mysql-5.0-bg16593
| * | Fix for bug #16593 "Deadlock or crash in stress test for case wheredlenev@mysql.com2006-02-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | trigger starts trigger". In short, the deadlock/crash happened when execution of statement, which used stored functions or activated triggers, coincided with alteration of the tables used by these functions or triggers (in highly concurrent environment). Bug was caused by the incorrect handling of tables from prelocked set in open_tables() functions in situations when refresh happened. This fix replaces old smart but not very robust way of handling tables after refresh (which was closing only old tables), with new one which simply closes all tables opened so far and restarts open_tables(). Also fixed handling of temporary tables in close_tables_for_reopen(). No test case present since bug manifests itself only in concurrent environment.
* | | Merge rkalimullin@bk-internal.mysql.com:/home/bk/mysql-5.0ramil@mysql.com2006-02-031-7/+12
|\ \ \ | | | | | | | | | | | | into mysql.com:/usr/home/ram/work/5.0.b16511