Build Columnar.so and make Citus depends on it (#5661)

* [Columnar] Build columnar.so and let citus depends on it


Co-authored-by: Yanwen Jin <yanwjin@microsoft.com>
Co-authored-by: Ying Xu <32597660+yxu2162@users.noreply.github.com>
Co-authored-by: jeff-davis <Jeffrey.Davis@microsoft.com>
pull/5749/head
ywj 2022-03-01 12:31:14 -08:00 committed by GitHub
parent 65bd540943
commit a4133c69e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 48 additions and 11 deletions

View File

@ -10,13 +10,18 @@ ifeq (,$(wildcard Makefile.global))
endif endif
include Makefile.global include Makefile.global
all: extension all: extension
#build columnar only
columnar:
$(MAKE) -C src/backend/columnar all
# build extension # 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 $(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 $(MAKE) -C src/backend/distributed/ install
install-headers: extension install-headers: extension
$(MKDIR_P) '$(DESTDIR)$(includedir_server)/distributed/' $(MKDIR_P) '$(DESTDIR)$(includedir_server)/distributed/'
@ -27,6 +32,7 @@ install-headers: extension
clean-extension: clean-extension:
$(MAKE) -C src/backend/distributed/ clean $(MAKE) -C src/backend/distributed/ clean
$(MAKE) -C src/backend/columnar/ clean
clean-full: clean-full:
$(MAKE) -C src/backend/distributed/ clean-full $(MAKE) -C src/backend/distributed/ clean-full
.PHONY: extension install-extension clean-extension clean-full .PHONY: extension install-extension clean-extension clean-full
@ -35,8 +41,8 @@ install: install-extension install-headers
install-downgrades: install-downgrades:
$(MAKE) -C src/backend/distributed/ install-downgrades $(MAKE) -C src/backend/distributed/ install-downgrades
install-all: install-headers install-all: install-headers
$(MAKE) -C src/backend/columnar/ install-all
$(MAKE) -C src/backend/distributed/ install-all $(MAKE) -C src/backend/distributed/ install-all
clean: clean-extension clean: clean-extension
# apply or check style # apply or check style

View File

@ -0,0 +1,17 @@
citus_subdir = src/backend/columnar
citus_top_builddir = ../../..
safestringlib_srcdir = $(citus_abs_top_srcdir)/vendor/safestringlib
SUBDIRS = . safeclib
SUBDIRS +=
ENSURE_SUBDIRS_EXIST := $(shell mkdir -p $(SUBDIRS))
OBJS += \
$(patsubst $(citus_abs_srcdir)/%.c,%.o,$(foreach dir,$(SUBDIRS), $(sort $(wildcard $(citus_abs_srcdir)/$(dir)/*.c))))
MODULE_big = citus_columnar
PG_CPPFLAGS += -I$(libpq_srcdir) -I$(safestringlib_srcdir)/include
include $(citus_top_builddir)/Makefile.global
.PHONY: install-all
install-all: install

View File

@ -11,7 +11,6 @@
#include "postgres.h" #include "postgres.h"
#include "funcapi.h" #include "funcapi.h"
#include "pg_config.h"
#include "access/nbtree.h" #include "access/nbtree.h"
#include "access/table.h" #include "access/table.h"
#include "catalog/pg_am.h" #include "catalog/pg_am.h"

View File

@ -22,8 +22,13 @@
#include "columnar/columnar_tableam.h" #include "columnar/columnar_tableam.h"
PG_MODULE_MAGIC;
void _PG_init(void);
void void
columnar_init(void) _PG_init(void)
{ {
columnar_init_gucs(); columnar_init_gucs();
columnar_tableam_init(); columnar_tableam_init();

View File

@ -0,0 +1 @@
../../../vendor/safestringlib/safeclib/

View File

@ -19,8 +19,6 @@ DATA_built = $(generated_sql_files)
# directories with source files # directories with source files
SUBDIRS = . commands connection ddl deparser executor metadata operations planner progress relay safeclib test transaction utils worker SUBDIRS = . commands connection ddl deparser executor metadata operations planner progress relay safeclib test transaction utils worker
# columnar modules
SUBDIRS += ../columnar
# enterprise modules # enterprise modules
SUBDIRS += SUBDIRS +=
@ -39,9 +37,12 @@ all:
NO_PGXS = 1 NO_PGXS = 1
SHLIB_LINK = $(libpq) SHLIB_LINK = $(libpq)
SHLIB_LINK_INTERNAL += -L../columnar -l:citus_columnar.so
override enable_rpath = yes
include $(citus_top_builddir)/Makefile.global 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 # 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 # other artifact being installed to reflect the correct gitref for every build
CITUS_VERSION_INVALIDATE := $(filter-out utils/citus_version.o,$(OBJS)) CITUS_VERSION_INVALIDATE := $(filter-out utils/citus_version.o,$(OBJS))
@ -84,7 +85,8 @@ endif
.PHONY: clean-full install install-downgrades install-all .PHONY: clean-full install install-downgrades install-all
cleanup-before-install: cleanup-before-install:
rm -f $(DESTDIR)$(datadir)/$(datamoduledir)/citus* rm -f $(DESTDIR)$(datadir)/$(datamoduledir)/citus.control
rm -f $(DESTDIR)$(datadir)/$(datamoduledir)/citus--*
install: cleanup-before-install install: cleanup-before-install

View File

@ -353,7 +353,13 @@ _PG_init(void)
{ {
DoInitialCleanup(); DoInitialCleanup();
} }
columnar_init();
/*
* For convenience and backwards compatibility, we avoid users having to add both
* citus and columnar to shared_preload_libraries by loading citus_columnar.so as part of
* loading citus.so.
*/
load_file(COLUMNAR_LIB_NAME, false);
} }

View File

@ -11,6 +11,7 @@
#ifndef MOD_H #ifndef MOD_H
#define MOD_H #define MOD_H
#define COLUMNAR_LIB_NAME "citus_columnar"
/* Function declarations for extension loading and unloading */ /* Function declarations for extension loading and unloading */
extern void columnar_init(void); extern void columnar_init(void);