Re: BUG #18310: Some SQL commands fail to process duplicate objects with error: tuple already updated by self

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема Re: BUG #18310: Some SQL commands fail to process duplicate objects with error: tuple already updated by self
Дата
Msg-id ZbioUp1xRNnkRfkN@paquier.xyz
обсуждение исходный текст
Ответ на Re: BUG #18310: Some SQL commands fail to process duplicate objects with error: tuple already updated by self  (Tender Wang <tndrwang@gmail.com>)
Ответы Re: BUG #18310: Some SQL commands fail to process duplicate objects with error: tuple already updated by self  (Tender Wang <tndrwang@gmail.com>)
Список pgsql-bugs
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.
--
Michael

Вложения

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Tender Wang
Дата:
Сообщение: Re: BUG #18310: Some SQL commands fail to process duplicate objects with error: tuple already updated by self
Следующее
От: Tender Wang
Дата:
Сообщение: Re: BUG #18310: Some SQL commands fail to process duplicate objects with error: tuple already updated by self