src/bin/pg_dump/pg_dump.c
static void
expand_schema_name_patterns(Archive *fout,
							SimpleStringList *patterns,
							SimpleOidList *oids,
							bool strict_names)
{
	PQExpBuffer query;
	PGresult   *res;
	SimpleStringListCell *cell;
	int			i;

	if (patterns->head == NULL)
		return;					/* nothing to do */

	query = createPQExpBuffer();

	/*
	 * The loop below runs multiple SELECTs might sometimes result in
	 * duplicate entries in the OID list, but we don't care.
	 */

	for (cell = patterns->head; cell; cell = cell->next)
	{
		appendPQExpBufferStr(query,
							 "SELECT oid FROM pg_catalog.pg_namespace n\n");
		processSQLNamePattern(GetConnection(fout), query, cell->val, false,
							  false, NULL, "n.nspname", NULL, NULL);

		res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
		if (strict_names && PQntuples(res) == 0)
			fatal("no matching schemas were found for pattern \"%s\"", cell->val);

		for (i = 0; i < PQntuples(res); i++)
		{
			simple_oid_list_append(oids, atooid(PQgetvalue(res, i, 0)));
		}

		PQclear(res);
		resetPQExpBuffer(query);
	}

	destroyPQExpBuffer(query);
}
/*
 * Find the OIDs of all schemas matching the given list of patterns,
 * and append them to the given OID list.
 */
Find the OIDs of all schemas matching the given list of patterns,
and append them to the given OID list.
Find the OIDs of all schemas matching the given list of patterns and append them to the given OID list .
static void
expand_schema_name_patterns(Archive *fout,
							SimpleStringList *patterns,
							SimpleOidList *oids,
							bool strict_names)
{
	PQExpBuffer query;
	PGresult   *res;
	SimpleStringListCell *cell;
	int			i;
	if (patterns->head == NULL)
		return;					
	query = createPQExpBuffer();
	for (cell = patterns->head; cell; cell = cell->next)
	{
		appendPQExpBufferStr(query,
							 "SELECT oid FROM pg_catalog.pg_namespace n\n");
		processSQLNamePattern(GetConnection(fout), query, cell->val, false,
							  false, NULL, "n.nspname", NULL, NULL);
		res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
		if (strict_names && PQntuples(res) == 0)
			fatal("no matching schemas were found for pattern \"%s\"", cell->val);
		for (i = 0; i < PQntuples(res); i++)
		{
			simple_oid_list_append(oids, atooid(PQgetvalue(res, i, 0)));
		}
		PQclear(res);
		resetPQExpBuffer(query);
	}
	destroyPQExpBuffer(query);
}
static void expand_schema_name_patterns ( Archive * fout , SimpleStringList * patterns , SimpleOidList * oids , bool strict_names ) { PQExpBuffer query ; PGresult * res ; SimpleStringListCell * cell ; int i ; if ( patterns -> head == NULL ) return ; query = createPQExpBuffer ( ) ; for ( cell = patterns -> head ; cell ; cell = cell -> next ) { appendPQExpBufferStr ( query , " \n " ) ; processSQLNamePattern ( GetConnection ( fout ) , query , cell -> val , false , false , NULL , " " , NULL , NULL ) ; res = ExecuteSqlQuery ( fout , query -> data , PGRES_TUPLES_OK ) ; if ( strict_names && PQntuples ( res ) == 0 ) fatal ( " \" \" " , cell -> val ) ; for ( i = 0 ; i < PQntuples ( res ) ; i ++ ) { simple_oid_list_append ( oids , atooid ( PQgetvalue ( res , i , 0 ) ) ) ; } PQclear ( res ) ; resetPQExpBuffer ( query ) ; } destroyPQExpBuffer ( query ) ; }
Find the OIDs of all schemas matching the given list of patterns,
 and append them to the given OID list.
Find the OIDs of all schemas matching the given list of patterns and append them to the given OID list .
/* nothing to do */ /*
	 * The loop below runs multiple SELECTs might sometimes result in
	 * duplicate entries in the OID list, but we don't care.
	 */