SoFunction
Updated on 2025-04-07

Detailed explanation of the addition of keywords in PostgreSQL syntax

Detailed explanation of the addition of keywords in PostgreSQL syntax

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

Record the keywords added to the parser syntax parsing module.

Introduction to several core files

Source File illustrate
Define syntax structure, generate and
Define the lexical structure, and generate it after flex compile
Keyword list, need to be sorted in order
check_keywords.pl It will be called under linux for keyword check (order, legality, etc.)

Adding keywords in the syntax

  1. %token <keyword> add keyword PARTITIONS
  2. Add keyword PARTITIONS to the reserved_keyword segment of the file
  3. File, add 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. Thank you for reading. I hope it can help you. Thank you for your support for this site!