@@ -9,11 +9,11 @@ plpy.info('This is message text.',
99 detail = 'This is detail text',
1010 hint = 'This is hint text.',
1111 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')
1717plpy.notice('notice', detail = 'some detail')
1818plpy.warning('warning', detail = 'some detail')
1919plpy.error('stop on error', detail = 'some detail', hint = 'some hint')
@@ -70,12 +70,12 @@ CONTEXT: PL/Python anonymous code block
7070-- raise exception in python, handle exception in plgsql
7171CREATE OR REPLACE FUNCTION raise_exception(_message text, _detail text DEFAULT NULL, _hint text DEFAULT NULL,
7272 _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)
7575RETURNS void AS $$
7676kwargs = { "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 }
7979# ignore None values - should work on Python2.3
8080dict = {}
8181for k in kwargs:
@@ -101,11 +101,11 @@ SELECT raise_exception(_message => 'message text',
101101 _detail => 'detail text',
102102 _hint => 'hint text',
103103 _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');
109109ERROR: plpy.Error: message text
110110DETAIL: detail text
111111HINT: hint text
@@ -115,9 +115,9 @@ CONTEXT: Traceback (most recent call last):
115115PL/Python function "raise_exception"
116116SELECT raise_exception(_message => 'message text',
117117 _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');
121121ERROR: plpy.Error: message text
122122HINT: hint text
123123CONTEXT: Traceback (most recent call last):
@@ -133,19 +133,19 @@ DECLARE
133133 __schema_name text;
134134 __table_name text;
135135 __column_name text;
136- __datatype text;
137- __constraint text;
136+ __datatype_name text;
137+ __constraint_name text;
138138BEGIN
139139 BEGIN
140140 PERFORM raise_exception(_message => 'message text',
141141 _detail => 'detail text',
142142 _hint => 'hint text',
143143 _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');
149149 EXCEPTION WHEN SQLSTATE 'XX555' THEN
150150 GET STACKED DIAGNOSTICS __message = MESSAGE_TEXT,
151151 __detail = PG_EXCEPTION_DETAIL,
@@ -154,24 +154,24 @@ BEGIN
154154 __schema_name = SCHEMA_NAME,
155155 __table_name = TABLE_NAME,
156156 __column_name = COLUMN_NAME,
157- __datatype = PG_DATATYPE_NAME,
158- __constraint = CONSTRAINT_NAME;
157+ __datatype_name = PG_DATATYPE_NAME,
158+ __constraint_name = CONSTRAINT_NAME;
159159 RAISE NOTICE 'handled exception'
160160 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)',
162162 __message, __detail, __hint, __sqlstate, __schema_name,
163- __table_name, __column_name, __datatype, __constraint );
163+ __table_name, __column_name, __datatype_name, __constraint_name );
164164 END;
165165END;
166166$$;
167167NOTICE: 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)
169169-- the displayed context is different between Python2 and Python3,
170170-- but that's not important for this test
171171\set SHOW_CONTEXT never
172172do $$
173173try:
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')")
175175except Exception, e:
176176 plpy.info(e.spidata)
177177 raise e
@@ -181,11 +181,11 @@ ERROR: plpy.SPIError: plpy.Error: my message
181181HINT: some hint
182182do $$
183183try:
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')
185185except 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))
187187 raise e
188188$$ 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
190190ERROR: plpy.Error: my message
191191HINT: some hint
0 commit comments