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
5b45ebe8
Commit
5b45ebe8
authored
Jun 21, 2002
by
bar@gw.udmsearch.izhnet.ru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
database default character set is now stored in database directory
parent
d616c901
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
4 deletions
+59
-4
sql/mysql_priv.h
sql/mysql_priv.h
+1
-1
sql/sql_db.cc
sql/sql_db.cc
+56
-2
sql/sql_parse.cc
sql/sql_parse.cc
+1
-1
sql/sql_yacc.yy
sql/sql_yacc.yy
+1
-0
No files found.
sql/mysql_priv.h
View file @
5b45ebe8
...
...
@@ -289,7 +289,7 @@ inline THD *_current_thd(void)
#define prepare_execute(A) ((A)->command == COM_EXECUTE)
int
mysql_create_db
(
THD
*
thd
,
char
*
db
,
uint
create_info
,
bool
silent
);
int
mysql_create_db
(
THD
*
thd
,
char
*
db
,
HA_CREATE_INFO
*
create_info
,
bool
silent
);
int
mysql_rm_db
(
THD
*
thd
,
char
*
db
,
bool
if_exists
,
bool
silent
);
void
mysql_binlog_send
(
THD
*
thd
,
char
*
log_ident
,
ulong
pos
,
ushort
flags
);
int
mysql_rm_table
(
THD
*
thd
,
TABLE_LIST
*
tables
,
my_bool
if_exists
);
...
...
sql/sql_db.cc
View file @
5b45ebe8
...
...
@@ -31,13 +31,15 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp,
/* db-name is already validated when we come here */
int
mysql_create_db
(
THD
*
thd
,
char
*
db
,
uint
create_options
,
bool
silent
)
int
mysql_create_db
(
THD
*
thd
,
char
*
db
,
HA_CREATE_INFO
*
create_info
,
bool
silent
)
{
char
path
[
FN_REFLEN
+
16
];
MY_DIR
*
dirp
;
long
result
=
1
;
int
error
=
0
;
DBUG_ENTER
(
"mysql_create_db"
);
register
File
file
;
uint
create_options
=
create_info
?
create_info
->
options
:
0
;
VOID
(
pthread_mutex_lock
(
&
LOCK_mysql_create_db
));
...
...
@@ -73,6 +75,37 @@ int mysql_create_db(THD *thd, char *db, uint create_options, bool silent)
}
}
/*
Create database options file:
Currently databse default charset is only stored there.
*/
strcat
(
path
,
"/"
);
unpack_dirname
(
path
,
path
);
strcat
(
path
,
"db.opt"
);
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"
);
if
(
my_write
(
file
,(
byte
*
)
path
,
strlen
(
path
),
MYF
(
MY_NABP
+
MY_WME
)))
{
// QQ : should we send more suitable error message?
my_error
(
ER_CANT_CREATE_DB
,
MYF
(
0
),
db
,
my_errno
);
error
=
-
1
;
goto
exit
;
}
my_close
(
file
,
MYF
(
0
));
}
else
{
// QQ : should we send more suitable error message?
my_error
(
ER_CANT_CREATE_DB
,
MYF
(
0
),
db
,
my_errno
);
error
=
-
1
;
goto
exit
;
}
if
(
!
silent
)
{
if
(
!
thd
->
query
)
...
...
@@ -104,7 +137,7 @@ exit2:
DBUG_RETURN
(
error
);
}
const
char
*
del_exts
[]
=
{
".frm"
,
".BAK"
,
".TMD"
,
NullS
};
const
char
*
del_exts
[]
=
{
".frm"
,
".BAK"
,
".TMD"
,
".opt"
,
NullS
};
static
TYPELIB
deletable_extentions
=
{
array_elements
(
del_exts
)
-
1
,
"del_exts"
,
del_exts
};
...
...
@@ -333,6 +366,7 @@ bool mysql_change_db(THD *thd,const char *name)
char
path
[
FN_REFLEN
];
uint
db_access
;
DBUG_ENTER
(
"mysql_change_db"
);
register
File
file
;
if
(
!
dbname
||
!
(
db_length
=
strip_sp
(
dbname
)))
{
...
...
@@ -382,5 +416,25 @@ bool mysql_change_db(THD *thd,const char *name)
thd
->
db
=
dbname
;
thd
->
db_length
=
db_length
;
thd
->
db_access
=
db_access
;
/*
Load database options file:
*/
strcat
(
path
,
"/"
);
unpack_dirname
(
path
,
path
);
strcat
(
path
,
"db.opt"
);
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
)
{
path
[
nbytes
]
=
'\0'
;
// BAR TODO: parse create options
// and extract database default charset
}
my_close
(
file
,
MYF
(
0
));
}
DBUG_RETURN
(
0
);
}
sql/sql_parse.cc
View file @
5b45ebe8
...
...
@@ -2308,7 +2308,7 @@ mysql_execute_command(void)
}
if
(
check_access
(
thd
,
CREATE_ACL
,
lex
->
name
,
0
,
1
))
break
;
res
=
mysql_create_db
(
thd
,
lex
->
name
,
lex
->
create_info
.
options
,
0
);
res
=
mysql_create_db
(
thd
,
lex
->
name
,
&
lex
->
create_info
,
0
);
break
;
}
case
SQLCOM_DROP_DB
:
...
...
sql/sql_yacc.yy
View file @
5b45ebe8
...
...
@@ -798,6 +798,7 @@ create:
lex->sql_command=SQLCOM_CREATE_DB;
lex->name=$4.str;
lex->create_info.options=$3;
lex->create_info.table_charset=lex->charset;
}
| CREATE udf_func_type UDF_SYM ident
{
...
...
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