pg_resetxlog specifies log location in hex; more pg_upgrade testing
authorBruce Momjian <[email protected]>
Fri, 11 Jan 2002 06:33:01 +0000 (06:33 +0000)
committerBruce Momjian <[email protected]>
Fri, 11 Jan 2002 06:33:01 +0000 (06:33 +0000)
improvments.

contrib/pg_resetxlog/pg_resetxlog.c
src/bin/pg_dump/pg_upgrade

index 2324ffe4671fcc7f42d2291a8e9a2442500160b5..df7ab1b63eebc0de18b47a3722c4ae44f0840fd6 100644 (file)
@@ -482,7 +482,7 @@ usage(void)
                        "  -f\t  force update to be done\n"
                        "  -n\t  no update, just show extracted pg_control values (for testing)\n"
                        "  -x XID  set XID in pg_control\n"
-                       "  -l log_id offset   set checkpoint location in pg_control\n");
+                       "  -l log_id offset   set hex checkpoint location in pg_control\n");
        exit(1);
 }
 
@@ -523,11 +523,11 @@ main(int argc, char **argv)
                        argn++;
                        if (argn == argc)
                                usage();
-                       set_checkpoint.xlogid = strtoul(argv[argn], NULL, 0);
+                       set_checkpoint.xlogid = strtoul(argv[argn], NULL, 16);
                        argn++;
                        if (argn == argc)
                                usage();
-                       set_checkpoint.xrecoff = strtoul(argv[argn], NULL, 0);
+                       set_checkpoint.xrecoff = strtoul(argv[argn], NULL, 16);
                        if (set_checkpoint.xlogid == 0 &&
                                set_checkpoint.xrecoff == 0)
                        {
index b4abb943ace59ab120d52979abb44ca07b6d2658..9005d1a5719e90e20510eb255fc23122a3035caf 100755 (executable)
@@ -3,6 +3,8 @@
 # pg_upgrade: update a database without needing a full dump/reload cycle.
 # CAUTION: Read the manual page before trying to use this!
 
+#set -x
+
 # $Header$
 #
 # NOTE: we must be sure to update the version-checking code a few dozen lines
@@ -106,7 +108,7 @@ Install it from pgsql/contrib/pg_resetxlog and continue.;  exiting" 1>&2
        exit 1
 fi
 
-if ! pg_resetxlog -x | grep -q XID
+if ! pg_resetxlog -x 2>&1 | grep -q XID
 then   echo "Old version of pg_resetxlog found in path.
 Install a newer version from pgsql/contrib/pg_resetxlog.;  exiting" 1>&2
        exit 1
@@ -261,7 +263,7 @@ fi
 
 # Set checkpoint location of new database
 
-pg_resetxlog -l `echo "$CHKPOINT | tr '/' ' '` data
+pg_resetxlog -l `echo "$CHKPOINT" | tr '/' ' '` data
 if [ "$?" -ne 0 ]
 then   echo "Unable to set new checkpoint location.;  exiting" 1>&2
        exit 1
@@ -278,7 +280,7 @@ fi
 # Set sequence values for 7.1-version sequences, which were int4.
 
 if [ "$SRC_VERSION" = "7.1" ]
-else   echo "Set int8 sequence values from 7.1..."
+then   echo "Set int8 sequence values from 7.1..."
 
        psql -d template1 -At -c "SELECT datname FROM pg_database" | 
        while read DB
@@ -355,10 +357,11 @@ SET relkind = 'S'
 WHERE relname = '$SEQUENCE';
 
 SQL_END
-               if [ $? -ne 0 ]
-               then    echo "There were errors during int4 sequence restore.
-       $0 aborted." 1>&2
-                       exit 1
+                       if [ $? -ne 0 ]
+                       then    echo "There were errors during int4 sequence restore.
+$0 aborted." 1>&2
+                               exit 1
+                       fi
                done
        done
 fi