Ejemplo n.º 1
0
/*
 * Establish persistent connection to backend
 */
static void establish_persistent_connection(void)
{
	int i;
	BackendInfo *bkinfo;
	POOL_CONNECTION_POOL_SLOT *s;

	for (i=0;i<NUM_BACKENDS;i++)
	{
		if (!VALID_BACKEND(i))
			continue;

		if (slots[i] == NULL)
		{
			bkinfo = pool_get_node_info(i);
			s = make_persistent_db_connection(bkinfo->backend_hostname, 
											  bkinfo->backend_port,
											  "postgres",
											  pool_config->sr_check_user,
											  pool_config->sr_check_password, true);
			if (s)
				slots[i] = s;
			else
				slots[i] = NULL;
		}
	}
}
Ejemplo n.º 2
0
/*
 * Initialize system DB connection
 */
static void init_system_db_connection(void)
{	
	if (pool_config->parallel_mode || pool_config->enable_query_cache)
	{
		system_db_connect();
		if (PQstatus(system_db_info->pgconn) != CONNECTION_OK)
		{
			pool_error("Could not make persistent libpq system DB connection");
		}

		system_db_info->connection = make_persistent_db_connection(pool_config->system_db_hostname,
																   pool_config->system_db_port,
																   pool_config->system_db_dbname,
																   pool_config->system_db_user,
																   pool_config->system_db_password, false);
		if (system_db_info->connection == NULL)
		{
			pool_error("Could not make persistent system DB connection");
		}
	}
}