Re: BufFileRead() error signalling

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BufFileRead() error signalling
Дата
Msg-id 30568.1574289111@sss.pgh.pa.us
обсуждение исходный текст
Ответ на BufFileRead() error signalling  (Thomas Munro <thomas.munro@gmail.com>)
Ответы Re: BufFileRead() error signalling  (Thomas Munro <thomas.munro@gmail.com>)
Список pgsql-hackers
Thomas Munro <thomas.munro@gmail.com> writes:
> As noted by Amit Khandhekar yesterday[1], BufFileLoad() silently eats
> pread()'s error and makes them indistinguishable from EOF.

That's definitely bad.

> I think the choices are: (1) switch to ssize_t and return -1, (2) add
> at least one of BufFileEof(), BufFileError(), (3) have BufFileRead()
> raise errors with elog().  I lean towards (2), and I doubt we need
> BufFileClear() because the only thing we ever do in client code on
> error is immediately burn the world down.

I'd vote for (3), I think.  Making the callers responsible for error
checks just leaves us with a permanent hazard of errors-of-omission,
and as you say, there's really no use-case where we'd be trying to
recover from the error.

I think that the motivation for making the caller do it might've
been an idea that the caller could provide a more useful error
message, but I'm not real sure that that's true --- the caller
doesn't know the physical file's name, and it doesn't necessarily
have the right errno either.

Possibly we could address any loss of usefulness by requiring callers
to pass some sort of context identification to BufFileCreate?

            regards, tom lane



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

Предыдущее
От: Thomas Munro
Дата:
Сообщение: Re: BufFileRead() error signalling
Следующее
От: Andy Fan
Дата:
Сообщение: Re: why doesn't optimizer can pull up where a > ( ... )