On 2024-04-06 Sa 20:49, Andres Freund wrote:

That's probably unnecessary optimization, but it seems a tad silly to read an
entire, potentially sizable, file to just use the last 1k. Not sure if the way
slurp_file() uses seek supports negative ofsets, the docs read to me like that
may only be supported with SEEK_END.


We should enhance slurp_file() so it uses SEEK_END if the offset is negative. It would be a trivial patch:


diff --git a/src/test/perl/PostgreSQL/Test/Utils.pm 
b/src/test/perl/PostgreSQL/Test/Utils.pm
index 42d5a50dc8..8256573957 100644
--- a/src/test/perl/PostgreSQL/Test/Utils.pm
+++ b/src/test/perl/PostgreSQL/Test/Utils.pm
@@ -524,7 +524,7 @@ sub slurp_file
    if (defined($offset))
    {
-       seek($fh, $offset, SEEK_SET)
+       seek($fh, $offset, ($offset < 0 ? SEEK_END : SEEK_SET))
          or croak "could not seek \"$filename\": $!";
    }

cheers


andrew


cheers


andrew

--
Andrew Dunstan
EDB:https://www.enterprisedb.com

Reply via email to