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
14a24665
Commit
14a24665
authored
Oct 01, 2003
by
vva@eagle.mysql.r18.ru
Browse files
Options
Browse Files
Download
Plain Diff
Merge eagle.mysql.r18.ru:/home/vva/work/mysql.orig/clear/mysql-4.0
into eagle.mysql.r18.ru:/home/vva/work/BUG_1194/mysql-4.0
parents
7aae6ba4
761c7906
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
119 additions
and
26 deletions
+119
-26
mysql-test/r/user_var.result
mysql-test/r/user_var.result
+32
-0
mysql-test/t/user_var.test
mysql-test/t/user_var.test
+19
-0
sql/item_func.cc
sql/item_func.cc
+36
-26
sql/item_func.h
sql/item_func.h
+32
-0
No files found.
mysql-test/r/user_var.result
View file @
14a24665
...
@@ -42,3 +42,35 @@ select @a:=10, @b:=2, @a > @b, @a < @b;
...
@@ -42,3 +42,35 @@ select @a:=10, @b:=2, @a > @b, @a < @b;
select @a:="10", @b:="2", @a > @b, @a < @b;
select @a:="10", @b:="2", @a > @b, @a < @b;
@a:="10" @b:="2" @a > @b @a < @b
@a:="10" @b:="2" @a > @b @a < @b
10 2 0 1
10 2 0 1
select @a:=1;
@a:=1
1
select @a, @a:=1;
@a @a:=1
1 1
create table t1 (id int);
insert into t1 values (1);
select @c:=0;
@c:=0
0
update t1 SET id=(@c:=@c+1);
select @c;
@c
1
select @c:=0;
@c:=0
0
update t1 set id=(@c:=@c+1);
select @c;
@c
1
select @c:=0;
@c:=0
0
select @c:=@c+1;
@c:=@c+1
1
drop table t1;
select @a:=10, @b:=2, @a>@b, @a:="10", @b:="2", @a>@b, @a:=10, @b:=2, @a>@b, @a:="10", @b:="2", @a>@b;
@a:=10 @b:=2 @a>@b @a:="10" @b:="2" @a>@b @a:=10 @b:=2 @a>@b @a:="10" @b:="2" @a>@b
10 2 1 10 2 0 10 2 1 10 2 0
mysql-test/t/user_var.test
View file @
14a24665
...
@@ -23,3 +23,22 @@ select @a:=10, @b:=1, @a > @b, @a < @b;
...
@@ -23,3 +23,22 @@ select @a:=10, @b:=1, @a > @b, @a < @b;
select
@
a
:=
"10"
,
@
b
:=
"1"
,
@
a
>
@
b
,
@
a
<
@
b
;
select
@
a
:=
"10"
,
@
b
:=
"1"
,
@
a
>
@
b
,
@
a
<
@
b
;
select
@
a
:=
10
,
@
b
:=
2
,
@
a
>
@
b
,
@
a
<
@
b
;
select
@
a
:=
10
,
@
b
:=
2
,
@
a
>
@
b
,
@
a
<
@
b
;
select
@
a
:=
"10"
,
@
b
:=
"2"
,
@
a
>
@
b
,
@
a
<
@
b
;
select
@
a
:=
"10"
,
@
b
:=
"2"
,
@
a
>
@
b
,
@
a
<
@
b
;
# Fixed bug #1194
select
@
a
:=
1
;
select
@
a
,
@
a
:=
1
;
create
table
t1
(
id
int
);
insert
into
t1
values
(
1
);
select
@
c
:=
0
;
update
t1
SET
id
=
(
@
c
:=@
c
+
1
);
select
@
c
;
select
@
c
:=
0
;
update
t1
set
id
=
(
@
c
:=@
c
+
1
);
select
@
c
;
select
@
c
:=
0
;
select
@
c
:=@
c
+
1
;
drop
table
t1
;
# just fof fun :)
select
@
a
:=
10
,
@
b
:=
2
,
@
a
>@
b
,
@
a
:=
"10"
,
@
b
:=
"2"
,
@
a
>@
b
,
@
a
:=
10
,
@
b
:=
2
,
@
a
>@
b
,
@
a
:=
"10"
,
@
b
:=
"2"
,
@
a
>@
b
;
\ No newline at end of file
sql/item_func.cc
View file @
14a24665
...
@@ -1899,52 +1899,61 @@ void Item_func_set_user_var::update_hash(void *ptr, uint length,
...
@@ -1899,52 +1899,61 @@ void Item_func_set_user_var::update_hash(void *ptr, uint length,
return
;
return
;
}
}
bool
bool
Item_func_set_user_var
::
update
()
Item_func_set_user_var
::
update
()
{
{
DBUG_ENTER
(
"Item_func_set_user_var::update"
);
switch
(
cached_result_type
)
{
switch
(
cached_result_type
)
{
case
REAL_RESULT
:
case
REAL_RESULT
:
(
void
)
native_val
();
break
;
(
void
)
val
();
case
INT_RESULT
:
(
void
)
native_val_int
();
break
;
break
;
case
STRING_RESULT
:
(
void
)
native_val_str
();
break
;
case
INT_RESULT
:
(
void
)
val_int
();
break
;
case
STRING_RESULT
:
char
buffer
[
MAX_FIELD_WIDTH
];
String
tmp
(
buffer
,
sizeof
(
buffer
));
(
void
)
val_str
(
&
tmp
);
break
;
}
}
return
current_thd
->
fatal_error
;
DBUG_RETURN
(
current_thd
->
fatal_error
)
;
}
}
double
double
Item_func_set_user_var
::
val
()
Item_func_set_user_var
::
val
()
{
{
double
value
=
args
[
0
]
->
val
();
DBUG_ENTER
(
"Item_func_set_user_var::val"
);
update_hash
((
void
*
)
&
value
,
sizeof
(
value
),
REAL_RESULT
);
switch
(
cached_result_type
)
{
return
value
;
case
REAL_RESULT
:
return
native_val
();
break
;
case
INT_RESULT
:
return
native_val_int
();
break
;
case
STRING_RESULT
:
{
String
*
res
=
native_val_str
();
return
!
res
?
0
:
atof
(
res
->
c_ptr
());
}
}
DBUG_RETURN
(
args
[
0
]
->
val
());
}
}
longlong
longlong
Item_func_set_user_var
::
val_int
()
Item_func_set_user_var
::
val_int
()
{
{
longlong
value
=
args
[
0
]
->
val_int
();
DBUG_ENTER
(
"Item_func_set_user_var::val_int"
);
update_hash
((
void
*
)
&
value
,
sizeof
(
longlong
),
INT_RESULT
);
switch
(
cached_result_type
)
{
return
value
;
case
REAL_RESULT
:
return
(
longlong
)
native_val
();
break
;
case
INT_RESULT
:
return
native_val_int
();
break
;
case
STRING_RESULT
:
{
String
*
res
=
native_val_str
();
return
!
res
?
0
:
strtoull
(
res
->
c_ptr
(),
NULL
,
10
);
}
}
DBUG_RETURN
(
args
[
0
]
->
val_int
());
}
}
String
*
String
*
Item_func_set_user_var
::
val_str
(
String
*
str
)
Item_func_set_user_var
::
val_str
(
String
*
str
)
{
{
String
*
res
=
args
[
0
]
->
val_str
(
str
);
DBUG_ENTER
(
"Item_func_set_user_var::val_str"
);
if
(
!
res
)
// Null value
switch
(
cached_result_type
)
{
update_hash
((
void
*
)
0
,
0
,
STRING_RESULT
);
case
REAL_RESULT
:
str
->
set
(
native_val
(),
decimals
);
break
;
else
case
INT_RESULT
:
str
->
set
(
native_val_int
(),
decimals
);
break
;
update_hash
(
res
->
c_ptr
(),
res
->
length
()
+
1
,
STRING_RESULT
);
case
STRING_RESULT
:
str
=
native_val_str
(
str
);
break
;
return
res
;
}
DBUG_RETURN
(
str
);
}
}
...
@@ -1973,6 +1982,7 @@ user_var_entry *Item_func_get_user_var::get_entry()
...
@@ -1973,6 +1982,7 @@ user_var_entry *Item_func_get_user_var::get_entry()
String
*
String
*
Item_func_get_user_var
::
val_str
(
String
*
str
)
Item_func_get_user_var
::
val_str
(
String
*
str
)
{
{
DBUG_ENTER
(
"Item_func_get_user_var::val_str"
);
user_var_entry
*
entry
=
get_entry
();
user_var_entry
*
entry
=
get_entry
();
if
(
!
entry
)
if
(
!
entry
)
return
NULL
;
return
NULL
;
...
@@ -1991,7 +2001,7 @@ Item_func_get_user_var::val_str(String *str)
...
@@ -1991,7 +2001,7 @@ Item_func_get_user_var::val_str(String *str)
}
}
break
;
break
;
}
}
return
str
;
DBUG_RETURN
(
str
)
;
}
}
...
...
sql/item_func.h
View file @
14a24665
...
@@ -889,6 +889,38 @@ class Item_func_set_user_var :public Item_func
...
@@ -889,6 +889,38 @@ class Item_func_set_user_var :public Item_func
LEX_STRING
name
;
LEX_STRING
name
;
user_var_entry
*
entry
;
user_var_entry
*
entry
;
double
native_val
()
{
double
value
=
args
[
0
]
->
val
();
update_hash
((
void
*
)
&
value
,
sizeof
(
value
),
REAL_RESULT
);
return
value
;
}
longlong
native_val_int
()
{
longlong
value
=
args
[
0
]
->
val_int
();
update_hash
((
void
*
)
&
value
,
sizeof
(
longlong
),
INT_RESULT
);
return
value
;
}
String
*
native_val_str
(
String
*
str
)
{
char
buffer
[
MAX_FIELD_WIDTH
];
String
*
res
=
args
[
0
]
->
val_str
(
str
);
if
(
!
res
)
// Null value
update_hash
((
void
*
)
0
,
0
,
STRING_RESULT
);
else
update_hash
(
res
->
c_ptr
(),
res
->
length
()
+
1
,
STRING_RESULT
);
return
res
;
}
String
*
native_val_str
()
{
char
buffer
[
MAX_FIELD_WIDTH
];
String
tmp
(
buffer
,
sizeof
(
buffer
));
return
native_val_str
(
&
tmp
);
}
public:
public:
Item_func_set_user_var
(
LEX_STRING
a
,
Item
*
b
)
:
Item_func
(
b
),
name
(
a
)
{}
Item_func_set_user_var
(
LEX_STRING
a
,
Item
*
b
)
:
Item_func
(
b
),
name
(
a
)
{}
double
val
();
double
val
();
...
...
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