Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
e063ab1f
Commit
e063ab1f
authored
Dec 14, 2004
by
ram@gw.mysql.r18.ru
Browse files
Options
Browse Files
Download
Plain Diff
Merge rkalimullin@bk-internal.mysql.com:/home/bk/mysql-4.1
into gw.mysql.r18.ru:/usr/home/ram/work/4.1
parents
d35c6c9c
75fc0ac4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
0 deletions
+74
-0
sql/sql_prepare.cc
sql/sql_prepare.cc
+23
-0
tests/client_test.c
tests/client_test.c
+51
-0
No files found.
sql/sql_prepare.cc
View file @
e063ab1f
...
...
@@ -1514,6 +1514,27 @@ static bool init_param_array(Prepared_statement *stmt)
}
/* Init statement before execution */
static
void
cleanup_stmt_for_execute
(
Prepared_statement
*
stmt
)
{
THD
*
thd
=
stmt
->
thd
;
LEX
*
lex
=
stmt
->
lex
;
SELECT_LEX
*
sl
=
lex
->
all_selects_list
;
for
(;
sl
;
sl
=
sl
->
next_select_in_list
())
{
for
(
TABLE_LIST
*
tables
=
(
TABLE_LIST
*
)
sl
->
table_list
.
first
;
tables
;
tables
=
tables
->
next
)
{
if
(
tables
->
table
)
tables
->
table
->
insert_values
=
0
;
}
}
}
/*
Given a query string with parameter markers, create a Prepared Statement
from it and send PS info back to the client.
...
...
@@ -1614,6 +1635,7 @@ int mysql_stmt_prepare(THD *thd, char *packet, uint packet_length,
if
(
!
error
)
error
=
send_prepare_results
(
stmt
,
test
(
name
));
cleanup_stmt_for_execute
(
stmt
);
/* restore to WAIT_PRIOR: QUERY_PRIOR is set inside alloc_query */
if
(
!
(
specialflag
&
SPECIAL_NO_PRIOR
))
...
...
@@ -1904,6 +1926,7 @@ static void execute_stmt(THD *thd, Prepared_statement *stmt,
reset_stmt_params
(
stmt
);
close_thread_tables
(
thd
);
// to close derived tables
thd
->
set_statement
(
&
thd
->
stmt_backup
);
cleanup_stmt_for_execute
(
stmt
);
DBUG_VOID_RETURN
;
}
...
...
tests/client_test.c
View file @
e063ab1f
...
...
@@ -1026,6 +1026,56 @@ static void test_tran_innodb()
}
/* Test for BUG#7242 */
static
void
test_prepare_insert_update
()
{
MYSQL_STMT
*
stmt
;
int
rc
;
int
i
;
const
char
*
testcase
[]
=
{
"CREATE TABLE t1 (a INT, b INT, c INT, UNIQUE (A), UNIQUE(B))"
,
"INSERT t1 VALUES (1,2,10), (3,4,20)"
,
"INSERT t1 VALUES (5,6,30), (7,4,40), (8,9,60) ON DUPLICATE KEY UPDATE c=c+100"
,
"SELECT * FROM t1"
,
"INSERT t1 SET a=5 ON DUPLICATE KEY UPDATE b=0"
,
"SELECT * FROM t1"
,
"INSERT t1 VALUES (2,1,11), (7,4,40) ON DUPLICATE KEY UPDATE c=c+VALUES(a)"
,
NULL
};
const
char
**
cur_query
;
myheader
(
"test_prepare_insert_update"
);
for
(
cur_query
=
testcase
;
*
cur_query
;
cur_query
++
)
{
printf
(
"
\n
Running query: %s"
,
*
cur_query
);
strmov
(
query
,
*
cur_query
);
stmt
=
mysql_simple_prepare
(
mysql
,
query
);
check_stmt
(
stmt
);
verify_param_count
(
stmt
,
0
);
rc
=
mysql_stmt_execute
(
stmt
);
check_execute
(
stmt
,
rc
);
/* try the last query several times */
if
(
!
cur_query
[
1
])
{
for
(
i
=
0
;
i
<
3
;
i
++
)
{
printf
(
"
\n
Executing last statement again"
);
rc
=
mysql_stmt_execute
(
stmt
);
check_execute
(
stmt
,
rc
);
rc
=
mysql_stmt_execute
(
stmt
);
check_execute
(
stmt
,
rc
);
}
}
mysql_stmt_close
(
stmt
);
}
rc
=
mysql_commit
(
mysql
);
myquery
(
rc
);
}
/* Test simple prepares of all DML statements */
static
void
test_prepare_simple
()
...
...
@@ -11513,6 +11563,7 @@ and you are welcome to modify and redistribute it under the GPL license\n");
static
struct
my_tests_st
my_tests
[]
=
{
{
"client_query"
,
client_query
},
{
"test_prepare_insert_update"
,
test_prepare_insert_update
},
#if NOT_YET_WORKING
{
"test_drop_temp"
,
test_drop_temp
},
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment