Re: Available disk space per tablespace - Mailing list pgsql-hackers

From Zsolt Parragi
Subject Re: Available disk space per tablespace
Date
Msg-id CAN4CZFMOx6EHxd-=RiZukBL7oaV0vd9TSRDs8TN8WD_8Cx2R0A@mail.gmail.com
Whole thread
In response to Re: Available disk space per tablespace  (Christoph Berg <myon@debian.org>)
List pgsql-hackers
Hello!

#ifdef WIN32
+ if (! GetDiskFreeSpaceEx(tblspcPath, &lpFreeBytesAvailable, NULL, NULL))
+ elog(ERROR, "GetDiskFreeSpaceEx failed: error code %lu", GetLastError());
+
+ return lpFreeBytesAvailable.QuadPart; /* ULONGLONG part of ULARGE_INTEGER */
+#else

Shouldn't this use proper error codes similar to the else branch, and
also _dosmaperr?

There's also a behavior difference here compared to Linux, it returns
-1 on ENOENT, the Windows version errors out on the matching
condition.


+ "  wHERE db.datname OPERATOR(pg_catalog.=)
pg_catalog.current_database()) dbsub\n");

typo, should be WHERE


+ (errcode_for_file_access(),
+ errmsg("could not statvfs directory \"%s\": %m", tblspcPath)));

Is this error message user friendly? Wouldn't be something like "could
not get free disk space for directory" be better?


+        Returns the available disk space in the tablespace with the
+        specified name or OID.

Does the tablespace have a disk space? Maybe "returns the space on the
filesystem hosting the tablespace"?

+ return fst.f_bavail * fst.f_frsize; /* available blocks times fragment size */

> There is some code that does int width expansion, but I believe we
> don't need that since the `fst.f_bavail * fst.f_frsize` multiplication
> takes care of converting that to int64 (if it wasn't already 64bits
> before).

I don't think this is the case, we first multiply and then cast.
Multiplication still happens with 32 bit types.

Relevant parts on Godbolt: https://godbolt.org/z/7dj7crf6K



pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: [PATCH] Fix ProcKill lock-group vs procLatch recycle race
Next
From: Michael Paquier
Date:
Subject: Re: Fix DROP PROPERTY GRAPH "unsupported object class" error