index 59063976b36dd3fa6377af2d47de5c70e3d381f0..03f7cdce8cd5fafdacfcc4d8c053eadd01c26ed7 100644 (file)
@@ -414,6 +414,7 @@ pl_block : decl_sect K_BEGIN proc_sect exception_sect K_END opt_label
new->cmd_type = PLPGSQL_STMT_BLOCK;
new->lineno = plpgsql_location_to_lineno(@2);
+ new->stmtid = ++plpgsql_curr_compile->nstatements;
new->label = 1ドル.label;
new->n_initvars = 1ドル.n_initvars;
new->initvarnos = 1ドル.initvarnos;
@@ -905,6 +906,7 @@ stmt_perform : K_PERFORM expr_until_semi
new = palloc0(sizeof(PLpgSQL_stmt_perform));
new->cmd_type = PLPGSQL_STMT_PERFORM;
new->lineno = plpgsql_location_to_lineno(@1);
+ new->stmtid = ++plpgsql_curr_compile->nstatements;
new->expr = 2ドル;
$$ = (PLpgSQL_stmt *)new;
new = palloc0(sizeof(PLpgSQL_stmt_call));
new->cmd_type = PLPGSQL_STMT_CALL;
new->lineno = plpgsql_location_to_lineno(@1);
+ new->stmtid = ++plpgsql_curr_compile->nstatements;
new->expr = read_sql_stmt("CALL ");
new->is_call = true;
new = palloc0(sizeof(PLpgSQL_stmt_call));
new->cmd_type = PLPGSQL_STMT_CALL;
new->lineno = plpgsql_location_to_lineno(@1);
+ new->stmtid = ++plpgsql_curr_compile->nstatements;
new->expr = read_sql_stmt("DO ");
new->is_call = false;
@@ -947,6 +951,7 @@ stmt_assign : assign_var assign_operator expr_until_semi
new = palloc0(sizeof(PLpgSQL_stmt_assign));
new->cmd_type = PLPGSQL_STMT_ASSIGN;
new->lineno = plpgsql_location_to_lineno(@1);
+ new->stmtid = ++plpgsql_curr_compile->nstatements;
new->varno = 1ドル->dno;
new->expr = 3ドル;
@@ -962,6 +967,7 @@ stmt_getdiag : K_GET getdiag_area_opt K_DIAGNOSTICS getdiag_list ';'
new = palloc0(sizeof(PLpgSQL_stmt_getdiag));
new->cmd_type = PLPGSQL_STMT_GETDIAG;
new->lineno = plpgsql_location_to_lineno(@1);
+ new->stmtid = ++plpgsql_curr_compile->nstatements;
new->is_stacked = 2ドル;
new->diag_items = 4ドル;
@@ -1149,6 +1155,7 @@ stmt_if : K_IF expr_until_then proc_sect stmt_elsifs stmt_else K_END K_IF ';'
new = palloc0(sizeof(PLpgSQL_stmt_if));
new->cmd_type = PLPGSQL_STMT_IF;
new->lineno = plpgsql_location_to_lineno(@1);
+ new->stmtid = ++plpgsql_curr_compile->nstatements;
new->cond = 2ドル;
new->then_body = 3ドル;
new->elsif_list = 4ドル;
new = palloc0(sizeof(PLpgSQL_stmt_loop));
new->cmd_type = PLPGSQL_STMT_LOOP;
new->lineno = plpgsql_location_to_lineno(@2);
+ new->stmtid = ++plpgsql_curr_compile->nstatements;
new->label = 1ドル;
new->body = 3ドル.stmts;
@@ -1270,6 +1278,7 @@ stmt_while : opt_loop_label K_WHILE expr_until_loop loop_body
new = palloc0(sizeof(PLpgSQL_stmt_while));
new->cmd_type = PLPGSQL_STMT_WHILE;
new->lineno = plpgsql_location_to_lineno(@2);
+ new->stmtid = ++plpgsql_curr_compile->nstatements;
new->label = 1ドル;
new->cond = 3ドル;
new->body = 4ドル.stmts;
@@ -1290,6 +1299,7 @@ stmt_for : opt_loop_label K_FOR for_control loop_body
new = (PLpgSQL_stmt_fori *) 3ドル;
new->lineno = plpgsql_location_to_lineno(@2);
+ new->stmtid = ++plpgsql_curr_compile->nstatements;
new->label = 1ドル;
new->body = 4ドル.stmts;
$$ = (PLpgSQL_stmt *) new;
@@ -1304,6 +1314,7 @@ stmt_for : opt_loop_label K_FOR for_control loop_body
/* forq is the common supertype of all three */
new = (PLpgSQL_stmt_forq *) 3ドル;
new->lineno = plpgsql_location_to_lineno(@2);
+ new->stmtid = ++plpgsql_curr_compile->nstatements;
new->label = 1ドル;
new->body = 4ドル.stmts;
$$ = (PLpgSQL_stmt *) new;
new = palloc0(sizeof(PLpgSQL_stmt_dynfors));
new->cmd_type = PLPGSQL_STMT_DYNFORS;
+ new->stmtid = ++plpgsql_curr_compile->nstatements;
if (1ドル.row)
{
new->var = (PLpgSQL_variable *) 1ドル.row;
new = (PLpgSQL_stmt_forc *) palloc0(sizeof(PLpgSQL_stmt_forc));
new->cmd_type = PLPGSQL_STMT_FORC;
+ new->stmtid = ++plpgsql_curr_compile->nstatements;
new->curvar = cursor->dno;
/* Should have had a single variable name */
new = palloc0(sizeof(PLpgSQL_stmt_fori));
new->cmd_type = PLPGSQL_STMT_FORI;
+ new->stmtid = ++plpgsql_curr_compile->nstatements;
new->var = fvar;
new->reverse = reverse;
new->lower = expr1;
new = palloc0(sizeof(PLpgSQL_stmt_fors));
new->cmd_type = PLPGSQL_STMT_FORS;
+ new->stmtid = ++plpgsql_curr_compile->nstatements;
if (1ドル.row)
{
new->var = (PLpgSQL_variable *) 1ドル.row;
@@ -1626,6 +1641,7 @@ stmt_foreach_a : opt_loop_label K_FOREACH for_variable foreach_slice K_IN K_ARRA
new = palloc0(sizeof(PLpgSQL_stmt_foreach_a));
new->cmd_type = PLPGSQL_STMT_FOREACH_A;
new->lineno = plpgsql_location_to_lineno(@2);
+ new->stmtid = ++plpgsql_curr_compile->nstatements;
new->label = 1ドル;
new->slice = 4ドル;
new->expr = 7ドル;
new = palloc0(sizeof(PLpgSQL_stmt_exit));
new->cmd_type = PLPGSQL_STMT_EXIT;
+ new->stmtid = ++plpgsql_curr_compile->nstatements;
new->is_exit = 1ドル;
new->lineno = plpgsql_location_to_lineno(@1);
new->label = 2ドル;
new->cmd_type = PLPGSQL_STMT_RAISE;
new->lineno = plpgsql_location_to_lineno(@1);
+ new->stmtid = ++plpgsql_curr_compile->nstatements;
new->elog_level = ERROR; /* default */
new->condname = NULL;
new->message = NULL;
new->cmd_type = PLPGSQL_STMT_ASSERT;
new->lineno = plpgsql_location_to_lineno(@1);
+ new->stmtid = ++plpgsql_curr_compile->nstatements;
new->cond = read_sql_expression2(',', ';',
", or ;",
new = palloc(sizeof(PLpgSQL_stmt_dynexecute));
new->cmd_type = PLPGSQL_STMT_DYNEXECUTE;
new->lineno = plpgsql_location_to_lineno(@1);
+ new->stmtid = ++plpgsql_curr_compile->nstatements;
new->query = expr;
new->into = false;
new->strict = false;
new = palloc0(sizeof(PLpgSQL_stmt_open));
new->cmd_type = PLPGSQL_STMT_OPEN;
new->lineno = plpgsql_location_to_lineno(@1);
+ new->stmtid = ++plpgsql_curr_compile->nstatements;
new->curvar = 2ドル->dno;
new->cursor_options = CURSOR_OPT_FAST_PLAN;
new = palloc(sizeof(PLpgSQL_stmt_close));
new->cmd_type = PLPGSQL_STMT_CLOSE;
new->lineno = plpgsql_location_to_lineno(@1);
+ new->stmtid = ++plpgsql_curr_compile->nstatements;
new->curvar = 2ドル->dno;
$$ = (PLpgSQL_stmt *)new;
new = palloc(sizeof(PLpgSQL_stmt_commit));
new->cmd_type = PLPGSQL_STMT_COMMIT;
new->lineno = plpgsql_location_to_lineno(@1);
+ new->stmtid = ++plpgsql_curr_compile->nstatements;
$$ = (PLpgSQL_stmt *)new;
}
new = palloc(sizeof(PLpgSQL_stmt_rollback));
new->cmd_type = PLPGSQL_STMT_ROLLBACK;
new->lineno = plpgsql_location_to_lineno(@1);
+ new->stmtid = ++plpgsql_curr_compile->nstatements;
$$ = (PLpgSQL_stmt *)new;
}
new = palloc0(sizeof(PLpgSQL_stmt_set));
new->cmd_type = PLPGSQL_STMT_SET;
new->lineno = plpgsql_location_to_lineno(@1);
+ new->stmtid = ++plpgsql_curr_compile->nstatements;
+
new->expr = read_sql_stmt("SET ");
$$ = (PLpgSQL_stmt *)new;
new = palloc0(sizeof(PLpgSQL_stmt_set));
new->cmd_type = PLPGSQL_STMT_SET;
new->lineno = plpgsql_location_to_lineno(@1);
+ new->stmtid = ++plpgsql_curr_compile->nstatements;
new->expr = read_sql_stmt("RESET ");
$$ = (PLpgSQL_stmt *)new;
execsql = palloc(sizeof(PLpgSQL_stmt_execsql));
execsql->cmd_type = PLPGSQL_STMT_EXECSQL;
execsql->lineno = plpgsql_location_to_lineno(location);
+ execsql->stmtid = ++plpgsql_curr_compile->nstatements;
execsql->sqlstmt = expr;
execsql->into = have_into;
execsql->strict = have_strict;
*/
fetch = (PLpgSQL_stmt_fetch *) palloc0(sizeof(PLpgSQL_stmt_fetch));
fetch->cmd_type = PLPGSQL_STMT_FETCH;
+ fetch->stmtid = ++plpgsql_curr_compile->nstatements;
/* set direction defaults: */
fetch->direction = FETCH_FORWARD;
fetch->how_many = 1;
new = palloc0(sizeof(PLpgSQL_stmt_return));
new->cmd_type = PLPGSQL_STMT_RETURN;
new->lineno = plpgsql_location_to_lineno(location);
+ new->stmtid = ++plpgsql_curr_compile->nstatements;
new->expr = NULL;
new->retvarno = -1;
new = palloc0(sizeof(PLpgSQL_stmt_return_next));
new->cmd_type = PLPGSQL_STMT_RETURN_NEXT;
new->lineno = plpgsql_location_to_lineno(location);
+ new->stmtid = ++plpgsql_curr_compile->nstatements;
new->expr = NULL;
new->retvarno = -1;
new = palloc0(sizeof(PLpgSQL_stmt_return_query));
new->cmd_type = PLPGSQL_STMT_RETURN_QUERY;
new->lineno = plpgsql_location_to_lineno(location);
+ new->stmtid = ++plpgsql_curr_compile->nstatements;
/* check for RETURN QUERY EXECUTE */
if ((tok = yylex()) != K_EXECUTE)
new = palloc(sizeof(PLpgSQL_stmt_case));
new->cmd_type = PLPGSQL_STMT_CASE;
new->lineno = plpgsql_location_to_lineno(location);
+ new->stmtid = ++plpgsql_curr_compile->nstatements;
new->t_expr = t_expr;
new->t_varno = 0;
new->case_when_list = case_when_list;
index a7118b8386101ece1177248bf122b63b2e4f877d..0a5fbfa9d689bb7c6cfc25b33b540bfa39db6465 100644 (file)
{
PLpgSQL_stmt_type cmd_type;
int lineno;
+
+ /*
+ * Unique statement ID in this function (starting at 1; 0 is invalid/not
+ * set). This can be used by a profiler as the index for an array of
+ * per-statement metrics.
+ */
+ unsigned int stmtid;
} PLpgSQL_stmt;
/*
{
PLpgSQL_stmt_type cmd_type;
int lineno;
+ unsigned int stmtid;
char *label;
List *body; /* List of statements */
int n_initvars; /* Length of initvarnos[] */
{
PLpgSQL_stmt_type cmd_type;
int lineno;
+ unsigned int stmtid;
int varno;
PLpgSQL_expr *expr;
} PLpgSQL_stmt_assign;
{
PLpgSQL_stmt_type cmd_type;
int lineno;
+ unsigned int stmtid;
PLpgSQL_expr *expr;
} PLpgSQL_stmt_perform;
{
PLpgSQL_stmt_type cmd_type;
int lineno;
+ unsigned int stmtid;
PLpgSQL_expr *expr;
bool is_call;
PLpgSQL_variable *target;
{
PLpgSQL_stmt_type cmd_type;
int lineno;
+ unsigned int stmtid;
} PLpgSQL_stmt_commit;
/*
{
PLpgSQL_stmt_type cmd_type;
int lineno;
+ unsigned int stmtid;
} PLpgSQL_stmt_rollback;
/*
{
PLpgSQL_stmt_type cmd_type;
int lineno;
+ unsigned int stmtid;
PLpgSQL_expr *expr;
} PLpgSQL_stmt_set;
{
PLpgSQL_stmt_type cmd_type;
int lineno;
+ unsigned int stmtid;
bool is_stacked; /* STACKED or CURRENT diagnostics area? */
List *diag_items; /* List of PLpgSQL_diag_item */
} PLpgSQL_stmt_getdiag;
{
PLpgSQL_stmt_type cmd_type;
int lineno;
+ unsigned int stmtid;
PLpgSQL_expr *cond; /* boolean expression for THEN */
List *then_body; /* List of statements */
List *elsif_list; /* List of PLpgSQL_if_elsif structs */
{
PLpgSQL_stmt_type cmd_type;
int lineno;
+ unsigned int stmtid;
PLpgSQL_expr *t_expr; /* test expression, or NULL if none */
int t_varno; /* var to store test expression value into */
List *case_when_list; /* List of PLpgSQL_case_when structs */
{
PLpgSQL_stmt_type cmd_type;
int lineno;
+ unsigned int stmtid;
char *label;
List *body; /* List of statements */
} PLpgSQL_stmt_loop;
{
PLpgSQL_stmt_type cmd_type;
int lineno;
+ unsigned int stmtid;
char *label;
PLpgSQL_expr *cond;
List *body; /* List of statements */
{
PLpgSQL_stmt_type cmd_type;
int lineno;
+ unsigned int stmtid;
char *label;
PLpgSQL_var *var;
PLpgSQL_expr *lower;
{
PLpgSQL_stmt_type cmd_type;
int lineno;
+ unsigned int stmtid;
char *label;
PLpgSQL_variable *var; /* Loop variable (record or row) */
List *body; /* List of statements */
{
PLpgSQL_stmt_type cmd_type;
int lineno;
+ unsigned int stmtid;
char *label;
PLpgSQL_variable *var; /* Loop variable (record or row) */
List *body; /* List of statements */
{
PLpgSQL_stmt_type cmd_type;
int lineno;
+ unsigned int stmtid;
char *label;
PLpgSQL_variable *var; /* Loop variable (record or row) */
List *body; /* List of statements */
{
PLpgSQL_stmt_type cmd_type;
int lineno;
+ unsigned int stmtid;
char *label;
PLpgSQL_variable *var; /* Loop variable (record or row) */
List *body; /* List of statements */
{
PLpgSQL_stmt_type cmd_type;
int lineno;
+ unsigned int stmtid;
char *label;
int varno; /* loop target variable */
int slice; /* slice dimension, or 0 */
{
PLpgSQL_stmt_type cmd_type;
int lineno;
+ unsigned int stmtid;
int curvar;
int cursor_options;
PLpgSQL_expr *argquery;
{
PLpgSQL_stmt_type cmd_type;
int lineno;
+ unsigned int stmtid;
PLpgSQL_variable *target; /* target (record or row) */
int curvar; /* cursor variable to fetch from */
FetchDirection direction; /* fetch direction */
{
PLpgSQL_stmt_type cmd_type;
int lineno;
+ unsigned int stmtid;
int curvar;
} PLpgSQL_stmt_close;
{
PLpgSQL_stmt_type cmd_type;
int lineno;
+ unsigned int stmtid;
bool is_exit; /* Is this an exit or a continue? */
char *label; /* NULL if it's an unlabelled EXIT/CONTINUE */
PLpgSQL_expr *cond;
{
PLpgSQL_stmt_type cmd_type;
int lineno;
+ unsigned int stmtid;
PLpgSQL_expr *expr;
int retvarno;
} PLpgSQL_stmt_return;
{
PLpgSQL_stmt_type cmd_type;
int lineno;
+ unsigned int stmtid;
PLpgSQL_expr *expr;
int retvarno;
} PLpgSQL_stmt_return_next;
@@ -814,6 +845,7 @@ typedef struct PLpgSQL_stmt_return_query
{
PLpgSQL_stmt_type cmd_type;
int lineno;
+ unsigned int stmtid;
PLpgSQL_expr *query; /* if static query */
PLpgSQL_expr *dynquery; /* if dynamic query (RETURN QUERY EXECUTE) */
List *params; /* USING arguments for dynamic query */
{
PLpgSQL_stmt_type cmd_type;
int lineno;
+ unsigned int stmtid;
int elog_level;
char *condname; /* condition name, SQLSTATE, or NULL */
char *message; /* old-style message format literal, or NULL */
{
PLpgSQL_stmt_type cmd_type;
int lineno;
+ unsigned int stmtid;
PLpgSQL_expr *cond;
PLpgSQL_expr *message;
} PLpgSQL_stmt_assert;
{
PLpgSQL_stmt_type cmd_type;
int lineno;
+ unsigned int stmtid;
PLpgSQL_expr *sqlstmt;
bool mod_stmt; /* is the stmt INSERT/UPDATE/DELETE? Note:
* mod_stmt is set when we plan the query */
{
PLpgSQL_stmt_type cmd_type;
int lineno;
+ unsigned int stmtid;
PLpgSQL_expr *query; /* string expression */
bool into; /* INTO supplied? */
bool strict; /* INTO STRICT flag */
int extra_warnings;
int extra_errors;
+ /* count of statements inside function */
+ unsigned int nstatements;
+
/* the datums representing the function's local variables */
int ndatums;
PLpgSQL_datum **datums;