diff options
Diffstat (limited to 'src/backend/utils/adt')
-rw-r--r-- | src/backend/utils/adt/arrayfuncs.c | 3 | ||||
-rw-r--r-- | src/backend/utils/adt/dbsize.c | 10 | ||||
-rw-r--r-- | src/backend/utils/adt/formatting.c | 16 | ||||
-rw-r--r-- | src/backend/utils/adt/json.c | 25 | ||||
-rw-r--r-- | src/backend/utils/adt/jsonb.c | 12 | ||||
-rw-r--r-- | src/backend/utils/adt/jsonb_util.c | 3 | ||||
-rw-r--r-- | src/backend/utils/adt/jsonfuncs.c | 7 | ||||
-rw-r--r-- | src/backend/utils/adt/jsonpath.c | 10 | ||||
-rw-r--r-- | src/backend/utils/adt/jsonpath_exec.c | 36 | ||||
-rw-r--r-- | src/backend/utils/adt/like.c | 4 | ||||
-rw-r--r-- | src/backend/utils/adt/multirangetypes.c | 3 | ||||
-rw-r--r-- | src/backend/utils/adt/numeric.c | 215 | ||||
-rw-r--r-- | src/backend/utils/adt/pg_locale.c | 4 | ||||
-rw-r--r-- | src/backend/utils/adt/pgstatfuncs.c | 2 | ||||
-rw-r--r-- | src/backend/utils/adt/rangetypes_spgist.c | 4 | ||||
-rw-r--r-- | src/backend/utils/adt/ri_triggers.c | 27 | ||||
-rw-r--r-- | src/backend/utils/adt/ruleutils.c | 50 | ||||
-rw-r--r-- | src/backend/utils/adt/selfuncs.c | 12 | ||||
-rw-r--r-- | src/backend/utils/adt/timestamp.c | 227 | ||||
-rw-r--r-- | src/backend/utils/adt/uuid.c | 4 | ||||
-rw-r--r-- | src/backend/utils/adt/varchar.c | 4 | ||||
-rw-r--r-- | src/backend/utils/adt/varlena.c | 8 |
22 files changed, 354 insertions, 332 deletions
diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c index 78e951a6bca..2570e5e6301 100644 --- a/src/backend/utils/adt/arrayfuncs.c +++ b/src/backend/utils/adt/arrayfuncs.c @@ -3996,7 +3996,8 @@ hash_array(PG_FUNCTION_ARGS) /* * Make fake type cache entry structure. Note that we can't just - * modify typentry, since that points directly into the type cache. + * modify typentry, since that points directly into the type + * cache. */ record_typentry = palloc0(sizeof(*record_typentry)); record_typentry->type_id = element_type; diff --git a/src/backend/utils/adt/dbsize.c b/src/backend/utils/adt/dbsize.c index 0576764ac4b..b4a2c8d2197 100644 --- a/src/backend/utils/adt/dbsize.c +++ b/src/backend/utils/adt/dbsize.c @@ -112,8 +112,8 @@ calculate_database_size(Oid dbOid) AclResult aclresult; /* - * User must have connect privilege for target database or have privileges of - * pg_read_all_stats + * User must have connect privilege for target database or have privileges + * of pg_read_all_stats */ aclresult = pg_database_aclcheck(dbOid, GetUserId(), ACL_CONNECT); if (aclresult != ACLCHECK_OK && @@ -196,9 +196,9 @@ calculate_tablespace_size(Oid tblspcOid) AclResult aclresult; /* - * User must have privileges of pg_read_all_stats or have CREATE privilege for - * target tablespace, either explicitly granted or implicitly because it - * is default for current database. + * User must have privileges of pg_read_all_stats or have CREATE privilege + * for target tablespace, either explicitly granted or implicitly because + * it is default for current database. */ if (tblspcOid != MyDatabaseTableSpace && !has_privs_of_role(GetUserId(), ROLE_PG_READ_ALL_STATS)) diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c index 97a4544ffc6..e909c1a200c 100644 --- a/src/backend/utils/adt/formatting.c +++ b/src/backend/utils/adt/formatting.c @@ -898,7 +898,7 @@ static const KeyWord DCH_keywords[] = { {"month", 5, DCH_month, false, FROM_CHAR_DATE_GREGORIAN}, {"mon", 3, DCH_mon, false, FROM_CHAR_DATE_GREGORIAN}, {"ms", 2, DCH_MS, true, FROM_CHAR_DATE_NONE}, - {"of", 2, DCH_OF, false, FROM_CHAR_DATE_NONE}, /* o */ + {"of", 2, DCH_OF, false, FROM_CHAR_DATE_NONE}, /* o */ {"p.m.", 4, DCH_p_m, false, FROM_CHAR_DATE_NONE}, /* p */ {"pm", 2, DCH_pm, false, FROM_CHAR_DATE_NONE}, {"q", 1, DCH_Q, true, FROM_CHAR_DATE_NONE}, /* q */ @@ -906,7 +906,7 @@ static const KeyWord DCH_keywords[] = { {"sssss", 5, DCH_SSSS, true, FROM_CHAR_DATE_NONE}, /* s */ {"ssss", 4, DCH_SSSS, true, FROM_CHAR_DATE_NONE}, {"ss", 2, DCH_SS, true, FROM_CHAR_DATE_NONE}, - {"tzh", 3, DCH_TZH, false, FROM_CHAR_DATE_NONE}, /* t */ + {"tzh", 3, DCH_TZH, false, FROM_CHAR_DATE_NONE}, /* t */ {"tzm", 3, DCH_TZM, true, FROM_CHAR_DATE_NONE}, {"tz", 2, DCH_tz, false, FROM_CHAR_DATE_NONE}, {"us", 2, DCH_US, true, FROM_CHAR_DATE_NONE}, /* u */ @@ -1675,8 +1675,8 @@ str_tolower(const char *buff, size_t nbytes, Oid collid) if (!OidIsValid(collid)) { /* - * This typically means that the parser could not resolve a - * conflict of implicit collations, so report it that way. + * This typically means that the parser could not resolve a conflict + * of implicit collations, so report it that way. */ ereport(ERROR, (errcode(ERRCODE_INDETERMINATE_COLLATION), @@ -1797,8 +1797,8 @@ str_toupper(const char *buff, size_t nbytes, Oid collid) if (!OidIsValid(collid)) { /* - * This typically means that the parser could not resolve a - * conflict of implicit collations, so report it that way. + * This typically means that the parser could not resolve a conflict + * of implicit collations, so report it that way. */ ereport(ERROR, (errcode(ERRCODE_INDETERMINATE_COLLATION), @@ -1920,8 +1920,8 @@ str_initcap(const char *buff, size_t nbytes, Oid collid) if (!OidIsValid(collid)) { /* - * This typically means that the parser could not resolve a - * conflict of implicit collations, so report it that way. + * This typically means that the parser could not resolve a conflict + * of implicit collations, so report it that way. */ ereport(ERROR, (errcode(ERRCODE_INDETERMINATE_COLLATION), diff --git a/src/backend/utils/adt/json.c b/src/backend/utils/adt/json.c index 63649ba7351..553cc25eb9d 100644 --- a/src/backend/utils/adt/json.c +++ b/src/backend/utils/adt/json.c @@ -44,9 +44,9 @@ typedef struct JsonUniqueHashEntry /* Context for key uniqueness check in builder functions */ typedef struct JsonUniqueBuilderState { - JsonUniqueCheckState check; /* unique check */ + JsonUniqueCheckState check; /* unique check */ StringInfoData skipped_keys; /* skipped keys with NULL values */ - MemoryContext mcxt; /* context for saving skipped keys */ + MemoryContext mcxt; /* context for saving skipped keys */ } JsonUniqueBuilderState; /* Element of object stack for key uniqueness check during json parsing */ @@ -774,10 +774,10 @@ to_json_is_immutable(Oid typoid) return false; case JSONTYPE_ARRAY: - return false; /* TODO recurse into elements */ + return false; /* TODO recurse into elements */ case JSONTYPE_COMPOSITE: - return false; /* TODO recurse into fields */ + return false; /* TODO recurse into fields */ case JSONTYPE_NUMERIC: case JSONTYPE_CAST: @@ -938,7 +938,7 @@ static uint32 json_unique_hash(const void *key, Size keysize) { const JsonUniqueHashEntry *entry = (JsonUniqueHashEntry *) key; - uint32 hash = hash_bytes_uint32(entry->object_id); + uint32 hash = hash_bytes_uint32(entry->object_id); hash ^= hash_bytes((const unsigned char *) entry->key, entry->key_len); @@ -1011,6 +1011,7 @@ json_unique_builder_get_skipped_keys(JsonUniqueBuilderState *cxt) if (!out->data) { MemoryContext oldcxt = MemoryContextSwitchTo(cxt->mcxt); + initStringInfo(out); MemoryContextSwitchTo(oldcxt); } @@ -1116,8 +1117,8 @@ json_object_agg_transfn_worker(FunctionCallInfo fcinfo, out = state->str; /* - * Append comma delimiter only if we have already outputted some fields - * after the initial string "{ ". + * Append comma delimiter only if we have already outputted some + * fields after the initial string "{ ". */ if (out->len > 2) appendStringInfoString(out, ", "); @@ -1285,7 +1286,7 @@ json_build_object_worker(int nargs, Datum *args, bool *nulls, Oid *types, if (nulls[i]) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("argument %d cannot be null", i + 1), + errmsg("argument %d cannot be null", i + 1), errhint("Object keys should be text."))); /* save key offset before key appending */ @@ -1327,6 +1328,7 @@ json_build_object(PG_FUNCTION_ARGS) Datum *args; bool *nulls; Oid *types; + /* build argument values to build the object */ int nargs = extract_variadic_args(fcinfo, 0, true, &args, &types, &nulls); @@ -1382,6 +1384,7 @@ json_build_array(PG_FUNCTION_ARGS) Datum *args; bool *nulls; Oid *types; + /* build argument values to build the object */ int nargs = extract_variadic_args(fcinfo, 0, true, &args, &types, &nulls); @@ -1706,7 +1709,7 @@ json_validate(text *json, bool check_unique_keys, bool throw_error) if (throw_error) json_ereport_error(result, lex); - return false; /* invalid json */ + return false; /* invalid json */ } if (check_unique_keys && !state.unique) @@ -1716,10 +1719,10 @@ json_validate(text *json, bool check_unique_keys, bool throw_error) (errcode(ERRCODE_DUPLICATE_JSON_OBJECT_KEY_VALUE), errmsg("duplicate JSON object key value"))); - return false; /* not unique keys */ + return false; /* not unique keys */ } - return true; /* ok */ + return true; /* ok */ } /* diff --git a/src/backend/utils/adt/jsonb.c b/src/backend/utils/adt/jsonb.c index 26d81366c9f..39355e242d2 100644 --- a/src/backend/utils/adt/jsonb.c +++ b/src/backend/utils/adt/jsonb.c @@ -1148,10 +1148,10 @@ to_jsonb_is_immutable(Oid typoid) return false; case JSONBTYPE_ARRAY: - return false; /* TODO recurse into elements */ + return false; /* TODO recurse into elements */ case JSONBTYPE_COMPOSITE: - return false; /* TODO recurse into fields */ + return false; /* TODO recurse into fields */ case JSONBTYPE_NUMERIC: case JSONBTYPE_JSONCAST: @@ -1240,6 +1240,7 @@ jsonb_build_object(PG_FUNCTION_ARGS) Datum *args; bool *nulls; Oid *types; + /* build argument values to build the object */ int nargs = extract_variadic_args(fcinfo, 0, true, &args, &types, &nulls); @@ -1299,6 +1300,7 @@ jsonb_build_array(PG_FUNCTION_ARGS) Datum *args; bool *nulls; Oid *types; + /* build argument values to build the object */ int nargs = extract_variadic_args(fcinfo, 0, true, &args, &types, &nulls); @@ -2229,7 +2231,7 @@ jsonb_float8(PG_FUNCTION_ARGS) Jsonb * JsonbMakeEmptyArray(void) { - JsonbValue jbv; + JsonbValue jbv; jbv.type = jbvArray; jbv.val.array.elems = NULL; @@ -2245,7 +2247,7 @@ JsonbMakeEmptyArray(void) Jsonb * JsonbMakeEmptyObject(void) { - JsonbValue jbv; + JsonbValue jbv; jbv.type = jbvObject; jbv.val.object.pairs = NULL; @@ -2272,7 +2274,7 @@ JsonbUnquote(Jsonb *jb) return pstrdup(v.val.boolean ? "true" : "false"); else if (v.type == jbvNumeric) return DatumGetCString(DirectFunctionCall1(numeric_out, - PointerGetDatum(v.val.numeric))); + PointerGetDatum(v.val.numeric))); else if (v.type == jbvNull) return pstrdup("null"); else diff --git a/src/backend/utils/adt/jsonb_util.c b/src/backend/utils/adt/jsonb_util.c index 21d874c098a..5318eda9cfb 100644 --- a/src/backend/utils/adt/jsonb_util.c +++ b/src/backend/utils/adt/jsonb_util.c @@ -1959,7 +1959,8 @@ uniqueifyJsonbObject(JsonbValue *object, bool unique_keys, bool skip_nulls) if (hasNonUniq || skip_nulls) { - JsonbPair *ptr, *res; + JsonbPair *ptr, + *res; while (skip_nulls && object->val.object.nPairs > 0 && object->val.object.pairs->value.type == jbvNull) diff --git a/src/backend/utils/adt/jsonfuncs.c b/src/backend/utils/adt/jsonfuncs.c index d1356d64166..d427bdfbe0d 100644 --- a/src/backend/utils/adt/jsonfuncs.c +++ b/src/backend/utils/adt/jsonfuncs.c @@ -3139,7 +3139,7 @@ Datum json_populate_type(Datum json_val, Oid json_type, Oid typid, int32 typmod, void **cache, MemoryContext mcxt, bool *isnull) { - JsValue jsv = { 0 }; + JsValue jsv = {0}; JsonbValue jbv; jsv.is_json = json_type == JSONOID; @@ -3157,7 +3157,8 @@ json_populate_type(Datum json_val, Oid json_type, Oid typid, int32 typmod, jsv.val.json.str = VARDATA_ANY(json); jsv.val.json.len = VARSIZE_ANY_EXHDR(json); - jsv.val.json.type = JSON_TOKEN_INVALID; /* not used in populate_composite() */ + jsv.val.json.type = JSON_TOKEN_INVALID; /* not used in + * populate_composite() */ } else { @@ -3174,7 +3175,7 @@ json_populate_type(Datum json_val, Oid json_type, Oid typid, int32 typmod, if (!*cache) *cache = MemoryContextAllocZero(mcxt, sizeof(ColumnIOData)); - return populate_record_field(*cache , typid, typmod, NULL, mcxt, + return populate_record_field(*cache, typid, typmod, NULL, mcxt, PointerGetDatum(NULL), &jsv, isnull); } diff --git a/src/backend/utils/adt/jsonpath.c b/src/backend/utils/adt/jsonpath.c index 0ac14153aae..da9df4ae766 100644 --- a/src/backend/utils/adt/jsonpath.c +++ b/src/backend/utils/adt/jsonpath.c @@ -1094,7 +1094,7 @@ typedef struct JsonPathMutableContext { List *varnames; /* list of variable names */ List *varexprs; /* list of variable expressions */ - JsonPathDatatypeStatus current; /* status of @ item */ + JsonPathDatatypeStatus current; /* status of @ item */ bool lax; /* jsonpath is lax or strict */ bool mutable; /* resulting mutability status */ } JsonPathMutableContext; @@ -1282,18 +1282,18 @@ jspIsMutableWalker(JsonPathItem *jpi, JsonPathMutableContext *cxt) jspIsMutableWalker(&arg, cxt); break; - /* literals */ + /* literals */ case jpiNull: case jpiString: case jpiNumeric: case jpiBool: - /* accessors */ + /* accessors */ case jpiKey: case jpiAnyKey: - /* special items */ + /* special items */ case jpiSubscript: case jpiLast: - /* item methods */ + /* item methods */ case jpiType: case jpiSize: case jpiAbs: diff --git a/src/backend/utils/adt/jsonpath_exec.c b/src/backend/utils/adt/jsonpath_exec.c index 2544c6b1551..0943a381bac 100644 --- a/src/backend/utils/adt/jsonpath_exec.c +++ b/src/backend/utils/adt/jsonpath_exec.c @@ -288,9 +288,9 @@ static void getJsonPathItem(JsonPathExecContext *cxt, JsonPathItem *item, JsonbValue *value); static void getJsonPathVariable(JsonPathExecContext *cxt, JsonPathItem *variable, JsonbValue *value); -static int getJsonPathVariableFromJsonb(void *varsJsonb, char *varName, - int varNameLen, JsonbValue *val, - JsonbValue *baseObject); +static int getJsonPathVariableFromJsonb(void *varsJsonb, char *varName, + int varNameLen, JsonbValue *val, + JsonbValue *baseObject); static int JsonbArraySize(JsonbValue *jb); static JsonPathBool executeComparison(JsonPathItem *cmp, JsonbValue *lv, JsonbValue *rv, void *p); @@ -322,7 +322,7 @@ static int compareDatetime(Datum val1, Oid typid1, Datum val2, Oid typid2, static JsonTableJoinState *JsonTableInitPlanState(JsonTableContext *cxt, - Node *plan, JsonTableScanState *parent); + Node *plan, JsonTableScanState *parent); static bool JsonTableNextRow(JsonTableScanState *scan); @@ -2743,7 +2743,7 @@ static int compareDatetime(Datum val1, Oid typid1, Datum val2, Oid typid2, bool useTz, bool *cast_error) { - PGFunction cmpfunc; + PGFunction cmpfunc; *cast_error = false; @@ -2987,8 +2987,8 @@ JsonPathQuery(Datum jb, JsonPath *jp, JsonWrapper wrapper, bool *empty, JsonbValue * JsonPathValue(Datum jb, JsonPath *jp, bool *empty, bool *error, List *vars) { - JsonbValue *res; - JsonValueList found = { 0 }; + JsonbValue *res; + JsonValueList found = {0}; JsonPathExecResult jper PG_USED_FOR_ASSERTS_ONLY; int count; @@ -3123,8 +3123,8 @@ JsonItemFromDatum(Datum val, Oid typid, int32 typmod, JsonbValue *res) text *txt = DatumGetTextP(val); char *str = text_to_cstring(txt); Jsonb *jb = - DatumGetJsonbP(DirectFunctionCall1(jsonb_in, - CStringGetDatum(str))); + DatumGetJsonbP(DirectFunctionCall1(jsonb_in, + CStringGetDatum(str))); pfree(str); @@ -3221,7 +3221,7 @@ JsonTableInitOpaque(TableFuncScanState *state, int natts) { JsonTableContext *cxt; PlanState *ps = &state->ss.ps; - TableFuncScan *tfs = castNode(TableFuncScan, ps->plan); + TableFuncScan *tfs = castNode(TableFuncScan, ps->plan); TableFunc *tf = tfs->tablefunc; JsonExpr *ci = castNode(JsonExpr, tf->docexpr); JsonTableParent *root = castNode(JsonTableParent, tf->plan); @@ -3298,7 +3298,7 @@ JsonTableResetContextItem(JsonTableScanState *scan, Datum item) { MemoryContext oldcxt; JsonPathExecResult res; - Jsonb *js = (Jsonb *) DatumGetJsonbP(item); + Jsonb *js = (Jsonb *) DatumGetJsonbP(item); JsonValueListClear(&scan->found); @@ -3307,7 +3307,7 @@ JsonTableResetContextItem(JsonTableScanState *scan, Datum item) oldcxt = MemoryContextSwitchTo(scan->mcxt); res = executeJsonPath(scan->path, scan->args, EvalJsonPathVar, js, - scan->errorOnError, &scan->found, false /* FIXME */); + scan->errorOnError, &scan->found, false /* FIXME */ ); MemoryContextSwitchTo(oldcxt); @@ -3369,9 +3369,9 @@ JsonTableNextJoinRow(JsonTableJoinState *state) /* inner rows are exhausted */ if (state->u.join.cross) - state->u.join.advanceRight = false; /* next outer row */ + state->u.join.advanceRight = false; /* next outer row */ else - return false; /* end of scan */ + return false; /* end of scan */ } while (!state->u.join.advanceRight) @@ -3387,7 +3387,7 @@ JsonTableNextJoinRow(JsonTableJoinState *state) JsonTableRescanRecursive(state->u.join.right); if (!JsonTableNextJoinRow(state->u.join.right)) - continue; /* next outer row */ + continue; /* next outer row */ state->u.join.advanceRight = true; /* next inner row */ } @@ -3460,7 +3460,7 @@ JsonTableNextRow(JsonTableScanState *scan) { scan->current = PointerGetDatum(NULL); scan->currentIsNull = true; - return false; /* end of scan */ + return false; /* end of scan */ } /* set current row item */ @@ -3518,12 +3518,12 @@ JsonTableGetValue(TableFuncScanState *state, int colnum, JsonTableScanState *scan = cxt->colexprs[colnum].scan; Datum result; - if (scan->currentIsNull) /* NULL from outer/union join */ + if (scan->currentIsNull) /* NULL from outer/union join */ { result = (Datum) 0; *isnull = true; } - else if (estate) /* regular column */ + else if (estate) /* regular column */ { result = ExecEvalExpr(estate, econtext, isnull); } diff --git a/src/backend/utils/adt/like.c b/src/backend/utils/adt/like.c index 833ee8f814c..e02fc3725ad 100644 --- a/src/backend/utils/adt/like.c +++ b/src/backend/utils/adt/like.c @@ -181,8 +181,8 @@ Generic_Text_IC_like(text *str, text *pat, Oid collation) if (!OidIsValid(collation)) { /* - * This typically means that the parser could not resolve a - * conflict of implicit collations, so report it that way. + * This typically means that the parser could not resolve a conflict + * of implicit collations, so report it that way. */ ereport(ERROR, (errcode(ERRCODE_INDETERMINATE_COLLATION), diff --git a/src/backend/utils/adt/multirangetypes.c b/src/backend/utils/adt/multirangetypes.c index 67d7d67fb83..da5c7d09069 100644 --- a/src/backend/utils/adt/multirangetypes.c +++ b/src/backend/utils/adt/multirangetypes.c @@ -1439,7 +1439,8 @@ multirange_agg_transfn(PG_FUNCTION_ARGS) if (range_count == 0) { /* - * Add an empty range so we get an empty result (not a null result). + * Add an empty range so we get an empty result (not a null + * result). */ accumArrayResult(state, RangeTypePGetDatum(make_empty_range(rngtypcache)), diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c index 45547f6ae7f..920a63b0081 100644 --- a/src/backend/utils/adt/numeric.c +++ b/src/backend/utils/adt/numeric.c @@ -8537,139 +8537,138 @@ div_var(const NumericVar *var1, const NumericVar *var2, NumericVar *result, alloc_var(result, res_ndigits); res_digits = result->digits; + /* + * The full multiple-place algorithm is taken from Knuth volume 2, + * Algorithm 4.3.1D. + * + * We need the first divisor digit to be >= NBASE/2. If it isn't, make it + * so by scaling up both the divisor and dividend by the factor "d". (The + * reason for allocating dividend[0] above is to leave room for possible + * carry here.) + */ + if (divisor[1] < HALF_NBASE) + { + int d = NBASE / (divisor[1] + 1); + + carry = 0; + for (i = var2ndigits; i > 0; i--) + { + carry += divisor[i] * d; + divisor[i] = carry % NBASE; + carry = carry / NBASE; + } + Assert(carry == 0); + carry = 0; + /* at this point only var1ndigits of dividend can be nonzero */ + for (i = var1ndigits; i >= 0; i--) + { + carry += dividend[i] * d; + dividend[i] = carry % NBASE; + carry = carry / NBASE; + } + Assert(carry == 0); + Assert(divisor[1] >= HALF_NBASE); + } + /* First 2 divisor digits are used repeatedly in main loop */ + divisor1 = divisor[1]; + divisor2 = divisor[2]; + + /* + * Begin the main loop. Each iteration of this loop produces the j'th + * quotient digit by dividing dividend[j .. j + var2ndigits] by the + * divisor; this is essentially the same as the common manual procedure + * for long division. + */ + for (j = 0; j < res_ndigits; j++) + { + /* Estimate quotient digit from the first two dividend digits */ + int next2digits = dividend[j] * NBASE + dividend[j + 1]; + int qhat; + /* - * The full multiple-place algorithm is taken from Knuth volume 2, - * Algorithm 4.3.1D. - * - * We need the first divisor digit to be >= NBASE/2. If it isn't, - * make it so by scaling up both the divisor and dividend by the - * factor "d". (The reason for allocating dividend[0] above is to - * leave room for possible carry here.) + * If next2digits are 0, then quotient digit must be 0 and there's no + * need to adjust the working dividend. It's worth testing here to + * fall out ASAP when processing trailing zeroes in a dividend. */ - if (divisor[1] < HALF_NBASE) + if (next2digits == 0) { - int d = NBASE / (divisor[1] + 1); - - carry = 0; - for (i = var2ndigits; i > 0; i--) - { - carry += divisor[i] * d; - divisor[i] = carry % NBASE; - carry = carry / NBASE; - } - Assert(carry == 0); - carry = 0; - /* at this point only var1ndigits of dividend can be nonzero */ - for (i = var1ndigits; i >= 0; i--) - { - carry += dividend[i] * d; - dividend[i] = carry % NBASE; - carry = carry / NBASE; - } - Assert(carry == 0); - Assert(divisor[1] >= HALF_NBASE); + res_digits[j] = 0; + continue; } - /* First 2 divisor digits are used repeatedly in main loop */ - divisor1 = divisor[1]; - divisor2 = divisor[2]; + + if (dividend[j] == divisor1) + qhat = NBASE - 1; + else + qhat = next2digits / divisor1; /* - * Begin the main loop. Each iteration of this loop produces the j'th - * quotient digit by dividing dividend[j .. j + var2ndigits] by the - * divisor; this is essentially the same as the common manual - * procedure for long division. + * Adjust quotient digit if it's too large. Knuth proves that after + * this step, the quotient digit will be either correct or just one + * too large. (Note: it's OK to use dividend[j+2] here because we + * know the divisor length is at least 2.) */ - for (j = 0; j < res_ndigits; j++) + while (divisor2 * qhat > + (next2digits - qhat * divisor1) * NBASE + dividend[j + 2]) + qhat--; + + /* As above, need do nothing more when quotient digit is 0 */ + if (qhat > 0) { - /* Estimate quotient digit from the first two dividend digits */ - int next2digits = dividend[j] * NBASE + dividend[j + 1]; - int qhat; + NumericDigit *dividend_j = ÷nd[j]; /* - * If next2digits are 0, then quotient digit must be 0 and there's - * no need to adjust the working dividend. It's worth testing - * here to fall out ASAP when processing trailing zeroes in a - * dividend. + * Multiply the divisor by qhat, and subtract that from the + * working dividend. The multiplication and subtraction are + * folded together here, noting that qhat <= NBASE (since it might + * be one too large), and so the intermediate result "tmp_result" + * is in the range [-NBASE^2, NBASE - 1], and "borrow" is in the + * range [0, NBASE]. */ - if (next2digits == 0) + borrow = 0; + for (i = var2ndigits; i >= 0; i--) { - res_digits[j] = 0; - continue; - } + int tmp_result; - if (dividend[j] == divisor1) - qhat = NBASE - 1; - else - qhat = next2digits / divisor1; + tmp_result = dividend_j[i] - borrow - divisor[i] * qhat; + borrow = (NBASE - 1 - tmp_result) / NBASE; + dividend_j[i] = tmp_result + borrow * NBASE; + } /* - * Adjust quotient digit if it's too large. Knuth proves that - * after this step, the quotient digit will be either correct or - * just one too large. (Note: it's OK to use dividend[j+2] here - * because we know the divisor length is at least 2.) + * If we got a borrow out of the top dividend digit, then indeed + * qhat was one too large. Fix it, and add back the divisor to + * correct the working dividend. (Knuth proves that this will + * occur only about 3/NBASE of the time; hence, it's a good idea + * to test this code with small NBASE to be sure this section gets + * exercised.) */ - while (divisor2 * qhat > - (next2digits - qhat * divisor1) * NBASE + dividend[j + 2]) - qhat--; - - /* As above, need do nothing more when quotient digit is 0 */ - if (qhat > 0) + if (borrow) { - NumericDigit *dividend_j = ÷nd[j]; - - /* - * Multiply the divisor by qhat, and subtract that from the - * working dividend. The multiplication and subtraction are - * folded together here, noting that qhat <= NBASE (since it - * might be one too large), and so the intermediate result - * "tmp_result" is in the range [-NBASE^2, NBASE - 1], and - * "borrow" is in the range [0, NBASE]. - */ - borrow = 0; + qhat--; + carry = 0; for (i = var2ndigits; i >= 0; i--) { - int tmp_result; - - tmp_result = dividend_j[i] - borrow - divisor[i] * qhat; - borrow = (NBASE - 1 - tmp_result) / NBASE; - dividend_j[i] = tmp_result + borrow * NBASE; - } - - /* - * If we got a borrow out of the top dividend digit, then - * indeed qhat was one too large. Fix it, and add back the - * divisor to correct the working dividend. (Knuth proves - * that this will occur only about 3/NBASE of the time; hence, - * it's a good idea to test this code with small NBASE to be - * sure this section gets exercised.) - */ - if (borrow) - { - qhat--; - carry = 0; - for (i = var2ndigits; i >= 0; i--) + carry += dividend_j[i] + divisor[i]; + if (carry >= NBASE) { - carry += dividend_j[i] + divisor[i]; - if (carry >= NBASE) - { - dividend_j[i] = carry - NBASE; - carry = 1; - } - else - { - dividend_j[i] = carry; - carry = 0; - } + dividend_j[i] = carry - NBASE; + carry = 1; + } + else + { + dividend_j[i] = carry; + carry = 0; } - /* A carry should occur here to cancel the borrow above */ - Assert(carry == 1); } + /* A carry should occur here to cancel the borrow above */ + Assert(carry == 1); } - - /* And we're done with this quotient digit */ - res_digits[j] = qhat; } + /* And we're done with this quotient digit */ + res_digits[j] = qhat; + } + pfree(dividend); /* diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c index 2c47dea3429..a0490a75224 100644 --- a/src/backend/utils/adt/pg_locale.c +++ b/src/backend/utils/adt/pg_locale.c @@ -1625,7 +1625,7 @@ pg_newlocale_from_collation(Oid collid) } datum = SysCacheGetAttr(COLLOID, tp, Anum_pg_collation_collversion, - &isnull); + &isnull); if (!isnull) { char *actual_versionstr; @@ -1992,7 +1992,7 @@ check_icu_locale(const char *icu_locale) { #ifdef USE_ICU UCollator *collator; - UErrorCode status; + UErrorCode status; status = U_ZERO_ERROR; collator = ucol_open(icu_locale, &status); diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c index d3ad795a6ea..893690dad52 100644 --- a/src/backend/utils/adt/pgstatfuncs.c +++ b/src/backend/utils/adt/pgstatfuncs.c @@ -2411,7 +2411,7 @@ pg_stat_have_stats(PG_FUNCTION_ARGS) char *stats_type = text_to_cstring(PG_GETARG_TEXT_P(0)); Oid dboid = PG_GETARG_OID(1); Oid objoid = PG_GETARG_OID(2); - PgStat_Kind kind = pgstat_get_kind_from_str(stats_type); + PgStat_Kind kind = pgstat_get_kind_from_str(stats_type); PG_RETURN_BOOL(pgstat_have_entry(kind, dboid, objoid)); } diff --git a/src/backend/utils/adt/rangetypes_spgist.c b/src/backend/utils/adt/rangetypes_spgist.c index f90b0a3b358..1190b8000bc 100644 --- a/src/backend/utils/adt/rangetypes_spgist.c +++ b/src/backend/utils/adt/rangetypes_spgist.c @@ -608,8 +608,8 @@ spg_range_quad_inner_consistent(PG_FUNCTION_ARGS) /* * Non-empty range A contains non-empty range B if lower * bound of A is lower or equal to lower bound of range B - * and upper bound of range A is greater than or equal to upper - * bound of range A. + * and upper bound of range A is greater than or equal to + * upper bound of range A. * * All non-empty ranges contain an empty range. */ diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c index 01d4c22cfce..51b3fdc9a01 100644 --- a/src/backend/utils/adt/ri_triggers.c +++ b/src/backend/utils/adt/ri_triggers.c @@ -113,8 +113,10 @@ typedef struct RI_ConstraintInfo Oid fk_relid; /* referencing relation */ char confupdtype; /* foreign key's ON UPDATE action */ char confdeltype; /* foreign key's ON DELETE action */ - int ndelsetcols; /* number of columns referenced in ON DELETE SET clause */ - int16 confdelsetcols[RI_MAX_NUMKEYS]; /* attnums of cols to set on delete */ + int ndelsetcols; /* number of columns referenced in ON DELETE + * SET clause */ + int16 confdelsetcols[RI_MAX_NUMKEYS]; /* attnums of cols to set on + * delete */ char confmatchtype; /* foreign key's match type */ int nkeys; /* number of key columns */ int16 pk_attnums[RI_MAX_NUMKEYS]; /* attnums of referenced cols */ @@ -1059,7 +1061,8 @@ ri_set(TriggerData *trigdata, bool is_set_null, int tgkind) /* * Fetch or prepare a saved plan for the trigger. */ - switch (tgkind) { + switch (tgkind) + { case RI_TRIGTYPE_UPDATE: queryno = is_set_null ? RI_PLAN_SETNULL_ONUPDATE @@ -1086,25 +1089,29 @@ ri_set(TriggerData *trigdata, bool is_set_null, int tgkind) const char *qualsep; Oid queryoids[RI_MAX_NUMKEYS]; const char *fk_only; - int num_cols_to_set; + int num_cols_to_set; const int16 *set_cols; - switch (tgkind) { + switch (tgkind) + { case RI_TRIGTYPE_UPDATE: num_cols_to_set = riinfo->nkeys; set_cols = riinfo->fk_attnums; break; case RI_TRIGTYPE_DELETE: + /* - * If confdelsetcols are present, then we only update - * the columns specified in that array, otherwise we - * update all the referencing columns. + * If confdelsetcols are present, then we only update the + * columns specified in that array, otherwise we update all + * the referencing columns. */ - if (riinfo->ndelsetcols != 0) { + if (riinfo->ndelsetcols != 0) + { num_cols_to_set = riinfo->ndelsetcols; set_cols = riinfo->confdelsetcols; } - else { + else + { num_cols_to_set = riinfo->nkeys; set_cols = riinfo->fk_attnums; } diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 5d49f564a2e..f22ecfc5832 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2331,7 +2331,10 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand, if (string) appendStringInfo(&buf, " ON DELETE %s", string); - /* Add columns specified to SET NULL or SET DEFAULT if provided. */ + /* + * Add columns specified to SET NULL or SET DEFAULT if + * provided. + */ val = SysCacheGetAttr(CONSTROID, tup, Anum_pg_constraint_confdelsetcols, &isnull); if (!isnull) @@ -8260,7 +8263,7 @@ isSimpleNode(Node *node, Node *parentNode, int prettyFlags) case T_GroupingFunc: /* own parentheses */ case T_WindowFunc: /* own parentheses */ case T_CaseExpr: /* other separators */ - case T_JsonExpr: /* own parentheses */ + case T_JsonExpr: /* own parentheses */ return true; default: return false; @@ -8456,8 +8459,8 @@ get_json_format(JsonFormat *format, StringInfo buf) if (format->encoding != JS_ENC_DEFAULT) { const char *encoding = - format->encoding == JS_ENC_UTF16 ? "UTF16" : - format->encoding == JS_ENC_UTF32 ? "UTF32" : "UTF8"; + format->encoding == JS_ENC_UTF16 ? "UTF16" : + format->encoding == JS_ENC_UTF32 ? "UTF32" : "UTF8"; appendStringInfo(buf, " ENCODING %s", encoding); } @@ -8479,7 +8482,7 @@ get_json_returning(JsonReturning *returning, StringInfo buf, if (!json_format_by_default || returning->format->format_type != - (returning->typid == JSONBOID ? JS_FORMAT_JSONB : JS_FORMAT_JSON)) + (returning->typid == JSONBOID ? JS_FORMAT_JSONB : JS_FORMAT_JSON)) get_json_format(returning->format, buf); } @@ -9778,7 +9781,8 @@ get_rule_expr(Node *node, deparse_context *context, if (jexpr->passing_values) { - ListCell *lc1, *lc2; + ListCell *lc1, + *lc2; bool needcomma = false; appendStringInfoString(buf, " PASSING "); @@ -10147,7 +10151,7 @@ get_json_constructor(JsonConstructorExpr *ctor, deparse_context *context, if (nargs > 0) { const char *sep = ctor->type == JSCTOR_JSON_OBJECT && - (nargs % 2) != 0 ? " : " : ", "; + (nargs % 2) != 0 ? " : " : ", "; appendStringInfoString(buf, sep); } @@ -10251,7 +10255,8 @@ get_agg_expr_helper(Aggref *aggref, deparse_context *context, if (is_json_objectagg) { if (i > 2) - break; /* skip ABSENT ON NULL and WITH UNIQUE args */ + break; /* skip ABSENT ON NULL and WITH UNIQUE + * args */ appendStringInfoString(buf, " : "); } @@ -11160,16 +11165,16 @@ get_json_table_nested_columns(TableFunc *tf, Node *node, } else { - JsonTableParent *n = castNode(JsonTableParent, node); + JsonTableParent *n = castNode(JsonTableParent, node); - if (needcomma) - appendStringInfoChar(context->buf, ','); + if (needcomma) + appendStringInfoChar(context->buf, ','); - appendStringInfoChar(context->buf, ' '); - appendContextKeyword(context, "NESTED PATH ", 0, 0, 0); - get_const_expr(n->path, context, -1); - appendStringInfo(context->buf, " AS %s", quote_identifier(n->name)); - get_json_table_columns(tf, n, context, showimplicit); + appendStringInfoChar(context->buf, ' '); + appendContextKeyword(context, "NESTED PATH ", 0, 0, 0); + get_const_expr(n->path, context, -1); + appendStringInfo(context->buf, " AS %s", quote_identifier(n->name)); + get_json_table_columns(tf, n, context, showimplicit); } } @@ -11199,17 +11204,17 @@ get_json_table_plan(TableFunc *tf, Node *node, deparse_context *context, } else { - JsonTableParent *n = castNode(JsonTableParent, node); + JsonTableParent *n = castNode(JsonTableParent, node); - appendStringInfoString(context->buf, quote_identifier(n->name)); + appendStringInfoString(context->buf, quote_identifier(n->name)); - if (n->child) - { + if (n->child) + { appendStringInfoString(context->buf, n->outerJoin ? " OUTER " : " INNER "); get_json_table_plan(tf, n->child, context, IsA(n->child, JsonTableSibling)); - } + } } if (parenthesize) @@ -11348,7 +11353,8 @@ get_json_table(TableFunc *tf, deparse_context *context, bool showimplicit) if (jexpr->passing_values) { - ListCell *lc1, *lc2; + ListCell *lc1, + *lc2; bool needcomma = false; appendStringInfoChar(buf, ' '); diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index 71cbc1c3d80..fa1f589fad8 100644 --- a/src/backend/utils/adt/selfuncs.c +++ b/src/backend/utils/adt/selfuncs.c @@ -3380,9 +3380,9 @@ estimate_num_groups(PlannerInfo *root, List *groupExprs, double input_rows, */ double estimate_num_groups_incremental(PlannerInfo *root, List *groupExprs, - double input_rows, - List **pgset, EstimationInfo *estinfo, - List **cache_varinfos, int prevNExprs) + double input_rows, + List **pgset, EstimationInfo *estinfo, + List **cache_varinfos, int prevNExprs) { List *varinfos = (cache_varinfos) ? *cache_varinfos : NIL; double srf_multiplier = 1.0; @@ -3433,7 +3433,7 @@ estimate_num_groups_incremental(PlannerInfo *root, List *groupExprs, if (cache_varinfos && j++ < prevNExprs) { if (pgset) - i++; /* to keep in sync with lines below */ + i++; /* to keep in sync with lines below */ continue; } @@ -3944,7 +3944,7 @@ estimate_multivariate_ndistinct(PlannerInfo *root, RelOptInfo *rel, Oid statOid = InvalidOid; MVNDistinct *stats; StatisticExtInfo *matched_info = NULL; - RangeTblEntry *rte; + RangeTblEntry *rte; /* bail out immediately if the table has no extended statistics */ if (!rel->statlist) @@ -5255,7 +5255,7 @@ examine_variable(PlannerInfo *root, Node *node, int varRelid, foreach(slist, onerel->statlist) { StatisticExtInfo *info = (StatisticExtInfo *) lfirst(slist); - RangeTblEntry *rte = planner_rt_fetch(onerel->relid, root); + RangeTblEntry *rte = planner_rt_fetch(onerel->relid, root); ListCell *expr_item; int pos; diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c index 8acb725bc8f..f70f829d830 100644 --- a/src/backend/utils/adt/timestamp.c +++ b/src/backend/utils/adt/timestamp.c @@ -2194,6 +2194,7 @@ timestamp_sortsupport(PG_FUNCTION_ARGS) SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0); #if SIZEOF_DATUM >= 8 + /* * If this build has pass-by-value timestamps, then we can use a standard * comparator function. @@ -4349,59 +4350,59 @@ interval_trunc(PG_FUNCTION_ARGS) if (type == UNITS) { interval2itm(*interval, tm); - switch (val) - { - case DTK_MILLENNIUM: - /* caution: C division may have negative remainder */ - tm->tm_year = (tm->tm_year / 1000) * 1000; - /* FALL THRU */ - case DTK_CENTURY: - /* caution: C division may have negative remainder */ - tm->tm_year = (tm->tm_year / 100) * 100; - /* FALL THRU */ - case DTK_DECADE: - /* caution: C division may have negative remainder */ - tm->tm_year = (tm->tm_year / 10) * 10; - /* FALL THRU */ - case DTK_YEAR: - tm->tm_mon = 0; - /* FALL THRU */ - case DTK_QUARTER: - tm->tm_mon = 3 * (tm->tm_mon / 3); - /* FALL THRU */ - case DTK_MONTH: - tm->tm_mday = 0; - /* FALL THRU */ - case DTK_DAY: - tm->tm_hour = 0; - /* FALL THRU */ - case DTK_HOUR: - tm->tm_min = 0; - /* FALL THRU */ - case DTK_MINUTE: - tm->tm_sec = 0; - /* FALL THRU */ - case DTK_SECOND: - tm->tm_usec = 0; - break; - case DTK_MILLISEC: - tm->tm_usec = (tm->tm_usec / 1000) * 1000; - break; - case DTK_MICROSEC: - break; - - default: - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("unit \"%s\" not supported for type %s", - lowunits, format_type_be(INTERVALOID)), - (val == DTK_WEEK) ? errdetail("Months usually have fractional weeks.") : 0)); - } + switch (val) + { + case DTK_MILLENNIUM: + /* caution: C division may have negative remainder */ + tm->tm_year = (tm->tm_year / 1000) * 1000; + /* FALL THRU */ + case DTK_CENTURY: + /* caution: C division may have negative remainder */ + tm->tm_year = (tm->tm_year / 100) * 100; + /* FALL THRU */ + case DTK_DECADE: + /* caution: C division may have negative remainder */ + tm->tm_year = (tm->tm_year / 10) * 10; + /* FALL THRU */ + case DTK_YEAR: + tm->tm_mon = 0; + /* FALL THRU */ + case DTK_QUARTER: + tm->tm_mon = 3 * (tm->tm_mon / 3); + /* FALL THRU */ + case DTK_MONTH: + tm->tm_mday = 0; + /* FALL THRU */ + case DTK_DAY: + tm->tm_hour = 0; + /* FALL THRU */ + case DTK_HOUR: + tm->tm_min = 0; + /* FALL THRU */ + case DTK_MINUTE: + tm->tm_sec = 0; + /* FALL THRU */ + case DTK_SECOND: + tm->tm_usec = 0; + break; + case DTK_MILLISEC: + tm->tm_usec = (tm->tm_usec / 1000) * 1000; + break; + case DTK_MICROSEC: + break; - if (itm2interval(tm, result) != 0) + default: ereport(ERROR, - (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE), - errmsg("interval out of range"))); + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("unit \"%s\" not supported for type %s", + lowunits, format_type_be(INTERVALOID)), + (val == DTK_WEEK) ? errdetail("Months usually have fractional weeks.") : 0)); + } + + if (itm2interval(tm, result) != 0) + ereport(ERROR, + (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE), + errmsg("interval out of range"))); } else { @@ -5225,80 +5226,80 @@ interval_part_common(PG_FUNCTION_ARGS, bool retnumeric) if (type == UNITS) { interval2itm(*interval, tm); - switch (val) - { - case DTK_MICROSEC: - intresult = tm->tm_sec * INT64CONST(1000000) + tm->tm_usec; - break; + switch (val) + { + case DTK_MICROSEC: + intresult = tm->tm_sec * INT64CONST(1000000) + tm->tm_usec; + break; - case DTK_MILLISEC: - if (retnumeric) - /*--- - * tm->tm_sec * 1000 + fsec / 1000 - * = (tm->tm_sec * 1'000'000 + fsec) / 1000 - */ - PG_RETURN_NUMERIC(int64_div_fast_to_numeric(tm->tm_sec * INT64CONST(1000000) + tm->tm_usec, 3)); - else - PG_RETURN_FLOAT8(tm->tm_sec * 1000.0 + tm->tm_usec / 1000.0); - break; + case DTK_MILLISEC: + if (retnumeric) + /*--- + * tm->tm_sec * 1000 + fsec / 1000 + * = (tm->tm_sec * 1'000'000 + fsec) / 1000 + */ + PG_RETURN_NUMERIC(int64_div_fast_to_numeric(tm->tm_sec * INT64CONST(1000000) + tm->tm_usec, 3)); + else + PG_RETURN_FLOAT8(tm->tm_sec * 1000.0 + tm->tm_usec / 1000.0); + break; - case DTK_SECOND: - if (retnumeric) - /*--- - * tm->tm_sec + fsec / 1'000'000 - * = (tm->tm_sec * 1'000'000 + fsec) / 1'000'000 - */ - PG_RETURN_NUMERIC(int64_div_fast_to_numeric(tm->tm_sec * INT64CONST(1000000) + tm->tm_usec, 6)); - else - PG_RETURN_FLOAT8(tm->tm_sec + tm->tm_usec / 1000000.0); - break; + case DTK_SECOND: + if (retnumeric) + /*--- + * tm->tm_sec + fsec / 1'000'000 + * = (tm->tm_sec * 1'000'000 + fsec) / 1'000'000 + */ + PG_RETURN_NUMERIC(int64_div_fast_to_numeric(tm->tm_sec * INT64CONST(1000000) + tm->tm_usec, 6)); + else + PG_RETURN_FLOAT8(tm->tm_sec + tm->tm_usec / 1000000.0); + break; - case DTK_MINUTE: - intresult = tm->tm_min; - break; + case DTK_MINUTE: + intresult = tm->tm_min; + break; - case DTK_HOUR: - intresult = tm->tm_hour; - break; + case DTK_HOUR: + intresult = tm->tm_hour; + break; - case DTK_DAY: - intresult = tm->tm_mday; - break; + case DTK_DAY: + intresult = tm->tm_mday; + break; - case DTK_MONTH: - intresult = tm->tm_mon; - break; + case DTK_MONTH: + intresult = tm->tm_mon; + break; - case DTK_QUARTER: - intresult = (tm->tm_mon / 3) + 1; - break; + case DTK_QUARTER: + intresult = (tm->tm_mon / 3) + 1; + break; - case DTK_YEAR: - intresult = tm->tm_year; - break; + case DTK_YEAR: + intresult = tm->tm_year; + break; - case DTK_DECADE: - /* caution: C division may have negative remainder */ - intresult = tm->tm_year / 10; - break; + case DTK_DECADE: + /* caution: C division may have negative remainder */ + intresult = tm->tm_year / 10; + break; - case DTK_CENTURY: - /* caution: C division may have negative remainder */ - intresult = tm->tm_year / 100; - break; + case DTK_CENTURY: + /* caution: C division may have negative remainder */ + intresult = tm->tm_year / 100; + break; - case DTK_MILLENNIUM: - /* caution: C division may have negative remainder */ - intresult = tm->tm_year / 1000; - break; + case DTK_MILLENNIUM: + /* caution: C division may have negative remainder */ + intresult = tm->tm_year / 1000; + break; - default: - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("unit \"%s\" not supported for type %s", - lowunits, format_type_be(INTERVALOID)))); - intresult = 0; - } + default: + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("unit \"%s\" not supported for type %s", + lowunits, format_type_be(INTERVALOID)))); + intresult = 0; + } } else if (type == RESERV && val == DTK_EPOCH) { diff --git a/src/backend/utils/adt/uuid.c b/src/backend/utils/adt/uuid.c index a157f864e12..7cec9372485 100644 --- a/src/backend/utils/adt/uuid.c +++ b/src/backend/utils/adt/uuid.c @@ -377,8 +377,8 @@ uuid_abbrev_convert(Datum original, SortSupport ssup) * * This is needed so that ssup_datum_unsigned_cmp() (an unsigned integer * 3-way comparator) works correctly on all platforms. If we didn't do - * this, the comparator would have to call memcmp() with a pair of pointers - * to the first byte of each abbreviated key, which is slower. + * this, the comparator would have to call memcmp() with a pair of + * pointers to the first byte of each abbreviated key, which is slower. */ res = DatumBigEndianToNative(res); diff --git a/src/backend/utils/adt/varchar.c b/src/backend/utils/adt/varchar.c index 8b5b30ed714..bbeb0a2653a 100644 --- a/src/backend/utils/adt/varchar.c +++ b/src/backend/utils/adt/varchar.c @@ -744,7 +744,7 @@ bpchareq(PG_FUNCTION_ARGS) bool result; Oid collid = PG_GET_COLLATION(); bool locale_is_c = false; - pg_locale_t mylocale = 0; + pg_locale_t mylocale = 0; check_collation_set(collid); @@ -789,7 +789,7 @@ bpcharne(PG_FUNCTION_ARGS) bool result; Oid collid = PG_GET_COLLATION(); bool locale_is_c = false; - pg_locale_t mylocale = 0; + pg_locale_t mylocale = 0; check_collation_set(collid); diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c index cfc135c7beb..919138eaf32 100644 --- a/src/backend/utils/adt/varlena.c +++ b/src/backend/utils/adt/varlena.c @@ -1758,7 +1758,7 @@ texteq(PG_FUNCTION_ARGS) { Oid collid = PG_GET_COLLATION(); bool locale_is_c = false; - pg_locale_t mylocale = 0; + pg_locale_t mylocale = 0; bool result; check_collation_set(collid); @@ -1817,7 +1817,7 @@ textne(PG_FUNCTION_ARGS) { Oid collid = PG_GET_COLLATION(); bool locale_is_c = false; - pg_locale_t mylocale = 0; + pg_locale_t mylocale = 0; bool result; check_collation_set(collid); @@ -2674,8 +2674,8 @@ done: * * This is needed so that ssup_datum_unsigned_cmp() (an unsigned integer * 3-way comparator) works correctly on all platforms. If we didn't do - * this, the comparator would have to call memcmp() with a pair of pointers - * to the first byte of each abbreviated key, which is slower. + * this, the comparator would have to call memcmp() with a pair of + * pointers to the first byte of each abbreviated key, which is slower. */ res = DatumBigEndianToNative(res); |