Fix a bug that pg_reorg cannot parse index definitions with reserved named columns,
i.e, it failed to parse quoted column names. (bug #1010828)
This commit is contained in:
parent
79757ccb62
commit
67a5d7b786
@ -1,12 +1,14 @@
|
|||||||
|
# SPEC file for pg_reorg
|
||||||
|
# Copyright(C) 2009-2010 NIPPON TELEGRAPH AND TELEPHONE CORPORATION
|
||||||
%define sname pg_reorg
|
%define sname pg_reorg
|
||||||
|
|
||||||
Summary: Reorganize tables in PostgreSQL databases without any locks.
|
Summary: Reorganize tables in PostgreSQL databases without any locks.
|
||||||
Name: %{sname}
|
Name: %{sname}
|
||||||
Version: 1.1.1
|
Version: 1.1.2
|
||||||
Release: 1%{?dist}
|
Release: 1%{?dist}
|
||||||
License: BSD
|
License: BSD
|
||||||
Group: Applications/Databases
|
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}/
|
URL: http://pgfoundry.org/projects/%{sname}/
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n)
|
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n)
|
||||||
|
|
||||||
@ -14,15 +16,12 @@ BuildRequires: postgresql-devel, postgresql
|
|||||||
Requires: postgresql
|
Requires: postgresql
|
||||||
|
|
||||||
%description
|
%description
|
||||||
|
pg_reorg can re-organize tables on a postgres database without any locks so that
|
||||||
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.
|
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
|
%prep
|
||||||
rm -rf %{_libdir}/pgsql/pgxs/src/backend/
|
%setup -q -n %{sname}-%{version}
|
||||||
rm -rf %{_builddir}/src
|
|
||||||
rm -rf %{_builddir}/%{sname}
|
|
||||||
|
|
||||||
%setup -n %{sname}
|
|
||||||
|
|
||||||
%build
|
%build
|
||||||
USE_PGXS=1 make %{?_smp_mflags}
|
USE_PGXS=1 make %{?_smp_mflags}
|
||||||
@ -31,8 +30,12 @@ USE_PGXS=1 make %{?_smp_mflags}
|
|||||||
rm -rf %{buildroot}
|
rm -rf %{buildroot}
|
||||||
USE_PGXS=1 make DESTDIR=%{buildroot} install
|
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
|
%files
|
||||||
%defattr(755,root,root,755)
|
%defattr(755,root,root,755)
|
||||||
@ -44,9 +47,9 @@ USE_PGXS=1 make DESTDIR=%{buildroot} install
|
|||||||
|
|
||||||
%clean
|
%clean
|
||||||
rm -rf %{buildroot}
|
rm -rf %{buildroot}
|
||||||
rm -rf %{_libdir}/pgsql/pgxs/src/backend/
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Apr 22 2010 - NTT OSS Center <itagaki.takahiro@oss.ntt.co.jp> 1.1.2-1
|
||||||
* Mon Jan 15 2010 - Toru SHIMOGAKI <shimogaki.toru@oss.ntt.co.jp> 1.0.8-1
|
* Mon Jan 15 2010 - Toru SHIMOGAKI <shimogaki.toru@oss.ntt.co.jp> 1.0.8-1
|
||||||
* Tue Sep 08 2009 - Toru SHIMOGAKI <shimogaki.toru@oss.ntt.co.jp> 1.0.6-1
|
* Tue Sep 08 2009 - Toru SHIMOGAKI <shimogaki.toru@oss.ntt.co.jp> 1.0.6-1
|
||||||
* Fri May 15 2009 - Toru SHIMOGAKI <shimogaki.toru@oss.ntt.co.jp> 1.0.4-1
|
* Fri May 15 2009 - Toru SHIMOGAKI <shimogaki.toru@oss.ntt.co.jp> 1.0.4-1
|
||||||
|
@ -4,11 +4,11 @@ SET client_min_messages = warning;
|
|||||||
--
|
--
|
||||||
CREATE TABLE tbl_cluster (
|
CREATE TABLE tbl_cluster (
|
||||||
col1 int,
|
col1 int,
|
||||||
col2 timestamp,
|
"time" timestamp,
|
||||||
","")" text,
|
","")" text,
|
||||||
PRIMARY KEY (","")", col1) WITH (fillfactor = 75)
|
PRIMARY KEY (","")", col1) WITH (fillfactor = 75)
|
||||||
) WITH (fillfactor = 70);
|
) 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";
|
ALTER TABLE tbl_cluster CLUSTER ON ","") cluster";
|
||||||
CREATE TABLE tbl_only_pkey (
|
CREATE TABLE tbl_only_pkey (
|
||||||
col1 int PRIMARY KEY,
|
col1 int PRIMARY KEY,
|
||||||
@ -100,11 +100,11 @@ SELECT * FROM tbl_with_dropped_toast;
|
|||||||
Column | Type | Modifiers
|
Column | Type | Modifiers
|
||||||
--------+-----------------------------+-----------
|
--------+-----------------------------+-----------
|
||||||
col1 | integer | not null
|
col1 | integer | not null
|
||||||
col2 | timestamp without time zone |
|
time | timestamp without time zone |
|
||||||
,") | text | not null
|
,") | text | not null
|
||||||
Indexes:
|
Indexes:
|
||||||
"tbl_cluster_pkey" PRIMARY KEY, btree (","")", col1) WITH (fillfactor=75)
|
"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
|
\d tbl_gistkey
|
||||||
Table "public.tbl_gistkey"
|
Table "public.tbl_gistkey"
|
||||||
@ -157,7 +157,7 @@ Table "public.tbl_with_dropped_toast"
|
|||||||
Indexes:
|
Indexes:
|
||||||
"tbl_with_dropped_toast_pkey" PRIMARY KEY, btree (i, j) CLUSTER
|
"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 | ,")
|
col1 | to_char | ,")
|
||||||
------+---------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
------+---------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
2 | 2008-01-01 00:00:00 | king
|
2 | 2008-01-01 00:00:00 | king
|
||||||
@ -222,12 +222,3 @@ SELECT oid, relname
|
|||||||
-----+---------
|
-----+---------
|
||||||
(0 rows)
|
(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;
|
|
||||||
|
@ -4,12 +4,12 @@ SET client_min_messages = warning;
|
|||||||
--
|
--
|
||||||
CREATE TABLE tbl_cluster (
|
CREATE TABLE tbl_cluster (
|
||||||
col1 int,
|
col1 int,
|
||||||
col2 timestamp,
|
"time" timestamp,
|
||||||
","")" text,
|
","")" text,
|
||||||
PRIMARY KEY (","")", col1) WITH (fillfactor = 75)
|
PRIMARY KEY (","")", col1) WITH (fillfactor = 75)
|
||||||
) WITH (fillfactor = 70);
|
) 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";
|
ALTER TABLE tbl_cluster CLUSTER ON ","") cluster";
|
||||||
|
|
||||||
CREATE TABLE tbl_only_pkey (
|
CREATE TABLE tbl_only_pkey (
|
||||||
@ -110,7 +110,7 @@ SELECT * FROM tbl_with_dropped_toast;
|
|||||||
\d tbl_with_dropped_column
|
\d tbl_with_dropped_column
|
||||||
\d tbl_with_dropped_toast
|
\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_ckey ORDER BY 1;
|
||||||
SELECT * FROM tbl_only_pkey ORDER BY 1;
|
SELECT * FROM tbl_only_pkey ORDER BY 1;
|
||||||
SELECT * FROM tbl_gistkey ORDER BY 1;
|
SELECT * FROM tbl_gistkey ORDER BY 1;
|
||||||
@ -130,14 +130,3 @@ SELECT oid, relname
|
|||||||
WHERE relkind = 'r'
|
WHERE relkind = 'r'
|
||||||
AND reltoastrelid <> 0
|
AND reltoastrelid <> 0
|
||||||
AND reltoastrelid NOT IN (SELECT oid FROM pg_class WHERE relkind = 't');
|
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;
|
|
||||||
|
26
lib/reorg.c
26
lib/reorg.c
@ -360,7 +360,6 @@ skip_until(Oid index, char *sql, char end)
|
|||||||
char instr = 0;
|
char instr = 0;
|
||||||
int nopen = 0;
|
int nopen = 0;
|
||||||
|
|
||||||
sql++;
|
|
||||||
for (; *sql && (nopen > 0 || instr != 0 || *sql != end); sql++)
|
for (; *sql && (nopen > 0 || instr != 0 || *sql != end); sql++)
|
||||||
{
|
{
|
||||||
if (instr)
|
if (instr)
|
||||||
@ -491,29 +490,8 @@ reorg_get_index_keys(PG_FUNCTION_ARGS)
|
|||||||
while (isspace((unsigned char) *token))
|
while (isspace((unsigned char) *token))
|
||||||
token++;
|
token++;
|
||||||
next = skip_until(index, next, ',');
|
next = skip_until(index, next, ',');
|
||||||
|
opcname = skip_until(index, token, ' ');
|
||||||
opcname = token + strlen(token);
|
if (opcname)
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
/* lookup default operator name from operator class */
|
/* lookup default operator name from operator class */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user