Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id B8D96D2C813 for ; Sat, 28 Jan 2012 22:08:44 -0400 (AST) Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RrKC8-00019I-5t for pgsql-bugs@postgresql.org; Sun, 29 Jan 2012 02:08:44 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id q0T28QLf011809; Sat, 28 Jan 2012 21:08:27 -0500 (EST) To: Phil Sorber cc: pgsql-bugs@postgresql.org Subject: Re: Example in plpgsql docs can lead to infinite loop In-reply-to: References: Comments: In-reply-to Phil Sorber message dated "Fri, 27 Jan 2012 15:56:07 -0500" Date: Sat, 28 Jan 2012 21:08:26 -0500 Message-ID: <11808.1327802906@sss.pgh.pa.us> From: Tom Lane X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201201/229 X-Sequence-Number: 32296 Phil Sorber writes: > http://www.postgresql.org/docs/devel/static/plpgsql-control-structures.html#PLPGSQL-UPSERT-EXAMPLE > This example can lead to an infinite loop if there is another column > that has a unique key constraint on it in addition to the primary key > and someone tries to execute the function with a unique primary key > but a duplicate value for the column with the unique constraint. Hmm. It might work, depending on what the table's various unique indexes are for, but I agree that a caution about the case is reasonable. I adjusted your text a bit and committed this. regards, tom lane