Skip to content

Commit 038c075

Browse files
committed
Support reorganizing tables with non-default operator class.
1 parent 27e6839 commit 038c075

File tree

10 files changed

+1078
-952
lines changed

10 files changed

+1078
-952
lines changed

Makefile

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,26 @@
33
#
44
# Copyright (c) 2008-2009, NIPPON TELEGRAPH AND TELEPHONE CORPORATION
55
#
6-
.PHONY: all install clean
6+
ifdef USE_PGXS
7+
PG_CONFIG = pg_config
8+
PGXS := $(shell $(PG_CONFIG) --pgxs)
9+
include $(PGXS)
10+
else
11+
subdir = pg_statsinfo
12+
top_builddir = ../..
13+
include $(top_builddir)/src/Makefile.global
14+
endif
715

8-
all:
9-
make -C bin
10-
make -C lib
16+
SUBDIRS = bin lib
1117

12-
install:
13-
make -C bin install
14-
make -C lib install
18+
all install installdirs uninstall distprep clean distclean maintainer-clean debug:
19+
@for dir in $(SUBDIRS); do \
20+
$(MAKE) -C $$dir $@ || exit; \
21+
done
1522

16-
clean:
17-
make -C bin clean
18-
make -C lib clean
19-
20-
debug:
21-
make -C bin DEBUG_REORG=enable
22-
make -C lib DEBUG_REORG=enable
23-
24-
uninstall:
25-
make -C bin uninstall
26-
make -C lib uninstall
27-
28-
installcheck:
29-
make -C bin installcheck
23+
# We'd like check operations to run all the subtests before failing.
24+
check installcheck:
25+
@CHECKERR=0; for dir in $(SUBDIRS); do \
26+
$(MAKE) -C $$dir $@ || CHECKERR=$$?; \
27+
done; \
28+
exit $$CHECKERR

bin/expected/init.out

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
SET client_min_messages = warning;
2-
\set ECHO none
3-
RESET client_min_messages;
1+
SET client_min_messages = warning;
2+
\set ECHO none
3+
RESET client_min_messages;

bin/expected/reorg.out

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ SET client_min_messages = warning;
55
CREATE TABLE tbl_cluster (
66
col1 int,
77
col2 timestamp,
8-
":-)" text,
9-
PRIMARY KEY (":-)", col1)
8+
","")" text,
9+
PRIMARY KEY (","")", col1)
1010
) WITH (fillfactor = 70);
11-
CREATE INDEX cidx_cluster ON tbl_cluster (col2, length(":-)"));
12-
ALTER TABLE tbl_cluster CLUSTER ON cidx_cluster;
11+
CREATE INDEX ","") cluster" ON tbl_cluster (col2, length(","")"), ","")" text_pattern_ops);
12+
ALTER TABLE tbl_cluster CLUSTER ON ","") cluster";
1313
CREATE TABLE tbl_only_pkey (
1414
col1 int PRIMARY KEY,
15-
":-)" text
15+
","")" text
1616
);
1717
CREATE TABLE tbl_only_ckey (
1818
col1 int,
1919
col2 timestamp,
20-
":-)" text
20+
","")" text
2121
) WITH (fillfactor = 70);
22-
CREATE INDEX cidx_only_ckey ON tbl_only_ckey (col2, ":-)");
22+
CREATE INDEX cidx_only_ckey ON tbl_only_ckey (col2, ","")");
2323
ALTER TABLE tbl_only_ckey CLUSTER ON cidx_only_ckey;
2424
CREATE TABLE tbl_gistkey (
2525
id integer PRIMARY KEY,
@@ -83,10 +83,10 @@ SELECT * FROM tbl_with_dropped_column;
8383
--------+-----------------------------+-----------
8484
col1 | integer | not null
8585
col2 | timestamp without time zone |
86-
:-) | text | not null
86+
,") | text | not null
8787
Indexes:
88-
"tbl_cluster_pkey" PRIMARY KEY, btree (":-)", col1)
89-
"cidx_cluster" btree (col2, length(":-)")) CLUSTER
88+
"tbl_cluster_pkey" PRIMARY KEY, btree (","")", col1)
89+
",") cluster" btree (col2, length(","")"), ","")" text_pattern_ops) CLUSTER
9090

9191
\d tbl_gistkey
9292
Table "public.tbl_gistkey"
@@ -104,16 +104,16 @@ Indexes:
104104
--------+-----------------------------+-----------
105105
col1 | integer |
106106
col2 | timestamp without time zone |
107-
:-) | text |
107+
,") | text |
108108
Indexes:
109-
"cidx_only_ckey" btree (col2, ":-)") CLUSTER
109+
"cidx_only_ckey" btree (col2, ","")") CLUSTER
110110

111111
\d tbl_only_pkey
112112
Table "public.tbl_only_pkey"
113113
Column | Type | Modifiers
114114
--------+---------+-----------
115115
col1 | integer | not null
116-
:-) | text |
116+
,") | text |
117117
Indexes:
118118
"tbl_only_pkey_pkey" PRIMARY KEY, btree (col1)
119119

@@ -130,8 +130,8 @@ Indexes:
130130
"idx_c1c2" btree (c1, c2)
131131
"idx_c2c1" btree (c2, c1)
132132

133-
SELECT col1, to_char(col2, 'YYYY-MM-DD HH24:MI:SS'), ":-)" FROM tbl_cluster;
134-
col1 | to_char | :-)
133+
SELECT col1, to_char(col2, 'YYYY-MM-DD HH24:MI:SS'), ","")" FROM tbl_cluster;
134+
col1 | to_char | ,")
135135
------+---------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
136136
2 | 2008-01-01 00:00:00 | king
137137
5 | 2008-01-01 00:30:00 | 1.4142135623730950488016887242096980785696718753769480731766797379907324784621070388503875343276415727350138462309122970249248360558507372126441214970999358314132226659275055927557999505011527820605714701095599716059702745345968620147285174186408891986095523292304843087143214508397626036279952514079896872533965463318088296406206152583523950547457502877599617298355752203375318570113543746034084988471603868999706990048150305440277903164542478230684929369186215805784631115966687130130156185689872372352885092648612494977154218334204285686060146824720771435854874155657069677653720226485447015858801620758474922657226002085584466521458398893944370926591800311388246468157082630100594858704003186480342194897278290641045072636881313739855256117322040245091227700226941127573627280495738108967504018369868368450725799364729060762996941380475654823728997180326802474420629269124859052181004459842150591120249441341728531478105803603371077309182869314710171111683916581726889419758716582152128229518488471.732050807568877293527446341505872366942805253810380628055806979451933016908800037081146186757248575675626141415406703029969945094998952478811655512094373648528093231902305582067974820101084674923265015312343266903322886650672254668921837971227047131660367861588019049986537379859389467650347506576050756618348129606100947602187190325083145829523959832997789824508288714463832917347224163984587855397667958063818353666110843173780894378316102088305524901670023520711144288695990956365797087168498072899493296484283020786408603988738697537582317317831395992983007838702877053913369563312103707264019249106768231199288375641141422016742752102372994270831059898459475987664288897796147837958390228854852903576033852808064381972344661059689722872865264153822664698420021195484155278441181286534507035191650016689294415480846071277143999762926834629577438361895110127148638746976545982451788550975379013880664961911962222957110555242923723192197738262561631468842032853716682938649611917049738836395495938
@@ -141,14 +141,14 @@ SELECT col1, to_char(col2, 'YYYY-MM-DD HH24:MI:SS'), ":-)" FROM tbl_cluster;
141141
(5 rows)
142142

143143
SELECT * FROM tbl_only_ckey ORDER BY 1;
144-
col1 | col2 | :-)
144+
col1 | col2 | ,")
145145
------+--------------------------+-----
146146
1 | Tue Jan 01 00:00:00 2008 | abc
147147
2 | Fri Feb 01 00:00:00 2008 | def
148148
(2 rows)
149149

150150
SELECT * FROM tbl_only_pkey ORDER BY 1;
151-
col1 | :-)
151+
col1 | ,")
152152
------+-----
153153
1 | abc
154154
2 | def

bin/sql/reorg.sql

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@ SET client_min_messages = warning;
55
CREATE TABLE tbl_cluster (
66
col1 int,
77
col2 timestamp,
8-
":-)" text,
9-
PRIMARY KEY (":-)", col1)
8+
","")" text,
9+
PRIMARY KEY (","")", col1)
1010
) WITH (fillfactor = 70);
1111

12-
CREATE INDEX cidx_cluster ON tbl_cluster (col2, length(":-)"));
13-
ALTER TABLE tbl_cluster CLUSTER ON cidx_cluster;
12+
CREATE INDEX ","") cluster" ON tbl_cluster (col2, length(","")"), ","")" text_pattern_ops);
13+
ALTER TABLE tbl_cluster CLUSTER ON ","") cluster";
1414

1515
CREATE TABLE tbl_only_pkey (
1616
col1 int PRIMARY KEY,
17-
":-)" text
17+
","")" text
1818
);
1919

2020
CREATE TABLE tbl_only_ckey (
2121
col1 int,
2222
col2 timestamp,
23-
":-)" text
23+
","")" text
2424
) WITH (fillfactor = 70);
2525

26-
CREATE INDEX cidx_only_ckey ON tbl_only_ckey (col2, ":-)");
26+
CREATE INDEX cidx_only_ckey ON tbl_only_ckey (col2, ","")");
2727
ALTER TABLE tbl_only_ckey CLUSTER ON cidx_only_ckey;
2828

2929
CREATE TABLE tbl_gistkey (
@@ -95,7 +95,7 @@ SELECT * FROM tbl_with_dropped_column;
9595
\d tbl_only_pkey
9696
\d tbl_with_dropped_column
9797

98-
SELECT col1, to_char(col2, 'YYYY-MM-DD HH24:MI:SS'), ":-)" FROM tbl_cluster;
98+
SELECT col1, to_char(col2, 'YYYY-MM-DD HH24:MI:SS'), ","")" FROM tbl_cluster;
9999
SELECT * FROM tbl_only_ckey ORDER BY 1;
100100
SELECT * FROM tbl_only_pkey ORDER BY 1;
101101
SELECT * FROM tbl_gistkey ORDER BY 1;

0 commit comments

Comments
 (0)