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
ad62ba83
Commit
ad62ba83
authored
Jul 22, 2003
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed bug 663 and WL 1052 (sql_mode is safe for mysqldump)
parent
603c89a0
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
71 additions
and
3 deletions
+71
-3
client/mysqldump.c
client/mysqldump.c
+13
-0
mysql-test/r/auto_increment.result
mysql-test/r/auto_increment.result
+25
-0
mysql-test/t/auto_increment.test
mysql-test/t/auto_increment.test
+14
-0
sql/field_conv.cc
sql/field_conv.cc
+3
-0
sql/handler.cc
sql/handler.cc
+4
-1
sql/mysql_priv.h
sql/mysql_priv.h
+1
-0
sql/mysqld.cc
sql/mysqld.cc
+1
-1
sql/sql_base.cc
sql/sql_base.cc
+8
-1
sql/sql_insert.cc
sql/sql_insert.cc
+1
-0
sql/table.h
sql/table.h
+1
-0
No files found.
client/mysqldump.c
View file @
ad62ba83
...
@@ -352,6 +352,11 @@ static void write_header(FILE *sql_file, char *db_name)
...
@@ -352,6 +352,11 @@ static void write_header(FILE *sql_file, char *db_name)
mysql_get_server_info
(
&
mysql_connection
));
mysql_get_server_info
(
&
mysql_connection
));
if
(
!
opt_set_names
)
if
(
!
opt_set_names
)
fprintf
(
sql_file
,
"
\n
/*!40101 SET NAMES %s*/;
\n
"
,
default_charset
);
fprintf
(
sql_file
,
"
\n
/*!40101 SET NAMES %s*/;
\n
"
,
default_charset
);
fprintf
(
md_result_file
,
"\
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
\n
\
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
\n
\
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=NO_AUTO_VALUE_ON_ZERO */;
\n
\
"
);
}
}
return
;
return
;
}
/* write_header */
}
/* write_header */
...
@@ -361,6 +366,14 @@ static void write_footer(FILE *sql_file)
...
@@ -361,6 +366,14 @@ static void write_footer(FILE *sql_file)
{
{
if
(
opt_xml
)
if
(
opt_xml
)
fprintf
(
sql_file
,
"</mysqldump>"
);
fprintf
(
sql_file
,
"</mysqldump>"
);
else
{
fprintf
(
md_result_file
,
"
\n
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
\n
\
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
\n
\
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
\n
\
"
);
}
fputs
(
"
\n
"
,
sql_file
);
fputs
(
"
\n
"
,
sql_file
);
}
/* write_footer */
}
/* write_footer */
...
...
mysql-test/r/auto_increment.result
View file @
ad62ba83
...
@@ -150,3 +150,28 @@ select last_insert_id();
...
@@ -150,3 +150,28 @@ select last_insert_id();
last_insert_id()
last_insert_id()
0
0
drop table t1;
drop table t1;
drop table if exists t1;
Warnings:
Note 1051 Unknown table 't1'
create table t1(a int auto_increment,b int null,primary key(a));
SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO;
insert into t1(a,b)values(NULL,1);
insert into t1(a,b)values(200,2);
insert into t1(a,b)values(0,3);
insert into t1(b)values(4);
SET SQL_MODE='';
insert into t1(a,b)values(NULL,5);
insert into t1(a,b)values(300,6);
insert into t1(a,b)values(0,7);
insert into t1(b)values(8);
select * from t1;
a b
1 1
200 2
0 3
201 4
202 5
300 6
301 7
302 8
drop table t1;
mysql-test/t/auto_increment.test
View file @
ad62ba83
...
@@ -106,3 +106,17 @@ select last_insert_id();
...
@@ -106,3 +106,17 @@ select last_insert_id();
drop
table
t1
;
drop
table
t1
;
drop
table
if
exists
t1
;
create
table
t1
(
a
int
auto_increment
,
b
int
null
,
primary
key
(
a
));
SET
SQL_MODE
=
NO_AUTO_VALUE_ON_ZERO
;
insert
into
t1
(
a
,
b
)
values
(
NULL
,
1
);
insert
into
t1
(
a
,
b
)
values
(
200
,
2
);
insert
into
t1
(
a
,
b
)
values
(
0
,
3
);
insert
into
t1
(
b
)
values
(
4
);
SET
SQL_MODE
=
''
;
insert
into
t1
(
a
,
b
)
values
(
NULL
,
5
);
insert
into
t1
(
a
,
b
)
values
(
300
,
6
);
insert
into
t1
(
a
,
b
)
values
(
0
,
7
);
insert
into
t1
(
b
)
values
(
8
);
select
*
from
t1
;
drop
table
t1
;
sql/field_conv.cc
View file @
ad62ba83
...
@@ -172,7 +172,10 @@ set_field_to_null_with_conversions(Field *field, bool no_conversions)
...
@@ -172,7 +172,10 @@ set_field_to_null_with_conversions(Field *field, bool no_conversions)
}
}
field
->
reset
();
field
->
reset
();
if
(
field
==
field
->
table
->
next_number_field
)
if
(
field
==
field
->
table
->
next_number_field
)
{
field
->
table
->
auto_increment_field_is_null
=
true
;
return
0
;
// field is set in handler.cc
return
0
;
// field is set in handler.cc
}
if
(
current_thd
->
count_cuted_fields
)
if
(
current_thd
->
count_cuted_fields
)
{
{
field
->
set_warning
(
MYSQL_ERROR
::
WARN_LEVEL_WARN
,
ER_WARN_NULL_TO_NOTNULL
);
field
->
set_warning
(
MYSQL_ERROR
::
WARN_LEVEL_WARN
,
ER_WARN_NULL_TO_NOTNULL
);
...
...
sql/handler.cc
View file @
ad62ba83
...
@@ -697,7 +697,10 @@ void handler::update_auto_increment()
...
@@ -697,7 +697,10 @@ void handler::update_auto_increment()
longlong
nr
;
longlong
nr
;
THD
*
thd
;
THD
*
thd
;
DBUG_ENTER
(
"update_auto_increment"
);
DBUG_ENTER
(
"update_auto_increment"
);
if
(
table
->
next_number_field
->
val_int
()
!=
0
)
if
(
table
->
auto_increment_field_is_null
)
table
->
auto_increment_field_is_null
=
false
;
else
if
(
table
->
next_number_field
->
val_int
()
!=
0
||
current_thd
->
variables
.
sql_mode
&
MODE_NO_AUTO_VALUE_ON_ZERO
)
{
{
auto_increment_column_changed
=
0
;
auto_increment_column_changed
=
0
;
DBUG_VOID_RETURN
;
DBUG_VOID_RETURN
;
...
...
sql/mysql_priv.h
View file @
ad62ba83
...
@@ -221,6 +221,7 @@ extern CHARSET_INFO *national_charset_info, *table_alias_charset;
...
@@ -221,6 +221,7 @@ extern CHARSET_INFO *national_charset_info, *table_alias_charset;
#define MODE_MYSQL323 32768
#define MODE_MYSQL323 32768
#define MODE_MYSQL40 65536
#define MODE_MYSQL40 65536
#define MODE_ANSI (MODE_MYSQL40*2)
#define MODE_ANSI (MODE_MYSQL40*2)
#define MODE_NO_AUTO_VALUE_ON_ZERO (MODE_ANSI*2)
#define RAID_BLOCK_SIZE 1024
#define RAID_BLOCK_SIZE 1024
...
...
sql/mysqld.cc
View file @
ad62ba83
...
@@ -212,7 +212,7 @@ const char *sql_mode_names[] =
...
@@ -212,7 +212,7 @@ const char *sql_mode_names[] =
"?"
,
"ONLY_FULL_GROUP_BY"
,
"NO_UNSIGNED_SUBTRACTION"
,
"?"
,
"ONLY_FULL_GROUP_BY"
,
"NO_UNSIGNED_SUBTRACTION"
,
"POSTGRESQL"
,
"ORACLE"
,
"MSSQL"
,
"DB2"
,
"SAPDB"
,
"NO_KEY_OPTIONS"
,
"POSTGRESQL"
,
"ORACLE"
,
"MSSQL"
,
"DB2"
,
"SAPDB"
,
"NO_KEY_OPTIONS"
,
"NO_TABLE_OPTIONS"
,
"NO_FIELD_OPTIONS"
,
"MYSQL323"
,
"MYSQL40"
,
"ANSI"
,
"NO_TABLE_OPTIONS"
,
"NO_FIELD_OPTIONS"
,
"MYSQL323"
,
"MYSQL40"
,
"ANSI"
,
NullS
"NO_AUTO_VALUE_ON_ZERO"
,
NullS
};
};
TYPELIB
sql_mode_typelib
=
{
array_elements
(
sql_mode_names
)
-
1
,
""
,
TYPELIB
sql_mode_typelib
=
{
array_elements
(
sql_mode_names
)
-
1
,
""
,
sql_mode_names
};
sql_mode_names
};
...
...
sql/sql_base.cc
View file @
ad62ba83
...
@@ -2245,7 +2245,11 @@ fill_record(List<Item> &fields,List<Item> &values, bool ignore_errors)
...
@@ -2245,7 +2245,11 @@ fill_record(List<Item> &fields,List<Item> &values, bool ignore_errors)
while
((
field
=
(
Item_field
*
)
f
++
))
while
((
field
=
(
Item_field
*
)
f
++
))
{
{
value
=
v
++
;
value
=
v
++
;
if
(
value
->
save_in_field
(
field
->
field
,
0
)
>
0
&&
!
ignore_errors
)
Field
*
rfield
=
field
->
field
;
TABLE
*
table
=
rfield
->
table
;
if
(
rfield
==
table
->
next_number_field
)
table
->
auto_increment_field_is_null
=
false
;
if
(
value
->
save_in_field
(
rfield
,
0
)
>
0
&&
!
ignore_errors
)
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
}
}
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
...
@@ -2263,6 +2267,9 @@ fill_record(Field **ptr,List<Item> &values, bool ignore_errors)
...
@@ -2263,6 +2267,9 @@ fill_record(Field **ptr,List<Item> &values, bool ignore_errors)
while
((
field
=
*
ptr
++
))
while
((
field
=
*
ptr
++
))
{
{
value
=
v
++
;
value
=
v
++
;
TABLE
*
table
=
field
->
table
;
if
(
field
==
table
->
next_number_field
)
table
->
auto_increment_field_is_null
=
false
;
if
(
value
->
save_in_field
(
field
,
0
)
==
1
&&
!
ignore_errors
)
if
(
value
->
save_in_field
(
field
,
0
)
==
1
&&
!
ignore_errors
)
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
}
}
...
...
sql/sql_insert.cc
View file @
ad62ba83
...
@@ -253,6 +253,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
...
@@ -253,6 +253,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
else
else
bulk_insert
=
0
;
bulk_insert
=
0
;
table
->
auto_increment_field_is_null
=
true
;
while
((
values
=
its
++
))
while
((
values
=
its
++
))
{
{
if
(
fields
.
elements
||
!
value_count
)
if
(
fields
.
elements
||
!
value_count
)
...
...
sql/table.h
View file @
ad62ba83
...
@@ -116,6 +116,7 @@ struct st_table {
...
@@ -116,6 +116,7 @@ struct st_table {
my_bool
crashed
;
my_bool
crashed
;
my_bool
is_view
;
my_bool
is_view
;
my_bool
no_keyread
;
my_bool
no_keyread
;
my_bool
auto_increment_field_is_null
;
Field
*
next_number_field
,
/* Set if next_number is activated */
Field
*
next_number_field
,
/* Set if next_number is activated */
*
found_next_number_field
,
/* Set on open */
*
found_next_number_field
,
/* Set on open */
*
rowid_field
;
*
rowid_field
;
...
...
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