Re: BUG #18310: Some SQL commands fail to process duplicate objects with error: tuple already updated by self
Tender Wang <tndrwang@gmail.com>
From: Tender Wang <tndrwang@gmail.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Alexander Lakhin <exclusion@gmail.com>, pgsql-bugs@lists.postgresql.org
Date: 2024-01-30T08:02:06Z
Lists: pgsql-bugs
Michael Paquier <michael@paquier.xyz> 于2024年1月30日周二 15:42写道:
> On Tue, Jan 30, 2024 at 03:29:46PM +0800, Tender Wang wrote:
> > Michael Paquier <michael@paquier.xyz> 于2024年1月30日周二 14:28写道:
> > 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
> 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.
> >>
> >
> > 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.
>
Thanks a lot. I want to give it a second try. I will send a patch based on
your suggestion.
> --
> Michael
>
--
Tender Wang
OpenPie: https://en.openpie.com/
Commits
-
Fix various issues with ALTER TEXT SEARCH CONFIGURATION
- 0561097822a1 12.18 landed
- 4d0e8a008bdc 13.14 landed
- dde5b01c33f9 14.11 landed
- 41fa4b31c12f 15.6 landed
- f33e83285a14 16.2 landed
- 3e91dba8b079 17.0 landed
-
Fix DROP ROLE when specifying duplicated roles
- f57a580fd280 16.2 landed
- 50b797dc99ec 17.0 landed