Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 65FE2632C55 for ; Mon, 13 Apr 2009 18:34:08 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 52050-01-6 for ; Mon, 13 Apr 2009 18:34:05 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from qw-out-2122.google.com (qw-out-2122.google.com [74.125.92.25]) by mail.postgresql.org (Postfix) with ESMTP id EAA28634023 for ; Mon, 13 Apr 2009 18:32:54 -0300 (ADT) Received: by qw-out-2122.google.com with SMTP id 8so2264872qwh.61 for ; Mon, 13 Apr 2009 14:32:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=+VhXoEVu8QmWSUgLi007u+iNjcAfcauRiqWJBpVuGw0=; b=BAdX0eyDLeEuW9K6mt+By6/7BuHpSear9C0rasarAFcvEriNGcnT+aN6XGN19Ye3H9 YtgNA2KumHL6Jd5D3YPZ9T5Xsjm4CdFYbTVNm3ggwrZYExOZfyY30oCHsB7TIGXaEva0 bOGaEDRulY+6628Cq3Sz7nRVQIUCQZ/TMicyw= 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:content-transfer-encoding; b=pn49c7qyI+lg6sxY3Iz3CJ7RNu0Vn5qkZq2J34sg2xb5qIbFMCwwnKzZ06Hm/tp9sO cvet0U7FAGTO81VBJ/hY7+GkCbfg2enjlaidd8gibt8lXmkrSuXbRQTQE/vZSyofLIku RLu1qQRga7iOGk2Ieg9XmbDn2zdAcmawmdajU= MIME-Version: 1.0 Received: by 10.229.91.12 with SMTP id k12mr1816076qcm.66.1239658373648; Mon, 13 Apr 2009 14:32:53 -0700 (PDT) In-Reply-To: <396486430904131418g3898dc5h2472f9efab331489@mail.gmail.com> References: <49DC1034.1060705@frii.com> <49E37441.6030301@frii.com> <396486430904131418g3898dc5h2472f9efab331489@mail.gmail.com> Date: Mon, 13 Apr 2009 17:32:53 -0400 Message-ID: Subject: Re: changing multiple pk's in one update From: Glenn Maynard To: Richard Broersma Cc: pgsql-sql@postgresql.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200904/64 X-Sequence-Number: 32410 On Mon, Apr 13, 2009 at 5:18 PM, Richard Broersma wrote: >> Your PK is a composite of (entry, order)? =C2=A0Won't your foreign keys >> elsewhere all break when you shift the order around? > > If there really are foreign keys, then an update will not be allowed > to shift a primary key unless the foreign key is set with ON UPDATE > CASCADE then the shifts will be cascaded to all references > automatically. Right. I'm still dusting off my SQL after a long period of corrosion. :) The same applies, though, if you have external references to the PK; for example, if you have a web interface where "/sense/10/3" refers to entry 10, sense 3. If your senses are reordered by someone else, and you operate on /10/3, you may suddenly find yourself viewing or modifying (or deleting!) a different sense. This could even happen within the same transaction, if you're not very careful with locking... --=20 Glenn Maynard