Function call problems with BETWEEN

From: "Thomas G(dot) Lockhart" <lockhart(at)alumni(dot)caltech(dot)edu>
To: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>, Postgres Hackers List <hackers(at)postgresql(dot)org>
Subject: Function call problems with BETWEEN
Date: 1998-03-11 04:20:08
Message-ID: 350610F8.394ACE2B@alumni.caltech.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I think I've tracked down a problem I see using the BETWEEN operator:

postgres=> select 1 where float8(1) between 0.0 and 2.0;
ERROR: transformExpr: does not know how to transform node 105
postgres=> select 1 where float8(1) >= 0.0 and float8(1) <= 2.0;
?column?
--------
1
(1 row)

I'm pretty sure that the problem stems from the fact that in gram.y the
BETWEEN clause is expanded into the AND clauses as in the second
example, _but_ the parse tree for the function call is reused! So,
transformExpr() is run twice on the same part of the parse tree, and
does not know how to cope.

Probably the strongest solution would be to copy the entire parse tree.
Is there already a function to do that? It seems like it would be a lot
of work to start this from scratch.

Another possible solution would be to have transformExpr() accept a
previously transformed parse tree without damaging it. A simple minded
fix having transformExpr() ignore the T_Const (the "105" node in the
example) and T_Var nodes did not work.

Yet another solution would be to have transformExpr() replicate parse
trees instead of having gram.y do it.

Any thoughts on this?

- Tom

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas G. Lockhart 1998-03-11 04:44:38 Re: [HACKERS] Function call problems with BETWEEN
Previous Message Thomas G. Lockhart 1998-03-11 03:45:51 Re: [QUESTIONS] Basic table repair info.