Commit a0ab3d0d authored by Andrew McDonnell's avatar Andrew McDonnell

Regression test for #1134338 and #1134337 and #1134265

parent ce46146b
......@@ -380,7 +380,18 @@ void init_tmp_table_share(THD *thd, TABLE_SHARE *share, const char *key,
DBUG_ENTER("init_tmp_table_share");
DBUG_PRINT("enter", ("table: '%s'.'%s'", key, table_name));
bzero((char*) share, sizeof(*share));
/*
Dont let badly coded plugins crash the daemon here...
The table_name and path cannot be NULL.
ASSERT if debug enabled, otherwise, just warn and return.
*/
DBUG_ASSERT(table_name);
DBUG_ASSERT(path);
if (table_name==NULL || path==NULL) {
sql_print_warning("Someone called init_tmp_table_share() with invalid table_name or path.");
return;
}
bzero((char*) share, sizeof(*share));
/*
This can't be MY_THREAD_SPECIFIC for slaves as they are freed
during cleanup() from Relay_log_info::close_temporary_tables()
......
/* 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