继续分析,

如下这段,因为条件不成立,被跳过:

    /* Create transaction log symlink, if required */
if (strcmp(xlog_dir, "") != )
{ fprintf(stderr,"In main function -----------------190\n"); char *linkloc; /* clean up xlog directory name, check it's absolute */
canonicalize_path(xlog_dir);
if (!is_absolute_path(xlog_dir))
{
fprintf(stderr, _("%s: transaction log directory location must be an absolute path\n"), progname);
exit_nicely();
} /* check if the specified xlog directory exists/is empty */
switch (pg_check_dir(xlog_dir))
{
case :
/* xlog directory not there, must create it */
printf(_("creating directory %s ... "),
xlog_dir);
fflush(stdout); if (pg_mkdir_p(xlog_dir, S_IRWXU) != )
{
fprintf(stderr, _("%s: could not create directory \"%s\": %s\n"),
progname, xlog_dir, strerror(errno));
exit_nicely();
}
else
check_ok(); made_new_xlogdir = true;
break; case :
/* Present but empty, fix permissions and use it */
printf(_("fixing permissions on existing directory %s ... "),
xlog_dir);
fflush(stdout); if (chmod(xlog_dir, S_IRWXU) != )
{
fprintf(stderr, _("%s: could not change permissions of directory \"%s\": %s\n"),
progname, xlog_dir, strerror(errno));
exit_nicely();
}
else
check_ok(); found_existing_xlogdir = true;
break; case :
/* Present and not empty */
fprintf(stderr,
_("%s: directory \"%s\" exists but is not empty\n"),
progname, xlog_dir);
fprintf(stderr,
_("If you want to store the transaction log there, either\n"
"remove or empty the directory \"%s\".\n"),
xlog_dir);
exit_nicely(); default:
/* Trouble accessing directory */
fprintf(stderr, _("%s: could not access directory \"%s\": %s\n"),
progname, xlog_dir, strerror(errno));
exit_nicely();
} /* form name of the place where the symlink must go */
linkloc = (char *) pg_malloc(strlen(pg_data) + + );
sprintf(linkloc, "%s/pg_xlog", pg_data); #ifdef HAVE_SYMLINK
if (symlink(xlog_dir, linkloc) != )
{
fprintf(stderr, _("%s: could not create symbolic link \"%s\": %s\n"),
progname, linkloc, strerror(errno));
exit_nicely();
}
#else
fprintf(stderr, _("%s: symlinks are not supported on this platform"));
exit_nicely();
#endif
}

接下来:

开始创建各个子目录

    /* Create required subdirectories */
printf(_("creating subdirectories ... "));
fflush(stdout); for (i = ; i < (sizeof(subdirs) / sizeof(char *)); i++)
{
if (!mkdatadir(subdirs[i]))
exit_nicely();
}

加入调试代码后,可以看到,上述建立的各子目录分别是:

subdirs[0] is: global

subdirs[1] is: pg_xlog

subdirs[2] is: pg_xlog/archive_status

subdirs[3] is: pg_clog

subdirs[4] is: pg_notify

subdirs[5] is: pg_serial

subdirs[6] is: pg_subtrans

subdirs[7] is: pg_twophase

subdirs[8] is: pg_multixact/members

subdirs[9] is: pg_multixact/offsets

subdirs[10] is: base

subdirs[11] is: base/1

subdirs[12] is: pg_tblspc

subdirs[13] is: pg_stat_tmp

想起来了,前面有过定义的:

    static const char *subdirs[] = {
"global",
"pg_xlog",
"pg_xlog/archive_status",
"pg_clog",
"pg_notify",
"pg_serial",
"pg_subtrans",
"pg_twophase",
"pg_multixact/members",
"pg_multixact/offsets",
"base",
"base/1",
"pg_tblspc",
"pg_stat_tmp"
};

而接下来,就是:

    check_ok();

这个check_ok ,其注释就说得很清楚:

/*
* call exit_nicely() if we got a signal, or else output "ok".
*/
static void
check_ok(void)
{
if (caught_signal)
{
printf(_("caught signal\n"));
fflush(stdout);
exit_nicely();
}
else if (output_failed)
{
printf(_("could not write to child process: %s\n"),
strerror(output_errno));
fflush(stdout);
exit_nicely();
}
else
{
/* all seems well */
printf(_("ok\n"));
fflush(stdout);
}
}

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

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

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

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

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

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

    继续分析: setup_dictionary(); 展开: 其中: cmd 是:"/home/pgsql/project/bin/postgres" --single -F -O ...

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

    继续分析: setup_conversion(); 展开: 其实质是: 运行命令:"/home/pgsql/project/bin/postgres" --single -F -O ...

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

    继续分析 setup_description(); 展开后: 就是要把 share/postgres.description 文件的内容读入到 pg_description 和 pg_shdescri ...

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

    继续分析: /* * Make the per-database PG_VERSION for template1 only after init'ing it */ write_version_fi ...

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

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

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

    继续分析: make_postgres(); 展开: 目的是创建postgres数据库. cmd是:/home/pgsql/project/bin/postgres" --single -F ...

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

    继续分析 load_plpgsql(); 展开: 就是让postgres 执行 create extension plpgsql cmd是: "/home/pgsql/project/bin ...

随机推荐

  1. OOP——UML六种关系

    UML定义的关系主要有:泛化.实现.依赖.关联.聚合.组合,这六种关系紧密程度依次加强,分别看一下 泛化 概念:泛化是一种一般与特殊.一般与具体之间关系的描述,具体描述建立在一般描述的基础之上,并对其 ...

  2. 基于Live555,ffmpeg的RTSP播放器直播与点播

    基于Live555,ffmpeg的RTSP播放器直播与点播 多路RTSP高清视频播放器下载地址:http://download.csdn.net/detail/u011352914/6604437多路 ...

  3. redis配置实例及redis.conf详细说明

    一.配置实例 1.redis修改持久化路径.日志路径.清缓存 redis修改持久化路径和日志路径 vim  redis.conf logfile /data/redis_cache/logs/redi ...

  4. Android:实现一种浮动选择菜单的效果

    总结如何实现Android浮动层,主要是dialog的使用. 自定义一个类继承自Dialog类,然后在构造方法中,定义这个dialog的布局和一些初始化信息. 案例1: public class Me ...

  5. android让你的TabHost滑动起来

    在Android应用中,一般TabActivity和若干个Tab选项卡(TabWidget).如果选项卡的数量超过了5个,就不适合放到一个屏幕中,这样可以让这些选项卡滑动起来. 滑动的选项卡的实现有好 ...

  6. IOS release 版本的时候 去掉输出log NSLog

    在.pch文件中添加下面一段 #ifndef __OPTIMIZE__ #define NSLog(...) NSLog(__VA_ARGS__) #else #define NSLog(...) { ...

  7. .net获取当前网址url(各种参数值)

    .net获取当前网址url(各种参数值) 假设当前页完整地址是:http://www.test.com/aaa/bbb.aspx?id=1&name=category" 先来看一下整 ...

  8. 关于ShareSDK接入的各种问题,以及解决方案

    随着社交网络的流行,游戏接入分享已经是必然.毕竟这是非常好的一种推广方式.ShareSDK是一个非常好的内分享提供商!但是接入后发生的各种问题,下面给大家提供几个本人遇到的问题,以及解决方法: 1)微 ...

  9. redis集群的搭建

    1.首先下载好软件包 #cd /opt/tzr/ #wget http://redis.googlecode.com/files/redis-2.6.11.tar.gz #mkdir /opt/tzr ...

  10. 浅谈JavaScript中的原型模式

    在JavaScript中创建对象由很多种方式,如工厂模式.构造函数模式.原型模式等: <pre name="code" class="html">/ ...