1 | /* |
2 | * This Source Code Form is subject to the terms of the Mozilla Public |
3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
5 | * |
6 | * Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V. |
7 | */ |
8 | |
9 | #ifndef SQL_STACK_H |
10 | #define SQL_STACK_H |
11 | |
12 | /* sql_stack implementation |
13 | * used by mvc structure for variable stack |
14 | * trigger stack |
15 | * Multi statement stack (intermediate results) |
16 | * .... |
17 | * stmt generation |
18 | * stmt dependency (close to stmt generation) |
19 | */ |
20 | |
21 | #include "sql_mem.h" |
22 | |
23 | typedef struct sql_stack { |
24 | sql_allocator *sa; |
25 | int size; |
26 | int top; |
27 | void **values; |
28 | } sql_stack; |
29 | |
30 | extern sql_stack *sql_stack_new(sql_allocator *sa, int size); |
31 | extern void sql_stack_push(sql_stack *s, void *v); |
32 | extern void *sql_stack_pop(sql_stack *s); |
33 | extern void *sql_stack_peek(sql_stack *s, int pos); /* top == pos 0 */ |
34 | extern void *sql_stack_fetch(sql_stack *s, int pos); /* pos 0 is bottom of the stack */ |
35 | extern int sql_stack_top(sql_stack *s); |
36 | extern int sql_stack_empty(sql_stack *s); |
37 | |
38 | #endif /* SQL_STACK_H */ |
39 | |