@@ -9,11 +9,11 @@ plpy.info('This is message text.',
9
9
detail = 'This is detail text',
10
10
hint = 'This is hint text.',
11
11
sqlstate = 'XX000',
12
- schema = 'any info about schema',
13
- table = 'any info about table',
14
- column = 'any info about column',
15
- datatype = 'any info about datatype',
16
- constraint = 'any info about constraint')
12
+ schema_name = 'any info about schema',
13
+ table_name = 'any info about table',
14
+ column_name = 'any info about column',
15
+ datatype_name = 'any info about datatype',
16
+ constraint_name = 'any info about constraint')
17
17
plpy.notice('notice', detail = 'some detail')
18
18
plpy.warning('warning', detail = 'some detail')
19
19
plpy.error('stop on error', detail = 'some detail', hint = 'some hint')
@@ -70,12 +70,12 @@ CONTEXT: PL/Python anonymous code block
70
70
-- raise exception in python, handle exception in plgsql
71
71
CREATE OR REPLACE FUNCTION raise_exception(_message text, _detail text DEFAULT NULL, _hint text DEFAULT NULL,
72
72
_sqlstate text DEFAULT NULL,
73
- _schema text DEFAULT NULL, _table text DEFAULT NULL, _column text DEFAULT NULL,
74
- _datatype text DEFAULT NULL, _constraint text DEFAULT NULL)
73
+ _schema_name text DEFAULT NULL, _table_name text DEFAULT NULL, _column_name text DEFAULT NULL,
74
+ _datatype_name text DEFAULT NULL, _constraint_name text DEFAULT NULL)
75
75
RETURNS void AS $$
76
76
kwargs = { "message":_message, "detail":_detail, "hint":_hint,
77
- "sqlstate":_sqlstate, "schema":_schema , "table":_table ,
78
- "column":_column , "datatype":_datatype , "constraint":_constraint }
77
+ "sqlstate":_sqlstate, "schema_name":_schema_name , "table_name":_table_name ,
78
+ "column_name":_column_name , "datatype_name":_datatype_name , "constraint_name":_constraint_name }
79
79
# ignore None values - should work on Python2.3
80
80
dict = {}
81
81
for k in kwargs:
@@ -101,11 +101,11 @@ SELECT raise_exception(_message => 'message text',
101
101
_detail => 'detail text',
102
102
_hint => 'hint text',
103
103
_sqlstate => 'XX555',
104
- _schema => 'schema text',
105
- _table => 'table text',
106
- _column => 'column text',
107
- _datatype => 'datatype text',
108
- _constraint => 'constraint text');
104
+ _schema_name => 'schema text',
105
+ _table_name => 'table text',
106
+ _column_name => 'column text',
107
+ _datatype_name => 'datatype text',
108
+ _constraint_name => 'constraint text');
109
109
ERROR: plpy.Error: message text
110
110
DETAIL: detail text
111
111
HINT: hint text
@@ -115,9 +115,9 @@ CONTEXT: Traceback (most recent call last):
115
115
PL/Python function "raise_exception"
116
116
SELECT raise_exception(_message => 'message text',
117
117
_hint => 'hint text',
118
- _schema => 'schema text',
119
- _column => 'column text',
120
- _constraint => 'constraint text');
118
+ _schema_name => 'schema text',
119
+ _column_name => 'column text',
120
+ _constraint_name => 'constraint text');
121
121
ERROR: plpy.Error: message text
122
122
HINT: hint text
123
123
CONTEXT: Traceback (most recent call last):
@@ -133,19 +133,19 @@ DECLARE
133
133
__schema_name text;
134
134
__table_name text;
135
135
__column_name text;
136
- __datatype text;
137
- __constraint text;
136
+ __datatype_name text;
137
+ __constraint_name text;
138
138
BEGIN
139
139
BEGIN
140
140
PERFORM raise_exception(_message => 'message text',
141
141
_detail => 'detail text',
142
142
_hint => 'hint text',
143
143
_sqlstate => 'XX555',
144
- _schema => 'schema text',
145
- _table => 'table text',
146
- _column => 'column text',
147
- _datatype => 'datatype text',
148
- _constraint => 'constraint text');
144
+ _schema_name => 'schema text',
145
+ _table_name => 'table text',
146
+ _column_name => 'column text',
147
+ _datatype_name => 'datatype text',
148
+ _constraint_name => 'constraint text');
149
149
EXCEPTION WHEN SQLSTATE 'XX555' THEN
150
150
GET STACKED DIAGNOSTICS __message = MESSAGE_TEXT,
151
151
__detail = PG_EXCEPTION_DETAIL,
@@ -154,24 +154,24 @@ BEGIN
154
154
__schema_name = SCHEMA_NAME,
155
155
__table_name = TABLE_NAME,
156
156
__column_name = COLUMN_NAME,
157
- __datatype = PG_DATATYPE_NAME,
158
- __constraint = CONSTRAINT_NAME;
157
+ __datatype_name = PG_DATATYPE_NAME,
158
+ __constraint_name = CONSTRAINT_NAME;
159
159
RAISE NOTICE 'handled exception'
160
160
USING DETAIL = format('message:(%s), detail:(%s), hint: (%s), sqlstate: (%s), '
161
- 'schema :(%s), table :(%s), column :(%s), datatype :(%s), constraint :(%s)',
161
+ 'schema_name :(%s), table_name :(%s), column_name :(%s), datatype_name :(%s), constraint_name :(%s)',
162
162
__message, __detail, __hint, __sqlstate, __schema_name,
163
- __table_name, __column_name, __datatype, __constraint );
163
+ __table_name, __column_name, __datatype_name, __constraint_name );
164
164
END;
165
165
END;
166
166
$$;
167
167
NOTICE: handled exception
168
- DETAIL: message:(plpy.Error: message text), detail:(detail text), hint: (hint text), sqlstate: (XX555), schema :(schema text), table :(table text), column :(column text), datatype :(datatype text), constraint :(constraint text)
168
+ DETAIL: message:(plpy.Error: message text), detail:(detail text), hint: (hint text), sqlstate: (XX555), schema_name :(schema text), table_name :(table text), column_name :(column text), datatype_name :(datatype text), constraint_name :(constraint text)
169
169
-- the displayed context is different between Python2 and Python3,
170
170
-- but that's not important for this test
171
171
\set SHOW_CONTEXT never
172
172
do $$
173
173
try:
174
- plpy.execute("select raise_exception(_message => 'my message', _sqlstate => 'XX987', _hint => 'some hint', _table => 'users_tab', _datatype => 'user_type')")
174
+ plpy.execute("select raise_exception(_message => 'my message', _sqlstate => 'XX987', _hint => 'some hint', _table_name => 'users_tab', _datatype_name => 'user_type')")
175
175
except Exception, e:
176
176
plpy.info(e.spidata)
177
177
raise e
@@ -181,11 +181,11 @@ ERROR: plpy.SPIError: plpy.Error: my message
181
181
HINT: some hint
182
182
do $$
183
183
try:
184
- plpy.error(message = 'my message', sqlstate = 'XX987', hint = 'some hint', table = 'users_tab', datatype = 'user_type')
184
+ plpy.error(message = 'my message', sqlstate = 'XX987', hint = 'some hint', table_name = 'users_tab', datatype_name = 'user_type')
185
185
except Exception, e:
186
- plpy.info('sqlstate: %s, hint: %s, tablename : %s, datatype : %s' % (e.sqlstate, e.hint, e.table_name, e.datatype_name))
186
+ plpy.info('sqlstate: %s, hint: %s, table_name : %s, datatype_name : %s' % (e.sqlstate, e.hint, e.table_name, e.datatype_name))
187
187
raise e
188
188
$$ LANGUAGE plpythonu;
189
- INFO: sqlstate: XX987, hint: some hint, tablename : users_tab, datatype : user_type
189
+ INFO: sqlstate: XX987, hint: some hint, table_name : users_tab, datatype_name : user_type
190
190
ERROR: plpy.Error: my message
191
191
HINT: some hint
0 commit comments