Commit 1a11797f authored by Arjen Lentz's avatar Arjen Lentz

Added oqgraph "create attr" test as per Andrew's regression test. Fixups...

Added oqgraph "create attr" test as per Andrew's regression test. Fixups required before we can record results.
parent 9197b77d
DROP TABLE IF EXISTS not_backing;
DROP TABLE IF EXISTS backing;
DROP TABLE IF EXISTS oqtable;
CREATE TABLE `not_backing` (
id 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',
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 SMALLINT UNSIGNED 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;
--error 1296
DESCRIBE oqtable;
# attributes test
# empty table reference
DROP TABLE IF EXISTS `oqtable`;
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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='';
--error 1296
DESCRIBE oqtable;
# non-existent table reference
DROP TABLE IF EXISTS `oqtable`;
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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';
--error 1296
DESCRIBE oqtable;
# invalid table reference
DROP TABLE IF EXISTS `oqtable`;
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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';
--error 1296
DESCRIBE oqtable;
# empty origid
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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='';
--error 1296
DESCRIBE oqtable;
# invalid origid reference
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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';
--error 1296
DESCRIBE oqtable;
# wrong type origid
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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';
--error 1296
DESCRIBE oqtable;
# missing destid
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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';
--error 1296
DESCRIBE oqtable;
# empty destid
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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='';
--error 1296
DESCRIBE oqtable;
# invalid destid reference
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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';
--error 1296
DESCRIBE oqtable;
# wrong type destid
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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';
--error 1296
DESCRIBE oqtable;
# invalid origid with valid destid
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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='id';
--error 1296
DESCRIBE oqtable;
# wrong type origid with valid destid
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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='id';
--error 1296
DESCRIBE oqtable;
# same origid and destid
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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';
# this should fail when we put a check in for ORIGID != DESTID
# --error 1296
DESCRIBE oqtable;
# invalid weight reference
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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',WEIGHT='bogus';
--error 1296
DESCRIBE oqtable;
# wrong type weight
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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',WEIGHT='not_weight_type';
--error 1296
DESCRIBE oqtable;
# all valid
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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',WEIGHT='weight';
DESCRIBE oqtable;
# cleanup
DROP TABLE IF EXISTS oqtable;
DROP TABLE IF EXISTS backing;
DROP TABLE IF EXISTS not_backing;
/* How to run me: using the C preprocessor:
* cpp -P regressiontest.sql.in |client/mysql --skip-pager --force --silent test
*
* Expected result:
* 1. No mysqld crash
* 2. Error -1
* 3. Successful DESCRIBEs where noted
*/
#define Create_OQ_TABLE(name) \
CREATE TABLE name ( \
latch SMALLINT UNSIGNED 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
#define Drop(name) DROP TABLE IF EXISTS `name`
#define P1(x) #x
#define P2(x) P1(x)
#define EXPECT_ERROR_1 select P2(__LINE__) , 'Expect error -1:'
#define EXPECT_SUCCESS(x) select P2(__LINE__) , 'Expect ' x ':'
/* status*/
warnings
Drop(not_backing);
Drop(backing);
Drop(oqtable);
CREATE TABLE `not_backing` (
`id` int(10) unsigned NOT NULL DEFAULT '0',
`info` varchar(20) DEFAULT NULL,
KEY `name` (`info`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `backing` (
`id` 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`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/* Attempt to create with no attributes. Fail expcted. */
select __LINE__ ; Create_OQ_TABLE( oqtable); describe oqtable;
/* Attempt to create with various attributes missing, but at least one present */
/* Create will succeed, and then cause describe to fail */
select 'Attributes test...';
EXPECT_ERROR_1; Drop(oqtable); Create_OQ_TABLE( oqtable), DATA_TABLE=''; describe oqtable;
EXPECT_ERROR_1; Drop(oqtable); Create_OQ_TABLE( oqtable), DATA_TABLE='bogus'; describe oqtable;
EXPECT_ERROR_1; Drop(oqtable); Create_OQ_TABLE( oqtable), DATA_TABLE='not_backing'; describe oqtable;
EXPECT_ERROR_1; Drop(oqtable); Create_OQ_TABLE( oqtable), DATA_TABLE='backing'; describe oqtable;
/* attributes are processed insid ha_oqgraph::open left to right. So if dont put data_table in the following they all look the same as data_table=''*/
EXPECT_ERROR_1; Drop(oqtable); Create_OQ_TABLE( oqtable), DATA_TABLE='backing',ORIGID=''; describe oqtable;
EXPECT_ERROR_1; Drop(oqtable); Create_OQ_TABLE( oqtable), DATA_TABLE='backing',ORIGID='bogus'; describe oqtable;
EXPECT_ERROR_1; Drop(oqtable); Create_OQ_TABLE( oqtable), DATA_TABLE='backing',ORIGID='not_id_type'; describe oqtable;
EXPECT_ERROR_1; Drop(oqtable); Create_OQ_TABLE( oqtable), DATA_TABLE='backing',ORIGID='id'; describe oqtable;
EXPECT_ERROR_1; Drop(oqtable); Create_OQ_TABLE( oqtable), DATA_TABLE='backing',ORIGID='id',DESTID=''; describe oqtable;
EXPECT_ERROR_1; Drop(oqtable); Create_OQ_TABLE( oqtable), DATA_TABLE='backing',ORIGID='id',DESTID='bogus'; describe oqtable;
EXPECT_ERROR_1; Drop(oqtable); Create_OQ_TABLE( oqtable), DATA_TABLE='backing',ORIGID='id',DESTID='not_id_type'; describe oqtable;
EXPECT_ERROR_1; Drop(oqtable); Create_OQ_TABLE( oqtable), DATA_TABLE='backing',ORIGID='bogus',DESTID='id'; describe oqtable;
EXPECT_ERROR_1; Drop(oqtable); Create_OQ_TABLE( oqtable), DATA_TABLE='backing',ORIGID='not_id_type',DESTID='id'; describe oqtable;
EXPECT_SUCCESS('successful DESCRIBE'); Drop(oqtable); Create_OQ_TABLE( oqtable), DATA_TABLE='backing',ORIGID='id',DESTID='id'; describe oqtable;
EXPECT_ERROR_1; Drop(oqtable); Create_OQ_TABLE( oqtable), DATA_TABLE='backing',ORIGID='id',DESTID='id',WEIGHT='bogus'; describe oqtable;
EXPECT_ERROR_1; Drop(oqtable); Create_OQ_TABLE( oqtable), DATA_TABLE='backing',ORIGID='id',DESTID='id',WEIGHT='not_weight_type'; describe oqtable;
EXPECT_SUCCESS('successful DESCRIBE'); Drop(oqtable); Create_OQ_TABLE( oqtable), DATA_TABLE='backing',ORIGID='id',DESTID='id',WEIGHT='weight'; describe oqtable;
Drop(oqtable);
/* As at Feb 28, DATA_TABLE='x' does not check if x exists or is wrong structure, on hq_oqgraph::open (describe)
/* show tables; */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment