Permalink
Browse files

Update to build as an extension on 9.1.

  • Loading branch information...
1 parent 001505c commit e0abc714406a21d8d3b4a4f0036dc3ca3222cd77 @theory committed Apr 20, 2011
Showing with 46 additions and 14 deletions.
  1. +4 −0 Changes
  2. +25 −7 Makefile
  3. +5 −0 pair.control
  4. +9 −0 sql/pair--unpackaged.sql
  5. +0 −7 sql/pair.sql
  6. +1 −0 test/expected/base.out
  7. +2 −0 test/sql/base.sql
View
@@ -5,6 +5,10 @@ Revision history for PostgreSQL extension pair.
- Added abstract and doc file to the `provides` section of `META.json`.
- Changed doc extension to `.md` so that it will be parsed as Markdown
by PGXN.
+ - Added PostgreSQL 9.1 `CREATE EXTENSION` support, including migration
+ from an unpackaged install via `CREATE EXTENSION pair FROM
+ unpackaged`.
+
0.1.1 2010-10-29T22:42:05
- Fixed metadata file to list "pair" as the extension, not "pgtap".
View
@@ -1,15 +1,33 @@
-DATA = $(wildcard sql/*.sql)
+EXTENSION=pair
+EXTVERSION=0.1.2
+
+DATA = $(filter-out $(wildcard sql/*--*.sql),$(wildcard sql/*.sql))
DOCS = $(wildcard doc/*.txt)
TESTS = $(wildcard test/sql/*.sql)
REGRESS = $(patsubst test/sql/%.sql,%,$(TESTS))
REGRESS_OPTS = --inputdir=test
+MODULES = $(patsubst %.c,%,$(wildcard src/*.c))
-ifdef NO_PGXS
-top_builddir = ../..
-include $(top_builddir)/src/Makefile.global
-include $(top_srcdir)/contrib/contrib-global.mk
-else
PG_CONFIG = pg_config
+
+VERSION = $(shell $(PG_CONFIG) --version | awk '{print $$2}')
+PGVER_MAJOR = $(shell echo $(VERSION) | awk -F. '{ print ($$1 + 0) }')
+PGVER_MINOR = $(shell echo $(VERSION) | awk -F. '{ print ($$2 + 0) }')
+
+ifeq ($(PGVER_MAJOR), 9)
+ifneq ($(PGVER_MINOR), 0)
+all: sql/$(EXTENSION)--$(EXTVERSION).sql sql/$(EXTENSION)--unpackaged--$(EXTVERSION).sql
+
+sql/$(EXTENSION)--$(EXTVERSION).sql: sql/$(EXTENSION).sql
+ cp $< $@
+
+sql/$(EXTENSION)--unpackaged--$(EXTVERSION).sql: sql/$(EXTENSION)--unpackaged.sql
+ cp $< $@
+
+DATA = $(filter-out sql/$(EXTENSION)--unpackaged.sql,$(wildcard sql/*--*.sql)) sql/$(EXTENSION)--$(EXTVERSION).sql
+EXTRA_CLEAN = sql/$(EXTENSION)--$(EXTVERSION).sql sql/$(EXTENSION)--unpackaged--$(EXTVERSION).sql
+endif
+endif
+
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
-endif
View
@@ -0,0 +1,5 @@
+# pair extension
+comment = 'A key/value pair data type'
+default_version = '0.1.2'
+module_pathname = '$libdir/pair'
+relocatable = true
View
@@ -0,0 +1,9 @@
+ALTER EXTENSION pair ADD TYPE pair;
+ALTER EXTENSION pair ADD FUNCTION pair(anyelement, text);
+ALTER EXTENSION pair ADD FUNCTION pair(text, anyelement);
+ALTER EXTENSION pair ADD FUNCTION pair(anyelement, anyelement);
+ALTER EXTENSION pair ADD FUNCTION pair(text, text);
+ALTER EXTENSION pair ADD OPERATOR ~>(text, anyelement);
+ALTER EXTENSION pair ADD OPERATOR ~>(anyelement, text);
+ALTER EXTENSION pair ADD OPERATOR ~>(anyelement, anyelement);
+ALTER EXTENSION pair ADD OPERATOR ~>(text, text);
View
@@ -1,10 +1,5 @@
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
-
SET client_min_messages = warning;
-BEGIN;
-
CREATE TYPE pair AS ( k text, v text );
CREATE OR REPLACE FUNCTION pair(anyelement, text)
@@ -42,5 +37,3 @@ CREATE OPERATOR ~> (
RIGHTARG = text,
PROCEDURE = pair
);
-
-COMMIT;
View
@@ -72,3 +72,4 @@ SELECT ('foo' ~> 'bar').v;
bar
(1 row)
+ROLLBACK;
View
@@ -1,4 +1,5 @@
\set ECHO 0
+BEGIN;
\i sql/pair.sql
\set ECHO all
@@ -32,3 +33,4 @@ SELECT (pair('foo', 'bar')).v;
SELECT ('foo' ~> 'bar').k;
SELECT ('foo' ~> 'bar').v;
+ROLLBACK;

0 comments on commit e0abc71

Please sign in to comment.