Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
70d91d43
Commit
70d91d43
authored
Mar 22, 2007
by
gkodinov/kgeorge@magare.gmz
Browse files
Options
Browse Files
Download
Plain Diff
Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into magare.gmz:/home/kgeorge/mysql/autopush/B26207-5.0-opt
parents
99ac2467
ef1bb48a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
96 additions
and
13 deletions
+96
-13
mysql-test/r/insert_select.result
mysql-test/r/insert_select.result
+29
-0
mysql-test/t/insert_select.test
mysql-test/t/insert_select.test
+26
-1
sql/sql_select.h
sql/sql_select.h
+41
-12
No files found.
mysql-test/r/insert_select.result
View file @
70d91d43
...
@@ -744,3 +744,32 @@ f1 f2
...
@@ -744,3 +744,32 @@ f1 f2
2 2
2 2
10 10
10 10
DROP TABLE t1, t2;
DROP TABLE t1, t2;
SET SQL_MODE='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
CREATE TABLE t1 (c VARCHAR(30), INDEX ix_c (c(10)));
CREATE TABLE t2 (d VARCHAR(10));
INSERT INTO t1 (c) VALUES ('7_chars'), ('13_characters');
EXPLAIN
SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c='13_characters') FROM t1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
2 SUBQUERY t1 ref ix_c ix_c 13 const 1 Using where
SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c='13_characters') FROM t1;
(SELECT SUM(LENGTH(c)) FROM t1 WHERE c='13_characters')
13
13
INSERT INTO t2 (d)
SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c='13_characters') FROM t1;
INSERT INTO t2 (d)
SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c='7_chars') FROM t1;
INSERT INTO t2 (d)
SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c IN (SELECT t1.c FROM t1))
FROM t1;
SELECT * FROM t2;
d
13
13
7
7
20
20
DROP TABLE t1,t2;
mysql-test/t/insert_select.test
View file @
70d91d43
...
@@ -306,4 +306,29 @@ INSERT INTO t2 (f1, f2)
...
@@ -306,4 +306,29 @@ INSERT INTO t2 (f1, f2)
SELECT
*
FROM
t2
;
SELECT
*
FROM
t2
;
DROP
TABLE
t1
,
t2
;
DROP
TABLE
t1
,
t2
;
#
# Bug #26207: inserts don't work with shortened index
#
SET
SQL_MODE
=
'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
;
CREATE
TABLE
t1
(
c
VARCHAR
(
30
),
INDEX
ix_c
(
c
(
10
)));
CREATE
TABLE
t2
(
d
VARCHAR
(
10
));
INSERT
INTO
t1
(
c
)
VALUES
(
'7_chars'
),
(
'13_characters'
);
EXPLAIN
SELECT
(
SELECT
SUM
(
LENGTH
(
c
))
FROM
t1
WHERE
c
=
'13_characters'
)
FROM
t1
;
SELECT
(
SELECT
SUM
(
LENGTH
(
c
))
FROM
t1
WHERE
c
=
'13_characters'
)
FROM
t1
;
INSERT
INTO
t2
(
d
)
SELECT
(
SELECT
SUM
(
LENGTH
(
c
))
FROM
t1
WHERE
c
=
'13_characters'
)
FROM
t1
;
INSERT
INTO
t2
(
d
)
SELECT
(
SELECT
SUM
(
LENGTH
(
c
))
FROM
t1
WHERE
c
=
'7_chars'
)
FROM
t1
;
INSERT
INTO
t2
(
d
)
SELECT
(
SELECT
SUM
(
LENGTH
(
c
))
FROM
t1
WHERE
c
IN
(
SELECT
t1
.
c
FROM
t1
))
FROM
t1
;
SELECT
*
FROM
t2
;
DROP
TABLE
t1
,
t2
;
sql/sql_select.h
View file @
70d91d43
...
@@ -488,15 +488,11 @@ extern "C" int refpos_order_cmp(void* arg, const void *a,const void *b);
...
@@ -488,15 +488,11 @@ extern "C" int refpos_order_cmp(void* arg, const void *a,const void *b);
class
store_key
:
public
Sql_alloc
class
store_key
:
public
Sql_alloc
{
{
protected:
Field
*
to_field
;
// Store data here
char
*
null_ptr
;
char
err
;
public:
public:
bool
null_key
;
/* TRUE <=> the value of the key has a null part */
bool
null_key
;
/* TRUE <=> the value of the key has a null part */
enum
store_key_result
{
STORE_KEY_OK
,
STORE_KEY_FATAL
,
STORE_KEY_CONV
};
enum
store_key_result
{
STORE_KEY_OK
,
STORE_KEY_FATAL
,
STORE_KEY_CONV
};
store_key
(
THD
*
thd
,
Field
*
field_arg
,
char
*
ptr
,
char
*
null
,
uint
length
)
store_key
(
THD
*
thd
,
Field
*
field_arg
,
char
*
ptr
,
char
*
null
,
uint
length
)
:
null_
ptr
(
null
),
err
(
0
),
null_key
(
0
)
:
null_
key
(
0
),
null_ptr
(
null
),
err
(
0
)
{
{
if
(
field_arg
->
type
()
==
FIELD_TYPE_BLOB
)
if
(
field_arg
->
type
()
==
FIELD_TYPE_BLOB
)
{
{
...
@@ -510,8 +506,35 @@ class store_key :public Sql_alloc
...
@@ -510,8 +506,35 @@ class store_key :public Sql_alloc
ptr
,
(
uchar
*
)
null
,
1
);
ptr
,
(
uchar
*
)
null
,
1
);
}
}
virtual
~
store_key
()
{}
/* Not actually needed */
virtual
~
store_key
()
{}
/* Not actually needed */
virtual
enum
store_key_result
copy
()
=
0
;
virtual
const
char
*
name
()
const
=
0
;
virtual
const
char
*
name
()
const
=
0
;
/**
@brief sets ignore truncation warnings mode and calls the real copy method
@details this function makes sure truncation warnings when preparing the
key buffers don't end up as errors (because of an enclosing INSERT/UPDATE).
*/
enum
store_key_result
copy
()
{
enum
store_key_result
result
;
enum_check_fields
saved_count_cuted_fields
=
to_field
->
table
->
in_use
->
count_cuted_fields
;
to_field
->
table
->
in_use
->
count_cuted_fields
=
CHECK_FIELD_IGNORE
;
result
=
copy_inner
();
to_field
->
table
->
in_use
->
count_cuted_fields
=
saved_count_cuted_fields
;
return
result
;
}
protected:
Field
*
to_field
;
// Store data here
char
*
null_ptr
;
char
err
;
virtual
enum
store_key_result
copy_inner
()
=
0
;
};
};
...
@@ -531,13 +554,15 @@ class store_key_field: public store_key
...
@@ -531,13 +554,15 @@ class store_key_field: public store_key
copy_field
.
set
(
to_field
,
from_field
,
0
);
copy_field
.
set
(
to_field
,
from_field
,
0
);
}
}
}
}
enum
store_key_result
copy
()
const
char
*
name
()
const
{
return
field_name
;
}
protected:
enum
store_key_result
copy_inner
()
{
{
copy_field
.
do_copy
(
&
copy_field
);
copy_field
.
do_copy
(
&
copy_field
);
null_key
=
to_field
->
is_null
();
null_key
=
to_field
->
is_null
();
return
err
!=
0
?
STORE_KEY_FATAL
:
STORE_KEY_OK
;
return
err
!=
0
?
STORE_KEY_FATAL
:
STORE_KEY_OK
;
}
}
const
char
*
name
()
const
{
return
field_name
;
}
};
};
...
@@ -552,13 +577,15 @@ class store_key_item :public store_key
...
@@ -552,13 +577,15 @@ class store_key_item :public store_key
null_ptr_arg
?
null_ptr_arg
:
item_arg
->
maybe_null
?
null_ptr_arg
?
null_ptr_arg
:
item_arg
->
maybe_null
?
&
err
:
NullS
,
length
),
item
(
item_arg
)
&
err
:
NullS
,
length
),
item
(
item_arg
)
{}
{}
enum
store_key_result
copy
()
const
char
*
name
()
const
{
return
"func"
;
}
protected:
enum
store_key_result
copy_inner
()
{
{
int
res
=
item
->
save_in_field
(
to_field
,
1
);
int
res
=
item
->
save_in_field
(
to_field
,
1
);
null_key
=
to_field
->
is_null
()
||
item
->
null_value
;
null_key
=
to_field
->
is_null
()
||
item
->
null_value
;
return
(
err
!=
0
||
res
>
2
?
STORE_KEY_FATAL
:
(
store_key_result
)
res
);
return
(
err
!=
0
||
res
>
2
?
STORE_KEY_FATAL
:
(
store_key_result
)
res
);
}
}
const
char
*
name
()
const
{
return
"func"
;
}
};
};
...
@@ -574,7 +601,10 @@ class store_key_const_item :public store_key_item
...
@@ -574,7 +601,10 @@ class store_key_const_item :public store_key_item
&
err
:
NullS
,
length
,
item_arg
),
inited
(
0
)
&
err
:
NullS
,
length
,
item_arg
),
inited
(
0
)
{
{
}
}
enum
store_key_result
copy
()
const
char
*
name
()
const
{
return
"const"
;
}
protected:
enum
store_key_result
copy_inner
()
{
{
int
res
;
int
res
;
if
(
!
inited
)
if
(
!
inited
)
...
@@ -589,7 +619,6 @@ class store_key_const_item :public store_key_item
...
@@ -589,7 +619,6 @@ class store_key_const_item :public store_key_item
null_key
=
to_field
->
is_null
()
||
item
->
null_value
;
null_key
=
to_field
->
is_null
()
||
item
->
null_value
;
return
(
err
>
2
?
STORE_KEY_FATAL
:
(
store_key_result
)
err
);
return
(
err
>
2
?
STORE_KEY_FATAL
:
(
store_key_result
)
err
);
}
}
const
char
*
name
()
const
{
return
"const"
;
}
};
};
bool
cp_buffer_from_ref
(
THD
*
thd
,
TABLE_REF
*
ref
);
bool
cp_buffer_from_ref
(
THD
*
thd
,
TABLE_REF
*
ref
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment