DEV Community

Sergey Solovev
Sergey Solovev

Posted on • Edited on

The PostgreSQL Hacker Helper extension is one year old

PostgreSQL Hacker Helper is a VS Code extension for developing PostgreSQL source code. A couple of days ago (August 9th), one year has passed since the release of version 1.0.0.

Initially, it was a utility for dynamically calculating expressions and casting variables, but after a while I realized that not everything is so simple. The main catch is that there are types (if you can say so) that require special treatment.

The most striking example is a List, a dynamic array. What's so special about it? Firstly, there is only one data structure, but inside it it stores (either-or) a pointer/int/TransactionID/Oid. Secondly, its implementation depends on the version. Previously, it was implemented as a linked list, but today it is an array.

Another interesting example is Value. Today, this structure does not exist, as it has been split into separate String, Integer, Float, Boolean, and BitString (src/include/nodes/value.h). This also violates the initially beautiful picture, as you have to add (complex) logic - the name of the structure does not correspond to the type of the stored node.

I've added a lot of features this year:

  • Expression rendering (variables representing expressions are displayed by the expression they represent)
  • Displaying the contents of hash tables
  • Pointers to relations from variables of the Relids type
  • Formatting a source code using pgindent
  • Bootstrapping new extensions (creating template extension files)
  • Dump node representation to a log or a separate text file (via pprint/nodeToString)

If we talk about non-functional features:

  • Greater extensibility due to the configuration file
  • Support for multiple debugger extensions
  • Testing (integraion) and CI pipeline for this

What I remember most was the addition of CodeLLDB debugger support. I've been doing this for 5 days from morning to night. At the same time, I added testing.

The most difficult part of all this is supporting older versions of PostgreSQL. For the extension to work, I rely on dynamic evaluation of functions in the debugger, but various major releases may break binary compatibility and some functions may be removed. I can't remember how many times I spent hours looking for workarounds to implement some functionality.

Looking at all this, I realize that now it can be called an entire IDE for PostgreSQL. Although it seems that everything that could have been written has already been done, I am constantly finding new opportunities for its development.

Links for those interested: GitHub repo, VS Code marketplace.

Top comments (0)