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

Commit5106bdc

Browse files
committed
Use errcontext mechanism in PL/Python
Error messages from PL/Python now always mention the function name in theCONTEXT: field. This also obsoletes the few places that tried to do thesame manually.Regression test files are updated to work with Python 2.4-2.6. I don't haveaccess to older versions right now.
1 parent888d333 commit5106bdc

File tree

5 files changed

+128
-62
lines changed

5 files changed

+128
-62
lines changed

‎src/pl/plpython/expected/plpython_error.out

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@
22
-- the trigger handler once. the errors and subsequent core dump were
33
-- interesting.
44
SELECT invalid_type_uncaught('rick');
5-
WARNING: PL/Python:in PL/Python function "invalid_type_uncaught"
6-
DETAIL:plpy.SPIError: unrecognized error in PLy_spi_prepare
5+
WARNING: PL/Python:plpy.SPIError: unrecognized error in PLy_spi_prepare
6+
CONTEXT:PL/Python function "invalid_type_uncaught"
77
ERROR: type "test" does not exist
8+
CONTEXT: PL/Python function "invalid_type_uncaught"
89
SELECT invalid_type_caught('rick');
9-
WARNING: PL/Python:in PL/Python function "invalid_type_caught"
10-
DETAIL:plpy.SPIError: unrecognized error in PLy_spi_prepare
10+
WARNING: PL/Python:plpy.SPIError: unrecognized error in PLy_spi_prepare
11+
CONTEXT:PL/Python function "invalid_type_caught"
1112
ERROR: type "test" does not exist
13+
CONTEXT: PL/Python function "invalid_type_caught"
1214
SELECT invalid_type_reraised('rick');
13-
WARNING: PL/Python:in PL/Python function "invalid_type_reraised"
14-
DETAIL:plpy.SPIError: unrecognized error in PLy_spi_prepare
15+
WARNING: PL/Python:plpy.SPIError: unrecognized error in PLy_spi_prepare
16+
CONTEXT:PL/Python function "invalid_type_reraised"
1517
ERROR: type "test" does not exist
18+
CONTEXT: PL/Python function "invalid_type_reraised"
1619
SELECT valid_type('rick');
1720
valid_type
1821
------------
@@ -23,16 +26,20 @@ SELECT valid_type('rick');
2326
-- Test Unicode error handling.
2427
--
2528
SELECT unicode_return_error();
26-
ERROR: PL/Python: could not create string representation of Python object in PL/Python function "unicode_return_error" while creating return value
29+
ERROR: PL/Python: could not create string representation of Python object, while creating return value
2730
DETAIL: exceptions.UnicodeEncodeError: 'ascii' codec can't encode character u'\x80' in position 0: ordinal not in range(128)
31+
CONTEXT: PL/Python function "unicode_return_error"
2832
INSERT INTO unicode_test (testvalue) VALUES ('test');
29-
ERROR: PL/Python: could not compute string representation of Python object in PL/Python function "unicode_trigger_error" while modifying trigger row
33+
ERROR: PL/Python: could not compute string representation of Python object, while modifying trigger row
3034
DETAIL: exceptions.UnicodeEncodeError: 'ascii' codec can't encode character u'\x80' in position 0: ordinal not in range(128)
35+
CONTEXT: PL/Python function "unicode_trigger_error"
3136
SELECT unicode_plan_error1();
32-
WARNING: PL/Python:in PL/Python function "unicode_plan_error1"
33-
DETAIL:plpy.Error: unrecognized error in PLy_spi_execute_plan
34-
ERROR: PL/Python:PL/Python function "unicode_plan_error1"could not execute plan
37+
WARNING: PL/Python:plpy.Error: unrecognized error in PLy_spi_execute_plan
38+
CONTEXT:PL/Python function "unicode_plan_error1"
39+
ERROR: PL/Python: could not execute plan
3540
DETAIL: exceptions.UnicodeEncodeError: 'ascii' codec can't encode character u'\x80' in position 0: ordinal not in range(128)
41+
CONTEXT: PL/Python function "unicode_plan_error1"
3642
SELECT unicode_plan_error2();
37-
ERROR: PL/Python:PL/Python function "unicode_plan_error2"could not execute plan
43+
ERROR: PL/Python: could not execute plan
3844
DETAIL: exceptions.UnicodeEncodeError: 'ascii' codec can't encode character u'\x80' in position 0: ordinal not in range(128)
45+
CONTEXT: PL/Python function "unicode_plan_error2"

‎src/pl/plpython/expected/plpython_error_3.out

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@
22
-- the trigger handler once. the errors and subsequent core dump were
33
-- interesting.
44
SELECT invalid_type_uncaught('rick');
5-
WARNING: PL/Python:in PL/Python function "invalid_type_uncaught"
6-
DETAIL:<class 'plpy.SPIError'>: unrecognized error in PLy_spi_prepare
5+
WARNING: PL/Python:<class 'plpy.SPIError'>: unrecognized error in PLy_spi_prepare
6+
CONTEXT:PL/Python function "invalid_type_uncaught"
77
ERROR: type "test" does not exist
8+
CONTEXT: PL/Python function "invalid_type_uncaught"
89
SELECT invalid_type_caught('rick');
9-
WARNING: PL/Python:in PL/Python function "invalid_type_caught"
10-
DETAIL:<class 'plpy.SPIError'>: unrecognized error in PLy_spi_prepare
10+
WARNING: PL/Python:<class 'plpy.SPIError'>: unrecognized error in PLy_spi_prepare
11+
CONTEXT:PL/Python function "invalid_type_caught"
1112
ERROR: type "test" does not exist
13+
CONTEXT: PL/Python function "invalid_type_caught"
1214
SELECT invalid_type_reraised('rick');
13-
WARNING: PL/Python:in PL/Python function "invalid_type_reraised"
14-
DETAIL:<class 'plpy.SPIError'>: unrecognized error in PLy_spi_prepare
15+
WARNING: PL/Python:<class 'plpy.SPIError'>: unrecognized error in PLy_spi_prepare
16+
CONTEXT:PL/Python function "invalid_type_reraised"
1517
ERROR: type "test" does not exist
18+
CONTEXT: PL/Python function "invalid_type_reraised"
1619
SELECT valid_type('rick');
1720
valid_type
1821
------------
@@ -23,16 +26,20 @@ SELECT valid_type('rick');
2326
-- Test Unicode error handling.
2427
--
2528
SELECT unicode_return_error();
26-
ERROR: PL/Python: could not create string representation of Python object in PL/Python function "unicode_return_error" while creating return value
29+
ERROR: PL/Python: could not create string representation of Python object, while creating return value
2730
DETAIL: <type 'exceptions.UnicodeEncodeError'>: 'ascii' codec can't encode character u'\x80' in position 0: ordinal not in range(128)
31+
CONTEXT: PL/Python function "unicode_return_error"
2832
INSERT INTO unicode_test (testvalue) VALUES ('test');
29-
ERROR: PL/Python: could not compute string representation of Python object in PL/Python function "unicode_trigger_error" while modifying trigger row
33+
ERROR: PL/Python: could not compute string representation of Python object, while modifying trigger row
3034
DETAIL: <type 'exceptions.UnicodeEncodeError'>: 'ascii' codec can't encode character u'\x80' in position 0: ordinal not in range(128)
35+
CONTEXT: PL/Python function "unicode_trigger_error"
3136
SELECT unicode_plan_error1();
32-
WARNING: PL/Python:in PL/Python function "unicode_plan_error1"
33-
DETAIL:<class 'plpy.Error'>: unrecognized error in PLy_spi_execute_plan
34-
ERROR: PL/Python:PL/Python function "unicode_plan_error1"could not execute plan
37+
WARNING: PL/Python:<class 'plpy.Error'>: unrecognized error in PLy_spi_execute_plan
38+
CONTEXT:PL/Python function "unicode_plan_error1"
39+
ERROR: PL/Python: could not execute plan
3540
DETAIL: <type 'exceptions.UnicodeEncodeError'>: 'ascii' codec can't encode character u'\x80' in position 0: ordinal not in range(128)
41+
CONTEXT: PL/Python function "unicode_plan_error1"
3642
SELECT unicode_plan_error2();
37-
ERROR: PL/Python:PL/Python function "unicode_plan_error2"could not execute plan
43+
ERROR: PL/Python: could not execute plan
3844
DETAIL: <type 'exceptions.UnicodeEncodeError'>: 'ascii' codec can't encode character u'\x80' in position 0: ordinal not in range(128)
45+
CONTEXT: PL/Python function "unicode_plan_error2"

‎src/pl/plpython/expected/plpython_function.out

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,37 +136,67 @@ BEFORE INSERT OR UPDATE OR DELETE ON trigger_test
136136
FOR EACH ROW EXECUTE PROCEDURE trigger_data(23,'skidoo');
137137
insert into trigger_test values(1,'insert');
138138
NOTICE: ("TD[args] => ['23', 'skidoo']",)
139+
CONTEXT: PL/Python function "trigger_data"
139140
NOTICE: ('TD[event] => INSERT',)
141+
CONTEXT: PL/Python function "trigger_data"
140142
NOTICE: ('TD[level] => ROW',)
143+
CONTEXT: PL/Python function "trigger_data"
141144
NOTICE: ('TD[name] => show_trigger_data_trig',)
145+
CONTEXT: PL/Python function "trigger_data"
142146
NOTICE: ("TD[new] => {'i': 1, 'v': 'insert'}",)
147+
CONTEXT: PL/Python function "trigger_data"
143148
NOTICE: ('TD[old] => None',)
149+
CONTEXT: PL/Python function "trigger_data"
144150
NOTICE: ('TD[relid] => bogus:12345',)
151+
CONTEXT: PL/Python function "trigger_data"
145152
NOTICE: ('TD[table_name] => trigger_test',)
153+
CONTEXT: PL/Python function "trigger_data"
146154
NOTICE: ('TD[table_schema] => public',)
155+
CONTEXT: PL/Python function "trigger_data"
147156
NOTICE: ('TD[when] => BEFORE',)
157+
CONTEXT: PL/Python function "trigger_data"
148158
update trigger_test set v = 'update' where i = 1;
149159
NOTICE: ("TD[args] => ['23', 'skidoo']",)
160+
CONTEXT: PL/Python function "trigger_data"
150161
NOTICE: ('TD[event] => UPDATE',)
162+
CONTEXT: PL/Python function "trigger_data"
151163
NOTICE: ('TD[level] => ROW',)
164+
CONTEXT: PL/Python function "trigger_data"
152165
NOTICE: ('TD[name] => show_trigger_data_trig',)
166+
CONTEXT: PL/Python function "trigger_data"
153167
NOTICE: ("TD[new] => {'i': 1, 'v': 'update'}",)
168+
CONTEXT: PL/Python function "trigger_data"
154169
NOTICE: ("TD[old] => {'i': 1, 'v': 'insert'}",)
170+
CONTEXT: PL/Python function "trigger_data"
155171
NOTICE: ('TD[relid] => bogus:12345',)
172+
CONTEXT: PL/Python function "trigger_data"
156173
NOTICE: ('TD[table_name] => trigger_test',)
174+
CONTEXT: PL/Python function "trigger_data"
157175
NOTICE: ('TD[table_schema] => public',)
176+
CONTEXT: PL/Python function "trigger_data"
158177
NOTICE: ('TD[when] => BEFORE',)
178+
CONTEXT: PL/Python function "trigger_data"
159179
delete from trigger_test;
160180
NOTICE: ("TD[args] => ['23', 'skidoo']",)
181+
CONTEXT: PL/Python function "trigger_data"
161182
NOTICE: ('TD[event] => DELETE',)
183+
CONTEXT: PL/Python function "trigger_data"
162184
NOTICE: ('TD[level] => ROW',)
185+
CONTEXT: PL/Python function "trigger_data"
163186
NOTICE: ('TD[name] => show_trigger_data_trig',)
187+
CONTEXT: PL/Python function "trigger_data"
164188
NOTICE: ('TD[new] => None',)
189+
CONTEXT: PL/Python function "trigger_data"
165190
NOTICE: ("TD[old] => {'i': 1, 'v': 'update'}",)
191+
CONTEXT: PL/Python function "trigger_data"
166192
NOTICE: ('TD[relid] => bogus:12345',)
193+
CONTEXT: PL/Python function "trigger_data"
167194
NOTICE: ('TD[table_name] => trigger_test',)
195+
CONTEXT: PL/Python function "trigger_data"
168196
NOTICE: ('TD[table_schema] => public',)
197+
CONTEXT: PL/Python function "trigger_data"
169198
NOTICE: ('TD[when] => BEFORE',)
199+
CONTEXT: PL/Python function "trigger_data"
170200

171201
DROP TRIGGER show_trigger_data_trig on trigger_test;
172202

‎src/pl/plpython/expected/plpython_test.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ SELECT global_test_two();
3838
--
3939
SELECT import_fail();
4040
NOTICE: ('import socket failed -- No module named foosocket',)
41+
CONTEXT: PL/Python function "import_fail"
4142
import_fail
4243
--------------------
4344
failed as expected
@@ -191,6 +192,7 @@ SELECT test_void_func1(), test_void_func1() IS NULL AS "is null";
191192

192193
SELECT test_void_func2(); -- should fail
193194
ERROR: PL/Python function with return type "void" did not return None
195+
CONTEXT: PL/Python function "test_void_func2"
194196
SELECT test_return_none(), test_return_none() IS NULL AS "is null";
195197
test_return_none | is null
196198
------------------+---------

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp