Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
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
Abuhujair Javed
Postgres FD Implementation
Commits
d85c6883
Commit
d85c6883
authored
May 03, 2009
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix pg_resetxlog to remove archive status files along with WAL segment files.
Fujii Masao
parent
c52963ac
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
1 deletion
+60
-1
src/bin/pg_resetxlog/pg_resetxlog.c
src/bin/pg_resetxlog/pg_resetxlog.c
+60
-1
No files found.
src/bin/pg_resetxlog/pg_resetxlog.c
View file @
d85c6883
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.7
2 2009/02/25 13:03:07 petere
Exp $
* $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.7
3 2009/05/03 23:13:37 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -71,6 +71,7 @@ static void PrintControlValues(bool guessed);
...
@@ -71,6 +71,7 @@ static void PrintControlValues(bool guessed);
static
void
RewriteControlFile
(
void
);
static
void
RewriteControlFile
(
void
);
static
void
FindEndOfXLOG
(
void
);
static
void
FindEndOfXLOG
(
void
);
static
void
KillExistingXLOG
(
void
);
static
void
KillExistingXLOG
(
void
);
static
void
KillExistingArchiveStatus
(
void
);
static
void
WriteEmptyXLOG
(
void
);
static
void
WriteEmptyXLOG
(
void
);
static
void
usage
(
void
);
static
void
usage
(
void
);
...
@@ -360,6 +361,7 @@ main(int argc, char *argv[])
...
@@ -360,6 +361,7 @@ main(int argc, char *argv[])
*/
*/
RewriteControlFile
();
RewriteControlFile
();
KillExistingXLOG
();
KillExistingXLOG
();
KillExistingArchiveStatus
();
WriteEmptyXLOG
();
WriteEmptyXLOG
();
printf
(
_
(
"Transaction log reset
\n
"
));
printf
(
_
(
"Transaction log reset
\n
"
));
...
@@ -811,6 +813,63 @@ KillExistingXLOG(void)
...
@@ -811,6 +813,63 @@ KillExistingXLOG(void)
}
}
/*
* Remove existing archive status files
*/
static
void
KillExistingArchiveStatus
(
void
)
{
DIR
*
xldir
;
struct
dirent
*
xlde
;
char
path
[
MAXPGPATH
];
#define ARCHSTATDIR XLOGDIR "/archive_status"
xldir
=
opendir
(
ARCHSTATDIR
);
if
(
xldir
==
NULL
)
{
fprintf
(
stderr
,
_
(
"%s: could not open directory
\"
%s
\"
: %s
\n
"
),
progname
,
ARCHSTATDIR
,
strerror
(
errno
));
exit
(
1
);
}
errno
=
0
;
while
((
xlde
=
readdir
(
xldir
))
!=
NULL
)
{
if
(
strspn
(
xlde
->
d_name
,
"0123456789ABCDEF"
)
==
24
&&
(
strcmp
(
xlde
->
d_name
+
24
,
".ready"
)
==
0
||
strcmp
(
xlde
->
d_name
+
24
,
".done"
)
==
0
))
{
snprintf
(
path
,
MAXPGPATH
,
"%s/%s"
,
ARCHSTATDIR
,
xlde
->
d_name
);
if
(
unlink
(
path
)
<
0
)
{
fprintf
(
stderr
,
_
(
"%s: could not delete file
\"
%s
\"
: %s
\n
"
),
progname
,
path
,
strerror
(
errno
));
exit
(
1
);
}
}
errno
=
0
;
}
#ifdef WIN32
/*
* This fix is in mingw cvs (runtime/mingwex/dirent.c rev 1.4), but not in
* released version
*/
if
(
GetLastError
()
==
ERROR_NO_MORE_FILES
)
errno
=
0
;
#endif
if
(
errno
)
{
fprintf
(
stderr
,
_
(
"%s: could not read from directory
\"
%s
\"
: %s
\n
"
),
progname
,
ARCHSTATDIR
,
strerror
(
errno
));
exit
(
1
);
}
closedir
(
xldir
);
}
/*
/*
* Write an empty XLOG file, containing only the checkpoint record
* Write an empty XLOG file, containing only the checkpoint record
* already set up in ControlFile.
* already set up in ControlFile.
...
...
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