środa, 17 grudnia 2008

PostgreSQL tricks with broken db

Few PostgreSQL tricks for broken db:

case:

pg_dump: query returned 0 rows instead of one: SELECT typlen, typinput, typoutput, typreceive, typsend, typmodin, typmodout, typanalyze, typinput::pg_catalog.oid as typinputoid, typoutput::pg_catalog.oid as typoutputoid, typreceive::pg_catalog.oid as typreceiveoid, typsend::pg_catalog.oid as typsendoid, typmodin::pg_catalog.oid as typmodinoid, typmodout::pg_catalog.oid as typmodoutoid, typanalyze::pg_catalog.oid as typanalyzeoid, typdelim, typbyval, typalign, typstorage, pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) as typdefaultbin, typdefault FROM pg_catalog.pg_type WHERE oid = '1325300'::pg_catalog.oid

solution:

reindexdb -h localhost -U postgres db_name


case:

pg_dump: Error message from server: ERROR: catalog is missing 4 attribute(s) for relid 1325439

solution:

REINDEX TABLE pg_catalog.pg_attribute;


case:

pg_dump: failed sanity check, parent table OID 16401 of pg_rewrite entry OID 16403 not found

solution:

delete from pg_rewrite where oid = 16403;
REINDEX TABLE pg_catalog.pg_rewrite;

Brak komentarzy: