Permalink
Browse files

Initial half-baked version of the MySQL FDW.

  • Loading branch information...
dpage committed Apr 12, 2011
0 parents commit 688c0fdb7ed4eb9ff9ceb76f65b7608432a8b196
Showing with 802 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +40 −0 Makefile
  3. +66 −0 README
  4. +1 −0 expected/.gitignore
  5. +29 −0 mysql_fdw--1.0.sql
  6. +644 −0 mysql_fdw.c
  7. +19 −0 mysql_fdw.control
  8. +1 −0 sql/.gitignore
@@ -0,0 +1,2 @@
+# Generated subdirectories
+/results/
@@ -0,0 +1,40 @@
+##########################################################################
+#
+# foreign-data wrapper for MySQL
+#
+# Copyright (c) 2011, PostgreSQL Global Development Group
+#
+# This software is released under the PostgreSQL Licence
+#
+# Author: Dave Page <dpage@pgadmin.org>
+#
+# IDENTIFICATION
+# mysql_fdw/Makefile
+#
+##########################################################################
+
+MODULE_big = mysql_fdw
+OBJS = mysql_fdw.o
+
+EXTENSION = mysql_fdw
+DATA = mysql_fdw--1.0.sql
+
+REGRESS = mysql_fdw
+
+EXTRA_CLEAN = sql/mysql_fdw.sql expected/mysql_fdw.out
+
+MYSQL_CONFIG = mysql_config
+SHLIB_LINK := $(shell $(MYSQL_CONFIG) --libs)
+PG_CPPFLAGS := $(shell $(MYSQL_CONFIG) --include)
+
+ifdef USE_PGXS
+PG_CONFIG = pg_config
+PGXS := $(shell $(PG_CONFIG) --pgxs)
+include $(PGXS)
+else
+subdir = contrib/mysql_fdw
+top_builddir = ../..
+include $(top_builddir)/src/Makefile.global
+include $(top_srcdir)/contrib/contrib-global.mk
+endif
+
66 README
@@ -0,0 +1,66 @@
+MySQL FDW for PostgreSQL 9.1+
+==============================
+
+This PostgreSQL extension implements a Foreign Data Wrapper (FDW) for
+the MySQL.
+
+This code is experimental, and largely intended as a pet project for me
+to experiment with and learn about FDWs in PostgreSQL.
+
+By all means use it, but do so entirely at your own risk! You have been
+warned!
+
+Building
+--------
+
+FIXME: Library requirements etc.
+
+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
+-----------
+
+FIXME
+
+Usage
+-----
+
+The following parameters can be set on a MySQL foreign server:
+
+address: The address or hostname of the MySQL server.
+ Default: 127.0.0.1
+
+port: The port number on which the MySQL server is listening.
+ Default: 6379
+
+The following parameter can be set on a MySQL foreign table:
+
+database: The numeric ID of the MySQL database to query.
+ Default: 0
+
+The following parameter can be set on a user mapping for a MySQL
+foreign server:
+
+username: The username to use when connecting to MySQL
+
+password: The password to authenticate to the MySQL server with.
+ Default: <none>
+
+FIXME: Add additional options.
+
+Example
+-------
+
+FIXME
+
+--
+Dave Page
+dpage@pgadmin.org
@@ -0,0 +1 @@
+/file_fdw.out
@@ -0,0 +1,29 @@
+/*-------------------------------------------------------------------------
+ *
+ * foreign-data wrapper for MySQL
+ *
+ * Copyright (c) 2011, PostgreSQL Global Development Group
+ *
+ * This software is released under the PostgreSQL Licence
+ *
+ * Author: Dave Page <dpage@pgadmin.org>
+ *
+ * IDENTIFICATION
+ * mysql_fdw/mysql_fdw--1.0.sql
+ *
+ *-------------------------------------------------------------------------
+ */
+
+CREATE FUNCTION mysql_fdw_handler()
+RETURNS fdw_handler
+AS 'MODULE_PATHNAME'
+LANGUAGE C STRICT;
+
+CREATE FUNCTION mysql_fdw_validator(text[], oid)
+RETURNS void
+AS 'MODULE_PATHNAME'
+LANGUAGE C STRICT;
+
+CREATE FOREIGN DATA WRAPPER mysql_fdw
+ HANDLER mysql_fdw_handler
+ VALIDATOR mysql_fdw_validator;
Oops, something went wrong.

0 comments on commit 688c0fd

Please sign in to comment.