From fbb2e9a030ee7a3fa20ce402e4b1da9809b4eb52 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 2 May 2018 15:52:54 -0400 Subject: Fix assorted compiler warnings seen in the buildfarm. Failure to use DatumGetFoo/FooGetDatum macros correctly, or at all, causes some warnings about sign conversion. This is just cosmetic at the moment but in principle it's a type violation, so clean up the instances I could find. autoprewarm.c and sharedfileset.c contained code that unportably assumed that pid_t is the same size as int. We've variously dealt with this by casting pid_t to int or to unsigned long for printing purposes; I went with the latter. Fix uninitialized-variable warning in RestoreGUCState. This is a live bug in some sense, but of no great significance given that nobody is very likely to care what "line number" is associated with a GUC that hasn't got a source file recorded. --- src/backend/utils/adt/jsonb.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/backend/utils/adt/jsonb.c') diff --git a/src/backend/utils/adt/jsonb.c b/src/backend/utils/adt/jsonb.c index e99bbc482a9..9d2b89f90cf 100644 --- a/src/backend/utils/adt/jsonb.c +++ b/src/backend/utils/adt/jsonb.c @@ -343,6 +343,7 @@ jsonb_in_scalar(void *pstate, char *token, JsonTokenType tokentype) { JsonbInState *_state = (JsonbInState *) pstate; JsonbValue v; + Datum numd; switch (tokentype) { @@ -361,18 +362,19 @@ jsonb_in_scalar(void *pstate, char *token, JsonTokenType tokentype) */ Assert(token != NULL); v.type = jbvNumeric; - v.val.numeric = DatumGetNumeric(DirectFunctionCall3(numeric_in, CStringGetDatum(token), 0, -1)); - + numd = DirectFunctionCall3(numeric_in, + CStringGetDatum(token), + ObjectIdGetDatum(InvalidOid), + Int32GetDatum(-1)); + v.val.numeric = DatumGetNumeric(numd); break; case JSON_TOKEN_TRUE: v.type = jbvBool; v.val.boolean = true; - break; case JSON_TOKEN_FALSE: v.type = jbvBool; v.val.boolean = false; - break; case JSON_TOKEN_NULL: v.type = jbvNull; @@ -772,9 +774,14 @@ datum_to_jsonb(Datum val, bool is_null, JsonbInState *result, strchr(outputstr, 'n') != NULL); if (!numeric_error) { - jb.type = jbvNumeric; - jb.val.numeric = DatumGetNumeric(DirectFunctionCall3(numeric_in, CStringGetDatum(outputstr), 0, -1)); + Datum numd; + jb.type = jbvNumeric; + numd = DirectFunctionCall3(numeric_in, + CStringGetDatum(outputstr), + ObjectIdGetDatum(InvalidOid), + Int32GetDatum(-1)); + jb.val.numeric = DatumGetNumeric(numd); pfree(outputstr); } else -- cgit v1.2.3