接前面,继续分析: 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[], "postgres", PG_BACKEND_VERSIONSTR,
backend_exec)) < )
{
char full_path[MAXPGPATH]; if (find_my_exec(argv[], full_path) < )
strlcpy(full_path, progname, sizeof(full_path)); if (ret == -)
fprintf(stderr,
_("The program \"postgres\" is needed by %s "
"but was not found in the\n"
"same directory as \"%s\".\n"
"Check your installation.\n"),
progname, full_path);
else
fprintf(stderr,
_("The program \"postgres\" was found by \"%s\"\n"
"but was not the same version as %s.\n"
"Check your installation.\n"),
full_path, progname);
exit();
}

接下来,获得路径:

一个是 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) = '\0';
canonicalize_path(bin_path); fprintf(stderr,"bin_path is: %s \n",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\n"), progname);
exit();
} canonicalize_path(share_path); fprintf(stderr,"share_path is: %s \n",share_path);

PostgreSQL的initdb 源代码分析之五的更多相关文章

  1. PostgreSQL的initdb 源代码分析之六

    继续分析 下面的是获取运行此程序的用户名称,主要还是为了防止在linux下用root来运行的情形. effective_user = get_id(); ) username = effective_ ...

  2. PostgreSQL的 initdb 源代码分析之二

    继续分析 下面这一段,当 initdb --version 或者  initdb --help 才有意义. ) { ], || strcmp(argv[], ) { usage(progname); ...

  3. PostgreSQL的 initdb 源代码分析之二十四

    继续分析: make_template0(); 展开: 无需再作解释,就是创建template0数据库 /* * copy template1 to template0 */ static void ...

  4. PostgreSQL的 initdb 源代码分析之十五

    继续分析: if (pwprompt || pwfilename) get_set_pwd(); 由于我启动initdb的时候,没有设置口令相关的选项,故此略过. 接下来: setup_depend( ...

  5. PostgreSQL的 initdb 源代码分析之十三

    继续分析: /* Bootstrap template1 */ bootstrap_template1(); 展开: 我这里读入的文件是:/home/pgsql/project/share/postg ...

  6. PostgreSQL的 initdb 源代码分析之十二

    继续分析 /* Now create all the text config files */ setup_config(); 将其展开: 实质就是,确定各种参数,分别写入 postgresql.co ...

  7. PostgreSQL的 initdb 源代码分析之十一

    继续分析: /* Top level PG_VERSION is checked by bootstrapper, so make it first */ write_version_file(NUL ...

  8. PostgreSQL的 initdb 源代码分析之七

    继续分析:由于我使用initdb的时候,没有指定 locale,所以会使用OS的缺省locale,这里是 en_US.UTF-8 printf(_("The files belonging ...

  9. PostgreSQL的 initdb 源代码分析之四

    继续分析: if (pwprompt && pwfilename) { fprintf(stderr, _("%s: password prompt and password ...

随机推荐

  1. linux 定时任务调度Cron的用法详解

    在linux中,推荐使用crontab -e命令添加自定义的任务,退出后重启crond进程. 重新启动cron服务或重新加载cron配置,命令: 复制代码代码示例: /etc/rc.d/init.d/ ...

  2. 视频捕捉全教程(vc+vfw)

    目 录 一. 视频捕获快速入门 二.基本的捕获设置 1.设置捕获速度: 2.设置终止捕获 3.捕获的时间限制 三.关于捕获窗口 1.创建一个AVICAP捕获窗口 2.将一个捕获窗口连接至捕获设备 3. ...

  3. zoj 1119 /poj 1523 SPF

    题目描述:考虑图8.9中的两个网络,假定网络中的数据只在有线路直接连接的2个结点之间以点对点的方式传输.一个结点出现故障,比如图(a)所示的网络中结点3出现故障,将会阻止其他某些结点之间的通信.结点1 ...

  4. addView的误区

    如果在代码中动态使用addView(v),那么v里头所有在xml里设置好的layout_xxx全部失效!

  5. hdu 2818 Building Block(加权并查集)2009 Multi-University Training Contest 1

    题意: 一共有30000个箱子,刚开始时都是分开放置的.接下来会有两种操作: 1. M x y,表示把x箱子所在的一摞放到y箱子那一摞上. 2. C y,表示询问y下方有多少个箱子. 输入: 首行输入 ...

  6. Android引用百度定位API第三方组件后导致其它.so文件无法正常加载的问题

    查看当前调试设备CPU架构的方法: adb.exe shell getprop ro.product.cpu.abi  (一般返回值为:armeabi-v7a) adb.exe shell getpr ...

  7. npm + webpack +react

    踏上征途 在开始之前,你需要把你的 Node.js 和 NPM 都更新到最新的版本.访问 nodejs.org 查看安装详情.我们将会使用 NPM 安装一些工具. 开始使用 Webpack 非常简单, ...

  8. thread.join函数,java多线程中的join函数解析

    join函数的作用,是让当前线程等待,直到调用join()的 线程结束或者等到一段时间,我们来看以下代码 package mian; public class simpleplela { static ...

  9. bzoj 2095: [Poi2010]Bridges(二分法+混合图的欧拉回路)

    [题意] 给定n点m边的无向图,对于边u,v,从u到v边权为c,从v到u的边权为d,问能够经过每条边一次且仅一次,且最大权值最小的欧拉回路. [思路] 二分答案mid,然后切断权值大于mid的边,原图 ...

  10. Tkinter教程之Text(2)篇

    本文转载自:http://blog.csdn.net/jcodeer/article/details/1811347 '''Tkinter教程之Text(2)篇''''''6.使用tag来指定文本的属 ...