mirror of https://github.com/citusdata/citus.git
Fix crash on create statistics with non-RangeVar type (#8213)
This crash has been there for a while but wasn't tested before pg18. PG18 added this test: CREATE STATISTICS tst ON a FROM (VALUES (x)) AS foo; which tries to create statistics on a derived-on-the-fly table (which is not allowed) However Citus assumes we always have a valid table when intercepting CREATE STATISTICS command to check for Citus tables Added a check to return early if needed. pg18 commit: https://github.com/postgres/postgres/commit/3eea4dc2c Fixes #8212m3hm3t/pg18_rc1_conf^2
parent
5eb1d93be1
commit
bb840e58a7
|
|
@ -69,7 +69,15 @@ PreprocessCreateStatisticsStmt(Node *node, const char *queryString,
|
|||
{
|
||||
CreateStatsStmt *stmt = castNode(CreateStatsStmt, node);
|
||||
|
||||
RangeVar *relation = (RangeVar *) linitial(stmt->relations);
|
||||
Node *relationNode = (Node *) linitial(stmt->relations);
|
||||
|
||||
if (!IsA(relationNode, RangeVar))
|
||||
{
|
||||
return NIL;
|
||||
}
|
||||
|
||||
RangeVar *relation = (RangeVar *) relationNode;
|
||||
|
||||
Oid relationId = RangeVarGetRelid(relation, ShareUpdateExclusiveLock, false);
|
||||
|
||||
if (!IsCitusTable(relationId) || !ShouldPropagate())
|
||||
|
|
|
|||
|
|
@ -4,11 +4,17 @@
|
|||
SHOW server_version \gset
|
||||
SELECT substring(:'server_version', '\d+')::int >= 18 AS server_version_ge_18
|
||||
\gset
|
||||
-- test invalid statistics
|
||||
-- behavior is same among PG versions, error message differs
|
||||
-- relevant PG18 commit: 3eea4dc2c7
|
||||
CREATE STATISTICS tst ON a FROM (VALUES (x)) AS foo;
|
||||
ERROR: cannot create statistics on the specified relation
|
||||
DETAIL: CREATE STATISTICS only supports tables, foreign tables and materialized views.
|
||||
\if :server_version_ge_18
|
||||
\else
|
||||
\q
|
||||
\endif
|
||||
-- PG17-specific tests go here.
|
||||
-- PG18-specific tests go here.
|
||||
--
|
||||
-- Purpose: Verify PG18 behavior that NOT NULL constraints are materialized
|
||||
-- as pg_constraint rows with contype = 'n' on both coordinator and
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@
|
|||
SHOW server_version \gset
|
||||
SELECT substring(:'server_version', '\d+')::int >= 18 AS server_version_ge_18
|
||||
\gset
|
||||
-- test invalid statistics
|
||||
-- behavior is same among PG versions, error message differs
|
||||
-- relevant PG18 commit: 3eea4dc2c7
|
||||
CREATE STATISTICS tst ON a FROM (VALUES (x)) AS foo;
|
||||
ERROR: only a single relation is allowed in CREATE STATISTICS
|
||||
\if :server_version_ge_18
|
||||
\else
|
||||
\q
|
||||
|
|
|
|||
|
|
@ -5,12 +5,17 @@ SHOW server_version \gset
|
|||
SELECT substring(:'server_version', '\d+')::int >= 18 AS server_version_ge_18
|
||||
\gset
|
||||
|
||||
-- test invalid statistics
|
||||
-- behavior is same among PG versions, error message differs
|
||||
-- relevant PG18 commit: 3eea4dc2c7
|
||||
CREATE STATISTICS tst ON a FROM (VALUES (x)) AS foo;
|
||||
|
||||
\if :server_version_ge_18
|
||||
\else
|
||||
\q
|
||||
\endif
|
||||
|
||||
-- PG17-specific tests go here.
|
||||
-- PG18-specific tests go here.
|
||||
--
|
||||
|
||||
-- Purpose: Verify PG18 behavior that NOT NULL constraints are materialized
|
||||
|
|
|
|||
Loading…
Reference in New Issue