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_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_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 1466 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().

1467 {
1468  dump_ind();
1469  printf("ASSERT ");
1470  dump_expr(stmt->cond);
1471  printf("\n");
1472 
1473  dump_indent += 2;
1474  if (stmt->message != NULL)
1475  {
1476  dump_ind();
1477  printf(" MESSAGE = ");
1478  dump_expr(stmt->message);
1479  printf("\n");
1480  }
1481  dump_indent -= 2;
1482 }
#define printf(...)
Definition: port.h:222
PLpgSQL_expr * message
Definition: plpgsql.h:884
static void dump_ind(void)
Definition: pl_funcs.c:820
static int dump_indent
Definition: pl_funcs.c:784
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1592
PLpgSQL_expr * cond
Definition: plpgsql.h:883

◆ dump_assign()

static void dump_assign ( PLpgSQL_stmt_assign stmt)
static

Definition at line 974 of file pl_funcs.c.

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

Referenced by dump_stmt().

975 {
976  dump_ind();
977  printf("ASSIGN var %d := ", stmt->varno);
978  dump_expr(stmt->expr);
979  printf("\n");
980 }
#define printf(...)
Definition: port.h:222
static void dump_ind(void)
Definition: pl_funcs.c:820
PLpgSQL_expr * expr
Definition: plpgsql.h:519
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1592

◆ dump_block()

static void dump_block ( PLpgSQL_stmt_block block)
static

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

934 {
935  char *name;
936 
937  if (block->label == NULL)
938  name = "*unnamed*";
939  else
940  name = block->label;
941 
942  dump_ind();
943  printf("BLOCK <<%s>>\n", name);
944 
945  dump_stmts(block->body);
946 
947  if (block->exceptions)
948  {
949  ListCell *e;
950 
951  foreach(e, block->exceptions->exc_list)
952  {
954  PLpgSQL_condition *cond;
955 
956  dump_ind();
957  printf(" EXCEPTION WHEN ");
958  for (cond = exc->conditions; cond; cond = cond->next)
959  {
960  if (cond != exc->conditions)
961  printf(" OR ");
962  printf("%s", cond->condname);
963  }
964  printf(" THEN\n");
965  dump_stmts(exc->action);
966  }
967  }
968 
969  dump_ind();
970  printf(" END -- %s\n", name);
971 }
char * condname
Definition: plpgsql.h:471
struct PLpgSQL_condition * next
Definition: plpgsql.h:472
#define printf(...)
Definition: port.h:222
static void dump_ind(void)
Definition: pl_funcs.c:820
PLpgSQL_condition * conditions
Definition: plpgsql.h:491
#define lfirst(lc)
Definition: pg_list.h:169
PLpgSQL_exception_block * exceptions
Definition: plpgsql.h:507
const char * name
Definition: encode.c:561
e
Definition: preproc-init.c:82
static void dump_stmts(List *stmts)
Definition: pl_funcs.c:922

◆ dump_call()

static void dump_call ( PLpgSQL_stmt_call stmt)
static

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

1289 {
1290  dump_ind();
1291  printf("%s expr = ", stmt->is_call ? "CALL" : "DO");
1292  dump_expr(stmt->expr);
1293  printf("\n");
1294 }
#define printf(...)
Definition: port.h:222
PLpgSQL_expr * expr
Definition: plpgsql.h:541
static void dump_ind(void)
Definition: pl_funcs.c:820
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1592

◆ dump_case()

static void dump_case ( PLpgSQL_stmt_case stmt)
static

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

1014 {
1015  ListCell *l;
1016 
1017  dump_ind();
1018  printf("CASE %d ", stmt->t_varno);
1019  if (stmt->t_expr)
1020  dump_expr(stmt->t_expr);
1021  printf("\n");
1022  dump_indent += 6;
1023  foreach(l, stmt->case_when_list)
1024  {
1026 
1027  dump_ind();
1028  printf("WHEN ");
1029  dump_expr(cwt->expr);
1030  printf("\n");
1031  dump_ind();
1032  printf("THEN\n");
1033  dump_indent += 2;
1034  dump_stmts(cwt->stmts);
1035  dump_indent -= 2;
1036  }
1037  if (stmt->have_else)
1038  {
1039  dump_ind();
1040  printf("ELSE\n");
1041  dump_indent += 2;
1042  dump_stmts(stmt->else_stmts);
1043  dump_indent -= 2;
1044  }
1045  dump_indent -= 6;
1046  dump_ind();
1047  printf(" ENDCASE\n");
1048 }
#define printf(...)
Definition: port.h:222
List * else_stmts
Definition: plpgsql.h:625
PLpgSQL_expr * expr
Definition: plpgsql.h:634
List * case_when_list
Definition: plpgsql.h:623
static void dump_ind(void)
Definition: pl_funcs.c:820
#define lfirst(lc)
Definition: pg_list.h:169
static int dump_indent
Definition: pl_funcs.c:784
PLpgSQL_expr * t_expr
Definition: plpgsql.h:621
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1592
static void dump_stmts(List *stmts)
Definition: pl_funcs.c:922

◆ dump_close()

static void dump_close ( PLpgSQL_stmt_close stmt)
static

Definition at line 1272 of file pl_funcs.c.

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

Referenced by dump_stmt().

1273 {
1274  dump_ind();
1275  printf("CLOSE curvar=%d\n", stmt->curvar);
1276 }
#define printf(...)
Definition: port.h:222
static void dump_ind(void)
Definition: pl_funcs.c:820

◆ dump_commit()

static void dump_commit ( PLpgSQL_stmt_commit stmt)
static

Definition at line 1297 of file pl_funcs.c.

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

Referenced by dump_stmt().

1298 {
1299  dump_ind();
1300  if (stmt->chain)
1301  printf("COMMIT AND CHAIN\n");
1302  else
1303  printf("COMMIT\n");
1304 }
#define printf(...)
Definition: port.h:222
static void dump_ind(void)
Definition: pl_funcs.c:820

◆ dump_cursor_direction()

static void dump_cursor_direction ( PLpgSQL_stmt_fetch stmt)
static

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

1239 {
1240  dump_indent += 2;
1241  dump_ind();
1242  switch (stmt->direction)
1243  {
1244  case FETCH_FORWARD:
1245  printf(" FORWARD ");
1246  break;
1247  case FETCH_BACKWARD:
1248  printf(" BACKWARD ");
1249  break;
1250  case FETCH_ABSOLUTE:
1251  printf(" ABSOLUTE ");
1252  break;
1253  case FETCH_RELATIVE:
1254  printf(" RELATIVE ");
1255  break;
1256  default:
1257  printf("??? unknown cursor direction %d", stmt->direction);
1258  }
1259 
1260  if (stmt->expr)
1261  {
1262  dump_expr(stmt->expr);
1263  printf("\n");
1264  }
1265  else
1266  printf("%ld\n", stmt->how_many);
1267 
1268  dump_indent -= 2;
1269 }
FetchDirection direction
Definition: plpgsql.h:783
#define printf(...)
Definition: port.h:222
static void dump_ind(void)
Definition: pl_funcs.c:820
static int dump_indent
Definition: pl_funcs.c:784
PLpgSQL_expr * expr
Definition: plpgsql.h:785
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1592

◆ dump_dynexecute()

static void dump_dynexecute ( PLpgSQL_stmt_dynexecute stmt)
static

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

1505 {
1506  dump_ind();
1507  printf("EXECUTE ");
1508  dump_expr(stmt->query);
1509  printf("\n");
1510 
1511  dump_indent += 2;
1512  if (stmt->target != NULL)
1513  {
1514  dump_ind();
1515  printf(" INTO%s target = %d %s\n",
1516  stmt->strict ? " STRICT" : "",
1517  stmt->target->dno, stmt->target->refname);
1518  }
1519  if (stmt->params != NIL)
1520  {
1521  ListCell *lc;
1522  int i;
1523 
1524  dump_ind();
1525  printf(" USING\n");
1526  dump_indent += 2;
1527  i = 1;
1528  foreach(lc, stmt->params)
1529  {
1530  dump_ind();
1531  printf(" parameter %d: ", i++);
1532  dump_expr((PLpgSQL_expr *) lfirst(lc));
1533  printf("\n");
1534  }
1535  dump_indent -= 2;
1536  }
1537  dump_indent -= 2;
1538 }
#define NIL
Definition: pg_list.h:65
PLpgSQL_expr * query
Definition: plpgsql.h:911
#define printf(...)
Definition: port.h:222
static void dump_ind(void)
Definition: pl_funcs.c:820
#define lfirst(lc)
Definition: pg_list.h:169
static int dump_indent
Definition: pl_funcs.c:784
char * refname
Definition: plpgsql.h:290
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1592
int i
PLpgSQL_variable * target
Definition: plpgsql.h:914

◆ dump_dynfors()

static void dump_dynfors ( PLpgSQL_stmt_dynfors stmt)
static

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

1542 {
1543  dump_ind();
1544  printf("FORS %s EXECUTE ", stmt->var->refname);
1545  dump_expr(stmt->query);
1546  printf("\n");
1547  if (stmt->params != NIL)
1548  {
1549  ListCell *lc;
1550  int i;
1551 
1552  dump_indent += 2;
1553  dump_ind();
1554  printf(" USING\n");
1555  dump_indent += 2;
1556  i = 1;
1557  foreach(lc, stmt->params)
1558  {
1559  dump_ind();
1560  printf(" parameter $%d: ", i++);
1561  dump_expr((PLpgSQL_expr *) lfirst(lc));
1562  printf("\n");
1563  }
1564  dump_indent -= 4;
1565  }
1566  dump_stmts(stmt->body);
1567  dump_ind();
1568  printf(" ENDFORS\n");
1569 }
#define NIL
Definition: pg_list.h:65
#define printf(...)
Definition: port.h:222
PLpgSQL_expr * query
Definition: plpgsql.h:738
static void dump_ind(void)
Definition: pl_funcs.c:820
PLpgSQL_variable * var
Definition: plpgsql.h:735
#define lfirst(lc)
Definition: pg_list.h:169
static int dump_indent
Definition: pl_funcs.c:784
char * refname
Definition: plpgsql.h:290
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1592
int i
static void dump_stmts(List *stmts)
Definition: pl_funcs.c:922

◆ dump_execsql()

static void dump_execsql ( PLpgSQL_stmt_execsql stmt)
static

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

1486 {
1487  dump_ind();
1488  printf("EXECSQL ");
1489  dump_expr(stmt->sqlstmt);
1490  printf("\n");
1491 
1492  dump_indent += 2;
1493  if (stmt->target != NULL)
1494  {
1495  dump_ind();
1496  printf(" INTO%s target = %d %s\n",
1497  stmt->strict ? " STRICT" : "",
1498  stmt->target->dno, stmt->target->refname);
1499  }
1500  dump_indent -= 2;
1501 }
PLpgSQL_expr * sqlstmt
Definition: plpgsql.h:895
#define printf(...)
Definition: port.h:222
PLpgSQL_variable * target
Definition: plpgsql.h:900
static void dump_ind(void)
Definition: pl_funcs.c:820
static int dump_indent
Definition: pl_funcs.c:784
char * refname
Definition: plpgsql.h:290
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1592

◆ dump_exit()

static void dump_exit ( PLpgSQL_stmt_exit stmt)
static

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

1318 {
1319  dump_ind();
1320  printf("%s", stmt->is_exit ? "EXIT" : "CONTINUE");
1321  if (stmt->label != NULL)
1322  printf(" label='%s'", stmt->label);
1323  if (stmt->cond != NULL)
1324  {
1325  printf(" WHEN ");
1326  dump_expr(stmt->cond);
1327  }
1328  printf("\n");
1329 }
#define printf(...)
Definition: port.h:222
PLpgSQL_expr * cond
Definition: plpgsql.h:811
static void dump_ind(void)
Definition: pl_funcs.c:820
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1592

◆ dump_expr()

◆ dump_fetch()

static void dump_fetch ( PLpgSQL_stmt_fetch stmt)
static

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

1213 {
1214  dump_ind();
1215 
1216  if (!stmt->is_move)
1217  {
1218  printf("FETCH curvar=%d\n", stmt->curvar);
1219  dump_cursor_direction(stmt);
1220 
1221  dump_indent += 2;
1222  if (stmt->target != NULL)
1223  {
1224  dump_ind();
1225  printf(" target = %d %s\n",
1226  stmt->target->dno, stmt->target->refname);
1227  }
1228  dump_indent -= 2;
1229  }
1230  else
1231  {
1232  printf("MOVE curvar=%d\n", stmt->curvar);
1233  dump_cursor_direction(stmt);
1234  }
1235 }
static void dump_cursor_direction(PLpgSQL_stmt_fetch *stmt)
Definition: pl_funcs.c:1238
#define printf(...)
Definition: port.h:222
static void dump_ind(void)
Definition: pl_funcs.c:820
static int dump_indent
Definition: pl_funcs.c:784
char * refname
Definition: plpgsql.h:290
PLpgSQL_variable * target
Definition: plpgsql.h:781

◆ dump_forc()

static void dump_forc ( PLpgSQL_stmt_forc stmt)
static

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

1122 {
1123  dump_ind();
1124  printf("FORC %s ", stmt->var->refname);
1125  printf("curvar=%d\n", stmt->curvar);
1126 
1127  dump_indent += 2;
1128  if (stmt->argquery != NULL)
1129  {
1130  dump_ind();
1131  printf(" arguments = ");
1132  dump_expr(stmt->argquery);
1133  printf("\n");
1134  }
1135  dump_indent -= 2;
1136 
1137  dump_stmts(stmt->body);
1138 
1139  dump_ind();
1140  printf(" ENDFORC\n");
1141 }
PLpgSQL_variable * var
Definition: plpgsql.h:719
#define printf(...)
Definition: port.h:222
static void dump_ind(void)
Definition: pl_funcs.c:820
static int dump_indent
Definition: pl_funcs.c:784
char * refname
Definition: plpgsql.h:290
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1592
PLpgSQL_expr * argquery
Definition: plpgsql.h:723
static void dump_stmts(List *stmts)
Definition: pl_funcs.c:922

◆ dump_foreach_a()

static void dump_foreach_a ( PLpgSQL_stmt_foreach_a stmt)
static

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

1145 {
1146  dump_ind();
1147  printf("FOREACHA var %d ", stmt->varno);
1148  if (stmt->slice != 0)
1149  printf("SLICE %d ", stmt->slice);
1150  printf("IN ");
1151  dump_expr(stmt->expr);
1152  printf("\n");
1153 
1154  dump_stmts(stmt->body);
1155 
1156  dump_ind();
1157  printf(" ENDFOREACHA");
1158 }
PLpgSQL_expr * expr
Definition: plpgsql.h:753
#define printf(...)
Definition: port.h:222
static void dump_ind(void)
Definition: pl_funcs.c:820
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1592
static void dump_stmts(List *stmts)
Definition: pl_funcs.c:922

◆ dump_fori()

static void dump_fori ( PLpgSQL_stmt_fori stmt)
static

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

1078 {
1079  dump_ind();
1080  printf("FORI %s %s\n", stmt->var->refname, (stmt->reverse) ? "REVERSE" : "NORMAL");
1081 
1082  dump_indent += 2;
1083  dump_ind();
1084  printf(" lower = ");
1085  dump_expr(stmt->lower);
1086  printf("\n");
1087  dump_ind();
1088  printf(" upper = ");
1089  dump_expr(stmt->upper);
1090  printf("\n");
1091  if (stmt->step)
1092  {
1093  dump_ind();
1094  printf(" step = ");
1095  dump_expr(stmt->step);
1096  printf("\n");
1097  }
1098  dump_indent -= 2;
1099 
1100  dump_stmts(stmt->body);
1101 
1102  dump_ind();
1103  printf(" ENDFORI\n");
1104 }
char * refname
Definition: plpgsql.h:312
#define printf(...)
Definition: port.h:222
PLpgSQL_expr * lower
Definition: plpgsql.h:673
PLpgSQL_var * var
Definition: plpgsql.h:672
static void dump_ind(void)
Definition: pl_funcs.c:820
static int dump_indent
Definition: pl_funcs.c:784
PLpgSQL_expr * step
Definition: plpgsql.h:675
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1592
PLpgSQL_expr * upper
Definition: plpgsql.h:674
static void dump_stmts(List *stmts)
Definition: pl_funcs.c:922

◆ dump_fors()

static void dump_fors ( PLpgSQL_stmt_fors stmt)
static

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

1108 {
1109  dump_ind();
1110  printf("FORS %s ", stmt->var->refname);
1111  dump_expr(stmt->query);
1112  printf("\n");
1113 
1114  dump_stmts(stmt->body);
1115 
1116  dump_ind();
1117  printf(" ENDFORS\n");
1118 }
#define printf(...)
Definition: port.h:222
PLpgSQL_variable * var
Definition: plpgsql.h:704
static void dump_ind(void)
Definition: pl_funcs.c:820
char * refname
Definition: plpgsql.h:290
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1592
PLpgSQL_expr * query
Definition: plpgsql.h:707
static void dump_stmts(List *stmts)
Definition: pl_funcs.c:922

◆ dump_getdiag()

static void dump_getdiag ( PLpgSQL_stmt_getdiag stmt)
static

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

1573 {
1574  ListCell *lc;
1575 
1576  dump_ind();
1577  printf("GET %s DIAGNOSTICS ", stmt->is_stacked ? "STACKED" : "CURRENT");
1578  foreach(lc, stmt->diag_items)
1579  {
1580  PLpgSQL_diag_item *diag_item = (PLpgSQL_diag_item *) lfirst(lc);
1581 
1582  if (lc != list_head(stmt->diag_items))
1583  printf(", ");
1584 
1585  printf("{var %d} = %s", diag_item->target,
1586  plpgsql_getdiag_kindname(diag_item->kind));
1587  }
1588  printf("\n");
1589 }
#define printf(...)
Definition: port.h:222
PLpgSQL_getdiag_kind kind
Definition: plpgsql.h:573
static ListCell * list_head(const List *l)
Definition: pg_list.h:125
static void dump_ind(void)
Definition: pl_funcs.c:820
#define lfirst(lc)
Definition: pg_list.h:169
const char * plpgsql_getdiag_kindname(PLpgSQL_getdiag_kind kind)
Definition: pl_funcs.c:300

◆ dump_if()

static void dump_if ( PLpgSQL_stmt_if stmt)
static

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

984 {
985  ListCell *l;
986 
987  dump_ind();
988  printf("IF ");
989  dump_expr(stmt->cond);
990  printf(" THEN\n");
991  dump_stmts(stmt->then_body);
992  foreach(l, stmt->elsif_list)
993  {
995 
996  dump_ind();
997  printf(" ELSIF ");
998  dump_expr(elif->cond);
999  printf(" THEN\n");
1000  dump_stmts(elif->stmts);
1001  }
1002  if (stmt->else_body != NIL)
1003  {
1004  dump_ind();
1005  printf(" ELSE\n");
1006  dump_stmts(stmt->else_body);
1007  }
1008  dump_ind();
1009  printf(" ENDIF\n");
1010 }
#define NIL
Definition: pg_list.h:65
PLpgSQL_expr * cond
Definition: plpgsql.h:597
List * then_body
Definition: plpgsql.h:598
List * elsif_list
Definition: plpgsql.h:599
List * stmts
Definition: plpgsql.h:610
#define printf(...)
Definition: port.h:222
PLpgSQL_expr * cond
Definition: plpgsql.h:609
static void dump_ind(void)
Definition: pl_funcs.c:820
#define lfirst(lc)
Definition: pg_list.h:169
List * else_body
Definition: plpgsql.h:600
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1592
static void dump_stmts(List *stmts)
Definition: pl_funcs.c:922

◆ dump_ind()

static void dump_ind ( void  )
static

◆ dump_loop()

static void dump_loop ( PLpgSQL_stmt_loop stmt)
static

Definition at line 1051 of file pl_funcs.c.

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

Referenced by dump_stmt().

1052 {
1053  dump_ind();
1054  printf("LOOP\n");
1055 
1056  dump_stmts(stmt->body);
1057 
1058  dump_ind();
1059  printf(" ENDLOOP\n");
1060 }
#define printf(...)
Definition: port.h:222
static void dump_ind(void)
Definition: pl_funcs.c:820
static void dump_stmts(List *stmts)
Definition: pl_funcs.c:922

◆ dump_open()

static void dump_open ( PLpgSQL_stmt_open stmt)
static

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

1162 {
1163  dump_ind();
1164  printf("OPEN curvar=%d\n", stmt->curvar);
1165 
1166  dump_indent += 2;
1167  if (stmt->argquery != NULL)
1168  {
1169  dump_ind();
1170  printf(" arguments = '");
1171  dump_expr(stmt->argquery);
1172  printf("'\n");
1173  }
1174  if (stmt->query != NULL)
1175  {
1176  dump_ind();
1177  printf(" query = '");
1178  dump_expr(stmt->query);
1179  printf("'\n");
1180  }
1181  if (stmt->dynquery != NULL)
1182  {
1183  dump_ind();
1184  printf(" execute = '");
1185  dump_expr(stmt->dynquery);
1186  printf("'\n");
1187 
1188  if (stmt->params != NIL)
1189  {
1190  ListCell *lc;
1191  int i;
1192 
1193  dump_indent += 2;
1194  dump_ind();
1195  printf(" USING\n");
1196  dump_indent += 2;
1197  i = 1;
1198  foreach(lc, stmt->params)
1199  {
1200  dump_ind();
1201  printf(" parameter $%d: ", i++);
1202  dump_expr((PLpgSQL_expr *) lfirst(lc));
1203  printf("\n");
1204  }
1205  dump_indent -= 4;
1206  }
1207  }
1208  dump_indent -= 2;
1209 }
#define NIL
Definition: pg_list.h:65
#define printf(...)
Definition: port.h:222
PLpgSQL_expr * dynquery
Definition: plpgsql.h:769
PLpgSQL_expr * query
Definition: plpgsql.h:768
static void dump_ind(void)
Definition: pl_funcs.c:820
#define lfirst(lc)
Definition: pg_list.h:169
static int dump_indent
Definition: pl_funcs.c:784
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1592
PLpgSQL_expr * argquery
Definition: plpgsql.h:767
int i

◆ dump_perform()

static void dump_perform ( PLpgSQL_stmt_perform stmt)
static

Definition at line 1279 of file pl_funcs.c.

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

Referenced by dump_stmt().

1280 {
1281  dump_ind();
1282  printf("PERFORM expr = ");
1283  dump_expr(stmt->expr);
1284  printf("\n");
1285 }
#define printf(...)
Definition: port.h:222
PLpgSQL_expr * expr
Definition: plpgsql.h:530
static void dump_ind(void)
Definition: pl_funcs.c:820
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1592

◆ dump_raise()

static void dump_raise ( PLpgSQL_stmt_raise stmt)
static

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

1398 {
1399  ListCell *lc;
1400  int i = 0;
1401 
1402  dump_ind();
1403  printf("RAISE level=%d", stmt->elog_level);
1404  if (stmt->condname)
1405  printf(" condname='%s'", stmt->condname);
1406  if (stmt->message)
1407  printf(" message='%s'", stmt->message);
1408  printf("\n");
1409  dump_indent += 2;
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  if (stmt->options)
1418  {
1419  dump_ind();
1420  printf(" USING\n");
1421  dump_indent += 2;
1422  foreach(lc, stmt->options)
1423  {
1425 
1426  dump_ind();
1427  switch (opt->opt_type)
1428  {
1430  printf(" ERRCODE = ");
1431  break;
1433  printf(" MESSAGE = ");
1434  break;
1436  printf(" DETAIL = ");
1437  break;
1439  printf(" HINT = ");
1440  break;
1442  printf(" COLUMN = ");
1443  break;
1445  printf(" CONSTRAINT = ");
1446  break;
1448  printf(" DATATYPE = ");
1449  break;
1451  printf(" TABLE = ");
1452  break;
1454  printf(" SCHEMA = ");
1455  break;
1456  }
1457  dump_expr(opt->expr);
1458  printf("\n");
1459  }
1460  dump_indent -= 2;
1461  }
1462  dump_indent -= 2;
1463 }
#define printf(...)
Definition: port.h:222
PLpgSQL_raise_option_type opt_type
Definition: plpgsql.h:871
static void dump_ind(void)
Definition: pl_funcs.c:820
#define lfirst(lc)
Definition: pg_list.h:169
static int dump_indent
Definition: pl_funcs.c:784
PLpgSQL_expr * expr
Definition: plpgsql.h:872
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1592
int i

◆ dump_return()

static void dump_return ( PLpgSQL_stmt_return stmt)
static

Definition at line 1332 of file pl_funcs.c.

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

Referenced by dump_stmt().

1333 {
1334  dump_ind();
1335  printf("RETURN ");
1336  if (stmt->retvarno >= 0)
1337  printf("variable %d", stmt->retvarno);
1338  else if (stmt->expr != NULL)
1339  dump_expr(stmt->expr);
1340  else
1341  printf("NULL");
1342  printf("\n");
1343 }
PLpgSQL_expr * expr
Definition: plpgsql.h:822
#define printf(...)
Definition: port.h:222
static void dump_ind(void)
Definition: pl_funcs.c:820
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1592

◆ dump_return_next()

static void dump_return_next ( PLpgSQL_stmt_return_next stmt)
static

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

1347 {
1348  dump_ind();
1349  printf("RETURN NEXT ");
1350  if (stmt->retvarno >= 0)
1351  printf("variable %d", stmt->retvarno);
1352  else if (stmt->expr != NULL)
1353  dump_expr(stmt->expr);
1354  else
1355  printf("NULL");
1356  printf("\n");
1357 }
#define printf(...)
Definition: port.h:222
PLpgSQL_expr * expr
Definition: plpgsql.h:834
static void dump_ind(void)
Definition: pl_funcs.c:820
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1592

◆ dump_return_query()

static void dump_return_query ( PLpgSQL_stmt_return_query stmt)
static

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

1361 {
1362  dump_ind();
1363  if (stmt->query)
1364  {
1365  printf("RETURN QUERY ");
1366  dump_expr(stmt->query);
1367  printf("\n");
1368  }
1369  else
1370  {
1371  printf("RETURN QUERY EXECUTE ");
1372  dump_expr(stmt->dynquery);
1373  printf("\n");
1374  if (stmt->params != NIL)
1375  {
1376  ListCell *lc;
1377  int i;
1378 
1379  dump_indent += 2;
1380  dump_ind();
1381  printf(" USING\n");
1382  dump_indent += 2;
1383  i = 1;
1384  foreach(lc, stmt->params)
1385  {
1386  dump_ind();
1387  printf(" parameter $%d: ", i++);
1388  dump_expr((PLpgSQL_expr *) lfirst(lc));
1389  printf("\n");
1390  }
1391  dump_indent -= 4;
1392  }
1393  }
1394 }
#define NIL
Definition: pg_list.h:65
#define printf(...)
Definition: port.h:222
PLpgSQL_expr * query
Definition: plpgsql.h:846
static void dump_ind(void)
Definition: pl_funcs.c:820
#define lfirst(lc)
Definition: pg_list.h:169
static int dump_indent
Definition: pl_funcs.c:784
PLpgSQL_expr * dynquery
Definition: plpgsql.h:847
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1592
int i

◆ dump_rollback()

static void dump_rollback ( PLpgSQL_stmt_rollback stmt)
static

Definition at line 1307 of file pl_funcs.c.

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

Referenced by dump_stmt().

1308 {
1309  dump_ind();
1310  if (stmt->chain)
1311  printf("ROLLBACK AND CHAIN\n");
1312  else
1313  printf("ROLLBACK\n");
1314 }
#define printf(...)
Definition: port.h:222
static void dump_ind(void)
Definition: pl_funcs.c:820

◆ dump_stmt()

static void dump_stmt ( PLpgSQL_stmt stmt)
static

Definition at line 829 of file pl_funcs.c.

References PLpgSQL_stmt::cmd_type, PLpgSQL_stmt_rollback::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_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_WHILE, and printf.

Referenced by dump_stmts().

830 {
831  printf("%3d:", stmt->lineno);
832  switch (stmt->cmd_type)
833  {
834  case PLPGSQL_STMT_BLOCK:
835  dump_block((PLpgSQL_stmt_block *) stmt);
836  break;
837  case PLPGSQL_STMT_ASSIGN:
839  break;
840  case PLPGSQL_STMT_IF:
841  dump_if((PLpgSQL_stmt_if *) stmt);
842  break;
843  case PLPGSQL_STMT_CASE:
844  dump_case((PLpgSQL_stmt_case *) stmt);
845  break;
846  case PLPGSQL_STMT_LOOP:
847  dump_loop((PLpgSQL_stmt_loop *) stmt);
848  break;
849  case PLPGSQL_STMT_WHILE:
850  dump_while((PLpgSQL_stmt_while *) stmt);
851  break;
852  case PLPGSQL_STMT_FORI:
853  dump_fori((PLpgSQL_stmt_fori *) stmt);
854  break;
855  case PLPGSQL_STMT_FORS:
856  dump_fors((PLpgSQL_stmt_fors *) stmt);
857  break;
858  case PLPGSQL_STMT_FORC:
859  dump_forc((PLpgSQL_stmt_forc *) stmt);
860  break;
863  break;
864  case PLPGSQL_STMT_EXIT:
865  dump_exit((PLpgSQL_stmt_exit *) stmt);
866  break;
867  case PLPGSQL_STMT_RETURN:
869  break;
872  break;
875  break;
876  case PLPGSQL_STMT_RAISE:
877  dump_raise((PLpgSQL_stmt_raise *) stmt);
878  break;
879  case PLPGSQL_STMT_ASSERT:
881  break;
884  break;
887  break;
890  break;
893  break;
894  case PLPGSQL_STMT_OPEN:
895  dump_open((PLpgSQL_stmt_open *) stmt);
896  break;
897  case PLPGSQL_STMT_FETCH:
898  dump_fetch((PLpgSQL_stmt_fetch *) stmt);
899  break;
900  case PLPGSQL_STMT_CLOSE:
901  dump_close((PLpgSQL_stmt_close *) stmt);
902  break;
905  break;
906  case PLPGSQL_STMT_CALL:
907  dump_call((PLpgSQL_stmt_call *) stmt);
908  break;
909  case PLPGSQL_STMT_COMMIT:
911  break;
914  break;
915  default:
916  elog(ERROR, "unrecognized cmd_type: %d", stmt->cmd_type);
917  break;
918  }
919 }
int lineno
Definition: plpgsql.h:455
static void dump_raise(PLpgSQL_stmt_raise *stmt)
Definition: pl_funcs.c:1397
static void dump_perform(PLpgSQL_stmt_perform *stmt)
Definition: pl_funcs.c:1279
static void dump_forc(PLpgSQL_stmt_forc *stmt)
Definition: pl_funcs.c:1121
#define printf(...)
Definition: port.h:222
static void dump_rollback(PLpgSQL_stmt_rollback *stmt)
Definition: pl_funcs.c:1307
static void dump_fors(PLpgSQL_stmt_fors *stmt)
Definition: pl_funcs.c:1107
static void dump_fetch(PLpgSQL_stmt_fetch *stmt)
Definition: pl_funcs.c:1212
#define ERROR
Definition: elog.h:46
static void dump_case(PLpgSQL_stmt_case *stmt)
Definition: pl_funcs.c:1013
static void dump_getdiag(PLpgSQL_stmt_getdiag *stmt)
Definition: pl_funcs.c:1572
static void dump_if(PLpgSQL_stmt_if *stmt)
Definition: pl_funcs.c:983
static void dump_return_query(PLpgSQL_stmt_return_query *stmt)
Definition: pl_funcs.c:1360
static void dump_return(PLpgSQL_stmt_return *stmt)
Definition: pl_funcs.c:1332
static void dump_return_next(PLpgSQL_stmt_return_next *stmt)
Definition: pl_funcs.c:1346
static void dump_loop(PLpgSQL_stmt_loop *stmt)
Definition: pl_funcs.c:1051
static void dump_close(PLpgSQL_stmt_close *stmt)
Definition: pl_funcs.c:1272
static void dump_while(PLpgSQL_stmt_while *stmt)
Definition: pl_funcs.c:1063
static void dump_execsql(PLpgSQL_stmt_execsql *stmt)
Definition: pl_funcs.c:1485
static void dump_dynexecute(PLpgSQL_stmt_dynexecute *stmt)
Definition: pl_funcs.c:1504
static void dump_dynfors(PLpgSQL_stmt_dynfors *stmt)
Definition: pl_funcs.c:1541
static void dump_block(PLpgSQL_stmt_block *block)
Definition: pl_funcs.c:933
static void dump_foreach_a(PLpgSQL_stmt_foreach_a *stmt)
Definition: pl_funcs.c:1144
#define elog(elevel,...)
Definition: elog.h:232
static void dump_commit(PLpgSQL_stmt_commit *stmt)
Definition: pl_funcs.c:1297
static void dump_assert(PLpgSQL_stmt_assert *stmt)
Definition: pl_funcs.c:1466
static void dump_open(PLpgSQL_stmt_open *stmt)
Definition: pl_funcs.c:1161
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:454
static void dump_fori(PLpgSQL_stmt_fori *stmt)
Definition: pl_funcs.c:1077
static void dump_call(PLpgSQL_stmt_call *stmt)
Definition: pl_funcs.c:1288
static void dump_assign(PLpgSQL_stmt_assign *stmt)
Definition: pl_funcs.c:974
static void dump_exit(PLpgSQL_stmt_exit *stmt)
Definition: pl_funcs.c:1317

◆ dump_stmts()

static void dump_stmts ( List stmts)
static

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

923 {
924  ListCell *s;
925 
926  dump_indent += 2;
927  foreach(s, stmts)
928  dump_stmt((PLpgSQL_stmt *) lfirst(s));
929  dump_indent -= 2;
930 }
#define lfirst(lc)
Definition: pg_list.h:169
static int dump_indent
Definition: pl_funcs.c:784
static void dump_stmt(PLpgSQL_stmt *stmt)
Definition: pl_funcs.c:829

◆ dump_while()

static void dump_while ( PLpgSQL_stmt_while stmt)
static

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

1064 {
1065  dump_ind();
1066  printf("WHILE ");
1067  dump_expr(stmt->cond);
1068  printf("\n");
1069 
1070  dump_stmts(stmt->body);
1071 
1072  dump_ind();
1073  printf(" ENDWHILE\n");
1074 }
PLpgSQL_expr * cond
Definition: plpgsql.h:659
#define printf(...)
Definition: port.h:222
static void dump_ind(void)
Definition: pl_funcs.c:820
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1592
static void dump_stmts(List *stmts)
Definition: pl_funcs.c:922

◆ free_assert()

static void free_assert ( PLpgSQL_stmt_assert stmt)
static

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

673 {
674  free_expr(stmt->cond);
675  free_expr(stmt->message);
676 }
PLpgSQL_expr * message
Definition: plpgsql.h:884
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:715
PLpgSQL_expr * cond
Definition: plpgsql.h:883

◆ free_assign()

static void free_assign ( PLpgSQL_stmt_assign stmt)
static

Definition at line 495 of file pl_funcs.c.

References PLpgSQL_stmt_assign::expr, and free_expr().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

496 {
497  free_expr(stmt->expr);
498 }
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:715
PLpgSQL_expr * expr
Definition: plpgsql.h:519

◆ free_block()

static void free_block ( PLpgSQL_stmt_block block)
static

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

479 {
480  free_stmts(block->body);
481  if (block->exceptions)
482  {
483  ListCell *e;
484 
485  foreach(e, block->exceptions->exc_list)
486  {
488 
489  free_stmts(exc->action);
490  }
491  }
492 }
static void free_stmts(List *stmts)
Definition: pl_funcs.c:467
#define lfirst(lc)
Definition: pg_list.h:169
PLpgSQL_exception_block * exceptions
Definition: plpgsql.h:507
e
Definition: preproc-init.c:82

◆ free_call()

static void free_call ( PLpgSQL_stmt_call stmt)
static

Definition at line 608 of file pl_funcs.c.

References PLpgSQL_stmt_call::expr, and free_expr().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

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

◆ free_case()

static void free_case ( PLpgSQL_stmt_case stmt)
static

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

519 {
520  ListCell *l;
521 
522  free_expr(stmt->t_expr);
523  foreach(l, stmt->case_when_list)
524  {
526 
527  free_expr(cwt->expr);
528  free_stmts(cwt->stmts);
529  }
530  free_stmts(stmt->else_stmts);
531 }
List * else_stmts
Definition: plpgsql.h:625
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:715
PLpgSQL_expr * expr
Definition: plpgsql.h:634
List * case_when_list
Definition: plpgsql.h:623
static void free_stmts(List *stmts)
Definition: pl_funcs.c:467
#define lfirst(lc)
Definition: pg_list.h:169
PLpgSQL_expr * t_expr
Definition: plpgsql.h:621

◆ free_close()

static void free_close ( PLpgSQL_stmt_close stmt)
static

Definition at line 597 of file pl_funcs.c.

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

598 {
599 }

◆ free_commit()

static void free_commit ( PLpgSQL_stmt_commit stmt)
static

Definition at line 614 of file pl_funcs.c.

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

615 {
616 }

◆ free_dynexecute()

static void free_dynexecute ( PLpgSQL_stmt_dynexecute stmt)
static

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

686 {
687  ListCell *lc;
688 
689  free_expr(stmt->query);
690  foreach(lc, stmt->params)
691  {
692  free_expr((PLpgSQL_expr *) lfirst(lc));
693  }
694 }
PLpgSQL_expr * query
Definition: plpgsql.h:911
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:715
#define lfirst(lc)
Definition: pg_list.h:169

◆ free_dynfors()

static void free_dynfors ( PLpgSQL_stmt_dynfors stmt)
static

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

698 {
699  ListCell *lc;
700 
701  free_stmts(stmt->body);
702  free_expr(stmt->query);
703  foreach(lc, stmt->params)
704  {
705  free_expr((PLpgSQL_expr *) lfirst(lc));
706  }
707 }
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:715
PLpgSQL_expr * query
Definition: plpgsql.h:738
static void free_stmts(List *stmts)
Definition: pl_funcs.c:467
#define lfirst(lc)
Definition: pg_list.h:169

◆ free_execsql()

static void free_execsql ( PLpgSQL_stmt_execsql stmt)
static

Definition at line 679 of file pl_funcs.c.

References free_expr(), and PLpgSQL_stmt_execsql::sqlstmt.

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

680 {
681  free_expr(stmt->sqlstmt);
682 }
PLpgSQL_expr * sqlstmt
Definition: plpgsql.h:895
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:715

◆ free_exit()

static void free_exit ( PLpgSQL_stmt_exit stmt)
static

Definition at line 624 of file pl_funcs.c.

References PLpgSQL_stmt_exit::cond, and free_expr().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

625 {
626  free_expr(stmt->cond);
627 }
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:715
PLpgSQL_expr * cond
Definition: plpgsql.h:811

◆ free_expr()

static void free_expr ( PLpgSQL_expr expr)
static

◆ free_fetch()

static void free_fetch ( PLpgSQL_stmt_fetch stmt)
static

Definition at line 591 of file pl_funcs.c.

References PLpgSQL_stmt_fetch::expr, and free_expr().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

592 {
593  free_expr(stmt->expr);
594 }
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:715
PLpgSQL_expr * expr
Definition: plpgsql.h:785

◆ free_forc()

static void free_forc ( PLpgSQL_stmt_forc stmt)
static

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

564 {
565  free_stmts(stmt->body);
566  free_expr(stmt->argquery);
567 }
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:715
static void free_stmts(List *stmts)
Definition: pl_funcs.c:467
PLpgSQL_expr * argquery
Definition: plpgsql.h:723

◆ free_foreach_a()

static void free_foreach_a ( PLpgSQL_stmt_foreach_a stmt)
static

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

571 {
572  free_expr(stmt->expr);
573  free_stmts(stmt->body);
574 }
PLpgSQL_expr * expr
Definition: plpgsql.h:753
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:715
static void free_stmts(List *stmts)
Definition: pl_funcs.c:467

◆ free_fori()

static void free_fori ( PLpgSQL_stmt_fori stmt)
static

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

548 {
549  free_expr(stmt->lower);
550  free_expr(stmt->upper);
551  free_expr(stmt->step);
552  free_stmts(stmt->body);
553 }
PLpgSQL_expr * lower
Definition: plpgsql.h:673
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:715
static void free_stmts(List *stmts)
Definition: pl_funcs.c:467
PLpgSQL_expr * step
Definition: plpgsql.h:675
PLpgSQL_expr * upper
Definition: plpgsql.h:674

◆ free_fors()

static void free_fors ( PLpgSQL_stmt_fors stmt)
static

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

557 {
558  free_stmts(stmt->body);
559  free_expr(stmt->query);
560 }
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:715
static void free_stmts(List *stmts)
Definition: pl_funcs.c:467
PLpgSQL_expr * query
Definition: plpgsql.h:707

◆ free_getdiag()

static void free_getdiag ( PLpgSQL_stmt_getdiag stmt)
static

Definition at line 710 of file pl_funcs.c.

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

711 {
712 }

◆ free_if()

static void free_if ( PLpgSQL_stmt_if stmt)
static

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

502 {
503  ListCell *l;
504 
505  free_expr(stmt->cond);
506  free_stmts(stmt->then_body);
507  foreach(l, stmt->elsif_list)
508  {
510 
511  free_expr(elif->cond);
512  free_stmts(elif->stmts);
513  }
514  free_stmts(stmt->else_body);
515 }
PLpgSQL_expr * cond
Definition: plpgsql.h:597
List * then_body
Definition: plpgsql.h:598
List * elsif_list
Definition: plpgsql.h:599
List * stmts
Definition: plpgsql.h:610
PLpgSQL_expr * cond
Definition: plpgsql.h:609
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:715
static void free_stmts(List *stmts)
Definition: pl_funcs.c:467
#define lfirst(lc)
Definition: pg_list.h:169
List * else_body
Definition: plpgsql.h:600

◆ free_loop()

static void free_loop ( PLpgSQL_stmt_loop stmt)
static

Definition at line 534 of file pl_funcs.c.

References PLpgSQL_stmt_loop::body, and free_stmts().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

535 {
536  free_stmts(stmt->body);
537 }
static void free_stmts(List *stmts)
Definition: pl_funcs.c:467

◆ free_open()

static void free_open ( PLpgSQL_stmt_open stmt)
static

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

578 {
579  ListCell *lc;
580 
581  free_expr(stmt->argquery);
582  free_expr(stmt->query);
583  free_expr(stmt->dynquery);
584  foreach(lc, stmt->params)
585  {
586  free_expr((PLpgSQL_expr *) lfirst(lc));
587  }
588 }
PLpgSQL_expr * dynquery
Definition: plpgsql.h:769
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:715
PLpgSQL_expr * query
Definition: plpgsql.h:768
#define lfirst(lc)
Definition: pg_list.h:169
PLpgSQL_expr * argquery
Definition: plpgsql.h:767

◆ free_perform()

static void free_perform ( PLpgSQL_stmt_perform stmt)
static

Definition at line 602 of file pl_funcs.c.

References PLpgSQL_stmt_perform::expr, and free_expr().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

603 {
604  free_expr(stmt->expr);
605 }
PLpgSQL_expr * expr
Definition: plpgsql.h:530
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:715

◆ free_raise()

static void free_raise ( PLpgSQL_stmt_raise stmt)
static

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

656 {
657  ListCell *lc;
658 
659  foreach(lc, stmt->params)
660  {
661  free_expr((PLpgSQL_expr *) lfirst(lc));
662  }
663  foreach(lc, stmt->options)
664  {
666 
667  free_expr(opt->expr);
668  }
669 }
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:715
#define lfirst(lc)
Definition: pg_list.h:169
PLpgSQL_expr * expr
Definition: plpgsql.h:872

◆ free_return()

static void free_return ( PLpgSQL_stmt_return stmt)
static

Definition at line 630 of file pl_funcs.c.

References PLpgSQL_stmt_return::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:822
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:715

◆ free_return_next()

static void free_return_next ( PLpgSQL_stmt_return_next stmt)
static

Definition at line 636 of file pl_funcs.c.

References PLpgSQL_stmt_return_next::expr, and free_expr().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

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

◆ free_return_query()

static void free_return_query ( PLpgSQL_stmt_return_query stmt)
static

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

643 {
644  ListCell *lc;
645 
646  free_expr(stmt->query);
647  free_expr(stmt->dynquery);
648  foreach(lc, stmt->params)
649  {
650  free_expr((PLpgSQL_expr *) lfirst(lc));
651  }
652 }
PLpgSQL_expr * query
Definition: plpgsql.h:846
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:715
#define lfirst(lc)
Definition: pg_list.h:169
PLpgSQL_expr * dynquery
Definition: plpgsql.h:847

◆ free_rollback()

static void free_rollback ( PLpgSQL_stmt_rollback stmt)
static

Definition at line 619 of file pl_funcs.c.

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

620 {
621 }

◆ free_stmt()

static void free_stmt ( PLpgSQL_stmt stmt)
static

Definition at line 375 of file pl_funcs.c.

References PLpgSQL_stmt::cmd_type, PLpgSQL_stmt_rollback::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_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, and PLPGSQL_STMT_WHILE.

Referenced by free_stmts(), and plpgsql_getdiag_kindname().

376 {
377  switch (stmt->cmd_type)
378  {
379  case PLPGSQL_STMT_BLOCK:
380  free_block((PLpgSQL_stmt_block *) stmt);
381  break;
382  case PLPGSQL_STMT_ASSIGN:
384  break;
385  case PLPGSQL_STMT_IF:
386  free_if((PLpgSQL_stmt_if *) stmt);
387  break;
388  case PLPGSQL_STMT_CASE:
389  free_case((PLpgSQL_stmt_case *) stmt);
390  break;
391  case PLPGSQL_STMT_LOOP:
392  free_loop((PLpgSQL_stmt_loop *) stmt);
393  break;
394  case PLPGSQL_STMT_WHILE:
395  free_while((PLpgSQL_stmt_while *) stmt);
396  break;
397  case PLPGSQL_STMT_FORI:
398  free_fori((PLpgSQL_stmt_fori *) stmt);
399  break;
400  case PLPGSQL_STMT_FORS:
401  free_fors((PLpgSQL_stmt_fors *) stmt);
402  break;
403  case PLPGSQL_STMT_FORC:
404  free_forc((PLpgSQL_stmt_forc *) stmt);
405  break;
408  break;
409  case PLPGSQL_STMT_EXIT:
410  free_exit((PLpgSQL_stmt_exit *) stmt);
411  break;
412  case PLPGSQL_STMT_RETURN:
414  break;
417  break;
420  break;
421  case PLPGSQL_STMT_RAISE:
422  free_raise((PLpgSQL_stmt_raise *) stmt);
423  break;
424  case PLPGSQL_STMT_ASSERT:
426  break;
429  break;
432  break;
435  break;
438  break;
439  case PLPGSQL_STMT_OPEN:
440  free_open((PLpgSQL_stmt_open *) stmt);
441  break;
442  case PLPGSQL_STMT_FETCH:
443  free_fetch((PLpgSQL_stmt_fetch *) stmt);
444  break;
445  case PLPGSQL_STMT_CLOSE:
446  free_close((PLpgSQL_stmt_close *) stmt);
447  break;
450  break;
451  case PLPGSQL_STMT_CALL:
452  free_call((PLpgSQL_stmt_call *) stmt);
453  break;
454  case PLPGSQL_STMT_COMMIT:
456  break;
459  break;
460  default:
461  elog(ERROR, "unrecognized cmd_type: %d", stmt->cmd_type);
462  break;
463  }
464 }
static void free_assert(PLpgSQL_stmt_assert *stmt)
Definition: pl_funcs.c:672
static void free_dynexecute(PLpgSQL_stmt_dynexecute *stmt)
Definition: pl_funcs.c:685
static void free_raise(PLpgSQL_stmt_raise *stmt)
Definition: pl_funcs.c:655
static void free_open(PLpgSQL_stmt_open *stmt)
Definition: pl_funcs.c:577
static void free_return(PLpgSQL_stmt_return *stmt)
Definition: pl_funcs.c:630
static void free_loop(PLpgSQL_stmt_loop *stmt)
Definition: pl_funcs.c:534
static void free_dynfors(PLpgSQL_stmt_dynfors *stmt)
Definition: pl_funcs.c:697
static void free_rollback(PLpgSQL_stmt_rollback *stmt)
Definition: pl_funcs.c:619
static void free_assign(PLpgSQL_stmt_assign *stmt)
Definition: pl_funcs.c:495
static void free_getdiag(PLpgSQL_stmt_getdiag *stmt)
Definition: pl_funcs.c:710
#define ERROR
Definition: elog.h:46
static void free_fetch(PLpgSQL_stmt_fetch *stmt)
Definition: pl_funcs.c:591
static void free_close(PLpgSQL_stmt_close *stmt)
Definition: pl_funcs.c:597
static void free_case(PLpgSQL_stmt_case *stmt)
Definition: pl_funcs.c:518
static void free_fori(PLpgSQL_stmt_fori *stmt)
Definition: pl_funcs.c:547
static void free_perform(PLpgSQL_stmt_perform *stmt)
Definition: pl_funcs.c:602
static void free_return_next(PLpgSQL_stmt_return_next *stmt)
Definition: pl_funcs.c:636
static void free_call(PLpgSQL_stmt_call *stmt)
Definition: pl_funcs.c:608
static void free_fors(PLpgSQL_stmt_fors *stmt)
Definition: pl_funcs.c:556
static void free_exit(PLpgSQL_stmt_exit *stmt)
Definition: pl_funcs.c:624
static void free_if(PLpgSQL_stmt_if *stmt)
Definition: pl_funcs.c:501
static void free_return_query(PLpgSQL_stmt_return_query *stmt)
Definition: pl_funcs.c:642
static void free_execsql(PLpgSQL_stmt_execsql *stmt)
Definition: pl_funcs.c:679
static void free_forc(PLpgSQL_stmt_forc *stmt)
Definition: pl_funcs.c:563
#define elog(elevel,...)
Definition: elog.h:232
static void free_commit(PLpgSQL_stmt_commit *stmt)
Definition: pl_funcs.c:614
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:454
static void free_while(PLpgSQL_stmt_while *stmt)
Definition: pl_funcs.c:540
static void free_foreach_a(PLpgSQL_stmt_foreach_a *stmt)
Definition: pl_funcs.c:570
static void free_block(PLpgSQL_stmt_block *block)
Definition: pl_funcs.c:478

◆ free_stmts()

static void free_stmts ( List stmts)
static

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

468 {
469  ListCell *s;
470 
471  foreach(s, stmts)
472  {
473  free_stmt((PLpgSQL_stmt *) lfirst(s));
474  }
475 }
#define lfirst(lc)
Definition: pg_list.h:169
static void free_stmt(PLpgSQL_stmt *stmt)
Definition: pl_funcs.c:375

◆ free_while()

static void free_while ( PLpgSQL_stmt_while stmt)
static

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

541 {
542  free_expr(stmt->cond);
543  free_stmts(stmt->body);
544 }
PLpgSQL_expr * cond
Definition: plpgsql.h:659
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:715
static void free_stmts(List *stmts)
Definition: pl_funcs.c:467

◆ plpgsql_dumptree()

void plpgsql_dumptree ( PLpgSQL_function func)

Definition at line 1598 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_recfield::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_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().

1599 {
1600  int i;
1601  PLpgSQL_datum *d;
1602 
1603  printf("\nExecution tree of successfully compiled PL/pgSQL function %s:\n",
1604  func->fn_signature);
1605 
1606  printf("\nFunction's data area:\n");
1607  for (i = 0; i < func->ndatums; i++)
1608  {
1609  d = func->datums[i];
1610 
1611  printf(" entry %d: ", i);
1612  switch (d->dtype)
1613  {
1614  case PLPGSQL_DTYPE_VAR:
1615  case PLPGSQL_DTYPE_PROMISE:
1616  {
1617  PLpgSQL_var *var = (PLpgSQL_var *) d;
1618 
1619  printf("VAR %-16s type %s (typoid %u) atttypmod %d\n",
1620  var->refname, var->datatype->typname,
1621  var->datatype->typoid,
1622  var->datatype->atttypmod);
1623  if (var->isconst)
1624  printf(" CONSTANT\n");
1625  if (var->notnull)
1626  printf(" NOT NULL\n");
1627  if (var->default_val != NULL)
1628  {
1629  printf(" DEFAULT ");
1630  dump_expr(var->default_val);
1631  printf("\n");
1632  }
1633  if (var->cursor_explicit_expr != NULL)
1634  {
1635  if (var->cursor_explicit_argrow >= 0)
1636  printf(" CURSOR argument row %d\n", var->cursor_explicit_argrow);
1637 
1638  printf(" CURSOR IS ");
1640  printf("\n");
1641  }
1642  if (var->promise != PLPGSQL_PROMISE_NONE)
1643  printf(" PROMISE %d\n",
1644  (int) var->promise);
1645  }
1646  break;
1647  case PLPGSQL_DTYPE_ROW:
1648  {
1649  PLpgSQL_row *row = (PLpgSQL_row *) d;
1650  int i;
1651 
1652  printf("ROW %-16s fields", row->refname);
1653  for (i = 0; i < row->nfields; i++)
1654  {
1655  printf(" %s=var %d", row->fieldnames[i],
1656  row->varnos[i]);
1657  }
1658  printf("\n");
1659  }
1660  break;
1661  case PLPGSQL_DTYPE_REC:
1662  printf("REC %-16s typoid %u\n",
1663  ((PLpgSQL_rec *) d)->refname,
1664  ((PLpgSQL_rec *) d)->rectypeid);
1665  if (((PLpgSQL_rec *) d)->isconst)
1666  printf(" CONSTANT\n");
1667  if (((PLpgSQL_rec *) d)->notnull)
1668  printf(" NOT NULL\n");
1669  if (((PLpgSQL_rec *) d)->default_val != NULL)
1670  {
1671  printf(" DEFAULT ");
1672  dump_expr(((PLpgSQL_rec *) d)->default_val);
1673  printf("\n");
1674  }
1675  break;
1677  printf("RECFIELD %-16s of REC %d\n",
1678  ((PLpgSQL_recfield *) d)->fieldname,
1679  ((PLpgSQL_recfield *) d)->recparentno);
1680  break;
1681  default:
1682  printf("??? unknown data type %d\n", d->dtype);
1683  }
1684  }
1685  printf("\nFunction's statements:\n");
1686 
1687  dump_indent = 0;
1688  printf("%3d:", func->action->lineno);
1689  dump_block(func->action);
1690  printf("\nEnd of execution tree of function %s\n\n", func->fn_signature);
1691  fflush(stdout);
1692 }
PLpgSQL_promise_type promise
Definition: plpgsql.h:341
PLpgSQL_datum ** datums
Definition: plpgsql.h:1002
char * refname
Definition: plpgsql.h:366
char * refname
Definition: plpgsql.h:312
PLpgSQL_stmt_block * action
Definition: plpgsql.h:1006
PLpgSQL_expr * cursor_explicit_expr
Definition: plpgsql.h:326
PLpgSQL_type * datatype
Definition: plpgsql.h:319
bool isconst
Definition: plpgsql.h:314
#define printf(...)
Definition: port.h:222
PLpgSQL_datum_type dtype
Definition: plpgsql.h:276
bool notnull
Definition: plpgsql.h:315
int cursor_explicit_argrow
Definition: plpgsql.h:327
char ** fieldnames
Definition: plpgsql.h:381
PLpgSQL_expr * default_val
Definition: plpgsql.h:316
int * varnos
Definition: plpgsql.h:382
PLpgSQL_datum_type dtype
Definition: plpgsql.h:421
int nfields
Definition: plpgsql.h:380
static int dump_indent
Definition: pl_funcs.c:784
char * fn_signature
Definition: plpgsql.h:967
char * typname
Definition: plpgsql.h:199
static void dump_block(PLpgSQL_stmt_block *block)
Definition: pl_funcs.c:933
int32 atttypmod
Definition: plpgsql.h:207
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1592
int i
Oid typoid
Definition: plpgsql.h:200

◆ plpgsql_free_function_memory()

void plpgsql_free_function_memory ( PLpgSQL_function func)

Definition at line 725 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, elog, ERROR, PLpgSQL_function::fn_cxt, free_block(), free_expr(), i, MemoryContextDelete(), PLpgSQL_function::ndatums, 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().

726 {
727  int i;
728 
729  /* Better not call this on an in-use function */
730  Assert(func->use_count == 0);
731 
732  /* Release plans associated with variable declarations */
733  for (i = 0; i < func->ndatums; i++)
734  {
735  PLpgSQL_datum *d = func->datums[i];
736 
737  switch (d->dtype)
738  {
739  case PLPGSQL_DTYPE_VAR:
741  {
742  PLpgSQL_var *var = (PLpgSQL_var *) d;
743 
744  free_expr(var->default_val);
746  }
747  break;
748  case PLPGSQL_DTYPE_ROW:
749  break;
750  case PLPGSQL_DTYPE_REC:
751  {
752  PLpgSQL_rec *rec = (PLpgSQL_rec *) d;
753 
754  free_expr(rec->default_val);
755  }
756  break;
758  break;
759  default:
760  elog(ERROR, "unrecognized data type: %d", d->dtype);
761  }
762  }
763  func->ndatums = 0;
764 
765  /* Release plans in statement tree */
766  if (func->action)
767  free_block(func->action);
768  func->action = NULL;
769 
770  /*
771  * And finally, release all memory except the PLpgSQL_function struct
772  * itself (which has to be kept around because there may be multiple
773  * fn_extra pointers to it).
774  */
775  if (func->fn_cxt)
777  func->fn_cxt = NULL;
778 }
PLpgSQL_datum ** datums
Definition: plpgsql.h:1002
void MemoryContextDelete(MemoryContext context)
Definition: mcxt.c:218
PLpgSQL_stmt_block * action
Definition: plpgsql.h:1006
PLpgSQL_expr * cursor_explicit_expr
Definition: plpgsql.h:326
PLpgSQL_datum_type dtype
Definition: plpgsql.h:276
#define ERROR
Definition: elog.h:46
PLpgSQL_expr * default_val
Definition: plpgsql.h:316
unsigned long use_count
Definition: plpgsql.h:1014
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:715
MemoryContext fn_cxt
Definition: plpgsql.h:974
#define Assert(condition)
Definition: c.h:804
#define elog(elevel,...)
Definition: elog.h:232
int i
PLpgSQL_expr * default_val
Definition: plpgsql.h:396
static void free_block(PLpgSQL_stmt_block *block)
Definition: pl_funcs.c:478

◆ plpgsql_getdiag_kindname()

const char* plpgsql_getdiag_kindname ( PLpgSQL_getdiag_kind  kind)

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

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

◆ 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:445
#define Assert(condition)
Definition: c.h:804
const char * name
Definition: encode.c:561
void * palloc(Size size)
Definition: mcxt.c:1062
PLpgSQL_nsitem_type itemtype
Definition: plpgsql.h:438
char name[FLEXIBLE_ARRAY_MEMBER]
Definition: plpgsql.h:446
#define offsetof(type, field)
Definition: c.h:727

◆ 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:445
PLpgSQL_nsitem_type itemtype
Definition: plpgsql.h:438

◆ 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:445
PLpgSQL_nsitem_type itemtype
Definition: plpgsql.h:438
char name[FLEXIBLE_ARRAY_MEMBER]
Definition: plpgsql.h:446

◆ 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:445
const char * name
Definition: encode.c:561
PLpgSQL_nsitem_type itemtype
Definition: plpgsql.h:438
char name[FLEXIBLE_ARRAY_MEMBER]
Definition: plpgsql.h:446

◆ 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:445
#define Assert(condition)
Definition: c.h:804
PLpgSQL_nsitem_type itemtype
Definition: plpgsql.h:438

◆ 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, 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  }
292 
293  return "unknown";
294 }
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:454
#define _(x)
Definition: elog.c:89

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