Thanks to the Blackhole Foreign Data Wrapper for PostgreSQL for providing a good template of how to build FDWs for PostgreSQL.
make
(sudo) make install
A note about transactional support: This FDW supports Kyoto Tycoon transactions via LUA scripts. Therefore, KT needs to be compiled with LUA support. To do this, run
./configure --enable-luawhen compiling KT.
Furthermore the ktserver has to be started with tranactions.lua loaded:
./ktserver -scr <fdw directory>/transactions.luaIf you want to disable transactions remove -DUSE_TRANSACTIONS from the Makefile in the FDW.
make installcheck
insert into <table name> values ('key', 'value', 'kt_set');
Makes insert overwrite existing keys in kyototycoon.
insert into <table name> values ('key', NULL, 'kt_set');
If value == NULL and the 'kt_set' flag is present. The insert acts as a delete.
insert into <table name> values ('key', 'value', 'kt_append');
Should append 'value' to any existing value in 'key'
CREATE SERVER <server name> FOREIGN DATA WRAPPER kt_fdw OPTIONS
(host '127.0.0.1', port '1978', timeout '-1', reconnect '1000');
(the above options are the defaults)
CREATE USER MAPPING FOR PUBLIC SERVER kt_server;
CREATE FOREIGN TABLE <table name> (key TEXT, value BYTEA, flags TEXT) SERVER <server name>;
Now you can Select, Update, Delete and Insert!