src/bin/pg_dump/pg_dump.c
static PQExpBuffer
createDummyViewAsClause(Archive *fout, const TableInfo *tbinfo)
{
	PQExpBuffer result = createPQExpBuffer();
	int			j;

	appendPQExpBufferStr(result, "SELECT");

	for (j = 0; j < tbinfo->numatts; j++)
	{
		if (j > 0)
			appendPQExpBufferChar(result, ',');
		appendPQExpBufferStr(result, "\n    ");

		appendPQExpBuffer(result, "NULL::%s", tbinfo->atttypnames[j]);

		/*
		 * Must add collation if not default for the type, because CREATE OR
		 * REPLACE VIEW won't change it
		 */
		if (OidIsValid(tbinfo->attcollation[j]))
		{
			CollInfo   *coll;

			coll = findCollationByOid(tbinfo->attcollation[j]);
			if (coll)
				appendPQExpBuffer(result, " COLLATE %s",
								  fmtQualifiedDumpable(coll));
		}

		appendPQExpBuffer(result, " AS %s", fmtId(tbinfo->attnames[j]));
	}

	return result;
}
/*
 * Create a dummy AS clause for a view.  This is used when the real view
 * definition has to be postponed because of circular dependencies.
 * We must duplicate the view's external properties -- column names and types
 * (including collation) -- so that it works for subsequent references.
 *
 * This returns a new buffer which must be freed by the caller.
 */
Create a dummy AS clause for a view.  This is used when the real view
definition has to be postponed because of circular dependencies.
We must duplicate the view's external properties -- column names and types
(including collation) -- so that it works for subsequent references.

This returns a new buffer which must be freed by the caller.
Create a dummy AS clause for a view . This is used when the real view definition has to be postponed because of circular dependencies . We must duplicate the view ' s external properties -- column names and types ( including collation ) -- so that it works for subsequent references . This returns a new buffer which must be freed by the caller .
static PQExpBuffer
createDummyViewAsClause(Archive *fout, const TableInfo *tbinfo)
{
	PQExpBuffer result = createPQExpBuffer();
	int			j;
	appendPQExpBufferStr(result, "SELECT");
	for (j = 0; j < tbinfo->numatts; j++)
	{
		if (j > 0)
			appendPQExpBufferChar(result, ',');
		appendPQExpBufferStr(result, "\n    ");
		appendPQExpBuffer(result, "NULL::%s", tbinfo->atttypnames[j]);
		if (OidIsValid(tbinfo->attcollation[j]))
		{
			CollInfo   *coll;
			coll = findCollationByOid(tbinfo->attcollation[j]);
			if (coll)
				appendPQExpBuffer(result, " COLLATE %s",
								  fmtQualifiedDumpable(coll));
		}
		appendPQExpBuffer(result, " AS %s", fmtId(tbinfo->attnames[j]));
	}
	return result;
}
static PQExpBuffer createDummyViewAsClause ( Archive * fout , const TableInfo * tbinfo ) { PQExpBuffer result = createPQExpBuffer ( ) ; int j ; appendPQExpBufferStr ( result , " " ) ; for ( j = 0 ; j < tbinfo -> numatts ; j ++ ) { if ( j > 0 ) appendPQExpBufferChar ( result , ' ' ) ; appendPQExpBufferStr ( result , " \n " ) ; appendPQExpBuffer ( result , " " , tbinfo -> atttypnames [ j ] ) ; if ( OidIsValid ( tbinfo -> attcollation [ j ] ) ) { CollInfo * coll ; coll = findCollationByOid ( tbinfo -> attcollation [ j ] ) ; if ( coll ) appendPQExpBuffer ( result , " " , fmtQualifiedDumpable ( coll ) ) ; } appendPQExpBuffer ( result , " " , fmtId ( tbinfo -> attnames [ j ] ) ) ; } return result ; }
Create a dummy AS clause for a view.
Create a dummy AS clause for a view .
/*
		 * Must add collation if not default for the type, because CREATE OR
		 * REPLACE VIEW won't change it
		 */