Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
c7a141a9
Commit
c7a141a9
authored
Apr 09, 2016
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix PL/Python ereport() test to work on Python 2.3.
Per buildfarm. Pavel Stehule
parent
08e78543
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
12 deletions
+20
-12
src/pl/plpython/expected/plpython_test.out
src/pl/plpython/expected/plpython_test.out
+14
-10
src/pl/plpython/sql/plpython_test.sql
src/pl/plpython/sql/plpython_test.sql
+6
-2
No files found.
src/pl/plpython/expected/plpython_test.out
View file @
c7a141a9
...
...
@@ -150,22 +150,26 @@ RETURNS void AS $$
kwargs = { "message":_message, "detail":_detail, "hint":_hint,
"sqlstate":_sqlstate, "schema":_schema, "table":_table,
"column":_column, "datatype":_datatype, "constraint":_constraint }
# ignore None values
plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
# ignore None values - should work on Python2.3
dict = {}
for k in kwargs:
if kwargs[k] is not None:
dict[k] = kwargs[k]
plpy.error(**dict)
$$ LANGUAGE plpythonu;
SELECT raise_exception('hello', 'world');
ERROR: plpy.Error: hello
DETAIL: world
CONTEXT: Traceback (most recent call last):
PL/Python function "raise_exception", line
6
, in <module>
plpy.error(**dict
((k, v) for k, v in iter(kwargs.items()) if v)
)
PL/Python function "raise_exception", line
10
, in <module>
plpy.error(**dict)
PL/Python function "raise_exception"
SELECT raise_exception('message text', 'detail text', _sqlstate => 'YY333');
ERROR: plpy.Error: message text
DETAIL: detail text
CONTEXT: Traceback (most recent call last):
PL/Python function "raise_exception", line
6
, in <module>
plpy.error(**dict
((k, v) for k, v in iter(kwargs.items()) if v)
)
PL/Python function "raise_exception", line
10
, in <module>
plpy.error(**dict)
PL/Python function "raise_exception"
SELECT raise_exception(_message => 'message text',
_detail => 'detail text',
...
...
@@ -180,8 +184,8 @@ ERROR: plpy.Error: message text
DETAIL: detail text
HINT: hint text
CONTEXT: Traceback (most recent call last):
PL/Python function "raise_exception", line
6
, in <module>
plpy.error(**dict
((k, v) for k, v in iter(kwargs.items()) if v)
)
PL/Python function "raise_exception", line
10
, in <module>
plpy.error(**dict)
PL/Python function "raise_exception"
SELECT raise_exception(_message => 'message text',
_hint => 'hint text',
...
...
@@ -191,8 +195,8 @@ SELECT raise_exception(_message => 'message text',
ERROR: plpy.Error: message text
HINT: hint text
CONTEXT: Traceback (most recent call last):
PL/Python function "raise_exception", line
6
, in <module>
plpy.error(**dict
((k, v) for k, v in iter(kwargs.items()) if v)
)
PL/Python function "raise_exception", line
10
, in <module>
plpy.error(**dict)
PL/Python function "raise_exception"
DO $$
DECLARE
...
...
src/pl/plpython/sql/plpython_test.sql
View file @
c7a141a9
...
...
@@ -102,8 +102,12 @@ RETURNS void AS $$
kwargs
=
{
"message"
:
_message
,
"detail"
:
_detail
,
"hint"
:
_hint
,
"sqlstate"
:
_sqlstate
,
"schema"
:
_schema
,
"table"
:
_table
,
"column"
:
_column
,
"datatype"
:
_datatype
,
"constraint"
:
_constraint
}
#
ignore
None
values
plpy
.
error
(
**
dict
((
k
,
v
)
for
k
,
v
in
iter
(
kwargs
.
items
())
if
v
))
#
ignore
None
values
-
should
work
on
Python2
.
3
dict
=
{}
for
k
in
kwargs
:
if
kwargs
[
k
]
is
not
None
:
dict
[
k
]
=
kwargs
[
k
]
plpy
.
error
(
**
dict
)
$$
LANGUAGE
plpythonu
;
SELECT
raise_exception
(
'hello'
,
'world'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment