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
eb467636
Commit
eb467636
authored
Dec 09, 2008
by
Sergey Glukhov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug#35796 SHOW CREATE TABLE and default value for BIT field
show default value for BIT field in printable format
parent
b7139581
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
3 deletions
+48
-3
mysql-test/r/type_bit.result
mysql-test/r/type_bit.result
+15
-0
mysql-test/t/type_bit.test
mysql-test/t/type_bit.test
+15
-0
sql/item.cc
sql/item.cc
+3
-0
sql/sql_show.cc
sql/sql_show.cc
+15
-3
No files found.
mysql-test/r/type_bit.result
View file @
eb467636
...
...
@@ -708,4 +708,19 @@ HEX(b1) HEX(b2) i2
1 0 100
1 0 200
DROP TABLE t1, t2;
CREATE TABLE IF NOT EXISTS t1 (
f1 bit(2) NOT NULL default b'10',
f2 bit(14) NOT NULL default b'11110000111100'
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f1` bit(2) NOT NULL default b'10',
`f2` bit(14) NOT NULL default b'11110000111100'
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci
DROP TABLE t1;
CREATE TABLE IF NOT EXISTS t1 (
f1 bit(2) NOT NULL default b''
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
ERROR 42000: Invalid default value for 'f1'
End of 5.0 tests
mysql-test/t/type_bit.test
View file @
eb467636
...
...
@@ -352,4 +352,19 @@ SELECT HEX(b1), HEX(b2), i2 FROM t2
DROP
TABLE
t1
,
t2
;
#
# Bug #35796 SHOW CREATE TABLE and default value for BIT field
#
CREATE
TABLE
IF
NOT
EXISTS
t1
(
f1
bit
(
2
)
NOT
NULL
default
b
'10'
,
f2
bit
(
14
)
NOT
NULL
default
b
'11110000111100'
)
ENGINE
=
MyISAM
DEFAULT
CHARSET
=
latin1
COLLATE
=
latin1_general_ci
;
SHOW
CREATE
TABLE
t1
;
DROP
TABLE
t1
;
--
error
ER_INVALID_DEFAULT
CREATE
TABLE
IF
NOT
EXISTS
t1
(
f1
bit
(
2
)
NOT
NULL
default
b
''
)
ENGINE
=
MyISAM
DEFAULT
CHARSET
=
latin1
COLLATE
=
latin1_general_ci
;
--
echo
End
of
5.0
tests
sql/item.cc
View file @
eb467636
...
...
@@ -4950,6 +4950,9 @@ int Item_hex_string::save_in_field(Field *field, bool no_conversions)
ulonglong
nr
;
uint32
length
=
str_value
.
length
();
if
(
!
length
)
return
1
;
if
(
length
>
8
)
{
nr
=
field
->
flags
&
UNSIGNED_FLAG
?
ULONGLONG_MAX
:
LONGLONG_MAX
;
...
...
sql/sql_show.cc
View file @
eb467636
...
...
@@ -798,7 +798,7 @@ static bool get_field_default_value(THD *thd, TABLE *table,
{
bool
has_default
;
bool
has_now_default
;
enum
enum_field_types
field_type
=
field
->
type
();
/*
We are using CURRENT_TIMESTAMP instead of NOW because it is
more standard
...
...
@@ -806,7 +806,7 @@ static bool get_field_default_value(THD *thd, TABLE *table,
has_now_default
=
table
->
timestamp_field
==
field
&&
field
->
unireg_check
!=
Field
::
TIMESTAMP_UN_FIELD
;
has_default
=
(
field
->
type
()
!=
FIELD_TYPE_BLOB
&&
has_default
=
(
field
_type
!=
FIELD_TYPE_BLOB
&&
!
(
field
->
flags
&
NO_DEFAULT_VALUE_FLAG
)
&&
field
->
unireg_check
!=
Field
::
NEXT_NUMBER
&&
!
((
thd
->
variables
.
sql_mode
&
(
MODE_MYSQL323
|
MODE_MYSQL40
))
...
...
@@ -821,7 +821,19 @@ static bool get_field_default_value(THD *thd, TABLE *table,
{
// Not null by default
char
tmp
[
MAX_FIELD_WIDTH
];
String
type
(
tmp
,
sizeof
(
tmp
),
field
->
charset
());
field
->
val_str
(
&
type
);
if
(
field_type
==
MYSQL_TYPE_BIT
)
{
longlong
dec
=
field
->
val_int
();
char
*
ptr
=
longlong2str
(
dec
,
tmp
+
2
,
2
);
uint32
length
=
(
uint32
)
(
ptr
-
tmp
);
tmp
[
0
]
=
'b'
;
tmp
[
1
]
=
'\''
;
tmp
[
length
]
=
'\''
;
type
.
length
(
length
+
1
);
quoted
=
0
;
}
else
field
->
val_str
(
&
type
);
if
(
type
.
length
())
{
String
def_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