diff --git a/SPECS/pg_reorg.spec b/SPECS/pg_reorg.spec index 104b7fc..360996e 100755 --- a/SPECS/pg_reorg.spec +++ b/SPECS/pg_reorg.spec @@ -1,12 +1,14 @@ +# SPEC file for pg_reorg +# Copyright(C) 2009-2010 NIPPON TELEGRAPH AND TELEPHONE CORPORATION %define sname pg_reorg Summary: Reorganize tables in PostgreSQL databases without any locks. Name: %{sname} -Version: 1.1.1 +Version: 1.1.2 Release: 1%{?dist} License: BSD Group: Applications/Databases -Source0: http://pgfoundry.org/frs/download.php/1301/%{sname}-%{version}.tar.gz +Source0: %{sname}-%{version}.tar.gz URL: http://pgfoundry.org/projects/%{sname}/ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n) @@ -14,15 +16,12 @@ BuildRequires: postgresql-devel, postgresql Requires: postgresql %description - -pg_reorg can re-organize tables on a postgres database without any locks so that you can retrieve or update rows in tables being reorganized. The module is developed to be a better alternative of CLUSTER and VACUUM FULL. +pg_reorg can re-organize tables on a postgres database without any locks so that +you can retrieve or update rows in tables being reorganized. +The module is developed to be a better alternative of CLUSTER and VACUUM FULL. %prep -rm -rf %{_libdir}/pgsql/pgxs/src/backend/ -rm -rf %{_builddir}/src -rm -rf %{_builddir}/%{sname} - -%setup -n %{sname} +%setup -q -n %{sname}-%{version} %build USE_PGXS=1 make %{?_smp_mflags} @@ -31,8 +30,12 @@ USE_PGXS=1 make %{?_smp_mflags} rm -rf %{buildroot} USE_PGXS=1 make DESTDIR=%{buildroot} install -%define pg_sharedir +install -m 755 bin/pg_reorg %{buildroot}%{_bindir}/pg_reorg +install -m 755 lib/pg_reorg.so %{buildroot}%{_libdir}/pgsql/pg_reorg.so +install -m 644 lib/pg_reorg.sql %{buildroot}%{_datadir}/pgsql/contrib/pg_reorg.sql +install -m 644 lib/uninstall_pg_reorg.sql %{buildroot}%{_datadir}/pgsql/contrib/uninstall_pg_reorg.sql +%define pg_sharedir %files %defattr(755,root,root,755) @@ -44,9 +47,9 @@ USE_PGXS=1 make DESTDIR=%{buildroot} install %clean rm -rf %{buildroot} -rm -rf %{_libdir}/pgsql/pgxs/src/backend/ %changelog +* Thu Apr 22 2010 - NTT OSS Center 1.1.2-1 * Mon Jan 15 2010 - Toru SHIMOGAKI 1.0.8-1 * Tue Sep 08 2009 - Toru SHIMOGAKI 1.0.6-1 * Fri May 15 2009 - Toru SHIMOGAKI 1.0.4-1 diff --git a/bin/expected/reorg.out b/bin/expected/reorg.out index a1942a5..66654d7 100755 --- a/bin/expected/reorg.out +++ b/bin/expected/reorg.out @@ -4,11 +4,11 @@ SET client_min_messages = warning; -- CREATE TABLE tbl_cluster ( col1 int, - col2 timestamp, + "time" timestamp, ","")" text, PRIMARY KEY (","")", col1) WITH (fillfactor = 75) ) WITH (fillfactor = 70); -CREATE INDEX ","") cluster" ON tbl_cluster (col2, length(","")"), ","")" text_pattern_ops) WITH (fillfactor = 75); +CREATE INDEX ","") cluster" ON tbl_cluster ("time", length(","")"), ","")" text_pattern_ops) WITH (fillfactor = 75); ALTER TABLE tbl_cluster CLUSTER ON ","") cluster"; CREATE TABLE tbl_only_pkey ( col1 int PRIMARY KEY, @@ -100,11 +100,11 @@ SELECT * FROM tbl_with_dropped_toast; Column | Type | Modifiers --------+-----------------------------+----------- col1 | integer | not null - col2 | timestamp without time zone | + time | timestamp without time zone | ,") | text | not null Indexes: "tbl_cluster_pkey" PRIMARY KEY, btree (","")", col1) WITH (fillfactor=75) - ",") cluster" btree (col2, length(","")"), ","")" text_pattern_ops) WITH (fillfactor=75) CLUSTER + ",") cluster" btree ("time", length(","")"), ","")" text_pattern_ops) WITH (fillfactor=75) CLUSTER \d tbl_gistkey Table "public.tbl_gistkey" @@ -157,7 +157,7 @@ Table "public.tbl_with_dropped_toast" 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; +SELECT col1, to_char("time", 'YYYY-MM-DD HH24:MI:SS'), ","")" FROM tbl_cluster; col1 | to_char | ,") ------+---------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 2 | 2008-01-01 00:00:00 | king @@ -222,12 +222,3 @@ SELECT oid, relname -----+--------- (0 rows) --- --- clean up --- -DROP TABLE tbl_cluster; -DROP TABLE tbl_only_pkey; -DROP TABLE tbl_only_ckey; -DROP TABLE tbl_gistkey; -DROP TABLE tbl_with_dropped_column; -RESET client_min_messages; diff --git a/bin/sql/reorg.sql b/bin/sql/reorg.sql index 94bdbb3..fc29e0e 100755 --- a/bin/sql/reorg.sql +++ b/bin/sql/reorg.sql @@ -4,12 +4,12 @@ SET client_min_messages = warning; -- CREATE TABLE tbl_cluster ( col1 int, - col2 timestamp, + "time" timestamp, ","")" text, PRIMARY KEY (","")", col1) WITH (fillfactor = 75) ) WITH (fillfactor = 70); -CREATE INDEX ","") cluster" ON tbl_cluster (col2, length(","")"), ","")" text_pattern_ops) WITH (fillfactor = 75); +CREATE INDEX ","") cluster" ON tbl_cluster ("time", length(","")"), ","")" text_pattern_ops) WITH (fillfactor = 75); ALTER TABLE tbl_cluster CLUSTER ON ","") cluster"; CREATE TABLE tbl_only_pkey ( @@ -110,7 +110,7 @@ SELECT * FROM tbl_with_dropped_toast; \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 col1, to_char("time", '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; @@ -130,14 +130,3 @@ SELECT oid, relname WHERE relkind = 'r' AND reltoastrelid <> 0 AND reltoastrelid NOT IN (SELECT oid FROM pg_class WHERE relkind = 't'); - --- --- clean up --- - -DROP TABLE tbl_cluster; -DROP TABLE tbl_only_pkey; -DROP TABLE tbl_only_ckey; -DROP TABLE tbl_gistkey; -DROP TABLE tbl_with_dropped_column; -RESET client_min_messages; diff --git a/lib/reorg.c b/lib/reorg.c index 2b5c859..8616c85 100755 --- a/lib/reorg.c +++ b/lib/reorg.c @@ -360,7 +360,6 @@ skip_until(Oid index, char *sql, char end) char instr = 0; int nopen = 0; - sql++; for (; *sql && (nopen > 0 || instr != 0 || *sql != end); sql++) { if (instr) @@ -491,29 +490,8 @@ reorg_get_index_keys(PG_FUNCTION_ARGS) while (isspace((unsigned char) *token)) token++; next = skip_until(index, next, ','); - - opcname = token + strlen(token); - if (opcname[-1] == '"') - { - opcname--; - for (;;) - { - char *beg = strrchr(opcname, '"'); - if (beg == NULL) - parse_error(index); - else if (beg[-1] != '"') - break; - else /* escaped quote ("") */ - opcname = beg - 1; - } - } - else - { - while (opcname > token && IsToken(opcname[-1])) - opcname--; - } - - if (opcname > token && *opcname) + opcname = skip_until(index, token, ' '); + if (opcname) { /* lookup default operator name from operator class */