CouchDB FDW (beta) for PostgreSQL 9.1+ ====================================== This PostgreSQL extension implements a Foreign Data Wrapper (FDW) for the CouchDB document-oriented database: http://couchdb.apache.org/ IMPORTANT: There're bugs in the existing version. I'm working on it and will be releasing another version very soon. Building -------- To build the code, you need the yajl(Yet Another JSON Library) and libcurl installed on your system. You can checkout the yajl from GitHub: https://github.com/lloyd/yajl OR download from: http://lloyd.github.com/yajl/ libcurl C interface can be found here: http://curl.haxx.se/libcurl/c/ Once that's done, the extension can be built with: PATH=/usr/local/pgsql91/bin/:$PATH make USE_PGXS=1 make sudo PATH=/usr/local/pgsql91/bin/:$PATH make USE_PGXS=1 install (assuming you have PostgreSQL 9.1 in /usr/local/pgsql91). I've tested on Mac OS X 10.6 only, but other *nix's should also work. I haven't tested on Windows, but the code should be good on MinGW. Limitations ----------- - If there is no quals to pushdown, we get a list of '_id's to begin with, and then fetch whatever records still exist as we build the tuples. - We can only pushdown '_id' (with or without '_rev') to CouchDB, which must use the TEXTEQ operator. - The top-level-attributes of a document can be mapped to columns in a foreign table. - In case you want the map a column to the entire JOSN doc, use columnname '_doc' in foreign table options (which means your remote couchdb shouldn't have a top-level-attribute called '_doc', otherwise there will be conficts). Usage ----- The following parameters can be set on a CouchDB foreign server: address: The address or hostname of the CouchDB server. Default: 127.0.0.1 port: The port number on which the CouchDB server is listening. Default: 5984 The following parameter can be set on a CouchDB foreign table: database: The numeric ID of the CouchDB database to query. Default: test : The column mapping to remote JSON attributes. If there is no column mapping specified, default is the origninal column name. Please note that '_doc' is reserved for mapping the entire JSON document. The following parameter can be set on a user mapping for a CouchDB foreign server: username: The username to authenticate to the CouchDB server with. Default: password: The password to authenticate to the CouchDB server with. Default: Example ------- CREATE SERVER couchdb_server FOREIGN DATA WRAPPER couchdb_fdw OPTIONS (address '127.0.0.1', port '5984'); CREATE FOREIGN TABLE couchdb_table (key text, value text) SERVER couchdb_server OPTIONS (database 'testdb', key '_id', value '_doc'); CREATE USER MAPPING FOR PUBLIC SERVER couchdb_server OPTIONS (username 'testuser', password 'secret'); -- Zheng Yang zhengyang4k@gmail.com