Support for v13

merge-cstore-pykello
Jeff Davis 2020-11-01 16:57:31 -08:00
parent 65cf9f0a6c
commit acd49b68aa
4 changed files with 80 additions and 40 deletions

View File

@ -3,7 +3,7 @@
DO $proc$
BEGIN
IF version() ~ '12' THEN
IF version() ~ '12' or version() ~ '13' THEN
EXECUTE $$
CREATE FUNCTION cstore_tableam_handler(internal)
RETURNS table_am_handler

View File

@ -20,7 +20,11 @@
#include "access/heapam.h"
#include "access/reloptions.h"
#if PG_VERSION_NUM >= 130000
#include "access/heaptoast.h"
#else
#include "access/tuptoaster.h"
#endif
#include "access/xact.h"
#include "catalog/catalog.h"
#include "catalog/indexing.h"
@ -110,7 +114,14 @@ static const CStoreValidOption ValidOptionArray[] =
static object_access_hook_type prevObjectAccessHook = NULL;
/* local functions forward declarations */
#if PG_VERSION_NUM >= 100000
#if PG_VERSION_NUM >= 130000
static void CStoreProcessUtility(PlannedStmt *plannedStatement, const char *queryString,
ProcessUtilityContext context,
ParamListInfo paramListInfo,
QueryEnvironment *queryEnvironment,
DestReceiver *destReceiver,
QueryCompletion *queryCompletion);
#elif PG_VERSION_NUM >= 100000
static void CStoreProcessUtility(PlannedStmt *plannedStatement, const char *queryString,
ProcessUtilityContext context,
ParamListInfo paramListInfo,
@ -216,7 +227,8 @@ static ProcessUtility_hook_type PreviousProcessUtilityHook = NULL;
void
cstore_fdw_init()
{
PreviousProcessUtilityHook = ProcessUtility_hook;
PreviousProcessUtilityHook = (ProcessUtility_hook != NULL) ?
ProcessUtility_hook : standard_ProcessUtility;
ProcessUtility_hook = CStoreProcessUtility;
prevObjectAccessHook = object_access_hook;
object_access_hook = CStoreFdwObjectAccessHook;
@ -284,13 +296,20 @@ cstore_ddl_event_end_trigger(PG_FUNCTION_ARGS)
* the previous utility hook or the standard utility command via macro
* CALL_PREVIOUS_UTILITY.
*/
#if PG_VERSION_NUM >= 100000
#if PG_VERSION_NUM >= 130000
static void
CStoreProcessUtility(PlannedStmt *plannedStatement, const char *queryString,
ProcessUtilityContext context,
ParamListInfo paramListInfo,
QueryEnvironment *queryEnvironment,
DestReceiver *destReceiver, char *completionTag)
DestReceiver *destReceiver, QueryCompletion *queryCompletion)
#elif PG_VERSION_NUM >= 100000
static void
CStoreProcessUtility(PlannedStmt * plannedStatement, const char * queryString,
ProcessUtilityContext context,
ParamListInfo paramListInfo,
QueryEnvironment * queryEnvironment,
DestReceiver * destReceiver, char * completionTag)
#else
static void
CStoreProcessUtility(Node * parseTree, const char * queryString,
@ -299,6 +318,9 @@ CStoreProcessUtility(Node * parseTree, const char * queryString,
DestReceiver * destReceiver, char * completionTag)
#endif
{
#if PG_VERSION_NUM >= 130000
char *completionTag = NULL;
#endif
#if PG_VERSION_NUM >= 100000
Node *parseTree = plannedStatement->utilityStmt;
#endif
@ -313,8 +335,7 @@ CStoreProcessUtility(Node * parseTree, const char * queryString,
}
else
{
CALL_PREVIOUS_UTILITY(parseTree, queryString, context, paramListInfo,
destReceiver, completionTag);
CALL_PREVIOUS_UTILITY();
}
}
else if (nodeTag(parseTree) == T_TruncateStmt)
@ -330,8 +351,7 @@ CStoreProcessUtility(Node * parseTree, const char * queryString,
{
truncateStatement->relations = otherTablesList;
CALL_PREVIOUS_UTILITY(parseTree, queryString, context, paramListInfo,
destReceiver, completionTag);
CALL_PREVIOUS_UTILITY();
/* restore the former relation list. Our
* replacement could be freed but still needed
@ -352,21 +372,18 @@ CStoreProcessUtility(Node * parseTree, const char * queryString,
{
AlterTableStmt *alterTable = (AlterTableStmt *) parseTree;
CStoreProcessAlterTableCommand(alterTable);
CALL_PREVIOUS_UTILITY(parseTree, queryString, context, paramListInfo,
destReceiver, completionTag);
CALL_PREVIOUS_UTILITY();
}
else if (nodeTag(parseTree) == T_DropdbStmt)
{
/* let postgres handle error checking and dropping of the database */
CALL_PREVIOUS_UTILITY(parseTree, queryString, context, paramListInfo,
destReceiver, completionTag);
CALL_PREVIOUS_UTILITY();
}
/* handle other utility statements */
else
{
CALL_PREVIOUS_UTILITY(parseTree, queryString, context, paramListInfo,
destReceiver, completionTag);
CALL_PREVIOUS_UTILITY();
}
}

View File

@ -10,7 +10,11 @@
#include "access/rewriteheap.h"
#include "access/tableam.h"
#include "access/tsmapi.h"
#if PG_VERSION_NUM >= 130000
#include "access/heaptoast.h"
#else
#include "access/tuptoaster.h"
#endif
#include "access/xact.h"
#include "catalog/catalog.h"
#include "catalog/index.h"
@ -41,6 +45,7 @@
#include "cstore.h"
#include "cstore_customscan.h"
#include "cstore_tableam.h"
#include "cstore_version_compat.h"
#define CSTORE_TABLEAM_NAME "cstore_tableam"
@ -70,6 +75,15 @@ static ProcessUtility_hook_type PreviousProcessUtilityHook = NULL;
static void CStoreTableAMObjectAccessHook(ObjectAccessType access, Oid classId, Oid
objectId, int subId,
void *arg);
#if PG_VERSION_NUM >= 130000
static void CStoreTableAMProcessUtility(PlannedStmt *plannedStatement,
const char *queryString,
ProcessUtilityContext context,
ParamListInfo paramListInfo,
QueryEnvironment *queryEnvironment,
DestReceiver *destReceiver,
QueryCompletion *qc);
#else
static void CStoreTableAMProcessUtility(PlannedStmt *plannedStatement,
const char *queryString,
ProcessUtilityContext context,
@ -77,6 +91,8 @@ static void CStoreTableAMProcessUtility(PlannedStmt *plannedStatement,
QueryEnvironment *queryEnvironment,
DestReceiver *destReceiver,
char *completionTag);
#endif
static bool IsCStoreTableAmTable(Oid relationId);
static bool ConditionalLockRelationWithTimeout(Relation rel, LOCKMODE lockMode,
int timeout, int retryInterval);
@ -1035,6 +1051,7 @@ CStoreExecutorEnd(QueryDesc *queryDesc)
}
#if PG_VERSION_NUM >= 130000
static void
CStoreTableAMProcessUtility(PlannedStmt *plannedStatement,
const char *queryString,
@ -1042,7 +1059,17 @@ CStoreTableAMProcessUtility(PlannedStmt *plannedStatement,
ParamListInfo paramListInfo,
QueryEnvironment *queryEnvironment,
DestReceiver *destReceiver,
char *completionTag)
QueryCompletion *queryCompletion)
#else
static void
CStoreTableAMProcessUtility(PlannedStmt * plannedStatement,
const char * queryString,
ProcessUtilityContext context,
ParamListInfo paramListInfo,
QueryEnvironment * queryEnvironment,
DestReceiver * destReceiver,
char * completionTag)
#endif
{
Node *parseTree = plannedStatement->utilityStmt;
@ -1067,18 +1094,7 @@ CStoreTableAMProcessUtility(PlannedStmt *plannedStatement,
}
}
if (PreviousProcessUtilityHook != NULL)
{
PreviousProcessUtilityHook(plannedStatement, queryString, context,
paramListInfo, queryEnvironment,
destReceiver, completionTag);
}
else
{
standard_ProcessUtility(plannedStatement, queryString, context,
paramListInfo, queryEnvironment,
destReceiver, completionTag);
}
CALL_PREVIOUS_UTILITY();
}
@ -1087,7 +1103,8 @@ cstore_tableam_init()
{
PreviousExecutorEndHook = ExecutorEnd_hook;
ExecutorEnd_hook = CStoreExecutorEnd;
PreviousProcessUtilityHook = ProcessUtility_hook;
PreviousProcessUtilityHook = (ProcessUtility_hook != NULL) ?
ProcessUtility_hook : standard_ProcessUtility;
ProcessUtility_hook = CStoreTableAMProcessUtility;
prevObjectAccessHook = object_access_hook;
object_access_hook = CStoreTableAMObjectAccessHook;

View File

@ -32,18 +32,18 @@
ExplainPropertyInteger(qlabel, NULL, value, es)
#endif
#define PREVIOUS_UTILITY (PreviousProcessUtilityHook != NULL \
? PreviousProcessUtilityHook : standard_ProcessUtility)
#if PG_VERSION_NUM >= 100000
#define CALL_PREVIOUS_UTILITY(parseTree, queryString, context, paramListInfo, \
destReceiver, completionTag) \
PREVIOUS_UTILITY(plannedStatement, queryString, context, paramListInfo, \
queryEnvironment, destReceiver, completionTag)
#if PG_VERSION_NUM >= 130000
#define CALL_PREVIOUS_UTILITY() \
PreviousProcessUtilityHook(plannedStatement, queryString, context, paramListInfo, \
queryEnvironment, destReceiver, queryCompletion)
#elif PG_VERSION_NUM >= 100000
#define CALL_PREVIOUS_UTILITY() \
PreviousProcessUtilityHook(plannedStatement, queryString, context, paramListInfo, \
queryEnvironment, destReceiver, completionTag)
#else
#define CALL_PREVIOUS_UTILITY(parseTree, queryString, context, paramListInfo, \
destReceiver, completionTag) \
PREVIOUS_UTILITY(parseTree, queryString, context, paramListInfo, destReceiver, \
completionTag)
#define CALL_PREVIOUS_UTILITY() \
PreviousProcessUtilityHook(parseTree, queryString, context, paramListInfo, \
destReceiver, completionTag)
#endif
#if PG_VERSION_NUM < 120000
@ -56,4 +56,10 @@
#endif
#if PG_VERSION_NUM >= 130000
#define heap_open table_open
#define heap_openrv table_openrv
#define heap_close table_close
#endif
#endif /* CSTORE_COMPAT_H */