Multicorn PostgreSQL FDW on FreeBSD


I had to fight against Multicorn Foreign Data Wrappers because installing them on FreeBSD is not ideal. It is worth noting that the platform has not released a new stable version since February 2016, while the commit logs shows active development in order to be compatible with PostgreSQL 10. So what are problems installing Multicorn on FreeBSD? It is simple: Multicorn has not been made for FreeBSD and therefore the toolchain is not portable. In particular, in order to install it you have to:
  1. use gmake instead of make;
  2. change the she-bang line of preflight-check.sh which refers to Bash. Yes, really, Bash! Therefore change the first line from #!/bin/bash to #!/usr/local/bin/bash;
  3. install package python-distutils, for instance py27-python-distutils-extra-2.39, which in turn installs setuptools that is required by multicorn.
With the above, Multicorn can be installed, but there’s another trick to be aware of: the FDW Users’ Guide reports to use in pretty much all the examples the wrapper_multicorn as FDW, but that is wrong. The correct FDW to use is multicorn, as can be seen by the code within multicorn.sql:
CREATE FOREIGN DATA WRAPPER multicorn
So when you create a server with CREATE SERVER do use multicorn as FOREIGN DATA WRAPPER. With the above tricks I was able to run the file system FDW, as well as the Git one (which is pretty much un-documented). Unluckily, the GoogleFDW is both undocumented and not working, due to the need for a Google API and Custom Search that I reported to the module author after a little “debugging” (or kind of). I also asked to the ITPUG mailing list for someone proficient in Python for a Pull Request, maybe the ITPUG will be able to contribute!

The article Multicorn PostgreSQL FDW on FreeBSD has been posted by Luca Ferrari on November 2, 2017