File: delete.result

package info (click to toggle)
tarantool 2.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 85,364 kB
  • sloc: ansic: 513,760; cpp: 69,489; sh: 25,650; python: 19,190; perl: 14,973; makefile: 4,173; yacc: 1,329; sql: 1,074; pascal: 620; ruby: 190; awk: 18; lisp: 7
file content (193 lines) | stat: -rw-r--r-- 3,415 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
test_run = require('test_run').new()
---
...
engine = test_run:get_cfg('engine')
---
...
_ = box.space._session_settings:update('sql_default_engine', {{'=', 2, engine}})
---
...
-- box.cfg()
-- create space
box.execute("CREATE TABLE t1(a INT, b INT, PRIMARY KEY(a, b));");
---
- row_count: 1
...
-- Seed entries
box.execute("INSERT INTO t1 VALUES(1, 2);");
---
- row_count: 1
...
box.execute("INSERT INTO t1 VALUES(2, 4);");
---
- row_count: 1
...
box.execute("INSERT INTO t1 VALUES(1, 5);");
---
- row_count: 1
...
-- Two rows to be removed.
box.execute("DELETE FROM t1 WHERE a=1;");
---
- row_count: 2
...
-- Verify
box.execute("SELECT * FROM t1;");
---
- metadata:
  - name: A
    type: integer
  - name: B
    type: integer
  rows:
  - [2, 4]
...
-- Cleanup
box.execute("DROP TABLE t1;");
---
- row_count: 1
...
-- Debug
-- require("console").start()
--
-- gh-3535: Assertion with trigger and non existent table
--
box.execute("DELETE FROM t1;")
---
- null
- Space 'T1' does not exist
...
box.execute("CREATE TABLE t2 (s1 INT PRIMARY KEY);")
---
- row_count: 1
...
box.execute("CREATE TRIGGER t2 BEFORE INSERT ON t2 FOR EACH ROW BEGIN DELETE FROM t1; END;")
---
- row_count: 1
...
box.execute("INSERT INTO t2 VALUES (0);")
---
- null
- Space 'T1' does not exist
...
box.execute("DROP TABLE t2;")
---
- row_count: 1
...
--
-- gh-2201: TRUNCATE TABLE operation.
--
-- can't truncate system table.
box.execute("TRUNCATE TABLE \"_fk_constraint\";")
---
- null
- Can't truncate a system space, space '_fk_constraint'
...
box.execute("CREATE TABLE t1(id INT PRIMARY KEY, a INT, b TEXT);")
---
- row_count: 1
...
box.execute("INSERT INTO t1 VALUES(1, 1, 'one');")
---
- row_count: 1
...
box.execute("INSERT INTO t1 VALUES(2, 2, 'two');")
---
- row_count: 1
...
-- Truncate rollback
box.execute("START TRANSACTION")
---
- row_count: 0
...
box.execute("TRUNCATE TABLE t1;")
---
- row_count: 0
...
box.execute("ROLLBACK")
---
- row_count: 0
...
box.execute("SELECT * FROM t1")
---
- metadata:
  - name: ID
    type: integer
  - name: A
    type: integer
  - name: B
    type: string
  rows:
  - [1, 1, 'one']
  - [2, 2, 'two']
...
-- Can't truncate view.
box.execute("CREATE VIEW v1 AS SELECT * FROM t1;")
---
- row_count: 1
...
box.execute("TRUNCATE TABLE v1;")
---
- null
- 'Failed to execute SQL statement: can not truncate space ''V1'' because space is
  a view'
...
-- Can't truncate table with FK.
box.execute("CREATE TABLE t2(x INT PRIMARY KEY REFERENCES t1(id));")
---
- row_count: 1
...
box.execute("TRUNCATE TABLE t1;")
---
- null
- 'Failed to execute SQL statement: can not truncate space ''T1'' because other objects
  depend on it'
...
-- Table triggers should be ignored.
box.execute("DROP TABLE t2;")
---
- row_count: 1
...
box.execute("CREATE TABLE t2(x INT PRIMARY KEY);")
---
- row_count: 1
...
box.execute("CREATE TRIGGER trig2 BEFORE DELETE ON t1 FOR EACH ROW BEGIN INSERT INTO t2 VALUES(old.x); END;")
---
- row_count: 1
...
box.execute("TRUNCATE TABLE t1;")
---
- row_count: 0
...
box.execute("SELECT * FROM t1;")
---
- metadata:
  - name: ID
    type: integer
  - name: A
    type: integer
  - name: B
    type: string
  rows: []
...
box.execute("SELECT * FROM t2;")
---
- metadata:
  - name: X
    type: integer
  rows: []
...
-- Cleanup.
box.execute("DROP VIEW v1");
---
- row_count: 1
...
box.execute("DROP TABLE t1;")
---
- row_count: 1
...
box.execute("DROP TABLE t2;")
---
- row_count: 1
...