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
970ef45c
Commit
970ef45c
authored
Jul 31, 1999
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Re-enable pg_upgrade, after adding checks that the source
and target databases are of versions it knows about.
parent
d7f2c558
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
19 deletions
+60
-19
src/bin/pg_dump/pg_upgrade
src/bin/pg_dump/pg_upgrade
+60
-19
No files found.
src/bin/pg_dump/pg_upgrade
View file @
970ef45c
#!/bin/sh
#!/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!
# 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
# NOTE: we must be sure to update the version-checking code a few dozen lines
echo
"of the tables has changed compared to previous releases."
1>&2
# below for each new PostgreSQL release.
exit
1
trap
"rm -f /tmp/
$$
"
0 1 2 3 15
trap
"rm -f /tmp/
$$
"
0 1 2 3 15
...
@@ -33,37 +32,76 @@ OLDDIR="$1"
...
@@ -33,37 +32,76 @@ OLDDIR="$1"
# check things
# check things
if
[
!
-
f
"./data/PG_VERSION
"
]
if
[
!
-
d
"./data
"
]
then
echo
"
`
basename
$0
`
must be run from the directory containing
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
exit
1
fi
fi
if
[
!
-d
"./
$OLDDIR
"
]
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
exit
1
fi
fi
if
[
!
-d
"./
$OLDDIR
/base/template1"
]
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
exit
1
fi
fi
if
[
!
-
d
"./data
"
]
if
[
!
-
r
"./data/PG_VERSION
"
]
then
echo
"
You must run initdb to create the template1 database
."
1>&2
then
echo
"
Cannot read ./data/PG_VERSION --- something is wrong
."
1>&2
exit
1
exit
1
fi
fi
if
[
!
-
d
"./data/base/template1
"
]
if
[
!
-
r
"./
$OLDDIR
/PG_VERSION
"
]
then
echo
"
$0
must be run as the postgres superuser
."
1>&2
then
echo
"
Cannot read ./
$OLDDIR
/PG_VERSION --- something is wrong
."
1>&2
exit
1
exit
1
fi
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
# Check for version compatibility.
# we don't even need pgdump_oid because we are moving pg_variable
# This code will need to be updated/reviewed for each new PostgreSQL release.
# then shouldn't be in there anyway
# 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
' {
cat
$INPUT
|
awk
' {
if (toupper($1) == "COPY" && $2 != "pg_shadow")
if (toupper($1) == "COPY" && $2 != "pg_shadow")
...
@@ -82,6 +120,8 @@ $0 aborted." 1>&2
...
@@ -82,6 +120,8 @@ $0 aborted." 1>&2
exit
1
exit
1
fi
fi
echo
"Input script
$INPUT
complete, moving data files..."
for
DIR
in
data/base/
*
for
DIR
in
data/base/
*
do
do
BASEDIR
=
"
`
basename
$DIR
`
"
BASEDIR
=
"
`
basename
$DIR
`
"
...
@@ -92,13 +132,14 @@ do
...
@@ -92,13 +132,14 @@ do
BASEFILE
=
"
`
basename
$FILE
`
"
BASEFILE
=
"
`
basename
$FILE
`
"
if
[
`
expr
"
$BASEFILE
"
:
"pg_"
`
-ne
3
-a
\
if
[
`
expr
"
$BASEFILE
"
:
"pg_"
`
-ne
3
-a
\
"
$BASEFILE
"
!=
"PG_VERSION"
]
"
$BASEFILE
"
!=
"PG_VERSION"
]
then
mv
$FILE
$DIR
then
mv
-f
$FILE
$DIR
fi
fi
done
done
fi
fi
done
done
mv
$OLDDIR
/pg_log data
mv
-f
$OLDDIR
/pg_log data
mv
$OLDDIR
/pg_variable data
mv
-f
$OLDDIR
/pg_variable data
echo
"You may remove the
$OLDDIR
directory with 'rm -r
$OLDDIR
'."
echo
"You may remove the
$OLDDIR
directory with 'rm -r
$OLDDIR
'."
exit
0
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