mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
fix for bug #1946:
"You can always mysql_real_query a query with placeholders after mysql_prepare()" sql/sql_class.cc: prepare_command removed sql/sql_class.h: prepare_command removed sql/sql_prepare.cc: prepare_command removed sql/sql_yacc.yy: prepare_command removed tests/client_test.c: added test for bug #1946: "You can always mysql_real_query a query with placeholders after mysql_prepare()"
This commit is contained in:
@ -90,8 +90,8 @@ THD::THD():user_time(0), is_fatal_error(0),
|
||||
{
|
||||
host=user=priv_user=db=query=ip=0;
|
||||
host_or_ip= "connecting host";
|
||||
locked=killed=some_tables_deleted=no_errors=password=
|
||||
query_start_used=prepare_command=0;
|
||||
locked=killed=some_tables_deleted=no_errors=password= 0;
|
||||
query_start_used= 0;
|
||||
count_cuted_fields= CHECK_FIELD_IGNORE;
|
||||
db_length=query_length=col_access=0;
|
||||
query_error= tmp_table_used= 0;
|
||||
|
@ -606,7 +606,6 @@ public:
|
||||
bool system_thread,in_lock_tables,global_read_lock;
|
||||
bool query_error, bootstrap, cleanup_done;
|
||||
bool volatile killed;
|
||||
bool prepare_command;
|
||||
bool tmp_table_used;
|
||||
bool charset_is_system_charset, charset_is_collation_connection;
|
||||
bool slow_command;
|
||||
|
@ -785,7 +785,6 @@ static bool parse_prepare_query(PREP_STMT *stmt,
|
||||
mysql_init_query(thd);
|
||||
LEX *lex=lex_start(thd, (uchar*) packet, length);
|
||||
lex->safe_to_cache_query= 0;
|
||||
thd->prepare_command= TRUE;
|
||||
thd->lex.param_count= 0;
|
||||
if (!yyparse((void *)thd) && !thd->is_fatal_error)
|
||||
error= send_prepare_results(stmt);
|
||||
|
@ -4355,7 +4355,7 @@ param_marker:
|
||||
'?'
|
||||
{
|
||||
LEX *lex=Lex;
|
||||
if (YYTHD->prepare_command)
|
||||
if (YYTHD->command == COM_PREPARE)
|
||||
{
|
||||
lex->param_list.push_back($$=new Item_param((uint)(lex->tok_start-(uchar *)YYTHD->query)));
|
||||
lex->param_count++;
|
||||
|
@ -8065,6 +8065,32 @@ static void test_bug1500()
|
||||
mysql_stmt_close(stmt);
|
||||
}
|
||||
|
||||
static void test_bug1946()
|
||||
{
|
||||
MYSQL_STMT *stmt;
|
||||
int rc;
|
||||
|
||||
myheader("test_bug1946");
|
||||
const char *query= "INSERT INTO prepare_command VALUES (?)";
|
||||
|
||||
rc = mysql_query(mysql, "DROP TABLE IF EXISTS prepare_command");
|
||||
myquery(rc);
|
||||
|
||||
rc= mysql_query(mysql,"CREATE TABLE prepare_command(ID INT)");
|
||||
myquery(rc);
|
||||
|
||||
stmt = mysql_prepare(mysql, query, strlen(query));
|
||||
mystmt_init(stmt);
|
||||
rc= mysql_real_query(mysql, query, strlen(query));
|
||||
assert(rc != 0);
|
||||
fprintf(stdout, "Got error (as expected):\n");
|
||||
myerror(NULL);
|
||||
|
||||
mysql_stmt_close(stmt);
|
||||
rc= mysql_query(mysql,"DROP TABLE prepare_command");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Read and parse arguments and MySQL options from my.cnf
|
||||
*/
|
||||
@ -8208,6 +8234,8 @@ int main(int argc, char **argv)
|
||||
/* Used for internal new development debugging */
|
||||
test_drop_temp(); /* to test DROP TEMPORARY TABLE Access checks */
|
||||
#endif
|
||||
test_bug1946(); /* test that placeholders are allowed only in
|
||||
prepared queries */
|
||||
test_fetch_seek(); /* to test stmt seek() functions */
|
||||
test_fetch_nobuffs(); /* to fecth without prior bound buffers */
|
||||
test_open_direct(); /* direct execution in the middle of open stmts */
|
||||
|
Reference in New Issue
Block a user