Hacking PostgreSQL with Eclipse | PGConf EU 2017 | Metin Doslu

024d6a0dd14fb31c804969a57a06dfbe?s=47 Citus Data
October 26, 2017

Hacking PostgreSQL with Eclipse | PGConf EU 2017 | Metin Doslu

Hacking PostgreSQL, writing patches or creating extensions, might seem intimidating at first. The PostgreSQL codebase is huge and ever-evolving. In this talk, I will show how Eclipse, with the help of gdb, can make it a lot more accessible.

In this interactive talk, we will add the PostgreSQL project and set up gdb inside Eclipse. Then, we will walk step through the code using the debugger to reveal some of PostgreSQL internal data structures. We will show how to see the call stacks of errors and crashes, which saves a lot of headaches during development. Finally, we will show how to add a user-defined function that's written in C.

At the end of the talk, the audience will be more familiar with a simple but powerful environment to hack PostgreSQL.

024d6a0dd14fb31c804969a57a06dfbe?s=128

Citus Data

October 26, 2017
Tweet

Transcript

  1. Hacking PostgreSQL with Eclipse Metin Döşlü metin@citusdata.com PGCONF.EU 2017 1

  2. Motivation 2 Postgres can’t do everything You can extend it

    Eclipse makes it easy
  3. Extensions 3 postGIS - Spatial and Geographic objects pg_cron -

    Run periodic jobs hll - HyperLogLog (approximate distinct count) citus - Scale across multiple machines
  4. Personal Story 4 Distributed PostgreSQL PostgreSQL Extension

  5. Why Eclipse? 5 Start Fast Easy Navigation Rich Features

  6. Demo Outline 6 PostgreSQL Inside Eclipse Walking Around Deep Dive

  7. Demo Outline 7 PostgreSQL Inside Eclipse Walking Around Deep Dive

  8. Build PostgreSQL 8 ./configure CFLAGS=-"O0 -g" make -s -j4 sudo

    make install
  9. Import PostgreSQL into Eclipse 9 File -> Import C/C++ ->

    Existing Code as Makefile Project Turn off scalability mode (optional)
  10. Demo Outline 10 PostgreSQL Inside Eclipse Walking Around Deep Dive

  11. Attach GDB 11 select pg_backend_pid(); Debug As -> Debug Configurations

    C/C++ Attach to Application
  12. PostgreSQL Data Structures 12 Variables window p pprint(parse) printf "%s",

    pretty_format_node_dump(nodeToString(parse)) Preferences -> C/C++ -> Debug -> GDB -> Check “Show the GDB traces...”
  13. Errors 13 errstart() in elog.c if (elevel >= ERROR)

  14. Crashes 14 pg_crasher

  15. Demo Outline 15 PostgreSQL Inside Eclipse Walking Around Deep Dive

  16. Gatekeeper 16 watch

  17. Demo Outline 17 PostgreSQL Inside Eclipse Walking Around Deep Dive

  18. Summary 18 Postgres can’t do everything You can extend Eclipse

    makes it easy
  19. Hacking PostgreSQL with Eclipse Metin Döşlü metin@citusdata.com PGCONF.EU 2017 19