Skip to content

Commit 4cdfe45

Browse files
author
Artur Zakirov
committed
Fix the error with strict = false parameter
1 parent ae89d20 commit 4cdfe45

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

contrib/pg_variables/expected/pg_variables.out

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
CREATE EXTENSION pg_variables;
22
-- Integer variables
3+
SELECT pgv_get_int('vars', 'int1');
4+
ERROR: unrecognized package "vars"
5+
SELECT pgv_get_int('vars', 'int1', false);
6+
pgv_get_int
7+
-------------
8+
9+
(1 row)
10+
311
SELECT pgv_set_int('vars', 'int1', 101);
412
pgv_set_int
513
-------------

contrib/pg_variables/pg_variables.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,12 @@ variable_get(text *package_name, text *var_name,
132132
ScalarVar *scalar;
133133

134134
package = getPackageByName(package_name, false, strict);
135+
if (package == NULL)
136+
{
137+
*is_null = true;
138+
return 0;
139+
}
140+
135141
variable = getVariableByNameWithType(package->variablesHash,
136142
var_name, typid, false, strict);
137143

contrib/pg_variables/sql/pg_variables.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
CREATE EXTENSION pg_variables;
22

33
-- Integer variables
4+
SELECT pgv_get_int('vars', 'int1');
5+
SELECT pgv_get_int('vars', 'int1', false);
6+
47
SELECT pgv_set_int('vars', 'int1', 101);
58
SELECT pgv_set_int('vars', 'int2', 102);
69

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy