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
e5f9e18d
Commit
e5f9e18d
authored
Mar 25, 2004
by
pem@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge fix.
parents
3bf55c9a
63958229
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
86 additions
and
14 deletions
+86
-14
mysql-test/r/auto_increment.result
mysql-test/r/auto_increment.result
+1
-1
mysql-test/r/query_cache.result
mysql-test/r/query_cache.result
+1
-1
mysql-test/r/variables.result
mysql-test/r/variables.result
+1
-1
sql/item_func.cc
sql/item_func.cc
+14
-5
sql/item_func.h
sql/item_func.h
+4
-3
sql/sql_yacc.yy
sql/sql_yacc.yy
+2
-3
tests/client_test.c
tests/client_test.c
+63
-0
No files found.
mysql-test/r/auto_increment.result
View file @
e5f9e18d
...
...
@@ -142,7 +142,7 @@ explain extended select last_insert_id();
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select high_priority no_cache
255
AS `last_insert_id()`
Note 1003 select high_priority no_cache
last_insert_id()
AS `last_insert_id()`
insert into t1 set i = 254;
ERROR 23000: Duplicate entry '254' for key 1
select last_insert_id();
...
...
mysql-test/r/query_cache.result
View file @
e5f9e18d
...
...
@@ -292,7 +292,7 @@ DATABASE()
select ENCRYPT("test") from t1;
ENCRYPT("test")
select LAST_INSERT_ID() from t1;
last_insert_id
()
LAST_INSERT_ID
()
select RAND() from t1;
RAND()
select UNIX_TIMESTAMP() from t1;
...
...
mysql-test/r/variables.result
View file @
e5f9e18d
...
...
@@ -93,7 +93,7 @@ explain extended select @@IDENTITY,last_insert_id(), @@identity;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select high_priority no_cache 345 AS `@@IDENTITY`,
345
AS `last_insert_id()`,345 AS `@@identity`
Note 1003 select high_priority no_cache 345 AS `@@IDENTITY`,
last_insert_id()
AS `last_insert_id()`,345 AS `@@identity`
set big_tables=OFF, big_tables=ON, big_tables=0, big_tables=1, big_tables="OFF", big_tables="ON";
set global concurrent_insert=ON;
show variables like 'concurrent_insert';
...
...
sql/item_func.cc
View file @
e5f9e18d
...
...
@@ -2139,13 +2139,22 @@ longlong Item_func_release_lock::val_int()
}
longlong
Item_func_
set_
last_insert_id
::
val_int
()
longlong
Item_func_last_insert_id
::
val_int
()
{
DBUG_ASSERT
(
fixed
==
1
);
if
(
arg_count
)
{
longlong
value
=
args
[
0
]
->
val_int
();
current_thd
->
insert_id
(
value
);
null_value
=
args
[
0
]
->
null_value
;
return
value
;
}
else
{
Item
*
it
=
get_system_var
(
current_thd
,
OPT_SESSION
,
"last_insert_id"
,
14
,
"last_insert_id()"
);
return
it
->
val_int
();
}
}
/* This function is just used to test speed of different functions */
...
...
sql/item_func.h
View file @
e5f9e18d
...
...
@@ -729,13 +729,14 @@ public:
};
class
Item_func_
set_
last_insert_id
:
public
Item_int_func
class
Item_func_last_insert_id
:
public
Item_int_func
{
public:
Item_func_set_last_insert_id
(
Item
*
a
)
:
Item_int_func
(
a
)
{}
Item_func_last_insert_id
()
:
Item_int_func
()
{}
Item_func_last_insert_id
(
Item
*
a
)
:
Item_int_func
(
a
)
{}
longlong
val_int
();
const
char
*
func_name
()
const
{
return
"last_insert_id"
;
}
void
fix_length_and_dec
()
{
max_length
=
args
[
0
]
->
max_length
;
}
void
fix_length_and_dec
()
{
if
(
arg_count
)
max_length
=
args
[
0
]
->
max_length
;
}
};
class
Item_func_benchmark
:
public
Item_int_func
...
...
sql/sql_yacc.yy
View file @
e5f9e18d
...
...
@@ -2750,13 +2750,12 @@ simple_expr:
}
| LAST_INSERT_ID '(' ')'
{
$$= get_system_var(YYTHD, OPT_SESSION, "last_insert_id", 14,
"last_insert_id()");
$$= new Item_func_last_insert_id();
Lex->safe_to_cache_query= 0;
}
| LAST_INSERT_ID '(' expr ')'
{
$$= new Item_func_
set_
last_insert_id($3);
$$= new Item_func_last_insert_id($3);
Lex->safe_to_cache_query= 0;
}
| LEFT '(' expr ',' expr ')'
...
...
tests/client_test.c
View file @
e5f9e18d
...
...
@@ -8432,6 +8432,68 @@ static void test_union()
myquery
(
rc
);
}
static
void
test_bug3117
()
{
MYSQL_STMT
*
stmt
;
MYSQL_BIND
buffer
;
longlong
lii
;
ulong
length
;
my_bool
is_null
;
int
rc
;
myheader
(
"test_bug3117"
);
rc
=
mysql_query
(
mysql
,
"DROP TABLE IF EXISTS t1"
);
myquery
(
rc
);
rc
=
mysql_query
(
mysql
,
"CREATE TABLE t1 (id int auto_increment primary key)"
);
myquery
(
rc
);
stmt
=
mysql_simple_prepare
(
mysql
,
"SELECT LAST_INSERT_ID()"
);
mystmt_init
(
stmt
);
rc
=
mysql_query
(
mysql
,
"INSERT INTO t1 VALUES (NULL)"
);
myquery
(
rc
);
rc
=
mysql_execute
(
stmt
);
mystmt
(
stmt
,
rc
);
buffer
.
buffer_type
=
MYSQL_TYPE_LONGLONG
;
buffer
.
buffer_length
=
sizeof
(
lii
);
buffer
.
buffer
=
(
char
*
)
&
lii
;
buffer
.
length
=
&
length
;
buffer
.
is_null
=
&
is_null
;
rc
=
mysql_bind_result
(
stmt
,
&
buffer
);
mystmt
(
stmt
,
rc
);
rc
=
mysql_stmt_store_result
(
stmt
);
mystmt
(
stmt
,
rc
);
rc
=
mysql_fetch
(
stmt
);
mystmt
(
stmt
,
rc
);
assert
(
is_null
==
0
&&
lii
==
1
);
fprintf
(
stdout
,
"
\n\t
LAST_INSERT_ID() = 1 ok
\n
"
);
rc
=
mysql_query
(
mysql
,
"INSERT INTO t1 VALUES (NULL)"
);
myquery
(
rc
);
rc
=
mysql_execute
(
stmt
);
mystmt
(
stmt
,
rc
);
rc
=
mysql_fetch
(
stmt
);
mystmt
(
stmt
,
rc
);
assert
(
is_null
==
0
&&
lii
==
2
);
fprintf
(
stdout
,
"
\t
LAST_INSERT_ID() = 2 ok
\n
"
);
mysql_stmt_close
(
stmt
);
rc
=
mysql_query
(
mysql
,
"DROP TABLE t1"
);
myquery
(
rc
);
}
/*
Read and parse arguments and MySQL options from my.cnf
*/
...
...
@@ -8690,6 +8752,7 @@ int main(int argc, char **argv)
test_subqueries_ref
();
/* outer reference in subqueries converted
Item_field -> Item_ref */
test_union
();
/* test union with prepared statements */
test_bug3117
();
/* BUG#3117: LAST_INSERT_ID() */
end_time
=
time
((
time_t
*
)
0
);
total_time
+=
difftime
(
end_time
,
start_time
);
...
...
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