You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the plpgsql_check.mode = 'every_start' is not present in my config, this SQL works fine:
CREATETABLEttt (
id TEXT
);
CREATE OR REPLACEFUNCTIONf() RETURNS TEXTAS $$
DECLARE
v ttt%ROWTYPE;
BEGINv.id='hi';
RETURN v.id;
END $$ LANGUAGE plpgsql;
SELECT*FROM f():
But when that config line is present, the SQL gives the error:
ERROR: record "v" is not assigned to tuple structure
CONTEXT: PL/pgSQL function f() line 5 at assignment to field "id" of variable "v" declared on line 3
That error leads me to this comment in the plpgsql_check source:
Check that there is already a tuple in the record. We need that because records don't have any predefined field structure.
The documentation for RECORD certainly indicates that they "have no predefined structure", but for ROWTYPE it doesn't say that.
I am not a postgres/SQL pro-star, but I was under the impression that ROWTYPE does confer the structure of the table.
So... Am I wrong and my code is bad, or is plpgsql_check being overzealous in throwing an error for ROWTYPE?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
When the
plpgsql_check.mode = 'every_start'
is not present in my config, this SQL works fine:But when that config line is present, the SQL gives the error:
That error leads me to this comment in the plpgsql_check source:
The documentation for RECORD certainly indicates that they "have no predefined structure", but for ROWTYPE it doesn't say that.
I am not a postgres/SQL pro-star, but I was under the impression that ROWTYPE does confer the structure of the table.
So... Am I wrong and my code is bad, or is plpgsql_check being overzealous in throwing an error for ROWTYPE?
Beta Was this translation helpful? Give feedback.
All reactions