• 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
  • 相关阅读:
    mysql数据库操作
    django
    django-rest framwork
    Maven项目POM文件错误,提示“Plugin execution not covered by lifecycle configuration”的解决方案
    [Flutter] FFI之生成Ansi字符串指针
    多label实现准确率和召回率
    pickle.dump()和pickle.load()
    numpy.take()
    通俗易懂的lambda表达式,不懂来找我!
    collections(python常用内建模块)
  • 原文地址:https://www.cnblogs.com/gaojian/p/3179356.html
Copyright © 2020-2023  润新知