|
22 | 22 | *
|
23 | 23 | *
|
24 | 24 | * IDENTIFICATION
|
25 |
| - * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.306 2002/11/08 17:37:52 tgl Exp $ |
| 25 | + * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.307 2002/11/15 02:52:18 momjian Exp $ |
26 | 26 | *
|
27 | 27 | *-------------------------------------------------------------------------
|
28 | 28 | */
|
@@ -3157,8 +3157,10 @@ dumpOneDomain(Archive *fout, TypeInfo *tinfo)
|
3157 | 3157 | PQExpBufferq=createPQExpBuffer();
|
3158 | 3158 | PQExpBufferdelq=createPQExpBuffer();
|
3159 | 3159 | PQExpBufferquery=createPQExpBuffer();
|
| 3160 | +PQExpBufferchkquery=createPQExpBuffer(); |
3160 | 3161 | PGresult*res;
|
3161 | 3162 | intntups;
|
| 3163 | +inti; |
3162 | 3164 | char*typnotnull;
|
3163 | 3165 | char*typdefn;
|
3164 | 3166 | char*typdefault;
|
@@ -3228,6 +3230,34 @@ dumpOneDomain(Archive *fout, TypeInfo *tinfo)
|
3228 | 3230 | if (typdefault)
|
3229 | 3231 | appendPQExpBuffer(q," DEFAULT %s",typdefault);
|
3230 | 3232 |
|
| 3233 | +/* Fetch and process CHECK Constraints */ |
| 3234 | +appendPQExpBuffer(chkquery,"SELECT conname, consrc " |
| 3235 | +"FROM pg_catalog.pg_constraint " |
| 3236 | +"WHERE contypid = '%s'::pg_catalog.oid", |
| 3237 | +tinfo->oid); |
| 3238 | + |
| 3239 | +res=PQexec(g_conn,chkquery->data); |
| 3240 | +if (!res|| |
| 3241 | +PQresultStatus(res)!=PGRES_TUPLES_OK) |
| 3242 | +{ |
| 3243 | +write_msg(NULL,"query to obtain domain constraint information failed: %s", |
| 3244 | +PQerrorMessage(g_conn)); |
| 3245 | +exit_nicely(); |
| 3246 | +} |
| 3247 | + |
| 3248 | +/* Expecting a single result only */ |
| 3249 | +ntups=PQntuples(res); |
| 3250 | +for (i=0;i<ntups;i++) |
| 3251 | +{ |
| 3252 | +char*conname; |
| 3253 | +char*consrc; |
| 3254 | + |
| 3255 | +conname=PQgetvalue(res,i,PQfnumber(res,"conname")); |
| 3256 | +consrc=PQgetvalue(res,i,PQfnumber(res,"consrc")); |
| 3257 | + |
| 3258 | +appendPQExpBuffer(q," CONSTRAINT %s CHECK %s",fmtId(conname),consrc); |
| 3259 | +} |
| 3260 | + |
3231 | 3261 | appendPQExpBuffer(q,";\n");
|
3232 | 3262 |
|
3233 | 3263 | (*deps)[depIdx++]=NULL;/* End of List */
|
|