summaryrefslogtreecommitdiff
path: root/storage/oqgraph/mysql-test/oqgraph/create_attr.test
blob: d681d601faeffcb319ed66000d67da9ffb41ba9b (plain)
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
218
219
220
--disable_warnings
DROP TABLE IF EXISTS not_backing;
DROP TABLE IF EXISTS backing;
DROP TABLE IF EXISTS oqtable;
--enable_warnings


CREATE TABLE `not_backing` (
  id int(10) unsigned NOT NULL DEFAULT '0',
  id2 int(10) unsigned NOT NULL DEFAULT '0',
  info varchar(20) DEFAULT NULL,
  KEY name (info)
) DEFAULT CHARSET=latin1;

CREATE TABLE backing (
  id int(10) unsigned NOT NULL DEFAULT '0',
  id2 int(10) unsigned NOT NULL DEFAULT '0',
  parent int(10) unsigned DEFAULT NULL,
  weight real(10,4) NOT NULL DEFAULT 0.0,
  info varchar(20) DEFAULT NULL,
  not_id_type varchar(20) DEFAULT NULL,
  not_weight_type varchar(20) DEFAULT NULL,
  PRIMARY KEY (id),
  KEY name (info)
) DEFAULT CHARSET=latin1;


# oqgraph v2 create table should fail (missing attributes)
CREATE TABLE oqtable ( latch varchar(32) NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH;
--echo # Expect: 'Invalid OQGRAPH backing store (unspecified or empty data_table attribute)'
--error 1296
DESCRIBE oqtable;


# no table reference
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch varchar(32) NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, ORIGID='id', DESTID='id2';
--echo # Expect: 'Invalid OQGRAPH backing store (unspecified or empty data_table attribute)'
--error 1296
DESCRIBE oqtable;

# empty table reference
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch varchar(32) NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='', ORIGID='id', DESTID='id2';
--echo # Expect: 'Invalid OQGRAPH backing store (unspecified or empty data_table attribute)'
--error 1296
DESCRIBE oqtable;

# empty table reference
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch varchar(32) NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='', ORIGID='id';
--echo # Expect: 'Invalid OQGRAPH backing store (unspecified or empty data_table attribute)'
--error 1296
DESCRIBE oqtable;


# empty table reference
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch varchar(32) NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='', DESTID='id2';
--echo # Expect: 'Invalid OQGRAPH backing store (unspecified or empty data_table attribute)'
--error 1296
DESCRIBE oqtable;

# non-existent table reference
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch varchar(32) NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='bogus', ORIGID='id', DESTID='id2';
--echo # Expect: 'Table 'test.bogus' doesn't exist''
--disable_warnings
--error 1146
DESCRIBE oqtable;
--enable_warnings

# Table exists but no orig or dest specified
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch varchar(32) NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='not_backing';
--echo # Expect 'Invalid OQGRAPH backing store (unspecified or empty origid attribute)'
--error 1296
DESCRIBE oqtable;

# missing origid
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch varchar(32) NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='backing', DESTID='id2';
--echo # Expect 'Invalid OQGRAPH backing store (unspecified or empty origid attribute)'
--error 1296
DESCRIBE oqtable;

# empty origid
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch varchar(32) NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='backing',ORIGID='', DESTID='id2';
--echo # Expect 'Invalid OQGRAPH backing store (unspecified or empty origid attribute)'
--error 1296
DESCRIBE oqtable;

# invalid origid reference
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch varchar(32) NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='backing',ORIGID='bogus', DESTID='id2';
--echo # Expect Invalid OQGRAPH backing store ('/oqtable'.origid attribute not set to a valid column of 'backing')' 
--error 1296
DESCRIBE oqtable;

# wrong type origid
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch varchar(32) NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='backing',ORIGID='not_id_type', DESTID='id2';
--echo # Expect 'Column 'backing.not_id_type' is not a not-null integer type' 
--error 1296
DESCRIBE oqtable;

# missing destid
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch varchar(32) NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='backing',ORIGID='id';
--echo # Expect 'Invalid OQGRAPH backing store (unspecified or empty destid attribute)'
--error 1296
DESCRIBE oqtable;

# empty destid
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch varchar(32) NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='backing',ORIGID='id',DESTID='';
--echo # Expect 'Invalid OQGRAPH backing store (unspecified or empty destid attribute)'
--error 1296
DESCRIBE oqtable;

# invalid destid reference
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch varchar(32) NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='backing',ORIGID='id',DESTID='bogus';
--echo # Expect Invalid OQGRAPH backing store ('/oqtable'.destid attribute not set to a valid column of 'backing')' 
--error 1296
DESCRIBE oqtable;

# wrong type destid
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch varchar(32) NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='backing',ORIGID='id',DESTID='not_id_type';
--echo # Expect 'Column 'backing.not_id_type' is not a not-null integer type' 
--error 1296
DESCRIBE oqtable;

# same origid and destid
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch varchar(32) NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='backing',ORIGID='id',DESTID='id';
--echo # Expect 'Invalid OQGRAPH backing store ('/oqtable'.destid attribute set to same column as origid attribute)'
--error 1296
DESCRIBE oqtable;

# invalid weight reference
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch varchar(32) NULL NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='backing',ORIGID='id',DESTID='id2',WEIGHT='';
--echo # Expect 'Invalid OQGRAPH backing store ('/oqtable'.weight attribute not set to a valid column of 'backing')'
--error 1296
DESCRIBE oqtable;

# invalid weight reference
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch varchar(32) NULL NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='backing',ORIGID='id',DESTID='id2',WEIGHT='bogus';
--echo # Expect 'Invalid OQGRAPH backing store ('/oqtable'.weight attribute not set to a valid column of 'backing')'
--error 1296
DESCRIBE oqtable;

# wrong type weight
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch varchar(32) NULL NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='backing',ORIGID='id',DESTID='id2',WEIGHT='not_weight_type';
--echo # Expect 'Column 'backing.not_weight_type' is not a not-null real type' 
--error 1296
DESCRIBE oqtable;

# all valid
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch varchar(32) NULL NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='backing',ORIGID='id',DESTID='id2',WEIGHT='weight';
DESCRIBE oqtable;

#-- Expect an error if we attempt to use a view as the backing store
#-- 'VIEWs are not supported for an OQGRAPH backing store.'
#-- TODO

#-- TODO - what happens if we make two tables with the same backing store?

#-- TODO - what happens if data_table is a TEMPORARY table?

# cleanup
--disable_warnings
DROP TABLE IF EXISTS oqtable;
DROP TABLE IF EXISTS backing;
DROP TABLE IF EXISTS not_backing;
--enable_warnings