"too clever" when creating SQL functions

Поиск
Список
Период
Сортировка
От SZŰCS Gábor
Тема "too clever" when creating SQL functions
Дата
Msg-id 010d01c314c1$3ba30950$0a03a8c0@fejleszt2
обсуждение исходный текст
Ответы Re: "too clever" when creating SQL functions
Список pgsql-sql
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 ------------------------------



В списке pgsql-sql по дате отправления:

Предыдущее
От: Josh Berkus
Дата:
Сообщение: Re: index defragmentation
Следующее
От:
Дата:
Сообщение: Re: [GENERAL] PostgreSQL Qs