diff --git a/bin/expected/reorg.out b/bin/expected/reorg.out index 5dc66b3..a1942a5 100755 --- a/bin/expected/reorg.out +++ b/bin/expected/reorg.out @@ -39,6 +39,13 @@ ALTER INDEX tbl_with_dropped_column_pkey SET (fillfactor = 75); ALTER TABLE tbl_with_dropped_column CLUSTER ON tbl_with_dropped_column_pkey; CREATE INDEX idx_c1c2 ON tbl_with_dropped_column (c1, c2) WITH (fillfactor = 75); CREATE INDEX idx_c2c1 ON tbl_with_dropped_column (c2, c1); +CREATE TABLE tbl_with_dropped_toast ( + i integer, + j integer, + t text, + PRIMARY KEY (i, j) +); +ALTER TABLE tbl_with_dropped_toast CLUSTER ON tbl_with_dropped_toast_pkey; -- -- insert data -- @@ -59,6 +66,9 @@ ALTER TABLE tbl_with_dropped_column DROP COLUMN d1; ALTER TABLE tbl_with_dropped_column DROP COLUMN d2; ALTER TABLE tbl_with_dropped_column DROP COLUMN d3; ALTER TABLE tbl_with_dropped_column ADD COLUMN c3 text; +INSERT INTO tbl_with_dropped_toast VALUES(1, 10, 'abc'); +INSERT INTO tbl_with_dropped_toast VALUES(2, 20, sqrt(2::numeric(1000,999))::text || sqrt(3::numeric(1000,999))::text); +ALTER TABLE tbl_with_dropped_toast DROP COLUMN t; -- -- before -- @@ -69,6 +79,13 @@ SELECT * FROM tbl_with_dropped_column; c1 | 1 | c2 | (2 rows) +SELECT * FROM tbl_with_dropped_toast; + i | j +---+---- + 1 | 10 + 2 | 20 +(2 rows) + -- -- do reorg -- @@ -131,6 +148,15 @@ Indexes: "idx_c1c2" btree (c1, c2) WITH (fillfactor=75) "idx_c2c1" btree (c2, c1) +\d tbl_with_dropped_toast +Table "public.tbl_with_dropped_toast" + Column | Type | Modifiers +--------+---------+----------- + i | integer | not null + j | integer | not null +Indexes: + "tbl_with_dropped_toast_pkey" PRIMARY KEY, btree (i, j) CLUSTER + SELECT col1, to_char(col2, 'YYYY-MM-DD HH24:MI:SS'), ","")" FROM tbl_cluster; col1 | to_char | ,") ------+---------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ @@ -169,6 +195,33 @@ SELECT * FROM tbl_with_dropped_column; c1 | 2 | c2 | (2 rows) +SELECT * FROM tbl_with_dropped_toast; + i | j +---+---- + 1 | 10 + 2 | 20 +(2 rows) + +-- +-- check broken links or orphan toast relations +-- +SELECT oid, relname + FROM pg_class + WHERE relkind = 't' + AND oid NOT IN (SELECT reltoastrelid FROM pg_class WHERE relkind = 'r'); + oid | relname +-----+--------- +(0 rows) + +SELECT oid, relname + FROM pg_class + WHERE relkind = 'r' + AND reltoastrelid <> 0 + AND reltoastrelid NOT IN (SELECT oid FROM pg_class WHERE relkind = 't'); + oid | relname +-----+--------- +(0 rows) + -- -- clean up -- diff --git a/bin/pg_reorg.c b/bin/pg_reorg.c index 30bc208..62754d1 100755 --- a/bin/pg_reorg.c +++ b/bin/pg_reorg.c @@ -8,7 +8,7 @@ * @brief Client Modules */ -const char *PROGRAM_VERSION = "1.1.0"; +const char *PROGRAM_VERSION = "1.1.1"; const char *PROGRAM_URL = "http://reorg.projects.postgresql.org/"; const char *PROGRAM_EMAIL = "reorg-general@lists.pgfoundry.org"; diff --git a/bin/pgut/pgut.c b/bin/pgut/pgut.c index 8ae9353..6d22530 100755 --- a/bin/pgut/pgut.c +++ b/bin/pgut/pgut.c @@ -273,6 +273,7 @@ parse_int64(const char *value, int64 *result) #elif defined(HAVE_LONG_INT_64) val = strtol(value, &endptr, 0); #elif defined(HAVE_LONG_LONG_INT_64) + val = strtoll(value, &endptr, 0); #else val = strtol(value, &endptr, 0); #endif diff --git a/bin/sql/reorg.sql b/bin/sql/reorg.sql index 2dc7c7d..94bdbb3 100755 --- a/bin/sql/reorg.sql +++ b/bin/sql/reorg.sql @@ -47,6 +47,14 @@ ALTER TABLE tbl_with_dropped_column CLUSTER ON tbl_with_dropped_column_pkey; CREATE INDEX idx_c1c2 ON tbl_with_dropped_column (c1, c2) WITH (fillfactor = 75); CREATE INDEX idx_c2c1 ON tbl_with_dropped_column (c2, c1); +CREATE TABLE tbl_with_dropped_toast ( + i integer, + j integer, + t text, + PRIMARY KEY (i, j) +); +ALTER TABLE tbl_with_dropped_toast CLUSTER ON tbl_with_dropped_toast_pkey; + -- -- insert data -- @@ -72,11 +80,16 @@ ALTER TABLE tbl_with_dropped_column DROP COLUMN d1; ALTER TABLE tbl_with_dropped_column DROP COLUMN d2; ALTER TABLE tbl_with_dropped_column DROP COLUMN d3; ALTER TABLE tbl_with_dropped_column ADD COLUMN c3 text; + +INSERT INTO tbl_with_dropped_toast VALUES(1, 10, 'abc'); +INSERT INTO tbl_with_dropped_toast VALUES(2, 20, sqrt(2::numeric(1000,999))::text || sqrt(3::numeric(1000,999))::text); +ALTER TABLE tbl_with_dropped_toast DROP COLUMN t; -- -- before -- SELECT * FROM tbl_with_dropped_column; +SELECT * FROM tbl_with_dropped_toast; -- -- do reorg @@ -95,12 +108,28 @@ SELECT * FROM tbl_with_dropped_column; \d tbl_only_ckey \d tbl_only_pkey \d tbl_with_dropped_column +\d tbl_with_dropped_toast SELECT col1, to_char(col2, 'YYYY-MM-DD HH24:MI:SS'), ","")" FROM tbl_cluster; SELECT * FROM tbl_only_ckey ORDER BY 1; SELECT * FROM tbl_only_pkey ORDER BY 1; SELECT * FROM tbl_gistkey ORDER BY 1; SELECT * FROM tbl_with_dropped_column; +SELECT * FROM tbl_with_dropped_toast; + +-- +-- check broken links or orphan toast relations +-- +SELECT oid, relname + FROM pg_class + WHERE relkind = 't' + AND oid NOT IN (SELECT reltoastrelid FROM pg_class WHERE relkind = 'r'); + +SELECT oid, relname + FROM pg_class + WHERE relkind = 'r' + AND reltoastrelid <> 0 + AND reltoastrelid NOT IN (SELECT oid FROM pg_class WHERE relkind = 't'); -- -- clean up diff --git a/doc/index-ja.html b/doc/index-ja.html index 5d6b176..dd18f94 100755 --- a/doc/index-ja.html +++ b/doc/index-ja.html @@ -46,7 +46,7 @@ VACUUM を行うスクリプトが付属しており、"より良い vacuumdb"

ドキュメント

diff --git a/doc/index.html b/doc/index.html index 8fbc58f..4154f35 100755 --- a/doc/index.html +++ b/doc/index.html @@ -48,8 +48,8 @@ where you can find download

Documentation

Execution time

diff --git a/doc/pg_reorg-ja.html b/doc/pg_reorg-ja.html index ce1fced..0f26587 100755 --- a/doc/pg_reorg-ja.html +++ b/doc/pg_reorg-ja.html @@ -8,7 +8,7 @@ -

pg_reorg 1.1.0

+

pg_reorg 1.1.1