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

继续分析 下面这一段,当 initdb --version 或者  initdb --help 才有意义. ) { ], || strcmp(argv[], ) { usage(progname); exit(); } ], || strcmp(argv[], ) { puts("initdb (PostgreSQL) " PG_VERSION); exit(); } } 再看下一段: 实际上就是 initdb 运行时候,后面可以跟各种参数.我这里只考虑 -D那种就好了 /* proc…
继续分析: make_template0(); 展开: 无需再作解释,就是创建template0数据库 /* * copy template1 to template0 */ static void make_template0(void) { PG_CMD_DECL; const char **line; static const char *template0_setup[] = { "CREATE DATABASE template0;\n", "UPDATE pg_d…
继续分析: make_postgres(); 展开: 目的是创建postgres数据库. cmd是:/home/pgsql/project/bin/postgres" --single -F -O -c search_path=pg_catalog -c exit_on_error=true template1 >/dev/null /* * copy template1 to postgres */ static void make_postgres(void) { PG_CMD_DEC…
继续分析: vacuum_db(); 展开: cmd是:/home/pgsql/project/bin/postgres" --single -F -O -c search_path=pg_catalog -c exit_on_error=true template1 >/dev/null 其目的很明确,就是 对 template1 数据库执行 ANALYZE;VACUUM FULL;VACUUM FREEZE; /* * clean everything up in template1…
继续分析 load_plpgsql(); 展开: 就是让postgres 执行 create extension plpgsql cmd是: "/home/pgsql/project/bin/postgres" --single -F -O -c search_path=pg_catalog -c exit_on_error=true template1 >/dev/nullok /* * load PL/pgsql server-side language */ static…
继续分析: setup_schema(); 展开: 实质就是创建info_schema. cmd 是: "/home/pgsql/project/bin/postgres" --single -F -O -c search_path=pg_catalog -c exit_on_error=true -j template1 >/dev/null infor_schem_file是:/home/pgsql/project/share/information_schema.sql /…
继续分析: setup_privileges(); 展开: 这是设置权限. 其cmd是:"/home/pgsql/project/bin/postgres" --single -F -O -c search_path=pg_catalog -c exit_on_error=true template1 >/dev/null 其命令是:UPDATE pg_class   SET relacl = E'{"=r/\\"$POSTGRES_SUPERUSERNAME…
继续分析 /* 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 path[MAXPGPATH]; fpu…
继续分析 下面的是获取运行此程序的用户名称,主要还是为了防止在linux下用root来运行的情形. effective_user = get_id(); ) username = effective_user; 接下来,是准备好一写预备生成的文件的名称变量: set_input(&bki_file, "postgres.bki"); set_input(&desc_file, "postgres.description"); set_input(&a…
继续分析: if (pwprompt || pwfilename) get_set_pwd(); 由于我启动initdb的时候,没有设置口令相关的选项,故此略过. 接下来: setup_depend(); 展开: 就是一组sql问,送给 postgres 执行: cmd的值是: "/home/pgsql/project/bin/postgres" --single -F -O -c search_path=pg_catalog -c exit_on_error=true templat…
继续分析: /* Bootstrap template1 */ bootstrap_template1(); 展开: 我这里读入的文件是:/home/pgsql/project/share/postgres.bki /* * run the BKI script in bootstrap mode to create template1 */ static void bootstrap_template1(void) { PG_CMD_DECL; char **line; char *talka…
继续分析: /* Top level PG_VERSION is checked by bootstrapper, so make it first */ write_version_file(NULL); 就是建立了一个 PG_VERSION的文件 在我系统里,可以看到: [pgsql@localhost DemoDir]$ cat PG_VERSION 9.1 [pgsql@localhost DemoDir]$ 接下来: 我先看看 set_null_conf 函数 /* Select su…
继续分析:由于我使用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"), effectiv…
接前面,继续分析: putenv("TZ=GMT") 设置了时区信息. find_other_exec(argv[0], "postgres", PG_BACKEND_VERSIONSTR, backend_exec)) 就是要找到同目录下.同版本的postgres备用.initdb 执行后期,很多事情要依赖 postgres来处理的. /* * Also ensure that TZ is set, so that we don't waste time iden…
继续分析: if (pwprompt && pwfilename) { fprintf(stderr, _("%s: password prompt and password file cannot be specified together\n"), progname); exit(); } if (authmethod == NULL || !strlen(authmethod)) { authwarning = _("\nWARNING: enablin…
继续 其实接前面,整个while循环是这样的: ) { switch (c) { ...... } ...... } 这一句,c = getopt_long(argc, argv, "dD:E:L:nU:WA:sT:X:", long_options, &option_index), 除了获得initdb 后跟着的是 -D 还是 -E之类的,还有一个用途,就是给 全局变量 optarg 赋值.这个全局变量其实挺坑爹的. /* * getopt_long * Parse argc…
继续分析: setup_dictionary(); 展开: 其中: cmd 是:"/home/pgsql/project/bin/postgres" --single -F -O -c search_path=pg_catalog -c exit_on_error=true -j template1 >/dev/null dictionary_file 是:/home/pgsql/project/share/snowball_create.sql /* * load extra…
继续分析: setup_conversion(); 展开: 其实质是: 运行命令:"/home/pgsql/project/bin/postgres" --single -F -O -c search_path=pg_catalog -c exit_on_error=true template1 >/dev/null 传递参数:/home/pgsql/project/share/conversion_create.sql /* * load conversion function…
继续分析: setup_collation() 展开: /* * populate pg_collation */ static void setup_collation(void) { #if defined(HAVE_LOCALE_T) && !defined(WIN32) int i; FILE *locale_a_handle; char localebuf[NAMEDATALEN]; ; PG_CMD_DECL; #endif fputs(_("creating col…
继续分析 setup_description(); 展开后: 就是要把 share/postgres.description 文件的内容读入到 pg_description 和 pg_shdescription /* * load description data */ static void setup_description(void) { PG_CMD_DECL; fputs(_("loading system objects' descriptions ... "), stdo…
继续分析: /* * Make the per-database PG_VERSION for template1 only after init'ing it */ write_version_file("base/1"); 就是在base/1目录下,生成一个  PG_VERSION 文件. [pgsql@localhost ]$ pwd /home/pgsql/DemoDir/ [pgsql@localhost ]$ cat PG_VERSION 9.1 [pgsql@localh…
继续分析, 如下这段,因为条件不成立,被跳过: /* Create transaction log symlink, if required */ ) { fprintf(stderr,"In main function -----------------190\n"); char *linkloc; /* clean up xlog directory name, check it's absolute */ canonicalize_path(xlog_dir); if (!is_…
继续:下面的是定义信号处理函数. /* * now we are starting to do real work, trap signals so we can clean up */ /* some of these are not valid on Windows */ #ifdef SIGHUP pqsignal(SIGHUP, trapsig); #endif #ifdef SIGINT pqsignal(SIGINT, trapsig); #endif #ifdef SIGQUIT…
继续分析 由于 我并未进行特殊的参数设置,所以 (strlen(default_text_search_config) == 0) 成立. 故 调用   default_text_search_config = find_matching_ts_config(lc_ctype) 最后输出:The default text search configuration will be set to "english". ) { default_text_search_config = fin…
开始第一段: int main(int argc, char *argv[]) { /* * options with no short version return a low integer, the rest return * their short version value */ static struct option long_options[] = { {"pgdata", required_argument, NULL, 'D'}, {"encoding&q…
[转]hostapd源代码分析(二):hostapd的工作机制 原文链接:http://blog.csdn.net/qq_21949217/article/details/46004433 在我的上一篇文章<hostapd源代码分析(一):网络接口和BSS的初始化>中,介绍了两个重要的数据结构hostapd_iface和hostapd_data以及网络接口和BSS的初始化设置的过程.下面,我要在这一篇文章中详细介绍hostapd的工作机制.hostapd的模块结构如下 从上图中可以看出,hos…
因为时间关系:本次仅仅对这三个API($.camelCase.$.contains.$.each)方法进行分析 第一个方法变量转驼峰:$.camelCase('hello-world-welcome'); 源代码: var camelize; /**  * 字符串替换  * 使用replace第二个參数带回调  */ camelize = function(str) {      return str.replace(/-+(.)?/g,           function(match, ch…
今天的学习更有效率.该Rio分析过,学习之间的另一种方式RedisObject文件,只想说RedisObject有些生成和转换.都是很类似的.列出里面长长的API列表: /* ------------ API --------------------- */ robj *createObject(int type, void *ptr) /* 最初的创建robj对象方法,后面的创建方法与此相似 */ robj *createStringObject(char *ptr, size_t len)…
在上篇文章中初步的分析了一下,Redis工具类文件里的一些使用方法,包含2个随机算法和循环冗余校验算法,今天,继续学习Redis中的其它的一些辅助工具类的使用方法.包含里面的大小端转换算法,sha算法在Redis中的实现和通用工具类算法util.c. 先来看看大小端转换算法,大小端学习过操作系统的人一定知道是什么意思,在不同的操作系统中,高位数字的存储方式存在,高位在前,低位在后,或是高位在后,低位在前,所以这里面就涉及到转换,依据不同的操作系统,有不同的转换方式,所以Redis在这方面就开放了…
我使用的是opencv2.4.9.安装后.我的cvboost..cpp文件的路径是........\opencv\sources\apps\haartraining\cvhaartraining.cpp,研究源代码那么多天,有非常多收获.opencv库真是非常强大.当中在这篇博文中我有部分凝视,其它的有关知识请參考我博客http://blog.csdn.net/ding977921830?viewmode=contents.详细内容例如以下: /*M///////////////////////…