目前,可以知道,PostgreSQL的词法分析和句法分析,用的也是flex 和bison。

gram.y 就是用来生成 gram.c 的。

为了验证一下,先分析 distinct 一段:

/* We use (NIL) as a placeholder to indicate that all target expressions
* should be placed in the DISTINCT list during parsetree analysis.
*/
opt_distinct:
DISTINCT { $$ = list_make1(NIL); }
| DISTINCT ON '(' expr_list ')' { $$ = $4; }
| ALL { $$ = NIL; }
| /*EMPTY*/ { $$ = NIL; }
;

 

改为:

opt_distinct:
DISTINCT { $$ = list_make1(NIL);

                   fprintf(stderr,"jian distinct"); 

                }
| DISTINCT ON '(' expr_list ')' { $$ = $4; }
| ALL { $$ = NIL; }
| /*EMPTY*/ { $$ = NIL; }
;

 

通过psql 执行 :select distinct tid from a5;

果然看见 后台出现信息:jian distinct。

相关文章:

  • 2022-12-23
  • 2021-09-24
  • 2021-07-30
  • 2021-05-04
  • 2022-12-23
  • 2021-12-03
  • 2022-12-23
猜你喜欢
  • 2021-09-22
  • 2021-10-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-08
相关资源
相似解决方案