PL/Proxy on PostgreSQL 11 and FreeBSD 12

PL/Proxy is a project that allows database proxying, that is a way to connect to remote databases, and as a consequence allows for /sharding/ implementations.
The idea behind PL/Proxy is as simple as elegant: define a minimalistic language to access remote (database) objects and, more in particular, execute queries.

Unluckily, the latest stable release of PL/Proxy is 2.8 and is dated October 2017, that means PostgreSQL 10! There are a couple of Pull Requests to make it working against PostgreSQL 11, but hey have not been merged and the project code seems in pause.

Today I created a cumulative pull request that does a little adjustments to allow the compilation on FreeBSD 12 against PostgreSQL 11.

My pull request is inspired and borrows changes from other two pull requests:
  • pr-31 and credits to Laurenz Albe;
  • pr-33 that has been merged into mine, and credits to Christoph Berg.
    Then I added a compiler flag to adjust headers on FreeBSD 12, as well as dropped an old Bison syntax since this should be safe enough on modern PostgreSQL (at least 9.6 and higher. Some bit here and there to make all tests to pass against PostgreSQL 11, and everything seems right now.
    It is important to warn that my version is not production ready because it should be reviewed by at least one PL/Proxy developer.

And what about PostgreSQL 12?

Well, PostgreSQL 12 drops the usage of the special column Oid in catalogs, with commit 578b229718e8f15fa779e20f086c4b6bb3776106. What this means is that the macro HeapTupleGetOid is no longer there and PL/Proxy does an heavy usage of it. I’ve tried to blindly substitute it with ->t_tableOid, but this does not seems to work since the tests are failing to lookup objects. So any suggestion here is welcome!

The article PL/Proxy on PostgreSQL 11 and FreeBSD 12 has been posted by Luca Ferrari on August 26, 2019