Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tIQ9L-00EDsp-An for pgsql-hackers@arkaria.postgresql.org; Tue, 03 Dec 2024 10:28:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tIQ9I-0091J8-NR for pgsql-hackers@arkaria.postgresql.org; Tue, 03 Dec 2024 10:28:57 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tIQ9I-0091Iw-Bc for pgsql-hackers@lists.postgresql.org; Tue, 03 Dec 2024 10:28:57 +0000 Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tIQ9G-000oDx-J8 for pgsql-hackers@lists.postgresql.org; Tue, 03 Dec 2024 10:28:56 +0000 Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2ffa8df8850so60329331fa.3 for ; Tue, 03 Dec 2024 02:28:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733221732; x=1733826532; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ZpCe2AINbW0jThOur8UYF1/6GxKKrXDcsoQE/R2sUu8=; b=hpXNITf08ORnXhnWcX9YvqceJNDglCrNQF22qy2at1Pxp287/iklZ/0j++Gf1UO/Os ZNgsZ/2aby8xZBxnseGOaZ/b161EevKGqLhjSumQcc9lHp+VE2NjgXzeEZG2V9vvlVxf IvNClw2QN+8MFh6WQiQqoEkDdEGsouVlv1MRtaiJe4t0UFvo4yRdO+FN9kb7MGp0up26 r7ekTAK0Ywp1Aq+NsVZ10POhmYVn4IsDAPN4ABsEpYht3FwoEaYU7gRPBNvjbZK0N1hP b3BNBBS5XMobPzDRLay3uWWmawgj6us+ynd4jX2wb86Kifa+4OOdZPl3QHr8XzVGw27u zuBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733221732; x=1733826532; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZpCe2AINbW0jThOur8UYF1/6GxKKrXDcsoQE/R2sUu8=; b=u0rAmqToZIOYRVytMQ4bOqe8rROktftnVZTYgomDO4p5khBuNnTlxmXPLB3loK/uG8 QO73aXUhPMWEJf0DOtTHtAomHbh7UieWAqcr2tWZgEIHFzUX63Zh736kwFCyw2mtOIGQ c7Z35BRODLuFII08a13+lZvOXuA12aNVc/Fd4nZUBAH6Fpa7zkxU7kUmYw/V3UjZ2Ud+ 0X1bUCFXiy0QtTdWTpCYwnkoVsnkH5wc0GFKBM1SGNoumgteLNwT+xRSSqRCfcNApiVm OY/z36C+GOS/+YN8BkglyV01fFlFwsBVCzynSqZ3tfRhrH++rZfyzNjsjXNSmBROxmEn io0Q== X-Forwarded-Encrypted: i=1; AJvYcCWuSvclKV9DGQgRjJp5orXMcL9C4d+WBcDK5hzFZ9mVjF47VpmTbXRAO+/ZfWgQ3laIW9X7msbDyxT8BUuL@lists.postgresql.org X-Gm-Message-State: AOJu0YzRgz1CdMwQ7LZoJmXM2NVgB90dhjPbCMSPQ92zEMlCGWvE670o hmfOGpZ5ynRnMFLJQbm8V1TiL8vHwzTBh3JydT15/hWfa3XKY2TgqOIOWnWWcGogh44C2OG6331 LO+2FFikk2Rs3KZb1kTHkg7R4a/4= X-Gm-Gg: ASbGnct0RIQ6owZOnbuKGdxB/ZSl7QbBcIZe8IaDPSwvK6eT2l+zRTg2vVsnG6hyfX+ 6Zk72hmb5pFFNqoUT24TSg2JulsNuaKKeASISmzk7eM6EU/004SgDODSj5+F4 X-Google-Smtp-Source: AGHT+IEXiBsiFL6+ol+C2trpzDO53qbEoo9q4NEiaMK3lW1AqmBY8jARZtE1Afe4CylpEkZvObZHY5gKeCFIO0kPajo= X-Received: by 2002:a2e:a984:0:b0:2ff:c3d2:b09f with SMTP id 38308e7fff4ca-30009c72c70mr11049961fa.2.1733221732113; Tue, 03 Dec 2024 02:28:52 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Kirill Reshke Date: Tue, 3 Dec 2024 15:28:40 +0500 Message-ID: Subject: Re: on_error table, saving error info to a table To: jian he Cc: Nishant Sharma , PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 3 Dec 2024 at 09:29, jian he wrote: > > On Tue, Nov 5, 2024 at 6:30=E2=80=AFPM Nishant Sharma > wrote: > > > > Thanks for the v2 patch! > > > > I see v1 review comments got addressed in v2 along with some > > further improvements. > > > > 1) v2 Patch again needs re-base. > > > > 2) I think we need not worry whether table name is unique or not, > > table name can be provided by user and we can check if it does > > not exists then simply we can create it with appropriate columns, > > if it exists we use it to check if its correct on_error table and > > proceed. > > "simply we can create it with appropriate columns," > that would be more work. > so i stick to if there is a table can use to > error saving then use it, otherwise error out. > > > > > > 3) Using #define in between the code? I don't see that style in > > copyfromparse.c file. I do see such style in other src file. So, not > > sure if committer would allow it or not. > > #define ERROR_TBL_COLUMNS 10 > > > let's wait and see. > > > 4) Below appears redundant to me, it was not the case in v1 patch > > set, where it had only one return and one increment of error as new > > added code was at the end of the block:- > > + cstate->num_errors++; > > + return true; > > + } > > cstate->num_errors++; > > > changed per your advice. > > > I was not able to test the v2 due to conflicts in v2, I did attempt to > > resolve but I saw many failures in make world. > > > I get rid of all the SPI code. > > Instead, now I iterate through AttributeRelationId to check if the > error saving table is ok or not, > using DirectFunctionCall3 to do the privilege check. > removed gram.y change, turns out it is not necessary. > and other kinds of refactoring. > > please check attached. Hi! 1) > + switch (attForm->attnum) > + { > + case 1: > + (.....) > + case 2: case 1,2,3 ... Is too random. Other parts of core tend to use `#define Anum__ `. Can we follow this style? 2) >+ /* > + * similar to commit a9cf48a > + * (https://postgr.es/m/7bcfc39d4176faf85ab317d0c26786953646a411.camel@c= ybertec.at) > + * in COPY FROM keep error saving table locks until the transaction end. > + */ I can rarely see other comments referencing commits, and even few referencing a mail archive thread. Can we just write proper comment explaining the reasons? =3D=3D=3D=3D=3D overall Patch design is a little dubious for me. We give users some really incomprehensible API. To use on_error *relation* feature user must create tables with proper schema. Maybe a better design will be to auto-create on_error table if this table does not exist. Thoughts? --=20 Best regards, Kirill Reshke