提交 1843ec62 编写于 作者: H Heikki Linnakangas

Fix SQL escaping bug in internal query.

The old comment was unsure if toast tables and indexes have their Oids
in sync across the cluster. They do, so let's rely on that, which is
simpler.
上级 f1530ccc
......@@ -8,8 +8,6 @@
*/
#include "postgres.h"
#include <math.h>
#include "utils/lsyscache.h"
#include "utils/relcache.h"
#include "utils/syscache.h"
......@@ -37,26 +35,16 @@ cdbRelMaxSegSize(Relation rel)
CdbPgResults cdb_pgresults = {NULL, 0};
StringInfoData buffer;
char *schemaName;
char *relName;
/*
* Let's ask the QEs for the size of the relation
*/
initStringInfo(&buffer);
schemaName = get_namespace_name(RelationGetNamespace(rel));
if (schemaName == NULL)
elog(ERROR, "cache lookup failed for namespace %d",
RelationGetNamespace(rel));
relName = RelationGetRelationName(rel);
/*
* Safer to pass names than oids, just in case they get out of sync between QD and QE,
* which might happen with a toast table or index, I think (but maybe not)
* Relation Oids are assumed to be in sync in all nodes.
*/
appendStringInfo(&buffer, "select pg_relation_size('%s.%s')",
quote_identifier(schemaName), quote_identifier(relName));
appendStringInfo(&buffer, "select pg_relation_size(%u)",
RelationGetRelid(rel));
CdbDispatchCommand(buffer.data, DF_WITH_SNAPSHOT, &cdb_pgresults);
......
......@@ -125,3 +125,7 @@ SELECT * FROM altable ORDER BY 1;
0 | 1
(1 row)
-- Verify that changing the datatype of a funnily-named column works.
-- (There used to be a quoting bug in the internal query this issues.)
create table "foo'bar" (id int4, t text);
alter table "foo'bar" alter column t type integer using length(t);
......@@ -127,3 +127,7 @@ SELECT * FROM altable ORDER BY 1;
0 | 1
(1 row)
-- Verify that changing the datatype of a funnily-named column works.
-- (There used to be a quoting bug in the internal query this issues.)
create table "foo'bar" (id int4, t text);
alter table "foo'bar" alter column t type integer using length(t);
......@@ -82,3 +82,9 @@ UPDATE altable SET c = -10;
SELECT * FROM altable ORDER BY 1;
UPDATE altable SET c = 1;
SELECT * FROM altable ORDER BY 1;
-- Verify that changing the datatype of a funnily-named column works.
-- (There used to be a quoting bug in the internal query this issues.)
create table "foo'bar" (id int4, t text);
alter table "foo'bar" alter column t type integer using length(t);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册