继续分析: 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 /…
继续分析 下面这一段,当 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_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…
继续分析: /* 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…
继续分析 下面的是获取运行此程序的用户名称,主要还是为了防止在linux下用root来运行的情形. effective_user = get_id(); ) username = effective_user; 接下来,是准备好一写预备生成的文件的名称变量: set_input(&bki_file, "postgres.bki"); set_input(&desc_file, "postgres.description"); set_input(&a…