Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TBmdc-0006Ez-8Q for pgsql-bugs@postgresql.org; Wed, 12 Sep 2012 13:05:52 +0000 Received: from smtprelay0120.b.hostedemail.com ([64.98.42.120] helo=smtprelay.b.hostedemail.com) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TBmdV-0003rJ-84 for pgsql-bugs@postgresql.org; Wed, 12 Sep 2012 13:05:51 +0000 Received: from filter.hostedemail.com (b-bigip1 [10.5.19.254]) by smtprelay05.b.hostedemail.com (Postfix) with SMTP id 035D232AB4A3; Wed, 12 Sep 2012 13:05:42 +0000 (UTC) X-Panda: scanned! X-Spam-Summary: 50, 0, 0, , d41d8cd98f00b204, alvherre@alvh.no-ip.org, :::::::::, RULES_HIT:152:355:379:599:601:945:967:973:982:988:989:1260:1277:1311:1313:1345:1359:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2198:2199:2379:2393:2525:2553:2560:2563:2682:2685:2857:2859:2933:2937:2939:2942:2945:2947:2951:2954:3022:3027:3138:3139:3140:3141:3142:3355:3636:3865:3866:3867:3868:3869:3870:3871:3872:3873:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4184:4250:4321:4605:4659:5007:6119:6261:7679:7809:7903:8660:8700:8957:9025:9121:10004:10400:10848:10967:11256:11257:11658:11914:12043:12050:12296:12438:12517:12519:12679:12684, 0, RBL:none, CacheIP:none, Bayesian:0.5, 0.5, 0.5, Netcheck:none, DomainCache:0, MSF:not bulk, SPF:fn, MSBL:0, DNSBL:none, Custom_rules:0:0:0 X-Session-Marker: 616C76686572726540616C76682E6E6F2D69702E6F7267 X-Filterd-Recvd-Size: 3654 Received: from perhan.alvh.no-ip.org (unknown [200.85.215.105]) (Authenticated sender: alvherre@alvh.no-ip.org) by omf13.b.hostedemail.com (Postfix) with ESMTPA; Wed, 12 Sep 2012 13:05:42 +0000 (UTC) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 053366E378; Wed, 12 Sep 2012 10:05:39 -0300 (CLST) Content-Type: text/plain; charset=UTF-8 Cc: Bruce Momjian , Tom Lane , jeff , Pg Bugs Subject: Re: BUG #6704: ALTER EXTENSION postgis SET SCHEMA leaves dangling relations From: Alvaro Herrera To: Dimitri Fontaine In-reply-to: References: <26225.1340419030@sss.pgh.pa.us> <20120830214826.GC32350@momjian.us> Date: Wed, 12 Sep 2012 10:05:39 -0300 Message-Id: <1347454709-sup-1105@alvh.no-ip.org> User-Agent: Sup/git Content-Transfer-Encoding: quoted-printable X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201209/104 X-Sequence-Number: 34099 Excerpts from Dimitri Fontaine's message of mi=C3=A9 sep 12 06:51:43 -030= 0 2012: > Hi, >=20 > Sorry for being late at the party=E2=80=A6 been distracted away=E2=80=A6 Welcome ;-) > > On Fri, Jun 22, 2012 at 10:37:10PM -0400, Tom Lane wrote: > >> A bit of looking shows that ALTER EXTENSION SET SCHEMA calls > >> AlterObjectNamespace_oid on the table. AlterObjectNamespace_oid > >> calls AlterRelationNamespaceInternal, and nothing else. In comparis= on, > >> ALTER TABLE SET SCHEMA (AlterTableNamespace) calls > >> AlterRelationNamespaceInternal and about four other things. I'm not > >> sure if this was broken before the last round of refactoring in this > >> area, but for sure it's broken now. >=20 > Looking at that code, my theory of how we got there is that in the > submitted extension patch I did only use DEPENDENCY_INTERNAL and Tom > introduced the much better DEPENDENCY_EXTENSION tracking. With the > former, indexes and sequences and constraints where found in the > dependency walking code, but only the main relation is now registered i= n > the later model. >=20 > I need to do some testing about dependency tracking on SERIAL generated > sequences compared to manually created sequences in extension scripts, = I > think we track sequences directly only in the manual case. Well, what I saw was that both the table and its SERIAL-generated sequence got an DEPENDENCY_EXTENSION row in pg_depend, which is exactly what (IMV) causes the problem. One of my proposals is to tweak the code to avoid that row (but if we do that, then we need to do something about databases that contain such rows today). > I think we need to share more code in between > AlterRelationNamespaceInternal and AlterTableNamespace, but I'm not sur= e > if that's not exactly what =C3=81lvaro did try with his _oid() attempt = that > failed. What I did was create an AlterTableNamespaceInternal that goes through all the things that must be moved (this means calling AlterRelationNamespaceInternal for the table, and then doing some more calls to move the sequences, indexes, constraints). With this change, both AlterTableNamespace and AlterObjectNamespace_oid can call it. Previously, AlterObjectNamespace_oid was calling AlterRelationNamespaceInternal directly for the relation only. As far as I can see, that split of AlterTableNamespace is still needed. The problem here is that we need something *beyond* that fix. Did you look at my patches? Am I making sense? --=20 =C3=81lvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services