From: Peter Geoghegan Date: Thu, 13 Mar 2014 05:34:59 +0000 (-0700) Subject: Remove dead code X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=918647a1ea069613d9f795448e3ecaea697ae37d;p=users%2Fandresfreund%2Fpostgres.git Remove dead code gconv shows that the jbvBinary switch case within putStringConversion() to be dead code. This is unsurprising, as this is not one of the contexts in which a scalar can be a binary. --- diff --git a/src/backend/utils/adt/jsonb_support.c b/src/backend/utils/adt/jsonb_support.c index 0ad27ca49b..a791369522 100644 --- a/src/backend/utils/adt/jsonb_support.c +++ b/src/backend/utils/adt/jsonb_support.c @@ -284,8 +284,8 @@ compareJsonbSuperHeaderValue(JsonbSuperHeader a, JsonbSuperHeader b) * findJsonbValueFromSuperHeader() wrapper that sets up JsonbValue key. */ JsonbValue * -findJsonbValueFromSuperHeaderLen(JsonbSuperHeader sheader, uint32 flags, uint32 *lowbound, - char *key, uint32 keylen) +findJsonbValueFromSuperHeaderLen(JsonbSuperHeader sheader, uint32 flags, + uint32 *lowbound, char *key, uint32 keylen) { JsonbValue v; @@ -314,7 +314,7 @@ findJsonbValueFromSuperHeader(JsonbSuperHeader sheader, uint32 flags, { uint32 superheader = *(uint32 *) sheader; JEntry *array = (JEntry *) (sheader + sizeof(uint32)); - JsonbValue *r = palloc(sizeof(JsonbValue)); + JsonbValue *r = palloc(sizeof(JsonbValue)); Assert((superheader & (JB_FLAG_ARRAY | JB_FLAG_OBJECT)) != (JB_FLAG_ARRAY | JB_FLAG_OBJECT)); @@ -1048,7 +1048,7 @@ putJsonbValueConversion(ConvertState * state, JsonbValue * value, uint32 flags, /* * As part of the process of converting an arbitrary JsonbValue to a Jsonb, - * copy a string. + * copy a string associated with a scalar value. * * This is a worker function for putJsonbValueConversion() (itself a worker for * walkJsonbValueConversion()), handling aspects of copying strings in respect @@ -1124,33 +1124,6 @@ putStringConversion(ConvertState * state, JsonbValue * value, padlen + numlen; break; } - case jbvBinary: - { - padlen = INTALIGN(state->ptr - VARDATA(state->buffer)) - - (state->ptr - VARDATA(state->buffer)); - - /* - * Add padding as necessary - */ - for (p = padlen; p > 0; p--) - { - *state->ptr = '\0'; - state->ptr++; - } - - memcpy(state->ptr, value->binary.data, value->binary.len); - state->ptr += value->binary.len; - - state->curlptr->meta[i].header |= JENTRY_ISNEST; - - if (i == 0) - state->curlptr->meta[i].header |= value->binary.len + padlen; - else - state->curlptr->meta[i].header |= - (state->curlptr->meta[i - 1].header & JENTRY_POSMASK) + - value->binary.len + padlen; - } - break; default: elog(ERROR, "invalid jsonb scalar type"); } diff --git a/src/include/utils/jsonb.h b/src/include/utils/jsonb.h index 0ec2ef67a6..7d55adf3ec 100644 --- a/src/include/utils/jsonb.h +++ b/src/include/utils/jsonb.h @@ -40,6 +40,7 @@ #define JB_ROOT_IS_ARRAY(jbp_) (JB_ISEMPTY(jbp_) ? 0 : ( *(uint32*)VARDATA(jbp_) & JB_FLAG_ARRAY)) #define JB_ROOT_IS_SCALAR(jbp_) (JB_ISEMPTY(jbp_) ? 0 : ( *(uint32*)VARDATA(jbp_) & JB_FLAG_SCALAR)) +/* Flags indicate a stage of sequential Jsonb processing */ #define WJB_KEY (0x001) #define WJB_VALUE (0x002) #define WJB_ELEM (0x004)