public inbox for [email protected]  
help / color / mirror / Atom feed
Re: Regression in Postgres 17?
2+ messages / 2 participants
[nested] [flat]

* Re: Regression in Postgres 17?
@ 2024-10-22 16:03 Adrian Klaver <[email protected]>
  2024-10-22 16:12 ` Re: Regression in Postgres 17? Tom Lane <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Adrian Klaver @ 2024-10-22 16:03 UTC (permalink / raw)
  To: Colin 't Hart <[email protected]>; [email protected]

On 10/22/24 08:54, Colin 't Hart wrote:
> Hi,
> 
> This works in Postgres 15:
> 
> pg15> create function json_test(out value text, out json jsonb)
> returns record
> language sql
> as
> $$
>    select null::text, null::jsonb;
> $$
> ;
> CREATE FUNCTION
> pg15> select * from json_test();
> ┌───────┬──────┐
> │ value │ json │
> ├───────┼──────┤
> │       │      │
> └───────┴──────┘
> (1 row)
> 
> 
> In Postgres 17 trying to create the function yields an error:
> 
> pg17> create function json_test(out value text, out json jsonb)
> returns record
> language sql
> as
> $$
>    select null::text, null::jsonb;
> $$
> ;
> ERROR:  syntax error at or near "jsonb"
> LINE 1: create function json_test(out value text, out json jsonb)
> 
> 
> Am I doing something wrong? Or is this a regression?

Yes you are doing something wrong, naming an argument with a type 
name(json) is not a good idea. Guessing you got caught by this:

https://www.postgresql.org/docs/16/sql-keywords-appendix.html

JSON 	non-reserved 	reserved 	  	

https://www.postgresql.org/docs/17/sql-keywords-appendix.html

JSON 	non-reserved (cannot be function or type) 	reserved 	  	



> Thanks,
> 
> Colin

-- 
Adrian Klaver
[email protected]







^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Regression in Postgres 17?
  2024-10-22 16:03 Re: Regression in Postgres 17? Adrian Klaver <[email protected]>
@ 2024-10-22 16:12 ` Tom Lane <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2024-10-22 16:12 UTC (permalink / raw)
  To: Adrian Klaver <[email protected]>; +Cc: Colin 't Hart <[email protected]>; [email protected]

Adrian Klaver <[email protected]> writes:
>> In Postgres 17 trying to create the function yields an error:
>> 
>> pg17> create function json_test(out value text, out json jsonb)
>> returns record
>> ...
>> ERROR:  syntax error at or near "jsonb"
>> LINE 1: create function json_test(out value text, out json jsonb)
>> 
>> Am I doing something wrong? Or is this a regression?

> Yes you are doing something wrong, naming an argument with a type 
> name(json) is not a good idea.

The actual problem is that the SQL standards committee invented
some bizarre syntax that we couldn't parse without making JSON
a partially-reserved word.  It still works as a type name, but
in this particular syntax where it's not initially clear which
names are type names, you lose.  Double-quote the argument name,
or name it something other than "json".

			regards, tom lane






^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2024-10-22 16:12 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-10-22 16:03 Re: Regression in Postgres 17? Adrian Klaver <[email protected]>
2024-10-22 16:12 ` Tom Lane <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox