PostgreSQL的 initdb 源代码分析之十四

继续分析:

    /*
     * Make the per-database PG_VERSION for template1 only after init'ing it
     */
    write_version_file("base/1");

就是在base/1目录下,生成一个  PG_VERSION 文件。

[pgsql@localhost 1]$ pwd
/home/pgsql/DemoDir/base/1
[pgsql@localhost 1]$ cat PG_VERSION
9.1
[pgsql@localhost 1]$ 

接下来:

    /* 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;”

你可能感兴趣的:(PostgreSQL)