Skip to content

Commit 3ca814c

Browse files
committed
pathman: makefile changed in order to aggregate sql scripts
1 parent 4a264d2 commit 3ca814c

File tree

5 files changed

+19
-13
lines changed

5 files changed

+19
-13
lines changed

contrib/pathman/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.o
2+
*.so

contrib/pathman/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ MODULE_big = pathman
44
OBJS = init.o pathman.o $(WIN32RES)
55

66
EXTENSION = pathman
7+
EXTVERSION = 0.1
78
DATA = pathman--0.1.sql
89
PGFILEDESC = "pathman - partitioning tool"
910

1011
REGRESS = pathman
1112

13+
$(EXTENSION)--$(EXTVERSION).sql: sql/init.sql sql/hash.sql sql/range.sql
14+
cat $^ > $@
15+
1216
ifdef USE_PGXS
1317
PG_CONFIG = pg_config
1418
PGXS := $(shell $(PG_CONFIG) --pgxs)
@@ -18,4 +22,4 @@ subdir = contrib/pathman
1822
top_builddir = ../..
1923
include $(top_builddir)/src/Makefile.global
2024
include $(top_srcdir)/contrib/contrib-global.mk
21-
endif
25+
endif

contrib/pathman/sql/hash.sql

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/*
22
* Creates hash partitions for specified relation
33
*/
4-
CREATE OR REPLACE FUNCTION public.create_hash_partitions(
5-
IN relation TEXT
6-
, IN attribute TEXT
7-
, IN partitions_count INTEGER
4+
CREATE OR REPLACE FUNCTION create_hash_partitions(
5+
relation TEXT
6+
, attribute TEXT
7+
, partitions_count INTEGER
88
) RETURNS VOID AS
99
$$
1010
DECLARE
@@ -24,12 +24,12 @@ BEGIN
2424
/* Create partitions and update pg_pathman configuration */
2525
FOR partnum IN 0..partitions_count-1
2626
LOOP
27-
EXECUTE format('CREATE TABLE %s_%s (LIKE %1$s INCLUDING ALL)',
28-
relation
27+
EXECUTE format('CREATE TABLE %s_%s (LIKE %1$s INCLUDING ALL)'
28+
, relation
2929
, partnum);
3030

3131
EXECUTE format('ALTER TABLE %s_%s INHERIT %1$s'
32-
relation
32+
, relation
3333
, partnum);
3434

3535
-- EXECUTE format('CREATE TABLE %s_%s () INHERITS (%1$s)', relation, partnum);
@@ -52,7 +52,7 @@ $$ LANGUAGE plpgsql;
5252
/*
5353
* Creates hash trigger for specified relation
5454
*/
55-
CREATE OR REPLACE FUNCTION public.create_hash_insert_trigger(
55+
CREATE OR REPLACE FUNCTION create_hash_insert_trigger(
5656
IN relation TEXT
5757
, IN attr TEXT
5858
, IN partitions_count INTEGER)
@@ -105,7 +105,7 @@ $$ LANGUAGE plpgsql;
105105
/*
106106
* Drops all partitions for specified relation
107107
*/
108-
CREATE OR REPLACE FUNCTION public.drop_hash_partitions(IN relation TEXT)
108+
CREATE OR REPLACE FUNCTION drop_hash_partitions(IN relation TEXT)
109109
RETURNS VOID AS
110110
$$
111111
DECLARE
@@ -135,7 +135,7 @@ $$ LANGUAGE plpgsql;
135135
/*
136136
* Drops hash trigger
137137
*/
138-
CREATE OR REPLACE FUNCTION public.drop_hash_triggers(IN relation TEXT)
138+
CREATE OR REPLACE FUNCTION drop_hash_triggers(IN relation TEXT)
139139
RETURNS VOID AS
140140
$$
141141
BEGIN
@@ -146,7 +146,7 @@ BEGIN
146146
END
147147
$$ LANGUAGE plpgsql;
148148

149-
CREATE OR REPLACE FUNCTION public.create_hash_update_trigger(
149+
CREATE OR REPLACE FUNCTION create_hash_update_trigger(
150150
IN relation TEXT
151151
, IN attr TEXT
152152
, IN partitions_count INTEGER)
File renamed without changes.

contrib/pathman/sql/range.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ BEGIN
6363
SELECT relfilenode INTO v_relid
6464
FROM pg_class WHERE relname = v_relation;
6565

66-
SELECT max('max_dt') INTO v_part_timestamp FROM pg_pathman_range_rels;
66+
SELECT max(max_dt) INTO v_part_timestamp FROM pg_pathman_range_rels;
6767

6868
/* Create partitions and update pg_pathman configuration */
6969
FOR v_partnum IN 0..v_premake-1

0 commit comments

Comments
 (0)