PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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.

Macros

#define plpgsql_statement_tree_walker(s, sw, ew, c)
 
#define S_WALK(st)   stmt_callback(st, context)
 
#define E_WALK(ex)   expr_callback(ex, context)
 
#define S_LIST_WALK(lst)   foreach_ptr(PLpgSQL_stmt, st, lst) S_WALK(st)
 
#define E_LIST_WALK(lst)   foreach_ptr(PLpgSQL_expr, ex, lst) E_WALK(ex)
 

Typedefs

typedef void(* plpgsql_stmt_walker_callback) (PLpgSQL_stmt *stmt, void *context)
 
typedef void(* plpgsql_expr_walker_callback) (PLpgSQL_expr *expr, void *context)
 

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 plpgsql_statement_tree_walker_impl (PLpgSQL_stmt *stmt, plpgsql_stmt_walker_callback stmt_callback, plpgsql_expr_walker_callback expr_callback, void *context)
 
static void mark_stmt (PLpgSQL_stmt *stmt, Bitmapset *local_dnos)
 
static void mark_expr (PLpgSQL_expr *expr, Bitmapset *local_dnos)
 
void plpgsql_mark_local_assignment_targets (PLpgSQL_function *func)
 
static void free_stmt (PLpgSQL_stmt *stmt, void *context)
 
static void free_expr (PLpgSQL_expr *expr, void *context)
 
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
 

Macro Definition Documentation

◆ E_LIST_WALK

#define E_LIST_WALK (   lst)    foreach_ptr(PLpgSQL_expr, ex, lst) E_WALK(ex)

◆ E_WALK

#define E_WALK (   ex)    expr_callback(ex, context)

◆ plpgsql_statement_tree_walker

#define plpgsql_statement_tree_walker (   s,
  sw,
  ew,
  c 
)
Value:
void(* plpgsql_stmt_walker_callback)(PLpgSQL_stmt *stmt, void *context)
Definition: pl_funcs.c:349
static void plpgsql_statement_tree_walker_impl(PLpgSQL_stmt *stmt, plpgsql_stmt_walker_callback stmt_callback, plpgsql_expr_walker_callback expr_callback, void *context)
Definition: pl_funcs.c:364
void(* plpgsql_expr_walker_callback)(PLpgSQL_expr *expr, void *context)
Definition: pl_funcs.c:351
char * c

Definition at line 359 of file pl_funcs.c.

◆ S_LIST_WALK

#define S_LIST_WALK (   lst)    foreach_ptr(PLpgSQL_stmt, st, lst) S_WALK(st)

◆ S_WALK

#define S_WALK (   st)    stmt_callback(st, context)

Typedef Documentation

◆ plpgsql_expr_walker_callback

typedef void(* plpgsql_expr_walker_callback) (PLpgSQL_expr *expr, void *context)

Definition at line 351 of file pl_funcs.c.

◆ plpgsql_stmt_walker_callback

typedef void(* plpgsql_stmt_walker_callback) (PLpgSQL_stmt *stmt, void *context)

Definition at line 349 of file pl_funcs.c.

Function Documentation

◆ dump_assert()

static void dump_assert ( PLpgSQL_stmt_assert stmt)
static

Definition at line 1459 of file pl_funcs.c.

1460{
1461 dump_ind();
1462 printf("ASSERT ");
1463 dump_expr(stmt->cond);
1464 printf("\n");
1465
1466 dump_indent += 2;
1467 if (stmt->message != NULL)
1468 {
1469 dump_ind();
1470 printf(" MESSAGE = ");
1471 dump_expr(stmt->message);
1472 printf("\n");
1473 }
1474 dump_indent -= 2;
1475}
#define stmt
Definition: indent_codes.h:59
static int dump_indent
Definition: pl_funcs.c:777
static void dump_expr(PLpgSQL_expr *expr)
Definition: pl_funcs.c:1585
static void dump_ind(void)
Definition: pl_funcs.c:813
#define printf(...)
Definition: port.h:245

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

968{
969 dump_ind();
970 printf("ASSIGN var %d := ", stmt->varno);
971 dump_expr(stmt->expr);
972 printf("\n");
973}

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

927{
928 char *name;
929
930 if (block->label == NULL)
931 name = "*unnamed*";
932 else
933 name = block->label;
934
935 dump_ind();
936 printf("BLOCK <<%s>>\n", name);
937
938 dump_stmts(block->body);
939
940 if (block->exceptions)
941 {
942 ListCell *e;
943
944 foreach(e, block->exceptions->exc_list)
945 {
947 PLpgSQL_condition *cond;
948
949 dump_ind();
950 printf(" EXCEPTION WHEN ");
951 for (cond = exc->conditions; cond; cond = cond->next)
952 {
953 if (cond != exc->conditions)
954 printf(" OR ");
955 printf("%s", cond->condname);
956 }
957 printf(" THEN\n");
958 dump_stmts(exc->action);
959 }
960 }
961
962 dump_ind();
963 printf(" END -- %s\n", name);
964}
#define lfirst(lc)
Definition: pg_list.h:172
static void dump_stmts(List *stmts)
Definition: pl_funcs.c:915
e
Definition: preproc-init.c:82
char * condname
Definition: plpgsql.h:494
struct PLpgSQL_condition * next
Definition: plpgsql.h:495
PLpgSQL_condition * conditions
Definition: plpgsql.h:517
PLpgSQL_exception_block * exceptions
Definition: plpgsql.h:533
const char * name

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

1282{
1283 dump_ind();
1284 printf("%s expr = ", stmt->is_call ? "CALL" : "DO");
1285 dump_expr(stmt->expr);
1286 printf("\n");
1287}

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

1007{
1008 ListCell *l;
1009
1010 dump_ind();
1011 printf("CASE %d ", stmt->t_varno);
1012 if (stmt->t_expr)
1013 dump_expr(stmt->t_expr);
1014 printf("\n");
1015 dump_indent += 6;
1016 foreach(l, stmt->case_when_list)
1017 {
1019
1020 dump_ind();
1021 printf("WHEN ");
1022 dump_expr(cwt->expr);
1023 printf("\n");
1024 dump_ind();
1025 printf("THEN\n");
1026 dump_indent += 2;
1027 dump_stmts(cwt->stmts);
1028 dump_indent -= 2;
1029 }
1030 if (stmt->have_else)
1031 {
1032 dump_ind();
1033 printf("ELSE\n");
1034 dump_indent += 2;
1035 dump_stmts(stmt->else_stmts);
1036 dump_indent -= 2;
1037 }
1038 dump_indent -= 6;
1039 dump_ind();
1040 printf(" ENDCASE\n");
1041}
PLpgSQL_expr * expr
Definition: plpgsql.h:660

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

1266{
1267 dump_ind();
1268 printf("CLOSE curvar=%d\n", stmt->curvar);
1269}

References dump_ind(), printf, and stmt.

Referenced by dump_stmt().

◆ dump_commit()

static void dump_commit ( PLpgSQL_stmt_commit stmt)
static

Definition at line 1290 of file pl_funcs.c.

1291{
1292 dump_ind();
1293 if (stmt->chain)
1294 printf("COMMIT AND CHAIN\n");
1295 else
1296 printf("COMMIT\n");
1297}

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

1232{
1233 dump_indent += 2;
1234 dump_ind();
1235 switch (stmt->direction)
1236 {
1237 case FETCH_FORWARD:
1238 printf(" FORWARD ");
1239 break;
1240 case FETCH_BACKWARD:
1241 printf(" BACKWARD ");
1242 break;
1243 case FETCH_ABSOLUTE:
1244 printf(" ABSOLUTE ");
1245 break;
1246 case FETCH_RELATIVE:
1247 printf(" RELATIVE ");
1248 break;
1249 default:
1250 printf("??? unknown cursor direction %d", stmt->direction);
1251 }
1252
1253 if (stmt->expr)
1254 {
1255 dump_expr(stmt->expr);
1256 printf("\n");
1257 }
1258 else
1259 printf("%ld\n", stmt->how_many);
1260
1261 dump_indent -= 2;
1262}
@ FETCH_RELATIVE
Definition: parsenodes.h:3415
@ FETCH_ABSOLUTE
Definition: parsenodes.h:3414
@ FETCH_FORWARD
Definition: parsenodes.h:3411
@ FETCH_BACKWARD
Definition: parsenodes.h:3412

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

1498{
1499 dump_ind();
1500 printf("EXECUTE ");
1501 dump_expr(stmt->query);
1502 printf("\n");
1503
1504 dump_indent += 2;
1505 if (stmt->target != NULL)
1506 {
1507 dump_ind();
1508 printf(" INTO%s target = %d %s\n",
1509 stmt->strict ? " STRICT" : "",
1510 stmt->target->dno, stmt->target->refname);
1511 }
1512 if (stmt->params != NIL)
1513 {
1514 ListCell *lc;
1515 int i;
1516
1517 dump_ind();
1518 printf(" USING\n");
1519 dump_indent += 2;
1520 i = 1;
1521 foreach(lc, stmt->params)
1522 {
1523 dump_ind();
1524 printf(" parameter %d: ", i++);
1525 dump_expr((PLpgSQL_expr *) lfirst(lc));
1526 printf("\n");
1527 }
1528 dump_indent -= 2;
1529 }
1530 dump_indent -= 2;
1531}
int i
Definition: isn.c:74
#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 1534 of file pl_funcs.c.

1535{
1536 dump_ind();
1537 printf("FORS %s EXECUTE ", stmt->var->refname);
1538 dump_expr(stmt->query);
1539 printf("\n");
1540 if (stmt->params != NIL)
1541 {
1542 ListCell *lc;
1543 int i;
1544
1545 dump_indent += 2;
1546 dump_ind();
1547 printf(" USING\n");
1548 dump_indent += 2;
1549 i = 1;
1550 foreach(lc, stmt->params)
1551 {
1552 dump_ind();
1553 printf(" parameter $%d: ", i++);
1554 dump_expr((PLpgSQL_expr *) lfirst(lc));
1555 printf("\n");
1556 }
1557 dump_indent -= 4;
1558 }
1559 dump_stmts(stmt->body);
1560 dump_ind();
1561 printf(" ENDFORS\n");
1562}

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

1479{
1480 dump_ind();
1481 printf("EXECSQL ");
1482 dump_expr(stmt->sqlstmt);
1483 printf("\n");
1484
1485 dump_indent += 2;
1486 if (stmt->target != NULL)
1487 {
1488 dump_ind();
1489 printf(" INTO%s target = %d %s\n",
1490 stmt->strict ? " STRICT" : "",
1491 stmt->target->dno, stmt->target->refname);
1492 }
1493 dump_indent -= 2;
1494}

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

1311{
1312 dump_ind();
1313 printf("%s", stmt->is_exit ? "EXIT" : "CONTINUE");
1314 if (stmt->label != NULL)
1315 printf(" label='%s'", stmt->label);
1316 if (stmt->cond != NULL)
1317 {
1318 printf(" WHEN ");
1319 dump_expr(stmt->cond);
1320 }
1321 printf("\n");
1322}

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

1206{
1207 dump_ind();
1208
1209 if (!stmt->is_move)
1210 {
1211 printf("FETCH curvar=%d\n", stmt->curvar);
1213
1214 dump_indent += 2;
1215 if (stmt->target != NULL)
1216 {
1217 dump_ind();
1218 printf(" target = %d %s\n",
1219 stmt->target->dno, stmt->target->refname);
1220 }
1221 dump_indent -= 2;
1222 }
1223 else
1224 {
1225 printf("MOVE curvar=%d\n", stmt->curvar);
1227 }
1228}
static void dump_cursor_direction(PLpgSQL_stmt_fetch *stmt)
Definition: pl_funcs.c:1231

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

1115{
1116 dump_ind();
1117 printf("FORC %s ", stmt->var->refname);
1118 printf("curvar=%d\n", stmt->curvar);
1119
1120 dump_indent += 2;
1121 if (stmt->argquery != NULL)
1122 {
1123 dump_ind();
1124 printf(" arguments = ");
1125 dump_expr(stmt->argquery);
1126 printf("\n");
1127 }
1128 dump_indent -= 2;
1129
1130 dump_stmts(stmt->body);
1131
1132 dump_ind();
1133 printf(" ENDFORC\n");
1134}

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

1138{
1139 dump_ind();
1140 printf("FOREACHA var %d ", stmt->varno);
1141 if (stmt->slice != 0)
1142 printf("SLICE %d ", stmt->slice);
1143 printf("IN ");
1144 dump_expr(stmt->expr);
1145 printf("\n");
1146
1147 dump_stmts(stmt->body);
1148
1149 dump_ind();
1150 printf(" ENDFOREACHA");
1151}

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

1071{
1072 dump_ind();
1073 printf("FORI %s %s\n", stmt->var->refname, (stmt->reverse) ? "REVERSE" : "NORMAL");
1074
1075 dump_indent += 2;
1076 dump_ind();
1077 printf(" lower = ");
1078 dump_expr(stmt->lower);
1079 printf("\n");
1080 dump_ind();
1081 printf(" upper = ");
1082 dump_expr(stmt->upper);
1083 printf("\n");
1084 if (stmt->step)
1085 {
1086 dump_ind();
1087 printf(" step = ");
1088 dump_expr(stmt->step);
1089 printf("\n");
1090 }
1091 dump_indent -= 2;
1092
1093 dump_stmts(stmt->body);
1094
1095 dump_ind();
1096 printf(" ENDFORI\n");
1097}

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

1101{
1102 dump_ind();
1103 printf("FORS %s ", stmt->var->refname);
1104 dump_expr(stmt->query);
1105 printf("\n");
1106
1107 dump_stmts(stmt->body);
1108
1109 dump_ind();
1110 printf(" ENDFORS\n");
1111}

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

1566{
1567 ListCell *lc;
1568
1569 dump_ind();
1570 printf("GET %s DIAGNOSTICS ", stmt->is_stacked ? "STACKED" : "CURRENT");
1571 foreach(lc, stmt->diag_items)
1572 {
1573 PLpgSQL_diag_item *diag_item = (PLpgSQL_diag_item *) lfirst(lc);
1574
1575 if (lc != list_head(stmt->diag_items))
1576 printf(", ");
1577
1578 printf("{var %d} = %s", diag_item->target,
1579 plpgsql_getdiag_kindname(diag_item->kind));
1580 }
1581 printf("\n");
1582}
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:599

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

977{
978 ListCell *l;
979
980 dump_ind();
981 printf("IF ");
982 dump_expr(stmt->cond);
983 printf(" THEN\n");
984 dump_stmts(stmt->then_body);
985 foreach(l, stmt->elsif_list)
986 {
988
989 dump_ind();
990 printf(" ELSIF ");
991 dump_expr(elif->cond);
992 printf(" THEN\n");
993 dump_stmts(elif->stmts);
994 }
995 if (stmt->else_body != NIL)
996 {
997 dump_ind();
998 printf(" ELSE\n");
999 dump_stmts(stmt->else_body);
1000 }
1001 dump_ind();
1002 printf(" ENDIF\n");
1003}
PLpgSQL_expr * cond
Definition: plpgsql.h:635
List * stmts
Definition: plpgsql.h:636

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

1045{
1046 dump_ind();
1047 printf("LOOP\n");
1048
1049 dump_stmts(stmt->body);
1050
1051 dump_ind();
1052 printf(" ENDLOOP\n");
1053}

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

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

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

1273{
1274 dump_ind();
1275 printf("PERFORM expr = ");
1276 dump_expr(stmt->expr);
1277 printf("\n");
1278}

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

1391{
1392 ListCell *lc;
1393 int i = 0;
1394
1395 dump_ind();
1396 printf("RAISE level=%d", stmt->elog_level);
1397 if (stmt->condname)
1398 printf(" condname='%s'", stmt->condname);
1399 if (stmt->message)
1400 printf(" message='%s'", stmt->message);
1401 printf("\n");
1402 dump_indent += 2;
1403 foreach(lc, stmt->params)
1404 {
1405 dump_ind();
1406 printf(" parameter %d: ", i++);
1407 dump_expr((PLpgSQL_expr *) lfirst(lc));
1408 printf("\n");
1409 }
1410 if (stmt->options)
1411 {
1412 dump_ind();
1413 printf(" USING\n");
1414 dump_indent += 2;
1415 foreach(lc, stmt->options)
1416 {
1418
1419 dump_ind();
1420 switch (opt->opt_type)
1421 {
1423 printf(" ERRCODE = ");
1424 break;
1426 printf(" MESSAGE = ");
1427 break;
1429 printf(" DETAIL = ");
1430 break;
1432 printf(" HINT = ");
1433 break;
1435 printf(" COLUMN = ");
1436 break;
1438 printf(" CONSTRAINT = ");
1439 break;
1441 printf(" DATATYPE = ");
1442 break;
1444 printf(" TABLE = ");
1445 break;
1447 printf(" SCHEMA = ");
1448 break;
1449 }
1450 dump_expr(opt->expr);
1451 printf("\n");
1452 }
1453 dump_indent -= 2;
1454 }
1455 dump_indent -= 2;
1456}
@ 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:897
PLpgSQL_expr * expr
Definition: plpgsql.h:898

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

1326{
1327 dump_ind();
1328 printf("RETURN ");
1329 if (stmt->retvarno >= 0)
1330 printf("variable %d", stmt->retvarno);
1331 else if (stmt->expr != NULL)
1332 dump_expr(stmt->expr);
1333 else
1334 printf("NULL");
1335 printf("\n");
1336}

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

1340{
1341 dump_ind();
1342 printf("RETURN NEXT ");
1343 if (stmt->retvarno >= 0)
1344 printf("variable %d", stmt->retvarno);
1345 else if (stmt->expr != NULL)
1346 dump_expr(stmt->expr);
1347 else
1348 printf("NULL");
1349 printf("\n");
1350}

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

1354{
1355 dump_ind();
1356 if (stmt->query)
1357 {
1358 printf("RETURN QUERY ");
1359 dump_expr(stmt->query);
1360 printf("\n");
1361 }
1362 else
1363 {
1364 printf("RETURN QUERY EXECUTE ");
1365 dump_expr(stmt->dynquery);
1366 printf("\n");
1367 if (stmt->params != NIL)
1368 {
1369 ListCell *lc;
1370 int i;
1371
1372 dump_indent += 2;
1373 dump_ind();
1374 printf(" USING\n");
1375 dump_indent += 2;
1376 i = 1;
1377 foreach(lc, stmt->params)
1378 {
1379 dump_ind();
1380 printf(" parameter $%d: ", i++);
1381 dump_expr((PLpgSQL_expr *) lfirst(lc));
1382 printf("\n");
1383 }
1384 dump_indent -= 4;
1385 }
1386 }
1387}

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

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

References dump_ind(), printf, and stmt.

Referenced by dump_stmt().

◆ dump_stmt()

static void dump_stmt ( PLpgSQL_stmt stmt)
static

Definition at line 822 of file pl_funcs.c.

823{
824 printf("%3d:", stmt->lineno);
825 switch (stmt->cmd_type)
826 {
829 break;
832 break;
833 case PLPGSQL_STMT_IF:
835 break;
838 break;
841 break;
844 break;
847 break;
850 break;
853 break;
856 break;
859 break;
862 break;
865 break;
868 break;
871 break;
874 break;
877 break;
880 break;
883 break;
886 break;
889 break;
892 break;
895 break;
898 break;
901 break;
904 break;
907 break;
908 default:
909 elog(ERROR, "unrecognized cmd_type: %d", stmt->cmd_type);
910 break;
911 }
912}
#define ERROR
Definition: elog.h:39
#define elog(elevel,...)
Definition: elog.h:225
static void dump_dynexecute(PLpgSQL_stmt_dynexecute *stmt)
Definition: pl_funcs.c:1497
static void dump_return_next(PLpgSQL_stmt_return_next *stmt)
Definition: pl_funcs.c:1339
static void dump_close(PLpgSQL_stmt_close *stmt)
Definition: pl_funcs.c:1265
static void dump_perform(PLpgSQL_stmt_perform *stmt)
Definition: pl_funcs.c:1272
static void dump_if(PLpgSQL_stmt_if *stmt)
Definition: pl_funcs.c:976
static void dump_fetch(PLpgSQL_stmt_fetch *stmt)
Definition: pl_funcs.c:1205
static void dump_execsql(PLpgSQL_stmt_execsql *stmt)
Definition: pl_funcs.c:1478
static void dump_case(PLpgSQL_stmt_case *stmt)
Definition: pl_funcs.c:1006
static void dump_open(PLpgSQL_stmt_open *stmt)
Definition: pl_funcs.c:1154
static void dump_assign(PLpgSQL_stmt_assign *stmt)
Definition: pl_funcs.c:967
static void dump_loop(PLpgSQL_stmt_loop *stmt)
Definition: pl_funcs.c:1044
static void dump_raise(PLpgSQL_stmt_raise *stmt)
Definition: pl_funcs.c:1390
static void dump_rollback(PLpgSQL_stmt_rollback *stmt)
Definition: pl_funcs.c:1300
static void dump_while(PLpgSQL_stmt_while *stmt)
Definition: pl_funcs.c:1056
static void dump_block(PLpgSQL_stmt_block *block)
Definition: pl_funcs.c:926
static void dump_getdiag(PLpgSQL_stmt_getdiag *stmt)
Definition: pl_funcs.c:1565
static void dump_exit(PLpgSQL_stmt_exit *stmt)
Definition: pl_funcs.c:1310
static void dump_call(PLpgSQL_stmt_call *stmt)
Definition: pl_funcs.c:1281
static void dump_forc(PLpgSQL_stmt_forc *stmt)
Definition: pl_funcs.c:1114
static void dump_commit(PLpgSQL_stmt_commit *stmt)
Definition: pl_funcs.c:1290
static void dump_return(PLpgSQL_stmt_return *stmt)
Definition: pl_funcs.c:1325
static void dump_foreach_a(PLpgSQL_stmt_foreach_a *stmt)
Definition: pl_funcs.c:1137
static void dump_return_query(PLpgSQL_stmt_return_query *stmt)
Definition: pl_funcs.c:1353
static void dump_assert(PLpgSQL_stmt_assert *stmt)
Definition: pl_funcs.c:1459
static void dump_dynfors(PLpgSQL_stmt_dynfors *stmt)
Definition: pl_funcs.c:1534
static void dump_fori(PLpgSQL_stmt_fori *stmt)
Definition: pl_funcs.c:1070
static void dump_fors(PLpgSQL_stmt_fors *stmt)
Definition: pl_funcs.c:1100
@ 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 915 of file pl_funcs.c.

916{
917 ListCell *s;
918
919 dump_indent += 2;
920 foreach(s, stmts)
922 dump_indent -= 2;
923}
static void dump_stmt(PLpgSQL_stmt *stmt)
Definition: pl_funcs.c:822

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

1057{
1058 dump_ind();
1059 printf("WHILE ");
1060 dump_expr(stmt->cond);
1061 printf("\n");
1062
1063 dump_stmts(stmt->body);
1064
1065 dump_ind();
1066 printf(" ENDWHILE\n");
1067}

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

Referenced by dump_stmt().

◆ free_expr()

static void free_expr ( PLpgSQL_expr expr,
void *  context 
)
static

Definition at line 706 of file pl_funcs.c.

707{
708 if (expr && expr->plan)
709 {
710 SPI_freeplan(expr->plan);
711 expr->plan = NULL;
712 }
713}
int SPI_freeplan(SPIPlanPtr plan)
Definition: spi.c:1026
SPIPlanPtr plan
Definition: plpgsql.h:250

References PLpgSQL_expr::plan, and SPI_freeplan().

Referenced by free_stmt(), and plpgsql_free_function_memory().

◆ free_stmt()

static void free_stmt ( PLpgSQL_stmt stmt,
void *  context 
)
static

Definition at line 698 of file pl_funcs.c.

699{
700 if (stmt == NULL)
701 return;
703}
static void free_stmt(PLpgSQL_stmt *stmt, void *context)
Definition: pl_funcs.c:698
static void free_expr(PLpgSQL_expr *expr, void *context)
Definition: pl_funcs.c:706
#define plpgsql_statement_tree_walker(s, sw, ew, c)
Definition: pl_funcs.c:359

References free_expr(), free_stmt(), plpgsql_statement_tree_walker, and stmt.

Referenced by free_stmt(), and plpgsql_free_function_memory().

◆ mark_expr()

static void mark_expr ( PLpgSQL_expr expr,
Bitmapset local_dnos 
)
static

Definition at line 662 of file pl_funcs.c.

663{
664 /*
665 * If this expression has an assignment target, check whether the target
666 * is local, and mark the expression accordingly.
667 */
668 if (expr && expr->target_param >= 0)
669 expr->target_is_local = bms_is_member(expr->target_param, local_dnos);
670}
bool bms_is_member(int x, const Bitmapset *a)
Definition: bitmapset.c:510

References bms_is_member(), PLpgSQL_expr::target_is_local, and PLpgSQL_expr::target_param.

Referenced by mark_stmt().

◆ mark_stmt()

static void mark_stmt ( PLpgSQL_stmt stmt,
Bitmapset local_dnos 
)
static

Definition at line 623 of file pl_funcs.c.

624{
625 if (stmt == NULL)
626 return;
627 if (stmt->cmd_type == PLPGSQL_STMT_BLOCK)
628 {
630
631 if (block->exceptions)
632 {
633 /*
634 * The block creates a new exception scope, so variables declared
635 * at outer levels are nonlocal. For that matter, so are any
636 * variables declared in the block's DECLARE section. Hence, we
637 * must pass down empty local_dnos.
638 */
640 }
641 else
642 {
643 /*
644 * Otherwise, the block does not create a new exception scope, and
645 * any variables it declares can also be considered local within
646 * it. Note that only initializable datum types (VAR, REC) are
647 * included in initvarnos; but that's sufficient for our purposes.
648 */
649 local_dnos = bms_copy(local_dnos);
650 for (int i = 0; i < block->n_initvars; i++)
651 local_dnos = bms_add_member(local_dnos, block->initvarnos[i]);
653 local_dnos);
654 bms_free(local_dnos);
655 }
656 }
657 else
659}
void bms_free(Bitmapset *a)
Definition: bitmapset.c:239
Bitmapset * bms_add_member(Bitmapset *a, int x)
Definition: bitmapset.c:815
Bitmapset * bms_copy(const Bitmapset *a)
Definition: bitmapset.c:122
static void mark_stmt(PLpgSQL_stmt *stmt, Bitmapset *local_dnos)
Definition: pl_funcs.c:623
static void mark_expr(PLpgSQL_expr *expr, Bitmapset *local_dnos)
Definition: pl_funcs.c:662

References bms_add_member(), bms_copy(), bms_free(), PLpgSQL_stmt_block::exceptions, i, PLpgSQL_stmt_block::initvarnos, mark_expr(), mark_stmt(), PLpgSQL_stmt_block::n_initvars, plpgsql_statement_tree_walker, PLPGSQL_STMT_BLOCK, and stmt.

Referenced by mark_stmt(), and plpgsql_mark_local_assignment_targets().

◆ plpgsql_dumptree()

void plpgsql_dumptree ( PLpgSQL_function func)

Definition at line 1594 of file pl_funcs.c.

1595{
1596 int i;
1597 PLpgSQL_datum *d;
1598
1599 printf("\nExecution tree of successfully compiled PL/pgSQL function %s:\n",
1600 func->fn_signature);
1601
1602 printf("\nFunction's data area:\n");
1603 for (i = 0; i < func->ndatums; i++)
1604 {
1605 d = func->datums[i];
1606
1607 printf(" entry %d: ", i);
1608 switch (d->dtype)
1609 {
1610 case PLPGSQL_DTYPE_VAR:
1612 {
1613 PLpgSQL_var *var = (PLpgSQL_var *) d;
1614
1615 printf("VAR %-16s type %s (typoid %u) atttypmod %d\n",
1616 var->refname, var->datatype->typname,
1617 var->datatype->typoid,
1618 var->datatype->atttypmod);
1619 if (var->isconst)
1620 printf(" CONSTANT\n");
1621 if (var->notnull)
1622 printf(" NOT NULL\n");
1623 if (var->default_val != NULL)
1624 {
1625 printf(" DEFAULT ");
1626 dump_expr(var->default_val);
1627 printf("\n");
1628 }
1629 if (var->cursor_explicit_expr != NULL)
1630 {
1631 if (var->cursor_explicit_argrow >= 0)
1632 printf(" CURSOR argument row %d\n", var->cursor_explicit_argrow);
1633
1634 printf(" CURSOR IS ");
1636 printf("\n");
1637 }
1638 if (var->promise != PLPGSQL_PROMISE_NONE)
1639 printf(" PROMISE %d\n",
1640 (int) var->promise);
1641 }
1642 break;
1643 case PLPGSQL_DTYPE_ROW:
1644 {
1645 PLpgSQL_row *row = (PLpgSQL_row *) d;
1646
1647 printf("ROW %-16s fields", row->refname);
1648 for (int j = 0; j < row->nfields; j++)
1649 {
1650 printf(" %s=var %d", row->fieldnames[j],
1651 row->varnos[j]);
1652 }
1653 printf("\n");
1654 }
1655 break;
1656 case PLPGSQL_DTYPE_REC:
1657 printf("REC %-16s typoid %u\n",
1658 ((PLpgSQL_rec *) d)->refname,
1659 ((PLpgSQL_rec *) d)->rectypeid);
1660 if (((PLpgSQL_rec *) d)->isconst)
1661 printf(" CONSTANT\n");
1662 if (((PLpgSQL_rec *) d)->notnull)
1663 printf(" NOT NULL\n");
1664 if (((PLpgSQL_rec *) d)->default_val != NULL)
1665 {
1666 printf(" DEFAULT ");
1667 dump_expr(((PLpgSQL_rec *) d)->default_val);
1668 printf("\n");
1669 }
1670 break;
1672 printf("RECFIELD %-16s of REC %d\n",
1673 ((PLpgSQL_recfield *) d)->fieldname,
1674 ((PLpgSQL_recfield *) d)->recparentno);
1675 break;
1676 default:
1677 printf("??? unknown data type %d\n", d->dtype);
1678 }
1679 }
1680 printf("\nFunction's statements:\n");
1681
1682 dump_indent = 0;
1683 printf("%3d:", func->action->lineno);
1684 dump_block(func->action);
1685 printf("\nEnd of execution tree of function %s\n\n", func->fn_signature);
1686 fflush(stdout);
1687}
int j
Definition: isn.c:75
@ 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:299
PLpgSQL_stmt_block * action
Definition: plpgsql.h:1032
PLpgSQL_datum ** datums
Definition: plpgsql.h:1028
char * fn_signature
Definition: plpgsql.h:993
PLpgSQL_datum_type dtype
Definition: plpgsql.h:444
int * varnos
Definition: plpgsql.h:405
char * refname
Definition: plpgsql.h:389
char ** fieldnames
Definition: plpgsql.h:404
int nfields
Definition: plpgsql.h:403
Oid typoid
Definition: plpgsql.h:212
char * typname
Definition: plpgsql.h:211
int32 atttypmod
Definition: plpgsql.h:219
PLpgSQL_promise_type promise
Definition: plpgsql.h:364
int cursor_explicit_argrow
Definition: plpgsql.h:350
bool notnull
Definition: plpgsql.h:338
bool isconst
Definition: plpgsql.h:337
PLpgSQL_expr * cursor_explicit_expr
Definition: plpgsql.h:349
PLpgSQL_type * datatype
Definition: plpgsql.h:342
PLpgSQL_expr * default_val
Definition: plpgsql.h:339
char * refname
Definition: plpgsql.h:335

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

◆ plpgsql_free_function_memory()

void plpgsql_free_function_memory ( PLpgSQL_function func)

Definition at line 716 of file pl_funcs.c.

717{
718 int i;
719
720 /* Better not call this on an in-use function */
721 Assert(func->use_count == 0);
722
723 /* Release plans associated with variable declarations */
724 for (i = 0; i < func->ndatums; i++)
725 {
726 PLpgSQL_datum *d = func->datums[i];
727
728 switch (d->dtype)
729 {
732 {
733 PLpgSQL_var *var = (PLpgSQL_var *) d;
734
735 free_expr(var->default_val, NULL);
737 }
738 break;
740 break;
742 {
743 PLpgSQL_rec *rec = (PLpgSQL_rec *) d;
744
745 free_expr(rec->default_val, NULL);
746 }
747 break;
749 break;
750 default:
751 elog(ERROR, "unrecognized data type: %d", d->dtype);
752 }
753 }
754 func->ndatums = 0;
755
756 /* Release plans in statement tree */
757 free_stmt((PLpgSQL_stmt *) func->action, NULL);
758 func->action = NULL;
759
760 /*
761 * And finally, release all memory except the PLpgSQL_function struct
762 * itself (which has to be kept around because there may be multiple
763 * fn_extra pointers to it).
764 */
765 if (func->fn_cxt)
767 func->fn_cxt = NULL;
768}
Assert(PointerIsAligned(start, uint64))
void MemoryContextDelete(MemoryContext context)
Definition: mcxt.c:454
unsigned long use_count
Definition: plpgsql.h:1041
MemoryContext fn_cxt
Definition: plpgsql.h:1000
PLpgSQL_expr * default_val
Definition: plpgsql.h:419

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_expr(), free_stmt(), 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_mark_local_assignment_targets()

void plpgsql_mark_local_assignment_targets ( PLpgSQL_function func)

Definition at line 673 of file pl_funcs.c.

674{
675 Bitmapset *local_dnos;
676
677 /* Function parameters can be treated as local targets at outer level */
678 local_dnos = NULL;
679 for (int i = 0; i < func->fn_nargs; i++)
680 local_dnos = bms_add_member(local_dnos, func->fn_argvarnos[i]);
681 mark_stmt((PLpgSQL_stmt *) func->action, local_dnos);
682 bms_free(local_dnos);
683}
int fn_argvarnos[FUNC_MAX_ARGS]
Definition: plpgsql.h:1012

References PLpgSQL_function::action, bms_add_member(), bms_free(), PLpgSQL_function::fn_argvarnos, PLpgSQL_function::fn_nargs, i, and mark_stmt().

Referenced by do_compile(), and plpgsql_compile_inline().

◆ 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:1317
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:469
struct PLpgSQL_nsitem * prev
Definition: plpgsql.h:468
PLpgSQL_nsitem_type itemtype
Definition: plpgsql.h:461

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;
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;
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);
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 = "";
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_statement_tree_walker_impl()

static void plpgsql_statement_tree_walker_impl ( PLpgSQL_stmt stmt,
plpgsql_stmt_walker_callback  stmt_callback,
plpgsql_expr_walker_callback  expr_callback,
void *  context 
)
static

Definition at line 364 of file pl_funcs.c.

368{
369#define S_WALK(st) stmt_callback(st, context)
370#define E_WALK(ex) expr_callback(ex, context)
371#define S_LIST_WALK(lst) foreach_ptr(PLpgSQL_stmt, st, lst) S_WALK(st)
372#define E_LIST_WALK(lst) foreach_ptr(PLpgSQL_expr, ex, lst) E_WALK(ex)
373
374 switch (stmt->cmd_type)
375 {
377 {
379
380 S_LIST_WALK(bstmt->body);
381 if (bstmt->exceptions)
382 {
384 {
385 /* conditions list has no interesting sub-structure */
386 S_LIST_WALK(exc->action);
387 }
388 }
389 break;
390 }
392 {
394
395 E_WALK(astmt->expr);
396 break;
397 }
398 case PLPGSQL_STMT_IF:
399 {
401
402 E_WALK(ifstmt->cond);
403 S_LIST_WALK(ifstmt->then_body);
404 foreach_ptr(PLpgSQL_if_elsif, elif, ifstmt->elsif_list)
405 {
406 E_WALK(elif->cond);
407 S_LIST_WALK(elif->stmts);
408 }
409 S_LIST_WALK(ifstmt->else_body);
410 break;
411 }
413 {
415
416 E_WALK(cstmt->t_expr);
418 {
419 E_WALK(cwt->expr);
420 S_LIST_WALK(cwt->stmts);
421 }
422 S_LIST_WALK(cstmt->else_stmts);
423 break;
424 }
426 {
428
429 S_LIST_WALK(lstmt->body);
430 break;
431 }
433 {
435
436 E_WALK(wstmt->cond);
437 S_LIST_WALK(wstmt->body);
438 break;
439 }
441 {
443
444 E_WALK(fori->lower);
445 E_WALK(fori->upper);
446 E_WALK(fori->step);
447 S_LIST_WALK(fori->body);
448 break;
449 }
451 {
453
454 S_LIST_WALK(fors->body);
455 E_WALK(fors->query);
456 break;
457 }
459 {
461
462 S_LIST_WALK(forc->body);
463 E_WALK(forc->argquery);
464 break;
465 }
467 {
469
470 E_WALK(fstmt->expr);
471 S_LIST_WALK(fstmt->body);
472 break;
473 }
475 {
477
478 E_WALK(estmt->cond);
479 break;
480 }
482 {
484
485 E_WALK(rstmt->expr);
486 break;
487 }
489 {
491
492 E_WALK(rstmt->expr);
493 break;
494 }
496 {
498
499 E_WALK(rstmt->query);
500 E_WALK(rstmt->dynquery);
501 E_LIST_WALK(rstmt->params);
502 break;
503 }
505 {
507
508 E_LIST_WALK(rstmt->params);
510 {
511 E_WALK(opt->expr);
512 }
513 break;
514 }
516 {
518
519 E_WALK(astmt->cond);
520 E_WALK(astmt->message);
521 break;
522 }
524 {
526
527 E_WALK(xstmt->sqlstmt);
528 break;
529 }
531 {
533
534 E_WALK(dstmt->query);
535 E_LIST_WALK(dstmt->params);
536 break;
537 }
539 {
541
542 S_LIST_WALK(dstmt->body);
543 E_WALK(dstmt->query);
544 E_LIST_WALK(dstmt->params);
545 break;
546 }
548 {
549 /* no interesting sub-structure */
550 break;
551 }
553 {
555
556 E_WALK(ostmt->argquery);
557 E_WALK(ostmt->query);
558 E_WALK(ostmt->dynquery);
559 E_LIST_WALK(ostmt->params);
560 break;
561 }
563 {
565
566 E_WALK(fstmt->expr);
567 break;
568 }
570 {
571 /* no interesting sub-structure */
572 break;
573 }
575 {
577
578 E_WALK(pstmt->expr);
579 break;
580 }
582 {
584
585 E_WALK(cstmt->expr);
586 break;
587 }
590 {
591 /* no interesting sub-structure */
592 break;
593 }
594 default:
595 elog(ERROR, "unrecognized cmd_type: %d", stmt->cmd_type);
596 break;
597 }
598}
#define ifstmt
Definition: indent_codes.h:56
#define foreach_ptr(type, var, lst)
Definition: pg_list.h:469
#define E_LIST_WALK(lst)
#define S_LIST_WALK(lst)
#define E_WALK(ex)
PLpgSQL_expr * cond
Definition: plpgsql.h:909
PLpgSQL_expr * message
Definition: plpgsql.h:910
PLpgSQL_expr * expr
Definition: plpgsql.h:545
PLpgSQL_expr * expr
Definition: plpgsql.h:567
List * case_when_list
Definition: plpgsql.h:649
List * else_stmts
Definition: plpgsql.h:651
PLpgSQL_expr * t_expr
Definition: plpgsql.h:647
PLpgSQL_expr * query
Definition: plpgsql.h:937
PLpgSQL_expr * query
Definition: plpgsql.h:764
PLpgSQL_expr * sqlstmt
Definition: plpgsql.h:921
PLpgSQL_expr * cond
Definition: plpgsql.h:837
PLpgSQL_expr * expr
Definition: plpgsql.h:811
PLpgSQL_expr * argquery
Definition: plpgsql.h:749
PLpgSQL_expr * expr
Definition: plpgsql.h:779
PLpgSQL_expr * upper
Definition: plpgsql.h:700
PLpgSQL_expr * lower
Definition: plpgsql.h:699
PLpgSQL_expr * step
Definition: plpgsql.h:701
PLpgSQL_expr * query
Definition: plpgsql.h:733
PLpgSQL_expr * argquery
Definition: plpgsql.h:793
PLpgSQL_expr * dynquery
Definition: plpgsql.h:795
PLpgSQL_expr * query
Definition: plpgsql.h:794
PLpgSQL_expr * expr
Definition: plpgsql.h:556
PLpgSQL_expr * expr
Definition: plpgsql.h:860
PLpgSQL_expr * dynquery
Definition: plpgsql.h:873
PLpgSQL_expr * query
Definition: plpgsql.h:872
PLpgSQL_expr * expr
Definition: plpgsql.h:848
PLpgSQL_expr * cond
Definition: plpgsql.h:685

References PLpgSQL_stmt_forc::argquery, PLpgSQL_stmt_open::argquery, PLpgSQL_stmt_block::body, PLpgSQL_stmt_loop::body, PLpgSQL_stmt_while::body, PLpgSQL_stmt_fori::body, PLpgSQL_stmt_fors::body, PLpgSQL_stmt_forc::body, PLpgSQL_stmt_dynfors::body, PLpgSQL_stmt_foreach_a::body, PLpgSQL_stmt_case::case_when_list, PLpgSQL_stmt_while::cond, PLpgSQL_stmt_exit::cond, PLpgSQL_stmt_assert::cond, PLpgSQL_stmt_open::dynquery, PLpgSQL_stmt_return_query::dynquery, E_LIST_WALK, E_WALK, elog, PLpgSQL_stmt_case::else_stmts, ERROR, PLpgSQL_exception_block::exc_list, PLpgSQL_stmt_block::exceptions, PLpgSQL_stmt_assign::expr, PLpgSQL_stmt_perform::expr, PLpgSQL_stmt_call::expr, PLpgSQL_stmt_foreach_a::expr, PLpgSQL_stmt_fetch::expr, PLpgSQL_stmt_return::expr, PLpgSQL_stmt_return_next::expr, foreach_ptr, ifstmt, PLpgSQL_stmt_fori::lower, PLpgSQL_stmt_assert::message, PLpgSQL_stmt_raise::options, PLpgSQL_stmt_dynfors::params, PLpgSQL_stmt_open::params, PLpgSQL_stmt_return_query::params, PLpgSQL_stmt_raise::params, PLpgSQL_stmt_dynexecute::params, 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, PLpgSQL_stmt_fors::query, PLpgSQL_stmt_dynfors::query, PLpgSQL_stmt_open::query, PLpgSQL_stmt_return_query::query, PLpgSQL_stmt_dynexecute::query, S_LIST_WALK, PLpgSQL_stmt_execsql::sqlstmt, PLpgSQL_stmt_fori::step, stmt, PLpgSQL_stmt_case::t_expr, and PLpgSQL_stmt_fori::upper.

◆ 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 {
237 return _("statement block");
239 return _("assignment");
240 case PLPGSQL_STMT_IF:
241 return "IF";
243 return "CASE";
245 return "LOOP";
247 return "WHILE";
249 return _("FOR with integer loop variable");
251 return _("FOR over SELECT rows");
253 return _("FOR over cursor");
255 return _("FOREACH over array");
257 return ((PLpgSQL_stmt_exit *) stmt)->is_exit ? "EXIT" : "CONTINUE";
259 return "RETURN";
261 return "RETURN NEXT";
263 return "RETURN QUERY";
265 return "RAISE";
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";
278 return "OPEN";
280 return ((PLpgSQL_stmt_fetch *) stmt)->is_move ? "MOVE" : "FETCH";
282 return "CLOSE";
284 return "PERFORM";
286 return ((PLpgSQL_stmt_call *) stmt)->is_call ? "CALL" : "DO";
288 return "COMMIT";
290 return "ROLLBACK";
291 }
292
293 return "unknown";
294}
#define _(x)
Definition: elog.c:90

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