How can I find a broken row in a table

--_000_D78A8169F9436B4DB978300336168F3B3359AFE0FESWBREXCH00u cs_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable


Please help me, I am using PostgreSQL 7.3.4 running on Redhat5

there is a table that has a broken row, but now I don't know which one is b=
roken. the table has about 20974 pages. is there a command to find this? be=
cause I used select commands like: select * from table order by column desc=
limit X ; select * from table order by column asc limit X; but as soon as =
I say select * from table; it throws out an error, saying can't read block.


Thanks in advance

Khangelani




Confidentiality Notice:http://ucs.co.za/conf.html



________________________________
The contents of and attachments to this e-mail are intended for the address=
ee only, and may contain the confidential information of UCS Group and/or i=
ts subsidiaries. Any review, use or dissemination thereof by anyone other t=
han the intended addressee is prohibited. If you are not the intended addre=
ssee please notify the writer immediately and destroy the e-mail. UCS Group=
Limited and its subsidiaries distance themselves from and accept no liabil=
ity for unauthorised use of their e-mail facilities or e-mails sent other t=
han strictly for business purposes.

--_000_D78A8169F9436B4DB978300336168F3B3359AFE0FESWBREXCH00u cs_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
>
<meta name=3D"Generator" content=3D"Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
[at] font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
[at] font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
..MsoChpDefault
{mso-style-type:export-only;}
[at] page Section1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
{page:Section1;}
-->
</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=3D"EN-US" link=3D"blue" vlink=3D"purple">
<div class=3D"Section1">
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">Please help me, I am using PostgreSQL 7.3.4 running =
on Redhat5<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">there is a table that has a broken row, but now I do=
n't know which one is broken. the table has about 20974 pages. is there a c=
ommand to find this? because I used select commands like:
<b>select * from table order by column desc limit X</b> ; <b>select * from =
table order by column asc limit X</b>; but as soon as I say
<b>select * from table</b>; it throws out an error, saying can't read block=
..<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal"><span lang=3D"EN-ZA" style=3D"font-size:10.0pt;font-=
family:"Courier New";
color:blue"><o:p> </o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-ZA" style=3D"font-size:10.0pt;font-=
family:"Courier New";
color:blue">Thanks in advance 
<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-ZA" style=3D"font-size:10.0pt;font-=
family:"Courier New";
color:blue"><o:p> </o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-ZA" style=3D"font-size:10.0pt;font-=
family:"Courier New";
color:blue">Khangelani<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-ZA" style=3D"font-size:10.0pt;font-=
family:"Courier New";
color:blue"><o:p> </o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-ZA" style=3D"font-size:10.0pt;font-=
family:"Courier New";
color:blue"> </span><b><span lang=3D"EN-ZA" style=3D"font-family:"=
;Courier New";
color:black"><o:p></o:p></span></b></p>
<p class=3D"MsoNormal"><span lang=3D"EN-ZA" style=3D"font-size:10.0pt;font-=
family:"Courier New""><o:p> </o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-ZA" style=3D"font-size:10.0pt;font-=
family:"Courier New""><o:p> </o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-ZA">Confidentiality Notice:<a href=
=3D"http://ucs.co.za/conf.html"><span style=3D"color:blue">http://ucs.co.za=
/conf.html</span></a></span><span lang=3D"EN-ZA"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-ZA"><o:p> </o:p></span></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
</div>
<br>
<hr>
<font face=3D"Arial" color=3D"Gray" size=3D"1">The contents of and attachme=
nts to this e-mail are intended for the addressee only, and may contain the=
confidential information of UCS Group and/or its subsidiaries. Any review,=
use or dissemination thereof by anyone
other than the intended addressee is prohibited. If you are not the intend=
ed addressee please notify the writer immediately and destroy the e-mail. U=
CS Group Limited and its subsidiaries distance themselves from and accept n=
o liability for unauthorised use
of their e-mail facilities or e-mails sent other than strictly for busines=
s purposes.<br>
</font>
</body>
</html>

--_000_D78A8169F9436B4DB978300336168F3B3359AFE0FESWBREXCH00u cs_--
Khangelani Gama [ Fr, 16 April 2010 10:22 ] [ ID #2039130 ]

Re: How can I find a broken row in a table

Khangelani Gama <Khangelani.Gama [at] ucs-software.co.za> writes:
> Please help me, I am using PostgreSQL 7.3.4 running on Redhat5

> there is a table that has a broken row, but now I don't know which one
is broken. the table has about 20974 pages. is there a command to find
this?

You have to use divide-and-conquer. Try

select ctid from table limit N;

and vary N until you find the largest value that *doesn't* produce an
error. The block number in the last ctid from that query is the block
before the bad one, or possibly a small number of blocks before the bad
one if there are some totally-empty blocks.

regards, tom lane

--
Sent via pgsql-admin mailing list (pgsql-admin [at] postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
Tom Lane [ Fr, 16 April 2010 16:23 ] [ ID #2039134 ]

Re: How can I find a broken row in a table

Khangelani Gama <Khangelani.Gama [at] ucs-software.co.za> wrote:

> there is a table that has a broken row, but now I don't know which
> one is broken. the table has about 20974 pages.

If there are any indexes on the table which haven't been corrupted,
you might try selecting ranges of rows using one of them, capturing
the undamaged data into a new table. By subdividing damaged ranges
you can do a sort of "binary search" for the bad rows while
recovering the good ones.

-Kevin

--
Sent via pgsql-admin mailing list (pgsql-admin [at] postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
Kevin Grittner [ Fr, 16 April 2010 16:26 ] [ ID #2039135 ]
Datenbanken » gmane.comp.db.postgresql.admin » How can I find a broken row in a table

Vorheriges Thema: PostgreSQL with SSL
Nächstes Thema: Wal Segment files Backup Strategy for archiving