From: Tom Hughes Date: Mon, 7 Sep 2009 16:44:54 +0000 (+0000) Subject: Add xid_to_int4() function for Postgres. X-Git-Tag: live~6683 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/7b632da44adb75999ee094d8b99ff208caf65eba Add xid_to_int4() function for Postgres. --- diff --git a/db/functions/Makefile b/db/functions/Makefile index ddf67d608..bb7d54a9c 100644 --- a/db/functions/Makefile +++ b/db/functions/Makefile @@ -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 diff --git a/db/functions/xid_to_int4.c b/db/functions/xid_to_int4.c new file mode 100644 index 000000000..6863dfaca --- /dev/null +++ b/db/functions/xid_to_int4.c @@ -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 +#include + +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