Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd03668e

Browse files
committed
Switch some date/timestamp functions to use the soft error reporting
This commit changes some functions related to the data types date andtimestamp to use the soft error reporting rather than a custom booleanflag called "overflow", used to let the callers of these functions knowif an overflow happens.This results in the removal of some boilerplate code, as it is possibleto rely on an error context rather than a custom state, with thepossibility to use the error generated inside the functions updatedhere, if necessary.These functions were suffixed with "_opt_overflow". They are nowrenamed to use "_safe" as suffix.This work is similar to4246a97.Author: Amul Sul <sulamul@gmail.com>Reviewed-by: Amit Langote <amitlangote09@gmail.com>Reviewed-by: Michael Paquier <michael@paquier.xyz>Discussion:https://postgr.es/m/CAAJ_b95HEmFyzHZfsdPquSHeswcopk8MCG1Q_vn4tVkZ+xxofw@mail.gmail.com
1 parent5424f4d commitd03668e

File tree

3 files changed

+96
-146
lines changed

3 files changed

+96
-146
lines changed

‎contrib/btree_gin/btree_gin.c‎

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include"access/stratnum.h"
99
#include"mb/pg_wchar.h"
10+
#include"nodes/miscnodes.h"
1011
#include"utils/builtins.h"
1112
#include"utils/date.h"
1213
#include"utils/float.h"
@@ -496,10 +497,10 @@ cvt_date_timestamp(Datum input)
496497
{
497498
DateADTval=DatumGetDateADT(input);
498499
Timestampresult;
499-
intoverflow;
500+
ErrorSaveContextescontext= {T_ErrorSaveContext};
500501

501-
result=date2timestamp_opt_overflow(val,&overflow);
502-
/* We can ignorethe overflow result, since result is useful as-is */
502+
result=date2timestamp_safe(val,(Node*)&escontext);
503+
/* We can ignoreerrors, since result is useful as-is */
503504
returnTimestampGetDatum(result);
504505
}
505506

@@ -530,11 +531,11 @@ static Datum
530531
cvt_date_timestamptz(Datuminput)
531532
{
532533
DateADTval=DatumGetDateADT(input);
534+
ErrorSaveContextescontext= {T_ErrorSaveContext};
533535
TimestampTzresult;
534-
intoverflow;
535536

536-
result=date2timestamptz_opt_overflow(val,&overflow);
537-
/* We can ignorethe overflow result, since result is useful as-is */
537+
result=date2timestamptz_safe(val,(Node*)&escontext);
538+
/* We can ignoreerrors, since result is useful as-is */
538539
returnTimestampTzGetDatum(result);
539540
}
540541

@@ -604,23 +605,23 @@ static Datum
604605
cvt_timestamp_date(Datuminput)
605606
{
606607
Timestampval=DatumGetTimestamp(input);
608+
ErrorSaveContextescontext= {T_ErrorSaveContext};
607609
DateADTresult;
608-
intoverflow;
609610

610-
result=timestamp2date_opt_overflow(val,&overflow);
611-
/* We can ignorethe overflow result, since result is useful as-is */
611+
result=timestamp2date_safe(val,(Node*)&escontext);
612+
/* We can ignoreerrors, since result is useful as-is */
612613
returnDateADTGetDatum(result);
613614
}
614615

615616
staticDatum
616617
cvt_timestamptz_date(Datuminput)
617618
{
618619
TimestampTzval=DatumGetTimestampTz(input);
620+
ErrorSaveContextescontext= {T_ErrorSaveContext};
619621
DateADTresult;
620-
intoverflow;
621622

622-
result=timestamptz2date_opt_overflow(val,&overflow);
623-
/* We can ignorethe overflow result, since result is useful as-is */
623+
result=timestamptz2date_safe(val,(Node*)&escontext);
624+
/* We can ignoreerrors, since result is useful as-is */
624625
returnDateADTGetDatum(result);
625626
}
626627

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp