[PATCH] Slight improvement of worker_spi.c example

Поиск
Список
Период
Сортировка
От Aleksander Alekseev
Тема [PATCH] Slight improvement of worker_spi.c example
Дата
Msg-id CAJ7c6TMOhWmP92_fFss-cvNnsxdj5_TSdtmiE3AJOv6yGotoFQ@mail.gmail.com
обсуждение исходный текст
Ответы Re: [PATCH] Slight improvement of worker_spi.c example  (Aleksander Alekseev <aleksander@timescale.com>)
Список pgsql-hackers
Hi,

Currently the example uses the following order of calls:

    StartTransactionCommand();
    SPI_connect();
    PushActiveSnapshot(...);

    ...

    SPI_finish();
    PopActiveSnapshot();
    CommitTransactionCommand();

This could be somewhat misleading. Typically one expects something to be freed
in a reverse order compared to initialization. This creates a false impression
that PushActiveSnapshot(...) _should_ be called after SPI_connect().

The patch changes the order to:

    StartTransactionCommand();
    PushActiveSnapshot(...);
    SPI_connect();

    ...

    SPI_finish();
    PopActiveSnapshot();
    CommitTransactionCommand();

... and also clarifies that the order of PushActiveSnapshot(...) and
SPI_connect() is not important.

--
Best regards,
Aleksander Alekseev

Вложения

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

Предыдущее
От: Pavel Stehule
Дата:
Сообщение: Re: psql tests hangs
Следующее
От: Tom Lane
Дата:
Сообщение: Re: psql tests hangs