Re: Modifying SQL parser with extensions? - Mailing list pgsql-general

From Matthias Luedtke
Subject Re: Modifying SQL parser with extensions?
Date
Msg-id 4544FFA0.1010306@gmx.de
Whole thread Raw
In response to Re: Modifying SQL parser with extensions?  (Alvaro Herrera <alvherre@commandprompt.com>)
Responses Re: Modifying SQL parser with extensions?
Re: Modifying SQL parser with extensions?
List pgsql-general
Alvaro Herrera wrote:
>> In fact, parsing this SQL dialect would just be the first step, as the
>> annotations within the query induce an ordering of the result set.
>
> Huh, what is this supposed to be able to do that you can't do with the
> already existing ORDER BY clause?

Basically, conditional statements are annotated with integers that
represent weights, like

(...)WHERE (foo = 'a')[42] OR (bar = 'b')[20]

In the result set those entries that fulfill both conditions yield score
62, i.e. 42+20, and are ranked top, whereas entries that fulfill only
one of the conditions yield scores 42 and 20 respectively and are
therefore ranked lower.

Honestly, I'm only the poor student who has to implement what the
smarter ones have thought out. ;)

And, yes, it is possible to accomplish the desired sorting with the
ORDER BY clause, but as conditions become more complex, the self cooked
dialect is considered to be more readable and intuitive to the end user.

Regards,
Matthias

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Modifying SQL parser with extensions?
Next
From: Matthias Luedtke
Date:
Subject: Re: Modifying SQL parser with extensions?