* procedural language
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/gram.y,v 1.48.2.4 2006/05/21 19:57:07 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/gram.y,v 1.48.2.5 2007/02/08 18:38:15 tgl Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
$$.label = $1;
$$.n_initvars = 0;
$$.initvarnos = NULL;
- plpgsql_add_initdatums(NULL);
}
| opt_label decl_start
{
$$.label = $1;
$$.n_initvars = 0;
$$.initvarnos = NULL;
- plpgsql_add_initdatums(NULL);
}
| opt_label decl_start decl_stmts
{
$$.label = $3;
else
$$.label = $1;
+ /* Remember variables declared in decl_stmts */
$$.n_initvars = plpgsql_add_initdatums(&($$.initvarnos));
}
;
decl_start : K_DECLARE
{
+ /* Forget any variables created before block */
+ plpgsql_add_initdatums(NULL);
+ /* Make variable names be local to block */
plpgsql_ns_setlocal(true);
}
;
plpgsql_ns_additem(PLPGSQL_NSTYPE_VAR, new->varno,
$1.name);
- plpgsql_add_initdatums(NULL);
-
$$ = new;
}
;
* procedural language
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.69 2003/09/30 00:59:51 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.69.2.1 2007/02/08 18:38:16 tgl Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
function->found_varno = var->varno;
/*
- * Forget about the above created variables
- */
- plpgsql_add_initdatums(NULL);
-
- /*
- * Now parse the functions text
+ * Now parse the function's text
*/
parse_rc = plpgsql_yyparse();
if (parse_rc != 0)
/* ----------
- * plpgsql_add_initdatums Put all datum entries created
- * since the last call into the
- * finishing code block so the
- * block knows which variables to
- * reinitialize when entered.
+ * plpgsql_add_initdatums Make an array of the datum numbers of
+ * all the simple VAR datums created since the last call
+ * to this function.
+ *
+ * If varnos is NULL, we just forget any datum entries created since the
+ * last call.
+ *
+ * This is used around a DECLARE section to create a list of the VARs
+ * that have to be initialized at block entry. Note that VARs can also
+ * be created elsewhere than DECLARE, eg by a FOR-loop, but it is then
+ * the responsibility of special-purpose code to initialize them.
* ----------
*/
int