Re: pg_read_file() with virtual files returns empty string

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: pg_read_file() with virtual files returns empty string
Дата
Msg-id 148675.1593287024@sss.pgh.pa.us
обсуждение исходный текст
Ответ на pg_read_file() with virtual files returns empty string  (Joe Conway <mail@joeconway.com>)
Ответы Re: pg_read_file() with virtual files returns empty string  (Joe Conway <mail@joeconway.com>)
Список pgsql-hackers
Joe Conway <mail@joeconway.com> writes:
> The attached patch fixes this for me. I think it ought to be backpatched through
> pg11.

> Comments?

1. Doesn't seem to be accounting for the possibility of an error in fread().

2. Don't we want to remove the stat() call altogether, if we're not
going to believe its length?

3. This bit might need to cast the RHS to int64:
    if (bytes_to_read > (MaxAllocSize - VARHDRSZ))
otherwise it might be treated as an unsigned comparison.
Or you could check for bytes_to_read < 0 separately.

4. appendStringInfoString seems like quite the wrong thing to use
when the input is binary data.

5. Don't like the comment.  Whether the file is virtual or not isn't
very relevant here.

6. If the file size exceeds 1GB, I fear we'll get some rather opaque
failure from the stringinfo infrastructure.  It'd be better to
check for that here and give a file-too-large error.

            regards, tom lane



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

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: Fwd: PostgreSQL: WolfSSL support
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: pg_bsd_indent compiles bytecode