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
97d9936f
Commit
97d9936f
authored
Jun 24, 2002
by
bar@gw.udmsearch.izhnet.ru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Database default charset now works:
CREATE DATABASE dbname DEFAULT CHARACTERSET=latin1
parent
5b45ebe8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
9 deletions
+45
-9
.bzrignore
.bzrignore
+1
-0
sql/sql_class.cc
sql/sql_class.cc
+1
-0
sql/sql_class.h
sql/sql_class.h
+2
-1
sql/sql_db.cc
sql/sql_db.cc
+38
-7
sql/sql_table.cc
sql/sql_table.cc
+3
-1
No files found.
.bzrignore
View file @
97d9936f
...
...
@@ -478,3 +478,4 @@ vio/test-ssl
vio/test-sslclient
vio/test-sslserver
vio/viotest-ssl
tests/client_test
sql/sql_class.cc
View file @
97d9936f
...
...
@@ -103,6 +103,7 @@ THD::THD():user_time(0),fatal_error(0),last_insert_id_used(0),
file_id
=
0
;
cond_count
=
0
;
convert_set
=
0
;
db_charset
=
default_charset_info
;
mysys_var
=
0
;
#ifndef DBUG_OFF
dbug_sentry
=
THD_SENTRY_MAGIC
;
...
...
sql/sql_class.h
View file @
97d9936f
...
...
@@ -473,7 +473,8 @@ class THD :public ilink {
ulong
slave_proxy_id
;
NET
*
slave_net
;
// network connection from slave -> m.
my_off_t
log_pos
;
CHARSET_INFO
*
db_charset
;
THD
();
~
THD
();
void
cleanup
(
void
);
...
...
sql/sql_db.cc
View file @
97d9936f
...
...
@@ -25,6 +25,8 @@
#include <direct.h>
#endif
#define MY_DB_OPT_FILE ".db.opt"
static
long
mysql_rm_known_files
(
THD
*
thd
,
MY_DIR
*
dirp
,
const
char
*
db
,
const
char
*
path
,
uint
level
);
...
...
@@ -82,12 +84,12 @@ int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info, bool silent
strcat
(
path
,
"/"
);
unpack_dirname
(
path
,
path
);
strcat
(
path
,
"db.opt"
);
strcat
(
path
,
MY_DB_OPT_FILE
);
if
((
file
=
my_create
(
path
,
CREATE_MODE
,
O_RDWR
|
O_TRUNC
,
MYF
(
MY_WME
)))
>=
0
)
{
sprintf
(
path
,
"
CREATE DATABASE %s DEFAULT CHARACTER SET=%s
\n
"
,
db
,
(
create_info
&&
create_info
->
table_charset
)
?
create_info
->
table_charset
->
name
:
"DEFAULT"
);
sprintf
(
path
,
"
default-character-set=%s
\n
"
,
(
create_info
&&
create_info
->
table_charset
)
?
create_info
->
table_charset
->
name
:
"DEFAULT"
);
if
(
my_write
(
file
,(
byte
*
)
path
,
strlen
(
path
),
MYF
(
MY_NABP
+
MY_WME
)))
{
...
...
@@ -423,15 +425,44 @@ bool mysql_change_db(THD *thd,const char *name)
strcat
(
path
,
"/"
);
unpack_dirname
(
path
,
path
);
strcat
(
path
,
"db.opt"
);
strcat
(
path
,
MY_DB_OPT_FILE
);
if
((
file
=
my_open
(
path
,
O_RDWR
|
O_BINARY
,
MYF
(
MY_WME
)))
>=
0
)
{
int
nbytes
=
my_read
(
file
,(
byte
*
)
path
,
sizeof
(
path
),
MYF
(
0
));
if
(
nbytes
>=
0
)
{
char
*
ln
=
path
;
char
*
pe
=
path
+
nbytes
;
path
[
nbytes
]
=
'\0'
;
// BAR TODO: parse create options
// and extract database default charset
for
(
ln
=
path
;
ln
<
pe
;
)
{
char
*
le
,
*
val
;
for
(
le
=
ln
,
val
=
0
;
le
<
pe
;
le
++
)
{
switch
(
le
[
0
])
{
case
'='
:
le
[
0
]
=
'\0'
;
val
=
le
+
1
;
le
++
;
break
;
case
'\r'
:
case
'\n'
:
le
[
0
]
=
'\0'
;
le
++
;
for
(
;
(
le
[
0
]
==
'\r'
||
le
[
0
]
==
'\n'
)
;
le
++
);
if
(
!
strcmp
(
ln
,
"default-character-set"
)
&&
val
&&
val
[
0
])
{
thd
->
db_charset
=
get_charset_by_name
(
val
,
MYF
(
0
));
}
goto
cnt
;
break
;
}
}
cnt:
ln
=
le
;
}
}
my_close
(
file
,
MYF
(
0
));
}
...
...
sql/sql_table.cc
View file @
97d9936f
...
...
@@ -377,7 +377,9 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
auto_increment
++
;
if
(
!
sql_field
->
charset
)
sql_field
->
charset
=
create_info
->
table_charset
?
create_info
->
table_charset
:
default_charset_info
;
create_info
->
table_charset
:
thd
->
db_charset
?
thd
->
db_charset
:
default_charset_info
;
pos
+=
sql_field
->
pack_length
;
}
if
(
auto_increment
>
1
)
...
...
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