Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
108e3992
Commit
108e3992
authored
11 years ago
by
Heikki Linnakangas
Browse files
Options
Downloads
Patches
Plain Diff
Display old and new values in pg_resetxlog -n output.
For extra clarity. Rajeev Rastogi, reviewed by Amit Kapila
parent
22310b80
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
doc/src/sgml/ref/pg_resetxlog.sgml
+4
-3
4 additions, 3 deletions
doc/src/sgml/ref/pg_resetxlog.sgml
src/bin/pg_resetxlog/pg_resetxlog.c
+72
-15
72 additions, 15 deletions
src/bin/pg_resetxlog/pg_resetxlog.c
with
76 additions
and
18 deletions
doc/src/sgml/ref/pg_resetxlog.sgml
+
4
−
3
View file @
108e3992
...
@@ -177,9 +177,10 @@ PostgreSQL documentation
...
@@ -177,9 +177,10 @@ PostgreSQL documentation
<para>
<para>
The <option>-n</> (no operation) option instructs
The <option>-n</> (no operation) option instructs
<command>pg_resetxlog</command> to print the values reconstructed from
<command>pg_resetxlog</command> to print the values reconstructed from
<filename>pg_control</> and then exit without modifying anything.
<filename>pg_control</> and values about to be changed, and then exit
This is mainly a debugging tool, but can be useful as a sanity check
without modifying anything. This is mainly a debugging tool, but can be
before allowing <command>pg_resetxlog</command> to proceed for real.
useful as a sanity check before allowing <command>pg_resetxlog</command>
to proceed for real.
</para>
</para>
<para>
<para>
...
...
This diff is collapsed.
Click to expand it.
src/bin/pg_resetxlog/pg_resetxlog.c
+
72
−
15
View file @
108e3992
...
@@ -64,10 +64,18 @@ static ControlFileData ControlFile; /* pg_control values */
...
@@ -64,10 +64,18 @@ static ControlFileData ControlFile; /* pg_control values */
static
XLogSegNo
newXlogSegNo
;
/* new XLOG segment # */
static
XLogSegNo
newXlogSegNo
;
/* new XLOG segment # */
static
bool
guessed
=
false
;
/* T if we had to guess at any values */
static
bool
guessed
=
false
;
/* T if we had to guess at any values */
static
const
char
*
progname
;
static
const
char
*
progname
;
static
uint32
set_xid_epoch
=
(
uint32
)
-
1
;
static
TransactionId
set_xid
=
0
;
static
Oid
set_oid
=
0
;
static
MultiXactId
set_mxid
=
0
;
static
MultiXactOffset
set_mxoff
=
(
MultiXactOffset
)
-
1
;
static
uint32
minXlogTli
=
0
;
static
XLogSegNo
minXlogSegNo
=
0
;
static
bool
ReadControlFile
(
void
);
static
bool
ReadControlFile
(
void
);
static
void
GuessControlValues
(
void
);
static
void
GuessControlValues
(
void
);
static
void
PrintControlValues
(
bool
guessed
);
static
void
PrintControlValues
(
bool
guessed
);
static
void
PrintNewControlValues
(
void
);
static
void
RewriteControlFile
(
void
);
static
void
RewriteControlFile
(
void
);
static
void
FindEndOfXLOG
(
void
);
static
void
FindEndOfXLOG
(
void
);
static
void
KillExistingXLOG
(
void
);
static
void
KillExistingXLOG
(
void
);
...
@@ -82,14 +90,7 @@ main(int argc, char *argv[])
...
@@ -82,14 +90,7 @@ main(int argc, char *argv[])
int
c
;
int
c
;
bool
force
=
false
;
bool
force
=
false
;
bool
noupdate
=
false
;
bool
noupdate
=
false
;
uint32
set_xid_epoch
=
(
uint32
)
-
1
;
TransactionId
set_xid
=
0
;
Oid
set_oid
=
0
;
MultiXactId
set_mxid
=
0
;
MultiXactId
set_oldestmxid
=
0
;
MultiXactId
set_oldestmxid
=
0
;
MultiXactOffset
set_mxoff
=
(
MultiXactOffset
)
-
1
;
uint32
minXlogTli
=
0
;
XLogSegNo
minXlogSegNo
=
0
;
char
*
endptr
;
char
*
endptr
;
char
*
endptr2
;
char
*
endptr2
;
char
*
DataDir
;
char
*
DataDir
;
...
@@ -301,6 +302,13 @@ main(int argc, char *argv[])
...
@@ -301,6 +302,13 @@ main(int argc, char *argv[])
*/
*/
FindEndOfXLOG
();
FindEndOfXLOG
();
/*
* If we're not going to proceed with the reset, print the current control
* file parameters.
*/
if
((
guessed
&&
!
force
)
||
noupdate
)
PrintControlValues
(
guessed
);
/*
/*
* Adjust fields if required by switches. (Do this now so that printout,
* Adjust fields if required by switches. (Do this now so that printout,
* if any, includes these values.)
* if any, includes these values.)
...
@@ -356,7 +364,7 @@ main(int argc, char *argv[])
...
@@ -356,7 +364,7 @@ main(int argc, char *argv[])
*/
*/
if
((
guessed
&&
!
force
)
||
noupdate
)
if
((
guessed
&&
!
force
)
||
noupdate
)
{
{
PrintControlValues
(
guessed
);
Print
New
ControlValues
();
if
(
!
noupdate
)
if
(
!
noupdate
)
{
{
printf
(
_
(
"
\n
If these values seem acceptable, use -f to force reset.
\n
"
));
printf
(
_
(
"
\n
If these values seem acceptable, use -f to force reset.
\n
"
));
...
@@ -556,12 +564,11 @@ static void
...
@@ -556,12 +564,11 @@ static void
PrintControlValues
(
bool
guessed
)
PrintControlValues
(
bool
guessed
)
{
{
char
sysident_str
[
32
];
char
sysident_str
[
32
];
char
fname
[
MAXFNAMELEN
];
if
(
guessed
)
if
(
guessed
)
printf
(
_
(
"Guessed pg_control values:
\n\n
"
));
printf
(
_
(
"Guessed pg_control values:
\n\n
"
));
else
else
printf
(
_
(
"pg_control values:
\n\n
"
));
printf
(
_
(
"
Current
pg_control values:
\n\n
"
));
/*
/*
* Format system_identifier separately to keep platform-dependent format
* Format system_identifier separately to keep platform-dependent format
...
@@ -570,10 +577,6 @@ PrintControlValues(bool guessed)
...
@@ -570,10 +577,6 @@ PrintControlValues(bool guessed)
snprintf
(
sysident_str
,
sizeof
(
sysident_str
),
UINT64_FORMAT
,
snprintf
(
sysident_str
,
sizeof
(
sysident_str
),
UINT64_FORMAT
,
ControlFile
.
system_identifier
);
ControlFile
.
system_identifier
);
XLogFileName
(
fname
,
ControlFile
.
checkPointCopy
.
ThisTimeLineID
,
newXlogSegNo
);
printf
(
_
(
"First log segment after reset: %s
\n
"
),
fname
);
printf
(
_
(
"pg_control version number: %u
\n
"
),
printf
(
_
(
"pg_control version number: %u
\n
"
),
ControlFile
.
pg_control_version
);
ControlFile
.
pg_control_version
);
printf
(
_
(
"Catalog version number: %u
\n
"
),
printf
(
_
(
"Catalog version number: %u
\n
"
),
...
@@ -631,6 +634,60 @@ PrintControlValues(bool guessed)
...
@@ -631,6 +634,60 @@ PrintControlValues(bool guessed)
}
}
/*
* Print the values to be changed.
*/
static
void
PrintNewControlValues
()
{
char
fname
[
MAXFNAMELEN
];
/* This will be always printed in order to keep format same. */
printf
(
_
(
"
\n\n
Values to be changed:
\n\n
"
));
XLogFileName
(
fname
,
ControlFile
.
checkPointCopy
.
ThisTimeLineID
,
newXlogSegNo
);
printf
(
_
(
"First log segment after reset: %s
\n
"
),
fname
);
if
(
set_mxid
!=
0
)
{
printf
(
_
(
"NextMultiXactId: %u
\n
"
),
ControlFile
.
checkPointCopy
.
nextMulti
);
printf
(
_
(
"OldestMultiXid: %u
\n
"
),
ControlFile
.
checkPointCopy
.
oldestMulti
);
printf
(
_
(
"OldestMulti's DB: %u
\n
"
),
ControlFile
.
checkPointCopy
.
oldestMultiDB
);
}
if
(
set_mxoff
!=
-
1
)
{
printf
(
_
(
"NextMultiOffset: %u
\n
"
),
ControlFile
.
checkPointCopy
.
nextMultiOffset
);
}
if
(
set_oid
!=
0
)
{
printf
(
_
(
"NextOID: %u
\n
"
),
ControlFile
.
checkPointCopy
.
nextOid
);
}
if
(
set_xid
!=
0
)
{
printf
(
_
(
"NextXID: %u
\n
"
),
ControlFile
.
checkPointCopy
.
nextXid
);
printf
(
_
(
"OldestXID: %u
\n
"
),
ControlFile
.
checkPointCopy
.
oldestXid
);
printf
(
_
(
"OldestXID's DB: %u
\n
"
),
ControlFile
.
checkPointCopy
.
oldestXidDB
);
}
if
(
set_xid_epoch
!=
-
1
)
{
printf
(
_
(
"NextXID Epoch: %u
\n
"
),
ControlFile
.
checkPointCopy
.
nextXidEpoch
);
}
}
/*
/*
* Write out the new pg_control file.
* Write out the new pg_control file.
*/
*/
...
@@ -1039,7 +1096,7 @@ usage(void)
...
@@ -1039,7 +1096,7 @@ usage(void)
printf
(
_
(
" -f force update to be done
\n
"
));
printf
(
_
(
" -f force update to be done
\n
"
));
printf
(
_
(
" -l XLOGFILE force minimum WAL starting location for new transaction log
\n
"
));
printf
(
_
(
" -l XLOGFILE force minimum WAL starting location for new transaction log
\n
"
));
printf
(
_
(
" -m MXID,MXID set next and oldest multitransaction ID
\n
"
));
printf
(
_
(
" -m MXID,MXID set next and oldest multitransaction ID
\n
"
));
printf
(
_
(
" -n no update, just show
extracted control values
(for testing)
\n
"
));
printf
(
_
(
" -n no update, just show
what would be done
(for testing)
\n
"
));
printf
(
_
(
" -o OID set next OID
\n
"
));
printf
(
_
(
" -o OID set next OID
\n
"
));
printf
(
_
(
" -O OFFSET set next multitransaction offset
\n
"
));
printf
(
_
(
" -O OFFSET set next multitransaction offset
\n
"
));
printf
(
_
(
" -V, --version output version information, then exit
\n
"
));
printf
(
_
(
" -V, --version output version information, then exit
\n
"
));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment