Patch for pg_dump (6.4) inheritance bug - Mailing list pgsql-hackers
From | Oliver Elphick |
---|---|
Subject | Patch for pg_dump (6.4) inheritance bug |
Date | |
Msg-id | 199811242316.XAA01846@linda.lfix.co.uk Whole thread Raw |
In response to | Re: [HACKERS] Parser bug? ("Oliver Elphick" <olly@lfix.co.uk>) |
Responses |
Testing, Hello?
Re: [HACKERS] Patch for pg_dump (6.4) inheritance bug |
List | pgsql-hackers |
"Oliver Elphick" wrote: >I think this will do the job; can you please check it out: It seems to work, at least for my database, so here is a patch: *** postgresql-6.4/src/bin/pg_dump/pg_dump.c Tue Nov 24 23:01:27 1998 --- postgresql-6.4.orig/src/bin/pg_dump/pg_dump.c Mon Oct 26 01:05:07 1998 *************** *** 1459,1504 **** tblinfo[i].ncheck = atoi(PQgetvalue(res, i, i_relchecks)); tblinfo[i].ntrig = atoi(PQgetvalue(res,i, i_reltriggers)); ! /* Exclude inherited CHECKs from CHECK constraints total */ ! if (tblinfo[i].ncheck > 0) ! { ! PGresult *res2; ! int ntups2; ! ! if (g_verbose) ! fprintf(stderr, "%s excluding inherited CHECK constraints " ! "for relation: '%s' %s\n", ! g_comment_start, ! tblinfo[i].relname, ! g_comment_end); ! ! sprintf(query, "SELECT * from pg_relcheck, pg_inherits as i " ! "where rcrelid = '%s'::oid " ! " and exists " ! " (select * from pg_relcheck as c " ! " where c.rcname = pg_relcheck.rcname " ! " and c.rcrelid = i.inhparent) " ! " and rcrelid = i.inhrel", ! tblinfo[i].oid); ! res2 = PQexec(g_conn, query); ! if (!res2 || ! PQresultStatus(res2) != PGRES_TUPLES_OK) ! { ! fprintf(stderr, "getTables(): SELECT (for inherited CHECK) failed\n"); ! exit_nicely(g_conn); ! } ! ntups2 = PQntuples(res2); ! tblinfo[i].ncheck -= ntups2; ! if (tblinfo[i].ncheck < 0) ! { ! fprintf(stderr, "getTables(): found more inherited CHECKs than total for " ! "relation %s\n", ! tblinfo[i].relname); ! exit_nicely(g_conn); ! } ! } ! ! /* Get CHECK constraints originally defined for this table */ if (tblinfo[i].ncheck > 0) { PGresult *res2; --- 1459,1465 ---- tblinfo[i].ncheck = atoi(PQgetvalue(res, i, i_relchecks)); tblinfo[i].ntrig = atoi(PQgetvalue(res,i, i_reltriggers)); ! /* Get CHECK constraints */ if (tblinfo[i].ncheck > 0) { PGresult *res2; *************** *** 1513,1531 **** tblinfo[i].relname, g_comment_end); ! sprintf(query, "SELECT DISTINCT rcname, rcsrc " ! "from pg_relcheck, pg_inherits as i " ! "where rcrelid = '%s'::oid " ! /* allow all checks from tables that do not inherit */ ! " and (not exists " ! " (select * from pg_inherits " ! " where inhrel = pg_relcheck.rcrelid)" ! /* and allow checks that are not inherited from other tables */ ! " or (not exists " ! " (select * from pg_relcheck as c " ! " where c.rcname = pg_relcheck.rcname " ! " and c.rcrelid = i.inhparent) " ! " and rcrelid = i.inhrel))", tblinfo[i].oid); res2 = PQexec(g_conn,query); if (!res2 || --- 1474,1481 ---- tblinfo[i].relname, g_comment_end); ! sprintf(query, "SELECT rcname, rcsrc from pg_relcheck " ! "where rcrelid = '%s'::oid ", tblinfo[i].oid); res2 = PQexec(g_conn,query); if (!res2 || -- Oliver Elphick Oliver.Elphick@lfix.co.uk Isle of Wight http://www.lfix.co.uk/oliver PGP key from public servers; key ID32B8FAA1 ======================================== "Jesus saith unto him, I am the way, the truth, andthe life; no man cometh unto the Father, but by me." John 14:6
pgsql-hackers by date: