Merge branch 'funky-version-check'
Conflicts: bin/expected/repack.out bin/sql/repack.sql
This commit is contained in:
commit
98d304712c
19
Makefile
19
Makefile
@ -6,22 +6,25 @@
|
|||||||
# Portions Copyright (c) 2012, The Reorg Development Team
|
# Portions Copyright (c) 2012, The Reorg Development Team
|
||||||
#
|
#
|
||||||
|
|
||||||
USE_PGXS = 1
|
PG_CONFIG ?= pg_config
|
||||||
PG_CONFIG = pg_config
|
|
||||||
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
|
||||||
include $(PGXS)
|
|
||||||
|
|
||||||
SUBDIRS = bin lib
|
|
||||||
|
|
||||||
# Pull out the version number from pg_config
|
# Pull out the version number from pg_config
|
||||||
VERSION = $(shell $(PG_CONFIG) --version | awk '{print $$2}')
|
VERSION := $(shell $(PG_CONFIG) --version | awk '{print $$2}')
|
||||||
|
ifeq ("$(VERSION)","")
|
||||||
|
$(error pg_config not found)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# version as a number, e.g. 9.1.4 -> 901
|
||||||
|
INTVERSION := $(shell echo $$(($$(echo $(VERSION) | sed -E 's/([0-9]+)\.([0-9]+).*/\1*100+\2/'))))
|
||||||
|
|
||||||
# We support PostgreSQL 8.3 and later.
|
# We support PostgreSQL 8.3 and later.
|
||||||
ifneq ($(shell echo $(VERSION) | grep -E "^7\.|^8\.[012]"),)
|
ifeq ($(shell echo $$(($(INTVERSION) < 803))),1)
|
||||||
$(error pg_repack requires PostgreSQL 8.3 or later. This is $(VERSION))
|
$(error pg_repack requires PostgreSQL 8.3 or later. This is $(VERSION))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
SUBDIRS = bin lib
|
||||||
|
|
||||||
all install installdirs uninstall distprep clean distclean maintainer-clean debug:
|
all install installdirs uninstall distprep clean distclean maintainer-clean debug:
|
||||||
@for dir in $(SUBDIRS); do \
|
@for dir in $(SUBDIRS); do \
|
||||||
$(MAKE) -C $$dir $@ || exit; \
|
$(MAKE) -C $$dir $@ || exit; \
|
||||||
|
54
bin/Makefile
54
bin/Makefile
@ -5,12 +5,40 @@
|
|||||||
# Portions Copyright (c) 2011, Itagaki Takahiro
|
# Portions Copyright (c) 2011, Itagaki Takahiro
|
||||||
# Portions Copyright (c) 2012, The Reorg Development Team
|
# Portions Copyright (c) 2012, The Reorg Development Team
|
||||||
#
|
#
|
||||||
|
|
||||||
|
PG_CONFIG ?= pg_config
|
||||||
|
|
||||||
|
# version as a number, e.g. 9.1.4 -> 901
|
||||||
|
VERSION := $(shell $(PG_CONFIG) --version | awk '{print $$2}')
|
||||||
|
INTVERSION := $(shell echo $$(($$(echo $(VERSION) | sed -E 's/([0-9]+)\.([0-9]+).*/\1*100+\2/'))))
|
||||||
|
|
||||||
SRCS = pg_repack.c pgut/pgut.c pgut/pgut-fe.c
|
SRCS = pg_repack.c pgut/pgut.c pgut/pgut-fe.c
|
||||||
OBJS = $(SRCS:.c=.o)
|
OBJS = $(SRCS:.c=.o)
|
||||||
PROGRAM = pg_repack
|
PROGRAM = pg_repack
|
||||||
REGRESS = init repack tablespace
|
|
||||||
|
|
||||||
EXTRA_CLEAN = sql/init-$(MAJORVERSION).sql sql/init.sql
|
|
||||||
|
#
|
||||||
|
# Test suite
|
||||||
|
#
|
||||||
|
|
||||||
|
ifeq ($(shell echo $$(($(INTVERSION) >= 901))),1)
|
||||||
|
REGRESS := init-extension
|
||||||
|
else
|
||||||
|
REGRESS := init-legacy
|
||||||
|
endif
|
||||||
|
|
||||||
|
# plpgsql not available by default on pg < 9.0
|
||||||
|
ifeq ($(shell echo $$(($(INTVERSION) < 900))),1)
|
||||||
|
REGRESS += plpgsql
|
||||||
|
endif
|
||||||
|
|
||||||
|
REGRESS += repack tablespace
|
||||||
|
|
||||||
|
# This test depends on collate, not supported before 9.1
|
||||||
|
ifeq ($(shell echo $$(($(INTVERSION) >= 901))),1)
|
||||||
|
REGRESS += issue3
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
# The version number of the program. It should be the same of the library.
|
# The version number of the program. It should be the same of the library.
|
||||||
REPACK_VERSION = $(shell grep '"version":' ../META.json | head -1 \
|
REPACK_VERSION = $(shell grep '"version":' ../META.json | head -1 \
|
||||||
@ -33,25 +61,3 @@ include $(PGXS)
|
|||||||
LIBS := $(filter-out -lxml2, $(LIBS))
|
LIBS := $(filter-out -lxml2, $(LIBS))
|
||||||
LIBS := $(filter-out -lxslt, $(LIBS))
|
LIBS := $(filter-out -lxslt, $(LIBS))
|
||||||
|
|
||||||
ifndef MAJORVERSION
|
|
||||||
MAJORVERSION := $(basename $(VERSION))
|
|
||||||
endif
|
|
||||||
|
|
||||||
sql/init.sql: sql/init-$(MAJORVERSION).sql
|
|
||||||
cp sql/init-$(MAJORVERSION).sql sql/init.sql
|
|
||||||
expected/init.out: expected/init-$(MAJORVERSION).out
|
|
||||||
cp expected/init-$(MAJORVERSION).out expected/init.out
|
|
||||||
sql/init-8.3.sql:
|
|
||||||
cp sql/init-legacy.sql sql/init-8.3.sql
|
|
||||||
sql/init-8.4.sql:
|
|
||||||
cp sql/init-legacy.sql sql/init-8.4.sql
|
|
||||||
sql/init-9.0.sql:
|
|
||||||
cp sql/init-legacy.sql sql/init-9.0.sql
|
|
||||||
sql/init-9.1.sql:
|
|
||||||
cp sql/init-extension.sql sql/init-9.1.sql
|
|
||||||
sql/init-9.2.sql:
|
|
||||||
cp sql/init-extension.sql sql/init-9.2.sql
|
|
||||||
sql/init-9.3.sql:
|
|
||||||
cp sql/init-extension.sql sql/init-9.3.sql
|
|
||||||
|
|
||||||
installcheck: sql/init.sql
|
|
||||||
|
3
bin/expected/init-extension.out
Normal file
3
bin/expected/init-extension.out
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
SET client_min_messages = warning;
|
||||||
|
CREATE EXTENSION pg_repack;
|
||||||
|
RESET client_min_messages;
|
53
bin/expected/issue3.out
Normal file
53
bin/expected/issue3.out
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
--
|
||||||
|
-- pg_repack issue #3
|
||||||
|
--
|
||||||
|
CREATE TABLE issue3_1 (col1 int NOT NULL, col2 text NOT NULL);
|
||||||
|
CREATE UNIQUE INDEX issue3_1_idx ON issue3_1 (col1, col2 DESC);
|
||||||
|
SELECT repack.get_order_by('issue3_1_idx'::regclass::oid, 'issue3_1'::regclass::oid);
|
||||||
|
get_order_by
|
||||||
|
-----------------
|
||||||
|
col1, col2 DESC
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
\! pg_repack --dbname=contrib_regression --table=issue3_1
|
||||||
|
INFO: repacking table "issue3_1"
|
||||||
|
CREATE TABLE issue3_2 (col1 int NOT NULL, col2 text NOT NULL);
|
||||||
|
CREATE UNIQUE INDEX issue3_2_idx ON issue3_2 (col1 DESC, col2 text_pattern_ops);
|
||||||
|
SELECT repack.get_order_by('issue3_2_idx'::regclass::oid, 'issue3_2'::regclass::oid);
|
||||||
|
get_order_by
|
||||||
|
---------------------------
|
||||||
|
col1 DESC, col2 USING ~<~
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
\! pg_repack --dbname=contrib_regression --table=issue3_2
|
||||||
|
INFO: repacking table "issue3_2"
|
||||||
|
CREATE TABLE issue3_3 (col1 int NOT NULL, col2 text NOT NULL);
|
||||||
|
CREATE UNIQUE INDEX issue3_3_idx ON issue3_3 (col1 DESC, col2 DESC);
|
||||||
|
SELECT repack.get_order_by('issue3_3_idx'::regclass::oid, 'issue3_3'::regclass::oid);
|
||||||
|
get_order_by
|
||||||
|
----------------------
|
||||||
|
col1 DESC, col2 DESC
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
\! pg_repack --dbname=contrib_regression --table=issue3_3
|
||||||
|
INFO: repacking table "issue3_3"
|
||||||
|
CREATE TABLE issue3_4 (col1 int NOT NULL, col2 text NOT NULL);
|
||||||
|
CREATE UNIQUE INDEX issue3_4_idx ON issue3_4 (col1 NULLS FIRST, col2 text_pattern_ops DESC NULLS LAST);
|
||||||
|
SELECT repack.get_order_by('issue3_4_idx'::regclass::oid, 'issue3_4'::regclass::oid);
|
||||||
|
get_order_by
|
||||||
|
--------------------------------------------------
|
||||||
|
col1 NULLS FIRST, col2 DESC USING ~<~ NULLS LAST
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
\! pg_repack --dbname=contrib_regression --table=issue3_4
|
||||||
|
INFO: repacking table "issue3_4"
|
||||||
|
CREATE TABLE issue3_5 (col1 int NOT NULL, col2 text NOT NULL);
|
||||||
|
CREATE UNIQUE INDEX issue3_5_idx ON issue3_5 (col1 DESC NULLS FIRST, col2 COLLATE "POSIX" DESC);
|
||||||
|
SELECT repack.get_order_by('issue3_5_idx'::regclass::oid, 'issue3_5'::regclass::oid);
|
||||||
|
get_order_by
|
||||||
|
--------------------------------------
|
||||||
|
col1 DESC, col2 COLLATE "POSIX" DESC
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
\! pg_repack --dbname=contrib_regression --table=issue3_5
|
||||||
|
INFO: repacking table "issue3_5"
|
1
bin/expected/plpgsql.out
Normal file
1
bin/expected/plpgsql.out
Normal file
@ -0,0 +1 @@
|
|||||||
|
CREATE LANGUAGE plpgsql;
|
@ -327,59 +327,6 @@ INFO: repacking table "tbl_pk_uk"
|
|||||||
WARNING: relation "tbl_nn_puk" must have a primary key or not-null unique keys
|
WARNING: relation "tbl_nn_puk" must have a primary key or not-null unique keys
|
||||||
-- => WARNING
|
-- => WARNING
|
||||||
--
|
--
|
||||||
-- pg_repack issue #3
|
|
||||||
--
|
|
||||||
CREATE TABLE issue3_1 (col1 int NOT NULL, col2 text NOT NULL);
|
|
||||||
CREATE UNIQUE INDEX issue3_1_idx ON issue3_1 (col1, col2 DESC);
|
|
||||||
SELECT repack.get_order_by('issue3_1_idx'::regclass::oid, 'issue3_1'::regclass::oid);
|
|
||||||
get_order_by
|
|
||||||
-----------------
|
|
||||||
col1, col2 DESC
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
\! pg_repack --dbname=contrib_regression --table=issue3_1
|
|
||||||
INFO: repacking table "issue3_1"
|
|
||||||
CREATE TABLE issue3_2 (col1 int NOT NULL, col2 text NOT NULL);
|
|
||||||
CREATE UNIQUE INDEX issue3_2_idx ON issue3_2 (col1 DESC, col2 text_pattern_ops);
|
|
||||||
SELECT repack.get_order_by('issue3_2_idx'::regclass::oid, 'issue3_2'::regclass::oid);
|
|
||||||
get_order_by
|
|
||||||
---------------------------
|
|
||||||
col1 DESC, col2 USING ~<~
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
\! pg_repack --dbname=contrib_regression --table=issue3_2
|
|
||||||
INFO: repacking table "issue3_2"
|
|
||||||
CREATE TABLE issue3_3 (col1 int NOT NULL, col2 text NOT NULL);
|
|
||||||
CREATE UNIQUE INDEX issue3_3_idx ON issue3_3 (col1 DESC, col2 DESC);
|
|
||||||
SELECT repack.get_order_by('issue3_3_idx'::regclass::oid, 'issue3_3'::regclass::oid);
|
|
||||||
get_order_by
|
|
||||||
----------------------
|
|
||||||
col1 DESC, col2 DESC
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
\! pg_repack --dbname=contrib_regression --table=issue3_3
|
|
||||||
INFO: repacking table "issue3_3"
|
|
||||||
CREATE TABLE issue3_4 (col1 int NOT NULL, col2 text NOT NULL);
|
|
||||||
CREATE UNIQUE INDEX issue3_4_idx ON issue3_4 (col1 NULLS FIRST, col2 text_pattern_ops DESC NULLS LAST);
|
|
||||||
SELECT repack.get_order_by('issue3_4_idx'::regclass::oid, 'issue3_4'::regclass::oid);
|
|
||||||
get_order_by
|
|
||||||
--------------------------------------------------
|
|
||||||
col1 NULLS FIRST, col2 DESC USING ~<~ NULLS LAST
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
\! pg_repack --dbname=contrib_regression --table=issue3_4
|
|
||||||
INFO: repacking table "issue3_4"
|
|
||||||
CREATE TABLE issue3_5 (col1 int NOT NULL, col2 text NOT NULL);
|
|
||||||
CREATE UNIQUE INDEX issue3_5_idx ON issue3_5 (col1 DESC NULLS FIRST, col2 COLLATE "POSIX" DESC);
|
|
||||||
SELECT repack.get_order_by('issue3_5_idx'::regclass::oid, 'issue3_5'::regclass::oid);
|
|
||||||
get_order_by
|
|
||||||
--------------------------------------
|
|
||||||
col1 DESC, col2 COLLATE "POSIX" DESC
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
\! pg_repack --dbname=contrib_regression --table=issue3_5
|
|
||||||
INFO: repacking table "issue3_5"
|
|
||||||
--
|
|
||||||
-- Triggers handling
|
-- Triggers handling
|
||||||
--
|
--
|
||||||
CREATE FUNCTION trgtest() RETURNS trigger AS
|
CREATE FUNCTION trgtest() RETURNS trigger AS
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
SET client_min_messages = warning;
|
SET client_min_messages = warning;
|
||||||
\set ECHO none
|
|
||||||
CREATE EXTENSION pg_repack;
|
CREATE EXTENSION pg_repack;
|
||||||
\set ECHO all
|
|
||||||
RESET client_min_messages;
|
RESET client_min_messages;
|
||||||
|
27
bin/sql/issue3.sql
Normal file
27
bin/sql/issue3.sql
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
--
|
||||||
|
-- pg_repack issue #3
|
||||||
|
--
|
||||||
|
CREATE TABLE issue3_1 (col1 int NOT NULL, col2 text NOT NULL);
|
||||||
|
CREATE UNIQUE INDEX issue3_1_idx ON issue3_1 (col1, col2 DESC);
|
||||||
|
SELECT repack.get_order_by('issue3_1_idx'::regclass::oid, 'issue3_1'::regclass::oid);
|
||||||
|
\! pg_repack --dbname=contrib_regression --table=issue3_1
|
||||||
|
|
||||||
|
CREATE TABLE issue3_2 (col1 int NOT NULL, col2 text NOT NULL);
|
||||||
|
CREATE UNIQUE INDEX issue3_2_idx ON issue3_2 (col1 DESC, col2 text_pattern_ops);
|
||||||
|
SELECT repack.get_order_by('issue3_2_idx'::regclass::oid, 'issue3_2'::regclass::oid);
|
||||||
|
\! pg_repack --dbname=contrib_regression --table=issue3_2
|
||||||
|
|
||||||
|
CREATE TABLE issue3_3 (col1 int NOT NULL, col2 text NOT NULL);
|
||||||
|
CREATE UNIQUE INDEX issue3_3_idx ON issue3_3 (col1 DESC, col2 DESC);
|
||||||
|
SELECT repack.get_order_by('issue3_3_idx'::regclass::oid, 'issue3_3'::regclass::oid);
|
||||||
|
\! pg_repack --dbname=contrib_regression --table=issue3_3
|
||||||
|
|
||||||
|
CREATE TABLE issue3_4 (col1 int NOT NULL, col2 text NOT NULL);
|
||||||
|
CREATE UNIQUE INDEX issue3_4_idx ON issue3_4 (col1 NULLS FIRST, col2 text_pattern_ops DESC NULLS LAST);
|
||||||
|
SELECT repack.get_order_by('issue3_4_idx'::regclass::oid, 'issue3_4'::regclass::oid);
|
||||||
|
\! pg_repack --dbname=contrib_regression --table=issue3_4
|
||||||
|
|
||||||
|
CREATE TABLE issue3_5 (col1 int NOT NULL, col2 text NOT NULL);
|
||||||
|
CREATE UNIQUE INDEX issue3_5_idx ON issue3_5 (col1 DESC NULLS FIRST, col2 COLLATE "POSIX" DESC);
|
||||||
|
SELECT repack.get_order_by('issue3_5_idx'::regclass::oid, 'issue3_5'::regclass::oid);
|
||||||
|
\! pg_repack --dbname=contrib_regression --table=issue3_5
|
1
bin/sql/plpgsql.sql
Normal file
1
bin/sql/plpgsql.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
CREATE LANGUAGE plpgsql;
|
@ -188,34 +188,6 @@ CREATE UNIQUE INDEX tbl_nn_puk_pcol1_idx ON tbl_nn_puk(col1) WHERE col1 < 10;
|
|||||||
\! pg_repack --dbname=contrib_regression --table=tbl_nn_puk
|
\! pg_repack --dbname=contrib_regression --table=tbl_nn_puk
|
||||||
-- => WARNING
|
-- => WARNING
|
||||||
|
|
||||||
--
|
|
||||||
-- pg_repack issue #3
|
|
||||||
--
|
|
||||||
CREATE TABLE issue3_1 (col1 int NOT NULL, col2 text NOT NULL);
|
|
||||||
CREATE UNIQUE INDEX issue3_1_idx ON issue3_1 (col1, col2 DESC);
|
|
||||||
SELECT repack.get_order_by('issue3_1_idx'::regclass::oid, 'issue3_1'::regclass::oid);
|
|
||||||
\! pg_repack --dbname=contrib_regression --table=issue3_1
|
|
||||||
|
|
||||||
CREATE TABLE issue3_2 (col1 int NOT NULL, col2 text NOT NULL);
|
|
||||||
CREATE UNIQUE INDEX issue3_2_idx ON issue3_2 (col1 DESC, col2 text_pattern_ops);
|
|
||||||
SELECT repack.get_order_by('issue3_2_idx'::regclass::oid, 'issue3_2'::regclass::oid);
|
|
||||||
\! pg_repack --dbname=contrib_regression --table=issue3_2
|
|
||||||
|
|
||||||
CREATE TABLE issue3_3 (col1 int NOT NULL, col2 text NOT NULL);
|
|
||||||
CREATE UNIQUE INDEX issue3_3_idx ON issue3_3 (col1 DESC, col2 DESC);
|
|
||||||
SELECT repack.get_order_by('issue3_3_idx'::regclass::oid, 'issue3_3'::regclass::oid);
|
|
||||||
\! pg_repack --dbname=contrib_regression --table=issue3_3
|
|
||||||
|
|
||||||
CREATE TABLE issue3_4 (col1 int NOT NULL, col2 text NOT NULL);
|
|
||||||
CREATE UNIQUE INDEX issue3_4_idx ON issue3_4 (col1 NULLS FIRST, col2 text_pattern_ops DESC NULLS LAST);
|
|
||||||
SELECT repack.get_order_by('issue3_4_idx'::regclass::oid, 'issue3_4'::regclass::oid);
|
|
||||||
\! pg_repack --dbname=contrib_regression --table=issue3_4
|
|
||||||
|
|
||||||
CREATE TABLE issue3_5 (col1 int NOT NULL, col2 text NOT NULL);
|
|
||||||
CREATE UNIQUE INDEX issue3_5_idx ON issue3_5 (col1 DESC NULLS FIRST, col2 COLLATE "POSIX" DESC);
|
|
||||||
SELECT repack.get_order_by('issue3_5_idx'::regclass::oid, 'issue3_5'::regclass::oid);
|
|
||||||
\! pg_repack --dbname=contrib_regression --table=issue3_5
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Triggers handling
|
-- Triggers handling
|
||||||
--
|
--
|
||||||
|
11
lib/Makefile
11
lib/Makefile
@ -6,7 +6,11 @@
|
|||||||
# Portions Copyright (c) 2012, The Reorg Development Team
|
# Portions Copyright (c) 2012, The Reorg Development Team
|
||||||
#
|
#
|
||||||
|
|
||||||
PG_CONFIG = pg_config
|
PG_CONFIG ?= pg_config
|
||||||
|
|
||||||
|
# version as a number, e.g. 9.1.4 -> 901
|
||||||
|
VERSION := $(shell $(PG_CONFIG) --version | awk '{print $$2}')
|
||||||
|
INTVERSION := $(shell echo $$(($$(echo $(VERSION) | sed -E 's/([0-9]+)\.([0-9]+).*/\1*100+\2/'))))
|
||||||
|
|
||||||
EXTENSION = pg_repack
|
EXTENSION = pg_repack
|
||||||
MODULE_big = $(EXTENSION)
|
MODULE_big = $(EXTENSION)
|
||||||
@ -20,10 +24,7 @@ REPACK_VERSION = $(shell grep '"version":' ../META.json | head -1 \
|
|||||||
PG_CPPFLAGS = -DREPACK_VERSION=$(REPACK_VERSION)
|
PG_CPPFLAGS = -DREPACK_VERSION=$(REPACK_VERSION)
|
||||||
|
|
||||||
# Support CREATE EXTENSION for PG >= 9.1 and a simple sql script for PG < 9.1
|
# Support CREATE EXTENSION for PG >= 9.1 and a simple sql script for PG < 9.1
|
||||||
HAVE_EXTENSION = $(shell $(PG_CONFIG) --version \
|
ifeq ($(shell echo $$(($(INTVERSION) >= 901))),1)
|
||||||
| grep -qE " 8\.| 9\.0" && echo no || echo yes)
|
|
||||||
|
|
||||||
ifeq ($(HAVE_EXTENSION),yes)
|
|
||||||
DATA_built = pg_repack--$(REPACK_VERSION).sql pg_repack.control
|
DATA_built = pg_repack--$(REPACK_VERSION).sql pg_repack.control
|
||||||
else
|
else
|
||||||
DATA_built = pg_repack.sql
|
DATA_built = pg_repack.sql
|
||||||
|
Loading…
x
Reference in New Issue
Block a user