Fix memory leak and wrong usage of StringInfo in pgut_connect().
This commit is contained in:
parent
7865250a19
commit
d8d39cc948
@ -4,7 +4,7 @@
|
||||
|
||||
Summary: Reorganize tables in PostgreSQL databases without any locks.
|
||||
Name: %{sname}
|
||||
Version: 1.1.4
|
||||
Version: 1.1.5
|
||||
Release: 1%{?dist}
|
||||
License: BSD
|
||||
Group: Applications/Databases
|
||||
@ -13,7 +13,7 @@ URL: http://pgfoundry.org/projects/%{sname}/
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n)
|
||||
|
||||
BuildRequires: postgresql-devel, postgresql
|
||||
Requires: postgresql
|
||||
Requires: postgresql, postgresql-libs
|
||||
|
||||
%description
|
||||
pg_reorg can re-organize tables on a postgres database without any locks so that
|
||||
@ -28,7 +28,11 @@ USE_PGXS=1 make %{?_smp_mflags}
|
||||
|
||||
%install
|
||||
rm -rf %{buildroot}
|
||||
USE_PGXS=1 make DESTDIR=%{buildroot} install
|
||||
USE_PGXS=1 make DESTDIR=%{buildroot}
|
||||
|
||||
install -d %{buildroot}%{_libdir}/pgsql
|
||||
install -d %{buildroot}%{_bindir}
|
||||
install -d %{buildroot}%{_datadir}/pgsql/contrib
|
||||
|
||||
install -m 755 bin/pg_reorg %{buildroot}%{_bindir}/pg_reorg
|
||||
install -m 755 lib/pg_reorg.so %{buildroot}%{_libdir}/pgsql/pg_reorg.so
|
||||
@ -49,6 +53,7 @@ install -m 644 lib/uninstall_pg_reorg.sql %{buildroot}%{_datadir}/pgsql/contrib/
|
||||
rm -rf %{buildroot}
|
||||
|
||||
%changelog
|
||||
* Thu Oct 21 2010 - NTT OSS Center <sakamoto.masahiko@oss.ntt.co.jp> 1.1.5-1
|
||||
* Wed Sep 22 2010 - NTT OSS Center <sakamoto.masahiko@oss.ntt.co.jp> 1.1.4-1
|
||||
* 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
|
67
SPECS/pg_reorg90.spec
Executable file
67
SPECS/pg_reorg90.spec
Executable file
@ -0,0 +1,67 @@
|
||||
# SPEC file for pg_reorg
|
||||
# Copyright(C) 2009-2010 NIPPON TELEGRAPH AND TELEPHONE CORPORATION
|
||||
%define sname pg_reorg
|
||||
|
||||
%define _pgdir /usr/pgsql-9.0
|
||||
%define _bindir %{_pgdir}/bin
|
||||
%define _libdir %{_pgdir}/lib
|
||||
%define _datadir %{_pgdir}/share
|
||||
|
||||
Summary: Reorganize tables in PostgreSQL databases without any locks.
|
||||
Name: %{sname}
|
||||
Version: 1.1.5
|
||||
Release: 1%{?dist}
|
||||
License: BSD
|
||||
Group: Applications/Databases
|
||||
Source0: %{sname}-%{version}.tar.gz
|
||||
URL: http://pgfoundry.org/projects/%{sname}/
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n)
|
||||
|
||||
BuildRequires: postgresql90-devel, postgresql90
|
||||
Requires: postgresql90, postgresql90-libs
|
||||
|
||||
%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.
|
||||
|
||||
%prep
|
||||
%setup -q -n %{sname}-%{version}
|
||||
|
||||
%build
|
||||
USE_PGXS=1 make %{?_smp_mflags}
|
||||
|
||||
%install
|
||||
rm -rf %{buildroot}
|
||||
USE_PGXS=1 make DESTDIR=%{buildroot}
|
||||
|
||||
install -d %{buildroot}%{_libdir}
|
||||
install -d %{buildroot}%{_bindir}
|
||||
install -d %{buildroot}%{_datadir}/contrib
|
||||
|
||||
install -m 755 bin/pg_reorg %{buildroot}%{_bindir}/pg_reorg
|
||||
install -m 755 lib/pg_reorg.so %{buildroot}%{_libdir}/pg_reorg.so
|
||||
install -m 644 lib/pg_reorg.sql %{buildroot}%{_datadir}/contrib/pg_reorg.sql
|
||||
install -m 644 lib/uninstall_pg_reorg.sql %{buildroot}%{_datadir}/contrib/uninstall_pg_reorg.sql
|
||||
|
||||
%define pg_sharedir
|
||||
|
||||
%files
|
||||
%defattr(755,root,root,755)
|
||||
%{_bindir}/pg_reorg
|
||||
%{_libdir}/pg_reorg.so
|
||||
%defattr(644,root,root,755)
|
||||
%{_datadir}/contrib/pg_reorg.sql
|
||||
%{_datadir}/contrib/uninstall_pg_reorg.sql
|
||||
|
||||
%clean
|
||||
rm -rf %{buildroot}
|
||||
|
||||
%changelog
|
||||
* Thu Oct 21 2010 - NTT OSS Center <sakamoto.masahiko@oss.ntt.co.jp> 1.1.5-1
|
||||
* Wed Sep 22 2010 - NTT OSS Center <sakamoto.masahiko@oss.ntt.co.jp> 1.1.4-1
|
||||
* 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
|
||||
* 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
|
||||
- Initial packaging
|
@ -8,7 +8,7 @@
|
||||
* @brief Client Modules
|
||||
*/
|
||||
|
||||
const char *PROGRAM_VERSION = "1.1.3";
|
||||
const char *PROGRAM_VERSION = "1.1.5";
|
||||
const char *PROGRAM_URL = "http://reorg.projects.postgresql.org/";
|
||||
const char *PROGRAM_EMAIL = "reorg-general@lists.pgfoundry.org";
|
||||
|
||||
|
@ -408,11 +408,14 @@ pgut_connect(const char *info, YesNo prompt, int elevel)
|
||||
{
|
||||
passwd = prompt_for_password();
|
||||
initStringInfo(&add_pass);
|
||||
appendStringInfo(&add_pass, info);
|
||||
appendStringInfoString(&add_pass, info);
|
||||
appendStringInfo(&add_pass, " password=%s ", passwd);
|
||||
}
|
||||
else
|
||||
{
|
||||
passwd = NULL;
|
||||
add_pass.data = NULL;
|
||||
}
|
||||
|
||||
/* Start the connection. Loop until we have a password if requested by backend. */
|
||||
for (;;)
|
||||
@ -420,7 +423,7 @@ pgut_connect(const char *info, YesNo prompt, int elevel)
|
||||
PGconn *conn;
|
||||
CHECK_FOR_INTERRUPTS();
|
||||
|
||||
if(!passwd)
|
||||
if (!passwd)
|
||||
conn = PQconnectdb(info);
|
||||
else
|
||||
conn = PQconnectdb(add_pass.data);
|
||||
@ -438,10 +441,10 @@ pgut_connect(const char *info, YesNo prompt, int elevel)
|
||||
pgut_connections = c;
|
||||
pgut_conn_unlock();
|
||||
|
||||
if(passwd)
|
||||
if (add_pass.data != NULL)
|
||||
termStringInfo(&add_pass);
|
||||
|
||||
free(passwd);
|
||||
|
||||
return conn;
|
||||
}
|
||||
|
||||
@ -450,11 +453,19 @@ pgut_connect(const char *info, YesNo prompt, int elevel)
|
||||
PQfinish(conn);
|
||||
free(passwd);
|
||||
passwd = prompt_for_password();
|
||||
initStringInfo(&add_pass);
|
||||
appendStringInfo(&add_pass, info);
|
||||
if (add_pass.data != NULL)
|
||||
resetStringInfo(&add_pass);
|
||||
else
|
||||
initStringInfo(&add_pass);
|
||||
appendStringInfoString(&add_pass, info);
|
||||
appendStringInfo(&add_pass, " password=%s ", passwd);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (add_pass.data != NULL)
|
||||
termStringInfo(&add_pass);
|
||||
free(passwd);
|
||||
|
||||
ereport(elevel,
|
||||
(errcode(E_PG_CONNECT),
|
||||
errmsg("could not connect to database with \"%s\": %s",
|
||||
|
@ -75,7 +75,7 @@ static void RenameRelationInternal(Oid myrelid, const char *newrelname, Oid name
|
||||
Datum
|
||||
reorg_version(PG_FUNCTION_ARGS)
|
||||
{
|
||||
return CStringGetTextDatum("pg_reorg 1.1.2");
|
||||
return CStringGetTextDatum("pg_reorg 1.1.5");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -605,7 +605,7 @@ remove_dropped_columns_and_adjust_attnum(Oid oid, int16 natts1, int16 natts2)
|
||||
natts2 - natts1, SPI_processed);
|
||||
|
||||
/* renumber attnum */
|
||||
#if PG_VERSION_NUM >= 80500
|
||||
#if PG_VERSION_NUM >= 90000
|
||||
execute_with_format(SPI_OK_UPDATE,
|
||||
"UPDATE pg_catalog.pg_attribute m"
|
||||
" SET attnum = (SELECT count(*) FROM pg_attribute a"
|
||||
@ -802,7 +802,7 @@ reorg_swap(PG_FUNCTION_ARGS)
|
||||
/* adjust key attnum if the target table has dropped columns */
|
||||
if (natts1 != natts2)
|
||||
{
|
||||
#if PG_VERSION_NUM >= 80500
|
||||
#if PG_VERSION_NUM >= 90000
|
||||
execute_with_format(SPI_OK_UPDATE,
|
||||
"UPDATE pg_catalog.pg_index m SET indkey = n.indkey"
|
||||
" FROM pg_catalog.pg_index n"
|
||||
|
Loading…
x
Reference in New Issue
Block a user