Re: Named Operators

Поиск
Список
Период
Сортировка
От Ted Yu
Тема Re: Named Operators
Дата
Msg-id CALte62znmyieKuhE94AgPWW=QrEWVo8qSDzFzo+7ZD-ogsui3w@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Named Operators  (Gurjeet Singh <gurjeet@singh.im>)
Ответы Re: Named Operators  (Gurjeet Singh <gurjeet@singh.im>)
Список pgsql-hackers


On Fri, Jan 20, 2023 at 9:17 AM Gurjeet Singh <gurjeet@singh.im> wrote:
On Sat, Jan 14, 2023 at 6:14 AM Gurjeet Singh <gurjeet@singh.im> wrote:
>
> I agree that an identifier _surrounded_ by the same token (e.g. #foo#)
> or the pairing token (e.g. {foo}) looks better aesthetically, so I am
> okay with any of the following variations of the scheme, as well:
>
> \#foo\#  (tested; works)
> \#foo#   (not tested; reduces ident length by 1)
>
> We can choose a different character, instead of #. Perhaps \{foo} !

Please find attached the patch that uses \{foo} styled Named
Operators. This is in line with Tom's reluctant hint at possibly using
curly braces as delimiter characters. Since the curly braces are used
by the SQL Specification for row pattern recognition, this patch
proposes escaping the first of the curly braces.

We can get rid of the leading backslash, if (a) we're confident that
SQL committee will not use curly braces anywhere else, and (b) if
we're confident that if/when Postgres supports Row Pattern Recognition
feature, we'll be able to treat curly braces inside the PATTERN clause
specially. Since both of those conditions are unlikely, I think we
must settle for the escaped-first-curly-brace style for the naming our
operators.

Keeping with the previous posts, here's a sample SQL script showing
what the proposed syntax will look like in action. Personally, I
prefer the \#foo style, since the \# prefix stands out among the text,
better than \{..} does, and because # character is a better signal of
an operator than {.

create operator \{add_point}
    (function = box_add, leftarg = box, rightarg = point);
create table test(a box);
insert into test values('((0,0),(1,1))'), ('((0,0),(2,1))');
select a as original, a \{add_point} '(1,1)' as modified from test;
drop operator \{add_point}(box, point);

Best regards,
Gurjeet
http://Gurje.et

Hi,
Since `validIdentifier` doesn't modify the contents of `name` string, it seems that there is no need to create `tmp` string in `validNamedOperator`.
You can pass the start and end offsets into the string (name) as second and third parameters to `validIdentifier`.

Cheers

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

Предыдущее
От: Gurjeet Singh
Дата:
Сообщение: Re: Named Operators
Следующее
От: Ankit Kumar Pandey
Дата:
Сообщение: Re: [PATCH] Teach planner to further optimize sort in distinct