Skip to content

Commit

Permalink
Improve support of PostgreSQL 12
Browse files Browse the repository at this point in the history
  • Loading branch information
za-arthur committed Jul 30, 2019
1 parent 8f62247 commit 0e25dd1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pg_variables.c
Expand Up @@ -86,6 +86,19 @@ static void initObjectHistory(TransObject *object, TransObjectType type);
/* Hook functions */
static void variable_ExecutorEnd(QueryDesc *queryDesc);

#if PG_VERSION_NUM >= 120000
#define CHECK_ARGS_FOR_NULL() \
do { \
if (fcinfo->args[0].isnull) \
ereport(ERROR, \
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), \
errmsg("package name can not be NULL"))); \
if (fcinfo->args[1].isnull) \
ereport(ERROR, \
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), \
errmsg("variable name can not be NULL"))); \
} while(0)
#else /* PG_VERSION_NUM < 120000 */
#define CHECK_ARGS_FOR_NULL() \
do { \
if (fcinfo->argnull[0]) \
Expand All @@ -97,6 +110,7 @@ do { \
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), \
errmsg("variable name can not be NULL"))); \
} while(0)
#endif /* PG_VERSION_NUM */

static HTAB *packagesHash = NULL;
static MemoryContext ModuleContext = NULL;
Expand Down
2 changes: 2 additions & 0 deletions pg_variables_record.c
Expand Up @@ -137,7 +137,9 @@ init_record(RecordVar *record, TupleDesc tupdesc, Variable *variable)

oldcxt = MemoryContextSwitchTo(record->hctx);
record->tupdesc = CreateTupleDescCopy(tupdesc);
#if PG_VERSION_NUM < 120000
record->tupdesc->tdhasoid = false;
#endif
record->tupdesc->tdtypeid = RECORDOID;
record->tupdesc->tdtypmod = -1;
record->tupdesc = BlessTupleDesc(record->tupdesc);
Expand Down

0 comments on commit 0e25dd1

Please sign in to comment.