Re: domain cast in parameterized vs. non-parameterized query

From: David Kamholz <lautgesetz(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: domain cast in parameterized vs. non-parameterized query
Date: 2017-12-21 16:44:04
Message-ID: CAKuxgJ75svgj9zWOfVGKFx10EBuCo8dvueeY2FKhZdv49Z_8rA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>
> > Why the rewrite doesn't reduce it? Or why parser does it?
>
> Because ALTER DOMAIN can change what would be a valid value.

In the view case that makes sense, but I don't see how ALTER DOMAIN is
relevant to my original example. You can't alter a domain between the time
the query is parsed and executed, can you?

I also don't understand why prepared statements are different. The future
values are not known to pass the domain check at the time the statement is
prepared, and at the time it's executed, I'd think the value is known
exactly to the extent that a literal (non-parameterized) value is known.
That is, I'd expect the ability to run CoerceToDomain and fold to a
constant to be identical in both cases -- either possible in both or
impossible in both. Why the difference?

Dave

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2017-12-21 16:53:07 Re: domain cast in parameterized vs. non-parameterized query
Previous Message Tom Lane 2017-12-21 16:13:57 Re: force parallel mode vs CTAS