Thread: How does pg parse 'select '(1,2)''

How does pg parse 'select '(1,2)''

From
jacktby jacktby
Date:
I’m trying to add new grammar for my application. So I’m do research on gram.y.
I think it will make the '(1,2)' as " '(' a_expr ')' "; but I can’t find out something like
" a_expr ',' a_expr “, can you give me the details?


Re: How does pg parse 'select '(1,2)''

From
Kyotaro Horiguchi
Date:
At Sat, 5 Aug 2023 21:46:33 +0800, jacktby jacktby <jacktby@gmail.com> wrote in 
> I’m trying to add new grammar for my application. So I’m do research on gram.y.
> I think it will make the '(1,2)' as " '(' a_expr ')' "; but I can’t find out something like
> " a_expr ',' a_expr “, can you give me the details?

If you are trying literally "SELECT (1, 2)", I think that the parser
comes to the terminating a_expr through the following path.

<omitted>
simple_select: SELECT .. opt_target_list ...
opt_target_list: target_list
target_list: target_el | target list '.' target_el
target_el: a_expr
a_expr: c_expr
c_expr: implicit_row
implicit_row: '(' expr_list ',' a_expr ')'
expr_list: a_expr | expr_list ',' a_expr

regards.

-- 
Kyotaro Horiguchi
NTT Open Source Software Center