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.92) (envelope-from ) id 1jC3BA-00054i-Ty for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Mar 2020 15:21:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jC3B9-0006Qx-Pe for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Mar 2020 15:21:51 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jC3B9-0006QS-BR for pgsql-hackers@lists.postgresql.org; Wed, 11 Mar 2020 15:21:51 +0000 Received: from mail-ot1-x341.google.com ([2607:f8b0:4864:20::341]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jC3B6-0003hv-RG for pgsql-hackers@lists.postgresql.org; Wed, 11 Mar 2020 15:21:50 +0000 Received: by mail-ot1-x341.google.com with SMTP id b3so2360909otp.4 for ; Wed, 11 Mar 2020 08:21:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=ehYPm0RKjUAI1UIiboANpzNBm16zFmR5kMtGIItYLHY=; b=fTKXX4G6zzHZimTrU2Iq1rev6p2+qVQdcV3rn5pFP3bc7grDgc2lEDI4tQlPe773Af kNpSk7WHMEiwJztBUEyTTy97/EKtU7XTn2TGR+1/zkGhwiINB6AeGE/S4ATplyUupgMO HfT5EenQhXs2c5wkzVHqohZeD1IJ98iR9+qSEHnDnrjrMOT/Xm4wxFIa5IlIxwQkaeDs z7+h8Uz7fbQpnt1wVl8llid6pIEExS7ueh9Gz8bARlxBbRxwwV/zt8786jtlTioD0t8M 7SRO3W0W2qHJqhiuZxc5NeoB+EDf+u7D3lz9tYM89+O+/nl14NKzz1v76CgF4Gob3Ri7 AfQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=ehYPm0RKjUAI1UIiboANpzNBm16zFmR5kMtGIItYLHY=; b=aVJcGlaGuYDpGOiTisbBNIQA4SbegM4UEvAIoz/D6jlnRCJmk8UQ9vx1KoeHceCnqo 2i/l8t5wFP+nMGanYrKzFlZIYDFhZL02qLEpwwhdTUNG5BZgS/VaTgL0DxRkSSIT3gzU +r1hg1c2Jg+LB01WHURy6GkztMqpcyqdaizsC4sxPcLLgVlbhYzIOj6wNz89Dh/rPyjm NoJNMZBWvrFTernOEtoyAg5PR7lHANgpfKYPekS2Tkv/hXXGVrz20cT3XXU1EjUmjZWP KUaGcGANqeoxoXQ5rqCpWzl6EZxUDjStpx1xz2JHH58Zpvsjg7+emVgaDwUtNNH9F10G VrHQ== X-Gm-Message-State: ANhLgQ1TKge/8i2fH2NtDrbx69qoj+Kb24f6+l6YTHDfMP2Neoz7gQFG 4lXZcQPQt3rZ+BagV+PE0lCNywEYg3U= X-Google-Smtp-Source: ADFU+vt3x//Nzl3XQ8j0CPKTrI6KzR0CQontvnrneDlcEPRnYNNCfZqO35QlSlJ1LBt//yAqjONF3w== X-Received: by 2002:a9d:728e:: with SMTP id t14mr2865410otj.63.1583940107683; Wed, 11 Mar 2020 08:21:47 -0700 (PDT) Received: from [100.115.92.206] (cpe-70-119-96-135.tx.res.rr.com. [70.119.96.135]) by smtp.gmail.com with ESMTPSA id r20sm3522524oic.56.2020.03.11.08.21.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 11 Mar 2020 08:21:46 -0700 (PDT) From: Chris Bandy Subject: Re: [PATCH] Add schema and table names to partition error To: Amit Kapila Cc: pgsql-hackers@lists.postgresql.org References: <0aa113a3-3c7f-db48-bcd8-f9290b2269ae@gmail.com> <0acc36c9-1aef-1057-0c29-de473c850605@gmail.com> Message-ID: <4037ab52-27e4-bbfb-d618-adbab81125e2@gmail.com> Date: Wed, 11 Mar 2020 10:21:45 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=us-ascii Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Amit, On 3/11/20 6:29 AM, Amit Kapila wrote: > On Tue, Mar 3, 2020 at 10:05 AM Chris Bandy wrote: >> >> On 3/1/20 10:09 PM, Amit Langote wrote: >>> Hi Chris, >>> >>> On Mon, Mar 2, 2020 at 8:51 AM Chris Bandy wrote: >>>> On 3/1/20 5:14 AM, Amit Kapila wrote: >>>>> On Sun, Mar 1, 2020 at 10:10 AM Amit Langote wrote: >>>>>> >>>>>> There are couple more instances in src/backend/command/tablecmds.c >>>>>> where partition constraint is checked: >>>>>> >>>>>> Maybe, better fix these too for completeness. >>>>> >>>>> Another thing we might need to see is which of these can be >>>>> back-patched. We should also try to write the tests for cases we are >>>>> changing even if we don't want to commit those. >>>> >>>> I don't have any opinion on back-patching. Existing tests pass. I wasn't >>>> able to find another test that checks the constraint field of errors. >>>> There's a little bit in the tests for psql, but that is about the the >>>> \errverbose functionality rather than specific errors and their fields. >>> >>> Actually, it's not a bad idea to use \errverbose to test this. >>> >> >> I've added a second patch with tests that cover three of the five errors >> touched by the first patch. Rather than \errverbose, I simply \set >> VERBOSITY verbose. I could not find a way to exclude the location field >> from the output, so those lines will be likely be out of date soon--if >> not already. >> >> I couldn't find a way to exercise the errors in tablecmds.c. Does anyone >> know how to instigate a table rewrite that would violate partition >> constraints? I tried: >> > > When I tried to apply your patch on HEAD with patch -p1 < > , I am getting below errors > > (Stripping trailing CRs from patch; use --binary to disable.) > can't find file to patch at input line 17 > Perhaps you used the wrong -p or --strip option? > The text leading up to this was: > .. > > I have tried with git am as well, but it failed. I am not sure what > is the reason. Can you please once check at your end? Yes, sorry. This set (and v3 and v4) should work with -p0. Any following patches from me will use the normal -p1. > Also, see, if > it applies till 9.5 as I think we should backpatch this. > > IIUC, this patch is mainly to get the table name, schema name in case > of the error paths, so that your application can handle errors in case > partition constraint violation, right? Yes, that is correct. Which also means it doesn't apply to 9.5 (no partitions!) Later in this thread I created a test that covers all integrity violation errors.[1] *That* can be backpatched, if you'd like. For an approach limited to partitions only, I recommend looking at v4 rather than v2 or v3.[2] [1]: https://postgresql.org/message-id/0731def8-978e-0285-04ee-582762729b38%40gmail.com [2]: https://postgresql.org/message-id/7985cf2f-5082-22d9-1bb4-6b280150eeae%40gmail.com Thanks, Chris