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

Commit078d0ed

Browse files
author
Arthur Zakirov
committed
#5 untroduce pgv_set() and pgv_get() functions to handle anynonarray pseudotype
1 parent4590e57 commit078d0ed

File tree

6 files changed

+875
-15
lines changed

6 files changed

+875
-15
lines changed

‎Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ EXTENSION = pg_variables
77
DATA = pg_variables--1.0.sql
88
PGFILEDESC = "pg_variables - sessional variables"
99

10-
REGRESS = pg_variables
10+
REGRESS = pg_variables pg_variables_any
1111

1212
ifdefUSE_PGXS
1313
PG_CONFIG = pg_config

‎README.md‎

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ Note that the module does **not support transactions and savepoints**. For
99
example:
1010

1111
```sql
12-
SELECTpgv_set_int('vars','int1',101);
12+
SELECTpgv_set('vars','int1',101);
1313
BEGIN;
14-
SELECTpgv_set_int('vars','int2',102);
14+
SELECTpgv_set('vars','int2',102);
1515
ROLLBACK;
1616

1717
SELECT*FROM pgv_list()order by package, name;
@@ -42,32 +42,41 @@ Typical installation procedure may look like this:
4242
The functions provided by the**pg_variables** module are shown in the tables
4343
below. The module supports the following scalar and record types.
4444

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.
45+
To use**pgv_get()**function required package and variable must exists. It is
46+
necessary to set variable with**pgv_set()**function to use**pgv_get()**
47+
function.
4848

4949
If a package does not exists you will get the following error:
5050

5151
```sql
52-
SELECTpgv_get_int('vars','int1');
52+
SELECTpgv_get('vars','int1',NULL::int);
5353
ERROR: unrecognized package"vars"
5454
```
5555

5656
If a variable does not exists you will get the following error:
5757

5858
```sql
59-
SELECTpgv_get_int('vars','int1');
59+
SELECTpgv_get('vars','int1',NULL::int);
6060
ERROR: unrecognized variable"int1"
6161
```
6262

63-
**pgv_get_()**functions check the variable type. If the variable type does not
63+
**pgv_get()**function check the variable type. If the variable type does not
6464
match with the function type the error will be raised:
6565

6666
```sql
67-
SELECTpgv_get_text('vars','int1');
67+
SELECTpgv_get('vars','int1',NULL::text);
6868
ERROR: variable"int1" requires"integer" value
6969
```
7070

71+
##Scalar variables functions
72+
73+
Function | Returns
74+
-------- | -------
75+
`pgv_set(package text, name text, value anynonarray)` |`void`
76+
`pgv_get(package text, name text, var_type anynonarray, strict bool default true)` |`anynonarray`
77+
78+
##**Deprecated** scalar variables functions
79+
7180
###Integer variables
7281

7382
Function | Returns
@@ -117,7 +126,7 @@ Function | Returns
117126
`pgv_set_jsonb(package text, name text, value jsonb)` |`void`
118127
`pgv_get_jsonb(package text, name text, strict bool default true)` |`jsonb`
119128

120-
###Records
129+
##Record variables functions
121130

122131
The following functions are provided by the module to work with collections of
123132
record types.
@@ -159,16 +168,16 @@ Note that **pgv_stats()** works only with the PostgreSQL 9.6 and newer.
159168
It is easy to use functions to work with scalar variables:
160169

161170
```sql
162-
SELECTpgv_set_int('vars','int1',101);
163-
SELECTpgv_set_int('vars','int2',102);
171+
SELECTpgv_set('vars','int1',101);
172+
SELECTpgv_set('vars','int2',102);
164173

165-
SELECTpgv_get_int('vars','int1');
174+
SELECTpgv_get('vars','int1',NULL::int);
166175
pgv_get_int
167176
-------------
168177
101
169178
(1 row)
170179

171-
SELECTpgv_get_int('vars','int2');
180+
SELECTpgv_get('vars','int2',NULL::int);
172181
pgv_get_int
173182
-------------
174183
102

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp