From 2c2ea7a5c7544383af70ce031fb53793862bc60e Mon Sep 17 00:00:00 2001 From: Yanwen Jin Date: Thu, 27 Jan 2022 15:24:17 -0800 Subject: [PATCH] [Columnar] Build columnar.so and let citus depends on it --- Makefile | 13 +- src/backend/columnar/Makefile | 7 +- src/backend/columnar/columnar.c | 1 - src/backend/columnar/columnar.control | 6 - src/backend/columnar/columnar_tableam.c | 67 ++-- src/backend/columnar/mod.c | 4 +- src/backend/columnar/sql/columnar--11.0-1.sql | 339 ------------------ src/backend/distributed/Makefile | 11 +- src/backend/distributed/shared_library_init.c | 12 +- 9 files changed, 48 insertions(+), 412 deletions(-) delete mode 100644 src/backend/columnar/columnar.control delete mode 100644 src/backend/columnar/sql/columnar--11.0-1.sql diff --git a/Makefile b/Makefile index 7569fd6ce..84d2b6151 100644 --- a/Makefile +++ b/Makefile @@ -13,10 +13,17 @@ include Makefile.global all: extension +#build columnar only +columnar: + $(MAKE) -C src/backend/columnar all + cp $(citus_abs_srcdir)/src/backend/columnar/columnar.so $(citus_abs_srcdir)/src/backend/distributed/ + # build extension -extension: $(citus_top_builddir)/src/include/citus_version.h +extension: $(citus_top_builddir)/src/include/citus_version.h columnar $(MAKE) -C src/backend/distributed/ all -install-extension: extension +install-columnar: + $(MAKE) -C src/backend/columnar install +install-extension: extension install-columnar $(MAKE) -C src/backend/distributed/ install install-headers: extension $(MKDIR_P) '$(DESTDIR)$(includedir_server)/distributed/' @@ -27,6 +34,8 @@ install-headers: extension clean-extension: $(MAKE) -C src/backend/distributed/ clean + rm -f $(citus_abs_srcdir)/src/backend/distributed/columnar.so + $(MAKE) -C src/backend/columnar/ clean clean-full: $(MAKE) -C src/backend/distributed/ clean-full .PHONY: extension install-extension clean-extension clean-full diff --git a/src/backend/columnar/Makefile b/src/backend/columnar/Makefile index 8d8616c9f..77c8f6939 100644 --- a/src/backend/columnar/Makefile +++ b/src/backend/columnar/Makefile @@ -1,7 +1,3 @@ -#SUBDIRS = . safeclib -#OBJS += \ - $(patsubst $(citus_abs_srcdir)/%.c,%.o,$(foreach dir,$(SUBDIRS), $(sort $(wildcard $(citus_abs_srcdir)/$(dir)/*.c)))) - safestringlib_srcdir = $(citus_abs_top_srcdir)/vendor/safestringlib MODULE_big = columnar @@ -24,7 +20,6 @@ OBJS = safeclib/mem_primitives_lib.o \ write_state_management.o PG_CPPFLAGS += -I$(libpq_srcdir) -I$(safestringlib_srcdir)/include -EXTENSION = columnar DATA = $(wildcard sql/*--*.sql) REGRESS = columnar @@ -37,4 +32,4 @@ else subdir = src/backend/columnar top_builddir = ../../.. include $(top_builddir)/Makefile.global -endif +endif \ No newline at end of file diff --git a/src/backend/columnar/columnar.c b/src/backend/columnar/columnar.c index af0d4fe52..08d2d0fd8 100644 --- a/src/backend/columnar/columnar.c +++ b/src/backend/columnar/columnar.c @@ -23,7 +23,6 @@ #include "citus_version.h" #include "columnar/columnar.h" -PG_MODULE_MAGIC; /* Default values for option parameters */ #define DEFAULT_STRIPE_ROW_COUNT 150000 diff --git a/src/backend/columnar/columnar.control b/src/backend/columnar/columnar.control deleted file mode 100644 index 1a24e6dd9..000000000 --- a/src/backend/columnar/columnar.control +++ /dev/null @@ -1,6 +0,0 @@ -# Columnar extension -comment = 'Columnar extension' -default_version = '11.0-1' -module_pathname = '$libdir/columnar' -relocatable = false -schema = pg_catalog diff --git a/src/backend/columnar/columnar_tableam.c b/src/backend/columnar/columnar_tableam.c index 17508b519..6ae0547af 100644 --- a/src/backend/columnar/columnar_tableam.c +++ b/src/backend/columnar/columnar_tableam.c @@ -171,7 +171,7 @@ columnar_beginscan(Relation relation, Snapshot snapshot, ParallelTableScanDesc parallel_scan, uint32 flags) { - //CheckCitusVersion(ERROR); + CheckCitusVersion(ERROR); int natts = relation->rd_att->natts; @@ -418,7 +418,7 @@ columnar_parallelscan_reinitialize(Relation rel, ParallelTableScanDesc pscan) static IndexFetchTableData * columnar_index_fetch_begin(Relation rel) { - //CheckCitusVersion(ERROR); + CheckCitusVersion(ERROR); Oid relfilenode = rel->rd_node.relNode; if (PendingWritesInUpperTransactions(relfilenode, GetCurrentSubTransactionId())) @@ -643,7 +643,7 @@ static bool columnar_tuple_satisfies_snapshot(Relation rel, TupleTableSlot *slot, Snapshot snapshot) { - //CheckCitusVersion(ERROR); + CheckCitusVersion(ERROR); uint64 rowNumber = tid_to_row_number(slot->tts_tid); StripeMetadata *stripeMetadata = FindStripeByRowNumber(rel, rowNumber, snapshot); @@ -656,7 +656,7 @@ static TransactionId columnar_index_delete_tuples(Relation rel, TM_IndexDeleteOp *delstate) { - //CheckCitusVersion(ERROR); + CheckCitusVersion(ERROR); /* * XXX: We didn't bother implementing index_delete_tuple for neither of @@ -717,7 +717,7 @@ static void columnar_tuple_insert(Relation relation, TupleTableSlot *slot, CommandId cid, int options, BulkInsertState bistate) { - //CheckCitusVersion(ERROR); + CheckCitusVersion(ERROR); /* * columnar_init_write_state allocates the write state in a longer @@ -765,7 +765,7 @@ static void columnar_multi_insert(Relation relation, TupleTableSlot **slots, int ntuples, CommandId cid, int options, BulkInsertState bistate) { - //CheckCitusVersion(ERROR); + CheckCitusVersion(ERROR); ColumnarWriteState *writeState = columnar_init_write_state(relation, RelationGetDescr(relation), @@ -841,7 +841,7 @@ columnar_relation_set_new_filenode(Relation rel, TransactionId *freezeXid, MultiXactId *minmulti) { - //CheckCitusVersion(ERROR); + CheckCitusVersion(ERROR); if (persistence == RELPERSISTENCE_UNLOGGED) { @@ -878,7 +878,7 @@ columnar_relation_set_new_filenode(Relation rel, static void columnar_relation_nontransactional_truncate(Relation rel) { - //CheckCitusVersion(ERROR); + CheckCitusVersion(ERROR); RelFileNode relfilenode = rel->rd_node; @@ -926,7 +926,7 @@ columnar_relation_copy_for_cluster(Relation OldHeap, Relation NewHeap, double *tups_vacuumed, double *tups_recently_dead) { - //CheckCitusVersion(ERROR); + CheckCitusVersion(ERROR); TupleDesc sourceDesc = RelationGetDescr(OldHeap); TupleDesc targetDesc = RelationGetDescr(NewHeap); @@ -1024,14 +1024,14 @@ static void columnar_vacuum_rel(Relation rel, VacuumParams *params, BufferAccessStrategy bstrategy) { - // if (!CheckCitusVersion(WARNING)) - // { - // /* - // * Skip if the extension catalogs are not up-to-date, but avoid - // * erroring during auto-vacuum. - // */ - // return; - // } + if (!CheckCitusVersion(WARNING)) + { + /* + * Skip if the extension catalogs are not up-to-date, but avoid + * erroring during auto-vacuum. + */ + return; + } /* * If metapage version of relation is older, then we hint users to VACUUM @@ -1342,7 +1342,7 @@ columnar_index_build_range_scan(Relation columnarRelation, void *callback_state, TableScanDesc scan) { - //CheckCitusVersion(ERROR); + CheckCitusVersion(ERROR); if (start_blockno != 0 || numblocks != InvalidBlockNumber) { @@ -1592,7 +1592,7 @@ columnar_index_validate_scan(Relation columnarRelation, ValidateIndexState * validateIndexState) { -// CheckCitusVersion(ERROR); + CheckCitusVersion(ERROR); ColumnarReportTotalVirtualBlocks(columnarRelation, snapshot, PROGRESS_SCAN_BLOCKS_TOTAL); @@ -1764,7 +1764,7 @@ TupleSortSkipSmallerItemPointers(Tuplesortstate *tupleSort, ItemPointer targetIt static uint64 columnar_relation_size(Relation rel, ForkNumber forkNumber) { - //CheckCitusVersion(ERROR); + CheckCitusVersion(ERROR); uint64 nblocks = 0; @@ -1791,7 +1791,7 @@ columnar_relation_size(Relation rel, ForkNumber forkNumber) static bool columnar_relation_needs_toast_table(Relation rel) { - //CheckCitusVersion(ERROR); + CheckCitusVersion(ERROR); return false; } @@ -1802,7 +1802,7 @@ columnar_estimate_rel_size(Relation rel, int32 *attr_widths, BlockNumber *pages, double *tuples, double *allvisfrac) { - //CheckCitusVersion(ERROR); + CheckCitusVersion(ERROR); RelationOpenSmgr(rel); *pages = smgrnblocks(rel->rd_smgr, MAIN_FORKNUM); @@ -1975,7 +1975,7 @@ ColumnarTableDropHook(Oid relid) if (IsColumnarTableAmTable(relid)) { - //CheckCitusVersion(ERROR); + CheckCitusVersion(ERROR); /* * Drop metadata. No need to drop storage here since for @@ -2100,7 +2100,7 @@ ColumnarProcessUtility(PlannedStmt *pstmt, if (rel->rd_tableam == GetColumnarTableAmRoutine()) { - //CheckCitusVersion(ERROR); + CheckCitusVersion(ERROR); if (!ColumnarSupportsIndexAM(indexStmt->accessMethod)) { @@ -2323,7 +2323,7 @@ PG_FUNCTION_INFO_V1(alter_columnar_table_set); Datum alter_columnar_table_set(PG_FUNCTION_ARGS) { - //CheckCitusVersion(ERROR); + CheckCitusVersion(ERROR); Oid relationId = PG_GETARG_OID(0); @@ -2443,7 +2443,7 @@ PG_FUNCTION_INFO_V1(alter_columnar_table_reset); Datum alter_columnar_table_reset(PG_FUNCTION_ARGS) { - //CheckCitusVersion(ERROR); + CheckCitusVersion(ERROR); Oid relationId = PG_GETARG_OID(0); @@ -2507,21 +2507,6 @@ alter_columnar_table_reset(PG_FUNCTION_ARGS) PG_RETURN_VOID(); } -/* - * Check that the current user has owner rights to relationId, error out if - * not. Superusers are regarded as owners. - */ -void -EnsureTableOwner(Oid relationId) -{ - if (!pg_class_ownercheck(relationId, GetUserId())) - { - aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_TABLE, - get_rel_name(relationId)); - } -} - - /* * upgrade_columnar_storage - upgrade columnar storage to the current diff --git a/src/backend/columnar/mod.c b/src/backend/columnar/mod.c index 9f58e9943..e2a472a29 100644 --- a/src/backend/columnar/mod.c +++ b/src/backend/columnar/mod.c @@ -22,10 +22,11 @@ #include "columnar/columnar_tableam.h" +PG_MODULE_MAGIC; + void _PG_init(void); void _PG_fini(void); -//columnar_init void _PG_init(void) { @@ -33,7 +34,6 @@ _PG_init(void) columnar_tableam_init(); } -//columnar_fini void _PG_fini(void) { diff --git a/src/backend/columnar/sql/columnar--11.0-1.sql b/src/backend/columnar/sql/columnar--11.0-1.sql deleted file mode 100644 index 89fc1d93b..000000000 --- a/src/backend/columnar/sql/columnar--11.0-1.sql +++ /dev/null @@ -1,339 +0,0 @@ --- columnar--9.5-1--10.0-1.sql - -CREATE SCHEMA columnar; -SET search_path TO columnar; - - -CREATE SEQUENCE storageid_seq MINVALUE 10000000000 NO CYCLE; - -CREATE TABLE options ( - regclass regclass NOT NULL PRIMARY KEY, - chunk_group_row_limit int NOT NULL, - stripe_row_limit int NOT NULL, - compression_level int NOT NULL, - compression name NOT NULL -) WITH (user_catalog_table = true); - -COMMENT ON TABLE options IS 'columnar table specific options, maintained by alter_columnar_table_set'; - -CREATE TABLE stripe ( - storage_id bigint NOT NULL, - stripe_num bigint NOT NULL, - file_offset bigint NOT NULL, - data_length bigint NOT NULL, - column_count int NOT NULL, - chunk_row_count int NOT NULL, - row_count bigint NOT NULL, - chunk_group_count int NOT NULL, - PRIMARY KEY (storage_id, stripe_num) -) WITH (user_catalog_table = true); - -COMMENT ON TABLE stripe IS 'Columnar per stripe metadata'; - -CREATE TABLE chunk_group ( - storage_id bigint NOT NULL, - stripe_num bigint NOT NULL, - chunk_group_num int NOT NULL, - row_count bigint NOT NULL, - PRIMARY KEY (storage_id, stripe_num, chunk_group_num), - FOREIGN KEY (storage_id, stripe_num) REFERENCES stripe(storage_id, stripe_num) ON DELETE CASCADE -); - -COMMENT ON TABLE chunk_group IS 'Columnar chunk group metadata'; - -CREATE TABLE chunk ( - storage_id bigint NOT NULL, - stripe_num bigint NOT NULL, - attr_num int NOT NULL, - chunk_group_num int NOT NULL, - minimum_value bytea, - maximum_value bytea, - value_stream_offset bigint NOT NULL, - value_stream_length bigint NOT NULL, - exists_stream_offset bigint NOT NULL, - exists_stream_length bigint NOT NULL, - value_compression_type int NOT NULL, - value_compression_level int NOT NULL, - value_decompressed_length bigint NOT NULL, - value_count bigint NOT NULL, - PRIMARY KEY (storage_id, stripe_num, attr_num, chunk_group_num), - FOREIGN KEY (storage_id, stripe_num, chunk_group_num) REFERENCES chunk_group(storage_id, stripe_num, chunk_group_num) ON DELETE CASCADE -) WITH (user_catalog_table = true); - -COMMENT ON TABLE chunk IS 'Columnar per chunk metadata'; - -DO $proc$ -BEGIN - --- from version 12 and up we have support for tableam's if installed on pg11 we can't --- create the objects here. Instead we rely on citus_finish_pg_upgrade to be called by the --- user instead to add the missing objects -IF substring(current_Setting('server_version'), '\d+')::int >= 12 THEN - EXECUTE $$ ---#include "udfs/columnar_handler/10.0-1.sql" -CREATE OR REPLACE FUNCTION columnar.columnar_handler(internal) - RETURNS table_am_handler - LANGUAGE C -AS 'MODULE_PATHNAME', 'columnar_handler'; -COMMENT ON FUNCTION columnar.columnar_handler(internal) - IS 'internal function returning the handler for columnar tables'; - --- postgres 11.8 does not support the syntax for table am, also it is seemingly trying --- to parse the upgrade file and erroring on unknown syntax. --- normally this section would not execute on postgres 11 anyway. To trick it to pass on --- 11.8 we wrap the statement in a plpgsql block together with an EXECUTE. This is valid --- syntax on 11.8 and will execute correctly in 12 -DO $create_table_am$ -BEGIN -EXECUTE 'CREATE ACCESS METHOD columnar TYPE TABLE HANDLER columnar.columnar_handler'; -END $create_table_am$; - ---#include "udfs/alter_columnar_table_set/10.0-1.sql" -CREATE OR REPLACE FUNCTION pg_catalog.alter_columnar_table_set( - table_name regclass, - chunk_group_row_limit int DEFAULT NULL, - stripe_row_limit int DEFAULT NULL, - compression name DEFAULT null, - compression_level int DEFAULT NULL) - RETURNS void - LANGUAGE C -AS 'MODULE_PATHNAME', 'alter_columnar_table_set'; - -COMMENT ON FUNCTION pg_catalog.alter_columnar_table_set( - table_name regclass, - chunk_group_row_limit int, - stripe_row_limit int, - compression name, - compression_level int) -IS 'set one or more options on a columnar table, when set to NULL no change is made'; - - ---#include "udfs/alter_columnar_table_reset/10.0-1.sql" -CREATE OR REPLACE FUNCTION pg_catalog.alter_columnar_table_reset( - table_name regclass, - chunk_group_row_limit bool DEFAULT false, - stripe_row_limit bool DEFAULT false, - compression bool DEFAULT false, - compression_level bool DEFAULT false) - RETURNS void - LANGUAGE C -AS 'MODULE_PATHNAME', 'alter_columnar_table_reset'; - -COMMENT ON FUNCTION pg_catalog.alter_columnar_table_reset( - table_name regclass, - chunk_group_row_limit bool, - stripe_row_limit bool, - compression bool, - compression_level bool) -IS 'reset on or more options on a columnar table to the system defaults'; - - $$; -END IF; -END$proc$; - --- add citus_internal schema -CREATE SCHEMA IF NOT EXISTS citus_internal; - --- dropped in 10.0.3#include "udfs/columnar_ensure_objects_exist/10.0-1.sql" - --- citus_internal.columnar_ensure_objects_exist is an internal helper function to create --- missing objects, anything related to the table access methods. --- Since the API for table access methods is only available in PG12 we can't create these --- objects when Citus is installed in PG11. Once citus is installed on PG11 the user can --- upgrade their database to PG12. Now they require the table access method objects that --- we couldn't create before. --- This internal function is called from `citus_finish_pg_upgrade` which the user is --- required to call after a PG major upgrade. -CREATE OR REPLACE FUNCTION citus_internal.columnar_ensure_objects_exist() - RETURNS void - LANGUAGE plpgsql - SET search_path = pg_catalog -AS $ceoe$ -BEGIN - --- when postgres is version 12 or above we need to create the tableam. If the tableam --- exist we assume all objects have been created. --- IF substring(current_Setting('server_version'), '\d+')::int >= 12 THEN --- IF NOT EXISTS (SELECT 1 FROM pg_am WHERE amname = 'columnar') THEN - --- --#include "../columnar_handler/10.0-1.sql" - --- --#include "../alter_columnar_table_set/10.0-1.sql" - --- --#include "../alter_columnar_table_reset/10.0-1.sql" - --- -- ?? --- -- add the missing objects to the extension --- ALTER EXTENSION citus ADD FUNCTION columnar.columnar_handler(internal); --- ALTER EXTENSION citus ADD ACCESS METHOD columnar; --- ALTER EXTENSION citus ADD FUNCTION pg_catalog.alter_columnar_table_set( --- table_name regclass, --- chunk_group_row_limit int, --- stripe_row_limit int, --- compression name, --- compression_level int); --- ALTER EXTENSION citus ADD FUNCTION pg_catalog.alter_columnar_table_reset( --- table_name regclass, --- chunk_group_row_limit bool, --- stripe_row_limit bool, --- compression bool, --- compression_level bool); - --- END IF; --- END IF; --- END; --- $ceoe$; - --- COMMENT ON FUNCTION citus_internal.columnar_ensure_objects_exist() --- IS 'internal function to be called by pg_catalog.citus_finish_pg_upgrade responsible for creating the columnar objects'; - - -RESET search_path; - --- columnar--10.0.-1 --10.0.2 -GRANT USAGE ON SCHEMA columnar TO PUBLIC; -GRANT SELECT ON ALL tables IN SCHEMA columnar TO PUBLIC ; - --- columnar--10.0-3--10.1-1.sql - --- Drop foreign keys between columnar metadata tables. --- Postgres assigns different names to those foreign keys in PG11, so act accordingly. -DO $proc$ -BEGIN -IF substring(current_Setting('server_version'), '\d+')::int >= 12 THEN - EXECUTE $$ -ALTER TABLE columnar.chunk DROP CONSTRAINT chunk_storage_id_stripe_num_chunk_group_num_fkey; -ALTER TABLE columnar.chunk_group DROP CONSTRAINT chunk_group_storage_id_stripe_num_fkey; - $$; -ELSE - EXECUTE $$ -ALTER TABLE columnar.chunk DROP CONSTRAINT chunk_storage_id_fkey; -ALTER TABLE columnar.chunk_group DROP CONSTRAINT chunk_group_storage_id_fkey; - $$; -END IF; -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(); - ---10.1-1 -- 10.2-1 - --- columnar--10.1-1--10.2-1.sql - --- For a proper mapping between tid & (stripe, row_num), add a new column to --- columnar.stripe and define a BTREE index on this column. --- Also include storage_id column for per-relation scans. -ALTER TABLE columnar.stripe ADD COLUMN first_row_number bigint; -CREATE INDEX stripe_first_row_number_idx ON columnar.stripe USING BTREE(storage_id, first_row_number); - --- Populate first_row_number column of columnar.stripe table. --- --- For simplicity, we calculate MAX(row_count) value across all the stripes --- of all the columanar tables and then use it to populate first_row_number --- column. This would introduce some gaps however we are okay with that since --- it's already the case with regular INSERT/COPY's. -DO $$ -DECLARE - max_row_count bigint; - -- this should be equal to columnar_storage.h/COLUMNAR_FIRST_ROW_NUMBER - COLUMNAR_FIRST_ROW_NUMBER constant bigint := 1; -BEGIN - SELECT MAX(row_count) INTO max_row_count FROM columnar.stripe; - UPDATE columnar.stripe SET first_row_number = COLUMNAR_FIRST_ROW_NUMBER + - (stripe_num - 1) * max_row_count; -END; -$$; - ---#include "udfs/upgrade_columnar_storage/10.2-1.sql" -CREATE OR REPLACE FUNCTION citus_internal.upgrade_columnar_storage(rel regclass) - RETURNS VOID - STRICT - LANGUAGE c AS 'MODULE_PATHNAME', $$upgrade_columnar_storage$$; - -COMMENT ON FUNCTION citus_internal.upgrade_columnar_storage(regclass) - IS 'function to upgrade the columnar storage, if necessary'; - - ---#include "udfs/downgrade_columnar_storage/10.2-1.sql" - -CREATE OR REPLACE FUNCTION citus_internal.downgrade_columnar_storage(rel regclass) - RETURNS VOID - STRICT - LANGUAGE c AS 'MODULE_PATHNAME', $$downgrade_columnar_storage$$; - -COMMENT ON FUNCTION citus_internal.downgrade_columnar_storage(regclass) - IS 'function to downgrade the columnar storage, if necessary'; - --- upgrade storage for all columnar relations -SELECT citus_internal.upgrade_columnar_storage(c.oid) FROM pg_class c, pg_am a - WHERE c.relam = a.oid AND amname = 'columnar'; - --- columnar--10.2-1--10.2-2.sql - --- revoke read access for columnar.chunk from unprivileged --- user as it contains chunk min/max values -REVOKE SELECT ON columnar.chunk FROM PUBLIC; - - --- columnar--10.2-2--10.2-3.sql - --- Since stripe_first_row_number_idx is required to scan a columnar table, we --- need to make sure that it is created before doing anything with columnar --- tables during pg upgrades. --- --- However, a plain btree index is not a dependency of a table, so pg_upgrade --- cannot guarantee that stripe_first_row_number_idx gets created when --- creating columnar.stripe, unless we make it a unique "constraint". --- --- To do that, drop stripe_first_row_number_idx and create a unique --- constraint with the same name to keep the code change at minimum. -DROP INDEX columnar.stripe_first_row_number_idx; -ALTER TABLE columnar.stripe ADD CONSTRAINT stripe_first_row_number_idx -UNIQUE (storage_id, first_row_number); - --- columnar--10.2-3--10.2-4.sql - -CREATE OR REPLACE FUNCTION citus_internal.columnar_ensure_am_depends_catalog() - RETURNS void - LANGUAGE plpgsql - SET search_path = pg_catalog -AS $func$ -BEGIN - INSERT INTO pg_depend - SELECT -- Define a dependency edge from "columnar table access method" .. - 'pg_am'::regclass::oid as classid, - (select oid from pg_am where amname = 'columnar') as objid, - 0 as objsubid, - -- ... to each object that is registered to pg_class and that lives - -- in "columnar" schema. That contains catalog tables, indexes - -- created on them and the sequences created in "columnar" schema. - -- - -- Given the possibility of user might have created their own objects - -- in columnar schema, we explicitly specify list of objects that we - -- are interested in. - 'pg_class'::regclass::oid as refclassid, - columnar_schema_members.relname::regclass::oid as refobjid, - 0 as refobjsubid, - 'n' as deptype - FROM (VALUES ('columnar.chunk'), - ('columnar.chunk_group'), - ('columnar.chunk_group_pkey'), - ('columnar.chunk_pkey'), - ('columnar.options'), - ('columnar.options_pkey'), - ('columnar.storageid_seq'), - ('columnar.stripe'), - ('columnar.stripe_first_row_number_idx'), - ('columnar.stripe_pkey') - ) columnar_schema_members(relname) - -- Avoid inserting duplicate entries into pg_depend. - EXCEPT TABLE pg_depend; -END; -$func$; -COMMENT ON FUNCTION citus_internal.columnar_ensure_am_depends_catalog() - IS 'internal function responsible for creating dependencies from columnar ' - 'table access method to the rel objects in columnar schema'; - - -SELECT citus_internal.columnar_ensure_am_depends_catalog(); diff --git a/src/backend/distributed/Makefile b/src/backend/distributed/Makefile index a2ffcc142..716a62fbc 100644 --- a/src/backend/distributed/Makefile +++ b/src/backend/distributed/Makefile @@ -19,8 +19,7 @@ DATA_built = $(generated_sql_files) # directories with source files SUBDIRS = . commands connection ddl deparser executor metadata operations planner progress relay safeclib test transaction utils worker -# columnar modules -SUBDIRS += ../columnar + # enterprise modules SUBDIRS += @@ -34,14 +33,16 @@ OBJS += \ $(patsubst $(citus_abs_srcdir)/%.c,%.o,$(foreach dir,$(SUBDIRS), $(sort $(wildcard $(citus_abs_srcdir)/$(dir)/*.c)))) # be explicit about the default target -all: +all: NO_PGXS = 1 -SHLIB_LINK = $(libpq) +SHLIB_LINK += $(libpq) columnar.so include $(citus_top_builddir)/Makefile.global +rpathdir = $(shell $(PG_CONFIG) --libdir):$(shell $(PG_CONFIG) --pkglibdir) + # make sure citus_version.o is recompiled whenever any change is made to the binary or any # other artifact being installed to reflect the correct gitref for every build CITUS_VERSION_INVALIDATE := $(filter-out utils/citus_version.o,$(OBJS)) @@ -86,7 +87,7 @@ endif cleanup-before-install: rm -f $(DESTDIR)$(datadir)/$(datamoduledir)/citus* -install: cleanup-before-install +install: cleanup-before-install # install and install-downgrades should be run sequentially install-all: install diff --git a/src/backend/distributed/shared_library_init.c b/src/backend/distributed/shared_library_init.c index 5e3ab85d2..ca5de68b5 100644 --- a/src/backend/distributed/shared_library_init.c +++ b/src/backend/distributed/shared_library_init.c @@ -354,18 +354,10 @@ _PG_init(void) { DoInitialCleanup(); } - columnar_init(); + + load_file("columnar.so", false); } - -/* shared library deconstruction function */ -void -_PG_fini(void) -{ - columnar_fini(); -} - - /* * DoInitialCleanup does cleanup at start time. * Currently it: