| From: | Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com> |
|---|---|
| To: | Christoph Berg <myon(at)debian(dot)org> |
| Cc: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Quan Zongliang <quanzongliang(at)yeah(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Available disk space per tablespace |
| Date: | 2026-05-06 22:59:21 |
| Message-ID: | CAN4CZFMOx6EHxd-=RiZukBL7oaV0vd9TSRDs8TN8WD_8Cx2R0A@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Paquier | 2026-05-06 23:22:49 | Re: Fix DROP PROPERTY GRAPH "unsupported object class" error |
| Previous Message | Michael Paquier | 2026-05-06 22:54:58 | Re: [PATCH] Fix ProcKill lock-group vs procLatch recycle race |