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
5c2d36c3
Commit
5c2d36c3
authored
Jan 11, 2002
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code review for latest changes.
parent
c6fdf8bc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
34 deletions
+29
-34
contrib/pg_resetxlog/README.pg_resetxlog
contrib/pg_resetxlog/README.pg_resetxlog
+1
-1
contrib/pg_resetxlog/pg_resetxlog.c
contrib/pg_resetxlog/pg_resetxlog.c
+28
-33
No files found.
contrib/pg_resetxlog/README.pg_resetxlog
View file @
5c2d36c3
...
@@ -21,7 +21,7 @@ module pg_controldata and run it to be sure the DB state is SHUTDOWN).
...
@@ -21,7 +21,7 @@ module pg_controldata and run it to be sure the DB state is SHUTDOWN).
Then run pg_resetxlog, and finally install and start the new version of
Then run pg_resetxlog, and finally install and start the new version of
the database software.
the database software.
A tertiary purpose i
t
its use by pg_upgrade to set the next transaction
A tertiary purpose i
s
its use by pg_upgrade to set the next transaction
id and checkpoint location in pg_control.
id and checkpoint location in pg_control.
To run the program, make sure your postmaster is not running, then
To run the program, make sure your postmaster is not running, then
...
...
contrib/pg_resetxlog/pg_resetxlog.c
View file @
5c2d36c3
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $Header: /cvsroot/pgsql/contrib/pg_resetxlog/Attic/pg_resetxlog.c,v 1.1
6 2002/01/11 06:33:01 momjian
Exp $
* $Header: /cvsroot/pgsql/contrib/pg_resetxlog/Attic/pg_resetxlog.c,v 1.1
7 2002/01/11 21:27:13 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -63,7 +63,6 @@
...
@@ -63,7 +63,6 @@
snprintf(path, MAXPGPATH, "%s/%08X%08X", \
snprintf(path, MAXPGPATH, "%s/%08X%08X", \
XLogDir, log, seg)
XLogDir, log, seg)
/******************** end of stuff copied from xlog.c ********************/
/******************** end of stuff copied from xlog.c ********************/
...
@@ -134,7 +133,7 @@ ReadControlFile(void)
...
@@ -134,7 +133,7 @@ ReadControlFile(void)
return
true
;
return
true
;
}
}
fprintf
(
stderr
,
"pg_control exists but has invalid CRC; proceed
ing
with caution.
\n
"
);
fprintf
(
stderr
,
"pg_control exists but has invalid CRC; proceed with caution.
\n
"
);
/* We will use the data anyway, but treat it as guessed. */
/* We will use the data anyway, but treat it as guessed. */
memcpy
(
&
ControlFile
,
buffer
,
sizeof
(
ControlFile
));
memcpy
(
&
ControlFile
,
buffer
,
sizeof
(
ControlFile
));
guessed
=
true
;
guessed
=
true
;
...
@@ -218,12 +217,11 @@ GuessControlValues(void)
...
@@ -218,12 +217,11 @@ GuessControlValues(void)
static
void
static
void
PrintControlValues
(
bool
guessed
)
PrintControlValues
(
bool
guessed
)
{
{
printf
(
"
\n
%spg_control values:
\n\n
"
printf
(
"%spg_control values:
\n\n
"
"pg_control version number: %u
\n
"
"pg_control version number: %u
\n
"
"Catalog version number: %u
\n
"
"Catalog version number: %u
\n
"
"Current log file id: %u
\n
"
"Current log file id: %u
\n
"
"Next log file segment: %u
\n
"
"Next log file segment: %u
\n
"
"Latest checkpoint location: %X/%X
\n
"
"Latest checkpoint's StartUpID: %u
\n
"
"Latest checkpoint's StartUpID: %u
\n
"
"Latest checkpoint's NextXID: %u
\n
"
"Latest checkpoint's NextXID: %u
\n
"
"Latest checkpoint's NextOID: %u
\n
"
"Latest checkpoint's NextOID: %u
\n
"
...
@@ -237,8 +235,6 @@ PrintControlValues(bool guessed)
...
@@ -237,8 +235,6 @@ PrintControlValues(bool guessed)
ControlFile
.
catalog_version_no
,
ControlFile
.
catalog_version_no
,
ControlFile
.
logId
,
ControlFile
.
logId
,
ControlFile
.
logSeg
,
ControlFile
.
logSeg
,
ControlFile
.
checkPoint
.
xlogid
,
ControlFile
.
checkPoint
.
xrecoff
,
ControlFile
.
checkPointCopy
.
ThisStartUpID
,
ControlFile
.
checkPointCopy
.
ThisStartUpID
,
ControlFile
.
checkPointCopy
.
nextXid
,
ControlFile
.
checkPointCopy
.
nextXid
,
ControlFile
.
checkPointCopy
.
nextOid
,
ControlFile
.
checkPointCopy
.
nextOid
,
...
@@ -253,7 +249,7 @@ PrintControlValues(bool guessed)
...
@@ -253,7 +249,7 @@ PrintControlValues(bool guessed)
* Write out the new pg_control file.
* Write out the new pg_control file.
*/
*/
static
void
static
void
RewriteControlFile
(
TransactionId
set_xid
,
XLogRecPtr
set_checkpoint
)
RewriteControlFile
(
void
)
{
{
int
fd
;
int
fd
;
char
buffer
[
BLCKSZ
];
/* need not be aligned */
char
buffer
[
BLCKSZ
];
/* need not be aligned */
...
@@ -277,18 +273,10 @@ RewriteControlFile(TransactionId set_xid, XLogRecPtr set_checkpoint)
...
@@ -277,18 +273,10 @@ RewriteControlFile(TransactionId set_xid, XLogRecPtr set_checkpoint)
ControlFile
.
time
=
time
(
NULL
);
ControlFile
.
time
=
time
(
NULL
);
ControlFile
.
logId
=
newXlogId
;
ControlFile
.
logId
=
newXlogId
;
ControlFile
.
logSeg
=
newXlogSeg
+
1
;
ControlFile
.
logSeg
=
newXlogSeg
+
1
;
ControlFile
.
checkPoint
=
ControlFile
.
checkPointCopy
.
redo
;
ControlFile
.
prevCheckPoint
.
xlogid
=
0
;
ControlFile
.
prevCheckPoint
.
xlogid
=
0
;
ControlFile
.
prevCheckPoint
.
xrecoff
=
0
;
ControlFile
.
prevCheckPoint
.
xrecoff
=
0
;
if
(
set_xid
!=
0
)
ControlFile
.
checkPointCopy
.
nextXid
=
set_xid
;
if
(
set_checkpoint
.
xlogid
==
0
&&
set_checkpoint
.
xrecoff
==
0
)
ControlFile
.
checkPoint
=
ControlFile
.
checkPointCopy
.
redo
;
else
ControlFile
.
checkPoint
=
set_checkpoint
;
/* Contents are protected with a CRC */
/* Contents are protected with a CRC */
INIT_CRC64
(
ControlFile
.
crc
);
INIT_CRC64
(
ControlFile
.
crc
);
COMP_CRC64
(
ControlFile
.
crc
,
COMP_CRC64
(
ControlFile
.
crc
,
...
@@ -478,11 +466,11 @@ WriteEmptyXLOG(void)
...
@@ -478,11 +466,11 @@ WriteEmptyXLOG(void)
static
void
static
void
usage
(
void
)
usage
(
void
)
{
{
fprintf
(
stderr
,
"Usage: pg_resetxlog [-f] [-n] [-x xid] [ -l
log_id offset
] PGDataDirectory
\n
"
fprintf
(
stderr
,
"Usage: pg_resetxlog [-f] [-n] [-x xid] [ -l
fileid seg
] PGDataDirectory
\n
"
" -f
\t
force update to be done
\n
"
" -f
\t
\t
force update to be done
\n
"
" -n
\t
no update, just show extracted pg_control values (for testing)
\n
"
" -n
\t
\t
no update, just show extracted pg_control values (for testing)
\n
"
" -x
XID set XID in pg_control
\n
"
" -x
xid
\t
set next transaction ID
\n
"
" -l
log_id offset set hex checkpoint location in pg_control
\n
"
);
" -l
fileid seg
\t
force minimum WAL starting location for new xlog
\n
"
);
exit
(
1
);
exit
(
1
);
}
}
...
@@ -494,7 +482,8 @@ main(int argc, char **argv)
...
@@ -494,7 +482,8 @@ main(int argc, char **argv)
bool
force
=
false
;
bool
force
=
false
;
bool
noupdate
=
false
;
bool
noupdate
=
false
;
TransactionId
set_xid
=
0
;
TransactionId
set_xid
=
0
;
XLogRecPtr
set_checkpoint
=
{
0
,
0
};
uint32
minXlogId
=
0
,
minXlogSeg
=
0
;
int
fd
;
int
fd
;
char
path
[
MAXPGPATH
];
char
path
[
MAXPGPATH
];
...
@@ -514,7 +503,7 @@ main(int argc, char **argv)
...
@@ -514,7 +503,7 @@ main(int argc, char **argv)
set_xid
=
strtoul
(
argv
[
argn
],
NULL
,
0
);
set_xid
=
strtoul
(
argv
[
argn
],
NULL
,
0
);
if
(
set_xid
==
0
)
if
(
set_xid
==
0
)
{
{
fprintf
(
stderr
,
"XID can not be 0."
);
fprintf
(
stderr
,
"XID can not be 0.
\n
"
);
exit
(
1
);
exit
(
1
);
}
}
}
}
...
@@ -523,17 +512,11 @@ main(int argc, char **argv)
...
@@ -523,17 +512,11 @@ main(int argc, char **argv)
argn
++
;
argn
++
;
if
(
argn
==
argc
)
if
(
argn
==
argc
)
usage
();
usage
();
set_checkpoint
.
xlogid
=
strtoul
(
argv
[
argn
],
NULL
,
16
);
minXlogId
=
strtoul
(
argv
[
argn
],
NULL
,
0
);
argn
++
;
argn
++
;
if
(
argn
==
argc
)
if
(
argn
==
argc
)
usage
();
usage
();
set_checkpoint
.
xrecoff
=
strtoul
(
argv
[
argn
],
NULL
,
16
);
minXlogSeg
=
strtoul
(
argv
[
argn
],
NULL
,
0
);
if
(
set_checkpoint
.
xlogid
==
0
&&
set_checkpoint
.
xrecoff
==
0
)
{
fprintf
(
stderr
,
"Checkpoint can not be '0 0'."
);
exit
(
1
);
}
}
}
else
else
usage
();
usage
();
...
@@ -606,8 +589,20 @@ main(int argc, char **argv)
...
@@ -606,8 +589,20 @@ main(int argc, char **argv)
/*
/*
* Else, do the dirty deed.
* Else, do the dirty deed.
*
* First adjust fields if required by switches.
*/
*/
RewriteControlFile
(
set_xid
,
set_checkpoint
);
if
(
set_xid
!=
0
)
ControlFile
.
checkPointCopy
.
nextXid
=
set_xid
;
if
(
minXlogId
>
ControlFile
.
logId
||
(
minXlogId
==
ControlFile
.
logId
&&
minXlogSeg
>
ControlFile
.
logSeg
))
{
ControlFile
.
logId
=
minXlogId
;
ControlFile
.
logSeg
=
minXlogSeg
;
}
RewriteControlFile
();
KillExistingXLOG
();
KillExistingXLOG
();
WriteEmptyXLOG
();
WriteEmptyXLOG
();
...
...
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