zoukankan      html  css  js  c++  java
  • PostgreSQL的 initdb 源代码分析之二十五

    继续分析:

        make_postgres();

     展开:

    目的是创建postgres数据库。

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

    /*
     * copy template1 to postgres
     */
    static void
    make_postgres(void)
    {
        PG_CMD_DECL;
        const char **line;
        static const char *postgres_setup[] = {
            "CREATE DATABASE postgres;
    ",
            "COMMENT ON DATABASE postgres IS 'default administrative connection database';
    ",
            NULL
        };
    
        fputs(_("copying template1 to postgres ... "), stdout);
        fflush(stdout);
    
        snprintf(cmd, sizeof(cmd),
                 ""%s" %s template1 >%s",
                 backend_exec, backend_options,
                 DEVNULL);
    
        PG_CMD_OPEN;
    
        for (line = postgres_setup; *line; line++)
            PG_CMD_PUTS(*line);
    
        PG_CMD_CLOSE;
    
        check_ok();
    }

     再接下来,就是结束了:

        if (authwarning != NULL)
            fprintf(stderr, "%s", authwarning);
    
        /* Get directory specification used to start this executable */
        strcpy(bin_dir, argv[0]);
        get_parent_directory(bin_dir);
    
        printf(_("
    Success. You can now start the database server using:
    
    "
                 "    %s%s%spostgres%s -D %s%s%s
    "
                 "or
    "
                 "    %s%s%spg_ctl%s -D %s%s%s -l logfile start
    
    "),
           QUOTE_PATH, bin_dir, (strlen(bin_dir) > 0) ? DIR_SEP : "", QUOTE_PATH,
               QUOTE_PATH, pg_data_native, QUOTE_PATH,
           QUOTE_PATH, bin_dir, (strlen(bin_dir) > 0) ? DIR_SEP : "", QUOTE_PATH,
               QUOTE_PATH, pg_data_native, QUOTE_PATH);
    
        return 0;

    会给出一些提示信息,类似于:

    Success. You can now start the database server using:
    
        /home/pgsql/project/bin/postgres -D /home/pgsql/DemoDir
    or
        /home/pgsql/project/bin/pg_ctl -D /home/pgsql/DemoDir -l logfile start
  • 相关阅读:
    Codeforces Round #369 (Div. 2)
    poj3189二分图多重匹配
    a 标签传值
    phpStudy 虚拟主机
    wampserver 虚拟主机
    $file函数
    PHP脚本运行时间
    查询timestamp类型数据
    驼峰法
    easyUI导出数据
  • 原文地址:https://www.cnblogs.com/gaojian/p/3179356.html
Copyright © 2011-2022 走看看