skip to Main Content

I’ve noticed that in older version of PG (example 13)
when I had query like:

select 1 where 1=1and 2=2

all was OK

but i try this in PG 15 I get error: trailing junk after numeric literal at or near "1a"

Have something changed or maybe there is a new option in configuration to make it more strict ?

2

Answers


  1. This was changed in v 15.0.

    From the release notes:

    Prevent numeric literals from having non-numeric trailing characters (Peter Eisentraut)

    Previously, query text like 123abc would be interpreted as 123 followed by a separate token abc.

    and similar

    Adjust JSON numeric literal processing to match the SQL/JSON-standard (Peter Eisentraut)

    This accepts numeric formats like .1 and 1., and disallows trailing junk after numeric literals, like 1.type().

    Login or Signup to reply.
  2. For those looking for a fix in their query:

    Make sure you signal that your query is a string.
    E.g:

    SELECT * FROM db WHERE col IN (12A2, 1E23) 
    

    does not work but

    SELECT * FROM db WHERE col IN ('12A2', '1E23') 
    

    does the job.

    The problem above is solved by placing a space like so:

    SELECT 1 WHERE 1=1 AND 2=2
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search