Search Postgresql Archives

Resolution for "ERROR: cannot handle whole-row reference" ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hopefully I'm being blind and missing something obvious. Here's the scenario:

-- I have a large table/view with a large-ish number of columns (routinely
-- more than 32 cols) and need to pass every col through to a function, and
-- am not inclined to recompile with INDEX_MAX_KEYS/FUNC_MAX_ARGS set
-- to 64 unless I *absolutely* have to, and even then, I don't want to impose
-- an arbitrary limitation that I should be able to get around with the RECORD
-- type... "in theory."
CREATE TABLE t1 (c1 int, c2 int, c3 int, c4 int, c5 int, c6 int, c7 int, c8 int, c9 int, c10 int, c11 int, c12 int, c13 int, c14 int, c15 int, c16 int, c17 int, c18 int, c19 int, c20 int, c21 int, c22 int, c23 int, c24 int, c25 int, c26 int, c27 int, c28 int, c29 int, c30 int, c31 int, c32 int, c33 int, c34 int, c35 int, c36 int, c37 int);


CREATE FUNCTION f1(RECORD) RETURNS BOOL LANGUAGE 'plpgsql' AS 'BEGIN RETURN TRUE; END;';

CREATE RULE t1_ins AS ON INSERT TO t1 DO INSTEAD SELECT f1(NEW);
ERROR: function f1(t1) does not exist
HINT: No function matches the given name and argument types. You may need to add explicit type casts.


-- You can't cast NEW to a RECORD type and there's no member of the NEW/OLD
-- pseudorelation that'll return a RECORD, so, instead, let me try a whole row
-- as the argument:
CREATE FUNCTION f1(t1) RETURNS BOOL LANGUAGE 'plpgsql' AS 'BEGIN RETURN TRUE; END;';
CREATE RULE r_ins AS ON INSERT TO t1 DO INSTEAD SELECT f1(NEW);


INSERT INTO t1 (c1) VALUES (1);
ERROR:  cannot handle whole-row reference


Doh! Am I missing a different way of handling this in a flexible/scalable way? The comment in src/backend/rewrite/rewriteManip.c:886 leads me to believe that this is a limitation. I'd use a trigger, but t1 is actually a VIEW that I'm trying to intercept commands to with RULEs. Any guidance in handling this case is greatly appreciated. -sc


--
Sean Chittenden


---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives?

http://archives.postgresql.org

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux