mirror of https://github.com/citusdata/citus.git
Remove PG_VERSION_NUM >= 16 and PG_VERSION_NUM < 16
parent
85ef323368
commit
511c10fcc1
|
|
@ -25,9 +25,7 @@
|
||||||
#include <lz4.h>
|
#include <lz4.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
#include "varatt.h"
|
#include "varatt.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#if HAVE_LIBZSTD
|
#if HAVE_LIBZSTD
|
||||||
#include <zstd.h>
|
#include <zstd.h>
|
||||||
|
|
|
||||||
|
|
@ -39,10 +39,8 @@
|
||||||
#include "optimizer/paths.h"
|
#include "optimizer/paths.h"
|
||||||
#include "optimizer/plancat.h"
|
#include "optimizer/plancat.h"
|
||||||
#include "optimizer/restrictinfo.h"
|
#include "optimizer/restrictinfo.h"
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
#include "parser/parse_relation.h"
|
#include "parser/parse_relation.h"
|
||||||
#include "parser/parsetree.h"
|
#include "parser/parsetree.h"
|
||||||
#endif
|
|
||||||
#include "utils/builtins.h"
|
#include "utils/builtins.h"
|
||||||
#include "utils/lsyscache.h"
|
#include "utils/lsyscache.h"
|
||||||
#include "utils/relcache.h"
|
#include "utils/relcache.h"
|
||||||
|
|
@ -140,9 +138,7 @@ static List * set_deparse_context_planstate(List *dpcontext, Node *node,
|
||||||
/* other helpers */
|
/* other helpers */
|
||||||
static List * ColumnarVarNeeded(ColumnarScanState *columnarScanState);
|
static List * ColumnarVarNeeded(ColumnarScanState *columnarScanState);
|
||||||
static Bitmapset * ColumnarAttrNeeded(ScanState *ss);
|
static Bitmapset * ColumnarAttrNeeded(ScanState *ss);
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
static Bitmapset * fixup_inherited_columns(Oid parentId, Oid childId, Bitmapset *columns);
|
static Bitmapset * fixup_inherited_columns(Oid parentId, Oid childId, Bitmapset *columns);
|
||||||
#endif
|
|
||||||
|
|
||||||
/* saved hook value in case of unload */
|
/* saved hook value in case of unload */
|
||||||
static set_rel_pathlist_hook_type PreviousSetRelPathlistHook = NULL;
|
static set_rel_pathlist_hook_type PreviousSetRelPathlistHook = NULL;
|
||||||
|
|
@ -1063,9 +1059,7 @@ FindCandidateRelids(PlannerInfo *root, RelOptInfo *rel, List *joinClauses)
|
||||||
* For the relevant PG16 commit requiring this addition:
|
* For the relevant PG16 commit requiring this addition:
|
||||||
* postgres/postgres@2489d76
|
* postgres/postgres@2489d76
|
||||||
*/
|
*/
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
candidateRelids = bms_del_members(candidateRelids, root->outer_join_rels);
|
candidateRelids = bms_del_members(candidateRelids, root->outer_join_rels);
|
||||||
#endif
|
|
||||||
|
|
||||||
return candidateRelids;
|
return candidateRelids;
|
||||||
}
|
}
|
||||||
|
|
@ -1394,7 +1388,6 @@ AddColumnarScanPath(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte,
|
||||||
}
|
}
|
||||||
|
|
||||||
int numberOfColumnsRead = 0;
|
int numberOfColumnsRead = 0;
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
if (rte->perminfoindex > 0)
|
if (rte->perminfoindex > 0)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
|
@ -1426,9 +1419,6 @@ AddColumnarScanPath(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte,
|
||||||
perminfo->
|
perminfo->
|
||||||
selectedCols));
|
selectedCols));
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
numberOfColumnsRead = bms_num_members(rte->selectedCols);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int numberOfClausesPushed = list_length(allClauses);
|
int numberOfClausesPushed = list_length(allClauses);
|
||||||
|
|
||||||
|
|
@ -1449,8 +1439,6 @@ AddColumnarScanPath(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* fixup_inherited_columns
|
* fixup_inherited_columns
|
||||||
*
|
*
|
||||||
|
|
@ -1509,9 +1497,6 @@ fixup_inherited_columns(Oid parentId, Oid childId, Bitmapset *columns)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CostColumnarScan calculates the cost of scanning the columnar table. The
|
* CostColumnarScan calculates the cost of scanning the columnar table. The
|
||||||
* cost is estimated by using all stripe metadata to estimate based on the
|
* cost is estimated by using all stripe metadata to estimate based on the
|
||||||
|
|
|
||||||
|
|
@ -62,13 +62,9 @@
|
||||||
|
|
||||||
#include "distributed/listutils.h"
|
#include "distributed/listutils.h"
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
#include "parser/parse_relation.h"
|
#include "parser/parse_relation.h"
|
||||||
#include "storage/relfilelocator.h"
|
#include "storage/relfilelocator.h"
|
||||||
#include "utils/relfilenumbermap.h"
|
#include "utils/relfilenumbermap.h"
|
||||||
#else
|
|
||||||
#include "utils/relfilenodemap.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define COLUMNAR_RELOPTION_NAMESPACE "columnar"
|
#define COLUMNAR_RELOPTION_NAMESPACE "columnar"
|
||||||
#define SLOW_METADATA_ACCESS_WARNING \
|
#define SLOW_METADATA_ACCESS_WARNING \
|
||||||
|
|
@ -1789,10 +1785,8 @@ create_estate_for_relation(Relation rel)
|
||||||
rte->rellockmode = AccessShareLock;
|
rte->rellockmode = AccessShareLock;
|
||||||
|
|
||||||
/* Prepare permission info on PG 16+ */
|
/* Prepare permission info on PG 16+ */
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
List *perminfos = NIL;
|
List *perminfos = NIL;
|
||||||
addRTEPermissionInfo(&perminfos, rte);
|
addRTEPermissionInfo(&perminfos, rte);
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Initialize the range table, with the right signature for each PG version */
|
/* Initialize the range table, with the right signature for each PG version */
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_18
|
#if PG_VERSION_NUM >= PG_VERSION_18
|
||||||
|
|
@ -1804,7 +1798,7 @@ create_estate_for_relation(Relation rel)
|
||||||
perminfos,
|
perminfos,
|
||||||
NULL /* unpruned_relids: not used by columnar */
|
NULL /* unpruned_relids: not used by columnar */
|
||||||
);
|
);
|
||||||
#elif PG_VERSION_NUM >= PG_VERSION_16
|
#else
|
||||||
|
|
||||||
/* PG 16–17: three-arg signature (permInfos) */
|
/* PG 16–17: three-arg signature (permInfos) */
|
||||||
ExecInitRangeTable(
|
ExecInitRangeTable(
|
||||||
|
|
@ -1812,13 +1806,6 @@ create_estate_for_relation(Relation rel)
|
||||||
list_make1(rte),
|
list_make1(rte),
|
||||||
perminfos
|
perminfos
|
||||||
);
|
);
|
||||||
#else
|
|
||||||
|
|
||||||
/* PG 15: two-arg signature */
|
|
||||||
ExecInitRangeTable(
|
|
||||||
estate,
|
|
||||||
list_make1(rte)
|
|
||||||
);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
estate->es_output_cid = GetCurrentCommandId(true);
|
estate->es_output_cid = GetCurrentCommandId(true);
|
||||||
|
|
|
||||||
|
|
@ -169,11 +169,7 @@ ColumnarStorageInit(SMgrRelation srel, uint64 storageId)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create two pages */
|
/* create two pages */
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
PGIOAlignedBlock block;
|
PGIOAlignedBlock block;
|
||||||
#else
|
|
||||||
PGAlignedBlock block;
|
|
||||||
#endif
|
|
||||||
Page page = block.data;
|
Page page = block.data;
|
||||||
|
|
||||||
/* write metapage */
|
/* write metapage */
|
||||||
|
|
|
||||||
|
|
@ -1098,7 +1098,6 @@ columnar_vacuum_rel(Relation rel, VacuumParams *params,
|
||||||
List *indexList = RelationGetIndexList(rel);
|
List *indexList = RelationGetIndexList(rel);
|
||||||
int nindexes = list_length(indexList);
|
int nindexes = list_length(indexList);
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
struct VacuumCutoffs cutoffs;
|
struct VacuumCutoffs cutoffs;
|
||||||
vacuum_get_cutoffs(rel, params, &cutoffs);
|
vacuum_get_cutoffs(rel, params, &cutoffs);
|
||||||
|
|
||||||
|
|
@ -1140,41 +1139,6 @@ columnar_vacuum_rel(Relation rel, VacuumParams *params,
|
||||||
false);
|
false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else
|
|
||||||
TransactionId oldestXmin;
|
|
||||||
TransactionId freezeLimit;
|
|
||||||
MultiXactId multiXactCutoff;
|
|
||||||
|
|
||||||
/* initialize xids */
|
|
||||||
TransactionId xidFullScanLimit;
|
|
||||||
MultiXactId mxactFullScanLimit;
|
|
||||||
vacuum_set_xid_limits(rel,
|
|
||||||
params->freeze_min_age,
|
|
||||||
params->freeze_table_age,
|
|
||||||
params->multixact_freeze_min_age,
|
|
||||||
params->multixact_freeze_table_age,
|
|
||||||
&oldestXmin, &freezeLimit, &xidFullScanLimit,
|
|
||||||
&multiXactCutoff, &mxactFullScanLimit);
|
|
||||||
|
|
||||||
Assert(TransactionIdPrecedesOrEquals(freezeLimit, oldestXmin));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Columnar storage doesn't hold any transaction IDs, so we can always
|
|
||||||
* just advance to the most aggressive value.
|
|
||||||
*/
|
|
||||||
TransactionId newRelFrozenXid = oldestXmin;
|
|
||||||
MultiXactId newRelminMxid = multiXactCutoff;
|
|
||||||
|
|
||||||
double new_live_tuples = ColumnarTableTupleCount(rel);
|
|
||||||
|
|
||||||
/* all visible pages are always 0 */
|
|
||||||
BlockNumber new_rel_allvisible = 0;
|
|
||||||
|
|
||||||
vac_update_relstats(rel, new_rel_pages, new_live_tuples,
|
|
||||||
new_rel_allvisible, nindexes > 0,
|
|
||||||
newRelFrozenXid, newRelminMxid, false);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_18
|
#if PG_VERSION_NUM >= PG_VERSION_18
|
||||||
pgstat_report_vacuum(RelationGetRelid(rel),
|
pgstat_report_vacuum(RelationGetRelid(rel),
|
||||||
rel->rd_rel->relisshared,
|
rel->rd_rel->relisshared,
|
||||||
|
|
@ -2544,11 +2508,7 @@ static const TableAmRoutine columnar_am_methods = {
|
||||||
.tuple_lock = columnar_tuple_lock,
|
.tuple_lock = columnar_tuple_lock,
|
||||||
.finish_bulk_insert = columnar_finish_bulk_insert,
|
.finish_bulk_insert = columnar_finish_bulk_insert,
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
.relation_set_new_filelocator = columnar_relation_set_new_filelocator,
|
.relation_set_new_filelocator = columnar_relation_set_new_filelocator,
|
||||||
#else
|
|
||||||
.relation_set_new_filenode = columnar_relation_set_new_filelocator,
|
|
||||||
#endif
|
|
||||||
.relation_nontransactional_truncate = columnar_relation_nontransactional_truncate,
|
.relation_nontransactional_truncate = columnar_relation_nontransactional_truncate,
|
||||||
.relation_copy_data = columnar_relation_copy_data,
|
.relation_copy_data = columnar_relation_copy_data,
|
||||||
.relation_copy_for_cluster = columnar_relation_copy_for_cluster,
|
.relation_copy_for_cluster = columnar_relation_copy_for_cluster,
|
||||||
|
|
|
||||||
|
|
@ -35,12 +35,8 @@
|
||||||
#include "columnar/columnar_storage.h"
|
#include "columnar/columnar_storage.h"
|
||||||
#include "columnar/columnar_version_compat.h"
|
#include "columnar/columnar_version_compat.h"
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
#include "storage/relfilelocator.h"
|
#include "storage/relfilelocator.h"
|
||||||
#include "utils/relfilenumbermap.h"
|
#include "utils/relfilenumbermap.h"
|
||||||
#else
|
|
||||||
#include "utils/relfilenodemap.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct ColumnarWriteState
|
struct ColumnarWriteState
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1476,20 +1476,10 @@ InsertMetadataForCitusLocalTable(Oid citusLocalTableId, uint64 shardId,
|
||||||
static void
|
static void
|
||||||
FinalizeCitusLocalTableCreation(Oid relationId)
|
FinalizeCitusLocalTableCreation(Oid relationId)
|
||||||
{
|
{
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PG16+ supports truncate triggers on foreign tables
|
* PG16+ supports truncate triggers on foreign tables
|
||||||
*/
|
*/
|
||||||
if (RegularTable(relationId) || IsForeignTable(relationId))
|
if (RegularTable(relationId) || IsForeignTable(relationId))
|
||||||
#else
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If it is a foreign table, then skip creating citus truncate trigger
|
|
||||||
* as foreign tables do not support truncate triggers.
|
|
||||||
*/
|
|
||||||
if (RegularTable(relationId))
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
CreateTruncateTrigger(relationId);
|
CreateTruncateTrigger(relationId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,6 @@ CreateCollationDDLInternal(Oid collationId, Oid *collowner, char **quotedCollati
|
||||||
pfree(collctype);
|
pfree(collctype);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
char *collicurules = NULL;
|
char *collicurules = NULL;
|
||||||
datum = SysCacheGetAttr(COLLOID, heapTuple, Anum_pg_collation_collicurules, &isnull);
|
datum = SysCacheGetAttr(COLLOID, heapTuple, Anum_pg_collation_collicurules, &isnull);
|
||||||
if (!isnull)
|
if (!isnull)
|
||||||
|
|
@ -170,7 +169,6 @@ CreateCollationDDLInternal(Oid collationId, Oid *collowner, char **quotedCollati
|
||||||
appendStringInfo(&collationNameDef, ", rules = %s",
|
appendStringInfo(&collationNameDef, ", rules = %s",
|
||||||
quote_literal_cstr(collicurules));
|
quote_literal_cstr(collicurules));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (!collisdeterministic)
|
if (!collisdeterministic)
|
||||||
{
|
{
|
||||||
appendStringInfoString(&collationNameDef, ", deterministic = false");
|
appendStringInfoString(&collationNameDef, ", deterministic = false");
|
||||||
|
|
|
||||||
|
|
@ -1271,17 +1271,10 @@ CreateCitusTable(Oid relationId, CitusTableType tableType,
|
||||||
colocationId, citusTableParams.replicationModel,
|
colocationId, citusTableParams.replicationModel,
|
||||||
autoConverted);
|
autoConverted);
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PG16+ supports truncate triggers on foreign tables
|
* PG16+ supports truncate triggers on foreign tables
|
||||||
*/
|
*/
|
||||||
if (RegularTable(relationId) || IsForeignTable(relationId))
|
if (RegularTable(relationId) || IsForeignTable(relationId))
|
||||||
#else
|
|
||||||
|
|
||||||
/* foreign tables do not support TRUNCATE trigger */
|
|
||||||
if (RegularTable(relationId))
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
CreateTruncateTrigger(relationId);
|
CreateTruncateTrigger(relationId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -81,10 +81,7 @@ typedef struct DatabaseCollationInfo
|
||||||
char *datctype;
|
char *datctype;
|
||||||
char *daticulocale;
|
char *daticulocale;
|
||||||
char *datcollversion;
|
char *datcollversion;
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
char *daticurules;
|
char *daticurules;
|
||||||
#endif
|
|
||||||
} DatabaseCollationInfo;
|
} DatabaseCollationInfo;
|
||||||
|
|
||||||
static char * GenerateCreateDatabaseStatementFromPgDatabase(Form_pg_database
|
static char * GenerateCreateDatabaseStatementFromPgDatabase(Form_pg_database
|
||||||
|
|
@ -853,14 +850,12 @@ GetDatabaseCollation(Oid dbOid)
|
||||||
info.datcollversion = TextDatumGetCString(collverDatum);
|
info.datcollversion = TextDatumGetCString(collverDatum);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
Datum icurulesDatum = heap_getattr(tup, Anum_pg_database_daticurules, tupdesc,
|
Datum icurulesDatum = heap_getattr(tup, Anum_pg_database_daticurules, tupdesc,
|
||||||
&isNull);
|
&isNull);
|
||||||
if (!isNull)
|
if (!isNull)
|
||||||
{
|
{
|
||||||
info.daticurules = TextDatumGetCString(icurulesDatum);
|
info.daticurules = TextDatumGetCString(icurulesDatum);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
table_close(rel, AccessShareLock);
|
table_close(rel, AccessShareLock);
|
||||||
heap_freetuple(tup);
|
heap_freetuple(tup);
|
||||||
|
|
@ -954,13 +949,11 @@ GenerateCreateDatabaseStatementFromPgDatabase(Form_pg_database databaseForm)
|
||||||
quote_identifier(GetLocaleProviderString(
|
quote_identifier(GetLocaleProviderString(
|
||||||
databaseForm->datlocprovider)));
|
databaseForm->datlocprovider)));
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
if (collInfo.daticurules != NULL)
|
if (collInfo.daticurules != NULL)
|
||||||
{
|
{
|
||||||
appendStringInfo(&str, " ICU_RULES = %s", quote_identifier(
|
appendStringInfo(&str, " ICU_RULES = %s", quote_identifier(
|
||||||
collInfo.daticurules));
|
collInfo.daticurules));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
return str.data;
|
return str.data;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,10 +52,7 @@
|
||||||
#include "distributed/resource_lock.h"
|
#include "distributed/resource_lock.h"
|
||||||
#include "distributed/version_compat.h"
|
#include "distributed/version_compat.h"
|
||||||
#include "distributed/worker_manager.h"
|
#include "distributed/worker_manager.h"
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
#include "catalog/pg_namespace.h"
|
#include "catalog/pg_namespace.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* Local functions forward declarations for helper functions */
|
/* Local functions forward declarations for helper functions */
|
||||||
|
|
|
||||||
|
|
@ -110,10 +110,7 @@
|
||||||
#include "distributed/transmit.h"
|
#include "distributed/transmit.h"
|
||||||
#include "distributed/version_compat.h"
|
#include "distributed/version_compat.h"
|
||||||
#include "distributed/worker_protocol.h"
|
#include "distributed/worker_protocol.h"
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
#include "distributed/relation_utils.h"
|
#include "distributed/relation_utils.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* constant used in binary protocol */
|
/* constant used in binary protocol */
|
||||||
|
|
@ -3251,12 +3248,8 @@ CheckCopyPermissions(CopyStmt *copyStatement)
|
||||||
RangeTblEntry *rte = (RangeTblEntry*) linitial(range_table);
|
RangeTblEntry *rte = (RangeTblEntry*) linitial(range_table);
|
||||||
tupDesc = RelationGetDescr(rel);
|
tupDesc = RelationGetDescr(rel);
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
/* create permission info for rte */
|
/* create permission info for rte */
|
||||||
RTEPermissionInfo *perminfo = GetFilledPermissionInfo(rel->rd_id, rte->inh, required_access);
|
RTEPermissionInfo *perminfo = GetFilledPermissionInfo(rel->rd_id, rte->inh, required_access);
|
||||||
#else
|
|
||||||
rte->requiredPerms = required_access;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
attnums = CopyGetAttnums(tupDesc, rel, copyStatement->attlist);
|
attnums = CopyGetAttnums(tupDesc, rel, copyStatement->attlist);
|
||||||
foreach(cur, attnums)
|
foreach(cur, attnums)
|
||||||
|
|
@ -3265,29 +3258,17 @@ CheckCopyPermissions(CopyStmt *copyStatement)
|
||||||
|
|
||||||
if (is_from)
|
if (is_from)
|
||||||
{
|
{
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
perminfo->insertedCols = bms_add_member(perminfo->insertedCols, attno);
|
perminfo->insertedCols = bms_add_member(perminfo->insertedCols, attno);
|
||||||
#else
|
|
||||||
rte->insertedCols = bms_add_member(rte->insertedCols, attno);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
perminfo->selectedCols = bms_add_member(perminfo->selectedCols, attno);
|
perminfo->selectedCols = bms_add_member(perminfo->selectedCols, attno);
|
||||||
#else
|
|
||||||
rte->selectedCols = bms_add_member(rte->selectedCols, attno);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
/* link rte to its permission info then check permissions */
|
/* link rte to its permission info then check permissions */
|
||||||
rte->perminfoindex = 1;
|
rte->perminfoindex = 1;
|
||||||
ExecCheckPermissions(list_make1(rte), list_make1(perminfo), true);
|
ExecCheckPermissions(list_make1(rte), list_make1(perminfo), true);
|
||||||
#else
|
|
||||||
ExecCheckRTPerms(range_table, true);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* TODO: Perform RLS checks once supported */
|
/* TODO: Perform RLS checks once supported */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -851,12 +851,8 @@ GenerateGrantRoleStmtsFromOptions(RoleSpec *roleSpec, List *options)
|
||||||
|
|
||||||
if (strcmp(option->defname, "adminmembers") == 0)
|
if (strcmp(option->defname, "adminmembers") == 0)
|
||||||
{
|
{
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
DefElem *opt = makeDefElem("admin", (Node *) makeBoolean(true), -1);
|
DefElem *opt = makeDefElem("admin", (Node *) makeBoolean(true), -1);
|
||||||
grantRoleStmt->opt = list_make1(opt);
|
grantRoleStmt->opt = list_make1(opt);
|
||||||
#else
|
|
||||||
grantRoleStmt->admin_opt = true;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stmts = lappend(stmts, grantRoleStmt);
|
stmts = lappend(stmts, grantRoleStmt);
|
||||||
|
|
@ -916,8 +912,6 @@ GenerateGrantRoleStmtsOfRole(Oid roleid)
|
||||||
grantorRole->rolename = GetUserNameFromId(membership->grantor, false);
|
grantorRole->rolename = GetUserNameFromId(membership->grantor, false);
|
||||||
grantRoleStmt->grantor = grantorRole;
|
grantRoleStmt->grantor = grantorRole;
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
|
|
||||||
/* inherit option is always included */
|
/* inherit option is always included */
|
||||||
DefElem *inherit_opt;
|
DefElem *inherit_opt;
|
||||||
if (membership->inherit_option)
|
if (membership->inherit_option)
|
||||||
|
|
@ -943,9 +937,6 @@ GenerateGrantRoleStmtsOfRole(Oid roleid)
|
||||||
DefElem *set_opt = makeDefElem("set", (Node *) makeBoolean(false), -1);
|
DefElem *set_opt = makeDefElem("set", (Node *) makeBoolean(false), -1);
|
||||||
grantRoleStmt->opt = lappend(grantRoleStmt->opt, set_opt);
|
grantRoleStmt->opt = lappend(grantRoleStmt->opt, set_opt);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
grantRoleStmt->admin_opt = membership->admin_option;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
stmts = lappend(stmts, grantRoleStmt);
|
stmts = lappend(stmts, grantRoleStmt);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,7 @@ typedef struct CitusVacuumParams
|
||||||
VacOptValue truncate;
|
VacOptValue truncate;
|
||||||
VacOptValue index_cleanup;
|
VacOptValue index_cleanup;
|
||||||
int nworkers;
|
int nworkers;
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
int ring_size;
|
int ring_size;
|
||||||
#endif
|
|
||||||
} CitusVacuumParams;
|
} CitusVacuumParams;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -353,19 +351,12 @@ DeparseVacuumStmtPrefix(CitusVacuumParams vacuumParams)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if no flags remain, exit early */
|
/* if no flags remain, exit early */
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
if (vacuumFlags & VACOPT_PROCESS_TOAST &&
|
if (vacuumFlags & VACOPT_PROCESS_TOAST &&
|
||||||
vacuumFlags & VACOPT_PROCESS_MAIN)
|
vacuumFlags & VACOPT_PROCESS_MAIN)
|
||||||
{
|
{
|
||||||
/* process toast and process main are true by default */
|
/* process toast and process main are true by default */
|
||||||
if (((vacuumFlags & ~VACOPT_PROCESS_TOAST) & ~VACOPT_PROCESS_MAIN) == 0 &&
|
if (((vacuumFlags & ~VACOPT_PROCESS_TOAST) & ~VACOPT_PROCESS_MAIN) == 0 &&
|
||||||
vacuumParams.ring_size == -1 &&
|
vacuumParams.ring_size == -1 &&
|
||||||
#else
|
|
||||||
if (vacuumFlags & VACOPT_PROCESS_TOAST)
|
|
||||||
{
|
|
||||||
/* process toast is true by default */
|
|
||||||
if ((vacuumFlags & ~VACOPT_PROCESS_TOAST) == 0 &&
|
|
||||||
#endif
|
|
||||||
vacuumParams.truncate == VACOPTVALUE_UNSPECIFIED &&
|
vacuumParams.truncate == VACOPTVALUE_UNSPECIFIED &&
|
||||||
vacuumParams.index_cleanup == VACOPTVALUE_UNSPECIFIED &&
|
vacuumParams.index_cleanup == VACOPTVALUE_UNSPECIFIED &&
|
||||||
vacuumParams.nworkers == VACUUM_PARALLEL_NOTSET
|
vacuumParams.nworkers == VACUUM_PARALLEL_NOTSET
|
||||||
|
|
@ -413,7 +404,6 @@ DeparseVacuumStmtPrefix(CitusVacuumParams vacuumParams)
|
||||||
appendStringInfoString(vacuumPrefix, "PROCESS_TOAST FALSE,");
|
appendStringInfoString(vacuumPrefix, "PROCESS_TOAST FALSE,");
|
||||||
}
|
}
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
if (!(vacuumFlags & VACOPT_PROCESS_MAIN))
|
if (!(vacuumFlags & VACOPT_PROCESS_MAIN))
|
||||||
{
|
{
|
||||||
appendStringInfoString(vacuumPrefix, "PROCESS_MAIN FALSE,");
|
appendStringInfoString(vacuumPrefix, "PROCESS_MAIN FALSE,");
|
||||||
|
|
@ -433,7 +423,6 @@ DeparseVacuumStmtPrefix(CitusVacuumParams vacuumParams)
|
||||||
{
|
{
|
||||||
appendStringInfo(vacuumPrefix, "BUFFER_USAGE_LIMIT %d,", vacuumParams.ring_size);
|
appendStringInfo(vacuumPrefix, "BUFFER_USAGE_LIMIT %d,", vacuumParams.ring_size);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (vacuumParams.truncate != VACOPTVALUE_UNSPECIFIED)
|
if (vacuumParams.truncate != VACOPTVALUE_UNSPECIFIED)
|
||||||
{
|
{
|
||||||
|
|
@ -537,13 +526,10 @@ VacuumStmtParams(VacuumStmt *vacstmt)
|
||||||
bool full = false;
|
bool full = false;
|
||||||
bool disable_page_skipping = false;
|
bool disable_page_skipping = false;
|
||||||
bool process_toast = true;
|
bool process_toast = true;
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
bool process_main = true;
|
bool process_main = true;
|
||||||
bool skip_database_stats = false;
|
bool skip_database_stats = false;
|
||||||
bool only_database_stats = false;
|
bool only_database_stats = false;
|
||||||
params.ring_size = -1;
|
params.ring_size = -1;
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Set default value */
|
/* Set default value */
|
||||||
params.index_cleanup = VACOPTVALUE_UNSPECIFIED;
|
params.index_cleanup = VACOPTVALUE_UNSPECIFIED;
|
||||||
|
|
@ -563,13 +549,11 @@ VacuumStmtParams(VacuumStmt *vacstmt)
|
||||||
{
|
{
|
||||||
skip_locked = defGetBoolean(opt);
|
skip_locked = defGetBoolean(opt);
|
||||||
}
|
}
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
else if (strcmp(opt->defname, "buffer_usage_limit") == 0)
|
else if (strcmp(opt->defname, "buffer_usage_limit") == 0)
|
||||||
{
|
{
|
||||||
char *vac_buffer_size = defGetString(opt);
|
char *vac_buffer_size = defGetString(opt);
|
||||||
parse_int(vac_buffer_size, ¶ms.ring_size, GUC_UNIT_KB, NULL);
|
parse_int(vac_buffer_size, ¶ms.ring_size, GUC_UNIT_KB, NULL);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
else if (!vacstmt->is_vacuumcmd)
|
else if (!vacstmt->is_vacuumcmd)
|
||||||
{
|
{
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
|
|
@ -594,7 +578,6 @@ VacuumStmtParams(VacuumStmt *vacstmt)
|
||||||
{
|
{
|
||||||
disable_page_skipping = defGetBoolean(opt);
|
disable_page_skipping = defGetBoolean(opt);
|
||||||
}
|
}
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
else if (strcmp(opt->defname, "process_main") == 0)
|
else if (strcmp(opt->defname, "process_main") == 0)
|
||||||
{
|
{
|
||||||
process_main = defGetBoolean(opt);
|
process_main = defGetBoolean(opt);
|
||||||
|
|
@ -607,7 +590,6 @@ VacuumStmtParams(VacuumStmt *vacstmt)
|
||||||
{
|
{
|
||||||
only_database_stats = defGetBoolean(opt);
|
only_database_stats = defGetBoolean(opt);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
else if (strcmp(opt->defname, "process_toast") == 0)
|
else if (strcmp(opt->defname, "process_toast") == 0)
|
||||||
{
|
{
|
||||||
process_toast = defGetBoolean(opt);
|
process_toast = defGetBoolean(opt);
|
||||||
|
|
@ -678,11 +660,9 @@ VacuumStmtParams(VacuumStmt *vacstmt)
|
||||||
(analyze ? VACOPT_ANALYZE : 0) |
|
(analyze ? VACOPT_ANALYZE : 0) |
|
||||||
(freeze ? VACOPT_FREEZE : 0) |
|
(freeze ? VACOPT_FREEZE : 0) |
|
||||||
(full ? VACOPT_FULL : 0) |
|
(full ? VACOPT_FULL : 0) |
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
(process_main ? VACOPT_PROCESS_MAIN : 0) |
|
(process_main ? VACOPT_PROCESS_MAIN : 0) |
|
||||||
(skip_database_stats ? VACOPT_SKIP_DATABASE_STATS : 0) |
|
(skip_database_stats ? VACOPT_SKIP_DATABASE_STATS : 0) |
|
||||||
(only_database_stats ? VACOPT_ONLY_DATABASE_STATS : 0) |
|
(only_database_stats ? VACOPT_ONLY_DATABASE_STATS : 0) |
|
||||||
#endif
|
|
||||||
(process_toast ? VACOPT_PROCESS_TOAST : 0) |
|
(process_toast ? VACOPT_PROCESS_TOAST : 0) |
|
||||||
(disable_page_skipping ? VACOPT_DISABLE_PAGE_SKIPPING : 0);
|
(disable_page_skipping ? VACOPT_DISABLE_PAGE_SKIPPING : 0);
|
||||||
return params;
|
return params;
|
||||||
|
|
|
||||||
|
|
@ -400,7 +400,6 @@ DeparseGrantRoleStmt(Node *node)
|
||||||
static void
|
static void
|
||||||
AppendRevokeAdminOptionFor(StringInfo buf, GrantRoleStmt *stmt)
|
AppendRevokeAdminOptionFor(StringInfo buf, GrantRoleStmt *stmt)
|
||||||
{
|
{
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
if (!stmt->is_grant)
|
if (!stmt->is_grant)
|
||||||
{
|
{
|
||||||
DefElem *opt = NULL;
|
DefElem *opt = NULL;
|
||||||
|
|
@ -423,12 +422,6 @@ AppendRevokeAdminOptionFor(StringInfo buf, GrantRoleStmt *stmt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if (!stmt->is_grant && stmt->admin_opt)
|
|
||||||
{
|
|
||||||
appendStringInfo(buf, "ADMIN OPTION FOR ");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -437,7 +430,6 @@ AppendGrantWithAdminOption(StringInfo buf, GrantRoleStmt *stmt)
|
||||||
{
|
{
|
||||||
if (stmt->is_grant)
|
if (stmt->is_grant)
|
||||||
{
|
{
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
int opt_count = 0;
|
int opt_count = 0;
|
||||||
DefElem *opt = NULL;
|
DefElem *opt = NULL;
|
||||||
foreach_declared_ptr(opt, stmt->opt)
|
foreach_declared_ptr(opt, stmt->opt)
|
||||||
|
|
@ -463,12 +455,6 @@ AppendGrantWithAdminOption(StringInfo buf, GrantRoleStmt *stmt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if (stmt->admin_opt)
|
|
||||||
{
|
|
||||||
appendStringInfo(buf, " WITH ADMIN OPTION");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -88,10 +88,6 @@
|
||||||
#include "distributed/worker_manager.h"
|
#include "distributed/worker_manager.h"
|
||||||
#include "distributed/worker_protocol.h"
|
#include "distributed/worker_protocol.h"
|
||||||
|
|
||||||
#if PG_VERSION_NUM < PG_VERSION_16
|
|
||||||
#include "utils/relfilenodemap.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* user configuration */
|
/* user configuration */
|
||||||
int ReadFromSecondaries = USE_SECONDARY_NODES_NEVER;
|
int ReadFromSecondaries = USE_SECONDARY_NODES_NEVER;
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
#include "catalog/pg_constraint.h"
|
#include "catalog/pg_constraint.h"
|
||||||
#include "catalog/pg_extension.h"
|
#include "catalog/pg_extension.h"
|
||||||
#include "catalog/pg_namespace.h"
|
#include "catalog/pg_namespace.h"
|
||||||
|
#include "catalog/pg_proc_d.h"
|
||||||
#include "catalog/pg_type.h"
|
#include "catalog/pg_type.h"
|
||||||
#include "commands/extension.h"
|
#include "commands/extension.h"
|
||||||
#include "commands/sequence.h"
|
#include "commands/sequence.h"
|
||||||
|
|
@ -81,10 +82,6 @@
|
||||||
#include "distributed/worker_manager.h"
|
#include "distributed/worker_manager.h"
|
||||||
#include "distributed/worker_protocol.h"
|
#include "distributed/worker_protocol.h"
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
#include "catalog/pg_proc_d.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define DISK_SPACE_FIELDS 2
|
#define DISK_SPACE_FIELDS 2
|
||||||
|
|
||||||
/* Local functions forward declarations */
|
/* Local functions forward declarations */
|
||||||
|
|
|
||||||
|
|
@ -610,11 +610,10 @@ ConvertRteToSubqueryWithEmptyResult(RangeTblEntry *rte)
|
||||||
subquery->jointree = joinTree;
|
subquery->jointree = joinTree;
|
||||||
|
|
||||||
rte->rtekind = RTE_SUBQUERY;
|
rte->rtekind = RTE_SUBQUERY;
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
|
|
||||||
/* no permission checking for this RTE */
|
/* no permission checking for this RTE */
|
||||||
rte->perminfoindex = 0;
|
rte->perminfoindex = 0;
|
||||||
#endif
|
|
||||||
rte->subquery = subquery;
|
rte->subquery = subquery;
|
||||||
rte->alias = copyObject(rte->eref);
|
rte->alias = copyObject(rte->eref);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
#include "optimizer/plancat.h"
|
#include "optimizer/plancat.h"
|
||||||
#include "optimizer/planmain.h"
|
#include "optimizer/planmain.h"
|
||||||
#include "optimizer/planner.h"
|
#include "optimizer/planner.h"
|
||||||
|
#include "parser/parse_relation.h"
|
||||||
#include "parser/parse_type.h"
|
#include "parser/parse_type.h"
|
||||||
#include "parser/parsetree.h"
|
#include "parser/parsetree.h"
|
||||||
#include "utils/builtins.h"
|
#include "utils/builtins.h"
|
||||||
|
|
@ -71,10 +72,6 @@
|
||||||
#include "distributed/version_compat.h"
|
#include "distributed/version_compat.h"
|
||||||
#include "distributed/worker_shard_visibility.h"
|
#include "distributed/worker_shard_visibility.h"
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
#include "parser/parse_relation.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
static List *plannerRestrictionContextList = NIL;
|
static List *plannerRestrictionContextList = NIL;
|
||||||
int MultiTaskQueryLogLevel = CITUS_LOG_LEVEL_OFF; /* multi-task query log level */
|
int MultiTaskQueryLogLevel = CITUS_LOG_LEVEL_OFF; /* multi-task query log level */
|
||||||
|
|
@ -1510,7 +1507,6 @@ static void
|
||||||
ConcatenateRTablesAndPerminfos(PlannedStmt *mainPlan, PlannedStmt *concatPlan)
|
ConcatenateRTablesAndPerminfos(PlannedStmt *mainPlan, PlannedStmt *concatPlan)
|
||||||
{
|
{
|
||||||
mainPlan->rtable = list_concat(mainPlan->rtable, concatPlan->rtable);
|
mainPlan->rtable = list_concat(mainPlan->rtable, concatPlan->rtable);
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* concatPlan's range table list is concatenated to mainPlan's range table list
|
* concatPlan's range table list is concatenated to mainPlan's range table list
|
||||||
|
|
@ -1532,7 +1528,6 @@ ConcatenateRTablesAndPerminfos(PlannedStmt *mainPlan, PlannedStmt *concatPlan)
|
||||||
|
|
||||||
/* finally, concatenate perminfos as well */
|
/* finally, concatenate perminfos as well */
|
||||||
mainPlan->permInfos = list_concat(mainPlan->permInfos, concatPlan->permInfos);
|
mainPlan->permInfos = list_concat(mainPlan->permInfos, concatPlan->permInfos);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -116,24 +116,15 @@ PlannedStmt *
|
||||||
GeneratePlaceHolderPlannedStmt(Query *parse)
|
GeneratePlaceHolderPlannedStmt(Query *parse)
|
||||||
{
|
{
|
||||||
PlannedStmt *result = makeNode(PlannedStmt);
|
PlannedStmt *result = makeNode(PlannedStmt);
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
SeqScan *scanNode = makeNode(SeqScan);
|
SeqScan *scanNode = makeNode(SeqScan);
|
||||||
Plan *plan = &(scanNode->scan.plan);
|
Plan *plan = &(scanNode->scan.plan);
|
||||||
#else
|
|
||||||
Scan *scanNode = makeNode(Scan);
|
|
||||||
Plan *plan = &scanNode->plan;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
FastPathRestrictionContext fprCtxt PG_USED_FOR_ASSERTS_ONLY = { 0 };
|
FastPathRestrictionContext fprCtxt PG_USED_FOR_ASSERTS_ONLY = { 0 };
|
||||||
|
|
||||||
Assert(FastPathRouterQuery(parse, &fprCtxt));
|
Assert(FastPathRouterQuery(parse, &fprCtxt));
|
||||||
|
|
||||||
/* there is only a single relation rte */
|
/* there is only a single relation rte */
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
scanNode->scan.scanrelid = 1;
|
scanNode->scan.scanrelid = 1;
|
||||||
#else
|
|
||||||
scanNode->scanrelid = 1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
plan->targetlist =
|
plan->targetlist =
|
||||||
copyObject(FetchStatementTargetList((Node *) parse));
|
copyObject(FetchStatementTargetList((Node *) parse));
|
||||||
|
|
@ -149,9 +140,7 @@ GeneratePlaceHolderPlannedStmt(Query *parse)
|
||||||
result->stmt_len = parse->stmt_len;
|
result->stmt_len = parse->stmt_len;
|
||||||
|
|
||||||
result->rtable = copyObject(parse->rtable);
|
result->rtable = copyObject(parse->rtable);
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
result->permInfos = copyObject(parse->rteperminfos);
|
result->permInfos = copyObject(parse->rteperminfos);
|
||||||
#endif
|
|
||||||
result->planTree = (Plan *) plan;
|
result->planTree = (Plan *) plan;
|
||||||
result->hasReturning = (parse->returningList != NIL);
|
result->hasReturning = (parse->returningList != NIL);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -623,8 +623,6 @@ CreateCombineQueryForRouterPlan(DistributedPlan *distPlan)
|
||||||
combineQuery->canSetTag = true;
|
combineQuery->canSetTag = true;
|
||||||
combineQuery->rtable = list_make1(rangeTableEntry);
|
combineQuery->rtable = list_make1(rangeTableEntry);
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This part of the code is more of a sanity check for readability,
|
* This part of the code is more of a sanity check for readability,
|
||||||
* it doesn't really do anything.
|
* it doesn't really do anything.
|
||||||
|
|
@ -636,7 +634,6 @@ CreateCombineQueryForRouterPlan(DistributedPlan *distPlan)
|
||||||
Assert(rangeTableEntry->rtekind == RTE_FUNCTION &&
|
Assert(rangeTableEntry->rtekind == RTE_FUNCTION &&
|
||||||
rangeTableEntry->perminfoindex == 0);
|
rangeTableEntry->perminfoindex == 0);
|
||||||
combineQuery->rteperminfos = NIL;
|
combineQuery->rteperminfos = NIL;
|
||||||
#endif
|
|
||||||
|
|
||||||
combineQuery->targetList = targetList;
|
combineQuery->targetList = targetList;
|
||||||
combineQuery->jointree = joinTree;
|
combineQuery->jointree = joinTree;
|
||||||
|
|
@ -1599,13 +1596,10 @@ WrapSubquery(Query *subquery)
|
||||||
|
|
||||||
outerQuery->rtable = list_make1(rte_subq);
|
outerQuery->rtable = list_make1(rte_subq);
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
|
|
||||||
/* Ensure RTE_SUBQUERY has proper permission handling */
|
/* Ensure RTE_SUBQUERY has proper permission handling */
|
||||||
Assert(rte_subq->rtekind == RTE_SUBQUERY &&
|
Assert(rte_subq->rtekind == RTE_SUBQUERY &&
|
||||||
rte_subq->perminfoindex == 0);
|
rte_subq->perminfoindex == 0);
|
||||||
outerQuery->rteperminfos = NIL;
|
outerQuery->rteperminfos = NIL;
|
||||||
#endif
|
|
||||||
|
|
||||||
RangeTblRef *rtref = makeNode(RangeTblRef);
|
RangeTblRef *rtref = makeNode(RangeTblRef);
|
||||||
rtref->rtindex = 1; /* Only one RTE, so index is 1 */
|
rtref->rtindex = 1; /* Only one RTE, so index is 1 */
|
||||||
|
|
|
||||||
|
|
@ -135,9 +135,7 @@ typedef struct RangeTableEntryDetails
|
||||||
RangeTblEntry *rangeTableEntry;
|
RangeTblEntry *rangeTableEntry;
|
||||||
List *requiredAttributeNumbers;
|
List *requiredAttributeNumbers;
|
||||||
bool hasConstantFilterOnUniqueColumn;
|
bool hasConstantFilterOnUniqueColumn;
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
RTEPermissionInfo *perminfo;
|
RTEPermissionInfo *perminfo;
|
||||||
#endif
|
|
||||||
} RangeTableEntryDetails;
|
} RangeTableEntryDetails;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -208,17 +206,11 @@ RecursivelyPlanLocalTableJoins(Query *query,
|
||||||
GetPlannerRestrictionContext(context);
|
GetPlannerRestrictionContext(context);
|
||||||
|
|
||||||
List *rangeTableList = query->rtable;
|
List *rangeTableList = query->rtable;
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
List *rteperminfos = query->rteperminfos;
|
List *rteperminfos = query->rteperminfos;
|
||||||
#endif
|
|
||||||
int resultRTEIdentity = ResultRTEIdentity(query);
|
int resultRTEIdentity = ResultRTEIdentity(query);
|
||||||
ConversionCandidates *conversionCandidates =
|
ConversionCandidates *conversionCandidates =
|
||||||
CreateConversionCandidates(plannerRestrictionContext,
|
CreateConversionCandidates(plannerRestrictionContext,
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
rangeTableList, resultRTEIdentity, rteperminfos);
|
rangeTableList, resultRTEIdentity, rteperminfos);
|
||||||
#else
|
|
||||||
rangeTableList, resultRTEIdentity, NIL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ConversionChoice conversionChoise =
|
ConversionChoice conversionChoise =
|
||||||
GetConversionChoice(conversionCandidates, plannerRestrictionContext);
|
GetConversionChoice(conversionCandidates, plannerRestrictionContext);
|
||||||
|
|
@ -333,12 +325,8 @@ ConvertRTEsToSubquery(List *rangeTableEntryDetailsList, RecursivePlanningContext
|
||||||
RangeTblEntry *rangeTableEntry = rangeTableEntryDetails->rangeTableEntry;
|
RangeTblEntry *rangeTableEntry = rangeTableEntryDetails->rangeTableEntry;
|
||||||
List *requiredAttributeNumbers = rangeTableEntryDetails->requiredAttributeNumbers;
|
List *requiredAttributeNumbers = rangeTableEntryDetails->requiredAttributeNumbers;
|
||||||
ReplaceRTERelationWithRteSubquery(rangeTableEntry,
|
ReplaceRTERelationWithRteSubquery(rangeTableEntry,
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
requiredAttributeNumbers, context,
|
requiredAttributeNumbers, context,
|
||||||
rangeTableEntryDetails->perminfo);
|
rangeTableEntryDetails->perminfo);
|
||||||
#else
|
|
||||||
requiredAttributeNumbers, context, NULL);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -581,14 +569,12 @@ CreateConversionCandidates(PlannerRestrictionContext *plannerRestrictionContext,
|
||||||
RequiredAttrNumbersForRelation(rangeTableEntry, plannerRestrictionContext);
|
RequiredAttrNumbersForRelation(rangeTableEntry, plannerRestrictionContext);
|
||||||
rangeTableEntryDetails->hasConstantFilterOnUniqueColumn =
|
rangeTableEntryDetails->hasConstantFilterOnUniqueColumn =
|
||||||
HasConstantFilterOnUniqueColumn(rangeTableEntry, relationRestriction);
|
HasConstantFilterOnUniqueColumn(rangeTableEntry, relationRestriction);
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
rangeTableEntryDetails->perminfo = NULL;
|
rangeTableEntryDetails->perminfo = NULL;
|
||||||
if (rangeTableEntry->perminfoindex)
|
if (rangeTableEntry->perminfoindex)
|
||||||
{
|
{
|
||||||
rangeTableEntryDetails->perminfo = getRTEPermissionInfo(rteperminfos,
|
rangeTableEntryDetails->perminfo = getRTEPermissionInfo(rteperminfos,
|
||||||
rangeTableEntry);
|
rangeTableEntry);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
bool referenceOrDistributedTable =
|
bool referenceOrDistributedTable =
|
||||||
IsCitusTableType(rangeTableEntry->relid, REFERENCE_TABLE) ||
|
IsCitusTableType(rangeTableEntry->relid, REFERENCE_TABLE) ||
|
||||||
|
|
|
||||||
|
|
@ -835,11 +835,9 @@ ConvertCteRTEIntoSubquery(Query *mergeQuery, RangeTblEntry *sourceRte)
|
||||||
Query *cteQuery = (Query *) copyObject(sourceCte->ctequery);
|
Query *cteQuery = (Query *) copyObject(sourceCte->ctequery);
|
||||||
|
|
||||||
sourceRte->rtekind = RTE_SUBQUERY;
|
sourceRte->rtekind = RTE_SUBQUERY;
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
|
|
||||||
/* sanity check - sourceRte was RTE_CTE previously so it should have no perminfo */
|
/* sanity check - sourceRte was RTE_CTE previously so it should have no perminfo */
|
||||||
Assert(sourceRte->perminfoindex == 0);
|
Assert(sourceRte->perminfoindex == 0);
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* As we are delinking the CTE from main query, we have to walk through the
|
* As we are delinking the CTE from main query, we have to walk through the
|
||||||
|
|
@ -889,8 +887,6 @@ ConvertRelationRTEIntoSubquery(Query *mergeQuery, RangeTblEntry *sourceRte,
|
||||||
/* we copy the input rteRelation to preserve the rteIdentity */
|
/* we copy the input rteRelation to preserve the rteIdentity */
|
||||||
RangeTblEntry *newRangeTableEntry = copyObject(sourceRte);
|
RangeTblEntry *newRangeTableEntry = copyObject(sourceRte);
|
||||||
sourceResultsQuery->rtable = list_make1(newRangeTableEntry);
|
sourceResultsQuery->rtable = list_make1(newRangeTableEntry);
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
sourceResultsQuery->rteperminfos = NIL;
|
sourceResultsQuery->rteperminfos = NIL;
|
||||||
if (sourceRte->perminfoindex)
|
if (sourceRte->perminfoindex)
|
||||||
{
|
{
|
||||||
|
|
@ -902,7 +898,6 @@ ConvertRelationRTEIntoSubquery(Query *mergeQuery, RangeTblEntry *sourceRte,
|
||||||
newRangeTableEntry->perminfoindex = 1;
|
newRangeTableEntry->perminfoindex = 1;
|
||||||
sourceResultsQuery->rteperminfos = list_make1(perminfo);
|
sourceResultsQuery->rteperminfos = list_make1(perminfo);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* set the FROM expression to the subquery */
|
/* set the FROM expression to the subquery */
|
||||||
newRangeTableRef->rtindex = SINGLE_RTE_INDEX;
|
newRangeTableRef->rtindex = SINGLE_RTE_INDEX;
|
||||||
|
|
@ -929,9 +924,7 @@ ConvertRelationRTEIntoSubquery(Query *mergeQuery, RangeTblEntry *sourceRte,
|
||||||
|
|
||||||
/* replace the function with the constructed subquery */
|
/* replace the function with the constructed subquery */
|
||||||
sourceRte->rtekind = RTE_SUBQUERY;
|
sourceRte->rtekind = RTE_SUBQUERY;
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
sourceRte->perminfoindex = 0;
|
sourceRte->perminfoindex = 0;
|
||||||
#endif
|
|
||||||
sourceRte->subquery = sourceResultsQuery;
|
sourceRte->subquery = sourceResultsQuery;
|
||||||
sourceRte->inh = false;
|
sourceRte->inh = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -287,13 +287,11 @@ PG_FUNCTION_INFO_V1(worker_save_query_explain_analyze);
|
||||||
void
|
void
|
||||||
CitusExplainScan(CustomScanState *node, List *ancestors, struct ExplainState *es)
|
CitusExplainScan(CustomScanState *node, List *ancestors, struct ExplainState *es)
|
||||||
{
|
{
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
if (es->generic)
|
if (es->generic)
|
||||||
{
|
{
|
||||||
ereport(ERROR, (errmsg(
|
ereport(ERROR, (errmsg(
|
||||||
"EXPLAIN GENERIC_PLAN is currently not supported for Citus tables")));
|
"EXPLAIN GENERIC_PLAN is currently not supported for Citus tables")));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
CitusScanState *scanState = (CitusScanState *) node;
|
CitusScanState *scanState = (CitusScanState *) node;
|
||||||
DistributedPlan *distributedPlan = scanState->distributedPlan;
|
DistributedPlan *distributedPlan = scanState->distributedPlan;
|
||||||
|
|
|
||||||
|
|
@ -2259,13 +2259,10 @@ ConvertToQueryOnShard(Query *query, Oid citusTableOid, Oid shardId)
|
||||||
Assert(shardRelationId != InvalidOid);
|
Assert(shardRelationId != InvalidOid);
|
||||||
citusTableRte->relid = shardRelationId;
|
citusTableRte->relid = shardRelationId;
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
|
|
||||||
/* Change the range table permission oid to that of the shard's (PG16+) */
|
/* Change the range table permission oid to that of the shard's (PG16+) */
|
||||||
Assert(list_length(query->rteperminfos) == 1);
|
Assert(list_length(query->rteperminfos) == 1);
|
||||||
RTEPermissionInfo *rtePermInfo = (RTEPermissionInfo *) linitial(query->rteperminfos);
|
RTEPermissionInfo *rtePermInfo = (RTEPermissionInfo *) linitial(query->rteperminfos);
|
||||||
rtePermInfo->relid = shardRelationId;
|
rtePermInfo->relid = shardRelationId;
|
||||||
#endif
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -2573,18 +2570,6 @@ SelectsFromDistributedTable(List *rangeTableList, Query *query)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= 150013 && PG_VERSION_NUM < PG_VERSION_16
|
|
||||||
if (rangeTableEntry->rtekind == RTE_SUBQUERY && rangeTableEntry->relkind == 0)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* In PG15.13 commit https://github.com/postgres/postgres/commit/317aba70e
|
|
||||||
* relid is retained when converting views to subqueries,
|
|
||||||
* so we need an extra check identifying those views
|
|
||||||
*/
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (rangeTableEntry->relkind == RELKIND_VIEW ||
|
if (rangeTableEntry->relkind == RELKIND_VIEW ||
|
||||||
rangeTableEntry->relkind == RELKIND_MATVIEW)
|
rangeTableEntry->relkind == RELKIND_MATVIEW)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -81,16 +81,12 @@ CreateColocatedJoinChecker(Query *subquery, PlannerRestrictionContext *restricti
|
||||||
* functions (i.e., FilterPlannerRestrictionForQuery()) rely on queries
|
* functions (i.e., FilterPlannerRestrictionForQuery()) rely on queries
|
||||||
* not relations.
|
* not relations.
|
||||||
*/
|
*/
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
RTEPermissionInfo *perminfo = NULL;
|
RTEPermissionInfo *perminfo = NULL;
|
||||||
if (anchorRangeTblEntry->perminfoindex)
|
if (anchorRangeTblEntry->perminfoindex)
|
||||||
{
|
{
|
||||||
perminfo = getRTEPermissionInfo(subquery->rteperminfos, anchorRangeTblEntry);
|
perminfo = getRTEPermissionInfo(subquery->rteperminfos, anchorRangeTblEntry);
|
||||||
}
|
}
|
||||||
anchorSubquery = WrapRteRelationIntoSubquery(anchorRangeTblEntry, NIL, perminfo);
|
anchorSubquery = WrapRteRelationIntoSubquery(anchorRangeTblEntry, NIL, perminfo);
|
||||||
#else
|
|
||||||
anchorSubquery = WrapRteRelationIntoSubquery(anchorRangeTblEntry, NIL, NULL);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else if (anchorRangeTblEntry->rtekind == RTE_SUBQUERY)
|
else if (anchorRangeTblEntry->rtekind == RTE_SUBQUERY)
|
||||||
{
|
{
|
||||||
|
|
@ -286,13 +282,11 @@ WrapRteRelationIntoSubquery(RangeTblEntry *rteRelation,
|
||||||
RangeTblEntry *newRangeTableEntry = copyObject(rteRelation);
|
RangeTblEntry *newRangeTableEntry = copyObject(rteRelation);
|
||||||
subquery->rtable = list_make1(newRangeTableEntry);
|
subquery->rtable = list_make1(newRangeTableEntry);
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
if (perminfo)
|
if (perminfo)
|
||||||
{
|
{
|
||||||
newRangeTableEntry->perminfoindex = 1;
|
newRangeTableEntry->perminfoindex = 1;
|
||||||
subquery->rteperminfos = list_make1(perminfo);
|
subquery->rteperminfos = list_make1(perminfo);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* set the FROM expression to the subquery */
|
/* set the FROM expression to the subquery */
|
||||||
newRangeTableRef = makeNode(RangeTblRef);
|
newRangeTableRef = makeNode(RangeTblRef);
|
||||||
|
|
|
||||||
|
|
@ -2054,9 +2054,7 @@ SubqueryPushdownMultiNodeTree(Query *originalQuery)
|
||||||
pushedDownQuery->targetList = subqueryTargetEntryList;
|
pushedDownQuery->targetList = subqueryTargetEntryList;
|
||||||
pushedDownQuery->jointree = copyObject(queryTree->jointree);
|
pushedDownQuery->jointree = copyObject(queryTree->jointree);
|
||||||
pushedDownQuery->rtable = copyObject(queryTree->rtable);
|
pushedDownQuery->rtable = copyObject(queryTree->rtable);
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
pushedDownQuery->rteperminfos = copyObject(queryTree->rteperminfos);
|
pushedDownQuery->rteperminfos = copyObject(queryTree->rteperminfos);
|
||||||
#endif
|
|
||||||
pushedDownQuery->setOperations = copyObject(queryTree->setOperations);
|
pushedDownQuery->setOperations = copyObject(queryTree->setOperations);
|
||||||
pushedDownQuery->querySource = queryTree->querySource;
|
pushedDownQuery->querySource = queryTree->querySource;
|
||||||
pushedDownQuery->hasSubLinks = queryTree->hasSubLinks;
|
pushedDownQuery->hasSubLinks = queryTree->hasSubLinks;
|
||||||
|
|
@ -2190,9 +2188,7 @@ CreateSubqueryTargetListAndAdjustVars(List *columnList)
|
||||||
* the var - is empty. Otherwise, when given the query, the Postgres planner
|
* the var - is empty. Otherwise, when given the query, the Postgres planner
|
||||||
* may attempt to access a non-existent range table and segfault, as in #7787.
|
* may attempt to access a non-existent range table and segfault, as in #7787.
|
||||||
*/
|
*/
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
column->varnullingrels = NULL;
|
column->varnullingrels = NULL;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return subqueryTargetEntryList;
|
return subqueryTargetEntryList;
|
||||||
|
|
|
||||||
|
|
@ -973,7 +973,6 @@ RecursivelyPlanDistributedJoinNode(Node *node, Query *query,
|
||||||
List *requiredAttributes =
|
List *requiredAttributes =
|
||||||
RequiredAttrNumbersForRelation(distributedRte, restrictionContext);
|
RequiredAttrNumbersForRelation(distributedRte, restrictionContext);
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
RTEPermissionInfo *perminfo = NULL;
|
RTEPermissionInfo *perminfo = NULL;
|
||||||
if (distributedRte->perminfoindex)
|
if (distributedRte->perminfoindex)
|
||||||
{
|
{
|
||||||
|
|
@ -982,10 +981,6 @@ RecursivelyPlanDistributedJoinNode(Node *node, Query *query,
|
||||||
|
|
||||||
ReplaceRTERelationWithRteSubquery(distributedRte, requiredAttributes,
|
ReplaceRTERelationWithRteSubquery(distributedRte, requiredAttributes,
|
||||||
recursivePlanningContext, perminfo);
|
recursivePlanningContext, perminfo);
|
||||||
#else
|
|
||||||
ReplaceRTERelationWithRteSubquery(distributedRte, requiredAttributes,
|
|
||||||
recursivePlanningContext, NULL);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else if (distributedRte->rtekind == RTE_SUBQUERY)
|
else if (distributedRte->rtekind == RTE_SUBQUERY)
|
||||||
{
|
{
|
||||||
|
|
@ -1874,9 +1869,7 @@ ReplaceRTERelationWithRteSubquery(RangeTblEntry *rangeTableEntry,
|
||||||
|
|
||||||
/* replace the function with the constructed subquery */
|
/* replace the function with the constructed subquery */
|
||||||
rangeTableEntry->rtekind = RTE_SUBQUERY;
|
rangeTableEntry->rtekind = RTE_SUBQUERY;
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
rangeTableEntry->perminfoindex = 0;
|
rangeTableEntry->perminfoindex = 0;
|
||||||
#endif
|
|
||||||
rangeTableEntry->subquery = subquery;
|
rangeTableEntry->subquery = subquery;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -1949,13 +1942,10 @@ CreateOuterSubquery(RangeTblEntry *rangeTableEntry, List *outerSubqueryTargetLis
|
||||||
innerSubqueryRTE->eref->colnames = innerSubqueryColNames;
|
innerSubqueryRTE->eref->colnames = innerSubqueryColNames;
|
||||||
outerSubquery->rtable = list_make1(innerSubqueryRTE);
|
outerSubquery->rtable = list_make1(innerSubqueryRTE);
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
|
|
||||||
/* sanity check */
|
/* sanity check */
|
||||||
Assert(innerSubqueryRTE->rtekind == RTE_SUBQUERY &&
|
Assert(innerSubqueryRTE->rtekind == RTE_SUBQUERY &&
|
||||||
innerSubqueryRTE->perminfoindex == 0);
|
innerSubqueryRTE->perminfoindex == 0);
|
||||||
outerSubquery->rteperminfos = NIL;
|
outerSubquery->rteperminfos = NIL;
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* set the FROM expression to the subquery */
|
/* set the FROM expression to the subquery */
|
||||||
|
|
@ -2131,13 +2121,10 @@ TransformFunctionRTE(RangeTblEntry *rangeTblEntry)
|
||||||
/* set the FROM expression to the subquery */
|
/* set the FROM expression to the subquery */
|
||||||
subquery->rtable = list_make1(newRangeTableEntry);
|
subquery->rtable = list_make1(newRangeTableEntry);
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
|
|
||||||
/* sanity check */
|
/* sanity check */
|
||||||
Assert(newRangeTableEntry->rtekind == RTE_FUNCTION &&
|
Assert(newRangeTableEntry->rtekind == RTE_FUNCTION &&
|
||||||
newRangeTableEntry->perminfoindex == 0);
|
newRangeTableEntry->perminfoindex == 0);
|
||||||
subquery->rteperminfos = NIL;
|
subquery->rteperminfos = NIL;
|
||||||
#endif
|
|
||||||
|
|
||||||
newRangeTableRef->rtindex = 1;
|
newRangeTableRef->rtindex = 1;
|
||||||
subquery->jointree = makeFromExpr(list_make1(newRangeTableRef), NULL);
|
subquery->jointree = makeFromExpr(list_make1(newRangeTableRef), NULL);
|
||||||
|
|
@ -2459,9 +2446,7 @@ BuildEmptyResultQuery(List *targetEntryList, char *resultId)
|
||||||
valuesQuery->canSetTag = true;
|
valuesQuery->canSetTag = true;
|
||||||
valuesQuery->commandType = CMD_SELECT;
|
valuesQuery->commandType = CMD_SELECT;
|
||||||
valuesQuery->rtable = list_make1(valuesRangeTable);
|
valuesQuery->rtable = list_make1(valuesRangeTable);
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
valuesQuery->rteperminfos = NIL;
|
valuesQuery->rteperminfos = NIL;
|
||||||
#endif
|
|
||||||
valuesQuery->jointree = valuesJoinTree;
|
valuesQuery->jointree = valuesJoinTree;
|
||||||
valuesQuery->targetList = valueTargetList;
|
valuesQuery->targetList = valueTargetList;
|
||||||
|
|
||||||
|
|
@ -2478,9 +2463,7 @@ BuildEmptyResultQuery(List *targetEntryList, char *resultId)
|
||||||
resultQuery->commandType = CMD_SELECT;
|
resultQuery->commandType = CMD_SELECT;
|
||||||
resultQuery->canSetTag = true;
|
resultQuery->canSetTag = true;
|
||||||
resultQuery->rtable = list_make1(emptyRangeTable);
|
resultQuery->rtable = list_make1(emptyRangeTable);
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
resultQuery->rteperminfos = NIL;
|
resultQuery->rteperminfos = NIL;
|
||||||
#endif
|
|
||||||
RangeTblRef *rangeTableRef = makeNode(RangeTblRef);
|
RangeTblRef *rangeTableRef = makeNode(RangeTblRef);
|
||||||
rangeTableRef->rtindex = 1;
|
rangeTableRef->rtindex = 1;
|
||||||
|
|
||||||
|
|
@ -2630,9 +2613,7 @@ BuildReadIntermediateResultsQuery(List *targetEntryList, List *columnAliasList,
|
||||||
Query *resultQuery = makeNode(Query);
|
Query *resultQuery = makeNode(Query);
|
||||||
resultQuery->commandType = CMD_SELECT;
|
resultQuery->commandType = CMD_SELECT;
|
||||||
resultQuery->rtable = list_make1(rangeTableEntry);
|
resultQuery->rtable = list_make1(rangeTableEntry);
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
resultQuery->rteperminfos = NIL;
|
resultQuery->rteperminfos = NIL;
|
||||||
#endif
|
|
||||||
resultQuery->jointree = joinTree;
|
resultQuery->jointree = joinTree;
|
||||||
resultQuery->targetList = targetList;
|
resultQuery->targetList = targetList;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1508,7 +1508,6 @@ GetTargetSubquery(PlannerInfo *root, RangeTblEntry *rangeTableEntry, Var *varToB
|
||||||
bool
|
bool
|
||||||
IsRelOptOuterJoin(PlannerInfo *root, int varNo)
|
IsRelOptOuterJoin(PlannerInfo *root, int varNo)
|
||||||
{
|
{
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
if (root->simple_rel_array_size <= varNo)
|
if (root->simple_rel_array_size <= varNo)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -1520,7 +1519,6 @@ IsRelOptOuterJoin(PlannerInfo *root, int varNo)
|
||||||
/* must be an outer join */
|
/* must be an outer join */
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1515,8 +1515,6 @@ CreateSubscriptions(MultiConnection *sourceConnection,
|
||||||
appendStringInfo(createSubscriptionCommand,
|
appendStringInfo(createSubscriptionCommand,
|
||||||
"CREATE SUBSCRIPTION %s CONNECTION %s PUBLICATION %s "
|
"CREATE SUBSCRIPTION %s CONNECTION %s PUBLICATION %s "
|
||||||
"WITH (citus_use_authinfo=true, create_slot=false, "
|
"WITH (citus_use_authinfo=true, create_slot=false, "
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* password_required specifies whether connections to the publisher
|
* password_required specifies whether connections to the publisher
|
||||||
* made as a result of this subscription must use password authentication.
|
* made as a result of this subscription must use password authentication.
|
||||||
|
|
@ -1529,9 +1527,6 @@ CreateSubscriptions(MultiConnection *sourceConnection,
|
||||||
* it will be ignored anyway
|
* it will be ignored anyway
|
||||||
*/
|
*/
|
||||||
"copy_data=false, enabled=false, slot_name=%s, password_required=false",
|
"copy_data=false, enabled=false, slot_name=%s, password_required=false",
|
||||||
#else
|
|
||||||
"copy_data=false, enabled=false, slot_name=%s",
|
|
||||||
#endif
|
|
||||||
quote_identifier(target->subscriptionName),
|
quote_identifier(target->subscriptionName),
|
||||||
quote_literal_cstr(conninfo->data),
|
quote_literal_cstr(conninfo->data),
|
||||||
quote_identifier(target->publication->name),
|
quote_identifier(target->publication->name),
|
||||||
|
|
|
||||||
|
|
@ -94,42 +94,6 @@ replication_origin_filter_cb(LogicalDecodingContext *ctx, RepOriginId origin_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* update_replication_progress is copied from Postgres 15. We use it to send keepalive
|
|
||||||
* messages when we are filtering out the wal changes resulting from the initial copy.
|
|
||||||
* If we do not send out messages long enough, wal reciever will time out.
|
|
||||||
* Postgres 16 has refactored this code such that keepalive messages are sent during
|
|
||||||
* reordering phase which is above change_cb. So we do not need to send keepalive in
|
|
||||||
* change_cb.
|
|
||||||
*/
|
|
||||||
#if (PG_VERSION_NUM < PG_VERSION_16)
|
|
||||||
static void
|
|
||||||
update_replication_progress(LogicalDecodingContext *ctx, bool skipped_xact)
|
|
||||||
{
|
|
||||||
static int changes_count = 0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We don't want to try sending a keepalive message after processing each
|
|
||||||
* change as that can have overhead. Tests revealed that there is no
|
|
||||||
* noticeable overhead in doing it after continuously processing 100 or so
|
|
||||||
* changes.
|
|
||||||
*/
|
|
||||||
#define CHANGES_THRESHOLD 100
|
|
||||||
|
|
||||||
/*
|
|
||||||
* After continuously processing CHANGES_THRESHOLD changes, we
|
|
||||||
* try to send a keepalive message if required.
|
|
||||||
*/
|
|
||||||
if (ctx->end_xact || ++changes_count >= CHANGES_THRESHOLD)
|
|
||||||
{
|
|
||||||
OutputPluginUpdateProgress(ctx, skipped_xact);
|
|
||||||
changes_count = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* shard_split_change_cb function emits the incoming tuple change
|
* shard_split_change_cb function emits the incoming tuple change
|
||||||
* to the appropriate destination shard.
|
* to the appropriate destination shard.
|
||||||
|
|
@ -148,12 +112,6 @@ shard_split_change_cb(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (PG_VERSION_NUM < PG_VERSION_16)
|
|
||||||
|
|
||||||
/* Send replication keepalive. */
|
|
||||||
update_replication_progress(ctx, false);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* check if the relation is publishable.*/
|
/* check if the relation is publishable.*/
|
||||||
if (!is_publishable_relation(relation))
|
if (!is_publishable_relation(relation))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -562,11 +562,7 @@ static const TableAmRoutine fake_methods = {
|
||||||
.tuple_satisfies_snapshot = fake_tuple_satisfies_snapshot,
|
.tuple_satisfies_snapshot = fake_tuple_satisfies_snapshot,
|
||||||
.index_delete_tuples = fake_index_delete_tuples,
|
.index_delete_tuples = fake_index_delete_tuples,
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
.relation_set_new_filelocator = fake_relation_set_new_filenode,
|
.relation_set_new_filelocator = fake_relation_set_new_filenode,
|
||||||
#else
|
|
||||||
.relation_set_new_filenode = fake_relation_set_new_filenode,
|
|
||||||
#endif
|
|
||||||
.relation_nontransactional_truncate = fake_relation_nontransactional_truncate,
|
.relation_nontransactional_truncate = fake_relation_nontransactional_truncate,
|
||||||
.relation_copy_data = fake_copy_data,
|
.relation_copy_data = fake_copy_data,
|
||||||
.relation_copy_for_cluster = fake_copy_for_cluster,
|
.relation_copy_for_cluster = fake_copy_for_cluster,
|
||||||
|
|
|
||||||
|
|
@ -740,8 +740,6 @@ UnlockLockData(void)
|
||||||
* We have separate blocks for PG16 and <PG16 because SHM_QUEUE is completely
|
* We have separate blocks for PG16 and <PG16 because SHM_QUEUE is completely
|
||||||
* removed from PG16
|
* removed from PG16
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
static void
|
static void
|
||||||
AddEdgesForLockWaits(WaitGraph *waitGraph, PGPROC *waitingProc, PROCStack *remaining)
|
AddEdgesForLockWaits(WaitGraph *waitGraph, PGPROC *waitingProc, PROCStack *remaining)
|
||||||
{
|
{
|
||||||
|
|
@ -820,86 +818,6 @@ AddEdgesForWaitQueue(WaitGraph *waitGraph, PGPROC *waitingProc, PROCStack *remai
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
static void
|
|
||||||
AddEdgesForLockWaits(WaitGraph *waitGraph, PGPROC *waitingProc, PROCStack *remaining)
|
|
||||||
{
|
|
||||||
/* the lock for which this process is waiting */
|
|
||||||
LOCK *waitLock = waitingProc->waitLock;
|
|
||||||
|
|
||||||
/* determine the conflict mask for the lock level used by the process */
|
|
||||||
LockMethod lockMethodTable = GetLocksMethodTable(waitLock);
|
|
||||||
int conflictMask = lockMethodTable->conflictTab[waitingProc->waitLockMode];
|
|
||||||
|
|
||||||
/* iterate through the queue of processes holding the lock */
|
|
||||||
SHM_QUEUE *procLocks = &waitLock->procLocks;
|
|
||||||
PROCLOCK *procLock = (PROCLOCK *) SHMQueueNext(procLocks, procLocks,
|
|
||||||
offsetof(PROCLOCK, lockLink));
|
|
||||||
|
|
||||||
while (procLock != NULL)
|
|
||||||
{
|
|
||||||
PGPROC *currentProc = procLock->tag.myProc;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Skip processes from the same lock group, processes that don't conflict,
|
|
||||||
* and processes that are waiting on safe operations.
|
|
||||||
*/
|
|
||||||
if (!IsSameLockGroup(waitingProc, currentProc) &&
|
|
||||||
IsConflictingLockMask(procLock->holdMask, conflictMask) &&
|
|
||||||
!IsProcessWaitingForSafeOperations(currentProc))
|
|
||||||
{
|
|
||||||
AddWaitEdge(waitGraph, waitingProc, currentProc, remaining);
|
|
||||||
}
|
|
||||||
|
|
||||||
procLock = (PROCLOCK *) SHMQueueNext(procLocks, &procLock->lockLink,
|
|
||||||
offsetof(PROCLOCK, lockLink));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
AddEdgesForWaitQueue(WaitGraph *waitGraph, PGPROC *waitingProc, PROCStack *remaining)
|
|
||||||
{
|
|
||||||
/* the lock for which this process is waiting */
|
|
||||||
LOCK *waitLock = waitingProc->waitLock;
|
|
||||||
|
|
||||||
/* determine the conflict mask for the lock level used by the process */
|
|
||||||
LockMethod lockMethodTable = GetLocksMethodTable(waitLock);
|
|
||||||
int conflictMask = lockMethodTable->conflictTab[waitingProc->waitLockMode];
|
|
||||||
|
|
||||||
/* iterate through the wait queue */
|
|
||||||
PROC_QUEUE *waitQueue = &(waitLock->waitProcs);
|
|
||||||
int queueSize = waitQueue->size;
|
|
||||||
PGPROC *currentProc = (PGPROC *) waitQueue->links.next;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Iterate through the queue from the start until we encounter waitingProc,
|
|
||||||
* since we only care about processes in front of waitingProc in the queue.
|
|
||||||
*/
|
|
||||||
while (queueSize-- > 0 && currentProc != waitingProc)
|
|
||||||
{
|
|
||||||
int awaitMask = LOCKBIT_ON(currentProc->waitLockMode);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Skip processes from the same lock group, processes that don't conflict,
|
|
||||||
* and processes that are waiting on safe operations.
|
|
||||||
*/
|
|
||||||
if (!IsSameLockGroup(waitingProc, currentProc) &&
|
|
||||||
IsConflictingLockMask(awaitMask, conflictMask) &&
|
|
||||||
!IsProcessWaitingForSafeOperations(currentProc))
|
|
||||||
{
|
|
||||||
AddWaitEdge(waitGraph, waitingProc, currentProc, remaining);
|
|
||||||
}
|
|
||||||
|
|
||||||
currentProc = (PGPROC *) currentProc->links.next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* AddWaitEdge adds a new wait edge to a wait graph. The nodes in the graph are
|
* AddWaitEdge adds a new wait edge to a wait graph. The nodes in the graph are
|
||||||
* transactions and an edge indicates the "waiting" process is blocked on a lock
|
* transactions and an edge indicates the "waiting" process is blocked on a lock
|
||||||
|
|
|
||||||
|
|
@ -807,13 +807,9 @@ AdjustMaxPreparedTransactions(void)
|
||||||
* really check if max_prepared_xacts is configured by the user explicitly,
|
* really check if max_prepared_xacts is configured by the user explicitly,
|
||||||
* so check if it's value is default.
|
* so check if it's value is default.
|
||||||
*/
|
*/
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
struct config_generic *gconf = find_option("max_prepared_transactions",
|
struct config_generic *gconf = find_option("max_prepared_transactions",
|
||||||
false, false, ERROR);
|
false, false, ERROR);
|
||||||
if (gconf->source == PGC_S_DEFAULT)
|
if (gconf->source == PGC_S_DEFAULT)
|
||||||
#else
|
|
||||||
if (max_prepared_xacts == 0)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
char newvalue[12];
|
char newvalue[12];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,7 @@
|
||||||
|
|
||||||
#include "distributed/relation_utils.h"
|
#include "distributed/relation_utils.h"
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
#include "miscadmin.h"
|
#include "miscadmin.h"
|
||||||
#endif
|
|
||||||
#include "utils/lsyscache.h"
|
#include "utils/lsyscache.h"
|
||||||
#include "utils/rel.h"
|
#include "utils/rel.h"
|
||||||
|
|
||||||
|
|
@ -33,8 +31,6 @@ RelationGetNamespaceName(Relation relation)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GetFilledPermissionInfo creates RTEPermissionInfo for a given RTE
|
* GetFilledPermissionInfo creates RTEPermissionInfo for a given RTE
|
||||||
* and fills it with given data and returns this RTEPermissionInfo object.
|
* and fills it with given data and returns this RTEPermissionInfo object.
|
||||||
|
|
@ -56,6 +52,3 @@ GetFilledPermissionInfo(Oid relid, bool inh, AclMode requiredPerms)
|
||||||
perminfo->checkAsUser = GetUserId();
|
perminfo->checkAsUser = GetUserId();
|
||||||
return perminfo;
|
return perminfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
||||||
|
|
@ -27,11 +27,7 @@
|
||||||
#include "columnar/columnar_compression.h"
|
#include "columnar/columnar_compression.h"
|
||||||
#include "columnar/columnar_metadata.h"
|
#include "columnar/columnar_metadata.h"
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
#include "storage/relfilelocator.h"
|
#include "storage/relfilelocator.h"
|
||||||
#else
|
|
||||||
#include "storage/relfilenode.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define COLUMNAR_AM_NAME "columnar"
|
#define COLUMNAR_AM_NAME "columnar"
|
||||||
#define COLUMNAR_MODULE_NAME "citus_columnar"
|
#define COLUMNAR_MODULE_NAME "citus_columnar"
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,7 @@
|
||||||
#include "pg_version_compat.h"
|
#include "pg_version_compat.h"
|
||||||
#include "pg_version_constants.h"
|
#include "pg_version_constants.h"
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
#include "storage/relfilelocator.h"
|
#include "storage/relfilelocator.h"
|
||||||
#else
|
|
||||||
#include "storage/relfilenode.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -14,15 +14,11 @@
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
#include "pg_version_constants.h"
|
#include "pg_version_constants.h"
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
#include "parser/parse_relation.h"
|
#include "parser/parse_relation.h"
|
||||||
#endif
|
|
||||||
#include "utils/relcache.h"
|
#include "utils/relcache.h"
|
||||||
|
|
||||||
extern char * RelationGetNamespaceName(Relation relation);
|
extern char * RelationGetNamespaceName(Relation relation);
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
extern RTEPermissionInfo * GetFilledPermissionInfo(Oid relid, bool inh,
|
extern RTEPermissionInfo * GetFilledPermissionInfo(Oid relid, bool inh,
|
||||||
AclMode requiredPerms);
|
AclMode requiredPerms);
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* RELATION_UTILS_H */
|
#endif /* RELATION_UTILS_H */
|
||||||
|
|
|
||||||
|
|
@ -179,9 +179,7 @@ IsNodeWideObjectClass(ObjectClass objectClass)
|
||||||
case OCLASS_DATABASE:
|
case OCLASS_DATABASE:
|
||||||
case OCLASS_TBLSPACE:
|
case OCLASS_TBLSPACE:
|
||||||
case OCLASS_PARAMETER_ACL:
|
case OCLASS_PARAMETER_ACL:
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
|
||||||
case OCLASS_ROLE_MEMBERSHIP:
|
case OCLASS_ROLE_MEMBERSHIP:
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue