Commit 615cd4ff authored by unknown's avatar unknown

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
...@@ -1864,12 +1864,13 @@ void set_stmt_errmsg(MYSQL_STMT * stmt, const char *err, int errcode, ...@@ -1864,12 +1864,13 @@ void set_stmt_errmsg(MYSQL_STMT * stmt, const char *err, int errcode,
my_bool cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt) my_bool cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt)
{ {
uchar *pos; uchar *pos;
uint field_count, param_count, packet_length; uint field_count, param_count;
ulong packet_length;
MYSQL_DATA *fields_data; MYSQL_DATA *fields_data;
DBUG_ENTER("read_prepare_result"); DBUG_ENTER("cli_read_prepare_result");
mysql= mysql->last_used_con; mysql= mysql->last_used_con;
if ((packet_length=net_safe_read(mysql)) == packet_error) if ((packet_length= net_safe_read(mysql)) == packet_error)
DBUG_RETURN(1); DBUG_RETURN(1);
mysql->warning_count= 0; mysql->warning_count= 0;
......
...@@ -22,6 +22,9 @@ insert delayed into t1 values (null,"c"); ...@@ -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,"d"),(null,"e");
insert delayed into t1 values (3,"this will give an","error"); insert delayed into t1 values (3,"this will give an","error");
ERROR 21S01: Column count doesn't match value count at row 1 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; select * from t1;
a b a b
1 b 1 b
......
...@@ -31,6 +31,8 @@ insert delayed into t1 values (null,"c"); ...@@ -31,6 +31,8 @@ insert delayed into t1 values (null,"c");
insert delayed into t1 values (3,"d"),(null,"e"); insert delayed into t1 values (3,"d"),(null,"e");
--error 1136 --error 1136
insert delayed into t1 values (3,"this will give an","error"); 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; select * from t1;
drop table t1; drop table t1;
...@@ -2323,8 +2323,10 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables, ...@@ -2323,8 +2323,10 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables,
bool found_table=0; bool found_table=0;
for (; tables; tables= tables->next_local) 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) && 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; found_table=1;
Field *find= find_field_in_table(thd, tables, name, item->name, 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, ...@@ -3039,7 +3041,7 @@ insert_fields(THD *thd, TABLE_LIST *tables, const char *db_name,
iterator= &view_iter; iterator= &view_iter;
view= 1; view= 1;
alias_used= my_strcasecmp(table_alias_charset, alias_used= my_strcasecmp(table_alias_charset,
tables->real_name, tables->alias); tables->table_name, tables->alias);
} }
else else
{ {
......
...@@ -935,7 +935,7 @@ static bool mysql_test_insert(Prepared_statement *stmt, ...@@ -935,7 +935,7 @@ static bool mysql_test_insert(Prepared_statement *stmt,
{ {
my_error(ER_ILLEGAL_HA, MYF(0), (table_list->view ? my_error(ER_ILLEGAL_HA, MYF(0), (table_list->view ?
table_list->view_name.str : table_list->view_name.str :
table_list->real_name)); table_list->table_name));
goto error; goto error;
} }
while ((values= its++)) while ((values= its++))
...@@ -1445,7 +1445,7 @@ static bool mysql_insert_select_prepare_tester(THD *thd) ...@@ -1445,7 +1445,7 @@ static bool mysql_insert_select_prepare_tester(THD *thd)
and item_list belong to SELECT and item_list belong to SELECT
*/ */
first_select->resolve_mode= SELECT_LEX::SELECT_MODE; first_select->resolve_mode= SELECT_LEX::SELECT_MODE;
mysql_insert_select_prepare(thd); return mysql_insert_select_prepare(thd);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment