diff options
author | Bruce Momjian <bruce@momjian.us> | 2011-04-10 11:42:00 -0400 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2011-04-10 11:42:00 -0400 |
commit | bf50caf105a901c4f83ac1df3cdaf910c26694a4 (patch) | |
tree | dac42d7795070f107eefb085c500f86a4d35f92f /src/backend/utils/adt | |
parent | 9a8b73147c07e02e10e0d0a34aa99d72e3336fb2 (diff) | |
download | postgresql-bf50caf105a901c4f83ac1df3cdaf910c26694a4.tar.gz postgresql-bf50caf105a901c4f83ac1df3cdaf910c26694a4.zip |
pgindent run before PG 9.1 beta 1.
Diffstat (limited to 'src/backend/utils/adt')
24 files changed, 335 insertions, 326 deletions
diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c index 2f27018b256..dc75ad86ce2 100644 --- a/src/backend/utils/adt/acl.c +++ b/src/backend/utils/adt/acl.c @@ -113,7 +113,7 @@ static AclMode convert_role_priv_string(text *priv_type_text); static AclResult pg_role_aclcheck(Oid role_oid, Oid roleid, AclMode mode); static void RoleMembershipCacheCallback(Datum arg, int cacheid, ItemPointer tuplePtr); -static Oid get_role_oid_or_public(const char *rolname); +static Oid get_role_oid_or_public(const char *rolname); /* @@ -4829,7 +4829,7 @@ get_role_oid(const char *rolname, bool missing_ok) /* * get_role_oid_or_public - As above, but return ACL_ID_PUBLIC if the - * role name is "public". + * role name is "public". */ static Oid get_role_oid_or_public(const char *rolname) diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c index e023b2458ed..0869de66cef 100644 --- a/src/backend/utils/adt/arrayfuncs.c +++ b/src/backend/utils/adt/arrayfuncs.c @@ -72,7 +72,7 @@ typedef struct ArrayIteratorData /* current position information, updated on each iteration */ char *data_ptr; /* our current position in the array */ int current_item; /* the item # we're at in the array */ -} ArrayIteratorData; +} ArrayIteratorData; static bool array_isspace(char ch); static int ArrayCount(const char *str, int *dim, char typdelim); @@ -1268,7 +1268,8 @@ array_recv(PG_FUNCTION_ARGS) */ if (dim[i] != 0) { - int ub = lBound[i] + dim[i] - 1; + int ub = lBound[i] + dim[i] - 1; + if (lBound[i] > ub) ereport(ERROR, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), diff --git a/src/backend/utils/adt/cash.c b/src/backend/utils/adt/cash.c index 4c3279759d5..faef6f83813 100644 --- a/src/backend/utils/adt/cash.c +++ b/src/backend/utils/adt/cash.c @@ -945,11 +945,11 @@ numeric_cash(PG_FUNCTION_ARGS) Datum int4_cash(PG_FUNCTION_ARGS) { - int32 amount = PG_GETARG_INT32(0); - Cash result; - int fpoint; - int64 scale; - int i; + int32 amount = PG_GETARG_INT32(0); + Cash result; + int fpoint; + int64 scale; + int i; struct lconv *lconvert = PGLC_localeconv(); /* see comments about frac_digits in cash_in() */ @@ -964,7 +964,7 @@ int4_cash(PG_FUNCTION_ARGS) /* compute amount * scale, checking for overflow */ result = DatumGetInt64(DirectFunctionCall2(int8mul, Int64GetDatum(amount), - Int64GetDatum(scale))); + Int64GetDatum(scale))); PG_RETURN_CASH(result); } @@ -975,11 +975,11 @@ int4_cash(PG_FUNCTION_ARGS) Datum int8_cash(PG_FUNCTION_ARGS) { - int64 amount = PG_GETARG_INT64(0); - Cash result; - int fpoint; - int64 scale; - int i; + int64 amount = PG_GETARG_INT64(0); + Cash result; + int fpoint; + int64 scale; + int i; struct lconv *lconvert = PGLC_localeconv(); /* see comments about frac_digits in cash_in() */ @@ -994,7 +994,7 @@ int8_cash(PG_FUNCTION_ARGS) /* compute amount * scale, checking for overflow */ result = DatumGetInt64(DirectFunctionCall2(int8mul, Int64GetDatum(amount), - Int64GetDatum(scale))); + Int64GetDatum(scale))); PG_RETURN_CASH(result); } diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c index f96fa6cb72e..e737e720f5b 100644 --- a/src/backend/utils/adt/date.c +++ b/src/backend/utils/adt/date.c @@ -472,7 +472,7 @@ date2timestamptz(DateADT dateVal) double date2timestamp_no_overflow(DateADT dateVal) { - double result; + double result; if (DATE_IS_NOBEGIN(dateVal)) result = -DBL_MAX; diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index 0410b8384e9..db0a6487acf 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -2397,7 +2397,7 @@ DecodeTime(char *str, int fmask, int range, /* do a sanity check */ #ifdef HAVE_INT64_TIMESTAMP - if (tm->tm_hour < 0 || tm->tm_min < 0 || tm->tm_min > MINS_PER_HOUR -1 || + if (tm->tm_hour < 0 || tm->tm_min < 0 || tm->tm_min > MINS_PER_HOUR - 1 || tm->tm_sec < 0 || tm->tm_sec > SECS_PER_MINUTE || *fsec < INT64CONST(0) || *fsec > USECS_PER_SEC) diff --git a/src/backend/utils/adt/dbsize.c b/src/backend/utils/adt/dbsize.c index 543a244bf99..73a6ad32808 100644 --- a/src/backend/utils/adt/dbsize.c +++ b/src/backend/utils/adt/dbsize.c @@ -634,7 +634,7 @@ pg_relation_filepath(PG_FUNCTION_ARGS) break; default: elog(ERROR, "invalid relpersistence: %c", relform->relpersistence); - backend = InvalidBackendId; /* placate compiler */ + backend = InvalidBackendId; /* placate compiler */ break; } diff --git a/src/backend/utils/adt/enum.c b/src/backend/utils/adt/enum.c index be4f984ed68..8f65c84d305 100644 --- a/src/backend/utils/adt/enum.c +++ b/src/backend/utils/adt/enum.c @@ -461,7 +461,7 @@ enum_range_internal(Oid enumtypoid, Oid lower, Oid upper) Datum *elems; int max, cnt; - bool left_found; + bool left_found; /* * Scan the enum members in order using pg_enum_typid_sortorder_index. @@ -486,7 +486,7 @@ enum_range_internal(Oid enumtypoid, Oid lower, Oid upper) while (HeapTupleIsValid(enum_tuple = systable_getnext_ordered(enum_scan, ForwardScanDirection))) { - Oid enum_oid = HeapTupleGetOid(enum_tuple); + Oid enum_oid = HeapTupleGetOid(enum_tuple); if (!left_found && lower == enum_oid) left_found = true; diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c index 45e36f92e50..f895bbbb8b9 100644 --- a/src/backend/utils/adt/formatting.c +++ b/src/backend/utils/adt/formatting.c @@ -662,7 +662,7 @@ typedef enum /* last */ _DCH_last_ -} DCH_poz; +} DCH_poz; typedef enum { @@ -705,7 +705,7 @@ typedef enum /* last */ _NUM_last_ -} NUM_poz; +} NUM_poz; /* ---------- * KeyWords for DATE-TIME version @@ -1497,7 +1497,7 @@ str_tolower(const char *buff, size_t nbytes, Oid collid) #ifdef USE_WIDE_UPPER_LOWER else if (pg_database_encoding_max_length() > 1) { - pg_locale_t mylocale = 0; + pg_locale_t mylocale = 0; wchar_t *workspace; size_t curr_char; size_t result_size; @@ -1549,7 +1549,7 @@ str_tolower(const char *buff, size_t nbytes, Oid collid) #endif /* USE_WIDE_UPPER_LOWER */ else { - pg_locale_t mylocale = 0; + pg_locale_t mylocale = 0; char *p; if (collid != DEFAULT_COLLATION_OID) @@ -1618,7 +1618,7 @@ str_toupper(const char *buff, size_t nbytes, Oid collid) #ifdef USE_WIDE_UPPER_LOWER else if (pg_database_encoding_max_length() > 1) { - pg_locale_t mylocale = 0; + pg_locale_t mylocale = 0; wchar_t *workspace; size_t curr_char; size_t result_size; @@ -1670,7 +1670,7 @@ str_toupper(const char *buff, size_t nbytes, Oid collid) #endif /* USE_WIDE_UPPER_LOWER */ else { - pg_locale_t mylocale = 0; + pg_locale_t mylocale = 0; char *p; if (collid != DEFAULT_COLLATION_OID) @@ -1736,7 +1736,7 @@ str_initcap(const char *buff, size_t nbytes, Oid collid) for (p = result; *p; p++) { - char c; + char c; if (wasalnum) *p = c = pg_ascii_tolower((unsigned char) *p); @@ -1751,7 +1751,7 @@ str_initcap(const char *buff, size_t nbytes, Oid collid) #ifdef USE_WIDE_UPPER_LOWER else if (pg_database_encoding_max_length() > 1) { - pg_locale_t mylocale = 0; + pg_locale_t mylocale = 0; wchar_t *workspace; size_t curr_char; size_t result_size; @@ -1815,7 +1815,7 @@ str_initcap(const char *buff, size_t nbytes, Oid collid) #endif /* USE_WIDE_UPPER_LOWER */ else { - pg_locale_t mylocale = 0; + pg_locale_t mylocale = 0; char *p; if (collid != DEFAULT_COLLATION_OID) @@ -1838,7 +1838,7 @@ str_initcap(const char *buff, size_t nbytes, Oid collid) /* * Note: we assume that toupper_l()/tolower_l() will not be so broken - * as to need guard tests. When using the default collation, we apply + * as to need guard tests. When using the default collation, we apply * the traditional Postgres behavior that forces ASCII-style treatment * of I/i, but in non-default collations you get exactly what the * collation says. @@ -2318,7 +2318,7 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out, Oid col * intervals */ sprintf(s, "%0*d", S_FM(n->suffix) ? 0 : 2, - tm->tm_hour % (HOURS_PER_DAY / 2) == 0 ? HOURS_PER_DAY / 2 : + tm->tm_hour % (HOURS_PER_DAY / 2) == 0 ? HOURS_PER_DAY / 2 : tm->tm_hour % (HOURS_PER_DAY / 2)); if (S_THth(n->suffix)) str_numth(s, s, S_TH_TYPE(n->suffix)); @@ -2423,7 +2423,7 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out, Oid col strcpy(s, str_toupper_z(localized_full_months[tm->tm_mon - 1], collid)); else sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -9, - str_toupper_z(months_full[tm->tm_mon - 1], collid)); + str_toupper_z(months_full[tm->tm_mon - 1], collid)); s += strlen(s); break; case DCH_Month: diff --git a/src/backend/utils/adt/genfile.c b/src/backend/utils/adt/genfile.c index 7c59e9a20ef..6b3f77fec14 100644 --- a/src/backend/utils/adt/genfile.c +++ b/src/backend/utils/adt/genfile.c @@ -56,18 +56,19 @@ convert_and_check_filename(text *arg) /* Disallow '/a/b/data/..' */ if (path_contains_parent_reference(filename)) ereport(ERROR, - (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - (errmsg("reference to parent directory (\"..\") not allowed")))); + (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), + (errmsg("reference to parent directory (\"..\") not allowed")))); + /* - * Allow absolute paths if within DataDir or Log_directory, even - * though Log_directory might be outside DataDir. + * Allow absolute paths if within DataDir or Log_directory, even + * though Log_directory might be outside DataDir. */ if (!path_is_prefix_of_path(DataDir, filename) && (!is_absolute_path(Log_directory) || !path_is_prefix_of_path(Log_directory, filename))) ereport(ERROR, - (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - (errmsg("absolute path not allowed")))); + (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), + (errmsg("absolute path not allowed")))); } else if (!path_is_relative_and_below_cwd(filename)) ereport(ERROR, diff --git a/src/backend/utils/adt/like.c b/src/backend/utils/adt/like.c index b060faa6a9b..0934c69ebe5 100644 --- a/src/backend/utils/adt/like.c +++ b/src/backend/utils/adt/like.c @@ -30,19 +30,19 @@ #define LIKE_ABORT (-1) -static int SB_MatchText(char *t, int tlen, char *p, int plen, - pg_locale_t locale, bool locale_is_c); +static int SB_MatchText(char *t, int tlen, char *p, int plen, + pg_locale_t locale, bool locale_is_c); static text *SB_do_like_escape(text *, text *); -static int MB_MatchText(char *t, int tlen, char *p, int plen, - pg_locale_t locale, bool locale_is_c); +static int MB_MatchText(char *t, int tlen, char *p, int plen, + pg_locale_t locale, bool locale_is_c); static text *MB_do_like_escape(text *, text *); -static int UTF8_MatchText(char *t, int tlen, char *p, int plen, - pg_locale_t locale, bool locale_is_c); +static int UTF8_MatchText(char *t, int tlen, char *p, int plen, + pg_locale_t locale, bool locale_is_c); -static int SB_IMatchText(char *t, int tlen, char *p, int plen, - pg_locale_t locale, bool locale_is_c); +static int SB_IMatchText(char *t, int tlen, char *p, int plen, + pg_locale_t locale, bool locale_is_c); static int GenericMatchText(char *s, int slen, char *p, int plen); static int Generic_Text_IC_like(text *str, text *pat, Oid collation); @@ -188,11 +188,11 @@ Generic_Text_IC_like(text *str, text *pat, Oid collation) else { /* - * Here we need to prepare locale information for SB_lower_char. - * This should match the methods used in str_tolower(). + * Here we need to prepare locale information for SB_lower_char. This + * should match the methods used in str_tolower(). */ - pg_locale_t locale = 0; - bool locale_is_c = false; + pg_locale_t locale = 0; + bool locale_is_c = false; if (lc_ctype_is_c(collation)) locale_is_c = true; diff --git a/src/backend/utils/adt/nabstime.c b/src/backend/utils/adt/nabstime.c index 4b61b21cbed..6771e78af8e 100644 --- a/src/backend/utils/adt/nabstime.c +++ b/src/backend/utils/adt/nabstime.c @@ -182,8 +182,8 @@ tm2abstime(struct pg_tm * tm, int tz) tm->tm_mon < 1 || tm->tm_mon > MONTHS_PER_YEAR || tm->tm_mday < 1 || tm->tm_mday > 31 || tm->tm_hour < 0 || - tm->tm_hour > HOURS_PER_DAY || /* test for > 24:00:00 */ - (tm->tm_hour == HOURS_PER_DAY && (tm->tm_min > 0 || tm->tm_sec > 0)) || + tm->tm_hour > HOURS_PER_DAY || /* test for > 24:00:00 */ + (tm->tm_hour == HOURS_PER_DAY && (tm->tm_min > 0 || tm->tm_sec > 0)) || tm->tm_min < 0 || tm->tm_min > MINS_PER_HOUR - 1 || tm->tm_sec < 0 || tm->tm_sec > SECS_PER_MINUTE) return INVALID_ABSTIME; @@ -1163,7 +1163,7 @@ tintervalsame(PG_FUNCTION_ARGS) * 1. The interval length computations overflow at 2^31 seconds, causing * intervals longer than that to sort oddly compared to those shorter. * 2. infinity and minus infinity (NOEND_ABSTIME and NOSTART_ABSTIME) are - * just ordinary integers. Since this code doesn't handle them specially, + * just ordinary integers. Since this code doesn't handle them specially, * it's possible for [a b] to be considered longer than [c infinity] for * finite abstimes a, b, c. In combination with the previous point, the * interval [-infinity infinity] is treated as being shorter than many finite diff --git a/src/backend/utils/adt/network.c b/src/backend/utils/adt/network.c index 8cac11134c4..80e5915b3e5 100644 --- a/src/backend/utils/adt/network.c +++ b/src/backend/utils/adt/network.c @@ -319,7 +319,7 @@ inet_to_cidr(PG_FUNCTION_ARGS) inet *src = PG_GETARG_INET_P(0); inet *dst; int bits; - int byte; + int byte; int nbits; int maxbytes; @@ -340,15 +340,15 @@ inet_to_cidr(PG_FUNCTION_ARGS) /* clear the first byte, this might be a partial byte */ if (nbits != 0) { - ip_addr(dst)[byte] &=~(0xFF >> nbits); - byte ++; + ip_addr(dst)[byte] &= ~(0xFF >> nbits); + byte++; } /* clear remaining bytes */ maxbytes = ip_addrsize(dst); - while (byte <maxbytes) + while (byte < maxbytes) { ip_addr(dst)[byte] = 0; - byte ++; + byte++; } PG_RETURN_INET_P(dst); @@ -384,7 +384,7 @@ cidr_set_masklen(PG_FUNCTION_ARGS) inet *src = PG_GETARG_INET_P(0); int bits = PG_GETARG_INT32(1); inet *dst; - int byte; + int byte; int nbits; int maxbytes; @@ -409,15 +409,15 @@ cidr_set_masklen(PG_FUNCTION_ARGS) /* clear the first byte, this might be a partial byte */ if (nbits != 0) { - ip_addr(dst)[byte] &=~(0xFF >> nbits); - byte ++; + ip_addr(dst)[byte] &= ~(0xFF >> nbits); + byte++; } /* clear remaining bytes */ maxbytes = ip_addrsize(dst); - while (byte <maxbytes) + while (byte < maxbytes) { ip_addr(dst)[byte] = 0; - byte ++; + byte++; } PG_RETURN_INET_P(dst); @@ -716,7 +716,7 @@ network_broadcast(PG_FUNCTION_ARGS) { inet *ip = PG_GETARG_INET_P(0); inet *dst; - int byte; + int byte; int bits; int maxbytes; unsigned char mask; @@ -735,7 +735,7 @@ network_broadcast(PG_FUNCTION_ARGS) a = ip_addr(ip); b = ip_addr(dst); - for (byte = 0; byte <maxbytes; byte ++) + for (byte = 0; byte < maxbytes; byte++) { if (bits >= 8) { @@ -750,7 +750,7 @@ network_broadcast(PG_FUNCTION_ARGS) bits = 0; } - b[byte] = a[byte] |mask; + b[byte] = a[byte] | mask; } ip_family(dst) = ip_family(ip); @@ -765,7 +765,7 @@ network_network(PG_FUNCTION_ARGS) { inet *ip = PG_GETARG_INET_P(0); inet *dst; - int byte; + int byte; int bits; unsigned char mask; unsigned char *a, @@ -793,8 +793,8 @@ network_network(PG_FUNCTION_ARGS) bits = 0; } - b[byte] = a[byte] &mask; - byte ++; + b[byte] = a[byte] & mask; + byte++; } ip_family(dst) = ip_family(ip); @@ -809,7 +809,7 @@ network_netmask(PG_FUNCTION_ARGS) { inet *ip = PG_GETARG_INET_P(0); inet *dst; - int byte; + int byte; int bits; unsigned char mask; unsigned char *b; @@ -836,7 +836,7 @@ network_netmask(PG_FUNCTION_ARGS) } b[byte] = mask; - byte ++; + byte++; } ip_family(dst) = ip_family(ip); @@ -851,7 +851,7 @@ network_hostmask(PG_FUNCTION_ARGS) { inet *ip = PG_GETARG_INET_P(0); inet *dst; - int byte; + int byte; int bits; int maxbytes; unsigned char mask; @@ -884,7 +884,7 @@ network_hostmask(PG_FUNCTION_ARGS) } b[byte] = mask; - byte --; + byte--; } ip_family(dst) = ip_family(ip); @@ -994,7 +994,7 @@ bitncmp(void *l, void *r, int n) static bool addressOK(unsigned char *a, int bits, int family) { - int byte; + int byte; int nbits; int maxbits; int maxbytes; @@ -1022,12 +1022,12 @@ addressOK(unsigned char *a, int bits, int family) if (bits != 0) mask >>= nbits; - while (byte <maxbytes) + while (byte < maxbytes) { - if ((a[byte] &mask) != 0) + if ((a[byte] & mask) != 0) return false; mask = 0xff; - byte ++; + byte++; } return true; @@ -1396,7 +1396,7 @@ inetmi(PG_FUNCTION_ARGS) * two's complement, too bad. */ int nb = ip_addrsize(ip); - int byte = 0; + int byte = 0; unsigned char *pip = ip_addr(ip); unsigned char *pip2 = ip_addr(ip2); int carry = 1; @@ -1407,9 +1407,9 @@ inetmi(PG_FUNCTION_ARGS) carry = pip[nb] + (~pip2[nb] & 0xFF) + carry; lobyte = carry & 0xFF; - if (byte <sizeof(int64)) + if (byte < sizeof(int64)) { - res |= ((int64) lobyte) << (byte *8); + res |= ((int64) lobyte) << (byte * 8); } else { @@ -1424,15 +1424,15 @@ inetmi(PG_FUNCTION_ARGS) errmsg("result is out of range"))); } carry >>= 8; - byte ++; + byte++; } /* * If input is narrower than int64, overflow is not possible, but we * have to do proper sign extension. */ - if (carry == 0 && byte <sizeof(int64)) - res |= ((int64) -1) << (byte *8); + if (carry == 0 && byte < sizeof(int64)) + res |= ((int64) -1) << (byte * 8); } PG_RETURN_INT64(res); diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c index eec89aa54f2..6b60a5c1c78 100644 --- a/src/backend/utils/adt/numeric.c +++ b/src/backend/utils/adt/numeric.c @@ -94,11 +94,11 @@ typedef int16 NumericDigit; * If the high bits of the first word of a NumericChoice (n_header, or * n_short.n_header, or n_long.n_sign_dscale) are NUMERIC_SHORT, then the * numeric follows the NumericShort format; if they are NUMERIC_POS or - * NUMERIC_NEG, it follows the NumericLong format. If they are NUMERIC_NAN, + * NUMERIC_NEG, it follows the NumericLong format. If they are NUMERIC_NAN, * it is a NaN. We currently always store a NaN using just two bytes (i.e. * only n_header), but previous releases used only the NumericLong format, * so we might find 4-byte NaNs on disk if a database has been migrated using - * pg_upgrade. In either case, when the high bits indicate a NaN, the + * pg_upgrade. In either case, when the high bits indicate a NaN, the * remaining bits are never examined. Currently, we always initialize these * to zero, but it might be possible to use them for some other purpose in * the future. @@ -134,14 +134,14 @@ struct NumericLong union NumericChoice { uint16 n_header; /* Header word */ - struct NumericLong n_long; /* Long form (4-byte header) */ - struct NumericShort n_short; /* Short form (2-byte header) */ + struct NumericLong n_long; /* Long form (4-byte header) */ + struct NumericShort n_short; /* Short form (2-byte header) */ }; struct NumericData { int32 vl_len_; /* varlena header (do not touch directly!) */ - union NumericChoice choice; /* choice of format */ + union NumericChoice choice; /* choice of format */ }; @@ -160,7 +160,7 @@ struct NumericData #define NUMERIC_IS_SHORT(n) (NUMERIC_FLAGBITS(n) == NUMERIC_SHORT) #define NUMERIC_HDRSZ (VARHDRSZ + sizeof(uint16) + sizeof(int16)) -#define NUMERIC_HDRSZ_SHORT (VARHDRSZ + sizeof(uint16)) +#define NUMERIC_HDRSZ_SHORT (VARHDRSZ + sizeof(uint16)) /* * If the flag bits are NUMERIC_SHORT or NUMERIC_NAN, we want the short header; @@ -189,7 +189,7 @@ struct NumericData * Extract sign, display scale, weight. */ -#define NUMERIC_DSCALE_MASK 0x3FFF +#define NUMERIC_DSCALE_MASK 0x3FFF #define NUMERIC_SIGN(n) \ (NUMERIC_IS_SHORT(n) ? \ @@ -551,7 +551,7 @@ numeric_out(PG_FUNCTION_ARGS) /* * numeric_is_nan() - * - * Is Numeric value a NaN? + * Is Numeric value a NaN? */ bool numeric_is_nan(Numeric num) @@ -562,13 +562,13 @@ numeric_is_nan(Numeric num) /* * numeric_maximum_size() - * - * Maximum size of a numeric with given typmod, or -1 if unlimited/unknown. + * Maximum size of a numeric with given typmod, or -1 if unlimited/unknown. */ int32 numeric_maximum_size(int32 typmod) { - int precision; - int numeric_digits; + int precision; + int numeric_digits; if (typmod < (int32) (VARHDRSZ)) return -1; @@ -577,23 +577,23 @@ numeric_maximum_size(int32 typmod) precision = ((typmod - VARHDRSZ) >> 16) & 0xffff; /* - * This formula computes the maximum number of NumericDigits we could - * need in order to store the specified number of decimal digits. - * Because the weight is stored as a number of NumericDigits rather - * than a number of decimal digits, it's possible that the first - * NumericDigit will contain only a single decimal digit. Thus, the - * first two decimal digits can require two NumericDigits to store, - * but it isn't until we reach DEC_DIGITS + 2 decimal digits that we - * potentially need a third NumericDigit. + * This formula computes the maximum number of NumericDigits we could need + * in order to store the specified number of decimal digits. Because the + * weight is stored as a number of NumericDigits rather than a number of + * decimal digits, it's possible that the first NumericDigit will contain + * only a single decimal digit. Thus, the first two decimal digits can + * require two NumericDigits to store, but it isn't until we reach + * DEC_DIGITS + 2 decimal digits that we potentially need a third + * NumericDigit. */ numeric_digits = (precision + 2 * (DEC_DIGITS - 1)) / DEC_DIGITS; /* * In most cases, the size of a numeric will be smaller than the value * computed below, because the varlena header will typically get toasted - * down to a single byte before being stored on disk, and it may also - * be possible to use a short numeric header. But our job here is to - * compute the worst case. + * down to a single byte before being stored on disk, and it may also be + * possible to use a short numeric header. But our job here is to compute + * the worst case. */ return NUMERIC_HDRSZ + (numeric_digits * sizeof(NumericDigit)); } @@ -761,12 +761,13 @@ numeric (PG_FUNCTION_ARGS) * If the number is certainly in bounds and due to the target scale no * rounding could be necessary, just make a copy of the input and modify * its scale fields, unless the larger scale forces us to abandon the - * short representation. (Note we assume the existing dscale is honest...) + * short representation. (Note we assume the existing dscale is + * honest...) */ ddigits = (NUMERIC_WEIGHT(num) + 1) * DEC_DIGITS; if (ddigits <= maxdigits && scale >= NUMERIC_DSCALE(num) && (NUMERIC_CAN_BE_SHORT(scale, NUMERIC_WEIGHT(num)) - || !NUMERIC_IS_SHORT(num))) + || !NUMERIC_IS_SHORT(num))) { new = (Numeric) palloc(VARSIZE(num)); memcpy(new, num, VARSIZE(num)); @@ -1427,7 +1428,7 @@ hash_numeric(PG_FUNCTION_ARGS) int end_offset; int i; int hash_len; - NumericDigit *digits; + NumericDigit *digits; /* If it's NaN, don't try to hash the rest of the fields */ if (NUMERIC_IS_NAN(key)) @@ -3727,7 +3728,7 @@ make_result(NumericVar *var) SET_VARSIZE(result, len); result->choice.n_short.n_header = (sign == NUMERIC_NEG ? (NUMERIC_SHORT | NUMERIC_SHORT_SIGN_MASK) - : NUMERIC_SHORT) + : NUMERIC_SHORT) | (var->dscale << NUMERIC_SHORT_DSCALE_SHIFT) | (weight < 0 ? NUMERIC_SHORT_WEIGHT_SIGN_MASK : 0) | (weight & NUMERIC_SHORT_WEIGHT_MASK); diff --git a/src/backend/utils/adt/numutils.c b/src/backend/utils/adt/numutils.c index 38ce38821e1..37d208994c1 100644 --- a/src/backend/utils/adt/numutils.c +++ b/src/backend/utils/adt/numutils.c @@ -136,7 +136,7 @@ pg_ltoa(int32 value, char *a) * Avoid problems with the most negative integer not being representable * as a positive integer. */ - if (value == (-2147483647-1)) + if (value == (-2147483647 - 1)) { memcpy(a, "-2147483648", 12); return; @@ -150,8 +150,8 @@ pg_ltoa(int32 value, char *a) /* Compute the result string backwards. */ do { - int32 remainder; - int32 oldval = value; + int32 remainder; + int32 oldval = value; value /= 10; remainder = oldval - value * 10; @@ -167,7 +167,7 @@ pg_ltoa(int32 value, char *a) /* Reverse string. */ while (start < a) { - char swap = *start; + char swap = *start; *start++ = *a; *a-- = swap; @@ -190,7 +190,7 @@ pg_lltoa(int64 value, char *a) * Avoid problems with the most negative integer not being representable * as a positive integer. */ - if (value == (-INT64CONST(0x7FFFFFFFFFFFFFFF)-1)) + if (value == (-INT64CONST(0x7FFFFFFFFFFFFFFF) - 1)) { memcpy(a, "-9223372036854775808", 21); return; @@ -204,8 +204,8 @@ pg_lltoa(int64 value, char *a) /* Compute the result string backwards. */ do { - int64 remainder; - int64 oldval = value; + int64 remainder; + int64 oldval = value; value /= 10; remainder = oldval - value * 10; @@ -221,7 +221,7 @@ pg_lltoa(int64 value, char *a) /* Reverse string. */ while (start < a) { - char swap = *start; + char swap = *start; *start++ = *a; *a-- = swap; diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c index 09ff926cba6..0e6723d4690 100644 --- a/src/backend/utils/adt/pg_locale.c +++ b/src/backend/utils/adt/pg_locale.c @@ -107,7 +107,7 @@ typedef struct bool collate_is_c; /* is collation's LC_COLLATE C? */ bool ctype_is_c; /* is collation's LC_CTYPE C? */ bool flags_valid; /* true if above flags are valid */ - pg_locale_t locale; /* locale_t struct, or 0 if not valid */ + pg_locale_t locale; /* locale_t struct, or 0 if not valid */ } collation_cache_entry; static HTAB *collation_cache = NULL; @@ -242,7 +242,7 @@ check_locale(int category, const char *value) * * For most locale categories, the assign hook doesn't actually set the locale * permanently, just reset flags so that the next use will cache the - * appropriate values. (See explanation at the top of this file.) + * appropriate values. (See explanation at the top of this file.) * * Note: we accept value = "" as selecting the postmaster's environment * value, whatever it was (so long as the environment setting is legal). @@ -728,7 +728,6 @@ IsoLocaleName(const char *winlocname) return NULL; /* Not supported on this version of msvc/mingw */ #endif /* _MSC_VER >= 1400 */ } - #endif /* WIN32 && LC_MESSAGES */ @@ -750,7 +749,7 @@ IsoLocaleName(const char *winlocname) * could fail if the locale is C, so str_tolower() shouldn't call it * in that case. * - * Note that we currently lack any way to flush the cache. Since we don't + * Note that we currently lack any way to flush the cache. Since we don't * support ALTER COLLATION, this is OK. The worst case is that someone * drops a collation, and a useless cache entry hangs around in existing * backends. @@ -826,15 +825,15 @@ bool lc_collate_is_c(Oid collation) { /* - * If we're asked about "collation 0", return false, so that the code - * will go into the non-C path and report that the collation is bogus. + * If we're asked about "collation 0", return false, so that the code will + * go into the non-C path and report that the collation is bogus. */ if (!OidIsValid(collation)) return false; /* - * If we're asked about the default collation, we have to inquire of - * the C library. Cache the result so we only have to compute it once. + * If we're asked about the default collation, we have to inquire of the C + * library. Cache the result so we only have to compute it once. */ if (collation == DEFAULT_COLLATION_OID) { @@ -876,15 +875,15 @@ bool lc_ctype_is_c(Oid collation) { /* - * If we're asked about "collation 0", return false, so that the code - * will go into the non-C path and report that the collation is bogus. + * If we're asked about "collation 0", return false, so that the code will + * go into the non-C path and report that the collation is bogus. */ if (!OidIsValid(collation)) return false; /* - * If we're asked about the default collation, we have to inquire of - * the C library. Cache the result so we only have to compute it once. + * If we're asked about the default collation, we have to inquire of the C + * library. Cache the result so we only have to compute it once. */ if (collation == DEFAULT_COLLATION_OID) { @@ -921,7 +920,7 @@ lc_ctype_is_c(Oid collation) /* - * Create a locale_t from a collation OID. Results are cached for the + * Create a locale_t from a collation OID. Results are cached for the * lifetime of the backend. Thus, do not free the result with freelocale(). * * As a special optimization, the default/database collation returns 0. @@ -987,7 +986,7 @@ pg_newlocale_from_collation(Oid collid) { #ifndef WIN32 /* We need two newlocale() steps */ - locale_t loc1; + locale_t loc1; loc1 = newlocale(LC_COLLATE_MASK, collcollate, NULL); if (!loc1) @@ -1002,10 +1001,11 @@ pg_newlocale_from_collation(Oid collid) errmsg("could not create locale \"%s\": %m", collctype))); #else + /* - * XXX The _create_locale() API doesn't appear to support - * this. Could perhaps be worked around by changing - * pg_locale_t to contain two separate fields. + * XXX The _create_locale() API doesn't appear to support this. + * Could perhaps be worked around by changing pg_locale_t to + * contain two separate fields. */ ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), @@ -1016,8 +1016,7 @@ pg_newlocale_from_collation(Oid collid) cache_entry->locale = result; ReleaseSysCache(tp); - -#else /* not HAVE_LOCALE_T */ +#else /* not HAVE_LOCALE_T */ /* * For platforms that don't support locale_t, we can't do anything @@ -1025,8 +1024,8 @@ pg_newlocale_from_collation(Oid collid) */ ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("nondefault collations are not supported on this platform"))); -#endif /* not HAVE_LOCALE_T */ + errmsg("nondefault collations are not supported on this platform"))); +#endif /* not HAVE_LOCALE_T */ } return cache_entry->locale; diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c index 137c811bc3a..f811245cea0 100644 --- a/src/backend/utils/adt/pgstatfuncs.c +++ b/src/backend/utils/adt/pgstatfuncs.c @@ -364,7 +364,7 @@ pg_stat_get_vacuum_count(PG_FUNCTION_ARGS) { Oid relid = PG_GETARG_OID(0); int64 result; - PgStat_StatTabEntry *tabentry; + PgStat_StatTabEntry *tabentry; if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL) result = 0; @@ -379,7 +379,7 @@ pg_stat_get_autovacuum_count(PG_FUNCTION_ARGS) { Oid relid = PG_GETARG_OID(0); int64 result; - PgStat_StatTabEntry *tabentry; + PgStat_StatTabEntry *tabentry; if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL) result = 0; @@ -394,7 +394,7 @@ pg_stat_get_analyze_count(PG_FUNCTION_ARGS) { Oid relid = PG_GETARG_OID(0); int64 result; - PgStat_StatTabEntry *tabentry; + PgStat_StatTabEntry *tabentry; if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL) result = 0; @@ -409,7 +409,7 @@ pg_stat_get_autoanalyze_count(PG_FUNCTION_ARGS) { Oid relid = PG_GETARG_OID(0); int64 result; - PgStat_StatTabEntry *tabentry; + PgStat_StatTabEntry *tabentry; if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL) result = 0; @@ -1263,11 +1263,11 @@ pg_stat_get_db_conflict_all(PG_FUNCTION_ARGS) result = 0; else result = (int64) ( - dbentry->n_conflict_tablespace + - dbentry->n_conflict_lock + - dbentry->n_conflict_snapshot + - dbentry->n_conflict_bufferpin + - dbentry->n_conflict_startup_deadlock); + dbentry->n_conflict_tablespace + + dbentry->n_conflict_lock + + dbentry->n_conflict_snapshot + + dbentry->n_conflict_bufferpin + + dbentry->n_conflict_startup_deadlock); PG_RETURN_INT64(result); } diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c index 591d2eb16b0..84797191efa 100644 --- a/src/backend/utils/adt/ri_triggers.c +++ b/src/backend/utils/adt/ri_triggers.c @@ -2608,7 +2608,7 @@ RI_FKey_keyequal_upd_fk(Trigger *trigger, Relation fk_rel, * This is not a trigger procedure, but is called during ALTER TABLE * ADD FOREIGN KEY to validate the initial table contents. * - * We expect that the caller has made provision to prevent any problems + * We expect that the caller has made provision to prevent any problems * caused by concurrent actions. This could be either by locking rel and * pkrel at ShareRowExclusiveLock or higher, or by otherwise ensuring * that triggers implementing the checks are already active. @@ -2629,8 +2629,8 @@ RI_Initial_Check(Trigger *trigger, Relation fk_rel, Relation pk_rel) char fkrelname[MAX_QUOTED_REL_NAME_LEN]; char pkattname[MAX_QUOTED_NAME_LEN + 3]; char fkattname[MAX_QUOTED_NAME_LEN + 3]; - RangeTblEntry *pkrte; - RangeTblEntry *fkrte; + RangeTblEntry *pkrte; + RangeTblEntry *fkrte; const char *sep; int i; int old_work_mem; @@ -2662,7 +2662,7 @@ RI_Initial_Check(Trigger *trigger, Relation fk_rel, Relation pk_rel) for (i = 0; i < riinfo.nkeys; i++) { - int attno; + int attno; attno = riinfo.pk_attnums[i] - FirstLowInvalidHeapAttributeNumber; pkrte->selectedCols = bms_add_member(pkrte->selectedCols, attno); @@ -2789,10 +2789,10 @@ RI_Initial_Check(Trigger *trigger, Relation fk_rel, Relation pk_rel) /* * Run the plan. For safety we force a current snapshot to be used. (In - * transaction-snapshot mode, this arguably violates transaction - * isolation rules, but we really haven't got much choice.) - * We don't need to register the snapshot, because SPI_execute_snapshot - * will see to it. We need at most one tuple returned, so pass limit = 1. + * transaction-snapshot mode, this arguably violates transaction isolation + * rules, but we really haven't got much choice.) We don't need to + * register the snapshot, because SPI_execute_snapshot will see to it. We + * need at most one tuple returned, so pass limit = 1. */ spi_result = SPI_execute_snapshot(qplan, NULL, NULL, @@ -3337,8 +3337,8 @@ ri_PerformCheck(RI_QueryKey *qkey, SPIPlanPtr qplan, /* * In READ COMMITTED mode, we just need to use an up-to-date regular * snapshot, and we will see all rows that could be interesting. But in - * transaction-snapshot mode, we can't change the transaction snapshot. - * If the caller passes detectNewRows == false then it's okay to do the query + * transaction-snapshot mode, we can't change the transaction snapshot. If + * the caller passes detectNewRows == false then it's okay to do the query * with the transaction snapshot; otherwise we use a current snapshot, and * tell the executor to error out if it finds any rows under the current * snapshot that wouldn't be visible per the transaction snapshot. Note diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 326079a75ba..e436a1ee59f 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -169,11 +169,11 @@ static void set_deparse_planstate(deparse_namespace *dpns, PlanState *ps); static void push_child_plan(deparse_namespace *dpns, PlanState *ps, deparse_namespace *save_dpns); static void pop_child_plan(deparse_namespace *dpns, - deparse_namespace *save_dpns); + deparse_namespace *save_dpns); static void push_ancestor_plan(deparse_namespace *dpns, ListCell *ancestor_cell, deparse_namespace *save_dpns); static void pop_ancestor_plan(deparse_namespace *dpns, - deparse_namespace *save_dpns); + deparse_namespace *save_dpns); static void make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc, int prettyFlags); static void make_viewdef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc, @@ -948,7 +948,7 @@ pg_get_indexdef_worker(Oid indexrelid, int colno, if (!attrsOnly && (!colno || colno == keyno + 1)) { - Oid indcoll; + Oid indcoll; /* Add collation, if not default for column */ indcoll = indcollation->values[keyno]; @@ -2207,7 +2207,7 @@ set_deparse_planstate(deparse_namespace *dpns, PlanState *ps) * We special-case Append and MergeAppend to pretend that the first child * plan is the OUTER referent; we have to interpret OUTER Vars in their * tlists according to one of the children, and the first one is the most - * natural choice. Likewise special-case ModifyTable to pretend that the + * natural choice. Likewise special-case ModifyTable to pretend that the * first child plan is the OUTER referent; this is to support RETURNING * lists containing references to non-target relations. */ @@ -2263,8 +2263,8 @@ push_child_plan(deparse_namespace *dpns, PlanState *ps, /* * Currently we don't bother to adjust the ancestors list, because an - * OUTER or INNER reference really shouldn't contain any Params that - * would be set by the parent node itself. If we did want to adjust it, + * OUTER or INNER reference really shouldn't contain any Params that would + * be set by the parent node itself. If we did want to adjust it, * lcons'ing dpns->planstate onto dpns->ancestors would be the appropriate * thing --- and pop_child_plan would need to undo the change to the list. */ @@ -3780,8 +3780,8 @@ get_variable(Var *var, int levelsup, bool showstar, deparse_context *context) * subquery's alias, that's not possible for resjunk items since they have * no alias. So in that case, drill down to the subplan and print the * contents of the referenced tlist item. This works because in a plan - * tree, such Vars can only occur in a SubqueryScan or CteScan node, - * and we'll have set dpns->inner_plan to reference the child plan node. + * tree, such Vars can only occur in a SubqueryScan or CteScan node, and + * we'll have set dpns->inner_plan to reference the child plan node. */ if ((rte->rtekind == RTE_SUBQUERY || rte->rtekind == RTE_CTE) && attnum > list_length(rte->eref->colnames) && @@ -4145,7 +4145,7 @@ get_name_for_var_field(Var *var, int fieldno, if (lc != NULL) { Query *ctequery = (Query *) cte->ctequery; - TargetEntry *ste = get_tle_by_resno(GetCTETargetList(cte), + TargetEntry *ste = get_tle_by_resno(GetCTETargetList(cte), attnum); if (ste == NULL || ste->resjunk) @@ -4279,11 +4279,11 @@ static void get_parameter(Param *param, deparse_context *context) { /* - * If it's a PARAM_EXEC parameter, try to locate the expression from - * which the parameter was computed. This will necessarily be in some - * ancestor of the current expression's PlanState. Note that failing - * to find a referent isn't an error, since the Param might well be a - * subplan output rather than an input. + * If it's a PARAM_EXEC parameter, try to locate the expression from which + * the parameter was computed. This will necessarily be in some ancestor + * of the current expression's PlanState. Note that failing to find a + * referent isn't an error, since the Param might well be a subplan output + * rather than an input. */ if (param->paramkind == PARAM_EXEC) { @@ -4302,9 +4302,9 @@ get_parameter(Param *param, deparse_context *context) ListCell *lc2; /* - * NestLoops transmit params to their inner child only; also, - * once we've crawled up out of a subplan, this couldn't - * possibly be the right match. + * NestLoops transmit params to their inner child only; also, once + * we've crawled up out of a subplan, this couldn't possibly be + * the right match. */ if (IsA(ps, NestLoopState) && child_ps == innerPlanState(ps) && @@ -4314,7 +4314,7 @@ get_parameter(Param *param, deparse_context *context) foreach(lc2, nl->nestParams) { - NestLoopParam *nlp = (NestLoopParam *) lfirst(lc2); + NestLoopParam *nlp = (NestLoopParam *) lfirst(lc2); if (nlp->paramno == param->paramid) { @@ -4342,8 +4342,8 @@ get_parameter(Param *param, deparse_context *context) /* Matched subplan, so check its arguments */ forboth(lc3, subplan->parParam, lc4, subplan->args) { - int paramid = lfirst_int(lc3); - Node *arg = (Node *) lfirst(lc4); + int paramid = lfirst_int(lc3); + Node *arg = (Node *) lfirst(lc4); if (paramid == param->paramid) { @@ -4898,7 +4898,7 @@ get_rule_expr(Node *node, deparse_context *context, appendStringInfo(buf, " %s %s (", generate_operator_name(expr->opno, exprType(arg1), - get_base_element_type(exprType(arg2))), + get_base_element_type(exprType(arg2))), expr->useOr ? "ANY" : "ALL"); get_rule_expr_paren(arg2, context, true, node); appendStringInfoChar(buf, ')'); @@ -6126,7 +6126,7 @@ get_const_collation(Const *constval, deparse_context *context) if (OidIsValid(constval->constcollid)) { - Oid typcollation = get_typcollation(constval->consttype); + Oid typcollation = get_typcollation(constval->consttype); if (constval->constcollid != typcollation) { @@ -6384,7 +6384,7 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context) gavealias = true; } else if (rte->rtekind == RTE_RELATION && - strcmp(rte->eref->aliasname, get_relation_name(rte->relid)) != 0) + strcmp(rte->eref->aliasname, get_relation_name(rte->relid)) != 0) { /* * Apparently the rel has been renamed since the rule was made. diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index 092dc15a02b..41c5202146d 100644 --- a/src/backend/utils/adt/selfuncs.c +++ b/src/backend/utils/adt/selfuncs.c @@ -6329,28 +6329,28 @@ gincostestimate(PG_FUNCTION_ARGS) Cost *indexTotalCost = (Cost *) PG_GETARG_POINTER(6); Selectivity *indexSelectivity = (Selectivity *) PG_GETARG_POINTER(7); double *indexCorrelation = (double *) PG_GETARG_POINTER(8); - ListCell *l; - List *selectivityQuals; - double numPages = index->pages, - numTuples = index->tuples; - double numEntryPages, - numDataPages, - numPendingPages, - numEntries; - bool haveFullScan = false; - double partialEntriesInQuals = 0.0; - double searchEntriesInQuals = 0.0; - double exactEntriesInQuals = 0.0; - double entryPagesFetched, - dataPagesFetched, - dataPagesFetchedBySel; - double qual_op_cost, - qual_arg_cost, - spc_random_page_cost, - num_scans; - QualCost index_qual_cost; - Relation indexRel; - GinStatsData ginStats; + ListCell *l; + List *selectivityQuals; + double numPages = index->pages, + numTuples = index->tuples; + double numEntryPages, + numDataPages, + numPendingPages, + numEntries; + bool haveFullScan = false; + double partialEntriesInQuals = 0.0; + double searchEntriesInQuals = 0.0; + double exactEntriesInQuals = 0.0; + double entryPagesFetched, + dataPagesFetched, + dataPagesFetchedBySel; + double qual_op_cost, + qual_arg_cost, + spc_random_page_cost, + num_scans; + QualCost index_qual_cost; + Relation indexRel; + GinStatsData ginStats; /* * Obtain statistic information from the meta page @@ -6366,7 +6366,7 @@ gincostestimate(PG_FUNCTION_ARGS) /* * nPendingPages can be trusted, but the other fields are as of the last - * VACUUM. Scale them by the ratio numPages / nTotalPages to account for + * VACUUM. Scale them by the ratio numPages / nTotalPages to account for * growth since then. If the fields are zero (implying no VACUUM at all, * and an index created pre-9.1), assume all pages are entry pages. */ @@ -6374,11 +6374,11 @@ gincostestimate(PG_FUNCTION_ARGS) { numEntryPages = numPages; numDataPages = 0; - numEntries = numTuples; /* bogus, but no other info available */ + numEntries = numTuples; /* bogus, but no other info available */ } else { - double scale = numPages / ginStats.nTotalPages; + double scale = numPages / ginStats.nTotalPages; numEntryPages = ceil(numEntryPages * scale); numDataPages = ceil(numDataPages * scale); @@ -6389,7 +6389,8 @@ gincostestimate(PG_FUNCTION_ARGS) } /* - * Include predicate in selectivityQuals (should match genericcostestimate) + * Include predicate in selectivityQuals (should match + * genericcostestimate) */ if (index->indpred != NIL) { @@ -6411,12 +6412,12 @@ gincostestimate(PG_FUNCTION_ARGS) /* Estimate the fraction of main-table tuples that will be visited */ *indexSelectivity = clauselist_selectivity(root, selectivityQuals, - index->rel->relid, - JOIN_INNER, - NULL); + index->rel->relid, + JOIN_INNER, + NULL); /* fetch estimated page cost for schema containing index */ - get_tablespace_page_costs(index->reltablespace, + get_tablespace_page_costs(index->reltablespace, &spc_random_page_cost, NULL); @@ -6430,22 +6431,22 @@ gincostestimate(PG_FUNCTION_ARGS) */ foreach(l, indexQuals) { - RestrictInfo *rinfo = (RestrictInfo *) lfirst(l); - Expr *clause; - Node *leftop, - *rightop, - *operand; - Oid extractProcOid; - Oid clause_op; - int strategy_op; - Oid lefttype, - righttype; - int32 nentries = 0; - bool *partial_matches = NULL; - Pointer *extra_data = NULL; - bool *nullFlags = NULL; - int32 searchMode = GIN_SEARCH_MODE_DEFAULT; - int indexcol; + RestrictInfo *rinfo = (RestrictInfo *) lfirst(l); + Expr *clause; + Node *leftop, + *rightop, + *operand; + Oid extractProcOid; + Oid clause_op; + int strategy_op; + Oid lefttype, + righttype; + int32 nentries = 0; + bool *partial_matches = NULL; + Pointer *extra_data = NULL; + bool *nullFlags = NULL; + int32 searchMode = GIN_SEARCH_MODE_DEFAULT; + int indexcol; Assert(IsA(rinfo, RestrictInfo)); clause = rinfo->clause; @@ -6466,16 +6467,16 @@ gincostestimate(PG_FUNCTION_ARGS) else { elog(ERROR, "could not match index to operand"); - operand = NULL; /* keep compiler quiet */ + operand = NULL; /* keep compiler quiet */ } if (IsA(operand, RelabelType)) operand = (Node *) ((RelabelType *) operand)->arg; /* - * It's impossible to call extractQuery method for unknown operand. - * So unless operand is a Const we can't do much; just assume there - * will be one ordinary search entry from the operand at runtime. + * It's impossible to call extractQuery method for unknown operand. So + * unless operand is a Const we can't do much; just assume there will + * be one ordinary search entry from the operand at runtime. */ if (!IsA(operand, Const)) { @@ -6484,7 +6485,7 @@ gincostestimate(PG_FUNCTION_ARGS) } /* If Const is null, there can be no matches */ - if (((Const*) operand)->constisnull) + if (((Const *) operand)->constisnull) { *indexStartupCost = 0; *indexTotalCost = 0; @@ -6494,9 +6495,9 @@ gincostestimate(PG_FUNCTION_ARGS) /* * Get the operator's strategy number and declared input data types - * within the index opfamily. (We don't need the latter, but we - * use get_op_opfamily_properties because it will throw error if - * it fails to find a matching pg_amop entry.) + * within the index opfamily. (We don't need the latter, but we use + * get_op_opfamily_properties because it will throw error if it fails + * to find a matching pg_amop entry.) */ get_op_opfamily_properties(clause_op, index->opfamily[indexcol], false, &strategy_op, &lefttype, &righttype); @@ -6515,12 +6516,12 @@ gincostestimate(PG_FUNCTION_ARGS) { /* should not happen; throw same error as index_getprocinfo */ elog(ERROR, "missing support function %d for attribute %d of index \"%s\"", - GIN_EXTRACTQUERY_PROC, indexcol+1, + GIN_EXTRACTQUERY_PROC, indexcol + 1, get_rel_name(index->indexoid)); } OidFunctionCall7(extractProcOid, - ((Const*) operand)->constvalue, + ((Const *) operand)->constvalue, PointerGetDatum(&nentries), UInt16GetDatum(strategy_op), PointerGetDatum(&partial_matches), @@ -6538,9 +6539,9 @@ gincostestimate(PG_FUNCTION_ARGS) } else { - int32 i; + int32 i; - for (i=0; i<nentries; i++) + for (i = 0; i < nentries; i++) { /* * For partial match we haven't any information to estimate @@ -6585,32 +6586,30 @@ gincostestimate(PG_FUNCTION_ARGS) num_scans = 1; /* - * cost to begin scan, first of all, pay attention to - * pending list. + * cost to begin scan, first of all, pay attention to pending list. */ entryPagesFetched = numPendingPages; /* * Estimate number of entry pages read. We need to do * searchEntriesInQuals searches. Use a power function as it should be, - * but tuples on leaf pages usually is much greater. - * Here we include all searches in entry tree, including - * search of first entry in partial match algorithm + * but tuples on leaf pages usually is much greater. Here we include all + * searches in entry tree, including search of first entry in partial + * match algorithm */ entryPagesFetched += ceil(searchEntriesInQuals * rint(pow(numEntryPages, 0.15))); /* - * Add an estimate of entry pages read by partial match algorithm. - * It's a scan over leaf pages in entry tree. We haven't any useful stats - * here, so estimate it as proportion. + * Add an estimate of entry pages read by partial match algorithm. It's a + * scan over leaf pages in entry tree. We haven't any useful stats here, + * so estimate it as proportion. */ entryPagesFetched += ceil(numEntryPages * partialEntriesInQuals / numEntries); /* - * Partial match algorithm reads all data pages before - * doing actual scan, so it's a startup cost. Again, - * we havn't any useful stats here, so, estimate it as - * proportion + * Partial match algorithm reads all data pages before doing actual scan, + * so it's a startup cost. Again, we havn't any useful stats here, so, + * estimate it as proportion */ dataPagesFetched = ceil(numDataPages * partialEntriesInQuals / numEntries); @@ -6626,8 +6625,8 @@ gincostestimate(PG_FUNCTION_ARGS) } /* - * Here we use random page cost because logically-close pages could be - * far apart on disk. + * Here we use random page cost because logically-close pages could be far + * apart on disk. */ *indexStartupCost = (entryPagesFetched + dataPagesFetched) * spc_random_page_cost; @@ -6639,16 +6638,16 @@ gincostestimate(PG_FUNCTION_ARGS) * capacity of data page. */ dataPagesFetchedBySel = ceil(*indexSelectivity * - (numTuples / (BLCKSZ/SizeOfIptrData))); + (numTuples / (BLCKSZ / SizeOfIptrData))); if (dataPagesFetchedBySel > dataPagesFetched) { /* - * At least one of entries is very frequent and, unfortunately, - * we couldn't get statistic about entries (only tsvector has - * such statistics). So, we obviously have too small estimation of - * pages fetched from data tree. Re-estimate it from known - * capacity of data pages + * At least one of entries is very frequent and, unfortunately, we + * couldn't get statistic about entries (only tsvector has such + * statistics). So, we obviously have too small estimation of pages + * fetched from data tree. Re-estimate it from known capacity of data + * pages */ dataPagesFetched = dataPagesFetchedBySel; } @@ -6670,7 +6669,7 @@ gincostestimate(PG_FUNCTION_ARGS) qual_op_cost = cpu_operator_cost * (list_length(indexQuals) + list_length(indexOrderBys)); qual_arg_cost -= qual_op_cost; - if (qual_arg_cost < 0) /* just in case... */ + if (qual_arg_cost < 0) /* just in case... */ qual_arg_cost = 0; *indexStartupCost += qual_arg_cost; diff --git a/src/backend/utils/adt/tsginidx.c b/src/backend/utils/adt/tsginidx.c index 41700bfcf15..4cb961146b8 100644 --- a/src/backend/utils/adt/tsginidx.c +++ b/src/backend/utils/adt/tsginidx.c @@ -95,10 +95,12 @@ gin_extract_tsquery(PG_FUNCTION_ARGS) { TSQuery query = PG_GETARG_TSQUERY(0); int32 *nentries = (int32 *) PG_GETARG_POINTER(1); + /* StrategyNumber strategy = PG_GETARG_UINT16(2); */ bool **ptr_partialmatch = (bool **) PG_GETARG_POINTER(3); Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4); - /* bool **nullFlags = (bool **) PG_GETARG_POINTER(5); */ + + /* bool **nullFlags = (bool **) PG_GETARG_POINTER(5); */ int32 *searchMode = (int32 *) PG_GETARG_POINTER(6); Datum *entries = NULL; @@ -114,8 +116,8 @@ gin_extract_tsquery(PG_FUNCTION_ARGS) /* * If the query doesn't have any required positive matches (for - * instance, it's something like '! foo'), we have to do a full - * index scan. + * instance, it's something like '! foo'), we have to do a full index + * scan. */ if (tsquery_requires_match(item)) *searchMode = GIN_SEARCH_MODE_DEFAULT; @@ -235,7 +237,7 @@ gin_tsquery_consistent(PG_FUNCTION_ARGS) * Formerly, gin_extract_tsvector had only two arguments. Now it has three, * but we still need a pg_proc entry with two args to support reloading * pre-9.1 contrib/tsearch2 opclass declarations. This compatibility - * function should go away eventually. (Note: you might say "hey, but the + * function should go away eventually. (Note: you might say "hey, but the * code above is only *using* two args, so let's just declare it that way". * If you try that you'll find the opr_sanity regression test complains.) */ diff --git a/src/backend/utils/adt/tsvector_op.c b/src/backend/utils/adt/tsvector_op.c index b7a822d3544..66674917f0d 100644 --- a/src/backend/utils/adt/tsvector_op.c +++ b/src/backend/utils/adt/tsvector_op.c @@ -711,6 +711,7 @@ tsquery_requires_match(QueryItem *curitem) switch (curitem->qoperator.oper) { case OP_NOT: + /* * Assume there are no required matches underneath a NOT. For * some cases with nested NOTs, we could prove there's a required diff --git a/src/backend/utils/adt/varbit.c b/src/backend/utils/adt/varbit.c index 0eb6071e123..3fa81175fd8 100644 --- a/src/backend/utils/adt/varbit.c +++ b/src/backend/utils/adt/varbit.c @@ -237,6 +237,7 @@ bit_out(PG_FUNCTION_ARGS) /* same as varbit output */ return varbit_out(fcinfo); #else + /* * This is how one would print a hex string, in case someone wants to * write a formatting function. diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c index 7a545214755..9d96013d57e 100644 --- a/src/backend/utils/adt/varlena.c +++ b/src/backend/utils/adt/varlena.c @@ -81,7 +81,7 @@ void text_format_string_conversion(StringInfo buf, char conversion, static Datum text_to_array_internal(PG_FUNCTION_ARGS); static text *array_to_text_internal(FunctionCallInfo fcinfo, ArrayType *v, - char *fldsep, char *null_string); + char *fldsep, char *null_string); /***************************************************************************** @@ -1299,7 +1299,7 @@ varstr_cmp(char *arg1, int len1, char *arg2, int len2, Oid collid) char a2buf[STACKBUFLEN]; char *a1p, *a2p; - pg_locale_t mylocale = 0; + pg_locale_t mylocale = 0; if (collid != DEFAULT_COLLATION_OID) { @@ -1379,7 +1379,7 @@ varstr_cmp(char *arg1, int len1, char *arg2, int len2, Oid collid) result = wcscoll_l((LPWSTR) a1p, (LPWSTR) a2p, mylocale); else #endif - result = wcscoll((LPWSTR) a1p, (LPWSTR) a2p); + result = wcscoll((LPWSTR) a1p, (LPWSTR) a2p); if (result == 2147483647) /* _NLSCMPERROR; missing from mingw * headers */ ereport(ERROR, @@ -1426,7 +1426,7 @@ varstr_cmp(char *arg1, int len1, char *arg2, int len2, Oid collid) result = strcoll_l(a1p, a2p, mylocale); else #endif - result = strcoll(a1p, a2p); + result = strcoll(a1p, a2p); /* * In some locales strcoll() can claim that nonidentical strings are @@ -1487,10 +1487,10 @@ texteq(PG_FUNCTION_ARGS) /* * Since we only care about equality or not-equality, we can avoid all the - * expense of strcoll() here, and just do bitwise comparison. In fact, - * we don't even have to do a bitwise comparison if we can show the - * lengths of the strings are unequal; which might save us from having - * to detoast one or both values. + * expense of strcoll() here, and just do bitwise comparison. In fact, we + * don't even have to do a bitwise comparison if we can show the lengths + * of the strings are unequal; which might save us from having to detoast + * one or both values. */ len1 = toast_raw_datum_size(arg1); len2 = toast_raw_datum_size(arg2); @@ -2031,7 +2031,7 @@ byteaGetByte(PG_FUNCTION_ARGS) bytea *v = PG_GETARG_BYTEA_PP(0); int32 n = PG_GETARG_INT32(1); int len; - int byte; + int byte; len = VARSIZE_ANY_EXHDR(v); @@ -2062,7 +2062,7 @@ byteaGetBit(PG_FUNCTION_ARGS) int byteNo, bitNo; int len; - int byte; + int byte; len = VARSIZE_ANY_EXHDR(v); @@ -2077,7 +2077,7 @@ byteaGetBit(PG_FUNCTION_ARGS) byte = ((unsigned char *) VARDATA_ANY(v))[byteNo]; - if (byte &(1 << bitNo)) + if (byte & (1 << bitNo)) PG_RETURN_INT32(1); else PG_RETURN_INT32(0); @@ -3144,7 +3144,7 @@ text_to_array_internal(PG_FUNCTION_ARGS) /* single element can be a NULL too */ is_null = null_string ? text_isequal(inputstring, null_string) : false; PG_RETURN_ARRAYTYPE_P(create_singleton_array(fcinfo, TEXTOID, - PointerGetDatum(inputstring), + PointerGetDatum(inputstring), is_null, 1)); } @@ -3152,7 +3152,7 @@ text_to_array_internal(PG_FUNCTION_ARGS) /* start_ptr points to the start_posn'th character of inputstring */ start_ptr = VARDATA_ANY(inputstring); - for (fldnum = 1;; fldnum++) /* field number is 1 based */ + for (fldnum = 1;; fldnum++) /* field number is 1 based */ { CHECK_FOR_INTERRUPTS(); @@ -3197,8 +3197,8 @@ text_to_array_internal(PG_FUNCTION_ARGS) { /* * When fldsep is NULL, each character in the inputstring becomes an - * element in the result array. The separator is effectively the space - * between characters. + * element in the result array. The separator is effectively the + * space between characters. */ inputstring_len = VARSIZE_ANY_EXHDR(inputstring); @@ -3210,7 +3210,7 @@ text_to_array_internal(PG_FUNCTION_ARGS) while (inputstring_len > 0) { - int chunk_len = pg_mblen(start_ptr); + int chunk_len = pg_mblen(start_ptr); CHECK_FOR_INTERRUPTS(); @@ -3625,9 +3625,9 @@ string_agg_finalfn(PG_FUNCTION_ARGS) static text * concat_internal(const char *sepstr, int seplen, int argidx, FunctionCallInfo fcinfo) { - StringInfoData str; - text *result; - int i; + StringInfoData str; + text *result; + int i; initStringInfo(&str); @@ -3635,10 +3635,10 @@ concat_internal(const char *sepstr, int seplen, int argidx, FunctionCallInfo fci { if (!PG_ARGISNULL(i)) { - Oid valtype; - Datum value; - Oid typOutput; - bool typIsVarlena; + Oid valtype; + Datum value; + Oid typOutput; + bool typIsVarlena; if (i > argidx) appendBinaryStringInfo(&str, sepstr, seplen); @@ -3648,7 +3648,7 @@ concat_internal(const char *sepstr, int seplen, int argidx, FunctionCallInfo fci valtype = get_fn_expr_argtype(fcinfo->flinfo, i); getTypeOutputInfo(valtype, &typOutput, &typIsVarlena); appendStringInfoString(&str, - OidOutputFunctionCall(typOutput, value)); + OidOutputFunctionCall(typOutput, value)); } } @@ -3674,7 +3674,7 @@ text_concat(PG_FUNCTION_ARGS) Datum text_concat_ws(PG_FUNCTION_ARGS) { - text *sep; + text *sep; /* return NULL when separator is NULL */ if (PG_ARGISNULL(0)) @@ -3683,7 +3683,7 @@ text_concat_ws(PG_FUNCTION_ARGS) sep = PG_GETARG_TEXT_PP(0); PG_RETURN_TEXT_P(concat_internal( - VARDATA_ANY(sep), VARSIZE_ANY_EXHDR(sep), 1, fcinfo)); + VARDATA_ANY(sep), VARSIZE_ANY_EXHDR(sep), 1, fcinfo)); } /* @@ -3734,15 +3734,15 @@ text_right(PG_FUNCTION_ARGS) Datum text_reverse(PG_FUNCTION_ARGS) { - text *str = PG_GETARG_TEXT_PP(0); - const char *p = VARDATA_ANY(str); - int len = VARSIZE_ANY_EXHDR(str); - const char *endp = p + len; - text *result; - char *dst; + text *str = PG_GETARG_TEXT_PP(0); + const char *p = VARDATA_ANY(str); + int len = VARSIZE_ANY_EXHDR(str); + const char *endp = p + len; + text *result; + char *dst; result = palloc(len + VARHDRSZ); - dst = (char*) VARDATA(result) + len; + dst = (char *) VARDATA(result) + len; SET_VARSIZE(result, len + VARHDRSZ); if (pg_database_encoding_max_length() > 1) @@ -3750,7 +3750,7 @@ text_reverse(PG_FUNCTION_ARGS) /* multibyte version */ while (p < endp) { - int sz; + int sz; sz = pg_mblen(p); dst -= sz; @@ -3775,7 +3775,7 @@ Datum text_format(PG_FUNCTION_ARGS) { text *fmt; - StringInfoData str; + StringInfoData str; const char *cp; const char *start_ptr; const char *end_ptr; @@ -3795,9 +3795,9 @@ text_format(PG_FUNCTION_ARGS) /* Scan format string, looking for conversion specifiers. */ for (cp = start_ptr; cp < end_ptr; cp++) { - Datum value; - bool isNull; - Oid typid; + Datum value; + bool isNull; + Oid typid; /* * If it's not the start of a conversion specifier, just copy it to @@ -3830,11 +3830,12 @@ text_format(PG_FUNCTION_ARGS) ++arg; else { - bool unterminated = false; + bool unterminated = false; /* Parse digit string. */ arg = 0; - do { + do + { /* Treat overflowing arg position as unterminated. */ if (arg > INT_MAX / 10) break; @@ -3863,8 +3864,8 @@ text_format(PG_FUNCTION_ARGS) /* There's no argument 0. */ if (arg == 0) ereport(ERROR, - (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("conversion specifies argument 0, but arguments are numbered from 1"))); + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("conversion specifies argument 0, but arguments are numbered from 1"))); } /* Not enough arguments? Deduct 1 to avoid counting format string. */ @@ -3874,9 +3875,9 @@ text_format(PG_FUNCTION_ARGS) errmsg("too few arguments for format conversion"))); /* - * At this point, we should see the main conversion specifier. - * Whether or not an argument position was present, it's known - * that at least one character remains in the string at this point. + * At this point, we should see the main conversion specifier. Whether + * or not an argument position was present, it's known that at least + * one character remains in the string at this point. */ value = PG_GETARG_DATUM(arg); isNull = PG_ARGISNULL(arg); @@ -3893,7 +3894,7 @@ text_format(PG_FUNCTION_ARGS) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unrecognized conversion specifier: %c", - *cp))); + *cp))); } } @@ -3907,11 +3908,11 @@ text_format(PG_FUNCTION_ARGS) /* Format a %s, %I, or %L conversion. */ void text_format_string_conversion(StringInfo buf, char conversion, - Oid typid, Datum value, bool isNull) + Oid typid, Datum value, bool isNull) { - Oid typOutput; - bool typIsVarlena; - char *str; + Oid typOutput; + bool typIsVarlena; + char *str; /* Handle NULL arguments before trying to stringify the value. */ if (isNull) @@ -3919,7 +3920,7 @@ text_format_string_conversion(StringInfo buf, char conversion, if (conversion == 'L') appendStringInfoString(buf, "NULL"); else if (conversion == 'I') - ereport(ERROR, + ereport(ERROR, (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), errmsg("NULL cannot be escaped as an SQL identifier"))); return; @@ -3937,7 +3938,8 @@ text_format_string_conversion(StringInfo buf, char conversion, } else if (conversion == 'L') { - char *qstr = quote_literal_cstr(str); + char *qstr = quote_literal_cstr(str); + appendStringInfoString(buf, qstr); /* quote_literal_cstr() always allocates a new string */ pfree(qstr); @@ -3951,7 +3953,7 @@ text_format_string_conversion(StringInfo buf, char conversion, /* * text_format_nv - nonvariadic wrapper for text_format function. - * + * * note: this wrapper is necessary to be sanity_checks test ok */ Datum diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c index c175e4f4cac..ee82d4616c6 100644 --- a/src/backend/utils/adt/xml.c +++ b/src/backend/utils/adt/xml.c @@ -1200,9 +1200,10 @@ xml_parse(text *data, XmlOptionType xmloption_arg, bool preserve_whitespace, { /* * Note, that here we try to apply DTD defaults - * (XML_PARSE_DTDATTR) according to SQL/XML:2008 GR 10.16.7.d: 'Default - * values defined by internal DTD are applied'. As for external - * DTDs, we try to support them too, (see SQL/XML:2008 GR 10.16.7.e) + * (XML_PARSE_DTDATTR) according to SQL/XML:2008 GR 10.16.7.d: + * 'Default values defined by internal DTD are applied'. As for + * external DTDs, we try to support them too, (see SQL/XML:2008 GR + * 10.16.7.e) */ doc = xmlCtxtReadDoc(ctxt, utf8string, NULL, @@ -3435,10 +3436,10 @@ xpath_internal(text *xpath_expr_text, xmltype *data, ArrayType *namespaces, /* * Version 2.6.27 introduces a function named - * xmlXPathCompiledEvalToBoolean, which would be enough for - * xmlexists, but we can derive the existence by whether any - * nodes are returned, thereby preventing a library version - * upgrade and keeping the code the same. + * xmlXPathCompiledEvalToBoolean, which would be enough for xmlexists, + * but we can derive the existence by whether any nodes are returned, + * thereby preventing a library version upgrade and keeping the code + * the same. */ xpathobj = xmlXPathCompiledEval(xpathcomp, xpathctx); if (xpathobj == NULL) /* TODO: reason? */ @@ -3488,7 +3489,7 @@ xpath_internal(text *xpath_expr_text, xmltype *data, ArrayType *namespaces, xmlFreeDoc(doc); xmlFreeParserCtxt(ctxt); } -#endif /* USE_LIBXML */ +#endif /* USE_LIBXML */ /* * Evaluate XPath expression and return array of XML values. @@ -3524,7 +3525,8 @@ xpath(PG_FUNCTION_ARGS) * Determines if the node specified by the supplied XPath exists * in a given XML document, returning a boolean. */ -Datum xmlexists(PG_FUNCTION_ARGS) +Datum +xmlexists(PG_FUNCTION_ARGS) { #ifdef USE_LIBXML text *xpath_expr_text = PG_GETARG_TEXT_P(0); |