| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Joe Conway <mail(at)joeconway(dot)com> |
| Cc: | PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org> |
| Subject: | Re: pg_read_file() with virtual files returns empty string |
| Date: | 2020-06-28 22:00:16 |
| Message-ID: | 284570.1593381616@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Joe Conway <mail(at)joeconway(dot)com> writes:
> All good stuff -- I believe the attached checks all the boxes.
Looks okay to me, except I think you want
! if (bytes_to_read > 0)
to be
! if (bytes_to_read >= 0)
As it stands, a zero request will be treated like -1 (read all the
rest of the file) while ISTM it ought to be an expensive way to
read zero bytes --- perhaps useful to check the filename and seek
offset validity?
> The intention here seems to be that if you pass bytes_to_read = -1 with a
> negative offset, it will give you the last offset bytes of the file.
I think it's just trying to convert bytes_to_read = -1 into an explicit
positive length-to-read in all cases. We don't need that anymore with
this code, so dropping it is fine.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andy Fan | 2020-06-29 00:04:35 | Re: Commitfest 2020-07 |
| Previous Message | Tom Lane | 2020-06-28 19:48:04 | Revert workarounds for unportability of printf %.*s format? |