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

    printf(_("The files belonging to this database system will be owned "
"by user \"%s\".\n"
"This user must also own the server process.\n\n"),
effective_user); if (strcmp(lc_ctype, lc_collate) == &&
strcmp(lc_ctype, lc_time) == &&
strcmp(lc_ctype, lc_numeric) == &&
strcmp(lc_ctype, lc_monetary) == &&
strcmp(lc_ctype, lc_messages) == )
printf(_("The database cluster will be initialized with locale %s.\n"), lc_ctype); else
{ printf(_("The database cluster will be initialized with locales\n"
" COLLATE: %s\n"
" CTYPE: %s\n"
" MESSAGES: %s\n"
" MONETARY: %s\n"
" NUMERIC: %s\n"
" TIME: %s\n"),
lc_collate,
lc_ctype,
lc_messages,
lc_monetary,
lc_numeric,
lc_time);
}

接下来,再看Encoding:

我这里计算得到 ctype_enc 的值是 6,

pg_encoding_to_char(ctype_enc) 得到 UTF8。

所以输出: The default database encoding has accordingly been set to UTF8。

    if (strlen(encoding) == )
{
int ctype_enc; ctype_enc = pg_get_encoding_from_locale(lc_ctype, true); if (ctype_enc == -)
{
/* Couldn't recognize the locale's codeset */
fprintf(stderr, _("%s: could not find suitable encoding for locale %s\n"),
progname, lc_ctype);
fprintf(stderr, _("Rerun %s with the -E option.\n"), progname);
fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
progname);
exit();
}
else if (!pg_valid_server_encoding_id(ctype_enc))
{
/*
* We recognized it, but it's not a legal server encoding. On
* Windows, UTF-8 works with any locale, so we can fall back to
* UTF-8.
*/
#ifdef WIN32
printf(_("Encoding %s implied by locale is not allowed as a server-side encoding.\n"
"The default database encoding will be set to %s instead.\n"),
pg_encoding_to_char(ctype_enc),
pg_encoding_to_char(PG_UTF8));
ctype_enc = PG_UTF8;
encodingid = encodingid_to_string(ctype_enc);
#else
fprintf(stderr,
_("%s: locale %s requires unsupported encoding %s\n"),
progname, lc_ctype, pg_encoding_to_char(ctype_enc));
fprintf(stderr,
_("Encoding %s is not allowed as a server-side encoding.\n"
"Rerun %s with a different locale selection.\n"),
pg_encoding_to_char(ctype_enc), progname);
exit();
#endif
}
else
{
encodingid = encodingid_to_string(ctype_enc);
printf(_("The default database encoding has accordingly been set to %s.\n"),
pg_encoding_to_char(ctype_enc));
}
}
else
encodingid = get_encoding_id(encoding);

user_enc = atoi(encodingid);

    if (!check_locale_encoding(lc_ctype, user_enc) ||  
      !check_locale_encoding(lc_collate, user_enc))
        exit(1); /* check_locale_encoding printed the error */

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 源代码分析之五

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

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

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

随机推荐

  1. .Net中的各种序列化

    我们知道将对象的状态保持在存储媒体中,以便可以在以后重新创建精确的副本这正是数据持久化所要做的.而且,不同应用程序之间的通讯需要相互传输数据.那么序列化和反序列化正是为此而生. 序列化和反序列化 所谓 ...

  2. TCP/IP详解学习笔记(8)-DNS域名系统

    前面已经提到了访问一台机器要靠IP地址和MAC地址,其中,MAC地址可以通过ARP协议得到,所以这对用户是透明的,但是IP地址就不行,无论如何用户都需要用一个指定的IP来访问一台计算机,而IP地址又非 ...

  3. 基于ASP.NET MVC和Bootstrap搭建响应式个人博客站(一)

    1.0 为什么要做这个博客站? www.zynblog.com   在工作学习中,经常要搜索查找各种各样的资料,每次找到相关资料后都会顺手添加到浏览器书签中,时间一长,书签也就满了.而且下次再点击这个 ...

  4. MySQL安装之“测试”

    将MySQL安装完成之后还需要对其进行测试,判断MySQL是否安装成功,MySQL其可视化与我们之前使用过的SQLserver不同.MySQL其中测试方法有两种:一.使用MySQL命令进行测试:二.安 ...

  5. 【LeetCode 169】Majority Element

    Given an array of size n, find the majority element. The majority element is the element that appear ...

  6. CSS Sprite的优缺点分析

    目前大多数的开发人员对这个技术都有相当地掌握,也有很多关于它的教程和文章.几乎所有的文章中都宣称设计师和开发人员都应该使用 CSS sprite 来减少 HTTP 请求数,并且节省一些流量.这个技术被 ...

  7. [转]Ubuntu下GitHub的使用

    转自Pythoner 本文将对Ubuntu下Git的安装,以及如何连接GitHub进行讲解. 1.环境 OS: Ubuntu13.04 64bitsGit: 1.8.1.2 2.Git安装 执行如下命 ...

  8. 你想成为优秀的Java程序员吗?

    Java是全世界最受欢迎的3大编程语言之一,它可以开发出许多实用的WEB应用程序和桌面应用程序,更重要的一点,Java是跨平台的语言——编写一次,可以再任何地方运行.另外,Java也很容易入门,如果你 ...

  9. 第二百五十七天 how can I 坚持

    下了个vmware12,不能用,不支持intel vx.电脑太老了,该换了,不过还很好用.该咋办.明年买个小米笔记本. 小米今天出了个小米自行车.不过不是小米生态链产品,好丑. 今天懒掌柜定做宣传服. ...

  10. ReactNative 踩坑小计

    使用ES6語法編寫Component時綁定事件需要用this.MethodName.bind(this),否則MethodName中無法使用this <TouchableHighlight on ...