mirror of https://github.com/citusdata/citus.git
Rewrite AppendColumnNames for Pg14
Postgres changed stats expression types as of PG14. Hence we needed to write the AppendColumnNames method. Also they removed the error on PG side so we remove it as well. Relevant commits on pg14: a4d75c86bf15220df22de0a92c819ecef9db3849 388e75ad33489b77cfb9a8590a91e9287d8fb960pull/5209/head
parent
d1c0403055
commit
2656d885f9
|
@ -12,6 +12,8 @@
|
|||
*/
|
||||
#include "postgres.h"
|
||||
|
||||
#include "distributed/pg_version_constants.h"
|
||||
|
||||
#include "distributed/citus_ruleutils.h"
|
||||
#include "distributed/deparser.h"
|
||||
#include "distributed/listutils.h"
|
||||
|
@ -231,7 +233,25 @@ AppendStatTypes(StringInfo buf, CreateStatsStmt *stmt)
|
|||
appendStringInfoString(buf, ")");
|
||||
}
|
||||
|
||||
#if PG_VERSION_NUM >= PG_VERSION_14
|
||||
static void
|
||||
AppendColumnNames(StringInfo buf, CreateStatsStmt *stmt)
|
||||
{
|
||||
StatsElem *column = NULL;
|
||||
|
||||
foreach_ptr(column, stmt->exprs)
|
||||
{
|
||||
const char *columnName = quote_identifier(column->name);
|
||||
|
||||
appendStringInfoString(buf, columnName);
|
||||
|
||||
if (column != llast(stmt->exprs))
|
||||
{
|
||||
appendStringInfoString(buf, ", ");
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
static void
|
||||
AppendColumnNames(StringInfo buf, CreateStatsStmt *stmt)
|
||||
{
|
||||
|
@ -257,7 +277,7 @@ AppendColumnNames(StringInfo buf, CreateStatsStmt *stmt)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static void
|
||||
AppendTableName(StringInfo buf, CreateStatsStmt *stmt)
|
||||
|
|
|
@ -99,12 +99,7 @@ SELECT create_distributed_table('test','x');
|
|||
|
||||
(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
|
||||
SELECT stxname
|
||||
FROM pg_statistic_ext
|
||||
|
|
|
@ -79,10 +79,7 @@ SELECT create_distributed_table('ownertest','a');
|
|||
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
|
||||
SELECT stxname
|
||||
|
|
Loading…
Reference in New Issue