PGCon2019 - 3.4

PGCon 2019
The PostgreSQL Conference

Bo Peng
Day Talks - Day 2 - 2019-05-31
Room DMS 1120
Start time 16:00
Duration 00:45
ID 1310
Event type Lecture
Track Hacking
Language used for presentation English

Introducing PostgreSQL SQL parser through an experience of reusing it in other applications

SQL parser is an important subsystem in PostgreSQL because it understands SQL queries and turns it into a machine readable form so that subsequent subsystems can easily handle user's SQL. In this talk I will explain the internal of SQL parser through an experience in porting it to other applications.

PostgreSQL query processing architecture consists 4 steps: parser, rewriter, optimizer and executor. The parser is a PostgreSQL internal module to parse the SQL from application and returns an internal PostgreSQL parse tree.

The SQL parser is divided into two pieces: raw parser which is responsible for syntactic analysis of SQL, and analyzer which adds semantics information by looking up system catalogs.

In this talk, firstly I will explain the internal of the SQL parser. Next, because there are many applications which want to have an SQL parser, I will show you how to port the raw parser to an application by using Pgpool-II as a concrete example.