         "harmonic_weights_set"  BOOLEAN,
         "closed_voting"         BOOLEAN );
 
+COMMENT ON TYPE "check_issue_persistence" IS 'Type of data returned by "check_issue" function, to be passed to subsequent calls of the same function';
+
+
 CREATE FUNCTION "check_issue"
   ( "issue_id_p" "issue"."id"%TYPE,
     "persist"    "check_issue_persistence" )
   RETURNS "check_issue_persistence"
   LANGUAGE 'plpgsql' VOLATILE AS $$
     DECLARE
-      "issue_row" "issue"%ROWTYPE;
-      "state_v"   "issue_state";
+      "issue_row"      "issue"%ROWTYPE;
+      "policy_row"     "policy"%ROWTYPE;
+      "initiative_row" "initiative"%ROWTYPE;
+      "state_v"        "issue_state";
     BEGIN
       PERFORM "require_transaction_isolation"();
       IF "persist" ISNULL THEN

      "weight_v"              INT4;
      "sub_weight_v"          INT4;
    BEGIN
      "weight_v" := 0;
      FOR "issue_delegation_row" IN
        SELECT * FROM "issue_delegation"

    END;
  $$;

COMMENT ON FUNCTION "check_everything"() IS 'Amongst other regular tasks this function performs "check_issue" for every open issue. Use this function only for development and debugging purposes, as you may run into locking and/or serialization problems in productive environments.';



