mirror of https://github.com/citusdata/citus.git
PG16 - Throw meaningful error for stats without a name on Citus tables (#7136)
Relevant PG commit:
624aa2a13b
624aa2a13bd02dd584bb0995c883b5b93b2152df
pull/7139/head
parent
371f094b68
commit
36b51d617c
|
@ -77,6 +77,14 @@ PreprocessCreateStatisticsStmt(Node *node, const char *queryString,
|
||||||
|
|
||||||
EnsureCoordinator();
|
EnsureCoordinator();
|
||||||
|
|
||||||
|
if (!(stmt->defnames))
|
||||||
|
{
|
||||||
|
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||||
|
errmsg("cannot create statistics without a name on a "
|
||||||
|
"Citus table"),
|
||||||
|
errhint("Consider specifying a name for the statistics")));
|
||||||
|
}
|
||||||
|
|
||||||
QualifyTreeNode((Node *) stmt);
|
QualifyTreeNode((Node *) stmt);
|
||||||
|
|
||||||
Oid statsOid = get_statistics_object_oid(stmt->defnames, true);
|
Oid statsOid = get_statistics_object_oid(stmt->defnames, true);
|
||||||
|
|
|
@ -65,6 +65,28 @@ SET citus.log_remote_commands TO OFF;
|
||||||
-- only verifying it works and not printing log
|
-- only verifying it works and not printing log
|
||||||
-- remote commands because it can be flaky
|
-- remote commands because it can be flaky
|
||||||
VACUUM (ONLY_DATABASE_STATS);
|
VACUUM (ONLY_DATABASE_STATS);
|
||||||
|
-- Proper error when creating statistics without a name on a Citus table
|
||||||
|
-- Relevant PG commit:
|
||||||
|
-- https://github.com/postgres/postgres/commit/624aa2a13bd02dd584bb0995c883b5b93b2152df
|
||||||
|
CREATE TABLE test_stats (
|
||||||
|
a int,
|
||||||
|
b int
|
||||||
|
);
|
||||||
|
SELECT create_distributed_table('test_stats', 'a');
|
||||||
|
create_distributed_table
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
CREATE STATISTICS (dependencies) ON a, b FROM test_stats;
|
||||||
|
ERROR: cannot create statistics without a name on a Citus table
|
||||||
|
HINT: Consider specifying a name for the statistics
|
||||||
|
CREATE STATISTICS (ndistinct, dependencies) on a, b from test_stats;
|
||||||
|
ERROR: cannot create statistics without a name on a Citus table
|
||||||
|
HINT: Consider specifying a name for the statistics
|
||||||
|
CREATE STATISTICS (ndistinct, dependencies, mcv) on a, b from test_stats;
|
||||||
|
ERROR: cannot create statistics without a name on a Citus table
|
||||||
|
HINT: Consider specifying a name for the statistics
|
||||||
\set VERBOSITY terse
|
\set VERBOSITY terse
|
||||||
SET client_min_messages TO ERROR;
|
SET client_min_messages TO ERROR;
|
||||||
DROP SCHEMA pg16 CASCADE;
|
DROP SCHEMA pg16 CASCADE;
|
||||||
|
|
|
@ -45,6 +45,21 @@ SET citus.log_remote_commands TO OFF;
|
||||||
-- remote commands because it can be flaky
|
-- remote commands because it can be flaky
|
||||||
VACUUM (ONLY_DATABASE_STATS);
|
VACUUM (ONLY_DATABASE_STATS);
|
||||||
|
|
||||||
|
-- Proper error when creating statistics without a name on a Citus table
|
||||||
|
-- Relevant PG commit:
|
||||||
|
-- https://github.com/postgres/postgres/commit/624aa2a13bd02dd584bb0995c883b5b93b2152df
|
||||||
|
|
||||||
|
CREATE TABLE test_stats (
|
||||||
|
a int,
|
||||||
|
b int
|
||||||
|
);
|
||||||
|
|
||||||
|
SELECT create_distributed_table('test_stats', 'a');
|
||||||
|
|
||||||
|
CREATE STATISTICS (dependencies) ON a, b FROM test_stats;
|
||||||
|
CREATE STATISTICS (ndistinct, dependencies) on a, b from test_stats;
|
||||||
|
CREATE STATISTICS (ndistinct, dependencies, mcv) on a, b from test_stats;
|
||||||
|
|
||||||
\set VERBOSITY terse
|
\set VERBOSITY terse
|
||||||
SET client_min_messages TO ERROR;
|
SET client_min_messages TO ERROR;
|
||||||
DROP SCHEMA pg16 CASCADE;
|
DROP SCHEMA pg16 CASCADE;
|
||||||
|
|
Loading…
Reference in New Issue