Re: stringtype=unspecified is null check problem
От | David G. Johnston |
---|---|
Тема | Re: stringtype=unspecified is null check problem |
Дата | |
Msg-id | CAKFQuwZrn0F9RyM=WL9Z=pioGX5pwH1+mbBe-jGNnjy_J2E+Jw@mail.gmail.com обсуждение исходный текст |
Ответ на | AW: stringtype=unspecified is null check problem (Martin Handsteiner <martin.handsteiner@sibvisions.com>) |
Ответы |
Re: stringtype=unspecified is null check problem
(Tom Lane <tgl@sss.pgh.pa.us>)
|
Список | pgsql-jdbc |
There are 3 use cases, where I would need one setting, that always ensures, that null can be bound…
(setNull(1, <setting>) and stringtype=<setting>)
select 1 where 1=? -- setNull(1, Types.VARCHAR) and stringtype=unspecified
select 1 where 'A'=? -- setNull(1, Types.VARCHAR) and stringtype doesn’t matter
select 1 where ? is null -- setNull(1, Types.VARCHAR) and stringtype=VARCHAR
That there is no way to binding null in a simple way is a bug for me, because the following will work, and the database has also to decide, how to map null:
select 1 where 1=null -- now the database converts null to a number
select 1 where 'A'=null -- now the database converts null to a varchar
select 1 where null is null – now the database doesn’t care… so everthing works.
The question is, what is the difference between the two, and why should the caller parse the statement, if he uses jdbc. These examples are easy, but in real world, in 1=? the 1 could also be a sub select (select max(id) from …)
В списке pgsql-jdbc по дате отправления: