Skip to content

Commit 430989c

Browse files
Fix README.md
1 parent a86437f commit 430989c

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

README.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
# pg_variables - session variables with various types
22

3-
[![Build Status](https://travis-ci.org/postgrespro/pg_variables.svg?branch=master)](https://travis-ci.org/postgrespro/pg_variables)
4-
[![codecov](https://codecov.io/gh/postgrespro/pg_variables/branch/master/graph/badge.svg)](https://codecov.io/gh/postgrespro/pg_variables)
5-
[![GitHub license](https://img.shields.io/badge/license-PostgreSQL-blue.svg)](https://raw.githubusercontent.com/postgrespro/pg_variables/master/README.md)
6-
73
## Introduction
84

95
The **pg_variables** module provides functions to work with variables of various
106
types. Created variables live only in the current user session.
11-
12-
Note that the module does **not support transactions and savepoints by default**. For
13-
example:
14-
7+
By default, created variables are not transactional (i.e. they are not affected
8+
by `BEGIN`, `COMMIT` or `ROLLBACK` statements). This, however, is customizable
9+
by argument `is_transactional` of `pgv_set()`:
1510
```sql
1611
SELECT pgv_set('vars', 'int1', 101);
1712
BEGIN;
@@ -26,7 +21,7 @@ SELECT * FROM pgv_list() order by package, name;
2621
(2 rows)
2722
```
2823

29-
But if variable created with flag **is_transactional**, it does:
24+
But if variable created with flag **is_transactional**:
3025
```sql
3126
BEGIN;
3227
SELECT pgv_set('vars', 'trans_int', 101, true);
@@ -255,11 +250,11 @@ You can list packages and variables:
255250

256251
```sql
257252
SELECT * FROM pgv_list() order by package, name;
258-
package | name
259-
---------+------
260-
vars | int1
261-
vars | int2
262-
vars | r1
253+
package | name | is_transactional
254+
---------+------+------------------
255+
vars | int1 | f
256+
vars | int2 | f
257+
vars | r1 | f
263258
(3 rows)
264259
```
265260

@@ -285,8 +280,8 @@ You can delete all packages and variables:
285280
SELECT pgv_free();
286281
```
287282

288-
If you want variables with support of transactions and savepoints, you should add flag
289-
`is_transactional = true` as the last argument in functions `pgv_set()`
283+
If you want variables with support of transactions and savepoints, you should
284+
add flag `is_transactional = true` as the last argument in functions `pgv_set()`
290285
or `pgv_insert()`.
291286
Following use cases describe behavior of transactional variables:
292287
```sql
@@ -317,7 +312,8 @@ SELECT pgv_get('pack', 'var_text', NULL::text);
317312
before transaction block
318313

319314
```
320-
If you create variable after `BEGIN` or `SAVEPOINT` and than rollback to previous state - variable will not be exist:
315+
If you create variable after `BEGIN` or `SAVEPOINT` statements and than rollback
316+
to previous state - variable will not be exist:
321317
```sql
322318
BEGIN;
323319
SAVEPOINT sp1;
@@ -335,7 +331,10 @@ SELECT pgv_get('pack','var_int', NULL::int);
335331
ERROR: unrecognized variable "var_int"
336332
COMMIT;
337333
```
338-
If you created transactional variable once, you should use flag `is_transactional` every time when you want to change variable value by functions `pgv_set()`, `pgv_insert()` and deprecated setters (i.e. `pgv_set_int()`). If you try to change this option, you'll get an error:
334+
If you created transactional variable once, you should use flag `is_transactional`
335+
every time when you want to change variable value by functions `pgv_set()`,
336+
`pgv_insert()` and deprecated setters (i.e. `pgv_set_int()`). If you try to
337+
change this option, you'll get an error:
339338
```sql
340339
SELECT pgv_insert('pack', 'var_record', row(123::int, 'text'::text), true);
341340
pgv_insert

0 commit comments

Comments
 (0)