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 7552E9FAC9B for ; Wed, 6 Sep 2006 20:33:31 -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 91582-04 for ; Wed, 6 Sep 2006 20:33:20 -0300 (ADT) X-Greylist: delayed 00:32:03.97347 by SQLgrey- Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 805749FB2A9 for ; Wed, 6 Sep 2006 20:33:20 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from loki.globexplorer.com (loki.globexplorer.com [12.25.176.46]) by svr4.postgresql.org (Postfix) with ESMTP id F3F6E5AF887 for ; Wed, 6 Sep 2006 23:01:14 +0000 (GMT) Content-Class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 Subject: Re: Evaluation of if conditions Date: Wed, 6 Sep 2006 16:02:30 -0700 Message-ID: <71E37EF6B7DCC1499CEA0316A256832802B3E511@loki.wc.globexplorer.net> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [SQL] Evaluation of if conditions Thread-Index: AcbSBFzstwUyuMCCRoOwcG7CiUsqpgAA+gqF References: <001601c6d204$5d2cd840$0b00a8c0@tedy> From: "Gregory S. Williamson" To: "Daniel CAUNE" , X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200609/41 X-Sequence-Number: 26252 Daniel, AFAIK there is no short-circuiting of evaluations in postgres and I = don't think you can depend on the order they appear in to determine the = order in which they are checked, although more knowledgable people may = have better info than I ... so the rewritten form is the way to go. Greg Williamson DBA GlobeXplorer LLC -----Original Message----- From: pgsql-sql-owner@postgresql.org on behalf of Daniel CAUNE Sent: Wed 9/6/2006 3:32 PM To: pgsql-sql@postgresql.org Cc:=09 Subject: [SQL] Evaluation of if conditions 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 =3D 'INSERT') OR (OLD.bar =3D ...) THEN statement END IF; Should be rewritten as (for example): IF (TG_OP =3D 'INSERT') THEN statement ELSIF (OLD.bar =3D ...) THEN statement END IF; Regards, -- Daniel ---------------------------(end of broadcast)--------------------------- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match ------------------------------------------------------- Click link below if it is SPAM gsw@globexplorer.com "https://mailscanner.globexplorer.com/dspam/dspam.cgi?signatureID=3D44ff5= 167171391789821027&user=3Dgsw@globexplorer.com&retrain=3Dspam&template=3D= history&history_page=3D1" !DSPAM:44ff5167171391789821027! -------------------------------------------------------