继续分析,

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

    /* Create transaction log symlink, if required */if (strcmp(xlog_dir, "") != 0){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 0:/* xlog directory not there, must create it */printf(_("creating directory %s ... "),xlog_dir);fflush(stdout);if (pg_mkdir_p(xlog_dir, S_IRWXU) != 0){fprintf(stderr, _("%s: could not create directory \"%s\": %s\n"),progname, xlog_dir, strerror(errno));exit_nicely();}elsecheck_ok();made_new_xlogdir = true;break;case 1:/* 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) != 0){fprintf(stderr, _("%s: could not change permissions of directory \"%s\": %s\n"),progname, xlog_dir, strerror(errno));exit_nicely();}elsecheck_ok();found_existing_xlogdir = true;break;case 2:/* 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) + 8 + 1);sprintf(linkloc, "%s/pg_xlog", pg_data);#ifdef HAVE_SYMLINKif (symlink(xlog_dir, linkloc) != 0){fprintf(stderr, _("%s: could not create symbolic link \"%s\": %s\n"),progname, linkloc, strerror(errno));exit_nicely();}
#elsefprintf(stderr, _("%s: symlinks are not supported on this platform"));exit_nicely();
#endif}

接下来:

开始创建各个子目录

    /* Create required subdirectories */printf(_("creating subdirectories ... "));fflush(stdout);for (i = 0; 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);}
}

转载于:https://www.cnblogs.com/gaojian/p/3177146.html

PostgreSQL的 initdb 源代码分析之十相关推荐

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

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

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

    接前面,继续分析: putenv("TZ=GMT") 设置了时区信息. find_other_exec(argv[0], "postgres", PG_BACK ...

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

    继续:下面的是定义信号处理函数. /** now we are starting to do real work, trap signals so we can clean up*//* some o ...

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

    继续分析: vacuum_db(); 展开: cmd是:/home/pgsql/project/bin/postgres" --single -F -O -c search_path=pg_ ...

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

    继续分析: setup_schema(); 展开: 实质就是创建info_schema. cmd 是: "/home/pgsql/project/bin/postgres" --s ...

  6. Redis源代码分析(十)--- testhelp.h小测试框架和redis-check-aof.c 日志检测

    周期分析struct结构体redis代码.最后,越多越发现很多的代码其实大同小异.于struct有袋1,2不分析文件,关于set集合的一些东西,就放在下次分析好了,在选择下个分析的对象时,我考虑了一下 ...

  7. BT源代码学习心得(十):客户端源代码分析(相关对象一览) -- 转贴自 wolfenstein (NeverSayNever)

    BT源代码学习心得(十):客户端源代码分析(相关对象一览) Author:wolfenstein(NeverSayNever), BitTorrent/download.py中的Multitorren ...

  8. BT源代码学习心得(十五):客户端源代码分析(下载过程中的块选取策略)

    BT源代码学习心得(十五):客户端源代码分析(下载过程中的块选取策略) 发信人: wolfenstein (NeverSayNever), 个人文集 标  题: BT源代码学习心得(十五):客户端源代 ...

  9. Spark SQL 源代码分析系列

    从决定写Spark SQL文章的源代码分析,到现在一个月的时间,一个又一个几乎相同的结束很快,在这里也做了一个综合指数,方便阅读,下面是读取顺序 :) 第一章 Spark SQL源代码分析之核心流程 ...

最新文章

  1. 没有c语言基础可以学python吗-必须要有C语言基础才能学python吗
  2. java 中普通类继承,抽象类继承,接口类继承,子类一定要重写父类中的方法吗
  3. “蜥蜴之尾”——长老木马四代分析报告
  4. LOJ#2542 随机游走
  5. R中统计假设检验总结(一)
  6. linux命令大全---入门篇(菜鸟必会)
  7. 亚马逊云科技 2022 年 3 月新服务新功能强势来袭
  8. 简易交通灯设计——数电课设
  9. ps自带磨皮滤镜插件Portraiture3PS版
  10. android实现箭头流程列表_Android弹出选项框及指示箭头动画选择
  11. 乐刻运动年陈文化中的那六个成语解析:日拱一卒,功不唐捐|筚路蓝缕 玉汝于成|有梦可依,未来可期
  12. html做相册浏览,ul结合CSS制作网页相册滑动浏览效果
  13. 鸿蒙系统运行内存为啥只有8g,为什么手机运存是8G的,但是可用却只有5G?
  14. Android模糊查询(首字母、简拼、全拼,汉字)
  15. Android Camera驱动分析
  16. Linux---进程调度及CFS调度器
  17. 博弈论coursera
  18. HTML+CSS自用知识点(第四周)
  19. 为了安全起见,要求使用强SA密码的解决方法
  20. cartographer算法(一)——概述及框架

热门文章

  1. java generatedvalue_java-@GeneratedValue和@GenericGen之间的区别
  2. java年龄不能超过120,systemd 代码行数超过 120 万,创始人贡献的 commits 最多
  3. 特征提取方法: one-hot 和 TF-IDF
  4. Java中对象及常量,局部变量,全局变量的存储位置
  5. Algs4-1.3.10中序表达式转为后序表达式(第二次实现)
  6. 初创公司MindMaze研发情绪反应VR,让VR关怀你的喜怒哀乐
  7. Django的url别名功能的使用
  8. 腾讯云首发智能网关流控,公有云进入网络精细管控时代
  9. 2014年听写VOA50篇
  10. Linux常用命令汇总--cat