提交 effe6a93 编写于 作者: H Heikki Linnakangas

Fix quoting when dispatching SAVEPOINT commands.

Fixes github issue #6345.
Reviewed-by: NDaniel Gustafsson <dgustafsson@pivotal.io>
上级 71fa5566
......@@ -61,6 +61,7 @@
#include "utils/memutils.h"
#include "utils/relmapper.h"
#include "utils/builtins.h"
#include "utils/resource_manager.h"
#include "utils/sharedsnapshot.h"
#include "access/clog.h"
......@@ -4578,7 +4579,7 @@ DefineDispatchSavepoint(char *name)
{
char *cmd;
cmd = psprintf("SAVEPOINT %s", name);
cmd = psprintf("SAVEPOINT %s", quote_identifier(name));
/*
* dispatch a DTX command, in the event of an error, this call
......@@ -4711,7 +4712,7 @@ ReleaseSavepoint(List *options)
{
char *cmd;
cmd = psprintf("RELEASE SAVEPOINT %s", name);
cmd = psprintf("RELEASE SAVEPOINT %s", quote_identifier(name));
/*
* dispatch a DTX command, in the event of an error, this call will
......@@ -4878,7 +4879,7 @@ DispatchRollbackToSavepoint(char *name)
if (!name)
elog(ERROR, "could not find savepoint name for ROLLBACK TO SAVEPOINT");
cmd = psprintf("ROLLBACK TO SAVEPOINT %s", name);
cmd = psprintf("ROLLBACK TO SAVEPOINT %s", quote_identifier(name));
/*
* dispatch a DTX command, in the event of an error, this call will
......
......@@ -1013,3 +1013,28 @@ $$ language plpgsql;
create table stran_tt as select stran_func(b) from stran_foo;
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'stran_func' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
--
-- Check quoting when dispatching savepoints. (Not really PL/pgSQL related,
-- but here for lack of a better place.)
--
BEGIN;
CREATE TEMPORARY TABLE savepointtest (t text);
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 't' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
INSERT INTO savepointtest VALUES ('before savepoints');
SAVEPOINT "evil""savepoint1";
INSERT INTO savepointtest VALUES ('after sp 1');
SAVEPOINT "evil""savepoint2";
INSERT INTO savepointtest VALUES ('after sp 2');
ROLLBACK TO SAVEPOINT "evil""savepoint2";
RELEASE SAVEPOINT "evil""savepoint1";
INSERT INTO savepointtest VALUES ('back to top transaction');
COMMIT;
SELECT * FROM savepointtest;
t
-------------------------
before savepoints
after sp 1
back to top transaction
(3 rows)
......@@ -372,3 +372,21 @@ end;
$$ language plpgsql;
create table stran_tt as select stran_func(b) from stran_foo;
--
-- Check quoting when dispatching savepoints. (Not really PL/pgSQL related,
-- but here for lack of a better place.)
--
BEGIN;
CREATE TEMPORARY TABLE savepointtest (t text);
INSERT INTO savepointtest VALUES ('before savepoints');
SAVEPOINT "evil""savepoint1";
INSERT INTO savepointtest VALUES ('after sp 1');
SAVEPOINT "evil""savepoint2";
INSERT INTO savepointtest VALUES ('after sp 2');
ROLLBACK TO SAVEPOINT "evil""savepoint2";
RELEASE SAVEPOINT "evil""savepoint1";
INSERT INTO savepointtest VALUES ('back to top transaction');
COMMIT;
SELECT * FROM savepointtest;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册