Tom Lane escribió:
> I experimented with that a little bit and found it doesn't seem to be
> tremendously easy. A non-bootstrap-mode backend will PANIC immediately
> on startup if it doesn't find the critical system indexes, so the second
> step has issues. Also, there is no provision for resuming bootstrap
> mode in an already-existing database, so the third step doesn't work
> either.
FWIW we hacked up a sort-of-bootstrap mode in Mammoth Replicator to be
able to create our own catalogs and stuff. It's not particularly
hard nor large:
bootstrap.c | 31 ++++++!!!!!!!!!!!!!!!!!!!!!!!!!
1 file changed, 6 insertions(+), 25 modifications(!)
(This is BSD code so feel free to use it if you find it useful)
--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.
*** 83_rel/src/backend/bootstrap/bootstrap.c 2008-01-09 13:04:32.000000000 -0300
--- 23trunk/src/backend/bootstrap/bootstrap.c 2009-07-26 21:12:48.000000000 -0400
***************
*** 27,36 ****
--- 27,39 ----
#include "catalog/index.h"
#include "catalog/pg_type.h"
#include "libpq/pqsignal.h"
+ #include "mammoth_r/mcp_queue.h"
+ #include "mammoth_r/txlog.h"
#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "postmaster/bgwriter.h"
#include "postmaster/walwriter.h"
+ #include "postmaster/replication.h"
#include "storage/freespace.h"
#include "storage/ipc.h"
#include "storage/proc.h"
***************
*** 48,54 ****
#define ALLOC(t, c) ((t *) calloc((unsigned)(c), sizeof(t)))
static void CheckerModeMain(void);
! static void BootstrapModeMain(void);
static void bootstrap_signals(void);
static void ShutdownAuxiliaryProcess(int code, Datum arg);
static hashnode *AddStr(char *str, int strlength, int mderef);
--- 51,57 ----
#define ALLOC(t, c) ((t *) calloc((unsigned)(c), sizeof(t)))
static void CheckerModeMain(void);
! static void BootstrapModeMain(char *dbname);
static void bootstrap_signals(void);
static void ShutdownAuxiliaryProcess(int code, Datum arg);
static hashnode *AddStr(char *str, int strlength, int mderef);
***************
*** 207,212 ****
--- 210,216 ----
int flag;
AuxProcType auxType = CheckerProcess;
char *userDoption = NULL;
+ char *dbname = NULL;
/*
* initialize globals
***************
*** 313,319 ****
}
}
! if (argc != optind)
{
write_stderr("%s: invalid command-line arguments\n", progname);
proc_exit(1);
--- 317,325 ----
}
}
! if (auxType == MammothBootstrapProcess && argc - optind + 1)
! dbname = argv[optind++];
! else if (argc != optind || auxType == MammothBootstrapProcess)
{
write_stderr("%s: invalid command-line arguments\n", progname);
proc_exit(1);
***************
*** 337,342 ****
--- 343,350 ----
case WalWriterProcess:
statmsg = "wal writer process";
break;
+ case MammothBootstrapProcess:
+ statmsg = "mammoth bootstrap process";
default:
statmsg = "??? process";
break;
***************
*** 410,416 ****
bootstrap_signals();
BootStrapXLOG();
StartupXLOG();
! BootstrapModeMain();
proc_exit(1); /* should never return */
case StartupProcess:
--- 418,432 ----
bootstrap_signals();
BootStrapXLOG();
StartupXLOG();
! BootstrapModeMain(NULL);
! proc_exit(1); /* should never return */
!
! case MammothBootstrapProcess:
! bootstrap_signals();
! BootstrapTXLOG();
! BootStrapMCPQueue();
! StartupXLOG();
! BootstrapModeMain(dbname);
proc_exit(1); /* should never return */
case StartupProcess:
***************
*** 469,487 ****
* commands in a special bootstrap language.
*/
static void
! BootstrapModeMain(void)
{
int i;
Assert(!IsUnderPostmaster);
! SetProcessingMode(BootstrapProcessing);
/*
* Do backend-like initialization for bootstrap mode
*/
InitProcess();
! InitPostgres(NULL, InvalidOid, NULL, NULL);
/* Initialize stuff for bootstrap-file processing */
for (i = 0; i < MAXATTR; i++)
--- 485,506 ----
* commands in a special bootstrap language.
*/
static void
! BootstrapModeMain(char *dbname)
{
int i;
Assert(!IsUnderPostmaster);
! if (dbname == NULL)
! SetProcessingMode(BootstrapProcessing);
! else
! SetProcessingMode(MammothBootstrapProcessing);
/*
* Do backend-like initialization for bootstrap mode
*/
InitProcess();
! InitPostgres(dbname, InvalidOid, NULL, NULL);
/* Initialize stuff for bootstrap-file processing */
for (i = 0; i < MAXATTR; i++)
*** 83_rel/src/include/bootstrap/bootstrap.h 2008-01-09 13:04:49.000000000 -0300
--- 23trunk/src/include/bootstrap/bootstrap.h 2008-09-12 16:36:43.000000000 -0400
***************
*** 70,76 ****
BootstrapProcess,
StartupProcess,
BgWriterProcess,
! WalWriterProcess
} AuxProcType;
#endif /* BOOTSTRAP_H */
--- 70,77 ----
BootstrapProcess,
StartupProcess,
BgWriterProcess,
! WalWriterProcess,
! MammothBootstrapProcess = 99
} AuxProcType;
#endif /* BOOTSTRAP_H */
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers