继续分析

    /* Now create all the text config files */
setup_config();

将其展开:

实质就是,确定各种参数,分别写入 postgresql.conf 、pg_hba.conf、pg_indent.conf 文件。

/*
* set up all the config files
*/
static void
setup_config(void)
{
char **conflines;
char repltok[];
char path[MAXPGPATH]; fputs(_("creating configuration files ... "), stdout);
fflush(stdout); /* postgresql.conf */ conflines = readfile(conf_file); snprintf(repltok, sizeof(repltok), "max_connections = %d", n_connections);
conflines = replace_token(conflines, "#max_connections = 100", repltok); if ((n_buffers * (BLCKSZ / )) % == )
snprintf(repltok, sizeof(repltok), "shared_buffers = %dMB",
(n_buffers * (BLCKSZ / )) / );
else
snprintf(repltok, sizeof(repltok), "shared_buffers = %dkB",
n_buffers * (BLCKSZ / ));
conflines = replace_token(conflines, "#shared_buffers = 32MB", repltok); #if DEF_PGPORT != 5432
snprintf(repltok, sizeof(repltok), "#port = %d", DEF_PGPORT);
conflines = replace_token(conflines, "#port = 5432", repltok);
#endif snprintf(repltok, sizeof(repltok), "lc_messages = '%s'",
escape_quotes(lc_messages));
conflines = replace_token(conflines, "#lc_messages = 'C'", repltok); snprintf(repltok, sizeof(repltok), "lc_monetary = '%s'",
escape_quotes(lc_monetary));
conflines = replace_token(conflines, "#lc_monetary = 'C'", repltok); snprintf(repltok, sizeof(repltok), "lc_numeric = '%s'",
escape_quotes(lc_numeric));
conflines = replace_token(conflines, "#lc_numeric = 'C'", repltok); snprintf(repltok, sizeof(repltok), "lc_time = '%s'",
escape_quotes(lc_time));
conflines = replace_token(conflines, "#lc_time = 'C'", repltok); switch (locale_date_order(lc_time))
{
case DATEORDER_YMD:
strcpy(repltok, "datestyle = 'iso, ymd'");
break;
case DATEORDER_DMY:
strcpy(repltok, "datestyle = 'iso, dmy'");
break;
case DATEORDER_MDY:
default:
strcpy(repltok, "datestyle = 'iso, mdy'");
break;
}
conflines = replace_token(conflines, "#datestyle = 'iso, mdy'", repltok); snprintf(repltok, sizeof(repltok),
"default_text_search_config = 'pg_catalog.%s'",
escape_quotes(default_text_search_config));
conflines = replace_token(conflines,
"#default_text_search_config = 'pg_catalog.simple'",
repltok); snprintf(path, sizeof(path), "%s/postgresql.conf", pg_data); writefile(path, conflines); chmod(path, S_IRUSR | S_IWUSR); free(conflines); /* pg_hba.conf */ conflines = readfile(hba_file); #ifndef HAVE_UNIX_SOCKETS
conflines = filter_lines_with_token(conflines, "@remove-line-for-nolocal@");
#else
conflines = replace_token(conflines, "@remove-line-for-nolocal@", "");
#endif #ifdef HAVE_IPV6 /*
* Probe to see if there is really any platform support for IPv6, and
* comment out the relevant pg_hba line if not. This avoids runtime
* warnings if getaddrinfo doesn't actually cope with IPv6. Particularly
* useful on Windows, where executables built on a machine with IPv6 may
* have to run on a machine without.
*/
{
struct addrinfo *gai_result;
struct addrinfo hints;
int err = ; #ifdef WIN32
/* need to call WSAStartup before calling getaddrinfo */
WSADATA wsaData; err = WSAStartup(MAKEWORD(, ), &wsaData);
#endif /* for best results, this code should match parse_hba() */
hints.ai_flags = AI_NUMERICHOST;
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = ;
hints.ai_protocol = ;
hints.ai_addrlen = ;
hints.ai_canonname = NULL;
hints.ai_addr = NULL;
hints.ai_next = NULL; if (err != ||
getaddrinfo("::1", NULL, &hints, &gai_result) != )
conflines = replace_token(conflines,
"host all all ::1",
"#host all all ::1");
}
#else /* !HAVE_IPV6 */
/* If we didn't compile IPV6 support at all, always comment it out */
conflines = replace_token(conflines,
"host all all ::1",
"#host all all ::1");
#endif /* HAVE_IPV6 */ /* Replace default authentication methods */
conflines = replace_token(conflines,
"@authmethod@",
authmethod);
conflines = replace_token(conflines,
"@authmethodlocal@",
authmethodlocal); conflines = replace_token(conflines,
"@authcomment@",
strcmp(authmethod, "trust") ? "" : AUTHTRUST_WARNING); /* Replace username for replication */
conflines = replace_token(conflines,
"@default_username@",
username); snprintf(path, sizeof(path), "%s/pg_hba.conf", pg_data); writefile(path, conflines);
chmod(path, S_IRUSR | S_IWUSR); free(conflines); /* pg_ident.conf */ conflines = readfile(ident_file); snprintf(path, sizeof(path), "%s/pg_ident.conf", pg_data); writefile(path, conflines);
chmod(path, S_IRUSR | S_IWUSR); free(conflines); check_ok();
}

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

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

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

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

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

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

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

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

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

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

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

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

    继续分析, 如下这段,因为条件不成立,被跳过: /* Create transaction log symlink, if required */ ) { fprintf(stderr,"I ...

  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. 结合daterangepicker实现Datatables表格带参数查询

    http://dt.thxopen.com/example/user_share/send_extra_param.html#@一颗树 http://www.guoxk.com/node/jquery ...

  2. DirectShow系统初级指南

    流媒体的处理,以其复杂性和技术性,一向广受工业界的关注.特别伴随着因特网的普及,流媒体在网络上的广泛应用,怎样使流媒体的处理变得简单而富有成效逐渐成为了焦点问题.选择一种合适的应用方案,事半功倍.此时 ...

  3. distinct数据去重关键字

    在表中,可能会包含重复值.这并不成问题,不过,有时您也许希望仅仅列出不同(distinct)的值.关键词 distinct用于返回唯一不同的值. 表A: 示例1 select distinct nam ...

  4. (2)Spring集成Quartz定时任务框架介绍和Cron表达式详解

    在JavaEE系统中,我们会经常用到定时任务,比如每天凌晨生成前天报表,每一小时生成汇总数据等等.我们可以使用java.util.Timer结合java.util.TimerTask来完成这项工作,但 ...

  5. C/C++面试小知识点

    1.static有什么用途. 解答: 在函数体中,一个被声明为静态的变量在这一函数被调用过程中维持其值不变. 在模块内(但在函数体外),一个被声明为静态的变量可以被模块内所有函数访问,但不能被模块外其 ...

  6. zoj3822-Domination (概率dp)

    题意: 给你n*m的棋盘,每天选择的一个空的方格放一个棋子,求使棋盘的每行每列都至少有一个棋子的天数期望. 分析: 先想状态,要使每行每列都至少一个,考虑前i行j列,能放得就是i行j列里面的或第i+1 ...

  7. acdream 1044

    题意:有你一个草坪,草的初始高度都是100,让你用割草机割,割草机只能横着或竖着割,每次割的高度一定,问你能不能割出给定的草坪出来. 考虑任意一个草被割要么是横着要么竖着,所以任意一个草必然是它所在行 ...

  8. poj 3311 Hie with the Pie

    floyd,旅游问题每个点都要到,可重复,最后回来,dp http://poj.org/problem?id=3311 Hie with the Pie Time Limit: 2000MS   Me ...

  9. 022 UFT虚拟对象

    虚拟对象: 程序中那些行为标准类型对象的对象,但不能被QTP识别,则可把这些对象类型称为虚拟对象.并且映射到某类标准对象,例如button,check box等,QTP在测试过程中就会对这些虚拟对象模 ...

  10. 仿酷狗音乐播放器开发日志二十六 duilib在标题栏弹出菜单的方法

    转载请说明原出处,谢谢~~ 上篇日志说明了怎么让自定义控件响应右键消息.之后我给主窗体的标题栏增加右键响应,观察原酷狗后可以发现,在整个标题栏都是可以响应右键并弹出菜单的.应该的效果如下: 本以为像上 ...