Re: stat() on Windows might cause error if target file is larger than 4GB - Mailing list pgsql-hackers

From Tom Lane
Subject Re: stat() on Windows might cause error if target file is larger than 4GB
Date
Msg-id 8019.1536957986@sss.pgh.pa.us
Whole thread Raw
In response to Re: stat() on Windows might cause error if target file is larger than 4GB  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes:
> I do not think that using #define to play clever tricks like this can
> reasonably be classified as non-invasive.  Non-invasive doesn't mean
> it touches a small number of lines; it means it's unlikely to break
> stuff.  Otherwise,
> #define continue break
> would qualify as non-invasive.

This argument would hold more water if it weren't that "stat" is already
a macro in our Windows port:

#ifndef UNSAFE_STAT_OK
extern int    pgwin32_safestat(const char *path, struct stat *buf);
#define stat(a,b) pgwin32_safestat(a,b)
#endif

Admittedly, a macro with params will fire in fewer places than one
without, but claiming that the current situation is entirely surprise-free
seems wrong.

I also think that you're underestimating the value of continuing to spell
"struct stat" in the standard way.  People know what that is, if they've
done any Unix programming before, whereas "pg_struct_stat" requires some
learning.

More, I can just about guarantee that even if we make the substitution
today, new occurrences of "struct stat" will sneak in via patches, because
not everybody will remember this PG-ism all the time.  Yeah, probably the
buildfarm will find those mistakes, but maybe not quickly or reliably ---
I think it'd only show up as a warning not an error, which isn't going to
be something we'd notice easily.

So I'm not buying that "#define stat" is so evil it should be rejected
out of hand.  It may be that it doesn't work for some reason, but we
should at least test it.

            regards, tom lane


pgsql-hackers by date:

Previous
From: Jeremy Finzel
Date:
Subject: Re: Delta Materialized View Refreshes?
Next
From: Isaac Morland
Date:
Subject: Re: Delta Materialized View Refreshes?