postgres 之 initdb 源码分析 二

2.3 函数voidset_pglocale_pgservice(const char *argv0,const char *app)


设置一些环境变量信息
/*
 *	set_pglocale_pgservice
 *
 *	Set application-specific locale and service directory
 *
 *	This function takes the value of argv[0] rather than a full path.
 *
 * (You may be wondering why this is in exec.c.  It requires this module's
 * services and doesn't introduce any new dependencies,so this seems as
 * good as anyplace.)
 */
void
set_pglocale_pgservice(const char *argv0,const char *app)
{
	char		path[MAXPGPATH];
	char		my_exec_path[MAXPGPATH];
	char		env_path[MAXPGPATH + sizeof("PGSYSconfdIR=")];	/* longer than
																 * PGLOCALEDIR */

	/* don't set LC_ALL in the backend */
	if (strcmp(app,PG_TEXTDOMAIN("postgres")) != 0)
		setlocale(LC_ALL,"");

	if (find_my_exec(argv0,my_exec_path) < 0)
		return;

#ifdef ENABLE_NLS
	get_locale_path(my_exec_path,path);
	bindtextdomain(app,path);
	textdomain(app);

	if (getenv("PGLOCALEDIR") == NULL)
	{
		/* set for libpq to use */
		snprintf(env_path,sizeof(env_path),"PGLOCALEDIR=%s",path);
		canonicalize_path(env_path + 12);
		putenv(strdup(env_path));
	}
#endif

	if (getenv("PGSYSconfdIR") == NULL)
	{
		get_etc_path(my_exec_path,path);

		/* set for libpq to use */
		snprintf(env_path,"PGSYSconfdIR=%s",path);
		canonicalize_path(env_path + 13);
		putenv(strdup(env_path));
	}
}
附加信息:
(1)环境变量

相关文章

项目需要,有个数据需要导入,拿到手一开始以为是mysql,结果...
本文小编为大家详细介绍“怎么查看PostgreSQL数据库中所有表...
错误现象问题原因这是在远程连接时pg_hba.conf文件没有配置正...
因本地资源有限,在公共测试环境搭建了PGsql环境,从数据库本...
wamp 环境 这个提示就是说你的版本低于10了。 先打印ph...
psycopg2.OperationalError: SSL SYSCALL error: EOF detect...