diff --git a/.circleci/config.yml b/.circleci/config.yml index 9f2532c1d..645211182 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -45,6 +45,20 @@ jobs: paths: - install-12.tar + build-13: + docker: + - image: 'citus/extbuilder:13.0' + steps: + - checkout + - run: + name: 'Configure, Build, and Install' + command: | + PG_MAJOR=13 .circleci/build.sh + - persist_to_workspace: + root: . + paths: + - install-13.tar + test-11_checkinstall: docker: - image: 'citus/exttester:11.9' @@ -85,6 +99,26 @@ jobs: - codecov/upload: flags: 'test_12,installcheck' + test-13_checkinstall: + docker: + - image: 'citus/exttester:13.0' + working_directory: /home/circleci/project + steps: + - checkout + - attach_workspace: + at: . + - run: + name: 'Prepare Container & Install Extension' + command: | + chown -R circleci:circleci /home/circleci + tar xfv "${CIRCLE_WORKING_DIRECTORY}/install-${PG_MAJOR}.tar" --directory / + - run: + name: 'Run Test' + command: | + gosu circleci .circleci/run_test.sh installcheck + - codecov/upload: + flags: 'test_13,installcheck' + workflows: version: 2 build_and_test: @@ -94,8 +128,11 @@ workflows: - build-11 - build-12 + - build-13 - test-11_checkinstall: requires: [build-11] - test-12_checkinstall: requires: [build-12] + - test-13_checkinstall: + requires: [build-13] diff --git a/cstore_fdw--1.7--1.8.sql b/cstore_fdw--1.7--1.8.sql index 8fe9416d1..cf6d510d5 100644 --- a/cstore_fdw--1.7--1.8.sql +++ b/cstore_fdw--1.7--1.8.sql @@ -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 diff --git a/cstore_fdw.c b/cstore_fdw.c index 221c97843..328125535 100644 --- a/cstore_fdw.c +++ b/cstore_fdw.c @@ -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(); } } diff --git a/cstore_tableam.c b/cstore_tableam.c index ae7799410..c22ab7baf 100644 --- a/cstore_tableam.c +++ b/cstore_tableam.c @@ -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; diff --git a/cstore_version_compat.h b/cstore_version_compat.h index 3d1a60f93..69eb9c9f3 100644 --- a/cstore_version_compat.h +++ b/cstore_version_compat.h @@ -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 */