Re: Available disk space per tablespace

From: Christoph Berg <myon(at)debian(dot)org>
To: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, solai v <solai(dot)cdac(at)gmail(dot)com>, Rafia Sabih <rafia(dot)pghackers(at)gmail(dot)com>
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-07-21 13:09:41
Message-ID: al9vlU6MqdO2GNu5@msg.df7cb.de
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Zolt, Solai, Rafia,

thanks for the reviews!

Re: Zsolt Parragi
> 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.

> typo, should be WHERE

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

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

All fixed.

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

Thanks for catching that, also fixed!

Re: solai v
> Overall , the feature looks useful and worked well in my testing.

Thanks!

Re: Rafia Sabih
> > I looked into this patch and here are my two cents, the change in
> describe.c is in if (pset.sversion >= 190000), I think it should be
> pset.sversion >= 200000 now, isn't it...?

Yeah, PG 20 didn't exist yet when I wrote it. Updated now, thanks!

> Also, the first part of calculate_tablespace_avail and
> calculate_tablespace_size are the same, would it make sense to have a
> separate routine to have the acl check...?

We could merge the two functions into one and then add an if block for
the main function part, but I think it would make it messy.

The common part is the acl check plus the setup of the tblspcPath
variable, so we'd probably need two extra functions, but they would be
very small. I think we should leave it like it is now, but I'm open to
ideas of course.

v6 attached.

Christoph

Attachment Content-Type Size
v6-0001-Add-pg_tablespace_avail-functions.patch text/x-diff 12.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jonathan Gonzalez V. 2026-07-21 13:21:19 Re: [PATCH] Cover get_json_table_plan() with tests
Previous Message Alvaro Herrera 2026-07-21 13:07:33 Re: log_min_messages per backend type