Обсуждение: Explicit typing of numeric types

Поиск
Список
Период
Сортировка

Explicit typing of numeric types

От
"Alaric B. Snell"
Дата:
Guys,

After a painful experience with int8 indices not being used for:

SELECT * FROM foo WHERE id = 1;

...since 1 is an int4 not an int8, I'm wondering if there would be
anything wrong with making the JDBC driver always put out explicit type
declarations?

Eg, setLong emitting 1 :: int8. setString emitting 'foo' :: text. Etc.
Whaddyathink?

ABS

--
Alaric B. Snell, Developer
abs@frontwire.com


Re: Explicit typing of numeric types

От
Tom Lane
Дата:
"Alaric B. Snell" <abs@frontwire.com> writes:
> After a painful experience with int8 indices not being used for:
> SELECT * FROM foo WHERE id = 1;
> ...since 1 is an int4 not an int8, I'm wondering if there would be
> anything wrong with making the JDBC driver always put out explicit type
> declarations?

(a) How would JDBC know what to do better than the backend does?
What happens when (not if) JDBC puts out an inappropriate coercion?

(b) This is an acknowledged shortcoming that will be fixed someday.
I don't think it's appropriate to try to put temporary band-aids for
backend shortcomings in frontend drivers.  Surely the folks working on
JDBC have their own set of shortcomings to work on...

            regards, tom lane

Re: Explicit typing of numeric types

От
Tom Lane
Дата:
"Alaric B. Snell" <abs@frontwire.com> writes:
> Either way, can it do any *harm*? :-)

Certainly.  For example, suppose some app is using a setLong parameter to
output a constant that's actually being compared to an integer column.
Right now, this works (for "work" = "can be indexed").  With your
proposed hack, it wouldn't.

I realize it's pretty annoying to have to work around this at the
application level.  However, the app at least knows what it's doing,
ie, what data it's got and what the database column it's interested in
is.  Eventually, the backend will solve the problem correctly --- it
also has all the relevant information.  JDBC is the one place in the
chain that *cannot* solve the problem because it doesn't know enough.
Thus, a solution in JDBC cannot be a real solution, only a
broken-by-design kluge.

            regards, tom lane

Re: Explicit typing of numeric types

От
"Alaric B. Snell"
Дата:
On Tue, 15 Jan 2002, Barry Lind wrote:

> Alaric,
>
> This has been discussed before on this mail list and rejected.  Please
> see the archives for the rationale.

Hum... I tried to search the archives but got 'sorry, under construction',
so please don't think I'm always a lame non-archive-reading person :-)

>
> thanks,
> --Barry
>

ABS

--
Alaric B. Snell, Developer
abs@frontwire.com


Re: Explicit typing of numeric types

От
Barry Lind
Дата:
Alaric,

This has been discussed before on this mail list and rejected.  Please
see the archives for the rationale.

thanks,
--Barry


Alaric B. Snell wrote:

> Guys,
>
> After a painful experience with int8 indices not being used for:
>
> SELECT * FROM foo WHERE id = 1;
>
> ...since 1 is an int4 not an int8, I'm wondering if there would be
> anything wrong with making the JDBC driver always put out explicit type
> declarations?
>
> Eg, setLong emitting 1 :: int8. setString emitting 'foo' :: text. Etc.
> Whaddyathink?
>
> ABS
>
>



Re: Explicit typing of numeric types

От
Tom Lane
Дата:
"Alaric B. Snell" <abs@frontwire.com> writes:
> Hum... I tried to search the archives but got 'sorry, under construction',
> so please don't think I'm always a lame non-archive-reading person :-)

The fts.postgresql.org search engine seems to be down for repairs, but
the somewhat-less-slick archives at http://archives.postgresql.org/
still work.

            regards, tom lane

Re: Explicit typing of numeric types

От
"Alaric B. Snell"
Дата:
On Tue, 15 Jan 2002, Tom Lane wrote:

> "Alaric B. Snell" <abs@frontwire.com> writes:
> > Hum... I tried to search the archives but got 'sorry, under construction',
> > so please don't think I'm always a lame non-archive-reading person :-)
>
> The fts.postgresql.org search engine seems to be down for repairs, but
> the somewhat-less-slick archives at http://archives.postgresql.org/
> still work.

Alas, that stalls after outputting the search results header but before
showing any results when I try it with 'explicit type' as my search query,
searching the JDBC list archives!

I suspect I'm just not destined to read these archives... :-(

ABS

--
Alaric B. Snell, Developer
abs@frontwire.com