继续分析:

    setup_schema();

展开:

实质就是创建info_schema。

cmd 是:

"/home/pgsql/project/bin/postgres" --single -F -O -c search_path=pg_catalog -c exit_on_error=true -j template1 >/dev/null

infor_schem_file是:/home/pgsql/project/share/information_schema.sql

/*
 * load info schema and populate from features file
 */
static void
setup_schema(void)
{
    PG_CMD_DECL;
    char      **line;
    char      **lines;

    fputs(_("creating information schema ... "), stdout);
    fflush(stdout);

    lines = readfile(info_schema_file);

    ///fprintf(stderr,"\n====================info_schema_file is: %s\n", info_schema_file);

    /*
     * We use -j here to avoid backslashing stuff in information_schema.sql
     */
    snprintf(cmd, sizeof(cmd),
             "\"%s\" %s -j template1 >%s",
             backend_exec, backend_options,
             DEVNULL);

    ///fprintf(stderr,"\n=====================cmd is: %s \n",cmd);

    PG_CMD_OPEN;

    for (line = lines; *line != NULL; line++)
    {
        PG_CMD_PUTS(*line);
        free(*line);
    }

    free(lines);

    PG_CMD_CLOSE;

    snprintf(cmd, sizeof(cmd),
             "\"%s\" %s template1 >%s",
             backend_exec, backend_options,
             DEVNULL);

    PG_CMD_OPEN;

    PG_CMD_PRINTF1("UPDATE information_schema.sql_implementation_info "
                   "  SET character_value = '%s' "
                   "  WHERE implementation_info_name = 'DBMS VERSION';\n",
                   infoversion);

    PG_CMD_PRINTF1("COPY information_schema.sql_features "
                   "  (feature_id, feature_name, sub_feature_id, "
                   "  sub_feature_name, is_supported, comments) "
                   " FROM E'%s';\n",
                   escape_quotes(features_file));

    PG_CMD_CLOSE;

    check_ok();
}