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 1rUilU-00Cf6y-6T for pgsql-bugs@arkaria.postgresql.org; Tue, 30 Jan 2024 07:42:41 +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 1rUilS-003LZK-QC for pgsql-bugs@arkaria.postgresql.org; Tue, 30 Jan 2024 07:42:38 +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 1rUilR-003LZC-08 for pgsql-bugs@lists.postgresql.org; Tue, 30 Jan 2024 07:42:38 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rUilJ-0046sQ-Nl for pgsql-bugs@lists.postgresql.org; Tue, 30 Jan 2024 07:42:35 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id A2B8B3200B1B; Tue, 30 Jan 2024 02:42:27 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 30 Jan 2024 02:42:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1706600547; x=1706686947; bh=VNKlJgSU2a x/B7oRfInwuEKlmIO5CnZsZhxPvNsIGBA=; b=L06i5BJVE03Pe9Buy7dIg6NqQf JlMdFsDZ+E/7rPWkVERMb50EL7vO6MsRCzdjKeEq7z+It6H6wC50jeNLA3oyRAES wMBJkdb9SQvkKFJFtV1HqCkQJTJaIku/a+altYgPZxX2fUFWXVcMGENsNWDJ8OFs XMLIaEG4RRB2CPDQgiImex2IHw2mWvxbUHVv25Wr13oECVyYhsGEmX+MrSd/ALHc 601n4dk6kZ4u+a88AXyZh65CTbqQTCvBLVvgUiKL7/7BHRmANBvs1O/fn9bf5kvW NDOVEl9JQlUroSb+BZZUVRAWTdBuysKZbfD4bHRKmHAoXyyXOcPLiEPwu6tQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1706600547; x=1706686947; bh=VNKlJgSU2ax/B7oRfInwuEKlmIO5 CnZsZhxPvNsIGBA=; b=ABnFKwT5iefbtJC7wnqeRN8Pt+X6oW8vUPxNc8ZYpMEO TniLKsOVNrDFP1WgKtMc6EaKYLnGP/tSpJLr/49d91FmKY5As8CAKAeOXtEg+zn0 ssLwLhoHaad28Shk0lE2j4Y2z6X1SLtUU3LKs8MfmDOjqTlo97mel/UH0P3WHgBe nfkEevSYYIHEuqFoTCwXxC511Slw+3J0DgDlh5qMELusYYsHeXZ2UVHMnoCNIjih cXhxag+29xsQSXJmWs8i9un1v0fDQLz52osRROVDUFC8TvTHIrfpkzHWo/aRbTKd wywnAIbqWGEPsS9KgiqivmUfxvl1RlhT9I9lkK0R5g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrfedthedguddtkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enfghrlhcuvffnffculdejtddmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreer tddtjeenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlse hprghquhhivghrrdighiiiqeenucggtffrrghtthgvrhhnpeevteejgfejveegudekheei ueeiueeiveeuiedugeehveeugffgudeuleegleeiteenucevlhhushhtvghrufhiiigvpe dtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdig hiii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 30 Jan 2024 02:42:25 -0500 (EST) Date: Tue, 30 Jan 2024 16:42:10 +0900 From: Michael Paquier To: Tender Wang Cc: Alexander Lakhin , pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18310: Some SQL commands fail to process duplicate objects with error: tuple already updated by self Message-ID: References: <18310-1eb233c5908189c8@postgresql.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="+lSgWqqvp58oxZZw" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --+lSgWqqvp58oxZZw Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jan 30, 2024 at 03:29:46PM +0800, Tender Wang wrote: > Michael Paquier =E4=BA=8E2024=E5=B9=B41=E6=9C=8830= =E6=97=A5=E5=91=A8=E4=BA=8C 14:28=E5=86=99=E9=81=93=EF=BC=9A > I misunderstund the behavior in getTokenTypes() and in > DropConfigurationMapping(). I only realized it can fix the reported issue. Well, I don't think you should blame yourself, so no worries we are all here to learn :) tsdicts.sql has little to no coverage of the various grammar flavors we are discussing here, so we should try to close the hole with all the expectations I've just guessed while analyzing the code and the patch. So it is a=20 problem of fixing the root issue as much as expanding the regression tests with token names and IF EXISTS. >> I think that we should tweak getTokenTypes() so as we return *two* >> Lists, one for the IDs and a second with the token names, then use >> forboth() in DropConfigurationMapping() with the two lists and a >> simple foreach in MakeConfigurationMapping() when overriding the >> mappings, while getTokenTypes() checks if a number is in the first >> list before adding the name of a token in the second list. Or we >> could use a simple list with pointers to a local structure, but the >> second list is only needed by DropConfigurationMapping(). That would >> enforce a correct order of the token names and numbers, at least. >> I would be tempted to just use one List with a structure (number, >> token_name). It makes the checks for duplicates O(N^2) but we will >> never have hundreds of mapping entries in these DDL queries. >> >=20 > Hmm, I agree with you. Perhaps you'd like to give it a second try? Based on my suggestion, you just need to englobe the tokens retrieved into a single structure like that: typedef struct { int num; char *name; } TSTokenTypes; Then handle a List of these (could be as well an array with its length returned as an output argument of getTokenTypes(), to keep a non-duplicated list of tokens with a strict mapping between token name and token number. -- Michael --+lSgWqqvp58oxZZw Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmW4qFIACgkQnvQgOdby QH1q+Q/6Akw3JNzgXlLzjWxEVnaGHV2fJd/ih7Tawf0/9JLz6NxxifMWz4LHEmS1 IxeVnFrUSIsmtJQhfOC0U8g7zWeSMbmv5KlYF3UpG6YCDYlYAR13D7StzDwLQKUA 6fJerdfHotqi/ZUcDFxEm6+c2Su4X7U+t3cifPxvytSV3ALDSTNu0IhSUWcN7UsE SFJqUX/AONarCMAwXirvDkB1hhivJROMg+p8zB4XZnrl/I3xfLJ1rpBHvq26xDMS POt6pd6QbskMi7AIohx4e69oqxs+qMc+dcErgbQtyhN0qGphIjNciT8xZ5mXK6JB qPIqVsCQxF2hYtCqc3mlJ/qC93S3NFEiKqDL32RN/KD5P2sHzkCFEwPjsxpVKnvm p8njAzGi9Vm6AWRcztNDGT9rRo+kL/+D4wKZO8H4CNpuRT7YlKU5QoYJ8hxEz2sW OFlb0WG7wkcXeerdFxE19c0QeOG+zgoL6QVZsulBV4MB7AQx/PSyHBY3QvuGbBYI O0nUr6LyaxK3bn2VWe4GGQTYNad46utt/mwpOqtR5Nzp//6fsaT6QMy6HbOWxZFC YGB3vX1fiKvonwIzUgsygvfPgBzP4yZwm8oO/vzeFM7+zkoKn+2W5asXG2Cgt3kw GDwYqNryLJEgexliLrfdWGRGomfnVy0uQgg9wCsl0uToRzUgVFc= =De38 -----END PGP SIGNATURE----- --+lSgWqqvp58oxZZw--