Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWmXh-0005EY-OT for pgsql-admin@arkaria.postgresql.org; Thu, 26 Jan 2017 16:04:57 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cWmXh-0005lW-4n for pgsql-admin@arkaria.postgresql.org; Thu, 26 Jan 2017 16:04:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cWmW0-0003sD-S0 for pgsql-admin@postgresql.org; Thu, 26 Jan 2017 16:03:12 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cWmVx-0006Dr-Gb for pgsql-admin@postgresql.org; Thu, 26 Jan 2017 16:03:12 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v0QG3342004225; Thu, 26 Jan 2017 11:03:03 -0500 From: Tom Lane To: Maris Jansons cc: Jorge Torralba , pgsql-admin Subject: Re: Help: unfixable/undead error - missing chunk number 0 for toast value 413511 in pg_toast_25477 In-reply-to: <1735117324.25930609.1485423861541.JavaMail.zimbra@lailio.net> References: <2141896725.20994473.1485356017414.JavaMail.zimbra@lailio.net> <1715943237.23967907.1485379847032.JavaMail.zimbra@lailio.net> <1735117324.25930609.1485423861541.JavaMail.zimbra@lailio.net> Comments: In-reply-to Maris Jansons message dated "Thu, 26 Jan 2017 11:44:21 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4223.1485446583.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 26 Jan 2017 11:03:03 -0500 Message-ID: <4224.1485446583@sss.pgh.pa.us> X-Pg-Spam-Score: -5.1 (-----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org Maris Jansons writes: > I have identified the problematic column, in my case it is api_response, = my version of script:=20 > DO $f$=20 > DECLARE=20 > baddata TEXT;=20 > badid INT;=20 > BEGIN=20 > FOR badid IN SELECT id FROM api_logs LOOP=20 > BEGIN=20 > SELECT api_response=20 > INTO baddata=20 > FROM api_logs where id =3D badid;=20 > EXCEPTION=20 > WHEN OTHERS THEN=20 > RAISE NOTICE 'Data for ID % is corrupt', badid;=20 > CONTINUE;=20 > END;=20 > END LOOP;=20 > END;=20 > $f$=20 > However this script finishes without errors, but if I run simple=20 >> select api_response from api_logs;=20 > I get:=20 > ERROR: missing chunk number 0 for toast value 413511 in pg_toast_25477=20 > Maybe I have messed something up in the script?=20 Oh ... what is happening, I think, is that the toast pointers are getting stored into the "baddata" local variable as-is. The problem would only get detected if the system has to fetch the toasted value, and this code doesn't make it do so. You could do something that requires fetching the value, perhaps SELECT api_response || '' INTO baddata ... regards, tom lane --=20 Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-admin