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 1468 of file pl_funcs.c.

1469 {
1470  dump_ind();
1471  printf("ASSERT ");
1472  dump_expr(stmt->cond);
1473  printf("\n");
1474 
1475  dump_indent += 2;
1476  if (stmt->message != NULL)
1477  {
1478  dump_ind();
1479  printf(" MESSAGE = ");
1480  dump_expr(stmt->message);
1481  printf("\n");
1482  }
1483  dump_indent -= 2;
1484 }
#define stmt
Definition: indent_codes.h:59
static int dump_indent
Definition: pl_funcs.c:786
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1594
static void dump_ind(void)
Definition: pl_funcs.c:822
#define printf(...)
Definition: port.h:244

References dump_expr(), dump_ind(), dump_indent, printf, and stmt.

Referenced by dump_stmt().

◆ dump_assign()

static void dump_assign ( PLpgSQL_stmt_assign stmt)
static

Definition at line 976 of file pl_funcs.c.

977 {
978  dump_ind();
979  printf("ASSIGN var %d := ", stmt->varno);
980  dump_expr(stmt->expr);
981  printf("\n");
982 }

References dump_expr(), dump_ind(), printf, and stmt.

Referenced by dump_stmt().

◆ dump_block()

static void dump_block ( PLpgSQL_stmt_block block)
static

Definition at line 935 of file pl_funcs.c.

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

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

◆ dump_call()

static void dump_call ( PLpgSQL_stmt_call stmt)
static

Definition at line 1290 of file pl_funcs.c.

1291 {
1292  dump_ind();
1293  printf("%s expr = ", stmt->is_call ? "CALL" : "DO");
1294  dump_expr(stmt->expr);
1295  printf("\n");
1296 }

References dump_expr(), dump_ind(), printf, and stmt.

Referenced by dump_stmt().

◆ dump_case()

static void dump_case ( PLpgSQL_stmt_case stmt)
static

Definition at line 1015 of file pl_funcs.c.

1016 {
1017  ListCell *l;
1018 
1019  dump_ind();
1020  printf("CASE %d ", stmt->t_varno);
1021  if (stmt->t_expr)
1022  dump_expr(stmt->t_expr);
1023  printf("\n");
1024  dump_indent += 6;
1025  foreach(l, stmt->case_when_list)
1026  {
1028 
1029  dump_ind();
1030  printf("WHEN ");
1031  dump_expr(cwt->expr);
1032  printf("\n");
1033  dump_ind();
1034  printf("THEN\n");
1035  dump_indent += 2;
1036  dump_stmts(cwt->stmts);
1037  dump_indent -= 2;
1038  }
1039  if (stmt->have_else)
1040  {
1041  dump_ind();
1042  printf("ELSE\n");
1043  dump_indent += 2;
1044  dump_stmts(stmt->else_stmts);
1045  dump_indent -= 2;
1046  }
1047  dump_indent -= 6;
1048  dump_ind();
1049  printf(" ENDCASE\n");
1050 }
PLpgSQL_expr * expr
Definition: plpgsql.h:635

References dump_expr(), dump_ind(), dump_indent, dump_stmts(), PLpgSQL_case_when::expr, lfirst, printf, stmt, and PLpgSQL_case_when::stmts.

Referenced by dump_stmt().

◆ dump_close()

static void dump_close ( PLpgSQL_stmt_close stmt)
static

Definition at line 1274 of file pl_funcs.c.

1275 {
1276  dump_ind();
1277  printf("CLOSE curvar=%d\n", stmt->curvar);
1278 }

References dump_ind(), printf, and stmt.

Referenced by dump_stmt().

◆ dump_commit()

static void dump_commit ( PLpgSQL_stmt_commit stmt)
static

Definition at line 1299 of file pl_funcs.c.

1300 {
1301  dump_ind();
1302  if (stmt->chain)
1303  printf("COMMIT AND CHAIN\n");
1304  else
1305  printf("COMMIT\n");
1306 }

References dump_ind(), printf, and stmt.

Referenced by dump_stmt().

◆ dump_cursor_direction()

static void dump_cursor_direction ( PLpgSQL_stmt_fetch stmt)
static

Definition at line 1240 of file pl_funcs.c.

1241 {
1242  dump_indent += 2;
1243  dump_ind();
1244  switch (stmt->direction)
1245  {
1246  case FETCH_FORWARD:
1247  printf(" FORWARD ");
1248  break;
1249  case FETCH_BACKWARD:
1250  printf(" BACKWARD ");
1251  break;
1252  case FETCH_ABSOLUTE:
1253  printf(" ABSOLUTE ");
1254  break;
1255  case FETCH_RELATIVE:
1256  printf(" RELATIVE ");
1257  break;
1258  default:
1259  printf("??? unknown cursor direction %d", stmt->direction);
1260  }
1261 
1262  if (stmt->expr)
1263  {
1264  dump_expr(stmt->expr);
1265  printf("\n");
1266  }
1267  else
1268  printf("%ld\n", stmt->how_many);
1269 
1270  dump_indent -= 2;
1271 }
@ FETCH_RELATIVE
Definition: parsenodes.h:3155
@ FETCH_ABSOLUTE
Definition: parsenodes.h:3154
@ FETCH_FORWARD
Definition: parsenodes.h:3151
@ FETCH_BACKWARD
Definition: parsenodes.h:3152

References dump_expr(), dump_ind(), dump_indent, FETCH_ABSOLUTE, FETCH_BACKWARD, FETCH_FORWARD, FETCH_RELATIVE, printf, and stmt.

Referenced by dump_fetch().

◆ dump_dynexecute()

static void dump_dynexecute ( PLpgSQL_stmt_dynexecute stmt)
static

Definition at line 1506 of file pl_funcs.c.

1507 {
1508  dump_ind();
1509  printf("EXECUTE ");
1510  dump_expr(stmt->query);
1511  printf("\n");
1512 
1513  dump_indent += 2;
1514  if (stmt->target != NULL)
1515  {
1516  dump_ind();
1517  printf(" INTO%s target = %d %s\n",
1518  stmt->strict ? " STRICT" : "",
1519  stmt->target->dno, stmt->target->refname);
1520  }
1521  if (stmt->params != NIL)
1522  {
1523  ListCell *lc;
1524  int i;
1525 
1526  dump_ind();
1527  printf(" USING\n");
1528  dump_indent += 2;
1529  i = 1;
1530  foreach(lc, stmt->params)
1531  {
1532  dump_ind();
1533  printf(" parameter %d: ", i++);
1534  dump_expr((PLpgSQL_expr *) lfirst(lc));
1535  printf("\n");
1536  }
1537  dump_indent -= 2;
1538  }
1539  dump_indent -= 2;
1540 }
int i
Definition: isn.c:73
#define NIL
Definition: pg_list.h:68

References dump_expr(), dump_ind(), dump_indent, i, lfirst, NIL, printf, and stmt.

Referenced by dump_stmt().

◆ dump_dynfors()

static void dump_dynfors ( PLpgSQL_stmt_dynfors stmt)
static

Definition at line 1543 of file pl_funcs.c.

1544 {
1545  dump_ind();
1546  printf("FORS %s EXECUTE ", stmt->var->refname);
1547  dump_expr(stmt->query);
1548  printf("\n");
1549  if (stmt->params != NIL)
1550  {
1551  ListCell *lc;
1552  int i;
1553 
1554  dump_indent += 2;
1555  dump_ind();
1556  printf(" USING\n");
1557  dump_indent += 2;
1558  i = 1;
1559  foreach(lc, stmt->params)
1560  {
1561  dump_ind();
1562  printf(" parameter $%d: ", i++);
1563  dump_expr((PLpgSQL_expr *) lfirst(lc));
1564  printf("\n");
1565  }
1566  dump_indent -= 4;
1567  }
1568  dump_stmts(stmt->body);
1569  dump_ind();
1570  printf(" ENDFORS\n");
1571 }

References dump_expr(), dump_ind(), dump_indent, dump_stmts(), i, lfirst, NIL, printf, and stmt.

Referenced by dump_stmt().

◆ dump_execsql()

static void dump_execsql ( PLpgSQL_stmt_execsql stmt)
static

Definition at line 1487 of file pl_funcs.c.

1488 {
1489  dump_ind();
1490  printf("EXECSQL ");
1491  dump_expr(stmt->sqlstmt);
1492  printf("\n");
1493 
1494  dump_indent += 2;
1495  if (stmt->target != NULL)
1496  {
1497  dump_ind();
1498  printf(" INTO%s target = %d %s\n",
1499  stmt->strict ? " STRICT" : "",
1500  stmt->target->dno, stmt->target->refname);
1501  }
1502  dump_indent -= 2;
1503 }

References dump_expr(), dump_ind(), dump_indent, printf, and stmt.

Referenced by dump_stmt().

◆ dump_exit()

static void dump_exit ( PLpgSQL_stmt_exit stmt)
static

Definition at line 1319 of file pl_funcs.c.

1320 {
1321  dump_ind();
1322  printf("%s", stmt->is_exit ? "EXIT" : "CONTINUE");
1323  if (stmt->label != NULL)
1324  printf(" label='%s'", stmt->label);
1325  if (stmt->cond != NULL)
1326  {
1327  printf(" WHEN ");
1328  dump_expr(stmt->cond);
1329  }
1330  printf("\n");
1331 }

References dump_expr(), dump_ind(), printf, and stmt.

Referenced by dump_stmt().

◆ dump_expr()

◆ dump_fetch()

static void dump_fetch ( PLpgSQL_stmt_fetch stmt)
static

Definition at line 1214 of file pl_funcs.c.

1215 {
1216  dump_ind();
1217 
1218  if (!stmt->is_move)
1219  {
1220  printf("FETCH curvar=%d\n", stmt->curvar);
1222 
1223  dump_indent += 2;
1224  if (stmt->target != NULL)
1225  {
1226  dump_ind();
1227  printf(" target = %d %s\n",
1228  stmt->target->dno, stmt->target->refname);
1229  }
1230  dump_indent -= 2;
1231  }
1232  else
1233  {
1234  printf("MOVE curvar=%d\n", stmt->curvar);
1236  }
1237 }
static void dump_cursor_direction(PLpgSQL_stmt_fetch *stmt)
Definition: pl_funcs.c:1240

References dump_cursor_direction(), dump_ind(), dump_indent, printf, and stmt.

Referenced by dump_stmt().

◆ dump_forc()

static void dump_forc ( PLpgSQL_stmt_forc stmt)
static

Definition at line 1123 of file pl_funcs.c.

1124 {
1125  dump_ind();
1126  printf("FORC %s ", stmt->var->refname);
1127  printf("curvar=%d\n", stmt->curvar);
1128 
1129  dump_indent += 2;
1130  if (stmt->argquery != NULL)
1131  {
1132  dump_ind();
1133  printf(" arguments = ");
1134  dump_expr(stmt->argquery);
1135  printf("\n");
1136  }
1137  dump_indent -= 2;
1138 
1139  dump_stmts(stmt->body);
1140 
1141  dump_ind();
1142  printf(" ENDFORC\n");
1143 }

References dump_expr(), dump_ind(), dump_indent, dump_stmts(), printf, and stmt.

Referenced by dump_stmt().

◆ dump_foreach_a()

static void dump_foreach_a ( PLpgSQL_stmt_foreach_a stmt)
static

Definition at line 1146 of file pl_funcs.c.

1147 {
1148  dump_ind();
1149  printf("FOREACHA var %d ", stmt->varno);
1150  if (stmt->slice != 0)
1151  printf("SLICE %d ", stmt->slice);
1152  printf("IN ");
1153  dump_expr(stmt->expr);
1154  printf("\n");
1155 
1156  dump_stmts(stmt->body);
1157 
1158  dump_ind();
1159  printf(" ENDFOREACHA");
1160 }

References dump_expr(), dump_ind(), dump_stmts(), printf, and stmt.

Referenced by dump_stmt().

◆ dump_fori()

static void dump_fori ( PLpgSQL_stmt_fori stmt)
static

Definition at line 1079 of file pl_funcs.c.

1080 {
1081  dump_ind();
1082  printf("FORI %s %s\n", stmt->var->refname, (stmt->reverse) ? "REVERSE" : "NORMAL");
1083 
1084  dump_indent += 2;
1085  dump_ind();
1086  printf(" lower = ");
1087  dump_expr(stmt->lower);
1088  printf("\n");
1089  dump_ind();
1090  printf(" upper = ");
1091  dump_expr(stmt->upper);
1092  printf("\n");
1093  if (stmt->step)
1094  {
1095  dump_ind();
1096  printf(" step = ");
1097  dump_expr(stmt->step);
1098  printf("\n");
1099  }
1100  dump_indent -= 2;
1101 
1102  dump_stmts(stmt->body);
1103 
1104  dump_ind();
1105  printf(" ENDFORI\n");
1106 }

References dump_expr(), dump_ind(), dump_indent, dump_stmts(), printf, and stmt.

Referenced by dump_stmt().

◆ dump_fors()

static void dump_fors ( PLpgSQL_stmt_fors stmt)
static

Definition at line 1109 of file pl_funcs.c.

1110 {
1111  dump_ind();
1112  printf("FORS %s ", stmt->var->refname);
1113  dump_expr(stmt->query);
1114  printf("\n");
1115 
1116  dump_stmts(stmt->body);
1117 
1118  dump_ind();
1119  printf(" ENDFORS\n");
1120 }

References dump_expr(), dump_ind(), dump_stmts(), printf, and stmt.

Referenced by dump_stmt().

◆ dump_getdiag()

static void dump_getdiag ( PLpgSQL_stmt_getdiag stmt)
static

Definition at line 1574 of file pl_funcs.c.

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

References dump_ind(), PLpgSQL_diag_item::kind, lfirst, list_head(), plpgsql_getdiag_kindname(), printf, stmt, and PLpgSQL_diag_item::target.

Referenced by dump_stmt().

◆ dump_if()

static void dump_if ( PLpgSQL_stmt_if stmt)
static

Definition at line 985 of file pl_funcs.c.

986 {
987  ListCell *l;
988 
989  dump_ind();
990  printf("IF ");
991  dump_expr(stmt->cond);
992  printf(" THEN\n");
993  dump_stmts(stmt->then_body);
994  foreach(l, stmt->elsif_list)
995  {
997 
998  dump_ind();
999  printf(" ELSIF ");
1000  dump_expr(elif->cond);
1001  printf(" THEN\n");
1002  dump_stmts(elif->stmts);
1003  }
1004  if (stmt->else_body != NIL)
1005  {
1006  dump_ind();
1007  printf(" ELSE\n");
1008  dump_stmts(stmt->else_body);
1009  }
1010  dump_ind();
1011  printf(" ENDIF\n");
1012 }
PLpgSQL_expr * cond
Definition: plpgsql.h:610
List * stmts
Definition: plpgsql.h:611

References PLpgSQL_if_elsif::cond, dump_expr(), dump_ind(), dump_stmts(), lfirst, NIL, printf, stmt, and PLpgSQL_if_elsif::stmts.

Referenced by dump_stmt().

◆ dump_ind()

◆ dump_loop()

static void dump_loop ( PLpgSQL_stmt_loop stmt)
static

Definition at line 1053 of file pl_funcs.c.

1054 {
1055  dump_ind();
1056  printf("LOOP\n");
1057 
1058  dump_stmts(stmt->body);
1059 
1060  dump_ind();
1061  printf(" ENDLOOP\n");
1062 }

References dump_ind(), dump_stmts(), printf, and stmt.

Referenced by dump_stmt().

◆ dump_open()

static void dump_open ( PLpgSQL_stmt_open stmt)
static

Definition at line 1163 of file pl_funcs.c.

1164 {
1165  dump_ind();
1166  printf("OPEN curvar=%d\n", stmt->curvar);
1167 
1168  dump_indent += 2;
1169  if (stmt->argquery != NULL)
1170  {
1171  dump_ind();
1172  printf(" arguments = '");
1173  dump_expr(stmt->argquery);
1174  printf("'\n");
1175  }
1176  if (stmt->query != NULL)
1177  {
1178  dump_ind();
1179  printf(" query = '");
1180  dump_expr(stmt->query);
1181  printf("'\n");
1182  }
1183  if (stmt->dynquery != NULL)
1184  {
1185  dump_ind();
1186  printf(" execute = '");
1187  dump_expr(stmt->dynquery);
1188  printf("'\n");
1189 
1190  if (stmt->params != NIL)
1191  {
1192  ListCell *lc;
1193  int i;
1194 
1195  dump_indent += 2;
1196  dump_ind();
1197  printf(" USING\n");
1198  dump_indent += 2;
1199  i = 1;
1200  foreach(lc, stmt->params)
1201  {
1202  dump_ind();
1203  printf(" parameter $%d: ", i++);
1204  dump_expr((PLpgSQL_expr *) lfirst(lc));
1205  printf("\n");
1206  }
1207  dump_indent -= 4;
1208  }
1209  }
1210  dump_indent -= 2;
1211 }

References dump_expr(), dump_ind(), dump_indent, i, lfirst, NIL, printf, and stmt.

Referenced by dump_stmt().

◆ dump_perform()

static void dump_perform ( PLpgSQL_stmt_perform stmt)
static

Definition at line 1281 of file pl_funcs.c.

1282 {
1283  dump_ind();
1284  printf("PERFORM expr = ");
1285  dump_expr(stmt->expr);
1286  printf("\n");
1287 }

References dump_expr(), dump_ind(), printf, and stmt.

Referenced by dump_stmt().

◆ dump_raise()

static void dump_raise ( PLpgSQL_stmt_raise stmt)
static

Definition at line 1399 of file pl_funcs.c.

1400 {
1401  ListCell *lc;
1402  int i = 0;
1403 
1404  dump_ind();
1405  printf("RAISE level=%d", stmt->elog_level);
1406  if (stmt->condname)
1407  printf(" condname='%s'", stmt->condname);
1408  if (stmt->message)
1409  printf(" message='%s'", stmt->message);
1410  printf("\n");
1411  dump_indent += 2;
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  if (stmt->options)
1420  {
1421  dump_ind();
1422  printf(" USING\n");
1423  dump_indent += 2;
1424  foreach(lc, stmt->options)
1425  {
1427 
1428  dump_ind();
1429  switch (opt->opt_type)
1430  {
1432  printf(" ERRCODE = ");
1433  break;
1435  printf(" MESSAGE = ");
1436  break;
1438  printf(" DETAIL = ");
1439  break;
1441  printf(" HINT = ");
1442  break;
1444  printf(" COLUMN = ");
1445  break;
1447  printf(" CONSTRAINT = ");
1448  break;
1450  printf(" DATATYPE = ");
1451  break;
1453  printf(" TABLE = ");
1454  break;
1456  printf(" SCHEMA = ");
1457  break;
1458  }
1459  dump_expr(opt->expr);
1460  printf("\n");
1461  }
1462  dump_indent -= 2;
1463  }
1464  dump_indent -= 2;
1465 }
@ PLPGSQL_RAISEOPTION_COLUMN
Definition: plpgsql.h:173
@ PLPGSQL_RAISEOPTION_TABLE
Definition: plpgsql.h:176
@ PLPGSQL_RAISEOPTION_SCHEMA
Definition: plpgsql.h:177
@ PLPGSQL_RAISEOPTION_CONSTRAINT
Definition: plpgsql.h:174
@ PLPGSQL_RAISEOPTION_DETAIL
Definition: plpgsql.h:171
@ PLPGSQL_RAISEOPTION_MESSAGE
Definition: plpgsql.h:170
@ PLPGSQL_RAISEOPTION_HINT
Definition: plpgsql.h:172
@ PLPGSQL_RAISEOPTION_ERRCODE
Definition: plpgsql.h:169
@ PLPGSQL_RAISEOPTION_DATATYPE
Definition: plpgsql.h:175
PLpgSQL_raise_option_type opt_type
Definition: plpgsql.h:872
PLpgSQL_expr * expr
Definition: plpgsql.h:873

References dump_expr(), dump_ind(), dump_indent, PLpgSQL_raise_option::expr, i, lfirst, PLpgSQL_raise_option::opt_type, 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, printf, and stmt.

Referenced by dump_stmt().

◆ dump_return()

static void dump_return ( PLpgSQL_stmt_return stmt)
static

Definition at line 1334 of file pl_funcs.c.

1335 {
1336  dump_ind();
1337  printf("RETURN ");
1338  if (stmt->retvarno >= 0)
1339  printf("variable %d", stmt->retvarno);
1340  else if (stmt->expr != NULL)
1341  dump_expr(stmt->expr);
1342  else
1343  printf("NULL");
1344  printf("\n");
1345 }

References dump_expr(), dump_ind(), printf, and stmt.

Referenced by dump_stmt().

◆ dump_return_next()

static void dump_return_next ( PLpgSQL_stmt_return_next stmt)
static

Definition at line 1348 of file pl_funcs.c.

1349 {
1350  dump_ind();
1351  printf("RETURN NEXT ");
1352  if (stmt->retvarno >= 0)
1353  printf("variable %d", stmt->retvarno);
1354  else if (stmt->expr != NULL)
1355  dump_expr(stmt->expr);
1356  else
1357  printf("NULL");
1358  printf("\n");
1359 }

References dump_expr(), dump_ind(), printf, and stmt.

Referenced by dump_stmt().

◆ dump_return_query()

static void dump_return_query ( PLpgSQL_stmt_return_query stmt)
static

Definition at line 1362 of file pl_funcs.c.

1363 {
1364  dump_ind();
1365  if (stmt->query)
1366  {
1367  printf("RETURN QUERY ");
1368  dump_expr(stmt->query);
1369  printf("\n");
1370  }
1371  else
1372  {
1373  printf("RETURN QUERY EXECUTE ");
1374  dump_expr(stmt->dynquery);
1375  printf("\n");
1376  if (stmt->params != NIL)
1377  {
1378  ListCell *lc;
1379  int i;
1380 
1381  dump_indent += 2;
1382  dump_ind();
1383  printf(" USING\n");
1384  dump_indent += 2;
1385  i = 1;
1386  foreach(lc, stmt->params)
1387  {
1388  dump_ind();
1389  printf(" parameter $%d: ", i++);
1390  dump_expr((PLpgSQL_expr *) lfirst(lc));
1391  printf("\n");
1392  }
1393  dump_indent -= 4;
1394  }
1395  }
1396 }

References dump_expr(), dump_ind(), dump_indent, i, lfirst, NIL, printf, and stmt.

Referenced by dump_stmt().

◆ dump_rollback()

static void dump_rollback ( PLpgSQL_stmt_rollback stmt)
static

Definition at line 1309 of file pl_funcs.c.

1310 {
1311  dump_ind();
1312  if (stmt->chain)
1313  printf("ROLLBACK AND CHAIN\n");
1314  else
1315  printf("ROLLBACK\n");
1316 }

References dump_ind(), printf, and stmt.

Referenced by dump_stmt().

◆ dump_stmt()

static void dump_stmt ( PLpgSQL_stmt stmt)
static

Definition at line 831 of file pl_funcs.c.

832 {
833  printf("%3d:", stmt->lineno);
834  switch (stmt->cmd_type)
835  {
836  case PLPGSQL_STMT_BLOCK:
838  break;
839  case PLPGSQL_STMT_ASSIGN:
841  break;
842  case PLPGSQL_STMT_IF:
844  break;
845  case PLPGSQL_STMT_CASE:
847  break;
848  case PLPGSQL_STMT_LOOP:
850  break;
851  case PLPGSQL_STMT_WHILE:
853  break;
854  case PLPGSQL_STMT_FORI:
856  break;
857  case PLPGSQL_STMT_FORS:
859  break;
860  case PLPGSQL_STMT_FORC:
862  break;
865  break;
866  case PLPGSQL_STMT_EXIT:
868  break;
869  case PLPGSQL_STMT_RETURN:
871  break;
874  break;
877  break;
878  case PLPGSQL_STMT_RAISE:
880  break;
881  case PLPGSQL_STMT_ASSERT:
883  break;
886  break;
889  break;
892  break;
895  break;
896  case PLPGSQL_STMT_OPEN:
898  break;
899  case PLPGSQL_STMT_FETCH:
901  break;
902  case PLPGSQL_STMT_CLOSE:
904  break;
907  break;
908  case PLPGSQL_STMT_CALL:
910  break;
911  case PLPGSQL_STMT_COMMIT:
913  break;
916  break;
917  default:
918  elog(ERROR, "unrecognized cmd_type: %d", stmt->cmd_type);
919  break;
920  }
921 }
#define ERROR
Definition: elog.h:39
static void dump_dynexecute(PLpgSQL_stmt_dynexecute *stmt)
Definition: pl_funcs.c:1506
static void dump_return_next(PLpgSQL_stmt_return_next *stmt)
Definition: pl_funcs.c:1348
static void dump_close(PLpgSQL_stmt_close *stmt)
Definition: pl_funcs.c:1274
static void dump_perform(PLpgSQL_stmt_perform *stmt)
Definition: pl_funcs.c:1281
static void dump_if(PLpgSQL_stmt_if *stmt)
Definition: pl_funcs.c:985
static void dump_fetch(PLpgSQL_stmt_fetch *stmt)
Definition: pl_funcs.c:1214
static void dump_execsql(PLpgSQL_stmt_execsql *stmt)
Definition: pl_funcs.c:1487
static void dump_case(PLpgSQL_stmt_case *stmt)
Definition: pl_funcs.c:1015
static void dump_open(PLpgSQL_stmt_open *stmt)
Definition: pl_funcs.c:1163
static void dump_assign(PLpgSQL_stmt_assign *stmt)
Definition: pl_funcs.c:976
static void dump_loop(PLpgSQL_stmt_loop *stmt)
Definition: pl_funcs.c:1053
static void dump_raise(PLpgSQL_stmt_raise *stmt)
Definition: pl_funcs.c:1399
static void dump_rollback(PLpgSQL_stmt_rollback *stmt)
Definition: pl_funcs.c:1309
static void dump_while(PLpgSQL_stmt_while *stmt)
Definition: pl_funcs.c:1065
static void dump_block(PLpgSQL_stmt_block *block)
Definition: pl_funcs.c:935
static void dump_getdiag(PLpgSQL_stmt_getdiag *stmt)
Definition: pl_funcs.c:1574
static void dump_exit(PLpgSQL_stmt_exit *stmt)
Definition: pl_funcs.c:1319
static void dump_call(PLpgSQL_stmt_call *stmt)
Definition: pl_funcs.c:1290
static void dump_forc(PLpgSQL_stmt_forc *stmt)
Definition: pl_funcs.c:1123
static void dump_commit(PLpgSQL_stmt_commit *stmt)
Definition: pl_funcs.c:1299
static void dump_return(PLpgSQL_stmt_return *stmt)
Definition: pl_funcs.c:1334
static void dump_foreach_a(PLpgSQL_stmt_foreach_a *stmt)
Definition: pl_funcs.c:1146
static void dump_return_query(PLpgSQL_stmt_return_query *stmt)
Definition: pl_funcs.c:1362
static void dump_assert(PLpgSQL_stmt_assert *stmt)
Definition: pl_funcs.c:1468
static void dump_dynfors(PLpgSQL_stmt_dynfors *stmt)
Definition: pl_funcs.c:1543
static void dump_fori(PLpgSQL_stmt_fori *stmt)
Definition: pl_funcs.c:1079
static void dump_fors(PLpgSQL_stmt_fors *stmt)
Definition: pl_funcs.c:1109
@ PLPGSQL_STMT_DYNFORS
Definition: plpgsql.h:122
@ PLPGSQL_STMT_FORI
Definition: plpgsql.h:110
@ PLPGSQL_STMT_FETCH
Definition: plpgsql.h:125
@ PLPGSQL_STMT_CASE
Definition: plpgsql.h:107
@ PLPGSQL_STMT_OPEN
Definition: plpgsql.h:124
@ PLPGSQL_STMT_ROLLBACK
Definition: plpgsql.h:130
@ PLPGSQL_STMT_COMMIT
Definition: plpgsql.h:129
@ PLPGSQL_STMT_RETURN_QUERY
Definition: plpgsql.h:117
@ PLPGSQL_STMT_RETURN
Definition: plpgsql.h:115
@ PLPGSQL_STMT_CLOSE
Definition: plpgsql.h:126
@ PLPGSQL_STMT_WHILE
Definition: plpgsql.h:109
@ PLPGSQL_STMT_BLOCK
Definition: plpgsql.h:104
@ PLPGSQL_STMT_FORS
Definition: plpgsql.h:111
@ PLPGSQL_STMT_FORC
Definition: plpgsql.h:112
@ PLPGSQL_STMT_IF
Definition: plpgsql.h:106
@ PLPGSQL_STMT_PERFORM
Definition: plpgsql.h:127
@ PLPGSQL_STMT_LOOP
Definition: plpgsql.h:108
@ PLPGSQL_STMT_ASSERT
Definition: plpgsql.h:119
@ PLPGSQL_STMT_FOREACH_A
Definition: plpgsql.h:113
@ PLPGSQL_STMT_GETDIAG
Definition: plpgsql.h:123
@ PLPGSQL_STMT_RETURN_NEXT
Definition: plpgsql.h:116
@ PLPGSQL_STMT_ASSIGN
Definition: plpgsql.h:105
@ PLPGSQL_STMT_EXIT
Definition: plpgsql.h:114
@ PLPGSQL_STMT_EXECSQL
Definition: plpgsql.h:120
@ PLPGSQL_STMT_RAISE
Definition: plpgsql.h:118
@ PLPGSQL_STMT_CALL
Definition: plpgsql.h:128
@ PLPGSQL_STMT_DYNEXECUTE
Definition: plpgsql.h:121

References 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_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, printf, and stmt.

Referenced by dump_stmts().

◆ dump_stmts()

static void dump_stmts ( List stmts)
static

Definition at line 924 of file pl_funcs.c.

925 {
926  ListCell *s;
927 
928  dump_indent += 2;
929  foreach(s, stmts)
930  dump_stmt((PLpgSQL_stmt *) lfirst(s));
931  dump_indent -= 2;
932 }
static void dump_stmt(PLpgSQL_stmt *stmt)
Definition: pl_funcs.c:831

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

◆ dump_while()

static void dump_while ( PLpgSQL_stmt_while stmt)
static

Definition at line 1065 of file pl_funcs.c.

1066 {
1067  dump_ind();
1068  printf("WHILE ");
1069  dump_expr(stmt->cond);
1070  printf("\n");
1071 
1072  dump_stmts(stmt->body);
1073 
1074  dump_ind();
1075  printf(" ENDWHILE\n");
1076 }

References dump_expr(), dump_ind(), dump_stmts(), printf, and stmt.

Referenced by dump_stmt().

◆ free_assert()

static void free_assert ( PLpgSQL_stmt_assert stmt)
static

Definition at line 674 of file pl_funcs.c.

675 {
676  free_expr(stmt->cond);
677  free_expr(stmt->message);
678 }
static void free_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:717

References free_expr(), and stmt.

Referenced by free_stmt().

◆ free_assign()

static void free_assign ( PLpgSQL_stmt_assign stmt)
static

Definition at line 497 of file pl_funcs.c.

498 {
499  free_expr(stmt->expr);
500 }

References free_expr(), and stmt.

Referenced by free_stmt().

◆ free_block()

static void free_block ( PLpgSQL_stmt_block block)
static

Definition at line 480 of file pl_funcs.c.

481 {
482  free_stmts(block->body);
483  if (block->exceptions)
484  {
485  ListCell *e;
486 
487  foreach(e, block->exceptions->exc_list)
488  {
490 
491  free_stmts(exc->action);
492  }
493  }
494 }
static void free_stmts(List *stmts)
Definition: pl_funcs.c:469

References PLpgSQL_exception::action, PLpgSQL_stmt_block::body, PLpgSQL_exception_block::exc_list, PLpgSQL_stmt_block::exceptions, free_stmts(), and lfirst.

Referenced by free_stmt(), and plpgsql_free_function_memory().

◆ free_call()

static void free_call ( PLpgSQL_stmt_call stmt)
static

Definition at line 610 of file pl_funcs.c.

611 {
612  free_expr(stmt->expr);
613 }

References free_expr(), and stmt.

Referenced by free_stmt().

◆ free_case()

static void free_case ( PLpgSQL_stmt_case stmt)
static

Definition at line 520 of file pl_funcs.c.

521 {
522  ListCell *l;
523 
524  free_expr(stmt->t_expr);
525  foreach(l, stmt->case_when_list)
526  {
528 
529  free_expr(cwt->expr);
530  free_stmts(cwt->stmts);
531  }
532  free_stmts(stmt->else_stmts);
533 }

References PLpgSQL_case_when::expr, free_expr(), free_stmts(), lfirst, stmt, and PLpgSQL_case_when::stmts.

Referenced by free_stmt().

◆ free_close()

static void free_close ( PLpgSQL_stmt_close stmt)
static

Definition at line 599 of file pl_funcs.c.

600 {
601 }

Referenced by free_stmt().

◆ free_commit()

static void free_commit ( PLpgSQL_stmt_commit stmt)
static

Definition at line 616 of file pl_funcs.c.

617 {
618 }

Referenced by free_stmt().

◆ free_dynexecute()

static void free_dynexecute ( PLpgSQL_stmt_dynexecute stmt)
static

Definition at line 687 of file pl_funcs.c.

688 {
689  ListCell *lc;
690 
691  free_expr(stmt->query);
692  foreach(lc, stmt->params)
693  {
694  free_expr((PLpgSQL_expr *) lfirst(lc));
695  }
696 }

References free_expr(), lfirst, and stmt.

Referenced by free_stmt().

◆ free_dynfors()

static void free_dynfors ( PLpgSQL_stmt_dynfors stmt)
static

Definition at line 699 of file pl_funcs.c.

700 {
701  ListCell *lc;
702 
703  free_stmts(stmt->body);
704  free_expr(stmt->query);
705  foreach(lc, stmt->params)
706  {
707  free_expr((PLpgSQL_expr *) lfirst(lc));
708  }
709 }

References free_expr(), free_stmts(), lfirst, and stmt.

Referenced by free_stmt().

◆ free_execsql()

static void free_execsql ( PLpgSQL_stmt_execsql stmt)
static

Definition at line 681 of file pl_funcs.c.

682 {
683  free_expr(stmt->sqlstmt);
684 }

References free_expr(), and stmt.

Referenced by free_stmt().

◆ free_exit()

static void free_exit ( PLpgSQL_stmt_exit stmt)
static

Definition at line 626 of file pl_funcs.c.

627 {
628  free_expr(stmt->cond);
629 }

References free_expr(), and stmt.

Referenced by free_stmt().

◆ free_expr()

static void free_expr ( PLpgSQL_expr expr)
static

◆ free_fetch()

static void free_fetch ( PLpgSQL_stmt_fetch stmt)
static

Definition at line 593 of file pl_funcs.c.

594 {
595  free_expr(stmt->expr);
596 }

References free_expr(), and stmt.

Referenced by free_stmt().

◆ free_forc()

static void free_forc ( PLpgSQL_stmt_forc stmt)
static

Definition at line 565 of file pl_funcs.c.

566 {
567  free_stmts(stmt->body);
568  free_expr(stmt->argquery);
569 }

References free_expr(), free_stmts(), and stmt.

Referenced by free_stmt().

◆ free_foreach_a()

static void free_foreach_a ( PLpgSQL_stmt_foreach_a stmt)
static

Definition at line 572 of file pl_funcs.c.

573 {
574  free_expr(stmt->expr);
575  free_stmts(stmt->body);
576 }

References free_expr(), free_stmts(), and stmt.

Referenced by free_stmt().

◆ free_fori()

static void free_fori ( PLpgSQL_stmt_fori stmt)
static

Definition at line 549 of file pl_funcs.c.

550 {
551  free_expr(stmt->lower);
552  free_expr(stmt->upper);
553  free_expr(stmt->step);
554  free_stmts(stmt->body);
555 }

References free_expr(), free_stmts(), and stmt.

Referenced by free_stmt().

◆ free_fors()

static void free_fors ( PLpgSQL_stmt_fors stmt)
static

Definition at line 558 of file pl_funcs.c.

559 {
560  free_stmts(stmt->body);
561  free_expr(stmt->query);
562 }

References free_expr(), free_stmts(), and stmt.

Referenced by free_stmt().

◆ free_getdiag()

static void free_getdiag ( PLpgSQL_stmt_getdiag stmt)
static

Definition at line 712 of file pl_funcs.c.

713 {
714 }

Referenced by free_stmt().

◆ free_if()

static void free_if ( PLpgSQL_stmt_if stmt)
static

Definition at line 503 of file pl_funcs.c.

504 {
505  ListCell *l;
506 
507  free_expr(stmt->cond);
508  free_stmts(stmt->then_body);
509  foreach(l, stmt->elsif_list)
510  {
512 
513  free_expr(elif->cond);
514  free_stmts(elif->stmts);
515  }
516  free_stmts(stmt->else_body);
517 }

References PLpgSQL_if_elsif::cond, free_expr(), free_stmts(), lfirst, stmt, and PLpgSQL_if_elsif::stmts.

Referenced by free_stmt().

◆ free_loop()

static void free_loop ( PLpgSQL_stmt_loop stmt)
static

Definition at line 536 of file pl_funcs.c.

537 {
538  free_stmts(stmt->body);
539 }

References free_stmts(), and stmt.

Referenced by free_stmt().

◆ free_open()

static void free_open ( PLpgSQL_stmt_open stmt)
static

Definition at line 579 of file pl_funcs.c.

580 {
581  ListCell *lc;
582 
583  free_expr(stmt->argquery);
584  free_expr(stmt->query);
585  free_expr(stmt->dynquery);
586  foreach(lc, stmt->params)
587  {
588  free_expr((PLpgSQL_expr *) lfirst(lc));
589  }
590 }

References free_expr(), lfirst, and stmt.

Referenced by free_stmt().

◆ free_perform()

static void free_perform ( PLpgSQL_stmt_perform stmt)
static

Definition at line 604 of file pl_funcs.c.

605 {
606  free_expr(stmt->expr);
607 }

References free_expr(), and stmt.

Referenced by free_stmt().

◆ free_raise()

static void free_raise ( PLpgSQL_stmt_raise stmt)
static

Definition at line 657 of file pl_funcs.c.

658 {
659  ListCell *lc;
660 
661  foreach(lc, stmt->params)
662  {
663  free_expr((PLpgSQL_expr *) lfirst(lc));
664  }
665  foreach(lc, stmt->options)
666  {
668 
669  free_expr(opt->expr);
670  }
671 }

References PLpgSQL_raise_option::expr, free_expr(), lfirst, and stmt.

Referenced by free_stmt().

◆ free_return()

static void free_return ( PLpgSQL_stmt_return stmt)
static

Definition at line 632 of file pl_funcs.c.

633 {
634  free_expr(stmt->expr);
635 }

References free_expr(), and stmt.

Referenced by free_stmt().

◆ free_return_next()

static void free_return_next ( PLpgSQL_stmt_return_next stmt)
static

Definition at line 638 of file pl_funcs.c.

639 {
640  free_expr(stmt->expr);
641 }

References free_expr(), and stmt.

Referenced by free_stmt().

◆ free_return_query()

static void free_return_query ( PLpgSQL_stmt_return_query stmt)
static

Definition at line 644 of file pl_funcs.c.

645 {
646  ListCell *lc;
647 
648  free_expr(stmt->query);
649  free_expr(stmt->dynquery);
650  foreach(lc, stmt->params)
651  {
652  free_expr((PLpgSQL_expr *) lfirst(lc));
653  }
654 }

References free_expr(), lfirst, and stmt.

Referenced by free_stmt().

◆ free_rollback()

static void free_rollback ( PLpgSQL_stmt_rollback stmt)
static

Definition at line 621 of file pl_funcs.c.

622 {
623 }

Referenced by free_stmt().

◆ free_stmt()

static void free_stmt ( PLpgSQL_stmt stmt)
static

Definition at line 377 of file pl_funcs.c.

378 {
379  switch (stmt->cmd_type)
380  {
381  case PLPGSQL_STMT_BLOCK:
383  break;
384  case PLPGSQL_STMT_ASSIGN:
386  break;
387  case PLPGSQL_STMT_IF:
389  break;
390  case PLPGSQL_STMT_CASE:
392  break;
393  case PLPGSQL_STMT_LOOP:
395  break;
396  case PLPGSQL_STMT_WHILE:
398  break;
399  case PLPGSQL_STMT_FORI:
401  break;
402  case PLPGSQL_STMT_FORS:
404  break;
405  case PLPGSQL_STMT_FORC:
407  break;
410  break;
411  case PLPGSQL_STMT_EXIT:
413  break;
414  case PLPGSQL_STMT_RETURN:
416  break;
419  break;
422  break;
423  case PLPGSQL_STMT_RAISE:
425  break;
426  case PLPGSQL_STMT_ASSERT:
428  break;
431  break;
434  break;
437  break;
440  break;
441  case PLPGSQL_STMT_OPEN:
443  break;
444  case PLPGSQL_STMT_FETCH:
446  break;
447  case PLPGSQL_STMT_CLOSE:
449  break;
452  break;
453  case PLPGSQL_STMT_CALL:
455  break;
456  case PLPGSQL_STMT_COMMIT:
458  break;
461  break;
462  default:
463  elog(ERROR, "unrecognized cmd_type: %d", stmt->cmd_type);
464  break;
465  }
466 }
static void free_rollback(PLpgSQL_stmt_rollback *stmt)
Definition: pl_funcs.c:621
static void free_assign(PLpgSQL_stmt_assign *stmt)
Definition: pl_funcs.c:497
static void free_return(PLpgSQL_stmt_return *stmt)
Definition: pl_funcs.c:632
static void free_assert(PLpgSQL_stmt_assert *stmt)
Definition: pl_funcs.c:674
static void free_fori(PLpgSQL_stmt_fori *stmt)
Definition: pl_funcs.c:549
static void free_getdiag(PLpgSQL_stmt_getdiag *stmt)
Definition: pl_funcs.c:712
static void free_forc(PLpgSQL_stmt_forc *stmt)
Definition: pl_funcs.c:565
static void free_fetch(PLpgSQL_stmt_fetch *stmt)
Definition: pl_funcs.c:593
static void free_while(PLpgSQL_stmt_while *stmt)
Definition: pl_funcs.c:542
static void free_raise(PLpgSQL_stmt_raise *stmt)
Definition: pl_funcs.c:657
static void free_dynexecute(PLpgSQL_stmt_dynexecute *stmt)
Definition: pl_funcs.c:687
static void free_if(PLpgSQL_stmt_if *stmt)
Definition: pl_funcs.c:503
static void free_commit(PLpgSQL_stmt_commit *stmt)
Definition: pl_funcs.c:616
static void free_call(PLpgSQL_stmt_call *stmt)
Definition: pl_funcs.c:610
static void free_open(PLpgSQL_stmt_open *stmt)
Definition: pl_funcs.c:579
static void free_case(PLpgSQL_stmt_case *stmt)
Definition: pl_funcs.c:520
static void free_block(PLpgSQL_stmt_block *block)
Definition: pl_funcs.c:480
static void free_fors(PLpgSQL_stmt_fors *stmt)
Definition: pl_funcs.c:558
static void free_execsql(PLpgSQL_stmt_execsql *stmt)
Definition: pl_funcs.c:681
static void free_exit(PLpgSQL_stmt_exit *stmt)
Definition: pl_funcs.c:626
static void free_close(PLpgSQL_stmt_close *stmt)
Definition: pl_funcs.c:599
static void free_return_query(PLpgSQL_stmt_return_query *stmt)
Definition: pl_funcs.c:644
static void free_return_next(PLpgSQL_stmt_return_next *stmt)
Definition: pl_funcs.c:638
static void free_foreach_a(PLpgSQL_stmt_foreach_a *stmt)
Definition: pl_funcs.c:572
static void free_loop(PLpgSQL_stmt_loop *stmt)
Definition: pl_funcs.c:536
static void free_dynfors(PLpgSQL_stmt_dynfors *stmt)
Definition: pl_funcs.c:699
static void free_perform(PLpgSQL_stmt_perform *stmt)
Definition: pl_funcs.c:604

References 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, PLPGSQL_STMT_WHILE, and stmt.

Referenced by free_stmts().

◆ free_stmts()

static void free_stmts ( List stmts)
static

Definition at line 469 of file pl_funcs.c.

470 {
471  ListCell *s;
472 
473  foreach(s, stmts)
474  {
475  free_stmt((PLpgSQL_stmt *) lfirst(s));
476  }
477 }
static void free_stmt(PLpgSQL_stmt *stmt)
Definition: pl_funcs.c:377

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

◆ free_while()

static void free_while ( PLpgSQL_stmt_while stmt)
static

Definition at line 542 of file pl_funcs.c.

543 {
544  free_expr(stmt->cond);
545  free_stmts(stmt->body);
546 }

References free_expr(), free_stmts(), and stmt.

Referenced by free_stmt().

◆ plpgsql_dumptree()

void plpgsql_dumptree ( PLpgSQL_function func)

Definition at line 1600 of file pl_funcs.c.

1601 {
1602  int i;
1603  PLpgSQL_datum *d;
1604 
1605  printf("\nExecution tree of successfully compiled PL/pgSQL function %s:\n",
1606  func->fn_signature);
1607 
1608  printf("\nFunction's data area:\n");
1609  for (i = 0; i < func->ndatums; i++)
1610  {
1611  d = func->datums[i];
1612 
1613  printf(" entry %d: ", i);
1614  switch (d->dtype)
1615  {
1616  case PLPGSQL_DTYPE_VAR:
1617  case PLPGSQL_DTYPE_PROMISE:
1618  {
1619  PLpgSQL_var *var = (PLpgSQL_var *) d;
1620 
1621  printf("VAR %-16s type %s (typoid %u) atttypmod %d\n",
1622  var->refname, var->datatype->typname,
1623  var->datatype->typoid,
1624  var->datatype->atttypmod);
1625  if (var->isconst)
1626  printf(" CONSTANT\n");
1627  if (var->notnull)
1628  printf(" NOT NULL\n");
1629  if (var->default_val != NULL)
1630  {
1631  printf(" DEFAULT ");
1632  dump_expr(var->default_val);
1633  printf("\n");
1634  }
1635  if (var->cursor_explicit_expr != NULL)
1636  {
1637  if (var->cursor_explicit_argrow >= 0)
1638  printf(" CURSOR argument row %d\n", var->cursor_explicit_argrow);
1639 
1640  printf(" CURSOR IS ");
1642  printf("\n");
1643  }
1644  if (var->promise != PLPGSQL_PROMISE_NONE)
1645  printf(" PROMISE %d\n",
1646  (int) var->promise);
1647  }
1648  break;
1649  case PLPGSQL_DTYPE_ROW:
1650  {
1651  PLpgSQL_row *row = (PLpgSQL_row *) d;
1652 
1653  printf("ROW %-16s fields", row->refname);
1654  for (int j = 0; j < row->nfields; j++)
1655  {
1656  printf(" %s=var %d", row->fieldnames[j],
1657  row->varnos[j]);
1658  }
1659  printf("\n");
1660  }
1661  break;
1662  case PLPGSQL_DTYPE_REC:
1663  printf("REC %-16s typoid %u\n",
1664  ((PLpgSQL_rec *) d)->refname,
1665  ((PLpgSQL_rec *) d)->rectypeid);
1666  if (((PLpgSQL_rec *) d)->isconst)
1667  printf(" CONSTANT\n");
1668  if (((PLpgSQL_rec *) d)->notnull)
1669  printf(" NOT NULL\n");
1670  if (((PLpgSQL_rec *) d)->default_val != NULL)
1671  {
1672  printf(" DEFAULT ");
1673  dump_expr(((PLpgSQL_rec *) d)->default_val);
1674  printf("\n");
1675  }
1676  break;
1678  printf("RECFIELD %-16s of REC %d\n",
1679  ((PLpgSQL_recfield *) d)->fieldname,
1680  ((PLpgSQL_recfield *) d)->recparentno);
1681  break;
1682  default:
1683  printf("??? unknown data type %d\n", d->dtype);
1684  }
1685  }
1686  printf("\nFunction's statements:\n");
1687 
1688  dump_indent = 0;
1689  printf("%3d:", func->action->lineno);
1690  dump_block(func->action);
1691  printf("\nEnd of execution tree of function %s\n\n", func->fn_signature);
1692  fflush(stdout);
1693 }
int j
Definition: isn.c:74
static void const char fflush(stdout)
@ PLPGSQL_PROMISE_NONE
Definition: plpgsql.h:75
@ PLPGSQL_DTYPE_ROW
Definition: plpgsql.h:64
@ PLPGSQL_DTYPE_PROMISE
Definition: plpgsql.h:67
@ PLPGSQL_DTYPE_RECFIELD
Definition: plpgsql.h:66
@ PLPGSQL_DTYPE_REC
Definition: plpgsql.h:65
@ PLPGSQL_DTYPE_VAR
Definition: plpgsql.h:63
PLpgSQL_datum_type dtype
Definition: plpgsql.h:277
PLpgSQL_stmt_block * action
Definition: plpgsql.h:1007
PLpgSQL_datum ** datums
Definition: plpgsql.h:1003
char * fn_signature
Definition: plpgsql.h:968
PLpgSQL_datum_type dtype
Definition: plpgsql.h:422
int * varnos
Definition: plpgsql.h:383
char * refname
Definition: plpgsql.h:367
char ** fieldnames
Definition: plpgsql.h:382
int nfields
Definition: plpgsql.h:381
Oid typoid
Definition: plpgsql.h:201
char * typname
Definition: plpgsql.h:200
int32 atttypmod
Definition: plpgsql.h:208
PLpgSQL_promise_type promise
Definition: plpgsql.h:342
int cursor_explicit_argrow
Definition: plpgsql.h:328
bool notnull
Definition: plpgsql.h:316
bool isconst
Definition: plpgsql.h:315
PLpgSQL_expr * cursor_explicit_expr
Definition: plpgsql.h:327
PLpgSQL_type * datatype
Definition: plpgsql.h:320
PLpgSQL_expr * default_val
Definition: plpgsql.h:317
char * refname
Definition: plpgsql.h:313

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_rec::dtype, dump_block(), dump_expr(), dump_indent, fflush(), PLpgSQL_row::fieldnames, PLpgSQL_function::fn_signature, i, PLpgSQL_var::isconst, j, 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().

◆ plpgsql_free_function_memory()

void plpgsql_free_function_memory ( PLpgSQL_function func)

Definition at line 727 of file pl_funcs.c.

728 {
729  int i;
730 
731  /* Better not call this on an in-use function */
732  Assert(func->use_count == 0);
733 
734  /* Release plans associated with variable declarations */
735  for (i = 0; i < func->ndatums; i++)
736  {
737  PLpgSQL_datum *d = func->datums[i];
738 
739  switch (d->dtype)
740  {
741  case PLPGSQL_DTYPE_VAR:
743  {
744  PLpgSQL_var *var = (PLpgSQL_var *) d;
745 
746  free_expr(var->default_val);
748  }
749  break;
750  case PLPGSQL_DTYPE_ROW:
751  break;
752  case PLPGSQL_DTYPE_REC:
753  {
754  PLpgSQL_rec *rec = (PLpgSQL_rec *) d;
755 
756  free_expr(rec->default_val);
757  }
758  break;
760  break;
761  default:
762  elog(ERROR, "unrecognized data type: %d", d->dtype);
763  }
764  }
765  func->ndatums = 0;
766 
767  /* Release plans in statement tree */
768  if (func->action)
769  free_block(func->action);
770  func->action = NULL;
771 
772  /*
773  * And finally, release all memory except the PLpgSQL_function struct
774  * itself (which has to be kept around because there may be multiple
775  * fn_extra pointers to it).
776  */
777  if (func->fn_cxt)
779  func->fn_cxt = NULL;
780 }
Assert(fmt[strlen(fmt) - 1] !='\n')
void MemoryContextDelete(MemoryContext context)
Definition: mcxt.c:403
unsigned long use_count
Definition: plpgsql.h:1015
MemoryContext fn_cxt
Definition: plpgsql.h:975
PLpgSQL_expr * default_val
Definition: plpgsql.h:397

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

◆ plpgsql_getdiag_kindname()

const char* plpgsql_getdiag_kindname ( PLpgSQL_getdiag_kind  kind)

Definition at line 300 of file pl_funcs.c.

301 {
302  switch (kind)
303  {
305  return "ROW_COUNT";
307  return "PG_ROUTINE_OID";
309  return "PG_CONTEXT";
311  return "PG_EXCEPTION_CONTEXT";
313  return "PG_EXCEPTION_DETAIL";
315  return "PG_EXCEPTION_HINT";
317  return "RETURNED_SQLSTATE";
319  return "COLUMN_NAME";
321  return "CONSTRAINT_NAME";
323  return "PG_DATATYPE_NAME";
325  return "MESSAGE_TEXT";
327  return "TABLE_NAME";
329  return "SCHEMA_NAME";
330  }
331 
332  return "unknown";
333 }
@ PLPGSQL_GETDIAG_ERROR_DETAIL
Definition: plpgsql.h:153
@ PLPGSQL_GETDIAG_SCHEMA_NAME
Definition: plpgsql.h:161
@ PLPGSQL_GETDIAG_MESSAGE_TEXT
Definition: plpgsql.h:159
@ PLPGSQL_GETDIAG_DATATYPE_NAME
Definition: plpgsql.h:158
@ PLPGSQL_GETDIAG_TABLE_NAME
Definition: plpgsql.h:160
@ PLPGSQL_GETDIAG_CONSTRAINT_NAME
Definition: plpgsql.h:157
@ PLPGSQL_GETDIAG_COLUMN_NAME
Definition: plpgsql.h:156
@ PLPGSQL_GETDIAG_ROW_COUNT
Definition: plpgsql.h:149
@ PLPGSQL_GETDIAG_RETURNED_SQLSTATE
Definition: plpgsql.h:155
@ PLPGSQL_GETDIAG_CONTEXT
Definition: plpgsql.h:151
@ PLPGSQL_GETDIAG_ERROR_HINT
Definition: plpgsql.h:154
@ PLPGSQL_GETDIAG_ERROR_CONTEXT
Definition: plpgsql.h:152
@ PLPGSQL_GETDIAG_ROUTINE_OID
Definition: plpgsql.h:150

References 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_ROUTINE_OID, PLPGSQL_GETDIAG_ROW_COUNT, PLPGSQL_GETDIAG_SCHEMA_NAME, and PLPGSQL_GETDIAG_TABLE_NAME.

Referenced by dump_getdiag().

◆ 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.

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 }
void * palloc(Size size)
Definition: mcxt.c:1226
static PLpgSQL_nsitem * ns_top
Definition: pl_funcs.c:35
@ PLPGSQL_NSTYPE_LABEL
Definition: plpgsql.h:43
char name[FLEXIBLE_ARRAY_MEMBER]
Definition: plpgsql.h:447
struct PLpgSQL_nsitem * prev
Definition: plpgsql.h:446
PLpgSQL_nsitem_type itemtype
Definition: plpgsql.h:439

References Assert(), PLpgSQL_nsitem::itemno, PLpgSQL_nsitem::itemtype, name, PLpgSQL_nsitem::name, ns_top, palloc(), PLPGSQL_NSTYPE_LABEL, and PLpgSQL_nsitem::prev.

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

◆ 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.

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 }
@ PLPGSQL_LABEL_LOOP
Definition: plpgsql.h:54

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

◆ plpgsql_ns_init()

void plpgsql_ns_init ( void  )

Definition at line 43 of file pl_funcs.c.

44 {
45  ns_top = NULL;
46 }

References ns_top.

Referenced by do_compile(), and plpgsql_compile_inline().

◆ 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.

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 }
@ PLPGSQL_NSTYPE_VAR
Definition: plpgsql.h:44

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

◆ 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.

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 }

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

◆ plpgsql_ns_pop()

void plpgsql_ns_pop ( void  )

Definition at line 67 of file pl_funcs.c.

68 {
69  Assert(ns_top != NULL);
71  ns_top = ns_top->prev;
72  ns_top = ns_top->prev;
73 }

References Assert(), PLpgSQL_nsitem::itemtype, ns_top, PLPGSQL_NSTYPE_LABEL, and PLpgSQL_nsitem::prev.

◆ plpgsql_ns_push()

void plpgsql_ns_push ( const char *  label,
PLpgSQL_label_type  label_type 
)

Definition at line 54 of file pl_funcs.c.

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

References label, plpgsql_ns_additem(), and PLPGSQL_NSTYPE_LABEL.

Referenced by do_compile(), and plpgsql_compile_inline().

◆ plpgsql_ns_top()

PLpgSQL_nsitem* plpgsql_ns_top ( void  )

◆ plpgsql_stmt_typename()

const char* plpgsql_stmt_typename ( PLpgSQL_stmt stmt)

Definition at line 232 of file pl_funcs.c.

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 }
#define _(x)
Definition: elog.c:91

References _, 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 stmt.

Referenced by plpgsql_exec_error_callback().

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(), plpgsql_ns_init(), plpgsql_ns_pop(), and plpgsql_ns_top().