pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Daniel CAUNE <d.caune@free.fr>
To: pgsql-sql@postgresql.org
Subject: Evaluation of if conditions
Date: Wed, 06 Sep 2006 18:32:40 -0400
Message-ID: <001601c6d204$5d2cd840$0b00a8c0@tedy> (raw)

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




view thread (5+ messages)  latest in thread

Message-ID: <001601c6d204$5d2cd840$0b00a8c0@tedy>
Permalink:  ../001601c6d204$5d2cd840$0b00a8c0@tedy/
Also on:    postgresql.org/message-id/001601c6d204$5d2cd840$0b00a8c0@tedy

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: d.caune@free.fr
  Subject: Re: Evaluation of if conditions
  In-Reply-To: <001601c6d204$5d2cd840$0b00a8c0@tedy>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox