Re: best way to fetch next/prev record based on index

Поиск
Список
Период
Сортировка
От Greg Stark
Тема Re: best way to fetch next/prev record based on index
Дата
Msg-id 87oem0u182.fsf@stark.xeocode.com
обсуждение исходный текст
Ответ на Re: best way to fetch next/prev record based on index  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
Ответы Re: best way to fetch next/prev record based on index  (Greg Stark <gsstark@mit.edu>)
Re: best way to fetch next/prev record based on index  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-performance
Stephan Szabo <sszabo@megazone.bigpanda.com> writes:

> Given the comment on make_row_op,
>   /*
>    * XXX it's really wrong to generate a simple AND combination for < <=
>    * > >=.  We probably need to invent a new runtime node type to handle
>    * those correctly.  For the moment, though, keep on doing this ...
>    */
> I'd expect it'd be accepted.


Hm, this code is new. As of version 1.169 2004/04/18 it only accepted "=" and
"<>" operators:

    /* Combining operators other than =/<> is dubious... */
    if (row_length != 1 &&
        strcmp(opname, "=") != 0 &&
        strcmp(opname, "<>") != 0)
        ereport(ERROR,
                (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
          errmsg("row comparison cannot use operator %s",
                 opname)));


I think perhaps it's a bad idea to be introducing support for standard syntax
until we can support the correct semantics. It will only mislead people and
create backwards-compatibility headaches when we fix it to work properly.

Removing <,<=,>,>= would be trivial. Patch (untested):

--- parse_expr.c.~1.174.~    2004-07-28 01:01:12.000000000 -0400
+++ parse_expr.c    2004-07-28 01:52:29.000000000 -0400
@@ -1695,11 +1695,7 @@
      */
     oprname = strVal(llast(opname));

-    if ((strcmp(oprname, "=") == 0) ||
-        (strcmp(oprname, "<") == 0) ||
-        (strcmp(oprname, "<=") == 0) ||
-        (strcmp(oprname, ">") == 0) ||
-        (strcmp(oprname, ">=") == 0))
+    if (strcmp(oprname, "=") == 0)
     {
         boolop = AND_EXPR;
     }


Fixing it to write out complex boolean expressions wouldn't be too hard, but
I'm not clear it would be worth it, since I suspect the end result would be as
the comment indicates, to introduce a new runtime node.

--
greg

В списке pgsql-performance по дате отправления:

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: best way to fetch next/prev record based on index
Следующее
От: Greg Stark
Дата:
Сообщение: Re: best way to fetch next/prev record based on index