BigInt woes

From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: BigInt woes
Date: 2003-10-07 16:57:20
Message-ID: 3F82F070.3050902@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

I believe that the Int8/BigInt items are known issues but I have a
knew programmer that ran into it
over the weekend (he didn't call me when he encountered the problem,
when he should of) and we have a
customer that burned some significant time on it as well. Will this be
fixed in 7.4?

Here is a test case a customer sent me:

Suppose you have a table:

create table bid (
bid_id bigint not null,
bid_time timestamp, constraint bid_pk primary key (bid_id));

Populate it with a million rows or so.

This query:

explain select bid_id, bid_time from bid where bid_id = 10000

Will always sequential scan.

This query:

explain select bid_id, bid_time from bid where bid_id = '10000'

Will use the index.

Where this really gets to be a pain in the butt is with a UDF in
plpgsql... this UDF will only sequential scan:

create function bid_check(bigint) returns bool as '
declare
in_bid_id alias for $1;
begin

if (select count(*) from bid where bid_id = in_bid_id) = 1 then
return true;
else
return false;
end if;
end;
' language 'plpgsql';

The work around is to build the SQL statement in a string, embedding the
value of the variable with the quote_literal function and execute it.

--
Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC - S/JDBC
Postgresql support, programming, shared hosting and dedicated hosting.
+1-503-222-2783 - jd(at)commandprompt(dot)com - http://www.commandprompt.com
PostgreSQL.Org - Editor-N-Chief - http://www.postgresql.org

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2003-10-07 16:58:24 Re: Disabling function validation
Previous Message Peter Eisentraut 2003-10-07 16:39:43 Re: Disabling function validation