Commit 2d9c5f1b authored by Sergei Petrunia's avatar Sergei Petrunia Committed by Sergei Petrunia

CLX-55: Prepared Statements: a short term solution for UPDATEs

Direct UPDATE used to print the original statement. With Prepared Statement,
this could cause the statement with original parameter marks ('?') to be
printed.

Solve this in the same way as "Select Handler" does: print the statement back
from the parse tree. The parameters would be substituted.
parent 01f39762
......@@ -67,5 +67,18 @@ select * from t2;
a
1
drop table t1,t2;
#
# CLX-55: Prepared statement support:
# Implement "Direct Update" by printing the statement
#
create table t1 (a int primary key, b int) engine=xpand;
insert into t1 values (1,1),(2,2),(3,3);
prepare s from 'update t1 set b=b+? where a=?';
execute s using 10000, 2;
select * from t1;
a b
1 1
2 10002
3 3
USE test;
DROP DATABASE xpd;
......@@ -63,5 +63,17 @@ insert into t2 select * from t1;
select * from t2;
drop table t1,t2;
--echo #
--echo # CLX-55: Prepared statement support:
--echo # Implement "Direct Update" by printing the statement
--echo #
create table t1 (a int primary key, b int) engine=xpand;
insert into t1 values (1,1),(2,2),(3,3);
prepare s from 'update t1 set b=b+? where a=?';
execute s using 10000, 2;
--sorted_result
select * from t1;
USE test;
DROP DATABASE xpd;
......@@ -561,7 +561,8 @@ int ha_xpand::direct_update_rows(ha_rows *update_rows, ha_rows *found_rows)
return error_code;
String update_stmt;
update_stmt.append(thd->query_string.str());
// Do the same as create_xpand_select_handler does:
thd->lex->print(&update_stmt, QT_ORDINARY);
if (!thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
trx->auto_commit_next();
......
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