From: | Alex Bolenok <quassnoi(at)gmail(dot)com> |
---|---|
To: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
Cc: | "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Re: BUG #14089: ON CONFLICT allows function variables in index expressions |
Date: | 2016-04-18 12:36:49 |
Message-ID: | CAMX8OqLNK8qXoZ9a8ucxcCo3eRTN-DEZ2uFn+2fOednhji=MEg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
This would have made sense if fn_test(1) would not fail (the last statement
in my script), but it does fail. Somehow the variable is constant enough
for the statement to parse, but is not constant enough for it to run.
It just does not make any sense.
fn_test is an SQL function, not PL/pgSQL, it should see the variable in
place of a constant on the parsing stage and not compile at all.
I realize there is an explanation to that (it's the way it's programmed,
after all), and that might be not a bug worthy enough to fix (however,
there are people actually affected by it, see here:
http://stackoverflow.com/questions/36656643/is-variable-conflict-use-variable-not-working-with-on-conflict-clause-of-upsert
),
but it's clearly a bug in my opinion.
сб, 16 апр. 2016 г. в 5:22, David G. Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>:
> 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.
>
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2016-04-18 14:54:16 | Re: BUG #14089: ON CONFLICT allows function variables in index expressions |
Previous Message | rajeshwar.mukund | 2016-04-18 11:40:30 | BUG #14097: unalbe to locate runuser in /usr/pgsql-9.4/bin/postgresql94-setup |