Re: driver fails to handle strings in query statements properly

Поиск
Список
Период
Сортировка
От Dave Cramer
Тема Re: driver fails to handle strings in query statements properly
Дата
Msg-id 008101c14b8c$13f962a0$8201a8c0@inspiron
обсуждение исходный текст
Ответ на Re: driver fails to handle strings in query statements properly  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: driver fails to handle strings in query statements properly
Serialize
Список pgsql-jdbc
I tried it on a table which id was an int


Using "select 'id' as xxx from ..." Returns xxx as an unknown type
Using "select id as xxx from... " returns xxx as an int

I have no idea how the backend handles this, but if it can figure it out
in one instance why can't it figure it out when I put single quotes
around it?

Dave

-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org
[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Tom Lane
Sent: October 2, 2001 5:19 PM
To: Barry Lind
Cc: Dave@micro-automation.net; pgsql-jdbc@postgresql.org
Subject: Re: [JDBC] driver fails to handle strings in query statements
properly


Barry Lind <barry@xythos.com> writes:
> My thoughts as well.  If we encounter an 'unknown' type, just return
> it
> as a String.  Do you have time to fix this?

>> I suppose we could return it as a string when we are in doubt? Is
>> this reasonable since there are many other types it should be
>> returned as?

The backend will presently default to treating 'unknown' as type 'text'
if it hasn't got any better idea what to do, so I think it's reasonable
for JDBC to do likewise.

I believe the only case in which you could see 'unknown' reported as a
query result type is if a string literal is SELECTed without any
processing being done on it, viz

    SELECT 'foo'

As soon as the literal is passed to a function or operator, sorted,
grouped, etc, the system will insist on resolving it to a non-unknown
type.  If the usage context doesn't provide any other hint, 'text' will
be the chosen type.

            regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster



В списке pgsql-jdbc по дате отправления:

Предыдущее
От: "Dave Cramer"
Дата:
Сообщение: Re: driver fails to handle strings in query statements properly
Следующее
От: Dave Harkness
Дата:
Сообщение: Re: LOCK TABLE oddness in PLpgSQL function called via JDBC