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

    接前面,继续分析: putenv("TZ=GMT") 设置了时区信息。

    find_other_exec(argv[0], "postgres", PG_BACKEND_VERSIONSTR, backend_exec))

    就是要找到同目录下、同版本的postgres备用。initdb 执行后期,很多事情要依赖 postgres来处理的。

        /*
         * Also ensure that TZ is set, so that we don't waste time identifying the
         * system timezone each of the many times we start a standalone backend.
         * It's okay to use a hard-wired value here because nothing done during
         * initdb cares about the timezone setting.
         */
        putenv("TZ=GMT");
    
        if ((ret = find_other_exec(argv[0], "postgres", PG_BACKEND_VERSIONSTR,
                                   backend_exec)) < 0)
        {
            char        full_path[MAXPGPATH];
    
            if (find_my_exec(argv[0], full_path) < 0)
                strlcpy(full_path, progname, sizeof(full_path));
    
            if (ret == -1)
                fprintf(stderr,
                        _("The program "postgres" is needed by %s "
                          "but was not found in the
    "
                          "same directory as "%s".
    "
                          "Check your installation.
    "),
                        progname, full_path);
            else
                fprintf(stderr,
                        _("The program "postgres" was found by "%s"
    "
                          "but was not the same version as %s.
    "
                          "Check your installation.
    "),
                        full_path, progname);
            exit(1);
        }    

    接下来,获得路径:

    一个是 bin_path:      就是initdb执行的路径。我运行的结果是: /home/pgsql/project/bin

    一个是 share_path:  就是一些共享用信息的路径。我运行的结果是: /home/pgsql/project/share

        /* store binary directory */
        strcpy(bin_path, backend_exec);
        *last_dir_separator(bin_path) = '';
        canonicalize_path(bin_path);
    
        fprintf(stderr,"bin_path is: %s 
    ",bin_path);
    
        if (!share_path)
        {
            share_path = pg_malloc(MAXPGPATH);
            get_share_path(backend_exec, share_path);
        }
        else if (!is_absolute_path(share_path))
        {
            fprintf(stderr, _("%s: input file location must be an absolute path
    "), progname);
            exit(1);
        }
    
        canonicalize_path(share_path);
    
        fprintf(stderr,"share_path is: %s 
    ",share_path);
  • 相关阅读:
    值得品味的SQL
    C# Keycode对照表
    Web安全实践(9)攻击apache
    Web安全实践(8)攻击iis6.0
    Web安全实践(11)用户名枚举
    asp.net 动态添加JavaScript方法
    Web安全实践(12)密码探测
    Web安全实践(14)嗅探,arp欺骗,会话劫持与重放攻击(下)
    委托的异常处理
    Web安全实践(13)嗅探,arp欺骗,会话劫持与重放攻击(上)
  • 原文地址:https://www.cnblogs.com/gaojian/p/3174020.html
Copyright © 2011-2022 走看看