Commit 386df099 authored by Arjen Lentz's avatar Arjen Lentz

Merge upstream.

parents 79ab9ddb a0ab3d0d
...@@ -380,7 +380,18 @@ void init_tmp_table_share(THD *thd, TABLE_SHARE *share, const char *key, ...@@ -380,7 +380,18 @@ void init_tmp_table_share(THD *thd, TABLE_SHARE *share, const char *key,
DBUG_ENTER("init_tmp_table_share"); DBUG_ENTER("init_tmp_table_share");
DBUG_PRINT("enter", ("table: '%s'.'%s'", key, table_name)); 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 This can't be MY_THREAD_SPECIFIC for slaves as they are freed
during cleanup() from Relay_log_info::close_temporary_tables() during cleanup() from Relay_log_info::close_temporary_tables()
......
...@@ -353,7 +353,7 @@ int ha_oqgraph::open(const char *name, int mode, uint test_if_locked) ...@@ -353,7 +353,7 @@ int ha_oqgraph::open(const char *name, int mode, uint test_if_locked)
const char* p= strend(name)-1; const char* p= strend(name)-1;
while (p > name && *p != '\\' && *p != '/') while (p > name && *p != '\\' && *p != '/')
--p; --p;
init_tmp_table_share( init_tmp_table_share(
thd, share, table->s->db.str, table->s->db.length, thd, share, table->s->db.str, table->s->db.length,
options->table_name, ""); options->table_name, "");
...@@ -455,6 +455,14 @@ int ha_oqgraph::open(const char *name, int mode, uint test_if_locked) ...@@ -455,6 +455,14 @@ int ha_oqgraph::open(const char *name, int mode, uint test_if_locked)
break; break;
} }
if (!origid) {
fprint_error("Invalid OQGRAPH backing store ('%s'.origid attribute not set to a valid column of '%s')", p, options->table_name);
closefrm(edges, 0);
free_table_share(share);
return -1;
}
for (Field **field= edges->field; *field; ++field) for (Field **field= edges->field; *field; ++field)
{ {
if (strcmp(options->destid, (*field)->field_name)) if (strcmp(options->destid, (*field)->field_name))
...@@ -472,6 +480,13 @@ int ha_oqgraph::open(const char *name, int mode, uint test_if_locked) ...@@ -472,6 +480,13 @@ int ha_oqgraph::open(const char *name, int mode, uint test_if_locked)
break; break;
} }
if (!destid) {
fprint_error("Invalid OQGRAPH backing store ('%s'.destid attribute not set to a valid column of '%s')", p, options->table_name);
closefrm(edges, 0);
free_table_share(share);
return -1;
}
for (Field **field= edges->field; options->weight && *field; ++field) for (Field **field= edges->field; options->weight && *field; ++field)
{ {
if (strcmp(options->weight, (*field)->field_name)) if (strcmp(options->weight, (*field)->field_name))
...@@ -489,9 +504,8 @@ int ha_oqgraph::open(const char *name, int mode, uint test_if_locked) ...@@ -489,9 +504,8 @@ int ha_oqgraph::open(const char *name, int mode, uint test_if_locked)
break; break;
} }
if (!origid || !destid || (!weight && options->weight)) if (!weight && options->weight) {
{ fprint_error("Invalid OQGRAPH backing store ('%s'.weight attribute not set to a valid column of '%s')", p, options->table_name);
fprint_error("Data columns missing on table '%s'", options->table_name);
closefrm(edges, 0); closefrm(edges, 0);
free_table_share(share); free_table_share(share);
return -1; return -1;
......
/* 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