PostgreSQL: Codebase

$ git clone git://git.postgresql.org/git/postgresql.git
$ cd postgresql
$ ./src -L 1
./src
├── backend    (Server)
├── bin        (Client Programs)
├── common     (Utilities)
├── fe_utils   (Frontend Utilities)
├── include    (Headers)
├── interfaces (libpg and ecpg)
├── pl         (pl/pgsql)
├── port       (libpgport)
├── test       (tests)
├── timezone   (Timezone data)
  • Frontend — client.
  • Backend — server.
  • ecpg — Embedded SQL in C.

The "main" of Postgres backend: src/backend/tcop/postgres.c. tcop — Traffic cop, dispatches request to proper module.

Misc

  • palloc(), pfree() => malloc(), free()
  • documents written in SGML

Error Reporting

ereport, errcode, errmsg, errdetail, elog.

  • ereport used for user-facing errors.
  • elog used for debugging.

Postgres Errors (~ 500 of them) all have a code, defined in src/backend/utils/errcodes.txt.