@@ -3972,8 +3972,8 @@ timestamp_trunc(PG_FUNCTION_ARGS)
3972
3972
default :
3973
3973
ereport (ERROR ,
3974
3974
(errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
3975
- errmsg ("timestamp units \"%s\" not supported" ,
3976
- lowunits )));
3975
+ errmsg ("unit \"%s\" not supported for type %s " ,
3976
+ lowunits , format_type_be ( TIMESTAMPOID ) )));
3977
3977
result = 0 ;
3978
3978
}
3979
3979
@@ -3986,8 +3986,8 @@ timestamp_trunc(PG_FUNCTION_ARGS)
3986
3986
{
3987
3987
ereport (ERROR ,
3988
3988
(errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
3989
- errmsg ("timestamp units \"%s\" not recognized" ,
3990
- lowunits )));
3989
+ errmsg ("unit \"%s\" not recognized for type %s " ,
3990
+ lowunits , format_type_be ( TIMESTAMPOID ) )));
3991
3991
result = 0 ;
3992
3992
}
3993
3993
@@ -4165,8 +4165,8 @@ timestamptz_trunc_internal(text *units, TimestampTz timestamp, pg_tz *tzp)
4165
4165
default :
4166
4166
ereport (ERROR ,
4167
4167
(errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
4168
- errmsg ("timestamp with time zone units \"%s\" not "
4169
- "supported" , lowunits )));
4168
+ errmsg ("unit \"%s\" not supported for type %s" ,
4169
+ lowunits , format_type_be ( TIMESTAMPTZOID ) )));
4170
4170
result = 0 ;
4171
4171
}
4172
4172
@@ -4182,8 +4182,8 @@ timestamptz_trunc_internal(text *units, TimestampTz timestamp, pg_tz *tzp)
4182
4182
{
4183
4183
ereport (ERROR ,
4184
4184
(errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
4185
- errmsg ("timestamp with time zone units \"%s\" not recognized" ,
4186
- lowunits )));
4185
+ errmsg ("unit \"%s\" not recognized for type %s " ,
4186
+ lowunits , format_type_be ( TIMESTAMPTZOID ) )));
4187
4187
result = 0 ;
4188
4188
}
4189
4189
@@ -4337,17 +4337,11 @@ interval_trunc(PG_FUNCTION_ARGS)
4337
4337
break ;
4338
4338
4339
4339
default :
4340
- if (val == DTK_WEEK )
4341
- ereport (ERROR ,
4342
- (errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
4343
- errmsg ("interval units \"%s\" not supported "
4344
- "because months usually have fractional weeks" ,
4345
- lowunits )));
4346
- else
4347
- ereport (ERROR ,
4348
- (errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
4349
- errmsg ("interval units \"%s\" not supported" ,
4350
- lowunits )));
4340
+ ereport (ERROR ,
4341
+ (errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
4342
+ errmsg ("unit \"%s\" not supported for type %s" ,
4343
+ lowunits , format_type_be (INTERVALOID )),
4344
+ (val == DTK_WEEK ) ? errdetail ("Months usually have fractional weeks." ) : 0 ));
4351
4345
}
4352
4346
4353
4347
if (tm2interval (tm , fsec , result ) != 0 )
@@ -4362,8 +4356,8 @@ interval_trunc(PG_FUNCTION_ARGS)
4362
4356
{
4363
4357
ereport (ERROR ,
4364
4358
(errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
4365
- errmsg ("interval units \"%s\" not recognized" ,
4366
- lowunits )));
4359
+ errmsg ("unit \"%s\" not recognized for type %s " ,
4360
+ lowunits , format_type_be ( INTERVALOID ) )));
4367
4361
}
4368
4362
4369
4363
PG_RETURN_INTERVAL_P (result );
@@ -4559,18 +4553,11 @@ NonFiniteTimestampTzPart(int type, int unit, char *lowunits,
4559
4553
bool isNegative , bool isTz )
4560
4554
{
4561
4555
if ((type != UNITS ) && (type != RESERV ))
4562
- {
4563
- if (isTz )
4564
- ereport (ERROR ,
4565
- (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
4566
- errmsg ("timestamp with time zone units \"%s\" not recognized" ,
4567
- lowunits )));
4568
- else
4569
- ereport (ERROR ,
4570
- (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
4571
- errmsg ("timestamp units \"%s\" not recognized" ,
4572
- lowunits )));
4573
- }
4556
+ ereport (ERROR ,
4557
+ (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
4558
+ errmsg ("unit \"%s\" not recognized for type %s" ,
4559
+ lowunits ,
4560
+ format_type_be (isTz ? TIMESTAMPTZOID : TIMESTAMPOID ))));
4574
4561
4575
4562
switch (unit )
4576
4563
{
@@ -4606,16 +4593,11 @@ NonFiniteTimestampTzPart(int type, int unit, char *lowunits,
4606
4593
return get_float8_infinity ();
4607
4594
4608
4595
default :
4609
- if (isTz )
4610
- ereport (ERROR ,
4611
- (errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
4612
- errmsg ("timestamp with time zone units \"%s\" not supported" ,
4613
- lowunits )));
4614
- else
4615
- ereport (ERROR ,
4616
- (errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
4617
- errmsg ("timestamp units \"%s\" not supported" ,
4618
- lowunits )));
4596
+ ereport (ERROR ,
4597
+ (errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
4598
+ errmsg ("unit \"%s\" not supported for type %s" ,
4599
+ lowunits ,
4600
+ format_type_be (isTz ? TIMESTAMPTZOID : TIMESTAMPOID ))));
4619
4601
return 0.0 ; /* keep compiler quiet */
4620
4602
}
4621
4603
}
@@ -4814,8 +4796,8 @@ timestamp_part_common(PG_FUNCTION_ARGS, bool retnumeric)
4814
4796
default :
4815
4797
ereport (ERROR ,
4816
4798
(errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
4817
- errmsg ("timestamp units \"%s\" not supported" ,
4818
- lowunits )));
4799
+ errmsg ("unit \"%s\" not supported for type %s " ,
4800
+ lowunits , format_type_be ( TIMESTAMPOID ) )));
4819
4801
intresult = 0 ;
4820
4802
}
4821
4803
}
@@ -4861,8 +4843,8 @@ timestamp_part_common(PG_FUNCTION_ARGS, bool retnumeric)
4861
4843
default :
4862
4844
ereport (ERROR ,
4863
4845
(errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
4864
- errmsg ("timestamp units \"%s\" not supported" ,
4865
- lowunits )));
4846
+ errmsg ("unit \"%s\" not supported for type %s " ,
4847
+ lowunits , format_type_be ( TIMESTAMPOID ) )));
4866
4848
intresult = 0 ;
4867
4849
}
4868
4850
@@ -4871,7 +4853,8 @@ timestamp_part_common(PG_FUNCTION_ARGS, bool retnumeric)
4871
4853
{
4872
4854
ereport (ERROR ,
4873
4855
(errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
4874
- errmsg ("timestamp units \"%s\" not recognized" , lowunits )));
4856
+ errmsg ("unit \"%s\" not recognized for type %s" ,
4857
+ lowunits , format_type_be (TIMESTAMPOID ))));
4875
4858
intresult = 0 ;
4876
4859
}
4877
4860
@@ -5085,8 +5068,8 @@ timestamptz_part_common(PG_FUNCTION_ARGS, bool retnumeric)
5085
5068
default :
5086
5069
ereport (ERROR ,
5087
5070
(errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
5088
- errmsg ("timestamp with time zone units \"%s\" not supported" ,
5089
- lowunits )));
5071
+ errmsg ("unit \"%s\" not supported for type %s " ,
5072
+ lowunits , format_type_be ( TIMESTAMPTZOID ) )));
5090
5073
intresult = 0 ;
5091
5074
}
5092
5075
@@ -5133,17 +5116,17 @@ timestamptz_part_common(PG_FUNCTION_ARGS, bool retnumeric)
5133
5116
default :
5134
5117
ereport (ERROR ,
5135
5118
(errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
5136
- errmsg ("timestamp with time zone units \"%s\" not supported" ,
5137
- lowunits )));
5119
+ errmsg ("unit \"%s\" not supported for type %s " ,
5120
+ lowunits , format_type_be ( TIMESTAMPTZOID ) )));
5138
5121
intresult = 0 ;
5139
5122
}
5140
5123
}
5141
5124
else
5142
5125
{
5143
5126
ereport (ERROR ,
5144
5127
(errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
5145
- errmsg ("timestamp with time zone units \"%s\" not recognized" ,
5146
- lowunits )));
5128
+ errmsg ("unit \"%s\" not recognized for type %s " ,
5129
+ lowunits , format_type_be ( TIMESTAMPTZOID ) )));
5147
5130
5148
5131
intresult = 0 ;
5149
5132
}
@@ -5265,8 +5248,8 @@ interval_part_common(PG_FUNCTION_ARGS, bool retnumeric)
5265
5248
default :
5266
5249
ereport (ERROR ,
5267
5250
(errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
5268
- errmsg ("interval units \"%s\" not supported" ,
5269
- lowunits )));
5251
+ errmsg ("unit \"%s\" not supported for type %s " ,
5252
+ lowunits , format_type_be ( INTERVALOID ) )));
5270
5253
intresult = 0 ;
5271
5254
}
5272
5255
}
@@ -5326,8 +5309,8 @@ interval_part_common(PG_FUNCTION_ARGS, bool retnumeric)
5326
5309
{
5327
5310
ereport (ERROR ,
5328
5311
(errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
5329
- errmsg ("interval units \"%s\" not recognized" ,
5330
- lowunits )));
5312
+ errmsg ("unit \"%s\" not recognized for type %s " ,
5313
+ lowunits , format_type_be ( INTERVALOID ) )));
5331
5314
intresult = 0 ;
5332
5315
}
5333
5316
0 commit comments