Index: src/bin/pg_dump/pg_dump.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/bin/pg_dump/pg_dump.c,v
retrieving revision 1.305
diff -c -r1.305 pg_dump.c
*** src/bin/pg_dump/pg_dump.c	2002/10/22 19:15:23	1.305
--- src/bin/pg_dump/pg_dump.c	2002/11/14 03:58:20
***************
*** 3146,3153 ****
--- 3146,3155 ----
  	PQExpBuffer q = createPQExpBuffer();
  	PQExpBuffer delq = createPQExpBuffer();
  	PQExpBuffer query = createPQExpBuffer();
+ 	PQExpBuffer chkquery = createPQExpBuffer();
  	PGresult   *res;
  	int			ntups;
+ 	int			i;
  	char	   *typnotnull;
  	char	   *typdefn;
  	char	   *typdefault;
***************
*** 3217,3222 ****
--- 3219,3252 ----
  	if (typdefault)
  		appendPQExpBuffer(q, " DEFAULT %s", typdefault);
  
+ 	/* Fetch and process CHECK Constraints */
+ 	appendPQExpBuffer(chkquery, "SELECT conname, consrc "
+ 					  "FROM pg_catalog.pg_constraint "
+ 					  "WHERE contypid = '%s'::pg_catalog.oid",
+ 					  tinfo->oid);
+ 
+ 	res = PQexec(g_conn, chkquery->data);
+ 	if (!res ||
+ 		PQresultStatus(res) != PGRES_TUPLES_OK)
+ 	{
+ 		write_msg(NULL, "query to obtain domain constraint information failed: %s",
+ 				  PQerrorMessage(g_conn));
+ 		exit_nicely();
+ 	}
+ 
+ 	/* Expecting a single result only */
+ 	ntups = PQntuples(res);
+ 	for (i = 0; i < ntups; i++)
+ 	{
+ 		char	   *conname;
+ 		char	   *consrc;
+ 
+ 		conname = PQgetvalue(res, i, PQfnumber(res, "conname"));
+ 		consrc = PQgetvalue(res, i, PQfnumber(res, "consrc"));
+ 
+ 		appendPQExpBuffer(q, " CONSTRAINT %s CHECK %s", fmtId(conname), consrc);
+ 	}
+ 	
  	appendPQExpBuffer(q, ";\n");
  
  	(*deps)[depIdx++] = NULL;	/* End of List */
