Details the addition of keywords in the PostgreSQL syntax

  • 2020-05-06 11:56:58
  • OfStack

explains the addition of

keywords to PostgreSQL syntax

When PostgreSQL's background process Postgres receives the query statement, it first passes it to the query analysis module for lexical, syntactic, and semantic analysis.

Record the addition of keywords in the parser syntax parsing module.

Introduction to several core files

源文件 说明
gram.y 定义语法结构,bison编译后生成gram.y和gram.h
scan.l 定义词法结构,flex编译后生成scan.c
kwlist.h 关键字列表,需要按序排列 linux下会调用其进行关键字检查(顺序、合法性等)

The addition of

keywords in   syntax gram.y, %token < keyword > Add the keyword PARTITIONSgram.y file reserved_keyword paragraph add the keyword PARTITIONSkwlist.h file, add the statement: PG_KEYWORD("partitions", PARTITIONS, UNRESERVED_KEYWORD)

The above is the addition of keywords in PostgreSQL grammar. If you have any questions, please leave a message or go to the community of this site to communicate and discuss. Thanks for reading.

Related articles: