parent
061b0733b6
commit
81c3ebe03c
7 changed files with 1 additions and 85 deletions
|
@ -16,7 +16,7 @@ all: ${DESTDIR}/libpgosm.so
|
|||
clean:
|
||||
$(RM) ${DESTDIR}/*.so ${DESTDIR}/*.o
|
||||
|
||||
${DESTDIR}/libpgosm.so: ${DESTDIR}/quadtile.o ${DESTDIR}/xid_to_int4.o
|
||||
${DESTDIR}/libpgosm.so: ${DESTDIR}/quadtile.o
|
||||
cc ${LDFLAGS} -o $@ $^
|
||||
|
||||
${DESTDIR}/%.o: %.c
|
||||
|
|
|
@ -40,34 +40,3 @@ BEGIN
|
|||
RETURN (x << 1) | y;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql IMMUTABLE;
|
||||
|
||||
|
||||
-- xid_to_int4 converts a PostgreSQL transaction ID (xid) to a 32-bit integer
|
||||
-- which can then be used to efficiently find rows which have changed between
|
||||
-- two given transactions. This is currently used by Osmosis to extract a
|
||||
-- stream of edits for "diff replication" **HOWEVER** this is a pain point, as
|
||||
-- (ab)using the xid in this way is _not_ supported or recommended by Postgres
|
||||
-- devs. It is preventing us upgrading to PostgreSQL version 10+, and will
|
||||
-- hopefully be replaced Real Soon Now.
|
||||
--
|
||||
-- From the Osmosis distribution by Brett Henderson:
|
||||
-- https://github.com/openstreetmap/osmosis/blob/master/package/script/contrib/apidb_0.6_osmosis_xid_indexing.sql
|
||||
CREATE OR REPLACE FUNCTION xid_to_int4(t xid)
|
||||
RETURNS integer
|
||||
AS
|
||||
$$
|
||||
DECLARE
|
||||
tl bigint;
|
||||
ti int;
|
||||
BEGIN
|
||||
tl := t;
|
||||
|
||||
IF tl >= 2147483648 THEN
|
||||
tl := tl - 4294967296;
|
||||
END IF;
|
||||
|
||||
ti := tl;
|
||||
|
||||
RETURN ti;
|
||||
END;
|
||||
$$ LANGUAGE 'plpgsql' IMMUTABLE STRICT;
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
#include <postgres.h>
|
||||
#include <fmgr.h>
|
||||
|
||||
Datum
|
||||
xid_to_int4(PG_FUNCTION_ARGS)
|
||||
{
|
||||
TransactionId xid = PG_GETARG_INT32(0);
|
||||
|
||||
PG_RETURN_INT32(xid);
|
||||
}
|
||||
|
||||
PG_FUNCTION_INFO_V1(xid_to_int4);
|
||||
|
||||
/*
|
||||
* 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)
|
||||
*/
|
Loading…
Add table
Add a link
Reference in a new issue