PostgreSQL-13.3 parser.y with positional references by named references

From: Domingo Alvarez Duarte <mingodad(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: PostgreSQL-13.3 parser.y with positional references by named references
Date: 2021-07-04 12:33:06
Message-ID: e2ffc52f-96f2-0029-a582-ffc0cc65f7ee@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Here https://gist.github.com/mingodad/49291e0e9505522c66fcd3fcea4a939d I
posted the postgresql-13.3/src/backend/parser/gram.y with positional
references by named references that is supported by bison for some time now.

It was done with a custom script and some comments are missing, if there
is any interest in accept it I could try work on it to include the
missing comments and a different code layout.

It compiles on ubuntu 18.04.

I did a similar contribution here
https://github.com/facebookincubator/CG-SQL/pull/6

And here is snippet of how it looks like:

====

opt_all_clause:
    ALL    { $opt_all_clause = NIL;}
    | /*EMPTY*/    { $opt_all_clause = NIL; }
        ;

opt_sort_clause:
    sort_clause    { $opt_sort_clause = $sort_clause;}
    | /*EMPTY*/    { $opt_sort_clause = NIL; }
        ;

sort_clause:
    ORDER BY sortby_list    { $sort_clause = $sortby_list; }
        ;

sortby_list:
    sortby    { $sortby_list = list_make1($sortby); }
    | sortby_list[rhs_1] ',' sortby    { $$ /* sortby_list */ =
lappend($rhs_1, $sortby); }
        ;

sortby:
    a_expr USING qual_all_Op opt_nulls_order    {
                    $sortby = makeNode(SortBy);
                    $sortby->node = $a_expr;
                    $sortby->sortby_dir = SORTBY_USING;
                    $sortby->sortby_nulls = $opt_nulls_order;
                    $sortby->useOp = $qual_all_Op;
                    $sortby->location = @qual_all_Op;
                }
    | a_expr opt_asc_desc opt_nulls_order    {
                    $sortby = makeNode(SortBy);
                    $sortby->node = $a_expr;
                    $sortby->sortby_dir = $opt_asc_desc;
                    $sortby->sortby_nulls = $opt_nulls_order;
                    $sortby->useOp = NIL;
                    $sortby->location = -1;        /* no operator */
                }
        ;

====

Cheers !

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2021-07-04 13:01:04 Re: ATTACH PARTITION locking documentation for DEFAULT partitions
Previous Message Michael Paquier 2021-07-04 12:00:37 Re: Mention --enable-tap-tests in the TAP section page