Code

Added support for installing PostRR as an extension.
authorSebastian Harl <sh@tokkee.org>
Mon, 12 Nov 2012 20:24:11 +0000 (21:24 +0100)
committerSebastian Harl <sh@tokkee.org>
Mon, 12 Nov 2012 20:24:11 +0000 (21:24 +0100)
 * 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

.gitignore
configure.ac
src/Makefile.pgxs.in
src/postrr.control.in [new file with mode: 0644]
src/postrr.sql.in
src/uninstall_postrr.sql

index 6848d40571bcb31ad5b41f7c7b1dc89ed537f4ee..ce4ac14c203ea3a1b17c23ecf8db401ec2ee79a4 100644 (file)
@@ -25,7 +25,9 @@ ltmain.sh
 *.lo
 *.o
 postrr.7
 *.lo
 *.o
 postrr.7
+postrr.control
 postrr.h
 postrr.sql
 postrr.h
 postrr.sql
+postrr--*.sql
 postrr-*.so
 
 postrr-*.so
 
index 613595b10b669c4d2d8aa50ef41f25ffc1f19bba..cf16d83d45320de5d03b8a56ee59274558e59c75 100644 (file)
@@ -247,7 +247,7 @@ AM_CONDITIONAL([BUILD_DOCUMENTATION], test "x$build_documentation" = "xyes")
 
 AC_CONFIG_FILES([Makefile doc/Makefile
                src/Makefile src/Makefile.pgxs
 
 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()
 AC_OUTPUT
 
 AC_MSG_RESULT()
index f223061c439fa8fde40b8bdc29cac92cb2d8ff27..a91f7bd911606a4ed0edd8ddc5d5977a5b8207a3 100644 (file)
 PG_CPPFLAGS = @STRICT_CPPFLAGS@ -I@abs_builddir@
 
 MODULE_big=postrr-@POSTRR_MAJOR_VERSION@.@POSTRR_MINOR_VERSION@
 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
 
 
 PG_OBJS=base.o \
                cdata.o \
                rrtimeslice.o \
                utils/pg_spi.o
 
+EXTENSION=postrr
+
 DATA=postrr_comments.sql uninstall_postrr.sql
 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)
 
 # objects to be build by PGXS
 OBJS=$(PG_OBJS)
@@ -43,3 +44,6 @@ PG_CONFIG=@PG_CONFIG@
 PGXS=@PGXS@
 include $(PGXS)
 
 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 (file)
index 0000000..ff0afd3
--- /dev/null
@@ -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
+
index a3bff336ae94ef5288b4ab927a7a3c4704359d83..34d125773fa4da1cacc7864657899956af5ee41a 100644 (file)
 -- PostRR - PostgreSQL Round-Robin Extension
 --
 
 -- 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;
 
 
 CREATE SCHEMA postrr;
 
@@ -45,6 +43,8 @@ CREATE TABLE postrr.rrtimeslices (
        tsnum integer NOT NULL
 );
 
        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,
 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)
 );
 
        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'
 CREATE OR REPLACE FUNCTION PostRR_Version()
        RETURNS cstring
        AS 'postrr-@POSTRR_MAJOR_VERSION@.@POSTRR_MINOR_VERSION@', 'postrr_version'
@@ -408,9 +410,5 @@ BEGIN
 END;
 $$;
 
 END;
 $$;
 
-COMMIT;
-
-SET client_min_messages TO DEFAULT;
-
 -- vim: set tw=78 sw=4 ts=4 noexpandtab :
 
 -- vim: set tw=78 sw=4 ts=4 noexpandtab :
 
index 088309cd113fc9dfbc267ef80157243c5816b965..5bb3519c60c1d657d321c5428201aefddca11489 100644 (file)
 -- PostRR - PostgreSQL Round-Robin Extension
 --
 
 -- 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 :
 
 
 -- vim: set tw=78 sw=4 ts=4 noexpandtab :