forked from postgis/postgis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reference_transaction.xml
349 lines (266 loc) · 9.58 KB
/
reference_transaction.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
<?xml version="1.0" encoding="UTF-8"?>
<sect1 id="Long_Transactions_Support">
<sect1info>
<abstract>
<para>These functions implement a row locking mechanism to support long transactions.
They are provided primarily for implementors of the
<ulink url="http://www.opengeospatial.org/standards/wfs">Web Feature Service</ulink> specification.</para>
</abstract>
</sect1info>
<title>Long Transaction Support</title>
<note>
<para>For the locking mechanism to operate correctly the <emphasis role="bold">serializable</emphasis>
<ulink url="http://www.postgresql.org/docs/current/static/transaction-iso.html">
transaction isolation level</ulink> must be used.</para>
</note>
<refentry id="AddAuth">
<refnamediv>
<refname>AddAuth</refname>
<refpurpose>Adds an authorization token to be used in the current transaction.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>boolean <function>AddAuth</function></funcdef>
<paramdef><type>text </type> <parameter>auth_token</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Adds an authorization token to be used in the current transaction.</para>
<para>Adds the current transaction identifier
and authorization token to a temporary table called <varname>temp_lock_have_table</varname>.</para>
<para>Availability: 1.1.3</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>
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'
</programlisting>
</refsection>
<!-- Optionally add a "See Also" section -->
<refsection>
<title>See Also</title>
<para><xref linkend="LockRow" /></para>
</refsection>
</refentry>
<refentry id="CheckAuth">
<refnamediv>
<refname>CheckAuth</refname>
<refpurpose>Creates a trigger on a table to prevent/allow updates and deletes of rows based on authorization token.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>integer <function>CheckAuth</function></funcdef>
<paramdef><type>text </type> <parameter>a_schema_name</parameter></paramdef>
<paramdef><type>text </type> <parameter>a_table_name</parameter></paramdef>
<paramdef><type>text </type> <parameter>a_key_column_name</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>integer <function>CheckAuth</function></funcdef>
<paramdef><type>text </type> <parameter>a_table_name</parameter></paramdef>
<paramdef><type>text </type> <parameter>a_key_column_name</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Creates trigger on a table to prevent/allow updates and deletes of rows based on an authorization token.
Identify rows using <rowid_col> column.</para>
<para>If a_schema_name is not passed in, then searches for table in current schema.</para>
<note><para>If an authorization trigger already exists on this table function errors.</para>
<para>If Transaction support is not enabled, function throws an exception.</para>
</note>
<para>Availability: 1.1.3</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>
SELECT CheckAuth('public', 'towns', 'gid');
result
------
0
</programlisting>
</refsection>
<!-- Optionally add a "See Also" section -->
<refsection>
<title>See Also</title>
<para><xref linkend="EnableLongTransactions" /></para>
</refsection>
</refentry>
<refentry id="DisableLongTransactions">
<refnamediv>
<refname>DisableLongTransactions</refname>
<refpurpose>Disables long transaction support.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>text <function>DisableLongTransactions</function></funcdef>
<paramdef></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Disables long transaction support. This function removes the
long transaction support metadata tables, and drops all triggers
attached to lock-checked tables.</para>
<para>Drops meta table called <varname>authorization_table</varname> and a view called <varname>authorized_tables</varname>
and all triggers called <varname>checkauthtrigger</varname></para>
<para>Availability: 1.1.3</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>SELECT DisableLongTransactions();
--result--
Long transactions support disabled
</programlisting>
</refsection>
<!-- Optionally add a "See Also" section -->
<refsection>
<title>See Also</title>
<para><xref linkend="EnableLongTransactions" /></para>
</refsection>
</refentry>
<refentry id="EnableLongTransactions">
<refnamediv>
<refname>EnableLongTransactions</refname>
<refpurpose>Enables long transaction support.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>text <function>EnableLongTransactions</function></funcdef>
<paramdef></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Enables long transaction support.
This function creates the
required metadata tables. It must be called once before using the
other functions in this section. Calling it twice is
harmless.</para>
<para>Creates a meta table called <varname>authorization_table</varname> and a view called <varname>authorized_tables</varname></para>
<para>Availability: 1.1.3</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>SELECT EnableLongTransactions();
--result--
Long transactions support enabled
</programlisting>
</refsection>
<!-- Optionally add a "See Also" section -->
<refsection>
<title>See Also</title>
<para><xref linkend="DisableLongTransactions" /></para>
</refsection>
</refentry>
<refentry id="LockRow">
<refnamediv>
<refname>LockRow</refname>
<refpurpose>Sets lock/authorization for a row in a table.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>integer <function>LockRow</function></funcdef>
<paramdef><type>text </type> <parameter>a_schema_name</parameter></paramdef>
<paramdef><type>text </type> <parameter>a_table_name</parameter></paramdef>
<paramdef><type>text </type> <parameter>a_row_key</parameter></paramdef>
<paramdef><type>text</type> <parameter>an_auth_token</parameter></paramdef>
<paramdef><type>timestamp</type> <parameter>expire_dt</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>integer <function>LockRow</function></funcdef>
<paramdef><type>text </type> <parameter>a_table_name</parameter></paramdef>
<paramdef><type>text </type> <parameter>a_row_key</parameter></paramdef>
<paramdef><type>text</type> <parameter>an_auth_token</parameter></paramdef>
<paramdef><type>timestamp</type> <parameter>expire_dt</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>integer <function>LockRow</function></funcdef>
<paramdef><type>text </type> <parameter>a_table_name</parameter></paramdef>
<paramdef><type>text </type> <parameter>a_row_key</parameter></paramdef>
<paramdef><type>text</type> <parameter>an_auth_token</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Sets lock/authorization for a specific row in a table.
<varname>an_auth_token</varname> is a text value.
<varname>expire_dt</varname> is a timestamp
which defaults to <emphasis>now() + 1 hour</emphasis>.
Returns 1 if lock has been assigned, 0
otherwise (i.e. row is already locked by another auth.)</para>
<para>Availability: 1.1.3</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>SELECT LockRow('public', 'towns', '2', 'joey');
LockRow
-------
1
--Joey has already locked the record and Priscilla is out of luck
SELECT LockRow('public', 'towns', '2', 'priscilla');
LockRow
-------
0
</programlisting>
</refsection>
<!-- Optionally add a "See Also" section -->
<refsection>
<title>See Also</title>
<para><xref linkend="UnlockRows" /></para>
</refsection>
</refentry>
<refentry id="UnlockRows">
<refnamediv>
<refname>UnlockRows</refname>
<refpurpose>Removes all locks held by an authorization token.
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>integer <function>UnlockRows</function></funcdef>
<paramdef><type>text </type> <parameter>auth_token</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Removes all locks held by specified authorization token.
Returns the number of locks released.</para>
<para>Availability: 1.1.3</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>
SELECT LockRow('towns', '353', 'priscilla');
SELECT LockRow('towns', '2', 'priscilla');
SELECT UnLockRows('priscilla');
UnLockRows
------------
2
</programlisting>
</refsection>
<!-- Optionally add a "See Also" section -->
<refsection>
<title>See Also</title>
<para><xref linkend="LockRow" /></para>
</refsection>
</refentry>
</sect1>