Re: $1 IS NULL with iso-8859-1 type - Mailing list pgsql-hackers

From Tom Lane
Subject Re: $1 IS NULL with iso-8859-1 type
Date
Msg-id 3263809.1669060965@sss.pgh.pa.us
Whole thread Raw
In response to $1 IS NULL with iso-8859-1 type  (Daniele Varrazzo <daniele.varrazzo@gmail.com>)
List pgsql-hackers
Daniele Varrazzo <daniele.varrazzo@gmail.com> writes:
> The operator `IS NULL` doesn't work if the argument has unknown type.
> conn.execute("select %s is null", ['foo']).fetchone()
>     IndeterminateDatatype: could not determine data type of parameter $1

Yeah.

> 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.

True, the IS NULL operator itself doesn't care about the data type,
but that doesn't mean that noplace else in the system does.

As an example, if we silently resolved the type as "text" as you seem
to wish, and then the client sends a non-null integer in binary format,
we'll likely end up throwing a bad-encoding error.

Maybe that's not a big problem, I dunno.  But we can't just not
resolve the type, we have to pick something.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: pgsql: Prevent instability in contrib/pageinspect's regression test.
Next
From: Andres Freund
Date:
Subject: Re: Cleanup: Duplicated, misplaced comment in HeapScanDescData