pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: SZŰCS Gábor <surrano@mailbox.hu>
To: pgsql-sql@postgresql.org
Subject: "too clever" when creating SQL functions
Date: Wed, 7 May 2003 19:51:05 +0200
Message-ID: <010d01c314c1$3ba30950$0a03a8c0@fejleszt2> (raw)

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 ------------------------------




view thread (7+ messages)  latest in thread

Message-ID: <010d01c314c1$3ba30950$0a03a8c0@fejleszt2>
Permalink:  ../010d01c314c1$3ba30950$0a03a8c0@fejleszt2/
Also on:    postgresql.org/message-id/010d01c314c1$3ba30950$0a03a8c0@fejleszt2

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: surrano@mailbox.hu
  Subject: Re: "too clever" when creating SQL functions
  In-Reply-To: <010d01c314c1$3ba30950$0a03a8c0@fejleszt2>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox