0% found this document useful (0 votes)
199 views

Examples: 7.11 Long Transactions Support

This document provides examples and documentation on PostGIS functions for adding and checking authorization tokens to support long transactions in PostGIS. It includes examples of using the ST_AddMeasure() function to add M values to geometries, and using the AddAuth() and CheckAuth() functions to add and check authorization tokens in transactions to prevent unauthorized updates and deletes of rows.

Uploaded by

Mathias Eder
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
199 views

Examples: 7.11 Long Transactions Support

This document provides examples and documentation on PostGIS functions for adding and checking authorization tokens to support long transactions in PostGIS. It includes examples of using the ST_AddMeasure() function to add M values to geometries, and using the AddAuth() and CheckAuth() functions to add and check authorization tokens in transactions to prevent unauthorized updates and deletes of rows.

Uploaded by

Mathias Eder
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

PostGIS 1.5.

1 Manual
251 / 315

Examples
SELECT ST_AsEWKT(ST_AddMeasure(
ST_GeomFromEWKT(LINESTRING(1 0, 2 0, 4 0)),1,4)) As ewelev;
ewelev
-------------------------------LINESTRINGM(1 0 1,2 0 2,4 0 4)
SELECT ST_AsEWKT(ST_AddMeasure(
ST_GeomFromEWKT(LINESTRING(1 0 4, 2 0 4, 4 0 4)),10,40)) As ewelev;
ewelev
---------------------------------------LINESTRING(1 0 4 10,2 0 4 20,4 0 4 40)
SELECT ST_AsEWKT(ST_AddMeasure(
ST_GeomFromEWKT(LINESTRINGM(1 0 4, 2 0 4, 4 0 4)),10,40)) As ewelev;
ewelev
---------------------------------------LINESTRINGM(1 0 10,2 0 20,4 0 40)
SELECT ST_AsEWKT(ST_AddMeasure(
ST_GeomFromEWKT(MULTILINESTRINGM((1 0 4, 2 0 4, 4 0 4),(1 0 4, 2 0 4, 4 0 4))),10,70)) As ewelev;
ewelev
----------------------------------------------------------------MULTILINESTRINGM((1 0 10,2 0 20,4 0 40),(1 0 40,2 0 50,4 0 70))

7.11 Long Transactions Support


This module and associated pl/pgsql functions have been implemented to provide long locking support required by Web Feature
Service specification.

Note
Users must use serializable transaction level otherwise locking mechanism would break.

7.11.1 AddAuth
Name
AddAuth Add an authorization token to be used in current transaction.

Synopsis
boolean AddAuth(text auth_token);

Description
Add an authorization token to be used in current transaction.
Creates/adds to a temp table called temp_lock_have_table the current transaction identifier and authorization token key.
Availability: 1.1.3

PostGIS 1.5.1 Manual


252 / 315

Examples
SELECT LockRow(towns, 353, priscilla);
BEGIN TRANSACTION;
SELECT AddAuth(joey);
UPDATE towns SET the_geom = ST_Translate(the_geom,2,2) WHERE gid = 353;
COMMIT;

---Error-ERROR: UPDATE where "gid" = 353 requires authorization priscilla

See Also
LockRow

7.11.2 CheckAuth
Name
CheckAuth Creates trigger on a table to prevent/allow updates and deletes of rows based on authorization token.

Synopsis
integer CheckAuth(text a_schema_name, text a_table_name, text a_key_column_name);
integer CheckAuth(text a_table_name, text a_key_column_name);

Description
Creates trigger on a table to prevent/allow updates and deletes of rows based on authorization token. Identify rows using
<rowid_col> column.
If a_schema_name is not passed in, then searches for table in current schema.

Note
If an authorization trigger already exists on this table function errors.
If Transaction support is not enabled, function throws an exception.

Availability: 1.1.3

Examples
SELECT CheckAuth(public, towns, gid);
result
-----0

See Also
EnableLongTransactions

You might also like