Hi all,

This patch removes dead code from redo_dbase(). The code processes
CREATE/DROP DATABASE recovery records which are of types
XLOG_DBASE_CREATE_OLD and XLOG_DBASE_DROP_OLD. We do not create such
records.

I've removed XLOG_DBASE_CREATE_OLD and XLOG_DBASE_DROP_OLD from the header
as well but have not changed the values of XLOG_DBASE_CREATE and
XLOG_DBASE_DROP so as to avoid the need for an initdb. They can be
adjusted, however, when an initdb is forced.

Thanks,

Gavin
Index: src/backend/commands/dbcommands.c
===================================================================
RCS file: /usr/local/cvsroot/pgsql/src/backend/commands/dbcommands.c,v
retrieving revision 1.159
diff -u -p -r1.159 dbcommands.c
--- src/backend/commands/dbcommands.c   6 Jun 2005 20:22:57 -0000       1.159
+++ src/backend/commands/dbcommands.c   7 Jul 2005 01:20:54 -0000
@@ -1257,79 +1257,6 @@ dbase_redo(XLogRecPtr lsn, XLogRecord *r
                                        (errmsg("could not remove database 
directory \"%s\"",
                                                        dst_path)));
        }
-       else if (info == XLOG_DBASE_CREATE_OLD)
-       {
-               xl_dbase_create_rec_old *xlrec = (xl_dbase_create_rec_old *) 
XLogRecGetData(record);
-               char       *dst_path = xlrec->src_path + 
strlen(xlrec->src_path) + 1;
-               struct stat st;
-
-#ifndef WIN32
-               char            buf[2 * MAXPGPATH + 100];
-#endif
-
-               /*
-                * Our theory for replaying a CREATE is to forcibly drop the
-                * target subdirectory if present, then re-copy the source data.
-                * This may be more work than needed, but it is simple to
-                * implement.
-                */
-               if (stat(dst_path, &st) == 0 && S_ISDIR(st.st_mode))
-               {
-                       if (!rmtree(dst_path, true))
-                               ereport(WARNING,
-                                       (errmsg("could not remove database 
directory \"%s\"",
-                                                       dst_path)));
-               }
-
-               /*
-                * Force dirty buffers out to disk, to ensure source database is
-                * up-to-date for the copy.  (We really only need to flush 
buffers for
-                * the source database, but bufmgr.c provides no API for that.)
-                */
-               BufferSync();
-
-#ifndef WIN32
-
-               /*
-                * Copy this subdirectory to the new location
-                *
-                * XXX use of cp really makes this code pretty grotty, 
particularly
-                * with respect to lack of ability to report errors well.  
Someday
-                * rewrite to do it for ourselves.
-                */
-
-               /* We might need to use cp -R one day for portability */
-               snprintf(buf, sizeof(buf), "cp -r '%s' '%s'",
-                                xlrec->src_path, dst_path);
-               if (system(buf) != 0)
-                       ereport(ERROR,
-                                       (errmsg("could not initialize database 
directory"),
-                                        errdetail("Failing system command was: 
%s", buf),
-                                        errhint("Look in the postmaster's 
stderr log for more information.")));
-#else                                                  /* WIN32 */
-               if (copydir(xlrec->src_path, dst_path) != 0)
-               {
-                       /* copydir should already have given details of its 
troubles */
-                       ereport(ERROR,
-                                       (errmsg("could not initialize database 
directory")));
-               }
-#endif   /* WIN32 */
-       }
-       else if (info == XLOG_DBASE_DROP_OLD)
-       {
-               xl_dbase_drop_rec_old *xlrec = (xl_dbase_drop_rec_old *) 
XLogRecGetData(record);
-
-               /*
-                * Drop pages for this database that are in the shared buffer
-                * cache
-                */
-               DropBuffers(xlrec->db_id);
-
-               if (!rmtree(xlrec->dir_path, true))
-                       ereport(WARNING,
-                                       (errmsg("could not remove database 
directory \"%s\"",
-                                                       xlrec->dir_path)));
-       }
        else
                elog(PANIC, "dbase_redo: unknown op code %u", info);
 }
Index: src/include/commands/dbcommands.h
===================================================================
RCS file: /usr/local/cvsroot/pgsql/src/include/commands/dbcommands.h,v
retrieving revision 1.38
diff -u -p -r1.38 dbcommands.h
--- src/include/commands/dbcommands.h   6 Jun 2005 17:01:25 -0000       1.38
+++ src/include/commands/dbcommands.h   7 Jul 2005 01:21:23 -0000
@@ -18,8 +18,6 @@
 #include "nodes/parsenodes.h"
 
 /* XLOG stuff */
-#define XLOG_DBASE_CREATE_OLD  0x00
-#define XLOG_DBASE_DROP_OLD            0x10
 #define XLOG_DBASE_CREATE              0x20
 #define XLOG_DBASE_DROP                        0x30
 
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Reply via email to