File: index.inc

package info (click to toggle)
mariadb-10.3 1%3A10.3.34-0%2Bdeb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 531,600 kB
  • sloc: cpp: 1,415,326; ansic: 917,243; perl: 58,570; sh: 43,538; pascal: 39,206; java: 33,919; yacc: 32,096; javascript: 15,655; python: 10,576; ruby: 8,684; xml: 5,957; makefile: 4,893; sql: 3,750; asm: 841; lex: 670; php: 22; awk: 20; sed: 16
file content (155 lines) | stat: -rw-r--r-- 3,147 bytes parent folder | download | duplicates (5)
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
# 
# Basic syntax related to indexes: 
#   unique and non-unique keys,
#   single- and multi-column keys,
#   index option COMMENT.
#   
# See other index* tests for operations 
# which are less likely to be supported
#
# PRIMARY KEY syntax is covered in index_primary test.
# Index types BTREE|HASH -- in index_type_btree|hash tests.
# SPATIAL -- in type_spatial_indexes test.
# FULLTEXT -- in fulltext_search test.
# KEY_BLOCK_SIZE -- in index_key_block_size test.
#
# Usage to call the test from another test:
#
# A calling test may define $index_type, in which case
#   USING clause will be added to the syntax.
# 

################################################
# TODO:
# A part of the test is disabled because unique indexes
# are not currently supported
################################################


let $using_index_type = ;
if ($index_type)
{
  let $using_index_type = USING $index_type;
}


eval CREATE TABLE t1 (a INT,
  b CHAR(8),
  pk INT PRIMARY KEY,
  KEY $using_index_type (a)
) ENGINE=rocksdb;

--replace_column 7 #
SHOW KEYS IN t1;
DROP TABLE t1;

eval CREATE TABLE t1 (a INT,
  b CHAR(8),
  pk INT PRIMARY KEY,
  KEY a_b $using_index_type (a,b) COMMENT 'a_b index'
) ENGINE=rocksdb;

--replace_column 7 #
SHOW KEYS IN t1;
DROP TABLE t1;

eval CREATE TABLE t1 (a INT,
  b CHAR(8),
  pk INT PRIMARY KEY,
  KEY $using_index_type (a),
  KEY $using_index_type (b)
) ENGINE=rocksdb;

--replace_column 7 #
SHOW KEYS IN t1;
DROP TABLE t1;

--disable_parsing

eval CREATE TABLE t1 (a INT,
  b CHAR(8),
  pk INT PRIMARY KEY,
  UNIQUE INDEX $using_index_type (a)
) ENGINE=rocksdb;

--replace_column 7 #
SHOW KEYS IN t1;
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
--error ER_DUP_ENTRY,ER_DUP_KEY
INSERT INTO t1 (a,b) VALUES (1,'c');

DROP TABLE t1;

--source drop_table_sync.inc

--enable_parsing

#
# ALTER TABLE
#

CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
INSERT INTO t1 (a,b) VALUES (100,'z');

eval ALTER TABLE t1 ADD KEY (a) $using_index_type COMMENT 'simple index on a';
--replace_column 7 #
SHOW INDEX FROM t1;
ALTER TABLE t1 DROP KEY a;
DROP TABLE t1;

--disable_parsing

eval CREATE TABLE t1 (a INT,
  b CHAR(8),
  pk INT AUTO_INCREMENT PRIMARY KEY,
  UNIQUE INDEX $using_index_type (a)
) ENGINE=rocksdb;

--replace_column 7 #
SHOW KEYS IN t1;
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
--error ER_DUP_ENTRY,ER_DUP_KEY
INSERT INTO t1 (a,b) VALUES (1,'c');

ALTER TABLE t1 DROP INDEX a;
INSERT INTO t1 (a,b) VALUES (1,'c');
--error ER_DUP_ENTRY
eval ALTER TABLE t1 ADD UNIQUE INDEX a(a) $using_index_type;
DROP TABLE t1;

--enable_parsing

#
# Test index prefix length limits.
#
set global rocksdb_large_prefix=0;

CREATE TABLE t1 (
  a BLOB(1024),
  KEY (a(767))
) ENGINE=rocksdb;
DROP TABLE t1;

# Should display warning
CREATE TABLE t1 (
  a BLOB(1024),
  KEY (a(768))
) ENGINE=rocksdb;
DROP TABLE t1;

set global rocksdb_large_prefix=1;

CREATE TABLE t1 (
  a BLOB(4096),
  KEY (a(3072))
) ENGINE=rocksdb;
DROP TABLE t1;

# Should display warning
CREATE TABLE t1 (
  a BLOB(4096),
  KEY (a(3073))
) ENGINE=rocksdb;
DROP TABLE t1;

set global rocksdb_large_prefix=DEFAULT;