This is an automated email from the ASF dual-hosted git repository.
dehowef pushed a commit to branch PG13
in repository https://gitbox.apache.org/repos/asf/age.git
The following commit(s) were added to refs/heads/PG13 by this push:
new 64272636 Fix DockerHub warning messages for PG13_latest (#1379)
64272636 is described below
commit 6427263692ecfaef2301f6e2600b0f0acdb5d2e1
Author: John Gemignani <[email protected]>
AuthorDate: Tue Nov 7 15:17:19 2023 -0800
Fix DockerHub warning messages for PG13_latest (#1379)
Fixed DockerHub warning messages for float conversions and
PG_RETURN_NULL() usage.
This PR is just for PG13.
---
src/backend/utils/adt/agtype.c | 72 ++++++++++++++++++++++++++++++++++++------
1 file changed, 62 insertions(+), 10 deletions(-)
diff --git a/src/backend/utils/adt/agtype.c b/src/backend/utils/adt/agtype.c
index a569a897..3e21ca9f 100644
--- a/src/backend/utils/adt/agtype.c
+++ b/src/backend/utils/adt/agtype.c
@@ -2368,7 +2368,9 @@ static agtype_value*
agtype_build_map_as_agtype_value(FunctionCallInfo fcinfo)
nargs = extract_variadic_args(fcinfo, 0, true, &args, &types, &nulls);
if (nargs < 0)
- PG_RETURN_NULL();
+ {
+ return NULL;
+ }
if (nargs % 2 != 0)
{
@@ -2411,7 +2413,13 @@ PG_FUNCTION_INFO_V1(agtype_build_map);
*/
Datum agtype_build_map(PG_FUNCTION_ARGS)
{
- agtype_value *result= agtype_build_map_as_agtype_value(fcinfo);
+ agtype_value *result = agtype_build_map_as_agtype_value(fcinfo);
+
+ if (result == NULL)
+ {
+ PG_RETURN_NULL();
+ }
+
PG_RETURN_POINTER(agtype_value_to_agtype(result));
}
@@ -2439,7 +2447,13 @@ PG_FUNCTION_INFO_V1(agtype_build_map_nonull);
*/
Datum agtype_build_map_nonull(PG_FUNCTION_ARGS)
{
- agtype_value *result= agtype_build_map_as_agtype_value(fcinfo);
+ agtype_value *result = agtype_build_map_as_agtype_value(fcinfo);
+
+ if (result == NULL)
+ {
+ PG_RETURN_NULL();
+ }
+
remove_null_from_agtype_object(result);
PG_RETURN_POINTER(agtype_value_to_agtype(result));
}
@@ -5768,12 +5782,16 @@ Datum age_tointeger(PG_FUNCTION_ARGS)
/* check number of args */
if (nargs > 1)
+ {
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("toInteger() only supports one argument")));
+ }
/* check for null */
if (nargs < 0 || nulls[0])
+ {
PG_RETURN_NULL();
+ }
/*
* toInteger() supports integer, float, numeric, text, cstring, or the
@@ -5785,18 +5803,26 @@ Datum age_tointeger(PG_FUNCTION_ARGS)
if (type != AGTYPEOID)
{
if (type == INT2OID)
+ {
result = (int64) DatumGetInt16(arg);
+ }
else if (type == INT4OID)
+ {
result = (int64) DatumGetInt32(arg);
+ }
else if (type == INT8OID)
+ {
result = (int64) DatumGetInt64(arg);
+ }
else if (type == FLOAT4OID)
{
float4 f = DatumGetFloat4(arg);
if (isnan(f) || isinf(f) ||
- f < PG_INT64_MIN || f > PG_INT64_MAX)
+ f < (float4)PG_INT64_MIN || f > (float4)PG_INT64_MAX)
+ {
PG_RETURN_NULL();
+ }
result = (int64) f;
}
@@ -5805,8 +5831,10 @@ Datum age_tointeger(PG_FUNCTION_ARGS)
float8 f = DatumGetFloat8(arg);
if (isnan(f) || isinf(f) ||
- f < PG_INT64_MIN || f > PG_INT64_MAX)
+ f < (float8)PG_INT64_MIN || f > (float8)PG_INT64_MAX)
+ {
PG_RETURN_NULL();
+ }
result = (int64) f;
}
@@ -5818,17 +5846,23 @@ Datum age_tointeger(PG_FUNCTION_ARGS)
numeric_float8_no_overflow, arg));
if (isnan(f) || isinf(f) ||
- f < PG_INT64_MIN || f > PG_INT64_MAX)
+ f < (float8)PG_INT64_MIN || f > (float8)PG_INT64_MAX)
+ {
PG_RETURN_NULL();
+ }
result = (int64) f;
}
else if (type == CSTRINGOID || type == TEXTOID)
{
if (type == CSTRINGOID)
+ {
string = DatumGetCString(arg);
+ }
else
+ {
string = text_to_cstring(DatumGetTextPP(arg));
+ }
/* convert it if it is a regular integer string */
is_valid = scanint8(string, true, &result);
@@ -5847,16 +5881,20 @@ Datum age_tointeger(PG_FUNCTION_ARGS)
* return null.
*/
if (!is_valid || isnan(f) || isinf(f) ||
- f < PG_INT64_MIN || f > PG_INT64_MAX)
+ f < (float)PG_INT64_MIN || f > (float)PG_INT64_MAX)
+ {
PG_RETURN_NULL();
+ }
result = (int64) f;
}
}
else
+ {
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("toInteger() unsupported argument type %d",
type)));
+ }
}
else
{
@@ -5867,20 +5905,26 @@ Datum age_tointeger(PG_FUNCTION_ARGS)
agt_arg = DATUM_GET_AGTYPE_P(arg);
if (!AGT_ROOT_IS_SCALAR(agt_arg))
+ {
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("toInteger() only supports scalar
arguments")));
+ }
agtv_value = get_ith_agtype_value_from_container(&agt_arg->root, 0);
if (agtv_value->type == AGTV_INTEGER)
+ {
result = agtv_value->val.int_value;
+ }
else if (agtv_value->type == AGTV_FLOAT)
{
float f = agtv_value->val.float_value;
if (isnan(f) || isinf(f) ||
- f < PG_INT64_MIN || f > PG_INT64_MAX)
+ f < (float)PG_INT64_MIN || f > (float)PG_INT64_MAX)
+ {
PG_RETURN_NULL();
+ }
result = (int64) f;
}
@@ -5893,8 +5937,10 @@ Datum age_tointeger(PG_FUNCTION_ARGS)
numeric_float8_no_overflow, num));
if (isnan(f) || isinf(f) ||
- f < PG_INT64_MIN || f > PG_INT64_MAX)
+ f < (float8)PG_INT64_MIN || f > (float8)PG_INT64_MAX)
+ {
PG_RETURN_NULL();
+ }
result = (int64) f;
}
@@ -5921,18 +5967,24 @@ Datum age_tointeger(PG_FUNCTION_ARGS)
* return null.
*/
if (!is_valid || isnan(f) || isinf(f) ||
- f < PG_INT64_MIN || f > PG_INT64_MAX)
+ f < (float)PG_INT64_MIN || f > (float)PG_INT64_MAX)
+ {
PG_RETURN_NULL();
+ }
result = (int64) f;
}
else
+ {
free(string);
+ }
}
else
+ {
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("toInteger() unsupported argument agtype
%d",
agtv_value->type)));
+ }
}
/* build the result */