Bug fix

Started by Michael Davisalmost 26 years ago2 messagespatches
Jump to latest
#1Michael Davis
mdavis@sevainc.com

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

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Michael Davis (#1)
Re: Bug fix

Michael Davis <mdavis@sevainc.com> writes:

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.

Sorry, this is not an acceptable answer --- indeterminate results are
not an improvement over throwing an error.

regards, tom lane