? GNUmakefile
? config.log
? config.status
? pg_dump_composite_type_v1.patch
? src/Makefile.global
? src/backend/postgres
? src/backend/catalog/postgres.bki
? src/backend/catalog/postgres.description
? src/backend/catalog/postgres.shdescription
? src/backend/snowball/snowball_create.sql
? src/backend/utils/probes.h
? src/backend/utils/mb/conversion_procs/conversion_create.sql
? src/bin/initdb/initdb
? src/bin/pg_config/pg_config
? src/bin/pg_controldata/pg_controldata
? src/bin/pg_ctl/pg_ctl
? src/bin/pg_dump/pg_dump
? src/bin/pg_dump/pg_dumpall
? src/bin/pg_dump/pg_restore
? src/bin/pg_resetxlog/pg_resetxlog
? src/bin/psql/psql
? src/bin/scripts/clusterdb
? src/bin/scripts/createdb
? src/bin/scripts/createlang
? src/bin/scripts/createuser
? src/bin/scripts/dropdb
? src/bin/scripts/droplang
? src/bin/scripts/dropuser
? src/bin/scripts/reindexdb
? src/bin/scripts/vacuumdb
? src/include/pg_config.h
? src/include/stamp-h
? src/interfaces/ecpg/compatlib/exports.list
? src/interfaces/ecpg/compatlib/libecpg_compat.3.1.dylib
? src/interfaces/ecpg/ecpglib/exports.list
? src/interfaces/ecpg/ecpglib/libecpg.6.1.dylib
? src/interfaces/ecpg/include/ecpg_config.h
? src/interfaces/ecpg/include/stamp-h
? src/interfaces/ecpg/pgtypeslib/exports.list
? src/interfaces/ecpg/pgtypeslib/libpgtypes.3.1.dylib
? src/interfaces/ecpg/preproc/ecpg
? src/interfaces/libpq/exports.list
? src/interfaces/libpq/libpq.5.2.dylib
? src/port/pg_config_paths.h
? src/test/regress/log
? src/test/regress/pg_regress
? src/test/regress/results
? src/test/regress/testtablespace
? src/test/regress/tmp_check
? src/test/regress/expected/constraints.out
? src/test/regress/expected/copy.out
? src/test/regress/expected/create_function_1.out
? src/test/regress/expected/create_function_2.out
? src/test/regress/expected/largeobject.out
? src/test/regress/expected/largeobject_1.out
? src/test/regress/expected/misc.out
? src/test/regress/expected/tablespace.out
? src/test/regress/sql/constraints.sql
? src/test/regress/sql/copy.sql
? src/test/regress/sql/create_function_1.sql
? src/test/regress/sql/create_function_2.sql
? src/test/regress/sql/largeobject.sql
? src/test/regress/sql/misc.sql
? src/test/regress/sql/tablespace.sql
? src/timezone/zic
Index: src/bin/pg_dump/pg_dump.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v
retrieving revision 1.530
diff -c -r1.530 pg_dump.c
*** src/bin/pg_dump/pg_dump.c	22 Mar 2009 16:44:26 -0000	1.530
--- src/bin/pg_dump/pg_dump.c	26 Mar 2009 07:11:53 -0000
***************
*** 137,142 ****
--- 137,143 ----
  static void dumpEnumType(Archive *fout, TypeInfo *tinfo);
  static void dumpDomain(Archive *fout, TypeInfo *tinfo);
  static void dumpCompositeType(Archive *fout, TypeInfo *tinfo);
+ static void dumpCompositeTypeColumn(Archive *fout, TypeInfo *tinfo);
  static void dumpShellType(Archive *fout, ShellTypeInfo *stinfo);
  static void dumpProcLang(Archive *fout, ProcLangInfo *plang);
  static void dumpFunc(Archive *fout, FuncInfo *finfo);
***************
*** 6707,6712 ****
--- 6708,6813 ----
  	destroyPQExpBuffer(q);
  	destroyPQExpBuffer(delq);
  	destroyPQExpBuffer(query);
+ 
+ 	/* Dump column comments */
+ 	dumpCompositeTypeColumn(fout, tinfo);
+ }
+ 
+ /*
+  * dumpCompositeTypeColumn
+  *	  writes out to fout the comments on
+  *	  columns of composite type
+  */
+ static void
+ dumpCompositeTypeColumn(Archive *fout, TypeInfo *tinfo)
+ {
+ 	CommentItem *comments;
+ 	int ncomments;
+ 	PGresult *res;
+ 	PQExpBuffer query;
+ 	PQExpBuffer attrquery = createPQExpBuffer();
+ 	PQExpBuffer target;
+ 	Oid colTableOid;
+ 	int i;
+ 	int ntups;
+ 	int i_attname;
+ 	int i_attnum;
+ 
+ 	appendPQExpBuffer(attrquery,
+ 					  "SELECT pg_class.tableoid, "
+ 					  "       pg_attribute.attname, "
+ 					  "        pg_attribute.attnum "
+ 					  "FROM pg_class, pg_attribute "
+ 					  "WHERE pg_class.oid = '%u' and pg_class.oid = pg_attribute.attrelid "
+ 					  "ORDER BY pg_attribute.attnum "
+ 					  , tinfo->typrelid);
+ 
+ 	/* Fetch column's attname */
+ 	res = PQexec(g_conn, attrquery->data);
+ 	check_sql_result(res, g_conn, attrquery->data, PGRES_TUPLES_OK);
+ 	ntups = PQntuples(res);
+ 	if (ntups < 1)
+ 	{
+ 		write_msg(NULL, "query returned no rows: %s\n", attrquery->data);
+ 		exit_nicely();
+ 	}
+ 	colTableOid = atooid(PQgetvalue(res, 0, PQfnumber(res, "tableoid")));
+ 
+ 	/* Search for comments associated with relation, using table */
+ 	ncomments = findComments(fout,
+ 							 colTableOid,
+ 							 tinfo->typrelid,
+ 							 &comments);
+ 
+ 	/* If comments exist, build COMMENT ON statements */
+ 	if (ncomments <= 0)
+ 		return;
+ 
+ 	query = createPQExpBuffer();
+ 	target = createPQExpBuffer();
+ 
+ 	i_attnum = PQfnumber(res, "attnum");
+ 	i_attname = PQfnumber(res, "attname");
+ 	while (ncomments > 0)
+ 	{
+ 		const char *descr = comments->descr;
+ 		/* Just to be safe */
+ 		const char *attname = "unknown";
+ 		for (i = 0; i < ntups; i++)
+ 		{
+ 			if (atoi(PQgetvalue(res, i, i_attnum)) == comments->objsubid)
+ 			{
+ 				attname = PQgetvalue(res, i, i_attname);
+ 				break;
+ 			}
+ 		}
+ 		resetPQExpBuffer(target);
+ 		appendPQExpBuffer(target, "COLUMN %s.",
+ 						  fmtId(tinfo->dobj.name));
+ 		appendPQExpBuffer(target, "%s",
+ 						  fmtId(attname));
+ 		
+ 		resetPQExpBuffer(query);
+ 		appendPQExpBuffer(query, "COMMENT ON %s IS ", target->data);
+ 		appendStringLiteralAH(query, descr, fout);
+ 		appendPQExpBuffer(query, ";\n");
+ 
+ 		ArchiveEntry(fout, nilCatalogId, createDumpId(),
+ 					 target->data,
+ 					 tinfo->dobj.namespace->dobj.name,
+ 					 NULL,
+ 					 tinfo->rolname,
+ 					 false, "COMMENT", SECTION_NONE, query->data, "", NULL,
+ 					 &(tinfo->dobj.dumpId), 1,
+ 					 NULL, NULL);
+ 
+ 		comments++;
+ 		ncomments--;
+ 	}
+ 	destroyPQExpBuffer(attrquery);
+ 	destroyPQExpBuffer(query);
+ 	destroyPQExpBuffer(target);
+ 	PQclear(res);
  }
  
  /*