PostgreSQL Source Code  git master
pl_funcs.c File Reference
#include "postgres.h"
#include "utils/memutils.h"
#include "plpgsql.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 1490 of file pl_funcs.c.

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

Referenced by dump_stmt().

1491 {
1492  dump_ind();
1493  printf("ASSERT ");
1494  dump_expr(stmt->cond);
1495  printf("\n");
1496 
1497  dump_indent += 2;
1498  if (stmt->message != NULL)
1499  {
1500  dump_ind();
1501  printf(" MESSAGE = ");
1502  dump_expr(stmt->message);
1503  printf("\n");
1504  }
1505  dump_indent -= 2;
1506 }
PLpgSQL_expr * message
Definition: plpgsql.h:849
static void dump_ind(void)
Definition: pl_funcs.c:840
static int dump_indent
Definition: pl_funcs.c:803
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1616
PLpgSQL_expr * cond
Definition: plpgsql.h:848

◆ dump_assign()

static void dump_assign ( PLpgSQL_stmt_assign stmt)
static

Definition at line 997 of file pl_funcs.c.

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

Referenced by dump_stmt().

998 {
999  dump_ind();
1000  printf("ASSIGN var %d := ", stmt->varno);
1001  dump_expr(stmt->expr);
1002  printf("\n");
1003 }
static void dump_ind(void)
Definition: pl_funcs.c:840
PLpgSQL_expr * expr
Definition: plpgsql.h:500
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1616

◆ dump_block()

static void dump_block ( PLpgSQL_stmt_block block)
static

Definition at line 956 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, and PLpgSQL_condition::next.

Referenced by dump_stmt(), and plpgsql_dumptree().

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

◆ dump_call()

static void dump_call ( PLpgSQL_stmt_call stmt)
static

Definition at line 1311 of file pl_funcs.c.

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

Referenced by dump_stmt().

1312 {
1313  dump_ind();
1314  printf("%s expr = ", stmt->is_call ? "CALL" : "DO");
1315  dump_expr(stmt->expr);
1316  printf("\n");
1317 }
PLpgSQL_expr * expr
Definition: plpgsql.h:520
static void dump_ind(void)
Definition: pl_funcs.c:840
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1616

◆ dump_case()

static void dump_case ( PLpgSQL_stmt_case stmt)
static

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

1037 {
1038  ListCell *l;
1039 
1040  dump_ind();
1041  printf("CASE %d ", stmt->t_varno);
1042  if (stmt->t_expr)
1043  dump_expr(stmt->t_expr);
1044  printf("\n");
1045  dump_indent += 6;
1046  foreach(l, stmt->case_when_list)
1047  {
1049 
1050  dump_ind();
1051  printf("WHEN ");
1052  dump_expr(cwt->expr);
1053  printf("\n");
1054  dump_ind();
1055  printf("THEN\n");
1056  dump_indent += 2;
1057  dump_stmts(cwt->stmts);
1058  dump_indent -= 2;
1059  }
1060  if (stmt->have_else)
1061  {
1062  dump_ind();
1063  printf("ELSE\n");
1064  dump_indent += 2;
1065  dump_stmts(stmt->else_stmts);
1066  dump_indent -= 2;
1067  }
1068  dump_indent -= 6;
1069  dump_ind();
1070  printf(" ENDCASE\n");
1071 }
List * else_stmts
Definition: plpgsql.h:607
PLpgSQL_expr * expr
Definition: plpgsql.h:616
List * case_when_list
Definition: plpgsql.h:605
static void dump_ind(void)
Definition: pl_funcs.c:840
#define lfirst(lc)
Definition: pg_list.h:106
static int dump_indent
Definition: pl_funcs.c:803
PLpgSQL_expr * t_expr
Definition: plpgsql.h:603
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1616
static void dump_stmts(List *stmts)
Definition: pl_funcs.c:945

◆ dump_close()

static void dump_close ( PLpgSQL_stmt_close stmt)
static

Definition at line 1295 of file pl_funcs.c.

References PLpgSQL_stmt_close::curvar, and dump_ind().

Referenced by dump_stmt().

1296 {
1297  dump_ind();
1298  printf("CLOSE curvar=%d\n", stmt->curvar);
1299 }
static void dump_ind(void)
Definition: pl_funcs.c:840

◆ dump_commit()

static void dump_commit ( PLpgSQL_stmt_commit stmt)
static

Definition at line 1320 of file pl_funcs.c.

References dump_ind().

Referenced by dump_stmt().

1321 {
1322  dump_ind();
1323  printf("COMMIT\n");
1324 }
static void dump_ind(void)
Definition: pl_funcs.c:840

◆ dump_cursor_direction()

static void dump_cursor_direction ( PLpgSQL_stmt_fetch stmt)
static

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

1262 {
1263  dump_indent += 2;
1264  dump_ind();
1265  switch (stmt->direction)
1266  {
1267  case FETCH_FORWARD:
1268  printf(" FORWARD ");
1269  break;
1270  case FETCH_BACKWARD:
1271  printf(" BACKWARD ");
1272  break;
1273  case FETCH_ABSOLUTE:
1274  printf(" ABSOLUTE ");
1275  break;
1276  case FETCH_RELATIVE:
1277  printf(" RELATIVE ");
1278  break;
1279  default:
1280  printf("??? unknown cursor direction %d", stmt->direction);
1281  }
1282 
1283  if (stmt->expr)
1284  {
1285  dump_expr(stmt->expr);
1286  printf("\n");
1287  }
1288  else
1289  printf("%ld\n", stmt->how_many);
1290 
1291  dump_indent -= 2;
1292 }
FetchDirection direction
Definition: plpgsql.h:755
static void dump_ind(void)
Definition: pl_funcs.c:840
static int dump_indent
Definition: pl_funcs.c:803
PLpgSQL_expr * expr
Definition: plpgsql.h:757
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1616

◆ dump_dynexecute()

static void dump_dynexecute ( PLpgSQL_stmt_dynexecute stmt)
static

Definition at line 1528 of file pl_funcs.c.

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

Referenced by dump_stmt().

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

◆ dump_dynfors()

static void dump_dynfors ( PLpgSQL_stmt_dynfors stmt)
static

Definition at line 1565 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, PLpgSQL_stmt_dynfors::query, PLpgSQL_variable::refname, and PLpgSQL_stmt_dynfors::var.

Referenced by dump_stmt().

1566 {
1567  dump_ind();
1568  printf("FORS %s EXECUTE ", stmt->var->refname);
1569  dump_expr(stmt->query);
1570  printf("\n");
1571  if (stmt->params != NIL)
1572  {
1573  ListCell *lc;
1574  int i;
1575 
1576  dump_indent += 2;
1577  dump_ind();
1578  printf(" USING\n");
1579  dump_indent += 2;
1580  i = 1;
1581  foreach(lc, stmt->params)
1582  {
1583  dump_ind();
1584  printf(" parameter $%d: ", i++);
1585  dump_expr((PLpgSQL_expr *) lfirst(lc));
1586  printf("\n");
1587  }
1588  dump_indent -= 4;
1589  }
1590  dump_stmts(stmt->body);
1591  dump_ind();
1592  printf(" ENDFORS\n");
1593 }
#define NIL
Definition: pg_list.h:69
PLpgSQL_expr * query
Definition: plpgsql.h:713
static void dump_ind(void)
Definition: pl_funcs.c:840
PLpgSQL_variable * var
Definition: plpgsql.h:710
#define lfirst(lc)
Definition: pg_list.h:106
static int dump_indent
Definition: pl_funcs.c:803
char * refname
Definition: plpgsql.h:267
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1616
int i
static void dump_stmts(List *stmts)
Definition: pl_funcs.c:945

◆ dump_execsql()

static void dump_execsql ( PLpgSQL_stmt_execsql stmt)
static

Definition at line 1509 of file pl_funcs.c.

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

Referenced by dump_stmt().

1510 {
1511  dump_ind();
1512  printf("EXECSQL ");
1513  dump_expr(stmt->sqlstmt);
1514  printf("\n");
1515 
1516  dump_indent += 2;
1517  if (stmt->target != NULL)
1518  {
1519  dump_ind();
1520  printf(" INTO%s target = %d %s\n",
1521  stmt->strict ? " STRICT" : "",
1522  stmt->target->dno, stmt->target->refname);
1523  }
1524  dump_indent -= 2;
1525 }
PLpgSQL_expr * sqlstmt
Definition: plpgsql.h:859
PLpgSQL_variable * target
Definition: plpgsql.h:864
static void dump_ind(void)
Definition: pl_funcs.c:840
static int dump_indent
Definition: pl_funcs.c:803
char * refname
Definition: plpgsql.h:267
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1616

◆ dump_exit()

static void dump_exit ( PLpgSQL_stmt_exit stmt)
static

Definition at line 1341 of file pl_funcs.c.

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

Referenced by dump_stmt().

1342 {
1343  dump_ind();
1344  printf("%s", stmt->is_exit ? "EXIT" : "CONTINUE");
1345  if (stmt->label != NULL)
1346  printf(" label='%s'", stmt->label);
1347  if (stmt->cond != NULL)
1348  {
1349  printf(" WHEN ");
1350  dump_expr(stmt->cond);
1351  }
1352  printf("\n");
1353 }
PLpgSQL_expr * cond
Definition: plpgsql.h:781
static void dump_ind(void)
Definition: pl_funcs.c:840
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1616

◆ dump_expr()

◆ dump_fetch()

static void dump_fetch ( PLpgSQL_stmt_fetch stmt)
static

Definition at line 1235 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, PLpgSQL_variable::refname, and PLpgSQL_stmt_fetch::target.

Referenced by dump_stmt().

1236 {
1237  dump_ind();
1238 
1239  if (!stmt->is_move)
1240  {
1241  printf("FETCH curvar=%d\n", stmt->curvar);
1242  dump_cursor_direction(stmt);
1243 
1244  dump_indent += 2;
1245  if (stmt->target != NULL)
1246  {
1247  dump_ind();
1248  printf(" target = %d %s\n",
1249  stmt->target->dno, stmt->target->refname);
1250  }
1251  dump_indent -= 2;
1252  }
1253  else
1254  {
1255  printf("MOVE curvar=%d\n", stmt->curvar);
1256  dump_cursor_direction(stmt);
1257  }
1258 }
static void dump_cursor_direction(PLpgSQL_stmt_fetch *stmt)
Definition: pl_funcs.c:1261
static void dump_ind(void)
Definition: pl_funcs.c:840
static int dump_indent
Definition: pl_funcs.c:803
char * refname
Definition: plpgsql.h:267
PLpgSQL_variable * target
Definition: plpgsql.h:753

◆ dump_forc()

static void dump_forc ( PLpgSQL_stmt_forc stmt)
static

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

Referenced by dump_stmt().

1145 {
1146  dump_ind();
1147  printf("FORC %s ", stmt->var->refname);
1148  printf("curvar=%d\n", stmt->curvar);
1149 
1150  dump_indent += 2;
1151  if (stmt->argquery != NULL)
1152  {
1153  dump_ind();
1154  printf(" arguments = ");
1155  dump_expr(stmt->argquery);
1156  printf("\n");
1157  }
1158  dump_indent -= 2;
1159 
1160  dump_stmts(stmt->body);
1161 
1162  dump_ind();
1163  printf(" ENDFORC\n");
1164 }
PLpgSQL_variable * var
Definition: plpgsql.h:695
static void dump_ind(void)
Definition: pl_funcs.c:840
static int dump_indent
Definition: pl_funcs.c:803
char * refname
Definition: plpgsql.h:267
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1616
PLpgSQL_expr * argquery
Definition: plpgsql.h:699
static void dump_stmts(List *stmts)
Definition: pl_funcs.c:945

◆ dump_foreach_a()

static void dump_foreach_a ( PLpgSQL_stmt_foreach_a stmt)
static

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

1168 {
1169  dump_ind();
1170  printf("FOREACHA var %d ", stmt->varno);
1171  if (stmt->slice != 0)
1172  printf("SLICE %d ", stmt->slice);
1173  printf("IN ");
1174  dump_expr(stmt->expr);
1175  printf("\n");
1176 
1177  dump_stmts(stmt->body);
1178 
1179  dump_ind();
1180  printf(" ENDFOREACHA");
1181 }
PLpgSQL_expr * expr
Definition: plpgsql.h:727
static void dump_ind(void)
Definition: pl_funcs.c:840
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1616
static void dump_stmts(List *stmts)
Definition: pl_funcs.c:945

◆ dump_fori()

static void dump_fori ( PLpgSQL_stmt_fori stmt)
static

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

1101 {
1102  dump_ind();
1103  printf("FORI %s %s\n", stmt->var->refname, (stmt->reverse) ? "REVERSE" : "NORMAL");
1104 
1105  dump_indent += 2;
1106  dump_ind();
1107  printf(" lower = ");
1108  dump_expr(stmt->lower);
1109  printf("\n");
1110  dump_ind();
1111  printf(" upper = ");
1112  dump_expr(stmt->upper);
1113  printf("\n");
1114  if (stmt->step)
1115  {
1116  dump_ind();
1117  printf(" step = ");
1118  dump_expr(stmt->step);
1119  printf("\n");
1120  }
1121  dump_indent -= 2;
1122 
1123  dump_stmts(stmt->body);
1124 
1125  dump_ind();
1126  printf(" ENDFORI\n");
1127 }
char * refname
Definition: plpgsql.h:289
PLpgSQL_expr * lower
Definition: plpgsql.h:652
PLpgSQL_var * var
Definition: plpgsql.h:651
static void dump_ind(void)
Definition: pl_funcs.c:840
static int dump_indent
Definition: pl_funcs.c:803
PLpgSQL_expr * step
Definition: plpgsql.h:654
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1616
PLpgSQL_expr * upper
Definition: plpgsql.h:653
static void dump_stmts(List *stmts)
Definition: pl_funcs.c:945

◆ dump_fors()

static void dump_fors ( PLpgSQL_stmt_fors stmt)
static

Definition at line 1130 of file pl_funcs.c.

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

Referenced by dump_stmt().

1131 {
1132  dump_ind();
1133  printf("FORS %s ", stmt->var->refname);
1134  dump_expr(stmt->query);
1135  printf("\n");
1136 
1137  dump_stmts(stmt->body);
1138 
1139  dump_ind();
1140  printf(" ENDFORS\n");
1141 }
PLpgSQL_variable * var
Definition: plpgsql.h:681
static void dump_ind(void)
Definition: pl_funcs.c:840
char * refname
Definition: plpgsql.h:267
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1616
PLpgSQL_expr * query
Definition: plpgsql.h:684
static void dump_stmts(List *stmts)
Definition: pl_funcs.c:945

◆ dump_getdiag()

static void dump_getdiag ( PLpgSQL_stmt_getdiag stmt)
static

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

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

◆ dump_if()

static void dump_if ( PLpgSQL_stmt_if stmt)
static

Definition at line 1006 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, PLpgSQL_if_elsif::stmts, and PLpgSQL_stmt_if::then_body.

Referenced by dump_stmt().

1007 {
1008  ListCell *l;
1009 
1010  dump_ind();
1011  printf("IF ");
1012  dump_expr(stmt->cond);
1013  printf(" THEN\n");
1014  dump_stmts(stmt->then_body);
1015  foreach(l, stmt->elsif_list)
1016  {
1017  PLpgSQL_if_elsif *elif = (PLpgSQL_if_elsif *) lfirst(l);
1018 
1019  dump_ind();
1020  printf(" ELSIF ");
1021  dump_expr(elif->cond);
1022  printf(" THEN\n");
1023  dump_stmts(elif->stmts);
1024  }
1025  if (stmt->else_body != NIL)
1026  {
1027  dump_ind();
1028  printf(" ELSE\n");
1029  dump_stmts(stmt->else_body);
1030  }
1031  dump_ind();
1032  printf(" ENDIF\n");
1033 }
#define NIL
Definition: pg_list.h:69
PLpgSQL_expr * cond
Definition: plpgsql.h:580
List * then_body
Definition: plpgsql.h:581
List * elsif_list
Definition: plpgsql.h:582
List * stmts
Definition: plpgsql.h:593
PLpgSQL_expr * cond
Definition: plpgsql.h:592
static void dump_ind(void)
Definition: pl_funcs.c:840
#define lfirst(lc)
Definition: pg_list.h:106
List * else_body
Definition: plpgsql.h:583
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1616
static void dump_stmts(List *stmts)
Definition: pl_funcs.c:945

◆ dump_ind()

◆ dump_loop()

static void dump_loop ( PLpgSQL_stmt_loop stmt)
static

Definition at line 1074 of file pl_funcs.c.

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

Referenced by dump_stmt().

1075 {
1076  dump_ind();
1077  printf("LOOP\n");
1078 
1079  dump_stmts(stmt->body);
1080 
1081  dump_ind();
1082  printf(" ENDLOOP\n");
1083 }
static void dump_ind(void)
Definition: pl_funcs.c:840
static void dump_stmts(List *stmts)
Definition: pl_funcs.c:945

◆ dump_open()

static void dump_open ( PLpgSQL_stmt_open stmt)
static

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

Referenced by dump_stmt().

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

◆ dump_perform()

static void dump_perform ( PLpgSQL_stmt_perform stmt)
static

Definition at line 1302 of file pl_funcs.c.

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

Referenced by dump_stmt().

1303 {
1304  dump_ind();
1305  printf("PERFORM expr = ");
1306  dump_expr(stmt->expr);
1307  printf("\n");
1308 }
PLpgSQL_expr * expr
Definition: plpgsql.h:510
static void dump_ind(void)
Definition: pl_funcs.c:840
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1616

◆ dump_raise()

static void dump_raise ( PLpgSQL_stmt_raise stmt)
static

Definition at line 1421 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, and PLPGSQL_RAISEOPTION_TABLE.

Referenced by dump_stmt().

1422 {
1423  ListCell *lc;
1424  int i = 0;
1425 
1426  dump_ind();
1427  printf("RAISE level=%d", stmt->elog_level);
1428  if (stmt->condname)
1429  printf(" condname='%s'", stmt->condname);
1430  if (stmt->message)
1431  printf(" message='%s'", stmt->message);
1432  printf("\n");
1433  dump_indent += 2;
1434  foreach(lc, stmt->params)
1435  {
1436  dump_ind();
1437  printf(" parameter %d: ", i++);
1438  dump_expr((PLpgSQL_expr *) lfirst(lc));
1439  printf("\n");
1440  }
1441  if (stmt->options)
1442  {
1443  dump_ind();
1444  printf(" USING\n");
1445  dump_indent += 2;
1446  foreach(lc, stmt->options)
1447  {
1449 
1450  dump_ind();
1451  switch (opt->opt_type)
1452  {
1454  printf(" ERRCODE = ");
1455  break;
1457  printf(" MESSAGE = ");
1458  break;
1460  printf(" DETAIL = ");
1461  break;
1463  printf(" HINT = ");
1464  break;
1466  printf(" COLUMN = ");
1467  break;
1469  printf(" CONSTRAINT = ");
1470  break;
1472  printf(" DATATYPE = ");
1473  break;
1475  printf(" TABLE = ");
1476  break;
1478  printf(" SCHEMA = ");
1479  break;
1480  }
1481  dump_expr(opt->expr);
1482  printf("\n");
1483  }
1484  dump_indent -= 2;
1485  }
1486  dump_indent -= 2;
1487 }
PLpgSQL_raise_option_type opt_type
Definition: plpgsql.h:837
static void dump_ind(void)
Definition: pl_funcs.c:840
#define lfirst(lc)
Definition: pg_list.h:106
static int dump_indent
Definition: pl_funcs.c:803
PLpgSQL_expr * expr
Definition: plpgsql.h:838
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1616
int i

◆ dump_return()

static void dump_return ( PLpgSQL_stmt_return stmt)
static

Definition at line 1356 of file pl_funcs.c.

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

Referenced by dump_stmt().

1357 {
1358  dump_ind();
1359  printf("RETURN ");
1360  if (stmt->retvarno >= 0)
1361  printf("variable %d", stmt->retvarno);
1362  else if (stmt->expr != NULL)
1363  dump_expr(stmt->expr);
1364  else
1365  printf("NULL");
1366  printf("\n");
1367 }
PLpgSQL_expr * expr
Definition: plpgsql.h:791
static void dump_ind(void)
Definition: pl_funcs.c:840
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1616

◆ dump_return_next()

static void dump_return_next ( PLpgSQL_stmt_return_next stmt)
static

Definition at line 1370 of file pl_funcs.c.

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

Referenced by dump_stmt().

1371 {
1372  dump_ind();
1373  printf("RETURN NEXT ");
1374  if (stmt->retvarno >= 0)
1375  printf("variable %d", stmt->retvarno);
1376  else if (stmt->expr != NULL)
1377  dump_expr(stmt->expr);
1378  else
1379  printf("NULL");
1380  printf("\n");
1381 }
PLpgSQL_expr * expr
Definition: plpgsql.h:802
static void dump_ind(void)
Definition: pl_funcs.c:840
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1616

◆ dump_return_query()

static void dump_return_query ( PLpgSQL_stmt_return_query stmt)
static

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

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

◆ dump_rollback()

static void dump_rollback ( PLpgSQL_stmt_rollback stmt)
static

Definition at line 1327 of file pl_funcs.c.

References dump_ind().

Referenced by dump_stmt().

1328 {
1329  dump_ind();
1330  printf("ROLLBACK\n");
1331 }
static void dump_ind(void)
Definition: pl_funcs.c:840

◆ dump_set()

static void dump_set ( PLpgSQL_stmt_set stmt)
static

Definition at line 1334 of file pl_funcs.c.

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

Referenced by dump_stmt().

1335 {
1336  dump_ind();
1337  printf("%s\n", stmt->expr->query);
1338 }
char * query
Definition: plpgsql.h:217
PLpgSQL_expr * expr
Definition: plpgsql.h:550
static void dump_ind(void)
Definition: pl_funcs.c:840

◆ dump_stmt()

static void dump_stmt ( PLpgSQL_stmt stmt)
static

Definition at line 849 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, and PLPGSQL_STMT_WHILE.

Referenced by dump_stmts().

850 {
851  printf("%3d:", stmt->lineno);
852  switch (stmt->cmd_type)
853  {
854  case PLPGSQL_STMT_BLOCK:
855  dump_block((PLpgSQL_stmt_block *) stmt);
856  break;
857  case PLPGSQL_STMT_ASSIGN:
859  break;
860  case PLPGSQL_STMT_IF:
861  dump_if((PLpgSQL_stmt_if *) stmt);
862  break;
863  case PLPGSQL_STMT_CASE:
864  dump_case((PLpgSQL_stmt_case *) stmt);
865  break;
866  case PLPGSQL_STMT_LOOP:
867  dump_loop((PLpgSQL_stmt_loop *) stmt);
868  break;
869  case PLPGSQL_STMT_WHILE:
870  dump_while((PLpgSQL_stmt_while *) stmt);
871  break;
872  case PLPGSQL_STMT_FORI:
873  dump_fori((PLpgSQL_stmt_fori *) stmt);
874  break;
875  case PLPGSQL_STMT_FORS:
876  dump_fors((PLpgSQL_stmt_fors *) stmt);
877  break;
878  case PLPGSQL_STMT_FORC:
879  dump_forc((PLpgSQL_stmt_forc *) stmt);
880  break;
883  break;
884  case PLPGSQL_STMT_EXIT:
885  dump_exit((PLpgSQL_stmt_exit *) stmt);
886  break;
887  case PLPGSQL_STMT_RETURN:
889  break;
892  break;
895  break;
896  case PLPGSQL_STMT_RAISE:
897  dump_raise((PLpgSQL_stmt_raise *) stmt);
898  break;
899  case PLPGSQL_STMT_ASSERT:
901  break;
904  break;
907  break;
910  break;
913  break;
914  case PLPGSQL_STMT_OPEN:
915  dump_open((PLpgSQL_stmt_open *) stmt);
916  break;
917  case PLPGSQL_STMT_FETCH:
918  dump_fetch((PLpgSQL_stmt_fetch *) stmt);
919  break;
920  case PLPGSQL_STMT_CLOSE:
921  dump_close((PLpgSQL_stmt_close *) stmt);
922  break;
925  break;
926  case PLPGSQL_STMT_CALL:
927  dump_call((PLpgSQL_stmt_call *) stmt);
928  break;
929  case PLPGSQL_STMT_COMMIT:
931  break;
934  break;
935  case PLPGSQL_STMT_SET:
936  dump_set((PLpgSQL_stmt_set *) stmt);
937  break;
938  default:
939  elog(ERROR, "unrecognized cmd_type: %d", stmt->cmd_type);
940  break;
941  }
942 }
int lineno
Definition: plpgsql.h:445
static void dump_raise(PLpgSQL_stmt_raise *stmt)
Definition: pl_funcs.c:1421
static void dump_perform(PLpgSQL_stmt_perform *stmt)
Definition: pl_funcs.c:1302
static void dump_forc(PLpgSQL_stmt_forc *stmt)
Definition: pl_funcs.c:1144
static void dump_rollback(PLpgSQL_stmt_rollback *stmt)
Definition: pl_funcs.c:1327
static void dump_fors(PLpgSQL_stmt_fors *stmt)
Definition: pl_funcs.c:1130
static void dump_fetch(PLpgSQL_stmt_fetch *stmt)
Definition: pl_funcs.c:1235
#define ERROR
Definition: elog.h:43
static void dump_case(PLpgSQL_stmt_case *stmt)
Definition: pl_funcs.c:1036
static void dump_getdiag(PLpgSQL_stmt_getdiag *stmt)
Definition: pl_funcs.c:1596
static void dump_if(PLpgSQL_stmt_if *stmt)
Definition: pl_funcs.c:1006
static void dump_return_query(PLpgSQL_stmt_return_query *stmt)
Definition: pl_funcs.c:1384
static void dump_return(PLpgSQL_stmt_return *stmt)
Definition: pl_funcs.c:1356
static void dump_set(PLpgSQL_stmt_set *stmt)
Definition: pl_funcs.c:1334
static void dump_return_next(PLpgSQL_stmt_return_next *stmt)
Definition: pl_funcs.c:1370
static void dump_loop(PLpgSQL_stmt_loop *stmt)
Definition: pl_funcs.c:1074
static void dump_close(PLpgSQL_stmt_close *stmt)
Definition: pl_funcs.c:1295
static void dump_while(PLpgSQL_stmt_while *stmt)
Definition: pl_funcs.c:1086
static void dump_execsql(PLpgSQL_stmt_execsql *stmt)
Definition: pl_funcs.c:1509
static void dump_dynexecute(PLpgSQL_stmt_dynexecute *stmt)
Definition: pl_funcs.c:1528
static void dump_dynfors(PLpgSQL_stmt_dynfors *stmt)
Definition: pl_funcs.c:1565
static void dump_block(PLpgSQL_stmt_block *block)
Definition: pl_funcs.c:956
static void dump_foreach_a(PLpgSQL_stmt_foreach_a *stmt)
Definition: pl_funcs.c:1167
static void dump_commit(PLpgSQL_stmt_commit *stmt)
Definition: pl_funcs.c:1320
static void dump_assert(PLpgSQL_stmt_assert *stmt)
Definition: pl_funcs.c:1490
static void dump_open(PLpgSQL_stmt_open *stmt)
Definition: pl_funcs.c:1184
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:444
static void dump_fori(PLpgSQL_stmt_fori *stmt)
Definition: pl_funcs.c:1100
#define elog
Definition: elog.h:219
static void dump_call(PLpgSQL_stmt_call *stmt)
Definition: pl_funcs.c:1311
static void dump_assign(PLpgSQL_stmt_assign *stmt)
Definition: pl_funcs.c:997
static void dump_exit(PLpgSQL_stmt_exit *stmt)
Definition: pl_funcs.c:1341

◆ dump_stmts()

static void dump_stmts ( List stmts)
static

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

946 {
947  ListCell *s;
948 
949  dump_indent += 2;
950  foreach(s, stmts)
951  dump_stmt((PLpgSQL_stmt *) lfirst(s));
952  dump_indent -= 2;
953 }
#define lfirst(lc)
Definition: pg_list.h:106
static int dump_indent
Definition: pl_funcs.c:803
static void dump_stmt(PLpgSQL_stmt *stmt)
Definition: pl_funcs.c:849

◆ dump_while()

static void dump_while ( PLpgSQL_stmt_while stmt)
static

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

1087 {
1088  dump_ind();
1089  printf("WHILE ");
1090  dump_expr(stmt->cond);
1091  printf("\n");
1092 
1093  dump_stmts(stmt->body);
1094 
1095  dump_ind();
1096  printf(" ENDWHILE\n");
1097 }
PLpgSQL_expr * cond
Definition: plpgsql.h:639
static void dump_ind(void)
Definition: pl_funcs.c:840
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1616
static void dump_stmts(List *stmts)
Definition: pl_funcs.c:945

◆ free_assert()

static void free_assert ( PLpgSQL_stmt_assert stmt)
static

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

689 {
690  free_expr(stmt->cond);
691  free_expr(stmt->message);
692 }
PLpgSQL_expr * message
Definition: plpgsql.h:849
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:731
PLpgSQL_expr * cond
Definition: plpgsql.h:848

◆ free_assign()

static void free_assign ( PLpgSQL_stmt_assign stmt)
static

Definition at line 505 of file pl_funcs.c.

References PLpgSQL_stmt_assign::expr, and free_expr().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

506 {
507  free_expr(stmt->expr);
508 }
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:731
PLpgSQL_expr * expr
Definition: plpgsql.h:500

◆ free_block()

static void free_block ( PLpgSQL_stmt_block block)
static

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

489 {
490  free_stmts(block->body);
491  if (block->exceptions)
492  {
493  ListCell *e;
494 
495  foreach(e, block->exceptions->exc_list)
496  {
498 
499  free_stmts(exc->action);
500  }
501  }
502 }
static void free_stmts(List *stmts)
Definition: pl_funcs.c:477
#define lfirst(lc)
Definition: pg_list.h:106
PLpgSQL_exception_block * exceptions
Definition: plpgsql.h:489
e
Definition: preproc-init.c:82

◆ free_call()

static void free_call ( PLpgSQL_stmt_call stmt)
static

Definition at line 618 of file pl_funcs.c.

References PLpgSQL_stmt_call::expr, and free_expr().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

619 {
620  free_expr(stmt->expr);
621 }
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:731
PLpgSQL_expr * expr
Definition: plpgsql.h:520

◆ free_case()

static void free_case ( PLpgSQL_stmt_case stmt)
static

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

529 {
530  ListCell *l;
531 
532  free_expr(stmt->t_expr);
533  foreach(l, stmt->case_when_list)
534  {
536 
537  free_expr(cwt->expr);
538  free_stmts(cwt->stmts);
539  }
540  free_stmts(stmt->else_stmts);
541 }
List * else_stmts
Definition: plpgsql.h:607
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:731
PLpgSQL_expr * expr
Definition: plpgsql.h:616
List * case_when_list
Definition: plpgsql.h:605
static void free_stmts(List *stmts)
Definition: pl_funcs.c:477
#define lfirst(lc)
Definition: pg_list.h:106
PLpgSQL_expr * t_expr
Definition: plpgsql.h:603

◆ free_close()

static void free_close ( PLpgSQL_stmt_close stmt)
static

Definition at line 607 of file pl_funcs.c.

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

608 {
609 }

◆ free_commit()

static void free_commit ( PLpgSQL_stmt_commit stmt)
static

Definition at line 624 of file pl_funcs.c.

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

625 {
626 }

◆ free_dynexecute()

static void free_dynexecute ( PLpgSQL_stmt_dynexecute stmt)
static

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

702 {
703  ListCell *lc;
704 
705  free_expr(stmt->query);
706  foreach(lc, stmt->params)
707  {
708  free_expr((PLpgSQL_expr *) lfirst(lc));
709  }
710 }
PLpgSQL_expr * query
Definition: plpgsql.h:874
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:731
#define lfirst(lc)
Definition: pg_list.h:106

◆ free_dynfors()

static void free_dynfors ( PLpgSQL_stmt_dynfors stmt)
static

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

714 {
715  ListCell *lc;
716 
717  free_stmts(stmt->body);
718  free_expr(stmt->query);
719  foreach(lc, stmt->params)
720  {
721  free_expr((PLpgSQL_expr *) lfirst(lc));
722  }
723 }
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:731
PLpgSQL_expr * query
Definition: plpgsql.h:713
static void free_stmts(List *stmts)
Definition: pl_funcs.c:477
#define lfirst(lc)
Definition: pg_list.h:106

◆ free_execsql()

static void free_execsql ( PLpgSQL_stmt_execsql stmt)
static

Definition at line 695 of file pl_funcs.c.

References free_expr(), and PLpgSQL_stmt_execsql::sqlstmt.

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

696 {
697  free_expr(stmt->sqlstmt);
698 }
PLpgSQL_expr * sqlstmt
Definition: plpgsql.h:859
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:731

◆ free_exit()

static void free_exit ( PLpgSQL_stmt_exit stmt)
static

Definition at line 640 of file pl_funcs.c.

References PLpgSQL_stmt_exit::cond, and free_expr().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

641 {
642  free_expr(stmt->cond);
643 }
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:731
PLpgSQL_expr * cond
Definition: plpgsql.h:781

◆ free_expr()

static void free_expr ( PLpgSQL_expr expr)
static

◆ free_fetch()

static void free_fetch ( PLpgSQL_stmt_fetch stmt)
static

Definition at line 601 of file pl_funcs.c.

References PLpgSQL_stmt_fetch::expr, and free_expr().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

602 {
603  free_expr(stmt->expr);
604 }
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:731
PLpgSQL_expr * expr
Definition: plpgsql.h:757

◆ free_forc()

static void free_forc ( PLpgSQL_stmt_forc stmt)
static

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

574 {
575  free_stmts(stmt->body);
576  free_expr(stmt->argquery);
577 }
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:731
static void free_stmts(List *stmts)
Definition: pl_funcs.c:477
PLpgSQL_expr * argquery
Definition: plpgsql.h:699

◆ free_foreach_a()

static void free_foreach_a ( PLpgSQL_stmt_foreach_a stmt)
static

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

581 {
582  free_expr(stmt->expr);
583  free_stmts(stmt->body);
584 }
PLpgSQL_expr * expr
Definition: plpgsql.h:727
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:731
static void free_stmts(List *stmts)
Definition: pl_funcs.c:477

◆ free_fori()

static void free_fori ( PLpgSQL_stmt_fori stmt)
static

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

558 {
559  free_expr(stmt->lower);
560  free_expr(stmt->upper);
561  free_expr(stmt->step);
562  free_stmts(stmt->body);
563 }
PLpgSQL_expr * lower
Definition: plpgsql.h:652
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:731
static void free_stmts(List *stmts)
Definition: pl_funcs.c:477
PLpgSQL_expr * step
Definition: plpgsql.h:654
PLpgSQL_expr * upper
Definition: plpgsql.h:653

◆ free_fors()

static void free_fors ( PLpgSQL_stmt_fors stmt)
static

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

567 {
568  free_stmts(stmt->body);
569  free_expr(stmt->query);
570 }
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:731
static void free_stmts(List *stmts)
Definition: pl_funcs.c:477
PLpgSQL_expr * query
Definition: plpgsql.h:684

◆ free_getdiag()

static void free_getdiag ( PLpgSQL_stmt_getdiag stmt)
static

Definition at line 726 of file pl_funcs.c.

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

727 {
728 }

◆ free_if()

static void free_if ( PLpgSQL_stmt_if stmt)
static

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

512 {
513  ListCell *l;
514 
515  free_expr(stmt->cond);
516  free_stmts(stmt->then_body);
517  foreach(l, stmt->elsif_list)
518  {
520 
521  free_expr(elif->cond);
522  free_stmts(elif->stmts);
523  }
524  free_stmts(stmt->else_body);
525 }
PLpgSQL_expr * cond
Definition: plpgsql.h:580
List * then_body
Definition: plpgsql.h:581
List * elsif_list
Definition: plpgsql.h:582
List * stmts
Definition: plpgsql.h:593
PLpgSQL_expr * cond
Definition: plpgsql.h:592
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:731
static void free_stmts(List *stmts)
Definition: pl_funcs.c:477
#define lfirst(lc)
Definition: pg_list.h:106
List * else_body
Definition: plpgsql.h:583

◆ free_loop()

static void free_loop ( PLpgSQL_stmt_loop stmt)
static

Definition at line 544 of file pl_funcs.c.

References PLpgSQL_stmt_loop::body, and free_stmts().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

545 {
546  free_stmts(stmt->body);
547 }
static void free_stmts(List *stmts)
Definition: pl_funcs.c:477

◆ free_open()

static void free_open ( PLpgSQL_stmt_open stmt)
static

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

588 {
589  ListCell *lc;
590 
591  free_expr(stmt->argquery);
592  free_expr(stmt->query);
593  free_expr(stmt->dynquery);
594  foreach(lc, stmt->params)
595  {
596  free_expr((PLpgSQL_expr *) lfirst(lc));
597  }
598 }
PLpgSQL_expr * dynquery
Definition: plpgsql.h:742
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:731
PLpgSQL_expr * query
Definition: plpgsql.h:741
#define lfirst(lc)
Definition: pg_list.h:106
PLpgSQL_expr * argquery
Definition: plpgsql.h:740

◆ free_perform()

static void free_perform ( PLpgSQL_stmt_perform stmt)
static

Definition at line 612 of file pl_funcs.c.

References PLpgSQL_stmt_perform::expr, and free_expr().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

613 {
614  free_expr(stmt->expr);
615 }
PLpgSQL_expr * expr
Definition: plpgsql.h:510
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:731

◆ free_raise()

static void free_raise ( PLpgSQL_stmt_raise stmt)
static

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

672 {
673  ListCell *lc;
674 
675  foreach(lc, stmt->params)
676  {
677  free_expr((PLpgSQL_expr *) lfirst(lc));
678  }
679  foreach(lc, stmt->options)
680  {
682 
683  free_expr(opt->expr);
684  }
685 }
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:731
#define lfirst(lc)
Definition: pg_list.h:106
PLpgSQL_expr * expr
Definition: plpgsql.h:838

◆ free_return()

static void free_return ( PLpgSQL_stmt_return stmt)
static

Definition at line 646 of file pl_funcs.c.

References PLpgSQL_stmt_return::expr, and free_expr().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

647 {
648  free_expr(stmt->expr);
649 }
PLpgSQL_expr * expr
Definition: plpgsql.h:791
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:731

◆ free_return_next()

static void free_return_next ( PLpgSQL_stmt_return_next stmt)
static

Definition at line 652 of file pl_funcs.c.

References PLpgSQL_stmt_return_next::expr, and free_expr().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

653 {
654  free_expr(stmt->expr);
655 }
PLpgSQL_expr * expr
Definition: plpgsql.h:802
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:731

◆ free_return_query()

static void free_return_query ( PLpgSQL_stmt_return_query stmt)
static

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

659 {
660  ListCell *lc;
661 
662  free_expr(stmt->query);
663  free_expr(stmt->dynquery);
664  foreach(lc, stmt->params)
665  {
666  free_expr((PLpgSQL_expr *) lfirst(lc));
667  }
668 }
PLpgSQL_expr * query
Definition: plpgsql.h:813
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:731
#define lfirst(lc)
Definition: pg_list.h:106
PLpgSQL_expr * dynquery
Definition: plpgsql.h:814

◆ free_rollback()

static void free_rollback ( PLpgSQL_stmt_rollback stmt)
static

Definition at line 629 of file pl_funcs.c.

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

630 {
631 }

◆ free_set()

static void free_set ( PLpgSQL_stmt_set stmt)
static

Definition at line 634 of file pl_funcs.c.

References PLpgSQL_stmt_set::expr, and free_expr().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

635 {
636  free_expr(stmt->expr);
637 }
PLpgSQL_expr * expr
Definition: plpgsql.h:550
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:731

◆ free_stmt()

static void free_stmt ( PLpgSQL_stmt stmt)
static

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

383 {
384  switch (stmt->cmd_type)
385  {
386  case PLPGSQL_STMT_BLOCK:
387  free_block((PLpgSQL_stmt_block *) stmt);
388  break;
389  case PLPGSQL_STMT_ASSIGN:
391  break;
392  case PLPGSQL_STMT_IF:
393  free_if((PLpgSQL_stmt_if *) stmt);
394  break;
395  case PLPGSQL_STMT_CASE:
396  free_case((PLpgSQL_stmt_case *) stmt);
397  break;
398  case PLPGSQL_STMT_LOOP:
399  free_loop((PLpgSQL_stmt_loop *) stmt);
400  break;
401  case PLPGSQL_STMT_WHILE:
402  free_while((PLpgSQL_stmt_while *) stmt);
403  break;
404  case PLPGSQL_STMT_FORI:
405  free_fori((PLpgSQL_stmt_fori *) stmt);
406  break;
407  case PLPGSQL_STMT_FORS:
408  free_fors((PLpgSQL_stmt_fors *) stmt);
409  break;
410  case PLPGSQL_STMT_FORC:
411  free_forc((PLpgSQL_stmt_forc *) stmt);
412  break;
415  break;
416  case PLPGSQL_STMT_EXIT:
417  free_exit((PLpgSQL_stmt_exit *) stmt);
418  break;
419  case PLPGSQL_STMT_RETURN:
421  break;
424  break;
427  break;
428  case PLPGSQL_STMT_RAISE:
429  free_raise((PLpgSQL_stmt_raise *) stmt);
430  break;
431  case PLPGSQL_STMT_ASSERT:
433  break;
436  break;
439  break;
442  break;
445  break;
446  case PLPGSQL_STMT_OPEN:
447  free_open((PLpgSQL_stmt_open *) stmt);
448  break;
449  case PLPGSQL_STMT_FETCH:
450  free_fetch((PLpgSQL_stmt_fetch *) stmt);
451  break;
452  case PLPGSQL_STMT_CLOSE:
453  free_close((PLpgSQL_stmt_close *) stmt);
454  break;
457  break;
458  case PLPGSQL_STMT_CALL:
459  free_call((PLpgSQL_stmt_call *) stmt);
460  break;
461  case PLPGSQL_STMT_COMMIT:
463  break;
466  break;
467  case PLPGSQL_STMT_SET:
468  free_set((PLpgSQL_stmt_set *) stmt);
469  break;
470  default:
471  elog(ERROR, "unrecognized cmd_type: %d", stmt->cmd_type);
472  break;
473  }
474 }
static void free_assert(PLpgSQL_stmt_assert *stmt)
Definition: pl_funcs.c:688
static void free_dynexecute(PLpgSQL_stmt_dynexecute *stmt)
Definition: pl_funcs.c:701
static void free_raise(PLpgSQL_stmt_raise *stmt)
Definition: pl_funcs.c:671
static void free_open(PLpgSQL_stmt_open *stmt)
Definition: pl_funcs.c:587
static void free_return(PLpgSQL_stmt_return *stmt)
Definition: pl_funcs.c:646
static void free_loop(PLpgSQL_stmt_loop *stmt)
Definition: pl_funcs.c:544
static void free_dynfors(PLpgSQL_stmt_dynfors *stmt)
Definition: pl_funcs.c:713
static void free_set(PLpgSQL_stmt_set *stmt)
Definition: pl_funcs.c:634
static void free_rollback(PLpgSQL_stmt_rollback *stmt)
Definition: pl_funcs.c:629
static void free_assign(PLpgSQL_stmt_assign *stmt)
Definition: pl_funcs.c:505
static void free_getdiag(PLpgSQL_stmt_getdiag *stmt)
Definition: pl_funcs.c:726
#define ERROR
Definition: elog.h:43
static void free_fetch(PLpgSQL_stmt_fetch *stmt)
Definition: pl_funcs.c:601
static void free_close(PLpgSQL_stmt_close *stmt)
Definition: pl_funcs.c:607
static void free_case(PLpgSQL_stmt_case *stmt)
Definition: pl_funcs.c:528
static void free_fori(PLpgSQL_stmt_fori *stmt)
Definition: pl_funcs.c:557
static void free_perform(PLpgSQL_stmt_perform *stmt)
Definition: pl_funcs.c:612
static void free_return_next(PLpgSQL_stmt_return_next *stmt)
Definition: pl_funcs.c:652
static void free_call(PLpgSQL_stmt_call *stmt)
Definition: pl_funcs.c:618
static void free_fors(PLpgSQL_stmt_fors *stmt)
Definition: pl_funcs.c:566
static void free_exit(PLpgSQL_stmt_exit *stmt)
Definition: pl_funcs.c:640
static void free_if(PLpgSQL_stmt_if *stmt)
Definition: pl_funcs.c:511
static void free_return_query(PLpgSQL_stmt_return_query *stmt)
Definition: pl_funcs.c:658
static void free_execsql(PLpgSQL_stmt_execsql *stmt)
Definition: pl_funcs.c:695
static void free_forc(PLpgSQL_stmt_forc *stmt)
Definition: pl_funcs.c:573
static void free_commit(PLpgSQL_stmt_commit *stmt)
Definition: pl_funcs.c:624
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:444
static void free_while(PLpgSQL_stmt_while *stmt)
Definition: pl_funcs.c:550
#define elog
Definition: elog.h:219
static void free_foreach_a(PLpgSQL_stmt_foreach_a *stmt)
Definition: pl_funcs.c:580
static void free_block(PLpgSQL_stmt_block *block)
Definition: pl_funcs.c:488

◆ free_stmts()

static void free_stmts ( List stmts)
static

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

478 {
479  ListCell *s;
480 
481  foreach(s, stmts)
482  {
483  free_stmt((PLpgSQL_stmt *) lfirst(s));
484  }
485 }
#define lfirst(lc)
Definition: pg_list.h:106
static void free_stmt(PLpgSQL_stmt *stmt)
Definition: pl_funcs.c:382

◆ free_while()

static void free_while ( PLpgSQL_stmt_while stmt)
static

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

551 {
552  free_expr(stmt->cond);
553  free_stmts(stmt->body);
554 }
PLpgSQL_expr * cond
Definition: plpgsql.h:639
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:731
static void free_stmts(List *stmts)
Definition: pl_funcs.c:477

◆ plpgsql_dumptree()

void plpgsql_dumptree ( PLpgSQL_function func)

Definition at line 1622 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, PLpgSQL_var::promise, PLpgSQL_var::refname, PLpgSQL_row::refname, PLpgSQL_type::typname, PLpgSQL_type::typoid, and PLpgSQL_row::varnos.

Referenced by do_compile().

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

◆ plpgsql_free_function_memory()

void plpgsql_free_function_memory ( PLpgSQL_function func)

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

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

◆ plpgsql_getdiag_kindname()

const char* plpgsql_getdiag_kindname ( PLpgSQL_getdiag_kind  kind)

Definition at line 304 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_RESULT_OID, PLPGSQL_GETDIAG_RETURNED_SQLSTATE, PLPGSQL_GETDIAG_ROW_COUNT, PLPGSQL_GETDIAG_SCHEMA_NAME, and PLPGSQL_GETDIAG_TABLE_NAME.

Referenced by dump_getdiag().

305 {
306  switch (kind)
307  {
309  return "ROW_COUNT";
311  return "RESULT_OID";
313  return "PG_CONTEXT";
315  return "PG_EXCEPTION_CONTEXT";
317  return "PG_EXCEPTION_DETAIL";
319  return "PG_EXCEPTION_HINT";
321  return "RETURNED_SQLSTATE";
323  return "COLUMN_NAME";
325  return "CONSTRAINT_NAME";
327  return "PG_DATATYPE_NAME";
329  return "MESSAGE_TEXT";
331  return "TABLE_NAME";
333  return "SCHEMA_NAME";
334  }
335 
336  return "unknown";
337 }

◆ plpgsql_ns_additem()

void plpgsql_ns_additem ( PLpgSQL_nsitem_type  itemtype,
int  itemno,
const char *  name 
)

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

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

◆ plpgsql_ns_find_nearest_loop()

PLpgSQL_nsitem* plpgsql_ns_find_nearest_loop ( PLpgSQL_nsitem ns_cur)

Definition at line 216 of file pl_funcs.c.

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

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

◆ plpgsql_ns_init()

void plpgsql_ns_init ( void  )

Definition at line 45 of file pl_funcs.c.

Referenced by do_compile(), and plpgsql_compile_inline().

46 {
47  ns_top = NULL;
48 }
static PLpgSQL_nsitem * ns_top
Definition: pl_funcs.c:37

◆ 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 132 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().

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

◆ plpgsql_ns_lookup_label()

PLpgSQL_nsitem* plpgsql_ns_lookup_label ( PLpgSQL_nsitem ns_cur,
const char *  name 
)

Definition at line 197 of file pl_funcs.c.

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

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

◆ plpgsql_ns_pop()

void plpgsql_ns_pop ( void  )

Definition at line 69 of file pl_funcs.c.

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

70 {
71  Assert(ns_top != NULL);
73  ns_top = ns_top->prev;
74  ns_top = ns_top->prev;
75 }
static PLpgSQL_nsitem * ns_top
Definition: pl_funcs.c:37
struct PLpgSQL_nsitem * prev
Definition: plpgsql.h:435
#define Assert(condition)
Definition: c.h:699
PLpgSQL_nsitem_type itemtype
Definition: plpgsql.h:428

◆ plpgsql_ns_push()

void plpgsql_ns_push ( const char *  label,
PLpgSQL_label_type  label_type 
)

Definition at line 56 of file pl_funcs.c.

References plpgsql_ns_additem(), and PLPGSQL_NSTYPE_LABEL.

Referenced by do_compile(), and plpgsql_compile_inline().

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

◆ plpgsql_ns_top()

PLpgSQL_nsitem* plpgsql_ns_top ( void  )

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

84 {
85  return ns_top;
86 }
static PLpgSQL_nsitem * ns_top
Definition: pl_funcs.c:37

◆ plpgsql_stmt_typename()

const char* plpgsql_stmt_typename ( PLpgSQL_stmt stmt)

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

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

Variable Documentation

◆ dump_indent

◆ ns_top

PLpgSQL_nsitem* ns_top = NULL
static

Definition at line 37 of file pl_funcs.c.

Referenced by plpgsql_ns_additem(), and plpgsql_ns_top().