Commit 615cd4ff authored by unknown's avatar unknown
Browse files

Fixed a bug in prepared statements error handling

After merge fixes


libmysql/libmysql.c:
  Fixed a bug in prepared statements error handling introduced by me on a recent patch
mysql-test/r/delayed.result:
  Updated results
mysql-test/t/delayed.test:
  Bigger timeout needed when using --ps-protocol (don't understand why yet)
  Added output of not_flushed_dealyed_rows for easier debugging
sql/sql_base.cc:
  USE tables_share fix for prepared statements
sql/sql_prepare.cc:
  After merge fix
parent 8ff88672
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -1864,9 +1864,10 @@ void set_stmt_errmsg(MYSQL_STMT * stmt, const char *err, int errcode,
my_bool cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt)
{
  uchar *pos;
  uint field_count, param_count, packet_length;
  uint field_count, param_count;
  ulong packet_length;
  MYSQL_DATA *fields_data;
  DBUG_ENTER("read_prepare_result");
  DBUG_ENTER("cli_read_prepare_result");

  mysql= mysql->last_used_con;
  if ((packet_length= net_safe_read(mysql)) == packet_error)
+3 −0
Original line number Diff line number Diff line
@@ -22,6 +22,9 @@ insert delayed into t1 values (null,"c");
insert delayed into t1 values (3,"d"),(null,"e");
insert delayed into t1 values (3,"this will give an","error");
ERROR 21S01: Column count doesn't match value count at row 1
show status like 'not_flushed_delayed_rows';
Variable_name	Value
Not_flushed_delayed_rows	0
select * from t1;
a	b
1	b
+3 −1
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@ insert delayed into t1 values (null,"c");
insert delayed into t1 values (3,"d"),(null,"e");
--error 1136
insert delayed into t1 values (3,"this will give an","error");
--sleep 2
# 2 was not enough for --ps-protocol
--sleep 4
show status like 'not_flushed_delayed_rows';
select * from t1;
drop table t1;
+4 −2
Original line number Diff line number Diff line
@@ -2323,8 +2323,10 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables,
    bool found_table=0;
    for (; tables; tables= tables->next_local)
    {
      /* TODO; Ensure that db and tables->db always points to something ! */
      if (!my_strcasecmp(table_alias_charset, tables->alias, table_name) &&
	  (!db || !tables->db ||  !tables->db[0] || !strcmp(db,tables->db)))
	  (!db || !db[0] || !tables->db ||  !tables->db[0] ||
           !strcmp(db,tables->db)))
      {
	found_table=1;
	Field *find= find_field_in_table(thd, tables, name, item->name,
@@ -3039,7 +3041,7 @@ insert_fields(THD *thd, TABLE_LIST *tables, const char *db_name,
        iterator= &view_iter;
	view= 1;
	alias_used= my_strcasecmp(table_alias_charset,
				  tables->real_name, tables->alias);
				  tables->table_name, tables->alias);
      }
      else
      {
+2 −2
Original line number Diff line number Diff line
@@ -935,7 +935,7 @@ static bool mysql_test_insert(Prepared_statement *stmt,
    {
      my_error(ER_ILLEGAL_HA, MYF(0), (table_list->view ?
                                       table_list->view_name.str :
                                       table_list->real_name));
                                       table_list->table_name));
      goto error;
    }
    while ((values= its++))
@@ -1445,7 +1445,7 @@ static bool mysql_insert_select_prepare_tester(THD *thd)
    and item_list belong to SELECT
  */
  first_select->resolve_mode= SELECT_LEX::SELECT_MODE;
  mysql_insert_select_prepare(thd);
  return mysql_insert_select_prepare(thd);
}