Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T7YKq-0003D5-O2 for pgsql-bugs@postgresql.org; Fri, 31 Aug 2012 21:01:00 +0000 Received: from smtprelay0028.b.hostedemail.com ([64.98.42.28] helo=smtprelay.b.hostedemail.com) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T7YKn-0003Cs-4T for pgsql-bugs@postgresql.org; Fri, 31 Aug 2012 21:01:00 +0000 Received: from filter.hostedemail.com (b-bigip1 [10.5.19.254]) by smtprelay01.b.hostedemail.com (Postfix) with SMTP id 547CE72FCEC; Fri, 31 Aug 2012 21:00:55 +0000 (UTC) X-Panda: scanned! X-Spam-Summary: 50, 0, 0, , d41d8cd98f00b204, alvherre@alvh.no-ip.org, :::::, RULES_HIT:152:355:379:599:601:800:945:960:967:973:988:989:1260:1277:1311:1313:1345:1359:1431:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2379:2393:2525:2560:2563:2682:2685:2857:2859:2895:2933:2937:2939:2942:2945:2947:2951:2954:3022:3027:3138:3139:3140:3141:3142:3355:3865:3866:3867:3868:3869:3870:3871:3872:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4250:4321:4470:4605:4659:5007:6119:6261:7679:7903:8660:8957:9010:9025:9121:10004:10400:10848:10967:11256:11257:11658:11914:12043:12296:12438:12517:12519, 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: 3656 Received: from perhan.alvh.no-ip.org (unknown [200.85.215.105]) (Authenticated sender: alvherre@alvh.no-ip.org) by omf05.b.hostedemail.com (Postfix) with ESMTPA; Fri, 31 Aug 2012 21:00:54 +0000 (UTC) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id E40A56E5DD; Fri, 31 Aug 2012 17:00:52 -0400 (CLT) Content-Type: text/plain; charset=UTF-8 Cc: jeff , Pg Bugs Subject: Re: BUG #6704: ALTER EXTENSION postgis SET SCHEMA leaves dangling relations From: Alvaro Herrera To: Tom Lane In-reply-to: <1346444697-sup-476@alvh.no-ip.org> References: <26225.1340419030@sss.pgh.pa.us> <1346425015-sup-3266@alvh.no-ip.org> <29703.1346429879@sss.pgh.pa.us> <1346430351-sup-5026@alvh.no-ip.org> <1346439762-sup-9541@alvh.no-ip.org> <18412.1346443263@sss.pgh.pa.us> <1346444697-sup-476@alvh.no-ip.org> Date: Fri, 31 Aug 2012 17:00:52 -0400 Message-Id: <1346445756-sup-1463@alvh.no-ip.org> User-Agent: Sup/git Content-Transfer-Encoding: quoted-printable X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201208/270 X-Sequence-Number: 33994 Excerpts from Alvaro Herrera's message of vie ago 31 16:25:40 -0400 2012: > Excerpts from Tom Lane's message of vie ago 31 16:01:03 -0400 2012: > > Alvaro Herrera writes: > > > Here's a patch. > >=20 > > Looks reasonable, but please try a little harder on the comments for = the > > new function --- IMO it should have a header comment that explains wh= at > > it's supposed to do exactly. >=20 > Sure. >=20 > This doesn't actually work though: it's trying to move sequences twice. > Not sure what the right fix for this is ... still looking. The error message: alvherre=3D# alter extension isn set schema foo; ERROR: tuple already updated by self Besides being listed with deptype=3Dextension for the extension in question, the sequence has a deptype=3Dauto entry for the column, which leads to it being moved twice. I don't see any clean fix for this: 1. At extension creation time, skip generating dependencies for sequences that are part of a table. I don't see how to do this: We would have to reach within heap_create_with_catalog and tell it not to add an deptype=3Dextension dependency if it's called for a sequence that'= s part of a serial column. I don't think heap_create_with_catalog even knows that at all. 2. During ALTER EXTENSION execution, skip moving objects that have already been moved. Not really sure how this would be implemented; perhaps we could have AlterObjectNamespace_oid add each moved object to a list of moved objects, and skip everything that's already present in it. Seems very messy to implement. 3. Pass a flag to AlterTableNamespaceInternal, something like "skip_sequences", and do not call AlterSeqsNamespace it that's set. This seems really ugly though, and I'm not sure if it might break something else. 4. Maybe we could have AlterRelationNamespaceInternal check what the current namespace is for the object, and do nothing if it's already the target namespace. One thing to keep in mind is that existing databases might already have broken catalogs (i.e. extensions have already been moved and objects are already in nonexistant schemas). This is not very likely unless the user has not been using pg_dump at all. But many databases already have deptype=3Dextension pg_depend entries for sequences owned by SERIAL columns, so it's unclear that (1) is a good solution even if it were implementable. --=20 =C3=81lvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services