X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id AB8EA9FA081 for ; Wed, 6 Sep 2006 19:53:07 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 88693-04 for ; Wed, 6 Sep 2006 19:52:59 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from relais.videotron.ca (relais.videotron.ca [24.201.245.36]) by postgresql.org (Postfix) with ESMTP id A3ACA9FA0EB for ; Wed, 6 Sep 2006 19:32:59 -0300 (ADT) Received: from tedy ([66.130.229.163]) by VL-MH-MR002.ip.videotron.ca (Sun Java System Messaging Server 6.2-2.05 (built Apr 28 2005)) with ESMTP id <0J56006SYZYYJDF7@VL-MH-MR002.ip.videotron.ca> for pgsql-sql@postgresql.org; Wed, 06 Sep 2006 18:32:58 -0400 (EDT) Date: Wed, 06 Sep 2006 18:32:40 -0400 From: Daniel CAUNE Subject: Evaluation of if conditions To: pgsql-sql@postgresql.org Message-id: <001601c6d204$5d2cd840$0b00a8c0@tedy> MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2962 X-Mailer: Microsoft Office Outlook 11 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT Thread-index: AcbSBFzstwUyuMCCRoOwcG7CiUsqpg== X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.033 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200609/39 X-Sequence-Number: 26250 Hi, How does the IF statement evaluate conditions? Does it evaluate conditions following their declaration order from left to right? In case of or-conditions, does the IF statement stop evaluating conditions whenever a first or-condition is true? The following snippet seems to be invalid, which let me think that PL/PGSQL evaluates all the conditions: IF (TG_OP = 'INSERT') OR (OLD.bar = ...) THEN statement END IF; Should be rewritten as (for example): IF (TG_OP = 'INSERT') THEN statement ELSIF (OLD.bar = ...) THEN statement END IF; Regards, -- Daniel