#include "plpgsql.h"
#include "utils/memutils.h"
Go to the source code of this file.
static void dump_assign | ( | PLpgSQL_stmt_assign * | stmt | ) | [static] |
Definition at line 878 of file pl_funcs.c.
References dump_expr(), dump_ind(), PLpgSQL_stmt_assign::expr, and PLpgSQL_stmt_assign::varno.
Referenced by dump_stmt().
static void dump_block | ( | PLpgSQL_stmt_block * | block | ) | [static] |
Definition at line 837 of file pl_funcs.c.
References PLpgSQL_exception::action, PLpgSQL_stmt_block::body, PLpgSQL_exception::conditions, PLpgSQL_condition::condname, dump_ind(), dump_stmts(), PLpgSQL_exception_block::exc_list, PLpgSQL_stmt_block::exceptions, PLpgSQL_stmt_block::label, lfirst, name, PLpgSQL_condition::next, and NULL.
Referenced by dump_stmt(), and plpgsql_dumptree().
{ char *name; if (block->label == NULL) name = "*unnamed*"; else name = block->label; dump_ind(); printf("BLOCK <<%s>>\n", name); dump_stmts(block->body); if (block->exceptions) { ListCell *e; foreach(e, block->exceptions->exc_list) { PLpgSQL_exception *exc = (PLpgSQL_exception *) lfirst(e); PLpgSQL_condition *cond; dump_ind(); printf(" EXCEPTION WHEN "); for (cond = exc->conditions; cond; cond = cond->next) { if (cond != exc->conditions) printf(" OR "); printf("%s", cond->condname); } printf(" THEN\n"); dump_stmts(exc->action); } } dump_ind(); printf(" END -- %s\n", name); }
static void dump_case | ( | PLpgSQL_stmt_case * | stmt | ) | [static] |
Definition at line 917 of file pl_funcs.c.
References PLpgSQL_stmt_case::case_when_list, dump_expr(), dump_ind(), dump_indent, dump_stmts(), PLpgSQL_stmt_case::else_stmts, PLpgSQL_case_when::expr, PLpgSQL_stmt_case::have_else, lfirst, PLpgSQL_case_when::stmts, PLpgSQL_stmt_case::t_expr, and PLpgSQL_stmt_case::t_varno.
Referenced by dump_stmt().
{ ListCell *l; dump_ind(); printf("CASE %d ", stmt->t_varno); if (stmt->t_expr) dump_expr(stmt->t_expr); printf("\n"); dump_indent += 6; foreach(l, stmt->case_when_list) { PLpgSQL_case_when *cwt = (PLpgSQL_case_when *) lfirst(l); dump_ind(); printf("WHEN "); dump_expr(cwt->expr); printf("\n"); dump_ind(); printf("THEN\n"); dump_indent += 2; dump_stmts(cwt->stmts); dump_indent -= 2; } if (stmt->have_else) { dump_ind(); printf("ELSE\n"); dump_indent += 2; dump_stmts(stmt->else_stmts); dump_indent -= 2; } dump_indent -= 6; dump_ind(); printf(" ENDCASE\n"); }
static void dump_close | ( | PLpgSQL_stmt_close * | stmt | ) | [static] |
Definition at line 1180 of file pl_funcs.c.
References PLpgSQL_stmt_close::curvar, and dump_ind().
Referenced by dump_stmt().
static void dump_cursor_direction | ( | PLpgSQL_stmt_fetch * | stmt | ) | [static] |
Definition at line 1146 of file pl_funcs.c.
References PLpgSQL_stmt_fetch::direction, dump_expr(), dump_ind(), dump_indent, PLpgSQL_stmt_fetch::expr, FETCH_ABSOLUTE, FETCH_BACKWARD, FETCH_FORWARD, FETCH_RELATIVE, and PLpgSQL_stmt_fetch::how_many.
Referenced by dump_fetch().
{ dump_indent += 2; dump_ind(); switch (stmt->direction) { case FETCH_FORWARD: printf(" FORWARD "); break; case FETCH_BACKWARD: printf(" BACKWARD "); break; case FETCH_ABSOLUTE: printf(" ABSOLUTE "); break; case FETCH_RELATIVE: printf(" RELATIVE "); break; default: printf("??? unknown cursor direction %d", stmt->direction); } if (stmt->expr) { dump_expr(stmt->expr); printf("\n"); } else printf("%ld\n", stmt->how_many); dump_indent -= 2; }
static void dump_dynexecute | ( | PLpgSQL_stmt_dynexecute * | stmt | ) | [static] |
Definition at line 1356 of file pl_funcs.c.
References PLpgSQL_row::dno, PLpgSQL_rec::dno, dump_expr(), dump_ind(), dump_indent, i, lfirst, NIL, NULL, PLpgSQL_stmt_dynexecute::params, PLpgSQL_stmt_dynexecute::query, PLpgSQL_stmt_dynexecute::rec, PLpgSQL_row::refname, PLpgSQL_rec::refname, PLpgSQL_stmt_dynexecute::row, and PLpgSQL_stmt_dynexecute::strict.
Referenced by dump_stmt().
{ dump_ind(); printf("EXECUTE "); dump_expr(stmt->query); printf("\n"); dump_indent += 2; if (stmt->rec != NULL) { dump_ind(); printf(" INTO%s target = %d %s\n", stmt->strict ? " STRICT" : "", stmt->rec->dno, stmt->rec->refname); } if (stmt->row != NULL) { dump_ind(); printf(" INTO%s target = %d %s\n", stmt->strict ? " STRICT" : "", stmt->row->dno, stmt->row->refname); } if (stmt->params != NIL) { ListCell *lc; int i; dump_ind(); printf(" USING\n"); dump_indent += 2; i = 1; foreach(lc, stmt->params) { dump_ind(); printf(" parameter %d: ", i++); dump_expr((PLpgSQL_expr *) lfirst(lc)); printf("\n"); } dump_indent -= 2; } dump_indent -= 2; }
static void dump_dynfors | ( | PLpgSQL_stmt_dynfors * | stmt | ) | [static] |
Definition at line 1400 of file pl_funcs.c.
References PLpgSQL_stmt_dynfors::body, dump_expr(), dump_ind(), dump_indent, dump_stmts(), i, lfirst, NIL, NULL, PLpgSQL_stmt_dynfors::params, PLpgSQL_stmt_dynfors::query, PLpgSQL_stmt_dynfors::rec, PLpgSQL_row::refname, PLpgSQL_rec::refname, and PLpgSQL_stmt_dynfors::row.
Referenced by dump_stmt().
{ dump_ind(); printf("FORS %s EXECUTE ", (stmt->rec != NULL) ? stmt->rec->refname : stmt->row->refname); dump_expr(stmt->query); printf("\n"); if (stmt->params != NIL) { ListCell *lc; int i; dump_indent += 2; dump_ind(); printf(" USING\n"); dump_indent += 2; i = 1; foreach(lc, stmt->params) { dump_ind(); printf(" parameter $%d: ", i++); dump_expr((PLpgSQL_expr *) lfirst(lc)); printf("\n"); } dump_indent -= 4; } dump_stmts(stmt->body); dump_ind(); printf(" ENDFORS\n"); }
static void dump_execsql | ( | PLpgSQL_stmt_execsql * | stmt | ) | [static] |
Definition at line 1330 of file pl_funcs.c.
References PLpgSQL_row::dno, PLpgSQL_rec::dno, dump_expr(), dump_ind(), dump_indent, NULL, PLpgSQL_stmt_execsql::rec, PLpgSQL_row::refname, PLpgSQL_rec::refname, PLpgSQL_stmt_execsql::row, PLpgSQL_stmt_execsql::sqlstmt, and PLpgSQL_stmt_execsql::strict.
Referenced by dump_stmt().
{ dump_ind(); printf("EXECSQL "); dump_expr(stmt->sqlstmt); printf("\n"); dump_indent += 2; if (stmt->rec != NULL) { dump_ind(); printf(" INTO%s target = %d %s\n", stmt->strict ? " STRICT" : "", stmt->rec->dno, stmt->rec->refname); } if (stmt->row != NULL) { dump_ind(); printf(" INTO%s target = %d %s\n", stmt->strict ? " STRICT" : "", stmt->row->dno, stmt->row->refname); } dump_indent -= 2; }
static void dump_exit | ( | PLpgSQL_stmt_exit * | stmt | ) | [static] |
Definition at line 1196 of file pl_funcs.c.
References PLpgSQL_stmt_exit::cond, dump_expr(), dump_ind(), PLpgSQL_stmt_exit::is_exit, PLpgSQL_stmt_exit::label, and NULL.
Referenced by dump_stmt().
static void dump_expr | ( | PLpgSQL_expr * | expr | ) | [static] |
Definition at line 1452 of file pl_funcs.c.
References PLpgSQL_expr::query.
Referenced by dump_assign(), dump_case(), dump_cursor_direction(), dump_dynexecute(), dump_dynfors(), dump_execsql(), dump_exit(), dump_forc(), dump_foreach_a(), dump_fori(), dump_fors(), dump_if(), dump_open(), dump_perform(), dump_raise(), dump_return(), dump_return_next(), dump_return_query(), dump_while(), and plpgsql_dumptree().
{ printf("'%s'", expr->query); }
static void dump_fetch | ( | PLpgSQL_stmt_fetch * | stmt | ) | [static] |
Definition at line 1116 of file pl_funcs.c.
References PLpgSQL_stmt_fetch::curvar, PLpgSQL_row::dno, PLpgSQL_rec::dno, dump_cursor_direction(), dump_ind(), dump_indent, PLpgSQL_stmt_fetch::is_move, NULL, PLpgSQL_stmt_fetch::rec, PLpgSQL_row::refname, PLpgSQL_rec::refname, and PLpgSQL_stmt_fetch::row.
Referenced by dump_stmt().
{ dump_ind(); if (!stmt->is_move) { printf("FETCH curvar=%d\n", stmt->curvar); dump_cursor_direction(stmt); dump_indent += 2; if (stmt->rec != NULL) { dump_ind(); printf(" target = %d %s\n", stmt->rec->dno, stmt->rec->refname); } if (stmt->row != NULL) { dump_ind(); printf(" target = %d %s\n", stmt->row->dno, stmt->row->refname); } dump_indent -= 2; } else { printf("MOVE curvar=%d\n", stmt->curvar); dump_cursor_direction(stmt); } }
static void dump_forc | ( | PLpgSQL_stmt_forc * | stmt | ) | [static] |
Definition at line 1025 of file pl_funcs.c.
References PLpgSQL_stmt_forc::argquery, PLpgSQL_stmt_forc::body, PLpgSQL_stmt_forc::curvar, dump_expr(), dump_ind(), dump_indent, dump_stmts(), NULL, PLpgSQL_stmt_forc::rec, and PLpgSQL_rec::refname.
Referenced by dump_stmt().
{ dump_ind(); printf("FORC %s ", stmt->rec->refname); printf("curvar=%d\n", stmt->curvar); dump_indent += 2; if (stmt->argquery != NULL) { dump_ind(); printf(" arguments = "); dump_expr(stmt->argquery); printf("\n"); } dump_indent -= 2; dump_stmts(stmt->body); dump_ind(); printf(" ENDFORC\n"); }
static void dump_foreach_a | ( | PLpgSQL_stmt_foreach_a * | stmt | ) | [static] |
Definition at line 1048 of file pl_funcs.c.
References PLpgSQL_stmt_foreach_a::body, dump_expr(), dump_ind(), dump_stmts(), PLpgSQL_stmt_foreach_a::expr, PLpgSQL_stmt_foreach_a::slice, and PLpgSQL_stmt_foreach_a::varno.
Referenced by dump_stmt().
static void dump_fori | ( | PLpgSQL_stmt_fori * | stmt | ) | [static] |
Definition at line 981 of file pl_funcs.c.
References PLpgSQL_stmt_fori::body, dump_expr(), dump_ind(), dump_indent, dump_stmts(), PLpgSQL_stmt_fori::lower, PLpgSQL_var::refname, PLpgSQL_stmt_fori::reverse, PLpgSQL_stmt_fori::step, PLpgSQL_stmt_fori::upper, and PLpgSQL_stmt_fori::var.
Referenced by dump_stmt().
{ dump_ind(); printf("FORI %s %s\n", stmt->var->refname, (stmt->reverse) ? "REVERSE" : "NORMAL"); dump_indent += 2; dump_ind(); printf(" lower = "); dump_expr(stmt->lower); printf("\n"); dump_ind(); printf(" upper = "); dump_expr(stmt->upper); printf("\n"); if (stmt->step) { dump_ind(); printf(" step = "); dump_expr(stmt->step); printf("\n"); } dump_indent -= 2; dump_stmts(stmt->body); dump_ind(); printf(" ENDFORI\n"); }
static void dump_fors | ( | PLpgSQL_stmt_fors * | stmt | ) | [static] |
Definition at line 1011 of file pl_funcs.c.
References PLpgSQL_stmt_fors::body, dump_expr(), dump_ind(), dump_stmts(), NULL, PLpgSQL_stmt_fors::query, PLpgSQL_stmt_fors::rec, PLpgSQL_row::refname, PLpgSQL_rec::refname, and PLpgSQL_stmt_fors::row.
Referenced by dump_stmt().
static void dump_getdiag | ( | PLpgSQL_stmt_getdiag * | stmt | ) | [static] |
Definition at line 1432 of file pl_funcs.c.
References PLpgSQL_stmt_getdiag::diag_items, dump_ind(), PLpgSQL_stmt_getdiag::is_stacked, PLpgSQL_diag_item::kind, lfirst, list_head(), plpgsql_getdiag_kindname(), and PLpgSQL_diag_item::target.
Referenced by dump_stmt().
{ ListCell *lc; dump_ind(); printf("GET %s DIAGNOSTICS ", stmt->is_stacked ? "STACKED" : "CURRENT"); foreach(lc, stmt->diag_items) { PLpgSQL_diag_item *diag_item = (PLpgSQL_diag_item *) lfirst(lc); if (lc != list_head(stmt->diag_items)) printf(", "); printf("{var %d} = %s", diag_item->target, plpgsql_getdiag_kindname(diag_item->kind)); } printf("\n"); }
static void dump_if | ( | PLpgSQL_stmt_if * | stmt | ) | [static] |
Definition at line 887 of file pl_funcs.c.
References PLpgSQL_if_elsif::cond, PLpgSQL_stmt_if::cond, dump_expr(), dump_ind(), dump_stmts(), PLpgSQL_stmt_if::else_body, PLpgSQL_stmt_if::elsif_list, lfirst, NIL, PLpgSQL_if_elsif::stmts, and PLpgSQL_stmt_if::then_body.
Referenced by dump_stmt().
{ ListCell *l; dump_ind(); printf("IF "); dump_expr(stmt->cond); printf(" THEN\n"); dump_stmts(stmt->then_body); foreach(l, stmt->elsif_list) { PLpgSQL_if_elsif *elif = (PLpgSQL_if_elsif *) lfirst(l); dump_ind(); printf(" ELSIF "); dump_expr(elif->cond); printf(" THEN\n"); dump_stmts(elif->stmts); } if (stmt->else_body != NIL) { dump_ind(); printf(" ELSE\n"); dump_stmts(stmt->else_body); } dump_ind(); printf(" ENDIF\n"); }
static void dump_ind | ( | void | ) | [static] |
Definition at line 736 of file pl_funcs.c.
References dump_indent, and i.
Referenced by dump_assign(), dump_block(), dump_case(), dump_close(), dump_cursor_direction(), dump_dynexecute(), dump_dynfors(), dump_execsql(), dump_exit(), dump_fetch(), dump_forc(), dump_foreach_a(), dump_fori(), dump_fors(), dump_getdiag(), dump_if(), dump_loop(), dump_open(), dump_perform(), dump_raise(), dump_return(), dump_return_next(), dump_return_query(), and dump_while().
{ int i; for (i = 0; i < dump_indent; i++) printf(" "); }
static void dump_loop | ( | PLpgSQL_stmt_loop * | stmt | ) | [static] |
Definition at line 955 of file pl_funcs.c.
References PLpgSQL_stmt_loop::body, dump_ind(), and dump_stmts().
Referenced by dump_stmt().
{ dump_ind(); printf("LOOP\n"); dump_stmts(stmt->body); dump_ind(); printf(" ENDLOOP\n"); }
static void dump_open | ( | PLpgSQL_stmt_open * | stmt | ) | [static] |
Definition at line 1065 of file pl_funcs.c.
References PLpgSQL_stmt_open::argquery, PLpgSQL_stmt_open::curvar, dump_expr(), dump_ind(), dump_indent, PLpgSQL_stmt_open::dynquery, i, lfirst, NIL, NULL, PLpgSQL_stmt_open::params, and PLpgSQL_stmt_open::query.
Referenced by dump_stmt().
{ dump_ind(); printf("OPEN curvar=%d\n", stmt->curvar); dump_indent += 2; if (stmt->argquery != NULL) { dump_ind(); printf(" arguments = '"); dump_expr(stmt->argquery); printf("'\n"); } if (stmt->query != NULL) { dump_ind(); printf(" query = '"); dump_expr(stmt->query); printf("'\n"); } if (stmt->dynquery != NULL) { dump_ind(); printf(" execute = '"); dump_expr(stmt->dynquery); printf("'\n"); if (stmt->params != NIL) { ListCell *lc; int i; dump_indent += 2; dump_ind(); printf(" USING\n"); dump_indent += 2; i = 1; foreach(lc, stmt->params) { dump_ind(); printf(" parameter $%d: ", i++); dump_expr((PLpgSQL_expr *) lfirst(lc)); printf("\n"); } dump_indent -= 4; } } dump_indent -= 2; }
static void dump_perform | ( | PLpgSQL_stmt_perform * | stmt | ) | [static] |
Definition at line 1187 of file pl_funcs.c.
References dump_expr(), dump_ind(), and PLpgSQL_stmt_perform::expr.
Referenced by dump_stmt().
static void dump_raise | ( | PLpgSQL_stmt_raise * | stmt | ) | [static] |
Definition at line 1276 of file pl_funcs.c.
References PLpgSQL_stmt_raise::condname, dump_expr(), dump_ind(), dump_indent, PLpgSQL_stmt_raise::elog_level, PLpgSQL_raise_option::expr, i, lfirst, PLpgSQL_stmt_raise::message, PLpgSQL_raise_option::opt_type, PLpgSQL_stmt_raise::options, PLpgSQL_stmt_raise::params, PLPGSQL_RAISEOPTION_DETAIL, PLPGSQL_RAISEOPTION_ERRCODE, PLPGSQL_RAISEOPTION_HINT, and PLPGSQL_RAISEOPTION_MESSAGE.
Referenced by dump_stmt().
{ ListCell *lc; int i = 0; dump_ind(); printf("RAISE level=%d", stmt->elog_level); if (stmt->condname) printf(" condname='%s'", stmt->condname); if (stmt->message) printf(" message='%s'", stmt->message); printf("\n"); dump_indent += 2; foreach(lc, stmt->params) { dump_ind(); printf(" parameter %d: ", i++); dump_expr((PLpgSQL_expr *) lfirst(lc)); printf("\n"); } if (stmt->options) { dump_ind(); printf(" USING\n"); dump_indent += 2; foreach(lc, stmt->options) { PLpgSQL_raise_option *opt = (PLpgSQL_raise_option *) lfirst(lc); dump_ind(); switch (opt->opt_type) { case PLPGSQL_RAISEOPTION_ERRCODE: printf(" ERRCODE = "); break; case PLPGSQL_RAISEOPTION_MESSAGE: printf(" MESSAGE = "); break; case PLPGSQL_RAISEOPTION_DETAIL: printf(" DETAIL = "); break; case PLPGSQL_RAISEOPTION_HINT: printf(" HINT = "); break; } dump_expr(opt->expr); printf("\n"); } dump_indent -= 2; } dump_indent -= 2; }
static void dump_return | ( | PLpgSQL_stmt_return * | stmt | ) | [static] |
Definition at line 1211 of file pl_funcs.c.
References dump_expr(), dump_ind(), PLpgSQL_stmt_return::expr, NULL, and PLpgSQL_stmt_return::retvarno.
Referenced by dump_stmt().
static void dump_return_next | ( | PLpgSQL_stmt_return_next * | stmt | ) | [static] |
Definition at line 1225 of file pl_funcs.c.
References dump_expr(), dump_ind(), PLpgSQL_stmt_return_next::expr, NULL, and PLpgSQL_stmt_return_next::retvarno.
Referenced by dump_stmt().
static void dump_return_query | ( | PLpgSQL_stmt_return_query * | stmt | ) | [static] |
Definition at line 1239 of file pl_funcs.c.
References dump_expr(), dump_ind(), dump_indent, PLpgSQL_stmt_return_query::dynquery, i, lfirst, NIL, PLpgSQL_stmt_return_query::params, and PLpgSQL_stmt_return_query::query.
Referenced by dump_stmt().
{ dump_ind(); if (stmt->query) { printf("RETURN QUERY "); dump_expr(stmt->query); printf("\n"); } else { printf("RETURN QUERY EXECUTE "); dump_expr(stmt->dynquery); printf("\n"); if (stmt->params != NIL) { ListCell *lc; int i; dump_indent += 2; dump_ind(); printf(" USING\n"); dump_indent += 2; i = 1; foreach(lc, stmt->params) { dump_ind(); printf(" parameter $%d: ", i++); dump_expr((PLpgSQL_expr *) lfirst(lc)); printf("\n"); } dump_indent -= 4; } } }
static void dump_stmt | ( | PLpgSQL_stmt * | stmt | ) | [static] |
Definition at line 745 of file pl_funcs.c.
References PLpgSQL_stmt_perform::cmd_type, PLpgSQL_stmt::cmd_type, dump_assign(), dump_block(), dump_case(), dump_close(), dump_dynexecute(), dump_dynfors(), dump_execsql(), dump_exit(), dump_fetch(), dump_forc(), dump_foreach_a(), dump_fori(), dump_fors(), dump_getdiag(), dump_if(), dump_loop(), dump_open(), dump_perform(), dump_raise(), dump_return(), dump_return_next(), dump_return_query(), dump_while(), elog, ERROR, PLpgSQL_stmt::lineno, PLPGSQL_STMT_ASSIGN, PLPGSQL_STMT_BLOCK, PLPGSQL_STMT_CASE, PLPGSQL_STMT_CLOSE, PLPGSQL_STMT_DYNEXECUTE, PLPGSQL_STMT_DYNFORS, PLPGSQL_STMT_EXECSQL, PLPGSQL_STMT_EXIT, PLPGSQL_STMT_FETCH, PLPGSQL_STMT_FORC, PLPGSQL_STMT_FOREACH_A, PLPGSQL_STMT_FORI, PLPGSQL_STMT_FORS, PLPGSQL_STMT_GETDIAG, PLPGSQL_STMT_IF, PLPGSQL_STMT_LOOP, PLPGSQL_STMT_OPEN, PLPGSQL_STMT_PERFORM, PLPGSQL_STMT_RAISE, PLPGSQL_STMT_RETURN, PLPGSQL_STMT_RETURN_NEXT, PLPGSQL_STMT_RETURN_QUERY, and PLPGSQL_STMT_WHILE.
Referenced by dump_stmts().
{ printf("%3d:", stmt->lineno); switch ((enum PLpgSQL_stmt_types) stmt->cmd_type) { case PLPGSQL_STMT_BLOCK: dump_block((PLpgSQL_stmt_block *) stmt); break; case PLPGSQL_STMT_ASSIGN: dump_assign((PLpgSQL_stmt_assign *) stmt); break; case PLPGSQL_STMT_IF: dump_if((PLpgSQL_stmt_if *) stmt); break; case PLPGSQL_STMT_CASE: dump_case((PLpgSQL_stmt_case *) stmt); break; case PLPGSQL_STMT_LOOP: dump_loop((PLpgSQL_stmt_loop *) stmt); break; case PLPGSQL_STMT_WHILE: dump_while((PLpgSQL_stmt_while *) stmt); break; case PLPGSQL_STMT_FORI: dump_fori((PLpgSQL_stmt_fori *) stmt); break; case PLPGSQL_STMT_FORS: dump_fors((PLpgSQL_stmt_fors *) stmt); break; case PLPGSQL_STMT_FORC: dump_forc((PLpgSQL_stmt_forc *) stmt); break; case PLPGSQL_STMT_FOREACH_A: dump_foreach_a((PLpgSQL_stmt_foreach_a *) stmt); break; case PLPGSQL_STMT_EXIT: dump_exit((PLpgSQL_stmt_exit *) stmt); break; case PLPGSQL_STMT_RETURN: dump_return((PLpgSQL_stmt_return *) stmt); break; case PLPGSQL_STMT_RETURN_NEXT: dump_return_next((PLpgSQL_stmt_return_next *) stmt); break; case PLPGSQL_STMT_RETURN_QUERY: dump_return_query((PLpgSQL_stmt_return_query *) stmt); break; case PLPGSQL_STMT_RAISE: dump_raise((PLpgSQL_stmt_raise *) stmt); break; case PLPGSQL_STMT_EXECSQL: dump_execsql((PLpgSQL_stmt_execsql *) stmt); break; case PLPGSQL_STMT_DYNEXECUTE: dump_dynexecute((PLpgSQL_stmt_dynexecute *) stmt); break; case PLPGSQL_STMT_DYNFORS: dump_dynfors((PLpgSQL_stmt_dynfors *) stmt); break; case PLPGSQL_STMT_GETDIAG: dump_getdiag((PLpgSQL_stmt_getdiag *) stmt); break; case PLPGSQL_STMT_OPEN: dump_open((PLpgSQL_stmt_open *) stmt); break; case PLPGSQL_STMT_FETCH: dump_fetch((PLpgSQL_stmt_fetch *) stmt); break; case PLPGSQL_STMT_CLOSE: dump_close((PLpgSQL_stmt_close *) stmt); break; case PLPGSQL_STMT_PERFORM: dump_perform((PLpgSQL_stmt_perform *) stmt); break; default: elog(ERROR, "unrecognized cmd_type: %d", stmt->cmd_type); break; } }
static void dump_stmts | ( | List * | stmts | ) | [static] |
Definition at line 826 of file pl_funcs.c.
References dump_indent, dump_stmt(), and lfirst.
Referenced by dump_block(), dump_case(), dump_dynfors(), dump_forc(), dump_foreach_a(), dump_fori(), dump_fors(), dump_if(), dump_loop(), and dump_while().
{ ListCell *s; dump_indent += 2; foreach(s, stmts) dump_stmt((PLpgSQL_stmt *) lfirst(s)); dump_indent -= 2; }
static void dump_while | ( | PLpgSQL_stmt_while * | stmt | ) | [static] |
Definition at line 967 of file pl_funcs.c.
References PLpgSQL_stmt_while::body, PLpgSQL_stmt_while::cond, dump_expr(), dump_ind(), and dump_stmts().
Referenced by dump_stmt().
static void free_assign | ( | PLpgSQL_stmt_assign * | stmt | ) | [static] |
Definition at line 441 of file pl_funcs.c.
References PLpgSQL_stmt_assign::expr, and free_expr().
Referenced by free_stmt().
static void free_block | ( | PLpgSQL_stmt_block * | block | ) | [static] |
Definition at line 424 of file pl_funcs.c.
References PLpgSQL_exception::action, PLpgSQL_stmt_block::body, PLpgSQL_exception_block::exc_list, PLpgSQL_stmt_block::exceptions, free_stmts(), and lfirst.
Referenced by free_stmt(), and plpgsql_free_function_memory().
{ free_stmts(block->body); if (block->exceptions) { ListCell *e; foreach(e, block->exceptions->exc_list) { PLpgSQL_exception *exc = (PLpgSQL_exception *) lfirst(e); free_stmts(exc->action); } } }
static void free_case | ( | PLpgSQL_stmt_case * | stmt | ) | [static] |
Definition at line 464 of file pl_funcs.c.
References PLpgSQL_stmt_case::case_when_list, PLpgSQL_stmt_case::else_stmts, PLpgSQL_case_when::expr, free_expr(), free_stmts(), lfirst, PLpgSQL_case_when::stmts, and PLpgSQL_stmt_case::t_expr.
Referenced by free_stmt().
{ ListCell *l; free_expr(stmt->t_expr); foreach(l, stmt->case_when_list) { PLpgSQL_case_when *cwt = (PLpgSQL_case_when *) lfirst(l); free_expr(cwt->expr); free_stmts(cwt->stmts); } free_stmts(stmt->else_stmts); }
static void free_close | ( | PLpgSQL_stmt_close * | stmt | ) | [static] |
static void free_dynexecute | ( | PLpgSQL_stmt_dynexecute * | stmt | ) | [static] |
Definition at line 608 of file pl_funcs.c.
References free_expr(), lfirst, PLpgSQL_stmt_dynexecute::params, and PLpgSQL_stmt_dynexecute::query.
Referenced by free_stmt().
static void free_dynfors | ( | PLpgSQL_stmt_dynfors * | stmt | ) | [static] |
Definition at line 620 of file pl_funcs.c.
References PLpgSQL_stmt_dynfors::body, free_expr(), free_stmts(), lfirst, PLpgSQL_stmt_dynfors::params, and PLpgSQL_stmt_dynfors::query.
Referenced by free_stmt().
{ ListCell *lc; free_stmts(stmt->body); free_expr(stmt->query); foreach(lc, stmt->params) { free_expr((PLpgSQL_expr *) lfirst(lc)); } }
static void free_execsql | ( | PLpgSQL_stmt_execsql * | stmt | ) | [static] |
Definition at line 602 of file pl_funcs.c.
References free_expr(), and PLpgSQL_stmt_execsql::sqlstmt.
Referenced by free_stmt().
static void free_exit | ( | PLpgSQL_stmt_exit * | stmt | ) | [static] |
Definition at line 554 of file pl_funcs.c.
References PLpgSQL_stmt_exit::cond, and free_expr().
Referenced by free_stmt().
static void free_expr | ( | PLpgSQL_expr * | expr | ) | [static] |
Definition at line 638 of file pl_funcs.c.
References PLpgSQL_expr::plan, and SPI_freeplan().
Referenced by free_assign(), free_case(), free_dynexecute(), free_dynfors(), free_execsql(), free_exit(), free_fetch(), free_forc(), free_foreach_a(), free_fori(), free_fors(), free_if(), free_open(), free_perform(), free_raise(), free_return(), free_return_next(), free_return_query(), free_while(), and plpgsql_free_function_memory().
{ if (expr && expr->plan) { SPI_freeplan(expr->plan); expr->plan = NULL; } }
static void free_fetch | ( | PLpgSQL_stmt_fetch * | stmt | ) | [static] |
Definition at line 537 of file pl_funcs.c.
References PLpgSQL_stmt_fetch::expr, and free_expr().
Referenced by free_stmt().
static void free_forc | ( | PLpgSQL_stmt_forc * | stmt | ) | [static] |
Definition at line 509 of file pl_funcs.c.
References PLpgSQL_stmt_forc::argquery, PLpgSQL_stmt_forc::body, free_expr(), and free_stmts().
Referenced by free_stmt().
{ free_stmts(stmt->body); free_expr(stmt->argquery); }
static void free_foreach_a | ( | PLpgSQL_stmt_foreach_a * | stmt | ) | [static] |
Definition at line 516 of file pl_funcs.c.
References PLpgSQL_stmt_foreach_a::body, PLpgSQL_stmt_foreach_a::expr, free_expr(), and free_stmts().
Referenced by free_stmt().
{ free_expr(stmt->expr); free_stmts(stmt->body); }
static void free_fori | ( | PLpgSQL_stmt_fori * | stmt | ) | [static] |
Definition at line 493 of file pl_funcs.c.
References PLpgSQL_stmt_fori::body, free_expr(), free_stmts(), PLpgSQL_stmt_fori::lower, PLpgSQL_stmt_fori::step, and PLpgSQL_stmt_fori::upper.
Referenced by free_stmt().
static void free_fors | ( | PLpgSQL_stmt_fors * | stmt | ) | [static] |
Definition at line 502 of file pl_funcs.c.
References PLpgSQL_stmt_fors::body, free_expr(), free_stmts(), and PLpgSQL_stmt_fors::query.
Referenced by free_stmt().
{ free_stmts(stmt->body); free_expr(stmt->query); }
static void free_getdiag | ( | PLpgSQL_stmt_getdiag * | stmt | ) | [static] |
static void free_if | ( | PLpgSQL_stmt_if * | stmt | ) | [static] |
Definition at line 447 of file pl_funcs.c.
References PLpgSQL_if_elsif::cond, PLpgSQL_stmt_if::cond, PLpgSQL_stmt_if::else_body, PLpgSQL_stmt_if::elsif_list, free_expr(), free_stmts(), lfirst, PLpgSQL_if_elsif::stmts, and PLpgSQL_stmt_if::then_body.
Referenced by free_stmt().
{ ListCell *l; free_expr(stmt->cond); free_stmts(stmt->then_body); foreach(l, stmt->elsif_list) { PLpgSQL_if_elsif *elif = (PLpgSQL_if_elsif *) lfirst(l); free_expr(elif->cond); free_stmts(elif->stmts); } free_stmts(stmt->else_body); }
static void free_loop | ( | PLpgSQL_stmt_loop * | stmt | ) | [static] |
Definition at line 480 of file pl_funcs.c.
References PLpgSQL_stmt_loop::body, and free_stmts().
Referenced by free_stmt().
{ free_stmts(stmt->body); }
static void free_open | ( | PLpgSQL_stmt_open * | stmt | ) | [static] |
Definition at line 523 of file pl_funcs.c.
References PLpgSQL_stmt_open::argquery, PLpgSQL_stmt_open::dynquery, free_expr(), lfirst, PLpgSQL_stmt_open::params, and PLpgSQL_stmt_open::query.
Referenced by free_stmt().
static void free_perform | ( | PLpgSQL_stmt_perform * | stmt | ) | [static] |
Definition at line 548 of file pl_funcs.c.
References PLpgSQL_stmt_perform::expr, and free_expr().
Referenced by free_stmt().
static void free_raise | ( | PLpgSQL_stmt_raise * | stmt | ) | [static] |
Definition at line 585 of file pl_funcs.c.
References PLpgSQL_raise_option::expr, free_expr(), lfirst, PLpgSQL_stmt_raise::options, and PLpgSQL_stmt_raise::params.
Referenced by free_stmt().
{ ListCell *lc; foreach(lc, stmt->params) { free_expr((PLpgSQL_expr *) lfirst(lc)); } foreach(lc, stmt->options) { PLpgSQL_raise_option *opt = (PLpgSQL_raise_option *) lfirst(lc); free_expr(opt->expr); } }
static void free_return | ( | PLpgSQL_stmt_return * | stmt | ) | [static] |
Definition at line 560 of file pl_funcs.c.
References PLpgSQL_stmt_return::expr, and free_expr().
Referenced by free_stmt().
static void free_return_next | ( | PLpgSQL_stmt_return_next * | stmt | ) | [static] |
Definition at line 566 of file pl_funcs.c.
References PLpgSQL_stmt_return_next::expr, and free_expr().
Referenced by free_stmt().
static void free_return_query | ( | PLpgSQL_stmt_return_query * | stmt | ) | [static] |
Definition at line 572 of file pl_funcs.c.
References PLpgSQL_stmt_return_query::dynquery, free_expr(), lfirst, PLpgSQL_stmt_return_query::params, and PLpgSQL_stmt_return_query::query.
Referenced by free_stmt().
static void free_stmt | ( | PLpgSQL_stmt * | stmt | ) | [static] |
Definition at line 333 of file pl_funcs.c.
References PLpgSQL_stmt_perform::cmd_type, PLpgSQL_stmt::cmd_type, elog, ERROR, free_assign(), free_block(), free_case(), free_close(), free_dynexecute(), free_dynfors(), free_execsql(), free_exit(), free_fetch(), free_forc(), free_foreach_a(), free_fori(), free_fors(), free_getdiag(), free_if(), free_loop(), free_open(), free_perform(), free_raise(), free_return(), free_return_next(), free_return_query(), free_while(), PLPGSQL_STMT_ASSIGN, PLPGSQL_STMT_BLOCK, PLPGSQL_STMT_CASE, PLPGSQL_STMT_CLOSE, PLPGSQL_STMT_DYNEXECUTE, PLPGSQL_STMT_DYNFORS, PLPGSQL_STMT_EXECSQL, PLPGSQL_STMT_EXIT, PLPGSQL_STMT_FETCH, PLPGSQL_STMT_FORC, PLPGSQL_STMT_FOREACH_A, PLPGSQL_STMT_FORI, PLPGSQL_STMT_FORS, PLPGSQL_STMT_GETDIAG, PLPGSQL_STMT_IF, PLPGSQL_STMT_LOOP, PLPGSQL_STMT_OPEN, PLPGSQL_STMT_PERFORM, PLPGSQL_STMT_RAISE, PLPGSQL_STMT_RETURN, PLPGSQL_STMT_RETURN_NEXT, PLPGSQL_STMT_RETURN_QUERY, and PLPGSQL_STMT_WHILE.
Referenced by free_stmts().
{ switch ((enum PLpgSQL_stmt_types) stmt->cmd_type) { case PLPGSQL_STMT_BLOCK: free_block((PLpgSQL_stmt_block *) stmt); break; case PLPGSQL_STMT_ASSIGN: free_assign((PLpgSQL_stmt_assign *) stmt); break; case PLPGSQL_STMT_IF: free_if((PLpgSQL_stmt_if *) stmt); break; case PLPGSQL_STMT_CASE: free_case((PLpgSQL_stmt_case *) stmt); break; case PLPGSQL_STMT_LOOP: free_loop((PLpgSQL_stmt_loop *) stmt); break; case PLPGSQL_STMT_WHILE: free_while((PLpgSQL_stmt_while *) stmt); break; case PLPGSQL_STMT_FORI: free_fori((PLpgSQL_stmt_fori *) stmt); break; case PLPGSQL_STMT_FORS: free_fors((PLpgSQL_stmt_fors *) stmt); break; case PLPGSQL_STMT_FORC: free_forc((PLpgSQL_stmt_forc *) stmt); break; case PLPGSQL_STMT_FOREACH_A: free_foreach_a((PLpgSQL_stmt_foreach_a *) stmt); break; case PLPGSQL_STMT_EXIT: free_exit((PLpgSQL_stmt_exit *) stmt); break; case PLPGSQL_STMT_RETURN: free_return((PLpgSQL_stmt_return *) stmt); break; case PLPGSQL_STMT_RETURN_NEXT: free_return_next((PLpgSQL_stmt_return_next *) stmt); break; case PLPGSQL_STMT_RETURN_QUERY: free_return_query((PLpgSQL_stmt_return_query *) stmt); break; case PLPGSQL_STMT_RAISE: free_raise((PLpgSQL_stmt_raise *) stmt); break; case PLPGSQL_STMT_EXECSQL: free_execsql((PLpgSQL_stmt_execsql *) stmt); break; case PLPGSQL_STMT_DYNEXECUTE: free_dynexecute((PLpgSQL_stmt_dynexecute *) stmt); break; case PLPGSQL_STMT_DYNFORS: free_dynfors((PLpgSQL_stmt_dynfors *) stmt); break; case PLPGSQL_STMT_GETDIAG: free_getdiag((PLpgSQL_stmt_getdiag *) stmt); break; case PLPGSQL_STMT_OPEN: free_open((PLpgSQL_stmt_open *) stmt); break; case PLPGSQL_STMT_FETCH: free_fetch((PLpgSQL_stmt_fetch *) stmt); break; case PLPGSQL_STMT_CLOSE: free_close((PLpgSQL_stmt_close *) stmt); break; case PLPGSQL_STMT_PERFORM: free_perform((PLpgSQL_stmt_perform *) stmt); break; default: elog(ERROR, "unrecognized cmd_type: %d", stmt->cmd_type); break; } }
static void free_stmts | ( | List * | stmts | ) | [static] |
Definition at line 413 of file pl_funcs.c.
References free_stmt(), and lfirst.
Referenced by free_block(), free_case(), free_dynfors(), free_forc(), free_foreach_a(), free_fori(), free_fors(), free_if(), free_loop(), and free_while().
{ ListCell *s; foreach(s, stmts) { free_stmt((PLpgSQL_stmt *) lfirst(s)); } }
static void free_while | ( | PLpgSQL_stmt_while * | stmt | ) | [static] |
Definition at line 486 of file pl_funcs.c.
References PLpgSQL_stmt_while::body, PLpgSQL_stmt_while::cond, free_expr(), and free_stmts().
Referenced by free_stmt().
{ free_expr(stmt->cond); free_stmts(stmt->body); }
void plpgsql_dumptree | ( | PLpgSQL_function * | func | ) |
Definition at line 1458 of file pl_funcs.c.
References PLpgSQL_function::action, PLpgSQL_type::atttypmod, PLpgSQL_var::cursor_explicit_argrow, PLpgSQL_var::cursor_explicit_expr, PLpgSQL_var::datatype, PLpgSQL_function::datums, PLpgSQL_var::default_val, PLpgSQL_arrayelem::dtype, PLpgSQL_datum::dtype, dump_block(), dump_expr(), dump_indent, PLpgSQL_row::fieldnames, PLpgSQL_function::fn_signature, i, PLpgSQL_var::isconst, PLpgSQL_stmt_block::lineno, PLpgSQL_function::ndatums, PLpgSQL_row::nfields, PLpgSQL_var::notnull, NULL, PLPGSQL_DTYPE_ARRAYELEM, PLPGSQL_DTYPE_REC, PLPGSQL_DTYPE_RECFIELD, PLPGSQL_DTYPE_ROW, PLPGSQL_DTYPE_VAR, PLpgSQL_row::refname, PLpgSQL_var::refname, PLpgSQL_type::typname, PLpgSQL_type::typoid, and PLpgSQL_row::varnos.
Referenced by do_compile().
{ int i; PLpgSQL_datum *d; printf("\nExecution tree of successfully compiled PL/pgSQL function %s:\n", func->fn_signature); printf("\nFunction's data area:\n"); for (i = 0; i < func->ndatums; i++) { d = func->datums[i]; printf(" entry %d: ", i); switch (d->dtype) { case PLPGSQL_DTYPE_VAR: { PLpgSQL_var *var = (PLpgSQL_var *) d; printf("VAR %-16s type %s (typoid %u) atttypmod %d\n", var->refname, var->datatype->typname, var->datatype->typoid, var->datatype->atttypmod); if (var->isconst) printf(" CONSTANT\n"); if (var->notnull) printf(" NOT NULL\n"); if (var->default_val != NULL) { printf(" DEFAULT "); dump_expr(var->default_val); printf("\n"); } if (var->cursor_explicit_expr != NULL) { if (var->cursor_explicit_argrow >= 0) printf(" CURSOR argument row %d\n", var->cursor_explicit_argrow); printf(" CURSOR IS "); dump_expr(var->cursor_explicit_expr); printf("\n"); } } break; case PLPGSQL_DTYPE_ROW: { PLpgSQL_row *row = (PLpgSQL_row *) d; int i; printf("ROW %-16s fields", row->refname); for (i = 0; i < row->nfields; i++) { if (row->fieldnames[i]) printf(" %s=var %d", row->fieldnames[i], row->varnos[i]); } printf("\n"); } break; case PLPGSQL_DTYPE_REC: printf("REC %s\n", ((PLpgSQL_rec *) d)->refname); break; case PLPGSQL_DTYPE_RECFIELD: printf("RECFIELD %-16s of REC %d\n", ((PLpgSQL_recfield *) d)->fieldname, ((PLpgSQL_recfield *) d)->recparentno); break; case PLPGSQL_DTYPE_ARRAYELEM: printf("ARRAYELEM of VAR %d subscript ", ((PLpgSQL_arrayelem *) d)->arrayparentno); dump_expr(((PLpgSQL_arrayelem *) d)->subscript); printf("\n"); break; default: printf("??? unknown data type %d\n", d->dtype); } } printf("\nFunction's statements:\n"); dump_indent = 0; printf("%3d:", func->action->lineno); dump_block(func->action); printf("\nEnd of execution tree of function %s\n\n", func->fn_signature); fflush(stdout); }
void plpgsql_free_function_memory | ( | PLpgSQL_function * | func | ) |
Definition at line 648 of file pl_funcs.c.
References PLpgSQL_function::action, Assert, PLpgSQL_var::cursor_explicit_expr, PLpgSQL_function::datums, PLpgSQL_var::default_val, PLpgSQL_arrayelem::dtype, PLpgSQL_datum::dtype, elog, ERROR, PLpgSQL_function::fn_cxt, free_block(), free_expr(), i, MemoryContextDelete(), PLpgSQL_function::ndatums, PLPGSQL_DTYPE_ARRAYELEM, PLPGSQL_DTYPE_REC, PLPGSQL_DTYPE_RECFIELD, PLPGSQL_DTYPE_ROW, PLPGSQL_DTYPE_VAR, and PLpgSQL_function::use_count.
Referenced by delete_function(), and plpgsql_inline_handler().
{ int i; /* Better not call this on an in-use function */ Assert(func->use_count == 0); /* Release plans associated with variable declarations */ for (i = 0; i < func->ndatums; i++) { PLpgSQL_datum *d = func->datums[i]; switch (d->dtype) { case PLPGSQL_DTYPE_VAR: { PLpgSQL_var *var = (PLpgSQL_var *) d; free_expr(var->default_val); free_expr(var->cursor_explicit_expr); } break; case PLPGSQL_DTYPE_ROW: break; case PLPGSQL_DTYPE_REC: break; case PLPGSQL_DTYPE_RECFIELD: break; case PLPGSQL_DTYPE_ARRAYELEM: free_expr(((PLpgSQL_arrayelem *) d)->subscript); break; default: elog(ERROR, "unrecognized data type: %d", d->dtype); } } func->ndatums = 0; /* Release plans in statement tree */ if (func->action) free_block(func->action); func->action = NULL; /* * And finally, release all memory except the PLpgSQL_function struct * itself (which has to be kept around because there may be multiple * fn_extra pointers to it). */ if (func->fn_cxt) MemoryContextDelete(func->fn_cxt); func->fn_cxt = NULL; }
const char* plpgsql_getdiag_kindname | ( | int | kind | ) |
Definition at line 272 of file pl_funcs.c.
References PLPGSQL_GETDIAG_ERROR_CONTEXT, PLPGSQL_GETDIAG_ERROR_DETAIL, PLPGSQL_GETDIAG_ERROR_HINT, PLPGSQL_GETDIAG_MESSAGE_TEXT, PLPGSQL_GETDIAG_RESULT_OID, PLPGSQL_GETDIAG_RETURNED_SQLSTATE, and PLPGSQL_GETDIAG_ROW_COUNT.
Referenced by dump_getdiag().
{ switch (kind) { case PLPGSQL_GETDIAG_ROW_COUNT: return "ROW_COUNT"; case PLPGSQL_GETDIAG_RESULT_OID: return "RESULT_OID"; case PLPGSQL_GETDIAG_ERROR_CONTEXT: return "PG_EXCEPTION_CONTEXT"; case PLPGSQL_GETDIAG_ERROR_DETAIL: return "PG_EXCEPTION_DETAIL"; case PLPGSQL_GETDIAG_ERROR_HINT: return "PG_EXCEPTION_HINT"; case PLPGSQL_GETDIAG_RETURNED_SQLSTATE: return "RETURNED_SQLSTATE"; case PLPGSQL_GETDIAG_MESSAGE_TEXT: return "MESSAGE_TEXT"; } return "unknown"; }
void plpgsql_ns_additem | ( | int | itemtype, | |
int | itemno, | |||
const char * | name | |||
) |
Definition at line 92 of file pl_funcs.c.
References Assert, PLpgSQL_nsitem::itemno, PLpgSQL_nsitem::itemtype, PLpgSQL_nsitem::name, NULL, palloc(), PLPGSQL_NSTYPE_LABEL, and PLpgSQL_nsitem::prev.
Referenced by add_parameter_name(), plpgsql_build_record(), plpgsql_build_variable(), and plpgsql_ns_push().
{ PLpgSQL_nsitem *nse; Assert(name != NULL); /* first item added must be a label */ Assert(ns_top != NULL || itemtype == PLPGSQL_NSTYPE_LABEL); nse = palloc(sizeof(PLpgSQL_nsitem) + strlen(name)); nse->itemtype = itemtype; nse->itemno = itemno; nse->prev = ns_top; strcpy(nse->name, name); ns_top = nse; }
void plpgsql_ns_init | ( | void | ) |
Definition at line 43 of file pl_funcs.c.
Referenced by do_compile(), and plpgsql_compile_inline().
{ ns_top = NULL; }
PLpgSQL_nsitem* plpgsql_ns_lookup | ( | PLpgSQL_nsitem * | ns_cur, | |
bool | localmode, | |||
const char * | name1, | |||
const char * | name2, | |||
const char * | name3, | |||
int * | names_used | |||
) |
Definition at line 130 of file pl_funcs.c.
References PLpgSQL_nsitem::itemtype, PLpgSQL_nsitem::name, NULL, PLPGSQL_NSTYPE_VAR, and PLpgSQL_nsitem::prev.
Referenced by add_parameter_name(), plpgsql_param_ref(), plpgsql_parse_cwordtype(), plpgsql_parse_dblword(), plpgsql_parse_tripword(), plpgsql_parse_word(), plpgsql_parse_wordtype(), and resolve_column_ref().
{ /* Outer loop iterates once per block level in the namespace chain */ while (ns_cur != NULL) { PLpgSQL_nsitem *nsitem; /* Check this level for unqualified match to variable name */ for (nsitem = ns_cur; nsitem->itemtype != PLPGSQL_NSTYPE_LABEL; nsitem = nsitem->prev) { if (strcmp(nsitem->name, name1) == 0) { if (name2 == NULL || nsitem->itemtype != PLPGSQL_NSTYPE_VAR) { if (names_used) *names_used = 1; return nsitem; } } } /* Check this level for qualified match to variable name */ if (name2 != NULL && strcmp(nsitem->name, name1) == 0) { for (nsitem = ns_cur; nsitem->itemtype != PLPGSQL_NSTYPE_LABEL; nsitem = nsitem->prev) { if (strcmp(nsitem->name, name2) == 0) { if (name3 == NULL || nsitem->itemtype != PLPGSQL_NSTYPE_VAR) { if (names_used) *names_used = 2; return nsitem; } } } } if (localmode) break; /* do not look into upper levels */ ns_cur = nsitem->prev; } /* This is just to suppress possibly-uninitialized-variable warnings */ if (names_used) *names_used = 0; return NULL; /* No match found */ }
PLpgSQL_nsitem* plpgsql_ns_lookup_label | ( | PLpgSQL_nsitem * | ns_cur, | |
const char * | name | |||
) |
Definition at line 195 of file pl_funcs.c.
References PLpgSQL_nsitem::itemtype, PLpgSQL_nsitem::name, NULL, PLPGSQL_NSTYPE_LABEL, and PLpgSQL_nsitem::prev.
void plpgsql_ns_pop | ( | void | ) |
Definition at line 67 of file pl_funcs.c.
References Assert, PLpgSQL_nsitem::itemtype, NULL, PLPGSQL_NSTYPE_LABEL, and PLpgSQL_nsitem::prev.
void plpgsql_ns_push | ( | const char * | label | ) |
Definition at line 54 of file pl_funcs.c.
References NULL, plpgsql_ns_additem(), and PLPGSQL_NSTYPE_LABEL.
Referenced by do_compile(), and plpgsql_compile_inline().
{ if (label == NULL) label = ""; plpgsql_ns_additem(PLPGSQL_NSTYPE_LABEL, 0, label); }
PLpgSQL_nsitem* plpgsql_ns_top | ( | void | ) |
Definition at line 81 of file pl_funcs.c.
Referenced by add_parameter_name(), plpgsql_parse_cwordtype(), plpgsql_parse_dblword(), plpgsql_parse_tripword(), plpgsql_parse_word(), and plpgsql_parse_wordtype().
{ return ns_top; }
const char* plpgsql_stmt_typename | ( | PLpgSQL_stmt * | stmt | ) |
Definition at line 213 of file pl_funcs.c.
References _, PLpgSQL_stmt::cmd_type, PLPGSQL_STMT_ASSIGN, PLPGSQL_STMT_BLOCK, PLPGSQL_STMT_CASE, PLPGSQL_STMT_CLOSE, PLPGSQL_STMT_DYNEXECUTE, PLPGSQL_STMT_DYNFORS, PLPGSQL_STMT_EXECSQL, PLPGSQL_STMT_EXIT, PLPGSQL_STMT_FETCH, PLPGSQL_STMT_FORC, PLPGSQL_STMT_FOREACH_A, PLPGSQL_STMT_FORI, PLPGSQL_STMT_FORS, PLPGSQL_STMT_GETDIAG, PLPGSQL_STMT_IF, PLPGSQL_STMT_LOOP, PLPGSQL_STMT_OPEN, PLPGSQL_STMT_PERFORM, PLPGSQL_STMT_RAISE, PLPGSQL_STMT_RETURN, PLPGSQL_STMT_RETURN_NEXT, PLPGSQL_STMT_RETURN_QUERY, and PLPGSQL_STMT_WHILE.
Referenced by plpgsql_exec_error_callback().
{ switch ((enum PLpgSQL_stmt_types) stmt->cmd_type) { case PLPGSQL_STMT_BLOCK: return _("statement block"); case PLPGSQL_STMT_ASSIGN: return _("assignment"); case PLPGSQL_STMT_IF: return "IF"; case PLPGSQL_STMT_CASE: return "CASE"; case PLPGSQL_STMT_LOOP: return "LOOP"; case PLPGSQL_STMT_WHILE: return "WHILE"; case PLPGSQL_STMT_FORI: return _("FOR with integer loop variable"); case PLPGSQL_STMT_FORS: return _("FOR over SELECT rows"); case PLPGSQL_STMT_FORC: return _("FOR over cursor"); case PLPGSQL_STMT_FOREACH_A: return _("FOREACH over array"); case PLPGSQL_STMT_EXIT: return "EXIT"; case PLPGSQL_STMT_RETURN: return "RETURN"; case PLPGSQL_STMT_RETURN_NEXT: return "RETURN NEXT"; case PLPGSQL_STMT_RETURN_QUERY: return "RETURN QUERY"; case PLPGSQL_STMT_RAISE: return "RAISE"; case PLPGSQL_STMT_EXECSQL: return _("SQL statement"); case PLPGSQL_STMT_DYNEXECUTE: return _("EXECUTE statement"); case PLPGSQL_STMT_DYNFORS: return _("FOR over EXECUTE statement"); case PLPGSQL_STMT_GETDIAG: return "GET DIAGNOSTICS"; case PLPGSQL_STMT_OPEN: return "OPEN"; case PLPGSQL_STMT_FETCH: return "FETCH"; case PLPGSQL_STMT_CLOSE: return "CLOSE"; case PLPGSQL_STMT_PERFORM: return "PERFORM"; } return "unknown"; }
int dump_indent [static] |
Definition at line 704 of file pl_funcs.c.
Referenced by dump_case(), dump_cursor_direction(), dump_dynexecute(), dump_dynfors(), dump_execsql(), dump_fetch(), dump_forc(), dump_fori(), dump_ind(), dump_open(), dump_raise(), dump_return_query(), dump_stmts(), and plpgsql_dumptree().
PLpgSQL_nsitem* ns_top = NULL [static] |
Definition at line 35 of file pl_funcs.c.