From senthil@zoniac.com Fri Apr 1 15:09:44 2011 Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 40B1E1337B80 for ; Fri, 1 Apr 2011 12:09:44 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 64536-01 for ; Fri, 1 Apr 2011 15:09:33 +0000 (UTC) X-Greylist: delayed 00:05:09.057756 by SQLgrey-1.7.6 Received: from rs73.luxsci.com (rs73.luxsci.com [64.49.254.135]) by mail.postgresql.org (Postfix) with ESMTP id 5FDA21337B47 for ; Fri, 1 Apr 2011 12:09:33 -0300 (ADT) Received: from SenthilKumarG (NSG-Static-233.156.72.182.airtel.in [182.72.156.233] (may be forged)) (authenticated bits=0) by rs73.luxsci.com (8.13.8/8.13.8) with ESMTP id p31F4K7q030205 for ; Fri, 1 Apr 2011 10:04:22 -0500 Message-Id: <201104011504.p31F4K7q030205@rs73.luxsci.com> From: "Senthil Kumar G" To: Subject: DB Import Error... Date: Fri, 1 Apr 2011 20:34:28 +0530 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_405E_01CBF0AC.344D1860" X-Mailer: Microsoft Office Outlook, Build 11.0.5510 Thread-Index: Acvwfhj2S0NLoHcmR9aVAau8aaMUWA== X-MimeOLE: Produced By Microsoft MimeOLE V6.1.7600.16543 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.609 tagged_above=-10 required=5 tests=BAYES_00=-1.9, HTML_MESSAGE=0.001, MAY_BE_FORGED=0.29 X-Spam-Level: X-Archive-Number: 201104/22 X-Sequence-Number: 37203 This is a multi-part message in MIME format. ------=_NextPart_000_405E_01CBF0AC.344D1860 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi I am upgrading my staging environment from postgresql 8.2.3 to 9.0.3. I was able to do successfully. But, when i try to import the database which is created in 8.2.0 version to 9.0.3 version environment, i am getting following error. ERROR: constraint "xxxx" for relation "xxxx" already exist when i query it was not found. What could be the reason? What should i do to resolve this? Appreciate your quick answer. Thanks & Regards Senthil ------=_NextPart_000_405E_01CBF0AC.344D1860 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hi

 

I am upgrading my staging environment from postgresql = 8.2.3 to 9.0.3.

 

I was able to do = successfully.

 

But, when i try to import the database which is = created in 8.2.0 version to 9.0.3 version environment, i am getting following = error.

 

ERROR:  constraint "xxxx” for relation "xxxx” already exist

 

when i query it was not = found.

 

What could be the reason? What should i do to resolve = this?

 

Appreciate your quick = answer.

 

Thanks & = Regards

Senthil

 

------=_NextPart_000_405E_01CBF0AC.344D1860-- From Kevin.Grittner@wicourts.gov Fri Apr 1 15:19:13 2011 Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 4D53D1337C20 for ; Fri, 1 Apr 2011 12:19:13 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 76677-01-6 for ; Fri, 1 Apr 2011 15:19:06 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from gw.wicourts.gov (gwmta.wicourts.gov [165.219.244.99]) by mail.postgresql.org (Postfix) with ESMTP id 6B74C1337C0D for ; Fri, 1 Apr 2011 12:18:53 -0300 (ADT) Received: from Courts-MTA by gw.wicourts.gov with Novell_GroupWise; Fri, 01 Apr 2011 10:18:52 -0500 Message-Id: <4D95A686020000250003C123@gw.wicourts.gov> X-Mailer: Novell GroupWise Internet Agent 8.0.1 Date: Fri, 01 Apr 2011 10:18:46 -0500 From: "Kevin Grittner" To: , "Senthil Kumar G" Subject: Re: DB Import Error... References: <201104011504.p31F4K7q030205@rs73.luxsci.com> In-Reply-To: <201104011504.p31F4K7q030205@rs73.luxsci.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201104/23 X-Sequence-Number: 37204 "Senthil Kumar G" wrote: > I am upgrading my staging environment from postgresql 8.2.3 to > 9.0.3. > > I was able to do successfully. > [errors while applying dump to new database] > What could be the reason? What should i do to resolve this? The recommended upgrade technique is to us pg_dump (or pg_dumpall) from the newer version (9.0.3 in this case) to access the old database (running the 8.2.3 server in this case). If you followed some other procedure, like using the 8.2.3 software to dump the database, you should try the recommended approach instead. I generally dump in plain text format (the default) and pipe it to psql. -Kevin From raghuchennuru@gmail.com Fri Apr 1 15:27:31 2011 Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 6C8F31337B80 for ; Fri, 1 Apr 2011 12:27:31 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 73836-02-9 for ; Fri, 1 Apr 2011 15:27:13 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-qw0-f46.google.com (mail-qw0-f46.google.com [209.85.216.46]) by mail.postgresql.org (Postfix) with ESMTP id 0064B1337B6E for ; Fri, 1 Apr 2011 12:27:12 -0300 (ADT) Received: by qwk3 with SMTP id 3so2210196qwk.19 for ; Fri, 01 Apr 2011 08:27:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=hnu5tMmJpaRfSkRa1RCEnl1LbhK4UZll6BuQH1oLqI4=; b=A/2uTIdBj+4VbG3R9R52LCa25lLNw6N+wu3QNyl2WwSZWzXVwJwQGuQf5OQpv+VuAO gsEn5a5gpx7WdJS0nKvbNhG1HQUmHnL3NY+7hvD7AG/Pr/QKov3bRho34A11Qa+OzrNh Jnsx467Dxqop4nbQwkZbVPREU39DUKt/gjlnA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=C1SQV5WhTrkRvK8xyz7A1Z0iEqSjopst6/JvKQuQoXG4zIAv51L5mrMm4kmgMCwMFO zZM0cNIjIv8DzHbmgu4+Cgd59ysC8WxeK5Ug2mX/KhS+IvM+Pp5uizNlS4ospY14J3i6 hUUsUyYTvj9tla3ZLd2Nhl44VwdPE5IRfu8n8= MIME-Version: 1.0 Received: by 10.229.126.133 with SMTP id c5mr3573887qcs.90.1301671631671; Fri, 01 Apr 2011 08:27:11 -0700 (PDT) Received: by 10.229.119.135 with HTTP; Fri, 1 Apr 2011 08:27:11 -0700 (PDT) In-Reply-To: <201104011504.p31F4K7q030205@rs73.luxsci.com> References: <201104011504.p31F4K7q030205@rs73.luxsci.com> Date: Fri, 1 Apr 2011 20:57:11 +0530 Message-ID: Subject: Re: DB Import Error... From: raghu ram To: Senthil Kumar G Cc: pgsql-admin@postgresql.org Content-Type: multipart/alternative; boundary=000e0cdfcd6838530f049fdd0bd0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.898 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 201104/24 X-Sequence-Number: 37205 --000e0cdfcd6838530f049fdd0bd0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On Fri, Apr 1, 2011 at 8:34 PM, Senthil Kumar G wrote: > Hi > > > > I am upgrading my staging environment from postgresql 8.2.3 to 9.0.3. > > > > I was able to do successfully. > > > > But, when i try to import the database which is created in 8.2.0 version = to > 9.0.3 version environment, i am getting following error. > > > > ERROR: constraint "xxxx=94 for relation "xxxx=94 already exist > Based on above error message it looks like the constraint for relation already exists. Could you please follow below steps to upgrade from older version to new version:: *Step 1: * Perform the global dump on *old cluster [ i.e PostgreSQL 8.2.3]*using "pg_dumpall" binary of new PostgreSQL 9.0. /opt/PostgreSQL/9.0/bin/pg_dumpall -d postgres -U postgres *-p 5432* -g > /tmp/globaldump_oldpg823.sql *NOTE: * It Dumps only global objects i.e roles,users and tablespaces,no databases. Assuming old cluster running on the 5432 port number. *Step 2: * Take the dump of the database in *compressed format* using new version of pg_dump binary. Syntax: /opt/PostgreSQL/9.0/bin/pg_dump -Fc -v *-p 5432* -f nohup /opt/PostgreSQL/9.0/bin/pg_dump -Fc -v -p 5432 -f /tmp/demo.dmp demo>= > /tmp/dump.log 2>> /tmp/dump.log & -P =3D> port number of old cluster -Fc =3D> compressed format -v =3D> verbose output -f =3D> location of dump file to store and dump file name *NOTE: * Assuming old cluster running on the 5432 port number *Step 3: * Restore the global dump on new cluster of PostgreSQL 9.0.2 /opt/PostgreSQL/9.0/bin/psql -d postgres -U postgres -p 5433 -f /tmp/globaldump_oldpg832.sql *NOTE: * Assuming new cluster running on the 5433 port number *Step 4: * Restore the compressed dump file using new version of pg_restore binary *with parallel restore* operation. nohup /opt/PostgreSQL/9.0/bin/pg_restore -Fc -v -p 5433 -d demo -j 8 /tmp/demo.dmp >>/tmp/restore1.log 2>>/tmp/restore1.log & *NOTE: * Assuming new cluster running on the 5433 port number --Raghu Ram > > > when i query it was not found. > > > > What could be the reason? What should i do to resolve this? > > > > Appreciate your quick answer. > > > > Thanks & Regards > > Senthil > > > --000e0cdfcd6838530f049fdd0bd0 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: quoted-printable

On Fri, Apr 1, 2011 at 8:34 PM, Senthil = Kumar G <senthil= @zoniac.com> wrote:

Hi

=A0

I am upgrading my staging environment from p= ostgresql 8.2.3 to 9.0.3.

=A0

I was able to do successfully.=

=A0

But, when i try to import the database which= is created in 8.2.0 version to 9.0.3 version environment, i am getting following error.

=A0

ERROR:=A0 constraint= "xxxx=94 for relation "xxxx=94 already exist


Based on above error message it looks like the constraint for relation already exists.

Coul= d you please follow below steps to upgrade from older version to new version::

S= tep 1: Perform the global dump on old cluster [ i.e PostgreSQL 8.2.3] using "pg_dumpall" binary of new PostgreSQL 9.0.

/opt/PostgreSQL/9.0/bin/pg_dumpall -d postgres -U postgres -p 5432 -g > /tmp/globaldump_oldpg823.sql

N= OTE: It Dumps only global objects i.e roles,users and tablespaces,no databases.

= =20 Assuming old cluster running on the 5432 port number.

S= tep 2: Take the dump of the database in compressed format using new version of pg_dump binary.

Syntax: /opt/PostgreSQL/9.0/bin/pg_dump -Fc -v -p 5432 -f <dump file location> <database name>

nohu= p /opt/PostgreSQL/9.0/bin/pg_dump -Fc -v -p 5432 -f /tmp/demo.dmp demo>> /tmp/dump.log 2>> /tmp/dump.log &

-P =3D> port number of old cluster

-Fc =3D> compressed format

-v =3D> verbose output

-f =3D> location of dump file to store and dump file name

N= OTE: Assuming old cluster running on the 5432 port number

S= tep 3: Restore the global dump on new cluster of PostgreSQL 9.0.2

/opt= /PostgreSQL/9.0/bin/psql -d postgres -U postgres -p 5433 -f /tmp/globaldump_oldpg832.sql

N= OTE: Assuming new cluster running on the 5433 port number

S= tep 4: Restore the compressed dump file using new version of pg_restore binary with parallel restore operation.

nohu= p /opt/PostgreSQL/9.0/bin/pg_restore -Fc -v -p 5433 -d demo -j 8 /tmp/demo.dmp >>/tmp/restore1.log 2>>/tmp/restore1.log &

N= OTE: Assuming new cluster running on the 5433 port number

--= Raghu Ram



=A0

=A0

when i query it was not found.=

=A0

What could be the reason? What should i do t= o resolve this?

=A0

Appreciate your quick answer.<= /p>

=A0

Thanks & Regards=

Senthil

=A0


--000e0cdfcd6838530f049fdd0bd0-- From senthil@zoniac.com Fri Apr 1 15:37:17 2011 Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 5A3AB1337B80 for ; Fri, 1 Apr 2011 12:37:17 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 72313-02 for ; Fri, 1 Apr 2011 15:37:06 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from rs73.luxsci.com (rs73.luxsci.com [64.49.254.135]) by mail.postgresql.org (Postfix) with ESMTP id B8C771337B6E for ; Fri, 1 Apr 2011 12:37:05 -0300 (ADT) Received: from SenthilKumarG (NSG-Static-233.156.72.182.airtel.in [182.72.156.233] (may be forged)) (authenticated bits=0) by rs73.luxsci.com (8.13.8/8.13.8) with ESMTP id p31Fawd3011874; Fri, 1 Apr 2011 10:36:59 -0500 Message-Id: <201104011536.p31Fawd3011874@rs73.luxsci.com> From: "Senthil Kumar G" To: "'Kevin Grittner'" , In-Reply-To: <4D95A686020000250003C123@gw.wicourts.gov> Subject: Re: DB Import Error... Date: Fri, 1 Apr 2011 21:07:05 +0530 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 Thread-Index: AcvwgCZYRkNI1CsCRcmU66E5pLp9rgAAh5fQ X-MimeOLE: Produced By Microsoft MimeOLE V6.1.7600.16543 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.61 tagged_above=-10 required=5 tests=BAYES_00=-1.9, MAY_BE_FORGED=0.29 X-Spam-Level: X-Archive-Number: 201104/25 X-Sequence-Number: 37206 Hi Kevin: Thanks for your quick response. I will try out this and come back if issue was not resolved still. Thanks Senthil -----Original Message----- From: Kevin Grittner [mailto:Kevin.Grittner@wicourts.gov] Sent: Friday, April 01, 2011 8:49 PM To: pgsql-admin@postgresql.org; Senthil Kumar G Subject: Re: [ADMIN] DB Import Error... "Senthil Kumar G" wrote: > I am upgrading my staging environment from postgresql 8.2.3 to > 9.0.3. > > I was able to do successfully. > [errors while applying dump to new database] > What could be the reason? What should i do to resolve this? The recommended upgrade technique is to us pg_dump (or pg_dumpall) from the newer version (9.0.3 in this case) to access the old database (running the 8.2.3 server in this case). If you followed some other procedure, like using the 8.2.3 software to dump the database, you should try the recommended approach instead. I generally dump in plain text format (the default) and pipe it to psql. -Kevin From senthil@zoniac.com Fri Apr 1 15:46:21 2011 Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 825251337C1C for ; Fri, 1 Apr 2011 12:46:21 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 73067-01-6 for ; Fri, 1 Apr 2011 15:46:12 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from rs73.luxsci.com (rs73.luxsci.com [64.49.254.135]) by mail.postgresql.org (Postfix) with ESMTP id 8319B1337B8B for ; Fri, 1 Apr 2011 12:45:57 -0300 (ADT) Received: from SenthilKumarG (NSG-Static-233.156.72.182.airtel.in [182.72.156.233] (may be forged)) (authenticated bits=0) by rs73.luxsci.com (8.13.8/8.13.8) with ESMTP id p31Fjqax000615; Fri, 1 Apr 2011 10:45:53 -0500 Message-Id: <201104011545.p31Fjqax000615@rs73.luxsci.com> From: "Senthil Kumar G" To: "'raghu ram'" Cc: In-Reply-To: Subject: Re: DB Import Error... Date: Fri, 1 Apr 2011 21:15:59 +0530 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_41D4_01CBF0B2.0173C3C0" X-Mailer: Microsoft Office Outlook, Build 11.0.5510 Thread-Index: AcvwgUY8bGKe+5+7QBiFmDdBIEU9UAAAl2Cw X-MimeOLE: Produced By Microsoft MimeOLE V6.1.7600.16543 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.609 tagged_above=-10 required=5 tests=BAYES_00=-1.9, HTML_MESSAGE=0.001, MAY_BE_FORGED=0.29 X-Spam-Level: X-Archive-Number: 201104/27 X-Sequence-Number: 37208 This is a multi-part message in MIME format. ------=_NextPart_000_41D4_01CBF0B2.0173C3C0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Thanks raghu ram for your immediate response, i will try this path too along with my team and i will come back if any issues. Thanks Senthil _____ From: raghu ram [mailto:raghuchennuru@gmail.com] Sent: Friday, April 01, 2011 8:57 PM To: Senthil Kumar G Cc: pgsql-admin@postgresql.org Subject: Re: [ADMIN] DB Import Error... On Fri, Apr 1, 2011 at 8:34 PM, Senthil Kumar G wrote: Hi I am upgrading my staging environment from postgresql 8.2.3 to 9.0.3. I was able to do successfully. But, when i try to import the database which is created in 8.2.0 version to 9.0.3 version environment, i am getting following error. ERROR: constraint "xxxx" for relation "xxxx" already exist Based on above error message it looks like the constraint for relation already exists. Could you please follow below steps to upgrade from older version to new version:: Step 1: Perform the global dump on old cluster [ i.e PostgreSQL 8.2.3] using "pg_dumpall" binary of new PostgreSQL 9.0. /opt/PostgreSQL/9.0/bin/pg_dumpall -d postgres -U postgres -p 5432 -g > /tmp/globaldump_oldpg823.sql NOTE: It Dumps only global objects i.e roles,users and tablespaces,no databases. Assuming old cluster running on the 5432 port number. Step 2: Take the dump of the database in compressed format using new version of pg_dump binary. Syntax: /opt/PostgreSQL/9.0/bin/pg_dump -Fc -v -p 5432 -f nohup /opt/PostgreSQL/9.0/bin/pg_dump -Fc -v -p 5432 -f /tmp/demo.dmp demo>> /tmp/dump.log 2>> /tmp/dump.log & -P => port number of old cluster -Fc => compressed format -v => verbose output -f => location of dump file to store and dump file name NOTE: Assuming old cluster running on the 5432 port number Step 3: Restore the global dump on new cluster of PostgreSQL 9.0.2 /opt/PostgreSQL/9.0/bin/psql -d postgres -U postgres -p 5433 -f /tmp/globaldump_oldpg832.sql NOTE: Assuming new cluster running on the 5433 port number Step 4: Restore the compressed dump file using new version of pg_restore binary with parallel restore operation. nohup /opt/PostgreSQL/9.0/bin/pg_restore -Fc -v -p 5433 -d demo -j 8 /tmp/demo.dmp >>/tmp/restore1.log 2>>/tmp/restore1.log & NOTE: Assuming new cluster running on the 5433 port number --Raghu Ram when i query it was not found. What could be the reason? What should i do to resolve this? Appreciate your quick answer. Thanks & Regards Senthil ------=_NextPart_000_41D4_01CBF0B2.0173C3C0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Thanks raghu ram for your immediate response,

i will try this path too along with = my team and i will come back if any issues.

 

Thanks

Senthil

=

 


From: raghu = ram [mailto:raghuchennuru@gmail.com]
Sent: Friday, April 01, = 2011 8:57 PM
To: Senthil Kumar G
Cc: = pgsql-admin@postgresql.org
Subject: Re: [ADMIN] DB = Import Error...

 

 

On Fri, Apr 1, 2011 at 8:34 PM, Senthil Kumar G <senthil@zoniac.com> = wrote:

Hi<= /p>

 

I am upgrading my staging environment from postgresql 8.2.3 to = 9.0.3.

 

I was able to do successfully.

 

But, when i try to import the database which is created in 8.2.0 version to 9.0.3 = version environment, i am getting following error.

 

ERROR:  constraint "xxxx” for relation "xxxx” already = exist

 

Based on above error message it looks like the constraint for relation already = exists.

Could you please follow below steps to upgrade = from older version to new version::

Step 1: = Perform the global dump on old cluster [ i.e PostgreSQL 8.2.3] using "pg_dumpall" binary of new PostgreSQL = 9.0.

/opt/PostgreSQL/9.0/bin/pg_dumpall -d postgres -U postgres -p 5432 -g > /tmp/globaldump_oldpg823.sql

NOTE: = It Dumps only global objects i.e roles,users and tablespaces,no databases.

Assuming old cluster running on the 5432 port = number.

Step 2: = Take the dump of the database in compressed format using new = version of pg_dump binary.

Syntax: /opt/PostgreSQL/9.0/bin/pg_dump -Fc -v = -p 5432 -f <dump file = location> <database name>

nohup /opt/PostgreSQL/9.0/bin/pg_dump -Fc -v -p = 5432 -f /tmp/demo.dmp demo>> /tmp/dump.log 2>> /tmp/dump.log = &

-P =3D> port number of old = cluster

-Fc =3D> compressed format

-v =3D> verbose output

-f =3D> location of dump file to store and dump file = name

NOTE: = Assuming old cluster running on the 5432 port = number

Step 3: = Restore the global dump on new cluster of = PostgreSQL 9.0.2

/opt/PostgreSQL/9.0/bin/psql -d postgres -U = postgres -p 5433 -f /tmp/globaldump_oldpg832.sql

NOTE: = Assuming new cluster running on the 5433 port = number

Step 4: = Restore the compressed dump file using new = version of pg_restore binary with parallel = restore operation.

nohup /opt/PostgreSQL/9.0/bin/pg_restore -Fc -v = -p 5433 -d demo -j 8 /tmp/demo.dmp >>/tmp/restore1.log = 2>>/tmp/restore1.log &

NOTE: = Assuming new cluster running on the 5433 port = number

--Raghu Ram

 

 

 

 

when i query it was not found.

 

What could be the reason? What should i do to resolve this? =

 

Appreciate your quick answer.

 

Thanks & Regards

Senthil

 

 

------=_NextPart_000_41D4_01CBF0B2.0173C3C0-- From gnanam@zoniac.com Mon Apr 4 14:07:59 2011 Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 8DFB41337B68 for ; Mon, 4 Apr 2011 11:07:59 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 97304-08 for ; Mon, 4 Apr 2011 14:07:52 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from rs73.luxsci.com (rs73.luxsci.com [64.49.254.135]) by mail.postgresql.org (Postfix) with ESMTP id E2E271337B67 for ; Mon, 4 Apr 2011 11:07:51 -0300 (ADT) Received: from GNANAM (NSG-Static-233.156.72.182.airtel.in [182.72.156.233] (may be forged)) (authenticated bits=0) by rs73.luxsci.com (8.13.8/8.13.8) with ESMTP id p34E7keQ018531; Mon, 4 Apr 2011 09:07:48 -0500 Reply-To: From: "Gnanakumar" To: Cc: , References: <201104011542.p31Fg6L3025075@rs73.luxsci.com> In-Reply-To: <201104011542.p31Fg6L3025075@rs73.luxsci.com> Subject: Re: DB Import Error... Date: Mon, 4 Apr 2011 19:33:43 +0530 Organization: Zoniac Software Private Limited Message-ID: <006201cbf2d1$1ea55730$5bf00590$@com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AcvwgCZYRkNI1CsCRcmU66E5pLp9rgAAoYhQAJJzInA= Content-Language: en-us X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.61 tagged_above=-10 required=5 tests=BAYES_00=-1.9, MAY_BE_FORGED=0.29 X-Spam-Level: X-Archive-Number: 201104/34 X-Sequence-Number: 37215 > The recommended upgrade technique is to us pg_dump (or pg_dumpall) > from the newer version (9.0.3 in this case) to access the old > database (running the 8.2.3 server in this case). If you followed > some other procedure, like using the 8.2.3 software to dump the > database, you should try the recommended approach instead. > I generally dump in plain text format (the default) and pipe it to > psql. Before trying out to use pg_dump from the newer version (9.0.3 in this case), I analyzed (.sql dump file) to my knowledge on what's going wrong. Reason for this analysis is that the same .sql dump file is importing into 8.2.3 successfully without any errors, but why it should error when the same .sql dump is imported into 9.0.3. There are 260 occurrences of this type of error during import (ERROR: constraint "xxxx" for relation "xxxx" already exist). I then located the statement in .sql dump file which was throwing this error. It points out here: CREATE CONSTRAINT TRIGGER ifb_ci_ciid_ciid_fk AFTER UPDATE ON consultantinterview FROM interviewfeedback NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_upd"('ifb_ci_ciid_ciid_fk', 'interviewfeedback', 'consultantinterview', 'FULL', 'consultantinterviewid', 'consultantinterviewid'); After seeing this statement, I was shocked and surprised that the constraint "ifb_ci_ciid_ciid_fk" was dropped very long (years) back in our application and it's still being referred internally somewhere by PostgreSQL. I then tried to query from "pg_trigger" table: "select * from pg_trigger where tgconstrname = 'ifb_ci_ciid_ciid_fk' " and I'm seeing 9 records with "tgname" starting with " RI_ConstraintTrigger_xxxx". Also, on describing table using \d, I don't see this constraint listed in "Foreign-key constraints" section, but I could see this constraint listed in "Triggers" section starting with RI_ConstraintTrigger_xxxx. What I could infer from this based on my knowledge is that the FK constraints are dropped from the table but its associated constraint triggers are not dropped properly. How do I resolve/clean-up our database at this stage? From Kevin.Grittner@wicourts.gov Mon Apr 4 16:12:31 2011 Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 25EE81337B69 for ; Mon, 4 Apr 2011 13:12:31 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 45365-03 for ; Mon, 4 Apr 2011 16:12:20 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from gw.wicourts.gov (gwmta.wicourts.gov [165.219.244.99]) by mail.postgresql.org (Postfix) with ESMTP id 51B811337BD1 for ; Mon, 4 Apr 2011 13:12:20 -0300 (ADT) Received: from Courts-MTA by gw.wicourts.gov with Novell_GroupWise; Mon, 04 Apr 2011 11:12:19 -0500 Message-Id: <4D99A788020000250003C21A@gw.wicourts.gov> X-Mailer: Novell GroupWise Internet Agent 8.0.1 Date: Mon, 04 Apr 2011 11:12:08 -0500 From: "Kevin Grittner" To: , Cc: Subject: Re: DB Import Error... References: <201104011542.p31Fg6L3025075@rs73.luxsci.com> <006201cbf2d1$1ea55730$5bf00590$@com> In-Reply-To: <006201cbf2d1$1ea55730$5bf00590$@com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201104/38 X-Sequence-Number: 37219 "Gnanakumar" wrote: >> The recommended upgrade technique is to us pg_dump (or >> pg_dumpall) from the newer version (9.0.3 in this case) to access >> the old database (running the 8.2.3 server in this case). If you >> followed some other procedure, like using the 8.2.3 software to >> dump the database, you should try the recommended approach >> instead. > Before trying out to use pg_dump from the newer version (9.0.3 in > this case), I analyzed (.sql dump file) to my knowledge on what's > going wrong. > What I could infer from this based on my knowledge is that the FK > constraints are dropped from the table but its associated > constraint triggers are not dropped properly. > > How do I resolve/clean-up our database at this stage? If you're upgrading to 9.0, I would start by following the recommended upgrade procedure and seeing whether these problems then exist in the new database. Fixing old issues like this is one big reason for using the newer version of pg_dump. -Kevin From gnanam@zoniac.com Tue Apr 5 06:51:38 2011 Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 61E931337B4E for ; Tue, 5 Apr 2011 03:51:38 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 85028-08 for ; Tue, 5 Apr 2011 06:51:31 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from rs73.luxsci.com (rs73.luxsci.com [64.49.254.135]) by mail.postgresql.org (Postfix) with ESMTP id 32B141337B47 for ; Tue, 5 Apr 2011 03:51:30 -0300 (ADT) Received: from GNANAM (NSG-Static-233.156.72.182.airtel.in [182.72.156.233] (may be forged)) (authenticated bits=0) by rs73.luxsci.com (8.13.8/8.13.8) with ESMTP id p356pPEU001426; Tue, 5 Apr 2011 01:51:28 -0500 Reply-To: From: "Gnanakumar" To: "'Kevin Grittner'" , Cc: References: <201104011542.p31Fg6L3025075@rs73.luxsci.com> <006201cbf2d1$1ea55730$5bf00590$@com> <4D99A788020000250003C21A@gw.wicourts.gov> In-Reply-To: <4D99A788020000250003C21A@gw.wicourts.gov> Subject: Re: DB Import Error... Date: Tue, 5 Apr 2011 12:17:22 +0530 Organization: Zoniac Software Private Limited Message-ID: <002501cbf35d$54246310$fc6d2930$@com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: Acvy4xmHbz+uTFhaQie5Vh8Fq0DAIQAbjFkA Content-Language: en-us X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.61 tagged_above=-10 required=5 tests=BAYES_00=-1.9, MAY_BE_FORGED=0.29 X-Spam-Level: X-Archive-Number: 201104/42 X-Sequence-Number: 37223 > If you're upgrading to 9.0, I would start by following the > recommended upgrade procedure and seeing whether these problems then > exist in the new database. Fixing old issues like this is one big > reason for using the newer version of pg_dump. How do I use the newer version of pg_dump (9.0.3 in this case) to take SQL dump, when v8.2.3 is already installed in my server? BTW, originally we've installed v8.2.3 from the source (./configure, gmake, gmake install). Even if I try to install the new version 9.0.3 from source, will that not overwrite existing directories, files, binaries, etc.? Our current v8.2.3 setup: Installation directory: /usr/local/pgsql Port: 5432 Any procedure/steps/advice/suggestion to take dump using latest version of pg_dump without disturbing old database cluster is appreciated. NOTE: It's not one single database server, we've multiple onsite customer servers that has to be upgraded, hence I would like to address this issue in general. From Kevin.Grittner@wicourts.gov Tue Apr 5 14:48:58 2011 Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 8865F1337BF5 for ; Tue, 5 Apr 2011 11:48:58 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 03997-04-3 for ; Tue, 5 Apr 2011 14:48:50 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from gw.wicourts.gov (gwmta.wicourts.gov [165.219.244.99]) by mail.postgresql.org (Postfix) with ESMTP id DAE8B1337C0A for ; Tue, 5 Apr 2011 11:48:47 -0300 (ADT) Received: from Courts-MTA by gw.wicourts.gov with Novell_GroupWise; Tue, 05 Apr 2011 09:48:48 -0500 Message-Id: <4D9AE575020000250003C2F4@gw.wicourts.gov> X-Mailer: Novell GroupWise Internet Agent 8.0.1 Date: Tue, 05 Apr 2011 09:48:37 -0500 From: "Kevin Grittner" To: , Cc: Subject: Re: DB Import Error... References: <201104011542.p31Fg6L3025075@rs73.luxsci.com> <006201cbf2d1$1ea55730$5bf00590$@com> <4D99A788020000250003C21A@gw.wicourts.gov> <002501cbf35d$54246310$fc6d2930$@com> In-Reply-To: <002501cbf35d$54246310$fc6d2930$@com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201104/43 X-Sequence-Number: 37224 "Gnanakumar" wrote: >> If you're upgrading to 9.0, I would start by following the >> recommended upgrade procedure and seeing whether these problems >> then exist in the new database. Fixing old issues like this is >> one big reason for using the newer version of pg_dump. > > How do I use the newer version of pg_dump (9.0.3 in this case) to > take SQL dump, when v8.2.3 is already installed in my server? You can install two different versions of PostgreSQL in different directories, or you can run pg_dump from the machine which is your conversion target. We do both. We always build from source, and we use a --prefix on configure which includes the version. For example: --prefix=/usr/local/pgsql-9.0.3 To simplify usage we also create a symbolic link from /usr/local/pgsql to the version we want as the default on the machine, and we set our PATH to include /usr/local/pgsql/bin. We never use the symbolic link in our service scripts, though. Anyway, if you build with a different prefix you can pick your version by explicitly specifying the full path when you run a client program like pg_dump. > Any procedure/steps/advice/suggestion to take dump using latest > version of pg_dump without disturbing old database cluster is > appreciated. When we're moving from an old version on one machine to a newer version on another machine, we don't need to install the new version of PostgreSQL on the old machine. On the new machine run: pg_dump -h oldmachine -U username remotedbname | psql localdbname -Kevin From gnanam@zoniac.com Thu Apr 7 09:43:49 2011 Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 36E9C1337B2F for ; Thu, 7 Apr 2011 06:43:49 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 90860-01 for ; Thu, 7 Apr 2011 09:43:30 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from rs73.luxsci.com (rs73.luxsci.com [64.49.254.135]) by mail.postgresql.org (Postfix) with ESMTP id 318021337BD1 for ; Thu, 7 Apr 2011 06:43:29 -0300 (ADT) Received: from GNANAM (NSG-Static-233.156.72.182.airtel.in [182.72.156.233] (may be forged)) (authenticated bits=0) by rs73.luxsci.com (8.13.8/8.13.8) with ESMTP id p379hPof021913; Thu, 7 Apr 2011 04:43:27 -0500 Reply-To: From: "Gnanakumar" To: "'Kevin Grittner'" , Cc: References: <201104011542.p31Fg6L3025075@rs73.luxsci.com> <006201cbf2d1$1ea55730$5bf00590$@com> <4D99A788020000250003C21A@gw.wicourts.gov> <002501cbf35d$54246310$fc6d2930$@com> <4D9AE575020000250003C2F4@gw.wicourts.gov> In-Reply-To: <4D9AE575020000250003C2F4@gw.wicourts.gov> Subject: Re: DB Import Error... Date: Thu, 7 Apr 2011 15:09:19 +0530 Organization: Zoniac Software Private Limited Message-ID: <002b01cbf507$ae806f60$0b814e20$@com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AcvzoJ+1IBzpjQYUR/mntcRu5XBQsgBY+1/Q Content-Language: en-us X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.61 tagged_above=-10 required=5 tests=BAYES_00=-1.9, MAY_BE_FORGED=0.29 X-Spam-Level: X-Archive-Number: 201104/55 X-Sequence-Number: 37236 > You can install two different versions of PostgreSQL in different > directories, or you can run pg_dump from the machine which is your > conversion target. We do both. We always build from source, and we > use a --prefix on configure which includes the version. For > example: I even tried out the recommended upgrade technique also. That is, installed new version (9.0.3 in this case) of PostgreSQL in a different directory in the same machine and used pg_dump of this latest version to access the old database (running 8.2.3 in this case) to take a dump and then imported into 9.0.3. Still I'm facing *exactly* the same set of errors after importing (as I was getting before). ERROR: constraint "xxxx" for relation "xxxx" already exist There are 260 occurrences of this type of error. How do I resolve/fix this problem at this stage? Since this issue we're facing is with our Production database dump, timely suggestions/advice/help to resolve this are highly appreciated. From leite.marcelo@gmail.com Sat Apr 9 12:25:00 2011 Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 19DD91337B6E for ; Sat, 9 Apr 2011 09:25:00 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 10733-05 for ; Sat, 9 Apr 2011 12:24:42 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-fx0-f46.google.com (mail-fx0-f46.google.com [209.85.161.46]) by mail.postgresql.org (Postfix) with ESMTP id 83A8E1336FA7 for ; Sat, 9 Apr 2011 09:24:41 -0300 (ADT) Received: by fxm17 with SMTP id 17so2794437fxm.19 for ; Sat, 09 Apr 2011 05:24:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=uV7V+jTm4bQtqr8xTNgy+UuamwESeulBmzgEPrW9tUg=; b=V+1xaobtU9M1bAgoFJna6sBXB4oG433tzmu1Lrf2xhZ80MXZH85+6Dk+LFK2hhew5t /wI/AFKlG9Fa6CISNIGaJNDN9D0GSGKhxcB9SOHBAW18D58jQhOwUdT/y18btUAk1+BG WjVRI6Dm4oQfEnnzv+x3eIyrJ3ZPz6S1oDqFo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=hIx/YZG3+Ds2PytnnhpSPmOt9J0GXALMfQvvXDxm6y86kDL/8/gmFRmuO5EiwJDXkD yeTZbpgWmov96nej+LwiUc0vIcxZIyQVzXNGxArkrn6Zquu6ktjp9eE6R9rToCQZZ+kX t3j0JjqrNvCMj1PZ0JmiLv9XGgQi6+QI/v5Ig= Received: by 10.223.35.147 with SMTP id p19mr3379035fad.13.1302351881110; Sat, 09 Apr 2011 05:24:41 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.83.205 with HTTP; Sat, 9 Apr 2011 05:24:21 -0700 (PDT) In-Reply-To: <002b01cbf507$ae806f60$0b814e20$@com> References: <201104011542.p31Fg6L3025075@rs73.luxsci.com> <006201cbf2d1$1ea55730$5bf00590$@com> <4D99A788020000250003C21A@gw.wicourts.gov> <002501cbf35d$54246310$fc6d2930$@com> <4D9AE575020000250003C2F4@gw.wicourts.gov> <002b01cbf507$ae806f60$0b814e20$@com> From: Marcelo Leite Date: Sat, 9 Apr 2011 09:24:21 -0300 Message-ID: Subject: Re: DB Import Error... To: gnanam@zoniac.com Cc: Kevin Grittner , pgsql-admin@postgresql.org, raghuchennuru@gmail.com Content-Type: multipart/alternative; boundary=00151747baa83f069404a07b6ddf X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.888 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, T_TO_NO_BRKTS_FREEMAIL=0.01 X-Spam-Level: X-Archive-Number: 201104/68 X-Sequence-Number: 37249 --00151747baa83f069404a07b6ddf Content-Type: text/plain; charset=ISO-8859-1 Hi, even getting this error, do you have the database restored? Have you tried to dump only the schema (without data) and search for the problematic constraint to check if you have 2 or more with same name? Regards, MLeite --00151747baa83f069404a07b6ddf Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi,

even getting this error, do you have the database restored? Have you=20 tried to dump only the schema (without data) and search for the=A0=20 problematic constraint to check if you have 2 or more with same name?

Regards, MLeite
--00151747baa83f069404a07b6ddf-- From leite.marcelo@gmail.com Sat Apr 9 12:28:11 2011 Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 9A9571337B6E for ; Sat, 9 Apr 2011 09:28:11 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 42882-03 for ; Sat, 9 Apr 2011 12:27:52 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-fx0-f46.google.com (mail-fx0-f46.google.com [209.85.161.46]) by mail.postgresql.org (Postfix) with ESMTP id DA0701336FA7 for ; Sat, 9 Apr 2011 09:27:51 -0300 (ADT) Received: by fxm17 with SMTP id 17so2795197fxm.19 for ; Sat, 09 Apr 2011 05:27:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=EnCQgc4FGC/5MQ11zVA5Z53tB3saSt6nd9qTsFV11qo=; b=dFFO8HjM3UvUdJaKgUwM42MaAlXwW0ZO1/G/7wRhfQzB/jZ16BezIKnFZe/VNwPJ0C y9dkDvKprBL57p9z/UdIqmdLINcxhp6MliXE5zGuNqd5mnpfIuowGpBj1z+GaxxWtNBo 2NeclVeb57UqTFJw/EsPE8gbbfYLt54F2pP1w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=L8I0u/lURHdlz2lt6KYj9Lc+u7s0X8QSjl+78YbXmwi8gguCyqKVNjT/0FDv3VMzKw NTCIerpEz6iohI3mQ6G4mvValv2oxTESWe3rlhn+6PiZiPbarK/gqxHZeMvKsGYn8+ak pP1sCb/yigVvLLafscfDqE+Tp2/uNnASFAiCE= Received: by 10.223.110.21 with SMTP id l21mr948015fap.70.1302352071153; Sat, 09 Apr 2011 05:27:51 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.83.205 with HTTP; Sat, 9 Apr 2011 05:27:31 -0700 (PDT) In-Reply-To: References: <201104011542.p31Fg6L3025075@rs73.luxsci.com> <006201cbf2d1$1ea55730$5bf00590$@com> <4D99A788020000250003C21A@gw.wicourts.gov> <002501cbf35d$54246310$fc6d2930$@com> <4D9AE575020000250003C2F4@gw.wicourts.gov> <002b01cbf507$ae806f60$0b814e20$@com> From: Marcelo Leite Date: Sat, 9 Apr 2011 09:27:31 -0300 Message-ID: Subject: Re: DB Import Error... To: gnanam@zoniac.com Cc: Kevin Grittner , pgsql-admin@postgresql.org, raghuchennuru@gmail.com Content-Type: multipart/alternative; boundary=0016e68ba26692d9a304a07b78f3 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.888 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, T_TO_NO_BRKTS_FREEMAIL=0.01 X-Spam-Level: X-Archive-Number: 201104/69 X-Sequence-Number: 37250 --0016e68ba26692d9a304a07b78f3 Content-Type: text/plain; charset=ISO-8859-1 Sorry... when i said "search for the problematic constraint" i meant to open the file in a text editor and search for the problematic constraint. MLeite --0016e68ba26692d9a304a07b78f3 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Sorry...

when i said "search for the=A0=20 problematic constraint" i meant to open the file in a text editor and = search for the problematic constraint.

MLeite
--0016e68ba26692d9a304a07b78f3-- From gnanam@zoniac.com Mon Apr 11 15:35:24 2011 Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 7D8B61337C54 for ; Mon, 11 Apr 2011 12:35:24 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 63315-07-2 for ; Mon, 11 Apr 2011 15:35:03 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from rs73.luxsci.com (rs73.luxsci.com [64.49.254.135]) by mail.postgresql.org (Postfix) with ESMTP id 613EA1337CD8 for ; Mon, 11 Apr 2011 03:09:28 -0300 (ADT) Received: from GNANAM (NSG-Static-233.156.72.182.airtel.in [182.72.156.233] (may be forged)) (authenticated bits=0) by rs73.luxsci.com (8.13.8/8.13.8) with ESMTP id p3B69NNA019552; Mon, 11 Apr 2011 01:09:25 -0500 Reply-To: From: "Gnanakumar" To: "'Marcelo Leite'" Cc: "'Kevin Grittner'" , , References: <201104011542.p31Fg6L3025075@rs73.luxsci.com> <006201cbf2d1$1ea55730$5bf00590$@com> <4D99A788020000250003C21A@gw.wicourts.gov> <002501cbf35d$54246310$fc6d2930$@com> <4D9AE575020000250003C2F4@gw.wicourts.gov> <002b01cbf507$ae806f60$0b814e20$@com> In-Reply-To: Subject: Re: DB Import Error... Date: Mon, 11 Apr 2011 11:35:10 +0530 Organization: Zoniac Software Private Limited Message-ID: <003c01cbf80e$6e5dc220$4b194660$@com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: Acv2sYwUoxtNFdcuRbGVAkUxclzIzwBVhMQw Content-Language: en-us X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.61 tagged_above=-10 required=5 tests=BAYES_00=-1.9, MAY_BE_FORGED=0.29 X-Spam-Level: X-Archive-Number: 201104/77 X-Sequence-Number: 37258 > when i said "search for the=A0 problematic constraint" i meant to open = the file in a text editor and search for the problematic constraint. Yes, I've even opened the dump file and analyzed those constraints. In fact, I've already explained in detail about my observations here: http://archives.postgresql.org/pgsql-admin/2011-04/msg00033.php As I said in the above link, though many FK constraints were dropped = very long (years) back in our application, but its associated "constraint triggers" were not dropped properly by PostgreSQL from "pg_trigger" = table in v8.2.3. After understanding about PostgreSQL system catalog table (particularly pg_class, pg_trigger, pg_constraint), I wrote a function = on my own to delete the FK constraints that are still referred in pg_trigger table. After executing the below function in v8.2.3, I took pg_dump in v8.2.3 = and then imported the SQL dump into v9.0.3. Now, I don't see any errors = while importing in v9.0.3. NOTE: Previously, when there was errors while importing in v9.0.3, I = could see all those *dropped* FK constraints were again automatically = *recreated* in v9.0.3. I confirmed this from 2 places: psql (using \d) and pgAdmin = II tool. But after executing the below function in v8.0.3 before taking pg_dump and then import in v9.0.3, I don't see any errors now and also = at the same time, I don't see those dropped FK constraints reappearing/recreated here. Any advice/suggestion/remarks/alternatives to my approach are highly appreciated.=20 FUNCTION: CREATE OR REPLACE FUNCTION = delete_dropped_fk_constraints_from_pg_trigger() RETURNS numeric AS' DECLARE v_tgconstrname VARCHAR; v_table1 VARCHAR; v_table2 VARCHAR; v_child_trigger_count NUMERIC :=3D 0; v_parent_trigger_count NUMERIC :=3D 0; C1 CURSOR IS SELECT=20 DISTINCT tgconstrname, (select relname from pg_class where oid =3D tgrelid) as table1, (select relname from pg_class where oid =3D tgconstrrelid) as table2 FROM=20 pg_trigger WHERE=20 tgisconstraint =3D true=20 AND tgconstrname IS NOT NULL=20 AND LENGTH(tgconstrname) > 0=20 AND tgconstrname !=3D '''' AND tgconstrname NOT IN=20 (SELECT conname FROM pg_constraint=20 WHERE contype =3D ''f'')=20 ORDER BY 1; BEGIN OPEN C1; LOOP FETCH C1 INTO v_tgconstrname, v_table1, v_table2; IF NOT FOUND THEN EXIT; END IF; RAISE NOTICE ''FK Constraint Name=3D%, Table1=3D%, Table2=3D%'', v_tgconstrname, v_table1, v_table2; SELECT COUNT(*) INTO v_child_trigger_count FROM pg_trigger WHERE tgrelid =3D (SELECT oid FROM pg_class WHERE relname =3D LOWER(v_table1)) AND tgconstrname =3D LOWER(v_constr_name); SELECT COUNT(*) INTO v_parent_trigger_count FROM pg_trigger WHERE tgrelid =3D (SELECT oid FROM pg_class WHERE relname =3D LOWER(v_table2)) AND tgconstrname =3D LOWER(v_constr_name); DELETE FROM pg_trigger WHERE LOWER(tgconstrname) =3D LOWER(v_constr_name) AND tgrelid IN (SELECT oid FROM pg_class WHERE relname IN (LOWER(v_table1),LOWER(v_table2))); UPDATE pg_class SET reltriggers =3D reltriggers - v_child_trigger_count WHERE relname =3D LOWER(v_table1); IF (v_table1 <> v_table2) THEN -- This condition is checked for self-referencing FK constraints UPDATE pg_class SET reltriggers =3D reltriggers - v_parent_trigger_count WHERE relname =3D LOWER(v_table2); END IF; END LOOP; CLOSE C1; RETURN 1; END;' LANGUAGE 'plpgsql'; SELECT delete_dropped_fk_constraints_from_pg_trigger();