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
4c0e9b5e
Commit
4c0e9b5e
authored
23 years ago
by
Bruce Momjian
Browse files
Options
Downloads
Patches
Plain Diff
Add new -l flag to set checkpoint location for /contrib/pg_resetxlog.
parent
0385ba11
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
contrib/pg_resetxlog/README.pg_resetxlog
+1
-1
1 addition, 1 deletion
contrib/pg_resetxlog/README.pg_resetxlog
contrib/pg_resetxlog/pg_resetxlog.c
+36
-9
36 additions, 9 deletions
contrib/pg_resetxlog/pg_resetxlog.c
with
37 additions
and
10 deletions
contrib/pg_resetxlog/README.pg_resetxlog
+
1
−
1
View file @
4c0e9b5e
...
@@ -22,7 +22,7 @@ Then run pg_resetxlog, and finally install and start the new version of
...
@@ -22,7 +22,7 @@ Then run pg_resetxlog, and finally install and start the new version of
the database software.
the database software.
A tertiary purpose it its use by pg_upgrade to set the next transaction
A tertiary purpose it its use by pg_upgrade to set the next transaction
id 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
(as the Postgres admin user) do
(as the Postgres admin user) do
...
...
This diff is collapsed.
Click to expand it.
contrib/pg_resetxlog/pg_resetxlog.c
+
36
−
9
View file @
4c0e9b5e
...
@@ -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
2
2002/01/10
18:08:29
momjian Exp $
* $Header: /cvsroot/pgsql/contrib/pg_resetxlog/Attic/pg_resetxlog.c,v 1.1
3
2002/01/10
20:09:06
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -683,6 +683,7 @@ PrintControlValues(void)
...
@@ -683,6 +683,7 @@ PrintControlValues(void)
"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
"
...
@@ -695,6 +696,8 @@ PrintControlValues(void)
...
@@ -695,6 +696,8 @@ PrintControlValues(void)
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
,
...
@@ -709,7 +712,7 @@ PrintControlValues(void)
...
@@ -709,7 +712,7 @@ PrintControlValues(void)
* Write out the new pg_control file.
* Write out the new pg_control file.
*/
*/
static
void
static
void
RewriteControlFile
(
TransactionId
set_xid
)
RewriteControlFile
(
TransactionId
set_xid
,
XLogRecPtr
set_checkpoint
)
{
{
int
fd
;
int
fd
;
char
buffer
[
BLCKSZ
];
/* need not be aligned */
char
buffer
[
BLCKSZ
];
/* need not be aligned */
...
@@ -733,13 +736,18 @@ RewriteControlFile(TransactionId set_xid)
...
@@ -733,13 +736,18 @@ RewriteControlFile(TransactionId set_xid)
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
)
if
(
set_xid
!=
0
)
ControlFile
.
checkPointCopy
.
nextXid
=
set_xid
;
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
,
...
@@ -929,10 +937,11 @@ WriteEmptyXLOG(void)
...
@@ -929,10 +937,11 @@ WriteEmptyXLOG(void)
static
void
static
void
usage
(
void
)
usage
(
void
)
{
{
fprintf
(
stderr
,
"Usage: pg_resetxlog [-f] [-n] [-x xid] PGDataDirectory
\n
"
fprintf
(
stderr
,
"Usage: pg_resetxlog [-f] [-n] [-x xid] [ -l log_id offset ] PGDataDirectory
\n
"
" -f
\t
force update to be done
\n
"
" -f
\t
force update to be done
\n
"
" -n
\t
no update, just show extracted pg_control values (for testing)
\n
"
" -n
\t
no update, just show extracted pg_control values (for testing)
\n
"
" -x XID
\t
set XID in pg_control
\n
"
);
" -x XID set XID in pg_control
\n
"
" -l log_id offset set checkpoint location in pg_control
\n
"
);
exit
(
1
);
exit
(
1
);
}
}
...
@@ -944,6 +953,7 @@ main(int argc, char **argv)
...
@@ -944,6 +953,7 @@ 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
};
int
fd
;
int
fd
;
char
path
[
MAXPGPATH
];
char
path
[
MAXPGPATH
];
...
@@ -967,6 +977,23 @@ main(int argc, char **argv)
...
@@ -967,6 +977,23 @@ main(int argc, char **argv)
exit
(
1
);
exit
(
1
);
}
}
}
}
else
if
(
strcmp
(
argv
[
argn
],
"-l"
)
==
0
)
{
argn
++
;
if
(
argn
==
argc
)
usage
();
set_checkpoint
.
xlogid
=
strtoul
(
argv
[
argn
],
NULL
,
0
);
argn
++
;
if
(
argn
==
argc
)
usage
();
set_checkpoint
.
xrecoff
=
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
();
}
}
...
@@ -1035,7 +1062,7 @@ main(int argc, char **argv)
...
@@ -1035,7 +1062,7 @@ main(int argc, char **argv)
/*
/*
* Else, do the dirty deed.
* Else, do the dirty deed.
*/
*/
RewriteControlFile
(
set_xid
);
RewriteControlFile
(
set_xid
,
set_checkpoint
);
KillExistingXLOG
();
KillExistingXLOG
();
WriteEmptyXLOG
();
WriteEmptyXLOG
();
...
...
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