X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3CEDF476501 for ; Wed, 7 May 2003 13:51:10 -0400 (EDT) Received: from mail.deltav.hu (mail.deltav.hu [213.163.0.192]) by postgresql.org (Postfix) with ESMTP id C7FE5476520 for ; Wed, 7 May 2003 13:51:08 -0400 (EDT) Received: from fejleszt2 ([213.163.10.103]) by mail.deltav.hu (Netscape Messaging Server 3.6) with SMTP id AAA4395 for ; Wed, 7 May 2003 19:51:07 +0200 Message-ID: <010d01c314c1$3ba30950$0a03a8c0@fejleszt2> From: "=?iso-8859-2?B?U1rbQ1MgR+Fib3I=?=" To: Subject: "too clever" when creating SQL functions Date: Wed, 7 May 2003 19:51:05 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Spam-Status: No, hits=-3.1 required=5.0 tests=BAYES_20 version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200305/141 X-Sequence-Number: 13306 Dear Gurus, Please show me to the archives, if you feel like. I have an ugly function that can't be defined as language SQL, because it gets parsed at define-time, not run-time. Any ideas, other than making it plpgsql? Even better, is there a more elegant way to turn off/on triggers on a (set of) table(s)? The function and what psql says is at the end of this message. G. -- while (!asleep()) sheep++; ---------------------------- cut here ------------------------------ bin=# CREATE OR REPLACE FUNCTION triggers_on(name) RETURNS int AS ' bin'# CREATE TEMP TABLE tr (tmp_relname name, tmp_reltriggers smallint); bin'# bin'# INSERT INTO tr bin'# SELECT C.relname, count(T.oid) bin'# FROM pg_class C, pg_trigger T bin'# WHERE C.oid = T.tgrelid AND C.relname ~* $1 bin'# GROUP BY 1; bin'# UPDATE pg_class SET reltriggers = TMP.tmp_reltriggers bin'# FROM tr TMP bin'# WHERE pg_class.relname = TMP.tmp_relname; bin'# bin'# DROP TABLE tr; bin'# SELECT 1; bin'# ' LANGUAGE 'SQL'; ERROR: Relation "tr" does not exist ---------------------------- cut here ------------------------------