The following bug has been logged online: Bug reference: 2539 Logged by: David Fetter Email address: [EMAIL PROTECTED] 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 ---------------------------(end of broadcast)--------------------------- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match