How to disable rules??
How to disable rules??
От:
friedrich nietzsche <nietzsche_psql@yahoo.it>
Дата:
hi all,
I'm looking for a way to temporary disable a rule on a
table.
I've find (looking at the dump) the way to disable
triggers :
UPDATE "pg_class" SET "reltriggers" = 0 WHERE
"relname" = ''table_name'';
***QUERY***;
UPDATE pg_class SET reltriggers = (SELECT count(*)
FROM pg_trigger where pg_class.oid = tgrelid) WHERE
relname = ''table_name'';
obviously this doesn't work for rules, anyone know how
can I do??
thanks,
by
danilo
______________________________________________________________________
Scarica il nuovo Yahoo! Messenger: con webcam, nuove faccine e tante altre novità.
http://it.yahoo.com/mail_it/foot/?http://it.messenger.yahoo.com/
Function problems, cache lookup failed
От:
Archibald Zimonyi <archie@netg.se>
Дата:
Hi there,
I have two tables that I want to join together as well as an aggregate
function that takes one of the columns and makes one string out of many
rows of info.
One part of the aggregate function (the one that puts two strings
together) has been re-written cause I have to get lower case words first
and upper case words last. I am new to the making functions
but that particular function works on its own. However when I try to run
an SQL query with the aggregate function I get the following error:
ERROR: fmgr_info: function 18308: cache lookup failed
I have no idea what this is, can anyone help me?
Thanks in advance,
Archie
The table info, aggregate function info and SQL statement are below:
// The superior column is used with the function column_to_upper to
// make the disciples upper case.
CREATE TABLE cards_disciplines
( card_id integer NOT NULL, discipline_id integer NOT NULL, superior boolean NOT NULL, separator char(1) NULL, FOREIGN KEY (card_id) REFERENCES cards, FOREIGN KEY (discipline_id) REFERENCES disciplines
);
CREATE TABLE disciplines
( discipline_id integer DEFAULT NEXTVAL('disciplines_seq'), discipline_abbr char(3) NOT NULL, discipline text NOT NULL, PRIMARY KEY(discipline_id)
);
CREATE FUNCTION column_to_upper(text, boolean) RETURNS text AS 'DECLARE discipline ALIAS FOR $1; superior ALIAS FOR $2; BEGIN IF superior THEN RETURN upper(discipline); END IF;
RETURN discipline; END;' LANGUAGE 'plpgsql';
CREATE AGGREGATE discipline_string
( SFUNC = discipline_concat, BASETYPE = text, STYPE = text, FINALFUNC = discipline_fix, INITCOND = ''
);
CREATE FUNCTION discipline_concat(text, text) RETURNS text AS 'DECLARE discipline_str text := ''''; add_str text := ''''; temp_str text := ''''; start_int integer := 0; end_int integer := 5; BEGIN IF $2 ~ ''[A-Z]'' THEN discipline_str := $1 || \' \' || $2; ELSE WHILE char_length(substr($1, start_int, end_int)) > 3 LOOP temp_str := substr($1, start_int, end_int);
IF temp_str ~ ''[A-Z]'' AND discipline_str = '''' THEN discipline_str := add_str || $2 || \' \' || temp_str; add_str := ''''; ELSE add_str := add_str || temp_str; END IF;
start_int := start_int + 5; END LOOP;
temp_str := substr($1, start_int, 3); discipline_str := discipline_str || add_str || temp_str; END IF;
RETURN discipline_str; END; ' LANGUAGE 'plpgsql';
CREATE FUNCTION discipline_fix(text) RETURNS text AS 'SELECT substring($1 from 3 for char_length($1)) AS RESULT' LANGUAGE 'sql';
THE SQL STATEMENT THAT FAILS:
SELECT card_id, discipline_string(column_to_upper(d.discipline_abbr,
cd.superior)) AS discipline
FROM cards_disciplines cd INNER JOIN disciplines d USING (discipline_id)
WHERE cd.discipline_id = d.discipline_id
GROUP BY card_id;
Re: Function problems, cache lookup failed
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Archibald Zimonyi writes: > ERROR: fmgr_info: function 18308: cache lookup failed > I have no idea what this is, can anyone help me? The aggregate links to the function by OID. You deleted the function and recreated it, which means it's a new function with a new OID and so the aggregate is broken. You'll need to drop and recreate the aggregate too. Next time use CREATE OR REPLACE FUNCTION so you don't need to do that. (With CREATE OR REPLACE, you are just modifying the existing function, so its OID doesn't change.) 7.3 will prevent this sort of mistake... regards, tom lane