Remove HAS_TABLEAM config since we dropped pg11 support (#4862)

* Remove HAS_TABLEAM config

* Drop columnar_ensure_objects_exist

* Not call columnar_ensure_objects_exist in citus_finish_pg_upgrade
rebalance/notice_for_no_move
Onur Tirtir 2021-04-13 10:51:26 +03:00 committed by GitHub
parent 716cc629f1
commit fe5c985e1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 189 additions and 121 deletions

View File

@ -93,7 +93,5 @@ endif
override CPPFLAGS := @CPPFLAGS@ @CITUS_CPPFLAGS@ -I '${citus_abs_top_srcdir}/src/include' -I'${citus_top_builddir}/src/include' $(CPPFLAGS) override CPPFLAGS := @CPPFLAGS@ @CITUS_CPPFLAGS@ -I '${citus_abs_top_srcdir}/src/include' -I'${citus_top_builddir}/src/include' $(CPPFLAGS)
override LDFLAGS += @LDFLAGS@ @CITUS_LDFLAGS@ override LDFLAGS += @LDFLAGS@ @CITUS_LDFLAGS@
HAS_TABLEAM:=@HAS_TABLEAM@
# optional file with user defined, additional, rules # optional file with user defined, additional, rules
-include ${citus_abs_srcdir}/src/Makefile.custom -include ${citus_abs_srcdir}/src/Makefile.custom

10
configure vendored
View File

@ -622,7 +622,6 @@ ac_includes_default="\
ac_subst_vars='LTLIBOBJS ac_subst_vars='LTLIBOBJS
LIBOBJS LIBOBJS
HAS_TABLEAM
HAS_DOTGIT HAS_DOTGIT
POSTGRES_BUILDDIR POSTGRES_BUILDDIR
POSTGRES_SRCDIR POSTGRES_SRCDIR
@ -4533,11 +4532,6 @@ cat >>confdefs.h <<_ACEOF
_ACEOF _ACEOF
HAS_TABLEAM=yes
$as_echo "#define HAS_TABLEAM 1" >>confdefs.h
# Require lz4 & zstd only if we are compiling columnar
if test "$HAS_TABLEAM" == 'yes'; then
# #
# LZ4 # LZ4
# #
@ -4724,8 +4718,6 @@ fi
fi fi
fi # test "$HAS_TABLEAM" == 'yes'
@ -4852,8 +4844,6 @@ POSTGRES_BUILDDIR="$POSTGRES_BUILDDIR"
HAS_DOTGIT="$HAS_DOTGIT" HAS_DOTGIT="$HAS_DOTGIT"
HAS_TABLEAM="$HAS_TABLEAM"
ac_config_files="$ac_config_files Makefile.global" ac_config_files="$ac_config_files Makefile.global"

View File

@ -216,11 +216,6 @@ PGAC_ARG_REQ(with, reports-hostname, [HOSTNAME],
AC_DEFINE_UNQUOTED(REPORTS_BASE_URL, "$REPORTS_BASE_URL", AC_DEFINE_UNQUOTED(REPORTS_BASE_URL, "$REPORTS_BASE_URL",
[Base URL for statistics collection and update checks]) [Base URL for statistics collection and update checks])
HAS_TABLEAM=yes
AC_DEFINE([HAS_TABLEAM], 1, [Define to 1 to build with table access method support, pg12 and up])
# Require lz4 & zstd only if we are compiling columnar
if test "$HAS_TABLEAM" == 'yes'; then
# #
# LZ4 # LZ4
# #
@ -259,8 +254,6 @@ if test "$HAS_TABLEAM" == 'yes'; then
Use --without-zstd to disable zstd support.])]) Use --without-zstd to disable zstd support.])])
fi fi
fi # test "$HAS_TABLEAM" == 'yes'
PGAC_ARG_BOOL(with, security-flags, no, PGAC_ARG_BOOL(with, security-flags, no,
[use security flags]) [use security flags])
@ -296,7 +289,6 @@ AC_SUBST(CITUS_LDFLAGS, "$LIBS $CITUS_LDFLAGS")
AC_SUBST(POSTGRES_SRCDIR, "$POSTGRES_SRCDIR") AC_SUBST(POSTGRES_SRCDIR, "$POSTGRES_SRCDIR")
AC_SUBST(POSTGRES_BUILDDIR, "$POSTGRES_BUILDDIR") AC_SUBST(POSTGRES_BUILDDIR, "$POSTGRES_BUILDDIR")
AC_SUBST(HAS_DOTGIT, "$HAS_DOTGIT") AC_SUBST(HAS_DOTGIT, "$HAS_DOTGIT")
AC_SUBST(HAS_TABLEAM, "$HAS_TABLEAM")
AC_CONFIG_FILES([Makefile.global]) AC_CONFIG_FILES([Makefile.global])
AC_CONFIG_HEADERS([src/include/citus_config.h] [src/include/citus_version.h]) AC_CONFIG_HEADERS([src/include/citus_config.h] [src/include/citus_version.h])

View File

@ -11,7 +11,6 @@
*/ */
#include "citus_version.h" #include "citus_version.h"
#if HAS_TABLEAM
#include "postgres.h" #include "postgres.h"
@ -495,6 +494,3 @@ ColumnarScan_ExplainCustomScan(CustomScanState *node, List *ancestors,
chunkGroupsFiltered, es); chunkGroupsFiltered, es);
} }
} }
#endif /* HAS_TABLEAM */

View File

@ -1393,7 +1393,6 @@ columnar_relation_storageid(PG_FUNCTION_ARGS)
{ {
uint64 storageId = -1; uint64 storageId = -1;
#if HAS_TABLEAM
Oid relationId = PG_GETARG_OID(0); Oid relationId = PG_GETARG_OID(0);
Relation relation = relation_open(relationId, AccessShareLock); Relation relation = relation_open(relationId, AccessShareLock);
if (IsColumnarTableAmTable(relationId)) if (IsColumnarTableAmTable(relationId))
@ -1406,7 +1405,6 @@ columnar_relation_storageid(PG_FUNCTION_ARGS)
} }
relation_close(relation, AccessShareLock); relation_close(relation, AccessShareLock);
#endif
PG_RETURN_INT64(storageId); PG_RETURN_INT64(storageId);
} }

View File

@ -1,5 +1,4 @@
#include "citus_version.h" #include "citus_version.h"
#if HAS_TABLEAM
#include "postgres.h" #include "postgres.h"
@ -1810,6 +1809,3 @@ alter_columnar_table_reset(PG_FUNCTION_ARGS)
PG_RETURN_VOID(); PG_RETURN_VOID();
} }
#endif

View File

@ -20,24 +20,18 @@
#include "columnar/columnar.h" #include "columnar/columnar.h"
#include "columnar/mod.h" #include "columnar/mod.h"
#ifdef HAS_TABLEAM
#include "columnar/columnar_tableam.h" #include "columnar/columnar_tableam.h"
#endif
void void
columnar_init(void) columnar_init(void)
{ {
columnar_init_gucs(); columnar_init_gucs();
#ifdef HAS_TABLEAM
columnar_tableam_init(); columnar_tableam_init();
#endif
} }
void void
columnar_fini(void) columnar_fini(void)
{ {
#if HAS_TABLEAM
columnar_tableam_finish(); columnar_tableam_finish();
#endif
} }

View File

@ -16,3 +16,7 @@ ALTER TABLE columnar.chunk_group DROP CONSTRAINT chunk_group_storage_id_fkey;
$$; $$;
END IF; END IF;
END$proc$; END$proc$;
-- since we dropped pg11 support, we don't need to worry about missing
-- columnar objects when upgrading postgres
DROP FUNCTION citus_internal.columnar_ensure_objects_exist();

View File

@ -8,3 +8,6 @@ REFERENCES columnar.chunk_group(storage_id, stripe_num, chunk_group_num) ON DELE
ALTER TABLE columnar.chunk_group ALTER TABLE columnar.chunk_group
ADD FOREIGN KEY (storage_id, stripe_num) ADD FOREIGN KEY (storage_id, stripe_num)
REFERENCES columnar.stripe(storage_id, stripe_num) ON DELETE CASCADE; REFERENCES columnar.stripe(storage_id, stripe_num) ON DELETE CASCADE;
-- define columnar_ensure_objects_exist again
#include "../udfs/columnar_ensure_objects_exist/10.0-1.sql"

View File

@ -4,7 +4,6 @@
#include "postgres.h" #include "postgres.h"
#include "columnar/columnar.h" #include "columnar/columnar.h"
#if HAS_TABLEAM
#include <math.h> #include <math.h>
@ -378,8 +377,6 @@ PendingWritesInUpperTransactions(Oid relfilenode, SubTransactionId currentSubXid
} }
#endif
/* /*
* GetWriteContextForDebug exposes WriteStateContext for debugging * GetWriteContextForDebug exposes WriteStateContext for debugging
* purposes. * purposes.
@ -387,9 +384,5 @@ PendingWritesInUpperTransactions(Oid relfilenode, SubTransactionId currentSubXid
extern MemoryContext extern MemoryContext
GetWriteContextForDebug(void) GetWriteContextForDebug(void)
{ {
#if HAS_TABLEAM
return WriteStateContext; return WriteStateContext;
#else
return NULL;
#endif
} }

View File

@ -682,7 +682,6 @@ ConvertTable(TableConversionState *con)
} }
/* set columnar options */ /* set columnar options */
#if HAS_TABLEAM
if (con->accessMethod == NULL && con->originalAccessMethod && if (con->accessMethod == NULL && con->originalAccessMethod &&
strcmp(con->originalAccessMethod, "columnar") == 0) strcmp(con->originalAccessMethod, "columnar") == 0)
{ {
@ -702,7 +701,6 @@ ConvertTable(TableConversionState *con)
ExecuteQueryViaSPI(columnarOptionsSql, SPI_OK_SELECT); ExecuteQueryViaSPI(columnarOptionsSql, SPI_OK_SELECT);
} }
#endif
con->newRelationId = get_relname_relid(con->tempName, con->schemaId); con->newRelationId = get_relname_relid(con->tempName, con->schemaId);

View File

@ -2,3 +2,4 @@
#include "../../columnar/sql/columnar--10.0-3--10.1-1.sql" #include "../../columnar/sql/columnar--10.0-3--10.1-1.sql"
#include "udfs/create_distributed_table/10.1-1.sql"; #include "udfs/create_distributed_table/10.1-1.sql";
#include "udfs/citus_finish_pg_upgrade/10.1-1.sql"

View File

@ -15,3 +15,5 @@ COMMENT ON FUNCTION create_distributed_table(table_name regclass,
distribution_type citus.distribution_type, distribution_type citus.distribution_type,
colocate_with text) colocate_with text)
IS 'creates a distributed table'; IS 'creates a distributed table';
#include "../udfs/citus_finish_pg_upgrade/10.0-1.sql"

View File

@ -0,0 +1,114 @@
CREATE OR REPLACE FUNCTION pg_catalog.citus_finish_pg_upgrade()
RETURNS void
LANGUAGE plpgsql
SET search_path = pg_catalog
AS $cppu$
DECLARE
table_name regclass;
command text;
trigger_name text;
BEGIN
--
-- restore citus catalog tables
--
INSERT INTO pg_catalog.pg_dist_partition SELECT * FROM public.pg_dist_partition;
INSERT INTO pg_catalog.pg_dist_shard SELECT * FROM public.pg_dist_shard;
INSERT INTO pg_catalog.pg_dist_placement SELECT * FROM public.pg_dist_placement;
INSERT INTO pg_catalog.pg_dist_node_metadata SELECT * FROM public.pg_dist_node_metadata;
INSERT INTO pg_catalog.pg_dist_node SELECT * FROM public.pg_dist_node;
INSERT INTO pg_catalog.pg_dist_local_group SELECT * FROM public.pg_dist_local_group;
INSERT INTO pg_catalog.pg_dist_transaction SELECT * FROM public.pg_dist_transaction;
INSERT INTO pg_catalog.pg_dist_colocation SELECT * FROM public.pg_dist_colocation;
-- enterprise catalog tables
INSERT INTO pg_catalog.pg_dist_authinfo SELECT * FROM public.pg_dist_authinfo;
INSERT INTO pg_catalog.pg_dist_poolinfo SELECT * FROM public.pg_dist_poolinfo;
ALTER TABLE pg_catalog.pg_dist_rebalance_strategy DISABLE TRIGGER pg_dist_rebalance_strategy_enterprise_check_trigger;
INSERT INTO pg_catalog.pg_dist_rebalance_strategy SELECT
name,
default_strategy,
shard_cost_function::regprocedure::regproc,
node_capacity_function::regprocedure::regproc,
shard_allowed_on_node_function::regprocedure::regproc,
default_threshold,
minimum_threshold
FROM public.pg_dist_rebalance_strategy;
ALTER TABLE pg_catalog.pg_dist_rebalance_strategy ENABLE TRIGGER pg_dist_rebalance_strategy_enterprise_check_trigger;
--
-- drop backup tables
--
DROP TABLE public.pg_dist_authinfo;
DROP TABLE public.pg_dist_colocation;
DROP TABLE public.pg_dist_local_group;
DROP TABLE public.pg_dist_node;
DROP TABLE public.pg_dist_node_metadata;
DROP TABLE public.pg_dist_partition;
DROP TABLE public.pg_dist_placement;
DROP TABLE public.pg_dist_poolinfo;
DROP TABLE public.pg_dist_shard;
DROP TABLE public.pg_dist_transaction;
DROP TABLE public.pg_dist_rebalance_strategy;
--
-- reset sequences
--
PERFORM setval('pg_catalog.pg_dist_shardid_seq', (SELECT MAX(shardid)+1 AS max_shard_id FROM pg_dist_shard), false);
PERFORM setval('pg_catalog.pg_dist_placement_placementid_seq', (SELECT MAX(placementid)+1 AS max_placement_id FROM pg_dist_placement), false);
PERFORM setval('pg_catalog.pg_dist_groupid_seq', (SELECT MAX(groupid)+1 AS max_group_id FROM pg_dist_node), false);
PERFORM setval('pg_catalog.pg_dist_node_nodeid_seq', (SELECT MAX(nodeid)+1 AS max_node_id FROM pg_dist_node), false);
PERFORM setval('pg_catalog.pg_dist_colocationid_seq', (SELECT MAX(colocationid)+1 AS max_colocation_id FROM pg_dist_colocation), false);
--
-- register triggers
--
FOR table_name IN SELECT logicalrelid FROM pg_catalog.pg_dist_partition
LOOP
trigger_name := 'truncate_trigger_' || table_name::oid;
command := 'create trigger ' || trigger_name || ' after truncate on ' || table_name || ' execute procedure pg_catalog.citus_truncate_trigger()';
EXECUTE command;
command := 'update pg_trigger set tgisinternal = true where tgname = ' || quote_literal(trigger_name);
EXECUTE command;
END LOOP;
--
-- set dependencies
--
INSERT INTO pg_depend
SELECT
'pg_class'::regclass::oid as classid,
p.logicalrelid::regclass::oid as objid,
0 as objsubid,
'pg_extension'::regclass::oid as refclassid,
(select oid from pg_extension where extname = 'citus') as refobjid,
0 as refobjsubid ,
'n' as deptype
FROM pg_catalog.pg_dist_partition p;
-- restore pg_dist_object from the stable identifiers
-- DELETE/INSERT to avoid primary key violations
WITH old_records AS (
DELETE FROM
citus.pg_dist_object
RETURNING
type,
object_names,
object_args,
distribution_argument_index,
colocationid
)
INSERT INTO citus.pg_dist_object (classid, objid, objsubid, distribution_argument_index, colocationid)
SELECT
address.classid,
address.objid,
address.objsubid,
naming.distribution_argument_index,
naming.colocationid
FROM
old_records naming,
pg_get_object_address(naming.type, naming.object_names, naming.object_args) address;
END;
$cppu$;
COMMENT ON FUNCTION pg_catalog.citus_finish_pg_upgrade()
IS 'perform tasks to restore citus settings from a location that has been prepared before pg_upgrade';

View File

@ -107,8 +107,6 @@ BEGIN
FROM FROM
old_records naming, old_records naming,
pg_get_object_address(naming.type, naming.object_names, naming.object_args) address; pg_get_object_address(naming.type, naming.object_names, naming.object_args) address;
PERFORM citus_internal.columnar_ensure_objects_exist();
END; END;
$cppu$; $cppu$;

View File

@ -31,9 +31,6 @@
/* A string containing the version number, platform, and C compiler */ /* A string containing the version number, platform, and C compiler */
#undef CITUS_VERSION_STR #undef CITUS_VERSION_STR
/* Define to 1 to build with table access method support, pg12 and up */
#undef HAS_TABLEAM
/* Define to 1 if you have the <inttypes.h> header file. */ /* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H #undef HAVE_INTTYPES_H

View File

@ -32,6 +32,3 @@
/* Base URL for statistics collection and update checks */ /* Base URL for statistics collection and update checks */
#undef REPORTS_BASE_URL #undef REPORTS_BASE_URL
/* columnar table access method capability */
#undef HAS_TABLEAM

View File

@ -1,5 +1,4 @@
#include "citus_version.h" #include "citus_version.h"
#if HAS_TABLEAM
#include "postgres.h" #include "postgres.h"
#include "fmgr.h" #include "fmgr.h"
@ -22,4 +21,3 @@ extern int64 ColumnarScanChunkGroupsFiltered(TableScanDesc scanDesc);
extern bool IsColumnarTableAmTable(Oid relationId); extern bool IsColumnarTableAmTable(Oid relationId);
extern TableDDLCommand * ColumnarGetTableOptionsDDL(Oid relationId); extern TableDDLCommand * ColumnarGetTableOptionsDDL(Oid relationId);
extern char * GetShardedTableDDLCommandColumnar(uint64 shardId, void *context); extern char * GetShardedTableDDLCommandColumnar(uint64 shardId, void *context);
#endif

View File

@ -562,9 +562,10 @@ ALTER EXTENSION citus UPDATE TO '10.1-1';
SELECT * FROM print_extension_changes(); SELECT * FROM print_extension_changes();
previous_object | current_object previous_object | current_object
--------------------------------------------------------------------- ---------------------------------------------------------------------
function citus_internal.columnar_ensure_objects_exist() |
function create_distributed_table(regclass,text,citus.distribution_type,text) | function create_distributed_table(regclass,text,citus.distribution_type,text) |
| function create_distributed_table(regclass,text,citus.distribution_type,text,integer) | function create_distributed_table(regclass,text,citus.distribution_type,text,integer)
(2 rows) (3 rows)
DROP TABLE prev_objects, extension_diff; DROP TABLE prev_objects, extension_diff;
-- show running version -- show running version

View File

@ -56,7 +56,6 @@ ORDER BY 1;
function citus_extradata_container(internal) function citus_extradata_container(internal)
function citus_finish_pg_upgrade() function citus_finish_pg_upgrade()
function citus_get_active_worker_nodes() function citus_get_active_worker_nodes()
function citus_internal.columnar_ensure_objects_exist()
function citus_internal.find_groupid_for_node(text,integer) function citus_internal.find_groupid_for_node(text,integer)
function citus_internal.pg_dist_node_trigger_func() function citus_internal.pg_dist_node_trigger_func()
function citus_internal.pg_dist_rebalance_strategy_enterprise_check() function citus_internal.pg_dist_rebalance_strategy_enterprise_check()
@ -243,5 +242,5 @@ ORDER BY 1;
view citus_worker_stat_activity view citus_worker_stat_activity
view pg_dist_shard_placement view pg_dist_shard_placement
view time_partitions view time_partitions
(227 rows) (226 rows)

View File

@ -53,7 +53,6 @@ ORDER BY 1;
function citus_extradata_container(internal) function citus_extradata_container(internal)
function citus_finish_pg_upgrade() function citus_finish_pg_upgrade()
function citus_get_active_worker_nodes() function citus_get_active_worker_nodes()
function citus_internal.columnar_ensure_objects_exist()
function citus_internal.find_groupid_for_node(text,integer) function citus_internal.find_groupid_for_node(text,integer)
function citus_internal.pg_dist_node_trigger_func() function citus_internal.pg_dist_node_trigger_func()
function citus_internal.pg_dist_rebalance_strategy_enterprise_check() function citus_internal.pg_dist_rebalance_strategy_enterprise_check()
@ -239,5 +238,5 @@ ORDER BY 1;
view citus_worker_stat_activity view citus_worker_stat_activity
view pg_dist_shard_placement view pg_dist_shard_placement
view time_partitions view time_partitions
(223 rows) (222 rows)