pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedtimestamp out of range while casting return value to function's return type
5+ messages / 3 participants
[nested] [flat]
* timestamp out of range while casting return value to function's return type
@ 2019-08-24 00:57 Thiemo Kellner <thiemo@gelassene-pferde.biz>
2019-08-24 01:10 ` Re: timestamp out of range while casting return value to function's return type Tom Lane <tgl@sss.pgh.pa.us>
2019-08-24 10:00 ` Re: timestamp out of range while casting return value to function's return type Karsten Hilbert <Karsten.Hilbert@gmx.net>
0 siblings, 2 replies; 5+ messages in thread
From: Thiemo Kellner @ 2019-08-24 00:57 UTC (permalink / raw)
To: PostgreSQL General <pgsql-general@lists.postgresql.org>
Hi all
I created a function that ought to return a timestamptz (another
likewise timestamp) but calling it, I get mentionied error. What do I
miss? I tried to return a timestamp of the year 2000 to no avail.
Call: select utils.get_max_timestamptz();
--
Function
--
create or replace function GET_MAX_TIMESTAMPTZ()
returns timestamptz
language plpgsql
immutable
-- Include the hosting schema into search_path so that dblink
-- can find the pglogger objects. There is no need to access
-- objects in other schematas not covered with public.
as
$body$
begin
-- highest timestamps on 64bit lubuntu vanilla PostgreSQL 11.3
return '294277-01-01 00:59:59.999999'::timestamptz;
end;
$body$;
Kind regards
Thiemo
--
S/MIME Public Key: https://oc.gelassene-pferde.biz/index.php/s/eJuAUFONag6ofnH
Signal (Safer than WhatsApp): +49 1578 7723737
Handys: +41 78 947 36 21 | +49 1578 772 37 37
Tox-Id:
B7282A9E31D944DDAD1ECC5B33C36AAE80B32D119AB7391D602C937A65E8CA0625C495C5322B
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: timestamp out of range while casting return value to function's return type
2019-08-24 00:57 timestamp out of range while casting return value to function's return type Thiemo Kellner <thiemo@gelassene-pferde.biz>
@ 2019-08-24 01:10 ` Tom Lane <tgl@sss.pgh.pa.us>
2019-08-24 06:53 ` Re: timestamp out of range while casting return value to function's return type Thiemo Kellner <thiemo@gelassene-pferde.biz>
1 sibling, 1 reply; 5+ messages in thread
From: Tom Lane @ 2019-08-24 01:10 UTC (permalink / raw)
To: Thiemo Kellner <thiemo@gelassene-pferde.biz>; +Cc: PostgreSQL General <pgsql-general@lists.postgresql.org>
Thiemo Kellner <thiemo@gelassene-pferde.biz> writes:
> I created a function that ought to return a timestamptz (another
> likewise timestamp) but calling it, I get mentionied error. What do I
> miss?
Whether that:
> return '294277-01-01 00:59:59.999999'::timestamptz;
is in range or not depends on your timezone setting. It would
be considered in-range in UTC+1 or further east (so that the date
wraps back to 294276AD); in or west of Greenwich, not so much.
> I tried to return a timestamp of the year 2000 to no avail.
Hardly ...
regards, tom lane
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: timestamp out of range while casting return value to function's return type
2019-08-24 00:57 timestamp out of range while casting return value to function's return type Thiemo Kellner <thiemo@gelassene-pferde.biz>
2019-08-24 01:10 ` Re: timestamp out of range while casting return value to function's return type Tom Lane <tgl@sss.pgh.pa.us>
@ 2019-08-24 06:53 ` Thiemo Kellner <thiemo@gelassene-pferde.biz>
0 siblings, 0 replies; 5+ messages in thread
From: Thiemo Kellner @ 2019-08-24 06:53 UTC (permalink / raw)
To: PostgreSQL General <pgsql-general@lists.postgresql.org>
Hi Tom
Thanks for replying so fast. You are absolutely right.
I changed the code file but failed to install it. :-( I am sorry for
not checking the obvious.
Kind regards
Thiemo
Quoting Tom Lane <tgl@sss.pgh.pa.us>:
> Thiemo Kellner <thiemo@gelassene-pferde.biz> writes:
>> I created a function that ought to return a timestamptz (another
>> likewise timestamp) but calling it, I get mentionied error. What do I
>> miss?
>
> Whether that:
>
>> return '294277-01-01 00:59:59.999999'::timestamptz;
>
> is in range or not depends on your timezone setting. It would
> be considered in-range in UTC+1 or further east (so that the date
> wraps back to 294276AD); in or west of Greenwich, not so much.
>
>> I tried to return a timestamp of the year 2000 to no avail.
>
> Hardly ...
>
> regards, tom lane
--
S/MIME Public Key: https://oc.gelassene-pferde.biz/index.php/s/eJuAUFONag6ofnH
Signal (Safer than WhatsApp): +49 1578 7723737
Handys: +41 78 947 36 21 | +49 1578 772 37 37
Tox-Id:
B7282A9E31D944DDAD1ECC5B33C36AAE80B32D119AB7391D602C937A65E8CA0625C495C5322B
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: timestamp out of range while casting return value to function's return type
2019-08-24 00:57 timestamp out of range while casting return value to function's return type Thiemo Kellner <thiemo@gelassene-pferde.biz>
@ 2019-08-24 10:00 ` Karsten Hilbert <Karsten.Hilbert@gmx.net>
2019-08-24 10:18 ` Re: timestamp out of range while casting return value to function's return type Thiemo Kellner <thiemo@gelassene-pferde.biz>
1 sibling, 1 reply; 5+ messages in thread
From: Karsten Hilbert @ 2019-08-24 10:00 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On Sat, Aug 24, 2019 at 12:57:07AM +0000, Thiemo Kellner wrote:
> Call: select utils.get_max_timestamptz();
> --
>
> Function
> --
> create or replace function GET_MAX_TIMESTAMPTZ()
> returns timestamptz
> language plpgsql
> immutable
> -- Include the hosting schema into search_path so that dblink
> -- can find the pglogger objects. There is no need to access
> -- objects in other schematas not covered with public.
> as
> $body$
> begin
> -- highest timestamps on 64bit lubuntu vanilla PostgreSQL 11.3
> return '294277-01-01 00:59:59.999999'::timestamptz;
> end;
> $body$;
Also, but that's a nitpick perhaps not relevant to your use case:
This
$> psql -d gnumed_v22 -U <redacted>
psql (11.5 (Debian 11.5-1+deb10u1))
gnumed_v22=> select 'infinity'::timestamptz;
-[ RECORD 1 ]---------
timestamptz | infinity
gnumed_v22=>
is the highest timestamp.
(You *can* count the horses in *your* corral but there's
always more of them elsewhere ;-)
Just so you are aware.
Best,
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: timestamp out of range while casting return value to function's return type
2019-08-24 00:57 timestamp out of range while casting return value to function's return type Thiemo Kellner <thiemo@gelassene-pferde.biz>
2019-08-24 10:00 ` Re: timestamp out of range while casting return value to function's return type Karsten Hilbert <Karsten.Hilbert@gmx.net>
@ 2019-08-24 10:18 ` Thiemo Kellner <thiemo@gelassene-pferde.biz>
0 siblings, 0 replies; 5+ messages in thread
From: Thiemo Kellner @ 2019-08-24 10:18 UTC (permalink / raw)
To: PostgreSQL General <pgsql-general@lists.postgresql.org>
Hi Karsten
Thanks for the infinitly good hint. I remembered the infinity
blurredly somewhen this morning, looked it up in the docs and already
dumped my functions in favour of the infinity solution. :-) Great,
that PostgreSQL has the infinity concept! Thanks
Kind regards
Thiemo
Quoting Karsten Hilbert <Karsten.Hilbert@gmx.net>:
> On Sat, Aug 24, 2019 at 12:57:07AM +0000, Thiemo Kellner wrote:
>
>> Call: select utils.get_max_timestamptz();
>> --
>>
>> Function
>> --
>> create or replace function GET_MAX_TIMESTAMPTZ()
>> returns timestamptz
>> language plpgsql
>> immutable
>> -- Include the hosting schema into search_path so that dblink
>> -- can find the pglogger objects. There is no need to access
>> -- objects in other schematas not covered with public.
>> as
>> $body$
>> begin
>> -- highest timestamps on 64bit lubuntu vanilla PostgreSQL 11.3
>> return '294277-01-01 00:59:59.999999'::timestamptz;
>> end;
>> $body$;
>
> Also, but that's a nitpick perhaps not relevant to your use case:
>
> This
>
> $> psql -d gnumed_v22 -U <redacted>
> psql (11.5 (Debian 11.5-1+deb10u1))
>
> gnumed_v22=> select 'infinity'::timestamptz;
> -[ RECORD 1 ]---------
> timestamptz | infinity
>
> gnumed_v22=>
>
> is the highest timestamp.
>
> (You *can* count the horses in *your* corral but there's
> always more of them elsewhere ;-)
>
> Just so you are aware.
>
> Best,
> Karsten
> --
> GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
--
S/MIME Public Key: https://oc.gelassene-pferde.biz/index.php/s/eJuAUFONag6ofnH
Signal (Safer than WhatsApp): +49 1578 7723737
Handys: +41 78 947 36 21 | +49 1578 772 37 37
Tox-Id:
B7282A9E31D944DDAD1ECC5B33C36AAE80B32D119AB7391D602C937A65E8CA0625C495C5322B
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2019-08-24 10:18 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-08-24 00:57 timestamp out of range while casting return value to function's return type Thiemo Kellner <thiemo@gelassene-pferde.biz>
2019-08-24 01:10 ` Tom Lane <tgl@sss.pgh.pa.us>
2019-08-24 06:53 ` Thiemo Kellner <thiemo@gelassene-pferde.biz>
2019-08-24 10:00 ` Karsten Hilbert <Karsten.Hilbert@gmx.net>
2019-08-24 10:18 ` Thiemo Kellner <thiemo@gelassene-pferde.biz>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox