Add support for PostgreSQL 18 (#145)

- Fixed compiler errors and warnings.
- Added expected/pg_ivm_0.out to accommodate message changes introduced in PostgreSQL 18.
This commit is contained in:
Yugo Nagata 2025-07-09 19:26:28 +09:00 committed by GitHub
parent 8232f7fc9b
commit 96fdf6f789
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 1771 additions and 1 deletions

View file

@ -101,7 +101,11 @@ create_immv_internal(List *attrList, IntoClause *into)
CreateStmt *create = makeNode(CreateStmt); CreateStmt *create = makeNode(CreateStmt);
char relkind; char relkind;
Datum toast_options; Datum toast_options;
#if defined(PG_VERSION_NUM) && (PG_VERSION_NUM >= 180000)
const char *const validnsps[] = HEAP_RELOPT_NAMESPACES;
#else
static char *validnsps[] = HEAP_RELOPT_NAMESPACES; static char *validnsps[] = HEAP_RELOPT_NAMESPACES;
#endif
ObjectAddress intoRelationAddr; ObjectAddress intoRelationAddr;
/* This code supports both CREATE TABLE AS and CREATE MATERIALIZED VIEW */ /* This code supports both CREATE TABLE AS and CREATE MATERIALIZED VIEW */
@ -148,7 +152,12 @@ create_immv_internal(List *attrList, IntoClause *into)
NewRelationCreateToastTable(intoRelationAddr.objectId, toast_options); NewRelationCreateToastTable(intoRelationAddr.objectId, toast_options);
/* Create the "view" part of an IMMV. */ /* Create the "view" part of an IMMV. */
#if defined(PG_VERSION_NUM) && (PG_VERSION_NUM >= 180000)
StoreImmvQuery(intoRelationAddr.objectId, into->viewQuery);
#else
StoreImmvQuery(intoRelationAddr.objectId, (Query *) into->viewQuery); StoreImmvQuery(intoRelationAddr.objectId, (Query *) into->viewQuery);
#endif
CommandCounterIncrement(); CommandCounterIncrement();
return intoRelationAddr; return intoRelationAddr;
@ -1514,10 +1523,18 @@ CreateIndexOnIMMV(Query *query, Relation matviewRel)
indexRel = index_open(indexoid, AccessShareLock); indexRel = index_open(indexoid, AccessShareLock);
#if defined(PG_VERSION_NUM) && (PG_VERSION_NUM >= 180000)
if (CheckIndexCompatible(indexRel->rd_id,
index->accessMethod,
index->indexParams,
index->excludeOpNames,
false))
#else
if (CheckIndexCompatible(indexRel->rd_id, if (CheckIndexCompatible(indexRel->rd_id,
index->accessMethod, index->accessMethod,
index->indexParams, index->indexParams,
index->excludeOpNames)) index->excludeOpNames))
#endif
hasCompatibleIndex = true; hasCompatibleIndex = true;
index_close(indexRel, AccessShareLock); index_close(indexRel, AccessShareLock);

View file

@ -1395,6 +1395,8 @@ CREATE FUNCTION mytype_out(mytype)
RETURNS cstring AS 'int4out' RETURNS cstring AS 'int4out'
LANGUAGE INTERNAL STRICT IMMUTABLE; LANGUAGE INTERNAL STRICT IMMUTABLE;
NOTICE: argument type mytype is only a shell NOTICE: argument type mytype is only a shell
LINE 1: CREATE FUNCTION mytype_out(mytype)
^
CREATE TYPE mytype ( CREATE TYPE mytype (
LIKE = int4, LIKE = int4,
INPUT = mytype_in, INPUT = mytype_in,

1743
expected/pg_ivm_0.out Normal file

File diff suppressed because it is too large Load diff

View file

@ -617,7 +617,11 @@ refresh_immv_datafill(DestReceiver *dest, Query *query,
ExecutorStart(queryDesc, 0); ExecutorStart(queryDesc, 0);
/* run the plan */ /* run the plan */
#if PG_VERSION_NUM < 180000
ExecutorRun(queryDesc, ForwardScanDirection, 0, true); ExecutorRun(queryDesc, ForwardScanDirection, 0, true);
#else
ExecutorRun(queryDesc, ForwardScanDirection, 0);
#endif
processed = queryDesc->estate->es_processed; processed = queryDesc->estate->es_processed;

View file

@ -224,10 +224,14 @@ create_immv(PG_FUNCTION_ARGS)
ctas->into->options = NIL; ctas->into->options = NIL;
ctas->into->onCommit = ONCOMMIT_NOOP; ctas->into->onCommit = ONCOMMIT_NOOP;
ctas->into->tableSpaceName = NULL; ctas->into->tableSpaceName = NULL;
#if defined(PG_VERSION_NUM) && (PG_VERSION_NUM >= 180000)
ctas->into->viewQuery = (Query *) parsetree->stmt;
#else
ctas->into->viewQuery = parsetree->stmt; ctas->into->viewQuery = parsetree->stmt;
#endif
ctas->into->skipData = false; ctas->into->skipData = false;
query = transformStmt(pstate, (Node *)ctas); query = transformStmt(pstate, (Node *) ctas);
Assert(query->commandType == CMD_UTILITY && IsA(query->utilityStmt, CreateTableAsStmt)); Assert(query->commandType == CMD_UTILITY && IsA(query->utilityStmt, CreateTableAsStmt));
ExecCreateImmv(pstate, (CreateTableAsStmt *) query->utilityStmt, &qc); ExecCreateImmv(pstate, (CreateTableAsStmt *) query->utilityStmt, &qc);