parent
061b0733b6
commit
81c3ebe03c
7 changed files with 1 additions and 85 deletions
|
@ -129,5 +129,4 @@ If you want to deploy The Rails Port for production use, you'll need to make a f
|
||||||
* The included version of the map call is quite slow and eats a lot of memory. You should consider using [CGIMap](https://github.com/zerebubuth/openstreetmap-cgimap) instead.
|
* The included version of the map call is quite slow and eats a lot of memory. You should consider using [CGIMap](https://github.com/zerebubuth/openstreetmap-cgimap) instead.
|
||||||
* Make sure you generate the i18n files and precompile the production assets: `RAILS_ENV=production rake i18n:js:export assets:precompile`
|
* Make sure you generate the i18n files and precompile the production assets: `RAILS_ENV=production rake i18n:js:export assets:precompile`
|
||||||
* Make sure the web server user as well as the rails user can read, write and create directories in `tmp/`.
|
* Make sure the web server user as well as the rails user can read, write and create directories in `tmp/`.
|
||||||
* If you want to use diff replication then you might want to consider installing the shared library special SQL functions for the `xid_to_int4` function. A pure SQL version is available, but may become a performance issue on large databases with a high rate of changes. Note that you will need a version of PostgreSQL < 9.6 (yes, _less than_) to use `xid` indexing, whether pure SQL or shared library.
|
|
||||||
* If you expect to serve a lot of `/changes` API calls, then you might also want to install the shared library versions of the SQL functions.
|
* If you expect to serve a lot of `/changes` API calls, then you might also want to install the shared library versions of the SQL functions.
|
||||||
|
|
|
@ -278,7 +278,6 @@ Then we create the functions within each database. We're using `pwd` to substitu
|
||||||
|
|
||||||
```
|
```
|
||||||
psql -d openstreetmap -c "CREATE FUNCTION tile_for_point(int4, int4) RETURNS int8 AS '`pwd`/db/functions/libpgosm', 'tile_for_point' LANGUAGE C STRICT"
|
psql -d openstreetmap -c "CREATE FUNCTION tile_for_point(int4, int4) RETURNS int8 AS '`pwd`/db/functions/libpgosm', 'tile_for_point' LANGUAGE C STRICT"
|
||||||
psql -d openstreetmap -c "CREATE FUNCTION xid_to_int4(xid) RETURNS int4 AS '`pwd`/db/functions/libpgosm', 'xid_to_int4' LANGUAGE C STRICT"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
# Ruby development install and versions<a name="rbenv"></a> (optional)
|
# Ruby development install and versions<a name="rbenv"></a> (optional)
|
||||||
|
|
|
@ -16,7 +16,7 @@ all: ${DESTDIR}/libpgosm.so
|
||||||
clean:
|
clean:
|
||||||
$(RM) ${DESTDIR}/*.so ${DESTDIR}/*.o
|
$(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 $@ $^
|
cc ${LDFLAGS} -o $@ $^
|
||||||
|
|
||||||
${DESTDIR}/%.o: %.c
|
${DESTDIR}/%.o: %.c
|
||||||
|
|
|
@ -40,34 +40,3 @@ BEGIN
|
||||||
RETURN (x << 1) | y;
|
RETURN (x << 1) | y;
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE plpgsql IMMUTABLE;
|
$$ 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)
|
|
||||||
*/
|
|
|
@ -147,34 +147,6 @@ END;
|
||||||
$$;
|
$$;
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Name: xid_to_int4(xid); Type: FUNCTION; Schema: public; Owner: -
|
|
||||||
--
|
|
||||||
|
|
||||||
CREATE FUNCTION public.xid_to_int4(t xid) RETURNS integer
|
|
||||||
LANGUAGE plpgsql IMMUTABLE STRICT
|
|
||||||
AS $$
|
|
||||||
DECLARE
|
|
||||||
tl bigint;
|
|
||||||
ti int;
|
|
||||||
BEGIN
|
|
||||||
tl := t;
|
|
||||||
|
|
||||||
IF tl >= 2147483648 THEN
|
|
||||||
tl := tl - 4294967296;
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
ti := tl;
|
|
||||||
|
|
||||||
RETURN ti;
|
|
||||||
END;
|
|
||||||
$$;
|
|
||||||
|
|
||||||
|
|
||||||
SET default_tablespace = '';
|
|
||||||
|
|
||||||
SET default_table_access_method = heap;
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: acls; Type: TABLE; Schema: public; Owner: -
|
-- Name: acls; Type: TABLE; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
|
|
@ -53,7 +53,6 @@ sudo -u vagrant psql -d openstreetmap -f db/functions/functions.sql
|
||||||
#pushd db/functions
|
#pushd db/functions
|
||||||
#sudo -u vagrant make
|
#sudo -u vagrant make
|
||||||
#sudo -u vagrant psql openstreetmap -c "CREATE OR REPLACE FUNCTION tile_for_point(int4, int4) RETURNS int8 AS '/srv/openstreetmap-website/db/functions/libpgosm.so', 'tile_for_point' LANGUAGE C STRICT"
|
#sudo -u vagrant psql openstreetmap -c "CREATE OR REPLACE FUNCTION tile_for_point(int4, int4) RETURNS int8 AS '/srv/openstreetmap-website/db/functions/libpgosm.so', 'tile_for_point' LANGUAGE C STRICT"
|
||||||
#sudo -u vagrant psql openstreetmap -c "CREATE OR REPLACE FUNCTION xid_to_int4(xid) RETURNS int4 AS '/srv/openstreetmap-website/db/functions/libpgosm.so', 'xid_to_int4' LANGUAGE C STRICT"
|
|
||||||
#popd
|
#popd
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue