mirror of https://github.com/citusdata/citus.git
Fix assert failure when creating statistics
parent
7dddfa2d0b
commit
107097ee28
|
@ -82,6 +82,13 @@ PreprocessCreateStatisticsStmt(Node *node, const char *queryString,
|
||||||
|
|
||||||
QualifyTreeNode((Node *) stmt);
|
QualifyTreeNode((Node *) stmt);
|
||||||
|
|
||||||
|
Oid statsOid = get_statistics_object_oid(stmt->defnames, true);
|
||||||
|
if (statsOid != InvalidOid)
|
||||||
|
{
|
||||||
|
/* if stats object already exists, don't create DDLJobs */
|
||||||
|
return NIL;
|
||||||
|
}
|
||||||
|
|
||||||
char *ddlCommand = DeparseTreeNode((Node *) stmt);
|
char *ddlCommand = DeparseTreeNode((Node *) stmt);
|
||||||
|
|
||||||
DDLJob *ddlJob = palloc0(sizeof(DDLJob));
|
DDLJob *ddlJob = palloc0(sizeof(DDLJob));
|
||||||
|
|
|
@ -236,9 +236,16 @@ static void
|
||||||
AppendColumnNames(StringInfo buf, CreateStatsStmt *stmt)
|
AppendColumnNames(StringInfo buf, CreateStatsStmt *stmt)
|
||||||
{
|
{
|
||||||
ColumnRef *column = NULL;
|
ColumnRef *column = NULL;
|
||||||
|
|
||||||
foreach_ptr(column, stmt->exprs)
|
foreach_ptr(column, stmt->exprs)
|
||||||
{
|
{
|
||||||
Assert(IsA(column, ColumnRef));
|
if (!IsA(column, ColumnRef) || list_length(column->fields) != 1)
|
||||||
|
{
|
||||||
|
ereport(ERROR,
|
||||||
|
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||||
|
errmsg(
|
||||||
|
"only simple column references are allowed in CREATE STATISTICS")));
|
||||||
|
}
|
||||||
|
|
||||||
char *columnName = NameListToQuotedString(column->fields);
|
char *columnName = NameListToQuotedString(column->fields);
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,20 @@ SELECT create_distributed_table('ownertest','a');
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
-- test invalid column expressions
|
||||||
|
CREATE TABLE test (x int, y int);
|
||||||
|
SELECT create_distributed_table('test','x');
|
||||||
|
create_distributed_table
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
CREATE STATISTICS stats_xy ON (x, y) FROM test;
|
||||||
|
ERROR: only simple column references are allowed in CREATE STATISTICS
|
||||||
|
CREATE STATISTICS stats_xy ON x+y FROM test;
|
||||||
|
ERROR: only simple column references are allowed in CREATE STATISTICS
|
||||||
|
CREATE STATISTICS stats_xy ON x,y FROM test;
|
||||||
|
CREATE STATISTICS IF NOT EXISTS stats_xy ON x+y FROM test;
|
||||||
\c - - - :worker_1_port
|
\c - - - :worker_1_port
|
||||||
SELECT stxname
|
SELECT stxname
|
||||||
FROM pg_statistic_ext
|
FROM pg_statistic_ext
|
||||||
|
@ -182,7 +196,23 @@ ORDER BY stxname ASC;
|
||||||
st1_new_980090
|
st1_new_980090
|
||||||
st1_new_980092
|
st1_new_980092
|
||||||
st1_new_980094
|
st1_new_980094
|
||||||
(80 rows)
|
stats_xy_980161
|
||||||
|
stats_xy_980163
|
||||||
|
stats_xy_980165
|
||||||
|
stats_xy_980167
|
||||||
|
stats_xy_980169
|
||||||
|
stats_xy_980171
|
||||||
|
stats_xy_980173
|
||||||
|
stats_xy_980175
|
||||||
|
stats_xy_980177
|
||||||
|
stats_xy_980179
|
||||||
|
stats_xy_980181
|
||||||
|
stats_xy_980183
|
||||||
|
stats_xy_980185
|
||||||
|
stats_xy_980187
|
||||||
|
stats_xy_980189
|
||||||
|
stats_xy_980191
|
||||||
|
(96 rows)
|
||||||
|
|
||||||
SELECT count(DISTINCT stxnamespace)
|
SELECT count(DISTINCT stxnamespace)
|
||||||
FROM pg_statistic_ext
|
FROM pg_statistic_ext
|
||||||
|
|
|
@ -75,6 +75,15 @@ CREATE STATISTICS sc1.s9 ON a,b FROM ownertest;
|
||||||
ALTER STATISTICS sc1.s9 OWNER TO pg_signal_backend;
|
ALTER STATISTICS sc1.s9 OWNER TO pg_signal_backend;
|
||||||
SELECT create_distributed_table('ownertest','a');
|
SELECT create_distributed_table('ownertest','a');
|
||||||
|
|
||||||
|
-- test invalid column expressions
|
||||||
|
CREATE TABLE test (x int, y int);
|
||||||
|
SELECT create_distributed_table('test','x');
|
||||||
|
|
||||||
|
CREATE STATISTICS stats_xy ON (x, y) FROM test;
|
||||||
|
CREATE STATISTICS stats_xy ON x+y FROM test;
|
||||||
|
CREATE STATISTICS stats_xy ON x,y FROM test;
|
||||||
|
CREATE STATISTICS IF NOT EXISTS stats_xy ON x+y FROM test;
|
||||||
|
|
||||||
\c - - - :worker_1_port
|
\c - - - :worker_1_port
|
||||||
SELECT stxname
|
SELECT stxname
|
||||||
FROM pg_statistic_ext
|
FROM pg_statistic_ext
|
||||||
|
|
Loading…
Reference in New Issue