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
bedaf376
Commit
bedaf376
authored
Dec 17, 2002
by
bar@bar.mysql.r18.ru
Browse files
Options
Browse Files
Download
Plain Diff
Merge abarkov@work.mysql.com:/home/bk/mysql-4.1
into bar.mysql.r18.ru:/usr/home/bar/mysql-4.1.wrk
parents
0ce4ae35
dbc8dca8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
98 additions
and
25 deletions
+98
-25
include/mysql.h
include/mysql.h
+2
-1
libmysql/libmysql.c
libmysql/libmysql.c
+48
-12
libmysqld/libmysqld.c
libmysqld/libmysqld.c
+48
-12
No files found.
include/mysql.h
View file @
bedaf376
...
...
@@ -119,7 +119,8 @@ typedef struct st_mysql_data {
struct
st_mysql_options
{
unsigned
int
connect_timeout
,
client_flag
;
unsigned
int
port
;
char
*
host
,
*
init_command
,
*
user
,
*
password
,
*
unix_socket
,
*
db
;
char
*
host
,
*
user
,
*
password
,
*
unix_socket
,
*
db
;
struct
st_dynamic_array
*
init_commands
;
char
*
my_cnf_file
,
*
my_cnf_group
,
*
charset_dir
,
*
charset_name
;
char
*
ssl_key
;
/* PEM key file */
char
*
ssl_cert
;
/* PEM cert file */
...
...
libmysql/libmysql.c
View file @
bedaf376
...
...
@@ -935,6 +935,27 @@ static const char *default_options[]=
static
TYPELIB
option_types
=
{
array_elements
(
default_options
)
-
1
,
"options"
,
default_options
};
static
int
add_init_command
(
struct
st_mysql_options
*
options
,
const
char
*
cmd
)
{
char
**
ptr
,
*
tmp
;
if
(
!
options
->
init_commands
)
{
options
->
init_commands
=
(
DYNAMIC_ARRAY
*
)
my_malloc
(
sizeof
(
DYNAMIC_ARRAY
),
MYF
(
MY_WME
));
init_dynamic_array
(
options
->
init_commands
,
sizeof
(
char
*
),
0
,
5
CALLER_INFO
);
}
if
(
!
(
tmp
=
my_strdup
(
cmd
,
MYF
(
MY_WME
)))
||
insert_dynamic
(
options
->
init_commands
,
&
tmp
))
{
my_free
(
tmp
,
MYF
(
MY_ALLOW_ZERO_PTR
));
return
1
;
}
return
0
;
}
static
void
mysql_read_default_options
(
struct
st_mysql_options
*
options
,
const
char
*
filename
,
const
char
*
group
)
{
...
...
@@ -1003,11 +1024,7 @@ static void mysql_read_default_options(struct st_mysql_options *options,
}
break
;
case
8
:
/* init-command */
if
(
opt_arg
)
{
my_free
(
options
->
init_command
,
MYF
(
MY_ALLOW_ZERO_PTR
));
options
->
init_command
=
my_strdup
(
opt_arg
,
MYF
(
MY_WME
));
}
add_init_command
(
options
,
opt_arg
);
break
;
case
9
:
/* host */
if
(
opt_arg
)
...
...
@@ -2328,13 +2345,29 @@ Try also with PIPE or TCP/IP
net
->
compress
=
1
;
if
(
db
&&
mysql_select_db
(
mysql
,
db
))
goto
error
;
if
(
mysql
->
options
.
init_command
)
if
(
mysql
->
options
.
init_commands
)
{
DYNAMIC_ARRAY
*
init_commands
=
mysql
->
options
.
init_commands
;
char
**
ptr
=
(
char
**
)
init_commands
->
buffer
;
char
**
end
=
ptr
+
init_commands
->
elements
;
my_bool
reconnect
=
mysql
->
reconnect
;
mysql
->
reconnect
=
0
;
if
(
mysql_query
(
mysql
,
mysql
->
options
.
init_command
))
for
(;
ptr
<
end
;
ptr
++
)
{
MYSQL_RES
*
res
;
if
(
mysql_query
(
mysql
,
*
ptr
))
goto
error
;
if
(
mysql
->
fields
)
{
if
(
!
(
res
=
mysql_use_result
(
mysql
)))
goto
error
;
mysql_free_result
(
mysql_use_result
(
mysql
));
mysql_free_result
(
res
);
}
}
mysql
->
reconnect
=
reconnect
;
}
...
...
@@ -2579,7 +2612,6 @@ mysql_close(MYSQL *mysql)
my_free
(
mysql
->
user
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
passwd
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
db
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
init_command
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
user
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
host
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
password
,
MYF
(
MY_ALLOW_ZERO_PTR
));
...
...
@@ -2589,6 +2621,11 @@ mysql_close(MYSQL *mysql)
my_free
(
mysql
->
options
.
my_cnf_group
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
charset_dir
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
charset_name
,
MYF
(
MY_ALLOW_ZERO_PTR
));
if
(
mysql
->
options
.
init_commands
)
{
delete_dynamic
(
mysql
->
options
.
init_commands
);
my_free
((
char
*
)
mysql
->
options
.
init_commands
,
MYF
(
MY_WME
));
}
#ifdef HAVE_OPENSSL
mysql_ssl_free
(
mysql
);
#endif
/* HAVE_OPENSSL */
...
...
@@ -3334,8 +3371,7 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg)
mysql
->
options
.
client_flag
&=
~
CLIENT_LOCAL_FILES
;
break
;
case
MYSQL_INIT_COMMAND
:
my_free
(
mysql
->
options
.
init_command
,
MYF
(
MY_ALLOW_ZERO_PTR
));
mysql
->
options
.
init_command
=
my_strdup
(
arg
,
MYF
(
MY_WME
));
add_init_command
(
&
mysql
->
options
,
arg
);
break
;
case
MYSQL_READ_DEFAULT_FILE
:
my_free
(
mysql
->
options
.
my_cnf_file
,
MYF
(
MY_ALLOW_ZERO_PTR
));
...
...
libmysqld/libmysqld.c
View file @
bedaf376
...
...
@@ -451,6 +451,27 @@ static const char *default_options[]=
static
TYPELIB
option_types
=
{
array_elements
(
default_options
)
-
1
,
"options"
,
default_options
};
static
int
add_init_command
(
struct
st_mysql_options
*
options
,
const
char
*
cmd
)
{
char
**
ptr
,
*
tmp
;
if
(
!
options
->
init_commands
)
{
options
->
init_commands
=
(
DYNAMIC_ARRAY
*
)
my_malloc
(
sizeof
(
DYNAMIC_ARRAY
),
MYF
(
MY_WME
));
init_dynamic_array
(
options
->
init_commands
,
sizeof
(
char
*
),
0
,
5
CALLER_INFO
);
}
if
(
!
(
tmp
=
my_strdup
(
cmd
,
MYF
(
MY_WME
)))
||
insert_dynamic
(
options
->
init_commands
,
&
tmp
))
{
my_free
(
tmp
,
MYF
(
MY_ALLOW_ZERO_PTR
));
return
1
;
}
return
0
;
}
static
void
mysql_read_default_options
(
struct
st_mysql_options
*
options
,
const
char
*
filename
,
const
char
*
group
)
{
...
...
@@ -520,11 +541,7 @@ static void mysql_read_default_options(struct st_mysql_options *options,
}
break
;
case
8
:
/* init-command */
if
(
opt_arg
)
{
my_free
(
options
->
init_command
,
MYF
(
MY_ALLOW_ZERO_PTR
));
options
->
init_command
=
my_strdup
(
opt_arg
,
MYF
(
MY_WME
));
}
add_init_command
(
options
,
opt_arg
);
break
;
case
9
:
/* host */
if
(
opt_arg
)
...
...
@@ -1005,13 +1022,29 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
goto
error
;
if
(
db
&&
mysql_select_db
(
mysql
,
db
))
goto
error
;
if
(
mysql
->
options
.
init_command
)
if
(
mysql
->
options
.
init_commands
)
{
DYNAMIC_ARRAY
*
init_commands
=
mysql
->
options
.
init_commands
;
char
**
ptr
=
(
char
**
)
init_commands
->
buffer
;
char
**
end
=
ptr
+
init_commands
->
elements
;
my_bool
reconnect
=
mysql
->
reconnect
;
mysql
->
reconnect
=
0
;
if
(
mysql_query
(
mysql
,
mysql
->
options
.
init_command
))
for
(;
ptr
<
end
;
ptr
++
)
{
MYSQL_RES
*
res
;
if
(
mysql_query
(
mysql
,
*
ptr
))
goto
error
;
if
(
mysql
->
fields
)
{
if
(
!
(
res
=
mysql_use_result
(
mysql
)))
goto
error
;
mysql_free_result
(
mysql_use_result
(
mysql
));
mysql_free_result
(
res
);
}
}
mysql
->
reconnect
=
reconnect
;
}
...
...
@@ -1108,7 +1141,6 @@ mysql_close(MYSQL *mysql)
my_free
(
mysql
->
user
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
passwd
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
db
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
init_command
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
user
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
host
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
password
,
MYF
(
MY_ALLOW_ZERO_PTR
));
...
...
@@ -1118,6 +1150,11 @@ mysql_close(MYSQL *mysql)
my_free
(
mysql
->
options
.
my_cnf_group
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
charset_dir
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
charset_name
,
MYF
(
MY_ALLOW_ZERO_PTR
));
if
(
mysql
->
options
.
init_commands
)
{
delete_dynamic
(
mysql
->
options
.
init_commands
);
my_free
((
char
*
)
mysql
->
options
.
init_commands
,
MYF
(
MY_WME
));
}
/* Clear pointers for better safety */
mysql
->
host_info
=
mysql
->
user
=
mysql
->
passwd
=
mysql
->
db
=
0
;
bzero
((
char
*
)
&
mysql
->
options
,
sizeof
(
mysql
->
options
));
...
...
@@ -1820,8 +1857,7 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg)
mysql
->
options
.
client_flag
&=
~
CLIENT_LOCAL_FILES
;
break
;
case
MYSQL_INIT_COMMAND
:
my_free
(
mysql
->
options
.
init_command
,
MYF
(
MY_ALLOW_ZERO_PTR
));
mysql
->
options
.
init_command
=
my_strdup
(
arg
,
MYF
(
MY_WME
));
add_init_command
(
&
mysql
->
options
,
arg
);
break
;
case
MYSQL_READ_DEFAULT_FILE
:
my_free
(
mysql
->
options
.
my_cnf_file
,
MYF
(
MY_ALLOW_ZERO_PTR
));
...
...
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