$1 IS NULL with unknown type

From: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: $1 IS NULL with unknown type
Date: 2022-11-21 19:47:54
Message-ID: CA+mi_8ZYoZGXsEBkENULryqbXZ7Cd6kxQiPGtn8GVXxhU_UOCA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

The operator `IS NULL` doesn't work if the argument has unknown type.
In psycopg 3:

>>> conn.execute("select %s is null", ['foo']).fetchone()
IndeterminateDatatype: could not determine data type of parameter $1

This can get in the way of using the unknown type for strings (but
specifying the text oid for strings is worse, because there is no
implicit cast from string to most types).

It doesn't seem necessary to specify a type for an argument if it only
has to be compared with null: nullness is independent from the type
and is even specified, in the query parameters, in a separate array
from the parameter values.

Maybe this behaviour can be relaxed?

Cheers

-- Daniele

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2022-11-21 19:56:28 Re: pgsql: Prevent instability in contrib/pageinspect's regression test.
Previous Message Tom Lane 2022-11-21 19:21:35 Re: Add 64-bit XIDs into PostgreSQL 15