pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tim Pizey <tim@paneris.co.uk>
Cc: pgsql-sql@postgresql.org
Subject: Re: Invalid (null) int8, can't convert to float8
Date: Mon, 19 Mar 2001 13:44:38 -0500
Message-ID: <20699.985027478@sss.pgh.pa.us> (raw)
In-Reply-To: <3AB6417C.A4932BA4@paneris.co.uk>
References: <3AB6417C.A4932BA4@paneris.co.uk>

Tim Pizey <tim@paneris.co.uk> writes:
> If there is a a record with a Null textid in the table then psql reports
> the error:
> Invalid (null) int8, can't convert to float8
> to a query of the form 
> select id from chapter where textid = 9057599501;

> It does seem as though the textid in the query needs to be large to
> produce the error.

This is actually being interpreted as

select id from chapter where textid = 9057599501::float8;

and then the parser decides it needs to convert textid to float8 and
perform a float8 '=' (which among other things means this query won't
use the index).  This happens because the parser is going to interpret
that undecorated numeric constant as either int4 or float8, and it's
too big for int4, so float8 gets picked.

We have had some discussions about teaching the parser to be smarter
about choosing the type of numeric constants depending on context,
but for now you need to force the issue:

select id from chapter where textid = 9057599501::int8;

If you want the index to be used then you'd better do this all the
time, not only for values that are too big to be int4.

BTW, the inability to convert an int8 NULL to float8 is a bug;
it's fixed in 7.1.

			regards, tom lane



view thread (3+ messages)  latest in thread

Message-ID: <20699.985027478@sss.pgh.pa.us>
Permalink:  ../20699.985027478@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/20699.985027478@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, tim@paneris.co.uk
  Subject: Re: Invalid (null) int8, can't convert to float8
  In-Reply-To: <20699.985027478@sss.pgh.pa.us>
  References: <3AB6417C.A4932BA4@paneris.co.uk> <20699.985027478@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox