Skip site navigation (1) Skip section navigation (2)

BUG #2539: PL/PgSQL doesn't disallow COPY commands on compile, even though it disallows them.

From: "David Fetter" <david(at)fetter(dot)org>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #2539: PL/PgSQL doesn't disallow COPY commands on compile, even though it disallows them.
Date: 2006-07-19 22:46:17
Message-ID: 200607192246.k6JMkHXc053871@wwwmaster.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-bugs
The following bug has been logged online:

Bug reference:      2539
Logged by:          David Fetter
Email address:      david(at)fetter(dot)org
PostgreSQL version: All
Operating system:   Linux and OSX that I've tested
Description:        PL/PgSQL doesn't disallow COPY commands on compile, even
though it disallows them.
Details: 

Here's a repro:

davidfetter=> SHOW check_function_bodies ;
 check_function_bodies 
-----------------------
 on
(1 row)

davidfetter=> CREATE OR REPLACE FUNCTION bad_func()
RETURNS VOID
LANGUAGE plpgsql
AS $$
BEGIN
    CREATE TEMPORARY TABLE bad(i INTEGER) ON COMMIT DROP;
    INSERT INTO bad
    SELECT s.i FROM generate_series(1,10) AS s(i);
    COPY bad TO stdout;
END;
$$;
CREATE FUNCTION
davidfetter=> select bad_func();
ERROR:  SPI_execute_plan failed executing query "COPY bad TO stdout":
SPI_ERROR_COPY
CONTEXT:  PL/pgSQL function "bad_func" line 5 at SQL statement

Responses

pgsql-bugs by date

Next:From: Tom LaneDate: 2006-07-19 23:02:15
Subject: Re: BUG #2539: PL/PgSQL doesn't disallow COPY commands on compile, even though it disallows them.
Previous:From: Marius ┼ŻalinauskasDate: 2006-07-19 19:26:45
Subject: Re: BUG #2535: Unicode on Windows: aogonek is not distinguished from agrave

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group