[PATCH] Check snapshot argument of index_beginscan and family

Поиск
Список
Период
Сортировка
От Aleksander Alekseev
Тема [PATCH] Check snapshot argument of index_beginscan and family
Дата
Msg-id CAJ7c6TPxitD4vbKyP-mpmC1XwyHdPPqvjLzm+VpB88h8LGgneQ@mail.gmail.com
обсуждение исходный текст
Ответы Re: [PATCH] Check snapshot argument of index_beginscan and family  (Pavel Borisov <pashkin.elfe@gmail.com>)
Список pgsql-hackers
Hi hackers,

A colleague of mine (cc'ed) reported that he was able to pass a NULL
snapshot to index_beginscan() and it even worked to a certain degree.

I took my toy extension [1] and replaced the argument with NULL as an
experiment:

```
eax=# CREATE EXTENSION experiment;
CREATE EXTENSION
eax=# SELECT phonebook_lookup_index('Alice');
 phonebook_lookup_index
------------------------
                     -1
(1 row)

eax=# SELECT phonebook_insert('Bob', 456);
 phonebook_insert
------------------
                1
(1 row)

eax=# SELECT phonebook_lookup_index('Alice');
 phonebook_lookup_index
------------------------
                     -1
(1 row)

eax=# SELECT phonebook_insert('Alice', 123);
 phonebook_insert
------------------
                2
(1 row)

eax=# SELECT phonebook_lookup_index('Alice');
server closed the connection unexpectedly
    This probably means the server terminated abnormally
    before or while processing the request.
```

So evidently it really works as long as the index doesn't find any
matching rows.

This could be really confusing for the extension authors so here is a
patch that adds corresponding Asserts().

[1]: https://github.com/afiskon/postgresql-extensions/tree/main/005-table-access

-- 
Best regards,
Aleksander Alekseev

Вложения

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

Предыдущее
От: Sergey Shinderuk
Дата:
Сообщение: Re: Bug in row_number() optimization
Следующее
От: Pavel Borisov
Дата:
Сообщение: Re: [PATCH] Check snapshot argument of index_beginscan and family