Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j3kxc-0002q4-5O for pgsql-general@arkaria.postgresql.org; Mon, 17 Feb 2020 18:17:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j3kxa-0004ea-4R for pgsql-general@arkaria.postgresql.org; Mon, 17 Feb 2020 18:17:34 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1j3kxZ-0004dl-Mh for pgsql-general@lists.postgresql.org; Mon, 17 Feb 2020 18:17:33 +0000 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1j3kxV-0001bf-Re for pgsql-general@postgresql.org; Mon, 17 Feb 2020 18:17:33 +0000 Received: by mail-pf1-x442.google.com with SMTP id p14so9318743pfn.4 for ; Mon, 17 Feb 2020 10:17:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ardentperf-com.20150623.gappssmtp.com; s=20150623; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=pClSYH48A4JwHvvfniaI2uO6Qcm4/lbeN9GJv6FcrJM=; b=rAMCVPT6gxpCkD7d/d4z2hY6RujBcvXgDIy2MjQY1R+L4FtnKEqnojc8rQDJnQ7b0L J+5ZSvZfU6PtyjrlM5ed0YhSD8NUUhecRWlx9HNSCPBTr9RrErW3kSAFeG388NIPN5Y8 IAt5QNvJmmCV8z3133n5/+JalLgHZwpPbIN0J64ooO5OKc/sNxnuLAHPY/NqaktSccne NYscPE6L53LO9JwYXv3B7HvhmSpSojjGconVfVT1gsOXS1H9aEMBzpCvx5CYR3ICtJI2 sKmdZJq3dXm9ObK8HNzh1dmKDhYXQlfC7sMaT1mS82NwwmB4XJAwG/996RmNyupHGuj8 0OWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=pClSYH48A4JwHvvfniaI2uO6Qcm4/lbeN9GJv6FcrJM=; b=Hj3auQUP+CQfGjjXxhIPXLetaXPjISMIefnLfTTJxD2DsYXqZFzjYohTQ/asRQrpQ4 garjhNq8pRiNnDHfOrgrrLIhr7l24vY7U5UUzv+F5RsxXeG3BhTgjo+7wptpKrf1FdcD qzXa2bLmrP3cjyWXkK73hfaMLy3F8C+B/bNr+TDgtyDKMfiNtBPDF9LPhpWF5Tisajz0 9pxksnNzVlxApMxvopTOXYej76jGe4WonRWDgRWsVH1nuE7SZtOi0Cy/lYPmqH+ap/IJ sLUu8/Ii1TkfZyIf1P1xnxR/oiYOkC2hq9aAcHAVpUjTvpuY9j3kYY2euOinK1dOP1kz htjQ== X-Gm-Message-State: APjAAAXYAYov39zUJIgOzm0r13i6d/7lN2UpzF3QWIIibZuQwdDrdecp ZNd48gDN72ZDO+n2AksP/mbUEwMyOA8= X-Google-Smtp-Source: APXvYqzznaB9Eg5df+y1glnUJOroDEfNPLLjkmaVv6+2rFgl5bXNABAeWHNWc7/267THyhiV+zmbLQ== X-Received: by 2002:a17:90a:71c1:: with SMTP id m1mr372613pjs.34.1581963447352; Mon, 17 Feb 2020 10:17:27 -0800 (PST) Received: from 186590ce269b.ant.amazon.com (54-240-196-170.amazon.com. [54.240.196.170]) by smtp.gmail.com with ESMTPSA id o9sm1127563pfg.130.2020.02.17.10.17.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 Feb 2020 10:17:26 -0800 (PST) Subject: Re: PL/pgSQL question about EXCEPTION clause & corrupt records From: Jeremy Schneider To: Nick Renders Cc: pgsql-general References: <4C495833-29AC-47F8-ADB7-D32E2A1F516F@arcict.com> Message-ID: <778b4c5c-312f-2e64-b690-5ddc9443966b@ardentperf.com> Date: Mon, 17 Feb 2020 10:17:26 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2/17/20 08:23, Jeremy Schneider wrote: > FWIW, Bertrand blogged an even faster way to do this about a month ago - > using pageinspect and processing blocks instead of rows > > https://bdrouvot.wordpress.com/2020/01/18/retrieve-postgresql-variable-length-storage-information-thanks-to-pageinspect/ > > >> On Feb 17, 2020, at 03:32, Nick Renders wrote: >> >> The problem is that I don't know which column is corrupt. But I found >> a solution: by simply copying the record into another variable, the >> values are parsed and the TOAST errors are thrown. >> >> In case anyone's interested, here's my code, based on an example from >> http://www.databasesoup.com/2013/10/de-corrupting-toast-tables.html Apologies - sent that slightly rushed email while I was taking the bus to the office this morning and linked the wrong blog post :D Here's the right one, showing a much faster way to identify which tuple links to a bad toast row: https://bdrouvot.wordpress.com/2020/01/04/get-toast-chunk_id-from-the-user-table-tuples-or-from-the-toast-index-thanks-to-pageinspect/ -Jeremy -- http://about.me/jeremy_schneider