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
45a41e85
Commit
45a41e85
authored
Sep 23, 2003
by
monty@narttu.mysql.fi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code cleanup of new patches
parent
5f164e2f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
93 additions
and
82 deletions
+93
-82
client/mysqlbinlog.cc
client/mysqlbinlog.cc
+58
-67
mysys/default.c
mysys/default.c
+12
-2
mysys/mf_dirname.c
mysys/mf_dirname.c
+23
-13
No files found.
client/mysqlbinlog.cc
View file @
45a41e85
...
...
@@ -20,8 +20,6 @@
#include <time.h>
#include <assert.h>
#include "log_event.h"
#include "include/my_sys.h"
#include "unistd.h"
#define BIN_LOG_HEADER_SIZE 4
#define PROBE_HEADER_LEN (EVENT_LEN_OFFSET+4)
...
...
@@ -75,49 +73,7 @@ class Load_log_processor
int
target_dir_name_len
;
DYNAMIC_ARRAY
file_names
;
const
char
*
create_file
(
Create_file_log_event
*
ce
)
{
const
char
*
bname
=
ce
->
fname
+
ce
->
fname_len
-
1
;
while
(
bname
>
ce
->
fname
&&
bname
[
-
1
]
!=
FN_LIBCHAR
)
bname
--
;
uint
blen
=
ce
->
fname_len
-
(
bname
-
ce
->
fname
);
uint
full_len
=
target_dir_name_len
+
blen
+
9
+
9
+
1
;
char
*
tmp
;
if
(
!
(
tmp
=
my_malloc
(
full_len
,
MYF
(
MY_WME
)))
||
set_dynamic
(
&
file_names
,(
gptr
)
&
ce
,
ce
->
file_id
))
{
die
(
"Could not construct local filename %s%s"
,
target_dir_name
,
bname
);
return
0
;
}
char
*
ptr
=
tmp
;
memcpy
(
ptr
,
target_dir_name
,
target_dir_name_len
);
ptr
+=
target_dir_name_len
;
memcpy
(
ptr
,
bname
,
blen
);
ptr
+=
blen
;
sprintf
(
ptr
,
"-%08x"
,
ce
->
file_id
);
ptr
+=
9
;
uint
version
=
0
;
for
(;;)
{
sprintf
(
ptr
,
"-%08x"
,
version
);
if
(
access
(
tmp
,
F_OK
))
break
;
version
++
;
if
(
version
>
UINT_MAX
)
{
die
(
"Could not construct local filename %s%s"
,
target_dir_name
,
bname
);
return
0
;
}
}
ce
->
set_fname_outside_temp_buf
(
tmp
,
full_len
);
return
tmp
;
}
const
char
*
create_file
(
Create_file_log_event
*
ce
);
void
append_to_file
(
const
char
*
fname
,
int
flags
,
gptr
data
,
uint
size
)
{
...
...
@@ -129,7 +85,6 @@ class Load_log_processor
}
public:
Load_log_processor
()
{
init_dynamic_array
(
&
file_names
,
sizeof
(
Create_file_log_event
*
),
...
...
@@ -142,26 +97,10 @@ class Load_log_processor
delete_dynamic
(
&
file_names
);
}
void
init_by_dir_name
(
const
char
*
atarget_dir_name
)
void
init_by_dir_name
(
const
char
*
dir
)
{
char
*
end
=
strmov
(
target_dir_name
,
atarget_dir_name
);
if
(
end
[
-
1
]
!=
FN_LIBCHAR
)
*
end
++=
FN_LIBCHAR
;
target_dir_name_len
=
end
-
target_dir_name
;
}
void
init_by_file_name
(
const
char
*
file_name
)
{
int
len
=
strlen
(
file_name
);
const
char
*
end
=
file_name
+
len
-
1
;
while
(
end
>
file_name
&&
*
end
!=
FN_LIBCHAR
)
end
--
;
if
(
*
end
!=
FN_LIBCHAR
)
target_dir_name_len
=
0
;
else
{
target_dir_name_len
=
end
-
file_name
+
1
;
memmove
(
target_dir_name
,
file_name
,
target_dir_name_len
);
}
target_dir_name_len
=
(
convert_dirname
(
target_dir_name
,
dir
,
NullS
)
-
target_dir_name
);
}
void
init_by_cur_dir
()
{
...
...
@@ -196,7 +135,8 @@ class Load_log_processor
void
process
(
Create_file_log_event
*
ce
)
{
const
char
*
fname
=
create_file
(
ce
);
append_to_file
(
fname
,
O_CREAT
|
O_EXCL
|
O_BINARY
|
O_WRONLY
,
ce
->
block
,
ce
->
block_len
);
append_to_file
(
fname
,
O_CREAT
|
O_EXCL
|
O_BINARY
|
O_WRONLY
,
ce
->
block
,
ce
->
block_len
);
}
void
process
(
Append_block_log_event
*
ae
)
{
...
...
@@ -204,8 +144,10 @@ class Load_log_processor
*
((
Create_file_log_event
**
)
file_names
.
buffer
+
ae
->
file_id
)
:
0
;
if
(
ce
)
append_to_file
(
ce
->
fname
,
O_APPEND
|
O_BINARY
|
O_WRONLY
,
ae
->
block
,
ae
->
block_len
);
append_to_file
(
ce
->
fname
,
O_APPEND
|
O_BINARY
|
O_WRONLY
,
ae
->
block
,
ae
->
block_len
);
else
{
/*
There is no Create_file event (a bad binlog or a big
--position). Assuming it's a big --position, we just do nothing and
...
...
@@ -214,8 +156,57 @@ class Load_log_processor
fprintf
(
stderr
,
"Warning: ignoring Append_block as there is no \
Create_file event for file_id: %u
\n
"
,
ae
->
file_id
);
}
}
};
const
char
*
Load_log_processor
::
create_file
(
Create_file_log_event
*
ce
)
{
const
char
*
bname
=
ce
->
fname
+
dirname_length
(
ce
->
fname
);
uint
blen
=
ce
->
fname_len
-
(
bname
-
ce
->
fname
);
uint
full_len
=
target_dir_name_len
+
blen
+
9
+
9
+
1
;
uint
version
=
0
;
char
*
tmp
,
*
ptr
;
if
(
!
(
tmp
=
my_malloc
(
full_len
,
MYF
(
MY_WME
)))
||
set_dynamic
(
&
file_names
,(
gptr
)
&
ce
,
ce
->
file_id
))
{
die
(
"Could not construct local filename %s%s"
,
target_dir_name
,
bname
);
return
0
;
}
memcpy
(
tmp
,
target_dir_name
,
target_dir_name_len
);
ptr
=
tmp
+
target_dir_name_len
;
memcpy
(
ptr
,
bname
,
blen
);
ptr
+=
blen
;
ptr
+=
my_sprintf
(
ptr
,(
ptr
,
"-%x"
,
ce
->
file_id
));
/*
Note that this code has a possible race condition if there was was
many simultaneous clients running which tried to create files at the same
time. Fortunately this should never be the case.
A better way to do this would be to use 'create_tmp_file() and avoid this
race condition altogether on the expense of getting more cryptic file
names.
*/
for
(;;)
{
sprintf
(
ptr
,
"-%x"
,
version
);
if
(
access
(
tmp
,
F_OK
))
break
;
/* If we have to try more than 1000 times, something is seriously wrong */
if
(
version
++
>
1000
)
{
die
(
"Could not construct local filename %s%s"
,
target_dir_name
,
bname
);
return
0
;
}
}
ce
->
set_fname_outside_temp_buf
(
tmp
,
full_len
);
return
tmp
;
}
Load_log_processor
load_processor
;
static
struct
my_option
my_long_options
[]
=
...
...
mysys/default.c
View file @
45a41e85
...
...
@@ -375,9 +375,20 @@ static int search_default_file(DYNAMIC_ARRAY *args, MEM_ROOT *alloc,
char
*
value_end
;
for
(
value
++
;
isspace
(
*
value
);
value
++
)
;
value_end
=
strend
(
value
);
/*
We don't have to test for value_end >= value as we know there is
an '=' before
*/
for
(
;
isspace
(
value_end
[
-
1
])
;
value_end
--
)
;
if
(
value_end
<
value
)
/* Empty string */
value_end
=
value
;
/* remove quotes around argument */
if
((
*
value
==
'\"'
||
*
value
==
'\''
)
&&
*
value
==
value_end
[
-
1
])
{
value
++
;
value_end
--
;
}
if
(
!
(
tmp
=
alloc_root
(
alloc
,(
uint
)
(
end
-
ptr
)
+
3
+
(
uint
)
(
value_end
-
value
)
+
1
)))
goto
err
;
...
...
@@ -385,10 +396,9 @@ static int search_default_file(DYNAMIC_ARRAY *args, MEM_ROOT *alloc,
goto
err
;
ptr
=
strnmov
(
strmov
(
tmp
,
"--"
),
ptr
,(
uint
)
(
end
-
ptr
));
*
ptr
++=
'='
;
for
(
;
value
!=
value_end
;
value
++
)
{
if
(
*
value
==
'\"'
||
*
value
==
'\''
)
continue
;
if
(
*
value
==
'\\'
&&
value
!=
value_end
-
1
)
{
switch
(
*++
value
)
{
...
...
mysys/mf_dirname.c
View file @
45a41e85
...
...
@@ -54,8 +54,16 @@ uint dirname_part(my_string to, const char *name)
}
/* dirname */
/*
/*
Convert directory name to use under this system
SYNPOSIS
convert_dirname()
to Store result here
from Original filename
from_end Pointer at end of filename (normally end \0)
IMPLEMENTATION
If MSDOS converts '/' to '\'
If VMS converts '<' to '[' and '>' to ']'
Adds a FN_LIBCHAR to end if the result string if there isn't one
...
...
@@ -63,10 +71,12 @@ uint dirname_part(my_string to, const char *name)
Copies data from 'from' until ASCII(0) for until from == from_end
If you want to use the whole 'from' string, just send NullS as the
last argument.
If the result string is larger than FN_REFLEN -1, then it's cut.
Returns pointer to end \0
*/
RETURN
Returns pointer to end \0 in to
*/
#ifndef FN_DEVCHAR
#define FN_DEVCHAR '\0'
/* For easier code */
...
...
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