Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 2FB71B5DBCA for ; Sat, 8 Oct 2011 06:31:46 -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 18393-06 for ; Sat, 8 Oct 2011 09:31:40 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from lo.gmane.org (lo.gmane.org [80.91.229.12]) by mail.postgresql.org (Postfix) with ESMTP id CDA56B5D80B for ; Sat, 8 Oct 2011 06:31:39 -0300 (ADT) Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1RCTFp-0003N6-DN for pgsql-sql@postgresql.org; Sat, 08 Oct 2011 11:31:37 +0200 Received: from ip-118-90-84-120.xdsl.xnet.co.nz ([118.90.84.120]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 08 Oct 2011 11:31:37 +0200 Received: from jasen by ip-118-90-84-120.xdsl.xnet.co.nz with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 08 Oct 2011 11:31:37 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org From: Jasen Betts Subject: Re: Edit multiple rows concurrent save Date: 8 Oct 2011 09:19:10 GMT Organization: Dis (not Dat) Organisation Lines: 25 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: ip-118-90-84-120.xdsl.xnet.co.nz X-Face: ?)Aw4rXwN5u0~$nqKj`xPz>xHCwgi^q+^?Ri*+R(&uv2=E1Q0Zk(>h!~o2ID@6{uf8s; a +M[5[U[QT7xFN%^gR"=tuJw%TXXR'Fp~W; (T"1(739R%m0Yyyv*gkGoPA.$b,D.w:z+<'"=-lVT?6 {T?=R^:W5g|E2#EhjKCa+nt":4b}dU7GYB*HBxn&Td$@f%.kl^:7X8rQWd[NTc"P"u6nkisze/Q; 8 "9Z{peQF,w)7UjV$c|RO/mQW/NMgWfr5*$-Z%u46"/00mx-,\R'fLPe.)^ User-Agent: slrn/pre1.0.0-18 (Linux) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.404 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-0.504 X-Spam-Level: X-Archive-Number: 201110/3 X-Sequence-Number: 35887 On 2011-09-29, Péter Szabó wrote: > users_has_cards.auctions + users_has_cards.decks never can be higher > then users_has_cards.total. It should be also granted that > users_has_cards.total - users_has_cards.auctions number of cards from > a specific type can be in any decks. > > The deck assembly input comes from web, and parsed with PHP, so it is > absolutely not trusted. > > I am started to write a PL/PgSQL function to handle the save of a > deck, but it seems unable to solve this issue. I don't know how to go > forward, so any idea is appreciated. so users_has_cards has a check ( total >= decks + auctions ) and decks_has_cards needs triggers on insert, update, and delete that manipulate the decks column of the users_has_cards record that corresponds to that card. This is probably goiung to make updates to the decks_has_cards table about 10 times slower (should still be faster than you could have done in PHP) -- ⚂⚃ 100% natural