Extended statistics on expressions - PG14 a4d75c8 (#5224)

(cherry picked from commit 1268415f123b5d99cfacfe207c8670240efc1c00)
pull/5209/head
Ahmet Gedemenli 2021-09-01 12:15:13 +03:00 committed by Sait Talha Nisanci
parent 113d5d6615
commit 1ff7186d20
3 changed files with 30 additions and 1 deletions

View File

@ -241,6 +241,14 @@ AppendColumnNames(StringInfo buf, CreateStatsStmt *stmt)
foreach_ptr(column, stmt->exprs)
{
if (!column->name)
{
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg(
"only simple column references are allowed in CREATE STATISTICS")));
}
const char *columnName = quote_identifier(column->name);
appendStringInfoString(buf, columnName);

View File

@ -142,6 +142,20 @@ DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
-- should error saying table space doesn't exist
reindex(TABLESPACE test_tablespace1) index idx;
ERROR: tablespace "test_tablespace1" does not exist
reset citus.log_remote_commands;
-- CREATE STATISTICS only allow simple column references
CREATE TABLE tbl1(a timestamp, b int);
SELECT create_distributed_table('tbl1','a');
create_distributed_table
---------------------------------------------------------------------
(1 row)
-- the last one should error out
CREATE STATISTICS s1 (dependencies) ON a, b FROM tbl1;
CREATE STATISTICS s2 (mcv) ON a, b FROM tbl1;
CREATE STATISTICS s3 (ndistinct) ON date_trunc('month', a), date_trunc('day', a) FROM tbl1;
ERROR: only simple column references are allowed in CREATE STATISTICS
set citus.log_remote_commands to off;
-- error out in case of ALTER TABLE .. DETACH PARTITION .. CONCURRENTLY/FINALIZE
-- only if it's a distributed partitioned table

View File

@ -37,6 +37,14 @@ reindex(TABLESPACE test_tablespace, verbose false) index idx ;
reindex(verbose, TABLESPACE test_tablespace) index idx ;
-- should error saying table space doesn't exist
reindex(TABLESPACE test_tablespace1) index idx;
reset citus.log_remote_commands;
-- CREATE STATISTICS only allow simple column references
CREATE TABLE tbl1(a timestamp, b int);
SELECT create_distributed_table('tbl1','a');
-- the last one should error out
CREATE STATISTICS s1 (dependencies) ON a, b FROM tbl1;
CREATE STATISTICS s2 (mcv) ON a, b FROM tbl1;
CREATE STATISTICS s3 (ndistinct) ON date_trunc('month', a), date_trunc('day', a) FROM tbl1;
set citus.log_remote_commands to off;
-- error out in case of ALTER TABLE .. DETACH PARTITION .. CONCURRENTLY/FINALIZE
@ -73,4 +81,3 @@ SELECT attname || ' ' || attcompression FROM pg_attribute WHERE attrelid::regcla
set client_min_messages to error;
drop schema pg14 cascade;