Re: Evaluation of if conditions
От | Gregory S. Williamson |
---|---|
Тема | Re: Evaluation of if conditions |
Дата | |
Msg-id | 71E37EF6B7DCC1499CEA0316A256832802B3E511@loki.wc.globexplorer.net обсуждение исходный текст |
Ответ на | Evaluation of if conditions (Daniel CAUNE <d.caune@free.fr>) |
Список | pgsql-sql |
Daniel, AFAIK there is no short-circuiting of evaluations in postgres and I don't think you can depend on the order they appear into determine the order in which they are checked, although more knowledgable people may have better info than I ... sothe 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: 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 = '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 ---------------------------(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 datatypesdo not match ------------------------------------------------------- Click link below if it is SPAM gsw@globexplorer.com "https://mailscanner.globexplorer.com/dspam/dspam.cgi?signatureID=44ff5167171391789821027&user=gsw@globexplorer.com&retrain=spam&template=history&history_page=1" !DSPAM:44ff5167171391789821027! -------------------------------------------------------
В списке pgsql-sql по дате отправления: