From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Hannu Krosing <hannu(at)tm(dot)ee> |
Cc: | Joel Burton <joel(at)joelburton(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Louis-David Mitterrand <vindex(at)apartia(dot)org>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: wierd AND condition evaluation for plpgsql |
Date: | 2002-05-28 22:56:09 |
Message-ID: | 17638.1022626569@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hannu Krosing <hannu(at)tm(dot)ee> writes:
> Are these intricacies of SQL standardised anywhere ?
SQL92 section 3.3.4.4, "rule evaluation order" appears to sanction PG's
behavior. In particular note the part that says syntax rules and access
rules are "effectively applied at the same time" (ie, this checking is
done before execution starts --- that legitimizes the error originally
complained of) and the parts that say that inessential portions of
expressions need not be evaluated and that implementations are not
required to perform evaluations strictly left-to-right.
3.3.4.4 Rule evaluation order
A conforming implementation is not required to perform the exact
sequence of actions defined in the General Rules, but shall achieve
the same effect on SQL-data and schemas as that sequence. The term
effectively is used to emphasize actions whose effect might be
achieved in other ways by an implementation.
The Syntax Rules and Access Rules for contained syntactic elements
are effectively applied at the same time as the Syntax Rules and
Access Rules for the containing syntactic elements. The General
Rules for contained syntactic elements are effectively applied be-
fore the General Rules for the containing syntactic elements. Where
the precedence of operators is determined by the Formats of this
International Standard or by parentheses, those operators are ef-
fectively applied in the order specified by that precedence. Where
the precedence is not determined by the Formats or by parentheses,
effective evaluation of expressions is generally performed from
left to right. However, it is implementation-dependent whether ex-
pressions are actually evaluated left to right, particularly when
operands or operators might cause conditions to be raised or if
the results of the expressions can be determined without completely
evaluating all parts of the expression. In general, if some syn-
tactic element contains more than one other syntactic element, then
the General Rules for contained elements that appear earlier in the
production for the containing syntactic element are applied before
the General Rules for contained elements that appear later.
For example, in the production:
<A> ::= <B> <C>
the Syntax Rules and Access Rules for <A>, <B>, and <C> are ef-
fectively applied simultaneously. The General Rules for <B> are
applied before the General Rules for <C>, and the General Rules for
<A> are applied after the General Rules for both <B> and <C>.
If the result of an expression or search condition can be deter-
mined without completely evaluating all parts of the expression or
search condition, then the parts of the expression or search condi-
tion whose evaluation is not necessary are called the inessential
parts. If the Access Rules pertaining to inessential parts are not
satisfied, then the syntax error or access rule violation exception
condition is raised regardless of whether or not the inessential
parts are actually evaluated. If evaluation of the inessential
parts would cause an exception condition to be raised, then it is
implementation-dependent whether or not that exception condition is
raised.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2002-05-29 00:35:52 | Re: [HACKERS] Re : Solaris Performance - 64 bit puzzle |
Previous Message | Tom Lane | 2002-05-28 22:32:26 | Re: Null values in indexes |