Re: Malformed Array Literal in PL/pgSQL Exception Block

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: "David E(dot) Wheeler" <david(at)justatheory(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Malformed Array Literal in PL/pgSQL Exception Block
Date: 2017-04-10 04:52:40
Message-ID: 87lgr8x3vp.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>>>>> "David" == David E Wheeler <david(at)justatheory(dot)com> writes:

David> And it works great, including in PL/pgSQL functions, except in
David> an exception block. When I run this:

David> BEGIN;

David> CREATE OR REPLACE FUNCTION foo(
David> ) RETURNS BOOLEAN IMMUTABLE LANGUAGE PLPGSQL AS $$
David> DECLARE
David> things TEXT[] := '{}';
David> BEGIN
David> things := things || 'foo';
David> RAISE division_by_zero;

This "raise" statement is not reached, because the previous line raises
the "malformed array literal" error.

David> EXCEPTION WHEN OTHERS THEN

If you change this to EXCEPTION WHEN division_by_zero THEN, the
reported error becomes:

ERROR: malformed array literal: "foo"
LINE 1: SELECT things || 'foo'

--
Andrew (irc:RhodiumToad)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David E. Wheeler 2017-04-10 04:53:42 Re: Malformed Array Literal in PL/pgSQL Exception Block
Previous Message Michael Paquier 2017-04-10 04:43:13 Re: [COMMITTERS] pgsql: Sync pg_dump and pg_dumpall output