Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PG17 compatibility: Resolve compilation issues #7651

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ae3ed7d
Enable configure
naisila Jul 8, 2024
3f5a1e0
Rename foreach_ macros to foreach_declared_ macros
naisila Jul 8, 2024
a816d1b
Remove ExecFreeExprContext call
naisila Jul 8, 2024
646ff0a
PG17 uses streaming IO in analyze, fix scan_analyze_next_block function
naisila Jul 8, 2024
85a3ed0
Define ObjectClass for PG17+ only since it's removed
naisila Jul 8, 2024
2434eff
No new node-wide object added so far in PG17, change assert
naisila Jul 8, 2024
2076339
Remove ReorderBufferTupleBuf structure.
naisila Jul 8, 2024
e9fe257
Define colliculocale and daticulocale since they have been renamed
naisila Jul 8, 2024
e33736e
makeStringConst defined in PG17
naisila Jul 8, 2024
4eafd3a
RangeVarCallbackOwnsTable was replaced by RangeVarCallbackMaintainsTable
naisila Jul 9, 2024
be2bec0
attstattarget is nullable, define pg compatible functions for it
naisila Jul 9, 2024
0176974
stxstattarget is nullable in PG17, write compat functions for it
naisila Jul 9, 2024
dd19847
Use ResourceOwner to track WaitEventSet in PG17
naisila Jul 10, 2024
022ca99
getIdentitySequence now uses Relation instead of relation_id
naisila Jul 10, 2024
e0a0874
Remove no-op tuplestore_donestoring function
naisila Jul 10, 2024
49f7bff
MergeAction can have 3 merge kinds (now enum) in PG17, write compat
naisila Jul 10, 2024
a23bf88
EXPLAIN (MEMORY) is added, make changes to ExplainOnePlan
naisila Jul 10, 2024
651bcc7
LIMIT_OPTION_DEFAULT has been removed as it's useless, use LIMIT_OPTI…
naisila Jul 10, 2024
ec9beb5
write compat for create_foreignscan_path bcs of more arguments in PG17
naisila Jul 10, 2024
140a443
pgprocno and lxid have been combined into a struct in PGPROC
naisila Jul 10, 2024
76f60a7
add pg17 build test
naisila Jul 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/backend/columnar/columnar_customscan.c
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you consider using the macros from pg17 (e.g. removing the local variables)? Would it be feasible?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still have to support PG15 and PG16. One way to do it would be to change Citus's current definition of these macros such that they are identical to PG17's definitions, and then iterate over all uses and remove the local variables.
Do you think that is better?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would require to add the macro definition for PG < 17. Both (the current / alternative) seem feasible options, and both require quite some editing. You already implemented one of them. It seems OK to me.

Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ ColumnarGetRelationInfoHook(PlannerInfo *root, Oid relationObjectId,

/* disable index-only scan */
IndexOptInfo *indexOptInfo = NULL;
foreach_ptr(indexOptInfo, rel->indexlist)
foreach_declared_ptr(indexOptInfo, rel->indexlist)
{
memset(indexOptInfo->canreturn, false, indexOptInfo->ncolumns * sizeof(bool));
}
Expand All @@ -381,7 +381,7 @@ RemovePathsByPredicate(RelOptInfo *rel, PathPredicate removePathPredicate)
List *filteredPathList = NIL;

Path *path = NULL;
foreach_ptr(path, rel->pathlist)
foreach_declared_ptr(path, rel->pathlist)
{
if (!removePathPredicate(path))
{
Expand Down Expand Up @@ -428,7 +428,7 @@ static void
CostColumnarPaths(PlannerInfo *root, RelOptInfo *rel, Oid relationId)
{
Path *path = NULL;
foreach_ptr(path, rel->pathlist)
foreach_declared_ptr(path, rel->pathlist)
{
if (IsA(path, IndexPath))
{
Expand Down Expand Up @@ -783,7 +783,7 @@ ExtractPushdownClause(PlannerInfo *root, RelOptInfo *rel, Node *node)
List *pushdownableArgs = NIL;

Node *boolExprArg = NULL;
foreach_ptr(boolExprArg, boolExpr->args)
foreach_declared_ptr(boolExprArg, boolExpr->args)
{
Expr *pushdownableArg = ExtractPushdownClause(root, rel,
(Node *) boolExprArg);
Expand Down Expand Up @@ -1550,7 +1550,7 @@ ColumnarPerStripeScanCost(RelOptInfo *rel, Oid relationId, int numberOfColumnsRe
uint32 maxColumnCount = 0;
uint64 totalStripeSize = 0;
StripeMetadata *stripeMetadata = NULL;
foreach_ptr(stripeMetadata, stripeList)
foreach_declared_ptr(stripeMetadata, stripeList)
{
totalStripeSize += stripeMetadata->dataLength;
maxColumnCount = Max(maxColumnCount, stripeMetadata->columnCount);
Expand Down
2 changes: 1 addition & 1 deletion src/backend/columnar/columnar_metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -2041,7 +2041,7 @@ GetHighestUsedRowNumber(uint64 storageId)
List *stripeMetadataList = ReadDataFileStripeList(storageId,
GetTransactionSnapshot());
StripeMetadata *stripeMetadata = NULL;
foreach_ptr(stripeMetadata, stripeMetadataList)
foreach_declared_ptr(stripeMetadata, stripeMetadataList)
{
highestRowNumber = Max(highestRowNumber,
StripeGetHighestRowNumber(stripeMetadata));
Expand Down
4 changes: 2 additions & 2 deletions src/backend/columnar/columnar_reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ ReadChunkGroupNextRow(ChunkGroupReadState *chunkGroupReadState, Datum *columnVal
memset(columnNulls, true, sizeof(bool) * chunkGroupReadState->columnCount);

int attno;
foreach_int(attno, chunkGroupReadState->projectedColumnList)
foreach_declared_int(attno, chunkGroupReadState->projectedColumnList)
{
const ChunkData *chunkGroupData = chunkGroupReadState->chunkGroupData;
const int rowIndex = chunkGroupReadState->currentRow;
Expand Down Expand Up @@ -1489,7 +1489,7 @@ ProjectedColumnMask(uint32 columnCount, List *projectedColumnList)
bool *projectedColumnMask = palloc0(columnCount * sizeof(bool));
int attno;

foreach_int(attno, projectedColumnList)
foreach_declared_int(attno, projectedColumnList)
{
/* attno is 1-indexed; projectedColumnMask is 0-indexed */
int columnIndex = attno - 1;
Expand Down
2 changes: 1 addition & 1 deletion src/backend/columnar/columnar_tableam.c
Original file line number Diff line number Diff line change
Expand Up @@ -3083,7 +3083,7 @@ DefElem *
GetExtensionOption(List *extensionOptions, const char *defname)
{
DefElem *defElement = NULL;
foreach_ptr(defElement, extensionOptions)
foreach_declared_ptr(defElement, extensionOptions)
{
if (IsA(defElement, DefElem) &&
strncmp(defElement->defname, defname, NAMEDATALEN) == 0)
Expand Down
4 changes: 2 additions & 2 deletions src/backend/distributed/clock/causal_clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ GetHighestClockInTransaction(List *nodeConnectionList)
{
MultiConnection *connection = NULL;

foreach_ptr(connection, nodeConnectionList)
foreach_declared_ptr(connection, nodeConnectionList)
{
int querySent =
SendRemoteCommand(connection, "SELECT citus_get_node_clock();");
Expand All @@ -349,7 +349,7 @@ GetHighestClockInTransaction(List *nodeConnectionList)
globalClockValue->counter)));

/* fetch the results and pick the highest clock value of all the nodes */
foreach_ptr(connection, nodeConnectionList)
foreach_declared_ptr(connection, nodeConnectionList)
{
bool raiseInterrupts = true;

Expand Down
36 changes: 18 additions & 18 deletions src/backend/distributed/commands/alter_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ UndistributeTables(List *relationIdList)
*/
List *originalForeignKeyRecreationCommands = NIL;
Oid relationId = InvalidOid;
foreach_oid(relationId, relationIdList)
foreach_declared_oid(relationId, relationIdList)
{
List *fkeyCommandsForRelation =
GetFKeyCreationCommandsRelationInvolvedWithTableType(relationId,
Expand Down Expand Up @@ -802,7 +802,7 @@ ConvertTableInternal(TableConversionState *con)
List *partitionList = PartitionList(con->relationId);

Oid partitionRelationId = InvalidOid;
foreach_oid(partitionRelationId, partitionList)
foreach_declared_oid(partitionRelationId, partitionList)
{
char *tableQualifiedName = generate_qualified_relation_name(
partitionRelationId);
Expand Down Expand Up @@ -873,7 +873,7 @@ ConvertTableInternal(TableConversionState *con)
}

TableDDLCommand *tableCreationCommand = NULL;
foreach_ptr(tableCreationCommand, preLoadCommands)
foreach_declared_ptr(tableCreationCommand, preLoadCommands)
{
Assert(CitusIsA(tableCreationCommand, TableDDLCommand));

Expand Down Expand Up @@ -947,7 +947,7 @@ ConvertTableInternal(TableConversionState *con)
con->suppressNoticeMessages);

TableDDLCommand *tableConstructionCommand = NULL;
foreach_ptr(tableConstructionCommand, postLoadCommands)
foreach_declared_ptr(tableConstructionCommand, postLoadCommands)
{
Assert(CitusIsA(tableConstructionCommand, TableDDLCommand));
char *tableConstructionSQL = GetTableDDLCommand(tableConstructionCommand);
Expand All @@ -965,7 +965,7 @@ ConvertTableInternal(TableConversionState *con)
MemoryContext oldContext = MemoryContextSwitchTo(citusPerPartitionContext);

char *attachPartitionCommand = NULL;
foreach_ptr(attachPartitionCommand, attachPartitionCommands)
foreach_declared_ptr(attachPartitionCommand, attachPartitionCommands)
{
MemoryContextReset(citusPerPartitionContext);

Expand All @@ -990,7 +990,7 @@ ConvertTableInternal(TableConversionState *con)

/* For now we only support cascade to colocation for alter_distributed_table UDF */
Assert(con->conversionType == ALTER_DISTRIBUTED_TABLE);
foreach_oid(colocatedTableId, con->colocatedTableList)
foreach_declared_oid(colocatedTableId, con->colocatedTableList)
{
if (colocatedTableId == con->relationId)
{
Expand Down Expand Up @@ -1018,7 +1018,7 @@ ConvertTableInternal(TableConversionState *con)
if (con->cascadeToColocated != CASCADE_TO_COLOCATED_NO_ALREADY_CASCADED)
{
char *foreignKeyCommand = NULL;
foreach_ptr(foreignKeyCommand, foreignKeyCommands)
foreach_declared_ptr(foreignKeyCommand, foreignKeyCommands)
{
ExecuteQueryViaSPI(foreignKeyCommand, SPI_OK_UTILITY);
}
Expand Down Expand Up @@ -1054,7 +1054,7 @@ CopyTableConversionReturnIntoCurrentContext(TableConversionReturn *tableConversi
tableConversionReturnCopy = palloc0(sizeof(TableConversionReturn));
List *copyForeignKeyCommands = NIL;
char *foreignKeyCommand = NULL;
foreach_ptr(foreignKeyCommand, tableConversionReturn->foreignKeyCommands)
foreach_declared_ptr(foreignKeyCommand, tableConversionReturn->foreignKeyCommands)
{
char *copyForeignKeyCommand = MemoryContextStrdup(CurrentMemoryContext,
foreignKeyCommand);
Expand Down Expand Up @@ -1129,7 +1129,7 @@ DropIndexesNotSupportedByColumnar(Oid relationId, bool suppressNoticeMessages)
RelationClose(columnarRelation);

Oid indexId = InvalidOid;
foreach_oid(indexId, indexIdList)
foreach_declared_oid(indexId, indexIdList)
{
char *indexAmName = GetIndexAccessMethodName(indexId);
if (extern_ColumnarSupportsIndexAM(indexAmName))
Expand Down Expand Up @@ -1389,7 +1389,7 @@ CreateTableConversion(TableConversionParameters *params)
* since they will be handled separately.
*/
Oid colocatedTableId = InvalidOid;
foreach_oid(colocatedTableId, colocatedTableList)
foreach_declared_oid(colocatedTableId, colocatedTableList)
{
if (PartitionTable(colocatedTableId))
{
Expand Down Expand Up @@ -1605,7 +1605,7 @@ DoesCascadeDropUnsupportedObject(Oid classId, Oid objectId, HTAB *nodeMap)
targetObjectId);

HeapTuple depTup = NULL;
foreach_ptr(depTup, dependencyTupleList)
foreach_declared_ptr(depTup, dependencyTupleList)
{
Form_pg_depend pg_depend = (Form_pg_depend) GETSTRUCT(depTup);

Expand Down Expand Up @@ -1645,7 +1645,7 @@ GetViewCreationCommandsOfTable(Oid relationId)
List *commands = NIL;

Oid viewOid = InvalidOid;
foreach_oid(viewOid, views)
foreach_declared_oid(viewOid, views)
{
StringInfo query = makeStringInfo();

Expand Down Expand Up @@ -1683,7 +1683,7 @@ WrapTableDDLCommands(List *commandStrings)
List *tableDDLCommands = NIL;

char *command = NULL;
foreach_ptr(command, commandStrings)
foreach_declared_ptr(command, commandStrings)
{
tableDDLCommands = lappend(tableDDLCommands, makeTableDDLCommandString(command));
}
Expand Down Expand Up @@ -1840,7 +1840,7 @@ ReplaceTable(Oid sourceId, Oid targetId, List *justBeforeDropCommands,
*/
List *ownedSequences = getOwnedSequences_internal(sourceId, 0, DEPENDENCY_AUTO);
Oid sequenceOid = InvalidOid;
foreach_oid(sequenceOid, ownedSequences)
foreach_declared_oid(sequenceOid, ownedSequences)
{
changeDependencyFor(RelationRelationId, sequenceOid,
RelationRelationId, sourceId, targetId);
Expand Down Expand Up @@ -1873,7 +1873,7 @@ ReplaceTable(Oid sourceId, Oid targetId, List *justBeforeDropCommands,
}

char *justBeforeDropCommand = NULL;
foreach_ptr(justBeforeDropCommand, justBeforeDropCommands)
foreach_declared_ptr(justBeforeDropCommand, justBeforeDropCommands)
{
ExecuteQueryViaSPI(justBeforeDropCommand, SPI_OK_UTILITY);
}
Expand Down Expand Up @@ -1987,7 +1987,7 @@ CheckAlterDistributedTableConversionParameters(TableConversionState *con)
Oid colocatedTableOid = InvalidOid;
text *colocateWithText = cstring_to_text(con->colocateWith);
Oid colocateWithTableOid = ResolveRelationId(colocateWithText, false);
foreach_oid(colocatedTableOid, con->colocatedTableList)
foreach_declared_oid(colocatedTableOid, con->colocatedTableList)
{
if (colocateWithTableOid == colocatedTableOid)
{
Expand Down Expand Up @@ -2214,7 +2214,7 @@ WillRecreateForeignKeyToReferenceTable(Oid relationId,
{
List *colocatedTableList = ColocatedTableList(relationId);
Oid colocatedTableOid = InvalidOid;
foreach_oid(colocatedTableOid, colocatedTableList)
foreach_declared_oid(colocatedTableOid, colocatedTableList)
{
if (HasForeignKeyToReferenceTable(colocatedTableOid))
{
Expand Down Expand Up @@ -2242,7 +2242,7 @@ WarningsForDroppingForeignKeysWithDistributedTables(Oid relationId)
List *foreignKeys = list_concat(referencingForeingKeys, referencedForeignKeys);

Oid foreignKeyOid = InvalidOid;
foreach_oid(foreignKeyOid, foreignKeys)
foreach_declared_oid(foreignKeyOid, foreignKeys)
{
ereport(WARNING, (errmsg("foreign key %s will be dropped",
get_constraint_name(foreignKeyOid))));
Expand Down
2 changes: 1 addition & 1 deletion src/backend/distributed/commands/begin.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ SaveBeginCommandProperties(TransactionStmt *transactionStmt)
*
* While BEGIN can be quite frequent it will rarely have options set.
*/
foreach_ptr(item, transactionStmt->options)
foreach_declared_ptr(item, transactionStmt->options)
{
A_Const *constant = (A_Const *) item->arg;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ GetPartitionRelationIds(List *relationIdList)
List *partitionRelationIdList = NIL;

Oid relationId = InvalidOid;
foreach_oid(relationId, relationIdList)
foreach_declared_oid(relationId, relationIdList)
{
if (PartitionTable(relationId))
{
Expand All @@ -189,7 +189,7 @@ LockRelationsWithLockMode(List *relationIdList, LOCKMODE lockMode)
{
Oid relationId;
relationIdList = SortList(relationIdList, CompareOids);
foreach_oid(relationId, relationIdList)
foreach_declared_oid(relationId, relationIdList)
{
LockRelationOid(relationId, lockMode);
}
Expand All @@ -207,7 +207,7 @@ static void
ErrorIfConvertingMultiLevelPartitionedTable(List *relationIdList)
{
Oid relationId;
foreach_oid(relationId, relationIdList)
foreach_declared_oid(relationId, relationIdList)
{
if (PartitionedTable(relationId) && PartitionTable(relationId))
{
Expand Down Expand Up @@ -236,7 +236,7 @@ void
ErrorIfAnyPartitionRelationInvolvedInNonInheritedFKey(List *relationIdList)
{
Oid relationId = InvalidOid;
foreach_oid(relationId, relationIdList)
foreach_declared_oid(relationId, relationIdList)
{
if (!PartitionTable(relationId))
{
Expand Down Expand Up @@ -300,7 +300,7 @@ bool
RelationIdListHasReferenceTable(List *relationIdList)
{
Oid relationId = InvalidOid;
foreach_oid(relationId, relationIdList)
foreach_declared_oid(relationId, relationIdList)
{
if (IsCitusTableType(relationId, REFERENCE_TABLE))
{
Expand All @@ -322,7 +322,7 @@ GetFKeyCreationCommandsForRelationIdList(List *relationIdList)
List *fKeyCreationCommands = NIL;

Oid relationId = InvalidOid;
foreach_oid(relationId, relationIdList)
foreach_declared_oid(relationId, relationIdList)
{
List *relationFKeyCreationCommands =
GetReferencingForeignConstaintCommands(relationId);
Expand All @@ -342,7 +342,7 @@ static void
DropRelationIdListForeignKeys(List *relationIdList, int fKeyFlags)
{
Oid relationId = InvalidOid;
foreach_oid(relationId, relationIdList)
foreach_declared_oid(relationId, relationIdList)
{
DropRelationForeignKeys(relationId, fKeyFlags);
}
Expand Down Expand Up @@ -399,7 +399,7 @@ GetRelationDropFkeyCommands(Oid relationId, int fKeyFlags)
List *relationFKeyIdList = GetForeignKeyOids(relationId, fKeyFlags);

Oid foreignKeyId;
foreach_oid(foreignKeyId, relationFKeyIdList)
foreach_declared_oid(foreignKeyId, relationFKeyIdList)
{
char *dropFkeyCascadeCommand = GetDropFkeyCascadeCommand(foreignKeyId);
dropFkeyCascadeCommandList = lappend(dropFkeyCascadeCommandList,
Expand Down Expand Up @@ -450,7 +450,7 @@ ExecuteCascadeOperationForRelationIdList(List *relationIdList,
cascadeOperationType)
{
Oid relationId = InvalidOid;
foreach_oid(relationId, relationIdList)
foreach_declared_oid(relationId, relationIdList)
{
/*
* The reason behind skipping certain table types in below loop is
Expand Down Expand Up @@ -531,7 +531,7 @@ ExecuteAndLogUtilityCommandListInTableTypeConversionViaSPI(List *utilityCommandL
PG_TRY();
{
char *utilityCommand = NULL;
foreach_ptr(utilityCommand, utilityCommandList)
foreach_declared_ptr(utilityCommand, utilityCommandList)
{
/*
* CREATE MATERIALIZED VIEW commands need to be parsed/transformed,
Expand Down Expand Up @@ -569,7 +569,7 @@ void
ExecuteAndLogUtilityCommandList(List *utilityCommandList)
{
char *utilityCommand = NULL;
foreach_ptr(utilityCommand, utilityCommandList)
foreach_declared_ptr(utilityCommand, utilityCommandList)
{
ExecuteAndLogUtilityCommand(utilityCommand);
}
Expand Down Expand Up @@ -597,7 +597,7 @@ void
ExecuteForeignKeyCreateCommandList(List *ddlCommandList, bool skip_validation)
{
char *ddlCommand = NULL;
foreach_ptr(ddlCommand, ddlCommandList)
foreach_declared_ptr(ddlCommand, ddlCommandList)
{
ExecuteForeignKeyCreateCommand(ddlCommand, skip_validation);
}
Expand Down
Loading