Bug fix - Mailing list pgsql-patches

From Michael Davis
Subject Bug fix
Date
Msg-id 01C06769.C6BFA7D0.mdavis@sevainc.com
Whole thread Raw
Responses Re: Bug fix
List pgsql-patches
This is a code patch for the following TODO items list under the "Types"
heading:

* SELECT col FROM tab WHERE numeric_col = 10.1 fails
* Allow better handling of numeric constants, type conversion [typeconv]

Description of this change:

Currently when the parsers finds more than one candidate to resolve an
expression, it returns no solution.  This patch tells the parse to return
the first solution when more than one solution exists.  This may fix many
small issues with expressions in where clauses.

This patch is needed for Access 97 to proper work with numeric data types.

How to duplicate the problem:
       create table tst (id int, amount numeric(9,2));
       insert into tst values (1, 1.10);
       insert into tst values (2, 1.00);
       insert into tst values (2, 2.00);
       select * from tst where amount = 1; -- should work
       select * from tst where amount = 1.1; -- should fail (before this
patch)
       select * from tst where amount = 1.10; -- should fail (before this
patch)
       select * from tst where amount = 1.0; -- should fail (before this
patch)
       select * from tst where amount = 1.00; -- should fail (before this
patch)

Here is the result of a cvs diff:

RCS file:
/home/projects/pgsql/cvsroot/pgsql/src/backend/parser/parse_oper.c,v
retrieving revision 1.45
diff -r1.45 parse_oper.c
535c535,538
<       if (ncandidates == 1)
---
>    /* Michael J Davis, 12/15/2000, since there is more than one canidate,
>       lets return the first canidate rather than returning no canidate
>    */
>       if (ncandidates >= 1)

Thanks,

Michael Davis
Database Architect and Senior Software Engineer, Seva Inc.
Office:        303-460-7360        Fax: 303-460-7362
Mobile:    720-320-6971
Email:        mdavis@sevainc.com



pgsql-patches by date:

Previous
From: Tom Lane
Date:
Subject: Planner speedup diffs
Next
From: Tom Lane
Date:
Subject: Re: Bug fix