Thread: SQL statements error in pgsql 16 but not in pgsql 12

SQL statements error in pgsql 16 but not in pgsql 12

From
Frank Komsic
Date:

Hi,

 

I was trying to upgrade our database from version 12.18 to the latest 16.3

 

After upgrading, the application has reported errors or “junk info” in the sql command line.

 

Example SQL code:

Message: ERROR: 42601: trailing junk after numeric literal at or near "19749O"
SQL: SELECT bb,mass,classifier,lot
FROM lab.pt_f003_view
WHERE (lot = 19749OR lot= 19750)
ORDER BY lot,bb

 

 

The above sql command works in version 12 but does not work in version 16 due to missing space in “WHERE (lot = 19749OR lot= 19750)”

 

Why did this work before and now it does not work?

 

Thanks

 

Frank Komsic

Re: SQL statements error in pgsql 16 but not in pgsql 12

From
"David G. Johnston"
Date:
On Mon, Jul 15, 2024 at 3:57 PM Frank Komsic <komsicf@shoeicanada.com> wrote:

The above sql command works in version 12 but does not work in version 16 due to missing space in “WHERE (lot = 19749OR lot= 19750)”

 

Why did this work before and now it does not work?

 


It seems to be a side-effect of supporting non-decimal literals.

Git: 6fcda9aba83449082124825b6d375c0a61e21c42

This comment in particular refers to a v15 change that is probably related if you want to dive deeper.


Suffice to say, we became more strict here since v12 and you will need to modify the query accordingly.

David J.

Re: SQL statements error in pgsql 16 but not in pgsql 12

From
Bharani SV-forum
Date:
cross check
WHERE (lot = 19749 OR lot= 19750)

where the OR is tagged to numeric 19749.

On Monday, July 15, 2024 at 06:58:06 PM EDT, Frank Komsic <komsicf@shoeicanada.com> wrote:


Hi,

 

I was trying to upgrade our database from version 12.18 to the latest 16.3

 

After upgrading, the application has reported errors or “junk info” in the sql command line.

 

Example SQL code:

Message: ERROR: 42601: trailing junk after numeric literal at or near "19749O"
SQL: SELECT bb,mass,classifier,lot
FROM lab.pt_f003_view
WHERE (lot = 19749OR lot= 19750)
ORDER BY lot,bb

 

 

The above sql command works in version 12 but does not work in version 16 due to missing space in “WHERE (lot = 19749OR lot= 19750)”

 

Why did this work before and now it does not work?

 

Thanks

 

Frank Komsic

Re: SQL statements error in pgsql 16 but not in pgsql 12

From
"David G. Johnston"
Date:
On Tue, Jul 16, 2024 at 7:58 AM Bharani SV-forum <esteembsv-forum@yahoo.com> wrote:
cross check
WHERE (lot = 19749 OR lot= 19750)

where the OR is tagged to numeric 19749.


What does "tagged" mean here?

David J.

Re: SQL statements error in pgsql 16 but not in pgsql 12

From
Frank Komsic
Date:

Thank you for your reply.

 

I gather I will have to lookover the entire code and set the SQL statements correctly.

 

Thanks


Frank

 

From: David G. Johnston <david.g.johnston@gmail.com>
Date: Monday, July 15, 2024 at 7:24
PM
To: Frank Komsic <komsicf@shoeicanada.com>
Cc: pgsql-sql@lists.postgresql.org <pgsql-sql@lists.postgresql.org>
Subject: Re: SQL statements error in pgsql 16 but not in pgsql 12

On Mon, Jul 15, 2024 at 3:57 PM Frank Komsic <komsicf@shoeicanada.com> wrote:

The above sql command works in version 12 but does not work in version 16 due to missing space in “WHERE (lot = 19749OR lot= 19750)”

 

Why did this work before and now it does not work?

 

 

It seems to be a side-effect of supporting non-decimal literals.

 

Git: 6fcda9aba83449082124825b6d375c0a61e21c42

 

This comment in particular refers to a v15 change that is probably related if you want to dive deeper.

 

 

Suffice to say, we became more strict here since v12 and you will need to modify the query accordingly.

 

David J.

Re: SQL statements error in pgsql 16 but not in pgsql 12

From
Bharani SV-forum
Date:
tagged mean " add to something "

hope ur picture posted with the sql query, i can see as
WHERE (lot = 19749OR lot= 19750)
instead of
WHERE (lot = 19749 OR lot= 19750)

Hope u have understood
On Tuesday, July 16, 2024 at 11:00:54 AM EDT, David G. Johnston <david.g.johnston@gmail.com> wrote:


On Tue, Jul 16, 2024 at 7:58 AM Bharani SV-forum <esteembsv-forum@yahoo.com> wrote:
cross check
WHERE (lot = 19749 OR lot= 19750)

where the OR is tagged to numeric 19749.


What does "tagged" mean here?

David J.

Re: SQL statements error in pgsql 16 but not in pgsql 12

From
Tom Lane
Date:
Bharani SV-forum <esteembsv-forum@yahoo.com> writes:
>  tagged mean " add to something "
> hope ur picture posted with the sql query, i can see asWHERE (lot = 19749OR lot= 19750)instead of
> WHERE (lot = 19749 OR lot= 19750)

That's not a great choice of word.  In any case, the point here
is that the SQL standard requires some whitespace between a number
and a following word, and starting from PG 15 we're enforcing that
to reduce ambiguity.

            regards, tom lane