mirror of
https://github.com/HypoPG/hypopg
synced 2026-05-24 09:38:21 +00:00
Fix compatibility for pg13.
Patch by Michael Paquier, with backward compatibility macro by me.
This commit is contained in:
parent
ef5445885d
commit
3bb72b7492
4 changed files with 28 additions and 10 deletions
12
hypopg.c
12
hypopg.c
|
|
@ -140,22 +140,22 @@ hypo_getNewOid(Oid relid)
|
|||
char relpersistence;
|
||||
|
||||
/* Open the relation on which we want a new OID */
|
||||
relation = heap_open(relid, AccessShareLock);
|
||||
relation = table_open(relid, AccessShareLock);
|
||||
|
||||
reltablespace = relation->rd_rel->reltablespace;
|
||||
relpersistence = relation->rd_rel->relpersistence;
|
||||
|
||||
/* Close the relation and release the lock now */
|
||||
heap_close(relation, AccessShareLock);
|
||||
table_close(relation, AccessShareLock);
|
||||
|
||||
/* Open pg_class to aks a new OID */
|
||||
pg_class = heap_open(RelationRelationId, RowExclusiveLock);
|
||||
pg_class = table_open(RelationRelationId, RowExclusiveLock);
|
||||
|
||||
/* ask for a new relfilenode */
|
||||
newoid = GetNewRelFileNode(reltablespace, pg_class, relpersistence);
|
||||
|
||||
/* Close pg_class and release the lock now */
|
||||
heap_close(pg_class, RowExclusiveLock);
|
||||
table_close(pg_class, RowExclusiveLock);
|
||||
|
||||
return newoid;
|
||||
}
|
||||
|
|
@ -297,7 +297,7 @@ hypo_get_relation_info_hook(PlannerInfo *root,
|
|||
Relation relation;
|
||||
|
||||
/* Open the current relation */
|
||||
relation = heap_open(relationObjectId, AccessShareLock);
|
||||
relation = table_open(relationObjectId, AccessShareLock);
|
||||
|
||||
if (relation->rd_rel->relkind == RELKIND_RELATION
|
||||
#if PG_VERSION_NUM >= 90300
|
||||
|
|
@ -324,7 +324,7 @@ hypo_get_relation_info_hook(PlannerInfo *root,
|
|||
}
|
||||
|
||||
/* Close the relation release the lock now */
|
||||
heap_close(relation, AccessShareLock);
|
||||
table_close(relation, AccessShareLock);
|
||||
}
|
||||
|
||||
if (prev_get_relation_info_hook)
|
||||
|
|
|
|||
|
|
@ -1396,7 +1396,7 @@ hypopg_get_indexdef(PG_FUNCTION_ARGS)
|
|||
if (indexpr_item == NULL)
|
||||
elog(ERROR, "too few entries in indexprs list");
|
||||
indexkey = (Node *) lfirst(indexpr_item);
|
||||
indexpr_item = lnext(indexpr_item);
|
||||
indexpr_item = lnext(entry->indexprs, indexpr_item);
|
||||
|
||||
/* Deparse */
|
||||
str = deparse_expression(indexkey, context, false, false);
|
||||
|
|
@ -1546,7 +1546,7 @@ hypo_estimate_index_simple(hypoIndex * entry, BlockNumber *pages, double *tuples
|
|||
rel = makeNode(RelOptInfo);
|
||||
|
||||
/* Open the hypo index' relation */
|
||||
relation = heap_open(entry->relid, AccessShareLock);
|
||||
relation = table_open(entry->relid, AccessShareLock);
|
||||
|
||||
if (!RelationNeedsWAL(relation) && RecoveryInProgress())
|
||||
ereport(ERROR,
|
||||
|
|
@ -1567,7 +1567,7 @@ hypo_estimate_index_simple(hypoIndex * entry, BlockNumber *pages, double *tuples
|
|||
&rel->pages, &rel->tuples, &rel->allvisfrac);
|
||||
|
||||
/* Close the relation and release the lock now */
|
||||
heap_close(relation, AccessShareLock);
|
||||
table_close(relation, AccessShareLock);
|
||||
|
||||
hypo_estimate_index(entry, rel);
|
||||
*pages = entry->pages;
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ build_index_tlist(PlannerInfo *root, IndexOptInfo *index,
|
|||
if (indexpr_item == NULL)
|
||||
elog(ERROR, "wrong number of index expressions");
|
||||
indexvar = (Expr *) lfirst(indexpr_item);
|
||||
indexpr_item = lnext(indexpr_item);
|
||||
indexpr_item = lnext(index->indexprs, indexpr_item);
|
||||
}
|
||||
|
||||
tlist = lappend(tlist,
|
||||
|
|
|
|||
|
|
@ -22,6 +22,24 @@
|
|||
|
||||
#include "include/hypopg_import.h"
|
||||
|
||||
/* Provide backward compatibility macros for table.c API on pre v12 versions */
|
||||
#if PG_VERSION_NUM < 120000
|
||||
#define table_open(r, l) heap_open(r, l)
|
||||
#define table_close(r, l) heap_close(r, l)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Hacky macro to provide backward compatibility with either 1 or 2 arg lnext()
|
||||
* on pre v13 versions
|
||||
*/
|
||||
#if PG_VERSION_NUM < 130000
|
||||
#define LNEXT(_1, _2, NAME, ...) NAME
|
||||
#undef lnext
|
||||
#define lnext(...) LNEXT(__VA_ARGS__, LNEXT2, LNEXT1) (__VA_ARGS__)
|
||||
#define LNEXT1(lc) ((lc)->next)
|
||||
#define LNEXT2(list, lc) ((lc)->next)
|
||||
#endif
|
||||
|
||||
extern bool isExplain;
|
||||
|
||||
/* GUC for enabling / disabling hypopg during EXPLAIN */
|
||||
|
|
|
|||
Loading…
Reference in a new issue