On Friday, April 15, 2016, Alex Bolenok <quassnoi(at)gmail(dot)com> wrote:
> The function should not even compile, as the INSERT query before it does
> not:
>
> test=# INSERT INTO test (value) SELECT * FROM (VALUES (1)) q (n) ON
> CONFLICT
> (value, (n)) DO NOTHING;
> ERROR: column "n" does not exist
>
> The parser should only allow the target table's column names and constants
> in the index expression, as it does when creating the index. A variable
> name is neither.
>
>
The parsed insert never see the letter "n". Once you comprehend that fact
your statement is true - because of the word "constant". That constant is
why it compiles.
David J.