/src/tarantool/src/box/sql/parse_def.c
Line | Count | Source |
1 | | /* |
2 | | * Copyright 2010-2019, Tarantool AUTHORS, please see AUTHORS file. |
3 | | * |
4 | | * Redistribution and use in source and binary forms, with or |
5 | | * without modification, are permitted provided that the following |
6 | | * conditions are met: |
7 | | * |
8 | | * 1. Redistributions of source code must retain the above |
9 | | * copyright notice, this list of conditions and the |
10 | | * following disclaimer. |
11 | | * |
12 | | * 2. Redistributions in binary form must reproduce the above |
13 | | * copyright notice, this list of conditions and the following |
14 | | * disclaimer in the documentation and/or other materials |
15 | | * provided with the distribution. |
16 | | * |
17 | | * THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND |
18 | | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
19 | | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
20 | | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
21 | | * <COPYRIGHT HOLDER> OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
22 | | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
23 | | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
24 | | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
25 | | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
26 | | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 | | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF |
28 | | * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
29 | | * SUCH DAMAGE. |
30 | | */ |
31 | | #include <string.h> |
32 | | |
33 | | #include "sqlInt.h" |
34 | | |
35 | | const struct Token sqlIntTokens[] = { |
36 | | {"0", 1, false}, |
37 | | {"1", 1, false}, |
38 | | {"2", 1, false}, |
39 | | {"3", 1, false}, |
40 | | }; |
41 | | |
42 | | void |
43 | | sqlTokenInit(struct Token *p, char *z) |
44 | 2.75M | { |
45 | 2.75M | p->z = z; |
46 | 2.75M | p->n = z == NULL ? 0 : strlen(z); |
47 | 2.75M | } |
48 | | |
49 | | void |
50 | | sql_ast_init_start_transaction(struct Parse *parse) |
51 | 0 | { |
52 | 0 | assert(parse->ast.type == SQL_AST_TYPE_UNKNOWN); |
53 | 0 | parse->ast.type = SQL_AST_TYPE_START_TRANSACTION; |
54 | 0 | } |
55 | | |
56 | | void |
57 | | sql_ast_init_commit(struct Parse *parse) |
58 | 0 | { |
59 | 0 | assert(parse->ast.type == SQL_AST_TYPE_UNKNOWN); |
60 | 0 | parse->ast.type = SQL_AST_TYPE_COMMIT; |
61 | 0 | } |
62 | | |
63 | | void |
64 | | sql_ast_init_rollback(struct Parse *parse) |
65 | 0 | { |
66 | 0 | assert(parse->ast.type == SQL_AST_TYPE_UNKNOWN); |
67 | 0 | parse->ast.type = SQL_AST_TYPE_ROLLBACK; |
68 | 0 | } |
69 | | |
70 | | void |
71 | | sql_ast_init_savepoint(struct Parse *parse, const struct Token *name) |
72 | 0 | { |
73 | 0 | assert(parse->ast.type == SQL_AST_TYPE_UNKNOWN); |
74 | 0 | parse->ast.type = SQL_AST_TYPE_SAVEPOINT; |
75 | 0 | parse->ast.savepoint.name = *name; |
76 | 0 | } |
77 | | |
78 | | void |
79 | | sql_ast_init_release_savepoint(struct Parse *parse, const struct Token *name) |
80 | 0 | { |
81 | 0 | assert(parse->ast.type == SQL_AST_TYPE_UNKNOWN); |
82 | 0 | parse->ast.type = SQL_AST_TYPE_RELEASE_SAVEPOINT; |
83 | 0 | parse->ast.savepoint.name = *name; |
84 | 0 | } |
85 | | |
86 | | void |
87 | | sql_ast_init_rollback_to_savepoint(struct Parse *parse, |
88 | | const struct Token *name) |
89 | 0 | { |
90 | 0 | assert(parse->ast.type == SQL_AST_TYPE_UNKNOWN); |
91 | 0 | parse->ast.type = SQL_AST_TYPE_ROLLBACK_TO_SAVEPOINT; |
92 | 0 | parse->ast.savepoint.name = *name; |
93 | 0 | } |