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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
aaf661fc
Commit
aaf661fc
authored
Oct 01, 2004
by
jan@hundin.mysql.fi
Browse files
Options
Browse Files
Download
Plain Diff
Merge jlindstrom@build.mysql.com:/home/bk/mysql-4.1
into hundin.mysql.fi:/home/jan/mysql-4.1
parents
2be1005b
48006039
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
75 additions
and
49 deletions
+75
-49
mysql-test/mysql-test-run.sh
mysql-test/mysql-test-run.sh
+3
-1
mysql-test/r/order_by.result
mysql-test/r/order_by.result
+3
-6
mysql-test/t/client_test.test
mysql-test/t/client_test.test
+1
-1
mysql-test/t/mysql_protocols.test
mysql-test/t/mysql_protocols.test
+3
-3
mysql-test/t/order_by.test
mysql-test/t/order_by.test
+3
-2
ndb/src/mgmclient/CommandInterpreter.cpp
ndb/src/mgmclient/CommandInterpreter.cpp
+6
-4
sql/item.cc
sql/item.cc
+9
-7
sql/mysql_priv.h
sql/mysql_priv.h
+2
-1
sql/sql_base.cc
sql/sql_base.cc
+28
-15
sql/sql_select.cc
sql/sql_select.cc
+17
-9
No files found.
mysql-test/mysql-test-run.sh
View file @
aaf661fc
...
...
@@ -507,6 +507,7 @@ if [ x$SOURCE_DIST = x1 ] ; then
fi
CLIENT_BINDIR
=
"
$BASEDIR
/client"
TESTS_BINDIR
=
"
$BASEDIR
/tests"
MYSQLADMIN
=
"
$CLIENT_BINDIR
/mysqladmin"
WAIT_PID
=
"
$BASEDIR
/extra/mysql_waitpid"
MYSQL_MANAGER_CLIENT
=
"
$CLIENT_BINDIR
/mysqlmanagerc"
...
...
@@ -525,6 +526,7 @@ else
MYSQLD
=
"
$VALGRIND
$BASEDIR
/bin/mysqld"
fi
CLIENT_BINDIR
=
"
$BASEDIR
/bin"
TESTS_BINDIR
=
"
$BASEDIR
/tests"
MYSQL_TEST
=
"
$CLIENT_BINDIR
/mysqltest"
MYSQL_DUMP
=
"
$CLIENT_BINDIR
/mysqldump"
MYSQL_BINLOG
=
"
$CLIENT_BINDIR
/mysqlbinlog"
...
...
@@ -582,7 +584,7 @@ MYSQL_DUMP="$MYSQL_DUMP --no-defaults -uroot --socket=$MASTER_MYSOCK --password=
MYSQL_BINLOG
=
"
$MYSQL_BINLOG
--no-defaults --local-load=
$MYSQL_TMP_DIR
$EXTRA_MYSQLBINLOG_OPT
"
MYSQL_FIX_SYSTEM_TABLES
=
"
$MYSQL_FIX_SYSTEM_TABLES
--no-defaults --host=localhost --port=
$MASTER_MYPORT
--socket=
$MASTER_MYSOCK
--user=root --password=
$DBPASSWD
--basedir=
$BASEDIR
--bindir=
$CLIENT_BINDIR
--verbose"
MYSQL
=
"
$MYSQL
--host=localhost --port=
$MASTER_MYPORT
--socket=
$MASTER_MYSOCK
--user=root --password=
$DBPASSWD
"
export
MYSQL MYSQL_DUMP MYSQL_BINLOG MYSQL_FIX_SYSTEM_TABLES CLIENT_BINDIR
export
MYSQL MYSQL_DUMP MYSQL_BINLOG MYSQL_FIX_SYSTEM_TABLES CLIENT_BINDIR
TESTS_BINDIR
MYSQL_TEST_ARGS
=
"--no-defaults --socket=
$MASTER_MYSOCK
--database=
$DB
\
--user=
$DBUSER
--password=
$DBPASSWD
--silent -v --skip-safemalloc
\
...
...
mysql-test/r/order_by.result
View file @
aaf661fc
...
...
@@ -680,6 +680,9 @@ order by col;
ERROR 23000: Column 'col' in order clause is ambiguous
select col1 from t1, t2 where t1.col1=t2.col2 order by col;
ERROR 23000: Column 'col' in order clause is ambiguous
select t1.col as t1_col, t2.col2 from t1, t2 where t1.col1=t2.col2
order by col;
ERROR 23000: Column 'col' in order clause is ambiguous
select t1.col as t1_col, t2.col from t1, t2 where t1.col1=t2.col2
order by col;
t1_col col
...
...
@@ -696,12 +699,6 @@ col col2
1 3
2 2
3 1
select t1.col as t1_col, t2.col2 from t1, t2 where t1.col1=t2.col2
order by col;
t1_col col2
1 1
2 2
3 3
select t2.col2, t2.col, t2.col from t2 order by col;
col2 col col
3 1 1
...
...
mysql-test/t/client_test.test
View file @
aaf661fc
--
disable_result_log
--
exec
../
tests
/
client_test
--
testcase
--
user
=
root
--
socket
=
var
/
tmp
/
master
.
sock
--
port
=
$MYSQL_TCP_PORT
--
exec
$TESTS_BINDIR
/
client_test
--
testcase
--
user
=
root
--
socket
=
var
/
tmp
/
master
.
sock
--
port
=
$MYSQL_TCP_PORT
mysql-test/t/mysql_protocols.test
View file @
aaf661fc
...
...
@@ -4,7 +4,7 @@
--
exec
echo
"select ' ok' as '<default>'"
|
$MYSQL
--
exec
echo
"select ' ok' as 'TCP'"
|
$MYSQL
--
protocol
=
TCP
--
exec
echo
"select ' ok' as 'SOCKET'"
|
$MYSQL
--
protocol
=
SOCKET
--
exec
echo
"select ' ok' as 'PIPE'"
|
$MYSQL
--
protocol
=
PIPE
2
>&
1
--
exec
echo
"select ' ok' as 'MEMORY'"
|
$MYSQL
--
protocol
=
MEMORY
2
>&
1
--
exec
echo
"select ' ok' as 'NullS'"
|
$MYSQL
--
protocol
=
NullS
2
>&
1
--
exec
echo
"select ' ok' as 'PIPE'"
|
$MYSQL
--
protocol
=
PIPE
2
>&
1
||
true
--
exec
echo
"select ' ok' as 'MEMORY'"
|
$MYSQL
--
protocol
=
MEMORY
2
>&
1
||
true
--
exec
echo
"select ' ok' as 'NullS'"
|
$MYSQL
--
protocol
=
NullS
2
>&
1
||
true
mysql-test/t/order_by.test
View file @
aaf661fc
...
...
@@ -472,13 +472,14 @@ select t1.col as c1, t2.col as c2 from t1, t2 where t1.col1=t2.col2
order
by
col
;
--
error
1052
select
col1
from
t1
,
t2
where
t1
.
col1
=
t2
.
col2
order
by
col
;
--
error
1052
select
t1
.
col
as
t1_col
,
t2
.
col2
from
t1
,
t2
where
t1
.
col1
=
t2
.
col2
order
by
col
;
select
t1
.
col
as
t1_col
,
t2
.
col
from
t1
,
t2
where
t1
.
col1
=
t2
.
col2
order
by
col
;
select
col2
as
c
,
col
as
c
from
t2
order
by
col
;
select
col2
as
col
,
col
as
col2
from
t2
order
by
col
;
select
t1
.
col
as
t1_col
,
t2
.
col2
from
t1
,
t2
where
t1
.
col1
=
t2
.
col2
order
by
col
;
select
t2
.
col2
,
t2
.
col
,
t2
.
col
from
t2
order
by
col
;
select
t2
.
col2
as
col
from
t2
order
by
t2
.
col
;
...
...
ndb/src/mgmclient/CommandInterpreter.cpp
View file @
aaf661fc
...
...
@@ -611,10 +611,12 @@ CommandInterpreter::executeHelp(char* parameters)
<<
endl
;
ndbout
<<
"<category> = "
;
for
(
int
i
=
0
;
i
<
CFG_MIN_LOGLEVEL
;
i
++
){
ndbout
<<
ndb_mgm_get_event_category_string
((
ndb_mgm_event_category
)
i
);
if
(
i
<
CFG_MIN_LOGLEVEL
-
1
)
{
for
(
int
i
=
CFG_MIN_LOGLEVEL
;
i
<=
CFG_MAX_LOGLEVEL
;
i
++
){
const
char
*
str
=
ndb_mgm_get_event_category_string
((
ndb_mgm_event_category
)
i
);
if
(
str
)
{
if
(
i
!=
CFG_MIN_LOGLEVEL
)
ndbout
<<
" | "
;
ndbout
<<
str
;
}
}
ndbout
<<
endl
;
...
...
sql/item.cc
View file @
aaf661fc
...
...
@@ -1246,6 +1246,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
TABLE_LIST
*
table_list
;
Item
**
refer
=
(
Item
**
)
not_found_item
;
uint
counter
;
bool
not_used
;
// Prevent using outer fields in subselects, that is not supported now
SELECT_LEX
*
cursel
=
(
SELECT_LEX
*
)
thd
->
lex
->
current_select
;
if
(
cursel
->
master_unit
()
->
first_select
()
->
linkage
!=
DERIVED_TABLE_TYPE
)
...
...
@@ -1288,7 +1289,8 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
}
if
(
sl
->
resolve_mode
==
SELECT_LEX
::
SELECT_MODE
&&
(
refer
=
find_item_in_list
(
this
,
sl
->
item_list
,
&
counter
,
REPORT_EXCEPT_NOT_FOUND
))
!=
REPORT_EXCEPT_NOT_FOUND
,
&
not_used
))
!=
(
Item
**
)
not_found_item
)
{
if
(
*
refer
&&
(
*
refer
)
->
fixed
)
// Avoid crash in case of error
...
...
@@ -1889,6 +1891,7 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
{
DBUG_ASSERT
(
fixed
==
0
);
uint
counter
;
bool
not_used
;
if
(
!
ref
)
{
TABLE_LIST
*
where
=
0
,
*
table_list
;
...
...
@@ -1908,13 +1911,13 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
first_select
()
->
linkage
!=
DERIVED_TABLE_TYPE
)
?
REPORT_EXCEPT_NOT_FOUND
:
REPORT_ALL_ERRORS
)
))
==
REPORT_ALL_ERRORS
),
&
not_used
))
==
(
Item
**
)
not_found_item
)
{
upward_lookup
=
1
;
Field
*
tmp
=
(
Field
*
)
not_found_field
;
/*
We can't find table field in
table
list of current select,
We can't find table field in
select
list of current select,
consequently we have to find it in outer subselect(s).
We can't join lists of outer & current select, because of scope
of view rules. For example if both tables (outer & current) have
...
...
@@ -1929,8 +1932,8 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
Item_subselect
*
prev_subselect_item
=
prev_unit
->
item
;
if
(
sl
->
resolve_mode
==
SELECT_LEX
::
SELECT_MODE
&&
(
ref
=
find_item_in_list
(
this
,
sl
->
item_list
,
&
counter
,
REPORT_EXCEPT_NOT_FOUND
))
!=
&
counter
,
REPORT_EXCEPT_NOT_FOUND
,
&
not_used
))
!=
(
Item
**
)
not_found_item
)
{
if
(
*
ref
&&
(
*
ref
)
->
fixed
)
// Avoid crash in case of error
...
...
@@ -1989,8 +1992,7 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
// Call to report error
find_item_in_list
(
this
,
*
(
thd
->
lex
->
current_select
->
get_item_list
()),
&
counter
,
REPORT_ALL_ERRORS
);
&
counter
,
REPORT_ALL_ERRORS
,
&
not_used
);
}
ref
=
0
;
return
1
;
...
...
sql/mysql_priv.h
View file @
aaf661fc
...
...
@@ -705,7 +705,8 @@ enum find_item_error_report_type {REPORT_ALL_ERRORS, REPORT_EXCEPT_NOT_FOUND,
IGNORE_ERRORS
};
extern
const
Item
**
not_found_item
;
Item
**
find_item_in_list
(
Item
*
item
,
List
<
Item
>
&
items
,
uint
*
counter
,
find_item_error_report_type
report_error
);
find_item_error_report_type
report_error
,
bool
*
unaliased
);
bool
get_key_map_from_key_list
(
key_map
*
map
,
TABLE
*
table
,
List
<
String
>
*
index_list
);
bool
insert_fields
(
THD
*
thd
,
TABLE_LIST
*
tables
,
...
...
sql/sql_base.cc
View file @
aaf661fc
...
...
@@ -2082,6 +2082,9 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables,
return not_found_item, report other errors,
return 0
IGNORE_ERRORS Do not report errors, return 0 if error
unaliased Set to true if item is field which was found
by original field name and not by its alias
in item list. Set to false otherwise.
RETURN VALUES
0 Item is not found or item is not unique,
...
...
@@ -2098,7 +2101,7 @@ const Item **not_found_item= (const Item**) 0x1;
Item
**
find_item_in_list
(
Item
*
find
,
List
<
Item
>
&
items
,
uint
*
counter
,
find_item_error_report_type
report_error
)
find_item_error_report_type
report_error
,
bool
*
unaliased
)
{
List_iterator
<
Item
>
li
(
items
);
Item
**
found
=
0
,
**
found_unaliased
=
0
,
*
item
;
...
...
@@ -2107,6 +2110,9 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter,
const
char
*
table_name
=
0
;
bool
found_unaliased_non_uniq
=
0
;
uint
unaliased_counter
;
*
unaliased
=
FALSE
;
if
(
find
->
type
()
==
Item
::
FIELD_ITEM
||
find
->
type
()
==
Item
::
REF_ITEM
)
{
field_name
=
((
Item_ident
*
)
find
)
->
field_name
;
...
...
@@ -2134,17 +2140,18 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter,
/*
If table name is specified we should find field 'field_name' in
table 'table_name'. According to SQL-standard we should ignore
aliases in this case. Note that we should prefer fields from the
select list over other fields from the tables participating in
this select in case of ambiguity.
aliases in this case.
Since we should NOT prefer fields from the select list over
other fields from the tables participating in this select in
case of ambiguity we have to do extra check outside this function.
We use strcmp for table names and database names as these may be
case sensitive.
In cases where they are not case sensitive, they are always in lower
case.
case sensitive. In cases where they are not case sensitive, they
are always in lower case.
item_field->field_name and item_field->table_name can be 0x0 if
item is not fix
field
ed yet.
item is not fix
_field()'
ed yet.
*/
if
(
item_field
->
field_name
&&
item_field
->
table_name
&&
!
my_strcasecmp
(
system_charset_info
,
item_field
->
field_name
,
...
...
@@ -2153,17 +2160,22 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter,
(
!
db_name
||
(
item_field
->
db_name
&&
!
strcmp
(
item_field
->
db_name
,
db_name
))))
{
if
(
found
)
if
(
found
_unaliased
)
{
if
((
*
found
)
->
eq
(
item
,
0
))
continue
;
// Same field twice
if
((
*
found_unaliased
)
->
eq
(
item
,
0
))
continue
;
/*
Two matching fields in select list.
We already can bail out because we are searching through
unaliased names only and will have duplicate error anyway.
*/
if
(
report_error
!=
IGNORE_ERRORS
)
my_printf_error
(
ER_NON_UNIQ_ERROR
,
ER
(
ER_NON_UNIQ_ERROR
),
MYF
(
0
),
find
->
full_name
(),
current_thd
->
where
);
return
(
Item
**
)
0
;
}
found
=
li
.
ref
();
*
counter
=
i
;
found
_unaliased
=
li
.
ref
();
unaliased_
counter
=
i
;
if
(
db_name
)
break
;
// Perfect match
}
...
...
@@ -2235,6 +2247,7 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter,
{
found
=
found_unaliased
;
*
counter
=
unaliased_counter
;
*
unaliased
=
TRUE
;
}
}
if
(
found
)
...
...
sql/sql_select.cc
View file @
aaf661fc
...
...
@@ -7946,15 +7946,14 @@ find_order_in_list(THD *thd, Item **ref_pointer_array,
TABLE_LIST
*
tables
,
ORDER
*
order
,
List
<
Item
>
&
fields
,
List
<
Item
>
&
all_fields
)
{
Item
*
it
emptr
=
*
order
->
item
;
if
(
it
emptr
->
type
()
==
Item
::
INT_ITEM
)
Item
*
it
=
*
order
->
item
;
if
(
it
->
type
()
==
Item
::
INT_ITEM
)
{
/* Order by position */
uint
count
=
(
uint
)
it
emptr
->
val_int
();
uint
count
=
(
uint
)
it
->
val_int
();
if
(
!
count
||
count
>
fields
.
elements
)
{
my_printf_error
(
ER_BAD_FIELD_ERROR
,
ER
(
ER_BAD_FIELD_ERROR
),
MYF
(
0
),
itemptr
->
full_name
(),
thd
->
where
);
MYF
(
0
),
it
->
full_name
(),
thd
->
where
);
return
1
;
}
order
->
item
=
ref_pointer_array
+
count
-
1
;
...
...
@@ -7962,20 +7961,28 @@ find_order_in_list(THD *thd, Item **ref_pointer_array,
return
0
;
}
uint
counter
;
Item
**
item
=
find_item_in_list
(
itemptr
,
fields
,
&
counter
,
REPORT_EXCEPT_NOT_FOUND
);
bool
unaliased
;
Item
**
item
=
find_item_in_list
(
it
,
fields
,
&
counter
,
REPORT_EXCEPT_NOT_FOUND
,
&
unaliased
);
if
(
!
item
)
return
1
;
if
(
item
!=
(
Item
**
)
not_found_item
)
{
/*
If we have found field not by its alias in select list but by its
original field name, we should additionaly check if we have conflict
for this name (in case if we would perform lookup in all tables).
*/
if
(
unaliased
&&
!
it
->
fixed
&&
it
->
fix_fields
(
thd
,
tables
,
order
->
item
))
return
1
;
order
->
item
=
ref_pointer_array
+
counter
;
order
->
in_field_list
=
1
;
return
0
;
}
order
->
in_field_list
=
0
;
Item
*
it
=
*
order
->
item
;
/*
We check it->fixed because Item_func_group_concat can put
arguments for which fix_fields already was called.
...
...
@@ -8104,10 +8111,11 @@ setup_new_fields(THD *thd,TABLE_LIST *tables,List<Item> &fields,
thd
->
set_query_id
=
1
;
// Not really needed, but...
uint
counter
;
bool
not_used
;
for
(;
new_field
;
new_field
=
new_field
->
next
)
{
if
((
item
=
find_item_in_list
(
*
new_field
->
item
,
fields
,
&
counter
,
IGNORE_ERRORS
)))
IGNORE_ERRORS
,
&
not_used
)))
new_field
->
item
=
item
;
/* Change to shared Item */
else
{
...
...
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