Commit graph

561 commits

Author SHA1 Message Date
unknown
c8f6457f65 Merge trift2.:/MySQL/M50/merge-5.0
into  trift2.:/MySQL/M51/push-5.1


netware/mysql_test_run.c:
  Auto merged
sql/sp_head.cc:
  Auto merged
2007-12-21 13:13:22 +01:00
unknown
81c29da83f sp_head.cc:
Corrected typo


sql/sp_head.cc:
  Corrected typo
2007-12-14 21:38:58 +01:00
unknown
e1fe5ab9ca sp_head.cc:
Made sp_head::operator delete() match prototype, added throw()
mysql_test_run.c, mysqld_safe.c:
  Include "mysql_version.h" to get MYSQL_PORT defined


sql/sp_head.cc:
  Made sp_head::operator delete() match prototype, added throw()
netware/mysql_test_run.c:
  Include "mysql_version.h" to get MYSQL_PORT defined
netware/mysqld_safe.c:
  Include "mysql_version.h" to get MYSQL_PORT defined
2007-12-14 18:23:11 +01: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
8bfcdce04d Merge lambda.hsd1.co.comcast.net.:/home/malff/TREE/mysql-5.1-base
into  lambda.hsd1.co.comcast.net.:/home/malff/TREE/mysql-5.1-rt-merge


sql/mysqld.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
2007-11-27 09:03:04 -07:00
unknown
77ab800e77 Merge lambda.hsd1.co.comcast.net.:/home/malff/TREE/mysql-5.0-base
into  lambda.hsd1.co.comcast.net.:/home/malff/TREE/mysql-5.0-rt-merge


sql/mysqld.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
2007-11-27 08:56:43 -07: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
1ae0237f24 Merge adventure.(none):/home/thek/Development/cpp/bug31153/my50-bug31153
into  adventure.(none):/home/thek/Development/cpp/mysql-5.0-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_yacc.yy:
  Manual merge.
2007-11-21 10:02:44 +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
unknown
19ef3ae88d Merge dl145h.mysql.com:/data0/mkindahl/mysql-5.1
into  dl145h.mysql.com:/data0/mkindahl/mysql-5.1-new-rpl


mysql-test/extra/rpl_tests/rpl_extraMaster_Col.test:
  Auto merged
mysql-test/mysql-test-run.pl:
  Auto merged
mysql-test/suite/rpl/include/rpl_mixed_dml.inc:
  Auto merged
mysql-test/suite/rpl/r/rpl_bug31076.result:
  Auto merged
mysql-test/suite/rpl/t/rpl_bug31076.test:
  Auto merged
mysql-test/suite/rpl/t/rpl_innodb_bug28430.test:
  Auto merged
mysql-test/suite/rpl_ndb/t/disabled.def:
  Auto merged
sql/field.cc:
  Auto merged
sql/ha_ndbcluster.cc:
  Auto merged
sql/handler.cc:
  Auto merged
sql/log.cc:
  Auto merged
sql/log_event.cc:
  Auto merged
sql/log_event_old.cc:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/slave.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_insert.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/sql_update.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
mysql-test/t/partition.test:
  Manual merge.
BitKeeper/deleted/.del-rpl_row_extraColmaster_ndb.result~a2c64bae75b49d2:
  Manual merge.
mysql-test/suite/rpl/r/rpl_extraColmaster_innodb.result:
  Manual merge.
mysql-test/suite/rpl/r/rpl_extraColmaster_myisam.result:
  Manual merge.
mysql-test/suite/rpl/t/disabled.def:
  Manual merge.
sql/sql_delete.cc:
  Manual merge.
2007-11-14 11:07:30 +01:00
unknown
611dbd0bb3 Bug#30882 Dropping a temporary table inside a stored function may cause a server crash
If a stored function that contains a drop temporary table statement
is invoked by a create temporary table of the same name may cause
a server crash. The problem is that when dropping a table no check
is done to ensure that table is not being used by some outer query
(or outer statement), potentially leaving the outer query with a
reference to a stale (freed) table.

The solution is when dropping a temporary table, always check if
the table is being used by some outer statement as a temporary
table can be dropped inside stored procedures.

The check is performed by looking at the TABLE::query_id value for
temporary tables. To simplify this check and to solve a bug related
to handling of temporary tables in prelocked mode, this patch changes
the way in which this member is used to track the fact that table is
used/unused. Now we ensure that TABLE::query_id is zero for unused
temporary tables (which means that all temporary tables which were
used by a statement should be marked as free for reuse after it's
execution has been completed).


mysql-test/include/handler.inc:
  Add test case for side effect of Bug#30882
mysql-test/r/handler_innodb.result:
  Add test case result for side effect of Bug#30882
mysql-test/r/handler_myisam.result:
  Add test case result for side effect of Bug#30882
mysql-test/r/sp-error.result:
  Add test case result for Bug#30882
mysql-test/t/sp-error.test:
  Add test case for Bug#30882
sql/event_db_repository.cc:
  Update close_thread_tables call, no more default values.
sql/mysql_priv.h:
  Remove implicit default parameters values of the close_thread_tables
  function as no callers are using it.
sql/slave.cc:
  Update close_thread_tables call, no more default values
sql/sp_head.cc:
  Update close_thread_tables call, no more default values
sql/sql_base.cc:
  Changed the approach to distinguishing currently unused temporary tables.
  Now we ensure that such tables always have TABLE::query_id set to 0 and
  use this fact to perform checks during opening and dropping of temporary
  tables. This means that we have to call close_thread_tables() even for
  statements which use only temporary tables. To make this call cheaper,
  we re-factored close_thread_tables() to not take LOCK_open unless there
  are open base tables.
sql/sql_handler.cc:
  Properly close temporary tables associated with a handler.
sql/sql_insert.cc:
  close_temporary_table is now merged into drop_temporary_table.
sql/sql_parse.cc:
  Now the condition doesn't cover all cases because close_thread_tables()
  must be called even for statements that use only temporary tables.
sql/sql_table.cc:
  Use drop_temporary_table which perform checks to verify if
  the table is not being used. Error path problem is due to
  a handler tables issue and is going to be addressed in bug
  31397.
sql/table.h:
  Rename previously unused clear_query_id and document the usage of
  query_id and open_by_handler.
2007-11-01 18:52:56 -02:00
unknown
2437001234 Use an inline getter method (thd->is_error()) to query if there is an error
in THD.
In future the error may be stored elsewhere (not in net.report_error) and 
it's important to start using an opaque getter to simplify merges.


sql/filesort.cc:
  net.report_error -> is_error()
sql/ha_ndbcluster_binlog.cc:
  net.report_error -> is_error()
sql/item_func.cc:
  net.report_error -> is_error()
sql/item_subselect.cc:
  net.report_error -> is_error()
sql/set_var.cc:
  net.report_error -> is_error()
sql/sp.cc:
  net.report_error -> is_error()
sql/sp_head.cc:
  net.report_error -> is_error()
sql/sql_base.cc:
  net.report_error -> is_error()
sql/sql_class.cc:
  net.report_error -> is_error()
sql/sql_class.h:
  net.report_error -> is_error()
sql/sql_connect.cc:
  net.report_error -> is_error()
sql/sql_delete.cc:
  net.report_error -> is_error()
sql/sql_insert.cc:
  net.report_error -> is_error()
sql/sql_parse.cc:
  net.report_error -> is_error()
sql/sql_prepare.cc:
  net.report_error -> is_error()
sql/sql_select.cc:
  net.report_error -> is_error()
sql/sql_union.cc:
  net.report_error -> is_error()
sql/sql_update.cc:
  net.report_error -> is_error()
sql/sql_view.cc:
  net.report_error -> is_error()
sql/sql_yacc.yy:
  net.report_error -> is_error()
2007-10-30 20:08:16 +03:00
unknown
200f0531ef Merge koti.dsl.inet.fi:/home/elkin/MySQL/TEAM/FIXES/5.0/bug27571_asyn_killed_flags
into  koti.dsl.inet.fi:/home/elkin/MySQL/5.1-merge-bug27571


client/mysql.cc:
  Auto merged
mysql-test/r/ctype_euckr.result:
  Auto merged
mysql-test/r/ctype_uca.result:
  Auto merged
mysql-test/suite/binlog/r/binlog_killed.result:
  Auto merged
mysql-test/suite/binlog/t/binlog_killed.test:
  Auto merged
sql/item_cmpfunc.cc:
  Auto merged
sql/log_event.cc:
  Auto merged
sql/log_event.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
strings/ctype-euc_kr.c:
  Auto merged
mysql-test/suite/rpl/r/rpl_sp_effects.result:
  manual merge ul
mysql-test/suite/rpl/t/rpl_sp_effects.test:
  manual merge
sql/slave.cc:
  leaving for manual merge
sql/sql_delete.cc:
  leaving for manual merge
sql/sql_insert.cc:
  leaving for manual merge
sql/sql_load.cc:
  leaving for manual merge
sql/sql_update.cc:
  leaving for manual merge
2007-10-30 11:31:03 +02:00
unknown
9be2220bfd Merge mysql.com:/home/bar/mysql-work/mysql-5.0
into  mysql.com:/home/bar/mysql-work/mysql-5.0-rpl-mr


client/mysql.cc:
  Auto merged
mysql-test/r/ctype_euckr.result:
  Auto merged
mysql-test/r/ctype_uca.result:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
strings/ctype-euc_kr.c:
  Auto merged
2007-10-24 10:49:46 +05:00
unknown
6cfd9a4fc3 Bug #26199 Replication Failure on Slave when using stored procs with bit-type parameters.
The value of the actual argument of BIT-type-arg stored procedure was binlogged as non-escaped
sequence of bytes corresponding to internal representation of the bit value.

The patch enforces binlogging of the bit-argument as a valid literal: prefixing the quoted bytes
sequence with _binary.
Note, that behaviour of Item_field::var_str for field_type() of MYSQL_TYPE_BIT is exceptional
in that the returned string contains the binary representation even though result_type() of
the item is INT_RESULT.


mysql-test/r/rpl_sp_effects.result:
  testing stored function and procedure called with BIT-arg.
mysql-test/t/rpl_sp_effects.test:
  results changed
sql/sp_head.cc:
  Treating BIT field type specially to for its value to be prefixed and quoted.
2007-10-21 18:37:37 +03:00
unknown
079ae23003 Rename: query_error -> is_slave_error.
Add comments.


sql/ha_ndbcluster_binlog.cc:
  query_error -> slave_error
sql/handler.cc:
  query_error -> slave_error
sql/log.cc:
  query_error -> slave_error
sql/log_event.cc:
  query_error -> slave_error
sql/log_event_old.cc:
  query_error -> slave_error
sql/mysqld.cc:
  query_error -> slave_error
sql/protocol.cc:
  query_error -> slave_error
sql/slave.cc:
  query_error -> slave_error
sql/sp_head.cc:
  query_error -> slave_error
sql/sql_class.cc:
  query_error -> slave_error
sql/sql_class.h:
  Rename: query_error -> is_slave_error, to avoid confusion.
  Add commenta.
sql/sql_connect.cc:
  Rename: query_error -> is_slave_error, to avoid confusion.
  Originally it was the same code to handle init-connect and init-slave 
  mysqld options. Then init-connect implementation forked off,
  but the one who copy-pasted the code didn't change it to not
  use a replication-specific variable.
2007-10-20 01:20:38 +04:00
unknown
42d4be2c75 Merge moksha.com.br:/Users/davi/mysql/bugs/21557-5.1
into  moksha.com.br:/Users/davi/mysql/mysql-5.1-runtime


sql/sp_head.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
2007-10-18 15:47:22 -03:00
unknown
b9b481ec70 Bug#21557 entries in the general query log truncated at 1000 characters.
The general log write function (general_log_print) uses printf style
arguments which need to be pre-processed, meaning that the all arguments
are copied to a single buffer and the problem is that the buffer size is
constant (1022 characters) but queries can be much larger then this.

The solution is to introduce a new log write function that accepts a
buffer and it's length as arguments. The function is to be used when
a formatted output is not required, which is the case for almost all
query write-to-log calls.

This is a incompatible change with respect to the log format of prepared
statements.


mysql-test/r/log_tables.result:
  Add test case result for Bug#21557
mysql-test/t/log_tables.test:
  Add test case for Bug#21557
sql/log.cc:
  Introduce the logger function general_log_write which is similar to
  general_log_print but accepts a single buffer and the buffer length.
  The function doesn't perform any formatting and sends the buffer
  directly to the underlying log handlers.
sql/log.h:
  Introduce the logger function general_log_write.
sql/log_event.cc:
  Pass the query buffer directly to the logger function, formatting
  is not required on this case.
sql/mysql_priv.h:
  Prototype for the logger function general_log_write.
sql/sp_head.cc:
  Pass the query buffer directly to the logger function, formatting
  is not required on this case.
sql/sql_parse.cc:
  Pass the buffer directly to the logger function when formatting
  is not required.
sql/sql_prepare.cc:
  Don't log the statement id, it avoids making a extra copy of the query
  and the query is not truncated anymore if it exceeds the limit.
2007-10-18 15:45:07 -03:00
unknown
84984f9111 Manual merge of 5.0-runtime to 5.1-runtime
mysql-test/r/sp-error.result:
  Manual merge
mysql-test/r/sp.result:
  Manual merge
mysql-test/r/udf.result:
  Manual merge
mysql-test/t/sp.test:
  Manual merge
mysql-test/t/udf.test:
  Manual merge
sql/item_create.cc:
  Manual merge
sql/sp_head.cc:
  Manual merge
sql/sql_yacc.yy:
  Manual merge
2007-10-16 20:47:08 -06:00
unknown
ad104d5bfd Bug#28318 CREATE FUNCTION (UDF) requires a schema
Bug#29816 Syntactically wrong query fails with misleading error message

The core problem is that an SQL-invoked function name can be a <schema
qualified routine name> that contains no <schema name>, but the mysql
parser insists that all stored procedures (function, procedures and
triggers) must have a <schema name>, which is not true for functions.
This problem is especially visible when trying to create a function
or when a query contains a syntax error after a function call (in the
same query), both will fail with a "No database selected" message if
the session is not attached to a particular schema, but the first
one should succeed and the second fail with a "syntax error" message.

Part of the fix is to revamp the sp name handling so that a schema
name may be omitted for functions -- this means that the internal
function name representation may not have a dot, which represents
that the function doesn't have a schema name. The other part is
to place schema checks after the type (function, trigger or procedure)
of the routine is known.


mysql-test/r/sp-error.result:
  Add test case result for Bug#29816
mysql-test/r/udf.result:
  Add test case result for Bug#28318
mysql-test/t/sp-error.test:
  Add test case for Bug#29816
mysql-test/t/udf.test:
  Add test case for Bug#28318
sql/sp.cc:
  Copy the (last) nul byte of the stored routine key and move name parsing
  code to the sp_name class constructor.
sql/sp_head.cc:
  Revamp routine name parsing for when no schema is specified and
  omit dot from the qualified name if the routine is not associated
  with a scheme name.
sql/sp_head.h:
  Name parsing got bigger, uninline by moving to a single unit -- the sp_head.cc
  file.
sql/sql_yacc.yy:
  Only copy the schema name if one is actually set and check for schema
  name presence only where it's necessary.
2007-10-09 20:46:33 -03:00
unknown
fa48986a0d Prerequisite patch for BUG#30472: libmysql doesn't reset charset,
insert_id after succ. mysql_change_user() call.

Supply a correct packet length to dispatch command.


sql/sp_head.cc:
  Fix packet length.
sql/sql_parse.cc:
  Fix packet length.
sql/sql_prepare.cc:
  Fix packet length.
tests/mysql_client_test.c:
  Test case for COM_CHANGE_USER.
2007-09-28 15:42:37 +04:00
unknown
d7463b5e1b Merge bk-internal.mysql.com:/home/bk/mysql-5.1-runtime
into  ibm.opbmk:/home/alik/Documents/MySQL/devel/5.1-rt-bug25843


sql/mysql_priv.h:
  Auto merged
sql/sp.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_db.cc:
  Auto merged
2007-08-31 22:13:27 +04:00
unknown
7e0ad09edf Fix for BUG#25843: changing default database between PREPARE and EXECUTE
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.


mysql-test/include/query_cache_sql_prepare.inc:
  The first part of the test case for BUG#25843.
mysql-test/r/query_cache_ps_no_prot.result:
  Update result file.
mysql-test/r/query_cache_ps_ps_prot.result:
  Update result file.
mysql-test/suite/rpl/r/rpl_ps.result:
  Update result file.
mysql-test/suite/rpl/t/rpl_ps.test:
  The second part of the test case for BUG#25843.
sql/mysql_priv.h:
  Added mysql_opt_change_db() prototype.
sql/sp.cc:
  1. Polishing;
  2. sp_use_new_db() has been removed;
  3. Use mysql_opt_change_db() instead of sp_use_new_db().
sql/sp.h:
  sp_use_new_db() has been removed.
  This function has nothing to do with a) sp and b) *new* database.
  It was merely "switch the current database if needed".
sql/sp_head.cc:
  1. Polishing.
  2. Use mysql_opt_change_db() instead of sp_use_new_db().
sql/sql_class.cc:
  Move THD::{db, db_length} into Statement.
sql/sql_class.h:
  Move THD::{db, db_length} into Statement.
sql/sql_db.cc:
  Introduce mysql_opt_change_db() as a replacement (and inspired by)
  sp_use_new_db().
sql/sql_prepare.cc:
  1. Remember the current database in Prepared_statement::prepare().
  2. Switch/restore the current database in Prepared_statement::execute().
2007-08-31 20:42:14 +04:00
unknown
89d3d58511 Merge weblab.(none):/home/marcsql/TREE/mysql-5.1-base
into  weblab.(none):/home/marcsql/TREE/mysql-5.1-rt50-merge


client/mysql.cc:
  Auto merged
mysql-test/r/query_cache.result:
  Auto merged
mysql-test/t/query_cache.test:
  Auto merged
sql/item_cmpfunc.h:
  Auto merged
sql/sp.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_db.cc:
  Auto merged
sql/sql_handler.cc:
  Auto merged
sql/sql_lex.cc:
  Auto merged
sql/sql_lex.h:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
2007-08-30 13:23:59 -06:00
unknown
26aadd2175 Bug#21975 Grant and revoke statements are non-transactional
Bug#21422 GRANT/REVOKE possible inside stored function, probably in a trigger
Bug#17244 GRANT gives strange error message when used in a stored function

GRANT/REVOKE statements are non-transactional (no explicit transaction
boundaries) in nature and hence are forbidden inside stored functions and
triggers, but they weren't being effectively forbidden. Furthermore, the
absence of implict commits makes changes made by GRANT/REVOKE statements to
not be rolled back.

The implemented fix is to issue a implicit commit with every GRANT/REVOKE
statement, effectively prohibiting these statements in stored functions
and triggers. The implicit commit also fixes the replication bug, and looks
like being in concert with the behavior of DDL and administrative statements.

Since this is a incompatible change, the following sentence should be
added to the Manual in the very end of the 3rd paragraph, subclause
13.4.3 "Statements That Cause an Implicit Commit": "Beginning with
MySQL 5.0.??, the GRANT and REVOKE statements cause an implicit commit."

Patch contributed by Vladimir Shebordaev


mysql-test/r/sp-error.result:
  Test case result for Bug#17244
mysql-test/t/sp-error.test:
  Test case for Bug#17244
sql/sp_head.cc:
  Set that a procedure with GRANT/REVOKE command has a (implicit or explicit)
  commit.
sql/sql_parse.cc:
  End active transaction in SQLCOM_GRANT and SQLCOM_REVOKE, and thus effectively
  prohibit these statements in stored functions and triggers. An implicit commit
  also fixes a bug in replication, when GRANT or REVOKE would disappear from the
  binary log in case of a subsequent ROLLBACK, since they were considered
  transactional statements.
mysql-test/suite/rpl/r/rpl_binlog_grant.result:
  Add test case result for Bug#21975
mysql-test/suite/rpl/t/rpl_binlog_grant.test:
  Add test case for Bug#21975
2007-08-29 16:59:38 -03:00
unknown
c5f0611fad Merge bk-internal.mysql.com:/home/bk/mysql-5.1
into  mysql.com:/home/my/mysql-5.1


configure.in:
  Auto merged
client/mysql.cc:
  Auto merged
include/m_ctype.h:
  Auto merged
sql/field.cc:
  Auto merged
sql/handler.cc:
  Auto merged
sql/handler.h:
  Auto merged
sql/item.cc:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/item_strfunc.cc:
  Auto merged
sql/item_strfunc.h:
  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/set_var.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_delete.cc:
  Auto merged
sql/sql_insert.cc:
  Auto merged
sql/sql_lex.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_string.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
sql/table.cc:
  Auto merged
sql/table.h:
  Auto merged
storage/myisam/mi_rkey.c:
  Auto merged
client/mysqldump.c:
  Manual merge (trivial)
scripts/mysql_install_db.sh:
  Complex merge (parital rewrite of new code)
sql/sql_show.cc:
  Manual merge
tests/mysql_client_test.c:
  then
    if ! test -x "$print_defaults"
    then
      missing_in_basedir my_print_defaults
      exit 1
    fi
  else
2007-08-14 00:22:34 +03:00
unknown
09a53f28a7 Fixed a lot of compiler warnings and errors detected by Forte C++ on Solaris
Faster thr_alarm()
Added 'Opened_files' status variable to track calls to my_open()
Don't give warnings when running mysql_install_db
Added option --source-install to mysql_install_db

I had to do the following renames() as used polymorphism didn't work with Forte compiler on 64 bit systems
index_read()      -> index_read_map()
index_read_idx()  -> index_read_idx_map()
index_read_last() -> index_read_last_map()


BUILD/compile-solaris-sparc-forte:
  Updated script to current Solaris installations
  Now we compile by default for 64 bits
client/mysql.cc:
  Declare functions sent to C code with extern "C" to avoid compiler warnings (on Forte)
client/mysql_upgrade.c:
  Fixed compiler warning (on Forte)
client/mysqladmin.cc:
  Declare functions sent to C code with extern "C" to avoid compiler warnings (on Forte)
client/mysqlcheck.c:
  Fixed compiler warning (on Forte)
client/mysqldump.c:
  Fixed compiler warning (on Forte)
client/mysqlslap.c:
  Fixed compiler warning (on Forte)
client/mysqltest.c:
  Fixed compiler warning (on Forte)
client/sql_string.cc:
  Avoid compiler warnings when using C function pointers in C++
configure.in:
  Added detection of mtmalloc and ieeefp.h
extra/replace.c:
  Fixed compiler warning (on Forte)
include/m_ctype.h:
  Added some typedef's to make it easy to use C function pointers in C++
include/my_sys.h:
  Added my_file_total_opened (counter for calls to my_open())
include/myisam.h:
  Fixed compiler warning (on Forte)
libmysql/libmysql.c:
  Fixed compiler warning (on Forte) by adding casts and change types
libmysql/manager.c:
  Fixed compiler warning (on Forte) by adding casts and change types
mysql-test/r/ctype_cp932_binlog_stm.result:
  Updated positions
  (Needed because we didn't before correctly restore collation_database after running stored procedure
mysys/my_fopen.c:
  Count number of opened files
mysys/my_open.c:
  Count number of opened files
mysys/my_static.c:
  Count number of opened files
mysys/thr_alarm.c:
  Optimization to do less alarm() and pthread_sigmask() calls.
  Idea is to remember time for next pending alarm and not reschedule a new alarm if it's after the current one.
  Before we only did this if there was other pending alarms.
  We don't have to use pthread_sigmask() in case of 'USE_ONE_SIGNAL_HAND' as the alarm()
  signal will be blocked for the calling thread anyway and no other thread will have the alarm() signal enabled to call process_alarm()
regex/regcomp.c:
  Fixed compiler warning (on Forte) by adding casts and change types
scripts/mysql_install_db.sh:
  Added option --source-install to allow one to create a mysql database from the source tree without installing MySQL
  Don't give (unnecessary) warnings
server-tools/instance-manager/angel.cc:
  Declare functions sent to C code with extern "C" to avoid compiler warnings (on Forte)
server-tools/instance-manager/thread_registry.cc:
  Declare functions sent to C code with extern "C" to avoid compiler warnings (on Forte)
sql/event_db_repository.cc:
  index_read() -> index_read_map()
sql/event_queue.cc:
  Declare functions sent to C code with extern "C" to avoid compiler warnings (on Forte)
sql/field.cc:
  Fixed compiler warnings about hidden fields
sql/ha_partition.cc:
  Fixed compiler warnings about hidden fields
  index_read() -> index_read_map()
sql/ha_partition.h:
  index_read() -> index_read_map()
sql/handler.cc:
  Added PAGE option to row types (to prepare for future)
  index_read() -> index_read_map()
sql/handler.h:
  Added ROW_TYPE_PAGE (for future)
  Added flag to signal if table was to be created transactionally
  I had to do the following renames() as used polymorphism didn't work with Forte compiler on 64 bit systems
  index_read()      -> index_read_map()
  index_read_idx()  -> index_read_idx_map()
  index_read_last() -> index_read_last_map()
sql/item.cc:
  Fixed indentation
  Renamed local variable to avoid hiding class variable
sql/item_cmpfunc.cc:
  Renamed local variable to avoid hiding class variable
sql/item_cmpfunc.h:
  Removed not used variable
sql/item_func.cc:
  Renamed local variable to avoid hiding class variable
sql/item_strfunc.cc:
  Moved functions from Item_strfunc.cc
sql/item_strfunc.h:
  Move functions to item_strfunc.cc
  Use C function pointer type to avoid compiler warnings (with Forte)
sql/item_subselect.cc:
  index_read() -> index_read_map()
sql/item_xmlfunc.cc:
  Renamed local variable to avoid hiding class variable
  Declare functions sent to C code with extern "C" to avoid compiler warnings (on Forte)
sql/key.cc:
  Fixed indentation
sql/log.cc:
  Renamed local variable to avoid hiding class variable
sql/log_event.cc:
  Removed call to my_time() when creating class instance of Log_event() as this may have static instances.
  (One can't call my_time() before my_init())
  index_read() -> index_read_map()
  Renamed local variable to avoid hiding class variable
sql/log_event_old.cc:
  Renamed local variable to avoid hiding class variable
sql/mysql_priv.h:
  Made all create_backup_ctx() declarations identical.
  This lifted up a bug where wrong create_backup_ctx() was called in some cases.
  Declare functions sent to C code with extern "C" to avoid compiler warnings (on Forte)
sql/mysqld.cc:
  Declare functions sent to C code with extern "C" to avoid compiler warnings (on Forte)
  Fixed indentation
  Don't call end_thr_alarm() when calling unireg_abort() as unireg_abort() already calls end_thr_alarm()
  Added variable 'Opened_files' (number of calls to my_open() or my_fopen())
  Don't print 'loose' warnings when using --bootstrap (to avoid warnings when running mysql_install_db)
  Fixed compiler warnings
sql/opt_range.cc:
  index_read() -> index_read_map()
sql/opt_sum.cc:
  index_read() -> index_read_map()
sql/partition_info.cc:
  Renamed local variable to avoid hiding class variable
sql/rpl_filter.cc:
  Declare functions sent to C code with extern "C" to avoid compiler warnings (on Forte)
sql/set_var.cc:
  Renamed local variable to avoid hiding class variable
  Added 'process_key_cache_t' type to avoid compiler warning (on Forte)
sql/set_var.h:
  Added 'process_key_cache_t' type to avoid compiler warning (on Forte)
sql/sp.cc:
  More debugging
  index_read() -> index_read_map()
sql/sp_cache.cc:
  Declare functions sent to C code with extern "C" to avoid compiler warnings (on Forte)
sql/sp_head.cc:
  Declare functions sent to C code with extern "C" to avoid compiler warnings (on Forte)
  Moved 'saved_creation_ctx' higher up to be able to free objects allocated by create_backup_ctx()
sql/sql_acl.cc:
  index_read() -> index_read_map()
sql/sql_class.cc:
  Renamed local variable to avoid hiding class variable
  Declare functions sent to C code with extern "C" to avoid compiler warnings (on Forte)
sql/sql_class.h:
  Renamed local variable to avoid hiding class variable
sql/sql_db.cc:
  Declare functions sent to C code with extern "C" to avoid compiler warnings (on Forte)
sql/sql_delete.cc:
  Renamed local variable to avoid hiding class variable
sql/sql_handler.cc:
  index_read() -> index_read_map()
sql/sql_help.cc:
  index_read() -> index_read_map()
sql/sql_insert.cc:
  index_read() -> index_read_map()
  Renamed local variable to avoid hiding class variable
sql/sql_lex.cc:
  Renamed local variable to avoid hiding class variable
sql/sql_plugin.cc:
  Declare functions sent to C code with extern "C" to avoid compiler warnings (on Forte)
  index_read() -> index_read_map()
  Don't give warnings about not used plugins if we are using --warnings=0
sql/sql_select.cc:
  index_read() -> index_read_map()
sql-common/client.c:
  Fixed compiler warning (on Forte)
sql-common/my_time.c:
  Removed never accessed code
  Fixed compiler warning (on Forte)
sql/sql_servers.cc:
  index_read() -> index_read_map()
sql/sql_show.cc:
  Added TRANSACTIONAL to SHOW CREATE
  Fixed ROW_TYPE_PAGE
sql/sql_string.cc:
  Avoid compiler warnings when using C function pointers in C++
sql/sql_table.cc:
  Set create_info->transactional if we used TRANSACTIONAL=1
sql/sql_udf.cc:
  index_read() -> index_read_map()
sql/sql_yacc.yy:
  Added TRANSACTIONAL=0|1 to CREATE (for future)
  Added row type PAGE (was only partionally handled before)
sql/strfunc.cc:
  Avoid compiler warnings when using C function pointers in C++
sql/table.cc:
  More DBUG statements
  Declare all create_backup_ctx() functions identically
  Remember if table was created with TRANSACTIONAL flag or not (future safe)
  Renamed local variable to avoid hiding class variable
sql/table.h:
  Remember if table was created with TRANSACTIONAL=1
sql/tztime.cc:
  index_read() -> index_read_map()
sql-common/pack.c:
  Fixed compiler warning (on Forte)
storage/archive/archive_reader.c:
  Fixed compiler warning (on Forte)
storage/archive/azio.c:
  Fixed compiler warning (on Forte)
storage/blackhole/ha_blackhole.cc:
  index_read() -> index_read_map()
storage/blackhole/ha_blackhole.h:
  index_read() -> index_read_map()
storage/csv/ha_tina.cc:
  Declare functions sent to C code with extern "C" to avoid compiler warnings (on Forte)
storage/example/ha_example.cc:
  index_read() -> index_read_map()
storage/example/ha_example.h:
  index_read() -> index_read_map()
storage/heap/ha_heap.cc:
  index_read() -> index_read_map()
storage/heap/ha_heap.h:
  index_read() -> index_read_map()
storage/heap/hp_test1.c:
  Fixed compiler warning (on Forte)
storage/heap/hp_test2.c:
  Fixed compiler warning (on Forte)
storage/myisam/ft_boolean_search.c:
  Fixed compiler warning (on Forte)
storage/myisam/ft_nlq_search.c:
  Fixed compiler warning (on Forte)
storage/myisam/ft_parser.c:
  Fixed compiler warning (on Forte)
storage/myisam/ft_stopwords.c:
  Fixed compiler warning (on Forte)
storage/myisam/ha_myisam.cc:
  index_read() -> index_read_map()
storage/myisam/ha_myisam.h:
  index_read() -> index_read_map()
storage/myisam/mi_check.c:
  Fixed compiler warning (on Forte)
storage/myisam/mi_delete.c:
  Fixed compiler warning (on Forte)
storage/myisam/mi_dynrec.c:
  Fixed compiler warning (on Forte)
storage/myisam/mi_extra.c:
  Fixed compiler warning (on Forte)
storage/myisam/mi_key.c:
  Fixed compiler warning (on Forte)
storage/myisam/mi_keycache.c:
  Fixed compiler warning (on Forte)
storage/myisam/mi_locking.c:
  Fixed compiler warning (on Forte)
storage/myisam/mi_log.c:
  Fixed compiler warning (on Forte)
storage/myisam/mi_open.c:
  Fixed compiler warning (on Forte)
storage/myisam/mi_packrec.c:
  Fixed compiler warning (on Forte)
storage/myisam/mi_page.c:
  Fixed compiler warning (on Forte)
storage/myisam/mi_rkey.c:
  Added comment
storage/myisam/mi_search.c:
  Fixed compiler warning (on Forte)
storage/myisam/mi_statrec.c:
  Fixed compiler warning (on Forte)
storage/myisam/mi_test1.c:
  Fixed compiler warning (on Forte)
storage/myisam/mi_test2.c:
  Fixed compiler warning (on Forte)
storage/myisam/mi_test3.c:
  Fixed compiler warning (on Forte)
storage/myisam/mi_update.c:
  Fixed compiler warning (on Forte)
storage/myisam/mi_write.c:
  Fixed compiler warning (on Forte)
storage/myisam/myisamdef.h:
  Fixed that file_read/file_write returns type size_t
  Changed some functions to use uchar * as argument/return value instead of char*
  This fixed some compiler warnings on Forte
storage/myisam/myisamlog.c:
  Fixed compiler warning (on Forte)
storage/myisam/myisampack.c:
  Fixed compiler warning (on Forte)
storage/myisam/rt_test.c:
  Fixed compiler warning (on Forte)
storage/myisam/sort.c:
  Fixed compiler warning (on Forte) by adding casts or changing variables to uchar*
storage/myisam/sp_test.c:
  Fixed compiler warning (on Forte) by adding casts or changing variables to uchar*
storage/myisammrg/ha_myisammrg.cc:
  index_read() -> index_read_map()
storage/myisammrg/ha_myisammrg.h:
  index_read() -> index_read_map()
storage/myisammrg/myrg_create.c:
  Fixed compiler warning (on Forte) by adding casts or changing variable types
storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp:
  Tdummy -> align  (as in other part of cluster code)
storage/ndb/src/kernel/vm/DynArr256.cpp:
  Removed not used variable
storage/ndb/src/ndbapi/Ndb.cpp:
  Removed not used variable
strings/strtod.c:
  Include ieeefp.h to avoid compiler warning
tests/bug25714.c:
  Fixed compiler warning
tests/mysql_client_test.c:
  Remove not used variable
  Fixed indentation
  Removed never reached code
  Fixed compiler warning (on Forte) by adding casts or changing variable types
vio/viosocket.c:
  Fixed compiler warning (on Forte) by adding casts or changing variable types
2007-08-13 16:11:25 +03:00
unknown
125bc936ac Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  magare.gmz:/home/kgeorge/mysql/autopush/B27417-5.0-opt


sql/handler.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
2007-07-31 15:23:25 +03:00
unknown
1f6088cc8b Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.1-opt
into  magare.gmz:/home/kgeorge/mysql/autopush/B27417-5.1-opt


sql/sp_head.cc:
  Auto merged
2007-07-31 14:59:52 +03:00
unknown
6312042ca7 Merge gleb.loc:/home/uchum/work/bk/5.0-opt-30120
into  gleb.loc:/home/uchum/work/bk/5.1-opt


sql/item.cc:
  Auto merged
sql/item.h:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
mysql-test/r/sp.result:
  Merge with 5.0-opt.
mysql-test/t/sp.test:
  Merge with 5.0-opt.
2007-07-31 12:09:59 +05:00
unknown
e5fd6b3c71 (Pushing for Andrei)
Merge magare.gmz:/home/kgeorge/mysql/work/B27417-5.0-opt
into  magare.gmz:/home/kgeorge/mysql/work/B27417-5.1-opt


mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result:
  Auto merged
sql/ha_ndbcluster.cc:
  Auto merged
sql/handler.cc:
  Auto merged
sql/handler.h:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_table.cc:
  Auto merged
mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test:
  merge of bug 27471 from 5.0-opt to 5.1-opt
sql/log.cc:
  merge of bug 27471 from 5.0-opt to 5.1-opt
sql/set_var.cc:
  merge of bug 27471 from 5.0-opt to 5.1-opt
sql/sp_head.cc:
  merge of bug 27471 from 5.0-opt to 5.1-opt
sql/sql_delete.cc:
  merge of bug 27471 from 5.0-opt to 5.1-opt
sql/sql_insert.cc:
  merge of bug 27471 from 5.0-opt to 5.1-opt
sql/sql_load.cc:
  merge of bug 27471 from 5.0-opt to 5.1-opt
sql/sql_parse.cc:
  merge of bug 27471 from 5.0-opt to 5.1-opt
sql/sql_update.cc:
  merge of bug 27471 from 5.0-opt to 5.1-opt
2007-07-30 19:02:21 +03:00
unknown
1307d3b803 (pushing for Andrei)
Bug #27417 thd->no_trans_update.stmt lost value inside of SF-exec-stack
  
Once had been set the flag might later got reset inside of a stored routine 
execution stack.
The reason was in that there was no check if a new statement started at time 
of resetting.
The artifact affects most of binlogable DML queries. Notice, that multi-update 
is wrapped up within
  bug@27716 fix, multi-delete bug@29136.
  
Fixed with saving parent's statement flag of whether the statement modified 
non-transactional table, and unioning (merging) the value with that was gained 
in mysql_execute_command.
  
Resettling thd->no_trans_update members into thd->transaction.`member`;
Asserting code;
Effectively the following properties are held.
  
1. At the end of a substatement thd->transaction.stmt.modified_non_trans_table
   reflects the fact if such a table got modified by the substatement.
   That also respects THD::really_abort_on_warnin() requirements.
2. Eventually thd->transaction.stmt.modified_non_trans_table will be computed as
   the union of the values of all invoked sub-statements.
   That fixes this bug#27417;

Computing of thd->transaction.all.modified_non_trans_table is refined to base to 
the stmt's value for all the case including insert .. select statement which 
before the patch had an extra issue bug@28960.
Minor issues are covered with mysql_load, mysql_delete, and binloggin of insert in
to temp_table select. 
  
The supplied test verifies limitely, mostly asserts. The ultimate testing is defered
for bug@13270, bug@23333.


mysql-test/r/mix_innodb_myisam_binlog.result:
  results changed
mysql-test/t/mix_innodb_myisam_binlog.test:
  regression test incl the related bug#28960.
sql/ha_ndbcluster.cc:
  thd->transaction.{all,stmt}.modified_non_trans_table
  instead of
  thd->no_trans_update.{all,stmt}
sql/handler.cc:
  thd->transaction.{all,stmt}.modified_non_trans_table
  instead of
  thd->no_trans_update.{all,stmt}
sql/handler.h:
  new member added
sql/log.cc:
  thd->transaction.{all,stmt}.modified_non_trans_table
  instead of
  thd->no_trans_update.{all,stmt}
sql/set_var.cc:
  thd->transaction.{all,stmt}.modified_non_trans_table
  instead of
  thd->no_trans_update.{all,stmt}
sql/sp_head.cc:
  thd->transaction.{all,stmt}.modified_non_trans_table
  instead of
  thd->no_trans_update.{all,stmt}
  
  and saving and merging stmt's flag at the end of a substatement.
sql/sql_class.cc:
  thd->transaction.{all,stmt}.modified_non_trans_table
  instead of
  thd->no_trans_update.{all,stmt}
sql/sql_class.h:
  thd->transaction.{all,stmt}.modified_non_trans_table
  instead of
  thd->no_trans_update.{all,stmt}
sql/sql_delete.cc:
  correcting basic delete incl truncate branch and multi-delete queries to set
  stmt.modified_non_trans_table;
  optimization to set the flag at the end of per-row loop;
  multi-delete still has an extra issue similar to bug#27716 of multi-update 
  - to be address with bug_29136 fix.
sql/sql_insert.cc:
  thd->transaction.{all,stmt}.modified_non_trans_table
  instead of
  thd->no_trans_update.{all,stmt}
sql/sql_load.cc:
  eliminating a separate issue where the stmt flag was saved and re-stored after 
  write_record that actually could change it and the change would be lost but 
  should remain permanent;
  thd->transaction.{all,stmt}.modified_non_trans_table
  instead of
  thd->no_trans_update.{all,stmt}
sql/sql_parse.cc:
  initialization to transaction.stmt.modified_non_trans_table at the common part 
  of all types of statements processing - mysql_execute_command().
sql/sql_table.cc:
  moving the reset up to the mysql_execute_command() caller
sql/sql_update.cc:
  correcting update query case (multi-update part of the issues covered by other 
  bug#27716 fix)
  thd->transaction.{all,stmt}.modified_non_trans_table
  instead of
  thd->no_trans_update.{all,stmt}
2007-07-30 18:27:36 +03:00
unknown
33fc4ad4e1 Fixed bug #30120.
SP with local variables with non-ASCII names crashed the server.

The server replaces SP local variable names with NAME_CONST calls
when putting statements into the binary log. It used UTF8-encoded
item names as variable names for the replacement inside NAME_CONST
calls. However, statement string may be encoded by any
known character set by the SET NAMES statement.
The server used byte length of UTF8-encoded names to increment
the position in the query string that led to array index overrun.


sql/item.cc:
  Fixed bug #30120.
  The Item_splocal class constructor has been modified to
  accept new parameter `len_in_q': the byte length of
  variable name in the query string.
sql/item.h:
  Fixed bug #30120.
  The Item_splocal class has been modified to keep new
  field `len_in_query': the byte length of variable name in
  the query string.
sql/sp_head.cc:
  Fixed bug #30120.
  The subst_spvars function has been modified to increment
  position in the query string by the lengths of not
  encoded variable names instead of byte length of names
  encoded to UTF-8.
sql/sql_yacc.yy:
  Fixed bug #30120.
  The simple_ident rule action has been modified to
  pass the byte length of the local variable name token
  to the Item_splocal object constructor.
mysql-test/t/sp.test:
  Updated test case for bug #30120.
mysql-test/r/sp.result:
  Updated test case for bug #30120.
2007-07-30 04:35:16 +05:00
unknown
11816452bc sp_head.cc:
Post-merge fix.


sql/sp_head.cc:
  Post-merge fix.
2007-07-29 21:12:54 +05:00
unknown
a0a216bb40 Merge gleb.loc:/home/uchum/work/bk/5.0-opt
into  gleb.loc:/home/uchum/work/bk/5.1-opt


mysql-test/r/query_cache.result:
  Auto merged
mysql-test/r/view.result:
  Auto merged
mysql-test/t/query_cache.test:
  Auto merged
sql/sql_show.cc:
  Auto merged
mysql-test/t/view.test:
  Merge with 5.0-opt.
sql/sp_head.cc:
  Merge with 5.0-opt.
2007-07-29 14:41:39 +05:00
unknown
d86f0a1382 Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  moonbone.local:/mnt/gentoo64/work/29856-bug-5.0-opt-mysql


sql/sp_head.cc:
  Auto merged
mysql-test/r/query_cache.result:
  SCCS merged
mysql-test/t/query_cache.test:
  SCCS merged
2007-07-28 22:47:03 +04:00
unknown
40d596c200 Bug#29856: Insufficient buffer space led to a server crash.
The subst_spvars function is used to create query string with SP variables 
substituted with their values. This string is used later for the binary log
and for the query cache. The problem is that the
query_cache_send_result_to_client function requires some additional space
after the query to store database name and query cache flags. This 
space wasn't reserved by the subst_spvars function which led to a memory
corruption and crash.

Now the subst_spvars function reserves additional space for the query cache.


mysql-test/t/query_cache.test:
  Added a test case for the bug#29856: Insufficient buffer space led to a server crash.
mysql-test/r/query_cache.result:
  Added a test case for the bug#29856: Insufficient buffer space led to a server crash.
sql/sp_head.cc:
  Bug#29856: Insufficient buffer space led to a server crash.
  Now the subst_spvars function reserves additional space for the query cache.
2007-07-28 15:01:29 +04:00
unknown
bc642e1132 Post-merge fixes (merge from the main).
mysql-test/r/innodb_mysql.result:
  Update test results (merge from the main tree).
mysql-test/r/query_cache.result:
  Update test results (merge from the main tree).
mysql-test/r/sp.result:
  Update test results (merge from the main tree).
mysql-test/t/query_cache.test:
  Use --echo End of to simplify future merges.
sql/handler.h:
  st_table_list -> TABLE_LIST
sql/item_create.cc:
  A post-merge fix (this code is in sql_yacc.yy in 5.0)
sql/rpl_utility.h:
  st_table_list -> TABLE_LIST
sql/sp.cc:
  A post-merge fix.
sql/sp_head.cc:
  In 5.1 memdup_root returns void*.
sql/sql_show.cc:
  st_table_list -> TABLE_LIST
sql/sql_show.h:
  st_table_list -> TABLE_LIST
sql/sql_yacc.yy:
  A post-merge fix.
sql/table.cc:
  st_table_list -> TABLE_LIST
sql/table.h:
  st_table_list -> TABLE_LIST
2007-07-17 00:59:21 +04:00
unknown
9562c54a5c Merge bodhi.(none):/opt/local/work/mysql-5.0-runtime
into  bodhi.(none):/opt/local/work/mysql-5.1-runtime


mysql-test/r/trigger.result:
  Auto merged
mysql-test/t/query_cache.test:
  Auto merged
mysql-test/t/sp.test:
  Auto merged
mysql-test/t/trigger.test:
  Auto merged
sql/item.cc:
  Auto merged
sql/item.h:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/sp_head.h:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_db.cc:
  Auto merged
sql/sql_lex.cc:
  Auto merged
sql/sql_lex.h:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_show.cc:
  Auto merged
sql/sql_trigger.h:
  Auto merged
sql/sql_view.cc:
  Auto merged
sql/table.cc:
  Auto merged
storage/myisam/ha_myisam.h:
  Auto merged
mysql-test/include/mix1.inc:
  Manual merge.
mysql-test/r/information_schema.result:
  Manual merge.
mysql-test/r/innodb_mysql.result:
  Manual merge.
mysql-test/r/query_cache.result:
  Manual merge.
mysql-test/r/sp.result:
  Manual merge.
mysql-test/t/information_schema.test:
  Manual merge.
sql/handler.h:
  Manual merge.
sql/sp.cc:
  Manual merge.
sql/sp_head.cc:
  Manual merge.
sql/sql_prepare.cc:
  Manual merge.
sql/sql_trigger.cc:
  Manual merge.
sql/sql_yacc.yy:
  Manual merge.
sql/table.h:
  Manual merge.
storage/myisam/ha_myisam.cc:
  Manual merge.
2007-07-16 23:31:36 +04:00
unknown
9dc3088f9e A fix and a test case for Bug#26141 mixing table types in trigger
causes full table lock on innodb table.
Also fixes Bug#28502 Triggers that update another innodb table 
will block on X lock unnecessarily (duplciate).
Code review fixes.

Both bugs' synopses are misleading: InnoDB table is
not X locked. The statements, however, cannot proceed concurrently, 
but this happens due to lock conflicts for tables used in triggers,
not for the InnoDB table. 

If a user had an InnoDB table, and two triggers, AFTER UPDATE and 
AFTER INSERT, competing for different resources (e.g. two distinct
MyISAM tables), then these two triggers would not be able to execute
concurrently. Moreover, INSERTS/UPDATES of the InnoDB table would
not be able to run concurrently. 
The problem had other side-effects (see respective bug reports).

This behavior was a consequence of a shortcoming of the pre-locking
algorithm, which would not distinguish between different DML operations
(e.g. INSERT and DELETE) and pre-lock all the tables
that are used by any trigger defined on the subject table.

The idea of the fix is to extend the pre-locking algorithm to keep track,
for each table, what DML operation it is used for and not
load triggers that are known to never be fired.


mysql-test/r/trigger-trans.result:
  Update results (Bug#26141)
mysql-test/r/trigger.result:
  Update results (Bug#28502)
mysql-test/t/trigger-trans.test:
  Add a test case for Bug#26141 mixing table types in trigger causes 
  full table lock on innodb table.
mysql-test/t/trigger.test:
  Add a test case for Bug#28502 Triggers that update another innodb 
  table will block echo on X lock unnecessarily. Add more test 
  coverage for triggers.
sql/item.h:
  enum trg_event_type is needed in table.h
sql/sp.cc:
  Take into account table_list->trg_event_map when determining
  what tables to pre-lock. 
  
  After this change, if we attempt to fire a 
  trigger for which we had not pre-locked any tables, error
  'Table was not locked with LOCK TABLES' will be printed.
  This, however, should never happen, provided the pre-locking
  algorithm has no programming bugs.
  
  Previously a trigger key in the sroutines hash was based on the name 
  of the table the trigger belongs to. This was possible because we would
  always add to the pre-locking list all the triggers defined for a table when
  handling this table.
  Now the key is based on the name of the trigger, owing
  to the fact that a trigger name must be unique in the database it
  belongs to.
sql/sp_head.cc:
  Generate sroutines hash key in init_spname(). This is a convenient
  place since there we have all the necessary information and can
  avoid an extra alloc.
  
  Maintain and merge trg_event_map when adding and merging elements
  of the pre-locking list.
sql/sp_head.h:
  Add ,m_sroutines_key member, used when inserting the sphead for a
  trigger into the cache of routines used by a statement.
  Previously the key was based on the table name the trigger belonged
  to, since for a given table we would add to the sroutines list
  all the triggers defined on it.
sql/sql_lex.cc:
  Introduce a new lex step: set_trg_event_type_for_tables().
  It is called when we have finished parsing but before opening
  and locking tables. Now this step is used to evaluate for each
  TABLE_LIST instance which INSERT/UPDATE/DELETE operation, if any,
  it is used in.
  In future this method could be extended to aggregate other information
  that is hard to aggregate during parsing.
sql/sql_lex.h:
  Add declaration for set_trg_event_type_for_tables().
sql/sql_parse.cc:
  Call set_trg_event_type_for_tables() after MYSQLparse(). Remove tabs.
sql/sql_prepare.cc:
  Call set_trg_event_type_for_tables() after  MYSQLparse().
sql/sql_trigger.cc:
  Call set_trg_event_type_for_tables() after MYSQLparse().
sql/sql_trigger.h:
  Remove an obsolete member.
sql/sql_view.cc:
  Call set_trg_event_type_for_tables() after MYSQLparse().
sql/sql_yacc.yy:
  Move assignment of sp_head::m_type before calling sp_head::init_spname(), 
  one is now used inside another.
sql/table.cc:
  Implement TABLE_LIST::set_trg_event_map() - a method that calculates
  wh triggers may be fired on this table when executing a statement.
sql/table.h:
  Add missing declarations.
  Move declaration of trg_event_type from item.h (it will be needed for 
  trg_event_map bitmap when we start using Bitmap template instead
  of uint8).
2007-07-12 22:26:41 +04:00
unknown
6ba23b0ac9 Fix for 5.1 for BUG#10491: Server returns data as charset binary
SHOW CREATE TABLE or SELECT FROM I_S.

This is the last patch for this bug, which depends on the big
CS patch and was pending.

The problem was that SHOW CREATE statements returned original
queries in the binary character set. That could cause the query
to be unreadable.

The fix is to use original character_set_client when sending
the original query to the client. In order to preserve the query
in mysqldump, 'binary' character set results should be set when
issuing SHOW CREATE statement. If either source or destination
character set is 'binary' , no conversion is performed.
The idea is that since the source character set is no longer
'binary', we fix the destination character set to still produce
valid dumps.


client/mysqldump.c:
  Switch character_set_results of mysqldump-connection before
  calling SHOW CREATE statements for the objects.
mysql-test/r/show_check.result:
  Result file.
mysql-test/t/show_check.test:
  Add test case for the part of BUG#10491.
sql/events.cc:
  Send original query in the original character set.
sql/sp_head.cc:
  Send original query in the original character set.
sql/sql_show.cc:
  Send original query in the original character set.
2007-07-12 12:49:39 +04:00
unknown
58935a314e Merge bodhi.(none):/opt/local/work/mysql-5.0-runtime
into  bodhi.(none):/opt/local/work/mysql-5.1-runtime


mysql-test/r/ps_1general.result:
  Auto merged
mysql-test/r/ps_2myisam.result:
  Auto merged
mysql-test/r/ps_3innodb.result:
  Auto merged
mysql-test/r/ps_4heap.result:
  Auto merged
mysql-test/r/ps_5merge.result:
  Auto merged
BitKeeper/deleted/.del-ps_6bdb.result:
  Auto merged
mysql-test/r/ps_7ndb.result:
  Auto merged
sql/handler.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_error.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_prepare.cc:
  Auto merged
sql/sql_view.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
mysql-test/r/show_check.result:
  Manual merge.
mysql-test/t/show_check.test:
  Manual merge.
sql/item.h:
  Manual merge.
sql/sp.cc:
  Manual merge.
sql/sql_trigger.cc:
  Manual merge.
tests/mysql_client_test.c:
  Manual merge.
2007-07-02 01:55:01 +04:00
unknown
405f82d390 Patch for the following bugs:
- BUG#11986: Stored routines and triggers can fail if the code
    has a non-ascii symbol
  - BUG#16291: mysqldump corrupts string-constants with non-ascii-chars
  - BUG#19443: INFORMATION_SCHEMA does not support charsets properly
  - BUG#21249: Character set of SP-var can be ignored
  - BUG#25212: Character set of string constant is ignored (stored routines)
  - BUG#25221: Character set of string constant is ignored (triggers)

There were a few general problems that caused these bugs:
1. Character set information of the original (definition) query for views,
   triggers, stored routines and events was lost.
2. mysqldump output query in client character set, which can be
   inappropriate to encode definition-query.
3. INFORMATION_SCHEMA used strings with mixed encodings to display object
   definition;

1. No query-definition-character set.

In order to compile query into execution code, some extra data (such as
environment variables or the database character set) is used. The problem
here was that this context was not preserved. So, on the next load it can
differ from the original one, thus the result will be different.

The context contains the following data:
  - client character set;
  - connection collation (character set and collation);
  - collation of the owner database;

The fix is to store this context and use it each time we parse (compile)
and execute the object (stored routine, trigger, ...).

2. Wrong mysqldump-output.

The original query can contain several encodings (by means of character set
introducers). The problem here was that we tried to convert original query
to the mysqldump-client character set.

Moreover, we stored queries in different character sets for different
objects (views, for one, used UTF8, triggers used original character set).

The solution is
  - to store definition queries in the original character set;
  - to change SHOW CREATE statement to output definition query in the
    binary character set (i.e. without any conversion);
  - introduce SHOW CREATE TRIGGER statement;
  - to dump special statements to switch the context to the original one
    before dumping and restore it afterwards.

Note, in order to preserve the database collation at the creation time,
additional ALTER DATABASE might be used (to temporary switch the database
collation back to the original value). In this case, ALTER DATABASE
privilege will be required. This is a backward-incompatible change.

3. INFORMATION_SCHEMA showed non-UTF8 strings

The fix is to generate UTF8-query during the parsing, store it in the object
and show it in the INFORMATION_SCHEMA.

Basically, the idea is to create a copy of the original query convert it to
UTF8. Character set introducers are removed and all text literals are
converted to UTF8.

This UTF8 query is intended to provide user-readable output. It must not be
used to recreate the object.  Specialized SHOW CREATE statements should be
used for this.

The reason for this limitation is the following: the original query can
contain symbols from several character sets (by means of character set
introducers).

Example:

  - original query:
    CREATE VIEW v1 AS SELECT _cp1251 'Hello' AS c1;

  - UTF8 query (for INFORMATION_SCHEMA):
    CREATE VIEW v1 AS SELECT 'Hello' AS c1;


client/mysqldump.c:
  Set original character set and collation before dumping definition query.
include/my_sys.h:
  Move out-parameter to the end of list.
mysql-test/lib/mtr_report.pl:
  Ignore server-warnings during the test case.
mysql-test/r/create.result:
  Update result file.
mysql-test/r/ctype_cp932_binlog_stm.result:
  Update result file.
mysql-test/r/events.result:
  Update result file.
mysql-test/r/events_bugs.result:
  Update result file.
mysql-test/r/events_grant.result:
  Update result file.
mysql-test/r/func_in.result:
  Update result file.
mysql-test/r/gis.result:
  Update result file.
mysql-test/r/grant.result:
  Update result file.
mysql-test/r/information_schema.result:
  Update result file.
mysql-test/r/information_schema_db.result:
  Update result file.
mysql-test/r/lowercase_view.result:
  Update result file.
mysql-test/r/mysqldump.result:
  Update result file.
mysql-test/r/ndb_sp.result:
  Update result file.
mysql-test/r/ps.result:
  Update result file.
mysql-test/r/rpl_replicate_do.result:
  Update result file.
mysql-test/r/rpl_sp.result:
  Update result file.
mysql-test/r/rpl_trigger.result:
  Update result file.
mysql-test/r/rpl_view.result:
  Update result file.
mysql-test/r/show_check.result:
  Update result file.
mysql-test/r/skip_grants.result:
  Update result file.
mysql-test/r/sp-destruct.result:
  Update result file.
mysql-test/r/sp-error.result:
  Update result file.
mysql-test/r/sp-security.result:
  Update result file.
mysql-test/r/sp.result:
  Update result file.
mysql-test/r/sql_mode.result:
  Update result file.
mysql-test/r/system_mysql_db.result:
  Update result file.
mysql-test/r/temp_table.result:
  Update result file.
mysql-test/r/trigger-compat.result:
  Update result file.
mysql-test/r/trigger-grant.result:
  Update result file.
mysql-test/r/trigger.result:
  Update result file.
mysql-test/r/view.result:
  Update result file.
mysql-test/r/view_grant.result:
  Update result file.
mysql-test/t/events.test:
  Update test case (new columns added).
mysql-test/t/information_schema.test:
  Update test case (new columns added).
mysql-test/t/show_check.test:
  Test case for SHOW CREATE TRIGGER in prepared statements and
  stored routines.
mysql-test/t/sp-destruct.test:
  Update test case (new columns added).
mysql-test/t/sp.test:
  Update test case (new columns added).
mysql-test/t/view.test:
  Update test.
mysys/charset.c:
  Move out-parameter to the end of list.
scripts/mysql_system_tables.sql:
  Add new columns to mysql.proc and mysql.event.
scripts/mysql_system_tables_fix.sql:
  Add new columns to mysql.proc and mysql.event.
sql/event_data_objects.cc:
  Support new attributes for events.
sql/event_data_objects.h:
  Support new attributes for events.
sql/event_db_repository.cc:
  Support new attributes for events.
sql/event_db_repository.h:
  Support new attributes for events.
sql/events.cc:
  Add new columns to SHOW CREATE event resultset.
sql/mysql_priv.h:
  1. Introduce Object_creation_ctx;
  2. Introduce SHOW CREATE TRIGGER;
  3. Introduce auxilary functions.
sql/sp.cc:
  Add support for new store routines attributes.
sql/sp_head.cc:
  Add support for new store routines attributes.
sql/sp_head.h:
  Add support for new store routines attributes.
sql/sql_lex.cc:
  Generate UTF8-body on parsing/lexing.
sql/sql_lex.h:
  1. Generate UTF8-body on parsing/lexing.
  2. Introduce SHOW CREATE TRIGGER.
sql/sql_parse.cc:
  Introduce SHOW CREATE TRIGGER.
sql/sql_partition.cc:
  Update parse_sql().
sql/sql_prepare.cc:
  Update parse_sql().
sql/sql_show.cc:
  Support new attributes for views
sql/sql_trigger.cc:
  Support new attributes for views
sql/sql_trigger.h:
  Support new attributes for views
sql/sql_view.cc:
  Support new attributes for views
sql/sql_yacc.yy:
  1. Add SHOW CREATE TRIGGER statement.
  2. Generate UTF8-body for views, stored routines, triggers and events.
sql/table.cc:
  Introduce Object_creation_ctx.
sql/table.h:
  Introduce Object_creation_ctx.
sql/share/errmsg.txt:
  Add new errors.
mysql-test/include/ddl_i18n.check_events.inc:
  Aux file for test suite.
mysql-test/include/ddl_i18n.check_sp.inc:
  Aux file for test suite.
mysql-test/include/ddl_i18n.check_triggers.inc:
  Aux file for test suite.
mysql-test/include/ddl_i18n.check_views.inc:
  Aux file for test suite.
mysql-test/include/have_cp1251.inc:
  Aux file for test suite.
mysql-test/include/have_cp866.inc:
  Aux file for test suite.
mysql-test/include/have_koi8r.inc:
  Aux file for test suite.
mysql-test/include/have_utf8.inc:
  Aux file for test suite.
mysql-test/r/ddl_i18n_koi8r.result:
  Result file.
mysql-test/r/ddl_i18n_utf8.result:
  Result file.
mysql-test/r/have_cp1251.require:
  Aux file for test suite.
mysql-test/r/have_cp866.require:
  Aux file for test suite.
mysql-test/r/have_koi8r.require:
  Aux file for test suite.
mysql-test/r/have_utf8.require:
  Aux file for test suite.
mysql-test/t/ddl_i18n_koi8r.test:
  Complete koi8r test case for the CS patch.
mysql-test/t/ddl_i18n_utf8.test:
  Complete utf8 test case for the CS patch.
2007-06-28 21:34:54 +04:00
unknown
63d7c4a8c8 Merge mysql.com:/nfsdisk1/lars/bk/mysql-5.1
into  mysql.com:/nfsdisk1/lars/bk/mysql-5.1-new-rpl


mysql-test/t/disabled.def:
  Auto merged
mysql-test/t/ndb_index_ordered.test:
  Auto merged
mysys/charset.c:
  Auto merged
sql/field.cc:
  Auto merged
sql/handler.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sp_head.h:
  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_parse.cc:
  Auto merged
sql/sql_view.cc:
  Auto merged
2007-06-21 17:13:02 +02:00
unknown
c6d220e9fb Fix typo in the patch for BUG#25411 on 24-Apr-2007.
sql/handler.cc:
  Polishing to have the consistent code.
sql/sp_head.cc:
  Polishing to have the consistent code.
sql/sql_error.cc:
  Polishing to have the consistent code.
sql/sql_trigger.cc:
  Polishing to have the consistent code.
2007-06-19 01:54:35 +04:00
unknown
e57122a7c0 Part of patch for BUG#11986: make sp_head::m_body_begin pointer
private and provide a setter for it. The setter will be used to
construct UTF-query in the following patches.


sql/sp_head.cc:
  Make sp_head::m_body_begin pointer private.
sql/sp_head.h:
  Make sp_head::m_body_begin pointer private.
sql/sql_yacc.yy:
  Make sp_head::m_body_begin pointer private.
2007-06-14 22:14:52 +04:00
unknown
83de46bcf7 This the 4-th patch in scope of CS patch (BUG#11986).
The patch contains the following changes:
  - Introduce auxilary functions to convenient work with character sets:
    - resolve_charset();
    - resolve_collation();
    - get_default_db_collation();
  - Introduce lex_string_set();
  - Refactor Table_trigger_list::process_triggers() &
    sp_head::execute_trigger() to be consistent with other code;
  - Move reusable code from add_table_for_trigger() into
    build_trn_path(), check_trn_exists() and load_table_name_for_trigger()
    to be used in the following patch.
  - Rename triggers_file_ext and trigname_file_ext into TRN_EXT and
    TRG_EXT respectively.


include/my_sys.h:
  Introduced auxilary functions (to be used in the following patch).
mysys/charset.c:
  Introduced auxilary functions (to be used in the following patch).
sql/handler.cc:
  Rename triggers_file_ext -> TRG_EXT;
  Rename trigname_file_ext -> TRN_EXT.
sql/mysql_priv.h:
  1. Fix typo;
  2. Introduce auxilary functions (set_lex_string() will  be used
     in the following patch);
  3. Rename triggers_file_ext -> TRG_EXT;
     Rename trigname_file_ext -> TRN_EXT.
sql/sp_head.cc:
  Make sp_head::execute_trigger() consistent with
  sp_head::execute_function() and sp_head::execute_procedure().
sql/sp_head.h:
  Make sp_head::execute_trigger() consistent with
  sp_head::execute_function() and sp_head::execute_procedure().
sql/sql_db.cc:
  1. Introduce auxilary function.
  2. Polishing.
sql/sql_trigger.cc:
  1. Move common code from add_table_for_trigger() into
     - build_trn_path();
     - check_trn_exists();
     - load_table_name_for_trigger();
  2. Polishing.
sql/sql_trigger.h:
  1. Move common code from add_table_for_trigger() into
     - build_trn_path();
     - check_trn_exists();
     - load_table_name_for_trigger();
  2. Polishing.
2007-06-14 19:23:55 +04:00
unknown
f09496c8c2 Bug#25411 (trigger code truncated), PART II
Bug 28127 (Some valid identifiers names are not parsed correctly)
Bug 26302 (MySQL server cuts off trailing "*/" from comments in SP/func)

This patch is the second part of a major cleanup, required to fix
Bug 25411 (trigger code truncated).

The root cause of the issue stems from the function skip_rear_comments,
which was a work around to remove "extra" "*/" characters from the query
text, when parsing a query and reusing the text fragments to represent a
view, trigger, function or stored procedure.
The reason for this work around is that "special comments",
like /*!50002 XXX */, were not parsed properly, so that a query like:
  AAA /*!50002 BBB */ CCC
would be seen by the parser as "AAA BBB */ CCC" when the current version
is greater or equal to 5.0.2

The root cause of this stems from how special comments are parsed.
Special comments are really out-of-bound text that appear inside a query,
that affects how the parser behave.
In nature, /*!50002 XXX */ in MySQL is similar to the C concept
of preprocessing :
  #if VERSION >= 50002
  XXX
  #endif

Depending on the current VERSION of the server, either the special comment
should be expanded or it should be ignored, but in all cases the "text" of
the query should be re-written to strip the "/*!50002" and "*/" markers,
which does not belong to the SQL language itself.

Prior to this fix, these markers would leak into :
- the storage format for VIEW,
- the storage format for FUNCTION,
- the storage format for FUNCTION parameters, in mysql.proc (param_list),
- the storage format for PROCEDURE,
- the storage format for PROCEDURE parameters, in mysql.proc (param_list),
- the storage format for TRIGGER,
- the binary log used for replication.

In all cases, not only this cause format corruption, but also provide a vector
for dormant security issues, by allowing to tunnel code that will be activated
after an upgrade.

The proper solution is to deal with special comments strictly during parsing,
when accepting a query from the outside world.
Once a query is parsed and an object is created with a persistant
representation, this object should not arbitrarily mutate after an upgrade.
In short, special comments are a useful but limited feature for MYSQLdump,
when used at an *interface* level to facilitate import/export,
but bloating the server *internal* storage format is *not* the proper way
to deal with configuration management of the user logic.

With this fix:
- the Lex_input_stream class now acts as a comment pre-processor,
and either expands or ignore special comments on the fly.
- MYSQLlex and sql_yacc.yy have been cleaned up to strictly use the
public interface of Lex_input_stream. In particular, how the input stream
accepts or rejects a character is private to Lex_input_stream, and the
internal buffer pointers of that class are strictly private, and should not
be tempered with during parsing.

This caused many changes mostly in sql_lex.cc.

During the code cleanup in case MY_LEX_NUMBER_IDENT,
Bug 28127 (Some valid identifiers names are not parsed correctly)
was found and fixed.

By parsing special comments properly, and removing the function
'skip_rear_comments' [sic],
Bug 26302 (MySQL server cuts off trailing "*/" from comments in SP/func)
has been fixed as well.


sql/event_data_objects.cc:
  Cleanup of the code that extracts the query text
sql/sp.cc:
  Cleanup of the code that extracts the query text
sql/sp_head.cc:
  Cleanup of the code that extracts the query text
sql/sql_trigger.cc:
  Cleanup of the code that extracts the query text
sql/sql_view.cc:
  Cleanup of the code that extracts the query text
mysql-test/r/comments.result:
  Bug#25411 (trigger code truncated)
mysql-test/r/sp.result:
  Bug#25411 (trigger code truncated)
  Bug 26302 (MySQL server cuts off trailing "*/" from comments in SP/func)
mysql-test/r/trigger.result:
  Bug#25411 (trigger code truncated)
mysql-test/r/varbinary.result:
  Bug 28127 (Some valid identifiers names are not parsed correctly)
mysql-test/t/comments.test:
  Bug#25411 (trigger code truncated)
mysql-test/t/sp.test:
  Bug#25411 (trigger code truncated)
  Bug 26302 (MySQL server cuts off trailing "*/" from comments in SP/func)
mysql-test/t/trigger.test:
  Bug#25411 (trigger code truncated)
mysql-test/t/varbinary.test:
  Bug 28127 (Some valid identifiers names are not parsed correctly)
sql/sql_lex.cc:
  Implemented comment pre-processing in Lex_input_stream,
  major cleanup of the lex/yacc code to not use Lex_input_stream private members.
sql/sql_lex.h:
  Implemented comment pre-processing in Lex_input_stream,
  major cleanup of the lex/yacc code to not use Lex_input_stream private members.
sql/sql_yacc.yy:
  post merge fix : view_check_options must be parsed before signaling the end of the query
2007-06-12 15:23:58 -06:00
unknown
9ab7ce8dcb Merge weblab.(none):/home/marcsql/TREE/mysql-5.1-base
into  weblab.(none):/home/marcsql/TREE/mysql-5.1-rt-merge


sql/field.cc:
  Auto merged
sql/field.h:
  Auto merged
sql/item.h:
  Auto merged
sql/item_sum.cc:
  Auto merged
sql/item_timefunc.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_lex.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
2007-06-11 15:57:59 -06:00