Commit 50c37672 authored by anozdrin/alik@quad.opbmk's avatar anozdrin/alik@quad.opbmk
Browse files

Merge quad.opbmk:/mnt/raid/alik/MySQL/devel/5.0

into  quad.opbmk:/mnt/raid/alik/MySQL/devel/5.0-rt-merged
parents 3bff5b59 44fe22e7
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -2456,7 +2456,7 @@ static my_bool execute(MYSQL_STMT *stmt, char *packet, ulong length)
  int4store(buff+5, 1);                         /* iteration count */

  res= test(cli_advanced_command(mysql, COM_STMT_EXECUTE, buff, sizeof(buff),
                                 packet, length, 1, NULL) ||
                                 packet, length, 1, stmt) ||
            (*mysql->methods->read_query_result)(mysql));
  stmt->affected_rows= mysql->affected_rows;
  stmt->server_status= mysql->server_status;
@@ -2673,7 +2673,7 @@ stmt_read_row_from_cursor(MYSQL_STMT *stmt, unsigned char **row)
    int4store(buff + 4, stmt->prefetch_rows); /* number of rows to fetch */
    if ((*mysql->methods->advanced_command)(mysql, COM_STMT_FETCH,
                                            buff, sizeof(buff), NullS, 0,
                                            1, NULL))
                                            1, stmt))
    {
      set_stmt_errmsg(stmt, net->last_error, net->last_errno, net->sqlstate);
      return 1;
@@ -3340,7 +3340,7 @@ mysql_stmt_send_long_data(MYSQL_STMT *stmt, uint param_number,
    */
    if ((*mysql->methods->advanced_command)(mysql, COM_STMT_SEND_LONG_DATA,
                                            buff, sizeof(buff), data,
                                            length, 1, NULL))
                                            length, 1, stmt))
    {
      set_stmt_errmsg(stmt, mysql->net.last_error,
		      mysql->net.last_errno, mysql->net.sqlstate);
@@ -4737,6 +4737,13 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt)
  MYSQL_DATA *result= &stmt->result;
  DBUG_ENTER("mysql_stmt_store_result");

  if (!mysql)
  {
    /* mysql can be reset in mysql_close called from mysql_reconnect */
    set_stmt_error(stmt, CR_SERVER_LOST, unknown_sqlstate);
    DBUG_RETURN(1);
  }

  mysql= mysql->last_used_con;

  if (!stmt->field_count)
@@ -4762,7 +4769,7 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt)
    int4store(buff, stmt->stmt_id);
    int4store(buff + 4, (int)~0); /* number of rows to fetch */
    if (cli_advanced_command(mysql, COM_STMT_FETCH, buff, sizeof(buff),
                             NullS, 0, 1, NULL))
                             NullS, 0, 1, stmt))
    {
      set_stmt_errmsg(stmt, net->last_error, net->last_errno, net->sqlstate);
      DBUG_RETURN(1);
@@ -4949,7 +4956,7 @@ static my_bool reset_stmt_handle(MYSQL_STMT *stmt, uint flags)
        char buff[MYSQL_STMT_HEADER]; /* packet header: 4 bytes for stmt id */
        int4store(buff, stmt->stmt_id);
        if ((*mysql->methods->advanced_command)(mysql, COM_STMT_RESET, buff,
                                                sizeof(buff), 0, 0, 0, NULL))
                                                sizeof(buff), 0, 0, 0, stmt))
        {
          set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno,
                          mysql->net.sqlstate);
+19 −0
Original line number Diff line number Diff line
@@ -140,4 +140,23 @@ select * from t3;
c
1
drop table t1, t2, t3;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=innodb;
CREATE TABLE t2(b INT, FOREIGN KEY(b) REFERENCES t1(a)) ENGINE=innodb;
INSERT INTO t1 VALUES (1);
CREATE TRIGGER t1_bd BEFORE DELETE ON t1 FOR EACH ROW SET @a = 1;
CREATE TRIGGER t1_ad AFTER DELETE ON t1 FOR EACH ROW SET @b = 1;
SET @a = 0;
SET @b = 0;
TRUNCATE t1;
SELECT @a, @b;
@a	@b
0	0
INSERT INTO t1 VALUES (1);
DELETE FROM t1;
SELECT @a, @b;
@a	@b
1	1
DROP TABLE t2, t1;
End of 5.0 tests
+2 −2
Original line number Diff line number Diff line
@@ -8,8 +8,8 @@
# server or run mysql-test-run --debug mysql_client_test and check
# var/log/mysql_client_test.trace

--exec echo "$MYSQL_CLIENT_TEST" > $MYSQLTEST_VARDIR/log/mysql_client_test.log 2>&1
--exec $MYSQL_CLIENT_TEST --getopt-ll-test=25600M >> $MYSQLTEST_VARDIR/log/mysql_client_test.log 2>&1
--exec echo "$MYSQL_CLIENT_TEST" > $MYSQLTEST_VARDIR/log/mysql_client_test.out.log 2>&1
--exec $MYSQL_CLIENT_TEST --getopt-ll-test=25600M >> $MYSQLTEST_VARDIR/log/mysql_client_test.out.log 2>&1

# End of 4.1 tests
echo ok;
+32 −0
Original line number Diff line number Diff line
@@ -128,5 +128,37 @@ drop table t1, t2, t3;
disconnect connection_update;
disconnect connection_aux;

#
# Bug#34643: TRUNCATE crash if trigger and foreign key.
#

--disable_warnings
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
--enable_warnings

CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=innodb;
CREATE TABLE t2(b INT, FOREIGN KEY(b) REFERENCES t1(a)) ENGINE=innodb;

INSERT INTO t1 VALUES (1);

CREATE TRIGGER t1_bd BEFORE DELETE ON t1 FOR EACH ROW SET @a = 1;
CREATE TRIGGER t1_ad AFTER DELETE ON t1 FOR EACH ROW SET @b = 1;

SET @a = 0;
SET @b = 0;

TRUNCATE t1;

SELECT @a, @b;

INSERT INTO t1 VALUES (1);

DELETE FROM t1;

SELECT @a, @b;

DROP TABLE t2, t1;


--echo End of 5.0 tests
+7 −3
Original line number Diff line number Diff line
@@ -669,11 +669,12 @@ my_bool
cli_advanced_command(MYSQL *mysql, enum enum_server_command command,
		     const char *header, ulong header_length,
		     const char *arg, ulong arg_length, my_bool skip_check,
                     MYSQL_STMT *stmt __attribute__((unused)))
                     MYSQL_STMT *stmt)
{
  NET *net= &mysql->net;
  my_bool result= 1;
  init_sigpipe_variables
  my_bool stmt_skip= stmt ? stmt->state != MYSQL_STMT_INIT_DONE : FALSE;
  DBUG_ENTER("cli_advanced_command");

  /* Don't give sigpipe errors if the client doesn't want them */
@@ -681,7 +682,7 @@ cli_advanced_command(MYSQL *mysql, enum enum_server_command command,

  if (mysql->net.vio == 0)
  {						/* Do reconnect if possible */
    if (mysql_reconnect(mysql))
    if (mysql_reconnect(mysql) || stmt_skip)
      DBUG_RETURN(1);
  }
  if (mysql->status != MYSQL_STATUS_READY ||
@@ -712,7 +713,7 @@ cli_advanced_command(MYSQL *mysql, enum enum_server_command command,
      goto end;
    }
    end_server(mysql);
    if (mysql_reconnect(mysql))
    if (mysql_reconnect(mysql) || stmt_skip)
      goto end;
    if (net_write_command(net,(uchar) command, header, header_length,
			  arg, arg_length))
@@ -2518,6 +2519,9 @@ my_bool mysql_reconnect(MYSQL *mysql)
      if (stmt->state != MYSQL_STMT_INIT_DONE)
      {
        stmt->mysql= 0;
        stmt->last_errno= CR_SERVER_LOST;
        strmov(stmt->last_error, ER(CR_SERVER_LOST));
        strmov(stmt->sqlstate, unknown_sqlstate);
      }
      else
      {
Loading