src/bin/pg_dump/pg_dump.c
static void
dumpDatabaseConfig(Archive *AH, PQExpBuffer outbuf,
				   const char *dbname, Oid dboid)
{
	PGconn	   *conn = GetConnection(AH);
	PQExpBuffer buf = createPQExpBuffer();
	PGresult   *res;

	/* First collect database-specific options */
	printfPQExpBuffer(buf, "SELECT unnest(setconfig) FROM pg_db_role_setting "
					  "WHERE setrole = 0 AND setdatabase = '%u'::oid",
					  dboid);

	res = ExecuteSqlQuery(AH, buf->data, PGRES_TUPLES_OK);

	for (int i = 0; i < PQntuples(res); i++)
		makeAlterConfigCommand(conn, PQgetvalue(res, i, 0),
							   "DATABASE", dbname, NULL, NULL,
							   outbuf);

	PQclear(res);

	/* Now look for role-and-database-specific options */
	printfPQExpBuffer(buf, "SELECT rolname, unnest(setconfig) "
					  "FROM pg_db_role_setting s, pg_roles r "
					  "WHERE setrole = r.oid AND setdatabase = '%u'::oid",
					  dboid);

	res = ExecuteSqlQuery(AH, buf->data, PGRES_TUPLES_OK);

	for (int i = 0; i < PQntuples(res); i++)
		makeAlterConfigCommand(conn, PQgetvalue(res, i, 1),
							   "ROLE", PQgetvalue(res, i, 0),
							   "DATABASE", dbname,
							   outbuf);

	PQclear(res);

	destroyPQExpBuffer(buf);
}
/*
 * Collect any database-specific or role-and-database-specific SET options
 * for this database, and append them to outbuf.
 */
Collect any database-specific or role-and-database-specific SET options
for this database, and append them to outbuf.
Collect any database - specific or role - and - database - specific SET options for this database and append them to outbuf .
static void
dumpDatabaseConfig(Archive *AH, PQExpBuffer outbuf,
				   const char *dbname, Oid dboid)
{
	PGconn	   *conn = GetConnection(AH);
	PQExpBuffer buf = createPQExpBuffer();
	PGresult   *res;
	printfPQExpBuffer(buf, "SELECT unnest(setconfig) FROM pg_db_role_setting "
					  "WHERE setrole = 0 AND setdatabase = '%u'::oid",
					  dboid);
	res = ExecuteSqlQuery(AH, buf->data, PGRES_TUPLES_OK);
	for (int i = 0; i < PQntuples(res); i++)
		makeAlterConfigCommand(conn, PQgetvalue(res, i, 0),
							   "DATABASE", dbname, NULL, NULL,
							   outbuf);
	PQclear(res);
	printfPQExpBuffer(buf, "SELECT rolname, unnest(setconfig) "
					  "FROM pg_db_role_setting s, pg_roles r "
					  "WHERE setrole = r.oid AND setdatabase = '%u'::oid",
					  dboid);
	res = ExecuteSqlQuery(AH, buf->data, PGRES_TUPLES_OK);
	for (int i = 0; i < PQntuples(res); i++)
		makeAlterConfigCommand(conn, PQgetvalue(res, i, 1),
							   "ROLE", PQgetvalue(res, i, 0),
							   "DATABASE", dbname,
							   outbuf);
	PQclear(res);
	destroyPQExpBuffer(buf);
}
static void dumpDatabaseConfig ( Archive * AH , PQExpBuffer outbuf , const char * dbname , Oid dboid ) { PGconn * conn = GetConnection ( AH ) ; PQExpBuffer buf = createPQExpBuffer ( ) ; PGresult * res ; printfPQExpBuffer ( buf , " " " " , dboid ) ; res = ExecuteSqlQuery ( AH , buf -> data , PGRES_TUPLES_OK ) ; for ( int i = 0 ; i < PQntuples ( res ) ; i ++ ) makeAlterConfigCommand ( conn , PQgetvalue ( res , i , 0 ) , " " , dbname , NULL , NULL , outbuf ) ; PQclear ( res ) ; printfPQExpBuffer ( buf , " " " " " " , dboid ) ; res = ExecuteSqlQuery ( AH , buf -> data , PGRES_TUPLES_OK ) ; for ( int i = 0 ; i < PQntuples ( res ) ; i ++ ) makeAlterConfigCommand ( conn , PQgetvalue ( res , i , 1 ) , " " , PQgetvalue ( res , i , 0 ) , " " , dbname , outbuf ) ; PQclear ( res ) ; destroyPQExpBuffer ( buf ) ; }
Collect any database-specific or role-and-database-specific SET options
 for this database, and append them to outbuf.
Collect any database - specific or role - and - database - specific SET options for this database and append them to outbuf .
/* First collect database-specific options */ /* Now look for role-and-database-specific options */