summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2002-05-28 22:43:10 +0300
committerunknown <bell@sanja.is.com.ua>2002-05-28 22:43:10 +0300
commit56f154165c9ea67a385f194d6c5709b673abb927 (patch)
tree33e3a08d824e5e8b3ce14a6afebc19a32df09d29
parent3d9cd36f47649a5693695576d3e6fb9dfd6648d9 (diff)
parent3cdaf67e9c0a5f35dc9c934f2fe3b09c561d8c49 (diff)
downloadmariadb-git-56f154165c9ea67a385f194d6c5709b673abb927.tar.gz
merging
mysql-test/r/derived.result: Auto merged mysql-test/t/derived.test: Auto merged
-rw-r--r--heap/hp_open.c4
-rw-r--r--heap/hp_write.c27
-rw-r--r--include/my_tree.h5
-rw-r--r--mysql-test/r/derived.result4
-rw-r--r--mysql-test/t/derived.test1
-rw-r--r--mysys/tree.c5
-rw-r--r--sql/sql_derived.cc10
7 files changed, 35 insertions, 21 deletions
diff --git a/heap/hp_open.c b/heap/hp_open.c
index 3aa35e2cf88..d48423c506a 100644
--- a/heap/hp_open.c
+++ b/heap/hp_open.c
@@ -99,8 +99,8 @@ HP_INFO *heap_open(const char *name, int mode, uint keys, HP_KEYDEF *keydef,
if (keydef[i].algorithm == HA_KEY_ALG_BTREE)
{
- init_tree(&keyinfo->rb_tree, 0, 0, 0, (qsort_cmp2)keys_compare, 1,
- NULL, NULL);
+ init_tree(&keyinfo->rb_tree, 0, 0, sizeof(byte*),
+ (qsort_cmp2)keys_compare, 1, NULL, NULL);
keyinfo->delete_key= hp_rb_delete_key;
keyinfo->write_key= hp_rb_write_key;
nsegs++;
diff --git a/heap/hp_write.c b/heap/hp_write.c
index fcfe922d9c0..3e74a98b23c 100644
--- a/heap/hp_write.c
+++ b/heap/hp_write.c
@@ -96,22 +96,23 @@ int hp_rb_write_key(HP_INFO *info, HP_KEYDEF *keyinfo, const byte *record,
info->last_pos= NULL; /* For heap_rnext/heap_rprev */
custom_arg.keyseg= keyinfo->seg;
custom_arg.key_length= hp_rb_make_key(keyinfo, info->recbuf, record, recpos);
- if ((keyinfo->flag & HA_NOSAME) &&
- (!(keyinfo->flag & HA_NULL_PART_KEY) ||
- !hp_if_null_in_key(keyinfo, record)))
+ if (keyinfo->flag & HA_NOSAME)
{
custom_arg.search_flag= SEARCH_FIND | SEARCH_SAME;
- if (tree_search_key(&keyinfo->rb_tree, info->recbuf, info->parents,
- &info->last_pos, 0, &custom_arg))
- {
- my_errno= HA_ERR_FOUND_DUPP_KEY;
- return 1;
- }
+ keyinfo->rb_tree.flag= TREE_NO_DUPS;
+ }
+ else
+ {
+ custom_arg.search_flag= SEARCH_SAME;
+ keyinfo->rb_tree.flag= 0;
+ }
+ if (!tree_insert(&keyinfo->rb_tree, (void*)info->recbuf,
+ custom_arg.key_length, &custom_arg))
+ {
+ my_errno= HA_ERR_FOUND_DUPP_KEY;
+ return 1;
}
- custom_arg.search_flag= SEARCH_SAME;
- return tree_insert(&keyinfo->rb_tree, (void*)info->recbuf,
- custom_arg.key_length + sizeof(byte*),
- &custom_arg) ? 0 : 1;
+ return 0;
}
/* Find where to place new record */
diff --git a/include/my_tree.h b/include/my_tree.h
index 826c2b7c808..bfe441f54a6 100644
--- a/include/my_tree.h
+++ b/include/my_tree.h
@@ -27,6 +27,8 @@ extern "C" {
#define tree_set_pointer(element,ptr) *((byte **) (element+1))=((byte*) (ptr))
+#define TREE_NO_DUPS 1
+
typedef enum { left_root_right, right_root_left } TREE_WALK;
typedef uint32 element_count;
typedef int (*tree_walk_action)(void *,element_count,void *);
@@ -55,10 +57,11 @@ typedef struct st_tree {
TREE_ELEMENT **parents[MAX_TREE_HEIGHT];
uint offset_to_key,elements_in_tree,size_of_element,memory_limit,allocated;
qsort_cmp2 compare;
- void* custom_arg;
+ void *custom_arg;
MEM_ROOT mem_root;
my_bool with_delete;
tree_element_free free;
+ uint flag;
} TREE;
/* Functions on whole tree */
diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result
index 822993a7bf2..e05be96c6b7 100644
--- a/mysql-test/r/derived.result
+++ b/mysql-test/r/derived.result
@@ -7,6 +7,10 @@ select t1.a,t3.y from t1,(select a as y from t2 where b='c') as t3 where t1.a
a y
3 3
3 3
+select t1.a,t3.a from t1,(select * from t2 where b='c') as t3 where t1.a = t3.a;
+a a
+3 3
+3 3
CREATE TABLE t3 (a int not null, b char (10) not null);
insert into t3 values (3,'f'),(4,'y'),(5,'z'),(6,'c');
select t1.a,t4.y from t1,(select t2.a as y from t2,(select t3.b from t3 where t3.a>3) as t5 where t2.b=t5.b) as t4 where t1.a = t4.y;
diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test
index c5f57007e54..76ef5fba351 100644
--- a/mysql-test/t/derived.test
+++ b/mysql-test/t/derived.test
@@ -4,6 +4,7 @@ insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c');
CREATE TABLE t2 (a int not null, b char (10) not null);
insert into t2 values (3,'c'),(4,'d'),(5,'f'),(6,'e');
select t1.a,t3.y from t1,(select a as y from t2 where b='c') as t3 where t1.a = t3.y;
+select t1.a,t3.a from t1,(select * from t2 where b='c') as t3 where t1.a = t3.a;
CREATE TABLE t3 (a int not null, b char (10) not null);
insert into t3 values (3,'f'),(4,'y'),(5,'z'),(6,'c');
select t1.a,t4.y from t1,(select t2.a as y from t2,(select t3.b from t3 where t3.a>3) as t5 where t2.b=t5.b) as t4 where t1.a = t4.y;
diff --git a/mysys/tree.c b/mysys/tree.c
index 1bd49ef5182..489262fcdc7 100644
--- a/mysys/tree.c
+++ b/mysys/tree.c
@@ -86,6 +86,7 @@ void init_tree(TREE *tree, uint default_alloc_size, uint memory_limit,
tree->custom_arg = custom_arg;
tree->null_element.colour=BLACK;
tree->null_element.left=tree->null_element.right=0;
+ tree->flag= 0;
if (!free_element && size >= 0 &&
((uint) size <= sizeof(void*) || ((uint) size & (sizeof(void*)-1))))
{
@@ -231,7 +232,11 @@ TREE_ELEMENT *tree_insert(TREE *tree, void *key, uint key_size,
rb_insert(tree,parent,element); /* rebalance tree */
}
else
+ {
+ if (tree->flag & TREE_NO_DUPS)
+ return(NULL);
element->count++;
+ }
DBUG_EXECUTE("check_tree", test_rb_tree(tree->root););
return element;
}
diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc
index 4a64c30e7e5..fb40a85fd91 100644
--- a/sql/sql_derived.cc
+++ b/sql/sql_derived.cc
@@ -75,11 +75,11 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *t)
}
bzero((char*) &tmp_table_param,sizeof(tmp_table_param));
tmp_table_param.field_count=item_list.elements;
- if (!(table= create_tmp_table(thd, &tmp_table_param, sl->item_list,
- (ORDER*) 0, 0, 1, 0,
- (sl->options | thd->options |
- TMP_TABLE_ALL_COLUMNS),
- unit)))
+ if (!(table=create_tmp_table(thd, &tmp_table_param, item_list,
+ (ORDER*) 0, 0, 1, 0,
+ (sl->options | thd->options |
+ TMP_TABLE_ALL_COLUMNS),
+ unit)))
{
res=-1;
goto exit;