Commit graph

637 commits

Author SHA1 Message Date
Konstantin Osipov
c6b8dcedf9 A fix for Bug#44495 "Prepared Statement: CALL p(<x>) - `thd->protocol == &thd->protocol_text'
failed"

Do not assume that SQL prepared statements always run in text protocol.
When invoked from a stored procedure, which is itself invoked
by means of prepared CALL statement, the protocol may be binary.
Juggle with the protocol only when we want to change it
to binary in COM_STMT_EXECUTE, COM_STMT_PREPARE.

This is a backport from 5.4/6.0, where the bug was fixed
as part of WL#4264 "Backup: Stabilize Service Interface"
2009-07-15 21:00:34 +04:00
Staale Smedseng
2380d465f0 Merge from 5.0-bugteam 2009-06-17 16:56:44 +02:00
Staale Smedseng
3b0e6e4109 Bug #43414 Parenthesis (and other) warnings compiling MySQL
with gcc 4.3.2
      
Compiling MySQL with gcc 4.3.2 and later produces a number of 
warnings, many of which are new with the recent compiler
versions.
                  
This bug will be resolved in more than one patch to limit the
size of changesets. This is the second patch, fixing more
of the warnings.
2009-06-17 15:54:01 +02:00
Staale Smedseng
a103509788 Bug #43414 Parenthesis (and other) warnings compiling MySQL
with gcc 4.3.2

Compiling MySQL with gcc 4.3.2 and later produces a number of 
warnings, many of which are new with the recent compiler
versions.
            
This bug will be resolved in more than one patch to limit the
size of changesets. This is the second patch, fixing more
of the warnings.
2009-06-10 16:04:07 +02:00
Magnus Blåudd
51dd28a9a9 Merge bug#45326 2009-06-05 13:23:58 +02:00
Magnus Blåudd
6c999d777a Bug#45326 Linker failure for libmysqld with VC++ 2008
- Rename the  functions in mysqld that conflict with the one in the
   external interface defined by mysql.h
2009-06-05 13:11:55 +02:00
Staale Smedseng
059dba14b7 Recommit of bug 43560 after merge with mysql-5.1-bugteam 2009-05-20 16:17:47 +02:00
Chad MILLER
4822696ecb Pull 5.1 treatment of community features into 5.0. 2009-05-05 17:03:23 -04:00
Chad MILLER
14f923c028 Merge 5.0.80 release and 5.0 community. Version left at 5.0.80. 2009-04-14 13:20:13 -04:00
Ignacio Galarza
5b7347bda3 Bug#29125 Windows Server X64: so many compiler warnings
- Remove bothersome warning messages.  This change focuses on the warnings 
that are covered by the ignore file: support-files/compiler_warnings.supp.
- Strings are guaranteed to be max uint in length
2009-02-13 11:41:47 -05:00
Ignacio Galarza
54fbbf9591 Bug#29125 Windows Server X64: so many compiler warnings
- Remove bothersome warning messages.  This change focuses on the warnings 
that are covered by the ignore file: support-files/compiler_warnings.supp.
- Strings are guaranteed to be max uint in length
2009-02-10 17:47:54 -05:00
Chad MILLER
926e5f6694 Merged from 5.0 (enterprise). 2008-12-17 15:01:34 -05:00
Marc Alff
f34c99b4d8 Bug#35577, manual merge mysql-5.0-bugteam -> mysql-5.1-bugteam 2008-07-14 19:43:12 -06:00
Marc Alff
e73e7bb9ae Bug#35577 (CREATE PROCEDURE causes either crash or syntax error depending on
build)

The crash was caused by freeing the internal parser stack during the parser
execution.
This occured only for complex stored procedures, after reallocating the parser
stack using my_yyoverflow(), with the following C call stack:
- MYSQLparse()
- any rule calling sp_head::restore_lex()
- lex_end()
- x_free(lex->yacc_yyss), xfree(lex->yacc_yyvs)

The root cause is the implementation of stored procedures, which breaks the
assumption from 4.1 that there is only one LEX structure per parser call.

The solution is to separate the LEX structure into:
- attributes that represent a statement (the current LEX structure),
- attributes that relate to the syntax parser itself (Yacc_state),
so that parsing multiple statements in stored programs can create multiple
LEX structures while not changing the unique Yacc_state.

Now, Yacc_state and the existing Lex_input_stream are aggregated into
Parser_state, a structure that represent the complete state of the (Lexical +
Syntax) parser.


mysql-test/r/parser_stack.result:
  Bug#35577 (CREATE PROCEDURE causes either crash or syntax error depending on
  build)
mysql-test/t/parser_stack.test:
  Bug#35577 (CREATE PROCEDURE causes either crash or syntax error depending on
  build)
sql/sp.cc:
  Bug#35577 (CREATE PROCEDURE causes either crash or syntax error depending on
  build)
sql/sp_head.cc:
  Bug#35577 (CREATE PROCEDURE causes either crash or syntax error depending on
  build)
sql/sql_class.cc:
  Bug#35577 (CREATE PROCEDURE causes either crash or syntax error depending on
  build)
sql/sql_class.h:
  Bug#35577 (CREATE PROCEDURE causes either crash or syntax error depending on
  build)
sql/sql_lex.cc:
  Bug#35577 (CREATE PROCEDURE causes either crash or syntax error depending on
  build)
sql/sql_lex.h:
  Bug#35577 (CREATE PROCEDURE causes either crash or syntax error depending on
  build)
sql/sql_parse.cc:
  Bug#35577 (CREATE PROCEDURE causes either crash or syntax error depending on
  build)
sql/sql_prepare.cc:
  Bug#35577 (CREATE PROCEDURE causes either crash or syntax error depending on
  build)
sql/sql_trigger.cc:
  Bug#35577 (CREATE PROCEDURE causes either crash or syntax error depending on
  build)
sql/sql_view.cc:
  Bug#35577 (CREATE PROCEDURE causes either crash or syntax error depending on
  build)
sql/sql_yacc.yy:
  Bug#35577 (CREATE PROCEDURE causes either crash or syntax error depending on
  build)
2008-07-14 15:41:30 -06:00
Chad MILLER
a4e7283a92 Merge from 5.0 trunk. 2008-07-14 16:16:37 -04:00
Chad MILLER
c425bf421d Merge chunk from trunk. 2008-07-10 14:50:07 -04:00
Konstantin Osipov
7b8bfb2a93 A fix for
Bug#12093 "SP not found on second PS execution if another thread 
drops other SP in between" and
Bug#21294 "executing a prepared statement that executes a stored 
function which was recreat"

Stored functions are resolved at prepared statement prepare only.
If someone flushes the stored functions cache between prepare and
execute, execution fails.

The fix is to detect the situation of the cache flush and automatically
reprepare the prepared statement after it.

mysql-test/r/ps_ddl.result:
  Update results (Bug#12093 and Bug#21294, the test cases are already
  in the source tree).
mysql-test/r/ps_ddl1.result:
  Update results (Bug#12093 and Bug#21294, the test cases are already
  in the source tree).
mysql-test/r/sp-error.result:
  Update results (Bug#12093 and Bug#21294, the test cases are already
  in the source tree).
mysql-test/t/ps_ddl.test:
  Modify the test to not expect an error where there is no error
  any more (Bug#12093, Bug#21294).
mysql-test/t/ps_ddl1.test:
  Modify the test to not expect an error where there is no error
  any more (Bug#12093, Bug#21294).
mysql-test/t/sp-error.test:
  Modify the test to not expect an error where there is no error
  any more (Bug#12093, Bug#21294).
sql/sp_cache.cc:
  Implement sp_cache_version() -- returns the current version of 
  a stored routines cache.
sql/sp_cache.h:
  Declare sp_cache_version().
sql/sql_prepare.cc:
  Keep track of stored functions cache version, and invalidate
  the statement if it changed between prepared statement
  prepare and execute (and the statement actually uses stored routines).
2008-07-03 23:41:22 +04:00
Mattias Jonsson
58f30a5886 Bug#31210: INSERT DELAYED crashes server when used on partitioned tables
post push patch

push build found tree failing test when using:
--ps-protocol --mysqld=--binlog-format=row
Changed to the new error message.

sql/sql_prepare.cc:
  Bug#31210: INSERT DELAYED crashes server when used on partitioned tables
  
  Changed to the newly added error message
2008-06-09 14:39:20 +02:00
unknown
02c901ee5e Bug#27430 "Crash in subquery code when in PS and table DDL changed after
PREPARE", review fixes:
- make the patch follow the specification of WL#4166 and remove  
the new error that was originally introduced.
Now the client never gets an error from reprepare, unless it failed.
I.e. even if the statement at hand returns a completely different
result set, this is not considered a server error.
The C API library, that can not handle this situation, was modified to
return a client error.
Added additional test coverage.


include/errmsg.h:
  Add a new client side error: now when we automatically
  reprepare a statement, the new result set may contain a different
  number of columns.
include/mysql_com.h:
  Add a new server status to be sent to the client if the 
  number of columns in the result set is different.
libmysql/errmsg.c:
  Add a new error message.
libmysql/libmysql.c:
  Make the client library robust against a result set that
  contains a different number of columns from prepare time.
  Previously that could never happen, and we simply had an assert.
  That means in particular that all clients are advised to upgrade
  with transition to 5.1, if they are using prepared statements C API.
  Make mysql_stmt_store_result() and mysql_stmt_execute() robust against 
  "broken" statement handles (those that have an error).
sql/sql_parse.cc:
  Clear transient server status flags at start of statement more 
  systematically.
sql/share/errmsg.txt:
  Remove an error that is unused and is not part of any public release.
sql/sql_prepare.cc:
  Instead of returning an error in case the number of result set columns
  has changed, simply update the client in server status.
  That will allow modern clients automatically recover from an error.
tests/mysql_client_test.c:
  Add additional coverage to the cases when the number of result
  set columns changed as a result of reprepare.
  Cover conversion and truncation of result set columns.
2008-05-20 20:36:26 +04:00
unknown
37b2c32d95 Bug#27430 "Crash in subquery code when in PS and table DDL changed after
PREPARE": rename members, methods, classes to follow the spec 
(a code review request)


sql/mysql_priv.h:
  enum_metadata_type -> enum_table_ref_type
sql/sp_head.cc:
  Metadata_version_observer -> Reprepare_observer
sql/sql_base.cc:
  metadata -> table_ref
sql/sql_class.cc:
  Replace an abstract interface with a concrete implementation.
sql/sql_class.h:
  enum_metadata_type -> enum_table_ref_type
sql/sql_prepare.cc:
  Move implementation of Execute_observer to sql_class.cc and
  rename the class to Reprepare_observer.
  Use getters instead of direct access to the members.
sql/table.h:
  metadata -> table_ref
2008-05-20 11:29:16 +04:00
unknown
1c12291b2f Fix mysql_client_test failure in pushbuild 5.1-27430
(Bug#27430)


sql/sql_prepare.cc:
  Fix a simple coding mistake.
2008-05-18 10:28:36 +04:00
unknown
1cf0b5cb89 Implement some code review fixes for the fix for Bug#27430
"Crash in subquery code when in PS and table DDL changed after PREPARE"


include/my_sys.h:
  Add two new flags for my_error(). These flags help parameterize
  behavoiur of my_message_sql()
sql/item.cc:
  Update comments.
  Fix a typo in Item_param::set_param_type_and_swap_value()
sql/mysqld.cc:
  Implement two additional flags for my_error():
   - if ME_NO_SP_HANDLER is specified, ignore stored procedure continue/
      exit handlers
   - if ME_NO_WARNING_FOR_ERROR is specified, do not push warning
sql/sql_base.cc:
  Update comments.
  Rename a few methods.
sql/sql_class.h:
  Update and improve comments.
sql/sql_prepare.cc:
  Update comments.
  Style changes.
sql/table.h:
  Update comments.
  Style changes.
  Rename a few methods.
tests/mysql_client_test.c:
  Zero the bind array, to follow C API requirements.
2008-05-18 01:51:18 +04:00
unknown
bd2a732812 WL#4165 "Prepared statements: validation".
Add metadata validation to ~20 more SQL commands. Make sure that
these commands actually work in ps-protocol, since until now they
were enabled, but not carefully tested.
Fixes the ml003 bug found by Matthias during internal testing of the
patch.


mysql-test/r/ps_ddl.result:
  Update test results (WL#4165)
mysql-test/t/ps_ddl.test:
  Cover with tests metadata validation of 26 SQL statements.
sql/mysql_priv.h:
  Fix the name in the comment.
sql/sp_head.cc:
  Changed the way the observer is removed in case of stored procedures
  to support validation prepare stmt from "call p1(<expr>)": whereas
  tables used in the expression must be validated, substatements
  of p1 must not.
  The previous scheme used to silence the observer only in stored
  functions and triggers.
sql/sql_class.cc:
  Now the observer is silenced in sp_head::execute(). Remove it from
  Sub_statement_state.
sql/sql_class.h:
  Now the observer is silenced in sp_head::execute(). Remove it from
  Sub_statement_state.
sql/sql_parse.cc:
  Add CF_REEXECUTION_FRAGILE to 20 more SQLCOMs that need it.
sql/sql_prepare.cc:
  Add metadata validation to ~20 new SQLCOMs that need it.
  Fix memory leaks with expressions used in SHOW DATABASES and CALL
  (and prepared statements).
  We need to fix all expressions at prepare, since if these expressions
  use subqueries, there are one-time transformations of the parse
  tree that must be done at prepare. 
  List of fixed commands includes: SHOW TABLES, SHOW DATABASES,
  SHOW TRIGGERS, SHOW EVENTS, SHOW OPEN TABLES,SHOW KEYS, SHOW FIELDS, 
  SHOW COLLATIONS, SHOW CHARSETS, SHOW VARIABLES, SHOW TATUS, SHOW TABLE
  STATUS, SHOW PROCEDURE STATUS, SHOW FUNCTION STATUS, CALL.
  Add comment to set_parameters().
sql/table.h:
  Update comments.
2008-04-17 01:04:49 +04:00
unknown
1ff9a2437a Fix pushbuild errors and warnings. 2008-04-08 21:49:31 +04:00
unknown
a63dde5a5b Tentative implementation of
WL#4165 Prepared statements: validation 
WL#4166 Prepared statements: automatic re-prepare
Fixes
Bug#27430 Crash in subquery code when in PS and table DDL changed after PREPARE
Bug#27690 Re-execution of prepared statement after table was replaced with a view crashes
Bug#27420 A combination of PS and view operations cause error + assertion on shutdown

The basic idea of the patch is to keep track of table metadata between
prepared statement prepare and execute. If some table used in the statement
has changed, the prepared statement is re-prepared before execution.

See WL#4165 and WL#4166 contents and comments in the code for details
of the implementation.


include/my_global.h:
  Remove 'register' keyword to avoid warnings when swapping large structures
  that don't fit into a register. Any modern compiler is capable of placing
  a variable in a register when that would benefit performance.
mysql-test/r/ps_1general.result:
  Update test results: since now we re-prepare automatically,
  more correct results are produced in prepare-ddl-execute scenario.
mysql-test/r/query_cache_merge.result:
  Ensure that the table definition cache is large enough for
  the test to pass in --ps-protocol
mysql-test/r/trigger.result:
  Update test results to reflect automatic statement reprepare.
mysql-test/t/disabled.def:
  Enable ps_ddl.test, which now passes.
mysql-test/t/ps_1general.test:
  Since now we re-execute prepared statements after DDL successfully,
  change the test to produce repeatable results. Remove expectancy of
  an error in one place where now we automatically reprepare the prepared
  statement.
mysql-test/t/query_cache_merge.test:
  Ensure the table definition cache is large enough for the test to pass
  in --ps-protocol
mysql-test/t/trigger.test:
  Sinc
sql/item.cc:
  Implement Item_param "copy" functionality, used at re-prepare of
  a prepared statement.
  We copy the type of the original parameter, and move the assigned value,
  if any. Sic, the value is "moved", since it can be quite big --
  e.g. in case we deal with a LONG DATA parameter.
  It's essential to move the value from the old parameter since
  at the time of re-prepare the client packet with the necessary information
  may be not available.
sql/item.h:
  Declare a new method used for reprepare.
sql/my_decimal.h:
  Implement "swap()" functionality of class my_decimal to be
  able to easily swap two decimal values.
sql/mysql_priv.h:
  Declare enum_metadata_type.
sql/mysqld.cc:
  Implement a status variable for the number of reprepared statements.
sql/sql_base.cc:
  Implement metadata version validation.
sql/share/errmsg.txt:
  Add two new error messages: ER_NEED_REPREPARE and ER_PS_REBIND.
  The first error (theoretically) never reaches the user.
  It is issued by the metadata validation framework when a metadata version
  has changed between prepare and execute. Later on it's intercepted
  and the statement is automatically re-prepared. Only if the error
  has occurred repeatedly MAX_REPREPARE_ATTEMTS (3) times do we
  return it to the user.
  
  The second error is issued when after re-prepare we discover
  that the metadata we sent over to the client using the binary
  protocol differs drammatically from the new result set metadata 
  that the reprepared statement produces (e.g. number of result
  set columns is different).
sql/sql_class.cc:
  Implement metadata version validation framework.
sql/sql_class.h:
  Declarations for metadata version validation framework.
sql/sql_parse.cc:
  Mark commands for which we must invalidate and reprepare a prepared
  statement when metadata has changed.
sql/sql_prepare.cc:
  Implement WL#4165 and WL#4166 (limited support of metadata validation
  and re-prepare).
sql/table.h:
  Implement metadata validation.
tests/mysql_client_test.c:
  Add a test case for WL#4166
2008-04-08 20:01:20 +04:00
unknown
f6bee7c13d Merge mysql.com:/Users/davi/mysql/bugs/ps-cleanup-5.1
into  mysql.com:/Users/davi/mysql/mysql-5.1-runtime


sql/sql_prepare.cc:
  Auto merged
2008-03-31 09:54:36 -03:00
unknown
a451de2f59 Merge host.loc:/home/uchum/work/mysql-5.1
into  host.loc:/home/uchum/work/5.1-opt


client/mysqltest.c:
  Auto merged
mysql-test/r/information_schema.result:
  Auto merged
mysql-test/t/information_schema.test:
  Auto merged
sql/item.cc:
  Auto merged
sql/log.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/sql_acl.cc:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_delete.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_prepare.cc:
  Auto merged
sql/sql_show.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/sql_update.cc:
  Auto merged
2008-03-27 15:54:45 +04:00
unknown
11cfd2ed67 Merge host.loc:/home/uchum/work/mysql-5.0
into  host.loc:/home/uchum/work/5.0-opt


sql/sql_delete.cc:
  Auto merged
sql/sql_prepare.cc:
  Auto merged
sql/sql_update.cc:
  Auto merged
2008-03-27 15:52:55 +04:00
unknown
5a7d224da2 Post-merge fixes for bug 35103
Don't signal errors for the COM_STMT_SEND_LONG_DATA
and COM_STMT_CLOSE commands.


sql/sql_prepare.cc:
  Move error signaling to the callers and out of the helper
  functions because some prepared statements commands
  don't signal errors (they won't send response packets).
2008-03-25 20:48:20 -03:00
unknown
1b6118190e Merge magare.gmz:/home/kgeorge/mysql/autopush/B26461-5.0-opt
into  magare.gmz:/home/kgeorge/mysql/work/B26461-5.1-opt


CMakeLists.txt:
  Auto merged
include/config-win.h:
  Auto merged
include/my_global.h:
  Auto merged
sql/procedure.h:
  Auto merged
sql/sql_acl.cc:
  Auto merged
sql/sql_acl.h:
  Auto merged
sql/sql_analyse.cc:
  Auto merged
sql/sql_analyse.h:
  Auto merged
sql/sql_db.cc:
  Auto merged
sql/sql_delete.cc:
  Auto merged
sql/sql_load.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_update.cc:
  Auto merged
sql/handler.h:
  merged bug 26461 to 5.1-opt
sql/mysql_priv.h:
  merged bug 26461 to 5.1-opt
sql/sql_base.cc:
  merged bug 26461 to 5.1-opt
sql/sql_prepare.cc:
  merged bug 26461 to 5.1-opt
2008-03-21 17:48:28 +02:00
unknown
cebb6727b3 Bug #26461: Intrinsic data type bool (1 byte) redefined to BOOL (4 bytes)
The bool data type was redefined to BOOL (4 bytes on windows).
Removed the #define and fixed some of the warnings that were uncovered
by this.
Note that the fix also disables 2 warnings :
4800 : 'type' : forcing value to bool 'true' or 'false' (performance warning)
4805: 'operation' : unsafe mix of type 'type' and type 'type' in operation

These warnings will be handled in a separate bug, as they are performance related or bogus.

Fixed to int the return type of functions that return more than 
2 distinct values.


CMakeLists.txt:
  Bug #26461: disable the C4800 and C4805 warnings temporarily
include/config-win.h:
  Bug #26461: 
   - no need for this define for Windows.
   - windows C++ compilers have a bool type
include/my_global.h:
  Bug #26461: removed bool_defined (no longer needed)
sql/handler.h:
  Bug #26461: bool functions must return boolean values
sql/mysql_priv.h:
  Bug #26461: fixed return type of functions that return more than
  2 distinct values.
sql/procedure.h:
  Bug #26461: fixed return type of functions that return more than
  2 distinct values.
sql/sql_acl.cc:
  Bug #26461: fixed return type of functions that return more than
  2 distinct values.
sql/sql_acl.h:
  Bug #26461: fixed return type of functions that return more than
  2 distinct values.
sql/sql_analyse.cc:
  Bug #26461: fixed return type of functions that return more than
  2 distinct values.
sql/sql_analyse.h:
  Bug #26461: fixed return type of functions that return more than
  2 distinct values.
sql/sql_base.cc:
  Bug #26461: fixed return type of functions that return more than
  2 distinct values.
sql/sql_db.cc:
  Bug #26461: fixed return type of functions that return more than
  2 distinct values.
sql/sql_delete.cc:
  Bug #26461: fixed return type of functions that return more than
  2 distinct values.
sql/sql_load.cc:
  Bug #26461: fixed return type of functions that return more than
  2 distinct values.
sql/sql_parse.cc:
  Bug #26461: fixed return type of functions that return more than
  2 distinct values.
sql/sql_prepare.cc:
  Bug #26461: fixed return type of functions that return more than
  2 distinct values.
sql/sql_update.cc:
  Bug #26461: fixed return type of functions that return more than
  2 distinct values.
2008-03-21 17:23:17 +02:00
unknown
809522598a Post-merge fixes for Bug 35103
libmysql/libmysql.c:
  Manual merge
sql/sql_class.cc:
  Don't send anything back to the client if disabled.
sql/sql_prepare.cc:
  Don't send any packet back for statement close.
tests/mysql_client_test.c:
  Manual merge
2008-03-17 16:39:09 -03:00
unknown
23d567aa7c Post-merge fix for Bug 35103.
sql/sql_prepare.cc:
  Don't send unexpected error to the client.
2008-03-17 11:16:37 -03:00
unknown
063b504772 Bug#35103 mysql_client_test::test_bug29948 causes sporadic failures
The problem was that the COM_STMT_SEND_LONG_DATA was sending a response
packet if the prepared statement wasn't found in the server (due to
reconnection). The commands COM_STMT_SEND_LONG_DATA and COM_STMT_CLOSE
should not send any packets, even error packets should not be sent since
they are not expected by the client API.

The solution is to clear generated during the execution of the aforementioned
commands and to skip resend of prepared statement commands. Another fix is
that if the connection breaks during the send of prepared statement command,
the command is not sent again since the prepared statement is no longer in the
server.


libmysql/libmysql.c:
  The mysql handle might be reset after a reconnection.
  Pass the now used stmt argument to cli_advanced_command.
sql-common/client.c:
  Don't resend command if the connection broke and it's a prepared
  statement command. If the session is broken, prepared statements
  on the server are gone, set the error accordanly.
sql/sql_prepare.cc:
  Clear any error set during the execution of the request
  command.
tests/mysql_client_test.c:
  Fix memory leak by freeing result associated with statement.
  Remove test case for Bug 29948 because it's not reliable in
  5.0 (fixed in 5.1) due to KILL queries sending two packets for
  a thread that kills itself.
2008-03-14 17:40:12 -03:00
unknown
b2e879cbe8 Bug#28386 the general log is incomplete
The problem is that the commands COM_STMT_CLOSE, COM_STMT_RESET,
COM_STMT_SEND_LONG_DATA weren't being logged to the general log.

The solution is to log the general log the aforementioned commands.


mysql-test/t/mysql_client_test-master.opt:
  Also log to table.
sql/sql_prepare.cc:
  Log COM_STMT_CLOSE, COM_STMT_RESET and COM_STMT_SEND_LONG_DATA.
tests/mysql_client_test.c:
  Add test case for Bug#28386
2008-02-25 07:48:02 -03:00
unknown
955b3e3d0b Merge buzz.(none):/home/davi/mysql-5.0-runtime
into  buzz.(none):/home/davi/mysql-5.1-runtime


mysql-test/r/ps.result:
  Auto merged
mysql-test/t/ps.test:
  Auto merged
sql/sql_view.h:
  Auto merged
sql/item.h:
  Manual merge
sql/sql_prepare.cc:
  Manual merge
sql/sql_view.cc:
  Manual merge
2008-02-21 23:21:52 -02:00
unknown
9f245df853 Post-merge fix to silence compiler warning.
sql/sql_prepare.cc:
  Removed unused variable.
2008-02-21 19:28:25 -02:00
unknown
315665cf67 Bug#32890 Crash after repeated create and drop of tables and views
The problem is that CREATE VIEW statements inside prepared statements
weren't being expanded during the prepare phase, which leads to objects
not being allocated in the appropriate memory arenas.

The solution is to perform the validation of CREATE VIEW statements
during the prepare phase of a prepared statement. The validation
during the prepare phase assures that transformations of the parsed
tree will use the permanent arena of the prepared statement.


mysql-test/r/ps.result:
  Add test case result for Bug#32890
mysql-test/t/ps.test:
  Add test case for Bug#32890
sql/item.h:
  Restore original field name if name is auto generated.
sql/sql_prepare.cc:
  Validate and prepare a CREATE VIEW statement for execution.
sql/sql_view.cc:
  Move privileges check to it's own function.
sql/sql_view.h:
  Export function which check privileges of a CREATE VIEW statement.
2008-02-21 14:58:29 -03:00
unknown
9060b50f14 Rename send_eof() to my_eof() for consistency with my_ok() and my_error() 2008-02-19 15:58:08 +03:00
unknown
14021c96c4 Rename send_ok to my_ok. Similarly to my_error, it only records the status,
does not send it to the client.
2008-02-19 15:45:21 +03:00
unknown
d639cdc39c Merge quad.:/mnt/raid/alik/MySQL/devel/5.1
into  quad.:/mnt/raid/alik/MySQL/devel/5.1-rt-merged


client/mysqlcheck.c:
  Auto merged
configure.in:
  Auto merged
extra/resolveip.c:
  Auto merged
include/my_sys.h:
  Auto merged
mysql-test/mysql-test-run.pl:
  Auto merged
mysql-test/r/ctype_ucs.result:
  Auto merged
mysql-test/r/func_misc.result:
  Auto merged
mysql-test/r/information_schema.result:
  Auto merged
mysql-test/r/mysqlcheck.result:
  Auto merged
mysql-test/r/variables.result:
  Auto merged
mysql-test/t/ctype_ucs.test:
  Auto merged
mysql-test/t/func_misc.test:
  Auto merged
mysql-test/t/information_schema.test:
  Auto merged
mysql-test/t/mysqlcheck.test:
  Auto merged
sql/item_cmpfunc.cc:
  Auto merged
sql/item_cmpfunc.h:
  Auto merged
sql/item_strfunc.h:
  Auto merged
sql/item_timefunc.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/opt_range.cc:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/set_var.h:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sql_acl.cc:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_cache.cc:
  Auto merged
sql/sql_prepare.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_show.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/sql_trigger.cc:
  Auto merged
sql/sql_view.cc:
  Auto merged
storage/innobase/buf/buf0buf.c:
  Auto merged
storage/innobase/buf/buf0flu.c:
  Auto merged
storage/innobase/buf/buf0lru.c:
  Auto merged
storage/innobase/include/buf0buf.h:
  Auto merged
storage/innobase/include/buf0buf.ic:
  Auto merged
storage/innobase/include/sync0arr.h:
  Auto merged
storage/innobase/include/sync0rw.h:
  Auto merged
storage/innobase/include/sync0rw.ic:
  Auto merged
storage/innobase/include/sync0sync.h:
  Auto merged
storage/innobase/os/os0sync.c:
  Auto merged
storage/innobase/sync/sync0arr.c:
  Auto merged
storage/innobase/sync/sync0rw.c:
  Auto merged
storage/innobase/sync/sync0sync.c:
  Auto merged
storage/myisam/ft_boolean_search.c:
  Auto merged
storage/myisam/ha_myisam.cc:
  Auto merged
storage/myisam/sort.c:
  Auto merged
sql/sql_parse.cc:
  Manual merge.
2008-02-01 13:55:39 +03:00
unknown
39509d64c3 A fix and a test case for Bug#34166 Server crash in SHOW OPEN TABLES and
pre-locking.

The crash was caused by an implicit assumption in check_table_access() that
table_list parameter is always a part of lex->query_tables.

When iterating over the passed list of tables, check_table_access() used
to stop only when lex->query_tables_last_not_own was reached. 
In case of pre-locking, lex->query_tables_last_own is not NULL and points
to some element of lex->query_tables. When the parameter
of check_table_access() was not part of lex->query_tables, loop invariant
could never be violated and a crash would happen when the current table
pointer would point beyond the end of the provided list.

The fix is to change the signature of check_table_access() to also accept
a numeric limit of loop iterations, similarly to check_grant(), and 
supply this limit in all places when we want to check access of tables
that are outside lex->query_tables, or just want to check access to one table.


mysql-test/r/information_schema.result:
  Update test results (Bug#34166).
mysql-test/t/information_schema.test:
  Add a test case for Bug#34166.
sql/mysql_priv.h:
  Change signature of check_table_access() to accept a numeric limit
  of tables to check.
sql/sp_head.cc:
  Update to the new signature of check_table_access().
sql/sql_acl.cc:
  Improve code clarity: if there is a numeric limit, we should not need
  to look at first_not_own_table.
sql/sql_base.cc:
  Update to the new signature of check_table_access().
sql/sql_cache.cc:
  Update to the new signature of check_table_access().
sql/sql_parse.cc:
  Update to the new signature of check_table_access().
  Change check_table_access() to accept an optional numeric limit of tables
  to check. A crash would happen when check_table_access() was
  passed a list of tables that is not part of lex->query_tables and
  lex->query_tables_last_own was not NULL.
sql/sql_plugin.cc:
  Update to the new signature of check_table_access().
sql/sql_prepare.cc:
  Update to the new signature of check_table_access().
sql/sql_show.cc:
  Update to the new signature of check_table_access().
  Ensure that check_table_access() only checks access to the first
  table in the table list when called from list_open_tables().
  list_open_tables() supplies a table list that is created on stack,
  whereas check_table_access() used to assume that the supplied list is a part
  of thd->lex.
sql/sql_trigger.cc:
  Update to the new signature of check_table_access().
sql/sql_view.cc:
  Update to the new signature of check_table_access().
2008-01-30 18:27:41 +03:00
unknown
295732b580 Merge bk-internal.mysql.com:/home/bk/mysql-5.1-maint
into  janus.mylan:/usr/home/serg/Abk/mysql-5.1


configure.in:
  Auto merged
libmysql/CMakeLists.txt:
  Auto merged
libmysqld/lib_sql.cc:
  Auto merged
mysql-test/mysql-test-run.pl:
  Auto merged
mysql-test/r/information_schema.result:
  Auto merged
mysql-test/t/information_schema.test:
  Auto merged
sql/Makefile.am:
  Auto merged
sql/field.cc:
  Auto merged
sql/handler.cc:
  Auto merged
sql/item.cc:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/item_geofunc.cc:
  Auto merged
sql/item_subselect.cc:
  Auto merged
sql/key.cc:
  Auto merged
sql/lock.cc:
  Auto merged
sql/log.cc:
  Auto merged
sql/log_event.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/net_serv.cc:
  Auto merged
sql/opt_sum.cc:
  Auto merged
sql/protocol.h:
  Auto merged
sql/repl_failsafe.cc:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/set_var.h:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_cache.cc:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_delete.cc:
  Auto merged
sql/sql_insert.cc:
  Auto merged
sql/sql_lex.cc:
  Auto merged
sql/sql_prepare.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_select.h:
  Auto merged
sql/sql_show.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/sql_update.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
sql/table.h:
  Auto merged
storage/archive/ha_archive.cc:
  Auto merged
storage/innobase/buf/buf0buf.c:
  Auto merged
storage/innobase/buf/buf0flu.c:
  Auto merged
storage/innobase/buf/buf0lru.c:
  Auto merged
storage/innobase/include/buf0buf.h:
  Auto merged
storage/innobase/include/buf0buf.ic:
  Auto merged
storage/innobase/include/sync0arr.h:
  Auto merged
storage/innobase/include/sync0rw.h:
  Auto merged
storage/innobase/include/sync0rw.ic:
  Auto merged
storage/innobase/include/sync0sync.h:
  Auto merged
storage/innobase/os/os0sync.c:
  Auto merged
storage/innobase/sync/sync0arr.c:
  Auto merged
storage/innobase/sync/sync0rw.c:
  Auto merged
storage/innobase/sync/sync0sync.c:
  Auto merged
storage/myisam/ha_myisam.cc:
  Auto merged
storage/myisam/mi_open.c:
  Auto merged
storage/myisammrg/ha_myisammrg.cc:
  Auto merged
sql/ha_ndbcluster.cc:
  merged
sql/item_cmpfunc.cc:
  merged
sql/protocol.cc:
  merged
sql/slave.cc:
  merged
sql/sql_class.h:
  merged
sql/sql_parse.cc:
  merged
2007-12-20 22:11:37 +01:00
unknown
7fd0ad21a7 Merge zippy.cornsilk.net:/home/cmiller/work/mysql/mysql-5.1-forcollapseandmerge
into  zippy.cornsilk.net:/home/cmiller/work/mysql/mysql-5.1-maint


CMakeLists.txt:
  Auto merged
configure.in:
  Auto merged
libmysql/CMakeLists.txt:
  Auto merged
libmysqld/lib_sql.cc:
  Auto merged
mysql-test/r/information_schema_db.result:
  Auto merged
mysql-test/t/information_schema.test:
  Auto merged
sql/CMakeLists.txt:
  Auto merged
sql/ha_ndbcluster.cc:
  Auto merged
sql/item_cmpfunc.cc:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/lock.cc:
  Auto merged
sql/log_event.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/repl_failsafe.cc:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/set_var.h:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sql_cache.cc:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_insert.cc:
  Auto merged
sql/sql_lex.cc:
  Auto merged
sql/sql_lex.h:
  Auto merged
sql/sql_prepare.cc:
  Auto merged
sql/sql_repl.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_show.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/sql_view.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
sql/structs.h:
  Auto merged
sql/table.h:
  Auto merged
storage/archive/ha_archive.cc:
  Auto merged
storage/myisam/ha_myisam.cc:
  Auto merged
storage/myisam/mi_open.c:
  Auto merged
storage/myisammrg/ha_myisammrg.cc:
  Auto merged
support-files/mysql.spec.sh:
  Auto merged
client/mysqlcheck.c:
  Manual merge.
mysql-test/r/information_schema.result:
  Manual merge.
mysql-test/r/mysqlcheck.result:
  Manual merge.
mysql-test/t/mysqlcheck.test:
  Manual merge.
sql/slave.cc:
  Manual merge.
sql/sql_base.cc:
  Manual merge.
sql/sql_delete.cc:
  Manual merge.
sql/sql_parse.cc:
  Manual merge.
sql/sql_update.cc:
  Manual merge.
2007-12-14 13:42:09 -05:00
unknown
18f5e87ed9 Merge bk-internal.mysql.com:/home/bk/mysql-5.1-maint
into  zippy.cornsilk.net:/home/cmiller/work/mysql/mysql-5.1-maint


sql/field.cc:
  Auto merged
sql/filesort.cc:
  Auto merged
sql/ha_ndbcluster.cc:
  Auto merged
sql/handler.cc:
  Auto merged
sql/item_cmpfunc.cc:
  Auto merged
sql/item_create.cc:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/item_geofunc.cc:
  Auto merged
sql/item_strfunc.cc:
  Auto merged
sql/item_subselect.cc:
  Auto merged
sql/item_sum.cc:
  Auto merged
sql/item_timefunc.cc:
  Auto merged
sql/log.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/net_serv.cc:
  Auto merged
sql/opt_sum.cc:
  Auto merged
sql/protocol.h:
  Auto merged
sql/records.cc:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/sp.cc:
  Auto merged
sql/sp_head.h:
  Auto merged
sql/sql_cache.cc:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_prepare.cc:
  Auto merged
sql/sql_select.h:
  Auto merged
sql/sql_trigger.cc:
  Auto merged
sql/sql_update.cc:
  Auto merged
sql/sql_view.cc:
  Auto merged
sql/structs.h:
  Auto merged
sql/unireg.h:
  Auto merged
sql/item.cc:
  manual merge
sql/log_event.cc:
  manual merge
sql/protocol.cc:
  manual merge
sql/sp_head.cc:
  manual merge
sql/sql_base.cc:
  manual merge
sql/sql_parse.cc:
  manual merge
sql/sql_select.cc:
  manual merge
2007-12-14 10:52:10 -05:00
unknown
2a0d2fef51 Bug#12713 "Error in a stored function called from a SELECT doesn't
cause ROLLBACK of statement", part 1. Review fixes.

Do not send OK/EOF packets to the client until we reached the end of 
the current statement.
This is a consolidation, to keep the functionality that is shared by all 
SQL statements in one place in the server.
Currently this functionality includes:
- close_thread_tables()
- log_slow_statement().

After this patch and the subsequent patch for Bug#12713, it shall also include:
- ha_autocommit_or_rollback()
- net_end_statement()
- query_cache_end_of_result().

In future it may also include:
- mysql_reset_thd_for_next_command().


include/mysql_com.h:
  Rename now unused members of NET: no_send_ok, no_send_error, report_error.
  These were server-specific variables related to the client/server
  protocol. They have been made obsolete by this patch.
  
  Previously the same members of NET were used to store the error message
  both on the client and on the server. 
  The error message was stored in net.last_error (client: mysql->net.last_error,
  server: thd->net.last_error).
  The error code was stored in net.last_errno (client: mysql->net.last_errno,
  server: thd->net.last_errno).
  The server error code and message are now stored elsewhere 
  (in the Diagnostics_area), thus NET members are no longer used by the
  server.
  Rename last_error to client_last_error, last_errno to client_last_errno
  to avoid potential bugs introduced by merges.
include/mysql_h.ic:
  Update the ABI file to reflect a rename. 
  Renames do not break the binary compatibility.
libmysql/libmysql.c:
  Rename last_error to client_last_error, last_errno to client_last_errno.
  This is necessary to ensure no unnoticed bugs introduced by merged
  changesets.
  
  Remove net.report_error, net.no_send_ok, net.no_send_error.
libmysql/manager.c:
  Rename net.last_errno to net.client_last_errno.
libmysqld/lib_sql.cc:
  Rename net.last_errno to net.client_last_errno.
  
  Update the embedded implementation of the client-server protocol to
  reflect the refactoring of protocol.cc.
libmysqld/libmysqld.c:
  Rename net.last_errno to net.client_last_errno.
mysql-test/r/events.result:
  Update to reflect the change in mysql_rm_db(). Now we drop stored
  routines and events for a given database name only if there
  is a directory for this database name. ha_drop_database() and
  query_cache_invalidate() are called likewise. 
  Previously we would attempt to drop routines/events even if database
  directory was not found (it worked, since routines and events are stored
  in tables). This fixes Bug 29958 "Weird message on DROP DATABASE if mysql.proc
  does not exist".
  The change was done because the previous code used to call send_ok()
  twice, which led to an assertion failure when asserts against it were
  added by this patch.
mysql-test/r/grant.result:
  Fix the patch for Bug 16470, now FLUSH PRIVILEGES produces an error 
  if mysql.procs_priv is missing.
  This fixes the assert that send_ok() must not called after send_error()
  (the original patch for Bug 16470 was prone to this).
mysql-test/suite/rpl/r/rpl_row_tabledefs_2myisam.result:
  Produce a more detailed error message.
mysql-test/suite/rpl/r/rpl_row_tabledefs_3innodb.result:
  Produce a more detailed error message.
mysql-test/t/grant.test:
  Update the test, now FLUSH PRIVILEGES returns an error if mysql.procs_priv
  is missing.
server-tools/instance-manager/mysql_connection.cc:
  Rename net.last_errno to net.client_last_errno.
sql/ha_ndbcluster_binlog.cc:
  Add asserts. 
  
  Use getters to access statement status information.
  
  Add a comment why run_query() is broken. Reset the diagnostics area
  in the end of run_query() to fulfill the invariant that the diagnostics_area
  is never assigned twice per statement (see the comment in the code
  when this can happen). We still do not clear thd->is_fatal_error and
  thd->is_slave_error, which may lead to bugs, I consider the whole affair
  as something to be dealt with separately.
sql/ha_partition.cc:
  fatal_error() doesn't set an error by itself. Perhaps we should
  remove this method altogether and instead add a flag to my_error 
  to set thd->is_fatal_error property.
  
  Meanwhile, this change is a part of inspection made to the entire source
  code with the goal to ensure that fatal_error()
  is always accompanied by my_error().
sql/item_func.cc:
  There is no net.last_error anymore. Remove the obsolete assignment.
sql/log_event.cc:
  Use getters to access statement error status information.
sql/log_event_old.cc:
  Use getters to access statement error status information.
sql/mysqld.cc:
  Previously, if a continue handler for an error was found, my_message_sql() 
  would not set an error in THD. Since the current statement
  must be aborted in any case, find_handler() had a hack to assign 
  thd->net.report_error to 1.
  
  Remove this hack. Set an error in my_message_sql() even if the continue
  handler is found. The error will be cleared anyway when the handler
  is executed. This is one action among many in this patch to ensure the 
  invariant that whenever thd->is_error() is TRUE, we have a message in 
  thd->main_da.message().
sql/net_serv.cc:
  Use a full-blown my_error() in net_serv.cc to report an error,
  instead of just setting net->last_errno. This ensures the invariant that
  whenever thd->is_error() returns TRUE, we have a message in 
  thd->main_da.message().
  
  Remove initialization of removed NET members.
sql/opt_range.cc:
  Use my_error() instead of just raising thd->net.report_error. 
  This ensures the invariant that whenever thd->is_error() returns TRUE, 
  there is a message in thd->main_da.message().
sql/opt_sum.cc:
  Move invocation of fatal_error() right next to the place where
  we set the error message. That makes it easier to track that whenever
  fatal_error() is called, there is a message in THD.
sql/protocol.cc:
  Rename send_ok() and send_eof() to net_send_ok() and net_send_eof() 
  respectively. These functions write directly to the network and are not 
  for use anywhere outside the client/server protocol code. 
  
  Remove the code that was responsible for cases when either there is 
  no error code, or no error message, or both.
  Instead the calling code ensures that they are always present. Asserts
  are added to enforce the invariant.
  
  Instead of a direct access to thd->server_status and thd->total_warn_count
  use function parameters, since these from now on don't always come directly
  from THD.
  
  Introduce net_end_statement(), the single-entry-point replacement API for 
  send_ok(), send_eof() and net_send_error().
  
  Implement Protocol::end_partial_result_set to use in select_send::abort()
  when there is a continue handler.
sql/protocol.h:
  Update declarations.
sql/repl_failsafe.cc:
  Use getters to access statement status information in THD.
  Rename net.last_error to net.client_last_error.
sql/rpl_record.cc:
  Set an error message in prepare_record() if there is no default
  value for the field -- later we do print this message to the client.
sql/rpl_rli.cc:
  Use getters to access statement status information in THD.
sql/slave.cc:
  In create_table_from_dump() (a common function that is used in 
  LOAD MASTER TABLE SQL statement and COM_LOAD_MASTER_DATA), instead of hacks
  with no_send_ok, clear the diagnostics area when mysql_rm_table() succeeded.
  
  Update has_temporary_error() to work correctly when no error is set.
  This is the case when Incident_log_event is executed: it always returns
  an error but does not set an error message.
  
  Use getters to access error status information.
sql/sp_head.cc:
  Instead of hacks with no_send_error, work through the diagnostics area 
  interface to suppress sending of OK/ERROR packets to the client.
  
  Move query_cache_end_of_result before log_slow_statement(), similarly
  to how it's done in dispatch_command().
sql/sp_rcontext.cc:
  Remove hacks with assignment of thd->net.report_error, they are not
  necessary any more (see the changes in mysqld.cc).
sql/sql_acl.cc:
  Use getters to access error status information in THD.
sql/sql_base.cc:
  Access thd->main_da.sql_errno() only if there is an error. This fixes
  a bug when auto-discovery, that was effectively disabled under pre-locking.
sql/sql_binlog.cc:
  Remove hacks with no_send_ok/no_send_error, they are not necessary 
  anymore: the caller is responsible for network communication.
sql/sql_cache.cc:
  Disable sending of OK/ERROR/EOF packet in the end of dispatch_command
  if the response has been served from the query cache. This raises the 
  question whether we should store EOF packet in the query cache at all,
  or generate it anew for each statement (we should generate it anew), but
  this is to be addressed separately.
sql/sql_class.cc:
  Implement class Diagnostics_area. Please see comments in sql_class.h
  for details.
  
  Fix a subtle coding mistake in select_send::send_data: when on slave, 
  an error in Item::send() was ignored.
  The problem became visible due to asserts that the diagnostics area is
  never double assigned.
  
  Remove initialization of removed NET members.
  
  In select_send::abort() do not call select_send::send_eof(). This is
  not inheritance-safe. Even if a stored procedure continue handler is
  found, the current statement is aborted, not succeeded.
  Instead introduce a Protocol API to send the required response, 
  Protocol::end_partial_result_set().
  
  This simplifies implementation of select_send::send_eof(). No need
  to add more asserts that there is no error, there is an assert inside
  Diagnostics_area::set_ok_status() already.
  
  Leave no trace of no_send_* in the code.
sql/sql_class.h:
  Declare class Diagnostics_area. 
  
  Remove the hack with no_send_ok from
  Substatement_state.
  
  Provide inline implementations of send_ok/send_eof.
  
  Add commetns.
sql/sql_connect.cc:
  Remove hacks with no_send_error. 
  
  Since now an error in THD is always set if net->error, it's not necessary
  to check both net->error and thd->is_error() in the do_command loop.
  
  Use thd->main_da.message() instead of net->last_errno.
  
  Remove the hack with is_slave_error in sys_init_connect. Since now we do not
  reset the diagnostics area in net_send_error (it's reset at the beginning
  of the next statement), we can access it safely even after 
  execute_init_command.
sql/sql_db.cc:
  Update the code to satisfy the invariant that the diagnostics area is never
  assigned twice.
  Incidentally, this fixes Bug 29958 "Weird message on DROP DATABASE if 
  mysql.proc does not exist".
sql/sql_delete.cc:
  Change multi-delete to abort in abort(), as per select_send protocol.
  Fixes the merge error with the test for Bug 29136
sql/sql_derived.cc:
  Use getters to access error information.
sql/sql_insert.cc:
  Use getters to access error information.
sql-common/client.c:
  Rename last_error to client_last_error, last_errno to client_last_errno.
sql/sql_parse.cc:
  Remove hacks with no_send_error. Deploy net_end_statement().
  
  The story of COM_SHUTDOWN is interesting. Long story short, the server 
  would become on its death's door, and only no_send_ok/no_send_error assigned
  by send_ok()/net_send_error() would hide its babbling from the client.
  
  First of all, COM_QUIT does not require a response. So, the comment saying
  "Let's send a response to possible COM_QUIT" is not only groundless 
  (even mysqladmin shutdown/mysql_shutdown() doesn't send COM_QUIT after 
  COM_SHUTDOWN), it's plainly incorrect.
  
  Secondly, besides this additional 'OK' packet to respond to a hypothetical
  COM_QUIT, there was the following code in dispatch_command():
  
  if (thd->killed)
    thd->send_kill_message();
  if (thd->is_error()
    net_send_error(thd);
  
  This worked out really funny for the thread through which COM_SHUTDOWN
  was delivered: we would get COM_SHUTDOWN, say okay, say okay again, 
  kill everybody, get the kill signal ourselves, and then attempt to say 
  "Server shutdown in progress" to the client that is very likely long gone.
  
  This all became visible when asserts were added that the Diagnostics_area
  is not assigned twice.
  
  Move query_cache_end_of_result() to the end of dispatch_command(), since
  net_send_eof() has been moved there. This is safe, query_cache_end_of_result()
  is a no-op if there is no started query in the cache.
  
  Consistently use select_send interface to call abort() or send_eof()
  depending on the operation result.
  
  Remove thd->fatal_error() from reset_master(), it was a no-op. 
  in hacks with no_send_error woudl save us
  from complete breakage of the client/server protocol.
  
  Consistently use select_send::abort() whenever there is an error, 
  and select_send::send_eof() in case of success.
  The issue became visible due to added asserts.
sql/sql_partition.cc:
  Always set an error in THD whenever there is a call to fatal_error().
sql/sql_prepare.cc:
  Deploy class Diagnostics_area.
  Remove the unnecessary juggling with the protocol in 
  Select_fetch_protocol_binary::send_eof(). EOF packet format is 
  protocol-independent.
sql/sql_select.cc:
  Call fatal_error() directly in opt_sum_query.
  Call my_error() whenever we call thd->fatal_error().
sql/sql_servers.cc:
  Use getters to access error information in THD.
sql/sql_show.cc:
  Use getters to access error information in THD.
  
  Add comments.
  
  Call my_error() whenever we call fatal_error().
sql/sql_table.cc:
  Replace hacks with no_send_ok with the interface of the diagnostics area.
  
  Clear the error if ENOENT error in ha_delete_table().
sql/sql_update.cc:
  Introduce multi_update::abort(), which is the proper way to abort a
  multi-update. This fixes the merge conflict between this patch and
  the patch for Bug 29136.
sql/table.cc:
  Use a getter to access error information in THD.
sql/tztime.cc:
  Use a getter to access error information in THD.
2007-12-12 18:21:01 +03:00
unknown
b536aa6756 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  zippy.cornsilk.net:/home/cmiller/work/mysql/mysql-5.0-community


CMakeLists.txt:
  Auto merged
include/config-win.h:
  Auto merged
include/my_sys.h:
  Auto merged
libmysql/CMakeLists.txt:
  Auto merged
myisam/mi_open.c:
  Auto merged
mysql-test/r/information_schema.result:
  Auto merged
mysql-test/r/information_schema_db.result:
  Auto merged
mysql-test/r/symlink.result:
  Auto merged
mysql-test/t/information_schema.test:
  Auto merged
mysql-test/t/symlink.test:
  Auto merged
mysys/my_symlink2.c:
  Auto merged
sql/ha_myisam.cc:
  Auto merged
sql/ha_ndbcluster.cc:
  Auto merged
sql/item_cmpfunc.cc:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/log_event.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/set_var.h:
  Auto merged
sql/slave.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_insert.cc:
  Auto merged
sql/sql_lex.h:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_prepare.cc:
  Auto merged
sql/sql_repl.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/sql_view.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
sql/structs.h:
  Auto merged
sql/table.h:
  Auto merged
support-files/mysql.spec.sh:
  Auto merged
win/configure.js:
  Auto merged
Makefile.am:
  Manual merge.
client/mysqlcheck.c:
  Manual merge.
configure.in:
  Manual merge.
mysql-test/r/mysqlcheck.result:
  Manual merge.
mysql-test/t/mysqlcheck.test:
  Manual merge.
sql/sql_delete.cc:
  Manual merge.
sql/sql_update.cc:
  Manual merge.
2007-12-10 15:28:17 -05:00
unknown
569c2dcd12 Merge adventure.(none):/home/thek/Development/cpp/bug31153/my51-bug31153
into  adventure.(none):/home/thek/Development/cpp/mysql-5.1-runtime


sql/mysqld.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sp_head.h:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_lex.h:
  Auto merged
sql/sql_prepare.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
2007-11-21 20:57:28 +01:00
unknown
bc54a3736f Merge adventure.(none):/home/thek/Development/cpp/bug31153/my50-bug31153
into  adventure.(none):/home/thek/Development/cpp/bug31153/my51-bug31153


sql/mysqld.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sp_head.h:
  Auto merged
sql/sql_prepare.cc:
  Auto merged
sql/sql_yacc.yy:
  Null merge.
sql/sql_base.cc:
  Manual merge
sql/sql_lex.h:
  Manual merge
2007-11-21 11:25:17 +01:00
unknown
bb681dbc88 Bug #31153 calling stored procedure crashes server if available memory is low
When the server was out of memory it crashed because of invalid memory access.

This patch adds detection for failed memory allocations and make the server
output a proper error message.


sql/mysqld.cc:
  Don't try to push_warning from within push_warning. It will cause a recursion
  until the stack is consumed.
  
  If my_net_init fails (for example: because of OOM) the temporary vio object 
  might have been attached to the thd object already. This will cause a double
  free on the vio object when the thd object is deleted later on and the server
  will crash.
sql/sp_head.cc:
  Added check for out-of-memory on a 'new' operation.
  Refactored reset_lex method to return a error state code instead of void.
  Initialize the mem-root with init_sql_alloc to get a basic error handler for
  memory allocation problems. This alone won't prevent the server from crashing,
  NULL pointers have to be accounted for as well.
sql/sp_head.h:
  Use the throw() clause in operator new, to indicate to the compiler that
  memory allocation can fail and return NULL, so that the compiler should
  generate code to check for NULL before invoking C++ constructors, to be
  crash safe.
sql/sql_base.cc:
  Use init_sql_alloc to get basic out-of-memory error handling.
sql/sql_lex.h:
  Use the throw() clause in operator new, to indicate to the compiler that
  memory allocation can fail and return NULL, so that the compiler should
  generate code to check for NULL before invoking C++ constructors, to be
  crash safe.
sql/sql_prepare.cc:
  Use init_sql_alloc to get basic out-of-memory error handling.
sql/sql_yacc.yy:
  Check for memory allocation failures where it matters.
2007-11-19 17:59:44 +01:00