PostgreSQL Source Code  git master
pl_funcs.c File Reference
#include "postgres.h"
#include "plpgsql.h"
#include "utils/memutils.h"
Include dependency graph for pl_funcs.c:

Go to the source code of this file.

Functions

void plpgsql_ns_init (void)
 
void plpgsql_ns_push (const char *label, PLpgSQL_label_type label_type)
 
void plpgsql_ns_pop (void)
 
PLpgSQL_nsitemplpgsql_ns_top (void)
 
void plpgsql_ns_additem (PLpgSQL_nsitem_type itemtype, int itemno, const char *name)
 
PLpgSQL_nsitemplpgsql_ns_lookup (PLpgSQL_nsitem *ns_cur, bool localmode, const char *name1, const char *name2, const char *name3, int *names_used)
 
PLpgSQL_nsitemplpgsql_ns_lookup_label (PLpgSQL_nsitem *ns_cur, const char *name)
 
PLpgSQL_nsitemplpgsql_ns_find_nearest_loop (PLpgSQL_nsitem *ns_cur)
 
const char * plpgsql_stmt_typename (PLpgSQL_stmt *stmt)
 
const char * plpgsql_getdiag_kindname (PLpgSQL_getdiag_kind kind)
 
static void free_stmt (PLpgSQL_stmt *stmt)
 
static void free_block (PLpgSQL_stmt_block *block)
 
static void free_assign (PLpgSQL_stmt_assign *stmt)
 
static void free_if (PLpgSQL_stmt_if *stmt)
 
static void free_case (PLpgSQL_stmt_case *stmt)
 
static void free_loop (PLpgSQL_stmt_loop *stmt)
 
static void free_while (PLpgSQL_stmt_while *stmt)
 
static void free_fori (PLpgSQL_stmt_fori *stmt)
 
static void free_fors (PLpgSQL_stmt_fors *stmt)
 
static void free_forc (PLpgSQL_stmt_forc *stmt)
 
static void free_foreach_a (PLpgSQL_stmt_foreach_a *stmt)
 
static void free_exit (PLpgSQL_stmt_exit *stmt)
 
static void free_return (PLpgSQL_stmt_return *stmt)
 
static void free_return_next (PLpgSQL_stmt_return_next *stmt)
 
static void free_return_query (PLpgSQL_stmt_return_query *stmt)
 
static void free_raise (PLpgSQL_stmt_raise *stmt)
 
static void free_assert (PLpgSQL_stmt_assert *stmt)
 
static void free_execsql (PLpgSQL_stmt_execsql *stmt)
 
static void free_dynexecute (PLpgSQL_stmt_dynexecute *stmt)
 
static void free_dynfors (PLpgSQL_stmt_dynfors *stmt)
 
static void free_getdiag (PLpgSQL_stmt_getdiag *stmt)
 
static void free_open (PLpgSQL_stmt_open *stmt)
 
static void free_fetch (PLpgSQL_stmt_fetch *stmt)
 
static void free_close (PLpgSQL_stmt_close *stmt)
 
static void free_perform (PLpgSQL_stmt_perform *stmt)
 
static void free_call (PLpgSQL_stmt_call *stmt)
 
static void free_commit (PLpgSQL_stmt_commit *stmt)
 
static void free_rollback (PLpgSQL_stmt_rollback *stmt)
 
static void free_set (PLpgSQL_stmt_set *stmt)
 
static void free_expr (PLpgSQL_expr *expr)
 
static void free_stmts (List *stmts)
 
void plpgsql_free_function_memory (PLpgSQL_function *func)
 
static void dump_ind (void)
 
static void dump_stmt (PLpgSQL_stmt *stmt)
 
static void dump_block (PLpgSQL_stmt_block *block)
 
static void dump_assign (PLpgSQL_stmt_assign *stmt)
 
static void dump_if (PLpgSQL_stmt_if *stmt)
 
static void dump_case (PLpgSQL_stmt_case *stmt)
 
static void dump_loop (PLpgSQL_stmt_loop *stmt)
 
static void dump_while (PLpgSQL_stmt_while *stmt)
 
static void dump_fori (PLpgSQL_stmt_fori *stmt)
 
static void dump_fors (PLpgSQL_stmt_fors *stmt)
 
static void dump_forc (PLpgSQL_stmt_forc *stmt)
 
static void dump_foreach_a (PLpgSQL_stmt_foreach_a *stmt)
 
static void dump_exit (PLpgSQL_stmt_exit *stmt)
 
static void dump_return (PLpgSQL_stmt_return *stmt)
 
static void dump_return_next (PLpgSQL_stmt_return_next *stmt)
 
static void dump_return_query (PLpgSQL_stmt_return_query *stmt)
 
static void dump_raise (PLpgSQL_stmt_raise *stmt)
 
static void dump_assert (PLpgSQL_stmt_assert *stmt)
 
static void dump_execsql (PLpgSQL_stmt_execsql *stmt)
 
static void dump_dynexecute (PLpgSQL_stmt_dynexecute *stmt)
 
static void dump_dynfors (PLpgSQL_stmt_dynfors *stmt)
 
static void dump_getdiag (PLpgSQL_stmt_getdiag *stmt)
 
static void dump_open (PLpgSQL_stmt_open *stmt)
 
static void dump_fetch (PLpgSQL_stmt_fetch *stmt)
 
static void dump_cursor_direction (PLpgSQL_stmt_fetch *stmt)
 
static void dump_close (PLpgSQL_stmt_close *stmt)
 
static void dump_perform (PLpgSQL_stmt_perform *stmt)
 
static void dump_call (PLpgSQL_stmt_call *stmt)
 
static void dump_commit (PLpgSQL_stmt_commit *stmt)
 
static void dump_rollback (PLpgSQL_stmt_rollback *stmt)
 
static void dump_set (PLpgSQL_stmt_set *stmt)
 
static void dump_expr (PLpgSQL_expr *expr)
 
static void dump_stmts (List *stmts)
 
void plpgsql_dumptree (PLpgSQL_function *func)
 

Variables

static PLpgSQL_nsitemns_top = NULL
 
static int dump_indent
 

Function Documentation

◆ dump_assert()

static void dump_assert ( PLpgSQL_stmt_assert stmt)
static

Definition at line 1492 of file pl_funcs.c.

References PLpgSQL_stmt_assert::cond, dump_expr(), dump_ind(), dump_indent, PLpgSQL_stmt_assert::message, and printf.

Referenced by dump_stmt().

1493 {
1494  dump_ind();
1495  printf("ASSERT ");
1496  dump_expr(stmt->cond);
1497  printf("\n");
1498 
1499  dump_indent += 2;
1500  if (stmt->message != NULL)
1501  {
1502  dump_ind();
1503  printf(" MESSAGE = ");
1504  dump_expr(stmt->message);
1505  printf("\n");
1506  }
1507  dump_indent -= 2;
1508 }
#define printf(...)
Definition: port.h:198
PLpgSQL_expr * message
Definition: plpgsql.h:901
static void dump_ind(void)
Definition: pl_funcs.c:836
static int dump_indent
Definition: pl_funcs.c:799
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1618
PLpgSQL_expr * cond
Definition: plpgsql.h:900

◆ dump_assign()

static void dump_assign ( PLpgSQL_stmt_assign stmt)
static

Definition at line 993 of file pl_funcs.c.

References dump_expr(), dump_ind(), PLpgSQL_stmt_assign::expr, printf, and PLpgSQL_stmt_assign::varno.

Referenced by dump_stmt().

994 {
995  dump_ind();
996  printf("ASSIGN var %d := ", stmt->varno);
997  dump_expr(stmt->expr);
998  printf("\n");
999 }
#define printf(...)
Definition: port.h:198
static void dump_ind(void)
Definition: pl_funcs.c:836
PLpgSQL_expr * expr
Definition: plpgsql.h:525
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1618

◆ dump_block()

static void dump_block ( PLpgSQL_stmt_block block)
static

Definition at line 952 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 printf.

Referenced by dump_stmt(), and plpgsql_dumptree().

953 {
954  char *name;
955 
956  if (block->label == NULL)
957  name = "*unnamed*";
958  else
959  name = block->label;
960 
961  dump_ind();
962  printf("BLOCK <<%s>>\n", name);
963 
964  dump_stmts(block->body);
965 
966  if (block->exceptions)
967  {
968  ListCell *e;
969 
970  foreach(e, block->exceptions->exc_list)
971  {
973  PLpgSQL_condition *cond;
974 
975  dump_ind();
976  printf(" EXCEPTION WHEN ");
977  for (cond = exc->conditions; cond; cond = cond->next)
978  {
979  if (cond != exc->conditions)
980  printf(" OR ");
981  printf("%s", cond->condname);
982  }
983  printf(" THEN\n");
984  dump_stmts(exc->action);
985  }
986  }
987 
988  dump_ind();
989  printf(" END -- %s\n", name);
990 }
char * condname
Definition: plpgsql.h:477
struct PLpgSQL_condition * next
Definition: plpgsql.h:478
#define printf(...)
Definition: port.h:198
static void dump_ind(void)
Definition: pl_funcs.c:836
PLpgSQL_condition * conditions
Definition: plpgsql.h:497
#define lfirst(lc)
Definition: pg_list.h:190
PLpgSQL_exception_block * exceptions
Definition: plpgsql.h:513
const char * name
Definition: encode.c:521
e
Definition: preproc-init.c:82
static void dump_stmts(List *stmts)
Definition: pl_funcs.c:941

◆ dump_call()

static void dump_call ( PLpgSQL_stmt_call stmt)
static

Definition at line 1307 of file pl_funcs.c.

References dump_expr(), dump_ind(), PLpgSQL_stmt_call::expr, PLpgSQL_stmt_call::is_call, and printf.

Referenced by dump_stmt().

1308 {
1309  dump_ind();
1310  printf("%s expr = ", stmt->is_call ? "CALL" : "DO");
1311  dump_expr(stmt->expr);
1312  printf("\n");
1313 }
#define printf(...)
Definition: port.h:198
PLpgSQL_expr * expr
Definition: plpgsql.h:547
static void dump_ind(void)
Definition: pl_funcs.c:836
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1618

◆ dump_case()

static void dump_case ( PLpgSQL_stmt_case stmt)
static

Definition at line 1032 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, printf, PLpgSQL_case_when::stmts, PLpgSQL_stmt_case::t_expr, and PLpgSQL_stmt_case::t_varno.

Referenced by dump_stmt().

1033 {
1034  ListCell *l;
1035 
1036  dump_ind();
1037  printf("CASE %d ", stmt->t_varno);
1038  if (stmt->t_expr)
1039  dump_expr(stmt->t_expr);
1040  printf("\n");
1041  dump_indent += 6;
1042  foreach(l, stmt->case_when_list)
1043  {
1045 
1046  dump_ind();
1047  printf("WHEN ");
1048  dump_expr(cwt->expr);
1049  printf("\n");
1050  dump_ind();
1051  printf("THEN\n");
1052  dump_indent += 2;
1053  dump_stmts(cwt->stmts);
1054  dump_indent -= 2;
1055  }
1056  if (stmt->have_else)
1057  {
1058  dump_ind();
1059  printf("ELSE\n");
1060  dump_indent += 2;
1061  dump_stmts(stmt->else_stmts);
1062  dump_indent -= 2;
1063  }
1064  dump_indent -= 6;
1065  dump_ind();
1066  printf(" ENDCASE\n");
1067 }
#define printf(...)
Definition: port.h:198
List * else_stmts
Definition: plpgsql.h:642
PLpgSQL_expr * expr
Definition: plpgsql.h:651
List * case_when_list
Definition: plpgsql.h:640
static void dump_ind(void)
Definition: pl_funcs.c:836
#define lfirst(lc)
Definition: pg_list.h:190
static int dump_indent
Definition: pl_funcs.c:799
PLpgSQL_expr * t_expr
Definition: plpgsql.h:638
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1618
static void dump_stmts(List *stmts)
Definition: pl_funcs.c:941

◆ dump_close()

static void dump_close ( PLpgSQL_stmt_close stmt)
static

Definition at line 1291 of file pl_funcs.c.

References PLpgSQL_stmt_close::curvar, dump_ind(), and printf.

Referenced by dump_stmt().

1292 {
1293  dump_ind();
1294  printf("CLOSE curvar=%d\n", stmt->curvar);
1295 }
#define printf(...)
Definition: port.h:198
static void dump_ind(void)
Definition: pl_funcs.c:836

◆ dump_commit()

static void dump_commit ( PLpgSQL_stmt_commit stmt)
static

Definition at line 1316 of file pl_funcs.c.

References PLpgSQL_stmt_commit::chain, dump_ind(), and printf.

Referenced by dump_stmt().

1317 {
1318  dump_ind();
1319  if (stmt->chain)
1320  printf("COMMIT AND CHAIN\n");
1321  else
1322  printf("COMMIT\n");
1323 }
#define printf(...)
Definition: port.h:198
static void dump_ind(void)
Definition: pl_funcs.c:836

◆ dump_cursor_direction()

static void dump_cursor_direction ( PLpgSQL_stmt_fetch stmt)
static

Definition at line 1257 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, PLpgSQL_stmt_fetch::how_many, and printf.

Referenced by dump_fetch().

1258 {
1259  dump_indent += 2;
1260  dump_ind();
1261  switch (stmt->direction)
1262  {
1263  case FETCH_FORWARD:
1264  printf(" FORWARD ");
1265  break;
1266  case FETCH_BACKWARD:
1267  printf(" BACKWARD ");
1268  break;
1269  case FETCH_ABSOLUTE:
1270  printf(" ABSOLUTE ");
1271  break;
1272  case FETCH_RELATIVE:
1273  printf(" RELATIVE ");
1274  break;
1275  default:
1276  printf("??? unknown cursor direction %d", stmt->direction);
1277  }
1278 
1279  if (stmt->expr)
1280  {
1281  dump_expr(stmt->expr);
1282  printf("\n");
1283  }
1284  else
1285  printf("%ld\n", stmt->how_many);
1286 
1287  dump_indent -= 2;
1288 }
FetchDirection direction
Definition: plpgsql.h:800
#define printf(...)
Definition: port.h:198
static void dump_ind(void)
Definition: pl_funcs.c:836
static int dump_indent
Definition: pl_funcs.c:799
PLpgSQL_expr * expr
Definition: plpgsql.h:802
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1618

◆ dump_dynexecute()

static void dump_dynexecute ( PLpgSQL_stmt_dynexecute stmt)
static

Definition at line 1530 of file pl_funcs.c.

References PLpgSQL_variable::dno, dump_expr(), dump_ind(), dump_indent, i, lfirst, NIL, PLpgSQL_stmt_dynexecute::params, printf, PLpgSQL_stmt_dynexecute::query, PLpgSQL_variable::refname, PLpgSQL_stmt_dynexecute::strict, and PLpgSQL_stmt_dynexecute::target.

Referenced by dump_stmt().

1531 {
1532  dump_ind();
1533  printf("EXECUTE ");
1534  dump_expr(stmt->query);
1535  printf("\n");
1536 
1537  dump_indent += 2;
1538  if (stmt->target != NULL)
1539  {
1540  dump_ind();
1541  printf(" INTO%s target = %d %s\n",
1542  stmt->strict ? " STRICT" : "",
1543  stmt->target->dno, stmt->target->refname);
1544  }
1545  if (stmt->params != NIL)
1546  {
1547  ListCell *lc;
1548  int i;
1549 
1550  dump_ind();
1551  printf(" USING\n");
1552  dump_indent += 2;
1553  i = 1;
1554  foreach(lc, stmt->params)
1555  {
1556  dump_ind();
1557  printf(" parameter %d: ", i++);
1558  dump_expr((PLpgSQL_expr *) lfirst(lc));
1559  printf("\n");
1560  }
1561  dump_indent -= 2;
1562  }
1563  dump_indent -= 2;
1564 }
#define NIL
Definition: pg_list.h:65
PLpgSQL_expr * query
Definition: plpgsql.h:928
#define printf(...)
Definition: port.h:198
static void dump_ind(void)
Definition: pl_funcs.c:836
#define lfirst(lc)
Definition: pg_list.h:190
static int dump_indent
Definition: pl_funcs.c:799
char * refname
Definition: plpgsql.h:272
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1618
int i
PLpgSQL_variable * target
Definition: plpgsql.h:931

◆ dump_dynfors()

static void dump_dynfors ( PLpgSQL_stmt_dynfors stmt)
static

Definition at line 1567 of file pl_funcs.c.

References PLpgSQL_stmt_dynfors::body, dump_expr(), dump_ind(), dump_indent, dump_stmts(), i, lfirst, NIL, PLpgSQL_stmt_dynfors::params, printf, PLpgSQL_stmt_dynfors::query, PLpgSQL_variable::refname, and PLpgSQL_stmt_dynfors::var.

Referenced by dump_stmt().

1568 {
1569  dump_ind();
1570  printf("FORS %s EXECUTE ", stmt->var->refname);
1571  dump_expr(stmt->query);
1572  printf("\n");
1573  if (stmt->params != NIL)
1574  {
1575  ListCell *lc;
1576  int i;
1577 
1578  dump_indent += 2;
1579  dump_ind();
1580  printf(" USING\n");
1581  dump_indent += 2;
1582  i = 1;
1583  foreach(lc, stmt->params)
1584  {
1585  dump_ind();
1586  printf(" parameter $%d: ", i++);
1587  dump_expr((PLpgSQL_expr *) lfirst(lc));
1588  printf("\n");
1589  }
1590  dump_indent -= 4;
1591  }
1592  dump_stmts(stmt->body);
1593  dump_ind();
1594  printf(" ENDFORS\n");
1595 }
#define NIL
Definition: pg_list.h:65
#define printf(...)
Definition: port.h:198
PLpgSQL_expr * query
Definition: plpgsql.h:755
static void dump_ind(void)
Definition: pl_funcs.c:836
PLpgSQL_variable * var
Definition: plpgsql.h:752
#define lfirst(lc)
Definition: pg_list.h:190
static int dump_indent
Definition: pl_funcs.c:799
char * refname
Definition: plpgsql.h:272
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1618
int i
static void dump_stmts(List *stmts)
Definition: pl_funcs.c:941

◆ dump_execsql()

static void dump_execsql ( PLpgSQL_stmt_execsql stmt)
static

Definition at line 1511 of file pl_funcs.c.

References PLpgSQL_variable::dno, dump_expr(), dump_ind(), dump_indent, printf, PLpgSQL_variable::refname, PLpgSQL_stmt_execsql::sqlstmt, PLpgSQL_stmt_execsql::strict, and PLpgSQL_stmt_execsql::target.

Referenced by dump_stmt().

1512 {
1513  dump_ind();
1514  printf("EXECSQL ");
1515  dump_expr(stmt->sqlstmt);
1516  printf("\n");
1517 
1518  dump_indent += 2;
1519  if (stmt->target != NULL)
1520  {
1521  dump_ind();
1522  printf(" INTO%s target = %d %s\n",
1523  stmt->strict ? " STRICT" : "",
1524  stmt->target->dno, stmt->target->refname);
1525  }
1526  dump_indent -= 2;
1527 }
PLpgSQL_expr * sqlstmt
Definition: plpgsql.h:912
#define printf(...)
Definition: port.h:198
PLpgSQL_variable * target
Definition: plpgsql.h:917
static void dump_ind(void)
Definition: pl_funcs.c:836
static int dump_indent
Definition: pl_funcs.c:799
char * refname
Definition: plpgsql.h:272
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1618

◆ dump_exit()

static void dump_exit ( PLpgSQL_stmt_exit stmt)
static

Definition at line 1343 of file pl_funcs.c.

References PLpgSQL_stmt_exit::cond, dump_expr(), dump_ind(), PLpgSQL_stmt_exit::is_exit, PLpgSQL_stmt_exit::label, and printf.

Referenced by dump_stmt().

1344 {
1345  dump_ind();
1346  printf("%s", stmt->is_exit ? "EXIT" : "CONTINUE");
1347  if (stmt->label != NULL)
1348  printf(" label='%s'", stmt->label);
1349  if (stmt->cond != NULL)
1350  {
1351  printf(" WHEN ");
1352  dump_expr(stmt->cond);
1353  }
1354  printf("\n");
1355 }
#define printf(...)
Definition: port.h:198
PLpgSQL_expr * cond
Definition: plpgsql.h:828
static void dump_ind(void)
Definition: pl_funcs.c:836
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1618

◆ dump_expr()

◆ dump_fetch()

static void dump_fetch ( PLpgSQL_stmt_fetch stmt)
static

Definition at line 1231 of file pl_funcs.c.

References PLpgSQL_stmt_fetch::curvar, PLpgSQL_variable::dno, dump_cursor_direction(), dump_ind(), dump_indent, PLpgSQL_stmt_fetch::is_move, printf, PLpgSQL_variable::refname, and PLpgSQL_stmt_fetch::target.

Referenced by dump_stmt().

1232 {
1233  dump_ind();
1234 
1235  if (!stmt->is_move)
1236  {
1237  printf("FETCH curvar=%d\n", stmt->curvar);
1238  dump_cursor_direction(stmt);
1239 
1240  dump_indent += 2;
1241  if (stmt->target != NULL)
1242  {
1243  dump_ind();
1244  printf(" target = %d %s\n",
1245  stmt->target->dno, stmt->target->refname);
1246  }
1247  dump_indent -= 2;
1248  }
1249  else
1250  {
1251  printf("MOVE curvar=%d\n", stmt->curvar);
1252  dump_cursor_direction(stmt);
1253  }
1254 }
static void dump_cursor_direction(PLpgSQL_stmt_fetch *stmt)
Definition: pl_funcs.c:1257
#define printf(...)
Definition: port.h:198
static void dump_ind(void)
Definition: pl_funcs.c:836
static int dump_indent
Definition: pl_funcs.c:799
char * refname
Definition: plpgsql.h:272
PLpgSQL_variable * target
Definition: plpgsql.h:798

◆ dump_forc()

static void dump_forc ( PLpgSQL_stmt_forc stmt)
static

Definition at line 1140 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(), printf, PLpgSQL_variable::refname, and PLpgSQL_stmt_forc::var.

Referenced by dump_stmt().

1141 {
1142  dump_ind();
1143  printf("FORC %s ", stmt->var->refname);
1144  printf("curvar=%d\n", stmt->curvar);
1145 
1146  dump_indent += 2;
1147  if (stmt->argquery != NULL)
1148  {
1149  dump_ind();
1150  printf(" arguments = ");
1151  dump_expr(stmt->argquery);
1152  printf("\n");
1153  }
1154  dump_indent -= 2;
1155 
1156  dump_stmts(stmt->body);
1157 
1158  dump_ind();
1159  printf(" ENDFORC\n");
1160 }
PLpgSQL_variable * var
Definition: plpgsql.h:736
#define printf(...)
Definition: port.h:198
static void dump_ind(void)
Definition: pl_funcs.c:836
static int dump_indent
Definition: pl_funcs.c:799
char * refname
Definition: plpgsql.h:272
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1618
PLpgSQL_expr * argquery
Definition: plpgsql.h:740
static void dump_stmts(List *stmts)
Definition: pl_funcs.c:941

◆ dump_foreach_a()

static void dump_foreach_a ( PLpgSQL_stmt_foreach_a stmt)
static

Definition at line 1163 of file pl_funcs.c.

References PLpgSQL_stmt_foreach_a::body, dump_expr(), dump_ind(), dump_stmts(), PLpgSQL_stmt_foreach_a::expr, printf, PLpgSQL_stmt_foreach_a::slice, and PLpgSQL_stmt_foreach_a::varno.

Referenced by dump_stmt().

1164 {
1165  dump_ind();
1166  printf("FOREACHA var %d ", stmt->varno);
1167  if (stmt->slice != 0)
1168  printf("SLICE %d ", stmt->slice);
1169  printf("IN ");
1170  dump_expr(stmt->expr);
1171  printf("\n");
1172 
1173  dump_stmts(stmt->body);
1174 
1175  dump_ind();
1176  printf(" ENDFOREACHA");
1177 }
PLpgSQL_expr * expr
Definition: plpgsql.h:770
#define printf(...)
Definition: port.h:198
static void dump_ind(void)
Definition: pl_funcs.c:836
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1618
static void dump_stmts(List *stmts)
Definition: pl_funcs.c:941

◆ dump_fori()

static void dump_fori ( PLpgSQL_stmt_fori stmt)
static

Definition at line 1096 of file pl_funcs.c.

References PLpgSQL_stmt_fori::body, dump_expr(), dump_ind(), dump_indent, dump_stmts(), PLpgSQL_stmt_fori::lower, printf, PLpgSQL_var::refname, PLpgSQL_stmt_fori::reverse, PLpgSQL_stmt_fori::step, PLpgSQL_stmt_fori::upper, and PLpgSQL_stmt_fori::var.

Referenced by dump_stmt().

1097 {
1098  dump_ind();
1099  printf("FORI %s %s\n", stmt->var->refname, (stmt->reverse) ? "REVERSE" : "NORMAL");
1100 
1101  dump_indent += 2;
1102  dump_ind();
1103  printf(" lower = ");
1104  dump_expr(stmt->lower);
1105  printf("\n");
1106  dump_ind();
1107  printf(" upper = ");
1108  dump_expr(stmt->upper);
1109  printf("\n");
1110  if (stmt->step)
1111  {
1112  dump_ind();
1113  printf(" step = ");
1114  dump_expr(stmt->step);
1115  printf("\n");
1116  }
1117  dump_indent -= 2;
1118 
1119  dump_stmts(stmt->body);
1120 
1121  dump_ind();
1122  printf(" ENDFORI\n");
1123 }
char * refname
Definition: plpgsql.h:294
#define printf(...)
Definition: port.h:198
PLpgSQL_expr * lower
Definition: plpgsql.h:690
PLpgSQL_var * var
Definition: plpgsql.h:689
static void dump_ind(void)
Definition: pl_funcs.c:836
static int dump_indent
Definition: pl_funcs.c:799
PLpgSQL_expr * step
Definition: plpgsql.h:692
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1618
PLpgSQL_expr * upper
Definition: plpgsql.h:691
static void dump_stmts(List *stmts)
Definition: pl_funcs.c:941

◆ dump_fors()

static void dump_fors ( PLpgSQL_stmt_fors stmt)
static

Definition at line 1126 of file pl_funcs.c.

References PLpgSQL_stmt_fors::body, dump_expr(), dump_ind(), dump_stmts(), printf, PLpgSQL_stmt_fors::query, PLpgSQL_variable::refname, and PLpgSQL_stmt_fors::var.

Referenced by dump_stmt().

1127 {
1128  dump_ind();
1129  printf("FORS %s ", stmt->var->refname);
1130  dump_expr(stmt->query);
1131  printf("\n");
1132 
1133  dump_stmts(stmt->body);
1134 
1135  dump_ind();
1136  printf(" ENDFORS\n");
1137 }
#define printf(...)
Definition: port.h:198
PLpgSQL_variable * var
Definition: plpgsql.h:721
static void dump_ind(void)
Definition: pl_funcs.c:836
char * refname
Definition: plpgsql.h:272
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1618
PLpgSQL_expr * query
Definition: plpgsql.h:724
static void dump_stmts(List *stmts)
Definition: pl_funcs.c:941

◆ dump_getdiag()

static void dump_getdiag ( PLpgSQL_stmt_getdiag stmt)
static

Definition at line 1598 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(), printf, and PLpgSQL_diag_item::target.

Referenced by dump_stmt().

1599 {
1600  ListCell *lc;
1601 
1602  dump_ind();
1603  printf("GET %s DIAGNOSTICS ", stmt->is_stacked ? "STACKED" : "CURRENT");
1604  foreach(lc, stmt->diag_items)
1605  {
1606  PLpgSQL_diag_item *diag_item = (PLpgSQL_diag_item *) lfirst(lc);
1607 
1608  if (lc != list_head(stmt->diag_items))
1609  printf(", ");
1610 
1611  printf("{var %d} = %s", diag_item->target,
1612  plpgsql_getdiag_kindname(diag_item->kind));
1613  }
1614  printf("\n");
1615 }
#define printf(...)
Definition: port.h:198
PLpgSQL_getdiag_kind kind
Definition: plpgsql.h:590
static ListCell * list_head(const List *l)
Definition: pg_list.h:125
static void dump_ind(void)
Definition: pl_funcs.c:836
#define lfirst(lc)
Definition: pg_list.h:190
const char * plpgsql_getdiag_kindname(PLpgSQL_getdiag_kind kind)
Definition: pl_funcs.c:302

◆ dump_if()

static void dump_if ( PLpgSQL_stmt_if stmt)
static

Definition at line 1002 of file pl_funcs.c.

References PLpgSQL_stmt_if::cond, PLpgSQL_if_elsif::cond, dump_expr(), dump_ind(), dump_stmts(), PLpgSQL_stmt_if::else_body, PLpgSQL_stmt_if::elsif_list, lfirst, NIL, printf, PLpgSQL_if_elsif::stmts, and PLpgSQL_stmt_if::then_body.

Referenced by dump_stmt().

1003 {
1004  ListCell *l;
1005 
1006  dump_ind();
1007  printf("IF ");
1008  dump_expr(stmt->cond);
1009  printf(" THEN\n");
1010  dump_stmts(stmt->then_body);
1011  foreach(l, stmt->elsif_list)
1012  {
1013  PLpgSQL_if_elsif *elif = (PLpgSQL_if_elsif *) lfirst(l);
1014 
1015  dump_ind();
1016  printf(" ELSIF ");
1017  dump_expr(elif->cond);
1018  printf(" THEN\n");
1019  dump_stmts(elif->stmts);
1020  }
1021  if (stmt->else_body != NIL)
1022  {
1023  dump_ind();
1024  printf(" ELSE\n");
1025  dump_stmts(stmt->else_body);
1026  }
1027  dump_ind();
1028  printf(" ENDIF\n");
1029 }
#define NIL
Definition: pg_list.h:65
PLpgSQL_expr * cond
Definition: plpgsql.h:614
List * then_body
Definition: plpgsql.h:615
List * elsif_list
Definition: plpgsql.h:616
List * stmts
Definition: plpgsql.h:627
#define printf(...)
Definition: port.h:198
PLpgSQL_expr * cond
Definition: plpgsql.h:626
static void dump_ind(void)
Definition: pl_funcs.c:836
#define lfirst(lc)
Definition: pg_list.h:190
List * else_body
Definition: plpgsql.h:617
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1618
static void dump_stmts(List *stmts)
Definition: pl_funcs.c:941

◆ dump_ind()

◆ dump_loop()

static void dump_loop ( PLpgSQL_stmt_loop stmt)
static

Definition at line 1070 of file pl_funcs.c.

References PLpgSQL_stmt_loop::body, dump_ind(), dump_stmts(), and printf.

Referenced by dump_stmt().

1071 {
1072  dump_ind();
1073  printf("LOOP\n");
1074 
1075  dump_stmts(stmt->body);
1076 
1077  dump_ind();
1078  printf(" ENDLOOP\n");
1079 }
#define printf(...)
Definition: port.h:198
static void dump_ind(void)
Definition: pl_funcs.c:836
static void dump_stmts(List *stmts)
Definition: pl_funcs.c:941

◆ dump_open()

static void dump_open ( PLpgSQL_stmt_open stmt)
static

Definition at line 1180 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, PLpgSQL_stmt_open::params, printf, and PLpgSQL_stmt_open::query.

Referenced by dump_stmt().

1181 {
1182  dump_ind();
1183  printf("OPEN curvar=%d\n", stmt->curvar);
1184 
1185  dump_indent += 2;
1186  if (stmt->argquery != NULL)
1187  {
1188  dump_ind();
1189  printf(" arguments = '");
1190  dump_expr(stmt->argquery);
1191  printf("'\n");
1192  }
1193  if (stmt->query != NULL)
1194  {
1195  dump_ind();
1196  printf(" query = '");
1197  dump_expr(stmt->query);
1198  printf("'\n");
1199  }
1200  if (stmt->dynquery != NULL)
1201  {
1202  dump_ind();
1203  printf(" execute = '");
1204  dump_expr(stmt->dynquery);
1205  printf("'\n");
1206 
1207  if (stmt->params != NIL)
1208  {
1209  ListCell *lc;
1210  int i;
1211 
1212  dump_indent += 2;
1213  dump_ind();
1214  printf(" USING\n");
1215  dump_indent += 2;
1216  i = 1;
1217  foreach(lc, stmt->params)
1218  {
1219  dump_ind();
1220  printf(" parameter $%d: ", i++);
1221  dump_expr((PLpgSQL_expr *) lfirst(lc));
1222  printf("\n");
1223  }
1224  dump_indent -= 4;
1225  }
1226  }
1227  dump_indent -= 2;
1228 }
#define NIL
Definition: pg_list.h:65
#define printf(...)
Definition: port.h:198
PLpgSQL_expr * dynquery
Definition: plpgsql.h:786
PLpgSQL_expr * query
Definition: plpgsql.h:785
static void dump_ind(void)
Definition: pl_funcs.c:836
#define lfirst(lc)
Definition: pg_list.h:190
static int dump_indent
Definition: pl_funcs.c:799
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1618
PLpgSQL_expr * argquery
Definition: plpgsql.h:784
int i

◆ dump_perform()

static void dump_perform ( PLpgSQL_stmt_perform stmt)
static

Definition at line 1298 of file pl_funcs.c.

References dump_expr(), dump_ind(), PLpgSQL_stmt_perform::expr, and printf.

Referenced by dump_stmt().

1299 {
1300  dump_ind();
1301  printf("PERFORM expr = ");
1302  dump_expr(stmt->expr);
1303  printf("\n");
1304 }
#define printf(...)
Definition: port.h:198
PLpgSQL_expr * expr
Definition: plpgsql.h:536
static void dump_ind(void)
Definition: pl_funcs.c:836
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1618

◆ dump_raise()

static void dump_raise ( PLpgSQL_stmt_raise stmt)
static

Definition at line 1423 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_COLUMN, PLPGSQL_RAISEOPTION_CONSTRAINT, PLPGSQL_RAISEOPTION_DATATYPE, PLPGSQL_RAISEOPTION_DETAIL, PLPGSQL_RAISEOPTION_ERRCODE, PLPGSQL_RAISEOPTION_HINT, PLPGSQL_RAISEOPTION_MESSAGE, PLPGSQL_RAISEOPTION_SCHEMA, PLPGSQL_RAISEOPTION_TABLE, and printf.

Referenced by dump_stmt().

1424 {
1425  ListCell *lc;
1426  int i = 0;
1427 
1428  dump_ind();
1429  printf("RAISE level=%d", stmt->elog_level);
1430  if (stmt->condname)
1431  printf(" condname='%s'", stmt->condname);
1432  if (stmt->message)
1433  printf(" message='%s'", stmt->message);
1434  printf("\n");
1435  dump_indent += 2;
1436  foreach(lc, stmt->params)
1437  {
1438  dump_ind();
1439  printf(" parameter %d: ", i++);
1440  dump_expr((PLpgSQL_expr *) lfirst(lc));
1441  printf("\n");
1442  }
1443  if (stmt->options)
1444  {
1445  dump_ind();
1446  printf(" USING\n");
1447  dump_indent += 2;
1448  foreach(lc, stmt->options)
1449  {
1451 
1452  dump_ind();
1453  switch (opt->opt_type)
1454  {
1456  printf(" ERRCODE = ");
1457  break;
1459  printf(" MESSAGE = ");
1460  break;
1462  printf(" DETAIL = ");
1463  break;
1465  printf(" HINT = ");
1466  break;
1468  printf(" COLUMN = ");
1469  break;
1471  printf(" CONSTRAINT = ");
1472  break;
1474  printf(" DATATYPE = ");
1475  break;
1477  printf(" TABLE = ");
1478  break;
1480  printf(" SCHEMA = ");
1481  break;
1482  }
1483  dump_expr(opt->expr);
1484  printf("\n");
1485  }
1486  dump_indent -= 2;
1487  }
1488  dump_indent -= 2;
1489 }
#define printf(...)
Definition: port.h:198
PLpgSQL_raise_option_type opt_type
Definition: plpgsql.h:888
static void dump_ind(void)
Definition: pl_funcs.c:836
#define lfirst(lc)
Definition: pg_list.h:190
static int dump_indent
Definition: pl_funcs.c:799
PLpgSQL_expr * expr
Definition: plpgsql.h:889
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1618
int i

◆ dump_return()

static void dump_return ( PLpgSQL_stmt_return stmt)
static

Definition at line 1358 of file pl_funcs.c.

References dump_expr(), dump_ind(), PLpgSQL_stmt_return::expr, printf, and PLpgSQL_stmt_return::retvarno.

Referenced by dump_stmt().

1359 {
1360  dump_ind();
1361  printf("RETURN ");
1362  if (stmt->retvarno >= 0)
1363  printf("variable %d", stmt->retvarno);
1364  else if (stmt->expr != NULL)
1365  dump_expr(stmt->expr);
1366  else
1367  printf("NULL");
1368  printf("\n");
1369 }
PLpgSQL_expr * expr
Definition: plpgsql.h:839
#define printf(...)
Definition: port.h:198
static void dump_ind(void)
Definition: pl_funcs.c:836
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1618

◆ dump_return_next()

static void dump_return_next ( PLpgSQL_stmt_return_next stmt)
static

Definition at line 1372 of file pl_funcs.c.

References dump_expr(), dump_ind(), PLpgSQL_stmt_return_next::expr, printf, and PLpgSQL_stmt_return_next::retvarno.

Referenced by dump_stmt().

1373 {
1374  dump_ind();
1375  printf("RETURN NEXT ");
1376  if (stmt->retvarno >= 0)
1377  printf("variable %d", stmt->retvarno);
1378  else if (stmt->expr != NULL)
1379  dump_expr(stmt->expr);
1380  else
1381  printf("NULL");
1382  printf("\n");
1383 }
#define printf(...)
Definition: port.h:198
PLpgSQL_expr * expr
Definition: plpgsql.h:851
static void dump_ind(void)
Definition: pl_funcs.c:836
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1618

◆ dump_return_query()

static void dump_return_query ( PLpgSQL_stmt_return_query stmt)
static

Definition at line 1386 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, printf, and PLpgSQL_stmt_return_query::query.

Referenced by dump_stmt().

1387 {
1388  dump_ind();
1389  if (stmt->query)
1390  {
1391  printf("RETURN QUERY ");
1392  dump_expr(stmt->query);
1393  printf("\n");
1394  }
1395  else
1396  {
1397  printf("RETURN QUERY EXECUTE ");
1398  dump_expr(stmt->dynquery);
1399  printf("\n");
1400  if (stmt->params != NIL)
1401  {
1402  ListCell *lc;
1403  int i;
1404 
1405  dump_indent += 2;
1406  dump_ind();
1407  printf(" USING\n");
1408  dump_indent += 2;
1409  i = 1;
1410  foreach(lc, stmt->params)
1411  {
1412  dump_ind();
1413  printf(" parameter $%d: ", i++);
1414  dump_expr((PLpgSQL_expr *) lfirst(lc));
1415  printf("\n");
1416  }
1417  dump_indent -= 4;
1418  }
1419  }
1420 }
#define NIL
Definition: pg_list.h:65
#define printf(...)
Definition: port.h:198
PLpgSQL_expr * query
Definition: plpgsql.h:863
static void dump_ind(void)
Definition: pl_funcs.c:836
#define lfirst(lc)
Definition: pg_list.h:190
static int dump_indent
Definition: pl_funcs.c:799
PLpgSQL_expr * dynquery
Definition: plpgsql.h:864
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1618
int i

◆ dump_rollback()

static void dump_rollback ( PLpgSQL_stmt_rollback stmt)
static

Definition at line 1326 of file pl_funcs.c.

References PLpgSQL_stmt_rollback::chain, dump_ind(), and printf.

Referenced by dump_stmt().

1327 {
1328  dump_ind();
1329  if (stmt->chain)
1330  printf("ROLLBACK AND CHAIN\n");
1331  else
1332  printf("ROLLBACK\n");
1333 }
#define printf(...)
Definition: port.h:198
static void dump_ind(void)
Definition: pl_funcs.c:836

◆ dump_set()

static void dump_set ( PLpgSQL_stmt_set stmt)
static

Definition at line 1336 of file pl_funcs.c.

References dump_ind(), PLpgSQL_stmt_set::expr, printf, and PLpgSQL_expr::query.

Referenced by dump_stmt().

1337 {
1338  dump_ind();
1339  printf("%s\n", stmt->expr->query);
1340 }
char * query
Definition: plpgsql.h:221
#define printf(...)
Definition: port.h:198
PLpgSQL_expr * expr
Definition: plpgsql.h:582
static void dump_ind(void)
Definition: pl_funcs.c:836

◆ dump_stmt()

static void dump_stmt ( PLpgSQL_stmt stmt)
static

Definition at line 845 of file pl_funcs.c.

References PLpgSQL_stmt::cmd_type, PLpgSQL_stmt_set::cmd_type, dump_assert(), dump_assign(), dump_block(), dump_call(), dump_case(), dump_close(), dump_commit(), 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_rollback(), dump_set(), dump_while(), elog, ERROR, PLpgSQL_stmt::lineno, PLPGSQL_STMT_ASSERT, PLPGSQL_STMT_ASSIGN, PLPGSQL_STMT_BLOCK, PLPGSQL_STMT_CALL, PLPGSQL_STMT_CASE, PLPGSQL_STMT_CLOSE, PLPGSQL_STMT_COMMIT, 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, PLPGSQL_STMT_ROLLBACK, PLPGSQL_STMT_SET, PLPGSQL_STMT_WHILE, and printf.

Referenced by dump_stmts().

846 {
847  printf("%3d:", stmt->lineno);
848  switch (stmt->cmd_type)
849  {
850  case PLPGSQL_STMT_BLOCK:
851  dump_block((PLpgSQL_stmt_block *) stmt);
852  break;
853  case PLPGSQL_STMT_ASSIGN:
855  break;
856  case PLPGSQL_STMT_IF:
857  dump_if((PLpgSQL_stmt_if *) stmt);
858  break;
859  case PLPGSQL_STMT_CASE:
860  dump_case((PLpgSQL_stmt_case *) stmt);
861  break;
862  case PLPGSQL_STMT_LOOP:
863  dump_loop((PLpgSQL_stmt_loop *) stmt);
864  break;
865  case PLPGSQL_STMT_WHILE:
866  dump_while((PLpgSQL_stmt_while *) stmt);
867  break;
868  case PLPGSQL_STMT_FORI:
869  dump_fori((PLpgSQL_stmt_fori *) stmt);
870  break;
871  case PLPGSQL_STMT_FORS:
872  dump_fors((PLpgSQL_stmt_fors *) stmt);
873  break;
874  case PLPGSQL_STMT_FORC:
875  dump_forc((PLpgSQL_stmt_forc *) stmt);
876  break;
879  break;
880  case PLPGSQL_STMT_EXIT:
881  dump_exit((PLpgSQL_stmt_exit *) stmt);
882  break;
883  case PLPGSQL_STMT_RETURN:
885  break;
888  break;
891  break;
892  case PLPGSQL_STMT_RAISE:
893  dump_raise((PLpgSQL_stmt_raise *) stmt);
894  break;
895  case PLPGSQL_STMT_ASSERT:
897  break;
900  break;
903  break;
906  break;
909  break;
910  case PLPGSQL_STMT_OPEN:
911  dump_open((PLpgSQL_stmt_open *) stmt);
912  break;
913  case PLPGSQL_STMT_FETCH:
914  dump_fetch((PLpgSQL_stmt_fetch *) stmt);
915  break;
916  case PLPGSQL_STMT_CLOSE:
917  dump_close((PLpgSQL_stmt_close *) stmt);
918  break;
921  break;
922  case PLPGSQL_STMT_CALL:
923  dump_call((PLpgSQL_stmt_call *) stmt);
924  break;
925  case PLPGSQL_STMT_COMMIT:
927  break;
930  break;
931  case PLPGSQL_STMT_SET:
932  dump_set((PLpgSQL_stmt_set *) stmt);
933  break;
934  default:
935  elog(ERROR, "unrecognized cmd_type: %d", stmt->cmd_type);
936  break;
937  }
938 }
int lineno
Definition: plpgsql.h:461
static void dump_raise(PLpgSQL_stmt_raise *stmt)
Definition: pl_funcs.c:1423
static void dump_perform(PLpgSQL_stmt_perform *stmt)
Definition: pl_funcs.c:1298
static void dump_forc(PLpgSQL_stmt_forc *stmt)
Definition: pl_funcs.c:1140
#define printf(...)
Definition: port.h:198
static void dump_rollback(PLpgSQL_stmt_rollback *stmt)
Definition: pl_funcs.c:1326
static void dump_fors(PLpgSQL_stmt_fors *stmt)
Definition: pl_funcs.c:1126
static void dump_fetch(PLpgSQL_stmt_fetch *stmt)
Definition: pl_funcs.c:1231
#define ERROR
Definition: elog.h:43
static void dump_case(PLpgSQL_stmt_case *stmt)
Definition: pl_funcs.c:1032
static void dump_getdiag(PLpgSQL_stmt_getdiag *stmt)
Definition: pl_funcs.c:1598
static void dump_if(PLpgSQL_stmt_if *stmt)
Definition: pl_funcs.c:1002
static void dump_return_query(PLpgSQL_stmt_return_query *stmt)
Definition: pl_funcs.c:1386
static void dump_return(PLpgSQL_stmt_return *stmt)
Definition: pl_funcs.c:1358
static void dump_set(PLpgSQL_stmt_set *stmt)
Definition: pl_funcs.c:1336
static void dump_return_next(PLpgSQL_stmt_return_next *stmt)
Definition: pl_funcs.c:1372
static void dump_loop(PLpgSQL_stmt_loop *stmt)
Definition: pl_funcs.c:1070
static void dump_close(PLpgSQL_stmt_close *stmt)
Definition: pl_funcs.c:1291
static void dump_while(PLpgSQL_stmt_while *stmt)
Definition: pl_funcs.c:1082
static void dump_execsql(PLpgSQL_stmt_execsql *stmt)
Definition: pl_funcs.c:1511
static void dump_dynexecute(PLpgSQL_stmt_dynexecute *stmt)
Definition: pl_funcs.c:1530
static void dump_dynfors(PLpgSQL_stmt_dynfors *stmt)
Definition: pl_funcs.c:1567
static void dump_block(PLpgSQL_stmt_block *block)
Definition: pl_funcs.c:952
static void dump_foreach_a(PLpgSQL_stmt_foreach_a *stmt)
Definition: pl_funcs.c:1163
#define elog(elevel,...)
Definition: elog.h:228
static void dump_commit(PLpgSQL_stmt_commit *stmt)
Definition: pl_funcs.c:1316
static void dump_assert(PLpgSQL_stmt_assert *stmt)
Definition: pl_funcs.c:1492
static void dump_open(PLpgSQL_stmt_open *stmt)
Definition: pl_funcs.c:1180
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:460
static void dump_fori(PLpgSQL_stmt_fori *stmt)
Definition: pl_funcs.c:1096
static void dump_call(PLpgSQL_stmt_call *stmt)
Definition: pl_funcs.c:1307
static void dump_assign(PLpgSQL_stmt_assign *stmt)
Definition: pl_funcs.c:993
static void dump_exit(PLpgSQL_stmt_exit *stmt)
Definition: pl_funcs.c:1343

◆ dump_stmts()

static void dump_stmts ( List stmts)
static

Definition at line 941 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().

942 {
943  ListCell *s;
944 
945  dump_indent += 2;
946  foreach(s, stmts)
947  dump_stmt((PLpgSQL_stmt *) lfirst(s));
948  dump_indent -= 2;
949 }
#define lfirst(lc)
Definition: pg_list.h:190
static int dump_indent
Definition: pl_funcs.c:799
static void dump_stmt(PLpgSQL_stmt *stmt)
Definition: pl_funcs.c:845

◆ dump_while()

static void dump_while ( PLpgSQL_stmt_while stmt)
static

Definition at line 1082 of file pl_funcs.c.

References PLpgSQL_stmt_while::body, PLpgSQL_stmt_while::cond, dump_expr(), dump_ind(), dump_stmts(), and printf.

Referenced by dump_stmt().

1083 {
1084  dump_ind();
1085  printf("WHILE ");
1086  dump_expr(stmt->cond);
1087  printf("\n");
1088 
1089  dump_stmts(stmt->body);
1090 
1091  dump_ind();
1092  printf(" ENDWHILE\n");
1093 }
PLpgSQL_expr * cond
Definition: plpgsql.h:676
#define printf(...)
Definition: port.h:198
static void dump_ind(void)
Definition: pl_funcs.c:836
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1618
static void dump_stmts(List *stmts)
Definition: pl_funcs.c:941

◆ free_assert()

static void free_assert ( PLpgSQL_stmt_assert stmt)
static

Definition at line 684 of file pl_funcs.c.

References PLpgSQL_stmt_assert::cond, free_expr(), and PLpgSQL_stmt_assert::message.

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

685 {
686  free_expr(stmt->cond);
687  free_expr(stmt->message);
688 }
PLpgSQL_expr * message
Definition: plpgsql.h:901
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:727
PLpgSQL_expr * cond
Definition: plpgsql.h:900

◆ free_assign()

static void free_assign ( PLpgSQL_stmt_assign stmt)
static

Definition at line 501 of file pl_funcs.c.

References PLpgSQL_stmt_assign::expr, and free_expr().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

502 {
503  free_expr(stmt->expr);
504 }
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:727
PLpgSQL_expr * expr
Definition: plpgsql.h:525

◆ free_block()

static void free_block ( PLpgSQL_stmt_block block)
static

Definition at line 484 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(), plpgsql_free_function_memory(), and plpgsql_getdiag_kindname().

485 {
486  free_stmts(block->body);
487  if (block->exceptions)
488  {
489  ListCell *e;
490 
491  foreach(e, block->exceptions->exc_list)
492  {
494 
495  free_stmts(exc->action);
496  }
497  }
498 }
static void free_stmts(List *stmts)
Definition: pl_funcs.c:473
#define lfirst(lc)
Definition: pg_list.h:190
PLpgSQL_exception_block * exceptions
Definition: plpgsql.h:513
e
Definition: preproc-init.c:82

◆ free_call()

static void free_call ( PLpgSQL_stmt_call stmt)
static

Definition at line 614 of file pl_funcs.c.

References PLpgSQL_stmt_call::expr, and free_expr().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

615 {
616  free_expr(stmt->expr);
617 }
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:727
PLpgSQL_expr * expr
Definition: plpgsql.h:547

◆ free_case()

static void free_case ( PLpgSQL_stmt_case stmt)
static

Definition at line 524 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(), and plpgsql_getdiag_kindname().

525 {
526  ListCell *l;
527 
528  free_expr(stmt->t_expr);
529  foreach(l, stmt->case_when_list)
530  {
532 
533  free_expr(cwt->expr);
534  free_stmts(cwt->stmts);
535  }
536  free_stmts(stmt->else_stmts);
537 }
List * else_stmts
Definition: plpgsql.h:642
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:727
PLpgSQL_expr * expr
Definition: plpgsql.h:651
List * case_when_list
Definition: plpgsql.h:640
static void free_stmts(List *stmts)
Definition: pl_funcs.c:473
#define lfirst(lc)
Definition: pg_list.h:190
PLpgSQL_expr * t_expr
Definition: plpgsql.h:638

◆ free_close()

static void free_close ( PLpgSQL_stmt_close stmt)
static

Definition at line 603 of file pl_funcs.c.

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

604 {
605 }

◆ free_commit()

static void free_commit ( PLpgSQL_stmt_commit stmt)
static

Definition at line 620 of file pl_funcs.c.

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

621 {
622 }

◆ free_dynexecute()

static void free_dynexecute ( PLpgSQL_stmt_dynexecute stmt)
static

Definition at line 697 of file pl_funcs.c.

References free_expr(), lfirst, PLpgSQL_stmt_dynexecute::params, and PLpgSQL_stmt_dynexecute::query.

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

698 {
699  ListCell *lc;
700 
701  free_expr(stmt->query);
702  foreach(lc, stmt->params)
703  {
704  free_expr((PLpgSQL_expr *) lfirst(lc));
705  }
706 }
PLpgSQL_expr * query
Definition: plpgsql.h:928
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:727
#define lfirst(lc)
Definition: pg_list.h:190

◆ free_dynfors()

static void free_dynfors ( PLpgSQL_stmt_dynfors stmt)
static

Definition at line 709 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(), and plpgsql_getdiag_kindname().

710 {
711  ListCell *lc;
712 
713  free_stmts(stmt->body);
714  free_expr(stmt->query);
715  foreach(lc, stmt->params)
716  {
717  free_expr((PLpgSQL_expr *) lfirst(lc));
718  }
719 }
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:727
PLpgSQL_expr * query
Definition: plpgsql.h:755
static void free_stmts(List *stmts)
Definition: pl_funcs.c:473
#define lfirst(lc)
Definition: pg_list.h:190

◆ free_execsql()

static void free_execsql ( PLpgSQL_stmt_execsql stmt)
static

Definition at line 691 of file pl_funcs.c.

References free_expr(), and PLpgSQL_stmt_execsql::sqlstmt.

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

692 {
693  free_expr(stmt->sqlstmt);
694 }
PLpgSQL_expr * sqlstmt
Definition: plpgsql.h:912
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:727

◆ free_exit()

static void free_exit ( PLpgSQL_stmt_exit stmt)
static

Definition at line 636 of file pl_funcs.c.

References PLpgSQL_stmt_exit::cond, and free_expr().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

637 {
638  free_expr(stmt->cond);
639 }
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:727
PLpgSQL_expr * cond
Definition: plpgsql.h:828

◆ free_expr()

static void free_expr ( PLpgSQL_expr expr)
static

◆ free_fetch()

static void free_fetch ( PLpgSQL_stmt_fetch stmt)
static

Definition at line 597 of file pl_funcs.c.

References PLpgSQL_stmt_fetch::expr, and free_expr().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

598 {
599  free_expr(stmt->expr);
600 }
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:727
PLpgSQL_expr * expr
Definition: plpgsql.h:802

◆ free_forc()

static void free_forc ( PLpgSQL_stmt_forc stmt)
static

Definition at line 569 of file pl_funcs.c.

References PLpgSQL_stmt_forc::argquery, PLpgSQL_stmt_forc::body, free_expr(), and free_stmts().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

570 {
571  free_stmts(stmt->body);
572  free_expr(stmt->argquery);
573 }
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:727
static void free_stmts(List *stmts)
Definition: pl_funcs.c:473
PLpgSQL_expr * argquery
Definition: plpgsql.h:740

◆ free_foreach_a()

static void free_foreach_a ( PLpgSQL_stmt_foreach_a stmt)
static

Definition at line 576 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(), and plpgsql_getdiag_kindname().

577 {
578  free_expr(stmt->expr);
579  free_stmts(stmt->body);
580 }
PLpgSQL_expr * expr
Definition: plpgsql.h:770
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:727
static void free_stmts(List *stmts)
Definition: pl_funcs.c:473

◆ free_fori()

static void free_fori ( PLpgSQL_stmt_fori stmt)
static

Definition at line 553 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(), and plpgsql_getdiag_kindname().

554 {
555  free_expr(stmt->lower);
556  free_expr(stmt->upper);
557  free_expr(stmt->step);
558  free_stmts(stmt->body);
559 }
PLpgSQL_expr * lower
Definition: plpgsql.h:690
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:727
static void free_stmts(List *stmts)
Definition: pl_funcs.c:473
PLpgSQL_expr * step
Definition: plpgsql.h:692
PLpgSQL_expr * upper
Definition: plpgsql.h:691

◆ free_fors()

static void free_fors ( PLpgSQL_stmt_fors stmt)
static

Definition at line 562 of file pl_funcs.c.

References PLpgSQL_stmt_fors::body, free_expr(), free_stmts(), and PLpgSQL_stmt_fors::query.

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

563 {
564  free_stmts(stmt->body);
565  free_expr(stmt->query);
566 }
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:727
static void free_stmts(List *stmts)
Definition: pl_funcs.c:473
PLpgSQL_expr * query
Definition: plpgsql.h:724

◆ free_getdiag()

static void free_getdiag ( PLpgSQL_stmt_getdiag stmt)
static

Definition at line 722 of file pl_funcs.c.

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

723 {
724 }

◆ free_if()

static void free_if ( PLpgSQL_stmt_if stmt)
static

Definition at line 507 of file pl_funcs.c.

References PLpgSQL_stmt_if::cond, PLpgSQL_if_elsif::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(), and plpgsql_getdiag_kindname().

508 {
509  ListCell *l;
510 
511  free_expr(stmt->cond);
512  free_stmts(stmt->then_body);
513  foreach(l, stmt->elsif_list)
514  {
516 
517  free_expr(elif->cond);
518  free_stmts(elif->stmts);
519  }
520  free_stmts(stmt->else_body);
521 }
PLpgSQL_expr * cond
Definition: plpgsql.h:614
List * then_body
Definition: plpgsql.h:615
List * elsif_list
Definition: plpgsql.h:616
List * stmts
Definition: plpgsql.h:627
PLpgSQL_expr * cond
Definition: plpgsql.h:626
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:727
static void free_stmts(List *stmts)
Definition: pl_funcs.c:473
#define lfirst(lc)
Definition: pg_list.h:190
List * else_body
Definition: plpgsql.h:617

◆ free_loop()

static void free_loop ( PLpgSQL_stmt_loop stmt)
static

Definition at line 540 of file pl_funcs.c.

References PLpgSQL_stmt_loop::body, and free_stmts().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

541 {
542  free_stmts(stmt->body);
543 }
static void free_stmts(List *stmts)
Definition: pl_funcs.c:473

◆ free_open()

static void free_open ( PLpgSQL_stmt_open stmt)
static

Definition at line 583 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(), and plpgsql_getdiag_kindname().

584 {
585  ListCell *lc;
586 
587  free_expr(stmt->argquery);
588  free_expr(stmt->query);
589  free_expr(stmt->dynquery);
590  foreach(lc, stmt->params)
591  {
592  free_expr((PLpgSQL_expr *) lfirst(lc));
593  }
594 }
PLpgSQL_expr * dynquery
Definition: plpgsql.h:786
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:727
PLpgSQL_expr * query
Definition: plpgsql.h:785
#define lfirst(lc)
Definition: pg_list.h:190
PLpgSQL_expr * argquery
Definition: plpgsql.h:784

◆ free_perform()

static void free_perform ( PLpgSQL_stmt_perform stmt)
static

Definition at line 608 of file pl_funcs.c.

References PLpgSQL_stmt_perform::expr, and free_expr().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

609 {
610  free_expr(stmt->expr);
611 }
PLpgSQL_expr * expr
Definition: plpgsql.h:536
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:727

◆ free_raise()

static void free_raise ( PLpgSQL_stmt_raise stmt)
static

Definition at line 667 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(), and plpgsql_getdiag_kindname().

668 {
669  ListCell *lc;
670 
671  foreach(lc, stmt->params)
672  {
673  free_expr((PLpgSQL_expr *) lfirst(lc));
674  }
675  foreach(lc, stmt->options)
676  {
678 
679  free_expr(opt->expr);
680  }
681 }
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:727
#define lfirst(lc)
Definition: pg_list.h:190
PLpgSQL_expr * expr
Definition: plpgsql.h:889

◆ free_return()

static void free_return ( PLpgSQL_stmt_return stmt)
static

Definition at line 642 of file pl_funcs.c.

References PLpgSQL_stmt_return::expr, and free_expr().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

643 {
644  free_expr(stmt->expr);
645 }
PLpgSQL_expr * expr
Definition: plpgsql.h:839
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:727

◆ free_return_next()

static void free_return_next ( PLpgSQL_stmt_return_next stmt)
static

Definition at line 648 of file pl_funcs.c.

References PLpgSQL_stmt_return_next::expr, and free_expr().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

649 {
650  free_expr(stmt->expr);
651 }
PLpgSQL_expr * expr
Definition: plpgsql.h:851
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:727

◆ free_return_query()

static void free_return_query ( PLpgSQL_stmt_return_query stmt)
static

Definition at line 654 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(), and plpgsql_getdiag_kindname().

655 {
656  ListCell *lc;
657 
658  free_expr(stmt->query);
659  free_expr(stmt->dynquery);
660  foreach(lc, stmt->params)
661  {
662  free_expr((PLpgSQL_expr *) lfirst(lc));
663  }
664 }
PLpgSQL_expr * query
Definition: plpgsql.h:863
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:727
#define lfirst(lc)
Definition: pg_list.h:190
PLpgSQL_expr * dynquery
Definition: plpgsql.h:864

◆ free_rollback()

static void free_rollback ( PLpgSQL_stmt_rollback stmt)
static

Definition at line 625 of file pl_funcs.c.

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

626 {
627 }

◆ free_set()

static void free_set ( PLpgSQL_stmt_set stmt)
static

Definition at line 630 of file pl_funcs.c.

References PLpgSQL_stmt_set::expr, and free_expr().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

631 {
632  free_expr(stmt->expr);
633 }
PLpgSQL_expr * expr
Definition: plpgsql.h:582
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:727

◆ free_stmt()

static void free_stmt ( PLpgSQL_stmt stmt)
static

Definition at line 378 of file pl_funcs.c.

References PLpgSQL_stmt::cmd_type, PLpgSQL_stmt_set::cmd_type, elog, ERROR, free_assert(), free_assign(), free_block(), free_call(), free_case(), free_close(), free_commit(), 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_rollback(), free_set(), free_while(), PLPGSQL_STMT_ASSERT, PLPGSQL_STMT_ASSIGN, PLPGSQL_STMT_BLOCK, PLPGSQL_STMT_CALL, PLPGSQL_STMT_CASE, PLPGSQL_STMT_CLOSE, PLPGSQL_STMT_COMMIT, 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, PLPGSQL_STMT_ROLLBACK, PLPGSQL_STMT_SET, and PLPGSQL_STMT_WHILE.

Referenced by free_stmts(), and plpgsql_getdiag_kindname().

379 {
380  switch (stmt->cmd_type)
381  {
382  case PLPGSQL_STMT_BLOCK:
383  free_block((PLpgSQL_stmt_block *) stmt);
384  break;
385  case PLPGSQL_STMT_ASSIGN:
387  break;
388  case PLPGSQL_STMT_IF:
389  free_if((PLpgSQL_stmt_if *) stmt);
390  break;
391  case PLPGSQL_STMT_CASE:
392  free_case((PLpgSQL_stmt_case *) stmt);
393  break;
394  case PLPGSQL_STMT_LOOP:
395  free_loop((PLpgSQL_stmt_loop *) stmt);
396  break;
397  case PLPGSQL_STMT_WHILE:
398  free_while((PLpgSQL_stmt_while *) stmt);
399  break;
400  case PLPGSQL_STMT_FORI:
401  free_fori((PLpgSQL_stmt_fori *) stmt);
402  break;
403  case PLPGSQL_STMT_FORS:
404  free_fors((PLpgSQL_stmt_fors *) stmt);
405  break;
406  case PLPGSQL_STMT_FORC:
407  free_forc((PLpgSQL_stmt_forc *) stmt);
408  break;
411  break;
412  case PLPGSQL_STMT_EXIT:
413  free_exit((PLpgSQL_stmt_exit *) stmt);
414  break;
415  case PLPGSQL_STMT_RETURN:
417  break;
420  break;
423  break;
424  case PLPGSQL_STMT_RAISE:
425  free_raise((PLpgSQL_stmt_raise *) stmt);
426  break;
427  case PLPGSQL_STMT_ASSERT:
429  break;
432  break;
435  break;
438  break;
441  break;
442  case PLPGSQL_STMT_OPEN:
443  free_open((PLpgSQL_stmt_open *) stmt);
444  break;
445  case PLPGSQL_STMT_FETCH:
446  free_fetch((PLpgSQL_stmt_fetch *) stmt);
447  break;
448  case PLPGSQL_STMT_CLOSE:
449  free_close((PLpgSQL_stmt_close *) stmt);
450  break;
453  break;
454  case PLPGSQL_STMT_CALL:
455  free_call((PLpgSQL_stmt_call *) stmt);
456  break;
457  case PLPGSQL_STMT_COMMIT:
459  break;
462  break;
463  case PLPGSQL_STMT_SET:
464  free_set((PLpgSQL_stmt_set *) stmt);
465  break;
466  default:
467  elog(ERROR, "unrecognized cmd_type: %d", stmt->cmd_type);
468  break;
469  }
470 }
static void free_assert(PLpgSQL_stmt_assert *stmt)
Definition: pl_funcs.c:684
static void free_dynexecute(PLpgSQL_stmt_dynexecute *stmt)
Definition: pl_funcs.c:697
static void free_raise(PLpgSQL_stmt_raise *stmt)
Definition: pl_funcs.c:667
static void free_open(PLpgSQL_stmt_open *stmt)
Definition: pl_funcs.c:583
static void free_return(PLpgSQL_stmt_return *stmt)
Definition: pl_funcs.c:642
static void free_loop(PLpgSQL_stmt_loop *stmt)
Definition: pl_funcs.c:540
static void free_dynfors(PLpgSQL_stmt_dynfors *stmt)
Definition: pl_funcs.c:709
static void free_set(PLpgSQL_stmt_set *stmt)
Definition: pl_funcs.c:630
static void free_rollback(PLpgSQL_stmt_rollback *stmt)
Definition: pl_funcs.c:625
static void free_assign(PLpgSQL_stmt_assign *stmt)
Definition: pl_funcs.c:501
static void free_getdiag(PLpgSQL_stmt_getdiag *stmt)
Definition: pl_funcs.c:722
#define ERROR
Definition: elog.h:43
static void free_fetch(PLpgSQL_stmt_fetch *stmt)
Definition: pl_funcs.c:597
static void free_close(PLpgSQL_stmt_close *stmt)
Definition: pl_funcs.c:603
static void free_case(PLpgSQL_stmt_case *stmt)
Definition: pl_funcs.c:524
static void free_fori(PLpgSQL_stmt_fori *stmt)
Definition: pl_funcs.c:553
static void free_perform(PLpgSQL_stmt_perform *stmt)
Definition: pl_funcs.c:608
static void free_return_next(PLpgSQL_stmt_return_next *stmt)
Definition: pl_funcs.c:648
static void free_call(PLpgSQL_stmt_call *stmt)
Definition: pl_funcs.c:614
static void free_fors(PLpgSQL_stmt_fors *stmt)
Definition: pl_funcs.c:562
static void free_exit(PLpgSQL_stmt_exit *stmt)
Definition: pl_funcs.c:636
static void free_if(PLpgSQL_stmt_if *stmt)
Definition: pl_funcs.c:507
static void free_return_query(PLpgSQL_stmt_return_query *stmt)
Definition: pl_funcs.c:654
static void free_execsql(PLpgSQL_stmt_execsql *stmt)
Definition: pl_funcs.c:691
static void free_forc(PLpgSQL_stmt_forc *stmt)
Definition: pl_funcs.c:569
#define elog(elevel,...)
Definition: elog.h:228
static void free_commit(PLpgSQL_stmt_commit *stmt)
Definition: pl_funcs.c:620
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:460
static void free_while(PLpgSQL_stmt_while *stmt)
Definition: pl_funcs.c:546
static void free_foreach_a(PLpgSQL_stmt_foreach_a *stmt)
Definition: pl_funcs.c:576
static void free_block(PLpgSQL_stmt_block *block)
Definition: pl_funcs.c:484

◆ free_stmts()

static void free_stmts ( List stmts)
static

Definition at line 473 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().

474 {
475  ListCell *s;
476 
477  foreach(s, stmts)
478  {
479  free_stmt((PLpgSQL_stmt *) lfirst(s));
480  }
481 }
#define lfirst(lc)
Definition: pg_list.h:190
static void free_stmt(PLpgSQL_stmt *stmt)
Definition: pl_funcs.c:378

◆ free_while()

static void free_while ( PLpgSQL_stmt_while stmt)
static

Definition at line 546 of file pl_funcs.c.

References PLpgSQL_stmt_while::body, PLpgSQL_stmt_while::cond, free_expr(), and free_stmts().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

547 {
548  free_expr(stmt->cond);
549  free_stmts(stmt->body);
550 }
PLpgSQL_expr * cond
Definition: plpgsql.h:676
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:727
static void free_stmts(List *stmts)
Definition: pl_funcs.c:473

◆ plpgsql_dumptree()

void plpgsql_dumptree ( PLpgSQL_function func)

Definition at line 1624 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_datum::dtype, PLpgSQL_arrayelem::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, PLPGSQL_DTYPE_ARRAYELEM, PLPGSQL_DTYPE_PROMISE, PLPGSQL_DTYPE_REC, PLPGSQL_DTYPE_RECFIELD, PLPGSQL_DTYPE_ROW, PLPGSQL_DTYPE_VAR, PLPGSQL_PROMISE_NONE, printf, PLpgSQL_var::promise, PLpgSQL_var::refname, PLpgSQL_row::refname, generate_unaccent_rules::stdout, PLpgSQL_type::typname, PLpgSQL_type::typoid, and PLpgSQL_row::varnos.

Referenced by do_compile().

1625 {
1626  int i;
1627  PLpgSQL_datum *d;
1628 
1629  printf("\nExecution tree of successfully compiled PL/pgSQL function %s:\n",
1630  func->fn_signature);
1631 
1632  printf("\nFunction's data area:\n");
1633  for (i = 0; i < func->ndatums; i++)
1634  {
1635  d = func->datums[i];
1636 
1637  printf(" entry %d: ", i);
1638  switch (d->dtype)
1639  {
1640  case PLPGSQL_DTYPE_VAR:
1641  case PLPGSQL_DTYPE_PROMISE:
1642  {
1643  PLpgSQL_var *var = (PLpgSQL_var *) d;
1644 
1645  printf("VAR %-16s type %s (typoid %u) atttypmod %d\n",
1646  var->refname, var->datatype->typname,
1647  var->datatype->typoid,
1648  var->datatype->atttypmod);
1649  if (var->isconst)
1650  printf(" CONSTANT\n");
1651  if (var->notnull)
1652  printf(" NOT NULL\n");
1653  if (var->default_val != NULL)
1654  {
1655  printf(" DEFAULT ");
1656  dump_expr(var->default_val);
1657  printf("\n");
1658  }
1659  if (var->cursor_explicit_expr != NULL)
1660  {
1661  if (var->cursor_explicit_argrow >= 0)
1662  printf(" CURSOR argument row %d\n", var->cursor_explicit_argrow);
1663 
1664  printf(" CURSOR IS ");
1666  printf("\n");
1667  }
1668  if (var->promise != PLPGSQL_PROMISE_NONE)
1669  printf(" PROMISE %d\n",
1670  (int) var->promise);
1671  }
1672  break;
1673  case PLPGSQL_DTYPE_ROW:
1674  {
1675  PLpgSQL_row *row = (PLpgSQL_row *) d;
1676  int i;
1677 
1678  printf("ROW %-16s fields", row->refname);
1679  for (i = 0; i < row->nfields; i++)
1680  {
1681  printf(" %s=var %d", row->fieldnames[i],
1682  row->varnos[i]);
1683  }
1684  printf("\n");
1685  }
1686  break;
1687  case PLPGSQL_DTYPE_REC:
1688  printf("REC %-16s typoid %u\n",
1689  ((PLpgSQL_rec *) d)->refname,
1690  ((PLpgSQL_rec *) d)->rectypeid);
1691  if (((PLpgSQL_rec *) d)->isconst)
1692  printf(" CONSTANT\n");
1693  if (((PLpgSQL_rec *) d)->notnull)
1694  printf(" NOT NULL\n");
1695  if (((PLpgSQL_rec *) d)->default_val != NULL)
1696  {
1697  printf(" DEFAULT ");
1698  dump_expr(((PLpgSQL_rec *) d)->default_val);
1699  printf("\n");
1700  }
1701  break;
1703  printf("RECFIELD %-16s of REC %d\n",
1704  ((PLpgSQL_recfield *) d)->fieldname,
1705  ((PLpgSQL_recfield *) d)->recparentno);
1706  break;
1708  printf("ARRAYELEM of VAR %d subscript ",
1709  ((PLpgSQL_arrayelem *) d)->arrayparentno);
1710  dump_expr(((PLpgSQL_arrayelem *) d)->subscript);
1711  printf("\n");
1712  break;
1713  default:
1714  printf("??? unknown data type %d\n", d->dtype);
1715  }
1716  }
1717  printf("\nFunction's statements:\n");
1718 
1719  dump_indent = 0;
1720  printf("%3d:", func->action->lineno);
1721  dump_block(func->action);
1722  printf("\nEnd of execution tree of function %s\n\n", func->fn_signature);
1723  fflush(stdout);
1724 }
PLpgSQL_promise_type promise
Definition: plpgsql.h:323
PLpgSQL_datum ** datums
Definition: plpgsql.h:1021
char * refname
Definition: plpgsql.h:348
char * refname
Definition: plpgsql.h:294
PLpgSQL_stmt_block * action
Definition: plpgsql.h:1025
PLpgSQL_expr * cursor_explicit_expr
Definition: plpgsql.h:308
PLpgSQL_type * datatype
Definition: plpgsql.h:301
bool isconst
Definition: plpgsql.h:296
#define printf(...)
Definition: port.h:198
PLpgSQL_datum_type dtype
Definition: plpgsql.h:258
bool notnull
Definition: plpgsql.h:297
int cursor_explicit_argrow
Definition: plpgsql.h:309
char ** fieldnames
Definition: plpgsql.h:363
PLpgSQL_expr * default_val
Definition: plpgsql.h:298
int * varnos
Definition: plpgsql.h:364
PLpgSQL_datum_type dtype
Definition: plpgsql.h:403
int nfields
Definition: plpgsql.h:362
static int dump_indent
Definition: pl_funcs.c:799
char * fn_signature
Definition: plpgsql.h:983
char * typname
Definition: plpgsql.h:201
static void dump_block(PLpgSQL_stmt_block *block)
Definition: pl_funcs.c:952
int32 atttypmod
Definition: plpgsql.h:209
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1618
int i
Oid typoid
Definition: plpgsql.h:202

◆ plpgsql_free_function_memory()

void plpgsql_free_function_memory ( PLpgSQL_function func)

Definition at line 737 of file pl_funcs.c.

References PLpgSQL_function::action, Assert, PLpgSQL_var::cursor_explicit_expr, PLpgSQL_function::datums, PLpgSQL_var::default_val, PLpgSQL_rec::default_val, PLpgSQL_datum::dtype, PLpgSQL_arrayelem::dtype, elog, ERROR, PLpgSQL_function::fn_cxt, free_block(), free_expr(), i, MemoryContextDelete(), PLpgSQL_function::ndatums, PLPGSQL_DTYPE_ARRAYELEM, PLPGSQL_DTYPE_PROMISE, 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().

738 {
739  int i;
740 
741  /* Better not call this on an in-use function */
742  Assert(func->use_count == 0);
743 
744  /* Release plans associated with variable declarations */
745  for (i = 0; i < func->ndatums; i++)
746  {
747  PLpgSQL_datum *d = func->datums[i];
748 
749  switch (d->dtype)
750  {
751  case PLPGSQL_DTYPE_VAR:
753  {
754  PLpgSQL_var *var = (PLpgSQL_var *) d;
755 
756  free_expr(var->default_val);
758  }
759  break;
760  case PLPGSQL_DTYPE_ROW:
761  break;
762  case PLPGSQL_DTYPE_REC:
763  {
764  PLpgSQL_rec *rec = (PLpgSQL_rec *) d;
765 
766  free_expr(rec->default_val);
767  }
768  break;
770  break;
772  free_expr(((PLpgSQL_arrayelem *) d)->subscript);
773  break;
774  default:
775  elog(ERROR, "unrecognized data type: %d", d->dtype);
776  }
777  }
778  func->ndatums = 0;
779 
780  /* Release plans in statement tree */
781  if (func->action)
782  free_block(func->action);
783  func->action = NULL;
784 
785  /*
786  * And finally, release all memory except the PLpgSQL_function struct
787  * itself (which has to be kept around because there may be multiple
788  * fn_extra pointers to it).
789  */
790  if (func->fn_cxt)
792  func->fn_cxt = NULL;
793 }
PLpgSQL_datum ** datums
Definition: plpgsql.h:1021
void MemoryContextDelete(MemoryContext context)
Definition: mcxt.c:211
PLpgSQL_stmt_block * action
Definition: plpgsql.h:1025
PLpgSQL_expr * cursor_explicit_expr
Definition: plpgsql.h:308
PLpgSQL_datum_type dtype
Definition: plpgsql.h:258
#define ERROR
Definition: elog.h:43
PLpgSQL_expr * default_val
Definition: plpgsql.h:298
unsigned long use_count
Definition: plpgsql.h:1029
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:727
MemoryContext fn_cxt
Definition: plpgsql.h:990
#define Assert(condition)
Definition: c.h:739
#define elog(elevel,...)
Definition: elog.h:228
int i
PLpgSQL_expr * default_val
Definition: plpgsql.h:378
static void free_block(PLpgSQL_stmt_block *block)
Definition: pl_funcs.c:484

◆ plpgsql_getdiag_kindname()

const char* plpgsql_getdiag_kindname ( PLpgSQL_getdiag_kind  kind)

Definition at line 302 of file pl_funcs.c.

References free_assert(), free_assign(), free_block(), free_call(), free_case(), free_close(), free_commit(), free_dynexecute(), free_dynfors(), free_execsql(), free_exit(), free_expr(), 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_rollback(), free_set(), free_stmt(), free_while(), PLPGSQL_GETDIAG_COLUMN_NAME, PLPGSQL_GETDIAG_CONSTRAINT_NAME, PLPGSQL_GETDIAG_CONTEXT, PLPGSQL_GETDIAG_DATATYPE_NAME, PLPGSQL_GETDIAG_ERROR_CONTEXT, PLPGSQL_GETDIAG_ERROR_DETAIL, PLPGSQL_GETDIAG_ERROR_HINT, PLPGSQL_GETDIAG_MESSAGE_TEXT, PLPGSQL_GETDIAG_RETURNED_SQLSTATE, PLPGSQL_GETDIAG_ROW_COUNT, PLPGSQL_GETDIAG_SCHEMA_NAME, and PLPGSQL_GETDIAG_TABLE_NAME.

Referenced by dump_getdiag().

303 {
304  switch (kind)
305  {
307  return "ROW_COUNT";
309  return "PG_CONTEXT";
311  return "PG_EXCEPTION_CONTEXT";
313  return "PG_EXCEPTION_DETAIL";
315  return "PG_EXCEPTION_HINT";
317  return "RETURNED_SQLSTATE";
319  return "COLUMN_NAME";
321  return "CONSTRAINT_NAME";
323  return "PG_DATATYPE_NAME";
325  return "MESSAGE_TEXT";
327  return "TABLE_NAME";
329  return "SCHEMA_NAME";
330  }
331 
332  return "unknown";
333 }

◆ plpgsql_ns_additem()

void plpgsql_ns_additem ( PLpgSQL_nsitem_type  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, ns_top, offsetof, palloc(), PLPGSQL_NSTYPE_LABEL, and PLpgSQL_nsitem::prev.

Referenced by add_parameter_name(), plpgsql_build_record(), plpgsql_build_variable(), and plpgsql_ns_push().

93 {
94  PLpgSQL_nsitem *nse;
95 
96  Assert(name != NULL);
97  /* first item added must be a label */
98  Assert(ns_top != NULL || itemtype == PLPGSQL_NSTYPE_LABEL);
99 
100  nse = palloc(offsetof(PLpgSQL_nsitem, name) + strlen(name) + 1);
101  nse->itemtype = itemtype;
102  nse->itemno = itemno;
103  nse->prev = ns_top;
104  strcpy(nse->name, name);
105  ns_top = nse;
106 }
static PLpgSQL_nsitem * ns_top
Definition: pl_funcs.c:35
struct PLpgSQL_nsitem * prev
Definition: plpgsql.h:451
#define Assert(condition)
Definition: c.h:739
const char * name
Definition: encode.c:521
void * palloc(Size size)
Definition: mcxt.c:949
PLpgSQL_nsitem_type itemtype
Definition: plpgsql.h:444
char name[FLEXIBLE_ARRAY_MEMBER]
Definition: plpgsql.h:452
#define offsetof(type, field)
Definition: c.h:662

◆ plpgsql_ns_find_nearest_loop()

PLpgSQL_nsitem* plpgsql_ns_find_nearest_loop ( PLpgSQL_nsitem ns_cur)

Definition at line 214 of file pl_funcs.c.

References PLpgSQL_nsitem::itemno, PLpgSQL_nsitem::itemtype, PLPGSQL_LABEL_LOOP, PLPGSQL_NSTYPE_LABEL, and PLpgSQL_nsitem::prev.

215 {
216  while (ns_cur != NULL)
217  {
218  if (ns_cur->itemtype == PLPGSQL_NSTYPE_LABEL &&
219  ns_cur->itemno == PLPGSQL_LABEL_LOOP)
220  return ns_cur;
221  ns_cur = ns_cur->prev;
222  }
223 
224  return NULL; /* no loop found */
225 }
struct PLpgSQL_nsitem * prev
Definition: plpgsql.h:451
PLpgSQL_nsitem_type itemtype
Definition: plpgsql.h:444

◆ plpgsql_ns_init()

void plpgsql_ns_init ( void  )

Definition at line 43 of file pl_funcs.c.

Referenced by do_compile(), and plpgsql_compile_inline().

44 {
45  ns_top = NULL;
46 }
static PLpgSQL_nsitem * ns_top
Definition: pl_funcs.c:35

◆ plpgsql_ns_lookup()

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, PLPGSQL_NSTYPE_LABEL, 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().

133 {
134  /* Outer loop iterates once per block level in the namespace chain */
135  while (ns_cur != NULL)
136  {
137  PLpgSQL_nsitem *nsitem;
138 
139  /* Check this level for unqualified match to variable name */
140  for (nsitem = ns_cur;
141  nsitem->itemtype != PLPGSQL_NSTYPE_LABEL;
142  nsitem = nsitem->prev)
143  {
144  if (strcmp(nsitem->name, name1) == 0)
145  {
146  if (name2 == NULL ||
147  nsitem->itemtype != PLPGSQL_NSTYPE_VAR)
148  {
149  if (names_used)
150  *names_used = 1;
151  return nsitem;
152  }
153  }
154  }
155 
156  /* Check this level for qualified match to variable name */
157  if (name2 != NULL &&
158  strcmp(nsitem->name, name1) == 0)
159  {
160  for (nsitem = ns_cur;
161  nsitem->itemtype != PLPGSQL_NSTYPE_LABEL;
162  nsitem = nsitem->prev)
163  {
164  if (strcmp(nsitem->name, name2) == 0)
165  {
166  if (name3 == NULL ||
167  nsitem->itemtype != PLPGSQL_NSTYPE_VAR)
168  {
169  if (names_used)
170  *names_used = 2;
171  return nsitem;
172  }
173  }
174  }
175  }
176 
177  if (localmode)
178  break; /* do not look into upper levels */
179 
180  ns_cur = nsitem->prev;
181  }
182 
183  /* This is just to suppress possibly-uninitialized-variable warnings */
184  if (names_used)
185  *names_used = 0;
186  return NULL; /* No match found */
187 }
struct PLpgSQL_nsitem * prev
Definition: plpgsql.h:451
PLpgSQL_nsitem_type itemtype
Definition: plpgsql.h:444
char name[FLEXIBLE_ARRAY_MEMBER]
Definition: plpgsql.h:452

◆ plpgsql_ns_lookup_label()

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, PLPGSQL_NSTYPE_LABEL, and PLpgSQL_nsitem::prev.

196 {
197  while (ns_cur != NULL)
198  {
199  if (ns_cur->itemtype == PLPGSQL_NSTYPE_LABEL &&
200  strcmp(ns_cur->name, name) == 0)
201  return ns_cur;
202  ns_cur = ns_cur->prev;
203  }
204 
205  return NULL; /* label not found */
206 }
struct PLpgSQL_nsitem * prev
Definition: plpgsql.h:451
const char * name
Definition: encode.c:521
PLpgSQL_nsitem_type itemtype
Definition: plpgsql.h:444
char name[FLEXIBLE_ARRAY_MEMBER]
Definition: plpgsql.h:452

◆ plpgsql_ns_pop()

void plpgsql_ns_pop ( void  )

Definition at line 67 of file pl_funcs.c.

References Assert, PLpgSQL_nsitem::itemtype, PLPGSQL_NSTYPE_LABEL, and PLpgSQL_nsitem::prev.

68 {
69  Assert(ns_top != NULL);
71  ns_top = ns_top->prev;
72  ns_top = ns_top->prev;
73 }
static PLpgSQL_nsitem * ns_top
Definition: pl_funcs.c:35
struct PLpgSQL_nsitem * prev
Definition: plpgsql.h:451
#define Assert(condition)
Definition: c.h:739
PLpgSQL_nsitem_type itemtype
Definition: plpgsql.h:444

◆ plpgsql_ns_push()

void plpgsql_ns_push ( const char *  label,
PLpgSQL_label_type  label_type 
)

Definition at line 54 of file pl_funcs.c.

References plpgsql_ns_additem(), and PLPGSQL_NSTYPE_LABEL.

Referenced by do_compile(), and plpgsql_compile_inline().

55 {
56  if (label == NULL)
57  label = "";
58  plpgsql_ns_additem(PLPGSQL_NSTYPE_LABEL, (int) label_type, label);
59 }
void plpgsql_ns_additem(PLpgSQL_nsitem_type itemtype, int itemno, const char *name)
Definition: pl_funcs.c:92
static char * label

◆ plpgsql_ns_top()

PLpgSQL_nsitem* plpgsql_ns_top ( void  )

Definition at line 81 of file pl_funcs.c.

References ns_top.

Referenced by add_parameter_name(), plpgsql_parse_cwordtype(), plpgsql_parse_dblword(), plpgsql_parse_tripword(), plpgsql_parse_word(), and plpgsql_parse_wordtype().

82 {
83  return ns_top;
84 }
static PLpgSQL_nsitem * ns_top
Definition: pl_funcs.c:35

◆ plpgsql_stmt_typename()

const char* plpgsql_stmt_typename ( PLpgSQL_stmt stmt)

Definition at line 232 of file pl_funcs.c.

References _, PLpgSQL_stmt::cmd_type, PLPGSQL_STMT_ASSERT, PLPGSQL_STMT_ASSIGN, PLPGSQL_STMT_BLOCK, PLPGSQL_STMT_CALL, PLPGSQL_STMT_CASE, PLPGSQL_STMT_CLOSE, PLPGSQL_STMT_COMMIT, 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, PLPGSQL_STMT_ROLLBACK, PLPGSQL_STMT_SET, and PLPGSQL_STMT_WHILE.

Referenced by plpgsql_exec_error_callback().

233 {
234  switch (stmt->cmd_type)
235  {
236  case PLPGSQL_STMT_BLOCK:
237  return _("statement block");
238  case PLPGSQL_STMT_ASSIGN:
239  return _("assignment");
240  case PLPGSQL_STMT_IF:
241  return "IF";
242  case PLPGSQL_STMT_CASE:
243  return "CASE";
244  case PLPGSQL_STMT_LOOP:
245  return "LOOP";
246  case PLPGSQL_STMT_WHILE:
247  return "WHILE";
248  case PLPGSQL_STMT_FORI:
249  return _("FOR with integer loop variable");
250  case PLPGSQL_STMT_FORS:
251  return _("FOR over SELECT rows");
252  case PLPGSQL_STMT_FORC:
253  return _("FOR over cursor");
255  return _("FOREACH over array");
256  case PLPGSQL_STMT_EXIT:
257  return ((PLpgSQL_stmt_exit *) stmt)->is_exit ? "EXIT" : "CONTINUE";
258  case PLPGSQL_STMT_RETURN:
259  return "RETURN";
261  return "RETURN NEXT";
263  return "RETURN QUERY";
264  case PLPGSQL_STMT_RAISE:
265  return "RAISE";
266  case PLPGSQL_STMT_ASSERT:
267  return "ASSERT";
269  return _("SQL statement");
271  return "EXECUTE";
273  return _("FOR over EXECUTE statement");
275  return ((PLpgSQL_stmt_getdiag *) stmt)->is_stacked ?
276  "GET STACKED DIAGNOSTICS" : "GET DIAGNOSTICS";
277  case PLPGSQL_STMT_OPEN:
278  return "OPEN";
279  case PLPGSQL_STMT_FETCH:
280  return ((PLpgSQL_stmt_fetch *) stmt)->is_move ? "MOVE" : "FETCH";
281  case PLPGSQL_STMT_CLOSE:
282  return "CLOSE";
284  return "PERFORM";
285  case PLPGSQL_STMT_CALL:
286  return ((PLpgSQL_stmt_call *) stmt)->is_call ? "CALL" : "DO";
287  case PLPGSQL_STMT_COMMIT:
288  return "COMMIT";
290  return "ROLLBACK";
291  case PLPGSQL_STMT_SET:
292  return "SET";
293  }
294 
295  return "unknown";
296 }
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:460
#define _(x)
Definition: elog.c:87

Variable Documentation

◆ dump_indent

◆ ns_top

PLpgSQL_nsitem* ns_top = NULL
static

Definition at line 35 of file pl_funcs.c.

Referenced by plpgsql_ns_additem(), and plpgsql_ns_top().