继续分析:
/*
* Make the per-database PG_VERSION for template1 only after init'ing it
*/
write_version_file("base/1");
就是在base/1目录下,生成一个 PG_VERSION 文件。
[pgsql@localhost ]$ pwd
/home/pgsql/DemoDir/base/
[pgsql@localhost ]$ cat PG_VERSION
9.1
[pgsql@localhost ]$
接下来:
/* Create the stuff we don't need to use bootstrap mode for */ setup_auth();
展开后看:
/*
* set up the shadow password table
*/
static void
setup_auth(void)
{
PG_CMD_DECL;
const char **line;
static const char *pg_authid_setup[] = {
/*
* The authid table shouldn't be readable except through views, to
* ensure passwords are not publicly visible.
*/
"REVOKE ALL on pg_authid FROM public;\n",
NULL
}; fputs(_("initializing pg_authid ... "), stdout);
fflush(stdout); snprintf(cmd, sizeof(cmd),
"\"%s\" %s template1 >%s",
backend_exec, backend_options,
DEVNULL); PG_CMD_OPEN; for (line = pg_authid_setup; *line != NULL; line++)
PG_CMD_PUTS(*line); PG_CMD_CLOSE; check_ok();
}
此时,得到的cmd 是:
/home/pgsql/project/bin/postgres" --single -F -O -c search_path=pg_catalog -c exit_on_error=true template1 >/dev/null
然后再把 pg_authid_setup[] 里的内容送到 postgres里去执行。此处是 ”REVOKE ALL on pg_authid FROM public;”