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

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

◆ dump_assign()

static void dump_assign ( PLpgSQL_stmt_assign stmt)
static

Definition at line 995 of file pl_funcs.c.

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

Referenced by dump_stmt().

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

◆ dump_block()

static void dump_block ( PLpgSQL_stmt_block block)
static

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

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

◆ dump_call()

static void dump_call ( PLpgSQL_stmt_call stmt)
static

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

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

◆ dump_case()

static void dump_case ( PLpgSQL_stmt_case stmt)
static

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

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

◆ dump_close()

static void dump_close ( PLpgSQL_stmt_close stmt)
static

Definition at line 1293 of file pl_funcs.c.

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

Referenced by dump_stmt().

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

◆ dump_commit()

static void dump_commit ( PLpgSQL_stmt_commit stmt)
static

Definition at line 1318 of file pl_funcs.c.

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

Referenced by dump_stmt().

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

◆ dump_cursor_direction()

static void dump_cursor_direction ( PLpgSQL_stmt_fetch stmt)
static

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

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

◆ dump_dynexecute()

static void dump_dynexecute ( PLpgSQL_stmt_dynexecute stmt)
static

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

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

◆ dump_dynfors()

static void dump_dynfors ( PLpgSQL_stmt_dynfors stmt)
static

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

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

◆ dump_execsql()

static void dump_execsql ( PLpgSQL_stmt_execsql stmt)
static

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

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

◆ dump_exit()

static void dump_exit ( PLpgSQL_stmt_exit stmt)
static

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

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

◆ dump_expr()

◆ dump_fetch()

static void dump_fetch ( PLpgSQL_stmt_fetch stmt)
static

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

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

◆ dump_forc()

static void dump_forc ( PLpgSQL_stmt_forc stmt)
static

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

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

◆ dump_foreach_a()

static void dump_foreach_a ( PLpgSQL_stmt_foreach_a stmt)
static

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

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

◆ dump_fori()

static void dump_fori ( PLpgSQL_stmt_fori stmt)
static

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

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

◆ dump_fors()

static void dump_fors ( PLpgSQL_stmt_fors stmt)
static

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

1129 {
1130  dump_ind();
1131  printf("FORS %s ", stmt->var->refname);
1132  dump_expr(stmt->query);
1133  printf("\n");
1134 
1135  dump_stmts(stmt->body);
1136 
1137  dump_ind();
1138  printf(" ENDFORS\n");
1139 }
#define printf(...)
Definition: port.h:198
PLpgSQL_variable * var
Definition: plpgsql.h:720
static void dump_ind(void)
Definition: pl_funcs.c:838
char * refname
Definition: plpgsql.h:271
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1620
PLpgSQL_expr * query
Definition: plpgsql.h:723
static void dump_stmts(List *stmts)
Definition: pl_funcs.c:943

◆ dump_getdiag()

static void dump_getdiag ( PLpgSQL_stmt_getdiag stmt)
static

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

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

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

◆ dump_ind()

◆ dump_loop()

static void dump_loop ( PLpgSQL_stmt_loop stmt)
static

Definition at line 1072 of file pl_funcs.c.

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

Referenced by dump_stmt().

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

◆ dump_open()

static void dump_open ( PLpgSQL_stmt_open stmt)
static

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

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

◆ dump_perform()

static void dump_perform ( PLpgSQL_stmt_perform stmt)
static

Definition at line 1300 of file pl_funcs.c.

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

Referenced by dump_stmt().

1301 {
1302  dump_ind();
1303  printf("PERFORM expr = ");
1304  dump_expr(stmt->expr);
1305  printf("\n");
1306 }
#define printf(...)
Definition: port.h:198
PLpgSQL_expr * expr
Definition: plpgsql.h:535
static void dump_ind(void)
Definition: pl_funcs.c:838
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1620

◆ dump_raise()

static void dump_raise ( PLpgSQL_stmt_raise stmt)
static

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

1426 {
1427  ListCell *lc;
1428  int i = 0;
1429 
1430  dump_ind();
1431  printf("RAISE level=%d", stmt->elog_level);
1432  if (stmt->condname)
1433  printf(" condname='%s'", stmt->condname);
1434  if (stmt->message)
1435  printf(" message='%s'", stmt->message);
1436  printf("\n");
1437  dump_indent += 2;
1438  foreach(lc, stmt->params)
1439  {
1440  dump_ind();
1441  printf(" parameter %d: ", i++);
1442  dump_expr((PLpgSQL_expr *) lfirst(lc));
1443  printf("\n");
1444  }
1445  if (stmt->options)
1446  {
1447  dump_ind();
1448  printf(" USING\n");
1449  dump_indent += 2;
1450  foreach(lc, stmt->options)
1451  {
1453 
1454  dump_ind();
1455  switch (opt->opt_type)
1456  {
1458  printf(" ERRCODE = ");
1459  break;
1461  printf(" MESSAGE = ");
1462  break;
1464  printf(" DETAIL = ");
1465  break;
1467  printf(" HINT = ");
1468  break;
1470  printf(" COLUMN = ");
1471  break;
1473  printf(" CONSTRAINT = ");
1474  break;
1476  printf(" DATATYPE = ");
1477  break;
1479  printf(" TABLE = ");
1480  break;
1482  printf(" SCHEMA = ");
1483  break;
1484  }
1485  dump_expr(opt->expr);
1486  printf("\n");
1487  }
1488  dump_indent -= 2;
1489  }
1490  dump_indent -= 2;
1491 }
#define printf(...)
Definition: port.h:198
PLpgSQL_raise_option_type opt_type
Definition: plpgsql.h:887
static void dump_ind(void)
Definition: pl_funcs.c:838
#define lfirst(lc)
Definition: pg_list.h:190
static int dump_indent
Definition: pl_funcs.c:801
PLpgSQL_expr * expr
Definition: plpgsql.h:888
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1620
int i

◆ dump_return()

static void dump_return ( PLpgSQL_stmt_return stmt)
static

Definition at line 1360 of file pl_funcs.c.

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

Referenced by dump_stmt().

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

◆ dump_return_next()

static void dump_return_next ( PLpgSQL_stmt_return_next stmt)
static

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

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

◆ dump_return_query()

static void dump_return_query ( PLpgSQL_stmt_return_query stmt)
static

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

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

◆ dump_rollback()

static void dump_rollback ( PLpgSQL_stmt_rollback stmt)
static

Definition at line 1328 of file pl_funcs.c.

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

Referenced by dump_stmt().

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

◆ dump_set()

static void dump_set ( PLpgSQL_stmt_set stmt)
static

Definition at line 1338 of file pl_funcs.c.

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

Referenced by dump_stmt().

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

◆ dump_stmt()

static void dump_stmt ( PLpgSQL_stmt stmt)
static

Definition at line 847 of file pl_funcs.c.

References PLpgSQL_stmt::cmd_type, PLpgSQL_stmt_set::cmd_type, dump_assert(), dump_assign(), dump_block(), dump_call(), dump_case(), dump_close(), dump_commit(), dump_dynexecute(), dump_dynfors(), dump_execsql(), dump_exit(), dump_fetch(), dump_forc(), dump_foreach_a(), dump_fori(), dump_fors(), dump_getdiag(), dump_if(), dump_loop(), dump_open(), dump_perform(), dump_raise(), dump_return(), dump_return_next(), dump_return_query(), dump_rollback(), dump_set(), dump_while(), elog, ERROR, PLpgSQL_stmt::lineno, PLPGSQL_STMT_ASSERT, PLPGSQL_STMT_ASSIGN, PLPGSQL_STMT_BLOCK, PLPGSQL_STMT_CALL, PLPGSQL_STMT_CASE, PLPGSQL_STMT_CLOSE, PLPGSQL_STMT_COMMIT, PLPGSQL_STMT_DYNEXECUTE, PLPGSQL_STMT_DYNFORS, PLPGSQL_STMT_EXECSQL, PLPGSQL_STMT_EXIT, PLPGSQL_STMT_FETCH, PLPGSQL_STMT_FORC, PLPGSQL_STMT_FOREACH_A, PLPGSQL_STMT_FORI, PLPGSQL_STMT_FORS, PLPGSQL_STMT_GETDIAG, PLPGSQL_STMT_IF, PLPGSQL_STMT_LOOP, PLPGSQL_STMT_OPEN, PLPGSQL_STMT_PERFORM, PLPGSQL_STMT_RAISE, PLPGSQL_STMT_RETURN, PLPGSQL_STMT_RETURN_NEXT, PLPGSQL_STMT_RETURN_QUERY, PLPGSQL_STMT_ROLLBACK, PLPGSQL_STMT_SET, PLPGSQL_STMT_WHILE, and printf.

Referenced by dump_stmts().

848 {
849  printf("%3d:", stmt->lineno);
850  switch (stmt->cmd_type)
851  {
852  case PLPGSQL_STMT_BLOCK:
853  dump_block((PLpgSQL_stmt_block *) stmt);
854  break;
855  case PLPGSQL_STMT_ASSIGN:
857  break;
858  case PLPGSQL_STMT_IF:
859  dump_if((PLpgSQL_stmt_if *) stmt);
860  break;
861  case PLPGSQL_STMT_CASE:
862  dump_case((PLpgSQL_stmt_case *) stmt);
863  break;
864  case PLPGSQL_STMT_LOOP:
865  dump_loop((PLpgSQL_stmt_loop *) stmt);
866  break;
867  case PLPGSQL_STMT_WHILE:
868  dump_while((PLpgSQL_stmt_while *) stmt);
869  break;
870  case PLPGSQL_STMT_FORI:
871  dump_fori((PLpgSQL_stmt_fori *) stmt);
872  break;
873  case PLPGSQL_STMT_FORS:
874  dump_fors((PLpgSQL_stmt_fors *) stmt);
875  break;
876  case PLPGSQL_STMT_FORC:
877  dump_forc((PLpgSQL_stmt_forc *) stmt);
878  break;
881  break;
882  case PLPGSQL_STMT_EXIT:
883  dump_exit((PLpgSQL_stmt_exit *) stmt);
884  break;
885  case PLPGSQL_STMT_RETURN:
887  break;
890  break;
893  break;
894  case PLPGSQL_STMT_RAISE:
895  dump_raise((PLpgSQL_stmt_raise *) stmt);
896  break;
897  case PLPGSQL_STMT_ASSERT:
899  break;
902  break;
905  break;
908  break;
911  break;
912  case PLPGSQL_STMT_OPEN:
913  dump_open((PLpgSQL_stmt_open *) stmt);
914  break;
915  case PLPGSQL_STMT_FETCH:
916  dump_fetch((PLpgSQL_stmt_fetch *) stmt);
917  break;
918  case PLPGSQL_STMT_CLOSE:
919  dump_close((PLpgSQL_stmt_close *) stmt);
920  break;
923  break;
924  case PLPGSQL_STMT_CALL:
925  dump_call((PLpgSQL_stmt_call *) stmt);
926  break;
927  case PLPGSQL_STMT_COMMIT:
929  break;
932  break;
933  case PLPGSQL_STMT_SET:
934  dump_set((PLpgSQL_stmt_set *) stmt);
935  break;
936  default:
937  elog(ERROR, "unrecognized cmd_type: %d", stmt->cmd_type);
938  break;
939  }
940 }
int lineno
Definition: plpgsql.h:460
static void dump_raise(PLpgSQL_stmt_raise *stmt)
Definition: pl_funcs.c:1425
static void dump_perform(PLpgSQL_stmt_perform *stmt)
Definition: pl_funcs.c:1300
static void dump_forc(PLpgSQL_stmt_forc *stmt)
Definition: pl_funcs.c:1142
#define printf(...)
Definition: port.h:198
static void dump_rollback(PLpgSQL_stmt_rollback *stmt)
Definition: pl_funcs.c:1328
static void dump_fors(PLpgSQL_stmt_fors *stmt)
Definition: pl_funcs.c:1128
static void dump_fetch(PLpgSQL_stmt_fetch *stmt)
Definition: pl_funcs.c:1233
#define ERROR
Definition: elog.h:43
static void dump_case(PLpgSQL_stmt_case *stmt)
Definition: pl_funcs.c:1034
static void dump_getdiag(PLpgSQL_stmt_getdiag *stmt)
Definition: pl_funcs.c:1600
static void dump_if(PLpgSQL_stmt_if *stmt)
Definition: pl_funcs.c:1004
static void dump_return_query(PLpgSQL_stmt_return_query *stmt)
Definition: pl_funcs.c:1388
static void dump_return(PLpgSQL_stmt_return *stmt)
Definition: pl_funcs.c:1360
static void dump_set(PLpgSQL_stmt_set *stmt)
Definition: pl_funcs.c:1338
static void dump_return_next(PLpgSQL_stmt_return_next *stmt)
Definition: pl_funcs.c:1374
static void dump_loop(PLpgSQL_stmt_loop *stmt)
Definition: pl_funcs.c:1072
static void dump_close(PLpgSQL_stmt_close *stmt)
Definition: pl_funcs.c:1293
static void dump_while(PLpgSQL_stmt_while *stmt)
Definition: pl_funcs.c:1084
static void dump_execsql(PLpgSQL_stmt_execsql *stmt)
Definition: pl_funcs.c:1513
static void dump_dynexecute(PLpgSQL_stmt_dynexecute *stmt)
Definition: pl_funcs.c:1532
static void dump_dynfors(PLpgSQL_stmt_dynfors *stmt)
Definition: pl_funcs.c:1569
static void dump_block(PLpgSQL_stmt_block *block)
Definition: pl_funcs.c:954
static void dump_foreach_a(PLpgSQL_stmt_foreach_a *stmt)
Definition: pl_funcs.c:1165
#define elog(elevel,...)
Definition: elog.h:226
static void dump_commit(PLpgSQL_stmt_commit *stmt)
Definition: pl_funcs.c:1318
static void dump_assert(PLpgSQL_stmt_assert *stmt)
Definition: pl_funcs.c:1494
static void dump_open(PLpgSQL_stmt_open *stmt)
Definition: pl_funcs.c:1182
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:459
static void dump_fori(PLpgSQL_stmt_fori *stmt)
Definition: pl_funcs.c:1098
static void dump_call(PLpgSQL_stmt_call *stmt)
Definition: pl_funcs.c:1309
static void dump_assign(PLpgSQL_stmt_assign *stmt)
Definition: pl_funcs.c:995
static void dump_exit(PLpgSQL_stmt_exit *stmt)
Definition: pl_funcs.c:1345

◆ dump_stmts()

static void dump_stmts ( List stmts)
static

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

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

◆ dump_while()

static void dump_while ( PLpgSQL_stmt_while stmt)
static

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

1085 {
1086  dump_ind();
1087  printf("WHILE ");
1088  dump_expr(stmt->cond);
1089  printf("\n");
1090 
1091  dump_stmts(stmt->body);
1092 
1093  dump_ind();
1094  printf(" ENDWHILE\n");
1095 }
PLpgSQL_expr * cond
Definition: plpgsql.h:675
#define printf(...)
Definition: port.h:198
static void dump_ind(void)
Definition: pl_funcs.c:838
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1620
static void dump_stmts(List *stmts)
Definition: pl_funcs.c:943

◆ free_assert()

static void free_assert ( PLpgSQL_stmt_assert stmt)
static

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

687 {
688  free_expr(stmt->cond);
689  free_expr(stmt->message);
690 }
PLpgSQL_expr * message
Definition: plpgsql.h:900
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:729
PLpgSQL_expr * cond
Definition: plpgsql.h:899

◆ free_assign()

static void free_assign ( PLpgSQL_stmt_assign stmt)
static

Definition at line 503 of file pl_funcs.c.

References PLpgSQL_stmt_assign::expr, and free_expr().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

504 {
505  free_expr(stmt->expr);
506 }
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:729
PLpgSQL_expr * expr
Definition: plpgsql.h:524

◆ free_block()

static void free_block ( PLpgSQL_stmt_block block)
static

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

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

◆ free_call()

static void free_call ( PLpgSQL_stmt_call stmt)
static

Definition at line 616 of file pl_funcs.c.

References PLpgSQL_stmt_call::expr, and free_expr().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

617 {
618  free_expr(stmt->expr);
619 }
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:729
PLpgSQL_expr * expr
Definition: plpgsql.h:546

◆ free_case()

static void free_case ( PLpgSQL_stmt_case stmt)
static

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

527 {
528  ListCell *l;
529 
530  free_expr(stmt->t_expr);
531  foreach(l, stmt->case_when_list)
532  {
534 
535  free_expr(cwt->expr);
536  free_stmts(cwt->stmts);
537  }
538  free_stmts(stmt->else_stmts);
539 }
List * else_stmts
Definition: plpgsql.h:641
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:729
PLpgSQL_expr * expr
Definition: plpgsql.h:650
List * case_when_list
Definition: plpgsql.h:639
static void free_stmts(List *stmts)
Definition: pl_funcs.c:475
#define lfirst(lc)
Definition: pg_list.h:190
PLpgSQL_expr * t_expr
Definition: plpgsql.h:637

◆ free_close()

static void free_close ( PLpgSQL_stmt_close stmt)
static

Definition at line 605 of file pl_funcs.c.

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

606 {
607 }

◆ free_commit()

static void free_commit ( PLpgSQL_stmt_commit stmt)
static

Definition at line 622 of file pl_funcs.c.

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

623 {
624 }

◆ free_dynexecute()

static void free_dynexecute ( PLpgSQL_stmt_dynexecute stmt)
static

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

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

◆ free_dynfors()

static void free_dynfors ( PLpgSQL_stmt_dynfors stmt)
static

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

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

◆ free_execsql()

static void free_execsql ( PLpgSQL_stmt_execsql stmt)
static

Definition at line 693 of file pl_funcs.c.

References free_expr(), and PLpgSQL_stmt_execsql::sqlstmt.

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

694 {
695  free_expr(stmt->sqlstmt);
696 }
PLpgSQL_expr * sqlstmt
Definition: plpgsql.h:911
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:729

◆ free_exit()

static void free_exit ( PLpgSQL_stmt_exit stmt)
static

Definition at line 638 of file pl_funcs.c.

References PLpgSQL_stmt_exit::cond, and free_expr().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

639 {
640  free_expr(stmt->cond);
641 }
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:729
PLpgSQL_expr * cond
Definition: plpgsql.h:827

◆ free_expr()

static void free_expr ( PLpgSQL_expr expr)
static

◆ free_fetch()

static void free_fetch ( PLpgSQL_stmt_fetch stmt)
static

Definition at line 599 of file pl_funcs.c.

References PLpgSQL_stmt_fetch::expr, and free_expr().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

600 {
601  free_expr(stmt->expr);
602 }
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:729
PLpgSQL_expr * expr
Definition: plpgsql.h:801

◆ free_forc()

static void free_forc ( PLpgSQL_stmt_forc stmt)
static

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

572 {
573  free_stmts(stmt->body);
574  free_expr(stmt->argquery);
575 }
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:729
static void free_stmts(List *stmts)
Definition: pl_funcs.c:475
PLpgSQL_expr * argquery
Definition: plpgsql.h:739

◆ free_foreach_a()

static void free_foreach_a ( PLpgSQL_stmt_foreach_a stmt)
static

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

579 {
580  free_expr(stmt->expr);
581  free_stmts(stmt->body);
582 }
PLpgSQL_expr * expr
Definition: plpgsql.h:769
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:729
static void free_stmts(List *stmts)
Definition: pl_funcs.c:475

◆ free_fori()

static void free_fori ( PLpgSQL_stmt_fori stmt)
static

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

556 {
557  free_expr(stmt->lower);
558  free_expr(stmt->upper);
559  free_expr(stmt->step);
560  free_stmts(stmt->body);
561 }
PLpgSQL_expr * lower
Definition: plpgsql.h:689
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:729
static void free_stmts(List *stmts)
Definition: pl_funcs.c:475
PLpgSQL_expr * step
Definition: plpgsql.h:691
PLpgSQL_expr * upper
Definition: plpgsql.h:690

◆ free_fors()

static void free_fors ( PLpgSQL_stmt_fors stmt)
static

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

565 {
566  free_stmts(stmt->body);
567  free_expr(stmt->query);
568 }
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:729
static void free_stmts(List *stmts)
Definition: pl_funcs.c:475
PLpgSQL_expr * query
Definition: plpgsql.h:723

◆ free_getdiag()

static void free_getdiag ( PLpgSQL_stmt_getdiag stmt)
static

Definition at line 724 of file pl_funcs.c.

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

725 {
726 }

◆ free_if()

static void free_if ( PLpgSQL_stmt_if stmt)
static

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

510 {
511  ListCell *l;
512 
513  free_expr(stmt->cond);
514  free_stmts(stmt->then_body);
515  foreach(l, stmt->elsif_list)
516  {
518 
519  free_expr(elif->cond);
520  free_stmts(elif->stmts);
521  }
522  free_stmts(stmt->else_body);
523 }
PLpgSQL_expr * cond
Definition: plpgsql.h:613
List * then_body
Definition: plpgsql.h:614
List * elsif_list
Definition: plpgsql.h:615
List * stmts
Definition: plpgsql.h:626
PLpgSQL_expr * cond
Definition: plpgsql.h:625
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:729
static void free_stmts(List *stmts)
Definition: pl_funcs.c:475
#define lfirst(lc)
Definition: pg_list.h:190
List * else_body
Definition: plpgsql.h:616

◆ free_loop()

static void free_loop ( PLpgSQL_stmt_loop stmt)
static

Definition at line 542 of file pl_funcs.c.

References PLpgSQL_stmt_loop::body, and free_stmts().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

543 {
544  free_stmts(stmt->body);
545 }
static void free_stmts(List *stmts)
Definition: pl_funcs.c:475

◆ free_open()

static void free_open ( PLpgSQL_stmt_open stmt)
static

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

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

◆ free_perform()

static void free_perform ( PLpgSQL_stmt_perform stmt)
static

Definition at line 610 of file pl_funcs.c.

References PLpgSQL_stmt_perform::expr, and free_expr().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

611 {
612  free_expr(stmt->expr);
613 }
PLpgSQL_expr * expr
Definition: plpgsql.h:535
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:729

◆ free_raise()

static void free_raise ( PLpgSQL_stmt_raise stmt)
static

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

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

◆ free_return()

static void free_return ( PLpgSQL_stmt_return stmt)
static

Definition at line 644 of file pl_funcs.c.

References PLpgSQL_stmt_return::expr, and free_expr().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

645 {
646  free_expr(stmt->expr);
647 }
PLpgSQL_expr * expr
Definition: plpgsql.h:838
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:729

◆ free_return_next()

static void free_return_next ( PLpgSQL_stmt_return_next stmt)
static

Definition at line 650 of file pl_funcs.c.

References PLpgSQL_stmt_return_next::expr, and free_expr().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

651 {
652  free_expr(stmt->expr);
653 }
PLpgSQL_expr * expr
Definition: plpgsql.h:850
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:729

◆ free_return_query()

static void free_return_query ( PLpgSQL_stmt_return_query stmt)
static

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

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

◆ free_rollback()

static void free_rollback ( PLpgSQL_stmt_rollback stmt)
static

Definition at line 627 of file pl_funcs.c.

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

628 {
629 }

◆ free_set()

static void free_set ( PLpgSQL_stmt_set stmt)
static

Definition at line 632 of file pl_funcs.c.

References PLpgSQL_stmt_set::expr, and free_expr().

Referenced by free_stmt(), and plpgsql_getdiag_kindname().

633 {
634  free_expr(stmt->expr);
635 }
PLpgSQL_expr * expr
Definition: plpgsql.h:581
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:729

◆ free_stmt()

static void free_stmt ( PLpgSQL_stmt stmt)
static

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

381 {
382  switch (stmt->cmd_type)
383  {
384  case PLPGSQL_STMT_BLOCK:
385  free_block((PLpgSQL_stmt_block *) stmt);
386  break;
387  case PLPGSQL_STMT_ASSIGN:
389  break;
390  case PLPGSQL_STMT_IF:
391  free_if((PLpgSQL_stmt_if *) stmt);
392  break;
393  case PLPGSQL_STMT_CASE:
394  free_case((PLpgSQL_stmt_case *) stmt);
395  break;
396  case PLPGSQL_STMT_LOOP:
397  free_loop((PLpgSQL_stmt_loop *) stmt);
398  break;
399  case PLPGSQL_STMT_WHILE:
400  free_while((PLpgSQL_stmt_while *) stmt);
401  break;
402  case PLPGSQL_STMT_FORI:
403  free_fori((PLpgSQL_stmt_fori *) stmt);
404  break;
405  case PLPGSQL_STMT_FORS:
406  free_fors((PLpgSQL_stmt_fors *) stmt);
407  break;
408  case PLPGSQL_STMT_FORC:
409  free_forc((PLpgSQL_stmt_forc *) stmt);
410  break;
413  break;
414  case PLPGSQL_STMT_EXIT:
415  free_exit((PLpgSQL_stmt_exit *) stmt);
416  break;
417  case PLPGSQL_STMT_RETURN:
419  break;
422  break;
425  break;
426  case PLPGSQL_STMT_RAISE:
427  free_raise((PLpgSQL_stmt_raise *) stmt);
428  break;
429  case PLPGSQL_STMT_ASSERT:
431  break;
434  break;
437  break;
440  break;
443  break;
444  case PLPGSQL_STMT_OPEN:
445  free_open((PLpgSQL_stmt_open *) stmt);
446  break;
447  case PLPGSQL_STMT_FETCH:
448  free_fetch((PLpgSQL_stmt_fetch *) stmt);
449  break;
450  case PLPGSQL_STMT_CLOSE:
451  free_close((PLpgSQL_stmt_close *) stmt);
452  break;
455  break;
456  case PLPGSQL_STMT_CALL:
457  free_call((PLpgSQL_stmt_call *) stmt);
458  break;
459  case PLPGSQL_STMT_COMMIT:
461  break;
464  break;
465  case PLPGSQL_STMT_SET:
466  free_set((PLpgSQL_stmt_set *) stmt);
467  break;
468  default:
469  elog(ERROR, "unrecognized cmd_type: %d", stmt->cmd_type);
470  break;
471  }
472 }
static void free_assert(PLpgSQL_stmt_assert *stmt)
Definition: pl_funcs.c:686
static void free_dynexecute(PLpgSQL_stmt_dynexecute *stmt)
Definition: pl_funcs.c:699
static void free_raise(PLpgSQL_stmt_raise *stmt)
Definition: pl_funcs.c:669
static void free_open(PLpgSQL_stmt_open *stmt)
Definition: pl_funcs.c:585
static void free_return(PLpgSQL_stmt_return *stmt)
Definition: pl_funcs.c:644
static void free_loop(PLpgSQL_stmt_loop *stmt)
Definition: pl_funcs.c:542
static void free_dynfors(PLpgSQL_stmt_dynfors *stmt)
Definition: pl_funcs.c:711
static void free_set(PLpgSQL_stmt_set *stmt)
Definition: pl_funcs.c:632
static void free_rollback(PLpgSQL_stmt_rollback *stmt)
Definition: pl_funcs.c:627
static void free_assign(PLpgSQL_stmt_assign *stmt)
Definition: pl_funcs.c:503
static void free_getdiag(PLpgSQL_stmt_getdiag *stmt)
Definition: pl_funcs.c:724
#define ERROR
Definition: elog.h:43
static void free_fetch(PLpgSQL_stmt_fetch *stmt)
Definition: pl_funcs.c:599
static void free_close(PLpgSQL_stmt_close *stmt)
Definition: pl_funcs.c:605
static void free_case(PLpgSQL_stmt_case *stmt)
Definition: pl_funcs.c:526
static void free_fori(PLpgSQL_stmt_fori *stmt)
Definition: pl_funcs.c:555
static void free_perform(PLpgSQL_stmt_perform *stmt)
Definition: pl_funcs.c:610
static void free_return_next(PLpgSQL_stmt_return_next *stmt)
Definition: pl_funcs.c:650
static void free_call(PLpgSQL_stmt_call *stmt)
Definition: pl_funcs.c:616
static void free_fors(PLpgSQL_stmt_fors *stmt)
Definition: pl_funcs.c:564
static void free_exit(PLpgSQL_stmt_exit *stmt)
Definition: pl_funcs.c:638
static void free_if(PLpgSQL_stmt_if *stmt)
Definition: pl_funcs.c:509
static void free_return_query(PLpgSQL_stmt_return_query *stmt)
Definition: pl_funcs.c:656
static void free_execsql(PLpgSQL_stmt_execsql *stmt)
Definition: pl_funcs.c:693
static void free_forc(PLpgSQL_stmt_forc *stmt)
Definition: pl_funcs.c:571
#define elog(elevel,...)
Definition: elog.h:226
static void free_commit(PLpgSQL_stmt_commit *stmt)
Definition: pl_funcs.c:622
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:459
static void free_while(PLpgSQL_stmt_while *stmt)
Definition: pl_funcs.c:548
static void free_foreach_a(PLpgSQL_stmt_foreach_a *stmt)
Definition: pl_funcs.c:578
static void free_block(PLpgSQL_stmt_block *block)
Definition: pl_funcs.c:486

◆ free_stmts()

static void free_stmts ( List stmts)
static

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

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

◆ free_while()

static void free_while ( PLpgSQL_stmt_while stmt)
static

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

549 {
550  free_expr(stmt->cond);
551  free_stmts(stmt->body);
552 }
PLpgSQL_expr * cond
Definition: plpgsql.h:675
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:729
static void free_stmts(List *stmts)
Definition: pl_funcs.c:475

◆ plpgsql_dumptree()

void plpgsql_dumptree ( PLpgSQL_function func)

Definition at line 1626 of file pl_funcs.c.

References PLpgSQL_function::action, PLpgSQL_type::atttypmod, PLpgSQL_var::cursor_explicit_argrow, PLpgSQL_var::cursor_explicit_expr, PLpgSQL_var::datatype, PLpgSQL_function::datums, PLpgSQL_var::default_val, PLpgSQL_datum::dtype, PLpgSQL_arrayelem::dtype, dump_block(), dump_expr(), dump_indent, PLpgSQL_row::fieldnames, PLpgSQL_function::fn_signature, i, PLpgSQL_var::isconst, PLpgSQL_stmt_block::lineno, PLpgSQL_function::ndatums, PLpgSQL_row::nfields, PLpgSQL_var::notnull, PLPGSQL_DTYPE_ARRAYELEM, PLPGSQL_DTYPE_PROMISE, PLPGSQL_DTYPE_REC, PLPGSQL_DTYPE_RECFIELD, PLPGSQL_DTYPE_ROW, PLPGSQL_DTYPE_VAR, PLPGSQL_PROMISE_NONE, printf, PLpgSQL_var::promise, PLpgSQL_var::refname, PLpgSQL_row::refname, generate_unaccent_rules::stdout, PLpgSQL_type::typname, PLpgSQL_type::typoid, and PLpgSQL_row::varnos.

Referenced by do_compile().

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

◆ plpgsql_free_function_memory()

void plpgsql_free_function_memory ( PLpgSQL_function func)

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

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

◆ 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_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 "PG_CONTEXT";
313  return "PG_EXCEPTION_CONTEXT";
315  return "PG_EXCEPTION_DETAIL";
317  return "PG_EXCEPTION_HINT";
319  return "RETURNED_SQLSTATE";
321  return "COLUMN_NAME";
323  return "CONSTRAINT_NAME";
325  return "PG_DATATYPE_NAME";
327  return "MESSAGE_TEXT";
329  return "TABLE_NAME";
331  return "SCHEMA_NAME";
332  }
333 
334  return "unknown";
335 }

◆ 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:450
#define Assert(condition)
Definition: c.h:732
const char * name
Definition: encode.c:521
void * palloc(Size size)
Definition: mcxt.c:949
PLpgSQL_nsitem_type itemtype
Definition: plpgsql.h:443
char name[FLEXIBLE_ARRAY_MEMBER]
Definition: plpgsql.h:451
#define offsetof(type, field)
Definition: c.h:655

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

◆ 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:450
PLpgSQL_nsitem_type itemtype
Definition: plpgsql.h:443
char name[FLEXIBLE_ARRAY_MEMBER]
Definition: plpgsql.h:451

◆ 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:450
const char * name
Definition: encode.c:521
PLpgSQL_nsitem_type itemtype
Definition: plpgsql.h:443
char name[FLEXIBLE_ARRAY_MEMBER]
Definition: plpgsql.h:451

◆ 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:450
#define Assert(condition)
Definition: c.h:732
PLpgSQL_nsitem_type itemtype
Definition: plpgsql.h:443

◆ 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:86

◆ 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:459
#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().