pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: andrey_shvidky@hotmail.com
To: pgsql-bugs@postgresql.org
Cc: andrey_shvidky@hotmail.com
Subject: BUG #14861: Handle syntax_error
Date: Wed, 18 Oct 2017 15:32:20 +0000
Message-ID: <20171018153220.8201.15631@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

The following bug has been logged on the website:

Bug reference:      14861
Logged by:          Andrey Shvidky
Email address:      andrey_shvidky@hotmail.com
PostgreSQL version: 9.6.5
Operating system:   Windows 7 x64
Description:        

/*
Faced with such a unfairness.
I have a do block or function with error handling block.
In case when error type is 42601 (syntax_error) I can't get correct error
context.
The error context contains information about do block or function itself,
but not about last executed instruction.
In the folowing example, if I remove error handling I will happily have such
a message:

ERROR: subquery must return only one column
LINE 1: SELECT (select id, val1 from aaa)
 
But in case when error handling presents I have only sad:

message_text = subquery must return only one column
pg_exception_context = PL/pgSQL function inline_code_block line 9 at
assignment
pg_exception_detail =

Where information about "SELECT (select id, val1 from aaa)" hided?
 
Repro script:
*/

create temp table aaa (id int, val1 text);

do language plpgsql $$
declare
	error_message			text;
	error_detailed_message	text;
	error_context			text;
	arr_test				aaa[];
begin
	--arr_test = (select row(id, val1) from aaa);		-- No error, correct call
	arr_test = (select id, val1 from aaa);			-- Error 42601 syntax_error 
exception
	--when syntax_error then
	when others then
		get stacked diagnostics
			error_message = message_text
            ,error_context = pg_exception_context
			,error_detailed_message = pg_exception_detail;

		raise notice 'message_text = %', error_message;
		raise notice 'pg_exception_context = %', error_context;
        raise notice 'pg_exception_detail = %', error_detailed_message;
end
$$;

drop table if exists aaa;


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs


view thread (2+ messages)  latest in thread

Message-ID: <20171018153220.8201.15631@wrigleys.postgresql.org>
Permalink:  ../20171018153220.8201.15631@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/20171018153220.8201.15631@wrigleys.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: andrey_shvidky@hotmail.com
  Subject: Re: BUG #14861: Handle syntax_error
  In-Reply-To: <20171018153220.8201.15631@wrigleys.postgresql.org>
  References: <20171018153220.8201.15631@wrigleys.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox