mirror of
https://github.com/MariaDB/server.git
synced 2025-01-23 23:34:34 +01:00
Merge jlindstrom@bk-internal.mysql.com:/home/bk/mysql-4.1
into hundin.mysql.fi:/home/jan/mysql-4.1
This commit is contained in:
commit
e75f15f17c
11 changed files with 144 additions and 33 deletions
|
@ -529,6 +529,7 @@ show keys from t1;
|
||||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||||
t1 1 a 1 a A NULL NULL NULL YES BTREE disabled
|
t1 1 a 1 a A NULL NULL NULL YES BTREE disabled
|
||||||
create table t2 (a int);
|
create table t2 (a int);
|
||||||
|
set @@rand_seed1=31415926,@@rand_seed2=2718281828;
|
||||||
insert t1 select * from t2;
|
insert t1 select * from t2;
|
||||||
show keys from t1;
|
show keys from t1;
|
||||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||||
|
|
|
@ -87,6 +87,13 @@ a b c
|
||||||
7 8 3
|
7 8 3
|
||||||
8 2 3
|
8 2 3
|
||||||
drop table t2;
|
drop table t2;
|
||||||
|
CREATE TABLE t2 (
|
||||||
|
a int unsigned NOT NULL PRIMARY KEY,
|
||||||
|
b int unsigned not null,
|
||||||
|
c int unsigned,
|
||||||
|
UNIQUE USING HASH (b, c)
|
||||||
|
) engine=ndbcluster;
|
||||||
|
ERROR 42000: Column 'c' is used with UNIQUE or INDEX but is not defined as NOT NULL
|
||||||
CREATE TABLE t3 (
|
CREATE TABLE t3 (
|
||||||
a int unsigned NOT NULL,
|
a int unsigned NOT NULL,
|
||||||
b int unsigned not null,
|
b int unsigned not null,
|
||||||
|
|
|
@ -1990,3 +1990,18 @@ ac
|
||||||
700
|
700
|
||||||
NULL
|
NULL
|
||||||
drop tables t1,t2;
|
drop tables t1,t2;
|
||||||
|
create table t1 (a int not null, b int not null, c int, primary key (a,b));
|
||||||
|
insert into t1 values (1,1,1), (2,2,2), (3,3,3);
|
||||||
|
set @b:= 0;
|
||||||
|
explain select sum(a) from t1 where b > @b;
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE t1 index NULL PRIMARY 8 NULL 3 Using where; Using index
|
||||||
|
set @a:= (select sum(a) from t1 where b > @b);
|
||||||
|
explain select a from t1 where c=2;
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
|
||||||
|
do @a:= (select sum(a) from t1 where b > @b);
|
||||||
|
explain select a from t1 where c=2;
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
|
||||||
|
drop table t1;
|
||||||
|
|
|
@ -498,11 +498,12 @@ alter table t1 disable keys;
|
||||||
show keys from t1;
|
show keys from t1;
|
||||||
create table t2 (a int);
|
create table t2 (a int);
|
||||||
let $i=1000;
|
let $i=1000;
|
||||||
|
set @@rand_seed1=31415926,@@rand_seed2=2718281828;
|
||||||
--disable_query_log
|
--disable_query_log
|
||||||
while ($i)
|
while ($i)
|
||||||
{
|
{
|
||||||
dec $i;
|
dec $i;
|
||||||
eval insert t2 values (rand()*100000);
|
insert t2 values (rand()*100000);
|
||||||
}
|
}
|
||||||
--enable_query_log
|
--enable_query_log
|
||||||
insert t1 select * from t2;
|
insert t1 select * from t2;
|
||||||
|
|
|
@ -58,6 +58,14 @@ select * from t2 order by a;
|
||||||
|
|
||||||
drop table t2;
|
drop table t2;
|
||||||
|
|
||||||
|
-- error 1121
|
||||||
|
CREATE TABLE t2 (
|
||||||
|
a int unsigned NOT NULL PRIMARY KEY,
|
||||||
|
b int unsigned not null,
|
||||||
|
c int unsigned,
|
||||||
|
UNIQUE USING HASH (b, c)
|
||||||
|
) engine=ndbcluster;
|
||||||
|
|
||||||
#
|
#
|
||||||
# Show use of PRIMARY KEY USING HASH indexes
|
# Show use of PRIMARY KEY USING HASH indexes
|
||||||
#
|
#
|
||||||
|
|
|
@ -1282,3 +1282,22 @@ INSERT INTO `t2` VALUES (6,5,12,7,'a'),(12,0,0,7,'a'),(12,1,0,7,'a'),(12,5,5,7,'
|
||||||
SELECT b.sc FROM (SELECT (SELECT a.access FROM t1 a WHERE a.map = op.map AND a.slave = op.pid AND a.master = 1) ac FROM t2 op WHERE op.id = 12 AND op.map = 0) b;
|
SELECT b.sc FROM (SELECT (SELECT a.access FROM t1 a WHERE a.map = op.map AND a.slave = op.pid AND a.master = 1) ac FROM t2 op WHERE op.id = 12 AND op.map = 0) b;
|
||||||
SELECT b.ac FROM (SELECT (SELECT a.access FROM t1 a WHERE a.map = op.map AND a.slave = op.pid AND a.master = 1) ac FROM t2 op WHERE op.id = 12 AND op.map = 0) b;
|
SELECT b.ac FROM (SELECT (SELECT a.access FROM t1 a WHERE a.map = op.map AND a.slave = op.pid AND a.master = 1) ac FROM t2 op WHERE op.id = 12 AND op.map = 0) b;
|
||||||
drop tables t1,t2;
|
drop tables t1,t2;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Test for bug #6462. "Same request on same data returns different
|
||||||
|
# results." a.k.a. "Proper cleanup of subqueries is missing for
|
||||||
|
# SET and DO statements".
|
||||||
|
#
|
||||||
|
create table t1 (a int not null, b int not null, c int, primary key (a,b));
|
||||||
|
insert into t1 values (1,1,1), (2,2,2), (3,3,3);
|
||||||
|
set @b:= 0;
|
||||||
|
# Let us check that subquery will use covering index
|
||||||
|
explain select sum(a) from t1 where b > @b;
|
||||||
|
# This should not crash -debug server due to failing assertion
|
||||||
|
set @a:= (select sum(a) from t1 where b > @b);
|
||||||
|
# And this should not falsely report index usage
|
||||||
|
explain select a from t1 where c=2;
|
||||||
|
# Same for DO statement
|
||||||
|
do @a:= (select sum(a) from t1 where b > @b);
|
||||||
|
explain select a from t1 where c=2;
|
||||||
|
drop table t1;
|
||||||
|
|
|
@ -796,7 +796,8 @@ int ha_ndbcluster::build_index_list(TABLE *tab, enum ILBP phase)
|
||||||
error= create_unique_index(unique_index_name, key_info);
|
error= create_unique_index(unique_index_name, key_info);
|
||||||
break;
|
break;
|
||||||
case UNIQUE_INDEX:
|
case UNIQUE_INDEX:
|
||||||
error= create_unique_index(unique_index_name, key_info);
|
if (!(error= check_index_fields_not_null(i)))
|
||||||
|
error= create_unique_index(unique_index_name, key_info);
|
||||||
break;
|
break;
|
||||||
case ORDERED_INDEX:
|
case ORDERED_INDEX:
|
||||||
error= create_ordered_index(index_name, key_info);
|
error= create_ordered_index(index_name, key_info);
|
||||||
|
@ -848,6 +849,26 @@ NDB_INDEX_TYPE ha_ndbcluster::get_index_type_from_table(uint inx) const
|
||||||
ORDERED_INDEX);
|
ORDERED_INDEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ha_ndbcluster::check_index_fields_not_null(uint inx)
|
||||||
|
{
|
||||||
|
KEY* key_info= table->key_info + inx;
|
||||||
|
KEY_PART_INFO* key_part= key_info->key_part;
|
||||||
|
KEY_PART_INFO* end= key_part+key_info->key_parts;
|
||||||
|
DBUG_ENTER("check_index_fields_not_null");
|
||||||
|
|
||||||
|
for (; key_part != end; key_part++)
|
||||||
|
{
|
||||||
|
Field* field= key_part->field;
|
||||||
|
if (field->maybe_null())
|
||||||
|
{
|
||||||
|
my_printf_error(ER_NULL_COLUMN_IN_INDEX,ER(ER_NULL_COLUMN_IN_INDEX),
|
||||||
|
MYF(0),field->field_name);
|
||||||
|
DBUG_RETURN(ER_NULL_COLUMN_IN_INDEX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DBUG_RETURN(0);
|
||||||
|
}
|
||||||
|
|
||||||
void ha_ndbcluster::release_metadata()
|
void ha_ndbcluster::release_metadata()
|
||||||
{
|
{
|
||||||
|
|
|
@ -160,7 +160,8 @@ class ha_ndbcluster: public handler
|
||||||
void release_metadata();
|
void release_metadata();
|
||||||
NDB_INDEX_TYPE get_index_type(uint idx_no) const;
|
NDB_INDEX_TYPE get_index_type(uint idx_no) const;
|
||||||
NDB_INDEX_TYPE get_index_type_from_table(uint index_no) const;
|
NDB_INDEX_TYPE get_index_type_from_table(uint index_no) const;
|
||||||
|
int check_index_fields_not_null(uint index_no);
|
||||||
|
|
||||||
int pk_read(const byte *key, uint key_len, byte *buf);
|
int pk_read(const byte *key, uint key_len, byte *buf);
|
||||||
int complemented_pk_read(const byte *old_data, byte *new_data);
|
int complemented_pk_read(const byte *old_data, byte *new_data);
|
||||||
int peek_row();
|
int peek_row();
|
||||||
|
|
|
@ -2733,13 +2733,18 @@ int sql_set_variables(THD *thd, List<set_var_base> *var_list)
|
||||||
while ((var=it++))
|
while ((var=it++))
|
||||||
{
|
{
|
||||||
if ((error=var->check(thd)))
|
if ((error=var->check(thd)))
|
||||||
DBUG_RETURN(error);
|
goto err;
|
||||||
}
|
}
|
||||||
if (thd->net.report_error)
|
if (!thd->net.report_error)
|
||||||
DBUG_RETURN(1);
|
{
|
||||||
it.rewind();
|
it.rewind();
|
||||||
while ((var=it++))
|
while ((var= it++))
|
||||||
error|= var->update(thd); // Returns 0, -1 or 1
|
error|= var->update(thd); // Returns 0, -1 or 1
|
||||||
|
}
|
||||||
|
else
|
||||||
|
error= 1;
|
||||||
|
err:
|
||||||
|
free_underlaid_joins(thd, &thd->lex->select_lex);
|
||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ int mysql_do(THD *thd, List<Item> &values)
|
||||||
DBUG_RETURN(-1);
|
DBUG_RETURN(-1);
|
||||||
while ((value = li++))
|
while ((value = li++))
|
||||||
value->val_int();
|
value->val_int();
|
||||||
|
free_underlaid_joins(thd, &thd->lex->select_lex);
|
||||||
thd->clear_error(); // DO always is OK
|
thd->clear_error(); // DO always is OK
|
||||||
send_ok(thd);
|
send_ok(thd);
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
|
|
|
@ -23,13 +23,14 @@ struct uca_item_st
|
||||||
#define MY_UCA_PSHIFT 8
|
#define MY_UCA_PSHIFT 8
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static char *pname[]= {"", "2", "3"};
|
||||||
|
|
||||||
int main(int ac, char **av)
|
int main(int ac, char **av)
|
||||||
{
|
{
|
||||||
char str[256];
|
char str[256];
|
||||||
char *weights[64];
|
char *weights[64];
|
||||||
struct uca_item_st uca[64*1024];
|
struct uca_item_st uca[64*1024];
|
||||||
size_t code, page, w;
|
size_t code, w;
|
||||||
int pagemaxlen[MY_UCA_NPAGES];
|
|
||||||
int pageloaded[MY_UCA_NPAGES];
|
int pageloaded[MY_UCA_NPAGES];
|
||||||
|
|
||||||
bzero(uca, sizeof(uca));
|
bzero(uca, sizeof(uca));
|
||||||
|
@ -155,14 +156,20 @@ int main(int ac, char **av)
|
||||||
printf("#define MY_UCA_CMASK %d\n",MY_UCA_CMASK);
|
printf("#define MY_UCA_CMASK %d\n",MY_UCA_CMASK);
|
||||||
printf("#define MY_UCA_PSHIFT %d\n",MY_UCA_PSHIFT);
|
printf("#define MY_UCA_PSHIFT %d\n",MY_UCA_PSHIFT);
|
||||||
|
|
||||||
for (w=0; w<1; w++)
|
for (w=0; w<3; w++)
|
||||||
{
|
{
|
||||||
|
size_t page;
|
||||||
|
int pagemaxlen[MY_UCA_NPAGES];
|
||||||
|
|
||||||
for (page=0; page < MY_UCA_NPAGES; page++)
|
for (page=0; page < MY_UCA_NPAGES; page++)
|
||||||
{
|
{
|
||||||
size_t offs;
|
size_t offs;
|
||||||
size_t maxnum= 0;
|
size_t maxnum= 0;
|
||||||
size_t nchars= 0;
|
size_t nchars= 0;
|
||||||
size_t mchars;
|
size_t mchars;
|
||||||
|
size_t ndefs= 0;
|
||||||
|
|
||||||
|
pagemaxlen[page]= 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Skip this page if no weights were loaded
|
Skip this page if no weights were loaded
|
||||||
|
@ -183,15 +190,37 @@ int main(int ac, char **av)
|
||||||
code= page*MY_UCA_NCHARS+offs;
|
code= page*MY_UCA_NCHARS+offs;
|
||||||
|
|
||||||
/* Calculate only non-zero weights */
|
/* Calculate only non-zero weights */
|
||||||
num=0;
|
for (num=0, i=0; i < uca[code].num; i++)
|
||||||
for (i=0; i < uca[code].num; i++)
|
|
||||||
if (uca[code].weight[w][i])
|
if (uca[code].weight[w][i])
|
||||||
num++;
|
num++;
|
||||||
|
|
||||||
maxnum= maxnum < num ? num : maxnum;
|
maxnum= maxnum < num ? num : maxnum;
|
||||||
|
|
||||||
|
/* Check if default weight */
|
||||||
|
if (w == 1 && num == 1)
|
||||||
|
{
|
||||||
|
/* 0020 0000 ... */
|
||||||
|
if (uca[code].weight[w][0] == 0x0020)
|
||||||
|
ndefs++;
|
||||||
|
}
|
||||||
|
else if (w == 2 && num == 1)
|
||||||
|
{
|
||||||
|
/* 0002 0000 ... */
|
||||||
|
if (uca[code].weight[w][0] == 0x0002)
|
||||||
|
ndefs++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
maxnum++;
|
maxnum++;
|
||||||
|
|
||||||
|
/*
|
||||||
|
If the page have only default weights
|
||||||
|
then no needs to dump it, skip.
|
||||||
|
*/
|
||||||
|
if (ndefs == MY_UCA_NCHARS)
|
||||||
|
{
|
||||||
|
printf("/* Don't dump w=%d pg=%3X: ndefs=%d */\n",w, page, ndefs);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
switch (maxnum)
|
switch (maxnum)
|
||||||
{
|
{
|
||||||
case 0: mchars= 8; break;
|
case 0: mchars= 8; break;
|
||||||
|
@ -210,8 +239,8 @@ int main(int ac, char **av)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
printf("uint16 page%03Xdata[]= { /* %04X (%d weights per char) */\n",
|
printf("uint16 page%03Xdata%s[]= { /* %04X (%d weights per char) */\n",
|
||||||
page, page*MY_UCA_NCHARS, maxnum);
|
page, pname[w], page*MY_UCA_NCHARS, maxnum);
|
||||||
|
|
||||||
for (offs=0; offs < MY_UCA_NCHARS; offs++)
|
for (offs=0; offs < MY_UCA_NCHARS; offs++)
|
||||||
{
|
{
|
||||||
|
@ -251,25 +280,28 @@ int main(int ac, char **av)
|
||||||
}
|
}
|
||||||
printf("};\n\n");
|
printf("};\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("uchar ucal%s[%d]={\n", pname[w], MY_UCA_NPAGES);
|
||||||
|
for (page=0; page < MY_UCA_NPAGES; page++)
|
||||||
|
{
|
||||||
|
printf("%d%s%s",pagemaxlen[page],page<MY_UCA_NPAGES-1?",":"",(page+1) % 16 ? "":"\n");
|
||||||
|
}
|
||||||
|
printf("};\n");
|
||||||
|
|
||||||
|
|
||||||
|
printf("uint16 *ucaw%s[%d]={\n", pname[w], MY_UCA_NPAGES);
|
||||||
|
for (page=0; page < MY_UCA_NPAGES; page++)
|
||||||
|
{
|
||||||
|
const char *comma= page < MY_UCA_NPAGES-1 ? "," : "";
|
||||||
|
const char *nline= (page+1) % 4 ? "" : "\n";
|
||||||
|
if (!pagemaxlen[page])
|
||||||
|
printf("NULL %s%s", comma , nline);
|
||||||
|
else
|
||||||
|
printf("page%03Xdata%s%s%s", page, pname[w], comma, nline);
|
||||||
|
}
|
||||||
|
printf("};\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("uchar ucal[%d]={\n",MY_UCA_NPAGES);
|
|
||||||
for (page=0; page < MY_UCA_NPAGES; page++)
|
|
||||||
{
|
|
||||||
printf("%d%s%s",pagemaxlen[page],page<MY_UCA_NPAGES-1?",":"",(page+1) % 16 ? "":"\n");
|
|
||||||
}
|
|
||||||
printf("};\n");
|
|
||||||
|
|
||||||
|
|
||||||
printf("uint16 *ucaw[%d]={\n",MY_UCA_NPAGES);
|
|
||||||
for (page=0; page < MY_UCA_NPAGES; page++)
|
|
||||||
{
|
|
||||||
if (!pageloaded[page])
|
|
||||||
printf("NULL %s%s",page<MY_UCA_NPAGES-1?",":"", (page+1) % 4 ? "":"\n");
|
|
||||||
else
|
|
||||||
printf("page%03Xdata%s%s",page,page<MY_UCA_NPAGES-1?",":"", (page+1) % 4 ? "":"\n");
|
|
||||||
}
|
|
||||||
printf("};\n");
|
|
||||||
|
|
||||||
printf("int main(void){ return 0;};\n");
|
printf("int main(void){ return 0;};\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue