继续分析: 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…
继续分析: 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…
继续分析 /* 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…
继续分析: 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_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_…
继续分析: 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…
继续分析 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…