Add xid_to_int4() function for Postgres.

This commit is contained in:
Tom Hughes 2009-09-07 16:44:54 +00:00
parent b3ff342e6b
commit 7b632da44a
2 changed files with 35 additions and 2 deletions

View file

@ -15,8 +15,8 @@ clean:
libmyosm.so: quadtile-mysql.o maptile-mysql.o
cc ${LDFLAGS} -o libmyosm.so quadtile-mysql.o maptile-mysql.o
libpgosm.so: quadtile-pgsql.o maptile-pgsql.o
cc ${LDFLAGS} -o libpgosm.so quadtile-pgsql.o maptile-pgsql.o
libpgosm.so: quadtile-pgsql.o maptile-pgsql.o xid_to_int4-pgsql.o
cc ${LDFLAGS} -o libpgosm.so quadtile-pgsql.o maptile-pgsql.o xid_to_int4-pgsql.o
quadtile-mysql.o: quadtile.c ${QTDIR}/quad_tile.h
cc `mysql_config --include` -I${QTDIR} -fPIC -O3 -DUSE_MYSQL -c -o quadtile-mysql.o quadtile.c
@ -29,3 +29,6 @@ maptile-mysql.o: maptile.c
maptile-pgsql.o: maptile.c
cc -I `pg_config --includedir-server` -fPIC -O3 -DUSE_PGSQL -c -o maptile-pgsql.o maptile.c
xid_to_int4-pgsql.o: xid_to_int4.c
cc -I `pg_config --includedir-server` -fPIC -O3 -DUSE_PGSQL -c -o xid_to_int4-pgsql.o xid_to_int4.c

View file

@ -0,0 +1,30 @@
#ifndef USE_MYSQL
#ifndef USE_PGSQL
#error One of USE_MYSQL or USE_PGSQL must be defined
#endif
#endif
#ifdef USE_PGSQL
#ifdef USE_MYSQL
#error ONLY one of USE_MYSQL and USE_PGSQL should be defined
#endif
#include <postgres.h>
#include <fmgr.h>
int xid_to_int4(TransactionId xid)
{
return xid;
}
/*
* To bind this into PGSQL, try something like:
*
* CREATE FUNCTION xid_to_int4(xid) RETURNS int4
* AS '/path/to/rails-port/db/functions/libpgosm', 'xid_to_int4'
* LANGUAGE C IMMUTABLE STRICT;
*
* (without all the *s)
*/
#endif