Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit21a4e55

Browse files
author
Artur Zakirov
committed
Added more info into documentation
1 parente45c6eb commit21a4e55

File tree

2 files changed

+218
-23
lines changed

2 files changed

+218
-23
lines changed

‎contrib/pg_variables/README.md

Lines changed: 74 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,23 @@
55
The**pg_variables** module provides functions to work with variables of various
66
types. Created variables live only in the current user session.
77

8+
Note that the module does**not support transactions and savepoints**. For
9+
example:
10+
11+
```sql
12+
SELECT pgv_set_int('vars','int1',101);
13+
BEGIN;
14+
SELECT pgv_set_int('vars','int2',102);
15+
ROLLBACK;
16+
17+
SELECT*FROM pgv_list()order by package, name;
18+
package | name
19+
---------+------
20+
vars | int1
21+
vars | int2
22+
(2 rows)
23+
```
24+
825
##License
926

1027
This module available under the same license as
@@ -22,6 +39,35 @@ Typical installation procedure may look like this:
2239

2340
##Module functions
2441

42+
The functions provided by the**pg_variables** module are shown in the tables
43+
below. The module supports the following scalar and record types.
44+
45+
To use**pgv_get_()** functions required package and variable must exists. It is
46+
necessary to set variable with**pgv_set_()** functions to use**pgv_get_()**
47+
functions.
48+
49+
If a package does not exists you will get the following error:
50+
51+
```sql
52+
SELECT pgv_get_int('vars','int1');
53+
ERROR: unrecognized package"vars"
54+
```
55+
56+
If a variable does not exists you will get the following error:
57+
58+
```sql
59+
SELECT pgv_get_int('vars','int1');
60+
ERROR: unrecognized variable"int1"
61+
```
62+
63+
**pgv_get_()** functions check the variable type. If the variable type does not
64+
match with the function type the error will be raised:
65+
66+
```sql
67+
SELECT pgv_get_text('vars','int1');
68+
ERROR: variable"int1" requires"integer" value
69+
```
70+
2571
###Integer variables
2672

2773
Function | Returns
@@ -73,25 +119,37 @@ Function | Returns
73119

74120
###Records
75121

76-
Function | Returns
77-
-------- | -------
78-
`pgv_insert(package text, name text, r record)` |`void`
79-
`pgv_update(package text, name text, r record)` |`boolean`
80-
`pgv_delete(package text, name text, value anynonarray)` |`boolean`
81-
`pgv_select(package text, name text)` |`set of record`
82-
`pgv_select(package text, name text, value anynonarray)` |`record`
83-
`pgv_select(package text, name text, value anyarray)` |`set of record`
122+
The following functions are provided by the module to work with collections of
123+
record types.
124+
125+
To use**pgv_update()**,**pgv_delete()** and**pgv_select()** functions
126+
required package and variable must exists. Otherwise the error will be raised.
127+
It is necessary to set variable with**pgv_insert()** function to use these
128+
functions.
129+
130+
**pgv_update()**,**pgv_delete()** and**pgv_select()** functions check the
131+
variable type. If the variable type does not**record** type the error will be
132+
raised.
133+
134+
Function | Returns | Description
135+
-------- | ------- | -----------
136+
`pgv_insert(package text, name text, r record)` |`void` | Inserts a record to the variable collection. If package and variable do not exists they will be created. The first column of**r** will be a primary key. If exists a record with the same primary key the error will be raised. If this variable collection has other structure the error will be raised.
137+
`pgv_update(package text, name text, r record)` |`boolean` | Updates a record with the corresponding primary key (the first column of**r** is a primary key). Returns**true** if a record was found. If this variable collection has other structure the error will be raised.
138+
`pgv_delete(package text, name text, value anynonarray)` |`boolean` | Deletes a record with the corresponding primary key (the first column of**r** is a primary key). Returns**true** if a record was found.
139+
`pgv_select(package text, name text)` |`set of record` | Returns the variable collection records.
140+
`pgv_select(package text, name text, value anynonarray)` |`record` | Returns the record with the corresponding primary key (the first column of**r** is a primary key).
141+
`pgv_select(package text, name text, value anyarray)` |`set of record` | Returns the variable collection records with the corresponding primary keys (the first column of**r** is a primary key).
84142

85143
###Miscellaneous functions
86144

87-
Function | Returns
88-
-------- | -------
89-
`pgv_exists(package text, name text)` |`bool`
90-
`pgv_remove(package text, name text)` |`void`
91-
`pgv_remove(package text)` |`void`
92-
`pgv_free()` |`void`
93-
`pgv_list()` |`table(package text, name text)`
94-
`pgv_stats()` |`table(package text, used_memory bigint)`
145+
Function | Returns | Description
146+
-------- | ------- | -----------
147+
`pgv_exists(package text, name text)` |`bool` | Returns**true** if package and variable exists.
148+
`pgv_remove(package text, name text)` |`void` | Removes the variable with the corresponding name. Required package and variable must exists, otherwise the error will be raised.
149+
`pgv_remove(package text)` |`void` | Removes the package and all package variables with the corresponding name. Required package must exists, otherwise the error will be raised.
150+
`pgv_free()` |`void` | Removes all packages and variables.
151+
`pgv_list()` |`table(package text, name text)` | Returns set of records of assigned packages and variables.
152+
`pgv_stats()` |`table(package text, used_memory bigint)` | Returns list of assigned packages and used memory in bytes.
95153

96154
Note that**pgv_stats()** works only with the PostgreSQL 9.6 and newer.
97155

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp