From: Sebastian Harl Date: Mon, 12 Nov 2012 20:24:11 +0000 (+0100) Subject: Added support for installing PostRR as an extension. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=7e1366eab3849806ee6c671dcb3174814c98f198;p=postrr.git Added support for installing PostRR as an extension. * Added initial control file (generated by configure from .in) * Moved postrr.sql to postrr--VERSION.sql * Abort, if the SQL file is loaded directly (-> force the use of the extension) * Simply use 'DROP EXTENSION' in uninstall_postrr.sql --- diff --git a/.gitignore b/.gitignore index 6848d40..ce4ac14 100644 --- a/.gitignore +++ b/.gitignore @@ -25,7 +25,9 @@ ltmain.sh *.lo *.o postrr.7 +postrr.control postrr.h postrr.sql +postrr--*.sql postrr-*.so diff --git a/configure.ac b/configure.ac index 613595b..cf16d83 100644 --- a/configure.ac +++ b/configure.ac @@ -247,7 +247,7 @@ AM_CONDITIONAL([BUILD_DOCUMENTATION], test "x$build_documentation" = "xyes") AC_CONFIG_FILES([Makefile doc/Makefile src/Makefile src/Makefile.pgxs - src/postrr.sql]) + src/postrr.sql src/postrr.control]) AC_OUTPUT AC_MSG_RESULT() diff --git a/src/Makefile.pgxs.in b/src/Makefile.pgxs.in index f223061..a91f7bd 100644 --- a/src/Makefile.pgxs.in +++ b/src/Makefile.pgxs.in @@ -25,15 +25,16 @@ PG_CPPFLAGS = @STRICT_CPPFLAGS@ -I@abs_builddir@ MODULE_big=postrr-@POSTRR_MAJOR_VERSION@.@POSTRR_MINOR_VERSION@ -MODULEDIR=contrib/$(MODULE) PG_OBJS=base.o \ cdata.o \ rrtimeslice.o \ utils/pg_spi.o +EXTENSION=postrr + DATA=postrr_comments.sql uninstall_postrr.sql -DATA_built=postrr.sql +DATA_built=postrr--@POSTRR_MAJOR_VERSION@.@POSTRR_MINOR_VERSION@.@POSTRR_PATCH_VERSION@.sql # objects to be build by PGXS OBJS=$(PG_OBJS) @@ -43,3 +44,6 @@ PG_CONFIG=@PG_CONFIG@ PGXS=@PGXS@ include $(PGXS) +postrr--@POSTRR_MAJOR_VERSION@.@POSTRR_MINOR_VERSION@.@POSTRR_PATCH_VERSION@.sql: postrr.sql + cp $< $@ + diff --git a/src/postrr.control.in b/src/postrr.control.in new file mode 100644 index 0000000..ff0afd3 --- /dev/null +++ b/src/postrr.control.in @@ -0,0 +1,6 @@ +# PostRR extension +comment = 'PostgreSQL Round Robin Extension' +default_version = '@POSTRR_MAJOR_VERSION@.@POSTRR_MINOR_VERSION@.@POSTRR_PATCH_VERSION@' +module_pathname = '$libdir/postrr' +superuser = false + diff --git a/src/postrr.sql.in b/src/postrr.sql.in index a3bff33..34d1257 100644 --- a/src/postrr.sql.in +++ b/src/postrr.sql.in @@ -27,10 +27,8 @@ -- PostRR - PostgreSQL Round-Robin Extension -- --- suppress messages like 'return type foo is only a shell' -SET client_min_messages TO WARNING; - -BEGIN; +-- complain if script is sourced in psql, rather than via CREATE EXTENSION +\echo Use "CREATE EXTENSION postrr" to load this file. \quit CREATE SCHEMA postrr; @@ -45,6 +43,8 @@ CREATE TABLE postrr.rrtimeslices ( tsnum integer NOT NULL ); +SELECT pg_catalog.pg_extension_config_dump('postrr.rrtimeslices', ''); + CREATE TABLE postrr.rrarchives ( rraname text NOT NULL, tbl name NOT NULL, @@ -53,6 +53,8 @@ CREATE TABLE postrr.rrarchives ( UNIQUE (rraname, tbl, tscol, vcol) ); +SELECT pg_catalog.pg_extension_config_dump('postrr.rrarchives', ''); + CREATE OR REPLACE FUNCTION PostRR_Version() RETURNS cstring AS 'postrr-@POSTRR_MAJOR_VERSION@.@POSTRR_MINOR_VERSION@', 'postrr_version' @@ -408,9 +410,5 @@ BEGIN END; $$; -COMMIT; - -SET client_min_messages TO DEFAULT; - -- vim: set tw=78 sw=4 ts=4 noexpandtab : diff --git a/src/uninstall_postrr.sql b/src/uninstall_postrr.sql index 088309c..5bb3519 100644 --- a/src/uninstall_postrr.sql +++ b/src/uninstall_postrr.sql @@ -27,36 +27,7 @@ -- PostRR - PostgreSQL Round-Robin Extension -- -SET client_min_messages TO WARNING; - -DROP FUNCTION IF EXISTS RRTimeslice_validate(integer); - -DROP CAST IF EXISTS (rrtimeslice AS rrtimeslice); -DROP FUNCTION IF EXISTS RRTimeslice(rrtimeslice, integer, boolean); -DROP CAST IF EXISTS (rrtimeslice AS timestamp); -DROP FUNCTION IF EXISTS Tstamp(rrtimeslice); -DROP TYPE RRTimeslice CASCADE; -DROP FUNCTION IF EXISTS RRTimeslice_typmodin(cstring[]); -DROP FUNCTION IF EXISTS RRTimeslice_typmodout(integer); - -DROP FUNCTION IF EXISTS CData_validate(integer); - -DROP CAST IF EXISTS (cdata AS cdata); -DROP FUNCTION IF EXISTS CData(cdata, integer, boolean); -DROP TYPE CData CASCADE; -DROP FUNCTION IF EXISTS CData_typmodin(cstring[]); -DROP FUNCTION IF EXISTS CData_typmodout(integer); - -DROP FUNCTION IF EXISTS PostRR_Version(); - -DROP TABLE postrr.rrtimeslices; -DROP SEQUENCE postrr.tsid; - -DROP TABLE postrr.rrarchives; - -DROP SCHEMA postrr; - -SET client_min_messages TO DEFAULT; +DROP EXTENSION postrr; -- vim: set tw=78 sw=4 ts=4 noexpandtab :