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
970ef45c
Commit
970ef45c
authored
25 years ago
by
Tom Lane
Browse files
Options
Downloads
Patches
Plain Diff
Re-enable pg_upgrade, after adding checks that the source
and target databases are of versions it knows about.
parent
d7f2c558
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/bin/pg_dump/pg_upgrade
+60
-19
60 additions, 19 deletions
src/bin/pg_dump/pg_upgrade
with
60 additions
and
19 deletions
src/bin/pg_dump/pg_upgrade
+
60
−
19
View file @
970ef45c
#!/bin/sh
#
# pg_upgrade: update a database without needing a full dump/reload cycle
# pg_upgrade: update a database without needing a full dump/reload cycle
.
# CAUTION: read the manual page before trying to use this!
echo
"pg_upgrade is disabled in this release because the on-disk structure"
1>&2
echo
"of the tables has changed compared to previous releases."
1>&2
exit
1
# NOTE: we must be sure to update the version-checking code a few dozen lines
# below for each new PostgreSQL release.
trap
"rm -f /tmp/
$$
"
0 1 2 3 15
...
...
@@ -33,37 +32,76 @@ OLDDIR="$1"
# check things
if
[
!
-
f
"./data
/PG_VERSION
"
]
if
[
!
-
d
"./data"
]
then
echo
"
`
basename
$0
`
must be run from the directory containing
the database directory
\`
data' (
`
dirname
$PGDATA
`
.)"
1>&2
the database directory
\`
data
\'
(
`
dirname
$PGDATA
`
.)"
1>&2
echo
"You must have run initdb to create the template1 database."
1>&2
exit
1
fi
if
[
!
-d
"./
$OLDDIR
"
]
then
echo
"You must rename your old /data directory to /
$OLDDIR
and run initdb."
1>&2
then
echo
"You must rename your old data directory to
$OLDDIR
and run initdb."
1>&2
exit
1
fi
if
[
!
-d
"./data/base/template1"
]
then
echo
"Cannot find database template1 in ./data/base."
1>&2
echo
"Are you running
$0
as the postgres superuser?"
1>&2
exit
1
fi
if
[
!
-d
"./
$OLDDIR
/base/template1"
]
then
echo
"There is no
t
database template1 in ./
$OLDDIR
/base."
1>&2
then
echo
"There is no database template1 in ./
$OLDDIR
/base."
1>&2
exit
1
fi
if
[
!
-
d
"./data"
]
then
echo
"
You must run initdb to create the template1 database
."
1>&2
if
[
!
-
r
"./data
/PG_VERSION
"
]
then
echo
"
Cannot read ./data/PG_VERSION --- something is wrong
."
1>&2
exit
1
fi
if
[
!
-
d
"./
data/base/template1
"
]
then
echo
"
$0
must be run as the postgres superuser
."
1>&2
if
[
!
-
r
"./
$OLDDIR
/PG_VERSION
"
]
then
echo
"
Cannot read ./
$OLDDIR
/PG_VERSION --- something is wrong
."
1>&2
exit
1
fi
# do I need to create a database?
# Get the actual versions seen in the data dirs.
DESTVERSION
=
`
cat
./data/PG_VERSION
`
SRCVERSION
=
`
cat
./
$OLDDIR
/PG_VERSION
`
# remove any COPY statements
# we don't even need pgdump_oid because we are moving pg_variable
# then shouldn't be in there anyway
# Check for version compatibility.
# This code will need to be updated/reviewed for each new PostgreSQL release.
# MYVERSION is the expected output database version
MYVERSION
=
"6.6"
if
[
"
$DESTVERSION
"
!=
"
$MYVERSION
"
]
then
echo
"
$0
is for PostgreSQL version
$MYVERSION
, but ./data/PG_VERSION contains
$DESTVERSION
."
1>&2
echo
"Did you run initdb for version
$MYVERSION
?"
1>&2
exit
1
fi
# Check that input database is of a compatible version (anything with the same
# physical layout of user tables and indexes should be OK). I did not write
# something like "$SRCVERSION -ge $MINVERSION" because test(1) isn't bright
# enough to compare dotted version strings properly. Using a case statement
# looks uglier but is more flexible.
case
"
$SRCVERSION
"
in
6.5
)
;;
6.6
)
;;
*
)
echo
"Sorry,
`
basename
$0
`
cannot upgrade database version
$SRCVERSION
to
$DESTVERSION
."
1>&2
echo
"The on-disk structure of tables has changed."
1>&2
echo
"You will need to dump and restore using pg_dump."
1>&2
exit
1
;;
esac
# OK, ready to proceed.
# XXX Do I need to create a database?
# remove any COPY statements, except for the one that loads pg_shadow.
# there shouldn't be any others in there anyway...
cat
$INPUT
|
awk
' {
if (toupper($1) == "COPY" && $2 != "pg_shadow")
...
...
@@ -82,6 +120,8 @@ $0 aborted." 1>&2
exit
1
fi
echo
"Input script
$INPUT
complete, moving data files..."
for
DIR
in
data/base/
*
do
BASEDIR
=
"
`
basename
$DIR
`
"
...
...
@@ -92,13 +132,14 @@ do
BASEFILE
=
"
`
basename
$FILE
`
"
if
[
`
expr
"
$BASEFILE
"
:
"pg_"
`
-ne
3
-a
\
"
$BASEFILE
"
!=
"PG_VERSION"
]
then
mv
$FILE
$DIR
then
mv
-f
$FILE
$DIR
fi
done
fi
done
mv
$OLDDIR
/pg_log data
mv
$OLDDIR
/pg_variable data
mv
-f
$OLDDIR
/pg_log data
mv
-f
$OLDDIR
/pg_variable data
echo
"You may remove the
$OLDDIR
directory with 'rm -r
$OLDDIR
'."
exit
0
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