mirror of https://github.com/citusdata/citus.git
Fix crash on create statistics with non-RangeVar type pt2 (#8227)
Fixes #8225 very similar to #8213 Also the error message changed between pg18rc1 and pg18.0pull/8230/head
parent
5a3648b2cb
commit
c5dde4b115
|
|
@ -34,7 +34,14 @@ QualifyCreateStatisticsStmt(Node *node)
|
||||||
{
|
{
|
||||||
CreateStatsStmt *stmt = castNode(CreateStatsStmt, node);
|
CreateStatsStmt *stmt = castNode(CreateStatsStmt, node);
|
||||||
|
|
||||||
RangeVar *relation = (RangeVar *) linitial(stmt->relations);
|
Node *relationNode = (Node *) linitial(stmt->relations);
|
||||||
|
|
||||||
|
if (!IsA(relationNode, RangeVar))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
RangeVar *relation = (RangeVar *) relationNode;
|
||||||
|
|
||||||
if (relation->schemaname == NULL)
|
if (relation->schemaname == NULL)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,15 @@ SELECT substring(:'server_version', '\d+')::int >= 18 AS server_version_ge_18
|
||||||
\gset
|
\gset
|
||||||
-- test invalid statistics
|
-- test invalid statistics
|
||||||
-- behavior is same among PG versions, error message differs
|
-- behavior is same among PG versions, error message differs
|
||||||
-- relevant PG18 commit: 3eea4dc2c7
|
-- relevant PG18 commit: 3eea4dc2c7, 38883916e
|
||||||
CREATE STATISTICS tst ON a FROM (VALUES (x)) AS foo;
|
CREATE STATISTICS tst ON a FROM (VALUES (x)) AS foo;
|
||||||
ERROR: cannot create statistics on the specified relation
|
ERROR: CREATE STATISTICS only supports relation names in the FROM clause
|
||||||
DETAIL: CREATE STATISTICS only supports tables, foreign tables and materialized views.
|
CREATE FUNCTION tftest(int) returns table(a int, b int) as $$
|
||||||
|
SELECT $1, $1+i FROM generate_series(1,5) g(i);
|
||||||
|
$$ LANGUAGE sql IMMUTABLE STRICT;
|
||||||
|
CREATE STATISTICS alt_stat2 ON a FROM tftest(1);
|
||||||
|
ERROR: CREATE STATISTICS only supports relation names in the FROM clause
|
||||||
|
DROP FUNCTION tftest;
|
||||||
\if :server_version_ge_18
|
\if :server_version_ge_18
|
||||||
\else
|
\else
|
||||||
\q
|
\q
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,15 @@ SELECT substring(:'server_version', '\d+')::int >= 18 AS server_version_ge_18
|
||||||
\gset
|
\gset
|
||||||
-- test invalid statistics
|
-- test invalid statistics
|
||||||
-- behavior is same among PG versions, error message differs
|
-- behavior is same among PG versions, error message differs
|
||||||
-- relevant PG18 commit: 3eea4dc2c7
|
-- relevant PG18 commit: 3eea4dc2c7, 38883916e
|
||||||
CREATE STATISTICS tst ON a FROM (VALUES (x)) AS foo;
|
CREATE STATISTICS tst ON a FROM (VALUES (x)) AS foo;
|
||||||
ERROR: only a single relation is allowed in CREATE STATISTICS
|
ERROR: only a single relation is allowed in CREATE STATISTICS
|
||||||
|
CREATE FUNCTION tftest(int) returns table(a int, b int) as $$
|
||||||
|
SELECT $1, $1+i FROM generate_series(1,5) g(i);
|
||||||
|
$$ LANGUAGE sql IMMUTABLE STRICT;
|
||||||
|
CREATE STATISTICS alt_stat2 ON a FROM tftest(1);
|
||||||
|
ERROR: only a single relation is allowed in CREATE STATISTICS
|
||||||
|
DROP FUNCTION tftest;
|
||||||
\if :server_version_ge_18
|
\if :server_version_ge_18
|
||||||
\else
|
\else
|
||||||
\q
|
\q
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,15 @@ SELECT substring(:'server_version', '\d+')::int >= 18 AS server_version_ge_18
|
||||||
|
|
||||||
-- test invalid statistics
|
-- test invalid statistics
|
||||||
-- behavior is same among PG versions, error message differs
|
-- behavior is same among PG versions, error message differs
|
||||||
-- relevant PG18 commit: 3eea4dc2c7
|
-- relevant PG18 commit: 3eea4dc2c7, 38883916e
|
||||||
CREATE STATISTICS tst ON a FROM (VALUES (x)) AS foo;
|
CREATE STATISTICS tst ON a FROM (VALUES (x)) AS foo;
|
||||||
|
|
||||||
|
CREATE FUNCTION tftest(int) returns table(a int, b int) as $$
|
||||||
|
SELECT $1, $1+i FROM generate_series(1,5) g(i);
|
||||||
|
$$ LANGUAGE sql IMMUTABLE STRICT;
|
||||||
|
CREATE STATISTICS alt_stat2 ON a FROM tftest(1);
|
||||||
|
DROP FUNCTION tftest;
|
||||||
|
|
||||||
\if :server_version_ge_18
|
\if :server_version_ge_18
|
||||||
\else
|
\else
|
||||||
\q
|
\q
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue