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 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
|
test_run = require('test_run').new()
---
...
engine = test_run:get_cfg('engine')
---
...
_ = box.space._session_settings:update('sql_default_engine', {{'=', 2, engine}})
---
...
--
-- Check that original sql ON CONFLICT clause is really
-- disabled.
--
box.execute("CREATE TABLE t (id INTEGER PRIMARY KEY, v INTEGER UNIQUE ON CONFLICT ABORT)")
---
- null
- 'At line 1 at or near position 58: keyword ''ON'' is reserved. Please use double
quotes if ''ON'' is an identifier.'
...
box.execute("CREATE TABLE q (id INTEGER PRIMARY KEY, v INTEGER UNIQUE ON CONFLICT FAIL)")
---
- null
- 'At line 1 at or near position 58: keyword ''ON'' is reserved. Please use double
quotes if ''ON'' is an identifier.'
...
box.execute("CREATE TABLE p (id INTEGER PRIMARY KEY, v INTEGER UNIQUE ON CONFLICT IGNORE)")
---
- null
- 'At line 1 at or near position 58: keyword ''ON'' is reserved. Please use double
quotes if ''ON'' is an identifier.'
...
box.execute("CREATE TABLE g (id INTEGER PRIMARY KEY, v INTEGER UNIQUE ON CONFLICT REPLACE)")
---
- null
- 'At line 1 at or near position 58: keyword ''ON'' is reserved. Please use double
quotes if ''ON'' is an identifier.'
...
box.execute("CREATE TABLE e (id INTEGER PRIMARY KEY ON CONFLICT REPLACE, v INTEGER)")
---
- null
- 'At line 1 at or near position 40: keyword ''ON'' is reserved. Please use double
quotes if ''ON'' is an identifier.'
...
box.execute("CREATE TABLE t1(a INT PRIMARY KEY ON CONFLICT REPLACE)")
---
- null
- 'At line 1 at or near position 35: keyword ''ON'' is reserved. Please use double
quotes if ''ON'' is an identifier.'
...
box.execute("CREATE TABLE t2(a INT PRIMARY KEY ON CONFLICT IGNORE)")
---
- null
- 'At line 1 at or near position 35: keyword ''ON'' is reserved. Please use double
quotes if ''ON'' is an identifier.'
...
-- CHECK constraint is illegal with REPLACE option.
--
box.execute("CREATE TABLE t (id INTEGER PRIMARY KEY, a INTEGER CHECK (a > 5) ON CONFLICT REPLACE);")
---
- null
- 'At line 1 at or near position 65: keyword ''ON'' is reserved. Please use double
quotes if ''ON'' is an identifier.'
...
--
-- gh-3473: Primary key can't be declared with NULL.
--
box.execute("CREATE TABLE te17 (s1 INT NULL PRIMARY KEY NOT NULL);")
---
- null
- Primary index of space 'TE17' can not contain nullable parts
...
box.execute("CREATE TABLE te17 (s1 INT NULL PRIMARY KEY);")
---
- null
- Primary index of space 'TE17' can not contain nullable parts
...
box.execute("CREATE TABLE test (a int PRIMARY KEY, b int NULL ON CONFLICT IGNORE);")
---
- null
- 'Failed to execute SQL statement: NULL declaration for column ''B'' of table ''TEST''
has been already set to ''none'''
...
box.execute("CREATE TABLE test (a int, b int NULL, c int, PRIMARY KEY(a, b, c))")
---
- null
- Primary index of space 'TEST' can not contain nullable parts
...
-- Several NOT NULL REPLACE constraints work
--
box.execute("CREATE TABLE a (id INT PRIMARY KEY, a INT NOT NULL ON CONFLICT REPLACE DEFAULT 1, b INT NOT NULL ON CONFLICT REPLACE DEFAULT 2);")
---
- row_count: 1
...
box.execute("INSERT INTO a VALUES(1, NULL, NULL);")
---
- row_count: 1
...
box.execute("INSERT INTO a VALUES(2, NULL, NULL);")
---
- row_count: 1
...
box.execute("SELECT * FROM a;")
---
- metadata:
- name: ID
type: integer
- name: A
type: integer
- name: B
type: integer
rows:
- [1, 1, 2]
- [2, 1, 2]
...
box.execute("DROP TABLE a;")
---
- row_count: 1
...
-- gh-3566: UPDATE OR IGNORE causes deletion of old entry.
--
box.execute("CREATE TABLE tj (s0 INT PRIMARY KEY, s1 INT UNIQUE, s2 INT);")
---
- row_count: 1
...
box.execute("INSERT INTO tj VALUES (1, 1, 2), (2, 2, 3);")
---
- row_count: 2
...
box.execute("CREATE UNIQUE INDEX i ON tj (s2);")
---
- row_count: 1
...
box.execute("UPDATE OR IGNORE tj SET s1 = s1 + 1;")
---
- row_count: 1
...
box.execute("SELECT s1, s2 FROM tj;")
---
- metadata:
- name: S1
type: integer
- name: S2
type: integer
rows:
- [1, 2]
- [3, 3]
...
box.execute("UPDATE OR IGNORE tj SET s2 = s2 + 1;")
---
- row_count: 1
...
box.execute("SELECT s1, s2 FROM tj;")
---
- metadata:
- name: S1
type: integer
- name: S2
type: integer
rows:
- [1, 2]
- [3, 4]
...
-- gh-3565: INSERT OR REPLACE causes assertion fault.
--
box.execute("DROP TABLE tj;")
---
- row_count: 1
...
box.execute("CREATE TABLE tj (s1 INT PRIMARY KEY, s2 INT);")
---
- row_count: 1
...
box.execute("INSERT INTO tj VALUES (1, 2),(2, 3);")
---
- row_count: 2
...
box.execute("CREATE UNIQUE INDEX i ON tj (s2);")
---
- row_count: 1
...
box.execute("REPLACE INTO tj VALUES (1, 3);")
---
- row_count: 3
...
box.execute("SELECT * FROM tj;")
---
- metadata:
- name: S1
type: integer
- name: S2
type: integer
rows:
- [1, 3]
...
box.execute("INSERT INTO tj VALUES (2, 4), (3, 5);")
---
- row_count: 2
...
box.execute("UPDATE OR REPLACE tj SET s2 = s2 + 1;")
---
- row_count: 5
...
box.execute("SELECT * FROM tj;")
---
- metadata:
- name: S1
type: integer
- name: S2
type: integer
rows:
- [1, 4]
- [3, 6]
...
box.execute("DROP TABLE tj;")
---
- row_count: 1
...
|