Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id B70E145232C for ; Wed, 4 Jan 2012 15:25:39 -0400 (AST) Received: from andy.depesz.com ([88.198.47.100] helo=depesz.com) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RiWSv-0001BM-Ls for pgsql-bugs@postgresql.org; Wed, 04 Jan 2012 19:25:39 +0000 Received: from andy.depesz.com ([88.198.47.100] helo=depesz.com) by depesz.com with esmtpa (Exim 4.77) (envelope-from ) id 1RiWSi-0002lg-F3; Wed, 04 Jan 2012 20:25:24 +0100 Date: Wed, 4 Jan 2012 20:25:24 +0100 From: hubert depesz lubaczewski To: pramsey@cleverelephant.ca Cc: pgsql-bugs@postgresql.org Subject: Re: BUG #6379: SQL Function Causes Back-end Crash Message-ID: <20120104192524.GA8370@depesz.com> Reply-To: depesz@depesz.com References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Pg-Spam-Score: -3.8 (---) X-Archive-Number: 201201/23 X-Sequence-Number: 32090 On Wed, Jan 04, 2012 at 07:17:17PM +0000, pramsey@cleverelephant.ca wrote: > The following bug has been logged on the website: > > Bug reference: 6379 > Logged by: Paul Ramsey > Email address: pramsey@cleverelephant.ca > PostgreSQL version: 9.1.2 > Operating system: OSX 10.6.8 > Description: > > CREATE OR REPLACE FUNCTION kill_backend() > RETURNS VOID > AS $$ > DROP TABLE if EXISTS foo; > CREATE TABLE foo AS SELECT * FROM pg_class LIMIT 1; > $$ LANGUAGE 'SQL'; Cannot replicate: (depesz@localhost:5910) 20:23:43 [depesz] $ CREATE OR REPLACE FUNCTION kill_backend() >> RETURNS VOID >> AS $$ >> DROP TABLE if EXISTS foo; >> CREATE TABLE foo AS SELECT * FROM pg_class LIMIT 1; >> $$ LANGUAGE 'SQL'; CREATE FUNCTION (depesz@localhost:5910) 20:23:49 [depesz] $ select kill_backend(); NOTICE: table "foo" does not exist, skipping CONTEXT: SQL function "kill_backend" statement 1 kill_backend -------------- [null] (1 row) (depesz@localhost:5910) 20:23:55 [depesz] $ select kill_backend(); kill_backend -------------- [null] (1 row) (depesz@localhost:5910) 20:23:56 [depesz] $ select kill_backend(); kill_backend -------------- [null] (1 row) (depesz@localhost:5910) 20:23:58 [depesz] $ select version(); version ------------------------------------------------------------------------------------------------------- PostgreSQL 9.1.2 on x86_64-unknown-linux-gnu, compiled by gcc-4.6.real (Debian 4.6.2-5) 4.6.2, 64-bit (1 row) Side note - definition as is, doesn't work on 9.2: $ CREATE OR REPLACE FUNCTION kill_backend() >> RETURNS VOID >> AS $$ >> DROP TABLE if EXISTS foo; >> CREATE TABLE foo AS SELECT * FROM pg_class LIMIT 1; >> $$ LANGUAGE 'SQL'; ERROR: language "SQL" does not exist changing it to proper sql (not uppercase) fixed this problem. Best regards, depesz -- The best thing about modern society is how easy it is to avoid contact with it. http://depesz.com/