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 1rprbE-0096Vt-MU for pgsql-hackers@arkaria.postgresql.org; Thu, 28 Mar 2024 15:23:29 +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 1rprbB-00Fxua-RQ for pgsql-hackers@arkaria.postgresql.org; Thu, 28 Mar 2024 15:23:25 +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 1rprbB-00FxuR-98 for pgsql-hackers@lists.postgresql.org; Thu, 28 Mar 2024 15:23:25 +0000 Received: from mail-sy4aus01olkn2154.outbound.protection.outlook.com ([40.92.62.154] helo=AUS01-SY4-obe.outbound.protection.outlook.com) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rprb6-006tpb-AQ for pgsql-hackers@lists.postgresql.org; Thu, 28 Mar 2024 15:23:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E0ITyH2jj34QZLZjexaIa8e1z1yi4Di/VLZE13pHwIyh5xsu6CShMj/lL09EIn2BocHA01EBzOLTw9YuhakHCLCdh7YafYAlKGoi+yczDgeKnpZ8vvmcdTc5Py9QV9aPLQwXSlB0iK+PrecMI2ehkNVrUXjgsJA78P4zRfM6L7l6ZfkHNYWxGXYvreLxUhdOpAhoXYhuTGstgelz+9Do5jg3x8neIBcUEDLeDd4AmOphLuQgtx8TVlfAi4ZOH8RTM2JbSoN15tTaWPTe97Uy6zJPDW/3mKm5XXSgrwR1Tb7/jL6hOne2GKGa339hRl013YnH6h5l318WNQAPtksWdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YuJMbWAAIboG5sTWBlLME6KoIqZAOAeR3fwRqYywUzA=; b=ikKsBGLAAenfsJhypZbkLGx8/tkJ87mkYO0dzFkmsqVryuu1UN9iW/Ywion950tAqJlOnCpMEx+CLX8VxSKCBwEXYdFgo82TB6VJWQvYIP3wAGoj1PqHY2aT9eox+Po5YhXCiIpt6dWIYHEfsXuKsdwKapAtQDXobJQNvr+uCfHPpOieVpdaaM3DekjRngNpu5Dd4vMVGePTKjQy18ESN40o5ffF0002Q5ptsUQ0xkRKrXbms+XOJs9RFEu8tCZg0+o41sadRu8ahJJ2R4Jghu3DzyfiZQyLWBFHDMTP0d1ZKCbG10Neg3VjaEBhOtum7bn1TEmz3kcqzfxCv9pIIw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YuJMbWAAIboG5sTWBlLME6KoIqZAOAeR3fwRqYywUzA=; b=cg5M8M43yn0woB97Hs3//JQyOLmPYtTM4QimHwd+8GfX1ocV9hB6i/Mm4eYLdspDJ/4qGb+KoFAN8Zq5xzq9W8OtSUgF0Z02XQmTKqoVy2wsl6zAaZIIVQ0mu1AZ2ds25ILxTHQFCoOu1HspMmaRHXlvgeetN8kva+2+YxMIOsZgIF/fbK38bcsFbAZsKhB64Z7IodIVupK5O3HS4lEaQ37tr2RPM2NIPV9BaQvK6aUHzh4a8QrlWXZN3RLPcIC3qU6t840mkJ8O1FIP/UYA7nsm0XdHTUL36Z4s2yePqGxvZ9aBBA8p6NeQg7C1kkvvtuLkKgvjviDDcSSqL5uAQw== Received: from ME3P282MB3166.AUSP282.PROD.OUTLOOK.COM (2603:10c6:220:147::21) by SY5P282MB4400.AUSP282.PROD.OUTLOOK.COM (2603:10c6:10:269::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.32; Thu, 28 Mar 2024 15:23:10 +0000 Received: from ME3P282MB3166.AUSP282.PROD.OUTLOOK.COM ([fe80::9494:dde6:adea:18a1]) by ME3P282MB3166.AUSP282.PROD.OUTLOOK.COM ([fe80::9494:dde6:adea:18a1%4]) with mapi id 15.20.7409.039; Thu, 28 Mar 2024 15:23:10 +0000 References: User-agent: mu4e 1.4.15; emacs 28.1 From: Japin Li To: Alexander Korotkov Cc: Pavel Borisov , Mark Dilger , pgsql-hackers@lists.postgresql.org Subject: Re: Table AM Interface Enhancements In-reply-to: Date: Thu, 28 Mar 2024 23:23:05 +0800 Message-ID: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-TMN: [SXNn0QX9iq9Yt3SvG+aaSCcVOpRlGtYw] X-ClientProxiedBy: TYCP286CA0234.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:3c7::6) To ME3P282MB3166.AUSP282.PROD.OUTLOOK.COM (2603:10c6:220:147::21) X-Microsoft-Original-Message-ID: <87h6gqmld2.fsf@hotmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: ME3P282MB3166:EE_|SY5P282MB4400:EE_ X-MS-Office365-Filtering-Correlation-Id: bf7962ed-f9fd-4e32-401a-08dc4f3af9fd X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 49WvbjkhLUct5S3HksGxZJG6wk209lBR03h1HXRGL1Q91x+dbzdDQxqBeLlPVFoye7VjTq8fhF0WD1Gh8j18eTKiL2WScn2X9c9uWe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QzJ3N2dGUURPb3BOTlozeDFOalFGM2F1dk54enRJ?= =?utf-8?B?UWlsWUZ5a3UwNkg5eGNlck8xYUNEOHJ5VzRobEhhR0pLVHpUZnBteUFPTXVJ?= =?utf-8?B?ZlAyWEZiQVZ1WURFVHk3ZnY0V1RKNmVDQ2JQQ0NGQVg0eVU3cjRTVG5ZMkx0?= =?utf-8?B?T0JNZEl4K2N6UlBTQkRUbUpaRlVBY0IzLzhJMXczWHhDMFFKUTE0Q1BCTjZT?= =?utf-8?B?UFkzVXA4bVUvQzQ4cyttdkJlaGtmL3pkYzNURVBTUS9LVHlzR0xuVUF4V3VY?= =?utf-8?Q?xOh9mu2Xo2uQ4BsDf5YXpm2zNTRjd5mw6b+jjF2gMRk4=3D?= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-746f3.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: bf7962ed-f9fd-4e32-401a-08dc4f3af9fd X-MS-Exchange-CrossTenant-AuthSource: ME3P282MB3166.AUSP282.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Mar 2024 15:23:10.6206 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SY5P282MB4400 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, 28 Mar 2024 at 21:26, Alexander Korotkov wro= te: > Hi Pavel! > > Revised patchset is attached. > > On Thu, Mar 28, 2024 at 3:12=E2=80=AFPM Pavel Borisov wrote: >> The other extensibility that seems quite clear and uncontroversial to me= is 0006. >> >> It simply shifts the decision on whether tuple inserts should invoke ins= erts to the related indices to the table am level. It doesn't change the cu= rrent heap insert behavior so it's safe for the existing heap access method= . But new table access methods could redefine this (only for tables created= with these am's) and make index inserts independently of ExecInsertIndexTu= ples inside their own implementations of tuple_insert/tuple_multi_insert me= thods. >> >> I'd propose changing the comment: >> >> 1405 * This function sets `*insert_indexes` to true if expects caller t= o return >> 1406 * the relevant index tuples. If `*insert_indexes` is set to false= , then >> 1407 * this function cares about indexes itself. >> >> in the following way >> >> Tableam implementation of tuple_insert should set `*insert_indexes` to t= rue >> if it expects the caller to insert the relevant index tuples (as in heap >> implementation). It should set `*insert_indexes` to false if it cares >> about index inserts itself and doesn't want the caller to do index inser= ts. > > Changed as you proposed. > >> Maybe, a commit message is also better to reformulate to describe better= who should do what. > > Done. > > Also, I removed extra includes in 0001 as you proposed and edited the > commit message in 0002. > >> I think, with rebase and correction in the comments/commit message patch= 0006 is ready to be committed. > > I'm going to push 0001, 0002 and 0006 if no objections. Thanks for updating the patches. Here are some minor sugesstion. 0003 +static inline TupleTableSlot * +heapam_tuple_insert_with_arbiter(ResultRelInfo *resultRelInfo, I'm not entirely certain whether the "inline" keyword has any effect. 0004 +static bytea * +heapam_indexoptions(amoptions_function amoptions, char relkind, + Datum reloptions, bool validate) +{ + return index_reloptions(amoptions, reloptions, validate); +} Could you please explain why we are not verifying the relkind like heapam_reloptions()? - case RELKIND_VIEW: case RELKIND_MATVIEW: + case RELKIND_VIEW: case RELKIND_PARTITIONED_TABLE: I think this change is unnecessary. + { + Form_pg_class classForm; + HeapTuple classTup; + + /* fetch the relation's relcache entry */ + if (relation->rd_index->indrelid >=3D First= NormalObjectId) + { + classTup =3D SearchSysCacheCopy1(RE= LOID, ObjectIdGetDatum(relation->rd_index->indrelid)); + classForm =3D (Form_pg_class) GETST= RUCT(classTup); + if (classForm->relam >=3D FirstNorm= alObjectId) + tableam =3D GetTableAmRouti= neByAmOid(classForm->relam); + else + tableam =3D GetHeapamTableA= mRoutine(); + heap_freetuple(classTup); + } + else + { + tableam =3D GetHeapamTableAmRoutine= (); + } + amoptsfn =3D relation->rd_indam->amoptions; + } - We can reduce the indentation by moving the classFrom and classTup into the if branch. - Perhaps we could remove the brace of else branch to maintain consistency in the code style. -- Regards, Japin Li