继续分析:由于我使用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. 【MySQL】通过select语句把一列数据拼接成一条字符串

    通过 GROUP_CONCAT(如下图)

  2. JavaScript--事件模型(转)

    在各种浏览器中存在三种事件模型:原始事件模型( original event model),DOM2事件模型,IE事件模型.其中原始的事件模型被所有浏览器所支持,而DOM2中所定义的事件模型目前被除了 ...

  3. 【转载】图论 500题——主要为hdu/poj/zoj

    转自——http://blog.csdn.net/qwe20060514/article/details/8112550 =============================以下是最小生成树+并 ...

  4. codeforces 690C3 Brain Network

    simple:并查集一下 #include <vector> #include <iostream> #include <queue> #include <c ...

  5. IOS UIActivityIndicatorView 等待指示器

    自己做的一个 等待指示器 #import <UIKit/UIKit.h> @interface RockIndicatorView : UIView { } @property(nonat ...

  6. 仿酷狗音乐播放器开发日志二十五 duilib右键事件的不足的bug修复

    转载请说明原出处,谢谢~~ 虽然仿酷狗的各个菜单早就写好了,但是一直没有附加到程序里.今天把菜单和播放列表控件关联时发现了问题. 和播放列表相关的菜单有三个,分别是每个音乐项目控件相关的菜单.分组的菜 ...

  7. springmvc基础知识

    springmvc框架,类似于struts,主要用于MVC的控制层 spring的简单配置(非注解):  spring-mvc.xml文件(springMVC框架的基本文件) web.xml文件 ja ...

  8. dwr消息推送

    闲来无事,把自己关于对dwr消息推送的实现过程描述一番. 首先第一步,当然在工程中是加入dwr.jar了,接着在web.xml中配置以下代码 <servlet> <servlet-n ...

  9. bzoj 2134 单选错位(期望)

    [题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=2134 [题意] ai与ai+1相等得1分,求期望. [思路] 每个题的期望都是独立的. ...

  10. Hbase笔记——RowKey设计

    一).什么情况下使用Hbase 1)传统数据库无法承载高速插入.大量读取. 2)Hbase适合海量,但同时也是简单的操作. 3)成熟的数据分析主题,查询模式确立不轻易改变. 二).现实场景 1.电商浏 ...