postgres 之 initdb 源码分析 七

前端之家收集整理的这篇文章主要介绍了postgres 之 initdb 源码分析 七前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

2.17 函数setup_text_search

void
setup_text_search(void)
{
	if (strlen(default_text_search_config) == 0)
	{
		default_text_search_config = find_matching_ts_config(lc_ctype);
		if (default_text_search_config == NULL)
		{
			printf(_("%s: could not find suitable text search configuration for locale \"%s\"\n"),progname,lc_ctype);
			default_text_search_config = "simple";
		}
	}
	else
	{
		const char *checkmatch = find_matching_ts_config(lc_ctype);

		if (checkmatch == NULL)
		{
			printf(_("%s: warning: suitable text search configuration for locale \"%s\" is unknown\n"),lc_ctype);
		}
		else if (strcmp(checkmatch,default_text_search_config) != 0)
		{
			printf(_("%s: warning: specified text search configuration \"%s\" might not match locale \"%s\"\n"),default_text_search_config,lc_ctype);
		}
	}

	printf(_("The default text search configuration will be set to \"%s\".\n"),default_text_search_config);

}

2.17.1 initdb 第三行输出

initdb: could not find suitable text search configuration for locale "zh_CN.UTF-8"
The default text search configuration will be set to "simple".

2.18 initdb 是否指定-k


	if (data_checksums)
		printf(_("Data page checksums are enabled.\n"));
	else
		printf(_("Data page checksums are disabled.\n"));

-k,--data-checksums use data page checksums

2.18.1 initdb第四行输出


Data page checksums are disabled.

2.19 函数initialize_data_directory()

void
initialize_data_directory(void)
{
	int			i;

	setup_signals();

	umask(S_IRWXG | S_IRWXO);

	create_data_directory();

	create_xlog_symlink();

	/* Create required subdirectories */
	printf(_("creating subdirectories ... "));
	fflush(stdout);

	for (i = 0; i < (sizeof(subdirs) / sizeof(char *)); i++)
	{
		if (!mkdatadir(subdirs[i]))
			exit_nicely();
	}

	check_ok();

	/* Top level PG_VERSION is checked by bootstrapper,so make it first */
	write_version_file(NULL);

	/* Select suitable configuration settings */
	set_null_conf();
	test_config_settings();

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

	/* Bootstrap template1 */
	bootstrap_template1();

	/*
	 * Make the per-database PG_VERSION for template1 only after init'ing it
	 */
	write_version_file("base/1");

	/* Create the stuff we don't need to use bootstrap mode for */

	setup_auth();
	if (pwprompt || pwfilename)
		get_set_pwd();

	setup_depend();

	setup_sysviews();

	setup_description();

	setup_collation();

	setup_conversion();

	setup_dictionary();

	setup_privileges();

	setup_schema();

	load_plpgsql();

	vacuum_db();

	make_template0();

	make_postgres();
}

2.19.1 initdb 第五行输出

creating directory ./data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
creating configuration files ... ok
creating template1 database in ./data/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating collations ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
loading PL/pgsql server-side language ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok

2.19.2 initdb 第六行输出

执行函数perform_fsync()
syncing data to disk ... ok

2.19.3 initdb第七行输出

若认证方式为trust,则initdb输出
WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A,or
--auth-local and --auth-host,the next time you run initdb.

2.19.3 initdb第八行输出

	printf(_("\nSuccess. You can now start the database server using:\n\n"
			 "    %s%s%spostgres%s -D %s%s%s\n"
			 "or\n"
			 "    %s%s%spg_ctl%s -D %s%s%s -l logfile start\n\n"),QUOTE_PATH,bin_dir,(strlen(bin_dir) > 0) ? DIR_SEP : "",pgdata_native,QUOTE_PATH);

Success. You can now start the database server using:

    postgres -D ./data
or
    pg_ctl -D ./data -l logfile start



--initdb分析结束
原文链接:https://www.f2er.com/postgresql/195709.html

猜你在找的Postgre SQL相关文章