Re: custom function for converting human readable sizes to bytes - Mailing list pgsql-hackers

From Shulgin, Oleksandr
Subject Re: custom function for converting human readable sizes to bytes
Date
Msg-id CACACo5QOb6mtw1WGjaSXkuC8KnaEELJVR=cy-0eSeJ+r3VVjhQ@mail.gmail.com
Whole thread Raw
In response to Re: custom function for converting human readable sizes to bytes  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: custom function for converting human readable sizes to bytes  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
On Mon, Jan 4, 2016 at 6:14 PM, Robert Haas <robertmhaas@gmail.com> wrote:
On Mon, Jan 4, 2016 at 11:48 AM, Shulgin, Oleksandr
>
> postgres=# select pg_size_bytes('');
> ERROR:  invalid input syntax for type numeric: ""

I think that's a pretty bad error message.  I mean, the user is
calling a function that takes text as an input data type.  So, where's
numeric involved?

Is there a way to force CONTEXT output in the reported error?  I guess that could help.

I'm also kind of wondering what the intended use case for this
function is.  Why do we want it?  Do we want it?

As suggested above a usecase could be like the following:

SELECT relname FROM pg_class WHERE pg_relation_size(oid) > pg_size_bytes('100 GB');

I think it's neat and useful.

--
Alex

pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Some 9.5beta2 backend processes not terminating properly?
Next
From: Alvaro Herrera
Date:
Subject: Re: Additional role attributes && superuser review