diff options
Diffstat (limited to 'src/backend/utils')
67 files changed, 1823 insertions, 1753 deletions
diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c index 64d55b6b1c..67c4ea36e3 100644 --- a/src/backend/utils/adt/acl.c +++ b/src/backend/utils/adt/acl.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/acl.c,v 1.147 2009/02/06 21:15:11 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/acl.c,v 1.148 2009/06/11 14:49:03 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -84,7 +84,7 @@ static int oidComparator(const void *arg1, const void *arg2); static AclMode convert_priv_string(text *priv_type_text); static AclMode convert_any_priv_string(text *priv_type_text, - const priv_map *privileges); + const priv_map *privileges); static Oid convert_table_name(text *tablename); static AclMode convert_table_priv_string(text *priv_type_text); @@ -386,7 +386,7 @@ allocacl(int n) Acl * aclcopy(const Acl *orig_acl) { - Acl *result_acl; + Acl *result_acl; result_acl = allocacl(ACL_NUM(orig_acl)); @@ -406,7 +406,7 @@ aclcopy(const Acl *orig_acl) Acl * aclconcat(const Acl *left_acl, const Acl *right_acl) { - Acl *result_acl; + Acl *result_acl; result_acl = allocacl(ACL_NUM(left_acl) + ACL_NUM(right_acl)); @@ -1682,23 +1682,23 @@ static AclMode convert_table_priv_string(text *priv_type_text) { static const priv_map table_priv_map[] = { - { "SELECT", ACL_SELECT }, - { "SELECT WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_SELECT) }, - { "INSERT", ACL_INSERT }, - { "INSERT WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_INSERT) }, - { "UPDATE", ACL_UPDATE }, - { "UPDATE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_UPDATE) }, - { "DELETE", ACL_DELETE }, - { "DELETE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_DELETE) }, - { "TRUNCATE", ACL_TRUNCATE }, - { "TRUNCATE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_TRUNCATE) }, - { "REFERENCES", ACL_REFERENCES }, - { "REFERENCES WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_REFERENCES) }, - { "TRIGGER", ACL_TRIGGER }, - { "TRIGGER WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_TRIGGER) }, - { "RULE", 0 }, /* ignore old RULE privileges */ - { "RULE WITH GRANT OPTION", 0 }, - { NULL, 0 } + {"SELECT", ACL_SELECT}, + {"SELECT WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_SELECT)}, + {"INSERT", ACL_INSERT}, + {"INSERT WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_INSERT)}, + {"UPDATE", ACL_UPDATE}, + {"UPDATE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_UPDATE)}, + {"DELETE", ACL_DELETE}, + {"DELETE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_DELETE)}, + {"TRUNCATE", ACL_TRUNCATE}, + {"TRUNCATE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_TRUNCATE)}, + {"REFERENCES", ACL_REFERENCES}, + {"REFERENCES WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_REFERENCES)}, + {"TRIGGER", ACL_TRIGGER}, + {"TRIGGER WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_TRIGGER)}, + {"RULE", 0}, /* ignore old RULE privileges */ + {"RULE WITH GRANT OPTION", 0}, + {NULL, 0} }; return convert_any_priv_string(priv_type_text, table_priv_map); @@ -1928,7 +1928,7 @@ column_privilege_check(Oid tableoid, AttrNumber attnum, * existence of the pg_class row before risking calling pg_class_aclcheck. * Note: it might seem there's a race condition against concurrent DROP, * but really it's safe because there will be no syscache flush between - * here and there. So if we see the row in the syscache, so will + * here and there. So if we see the row in the syscache, so will * pg_class_aclcheck. */ if (!SearchSysCacheExists(RELOID, @@ -2314,15 +2314,15 @@ static AclMode convert_column_priv_string(text *priv_type_text) { static const priv_map column_priv_map[] = { - { "SELECT", ACL_SELECT }, - { "SELECT WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_SELECT) }, - { "INSERT", ACL_INSERT }, - { "INSERT WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_INSERT) }, - { "UPDATE", ACL_UPDATE }, - { "UPDATE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_UPDATE) }, - { "REFERENCES", ACL_REFERENCES }, - { "REFERENCES WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_REFERENCES) }, - { NULL, 0 } + {"SELECT", ACL_SELECT}, + {"SELECT WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_SELECT)}, + {"INSERT", ACL_INSERT}, + {"INSERT WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_INSERT)}, + {"UPDATE", ACL_UPDATE}, + {"UPDATE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_UPDATE)}, + {"REFERENCES", ACL_REFERENCES}, + {"REFERENCES WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_REFERENCES)}, + {NULL, 0} }; return convert_any_priv_string(priv_type_text, column_priv_map); @@ -2524,15 +2524,15 @@ static AclMode convert_database_priv_string(text *priv_type_text) { static const priv_map database_priv_map[] = { - { "CREATE", ACL_CREATE }, - { "CREATE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_CREATE) }, - { "TEMPORARY", ACL_CREATE_TEMP }, - { "TEMPORARY WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_CREATE_TEMP) }, - { "TEMP", ACL_CREATE_TEMP }, - { "TEMP WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_CREATE_TEMP) }, - { "CONNECT", ACL_CONNECT }, - { "CONNECT WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_CONNECT) }, - { NULL, 0 } + {"CREATE", ACL_CREATE}, + {"CREATE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_CREATE)}, + {"TEMPORARY", ACL_CREATE_TEMP}, + {"TEMPORARY WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_CREATE_TEMP)}, + {"TEMP", ACL_CREATE_TEMP}, + {"TEMP WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_CREATE_TEMP)}, + {"CONNECT", ACL_CONNECT}, + {"CONNECT WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_CONNECT)}, + {NULL, 0} }; return convert_any_priv_string(priv_type_text, database_priv_map); @@ -2713,9 +2713,9 @@ static AclMode convert_foreign_data_wrapper_priv_string(text *priv_type_text) { static const priv_map foreign_data_wrapper_priv_map[] = { - { "USAGE", ACL_USAGE }, - { "USAGE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_USAGE) }, - { NULL, 0 } + {"USAGE", ACL_USAGE}, + {"USAGE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_USAGE)}, + {NULL, 0} }; return convert_any_priv_string(priv_type_text, foreign_data_wrapper_priv_map); @@ -2919,9 +2919,9 @@ static AclMode convert_function_priv_string(text *priv_type_text) { static const priv_map function_priv_map[] = { - { "EXECUTE", ACL_EXECUTE }, - { "EXECUTE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_EXECUTE) }, - { NULL, 0 } + {"EXECUTE", ACL_EXECUTE}, + {"EXECUTE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_EXECUTE)}, + {NULL, 0} }; return convert_any_priv_string(priv_type_text, function_priv_map); @@ -3125,9 +3125,9 @@ static AclMode convert_language_priv_string(text *priv_type_text) { static const priv_map language_priv_map[] = { - { "USAGE", ACL_USAGE }, - { "USAGE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_USAGE) }, - { NULL, 0 } + {"USAGE", ACL_USAGE}, + {"USAGE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_USAGE)}, + {NULL, 0} }; return convert_any_priv_string(priv_type_text, language_priv_map); @@ -3331,11 +3331,11 @@ static AclMode convert_schema_priv_string(text *priv_type_text) { static const priv_map schema_priv_map[] = { - { "CREATE", ACL_CREATE }, - { "CREATE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_CREATE) }, - { "USAGE", ACL_USAGE }, - { "USAGE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_USAGE) }, - { NULL, 0 } + {"CREATE", ACL_CREATE}, + {"CREATE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_CREATE)}, + {"USAGE", ACL_USAGE}, + {"USAGE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_USAGE)}, + {NULL, 0} }; return convert_any_priv_string(priv_type_text, schema_priv_map); @@ -3515,9 +3515,9 @@ static AclMode convert_server_priv_string(text *priv_type_text) { static const priv_map server_priv_map[] = { - { "USAGE", ACL_USAGE }, - { "USAGE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_USAGE) }, - { NULL, 0 } + {"USAGE", ACL_USAGE}, + {"USAGE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_USAGE)}, + {NULL, 0} }; return convert_any_priv_string(priv_type_text, server_priv_map); @@ -3705,9 +3705,9 @@ static AclMode convert_tablespace_priv_string(text *priv_type_text) { static const priv_map tablespace_priv_map[] = { - { "CREATE", ACL_CREATE }, - { "CREATE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_CREATE) }, - { NULL, 0 } + {"CREATE", ACL_CREATE}, + {"CREATE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_CREATE)}, + {NULL, 0} }; return convert_any_priv_string(priv_type_text, tablespace_priv_map); @@ -3881,13 +3881,13 @@ static AclMode convert_role_priv_string(text *priv_type_text) { static const priv_map role_priv_map[] = { - { "USAGE", ACL_USAGE }, - { "MEMBER", ACL_CREATE }, - { "USAGE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_CREATE) }, - { "USAGE WITH ADMIN OPTION", ACL_GRANT_OPTION_FOR(ACL_CREATE) }, - { "MEMBER WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_CREATE) }, - { "MEMBER WITH ADMIN OPTION", ACL_GRANT_OPTION_FOR(ACL_CREATE) }, - { NULL, 0 } + {"USAGE", ACL_USAGE}, + {"MEMBER", ACL_CREATE}, + {"USAGE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_CREATE)}, + {"USAGE WITH ADMIN OPTION", ACL_GRANT_OPTION_FOR(ACL_CREATE)}, + {"MEMBER WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_CREATE)}, + {"MEMBER WITH ADMIN OPTION", ACL_GRANT_OPTION_FOR(ACL_CREATE)}, + {NULL, 0} }; return convert_any_priv_string(priv_type_text, role_priv_map); diff --git a/src/backend/utils/adt/array_userfuncs.c b/src/backend/utils/adt/array_userfuncs.c index b43ad38993..c30d6b42b0 100644 --- a/src/backend/utils/adt/array_userfuncs.c +++ b/src/backend/utils/adt/array_userfuncs.c @@ -6,7 +6,7 @@ * Copyright (c) 2003-2009, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/array_userfuncs.c,v 1.29 2009/06/09 18:15:04 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/array_userfuncs.c,v 1.30 2009/06/11 14:49:03 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -474,7 +474,7 @@ create_singleton_array(FunctionCallInfo fcinfo, Datum array_agg_transfn(PG_FUNCTION_ARGS) { - Oid arg1_typeid = get_fn_expr_argtype(fcinfo->flinfo, 1); + Oid arg1_typeid = get_fn_expr_argtype(fcinfo->flinfo, 1); MemoryContext aggcontext; ArrayBuildState *state; Datum elem; @@ -504,10 +504,9 @@ array_agg_transfn(PG_FUNCTION_ARGS) aggcontext); /* - * The transition type for array_agg() is declared to be "internal", - * which is a pass-by-value type the same size as a pointer. So we - * can safely pass the ArrayBuildState pointer through nodeAgg.c's - * machinations. + * The transition type for array_agg() is declared to be "internal", which + * is a pass-by-value type the same size as a pointer. So we can safely + * pass the ArrayBuildState pointer through nodeAgg.c's machinations. */ PG_RETURN_POINTER(state); } @@ -521,12 +520,12 @@ array_agg_finalfn(PG_FUNCTION_ARGS) int lbs[1]; /* - * Test for null before Asserting we are in right context. This is - * to avoid possible Assert failure in 8.4beta installations, where - * it is possible for users to create NULL constants of type internal. + * Test for null before Asserting we are in right context. This is to + * avoid possible Assert failure in 8.4beta installations, where it is + * possible for users to create NULL constants of type internal. */ if (PG_ARGISNULL(0)) - PG_RETURN_NULL(); /* returns null iff no input values */ + PG_RETURN_NULL(); /* returns null iff no input values */ /* cannot be called directly because of internal-type argument */ Assert(fcinfo->context && diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c index 4f0da19d23..b3973fbccb 100644 --- a/src/backend/utils/adt/arrayfuncs.c +++ b/src/backend/utils/adt/arrayfuncs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.156 2009/04/15 23:30:33 alvherre Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.157 2009/06/11 14:49:03 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -96,10 +96,10 @@ static void array_insert_slice(ArrayType *destArray, ArrayType *origArray, int typlen, bool typbyval, char typalign); static int array_cmp(FunctionCallInfo fcinfo); static ArrayType *create_array_envelope(int ndims, int *dimv, int *lbv, int nbytes, - Oid elmtype, int dataoffset); + Oid elmtype, int dataoffset); static ArrayType *array_fill_internal(ArrayType *dims, ArrayType *lbs, - Datum value, bool isnull, Oid elmtype, - FunctionCallInfo fcinfo); + Datum value, bool isnull, Oid elmtype, + FunctionCallInfo fcinfo); /* @@ -1532,7 +1532,7 @@ array_send(PG_FUNCTION_ARGS) /* * array_ndims : - * returns the number of dimensions of the array pointed to by "v" + * returns the number of dimensions of the array pointed to by "v" */ Datum array_ndims(PG_FUNCTION_ARGS) @@ -4287,9 +4287,9 @@ array_smaller(PG_FUNCTION_ARGS) typedef struct generate_subscripts_fctx { - int4 lower; - int4 upper; - bool reverse; + int4 lower; + int4 upper; + bool reverse; } generate_subscripts_fctx; /* @@ -4306,10 +4306,10 @@ generate_subscripts(PG_FUNCTION_ARGS) /* stuff done only on the first call of the function */ if (SRF_IS_FIRSTCALL()) { - ArrayType *v = PG_GETARG_ARRAYTYPE_P(0); - int reqdim = PG_GETARG_INT32(1); - int *lb, - *dimv; + ArrayType *v = PG_GETARG_ARRAYTYPE_P(0); + int reqdim = PG_GETARG_INT32(1); + int *lb, + *dimv; /* create a function context for cross-call persistence */ funcctx = SRF_FIRSTCALL_INIT(); @@ -4374,20 +4374,20 @@ generate_subscripts_nodir(PG_FUNCTION_ARGS) Datum array_fill_with_lower_bounds(PG_FUNCTION_ARGS) { - ArrayType *dims; - ArrayType *lbs; - ArrayType *result; + ArrayType *dims; + ArrayType *lbs; + ArrayType *result; Oid elmtype; - Datum value; - bool isnull; + Datum value; + bool isnull; if (PG_ARGISNULL(1) || PG_ARGISNULL(2)) ereport(ERROR, - (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), - errmsg("dimension array or low bound array cannot be NULL"))); + (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), + errmsg("dimension array or low bound array cannot be NULL"))); dims = PG_GETARG_ARRAYTYPE_P(1); - lbs = PG_GETARG_ARRAYTYPE_P(2); + lbs = PG_GETARG_ARRAYTYPE_P(2); if (!PG_ARGISNULL(0)) { @@ -4415,16 +4415,16 @@ array_fill_with_lower_bounds(PG_FUNCTION_ARGS) Datum array_fill(PG_FUNCTION_ARGS) { - ArrayType *dims; - ArrayType *result; + ArrayType *dims; + ArrayType *result; Oid elmtype; - Datum value; - bool isnull; + Datum value; + bool isnull; if (PG_ARGISNULL(1)) ereport(ERROR, - (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), - errmsg("dimension array or low bound array cannot be NULL"))); + (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), + errmsg("dimension array or low bound array cannot be NULL"))); dims = PG_GETARG_ARRAYTYPE_P(1); @@ -4451,7 +4451,7 @@ static ArrayType * create_array_envelope(int ndims, int *dimv, int *lbsv, int nbytes, Oid elmtype, int dataoffset) { - ArrayType *result; + ArrayType *result; result = (ArrayType *) palloc0(nbytes); SET_VARSIZE(result, nbytes); @@ -4469,36 +4469,36 @@ array_fill_internal(ArrayType *dims, ArrayType *lbs, Datum value, bool isnull, Oid elmtype, FunctionCallInfo fcinfo) { - ArrayType *result; - int *dimv; - int *lbsv; - int ndims; - int nitems; - int deflbs[MAXDIM]; - int16 elmlen; - bool elmbyval; - char elmalign; - ArrayMetaState *my_extra; + ArrayType *result; + int *dimv; + int *lbsv; + int ndims; + int nitems; + int deflbs[MAXDIM]; + int16 elmlen; + bool elmbyval; + char elmalign; + ArrayMetaState *my_extra; /* * Params checks */ if (ARR_NDIM(dims) != 1) ereport(ERROR, - (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), - errmsg("wrong number of array subscripts"), - errdetail("Dimension array must be one dimensional."))); + (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), + errmsg("wrong number of array subscripts"), + errdetail("Dimension array must be one dimensional."))); if (ARR_LBOUND(dims)[0] != 1) ereport(ERROR, - (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), - errmsg("wrong range of array subscripts"), - errdetail("Lower bound of dimension array must be one."))); + (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), + errmsg("wrong range of array subscripts"), + errdetail("Lower bound of dimension array must be one."))); if (ARR_HASNULL(dims)) ereport(ERROR, - (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), - errmsg("dimension values cannot be null"))); + (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), + errmsg("dimension values cannot be null"))); dimv = (int *) ARR_DATA_PTR(dims); ndims = ARR_DIMS(dims)[0]; @@ -4517,32 +4517,32 @@ array_fill_internal(ArrayType *dims, ArrayType *lbs, { if (ARR_NDIM(lbs) != 1) ereport(ERROR, - (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), - errmsg("wrong number of array subscripts"), - errdetail("Dimension array must be one dimensional."))); + (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), + errmsg("wrong number of array subscripts"), + errdetail("Dimension array must be one dimensional."))); if (ARR_LBOUND(lbs)[0] != 1) ereport(ERROR, - (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), - errmsg("wrong range of array subscripts"), - errdetail("Lower bound of dimension array must be one."))); + (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), + errmsg("wrong range of array subscripts"), + errdetail("Lower bound of dimension array must be one."))); if (ARR_HASNULL(lbs)) ereport(ERROR, - (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), - errmsg("dimension values cannot be null"))); + (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), + errmsg("dimension values cannot be null"))); if (ARR_DIMS(lbs)[0] != ndims) ereport(ERROR, - (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), - errmsg("wrong number of array subscripts"), - errdetail("Low bound array has different size than dimensions array."))); + (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), + errmsg("wrong number of array subscripts"), + errdetail("Low bound array has different size than dimensions array."))); lbsv = (int *) ARR_DATA_PTR(lbs); } else { - int i; + int i; for (i = 0; i < MAXDIM; i++) deflbs[i] = 1; @@ -4586,8 +4586,8 @@ array_fill_internal(ArrayType *dims, ArrayType *lbs, /* compute required space */ if (!isnull) { - int i; - char *p; + int i; + char *p; int nbytes; int totbytes; @@ -4624,8 +4624,8 @@ array_fill_internal(ArrayType *dims, ArrayType *lbs, } else { - int nbytes; - int dataoffset; + int nbytes; + int dataoffset; dataoffset = ARR_OVERHEAD_WITHNULLS(ndims, nitems); nbytes = dataoffset; @@ -4648,14 +4648,14 @@ array_unnest(PG_FUNCTION_ARGS) { typedef struct { - ArrayType *arr; - int nextelem; - int numelems; - char *elemdataptr; /* this moves with nextelem */ - bits8 *arraynullsptr; /* this does not */ - int16 elmlen; - bool elmbyval; - char elmalign; + ArrayType *arr; + int nextelem; + int numelems; + char *elemdataptr; /* this moves with nextelem */ + bits8 *arraynullsptr; /* this does not */ + int16 elmlen; + bool elmbyval; + char elmalign; } array_unnest_fctx; FuncCallContext *funcctx; @@ -4677,10 +4677,10 @@ array_unnest(PG_FUNCTION_ARGS) /* * Get the array value and detoast if needed. We can't do this - * earlier because if we have to detoast, we want the detoasted - * copy to be in multi_call_memory_ctx, so it will go away when - * we're done and not before. (If no detoast happens, we assume - * the originally passed array will stick around till then.) + * earlier because if we have to detoast, we want the detoasted copy + * to be in multi_call_memory_ctx, so it will go away when we're done + * and not before. (If no detoast happens, we assume the originally + * passed array will stick around till then.) */ arr = PG_GETARG_ARRAYTYPE_P(0); @@ -4710,8 +4710,8 @@ array_unnest(PG_FUNCTION_ARGS) if (fctx->nextelem < fctx->numelems) { - int offset = fctx->nextelem++; - Datum elem; + int offset = fctx->nextelem++; + Datum elem; /* * Check for NULL array element @@ -4727,7 +4727,7 @@ array_unnest(PG_FUNCTION_ARGS) /* * OK, get the element */ - char *ptr = fctx->elemdataptr; + char *ptr = fctx->elemdataptr; fcinfo->isnull = false; elem = ArrayCast(ptr, fctx->elmbyval, fctx->elmlen); diff --git a/src/backend/utils/adt/bool.c b/src/backend/utils/adt/bool.c index a9f9c5b207..848827a81a 100644 --- a/src/backend/utils/adt/bool.c +++ b/src/backend/utils/adt/bool.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/bool.c,v 1.47 2009/03/09 16:49:12 petere Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/bool.c,v 1.48 2009/06/11 14:49:03 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -110,7 +110,7 @@ parse_bool_with_len(const char *value, size_t len, bool *result) } if (result) - *result = false; /* suppress compiler warning */ + *result = false; /* suppress compiler warning */ return false; } diff --git a/src/backend/utils/adt/cash.c b/src/backend/utils/adt/cash.c index 73d55c5b54..784947e440 100644 --- a/src/backend/utils/adt/cash.c +++ b/src/backend/utils/adt/cash.c @@ -13,7 +13,7 @@ * this version handles 64 bit numbers and so can hold values up to * $92,233,720,368,547,758.07. * - * $PostgreSQL: pgsql/src/backend/utils/adt/cash.c,v 1.81 2009/06/10 16:31:32 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/cash.c,v 1.82 2009/06/11 14:49:03 momjian Exp $ */ #include "postgres.h" @@ -320,9 +320,8 @@ cash_out(PG_FUNCTION_ARGS) count -= strlen(csymbol) - 1; /* - * If points == 0 and the number of digits % mon_group == 0, - * the code above adds a trailing ssymbol on the far right, - * so remove it. + * If points == 0 and the number of digits % mon_group == 0, the code + * above adds a trailing ssymbol on the far right, so remove it. */ if (buf[LAST_DIGIT] == ssymbol) buf[LAST_DIGIT] = '\0'; @@ -792,13 +791,13 @@ cash_words(PG_FUNCTION_ARGS) /* Now treat as unsigned, to avoid trouble at INT_MIN */ val = (uint64) value; - m0 = val % INT64CONST(100); /* cents */ - m1 = (val / INT64CONST(100)) % 1000; /* hundreds */ - m2 = (val / INT64CONST(100000)) % 1000; /* thousands */ - m3 = (val / INT64CONST(100000000)) % 1000; /* millions */ + m0 = val % INT64CONST(100); /* cents */ + m1 = (val / INT64CONST(100)) % 1000; /* hundreds */ + m2 = (val / INT64CONST(100000)) % 1000; /* thousands */ + m3 = (val / INT64CONST(100000000)) % 1000; /* millions */ m4 = (val / INT64CONST(100000000000)) % 1000; /* billions */ m5 = (val / INT64CONST(100000000000000)) % 1000; /* trillions */ - m6 = (val / INT64CONST(100000000000000000)) % 1000; /* quadrillions */ + m6 = (val / INT64CONST(100000000000000000)) % 1000; /* quadrillions */ if (m6) { diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c index 5d84d6447d..43148bec90 100644 --- a/src/backend/utils/adt/date.c +++ b/src/backend/utils/adt/date.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.145 2009/05/26 01:29:09 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.146 2009/06/11 14:49:03 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -231,7 +231,7 @@ EncodeSpecialDate(DateADT dt, char *str) strcpy(str, EARLY); else if (DATE_IS_NOEND(dt)) strcpy(str, LATE); - else /* shouldn't happen */ + else /* shouldn't happen */ elog(ERROR, "invalid argument for EncodeSpecialDate"); } @@ -2552,7 +2552,7 @@ timetz_zone(PG_FUNCTION_ARGS) pg_tz *tzp; /* - * Look up the requested timezone. First we look in the date token table + * Look up the requested timezone. First we look in the date token table * (to handle cases like "EST"), and if that fails, we look in the * timezone database (to handle cases like "America/New_York"). (This * matches the order in which timestamp input checks the cases; it's diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index e6f4689a59..186522148d 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.207 2009/06/10 05:05:03 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.208 2009/06/11 14:49:03 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -40,17 +40,17 @@ static int DecodeTime(char *str, int fmask, int range, int *tmask, struct pg_tm * tm, fsec_t *fsec); static int DecodeTimezone(char *str, int *tzp); static const datetkn *datebsearch(const char *key, const datetkn *base, int nel); -static int DecodeDate(char *str, int fmask, int *tmask, bool *is2digits, - struct pg_tm * tm); -static int ValidateDate(int fmask, bool is2digits, bool bc, - struct pg_tm * tm); +static int DecodeDate(char *str, int fmask, int *tmask, bool *is2digits, + struct pg_tm * tm); +static int ValidateDate(int fmask, bool is2digits, bool bc, + struct pg_tm * tm); static void TrimTrailingZeros(char *str); static void AppendSeconds(char *cp, int sec, fsec_t fsec, - int precision, bool fillzeros); + int precision, bool fillzeros); static void AdjustFractSeconds(double frac, struct pg_tm * tm, fsec_t *fsec, - int scale); + int scale); static void AdjustFractDays(double frac, struct pg_tm * tm, fsec_t *fsec, - int scale); + int scale); const int day_tab[2][13] = @@ -266,7 +266,7 @@ static const datetkn *deltacache[MAXDATEFIELDS] = {NULL}; static int strtoi(const char *nptr, char **endptr, int base) { - long val; + long val; val = strtol(nptr, endptr, base); #ifdef HAVE_LONG_INT_64 @@ -461,8 +461,8 @@ static void AppendTimestampSeconds(char *cp, struct pg_tm * tm, fsec_t fsec) { /* - * In float mode, don't print fractional seconds before 1 AD, - * since it's unlikely there's any precision left ... + * In float mode, don't print fractional seconds before 1 AD, since it's + * unlikely there's any precision left ... */ #ifndef HAVE_INT64_TIMESTAMP if (tm->tm_year <= 0) @@ -478,18 +478,18 @@ AppendTimestampSeconds(char *cp, struct pg_tm * tm, fsec_t fsec) static void AdjustFractSeconds(double frac, struct pg_tm * tm, fsec_t *fsec, int scale) { - int sec; + int sec; if (frac == 0) return; - frac *= scale; - sec = (int) frac; + frac *= scale; + sec = (int) frac; tm->tm_sec += sec; - frac -= sec; + frac -= sec; #ifdef HAVE_INT64_TIMESTAMP - *fsec += rint(frac * 1000000); + *fsec += rint(frac * 1000000); #else - *fsec += frac; + *fsec += frac; #endif } @@ -497,14 +497,14 @@ AdjustFractSeconds(double frac, struct pg_tm * tm, fsec_t *fsec, int scale) static void AdjustFractDays(double frac, struct pg_tm * tm, fsec_t *fsec, int scale) { - int extra_days; + int extra_days; if (frac == 0) return; - frac *= scale; - extra_days = (int) frac; + frac *= scale; + extra_days = (int) frac; tm->tm_mday += extra_days; - frac -= extra_days; + frac -= extra_days; AdjustFractSeconds(frac, tm, fsec, SECS_PER_DAY); } @@ -1358,7 +1358,7 @@ DecodeDateTime(char **field, int *ftype, int nf, if (tmask & fmask) return DTERR_BAD_FORMAT; fmask |= tmask; - } /* end loop over fields */ + } /* end loop over fields */ /* do final checking/adjustment of Y/M/D fields */ dterr = ValidateDate(fmask, is2digits, bc, tm); @@ -2042,7 +2042,7 @@ DecodeTimeOnly(char **field, int *ftype, int nf, if (tmask & fmask) return DTERR_BAD_FORMAT; fmask |= tmask; - } /* end loop over fields */ + } /* end loop over fields */ /* do final checking/adjustment of Y/M/D fields */ dterr = ValidateDate(fmask, is2digits, bc, tm); @@ -2059,7 +2059,7 @@ DecodeTimeOnly(char **field, int *ftype, int nf, if (tm->tm_hour < 0 || tm->tm_min < 0 || tm->tm_min > 59 || tm->tm_sec < 0 || tm->tm_sec > 60 || tm->tm_hour > 24 || - /* test for > 24:00:00 */ + /* test for > 24:00:00 */ (tm->tm_hour == 24 && (tm->tm_min > 0 || tm->tm_sec > 0 || *fsec > 0)) || #ifdef HAVE_INT64_TIMESTAMP @@ -2262,7 +2262,7 @@ ValidateDate(int fmask, bool is2digits, bool bc, struct pg_tm * tm) else if (is2digits) { /* process 1 or 2-digit input as 1970-2069 AD, allow '0' and '00' */ - if (tm->tm_year < 0) /* just paranoia */ + if (tm->tm_year < 0) /* just paranoia */ return DTERR_FIELD_OVERFLOW; if (tm->tm_year < 70) tm->tm_year += 2000; @@ -2599,8 +2599,8 @@ DecodeNumberField(int len, char *str, int fmask, if ((cp = strchr(str, '.')) != NULL) { /* - * Can we use ParseFractionalSecond here? Not clear whether - * trailing junk should be rejected ... + * Can we use ParseFractionalSecond here? Not clear whether trailing + * junk should be rejected ... */ double frac; @@ -2805,16 +2805,16 @@ DecodeSpecial(int field, char *lowtoken, int *val) * * Zero out a pg_tm and associated fsec_t */ -static inline void -ClearPgTm(struct pg_tm *tm, fsec_t *fsec) +static inline void +ClearPgTm(struct pg_tm * tm, fsec_t *fsec) { tm->tm_year = 0; - tm->tm_mon = 0; + tm->tm_mon = 0; tm->tm_mday = 0; tm->tm_hour = 0; - tm->tm_min = 0; - tm->tm_sec = 0; - *fsec = 0; + tm->tm_min = 0; + tm->tm_sec = 0; + *fsec = 0; } @@ -2845,7 +2845,7 @@ DecodeInterval(char **field, int *ftype, int nf, int range, *dtype = DTK_DELTA; type = IGNORE_DTF; - ClearPgTm(tm,fsec); + ClearPgTm(tm, fsec); /* read through list backwards to pick up units before values */ for (i = nf - 1; i >= 0; i--) @@ -2863,16 +2863,16 @@ DecodeInterval(char **field, int *ftype, int nf, int range, case DTK_TZ: /* - * Timezone is a token with a leading sign character and - * at least one digit; there could be ':', '.', '-' - * embedded in it as well. + * Timezone is a token with a leading sign character and at + * least one digit; there could be ':', '.', '-' embedded in + * it as well. */ Assert(*field[i] == '-' || *field[i] == '+'); /* * Try for hh:mm or hh:mm:ss. If not, fall through to - * DTK_NUMBER case, which can handle signed float numbers - * and signed year-month values. + * DTK_NUMBER case, which can handle signed float numbers and + * signed year-month values. */ if (strchr(field[i] + 1, ':') != NULL && DecodeTime(field[i] + 1, fmask, INTERVAL_FULL_RANGE, @@ -2944,7 +2944,7 @@ DecodeInterval(char **field, int *ftype, int nf, int range, if (*cp == '-') { /* SQL "years-months" syntax */ - int val2; + int val2; val2 = strtoi(cp + 1, &cp, 10); if (errno == ERANGE || val2 < 0 || val2 >= MONTHS_PER_YEAR) @@ -3022,7 +3022,7 @@ DecodeInterval(char **field, int *ftype, int nf, int range, tm->tm_hour += val; AdjustFractSeconds(fval, tm, fsec, SECS_PER_HOUR); tmask = DTK_M(HOUR); - type = DTK_DAY; /* set for next field */ + type = DTK_DAY; /* set for next field */ break; case DTK_DAY: @@ -3133,7 +3133,7 @@ DecodeInterval(char **field, int *ftype, int nf, int range, /*---------- * The SQL standard defines the interval literal - * '-1 1:00:00' + * '-1 1:00:00' * to mean "negative 1 days and negative 1 hours", while Postgres * traditionally treats this as meaning "negative 1 days and positive * 1 hours". In SQL_STANDARD intervalstyle, we apply the leading sign @@ -3143,14 +3143,14 @@ DecodeInterval(char **field, int *ftype, int nf, int range, * This protects us against misinterpreting postgres-style dump output, * since the postgres-style output code has always put an explicit sign on * all fields following a negative field. But note that SQL-spec output - * is ambiguous and can be misinterpreted on load! (So it's best practice + * is ambiguous and can be misinterpreted on load! (So it's best practice * to dump in postgres style, not SQL style.) *---------- */ if (IntervalStyle == INTSTYLE_SQL_STANDARD && *field[0] == '-') { /* Check for additional explicit signs */ - bool more_signs = false; + bool more_signs = false; for (i = 1; i < nf; i++) { @@ -3164,8 +3164,8 @@ DecodeInterval(char **field, int *ftype, int nf, int range, if (!more_signs) { /* - * Rather than re-determining which field was field[0], just - * force 'em all negative. + * Rather than re-determining which field was field[0], just force + * 'em all negative. */ if (*fsec > 0) *fsec = -(*fsec); @@ -3245,28 +3245,28 @@ ISO8601IntegerWidth(char *fieldstart) /* DecodeISO8601Interval() - * Decode an ISO 8601 time interval of the "format with designators" - * (section 4.4.3.2) or "alternative format" (section 4.4.3.3) - * Examples: P1D for 1 day - * PT1H for 1 hour - * P2Y6M7DT1H30M for 2 years, 6 months, 7 days 1 hour 30 min - * P0002-06-07T01:30:00 the same value in alternative format + * Decode an ISO 8601 time interval of the "format with designators" + * (section 4.4.3.2) or "alternative format" (section 4.4.3.3) + * Examples: P1D for 1 day + * PT1H for 1 hour + * P2Y6M7DT1H30M for 2 years, 6 months, 7 days 1 hour 30 min + * P0002-06-07T01:30:00 the same value in alternative format * * Returns 0 if successful, DTERR code if bogus input detected. * Note: error code should be DTERR_BAD_FORMAT if input doesn't look like * ISO8601, otherwise this could cause unexpected error messages. * dtype, tm, fsec are output parameters. * - * A couple exceptions from the spec: - * - a week field ('W') may coexist with other units - * - allows decimals in fields other than the least significant unit. + * A couple exceptions from the spec: + * - a week field ('W') may coexist with other units + * - allows decimals in fields other than the least significant unit. */ int DecodeISO8601Interval(char *str, int *dtype, struct pg_tm * tm, fsec_t *fsec) { - bool datepart = true; - bool havefield = false; + bool datepart = true; + bool havefield = false; *dtype = DTK_DELTA; ClearPgTm(tm, fsec); @@ -3277,13 +3277,13 @@ DecodeISO8601Interval(char *str, str++; while (*str) { - char *fieldstart; - int val; - double fval; - char unit; - int dterr; + char *fieldstart; + int val; + double fval; + char unit; + int dterr; - if (*str == 'T') /* T indicates the beginning of the time part */ + if (*str == 'T') /* T indicates the beginning of the time part */ { datepart = false; havefield = false; @@ -3297,14 +3297,14 @@ DecodeISO8601Interval(char *str, return dterr; /* - * Note: we could step off the end of the string here. Code below + * Note: we could step off the end of the string here. Code below * *must* exit the loop if unit == '\0'. */ unit = *str++; if (datepart) { - switch (unit) /* before T: Y M W D */ + switch (unit) /* before T: Y M W D */ { case 'Y': tm->tm_year += val; @@ -3322,12 +3322,12 @@ DecodeISO8601Interval(char *str, tm->tm_mday += val; AdjustFractSeconds(fval, tm, fsec, SECS_PER_DAY); break; - case 'T': /* ISO 8601 4.4.3.3 Alternative Format / Basic */ + case 'T': /* ISO 8601 4.4.3.3 Alternative Format / Basic */ case '\0': if (ISO8601IntegerWidth(fieldstart) == 8 && !havefield) { tm->tm_year += val / 10000; - tm->tm_mon += (val / 100) % 100; + tm->tm_mon += (val / 100) % 100; tm->tm_mday += val % 100; AdjustFractSeconds(fval, tm, fsec, SECS_PER_DAY); if (unit == '\0') @@ -3337,12 +3337,13 @@ DecodeISO8601Interval(char *str, continue; } /* Else fall through to extended alternative format */ - case '-': /* ISO 8601 4.4.3.3 Alternative Format, Extended */ + case '-': /* ISO 8601 4.4.3.3 Alternative Format, + * Extended */ if (havefield) return DTERR_BAD_FORMAT; tm->tm_year += val; - tm->tm_mon += (fval * 12); + tm->tm_mon += (fval * 12); if (unit == '\0') return 0; if (unit == 'T') @@ -3355,7 +3356,7 @@ DecodeISO8601Interval(char *str, dterr = ParseISO8601Number(str, &str, &val, &fval); if (dterr) return dterr; - tm->tm_mon += val; + tm->tm_mon += val; AdjustFractDays(fval, tm, fsec, DAYS_PER_MONTH); if (*str == '\0') return 0; @@ -3368,7 +3369,7 @@ DecodeISO8601Interval(char *str, if (*str != '-') return DTERR_BAD_FORMAT; str++; - + dterr = ParseISO8601Number(str, &str, &val, &fval); if (dterr) return dterr; @@ -3390,7 +3391,7 @@ DecodeISO8601Interval(char *str, } else { - switch (unit) /* after T: H M S */ + switch (unit) /* after T: H M S */ { case 'H': tm->tm_hour += val; @@ -3404,17 +3405,18 @@ DecodeISO8601Interval(char *str, tm->tm_sec += val; AdjustFractSeconds(fval, tm, fsec, 1); break; - case '\0': /* ISO 8601 4.4.3.3 Alternative Format */ - if (ISO8601IntegerWidth(fieldstart) == 6 && !havefield) + case '\0': /* ISO 8601 4.4.3.3 Alternative Format */ + if (ISO8601IntegerWidth(fieldstart) == 6 && !havefield) { tm->tm_hour += val / 10000; - tm->tm_min += (val / 100) % 100; - tm->tm_sec += val % 100; + tm->tm_min += (val / 100) % 100; + tm->tm_sec += val % 100; AdjustFractSeconds(fval, tm, fsec, 1); return 0; } /* Else fall through to extended alternative format */ - case ':': /* ISO 8601 4.4.3.3 Alternative Format, Extended */ + case ':': /* ISO 8601 4.4.3.3 Alternative Format, + * Extended */ if (havefield) return DTERR_BAD_FORMAT; @@ -3422,22 +3424,22 @@ DecodeISO8601Interval(char *str, AdjustFractSeconds(fval, tm, fsec, SECS_PER_HOUR); if (unit == '\0') return 0; - + dterr = ParseISO8601Number(str, &str, &val, &fval); if (dterr) return dterr; - tm->tm_min += val; + tm->tm_min += val; AdjustFractSeconds(fval, tm, fsec, SECS_PER_MINUTE); if (*str == '\0') return 0; if (*str != ':') return DTERR_BAD_FORMAT; str++; - + dterr = ParseISO8601Number(str, &str, &val, &fval); if (dterr) return dterr; - tm->tm_sec += val; + tm->tm_sec += val; AdjustFractSeconds(fval, tm, fsec, 1); if (*str == '\0') return 0; @@ -3843,9 +3845,10 @@ AddPostgresIntPart(char *cp, int value, const char *units, value, units, (value != 1) ? "s" : ""); + /* - * Each nonzero field sets is_before for (only) the next one. This is - * a tad bizarre but it's how it worked before... + * Each nonzero field sets is_before for (only) the next one. This is a + * tad bizarre but it's how it worked before... */ *is_before = (value < 0); *is_zero = FALSE; @@ -3884,7 +3887,7 @@ AddVerboseIntPart(char *cp, int value, const char *units, * Actually, afaik, ISO 8601 does specify formats for "time * intervals...[of the]...format with time-unit designators", which * are pretty ugly. The format looks something like - * P1Y1M1DT1H1M1.12345S + * P1Y1M1DT1H1M1.12345S * but useful for exchanging data with computers instead of humans. * - ron 2003-07-14 * @@ -3897,11 +3900,11 @@ EncodeInterval(struct pg_tm * tm, fsec_t fsec, int style, char *str) { char *cp = str; int year = tm->tm_year; - int mon = tm->tm_mon; + int mon = tm->tm_mon; int mday = tm->tm_mday; int hour = tm->tm_hour; - int min = tm->tm_min; - int sec = tm->tm_sec; + int min = tm->tm_min; + int sec = tm->tm_sec; bool is_before = FALSE; bool is_zero = TRUE; @@ -3913,21 +3916,21 @@ EncodeInterval(struct pg_tm * tm, fsec_t fsec, int style, char *str) */ switch (style) { - /* SQL Standard interval format */ + /* SQL Standard interval format */ case INTSTYLE_SQL_STANDARD: { - bool has_negative = year < 0 || mon < 0 || - mday < 0 || hour < 0 || - min < 0 || sec < 0 || fsec < 0; - bool has_positive = year > 0 || mon > 0 || - mday > 0 || hour > 0 || - min > 0 || sec > 0 || fsec > 0; - bool has_year_month = year != 0 || mon != 0; - bool has_day_time = mday != 0 || hour != 0 || - min != 0 || sec != 0 || fsec != 0; - bool has_day = mday != 0; - bool sql_standard_value = !(has_negative && has_positive) && - !(has_year_month && has_day_time); + bool has_negative = year < 0 || mon < 0 || + mday < 0 || hour < 0 || + min < 0 || sec < 0 || fsec < 0; + bool has_positive = year > 0 || mon > 0 || + mday > 0 || hour > 0 || + min > 0 || sec > 0 || fsec > 0; + bool has_year_month = year != 0 || mon != 0; + bool has_day_time = mday != 0 || hour != 0 || + min != 0 || sec != 0 || fsec != 0; + bool has_day = mday != 0; + bool sql_standard_value = !(has_negative && has_positive) && + !(has_year_month && has_day_time); /* * SQL Standard wants only 1 "<sign>" preceding the whole @@ -3937,11 +3940,11 @@ EncodeInterval(struct pg_tm * tm, fsec_t fsec, int style, char *str) { *cp++ = '-'; year = -year; - mon = -mon; + mon = -mon; mday = -mday; hour = -hour; - min = -min; - sec = -sec; + min = -min; + sec = -sec; fsec = -fsec; } @@ -3952,15 +3955,14 @@ EncodeInterval(struct pg_tm * tm, fsec_t fsec, int style, char *str) else if (!sql_standard_value) { /* - * For non sql-standard interval values, - * force outputting the signs to avoid - * ambiguities with intervals with mixed - * sign components. + * For non sql-standard interval values, force outputting + * the signs to avoid ambiguities with intervals with + * mixed sign components. */ - char year_sign = (year < 0 || mon < 0) ? '-' : '+'; - char day_sign = (mday < 0) ? '-' : '+'; - char sec_sign = (hour < 0 || min < 0 || - sec < 0 || fsec < 0) ? '-' : '+'; + char year_sign = (year < 0 || mon < 0) ? '-' : '+'; + char day_sign = (mday < 0) ? '-' : '+'; + char sec_sign = (hour < 0 || min < 0 || + sec < 0 || fsec < 0) ? '-' : '+'; sprintf(cp, "%c%d-%d %c%d %c%d:%02d:", year_sign, abs(year), abs(mon), @@ -3988,23 +3990,23 @@ EncodeInterval(struct pg_tm * tm, fsec_t fsec, int style, char *str) } break; - /* ISO 8601 "time-intervals by duration only" */ + /* ISO 8601 "time-intervals by duration only" */ case INTSTYLE_ISO_8601: /* special-case zero to avoid printing nothing */ if (year == 0 && mon == 0 && mday == 0 && - hour == 0 && min == 0 && sec == 0 && fsec == 0) + hour == 0 && min == 0 && sec == 0 && fsec == 0) { sprintf(cp, "PT0S"); break; } *cp++ = 'P'; cp = AddISO8601IntPart(cp, year, 'Y'); - cp = AddISO8601IntPart(cp, mon , 'M'); + cp = AddISO8601IntPart(cp, mon, 'M'); cp = AddISO8601IntPart(cp, mday, 'D'); if (hour != 0 || min != 0 || sec != 0 || fsec != 0) *cp++ = 'T'; cp = AddISO8601IntPart(cp, hour, 'H'); - cp = AddISO8601IntPart(cp, min , 'M'); + cp = AddISO8601IntPart(cp, min, 'M'); if (sec != 0 || fsec != 0) { if (sec < 0 || fsec < 0) @@ -4016,14 +4018,14 @@ EncodeInterval(struct pg_tm * tm, fsec_t fsec, int style, char *str) } break; - /* Compatible with postgresql < 8.4 when DateStyle = 'iso' */ + /* Compatible with postgresql < 8.4 when DateStyle = 'iso' */ case INTSTYLE_POSTGRES: cp = AddPostgresIntPart(cp, year, "year", &is_zero, &is_before); cp = AddPostgresIntPart(cp, mon, "mon", &is_zero, &is_before); cp = AddPostgresIntPart(cp, mday, "day", &is_zero, &is_before); if (is_zero || hour != 0 || min != 0 || sec != 0 || fsec != 0) { - bool minus = (hour < 0 || min < 0 || sec < 0 || fsec < 0); + bool minus = (hour < 0 || min < 0 || sec < 0 || fsec < 0); sprintf(cp, "%s%s%02d:%02d:", is_zero ? "" : " ", @@ -4034,7 +4036,7 @@ EncodeInterval(struct pg_tm * tm, fsec_t fsec, int style, char *str) } break; - /* Compatible with postgresql < 8.4 when DateStyle != 'iso' */ + /* Compatible with postgresql < 8.4 when DateStyle != 'iso' */ case INTSTYLE_POSTGRES_VERBOSE: default: strcpy(cp, "@"); diff --git a/src/backend/utils/adt/dbsize.c b/src/backend/utils/adt/dbsize.c index a8b3eb2214..9b97751524 100644 --- a/src/backend/utils/adt/dbsize.c +++ b/src/backend/utils/adt/dbsize.c @@ -5,7 +5,7 @@ * Copyright (c) 2002-2009, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/dbsize.c,v 1.23 2009/01/01 17:23:49 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/dbsize.c,v 1.24 2009/06/11 14:49:03 momjian Exp $ * */ @@ -294,7 +294,7 @@ pg_relation_size(PG_FUNCTION_ARGS) rel = relation_open(relOid, AccessShareLock); size = calculate_relation_size(&(rel->rd_node), - forkname_to_number(text_to_cstring(forkName))); + forkname_to_number(text_to_cstring(forkName))); relation_close(rel, AccessShareLock); diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c index 8244738515..4547240be1 100644 --- a/src/backend/utils/adt/float.c +++ b/src/backend/utils/adt/float.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.161 2009/03/04 22:08:20 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.162 2009/06/11 14:49:03 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1335,8 +1335,8 @@ dpow(PG_FUNCTION_ARGS) /* * The SQL spec requires that we emit a particular SQLSTATE error code for - * certain error conditions. Specifically, we don't return a divide-by-zero - * error code for 0 ^ -1. + * certain error conditions. Specifically, we don't return a + * divide-by-zero error code for 0 ^ -1. */ if (arg1 == 0 && arg2 < 0) ereport(ERROR, diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c index 3498e2c503..064993bd87 100644 --- a/src/backend/utils/adt/formatting.c +++ b/src/backend/utils/adt/formatting.c @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------- * formatting.c * - * $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.156 2009/03/15 20:31:19 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.157 2009/06/11 14:49:03 momjian Exp $ * * * Portions Copyright (c) 1999-2009, PostgreSQL Global Development Group @@ -148,9 +148,9 @@ typedef struct */ typedef enum { - FROM_CHAR_DATE_NONE = 0, /* Value does not affect date mode. */ - FROM_CHAR_DATE_GREGORIAN, /* Gregorian (day, month, year) style date */ - FROM_CHAR_DATE_ISOWEEK /* ISO 8601 week date */ + FROM_CHAR_DATE_NONE = 0, /* Value does not affect date mode. */ + FROM_CHAR_DATE_GREGORIAN, /* Gregorian (day, month, year) style date */ + FROM_CHAR_DATE_ISOWEEK /* ISO 8601 week date */ } FromCharDateMode; typedef struct FormatNode FormatNode; @@ -286,9 +286,9 @@ static char *numth[] = {"st", "nd", "rd", "th", NULL}; * Flags & Options: * ---------- */ -#define ONE_UPPER 1 /* Name */ -#define ALL_UPPER 2 /* NAME */ -#define ALL_LOWER 3 /* name */ +#define ONE_UPPER 1 /* Name */ +#define ALL_UPPER 2 /* NAME */ +#define ALL_LOWER 3 /* name */ #define FULL_SIZ 0 @@ -421,8 +421,8 @@ typedef struct cc, j, us, - yysz, /* is it YY or YYYY ? */ - clock; /* 12 or 24 hour clock? */ + yysz, /* is it YY or YYYY ? */ + clock; /* 12 or 24 hour clock? */ } TmFromChar; #define ZERO_tmfc(_X) memset(_X, 0, sizeof(TmFromChar)) @@ -709,94 +709,94 @@ typedef enum */ static const KeyWord DCH_keywords[] = { /* name, len, id, is_digit, date_mode */ - {"A.D.", 4, DCH_A_D, FALSE, FROM_CHAR_DATE_NONE}, /* A */ + {"A.D.", 4, DCH_A_D, FALSE, FROM_CHAR_DATE_NONE}, /* A */ {"A.M.", 4, DCH_A_M, FALSE, FROM_CHAR_DATE_NONE}, {"AD", 2, DCH_AD, FALSE, FROM_CHAR_DATE_NONE}, {"AM", 2, DCH_AM, FALSE, FROM_CHAR_DATE_NONE}, - {"B.C.", 4, DCH_B_C, FALSE, FROM_CHAR_DATE_NONE}, /* B */ + {"B.C.", 4, DCH_B_C, FALSE, FROM_CHAR_DATE_NONE}, /* B */ {"BC", 2, DCH_BC, FALSE, FROM_CHAR_DATE_NONE}, - {"CC", 2, DCH_CC, TRUE, FROM_CHAR_DATE_NONE}, /* C */ - {"DAY", 3, DCH_DAY, FALSE, FROM_CHAR_DATE_NONE}, /* D */ + {"CC", 2, DCH_CC, TRUE, FROM_CHAR_DATE_NONE}, /* C */ + {"DAY", 3, DCH_DAY, FALSE, FROM_CHAR_DATE_NONE}, /* D */ {"DDD", 3, DCH_DDD, TRUE, FROM_CHAR_DATE_GREGORIAN}, {"DD", 2, DCH_DD, TRUE, FROM_CHAR_DATE_GREGORIAN}, {"DY", 2, DCH_DY, FALSE, FROM_CHAR_DATE_NONE}, {"Day", 3, DCH_Day, FALSE, FROM_CHAR_DATE_NONE}, {"Dy", 2, DCH_Dy, FALSE, FROM_CHAR_DATE_NONE}, {"D", 1, DCH_D, TRUE, FROM_CHAR_DATE_GREGORIAN}, - {"FX", 2, DCH_FX, FALSE, FROM_CHAR_DATE_NONE}, /* F */ - {"HH24", 4, DCH_HH24, TRUE, FROM_CHAR_DATE_NONE}, /* H */ + {"FX", 2, DCH_FX, FALSE, FROM_CHAR_DATE_NONE}, /* F */ + {"HH24", 4, DCH_HH24, TRUE, FROM_CHAR_DATE_NONE}, /* H */ {"HH12", 4, DCH_HH12, TRUE, FROM_CHAR_DATE_NONE}, {"HH", 2, DCH_HH, TRUE, FROM_CHAR_DATE_NONE}, - {"IDDD", 4, DCH_IDDD, TRUE, FROM_CHAR_DATE_ISOWEEK}, /* I */ + {"IDDD", 4, DCH_IDDD, TRUE, FROM_CHAR_DATE_ISOWEEK}, /* I */ {"ID", 2, DCH_ID, TRUE, FROM_CHAR_DATE_ISOWEEK}, {"IW", 2, DCH_IW, TRUE, FROM_CHAR_DATE_ISOWEEK}, {"IYYY", 4, DCH_IYYY, TRUE, FROM_CHAR_DATE_ISOWEEK}, {"IYY", 3, DCH_IYY, TRUE, FROM_CHAR_DATE_ISOWEEK}, {"IY", 2, DCH_IY, TRUE, FROM_CHAR_DATE_ISOWEEK}, {"I", 1, DCH_I, TRUE, FROM_CHAR_DATE_ISOWEEK}, - {"J", 1, DCH_J, TRUE, FROM_CHAR_DATE_NONE}, /* J */ - {"MI", 2, DCH_MI, TRUE, FROM_CHAR_DATE_NONE}, /* M */ + {"J", 1, DCH_J, TRUE, FROM_CHAR_DATE_NONE}, /* J */ + {"MI", 2, DCH_MI, TRUE, FROM_CHAR_DATE_NONE}, /* M */ {"MM", 2, DCH_MM, TRUE, FROM_CHAR_DATE_GREGORIAN}, {"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}, {"Month", 5, DCH_Month, FALSE, FROM_CHAR_DATE_GREGORIAN}, {"Mon", 3, DCH_Mon, FALSE, FROM_CHAR_DATE_GREGORIAN}, - {"P.M.", 4, DCH_P_M, FALSE, FROM_CHAR_DATE_NONE}, /* P */ + {"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 */ - {"RM", 2, DCH_RM, FALSE, FROM_CHAR_DATE_GREGORIAN}, /* R */ - {"SSSS", 4, DCH_SSSS, TRUE, FROM_CHAR_DATE_NONE}, /* S */ + {"Q", 1, DCH_Q, TRUE, FROM_CHAR_DATE_NONE}, /* Q */ + {"RM", 2, DCH_RM, FALSE, FROM_CHAR_DATE_GREGORIAN}, /* R */ + {"SSSS", 4, DCH_SSSS, TRUE, FROM_CHAR_DATE_NONE}, /* S */ {"SS", 2, DCH_SS, TRUE, FROM_CHAR_DATE_NONE}, - {"TZ", 2, DCH_TZ, FALSE, FROM_CHAR_DATE_NONE}, /* T */ - {"US", 2, DCH_US, TRUE, FROM_CHAR_DATE_NONE}, /* U */ - {"WW", 2, DCH_WW, TRUE, FROM_CHAR_DATE_GREGORIAN}, /* W */ + {"TZ", 2, DCH_TZ, FALSE, FROM_CHAR_DATE_NONE}, /* T */ + {"US", 2, DCH_US, TRUE, FROM_CHAR_DATE_NONE}, /* U */ + {"WW", 2, DCH_WW, TRUE, FROM_CHAR_DATE_GREGORIAN}, /* W */ {"W", 1, DCH_W, TRUE, FROM_CHAR_DATE_GREGORIAN}, - {"Y,YYY", 5, DCH_Y_YYY, TRUE, FROM_CHAR_DATE_GREGORIAN},/* Y */ + {"Y,YYY", 5, DCH_Y_YYY, TRUE, FROM_CHAR_DATE_GREGORIAN}, /* Y */ {"YYYY", 4, DCH_YYYY, TRUE, FROM_CHAR_DATE_GREGORIAN}, {"YYY", 3, DCH_YYY, TRUE, FROM_CHAR_DATE_GREGORIAN}, {"YY", 2, DCH_YY, TRUE, FROM_CHAR_DATE_GREGORIAN}, {"Y", 1, DCH_Y, TRUE, FROM_CHAR_DATE_GREGORIAN}, - {"a.d.", 4, DCH_a_d, FALSE, FROM_CHAR_DATE_NONE}, /* a */ + {"a.d.", 4, DCH_a_d, FALSE, FROM_CHAR_DATE_NONE}, /* a */ {"a.m.", 4, DCH_a_m, FALSE, FROM_CHAR_DATE_NONE}, {"ad", 2, DCH_ad, FALSE, FROM_CHAR_DATE_NONE}, {"am", 2, DCH_am, FALSE, FROM_CHAR_DATE_NONE}, - {"b.c.", 4, DCH_b_c, FALSE, FROM_CHAR_DATE_NONE}, /* b */ + {"b.c.", 4, DCH_b_c, FALSE, FROM_CHAR_DATE_NONE}, /* b */ {"bc", 2, DCH_bc, FALSE, FROM_CHAR_DATE_NONE}, - {"cc", 2, DCH_CC, TRUE, FROM_CHAR_DATE_NONE}, /* c */ - {"day", 3, DCH_day, FALSE, FROM_CHAR_DATE_NONE}, /* d */ + {"cc", 2, DCH_CC, TRUE, FROM_CHAR_DATE_NONE}, /* c */ + {"day", 3, DCH_day, FALSE, FROM_CHAR_DATE_NONE}, /* d */ {"ddd", 3, DCH_DDD, TRUE, FROM_CHAR_DATE_GREGORIAN}, {"dd", 2, DCH_DD, TRUE, FROM_CHAR_DATE_GREGORIAN}, {"dy", 2, DCH_dy, FALSE, FROM_CHAR_DATE_NONE}, {"d", 1, DCH_D, TRUE, FROM_CHAR_DATE_GREGORIAN}, - {"fx", 2, DCH_FX, FALSE, FROM_CHAR_DATE_NONE}, /* f */ - {"hh24", 4, DCH_HH24, TRUE, FROM_CHAR_DATE_NONE}, /* h */ + {"fx", 2, DCH_FX, FALSE, FROM_CHAR_DATE_NONE}, /* f */ + {"hh24", 4, DCH_HH24, TRUE, FROM_CHAR_DATE_NONE}, /* h */ {"hh12", 4, DCH_HH12, TRUE, FROM_CHAR_DATE_NONE}, {"hh", 2, DCH_HH, TRUE, FROM_CHAR_DATE_NONE}, - {"iddd", 4, DCH_IDDD, TRUE, FROM_CHAR_DATE_ISOWEEK}, /* i */ + {"iddd", 4, DCH_IDDD, TRUE, FROM_CHAR_DATE_ISOWEEK}, /* i */ {"id", 2, DCH_ID, TRUE, FROM_CHAR_DATE_ISOWEEK}, {"iw", 2, DCH_IW, TRUE, FROM_CHAR_DATE_ISOWEEK}, {"iyyy", 4, DCH_IYYY, TRUE, FROM_CHAR_DATE_ISOWEEK}, {"iyy", 3, DCH_IYY, TRUE, FROM_CHAR_DATE_ISOWEEK}, {"iy", 2, DCH_IY, TRUE, FROM_CHAR_DATE_ISOWEEK}, {"i", 1, DCH_I, TRUE, FROM_CHAR_DATE_ISOWEEK}, - {"j", 1, DCH_J, TRUE, FROM_CHAR_DATE_NONE}, /* j */ - {"mi", 2, DCH_MI, TRUE, FROM_CHAR_DATE_NONE}, /* m */ + {"j", 1, DCH_J, TRUE, FROM_CHAR_DATE_NONE}, /* j */ + {"mi", 2, DCH_MI, TRUE, FROM_CHAR_DATE_NONE}, /* m */ {"mm", 2, DCH_MM, TRUE, FROM_CHAR_DATE_GREGORIAN}, {"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}, - {"p.m.", 4, DCH_p_m, FALSE, FROM_CHAR_DATE_NONE}, /* p */ + {"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 */ - {"rm", 2, DCH_rm, FALSE, FROM_CHAR_DATE_GREGORIAN}, /* r */ - {"ssss", 4, DCH_SSSS, TRUE, FROM_CHAR_DATE_NONE}, /* s */ + {"q", 1, DCH_Q, TRUE, FROM_CHAR_DATE_NONE}, /* q */ + {"rm", 2, DCH_rm, FALSE, FROM_CHAR_DATE_GREGORIAN}, /* r */ + {"ssss", 4, DCH_SSSS, TRUE, FROM_CHAR_DATE_NONE}, /* s */ {"ss", 2, DCH_SS, TRUE, FROM_CHAR_DATE_NONE}, - {"tz", 2, DCH_tz, FALSE, FROM_CHAR_DATE_NONE}, /* t */ - {"us", 2, DCH_US, TRUE, FROM_CHAR_DATE_NONE}, /* u */ - {"ww", 2, DCH_WW, TRUE, FROM_CHAR_DATE_GREGORIAN}, /* w */ + {"tz", 2, DCH_tz, FALSE, FROM_CHAR_DATE_NONE}, /* t */ + {"us", 2, DCH_US, TRUE, FROM_CHAR_DATE_NONE}, /* u */ + {"ww", 2, DCH_WW, TRUE, FROM_CHAR_DATE_GREGORIAN}, /* w */ {"w", 1, DCH_W, TRUE, FROM_CHAR_DATE_GREGORIAN}, - {"y,yyy", 5, DCH_Y_YYY, TRUE, FROM_CHAR_DATE_GREGORIAN},/* y */ + {"y,yyy", 5, DCH_Y_YYY, TRUE, FROM_CHAR_DATE_GREGORIAN}, /* y */ {"yyyy", 4, DCH_YYYY, TRUE, FROM_CHAR_DATE_GREGORIAN}, {"yyy", 3, DCH_YYY, TRUE, FROM_CHAR_DATE_GREGORIAN}, {"yy", 2, DCH_YY, TRUE, FROM_CHAR_DATE_GREGORIAN}, @@ -814,42 +814,42 @@ static const KeyWord DCH_keywords[] = { */ static const KeyWord NUM_keywords[] = { /* name, len, id is in Index */ - {",", 1, NUM_COMMA}, /* , */ - {".", 1, NUM_DEC}, /* . */ - {"0", 1, NUM_0}, /* 0 */ - {"9", 1, NUM_9}, /* 9 */ - {"B", 1, NUM_B}, /* B */ - {"C", 1, NUM_C}, /* C */ - {"D", 1, NUM_D}, /* D */ - {"E", 1, NUM_E}, /* E */ - {"FM", 2, NUM_FM}, /* F */ - {"G", 1, NUM_G}, /* G */ - {"L", 1, NUM_L}, /* L */ - {"MI", 2, NUM_MI}, /* M */ - {"PL", 2, NUM_PL}, /* P */ + {",", 1, NUM_COMMA}, /* , */ + {".", 1, NUM_DEC}, /* . */ + {"0", 1, NUM_0}, /* 0 */ + {"9", 1, NUM_9}, /* 9 */ + {"B", 1, NUM_B}, /* B */ + {"C", 1, NUM_C}, /* C */ + {"D", 1, NUM_D}, /* D */ + {"E", 1, NUM_E}, /* E */ + {"FM", 2, NUM_FM}, /* F */ + {"G", 1, NUM_G}, /* G */ + {"L", 1, NUM_L}, /* L */ + {"MI", 2, NUM_MI}, /* M */ + {"PL", 2, NUM_PL}, /* P */ {"PR", 2, NUM_PR}, - {"RN", 2, NUM_RN}, /* R */ - {"SG", 2, NUM_SG}, /* S */ + {"RN", 2, NUM_RN}, /* R */ + {"SG", 2, NUM_SG}, /* S */ {"SP", 2, NUM_SP}, {"S", 1, NUM_S}, - {"TH", 2, NUM_TH}, /* T */ - {"V", 1, NUM_V}, /* V */ - {"b", 1, NUM_B}, /* b */ - {"c", 1, NUM_C}, /* c */ - {"d", 1, NUM_D}, /* d */ - {"e", 1, NUM_E}, /* e */ - {"fm", 2, NUM_FM}, /* f */ - {"g", 1, NUM_G}, /* g */ - {"l", 1, NUM_L}, /* l */ - {"mi", 2, NUM_MI}, /* m */ - {"pl", 2, NUM_PL}, /* p */ + {"TH", 2, NUM_TH}, /* T */ + {"V", 1, NUM_V}, /* V */ + {"b", 1, NUM_B}, /* b */ + {"c", 1, NUM_C}, /* c */ + {"d", 1, NUM_D}, /* d */ + {"e", 1, NUM_E}, /* e */ + {"fm", 2, NUM_FM}, /* f */ + {"g", 1, NUM_G}, /* g */ + {"l", 1, NUM_L}, /* l */ + {"mi", 2, NUM_MI}, /* m */ + {"pl", 2, NUM_PL}, /* p */ {"pr", 2, NUM_PR}, - {"rn", 2, NUM_rn}, /* r */ - {"sg", 2, NUM_SG}, /* s */ + {"rn", 2, NUM_rn}, /* r */ + {"sg", 2, NUM_SG}, /* s */ {"sp", 2, NUM_SP}, {"s", 1, NUM_S}, - {"th", 2, NUM_th}, /* t */ - {"v", 1, NUM_V}, /* v */ + {"th", 2, NUM_th}, /* t */ + {"v", 1, NUM_V}, /* v */ /* last */ {NULL, 0, 0} @@ -950,7 +950,7 @@ static void parse_format(FormatNode *node, char *str, const KeyWord *kw, KeySuffix *suf, const int *index, int ver, NUMDesc *Num); static void DCH_to_char(FormatNode *node, bool is_interval, - TmToChar *in, char *out); + TmToChar *in, char *out); static void DCH_from_char(FormatNode *node, char *in, TmFromChar *out); #ifdef DEBUG_TO_FROM_CHAR @@ -1474,7 +1474,7 @@ str_numth(char *dest, char *num, int type) char * str_tolower(const char *buff, size_t nbytes) { - char *result; + char *result; if (!buff) return NULL; @@ -1482,7 +1482,7 @@ str_tolower(const char *buff, size_t nbytes) #ifdef USE_WIDE_UPPER_LOWER if (pg_database_encoding_max_length() > 1 && !lc_ctype_is_c()) { - wchar_t *workspace; + wchar_t *workspace; size_t curr_char; size_t result_size; @@ -1508,9 +1508,9 @@ str_tolower(const char *buff, size_t nbytes) pfree(workspace); } else -#endif /* USE_WIDE_UPPER_LOWER */ +#endif /* USE_WIDE_UPPER_LOWER */ { - char *p; + char *p; result = pnstrdup(buff, nbytes); @@ -1530,7 +1530,7 @@ str_tolower(const char *buff, size_t nbytes) char * str_toupper(const char *buff, size_t nbytes) { - char *result; + char *result; if (!buff) return NULL; @@ -1538,7 +1538,7 @@ str_toupper(const char *buff, size_t nbytes) #ifdef USE_WIDE_UPPER_LOWER if (pg_database_encoding_max_length() > 1 && !lc_ctype_is_c()) { - wchar_t *workspace; + wchar_t *workspace; size_t curr_char; size_t result_size; @@ -1564,9 +1564,9 @@ str_toupper(const char *buff, size_t nbytes) pfree(workspace); } else -#endif /* USE_WIDE_UPPER_LOWER */ +#endif /* USE_WIDE_UPPER_LOWER */ { - char *p; + char *p; result = pnstrdup(buff, nbytes); @@ -1586,7 +1586,7 @@ str_toupper(const char *buff, size_t nbytes) char * str_initcap(const char *buff, size_t nbytes) { - char *result; + char *result; int wasalnum = false; if (!buff) @@ -1595,7 +1595,7 @@ str_initcap(const char *buff, size_t nbytes) #ifdef USE_WIDE_UPPER_LOWER if (pg_database_encoding_max_length() > 1 && !lc_ctype_is_c()) { - wchar_t *workspace; + wchar_t *workspace; size_t curr_char; size_t result_size; @@ -1627,9 +1627,9 @@ str_initcap(const char *buff, size_t nbytes) pfree(workspace); } else -#endif /* USE_WIDE_UPPER_LOWER */ +#endif /* USE_WIDE_UPPER_LOWER */ { - char *p; + char *p; result = pnstrdup(buff, nbytes); @@ -1805,8 +1805,8 @@ from_char_set_int(int *dest, const int value, const FormatNode *node) if (*dest != 0 && *dest != value) ereport(ERROR, (errcode(ERRCODE_INVALID_DATETIME_FORMAT), - errmsg("conflicting values for \"%s\" field in formatting string", - node->key->name), + errmsg("conflicting values for \"%s\" field in formatting string", + node->key->name), errdetail("This value contradicts a previous setting for " "the same field type."))); *dest = value; @@ -1847,8 +1847,7 @@ from_char_parse_int_len(int *dest, char **src, const int len, FormatNode *node) { /* * This node is in Fill Mode, or the next node is known to be a - * non-digit value, so we just slurp as many characters as we - * can get. + * non-digit value, so we just slurp as many characters as we can get. */ errno = 0; result = strtol(init, src, 10); @@ -1859,13 +1858,13 @@ from_char_parse_int_len(int *dest, char **src, const int len, FormatNode *node) * We need to pull exactly the number of characters given in 'len' out * of the string, and convert those. */ - char *last; + char *last; if (used < len) ereport(ERROR, (errcode(ERRCODE_INVALID_DATETIME_FORMAT), - errmsg("source string too short for \"%s\" formatting field", - node->key->name), + errmsg("source string too short for \"%s\" formatting field", + node->key->name), errdetail("Field requires %d characters, but only %d " "remain.", len, used), @@ -1879,12 +1878,12 @@ from_char_parse_int_len(int *dest, char **src, const int len, FormatNode *node) if (used > 0 && used < len) ereport(ERROR, (errcode(ERRCODE_INVALID_DATETIME_FORMAT), - errmsg("invalid value \"%s\" for \"%s\"", - copy, node->key->name), + errmsg("invalid value \"%s\" for \"%s\"", + copy, node->key->name), errdetail("Field requires %d characters, but only %d " - "could be parsed.", len, used), + "could be parsed.", len, used), errhint("If your source string is not fixed-width, try " - "using the \"FM\" modifier."))); + "using the \"FM\" modifier."))); *src += used; } @@ -1893,14 +1892,14 @@ from_char_parse_int_len(int *dest, char **src, const int len, FormatNode *node) ereport(ERROR, (errcode(ERRCODE_INVALID_DATETIME_FORMAT), errmsg("invalid value \"%s\" for \"%s\"", - copy, node->key->name), + copy, node->key->name), errdetail("Value must be an integer."))); if (errno == ERANGE || result < INT_MIN || result > INT_MAX) ereport(ERROR, (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE), errmsg("value for \"%s\" in source string is out of range", - node->key->name), + node->key->name), errdetail("Value must be in the range %d to %d.", INT_MIN, INT_MAX))); @@ -1998,7 +1997,7 @@ seq_search(char *name, char **array, int type, int max, int *len) /* * Perform a sequential search in 'array' for text matching the first 'max' - * characters of the source string. + * characters of the source string. * * If a match is found, copy the array index of the match into the integer * pointed to by 'dest', advance 'src' to the end of the part of the string @@ -2007,15 +2006,15 @@ seq_search(char *name, char **array, int type, int max, int *len) * If the string doesn't match, throw an error. */ static int -from_char_seq_search(int *dest, char **src, char **array, int type, int max, +from_char_seq_search(int *dest, char **src, char **array, int type, int max, FormatNode *node) { - int len; + int len; *dest = seq_search(*src, array, type, max, &len); if (len <= 0) { - char copy[DCH_MAX_ITEM_SIZ + 1]; + char copy[DCH_MAX_ITEM_SIZ + 1]; Assert(max <= DCH_MAX_ITEM_SIZ); strlcpy(copy, *src, max + 1); @@ -2023,9 +2022,9 @@ from_char_seq_search(int *dest, char **src, char **array, int type, int max, ereport(ERROR, (errcode(ERRCODE_INVALID_DATETIME_FORMAT), errmsg("invalid value \"%s\" for \"%s\"", - copy, node->key->name), + copy, node->key->name), errdetail("The given value did not match any of the allowed " - "values for this field."))); + "values for this field."))); } *src += len; return len; @@ -2111,7 +2110,7 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out) str_numth(s, s, S_TH_TYPE(n->suffix)); s += strlen(s); break; - case DCH_MS: /* millisecond */ + case DCH_MS: /* millisecond */ #ifdef HAVE_INT64_TIMESTAMP sprintf(s, "%03d", (int) (in->fsec / INT64CONST(1000))); #else @@ -2122,7 +2121,7 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out) str_numth(s, s, S_TH_TYPE(n->suffix)); s += strlen(s); break; - case DCH_US: /* microsecond */ + case DCH_US: /* microsecond */ #ifdef HAVE_INT64_TIMESTAMP sprintf(s, "%06d", (int) in->fsec); #else @@ -2263,7 +2262,7 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out) strcpy(s, str_toupper_z(localized_full_days[tm->tm_wday])); else sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -9, - str_toupper_z(days[tm->tm_wday])); + str_toupper_z(days[tm->tm_wday])); s += strlen(s); break; case DCH_Day: @@ -2317,7 +2316,7 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out) sprintf(s, "%0*d", S_FM(n->suffix) ? 0 : 3, (n->key->id == DCH_DDD) ? tm->tm_yday : - date2isoyearday(tm->tm_year, tm->tm_mon, tm->tm_mday)); + date2isoyearday(tm->tm_year, tm->tm_mon, tm->tm_mday)); if (S_THth(n->suffix)) str_numth(s, s, S_TH_TYPE(n->suffix)); s += strlen(s); @@ -2365,9 +2364,9 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out) s += strlen(s); break; case DCH_CC: - if (is_interval) /* straight calculation */ + if (is_interval) /* straight calculation */ i = tm->tm_year / 100; - else /* century 21 starts in 2001 */ + else /* century 21 starts in 2001 */ i = (tm->tm_year - 1) / 100 + 1; if (i <= 99 && i >= -99) sprintf(s, "%0*d", S_FM(n->suffix) ? 0 : 2, i); @@ -2556,7 +2555,7 @@ DCH_from_char(FormatNode *node, char *in, TmFromChar *out) from_char_parse_int(&out->ss, &s, n); s += SKIP_THth(n->suffix); break; - case DCH_MS: /* millisecond */ + case DCH_MS: /* millisecond */ len = from_char_parse_int_len(&out->ms, &s, 3, n); /* @@ -2567,7 +2566,7 @@ DCH_from_char(FormatNode *node, char *in, TmFromChar *out) s += SKIP_THth(n->suffix); break; - case DCH_US: /* microsecond */ + case DCH_US: /* microsecond */ len = from_char_parse_int_len(&out->us, &s, 6, n); out->us *= len == 1 ? 100000 : @@ -2662,6 +2661,7 @@ DCH_from_char(FormatNode *node, char *in, TmFromChar *out) s += SKIP_THth(n->suffix); break; case DCH_Q: + /* * We ignore Q when converting to date because it is not * normative. @@ -2678,13 +2678,15 @@ DCH_from_char(FormatNode *node, char *in, TmFromChar *out) break; case DCH_Y_YYY: { - int matched, years, millenia; + int matched, + years, + millenia; matched = sscanf(s, "%d,%03d", &millenia, &years); if (matched != 2) ereport(ERROR, (errcode(ERRCODE_INVALID_DATETIME_FORMAT), - errmsg("invalid input string for \"Y,YYY\""))); + errmsg("invalid input string for \"Y,YYY\""))); years += (millenia * 1000); from_char_set_int(&out->year, years, n); out->yysz = 4; @@ -2739,12 +2741,12 @@ DCH_from_char(FormatNode *node, char *in, TmFromChar *out) s += SKIP_THth(n->suffix); break; case DCH_RM: - from_char_seq_search(&value, &s, rm_months_upper, + from_char_seq_search(&value, &s, rm_months_upper, ALL_UPPER, MAX_RM_LEN, n); from_char_set_int(&out->mm, 12 - value, n); break; case DCH_rm: - from_char_seq_search(&value, &s, rm_months_lower, + from_char_seq_search(&value, &s, rm_months_lower, ALL_LOWER, MAX_RM_LEN, n); from_char_set_int(&out->mm, 12 - value, n); break; @@ -3276,16 +3278,16 @@ do_to_timestamp(text *date_txt, text *fmt, if (tmfc.ddd && (tm->tm_mon <= 1 || tm->tm_mday <= 1)) { /* - * The month and day field have not been set, so we use the day-of-year - * field to populate them. Depending on the date mode, this field may - * be interpreted as a Gregorian day-of-year, or an ISO week date - * day-of-year. + * The month and day field have not been set, so we use the + * day-of-year field to populate them. Depending on the date mode, + * this field may be interpreted as a Gregorian day-of-year, or an ISO + * week date day-of-year. */ if (!tm->tm_year && !tmfc.bc) ereport(ERROR, (errcode(ERRCODE_INVALID_DATETIME_FORMAT), - errmsg("cannot calculate day of year without year information"))); + errmsg("cannot calculate day of year without year information"))); if (tmfc.mode == FROM_CHAR_DATE_ISOWEEK) { @@ -3302,7 +3304,7 @@ do_to_timestamp(text *date_txt, text *fmt, static const int ysum[2][13] = { {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}, - {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366}}; + {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366}}; y = ysum[isleap(tm->tm_year)]; @@ -3388,8 +3390,8 @@ NUM_cache_getnew(char *str) for (ent = NUMCache; ent <= (NUMCache + NUM_CACHE_FIELDS); ent++) { /* - * entry removed via NUM_cache_remove() can be used here, - * which is why it's worth scanning first entry again + * entry removed via NUM_cache_remove() can be used here, which is + * why it's worth scanning first entry again */ if (ent->str[0] == '\0') { @@ -3621,6 +3623,7 @@ NUM_prepare_locale(NUMProc *Np) */ if (lconv->decimal_point && *lconv->decimal_point) Np->decimal = lconv->decimal_point; + else Np->decimal = "."; @@ -3637,7 +3640,7 @@ NUM_prepare_locale(NUMProc *Np) if (lconv->thousands_sep && *lconv->thousands_sep) Np->L_thousands_sep = lconv->thousands_sep; /* Make sure thousands separator doesn't match decimal point symbol. */ - else if (strcmp(Np->decimal, ",") != 0) + else if (strcmp(Np->decimal, ",") !=0) Np->L_thousands_sep = ","; else Np->L_thousands_sep = "."; diff --git a/src/backend/utils/adt/int8.c b/src/backend/utils/adt/int8.c index b636f8e82d..89162f080e 100644 --- a/src/backend/utils/adt/int8.c +++ b/src/backend/utils/adt/int8.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/int8.c,v 1.73 2009/01/01 17:23:49 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/int8.c,v 1.74 2009/06/11 14:49:03 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -608,7 +608,7 @@ int8div(PG_FUNCTION_ARGS) /* * Overflow check. The only possible overflow case is for arg1 = * INT64_MIN, arg2 = -1, where the correct result is -INT64_MIN, which - * can't be represented on a two's-complement machine. Most machines + * can't be represented on a two's-complement machine. Most machines * produce INT64_MIN but it seems some produce zero. */ if (arg2 == -1 && arg1 < 0 && result <= 0) @@ -661,9 +661,9 @@ int8inc(PG_FUNCTION_ARGS) /* * When int8 is pass-by-reference, we provide this special case to avoid * palloc overhead for COUNT(): when called from nodeAgg, we know that the - * argument is modifiable local storage, so just update it in-place. - * (If int8 is pass-by-value, then of course this is useless as well - * as incorrect, so just ifdef it out.) + * argument is modifiable local storage, so just update it in-place. (If + * int8 is pass-by-value, then of course this is useless as well as + * incorrect, so just ifdef it out.) */ #ifndef USE_FLOAT8_BYVAL /* controls int8 too */ if (fcinfo->context && @@ -833,7 +833,7 @@ int84div(PG_FUNCTION_ARGS) /* * Overflow check. The only possible overflow case is for arg1 = * INT64_MIN, arg2 = -1, where the correct result is -INT64_MIN, which - * can't be represented on a two's-complement machine. Most machines + * can't be represented on a two's-complement machine. Most machines * produce INT64_MIN but it seems some produce zero. */ if (arg2 == -1 && arg1 < 0 && result <= 0) @@ -1012,7 +1012,7 @@ int82div(PG_FUNCTION_ARGS) /* * Overflow check. The only possible overflow case is for arg1 = * INT64_MIN, arg2 = -1, where the correct result is -INT64_MIN, which - * can't be represented on a two's-complement machine. Most machines + * can't be represented on a two's-complement machine. Most machines * produce INT64_MIN but it seems some produce zero. */ if (arg2 == -1 && arg1 < 0 && result <= 0) diff --git a/src/backend/utils/adt/like_match.c b/src/backend/utils/adt/like_match.c index d72113b66b..06eedb659b 100644 --- a/src/backend/utils/adt/like_match.c +++ b/src/backend/utils/adt/like_match.c @@ -19,7 +19,7 @@ * Copyright (c) 1996-2009, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/like_match.c,v 1.25 2009/05/24 18:10:37 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/like_match.c,v 1.26 2009/06/11 14:49:03 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -100,8 +100,8 @@ MatchText(char *t, int tlen, char *p, int plen) if (plen <= 0) ereport(ERROR, (errcode(ERRCODE_INVALID_ESCAPE_SEQUENCE), - errmsg("LIKE pattern must not end with escape character"))); - if (TCHAR(*p) != TCHAR(*t)) + errmsg("LIKE pattern must not end with escape character"))); + if (TCHAR (*p) != TCHAR (*t)) return LIKE_FALSE; } else if (*p == '%') @@ -135,9 +135,9 @@ MatchText(char *t, int tlen, char *p, int plen) } while (tlen > 0 && plen > 0 && *p == '_'); /* - * If we are at the end of the pattern, succeed: % followed - * by n _'s matches any string of at least n characters, and - * we have now found there are at least n characters. + * If we are at the end of the pattern, succeed: % followed by + * n _'s matches any string of at least n characters, and we + * have now found there are at least n characters. */ if (plen <= 0) return LIKE_TRUE; @@ -155,13 +155,13 @@ MatchText(char *t, int tlen, char *p, int plen) } else { - char firstpat = TCHAR(*p); + char firstpat = TCHAR (*p); if (*p == '\\') { if (plen < 2) return LIKE_FALSE; - firstpat = TCHAR(p[1]); + firstpat = TCHAR (p[1]); } while (tlen > 0) @@ -170,7 +170,7 @@ MatchText(char *t, int tlen, char *p, int plen) * Optimization to prevent most recursion: don't recurse * unless first pattern byte matches first text byte. */ - if (TCHAR(*t) == firstpat) + if (TCHAR (*t) == firstpat) { int matched = MatchText(t, tlen, p, plen); @@ -195,7 +195,7 @@ MatchText(char *t, int tlen, char *p, int plen) NextByte(p, plen); continue; } - else if (TCHAR(*p) != TCHAR(*t)) + else if (TCHAR (*p) != TCHAR (*t)) { /* non-wildcard pattern char fails to match text char */ return LIKE_FALSE; @@ -220,8 +220,9 @@ MatchText(char *t, int tlen, char *p, int plen) if (tlen > 0) return LIKE_FALSE; /* end of pattern, but not of text */ - /* End of text string. Do we have matching pattern remaining? */ - while (plen > 0 && *p == '%') /* allow multiple %'s at end of pattern */ + /* End of text string. Do we have matching pattern remaining? */ + while (plen > 0 && *p == '%') /* allow multiple %'s at end of + * pattern */ NextByte(p, plen); if (plen <= 0) @@ -351,4 +352,5 @@ do_like_escape(text *pat, text *esc) #ifdef MATCH_LOWER #undef MATCH_LOWER + #endif diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c index 904abb911b..f78fc7363d 100644 --- a/src/backend/utils/adt/misc.c +++ b/src/backend/utils/adt/misc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/misc.c,v 1.70 2009/01/08 00:13:22 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/misc.c,v 1.71 2009/06/11 14:49:03 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -54,8 +54,8 @@ current_database(PG_FUNCTION_ARGS) /* * current_query() - * Expose the current query to the user (useful in stored procedures) - * We might want to use ActivePortal->sourceText someday. + * Expose the current query to the user (useful in stored procedures) + * We might want to use ActivePortal->sourceText someday. */ Datum current_query(PG_FUNCTION_ARGS) @@ -322,7 +322,7 @@ pg_get_keywords(PG_FUNCTION_ARGS) tupdesc = CreateTemplateTupleDesc(3, false); TupleDescInitEntry(tupdesc, (AttrNumber) 1, "word", TEXTOID, -1, 0); - TupleDescInitEntry(tupdesc, (AttrNumber) 2, "catcode", + TupleDescInitEntry(tupdesc, (AttrNumber) 2, "catcode", CHAROID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber) 3, "catdesc", TEXTOID, -1, 0); diff --git a/src/backend/utils/adt/nabstime.c b/src/backend/utils/adt/nabstime.c index b25938a205..d1c41e138f 100644 --- a/src/backend/utils/adt/nabstime.c +++ b/src/backend/utils/adt/nabstime.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.160 2009/03/22 01:12:32 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.161 2009/06/11 14:49:03 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -631,7 +631,7 @@ reltimein(PG_FUNCTION_ARGS) /* if those functions think it's a bad format, try ISO8601 style */ if (dterr == DTERR_BAD_FORMAT) - dterr = DecodeISO8601Interval(str, + dterr = DecodeISO8601Interval(str, &dtype, tm, &fsec); if (dterr != 0) diff --git a/src/backend/utils/adt/network.c b/src/backend/utils/adt/network.c index 8e58374e9b..f4fc67a843 100644 --- a/src/backend/utils/adt/network.c +++ b/src/backend/utils/adt/network.c @@ -1,7 +1,7 @@ /* * PostgreSQL type definitions for the INET and CIDR types. * - * $PostgreSQL: pgsql/src/backend/utils/adt/network.c,v 1.73 2008/03/25 22:42:44 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/network.c,v 1.74 2009/06/11 14:49:03 momjian Exp $ * * Jon Postel RIP 16 Oct 1998 */ @@ -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; @@ -335,19 +335,20 @@ inet_to_cidr(PG_FUNCTION_ARGS) /* zero out any bits to the right of the netmask */ byte = bits / 8; + nbits = bits % 8; /* 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); @@ -383,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; @@ -403,19 +404,20 @@ cidr_set_masklen(PG_FUNCTION_ARGS) /* zero out any bits to the right of the new netmask */ byte = bits / 8; + nbits = bits % 8; /* 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); @@ -714,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; @@ -733,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) { @@ -748,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); @@ -763,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, @@ -777,6 +779,7 @@ network_network(PG_FUNCTION_ARGS) b = ip_addr(dst); byte = 0; + while (bits) { if (bits >= 8) @@ -790,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); @@ -806,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; @@ -818,6 +821,7 @@ network_netmask(PG_FUNCTION_ARGS) b = ip_addr(dst); byte = 0; + while (bits) { if (bits >= 8) @@ -832,7 +836,7 @@ network_netmask(PG_FUNCTION_ARGS) } b[byte] = mask; - byte++; + byte ++; } ip_family(dst) = ip_family(ip); @@ -847,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; @@ -865,6 +869,7 @@ network_hostmask(PG_FUNCTION_ARGS) b = ip_addr(dst); byte = maxbytes - 1; + while (bits) { if (bits >= 8) @@ -879,7 +884,7 @@ network_hostmask(PG_FUNCTION_ARGS) } b[byte] = mask; - byte--; + byte --; } ip_family(dst) = ip_family(ip); @@ -989,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; @@ -1011,17 +1016,18 @@ addressOK(unsigned char *a, int bits, int family) return true; byte = bits / 8; + nbits = bits % 8; mask = 0xff; 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; @@ -1390,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; @@ -1401,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 { @@ -1418,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 0fbca23175..ba3721b12b 100644 --- a/src/backend/utils/adt/numeric.c +++ b/src/backend/utils/adt/numeric.c @@ -14,7 +14,7 @@ * Copyright (c) 1998-2009, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.117 2009/04/08 22:08:40 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.118 2009/06/11 14:49:03 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -90,7 +90,7 @@ typedef int16 NumericDigit; /* ---------- - * NumericVar is the format we use for arithmetic. The digit-array part + * NumericVar is the format we use for arithmetic. The digit-array part * is the same as the NumericData storage format, but the header is more * complex. * @@ -243,7 +243,7 @@ static void free_var(NumericVar *var); static void zero_var(NumericVar *var); static const char *set_var_from_str(const char *str, const char *cp, - NumericVar *dest); + NumericVar *dest); static void set_var_from_num(Numeric value, NumericVar *dest); static void set_var_from_var(NumericVar *value, NumericVar *dest); static char *get_str_from_var(NumericVar *var, int dscale); @@ -271,7 +271,7 @@ static void mul_var(NumericVar *var1, NumericVar *var2, NumericVar *result, static void div_var(NumericVar *var1, NumericVar *var2, NumericVar *result, int rscale, bool round); static void div_var_fast(NumericVar *var1, NumericVar *var2, NumericVar *result, - int rscale, bool round); + int rscale, bool round); static int select_div_scale(NumericVar *var1, NumericVar *var2); static void mod_var(NumericVar *var1, NumericVar *var2, NumericVar *result); static void ceil_var(NumericVar *var, NumericVar *result); @@ -348,8 +348,8 @@ numeric_in(PG_FUNCTION_ARGS) if (!isspace((unsigned char) *cp)) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type numeric: \"%s\"", - str))); + errmsg("invalid input syntax for type numeric: \"%s\"", + str))); cp++; } } @@ -367,16 +367,16 @@ numeric_in(PG_FUNCTION_ARGS) /* * We duplicate a few lines of code here because we would like to * throw any trailing-junk syntax error before any semantic error - * resulting from apply_typmod. We can't easily fold the two - * cases together because we mustn't apply apply_typmod to a NaN. + * resulting from apply_typmod. We can't easily fold the two cases + * together because we mustn't apply apply_typmod to a NaN. */ while (*cp) { if (!isspace((unsigned char) *cp)) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type numeric: \"%s\"", - str))); + errmsg("invalid input syntax for type numeric: \"%s\"", + str))); cp++; } @@ -1938,8 +1938,8 @@ numeric_power(PG_FUNCTION_ARGS) /* * The SQL spec requires that we emit a particular SQLSTATE error code for - * certain error conditions. Specifically, we don't return a divide-by-zero - * error code for 0 ^ -1. + * certain error conditions. Specifically, we don't return a + * divide-by-zero error code for 0 ^ -1. */ if (cmp_var(&arg1, &const_zero) == 0 && cmp_var(&arg2, &const_zero) < 0) @@ -2654,9 +2654,9 @@ int2_sum(PG_FUNCTION_ARGS) /* * If we're invoked by nodeAgg, we can cheat and modify our first * parameter in-place to avoid palloc overhead. If not, we need to return - * the new value of the transition variable. - * (If int8 is pass-by-value, then of course this is useless as well - * as incorrect, so just ifdef it out.) + * the new value of the transition variable. (If int8 is pass-by-value, + * then of course this is useless as well as incorrect, so just ifdef it + * out.) */ #ifndef USE_FLOAT8_BYVAL /* controls int8 too */ if (fcinfo->context && @@ -2705,9 +2705,9 @@ int4_sum(PG_FUNCTION_ARGS) /* * If we're invoked by nodeAgg, we can cheat and modify our first * parameter in-place to avoid palloc overhead. If not, we need to return - * the new value of the transition variable. - * (If int8 is pass-by-value, then of course this is useless as well - * as incorrect, so just ifdef it out.) + * the new value of the transition variable. (If int8 is pass-by-value, + * then of course this is useless as well as incorrect, so just ifdef it + * out.) */ #ifndef USE_FLOAT8_BYVAL /* controls int8 too */ if (fcinfo->context && @@ -4209,6 +4209,7 @@ div_var(NumericVar *var1, NumericVar *var2, NumericVar *result, /* If rounding needed, figure one more digit to ensure correct result */ if (round) res_ndigits++; + /* * The working dividend normally requires res_ndigits + var2ndigits * digits, but make it at least var1ndigits so we can load all of var1 @@ -4222,8 +4223,8 @@ div_var(NumericVar *var1, NumericVar *var2, NumericVar *result, /* * We need a workspace with room for the working dividend (div_ndigits+1 * digits) plus room for the possibly-normalized divisor (var2ndigits - * digits). It is convenient also to have a zero at divisor[0] with - * the actual divisor data in divisor[1 .. var2ndigits]. Transferring the + * digits). It is convenient also to have a zero at divisor[0] with the + * actual divisor data in divisor[1 .. var2ndigits]. Transferring the * digits into the workspace also allows us to realloc the result (which * might be the same as either input var) before we begin the main loop. * Note that we use palloc0 to ensure that divisor[0], dividend[0], and @@ -4244,8 +4245,8 @@ div_var(NumericVar *var1, NumericVar *var2, NumericVar *result, if (var2ndigits == 1) { /* - * If there's only a single divisor digit, we can use a fast path - * (cf. Knuth section 4.3.1 exercise 16). + * If there's only a single divisor digit, we can use a fast path (cf. + * Knuth section 4.3.1 exercise 16). */ divisor1 = divisor[1]; carry = 0; @@ -4264,12 +4265,12 @@ div_var(NumericVar *var1, NumericVar *var2, NumericVar *result, * * 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 + * 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); + int d = NBASE / (divisor[1] + 1); carry = 0; for (i = var2ndigits; i > 0; i--) @@ -4295,22 +4296,22 @@ div_var(NumericVar *var1, NumericVar *var2, NumericVar *result, 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 + * 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; + int next2digits = dividend[j] * NBASE + dividend[j + 1]; + int qhat; /* * 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. + * no need to adjust the working dividend. It's worth testing + * here to fall out ASAP when processing trailing zeroes in a + * dividend. */ if (next2digits == 0) { @@ -4322,14 +4323,15 @@ div_var(NumericVar *var1, NumericVar *var2, NumericVar *result, qhat = NBASE - 1; else qhat = next2digits / divisor1; + /* * 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.) + * 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.) */ while (divisor2 * qhat > - (next2digits - qhat * divisor1) * NBASE + dividend[j+2]) + (next2digits - qhat * divisor1) * NBASE + dividend[j + 2]) qhat--; /* As above, need do nothing more when quotient digit is 0 */ @@ -5253,16 +5255,16 @@ power_var(NumericVar *base, NumericVar *exp, NumericVar *result) } /* - * This avoids log(0) for cases of 0 raised to a non-integer. - * 0 ^ 0 handled by power_var_int(). + * This avoids log(0) for cases of 0 raised to a non-integer. 0 ^ 0 + * handled by power_var_int(). */ if (cmp_var(base, &const_zero) == 0) { set_var_from_var(&const_zero, result); - result->dscale = NUMERIC_MIN_SIG_DIGITS; /* no need to round */ + result->dscale = NUMERIC_MIN_SIG_DIGITS; /* no need to round */ return; } - + init_var(&ln_base); init_var(&ln_num); @@ -5330,11 +5332,13 @@ power_var_int(NumericVar *base, int exp, NumericVar *result, int rscale) switch (exp) { case 0: + /* - * While 0 ^ 0 can be either 1 or indeterminate (error), we - * treat it as 1 because most programming languages do this. - * SQL:2003 also requires a return value of 1. - * http://en.wikipedia.org/wiki/Exponentiation#Zero_to_the_zero_power + * While 0 ^ 0 can be either 1 or indeterminate (error), we treat + * it as 1 because most programming languages do this. SQL:2003 + * also requires a return value of 1. + * http://en.wikipedia.org/wiki/Exponentiation#Zero_to_the_zero_pow + * er */ set_var_from_var(&const_one, result); result->dscale = rscale; /* no need to round */ diff --git a/src/backend/utils/adt/oracle_compat.c b/src/backend/utils/adt/oracle_compat.c index 4b9e53868d..106671b7d5 100644 --- a/src/backend/utils/adt/oracle_compat.c +++ b/src/backend/utils/adt/oracle_compat.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/oracle_compat.c,v 1.83 2009/01/01 17:23:49 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/oracle_compat.c,v 1.84 2009/06/11 14:49:03 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -42,9 +42,9 @@ static text *dotrim(const char *string, int stringlen, Datum lower(PG_FUNCTION_ARGS) { - text *in_string = PG_GETARG_TEXT_PP(0); - char *out_string; - text *result; + text *in_string = PG_GETARG_TEXT_PP(0); + char *out_string; + text *result; out_string = str_tolower(VARDATA_ANY(in_string), VARSIZE_ANY_EXHDR(in_string)); @@ -72,9 +72,9 @@ lower(PG_FUNCTION_ARGS) Datum upper(PG_FUNCTION_ARGS) { - text *in_string = PG_GETARG_TEXT_PP(0); - char *out_string; - text *result; + text *in_string = PG_GETARG_TEXT_PP(0); + char *out_string; + text *result; out_string = str_toupper(VARDATA_ANY(in_string), VARSIZE_ANY_EXHDR(in_string)); @@ -105,9 +105,9 @@ upper(PG_FUNCTION_ARGS) Datum initcap(PG_FUNCTION_ARGS) { - text *in_string = PG_GETARG_TEXT_PP(0); - char *out_string; - text *result; + text *in_string = PG_GETARG_TEXT_PP(0); + char *out_string; + text *result; out_string = str_initcap(VARDATA_ANY(in_string), VARSIZE_ANY_EXHDR(in_string)); diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c index 7472a8ef79..03b6fad3ef 100644 --- a/src/backend/utils/adt/pg_locale.c +++ b/src/backend/utils/adt/pg_locale.c @@ -4,14 +4,14 @@ * * Portions Copyright (c) 2002-2009, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/backend/utils/adt/pg_locale.c,v 1.49 2009/04/01 09:17:32 heikki Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/pg_locale.c,v 1.50 2009/06/11 14:49:03 momjian Exp $ * *----------------------------------------------------------------------- */ /*---------- * Here is how the locale stuff is handled: LC_COLLATE and LC_CTYPE - * are fixed at CREATE DATABASE time, stored in pg_database, and cannot + * are fixed at CREATE DATABASE time, stored in pg_database, and cannot * be changed. Thus, the effects of strcoll(), strxfrm(), isupper(), * toupper(), etc. are always in the same fixed locale. * @@ -93,7 +93,7 @@ static char lc_numeric_envbuf[LC_ENV_BUFSIZE]; static char lc_time_envbuf[LC_ENV_BUFSIZE]; #if defined(WIN32) && defined(LC_MESSAGES) -static char *IsoLocaleName(const char *); /* MSVC specific */ +static char *IsoLocaleName(const char *); /* MSVC specific */ #endif @@ -159,9 +159,9 @@ pg_perm_setlocale(int category, const char *locale) result = IsoLocaleName(locale); if (result == NULL) result = (char *) locale; -#endif /* WIN32 */ +#endif /* WIN32 */ break; -#endif /* LC_MESSAGES */ +#endif /* LC_MESSAGES */ case LC_MONETARY: envvar = "LC_MONETARY"; envbuf = lc_monetary_envbuf; @@ -468,28 +468,33 @@ PGLC_localeconv(void) * pg_strftime(), which isn't locale-aware and does not need to be replaced. */ static size_t -strftime_win32(char *dst, size_t dstlen, const wchar_t *format, const struct tm *tm) +strftime_win32(char *dst, size_t dstlen, const wchar_t *format, const struct tm * tm) { - size_t len; - wchar_t wbuf[MAX_L10N_DATA]; - int encoding; + size_t len; + wchar_t wbuf[MAX_L10N_DATA]; + int encoding; encoding = GetDatabaseEncoding(); len = wcsftime(wbuf, MAX_L10N_DATA, format, tm); if (len == 0) - /* strftime call failed - return 0 with the contents of dst unspecified */ + + /* + * strftime call failed - return 0 with the contents of dst + * unspecified + */ return 0; len = WideCharToMultiByte(CP_UTF8, 0, wbuf, len, dst, dstlen, NULL, NULL); if (len == 0) elog(ERROR, - "could not convert string to UTF-8:error %lu", GetLastError()); + "could not convert string to UTF-8:error %lu", GetLastError()); dst[len] = '\0'; if (encoding != PG_UTF8) { - char *convstr = pg_do_encoding_conversion(dst, len, PG_UTF8, encoding); + char *convstr = pg_do_encoding_conversion(dst, len, PG_UTF8, encoding); + if (dst != convstr) { strlcpy(dst, convstr, dstlen); @@ -501,8 +506,7 @@ strftime_win32(char *dst, size_t dstlen, const wchar_t *format, const struct tm } #define strftime(a,b,c,d) strftime_win32(a,b,L##c,d) - -#endif /* WIN32 */ +#endif /* WIN32 */ /* @@ -511,12 +515,13 @@ strftime_win32(char *dst, size_t dstlen, const wchar_t *format, const struct tm void cache_locale_time(void) { - char *save_lc_time; + char *save_lc_time; time_t timenow; - struct tm *timeinfo; + struct tm *timeinfo; char buf[MAX_L10N_DATA]; char *ptr; int i; + #ifdef WIN32 char *save_lc_ctype; #endif @@ -611,10 +616,11 @@ cache_locale_time(void) * contains the iso formatted locale name. */ static -char *IsoLocaleName(const char *winlocname) +char * +IsoLocaleName(const char *winlocname) { -#if (_MSC_VER >= 1400) /* VC8.0 or later */ - static char iso_lc_messages[32]; +#if (_MSC_VER >= 1400) /* VC8.0 or later */ + static char iso_lc_messages[32]; _locale_t loct = NULL; if (pg_strcasecmp("c", winlocname) == 0 || @@ -627,8 +633,9 @@ char *IsoLocaleName(const char *winlocname) loct = _create_locale(LC_CTYPE, winlocname); if (loct != NULL) { - char isolang[32], isocrty[32]; - LCID lcid; + char isolang[32], + isocrty[32]; + LCID lcid; lcid = loct->locinfo->lc_handle[LC_CTYPE]; if (lcid == 0) @@ -644,8 +651,8 @@ char *IsoLocaleName(const char *winlocname) } return NULL; #else - return NULL; /* Not supported on this version of msvc/mingw */ -#endif /* _MSC_VER >= 1400 */ + return NULL; /* Not supported on this version of msvc/mingw */ +#endif /* _MSC_VER >= 1400 */ } -#endif /* WIN32 && LC_MESSAGES */ +#endif /* WIN32 && LC_MESSAGES */ diff --git a/src/backend/utils/adt/pg_lzcompress.c b/src/backend/utils/adt/pg_lzcompress.c index 20244ae3fc..3978e9581c 100644 --- a/src/backend/utils/adt/pg_lzcompress.c +++ b/src/backend/utils/adt/pg_lzcompress.c @@ -166,7 +166,7 @@ * * Copyright (c) 1999-2009, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/backend/utils/adt/pg_lzcompress.c,v 1.33 2009/01/06 15:51:38 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/pg_lzcompress.c,v 1.34 2009/06/11 14:49:03 momjian Exp $ * ---------- */ #include "postgres.h" @@ -210,23 +210,29 @@ typedef struct PGLZ_HistEntry * ---------- */ static const PGLZ_Strategy strategy_default_data = { - 32, /* Data chunks less than 32 bytes are not compressed */ - INT_MAX, /* No upper limit on what we'll try to compress */ - 25, /* Require 25% compression rate, or not worth it */ - 1024, /* Give up if no compression in the first 1KB */ - 128, /* Stop history lookup if a match of 128 bytes is found */ - 10 /* Lower good match size by 10% at every loop iteration */ + 32, /* Data chunks less than 32 bytes are not + * compressed */ + INT_MAX, /* No upper limit on what we'll try to + * compress */ + 25, /* Require 25% compression rate, or not worth + * it */ + 1024, /* Give up if no compression in the first 1KB */ + 128, /* Stop history lookup if a match of 128 bytes + * is found */ + 10 /* Lower good match size by 10% at every loop + * iteration */ }; const PGLZ_Strategy *const PGLZ_strategy_default = &strategy_default_data; static const PGLZ_Strategy strategy_always_data = { - 0, /* Chunks of any size are compressed */ + 0, /* Chunks of any size are compressed */ INT_MAX, - 0, /* It's enough to save one single byte */ - INT_MAX, /* Never give up early */ - 128, /* Stop history lookup if a match of 128 bytes is found */ - 6 /* Look harder for a good match */ + 0, /* It's enough to save one single byte */ + INT_MAX, /* Never give up early */ + 128, /* Stop history lookup if a match of 128 bytes + * is found */ + 6 /* Look harder for a good match */ }; const PGLZ_Strategy *const PGLZ_strategy_always = &strategy_always_data; @@ -502,8 +508,8 @@ pglz_compress(const char *source, int32 slen, PGLZ_Header *dest, strategy = PGLZ_strategy_default; /* - * If the strategy forbids compression (at all or if source chunk size - * out of range), fail. + * If the strategy forbids compression (at all or if source chunk size out + * of range), fail. */ if (strategy->match_size_good <= 0 || slen < strategy->min_input_size || @@ -537,11 +543,11 @@ pglz_compress(const char *source, int32 slen, PGLZ_Header *dest, need_rate = 99; /* - * Compute the maximum result size allowed by the strategy, namely - * the input size minus the minimum wanted compression rate. This had - * better be <= slen, else we might overrun the provided output buffer. + * Compute the maximum result size allowed by the strategy, namely the + * input size minus the minimum wanted compression rate. This had better + * be <= slen, else we might overrun the provided output buffer. */ - if (slen > (INT_MAX/100)) + if (slen > (INT_MAX / 100)) { /* Approximate to avoid overflow */ result_max = (slen / 100) * (100 - need_rate); @@ -572,7 +578,7 @@ pglz_compress(const char *source, int32 slen, PGLZ_Header *dest, /* * If we've emitted more than first_success_by bytes without finding - * anything compressible at all, fail. This lets us fall out + * anything compressible at all, fail. This lets us fall out * reasonably quickly when looking at incompressible input (such as * pre-compressed data). */ @@ -654,11 +660,11 @@ pglz_decompress(const PGLZ_Header *source, char *dest) while (sp < srcend && dp < destend) { /* - * Read one control byte and process the next 8 items (or as many - * as remain in the compressed input). + * Read one control byte and process the next 8 items (or as many as + * remain in the compressed input). */ unsigned char ctrl = *sp++; - int ctrlc; + int ctrlc; for (ctrlc = 0; ctrlc < 8 && sp < srcend; ctrlc++) { @@ -681,11 +687,11 @@ pglz_decompress(const PGLZ_Header *source, char *dest) len += *sp++; /* - * Check for output buffer overrun, to ensure we don't - * clobber memory in case of corrupt input. Note: we must - * advance dp here to ensure the error is detected below - * the loop. We don't simply put the elog inside the loop - * since that will probably interfere with optimization. + * Check for output buffer overrun, to ensure we don't clobber + * memory in case of corrupt input. Note: we must advance dp + * here to ensure the error is detected below the loop. We + * don't simply put the elog inside the loop since that will + * probably interfere with optimization. */ if (dp + len > destend) { @@ -711,8 +717,8 @@ pglz_decompress(const PGLZ_Header *source, char *dest) * An unset control bit means LITERAL BYTE. So we just copy * one from INPUT to OUTPUT. */ - if (dp >= destend) /* check for buffer overrun */ - break; /* do not clobber memory */ + if (dp >= destend) /* check for buffer overrun */ + break; /* do not clobber memory */ *dp++ = *sp++; } diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c index b56761d60c..89fb28a402 100644 --- a/src/backend/utils/adt/pgstatfuncs.c +++ b/src/backend/utils/adt/pgstatfuncs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/pgstatfuncs.c,v 1.53 2009/01/01 17:23:49 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/pgstatfuncs.c,v 1.54 2009/06/11 14:49:04 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -332,7 +332,7 @@ pg_stat_get_last_autoanalyze_time(PG_FUNCTION_ARGS) Datum pg_stat_get_function_calls(PG_FUNCTION_ARGS) { - Oid funcid = PG_GETARG_OID(0); + Oid funcid = PG_GETARG_OID(0); PgStat_StatFuncEntry *funcentry; if ((funcentry = pgstat_fetch_stat_funcentry(funcid)) == NULL) @@ -343,7 +343,7 @@ pg_stat_get_function_calls(PG_FUNCTION_ARGS) Datum pg_stat_get_function_time(PG_FUNCTION_ARGS) { - Oid funcid = PG_GETARG_OID(0); + Oid funcid = PG_GETARG_OID(0); PgStat_StatFuncEntry *funcentry; if ((funcentry = pgstat_fetch_stat_funcentry(funcid)) == NULL) @@ -354,7 +354,7 @@ pg_stat_get_function_time(PG_FUNCTION_ARGS) Datum pg_stat_get_function_self_time(PG_FUNCTION_ARGS) { - Oid funcid = PG_GETARG_OID(0); + Oid funcid = PG_GETARG_OID(0); PgStat_StatFuncEntry *funcentry; if ((funcentry = pgstat_fetch_stat_funcentry(funcid)) == NULL) @@ -410,10 +410,10 @@ pg_stat_get_activity(PG_FUNCTION_ARGS) if (SRF_IS_FIRSTCALL()) { MemoryContext oldcontext; - TupleDesc tupdesc; - + TupleDesc tupdesc; + funcctx = SRF_FIRSTCALL_INIT(); - + oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); tupdesc = CreateTemplateTupleDesc(10, false); @@ -441,33 +441,34 @@ pg_stat_get_activity(PG_FUNCTION_ARGS) /* * Get one backend - locate by pid. * - * We lookup the backend early, so we can return zero rows if it doesn't - * exist, instead of returning a single row full of NULLs. + * We lookup the backend early, so we can return zero rows if it + * doesn't exist, instead of returning a single row full of NULLs. */ - int pid = PG_GETARG_INT32(0); - int i; - int n = pgstat_fetch_stat_numbackends(); - + int pid = PG_GETARG_INT32(0); + int i; + int n = pgstat_fetch_stat_numbackends(); + for (i = 1; i <= n; i++) { PgBackendStatus *be = pgstat_fetch_stat_beentry(i); + if (be) { if (be->st_procpid == pid) { - *(int *)(funcctx->user_fctx) = i; + *(int *) (funcctx->user_fctx) = i; break; } } } - if (*(int *)(funcctx->user_fctx) == 0) + if (*(int *) (funcctx->user_fctx) == 0) /* Pid not found, return zero rows */ funcctx->max_calls = 0; else funcctx->max_calls = 1; } - + MemoryContextSwitchTo(oldcontext); } @@ -477,26 +478,26 @@ pg_stat_get_activity(PG_FUNCTION_ARGS) if (funcctx->call_cntr < funcctx->max_calls) { /* for each row */ - Datum values[10]; - bool nulls[10]; - HeapTuple tuple; + Datum values[10]; + bool nulls[10]; + HeapTuple tuple; PgBackendStatus *beentry; - SockAddr zero_clientaddr; + SockAddr zero_clientaddr; MemSet(values, 0, sizeof(values)); MemSet(nulls, 0, sizeof(nulls)); - - if (*(int *)(funcctx->user_fctx) > 0) + + if (*(int *) (funcctx->user_fctx) > 0) /* Get specific pid slot */ - beentry = pgstat_fetch_stat_beentry(*(int *)(funcctx->user_fctx)); + beentry = pgstat_fetch_stat_beentry(*(int *) (funcctx->user_fctx)); else /* Get the next one in the list */ - beentry = pgstat_fetch_stat_beentry(funcctx->call_cntr+1); /* 1-based index */ + beentry = pgstat_fetch_stat_beentry(funcctx->call_cntr + 1); /* 1-based index */ if (!beentry) { - int i; + int i; - for (i = 0; i < sizeof(nulls)/sizeof(nulls[0]); i++) + for (i = 0; i < sizeof(nulls) / sizeof(nulls[0]); i++) nulls[i] = true; nulls[3] = false; @@ -543,7 +544,7 @@ pg_stat_get_activity(PG_FUNCTION_ARGS) /* A zeroed client addr means we don't know */ memset(&zero_clientaddr, 0, sizeof(zero_clientaddr)); if (memcmp(&(beentry->st_clientaddr), &zero_clientaddr, - sizeof(zero_clientaddr) == 0)) + sizeof(zero_clientaddr) == 0)) { nulls[8] = true; nulls[9] = true; @@ -554,9 +555,9 @@ pg_stat_get_activity(PG_FUNCTION_ARGS) #ifdef HAVE_IPV6 || beentry->st_clientaddr.addr.ss_family == AF_INET6 #endif - ) + ) { - char remote_host[NI_MAXHOST]; + char remote_host[NI_MAXHOST]; char remote_port[NI_MAXSERV]; int ret; @@ -576,16 +577,17 @@ pg_stat_get_activity(PG_FUNCTION_ARGS) { clean_ipv6_addr(beentry->st_clientaddr.addr.ss_family, remote_host); values[8] = DirectFunctionCall1(inet_in, - CStringGetDatum(remote_host)); + CStringGetDatum(remote_host)); values[9] = Int32GetDatum(atoi(remote_port)); } } else if (beentry->st_clientaddr.addr.ss_family == AF_UNIX) { /* - * Unix sockets always reports NULL for host and -1 for port, so it's - * possible to tell the difference to connections we have no - * permissions to view, or with errors. + * Unix sockets always reports NULL for host and -1 for + * port, so it's possible to tell the difference to + * connections we have no permissions to view, or with + * errors. */ nulls[8] = true; values[9] = DatumGetInt32(-1); diff --git a/src/backend/utils/adt/quote.c b/src/backend/utils/adt/quote.c index d7553afc97..c9419081d7 100644 --- a/src/backend/utils/adt/quote.c +++ b/src/backend/utils/adt/quote.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/quote.c,v 1.26 2009/01/01 17:23:49 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/quote.c,v 1.27 2009/06/11 14:49:04 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -86,8 +86,8 @@ quote_literal(PG_FUNCTION_ARGS) /* * quote_nullable - - * Returns a properly quoted literal, with null values returned - * as the text string 'NULL'. + * Returns a properly quoted literal, with null values returned + * as the text string 'NULL'. */ Datum quote_nullable(PG_FUNCTION_ARGS) diff --git a/src/backend/utils/adt/regexp.c b/src/backend/utils/adt/regexp.c index f9ccf6352d..e4e3c77665 100644 --- a/src/backend/utils/adt/regexp.c +++ b/src/backend/utils/adt/regexp.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/regexp.c,v 1.81 2009/01/01 17:23:49 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/regexp.c,v 1.82 2009/06/11 14:49:04 momjian Exp $ * * Alistair Crooks added the code for the regex caching * agc - cached the regular expressions used - there's a good chance @@ -40,7 +40,7 @@ /* GUC-settable flavor parameter */ -int regex_flavor = REG_ADVANCED; +int regex_flavor = REG_ADVANCED; /* all the options of interest for regex functions */ @@ -582,10 +582,10 @@ textregexsubstr(PG_FUNCTION_ARGS) } /* - * It is possible to have a match to the whole pattern but no match - * for a subexpression; for example 'foo(bar)?' is considered to match - * 'foo' but there is no subexpression match. So this extra test for - * match failure is not redundant. + * It is possible to have a match to the whole pattern but no match for a + * subexpression; for example 'foo(bar)?' is considered to match 'foo' but + * there is no subexpression match. So this extra test for match failure + * is not redundant. */ if (so < 0 || eo < 0) PG_RETURN_NULL(); diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c index 53b9c43f08..5bcbd63304 100644 --- a/src/backend/utils/adt/ri_triggers.c +++ b/src/backend/utils/adt/ri_triggers.c @@ -15,7 +15,7 @@ * * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.112 2009/01/07 13:44:36 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.113 2009/06/11 14:49:04 momjian Exp $ * * ---------- */ @@ -3620,7 +3620,7 @@ static SPIPlanPtr ri_FetchPreparedPlan(RI_QueryKey *key) { RI_QueryHashEntry *entry; - SPIPlanPtr plan; + SPIPlanPtr plan; /* * On the first call initialize the hashtable @@ -3638,11 +3638,11 @@ ri_FetchPreparedPlan(RI_QueryKey *key) return NULL; /* - * Check whether the plan is still valid. If it isn't, we don't want - * to simply rely on plancache.c to regenerate it; rather we should - * start from scratch and rebuild the query text too. This is to cover - * cases such as table/column renames. We depend on the plancache - * machinery to detect possible invalidations, though. + * Check whether the plan is still valid. If it isn't, we don't want to + * simply rely on plancache.c to regenerate it; rather we should start + * from scratch and rebuild the query text too. This is to cover cases + * such as table/column renames. We depend on the plancache machinery to + * detect possible invalidations, though. * * CAUTION: this check is only trustworthy if the caller has already * locked both FK and PK rels. @@ -3652,8 +3652,8 @@ ri_FetchPreparedPlan(RI_QueryKey *key) return plan; /* - * Otherwise we might as well flush the cached plan now, to free a - * little memory space before we make a new one. + * Otherwise we might as well flush the cached plan now, to free a little + * memory space before we make a new one. */ entry->plan = NULL; if (plan) @@ -3682,8 +3682,8 @@ ri_HashPreparedPlan(RI_QueryKey *key, SPIPlanPtr plan) ri_InitHashTables(); /* - * Add the new plan. We might be overwriting an entry previously - * found invalid by ri_FetchPreparedPlan. + * Add the new plan. We might be overwriting an entry previously found + * invalid by ri_FetchPreparedPlan. */ entry = (RI_QueryHashEntry *) hash_search(ri_query_cache, (void *) key, diff --git a/src/backend/utils/adt/rowtypes.c b/src/backend/utils/adt/rowtypes.c index c2a030baac..9ea8a2d80f 100644 --- a/src/backend/utils/adt/rowtypes.c +++ b/src/backend/utils/adt/rowtypes.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/rowtypes.c,v 1.24 2009/01/01 17:23:50 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/rowtypes.c,v 1.25 2009/06/11 14:49:04 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -57,7 +57,7 @@ typedef struct RecordCompareData int32 record1_typmod; Oid record2_type; int32 record2_typmod; - ColumnCompareData columns[1]; /* VARIABLE LENGTH ARRAY */ + ColumnCompareData columns[1]; /* VARIABLE LENGTH ARRAY */ } RecordCompareData; @@ -822,7 +822,7 @@ record_cmp(FunctionCallInfo fcinfo) { fcinfo->flinfo->fn_extra = MemoryContextAlloc(fcinfo->flinfo->fn_mcxt, - sizeof(RecordCompareData) - sizeof(ColumnCompareData) + sizeof(RecordCompareData) - sizeof(ColumnCompareData) + ncols * sizeof(ColumnCompareData)); my_extra = (RecordCompareData *) fcinfo->flinfo->fn_extra; my_extra->ncolumns = ncols; @@ -854,8 +854,8 @@ record_cmp(FunctionCallInfo fcinfo) /* * Scan corresponding columns, allowing for dropped columns in different - * places in the two rows. i1 and i2 are physical column indexes, - * j is the logical column index. + * places in the two rows. i1 and i2 are physical column indexes, j is + * the logical column index. */ i1 = i2 = j = 0; while (i1 < ncolumns1 || i2 < ncolumns2) @@ -890,7 +890,7 @@ record_cmp(FunctionCallInfo fcinfo) errmsg("cannot compare dissimilar column types %s and %s at record column %d", format_type_be(tupdesc1->attrs[i1]->atttypid), format_type_be(tupdesc2->attrs[i2]->atttypid), - j+1))); + j + 1))); /* * Lookup the comparison function if not done already @@ -904,8 +904,8 @@ record_cmp(FunctionCallInfo fcinfo) if (!OidIsValid(typentry->cmp_proc_finfo.fn_oid)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), - errmsg("could not identify a comparison function for type %s", - format_type_be(typentry->type_id)))); + errmsg("could not identify a comparison function for type %s", + format_type_be(typentry->type_id)))); my_extra->columns[j].typentry = typentry; } @@ -957,8 +957,8 @@ record_cmp(FunctionCallInfo fcinfo) /* * If we didn't break out of the loop early, check for column count - * mismatch. (We do not report such mismatch if we found unequal - * column values; is that a feature or a bug?) + * mismatch. (We do not report such mismatch if we found unequal column + * values; is that a feature or a bug?) */ if (result == 0) { @@ -1048,7 +1048,7 @@ record_eq(PG_FUNCTION_ARGS) { fcinfo->flinfo->fn_extra = MemoryContextAlloc(fcinfo->flinfo->fn_mcxt, - sizeof(RecordCompareData) - sizeof(ColumnCompareData) + sizeof(RecordCompareData) - sizeof(ColumnCompareData) + ncols * sizeof(ColumnCompareData)); my_extra = (RecordCompareData *) fcinfo->flinfo->fn_extra; my_extra->ncolumns = ncols; @@ -1080,8 +1080,8 @@ record_eq(PG_FUNCTION_ARGS) /* * Scan corresponding columns, allowing for dropped columns in different - * places in the two rows. i1 and i2 are physical column indexes, - * j is the logical column index. + * places in the two rows. i1 and i2 are physical column indexes, j is + * the logical column index. */ i1 = i2 = j = 0; while (i1 < ncolumns1 || i2 < ncolumns2) @@ -1116,7 +1116,7 @@ record_eq(PG_FUNCTION_ARGS) errmsg("cannot compare dissimilar column types %s and %s at record column %d", format_type_be(tupdesc1->attrs[i1]->atttypid), format_type_be(tupdesc2->attrs[i2]->atttypid), - j+1))); + j + 1))); /* * Lookup the equality function if not done already @@ -1130,8 +1130,8 @@ record_eq(PG_FUNCTION_ARGS) if (!OidIsValid(typentry->eq_opr_finfo.fn_oid)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), - errmsg("could not identify an equality operator for type %s", - format_type_be(typentry->type_id)))); + errmsg("could not identify an equality operator for type %s", + format_type_be(typentry->type_id)))); my_extra->columns[j].typentry = typentry; } @@ -1168,8 +1168,8 @@ record_eq(PG_FUNCTION_ARGS) /* * If we didn't break out of the loop early, check for column count - * mismatch. (We do not report such mismatch if we found unequal - * column values; is that a feature or a bug?) + * mismatch. (We do not report such mismatch if we found unequal column + * values; is that a feature or a bug?) */ if (result) { diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 058899bcc6..f52bf8b5a1 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.299 2009/06/09 14:36:06 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.300 2009/06/11 14:49:04 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -176,10 +176,10 @@ static Node *get_rule_sortgroupclause(SortGroupClause *srt, List *tlist, bool force_colno, deparse_context *context); static void get_rule_orderby(List *orderList, List *targetList, - bool force_colno, deparse_context *context); + bool force_colno, deparse_context *context); static void get_rule_windowclause(Query *query, deparse_context *context); static void get_rule_windowspec(WindowClause *wc, List *targetList, - deparse_context *context); + deparse_context *context); static void push_plan(deparse_namespace *dpns, Plan *subplan); static char *get_variable(Var *var, int levelsup, bool showstar, deparse_context *context); @@ -219,7 +219,7 @@ static Node *processIndirection(Node *node, deparse_context *context, static void printSubscripts(ArrayRef *aref, deparse_context *context); static char *generate_relation_name(Oid relid, List *namespaces); static char *generate_function_name(Oid funcid, int nargs, Oid *argtypes, - bool *is_variadic); + bool *is_variadic); static char *generate_operator_name(Oid operid, Oid arg1, Oid arg2); static text *string_to_text(char *str); static char *flatten_reloptions(Oid relid); @@ -1435,8 +1435,8 @@ pg_get_serial_sequence(PG_FUNCTION_ARGS) /* * pg_get_functiondef - * Returns the complete "CREATE OR REPLACE FUNCTION ..." statement for - * the specified function. + * Returns the complete "CREATE OR REPLACE FUNCTION ..." statement for + * the specified function. */ Datum pg_get_functiondef(PG_FUNCTION_ARGS) @@ -1481,8 +1481,8 @@ pg_get_functiondef(PG_FUNCTION_ARGS) lang = (Form_pg_language) GETSTRUCT(langtup); /* - * We always qualify the function name, to ensure the right function - * gets replaced. + * We always qualify the function name, to ensure the right function gets + * replaced. */ nsp = get_namespace_name(proc->pronamespace); appendStringInfo(&buf, "CREATE OR REPLACE FUNCTION %s(", @@ -1533,7 +1533,7 @@ pg_get_functiondef(PG_FUNCTION_ARGS) tmp = SysCacheGetAttr(PROCOID, proctup, Anum_pg_proc_proconfig, &isnull); if (!isnull) { - ArrayType *a = DatumGetArrayTypeP(tmp); + ArrayType *a = DatumGetArrayTypeP(tmp); int i; Assert(ARR_ELEMTYPE(a) == TEXTOID); @@ -1542,7 +1542,7 @@ pg_get_functiondef(PG_FUNCTION_ARGS) for (i = 1; i <= ARR_DIMS(a)[0]; i++) { - Datum d; + Datum d; d = array_ref(a, 1, &i, -1 /* varlenarray */ , @@ -1595,9 +1595,9 @@ pg_get_functiondef(PG_FUNCTION_ARGS) /* * We always use dollar quoting. Figure out a suitable delimiter. * - * Since the user is likely to be editing the function body string, - * we shouldn't use a short delimiter that he might easily create a - * conflict with. Hence prefer "$function$", but extend if needed. + * Since the user is likely to be editing the function body string, we + * shouldn't use a short delimiter that he might easily create a conflict + * with. Hence prefer "$function$", but extend if needed. */ initStringInfo(&dq); appendStringInfoString(&dq, "$function"); @@ -1771,8 +1771,8 @@ print_function_arguments(StringInfo buf, HeapTuple proctup, &isnull); if (!isnull) { - char *str; - List *argdefaults; + char *str; + List *argdefaults; str = TextDatumGetCString(proargdefaults); argdefaults = (List *) stringToNode(str); @@ -1788,11 +1788,11 @@ print_function_arguments(StringInfo buf, HeapTuple proctup, inputargno = 0; for (i = 0; i < numargs; i++) { - Oid argtype = argtypes[i]; - char *argname = argnames ? argnames[i] : NULL; - char argmode = argmodes ? argmodes[i] : PROARGMODE_IN; + Oid argtype = argtypes[i]; + char *argname = argnames ? argnames[i] : NULL; + char argmode = argmodes ? argmodes[i] : PROARGMODE_IN; const char *modename; - bool isinput; + bool isinput; switch (argmode) { @@ -1818,7 +1818,7 @@ print_function_arguments(StringInfo buf, HeapTuple proctup, break; default: elog(ERROR, "invalid parameter mode '%c'", argmode); - modename = NULL; /* keep compiler quiet */ + modename = NULL; /* keep compiler quiet */ isinput = false; break; } @@ -1836,7 +1836,7 @@ print_function_arguments(StringInfo buf, HeapTuple proctup, appendStringInfoString(buf, format_type_be(argtype)); if (print_defaults && isinput && inputargno > nlackdefaults) { - Node *expr; + Node *expr; Assert(nextargdefault != NULL); expr = (Node *) lfirst(nextargdefault); @@ -1949,7 +1949,7 @@ deparse_context_for(const char *aliasname, Oid relid) * right child plans. A special case is that a nestloop inner indexscan * might have OUTER Vars, but the outer side of the join is not a child * plan node. To handle such cases the outer plan node must be passed - * separately. (Pass NULL for outer_plan otherwise.) + * separately. (Pass NULL for outer_plan otherwise.) * * Note: plan and outer_plan really ought to be declared as "Plan *", but * we use "Node *" to avoid having to include plannodes.h in builtins.h. @@ -2370,8 +2370,8 @@ static void get_with_clause(Query *query, deparse_context *context) { StringInfo buf = context->buf; - const char *sep; - ListCell *l; + const char *sep; + ListCell *l; if (query->cteList == NIL) return; @@ -2808,11 +2808,11 @@ get_rule_sortgroupclause(SortGroupClause *srt, List *tlist, bool force_colno, /* * Use column-number form if requested by caller. Otherwise, if - * expression is a constant, force it to be dumped with an explicit - * cast as decoration --- this is because a simple integer constant - * is ambiguous (and will be misinterpreted by findTargetlistEntry()) - * if we dump it without any decoration. Otherwise, just dump the - * expression normally. + * expression is a constant, force it to be dumped with an explicit cast + * as decoration --- this is because a simple integer constant is + * ambiguous (and will be misinterpreted by findTargetlistEntry()) if we + * dump it without any decoration. Otherwise, just dump the expression + * normally. */ if (force_colno) { @@ -3328,7 +3328,7 @@ push_plan(deparse_namespace *dpns, Plan *subplan) dpns->inner_plan = ((SubqueryScan *) subplan)->subplan; else if (IsA(subplan, CteScan)) { - int ctePlanId = ((CteScan *) subplan)->ctePlanId; + int ctePlanId = ((CteScan *) subplan)->ctePlanId; if (ctePlanId > 0 && ctePlanId <= list_length(dpns->subplans)) dpns->inner_plan = list_nth(dpns->subplans, ctePlanId - 1); @@ -3555,7 +3555,7 @@ get_name_for_var_field(Var *var, int fieldno, */ if (IsA(var, RowExpr)) { - RowExpr *r = (RowExpr *) var; + RowExpr *r = (RowExpr *) var; if (fieldno > 0 && fieldno <= list_length(r->colnames)) return strVal(list_nth(r->colnames, fieldno - 1)); @@ -3659,8 +3659,8 @@ get_name_for_var_field(Var *var, int fieldno, * This part has essentially the same logic as the parser's * expandRecordVariable() function, but we are dealing with a different * representation of the input context, and we only need one field name - * not a TupleDesc. Also, we need special cases for finding subquery - * and CTE subplans when deparsing Plan trees. + * not a TupleDesc. Also, we need special cases for finding subquery and + * CTE subplans when deparsing Plan trees. */ expr = (Node *) var; /* default if we can't drill down */ @@ -3721,10 +3721,10 @@ get_name_for_var_field(Var *var, int fieldno, { /* * We're deparsing a Plan tree so we don't have complete - * RTE entries (in particular, rte->subquery is NULL). - * But the only place we'd see a Var directly referencing - * a SUBQUERY RTE is in a SubqueryScan plan node, and we - * can look into the child plan's tlist instead. + * RTE entries (in particular, rte->subquery is NULL). But + * the only place we'd see a Var directly referencing a + * SUBQUERY RTE is in a SubqueryScan plan node, and we can + * look into the child plan's tlist instead. */ TargetEntry *tle; Plan *save_outer; @@ -3811,11 +3811,11 @@ get_name_for_var_field(Var *var, int fieldno, if (IsA(expr, Var)) { /* - * Recurse into the CTE to see what its Var refers - * to. We have to build an additional level of - * namespace to keep in step with varlevelsup in the - * CTE. Furthermore it could be an outer CTE, so - * we may have to delete some levels of namespace. + * Recurse into the CTE to see what its Var refers to. + * We have to build an additional level of namespace + * to keep in step with varlevelsup in the CTE. + * Furthermore it could be an outer CTE, so we may + * have to delete some levels of namespace. */ List *save_nslist = context->namespaces; List *new_nslist; @@ -3845,8 +3845,8 @@ get_name_for_var_field(Var *var, int fieldno, /* * We're deparsing a Plan tree so we don't have a CTE * list. But the only place we'd see a Var directly - * referencing a CTE RTE is in a CteScan plan node, and - * we can look into the subplan's tlist instead. + * referencing a CTE RTE is in a CteScan plan node, and we + * can look into the subplan's tlist instead. */ TargetEntry *tle; Plan *save_outer; @@ -4428,11 +4428,11 @@ get_rule_expr(Node *node, deparse_context *context, case T_SubPlan: { - SubPlan *subplan = (SubPlan *) node; + SubPlan *subplan = (SubPlan *) node; /* * We cannot see an already-planned subplan in rule deparsing, - * only while EXPLAINing a query plan. We don't try to + * only while EXPLAINing a query plan. We don't try to * reconstruct the original SQL, just reference the subplan * that appears elsewhere in EXPLAIN's result. */ @@ -4452,7 +4452,7 @@ get_rule_expr(Node *node, deparse_context *context, appendStringInfo(buf, "(alternatives: "); foreach(lc, asplan->subplans) { - SubPlan *splan = (SubPlan *) lfirst(lc); + SubPlan *splan = (SubPlan *) lfirst(lc); Assert(IsA(splan, SubPlan)); if (splan->useHashTable) @@ -4675,6 +4675,7 @@ get_rule_expr(Node *node, deparse_context *context, appendStringInfo(buf, "ARRAY["); get_rule_expr((Node *) arrayexpr->elements, context, true); appendStringInfoChar(buf, ']'); + /* * If the array isn't empty, we assume its elements are * coerced to the desired type. If it's empty, though, we @@ -4682,7 +4683,7 @@ get_rule_expr(Node *node, deparse_context *context, */ if (arrayexpr->elements == NIL) appendStringInfo(buf, "::%s", - format_type_with_typemod(arrayexpr->array_typeid, -1)); + format_type_with_typemod(arrayexpr->array_typeid, -1)); } break; @@ -5333,9 +5334,10 @@ get_windowfunc_expr(WindowFunc *wfunc, deparse_context *context) if (context->windowClause) elog(ERROR, "could not find window clause for winref %u", wfunc->winref); + /* - * In EXPLAIN, we don't have window context information available, - * so we have to settle for this: + * In EXPLAIN, we don't have window context information available, so + * we have to settle for this: */ appendStringInfoString(buf, "(?)"); } @@ -5523,9 +5525,9 @@ simple_quote_literal(StringInfo buf, const char *val) const char *valptr; /* - * We form the string literal according to the prevailing setting - * of standard_conforming_strings; we never use E''. User is - * responsible for making sure result is used correctly. + * We form the string literal according to the prevailing setting of + * standard_conforming_strings; we never use E''. User is responsible for + * making sure result is used correctly. */ appendStringInfoChar(buf, '\''); for (valptr = val; *valptr; valptr++) @@ -6335,7 +6337,7 @@ generate_relation_name(Oid relid, List *namespaces) * given that it is being called with the specified actual arg types. * (Arg types matter because of ambiguous-function resolution rules.) * - * The result includes all necessary quoting and schema-prefixing. We can + * The result includes all necessary quoting and schema-prefixing. We can * also pass back an indication of whether the function is variadic. */ static char * diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index 3f07db6857..3d60885a79 100644 --- a/src/backend/utils/adt/selfuncs.c +++ b/src/backend/utils/adt/selfuncs.c @@ -15,7 +15,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.260 2009/04/19 19:46:33 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.261 2009/06/11 14:49:04 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -72,7 +72,7 @@ * float8 oprjoin (internal, oid, internal, int2, internal); * * (Before Postgres 8.4, join estimators had only the first four of these - * parameters. That signature is still allowed, but deprecated.) The + * parameters. That signature is still allowed, but deprecated.) The * relationship between jointype and sjinfo is explained in the comments for * clause_selectivity() --- the short version is that jointype is usually * best ignored in favor of examining sjinfo. @@ -135,7 +135,7 @@ static double ineq_histogram_selectivity(VariableStatData *vardata, static double eqjoinsel_inner(Oid operator, VariableStatData *vardata1, VariableStatData *vardata2); static double eqjoinsel_semi(Oid operator, - VariableStatData *vardata1, VariableStatData *vardata2); + VariableStatData *vardata1, VariableStatData *vardata2); static bool convert_to_scalar(Datum value, Oid valuetypid, double *scaledvalue, Datum lobound, Datum hibound, Oid boundstypid, double *scaledlobound, double *scaledhibound); @@ -159,7 +159,7 @@ static double convert_one_bytea_to_scalar(unsigned char *value, int valuelen, static char *convert_string_datum(Datum value, Oid typid); static double convert_timevalue_to_scalar(Datum value, Oid typid); static bool get_variable_range(PlannerInfo *root, VariableStatData *vardata, - Oid sortop, Datum *min, Datum *max); + Oid sortop, Datum *min, Datum *max); static Selectivity prefix_selectivity(VariableStatData *vardata, Oid vartype, Oid opfamily, Const *prefixcon); static Selectivity pattern_selectivity(Const *patt, Pattern_Type ptype); @@ -228,17 +228,17 @@ var_eq_const(VariableStatData *vardata, Oid operator, double selec; /* - * If the constant is NULL, assume operator is strict and - * return zero, ie, operator will never return TRUE. + * If the constant is NULL, assume operator is strict and return zero, ie, + * operator will never return TRUE. */ if (constisnull) return 0.0; /* * If we matched the var to a unique index, assume there is exactly one - * match regardless of anything else. (This is slightly bogus, since - * the index's equality operator might be different from ours, but it's - * more likely to be right than ignoring the information.) + * match regardless of anything else. (This is slightly bogus, since the + * index's equality operator might be different from ours, but it's more + * likely to be right than ignoring the information.) */ if (vardata->isunique && vardata->rel && vardata->rel->tuples >= 1.0) return 1.0 / vardata->rel->tuples; @@ -257,10 +257,10 @@ var_eq_const(VariableStatData *vardata, Oid operator, /* * Is the constant "=" to any of the column's most common values? - * (Although the given operator may not really be "=", we will - * assume that seeing whether it returns TRUE is an appropriate - * test. If you don't like this, maybe you shouldn't be using - * eqsel for your operator...) + * (Although the given operator may not really be "=", we will assume + * that seeing whether it returns TRUE is an appropriate test. If you + * don't like this, maybe you shouldn't be using eqsel for your + * operator...) */ if (get_attstatsslot(vardata->statsTuple, vardata->atttype, vardata->atttypmod, @@ -299,17 +299,16 @@ var_eq_const(VariableStatData *vardata, Oid operator, { /* * Constant is "=" to this common value. We know selectivity - * exactly (or as exactly as ANALYZE could calculate it, - * anyway). + * exactly (or as exactly as ANALYZE could calculate it, anyway). */ selec = numbers[i]; } else { /* - * Comparison is against a constant that is neither NULL nor - * any of the common values. Its selectivity cannot be more - * than this: + * Comparison is against a constant that is neither NULL nor any + * of the common values. Its selectivity cannot be more than + * this: */ double sumcommon = 0.0; double otherdistinct; @@ -320,18 +319,17 @@ var_eq_const(VariableStatData *vardata, Oid operator, CLAMP_PROBABILITY(selec); /* - * and in fact it's probably a good deal less. We approximate - * that all the not-common values share this remaining - * fraction equally, so we divide by the number of other - * distinct values. + * and in fact it's probably a good deal less. We approximate that + * all the not-common values share this remaining fraction + * equally, so we divide by the number of other distinct values. */ otherdistinct = get_variable_numdistinct(vardata) - nnumbers; if (otherdistinct > 1) selec /= otherdistinct; /* - * Another cross-check: selectivity shouldn't be estimated as - * more than the least common "most common value". + * Another cross-check: selectivity shouldn't be estimated as more + * than the least common "most common value". */ if (nnumbers > 0 && selec > numbers[nnumbers - 1]) selec = numbers[nnumbers - 1]; @@ -368,9 +366,9 @@ var_eq_non_const(VariableStatData *vardata, Oid operator, /* * If we matched the var to a unique index, assume there is exactly one - * match regardless of anything else. (This is slightly bogus, since - * the index's equality operator might be different from ours, but it's - * more likely to be right than ignoring the information.) + * match regardless of anything else. (This is slightly bogus, since the + * index's equality operator might be different from ours, but it's more + * likely to be right than ignoring the information.) */ if (vardata->isunique && vardata->rel && vardata->rel->tuples >= 1.0) return 1.0 / vardata->rel->tuples; @@ -391,8 +389,8 @@ var_eq_non_const(VariableStatData *vardata, Oid operator, * result averaged over all possible values whether common or * uncommon. (Essentially, we are assuming that the not-yet-known * comparison value is equally likely to be any of the possible - * values, regardless of their frequency in the table. Is that a - * good idea?) + * values, regardless of their frequency in the table. Is that a good + * idea?) */ selec = 1.0 - stats->stanullfrac; ndistinct = get_variable_numdistinct(vardata); @@ -400,8 +398,8 @@ var_eq_non_const(VariableStatData *vardata, Oid operator, selec /= ndistinct; /* - * Cross-check: selectivity should never be estimated as more than - * the most common value's. + * Cross-check: selectivity should never be estimated as more than the + * most common value's. */ if (get_attstatsslot(vardata->statsTuple, vardata->atttype, vardata->atttypmod, @@ -610,7 +608,7 @@ mcv_selectivity(VariableStatData *vardata, FmgrInfo *opproc, * essentially using the histogram just as a representative sample. However, * small histograms are unlikely to be all that representative, so the caller * should be prepared to fall back on some other estimation approach when the - * histogram is missing or very small. It may also be prudent to combine this + * histogram is missing or very small. It may also be prudent to combine this * approach with another one when the histogram is small. * * If the actual histogram size is not at least min_hist_size, we won't bother @@ -1169,7 +1167,8 @@ patternsel(PG_FUNCTION_ARGS, Pattern_Type ptype, bool negate) * selectivity of the fixed prefix and remainder of pattern * separately, then combine the two to get an estimate of the * selectivity for the part of the column population represented by - * the histogram. (For small histograms, we combine these approaches.) + * the histogram. (For small histograms, we combine these + * approaches.) * * We then add up data for any most-common-values values; these are * not in the histogram population, and we can get exact answers for @@ -1205,7 +1204,7 @@ patternsel(PG_FUNCTION_ARGS, Pattern_Type ptype, bool negate) restsel = pattern_selectivity(rest, ptype); heursel = prefixsel * restsel; - if (selec < 0) /* fewer than 10 histogram entries? */ + if (selec < 0) /* fewer than 10 histogram entries? */ selec = heursel; else { @@ -1214,7 +1213,7 @@ patternsel(PG_FUNCTION_ARGS, Pattern_Type ptype, bool negate) * histogram and heuristic selectivities, putting increasingly * more trust in the histogram for larger sizes. */ - double hist_weight = hist_size / 100.0; + double hist_weight = hist_size / 100.0; selec = selec * hist_weight + heursel * (1.0 - hist_weight); } @@ -1863,22 +1862,22 @@ rowcomparesel(PlannerInfo *root, /* * Decide if it's a join clause. This should match clausesel.c's - * treat_as_join_clause(), except that we intentionally consider only - * the leading columns and not the rest of the clause. + * treat_as_join_clause(), except that we intentionally consider only the + * leading columns and not the rest of the clause. */ if (varRelid != 0) { /* - * Caller is forcing restriction mode (eg, because we are examining - * an inner indexscan qual). + * Caller is forcing restriction mode (eg, because we are examining an + * inner indexscan qual). */ is_join_clause = false; } else if (sjinfo == NULL) { /* - * It must be a restriction clause, since it's being evaluated at - * a scan node. + * It must be a restriction clause, since it's being evaluated at a + * scan node. */ is_join_clause = false; } @@ -1918,6 +1917,7 @@ eqjoinsel(PG_FUNCTION_ARGS) PlannerInfo *root = (PlannerInfo *) PG_GETARG_POINTER(0); Oid operator = PG_GETARG_OID(1); List *args = (List *) PG_GETARG_POINTER(2); + #ifdef NOT_USED JoinType jointype = (JoinType) PG_GETARG_INT16(3); #endif @@ -2163,11 +2163,11 @@ eqjoinsel_inner(Oid operator, * end up with the same answer anyway. * * An additional hack we use here is to clamp the nd1 and nd2 values - * to not more than what we are estimating the input relation sizes - * to be, providing a crude correction for the selectivity of - * restriction clauses on those relations. (We don't do that in the - * other path since there we are comparing the nd values to stats for - * the whole relations.) + * to not more than what we are estimating the input relation sizes to + * be, providing a crude correction for the selectivity of restriction + * clauses on those relations. (We don't do that in the other path + * since there we are comparing the nd values to stats for the whole + * relations.) */ double nullfrac1 = stats1 ? stats1->stanullfrac : 0.0; double nullfrac2 = stats2 ? stats2->stanullfrac : 0.0; @@ -2307,13 +2307,13 @@ eqjoinsel_semi(Oid operator, /* * Now we need to estimate the fraction of relation 1 that has at - * least one join partner. We know for certain that the matched - * MCVs do, so that gives us a lower bound, but we're really in the - * dark about everything else. Our crude approach is: if nd1 <= nd2 - * then assume all non-null rel1 rows have join partners, else assume - * for the uncertain rows that a fraction nd2/nd1 have join partners. - * We can discount the known-matched MCVs from the distinct-values - * counts before doing the division. + * least one join partner. We know for certain that the matched MCVs + * do, so that gives us a lower bound, but we're really in the dark + * about everything else. Our crude approach is: if nd1 <= nd2 then + * assume all non-null rel1 rows have join partners, else assume for + * the uncertain rows that a fraction nd2/nd1 have join partners. We + * can discount the known-matched MCVs from the distinct-values counts + * before doing the division. */ nd1 -= nmatches; nd2 -= nmatches; @@ -2321,10 +2321,10 @@ eqjoinsel_semi(Oid operator, selec = Max(matchfreq1, 1.0 - nullfrac1); else { - double uncertain = 1.0 - matchfreq1 - nullfrac1; + double uncertain = 1.0 - matchfreq1 - nullfrac1; CLAMP_PROBABILITY(uncertain); - selec = matchfreq1 + (nd2/nd1) * uncertain; + selec = matchfreq1 + (nd2 / nd1) * uncertain; } } else @@ -2343,7 +2343,7 @@ eqjoinsel_semi(Oid operator, if (nd1 <= nd2 || nd2 <= 0) selec = 1.0 - nullfrac1; else - selec = (nd2/nd1) * (1.0 - nullfrac1); + selec = (nd2 / nd1) * (1.0 - nullfrac1); } if (have_mcvs1) @@ -2572,8 +2572,8 @@ mergejoinscansel(PlannerInfo *root, Node *clause, * Look up the various operators we need. If we don't find them all, it * probably means the opfamily is broken, but we just fail silently. * - * Note: we expect that pg_statistic histograms will be sorted by the - * '<' operator, regardless of which sort direction we are considering. + * Note: we expect that pg_statistic histograms will be sorted by the '<' + * operator, regardless of which sort direction we are considering. */ switch (strategy) { @@ -2721,9 +2721,9 @@ mergejoinscansel(PlannerInfo *root, Node *clause, /* * Only one of the two "end" fractions can really be less than 1.0; - * believe the smaller estimate and reset the other one to exactly 1.0. - * If we get exactly equal estimates (as can easily happen with - * self-joins), believe neither. + * believe the smaller estimate and reset the other one to exactly 1.0. If + * we get exactly equal estimates (as can easily happen with self-joins), + * believe neither. */ if (*leftend > *rightend) *leftend = 1.0; @@ -2733,8 +2733,8 @@ mergejoinscansel(PlannerInfo *root, Node *clause, *leftend = *rightend = 1.0; /* - * Also, the fraction of the left variable that will be scanned before - * the first join pair is found is the fraction that's < the right-side + * Also, the fraction of the left variable that will be scanned before the + * first join pair is found is the fraction that's < the right-side * minimum value. But only believe non-default estimates, else stick with * our own default. */ @@ -2751,9 +2751,9 @@ mergejoinscansel(PlannerInfo *root, Node *clause, /* * Only one of the two "start" fractions can really be more than zero; - * believe the larger estimate and reset the other one to exactly 0.0. - * If we get exactly equal estimates (as can easily happen with - * self-joins), believe neither. + * believe the larger estimate and reset the other one to exactly 0.0. If + * we get exactly equal estimates (as can easily happen with self-joins), + * believe neither. */ if (*leftstart < *rightstart) *leftstart = 0.0; @@ -2764,8 +2764,8 @@ mergejoinscansel(PlannerInfo *root, Node *clause, /* * If the sort order is nulls-first, we're going to have to skip over any - * nulls too. These would not have been counted by scalarineqsel, and - * we can safely add in this fraction regardless of whether we believe + * nulls too. These would not have been counted by scalarineqsel, and we + * can safely add in this fraction regardless of whether we believe * scalarineqsel's results or not. But be sure to clamp the sum to 1.0! */ if (nulls_first) @@ -2898,7 +2898,7 @@ add_unique_group_var(PlannerInfo *root, List *varinfos, * is as follows: * 1. Expressions yielding boolean are assumed to contribute two groups, * independently of their content, and are ignored in the subsequent - * steps. This is mainly because tests like "col IS NULL" break the + * steps. This is mainly because tests like "col IS NULL" break the * heuristic used in step 2 especially badly. * 2. Reduce the given expressions to a list of unique Vars used. For * example, GROUP BY a, a + b is treated the same as GROUP BY a, b. @@ -2946,7 +2946,7 @@ estimate_num_groups(PlannerInfo *root, List *groupExprs, double input_rows) Assert(groupExprs != NIL); /* - * Count groups derived from boolean grouping expressions. For other + * Count groups derived from boolean grouping expressions. For other * expressions, find the unique Vars used, treating an expression as a Var * if we can find stats for it. For each one, record the statistical * estimate of number of distinct values (total in its table, without @@ -3655,7 +3655,9 @@ convert_string_datum(Datum value, Oid typid) #if _MSC_VER == 1400 /* VS.Net 2005 */ /* - * http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=99694 + * + * http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx? + * FeedbackID=99694 */ { char x[1]; @@ -3958,10 +3960,10 @@ get_join_variables(PlannerInfo *root, List *args, SpecialJoinInfo *sjinfo, if (vardata1->rel && bms_is_subset(vardata1->rel->relids, sjinfo->syn_righthand)) - *join_is_reversed = true; /* var1 is on RHS */ + *join_is_reversed = true; /* var1 is on RHS */ else if (vardata2->rel && bms_is_subset(vardata2->rel->relids, sjinfo->syn_lefthand)) - *join_is_reversed = true; /* var2 is on LHS */ + *join_is_reversed = true; /* var2 is on LHS */ else *join_is_reversed = false; } @@ -4036,8 +4038,8 @@ examine_variable(PlannerInfo *root, Node *node, int varRelid, (*get_relation_stats_hook) (root, rte, var->varattno, vardata)) { /* - * The hook took control of acquiring a stats tuple. If it - * did supply a tuple, it'd better have supplied a freefunc. + * The hook took control of acquiring a stats tuple. If it did + * supply a tuple, it'd better have supplied a freefunc. */ if (HeapTupleIsValid(vardata->statsTuple) && !vardata->freefunc) @@ -4169,10 +4171,10 @@ examine_variable(PlannerInfo *root, Node *node, int varRelid, /* * Has it got stats? We only consider stats for - * non-partial indexes, since partial indexes - * probably don't reflect whole-relation statistics; - * the above check for uniqueness is the only info - * we take from a partial index. + * non-partial indexes, since partial indexes probably + * don't reflect whole-relation statistics; the above + * check for uniqueness is the only info we take from + * a partial index. * * An index stats hook, however, must make its own * decisions about what to do with partial indexes. @@ -4194,7 +4196,7 @@ examine_variable(PlannerInfo *root, Node *node, int varRelid, { vardata->statsTuple = SearchSysCache(STATRELATT, - ObjectIdGetDatum(index->indexoid), + ObjectIdGetDatum(index->indexoid), Int16GetDatum(pos + 1), 0, 0); vardata->freefunc = ReleaseSysCache; @@ -4281,9 +4283,9 @@ get_variable_numdistinct(VariableStatData *vardata) /* * If there is a unique index for the variable, assume it is unique no - * matter what pg_statistic says; the statistics could be out of date, - * or we might have found a partial unique index that proves the var - * is unique for this query. + * matter what pg_statistic says; the statistics could be out of date, or + * we might have found a partial unique index that proves the var is + * unique for this query. */ if (vardata->isunique) stadistinct = -1.0; @@ -4817,7 +4819,7 @@ prefix_selectivity(VariableStatData *vardata, Oid cmpopr; FmgrInfo opproc; Const *greaterstrcon; - Selectivity eq_sel; + Selectivity eq_sel; cmpopr = get_opfamily_member(opfamily, vartype, vartype, BTGreaterEqualStrategyNumber); @@ -4868,17 +4870,17 @@ prefix_selectivity(VariableStatData *vardata, } /* - * If the prefix is long then the two bounding values might be too - * close together for the histogram to distinguish them usefully, - * resulting in a zero estimate (plus or minus roundoff error). - * To avoid returning a ridiculously small estimate, compute the - * estimated selectivity for "variable = 'foo'", and clamp to that. - * (Obviously, the resultant estimate should be at least that.) + * If the prefix is long then the two bounding values might be too close + * together for the histogram to distinguish them usefully, resulting in a + * zero estimate (plus or minus roundoff error). To avoid returning a + * ridiculously small estimate, compute the estimated selectivity for + * "variable = 'foo'", and clamp to that. (Obviously, the resultant + * estimate should be at least that.) * * We apply this even if we couldn't make a greater string. That case * suggests that the prefix is near the maximum possible, and thus - * probably off the end of the histogram, and thus we probably got a - * very small estimate from the >= condition; so we still need to clamp. + * probably off the end of the histogram, and thus we probably got a very + * small estimate from the >= condition; so we still need to clamp. */ cmpopr = get_opfamily_member(opfamily, vartype, vartype, BTEqualStrategyNumber); diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c index 3fb4ebe285..f4687d4ea9 100644 --- a/src/backend/utils/adt/timestamp.c +++ b/src/backend/utils/adt/timestamp.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.200 2009/06/01 23:55:15 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.201 2009/06/11 14:49:04 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -43,6 +43,7 @@ /* Set at postmaster start */ TimestampTz PgStartTime; + /* Set at configuration reload */ TimestampTz PgReloadTime; @@ -56,8 +57,8 @@ typedef struct typedef struct { - TimestampTz current; - TimestampTz finish; + TimestampTz current; + TimestampTz finish; Interval step; int step_sign; } generate_series_timestamptz_fctx; @@ -631,7 +632,7 @@ interval_in(PG_FUNCTION_ARGS) /* if those functions think it's a bad format, try ISO8601 style */ if (dterr == DTERR_BAD_FORMAT) - dterr = DecodeISO8601Interval(str, + dterr = DecodeISO8601Interval(str, &dtype, tm, &fsec); if (dterr != 0) @@ -750,7 +751,7 @@ intervaltypmodin(PG_FUNCTION_ARGS) tl = ArrayGetIntegerTypmods(ta, &n); /* - * tl[0] - interval range (fields bitmask) tl[1] - precision (optional) + * tl[0] - interval range (fields bitmask) tl[1] - precision (optional) * * Note we must validate tl[0] even though it's normally guaranteed * correct by the grammar --- consider SELECT 'foo'::"interval"(1000). @@ -963,22 +964,22 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod) int precision = INTERVAL_PRECISION(typmod); /* - * Our interpretation of intervals with a limited set of fields - * is that fields to the right of the last one specified are zeroed - * out, but those to the left of it remain valid. Thus for example - * there is no operational difference between INTERVAL YEAR TO MONTH - * and INTERVAL MONTH. In some cases we could meaningfully enforce - * that higher-order fields are zero; for example INTERVAL DAY could - * reject nonzero "month" field. However that seems a bit pointless - * when we can't do it consistently. (We cannot enforce a range limit - * on the highest expected field, since we do not have any equivalent - * of SQL's <interval leading field precision>.) + * Our interpretation of intervals with a limited set of fields is + * that fields to the right of the last one specified are zeroed out, + * but those to the left of it remain valid. Thus for example there + * is no operational difference between INTERVAL YEAR TO MONTH and + * INTERVAL MONTH. In some cases we could meaningfully enforce that + * higher-order fields are zero; for example INTERVAL DAY could reject + * nonzero "month" field. However that seems a bit pointless when we + * can't do it consistently. (We cannot enforce a range limit on the + * highest expected field, since we do not have any equivalent of + * SQL's <interval leading field precision>.) * * Note: before PG 8.4 we interpreted a limited set of fields as * actually causing a "modulo" operation on a given value, potentially - * losing high-order as well as low-order information. But there is + * losing high-order as well as low-order information. But there is * no support for such behavior in the standard, and it seems fairly - * undesirable on data consistency grounds anyway. Now we only + * undesirable on data consistency grounds anyway. Now we only * perform truncation or rounding of low-order fields. */ if (range == INTERVAL_FULL_RANGE) @@ -1137,7 +1138,7 @@ EncodeSpecialTimestamp(Timestamp dt, char *str) strcpy(str, EARLY); else if (TIMESTAMP_IS_NOEND(dt)) strcpy(str, LATE); - else /* shouldn't happen */ + else /* shouldn't happen */ elog(ERROR, "invalid argument for EncodeSpecialTimestamp"); } @@ -4394,7 +4395,7 @@ timestamp_zone(PG_FUNCTION_ARGS) PG_RETURN_TIMESTAMPTZ(timestamp); /* - * Look up the requested timezone. First we look in the date token table + * Look up the requested timezone. First we look in the date token table * (to handle cases like "EST"), and if that fails, we look in the * timezone database (to handle cases like "America/New_York"). (This * matches the order in which timestamp input checks the cases; it's @@ -4438,7 +4439,7 @@ timestamp_zone(PG_FUNCTION_ARGS) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("time zone \"%s\" not recognized", tzname))); - result = 0; /* keep compiler quiet */ + result = 0; /* keep compiler quiet */ } } @@ -4568,7 +4569,7 @@ timestamptz_zone(PG_FUNCTION_ARGS) PG_RETURN_TIMESTAMP(timestamp); /* - * Look up the requested timezone. First we look in the date token table + * Look up the requested timezone. First we look in the date token table * (to handle cases like "EST"), and if that fails, we look in the * timezone database (to handle cases like "America/New_York"). (This * matches the order in which timestamp input checks the cases; it's @@ -4611,7 +4612,7 @@ timestamptz_zone(PG_FUNCTION_ARGS) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("time zone \"%s\" not recognized", tzname))); - result = 0; /* keep compiler quiet */ + result = 0; /* keep compiler quiet */ } } @@ -4659,16 +4660,16 @@ generate_series_timestamp(PG_FUNCTION_ARGS) { FuncCallContext *funcctx; generate_series_timestamp_fctx *fctx; - Timestamp result; + Timestamp result; /* stuff done only on the first call of the function */ if (SRF_IS_FIRSTCALL()) { - Timestamp start = PG_GETARG_TIMESTAMP(0); - Timestamp finish = PG_GETARG_TIMESTAMP(1); - Interval *step = PG_GETARG_INTERVAL_P(2); + Timestamp start = PG_GETARG_TIMESTAMP(0); + Timestamp finish = PG_GETARG_TIMESTAMP(1); + Interval *step = PG_GETARG_INTERVAL_P(2); MemoryContext oldcontext; - Interval interval_zero; + Interval interval_zero; /* create a function context for cross-call persistence */ funcctx = SRF_FIRSTCALL_INIT(); @@ -4718,9 +4719,9 @@ generate_series_timestamp(PG_FUNCTION_ARGS) { /* increment current in preparation for next iteration */ fctx->current = DatumGetTimestamp( - DirectFunctionCall2(timestamp_pl_interval, - TimestampGetDatum(fctx->current), - PointerGetDatum(&fctx->step))); + DirectFunctionCall2(timestamp_pl_interval, + TimestampGetDatum(fctx->current), + PointerGetDatum(&fctx->step))); /* do when there is more left to send */ SRF_RETURN_NEXT(funcctx, TimestampGetDatum(result)); @@ -4747,9 +4748,9 @@ generate_series_timestamptz(PG_FUNCTION_ARGS) { TimestampTz start = PG_GETARG_TIMESTAMPTZ(0); TimestampTz finish = PG_GETARG_TIMESTAMPTZ(1); - Interval *step = PG_GETARG_INTERVAL_P(2); + Interval *step = PG_GETARG_INTERVAL_P(2); MemoryContext oldcontext; - Interval interval_zero; + Interval interval_zero; /* create a function context for cross-call persistence */ funcctx = SRF_FIRSTCALL_INIT(); @@ -4799,9 +4800,9 @@ generate_series_timestamptz(PG_FUNCTION_ARGS) { /* increment current in preparation for next iteration */ fctx->current = DatumGetTimestampTz( - DirectFunctionCall2(timestamptz_pl_interval, - TimestampTzGetDatum(fctx->current), - PointerGetDatum(&fctx->step))); + DirectFunctionCall2(timestamptz_pl_interval, + TimestampTzGetDatum(fctx->current), + PointerGetDatum(&fctx->step))); /* do when there is more left to send */ SRF_RETURN_NEXT(funcctx, TimestampTzGetDatum(result)); diff --git a/src/backend/utils/adt/trigfuncs.c b/src/backend/utils/adt/trigfuncs.c index b34046a7c3..380d174a6a 100644 --- a/src/backend/utils/adt/trigfuncs.c +++ b/src/backend/utils/adt/trigfuncs.c @@ -1,13 +1,13 @@ /*------------------------------------------------------------------------- * * trigfuncs.c - * Builtin functions for useful trigger support. + * Builtin functions for useful trigger support. * * * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/utils/adt/trigfuncs.c,v 1.6 2009/01/01 17:23:50 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/trigfuncs.c,v 1.7 2009/06/11 14:49:04 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -27,61 +27,64 @@ Datum suppress_redundant_updates_trigger(PG_FUNCTION_ARGS) { - TriggerData *trigdata = (TriggerData *) fcinfo->context; - HeapTuple newtuple, oldtuple, rettuple; - HeapTupleHeader newheader, oldheader; + TriggerData *trigdata = (TriggerData *) fcinfo->context; + HeapTuple newtuple, + oldtuple, + rettuple; + HeapTupleHeader newheader, + oldheader; - /* make sure it's called as a trigger */ - if (!CALLED_AS_TRIGGER(fcinfo)) - ereport(ERROR, + /* make sure it's called as a trigger */ + if (!CALLED_AS_TRIGGER(fcinfo)) + ereport(ERROR, (errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED), errmsg("suppress_redundant_updates_trigger: must be called as trigger"))); - - /* and that it's called on update */ - if (! TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event)) - ereport(ERROR, + + /* and that it's called on update */ + if (!TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event)) + ereport(ERROR, (errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED), errmsg("suppress_redundant_updates_trigger: must be called on update"))); - /* and that it's called before update */ - if (! TRIGGER_FIRED_BEFORE(trigdata->tg_event)) - ereport(ERROR, + /* and that it's called before update */ + if (!TRIGGER_FIRED_BEFORE(trigdata->tg_event)) + ereport(ERROR, (errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED), errmsg("suppress_redundant_updates_trigger: must be called before update"))); - /* and that it's called for each row */ - if (! TRIGGER_FIRED_FOR_ROW(trigdata->tg_event)) - ereport(ERROR, + /* and that it's called for each row */ + if (!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event)) + ereport(ERROR, (errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED), errmsg("suppress_redundant_updates_trigger: must be called for each row"))); /* get tuple data, set default result */ - rettuple = newtuple = trigdata->tg_newtuple; + rettuple = newtuple = trigdata->tg_newtuple; oldtuple = trigdata->tg_trigtuple; newheader = newtuple->t_data; oldheader = oldtuple->t_data; /* - * We are called before the OID, if any, has been transcribed from the - * old tuple to the new (in heap_update). To avoid a bogus compare - * failure, copy the OID now. But check that someone didn't already put - * another OID value into newtuple. (That's not actually possible at - * present, but maybe someday.) + * We are called before the OID, if any, has been transcribed from the old + * tuple to the new (in heap_update). To avoid a bogus compare failure, + * copy the OID now. But check that someone didn't already put another + * OID value into newtuple. (That's not actually possible at present, but + * maybe someday.) */ - if (trigdata->tg_relation->rd_rel->relhasoids && + if (trigdata->tg_relation->rd_rel->relhasoids && !OidIsValid(HeapTupleHeaderGetOid(newheader))) HeapTupleHeaderSetOid(newheader, HeapTupleHeaderGetOid(oldheader)); /* if the tuple payload is the same ... */ - if (newtuple->t_len == oldtuple->t_len && + if (newtuple->t_len == oldtuple->t_len && newheader->t_hoff == oldheader->t_hoff && - (HeapTupleHeaderGetNatts(newheader) == + (HeapTupleHeaderGetNatts(newheader) == HeapTupleHeaderGetNatts(oldheader)) && - ((newheader->t_infomask & ~HEAP_XACT_MASK) == + ((newheader->t_infomask & ~HEAP_XACT_MASK) == (oldheader->t_infomask & ~HEAP_XACT_MASK)) && - memcmp(((char *)newheader) + offsetof(HeapTupleHeaderData, t_bits), - ((char *)oldheader) + offsetof(HeapTupleHeaderData, t_bits), + memcmp(((char *) newheader) + offsetof(HeapTupleHeaderData, t_bits), + ((char *) oldheader) + offsetof(HeapTupleHeaderData, t_bits), newtuple->t_len - offsetof(HeapTupleHeaderData, t_bits)) == 0) { /* ... then suppress the update */ diff --git a/src/backend/utils/adt/tsginidx.c b/src/backend/utils/adt/tsginidx.c index 262a604ded..6b43585965 100644 --- a/src/backend/utils/adt/tsginidx.c +++ b/src/backend/utils/adt/tsginidx.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/tsginidx.c,v 1.15 2009/03/25 22:19:01 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/tsginidx.c,v 1.16 2009/06/11 14:49:04 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,42 +22,43 @@ Datum gin_cmp_tslexeme(PG_FUNCTION_ARGS) { - text *a = PG_GETARG_TEXT_PP(0); - text *b = PG_GETARG_TEXT_PP(1); - int cmp; + text *a = PG_GETARG_TEXT_PP(0); + text *b = PG_GETARG_TEXT_PP(1); + int cmp; cmp = tsCompareString( - VARDATA_ANY(a), VARSIZE_ANY_EXHDR(a), - VARDATA_ANY(b), VARSIZE_ANY_EXHDR(b), - false ); + VARDATA_ANY(a), VARSIZE_ANY_EXHDR(a), + VARDATA_ANY(b), VARSIZE_ANY_EXHDR(b), + false); - PG_FREE_IF_COPY(a,0); - PG_FREE_IF_COPY(b,1); - PG_RETURN_INT32( cmp ); + PG_FREE_IF_COPY(a, 0); + PG_FREE_IF_COPY(b, 1); + PG_RETURN_INT32(cmp); } Datum gin_cmp_prefix(PG_FUNCTION_ARGS) { - text *a = PG_GETARG_TEXT_PP(0); - text *b = PG_GETARG_TEXT_PP(1); + text *a = PG_GETARG_TEXT_PP(0); + text *b = PG_GETARG_TEXT_PP(1); + #ifdef NOT_USED StrategyNumber strategy = PG_GETARG_UINT16(2); - Pointer extra_data = PG_GETARG_POINTER(3); + Pointer extra_data = PG_GETARG_POINTER(3); #endif - int cmp; + int cmp; cmp = tsCompareString( - VARDATA_ANY(a), VARSIZE_ANY_EXHDR(a), - VARDATA_ANY(b), VARSIZE_ANY_EXHDR(b), - true ); + VARDATA_ANY(a), VARSIZE_ANY_EXHDR(a), + VARDATA_ANY(b), VARSIZE_ANY_EXHDR(b), + true); - if ( cmp < 0 ) - cmp = 1; /* prevent continue scan */ + if (cmp < 0) + cmp = 1; /* prevent continue scan */ - PG_FREE_IF_COPY(a,0); - PG_FREE_IF_COPY(b,1); - PG_RETURN_INT32( cmp ); + PG_FREE_IF_COPY(a, 0); + PG_FREE_IF_COPY(b, 1); + PG_RETURN_INT32(cmp); } Datum @@ -95,11 +96,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 **ptr_partialmatch = (bool **) PG_GETARG_POINTER(3); + Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4); Datum *entries = NULL; - bool *partialmatch; + bool *partialmatch; *nentries = 0; @@ -109,7 +111,7 @@ gin_extract_tsquery(PG_FUNCTION_ARGS) j = 0, len; QueryItem *item; - bool use_fullscan=false; + bool use_fullscan = false; int *map_item_operand; item = clean_NOT(GETQUERY(query), &len); @@ -126,15 +128,14 @@ gin_extract_tsquery(PG_FUNCTION_ARGS) (*nentries)++; entries = (Datum *) palloc(sizeof(Datum) * (*nentries)); - partialmatch = *ptr_partialmatch = (bool*) palloc(sizeof(bool) * (*nentries)); + partialmatch = *ptr_partialmatch = (bool *) palloc(sizeof(bool) * (*nentries)); /* - * Make map to convert item's number to corresponding - * operand's (the same, entry's) number. Entry's number - * is used in check array in consistent method. We use - * the same map for each entry. + * Make map to convert item's number to corresponding operand's (the + * same, entry's) number. Entry's number is used in check array in + * consistent method. We use the same map for each entry. */ - *extra_data = (Pointer*) palloc0(sizeof(Pointer)*(*nentries)); + *extra_data = (Pointer *) palloc0(sizeof(Pointer) * (*nentries)); map_item_operand = palloc0(sizeof(int) * (query->size + 1)); for (i = 0; i < query->size; i++) @@ -145,15 +146,15 @@ gin_extract_tsquery(PG_FUNCTION_ARGS) txt = cstring_to_text_with_len(GETOPERAND(query) + val->distance, val->length); - (*extra_data)[j] = (Pointer)map_item_operand; + (*extra_data)[j] = (Pointer) map_item_operand; map_item_operand[i] = j; partialmatch[j] = val->prefix; entries[j++] = PointerGetDatum(txt); } - if ( use_fullscan ) + if (use_fullscan) { - (*extra_data)[j] = (Pointer)map_item_operand; + (*extra_data)[j] = (Pointer) map_item_operand; map_item_operand[i] = j; entries[j++] = PointerGetDatum(cstring_to_text_with_len("", 0)); } @@ -185,7 +186,7 @@ checkcondition_gin(void *checkval, QueryOperand *val) *(gcv->need_recheck) = true; /* convert item's number to corresponding entry's (operand's) number */ - j = gcv->map_item_operand[ ((QueryItem *) val) - gcv->first_item ]; + j = gcv->map_item_operand[((QueryItem *) val) - gcv->first_item]; /* return presence of current entry in indexed value */ return gcv->check[j]; @@ -195,10 +196,12 @@ Datum gin_tsquery_consistent(PG_FUNCTION_ARGS) { bool *check = (bool *) PG_GETARG_POINTER(0); + /* StrategyNumber strategy = PG_GETARG_UINT16(1); */ TSQuery query = PG_GETARG_TSQUERY(2); + /* int32 nkeys = PG_GETARG_INT32(3); */ - Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); + Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); bool *recheck = (bool *) PG_GETARG_POINTER(5); bool res = FALSE; @@ -216,7 +219,7 @@ gin_tsquery_consistent(PG_FUNCTION_ARGS) */ gcv.first_item = item = GETQUERY(query); gcv.check = check; - gcv.map_item_operand = (int*)(extra_data[0]); + gcv.map_item_operand = (int *) (extra_data[0]); gcv.need_recheck = recheck; res = TS_execute( diff --git a/src/backend/utils/adt/tsgistidx.c b/src/backend/utils/adt/tsgistidx.c index 3f1c84d14b..72e45dcf0b 100644 --- a/src/backend/utils/adt/tsgistidx.c +++ b/src/backend/utils/adt/tsgistidx.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/tsgistidx.c,v 1.10 2009/01/01 17:23:50 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/tsgistidx.c,v 1.11 2009/06/11 14:49:04 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -307,10 +307,10 @@ checkcondition_arr(void *checkval, QueryOperand *val) /* Loop invariant: StopLow <= val < StopHigh */ - /* - * we are not able to find a a prefix by hash value + /* + * we are not able to find a a prefix by hash value */ - if ( val->prefix ) + if (val->prefix) return true; while (StopLow < StopHigh) @@ -330,11 +330,11 @@ checkcondition_arr(void *checkval, QueryOperand *val) static bool checkcondition_bit(void *checkval, QueryOperand *val) { - /* - * we are not able to find a a prefix in signature tree + /* + * we are not able to find a a prefix in signature tree */ - if ( val->prefix ) - return true; + if (val->prefix) + return true; return GETBIT(checkval, HASHVAL(val->valcrc)); } @@ -343,6 +343,7 @@ gtsvector_consistent(PG_FUNCTION_ARGS) { GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); TSQuery query = PG_GETARG_TSQUERY(1); + /* StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); */ /* Oid subtype = PG_GETARG_OID(3); */ bool *recheck = (bool *) PG_GETARG_POINTER(4); diff --git a/src/backend/utils/adt/tsquery.c b/src/backend/utils/adt/tsquery.c index 8b9c3d485d..7ca8467833 100644 --- a/src/backend/utils/adt/tsquery.c +++ b/src/backend/utils/adt/tsquery.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/tsquery.c,v 1.19 2009/01/01 17:23:50 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/tsquery.c,v 1.20 2009/06/11 14:49:04 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -56,7 +56,7 @@ struct TSQueryParserStateData #define WAITSINGLEOPERAND 4 /* - * subroutine to parse the modifiers (weight and prefix flag currently) + * subroutine to parse the modifiers (weight and prefix flag currently) * part, like ':1AB' of a query. */ static char * @@ -642,7 +642,7 @@ infix(INFIX *in, bool first) { *(in->cur) = ':'; in->cur++; - if ( curpol->prefix ) + if (curpol->prefix) { *(in->cur) = '*'; in->cur++; diff --git a/src/backend/utils/adt/tsquery_gist.c b/src/backend/utils/adt/tsquery_gist.c index 10d9fd01ec..be0b39bf1e 100644 --- a/src/backend/utils/adt/tsquery_gist.c +++ b/src/backend/utils/adt/tsquery_gist.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_gist.c,v 1.8 2009/01/01 17:23:50 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_gist.c,v 1.9 2009/06/11 14:49:04 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -55,9 +55,10 @@ gtsquery_consistent(PG_FUNCTION_ARGS) GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); TSQuery query = PG_GETARG_TSQUERY(1); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ bool *recheck = (bool *) PG_GETARG_POINTER(4); - TSQuerySign key = DatumGetTSQuerySign(entry->key); + TSQuerySign key = DatumGetTSQuerySign(entry->key); TSQuerySign sq = makeTSQuerySign(query); bool retval; diff --git a/src/backend/utils/adt/tsquery_op.c b/src/backend/utils/adt/tsquery_op.c index d3fc368769..6b7e976a43 100644 --- a/src/backend/utils/adt/tsquery_op.c +++ b/src/backend/utils/adt/tsquery_op.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_op.c,v 1.5 2009/05/27 19:41:58 petere Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_op.c,v 1.6 2009/06/11 14:49:04 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -188,7 +188,7 @@ NAME(PG_FUNCTION_ARGS) { \ PG_FREE_IF_COPY(b,1); \ \ PG_RETURN_BOOL( CONDITION ); \ -} \ +} \ /* keep compiler quiet - no extra ; */ \ extern int no_such_variable diff --git a/src/backend/utils/adt/tsquery_util.c b/src/backend/utils/adt/tsquery_util.c index 78814feca6..9efd5fa8d3 100644 --- a/src/backend/utils/adt/tsquery_util.c +++ b/src/backend/utils/adt/tsquery_util.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_util.c,v 1.10 2009/01/01 17:23:50 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_util.c,v 1.11 2009/06/11 14:49:04 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -125,7 +125,7 @@ QTNodeCompare(QTNode *an, QTNode *bn) return (ao->valcrc > bo->valcrc) ? -1 : 1; } - return tsCompareString( an->word, ao->length, bn->word, bo->length, false); + return tsCompareString(an->word, ao->length, bn->word, bo->length, false); } } diff --git a/src/backend/utils/adt/tsrank.c b/src/backend/utils/adt/tsrank.c index f1b7b8ea56..3dac5ce0cd 100644 --- a/src/backend/utils/adt/tsrank.c +++ b/src/backend/utils/adt/tsrank.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/tsrank.c,v 1.14 2009/01/01 17:23:50 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/tsrank.c,v 1.15 2009/06/11 14:49:04 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -72,9 +72,9 @@ cnt_length(TSVector t) } -#define WordECompareQueryItem(e,q,p,i,m) \ +#define WordECompareQueryItem(e,q,p,i,m) \ tsCompareString((q) + (i)->distance, (i)->length, \ - (e) + (p)->pos, (p)->len, (m)) + (e) + (p)->pos, (p)->len, (m)) /* @@ -90,7 +90,7 @@ find_wordentry(TSVector t, TSQuery q, QueryOperand *item, int32 *nitem) WordEntry *StopMiddle = StopHigh; int difference; - *nitem=0; + *nitem = 0; /* Loop invariant: StopLow <= item < StopHigh */ while (StopLow < StopHigh) @@ -100,7 +100,7 @@ find_wordentry(TSVector t, TSQuery q, QueryOperand *item, int32 *nitem) if (difference == 0) { StopHigh = StopMiddle; - *nitem=1; + *nitem = 1; break; } else if (difference > 0) @@ -109,22 +109,22 @@ find_wordentry(TSVector t, TSQuery q, QueryOperand *item, int32 *nitem) StopHigh = StopMiddle; } - if ( item->prefix == true ) + if (item->prefix == true) { - if ( StopLow >= StopHigh ) + if (StopLow >= StopHigh) StopMiddle = StopHigh; - *nitem=0; + *nitem = 0; - while( StopMiddle < (WordEntry *) STRPTR(t) && - WordECompareQueryItem(STRPTR(t), GETOPERAND(q), StopMiddle, item, true) == 0 ) + while (StopMiddle < (WordEntry *) STRPTR(t) && + WordECompareQueryItem(STRPTR(t), GETOPERAND(q), StopMiddle, item, true) == 0) { (*nitem)++; StopMiddle++; } } - return ( *nitem > 0 ) ? StopHigh : NULL; + return (*nitem > 0) ? StopHigh : NULL; } @@ -237,7 +237,7 @@ calc_rank_and(float *w, TSVector t, TSQuery q) if (!entry) continue; - while( entry - firstentry < nitem ) + while (entry - firstentry < nitem) { if (entry->haspos) pos[i] = _POSVECPTR(t, entry); @@ -260,7 +260,7 @@ calc_rank_and(float *w, TSVector t, TSQuery q) if (dist || (dist == 0 && (pos[i] == &POSNULL || pos[k] == &POSNULL))) { float curw; - + if (!dist) dist = MAXENTRYPOS; curw = sqrt(wpos(post[l]) * wpos(ct[p]) * word_distance(dist)); @@ -304,7 +304,7 @@ calc_rank_or(float *w, TSVector t, TSQuery q) if (!entry) continue; - while( entry - firstentry < nitem ) + while (entry - firstentry < nitem) { if (entry->haspos) { @@ -650,7 +650,7 @@ get_docrep(TSVector txt, QueryRepresentation *qr, int *doclen) if (!entry) continue; - while( entry - firstentry < nitem ) + while (entry - firstentry < nitem) { if (entry->haspos) { @@ -674,22 +674,22 @@ get_docrep(TSVector txt, QueryRepresentation *qr, int *doclen) if (j == 0) { int k; - + doc[cur].nitem = 0; doc[cur].item = (QueryItem **) palloc(sizeof(QueryItem *) * qr->query->size); - + for (k = 0; k < qr->query->size; k++) { QueryOperand *kptr = &item[k].operand; QueryOperand *iptr = &item[i].operand; - + if (k == i || (item[k].type == QI_VAL && compareQueryOperand(&kptr, &iptr, operand) == 0)) { /* - * if k == i, we've already checked above that it's - * type == Q_VAL + * if k == i, we've already checked above that + * it's type == Q_VAL */ doc[cur].item[doc[cur].nitem] = item + k; doc[cur].nitem++; diff --git a/src/backend/utils/adt/tsvector.c b/src/backend/utils/adt/tsvector.c index f449695725..397e6c780b 100644 --- a/src/backend/utils/adt/tsvector.c +++ b/src/backend/utils/adt/tsvector.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/tsvector.c,v 1.17 2009/05/21 20:09:36 teodor Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/tsvector.c,v 1.18 2009/06/11 14:49:04 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -85,9 +85,9 @@ compareentry(const void *va, const void *vb, void *arg) const WordEntryIN *b = (const WordEntryIN *) vb; char *BufferStr = (char *) arg; - return tsCompareString( &BufferStr[a->entry.pos], a->entry.len, - &BufferStr[b->entry.pos], b->entry.len, - false ); + return tsCompareString(&BufferStr[a->entry.pos], a->entry.len, + &BufferStr[b->entry.pos], b->entry.len, + false); } /* @@ -219,7 +219,7 @@ tsvectorin(PG_FUNCTION_ARGS) if (cur - tmpbuf > MAXSTRPOS) ereport(ERROR, (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), - errmsg("string is too long for tsvector (%ld bytes, max %ld bytes)", + errmsg("string is too long for tsvector (%ld bytes, max %ld bytes)", (long) (cur - tmpbuf), (long) MAXSTRPOS))); /* @@ -544,8 +544,8 @@ tsvectorrecv(PG_FUNCTION_ARGS) SET_VARSIZE(vec, hdrlen + datalen); if (needSort) - qsort_arg((void *) ARRPTR(vec), vec->size, sizeof(WordEntry), - compareentry, (void*)STRPTR(vec)); + qsort_arg((void *) ARRPTR(vec), vec->size, sizeof(WordEntry), + compareentry, (void *) STRPTR(vec)); PG_RETURN_TSVECTOR(vec); } diff --git a/src/backend/utils/adt/tsvector_op.c b/src/backend/utils/adt/tsvector_op.c index e7bce9a707..093f2a348a 100644 --- a/src/backend/utils/adt/tsvector_op.c +++ b/src/backend/utils/adt/tsvector_op.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/tsvector_op.c,v 1.22 2009/05/27 19:41:58 petere Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/tsvector_op.c,v 1.23 2009/06/11 14:49:04 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,8 +38,8 @@ typedef struct typedef struct StatEntry { - uint32 ndoc; /* zero indicates that we already was here while - walking throug the tree */ + uint32 ndoc; /* zero indicates that we already was here + * while walking throug the tree */ uint32 nentry; struct StatEntry *left; struct StatEntry *right; @@ -54,11 +54,11 @@ typedef struct int4 weight; uint32 maxdepth; - - StatEntry **stack; + + StatEntry **stack; uint32 stackpos; - StatEntry* root; + StatEntry *root; } TSVectorStat; #define STATHDRSIZE (offsetof(TSVectorStat, data)) @@ -127,7 +127,7 @@ silly_cmp_tsvector(const TSVector a, const TSVector b) { return (aptr->haspos > bptr->haspos) ? -1 : 1; } - else if ( (res=tsCompareString( STRPTR(a) + aptr->pos, aptr->len, STRPTR(b) + bptr->pos, bptr->len, false)) !=0 ) + else if ((res = tsCompareString(STRPTR(a) + aptr->pos, aptr->len, STRPTR(b) + bptr->pos, bptr->len, false)) != 0) { return res; } @@ -172,7 +172,7 @@ tsvector_##type(PG_FUNCTION_ARGS) \ PG_FREE_IF_COPY(a,0); \ PG_FREE_IF_COPY(b,1); \ PG_RETURN_##ret( res action 0 ); \ -} \ +} \ /* keep compiler quiet - no extra ; */ \ extern int no_such_variable @@ -524,40 +524,41 @@ tsvector_concat(PG_FUNCTION_ARGS) } /* - * Compare two strings by tsvector rules. + * Compare two strings by tsvector rules. * if isPrefix = true then it returns not-zero value if b has prefix a */ int4 tsCompareString(char *a, int lena, char *b, int lenb, bool prefix) { - int cmp; + int cmp; - if ( lena == 0 ) + if (lena == 0) { - if ( prefix ) - cmp = 0; /* emtry string is equal to any if a prefix match */ + if (prefix) + cmp = 0; /* emtry string is equal to any if a prefix + * match */ else - cmp = (lenb>0) ? -1 : 0; + cmp = (lenb > 0) ? -1 : 0; } - else if ( lenb == 0 ) + else if (lenb == 0) { - cmp = (lena>0) ? 1 : 0; + cmp = (lena > 0) ? 1 : 0; } else { cmp = memcmp(a, b, Min(lena, lenb)); - if ( prefix ) + if (prefix) { - if ( cmp == 0 && lena > lenb ) + if (cmp == 0 && lena > lenb) { /* * b argument is not beginning with argument a */ - cmp=1; + cmp = 1; } } - else if ( (cmp == 0) && (lena != lenb) ) + else if ((cmp == 0) && (lena != lenb)) { cmp = (lena < lenb) ? -1 : 1; } @@ -601,16 +602,16 @@ checkcondition_str(void *checkval, QueryOperand *val) WordEntry *StopLow = chkval->arrb; WordEntry *StopHigh = chkval->arre; WordEntry *StopMiddle = StopHigh; - int difference = -1; - bool res=false; + int difference = -1; + bool res = false; /* Loop invariant: StopLow <= val < StopHigh */ while (StopLow < StopHigh) { StopMiddle = StopLow + (StopHigh - StopLow) / 2; - difference = tsCompareString( chkval->operand + val->distance, val->length, - chkval->values + StopMiddle->pos, StopMiddle->len, - false); + difference = tsCompareString(chkval->operand + val->distance, val->length, + chkval->values + StopMiddle->pos, StopMiddle->len, + false); if (difference == 0) { @@ -624,19 +625,19 @@ checkcondition_str(void *checkval, QueryOperand *val) StopHigh = StopMiddle; } - if ( res == false && val->prefix == true ) + if (res == false && val->prefix == true) { /* * there was a failed exact search, so we should scan further to find * a prefix match. */ - if ( StopLow >= StopHigh ) + if (StopLow >= StopHigh) StopMiddle = StopHigh; - while( res == false && StopMiddle < chkval->arre && - tsCompareString( chkval->operand + val->distance, val->length, - chkval->values + StopMiddle->pos, StopMiddle->len, - true) == 0 ) + while (res == false && StopMiddle < chkval->arre && + tsCompareString(chkval->operand + val->distance, val->length, + chkval->values + StopMiddle->pos, StopMiddle->len, + true) == 0) { res = (val->weight && StopMiddle->haspos) ? checkclass_str(chkval, StopMiddle, val) : true; @@ -645,7 +646,7 @@ checkcondition_str(void *checkval, QueryOperand *val) } } - return res; + return res; } /* @@ -803,7 +804,7 @@ check_weight(TSVector txt, WordEntry *wptr, int8 weight) return num; } -#define compareStatWord(a,e,t) \ +#define compareStatWord(a,e,t) \ tsCompareString((a)->lexeme, (a)->lenlexeme, \ STRPTR(t) + (e)->pos, (e)->len, \ false) @@ -811,22 +812,22 @@ check_weight(TSVector txt, WordEntry *wptr, int8 weight) static void insertStatEntry(MemoryContext persistentContext, TSVectorStat *stat, TSVector txt, uint32 off) { - WordEntry *we = ARRPTR(txt) + off; - StatEntry *node = stat->root, - *pnode=NULL; + WordEntry *we = ARRPTR(txt) + off; + StatEntry *node = stat->root, + *pnode = NULL; int n, res = 0; - uint32 depth=1; + uint32 depth = 1; - if (stat->weight == 0) + if (stat->weight == 0) n = (we->haspos) ? POSDATALEN(txt, we) : 1; else n = (we->haspos) ? check_weight(txt, we, stat->weight) : 0; - if ( n == 0 ) - return; /* nothing to insert */ + if (n == 0) + return; /* nothing to insert */ - while( node ) + while (node) { res = compareStatWord(node, we, txt); @@ -837,7 +838,7 @@ insertStatEntry(MemoryContext persistentContext, TSVectorStat *stat, TSVector tx else { pnode = node; - node = ( res < 0 ) ? node->left : node->right; + node = (res < 0) ? node->left : node->right; } depth++; } @@ -847,14 +848,14 @@ insertStatEntry(MemoryContext persistentContext, TSVectorStat *stat, TSVector tx if (node == NULL) { - node = MemoryContextAlloc(persistentContext, STATENTRYHDRSZ + we->len ); + node = MemoryContextAlloc(persistentContext, STATENTRYHDRSZ + we->len); node->left = node->right = NULL; node->ndoc = 1; node->nentry = n; node->lenlexeme = we->len; memcpy(node->lexeme, STRPTR(txt) + we->pos, node->lenlexeme); - if ( pnode==NULL ) + if (pnode == NULL) { stat->root = node; } @@ -865,7 +866,7 @@ insertStatEntry(MemoryContext persistentContext, TSVectorStat *stat, TSVector tx else pnode->right = node; } - + } else { @@ -875,18 +876,18 @@ insertStatEntry(MemoryContext persistentContext, TSVectorStat *stat, TSVector tx } static void -chooseNextStatEntry(MemoryContext persistentContext, TSVectorStat *stat, TSVector txt, - uint32 low, uint32 high, uint32 offset) +chooseNextStatEntry(MemoryContext persistentContext, TSVectorStat *stat, TSVector txt, + uint32 low, uint32 high, uint32 offset) { - uint32 pos; - uint32 middle = (low + high) >> 1; + uint32 pos; + uint32 middle = (low + high) >> 1; pos = (low + middle) >> 1; if (low != middle && pos >= offset && pos - offset < txt->size) - insertStatEntry( persistentContext, stat, txt, pos - offset ); + insertStatEntry(persistentContext, stat, txt, pos - offset); pos = (high + middle + 1) >> 1; if (middle + 1 != high && pos >= offset && pos - offset < txt->size) - insertStatEntry( persistentContext, stat, txt, pos - offset ); + insertStatEntry(persistentContext, stat, txt, pos - offset); if (low != middle) chooseNextStatEntry(persistentContext, stat, txt, low, middle, offset); @@ -909,13 +910,13 @@ chooseNextStatEntry(MemoryContext persistentContext, TSVectorStat *stat, TSVecto static TSVectorStat * ts_accum(MemoryContext persistentContext, TSVectorStat *stat, Datum data) { - TSVector txt = DatumGetTSVector(data); - uint32 i, - nbit = 0, - offset; + TSVector txt = DatumGetTSVector(data); + uint32 i, + nbit = 0, + offset; if (stat == NULL) - { /* Init in first */ + { /* Init in first */ stat = MemoryContextAllocZero(persistentContext, sizeof(TSVectorStat)); stat->maxdepth = 1; } @@ -935,7 +936,7 @@ ts_accum(MemoryContext persistentContext, TSVectorStat *stat, Datum data) nbit = 1 << nbit; offset = (nbit - txt->size) / 2; - insertStatEntry( persistentContext, stat, txt, (nbit >> 1) - offset ); + insertStatEntry(persistentContext, stat, txt, (nbit >> 1) - offset); chooseNextStatEntry(persistentContext, stat, txt, 0, nbit, offset); return stat; @@ -945,22 +946,22 @@ static void ts_setup_firstcall(FunctionCallInfo fcinfo, FuncCallContext *funcctx, TSVectorStat *stat) { - TupleDesc tupdesc; - MemoryContext oldcontext; - StatEntry *node; + TupleDesc tupdesc; + MemoryContext oldcontext; + StatEntry *node; funcctx->user_fctx = (void *) stat; oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); stat->stack = palloc0(sizeof(StatEntry *) * (stat->maxdepth + 1)); - stat->stackpos = 0; + stat->stackpos = 0; node = stat->root; /* find leftmost value */ for (;;) { - stat->stack[ stat->stackpos ] = node; + stat->stack[stat->stackpos] = node; if (node->left) { stat->stackpos++; @@ -984,14 +985,14 @@ ts_setup_firstcall(FunctionCallInfo fcinfo, FuncCallContext *funcctx, } static StatEntry * -walkStatEntryTree(TSVectorStat *stat) +walkStatEntryTree(TSVectorStat *stat) { - StatEntry *node = stat->stack[ stat->stackpos ]; + StatEntry *node = stat->stack[stat->stackpos]; - if ( node == NULL ) + if (node == NULL) return NULL; - if ( node->ndoc != 0 ) + if (node->ndoc != 0) { /* return entry itself: we already was at left sublink */ return node; @@ -1031,8 +1032,8 @@ walkStatEntryTree(TSVectorStat *stat) static Datum ts_process_call(FuncCallContext *funcctx) { - TSVectorStat *st; - StatEntry *entry; + TSVectorStat *st; + StatEntry *entry; st = (TSVectorStat *) funcctx->user_fctx; @@ -1164,7 +1165,7 @@ ts_stat1(PG_FUNCTION_ARGS) if (SRF_IS_FIRSTCALL()) { - TSVectorStat *stat; + TSVectorStat *stat; text *txt = PG_GETARG_TEXT_P(0); funcctx = SRF_FIRSTCALL_INIT(); @@ -1189,7 +1190,7 @@ ts_stat2(PG_FUNCTION_ARGS) if (SRF_IS_FIRSTCALL()) { - TSVectorStat *stat; + TSVectorStat *stat; text *txt = PG_GETARG_TEXT_P(0); text *ws = PG_GETARG_TEXT_P(1); diff --git a/src/backend/utils/adt/uuid.c b/src/backend/utils/adt/uuid.c index cd11c22c5e..3c95bef6b5 100644 --- a/src/backend/utils/adt/uuid.c +++ b/src/backend/utils/adt/uuid.c @@ -6,7 +6,7 @@ * Copyright (c) 2007-2009, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/uuid.c,v 1.10 2009/01/01 17:23:50 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/uuid.c,v 1.11 2009/06/11 14:49:04 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -84,7 +84,7 @@ string_to_uuid(const char *source, pg_uuid_t *uuid) { const char *src = source; bool braces = false; - int i; + int i; if (src[0] == '{') { diff --git a/src/backend/utils/adt/varchar.c b/src/backend/utils/adt/varchar.c index 673dacbf45..c25385dee7 100644 --- a/src/backend/utils/adt/varchar.c +++ b/src/backend/utils/adt/varchar.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/varchar.c,v 1.130 2009/01/01 17:23:50 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/varchar.c,v 1.131 2009/06/11 14:49:04 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -595,7 +595,7 @@ varchar(PG_FUNCTION_ARGS) maxlen))); } - PG_RETURN_VARCHAR_P((VarChar *) cstring_to_text_with_len(s_data, + PG_RETURN_VARCHAR_P((VarChar *) cstring_to_text_with_len(s_data, maxmblen)); } diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c index 052d0578ac..b9b54e6db6 100644 --- a/src/backend/utils/adt/varlena.c +++ b/src/backend/utils/adt/varlena.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.170 2009/04/23 07:19:09 heikki Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.171 2009/06/11 14:49:04 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,7 +41,7 @@ typedef struct int len2; /* Skip table for Boyer-Moore-Horspool search algorithm: */ int skiptablemask; /* mask for ANDing with skiptable subscripts */ - int skiptable[256]; /* skip distance for given mismatched char */ + int skiptable[256]; /* skip distance for given mismatched char */ } TextPositionState; #define DatumGetUnknownP(X) ((unknown *) PG_DETOAST_DATUM(X)) @@ -121,7 +121,7 @@ text_to_cstring(const text *t) if (tunpacked != t) pfree(tunpacked); - + return result; } @@ -150,7 +150,7 @@ text_to_cstring_buffer(const text *src, char *dst, size_t dst_len) dst_len--; if (dst_len >= src_len) dst_len = src_len; - else /* ensure truncation is encoding-safe */ + else /* ensure truncation is encoding-safe */ dst_len = pg_mbcliplen(VARDATA_ANY(srcunpacked), src_len, dst_len); memcpy(dst, VARDATA_ANY(srcunpacked), dst_len); dst[dst_len] = '\0'; @@ -186,10 +186,10 @@ byteain(PG_FUNCTION_ARGS) char *inputText = PG_GETARG_CSTRING(0); char *tp; char *rp; - int byte; + int byte; bytea *result; - for (byte = 0, tp = inputText; *tp != '\0'; byte++) + for (byte = 0, tp = inputText; *tp != '\0'; byte ++) { if (tp[0] != '\\') tp++; @@ -212,7 +212,8 @@ byteain(PG_FUNCTION_ARGS) } } - byte += VARHDRSZ; + byte +=VARHDRSZ; + result = (bytea *) palloc(byte); SET_VARSIZE(result, byte); @@ -228,10 +229,11 @@ byteain(PG_FUNCTION_ARGS) (tp[3] >= '0' && tp[3] <= '7')) { byte = VAL(tp[1]); - byte <<= 3; - byte += VAL(tp[2]); - byte <<= 3; - *rp++ = byte + VAL(tp[3]); + byte <<=3; + byte +=VAL(tp[2]); + byte <<=3; + *rp++ = byte +VAL(tp[3]); + tp += 4; } else if ((tp[0] == '\\') && @@ -920,23 +922,23 @@ text_position_setup(text *t1, text *t2, TextPositionState *state) * searched (t1) and the "needle" is the pattern being sought (t2). * * If the needle is empty or bigger than the haystack then there is no - * point in wasting cycles initializing the table. We also choose not - * to use B-M-H for needles of length 1, since the skip table can't - * possibly save anything in that case. + * point in wasting cycles initializing the table. We also choose not to + * use B-M-H for needles of length 1, since the skip table can't possibly + * save anything in that case. */ if (len1 >= len2 && len2 > 1) { - int searchlength = len1 - len2; - int skiptablemask; - int last; - int i; + int searchlength = len1 - len2; + int skiptablemask; + int last; + int i; /* * First we must determine how much of the skip table to use. The * declaration of TextPositionState allows up to 256 elements, but for * short search problems we don't really want to have to initialize so * many elements --- it would take too long in comparison to the - * actual search time. So we choose a useful skip table size based on + * actual search time. So we choose a useful skip table size based on * the haystack length minus the needle length. The closer the needle * length is to the haystack length the less useful skipping becomes. * @@ -968,10 +970,11 @@ text_position_setup(text *t1, text *t2, TextPositionState *state) state->skiptable[i] = len2; /* - * Now examine the needle. For each character except the last one, + * Now examine the needle. For each character except the last one, * set the corresponding table element to the appropriate skip * distance. Note that when two characters share the same skip table - * entry, the one later in the needle must determine the skip distance. + * entry, the one later in the needle must determine the skip + * distance. */ last = len2 - 1; @@ -1021,7 +1024,7 @@ text_position_next(int start_pos, TextPositionState *state) if (needle_len == 1) { /* No point in using B-M-H for a one-character needle */ - char nchar = *needle; + char nchar = *needle; hptr = &haystack[start_pos]; while (hptr < haystack_end) @@ -1047,18 +1050,19 @@ text_position_next(int start_pos, TextPositionState *state) p = hptr; while (*nptr == *p) { - /* Matched it all? If so, return 1-based position */ + /* Matched it all? If so, return 1-based position */ if (nptr == needle) return p - haystack + 1; nptr--, p--; } + /* * No match, so use the haystack char at hptr to decide how - * far to advance. If the needle had any occurrence of that + * far to advance. If the needle had any occurrence of that * character (or more precisely, one sharing the same * skiptable entry) before its last character, then we advance * far enough to align the last such needle character with - * that haystack position. Otherwise we can advance by the + * that haystack position. Otherwise we can advance by the * whole needle length. */ hptr += state->skiptable[(unsigned char) *hptr & skiptablemask]; @@ -1102,18 +1106,19 @@ text_position_next(int start_pos, TextPositionState *state) p = hptr; while (*nptr == *p) { - /* Matched it all? If so, return 1-based position */ + /* Matched it all? If so, return 1-based position */ if (nptr == needle) return p - haystack + 1; nptr--, p--; } + /* * No match, so use the haystack char at hptr to decide how - * far to advance. If the needle had any occurrence of that + * far to advance. If the needle had any occurrence of that * character (or more precisely, one sharing the same * skiptable entry) before its last character, then we advance * far enough to align the last such needle character with - * that haystack position. Otherwise we can advance by the + * that haystack position. Otherwise we can advance by the * whole needle length. */ hptr += state->skiptable[*hptr & skiptablemask]; @@ -1764,7 +1769,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); @@ -1795,7 +1800,7 @@ byteaGetBit(PG_FUNCTION_ARGS) int byteNo, bitNo; int len; - int byte; + int byte; len = VARSIZE_ANY_EXHDR(v); @@ -1810,7 +1815,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); diff --git a/src/backend/utils/adt/windowfuncs.c b/src/backend/utils/adt/windowfuncs.c index a7d890577c..28a7847506 100644 --- a/src/backend/utils/adt/windowfuncs.c +++ b/src/backend/utils/adt/windowfuncs.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/windowfuncs.c,v 1.2 2009/01/01 17:23:50 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/windowfuncs.c,v 1.3 2009/06/11 14:49:04 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,7 +21,7 @@ */ typedef struct rank_context { - int64 rank; /* current rank */ + int64 rank; /* current rank */ } rank_context; /* @@ -29,15 +29,15 @@ typedef struct rank_context */ typedef struct { - int32 ntile; /* current result */ + int32 ntile; /* current result */ int64 rows_per_bucket; /* row number of current bucket */ - int64 boundary; /* how many rows should be in the bucket */ - int64 remainder; /* (total rows) % (bucket num) */ + int64 boundary; /* how many rows should be in the bucket */ + int64 remainder; /* (total rows) % (bucket num) */ } ntile_context; static bool rank_up(WindowObject winobj); static Datum leadlag_common(FunctionCallInfo fcinfo, - bool forward, bool withoffset, bool withdefault); + bool forward, bool withoffset, bool withdefault); /* @@ -81,7 +81,7 @@ rank_up(WindowObject winobj) Datum window_row_number(PG_FUNCTION_ARGS) { - WindowObject winobj = PG_WINDOW_OBJECT(); + WindowObject winobj = PG_WINDOW_OBJECT(); int64 curpos = WinGetCurrentPosition(winobj); WinSetMarkPosition(winobj, curpos); @@ -97,9 +97,9 @@ window_row_number(PG_FUNCTION_ARGS) Datum window_rank(PG_FUNCTION_ARGS) { - WindowObject winobj = PG_WINDOW_OBJECT(); - rank_context *context; - bool up; + WindowObject winobj = PG_WINDOW_OBJECT(); + rank_context *context; + bool up; up = rank_up(winobj); context = (rank_context *) @@ -117,9 +117,9 @@ window_rank(PG_FUNCTION_ARGS) Datum window_dense_rank(PG_FUNCTION_ARGS) { - WindowObject winobj = PG_WINDOW_OBJECT(); - rank_context *context; - bool up; + WindowObject winobj = PG_WINDOW_OBJECT(); + rank_context *context; + bool up; up = rank_up(winobj); context = (rank_context *) @@ -139,10 +139,10 @@ window_dense_rank(PG_FUNCTION_ARGS) Datum window_percent_rank(PG_FUNCTION_ARGS) { - WindowObject winobj = PG_WINDOW_OBJECT(); - rank_context *context; - bool up; - int64 totalrows = WinGetPartitionRowCount(winobj); + WindowObject winobj = PG_WINDOW_OBJECT(); + rank_context *context; + bool up; + int64 totalrows = WinGetPartitionRowCount(winobj); Assert(totalrows > 0); @@ -168,10 +168,10 @@ window_percent_rank(PG_FUNCTION_ARGS) Datum window_cume_dist(PG_FUNCTION_ARGS) { - WindowObject winobj = PG_WINDOW_OBJECT(); - rank_context *context; - bool up; - int64 totalrows = WinGetPartitionRowCount(winobj); + WindowObject winobj = PG_WINDOW_OBJECT(); + rank_context *context; + bool up; + int64 totalrows = WinGetPartitionRowCount(winobj); Assert(totalrows > 0); @@ -181,10 +181,10 @@ window_cume_dist(PG_FUNCTION_ARGS) if (up || context->rank == 1) { /* - * The current row is not peer to prior row or is just the first, - * so count up the number of rows that are peer to the current. + * The current row is not peer to prior row or is just the first, so + * count up the number of rows that are peer to the current. */ - int64 row; + int64 row; context->rank = WinGetCurrentPosition(winobj) + 1; @@ -210,8 +210,8 @@ window_cume_dist(PG_FUNCTION_ARGS) Datum window_ntile(PG_FUNCTION_ARGS) { - WindowObject winobj = PG_WINDOW_OBJECT(); - ntile_context *context; + WindowObject winobj = PG_WINDOW_OBJECT(); + ntile_context *context; context = (ntile_context *) WinGetPartitionLocalMemory(winobj, sizeof(ntile_context)); @@ -227,16 +227,15 @@ window_ntile(PG_FUNCTION_ARGS) nbuckets = DatumGetInt32(WinGetFuncArgCurrent(winobj, 0, &isnull)); /* - * per spec: - * If NT is the null value, then the result is the null value. + * per spec: If NT is the null value, then the result is the null + * value. */ if (isnull) PG_RETURN_NULL(); /* - * per spec: - * If NT is less than or equal to 0 (zero), then an exception - * condition is raised. + * per spec: If NT is less than or equal to 0 (zero), then an + * exception condition is raised. */ if (nbuckets <= 0) ereport(ERROR, @@ -251,8 +250,8 @@ window_ntile(PG_FUNCTION_ARGS) else { /* - * If the total number is not divisible, add 1 row to - * leading buckets. + * If the total number is not divisible, add 1 row to leading + * buckets. */ context->remainder = total % nbuckets; if (context->remainder != 0) @@ -287,12 +286,12 @@ static Datum leadlag_common(FunctionCallInfo fcinfo, bool forward, bool withoffset, bool withdefault) { - WindowObject winobj = PG_WINDOW_OBJECT(); - int32 offset; - bool const_offset; - Datum result; - bool isnull; - bool isout; + WindowObject winobj = PG_WINDOW_OBJECT(); + int32 offset; + bool const_offset; + Datum result; + bool isnull; + bool isout; if (withoffset) { @@ -407,9 +406,9 @@ window_lead_with_offset_and_default(PG_FUNCTION_ARGS) Datum window_first_value(PG_FUNCTION_ARGS) { - WindowObject winobj = PG_WINDOW_OBJECT(); - Datum result; - bool isnull; + WindowObject winobj = PG_WINDOW_OBJECT(); + Datum result; + bool isnull; result = WinGetFuncArgInFrame(winobj, 0, 0, WINDOW_SEEK_HEAD, true, @@ -428,9 +427,9 @@ window_first_value(PG_FUNCTION_ARGS) Datum window_last_value(PG_FUNCTION_ARGS) { - WindowObject winobj = PG_WINDOW_OBJECT(); - Datum result; - bool isnull; + WindowObject winobj = PG_WINDOW_OBJECT(); + Datum result; + bool isnull; result = WinGetFuncArgInFrame(winobj, 0, 0, WINDOW_SEEK_TAIL, true, @@ -449,11 +448,11 @@ window_last_value(PG_FUNCTION_ARGS) Datum window_nth_value(PG_FUNCTION_ARGS) { - WindowObject winobj = PG_WINDOW_OBJECT(); - bool const_offset; - Datum result; - bool isnull; - int32 nth; + WindowObject winobj = PG_WINDOW_OBJECT(); + bool const_offset; + Datum result; + bool isnull; + int32 nth; nth = DatumGetInt32(WinGetFuncArgCurrent(winobj, 1, &isnull)); if (isnull) diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c index 18f209489e..b92d41b93c 100644 --- a/src/backend/utils/adt/xml.c +++ b/src/backend/utils/adt/xml.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.91 2009/06/10 03:44:35 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.92 2009/06/11 14:49:04 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -79,8 +79,8 @@ /* GUC variables */ -int xmlbinary; -int xmloption; +int xmlbinary; +int xmloption; #ifdef USE_LIBXML @@ -100,17 +100,16 @@ static void *xml_palloc(size_t size); static void *xml_repalloc(void *ptr, size_t size); static void xml_pfree(void *ptr); static char *xml_pstrdup(const char *string); - -#endif /* USE_LIBXMLCONTEXT */ +#endif /* USE_LIBXMLCONTEXT */ static void xml_init(void); static xmlChar *xml_text2xmlChar(text *in); -static int parse_xml_decl(const xmlChar * str, size_t *lenp, - xmlChar ** version, xmlChar ** encoding, int *standalone); -static bool print_xml_decl(StringInfo buf, const xmlChar * version, +static int parse_xml_decl(const xmlChar *str, size_t *lenp, + xmlChar **version, xmlChar **encoding, int *standalone); +static bool print_xml_decl(StringInfo buf, const xmlChar *version, pg_enc encoding, int standalone); static xmlDocPtr xml_parse(text *data, XmlOptionType xmloption_arg, - bool preserve_whitespace, xmlChar * encoding); + bool preserve_whitespace, xmlChar *encoding); static text *xml_xmlnodetoxmltype(xmlNodePtr cur); #endif /* USE_LIBXML */ @@ -587,7 +586,7 @@ xmlelement(XmlExprState *xmlExpr, ExprContext *econtext) if (!isnull) { str = map_sql_value_to_xml_value(value, - exprType((Node *) e->expr), true); + exprType((Node *) e->expr), true); arg_strings = lappend(arg_strings, str); } } @@ -597,42 +596,42 @@ xmlelement(XmlExprState *xmlExpr, ExprContext *econtext) PG_TRY(); { - buf = xmlBufferCreate(); - if (!buf) - xml_ereport(ERROR, ERRCODE_OUT_OF_MEMORY, - "could not allocate xmlBuffer"); - writer = xmlNewTextWriterMemory(buf, 0); - if (!writer) - xml_ereport(ERROR, ERRCODE_OUT_OF_MEMORY, - "could not allocate xmlTextWriter"); + buf = xmlBufferCreate(); + if (!buf) + xml_ereport(ERROR, ERRCODE_OUT_OF_MEMORY, + "could not allocate xmlBuffer"); + writer = xmlNewTextWriterMemory(buf, 0); + if (!writer) + xml_ereport(ERROR, ERRCODE_OUT_OF_MEMORY, + "could not allocate xmlTextWriter"); - xmlTextWriterStartElement(writer, (xmlChar *) xexpr->name); + xmlTextWriterStartElement(writer, (xmlChar *) xexpr->name); - forboth(arg, named_arg_strings, narg, xexpr->arg_names) - { - char *str = (char *) lfirst(arg); - char *argname = strVal(lfirst(narg)); + forboth(arg, named_arg_strings, narg, xexpr->arg_names) + { + char *str = (char *) lfirst(arg); + char *argname = strVal(lfirst(narg)); - if (str) - xmlTextWriterWriteAttribute(writer, - (xmlChar *) argname, - (xmlChar *) str); - } + if (str) + xmlTextWriterWriteAttribute(writer, + (xmlChar *) argname, + (xmlChar *) str); + } - foreach(arg, arg_strings) - { - char *str = (char *) lfirst(arg); + foreach(arg, arg_strings) + { + char *str = (char *) lfirst(arg); - xmlTextWriterWriteRaw(writer, (xmlChar *) str); - } + xmlTextWriterWriteRaw(writer, (xmlChar *) str); + } - xmlTextWriterEndElement(writer); + xmlTextWriterEndElement(writer); - /* we MUST do this now to flush data out to the buffer ... */ - xmlFreeTextWriter(writer); - writer = NULL; + /* we MUST do this now to flush data out to the buffer ... */ + xmlFreeTextWriter(writer); + writer = NULL; - result = xmlBuffer_to_xmltype(buf); + result = xmlBuffer_to_xmltype(buf); } PG_CATCH(); { @@ -888,7 +887,7 @@ xml_init(void) resetStringInfo(xml_err_buf); /* - * We re-establish the error callback function every time. This makes + * We re-establish the error callback function every time. This makes * it safe for other subsystems (PL/Perl, say) to also use libxml with * their own callbacks ... so long as they likewise set up the * callbacks on every use. It's cheap enough to not be worth worrying @@ -930,7 +929,7 @@ xml_init(void) static xmlChar * xml_pnstrdup(const xmlChar *str, size_t len) { - xmlChar *result; + xmlChar *result; result = (xmlChar *) palloc((len + 1) * sizeof(xmlChar)); memcpy(result, str, len * sizeof(xmlChar)); @@ -945,8 +944,8 @@ xml_pnstrdup(const xmlChar *str, size_t len) * Result is 0 if OK, an error code if not. */ static int -parse_xml_decl(const xmlChar * str, size_t *lenp, - xmlChar ** version, xmlChar ** encoding, int *standalone) +parse_xml_decl(const xmlChar *str, size_t *lenp, + xmlChar **version, xmlChar **encoding, int *standalone) { const xmlChar *p; const xmlChar *save_p; @@ -1103,7 +1102,7 @@ finished: * which is the default version specified in SQL:2003. */ static bool -print_xml_decl(StringInfo buf, const xmlChar * version, +print_xml_decl(StringInfo buf, const xmlChar *version, pg_enc encoding, int standalone) { xml_init(); /* why is this here? */ @@ -1153,7 +1152,7 @@ print_xml_decl(StringInfo buf, const xmlChar * version, */ static xmlDocPtr xml_parse(text *data, XmlOptionType xmloption_arg, bool preserve_whitespace, - xmlChar * encoding) + xmlChar *encoding) { int32 len; xmlChar *string; @@ -1183,51 +1182,51 @@ xml_parse(text *data, XmlOptionType xmloption_arg, bool preserve_whitespace, /* Use a TRY block to ensure the ctxt is released */ PG_TRY(); { - if (xmloption_arg == XMLOPTION_DOCUMENT) - { - /* - * Note, that here we try to apply DTD defaults - * (XML_PARSE_DTDATTR) according to SQL/XML: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:10.16.7.e) - */ - doc = xmlCtxtReadDoc(ctxt, utf8string, - NULL, - "UTF-8", - XML_PARSE_NOENT | XML_PARSE_DTDATTR - | (preserve_whitespace ? 0 : XML_PARSE_NOBLANKS)); - if (doc == NULL) - xml_ereport(ERROR, ERRCODE_INVALID_XML_DOCUMENT, - "invalid XML document"); - } - else - { - int res_code; - size_t count; - xmlChar *version = NULL; - int standalone = -1; - - res_code = parse_xml_decl(utf8string, - &count, &version, NULL, &standalone); - if (res_code != 0) - xml_ereport_by_code(ERROR, ERRCODE_INVALID_XML_CONTENT, - "invalid XML content: invalid XML declaration", - res_code); - - doc = xmlNewDoc(version); - Assert(doc->encoding == NULL); - doc->encoding = xmlStrdup((const xmlChar *) "UTF-8"); - doc->standalone = standalone; - - res_code = xmlParseBalancedChunkMemory(doc, NULL, NULL, 0, - utf8string + count, NULL); - if (res_code != 0) + if (xmloption_arg == XMLOPTION_DOCUMENT) { - xmlFreeDoc(doc); - xml_ereport(ERROR, ERRCODE_INVALID_XML_CONTENT, - "invalid XML content"); + /* + * Note, that here we try to apply DTD defaults + * (XML_PARSE_DTDATTR) according to SQL/XML: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:10.16.7.e) + */ + doc = xmlCtxtReadDoc(ctxt, utf8string, + NULL, + "UTF-8", + XML_PARSE_NOENT | XML_PARSE_DTDATTR + | (preserve_whitespace ? 0 : XML_PARSE_NOBLANKS)); + if (doc == NULL) + xml_ereport(ERROR, ERRCODE_INVALID_XML_DOCUMENT, + "invalid XML document"); + } + else + { + int res_code; + size_t count; + xmlChar *version = NULL; + int standalone = -1; + + res_code = parse_xml_decl(utf8string, + &count, &version, NULL, &standalone); + if (res_code != 0) + xml_ereport_by_code(ERROR, ERRCODE_INVALID_XML_CONTENT, + "invalid XML content: invalid XML declaration", + res_code); + + doc = xmlNewDoc(version); + Assert(doc->encoding == NULL); + doc->encoding = xmlStrdup((const xmlChar *) "UTF-8"); + doc->standalone = standalone; + + res_code = xmlParseBalancedChunkMemory(doc, NULL, NULL, 0, + utf8string + count, NULL); + if (res_code != 0) + { + xmlFreeDoc(doc); + xml_ereport(ERROR, ERRCODE_INVALID_XML_CONTENT, + "invalid XML content"); + } } - } } PG_CATCH(); { @@ -1304,8 +1303,7 @@ xml_pstrdup(const char *string) { return MemoryContextStrdup(LibxmlContext, string); } - -#endif /* USE_LIBXMLCONTEXT */ +#endif /* USE_LIBXMLCONTEXT */ /* @@ -1529,7 +1527,7 @@ map_sql_identifier_to_xml_name(char *ident, bool fully_escaped, static char * unicode_to_sqlchar(pg_wchar c) { - unsigned char utf8string[5]; /* need room for trailing zero */ + unsigned char utf8string[5]; /* need room for trailing zero */ char *result; memset(utf8string, 0, sizeof(utf8string)); @@ -1537,7 +1535,7 @@ unicode_to_sqlchar(pg_wchar c) result = (char *) pg_do_encoding_conversion(utf8string, pg_encoding_mblen(PG_UTF8, - (char *) utf8string), + (char *) utf8string), PG_UTF8, GetDatabaseEncoding()); /* if pg_do_encoding_conversion didn't strdup, we must */ @@ -1585,8 +1583,8 @@ map_xml_name_to_sql_identifier(char *name) * * When xml_escape_strings is true, then certain characters in string * values are replaced by entity references (< etc.), as specified - * in SQL/XML:2003 section 9.16 GR 8) ii). This is normally what is - * wanted. The false case is mainly useful when the resulting value + * in SQL/XML:2003 section 9.16 GR 8) ii). This is normally what is + * wanted. The false case is mainly useful when the resulting value * is used with xmlTextWriterWriteAttribute() to write out an * attribute, because that function does the escaping itself. The SQL * standard of 2003 is somewhat buggy in this regard, so we do our @@ -1750,10 +1748,10 @@ map_sql_value_to_xml_value(Datum value, Oid type, bool xml_escape_strings) if (xmlbinary == XMLBINARY_BASE64) xmlTextWriterWriteBase64(writer, VARDATA_ANY(bstr), - 0, VARSIZE_ANY_EXHDR(bstr)); + 0, VARSIZE_ANY_EXHDR(bstr)); else xmlTextWriterWriteBinHex(writer, VARDATA_ANY(bstr), - 0, VARSIZE_ANY_EXHDR(bstr)); + 0, VARSIZE_ANY_EXHDR(bstr)); /* we MUST do this now to flush data out to the buffer */ xmlFreeTextWriter(writer); @@ -3194,7 +3192,7 @@ SPI_sql_row_to_xmlelement(int rownum, StringInfo result, char *tablename, appendStringInfo(result, " <%s>%s</%s>\n", colname, map_sql_value_to_xml_value(colval, - SPI_gettypeid(SPI_tuptable->tupdesc, i), true), + SPI_gettypeid(SPI_tuptable->tupdesc, i), true), colname); } @@ -3349,7 +3347,7 @@ xpath(PG_FUNCTION_ARGS) memcpy(string, datastr, len); string[len] = '\0'; - xpath_expr = (xmlChar *) palloc((xpath_len +1) * sizeof(xmlChar)); + xpath_expr = (xmlChar *) palloc((xpath_len + 1) * sizeof(xmlChar)); memcpy(xpath_expr, VARDATA(xpath_expr_text), xpath_len); xpath_expr[xpath_len] = '\0'; @@ -3358,81 +3356,81 @@ xpath(PG_FUNCTION_ARGS) PG_TRY(); { - /* - * redundant XML parsing (two parsings for the same value during one - * command execution are possible) - */ - ctxt = xmlNewParserCtxt(); - if (ctxt == NULL) - xml_ereport(ERROR, ERRCODE_OUT_OF_MEMORY, - "could not allocate parser context"); - doc = xmlCtxtReadMemory(ctxt, (char *) string, len, NULL, NULL, 0); - if (doc == NULL) - xml_ereport(ERROR, ERRCODE_INVALID_XML_DOCUMENT, - "could not parse XML document"); - xpathctx = xmlXPathNewContext(doc); - if (xpathctx == NULL) - xml_ereport(ERROR, ERRCODE_OUT_OF_MEMORY, - "could not allocate XPath context"); - xpathctx->node = xmlDocGetRootElement(doc); - if (xpathctx->node == NULL) - xml_ereport(ERROR, ERRCODE_INTERNAL_ERROR, - "could not find root XML element"); - - /* register namespaces, if any */ - if (ns_count > 0) - { - for (i = 0; i < ns_count; i++) + /* + * redundant XML parsing (two parsings for the same value during one + * command execution are possible) + */ + ctxt = xmlNewParserCtxt(); + if (ctxt == NULL) + xml_ereport(ERROR, ERRCODE_OUT_OF_MEMORY, + "could not allocate parser context"); + doc = xmlCtxtReadMemory(ctxt, (char *) string, len, NULL, NULL, 0); + if (doc == NULL) + xml_ereport(ERROR, ERRCODE_INVALID_XML_DOCUMENT, + "could not parse XML document"); + xpathctx = xmlXPathNewContext(doc); + if (xpathctx == NULL) + xml_ereport(ERROR, ERRCODE_OUT_OF_MEMORY, + "could not allocate XPath context"); + xpathctx->node = xmlDocGetRootElement(doc); + if (xpathctx->node == NULL) + xml_ereport(ERROR, ERRCODE_INTERNAL_ERROR, + "could not find root XML element"); + + /* register namespaces, if any */ + if (ns_count > 0) { - char *ns_name; - char *ns_uri; - - if (ns_names_uris_nulls[i * 2] || - ns_names_uris_nulls[i * 2 + 1]) - ereport(ERROR, - (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), - errmsg("neither namespace name nor URI may be null"))); - ns_name = TextDatumGetCString(ns_names_uris[i * 2]); - ns_uri = TextDatumGetCString(ns_names_uris[i * 2 + 1]); - if (xmlXPathRegisterNs(xpathctx, - (xmlChar *) ns_name, - (xmlChar *) ns_uri) != 0) - ereport(ERROR, /* is this an internal error??? */ - (errmsg("could not register XML namespace with name \"%s\" and URI \"%s\"", - ns_name, ns_uri))); + for (i = 0; i < ns_count; i++) + { + char *ns_name; + char *ns_uri; + + if (ns_names_uris_nulls[i * 2] || + ns_names_uris_nulls[i * 2 + 1]) + ereport(ERROR, + (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), + errmsg("neither namespace name nor URI may be null"))); + ns_name = TextDatumGetCString(ns_names_uris[i * 2]); + ns_uri = TextDatumGetCString(ns_names_uris[i * 2 + 1]); + if (xmlXPathRegisterNs(xpathctx, + (xmlChar *) ns_name, + (xmlChar *) ns_uri) != 0) + ereport(ERROR, /* is this an internal error??? */ + (errmsg("could not register XML namespace with name \"%s\" and URI \"%s\"", + ns_name, ns_uri))); + } } - } - xpathcomp = xmlXPathCompile(xpath_expr); - if (xpathcomp == NULL) /* TODO: show proper XPath error details */ - xml_ereport(ERROR, ERRCODE_INTERNAL_ERROR, - "invalid XPath expression"); + xpathcomp = xmlXPathCompile(xpath_expr); + if (xpathcomp == NULL) /* TODO: show proper XPath error details */ + xml_ereport(ERROR, ERRCODE_INTERNAL_ERROR, + "invalid XPath expression"); - xpathobj = xmlXPathCompiledEval(xpathcomp, xpathctx); - if (xpathobj == NULL) /* TODO: reason? */ - xml_ereport(ERROR, ERRCODE_INTERNAL_ERROR, - "could not create XPath object"); + xpathobj = xmlXPathCompiledEval(xpathcomp, xpathctx); + if (xpathobj == NULL) /* TODO: reason? */ + xml_ereport(ERROR, ERRCODE_INTERNAL_ERROR, + "could not create XPath object"); - /* return empty array in cases when nothing is found */ - if (xpathobj->nodesetval == NULL) - res_nitems = 0; - else - res_nitems = xpathobj->nodesetval->nodeNr; + /* return empty array in cases when nothing is found */ + if (xpathobj->nodesetval == NULL) + res_nitems = 0; + else + res_nitems = xpathobj->nodesetval->nodeNr; - if (res_nitems) - { - for (i = 0; i < xpathobj->nodesetval->nodeNr; i++) + if (res_nitems) { - Datum elem; - bool elemisnull = false; + for (i = 0; i < xpathobj->nodesetval->nodeNr; i++) + { + Datum elem; + bool elemisnull = false; - elem = PointerGetDatum(xml_xmlnodetoxmltype(xpathobj->nodesetval->nodeTab[i])); - astate = accumArrayResult(astate, elem, - elemisnull, XMLOID, - CurrentMemoryContext); + elem = PointerGetDatum(xml_xmlnodetoxmltype(xpathobj->nodesetval->nodeTab[i])); + astate = accumArrayResult(astate, elem, + elemisnull, XMLOID, + CurrentMemoryContext); + } } } - } PG_CATCH(); { if (xpathobj) diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c index a29c5c91aa..6fd672435f 100644 --- a/src/backend/utils/cache/catcache.c +++ b/src/backend/utils/cache/catcache.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/cache/catcache.c,v 1.146 2009/01/01 17:23:50 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/catcache.c,v 1.147 2009/06/11 14:49:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -104,30 +104,37 @@ GetCCHashEqFuncs(Oid keytype, PGFunction *hashfunc, RegProcedure *eqfunc) { case BOOLOID: *hashfunc = hashchar; + *eqfunc = F_BOOLEQ; break; case CHAROID: *hashfunc = hashchar; + *eqfunc = F_CHAREQ; break; case NAMEOID: *hashfunc = hashname; + *eqfunc = F_NAMEEQ; break; case INT2OID: *hashfunc = hashint2; + *eqfunc = F_INT2EQ; break; case INT2VECTOROID: *hashfunc = hashint2vector; + *eqfunc = F_INT2VECTOREQ; break; case INT4OID: *hashfunc = hashint4; + *eqfunc = F_INT4EQ; break; case TEXTOID: *hashfunc = hashtext; + *eqfunc = F_TEXTEQ; break; case OIDOID: @@ -140,15 +147,18 @@ GetCCHashEqFuncs(Oid keytype, PGFunction *hashfunc, RegProcedure *eqfunc) case REGCONFIGOID: case REGDICTIONARYOID: *hashfunc = hashoid; + *eqfunc = F_OIDEQ; break; case OIDVECTOROID: *hashfunc = hashoidvector; + *eqfunc = F_OIDVECTOREQ; break; default: elog(FATAL, "type %u not supported as catcache key", keytype); *hashfunc = NULL; /* keep compiler quiet */ + *eqfunc = InvalidOid; break; } diff --git a/src/backend/utils/cache/inval.c b/src/backend/utils/cache/inval.c index 398eb39dc5..5fac924207 100644 --- a/src/backend/utils/cache/inval.c +++ b/src/backend/utils/cache/inval.c @@ -80,7 +80,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/cache/inval.c,v 1.88 2009/01/01 17:23:50 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/inval.c,v 1.89 2009/06/11 14:49:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -403,7 +403,7 @@ ProcessInvalidationMessages(InvalidationListHeader *hdr, */ static void ProcessInvalidationMessagesMulti(InvalidationListHeader *hdr, - void (*func) (const SharedInvalidationMessage *msgs, int n)) + void (*func) (const SharedInvalidationMessage *msgs, int n)) { ProcessMessageListMulti(hdr->cclist, func(msgs, n)); ProcessMessageListMulti(hdr->rclist, func(msgs, n)); @@ -442,9 +442,9 @@ RegisterRelcacheInvalidation(Oid dbId, Oid relId) /* * Most of the time, relcache invalidation is associated with system - * catalog updates, but there are a few cases where it isn't. Quick - * hack to ensure that the next CommandCounterIncrement() will think - * that we need to do CommandEndInvalidationMessages(). + * catalog updates, but there are a few cases where it isn't. Quick hack + * to ensure that the next CommandCounterIncrement() will think that we + * need to do CommandEndInvalidationMessages(). */ (void) GetCurrentCommandId(true); @@ -1015,7 +1015,7 @@ CommandEndInvalidationMessages(void) * Prepare for invalidation messages for nontransactional updates. * * A nontransactional invalidation is one that must be sent whether or not - * the current transaction eventually commits. We arrange for all invals + * the current transaction eventually commits. We arrange for all invals * queued between this call and EndNonTransactionalInvalidation() to be sent * immediately when the latter is called. * @@ -1069,10 +1069,10 @@ EndNonTransactionalInvalidation(void) Assert(transInvalInfo->PriorCmdInvalidMsgs.rclist == NULL); /* - * At present, this function is only used for CTID-changing updates; - * since the relcache init file doesn't store any tuple CTIDs, we - * don't have to invalidate it. That might not be true forever - * though, in which case we'd need code similar to AtEOXact_Inval. + * At present, this function is only used for CTID-changing updates; since + * the relcache init file doesn't store any tuple CTIDs, we don't have to + * invalidate it. That might not be true forever though, in which case + * we'd need code similar to AtEOXact_Inval. */ /* Send out the invals */ diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c index b3ec6ad341..8247516bd1 100644 --- a/src/backend/utils/cache/lsyscache.c +++ b/src/backend/utils/cache/lsyscache.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.161 2009/01/01 17:23:50 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.162 2009/06/11 14:49:05 momjian Exp $ * * NOTES * Eventually, the index information should go through here, too. @@ -239,6 +239,7 @@ get_compare_function_for_ordering_op(Oid opno, Oid *cmpfunc, bool *reverse) opcintype, opcintype, BTORDER_PROC); + if (!OidIsValid(*cmpfunc)) /* should not happen */ elog(ERROR, "missing support function %d(%u,%u) in opfamily %u", BTORDER_PROC, opcintype, opcintype, opfamily); @@ -248,6 +249,7 @@ get_compare_function_for_ordering_op(Oid opno, Oid *cmpfunc, bool *reverse) /* ensure outputs are set on failure */ *cmpfunc = InvalidOid; + *reverse = false; return false; } diff --git a/src/backend/utils/cache/plancache.c b/src/backend/utils/cache/plancache.c index 6c0f90f1ad..437b7d1114 100644 --- a/src/backend/utils/cache/plancache.c +++ b/src/backend/utils/cache/plancache.c @@ -12,7 +12,7 @@ * * The plan cache manager itself is principally responsible for tracking * whether cached plans should be invalidated because of schema changes in - * the objects they depend on. When (and if) the next demand for a cached + * the objects they depend on. When (and if) the next demand for a cached * plan occurs, the query will be replanned. Note that this could result * in an error, for example if a column referenced by the query is no * longer present. The creator of a cached plan can specify whether it @@ -21,7 +21,7 @@ * caller to notice changes and cope with them. * * Currently, we track exactly the dependencies of plans on relations and - * user-defined functions. On relcache invalidation events or pg_proc + * user-defined functions. On relcache invalidation events or pg_proc * syscache invalidation events, we invalidate just those plans that depend * on the particular object being modified. (Note: this scheme assumes * that any table modification that requires replanning will generate a @@ -35,7 +35,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/cache/plancache.c,v 1.26 2009/01/01 17:23:50 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/plancache.c,v 1.27 2009/06/11 14:49:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -120,7 +120,7 @@ CreateCachedPlan(Node *raw_parse_tree, MemoryContext source_context; MemoryContext oldcxt; - Assert(query_string != NULL); /* required as of 8.4 */ + Assert(query_string != NULL); /* required as of 8.4 */ /* * Make a dedicated memory context for the CachedPlanSource and its @@ -220,7 +220,7 @@ FastCreateCachedPlan(Node *raw_parse_tree, OverrideSearchPath *search_path; MemoryContext oldcxt; - Assert(query_string != NULL); /* required as of 8.4 */ + Assert(query_string != NULL); /* required as of 8.4 */ /* * Fetch current search_path into given context, but do any recalculation @@ -475,8 +475,8 @@ RevalidateCachedPlan(CachedPlanSource *plansource, bool useResOwner) /* * If a snapshot is already set (the normal case), we can just use - * that for parsing/planning. But if it isn't, install one. Note: - * no point in checking whether parse analysis requires a snapshot; + * that for parsing/planning. But if it isn't, install one. Note: no + * point in checking whether parse analysis requires a snapshot; * utility commands don't have invalidatable plans, so we'd not get * here for such a command. */ @@ -609,8 +609,8 @@ CachedPlanIsValid(CachedPlanSource *plansource) Assert(plan->refcount > 0); /* - * Although we don't want to acquire locks here, it still seems - * useful to check for expiration of a transient plan. + * Although we don't want to acquire locks here, it still seems useful + * to check for expiration of a transient plan. */ if (TransactionIdIsValid(plan->saved_xmin) && !TransactionIdEquals(plan->saved_xmin, TransactionXmin)) @@ -990,7 +990,7 @@ PlanCacheFuncCallback(Datum arg, int cacheid, ItemPointer tuplePtr) { /* Invalidate the plan! */ plan->dead = true; - break; /* out of invalItems scan */ + break; /* out of invalItems scan */ } } if (plan->dead) diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index ae6fcea7e6..775865d569 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.286 2009/03/31 22:12:48 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.287 2009/06/11 14:49:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1129,7 +1129,7 @@ IndexSupportInitialize(oidvector *indclass, * Note there is no provision for flushing the cache. This is OK at the * moment because there is no way to ALTER any interesting properties of an * existing opclass --- all you can do is drop it, which will result in - * a useless but harmless dead entry in the cache. To support altering + * a useless but harmless dead entry in the cache. To support altering * opclass membership (not the same as opfamily membership!), we'd need to * be able to flush this cache as well as the contents of relcache entries * for indexes. @@ -1196,10 +1196,10 @@ LookupOpclassInfo(Oid operatorClassOid, /* * When testing for cache-flush hazards, we intentionally disable the - * operator class cache and force reloading of the info on each call. - * This is helpful because we want to test the case where a cache flush - * occurs while we are loading the info, and it's very hard to provoke - * that if this happens only once per opclass per backend. + * operator class cache and force reloading of the info on each call. This + * is helpful because we want to test the case where a cache flush occurs + * while we are loading the info, and it's very hard to provoke that if + * this happens only once per opclass per backend. */ #if defined(CLOBBER_CACHE_ALWAYS) opcentry->valid = false; @@ -1402,8 +1402,8 @@ formrdesc(const char *relationName, Oid relationReltype, relation->rd_rel->relisshared = false; /* - * Likewise, we must know if a relation is temp ... but formrdesc is - * not used for any temp relations. + * Likewise, we must know if a relation is temp ... but formrdesc is not + * used for any temp relations. */ relation->rd_rel->relistemp = false; @@ -1657,6 +1657,7 @@ RelationReloadIndexInfo(Relation relation) heap_freetuple(pg_class_tuple); /* We must recalculate physical address in case it changed */ RelationInitPhysicalAddr(relation); + /* * Must reset targblock, fsm_nblocks and vm_nblocks in case rel was * truncated @@ -2792,7 +2793,7 @@ AttrDefaultFetch(Relation relation) RelationGetRelationName(relation)); else attrdef[i].adbin = MemoryContextStrdup(CacheMemoryContext, - TextDatumGetCString(val)); + TextDatumGetCString(val)); break; } diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c index 4de61e7f94..922c4a626f 100644 --- a/src/backend/utils/cache/syscache.c +++ b/src/backend/utils/cache/syscache.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/cache/syscache.c,v 1.119 2009/01/01 17:23:50 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/syscache.c,v 1.120 2009/06/11 14:49:05 momjian Exp $ * * NOTES * These routines allow the parser/planner/executor to perform @@ -368,7 +368,7 @@ static const struct cachedesc cacheinfo[] = { }, 256 }, - {ForeignDataWrapperRelationId, /* FOREIGNDATAWRAPPERNAME */ + {ForeignDataWrapperRelationId, /* FOREIGNDATAWRAPPERNAME */ ForeignDataWrapperNameIndexId, 0, 1, @@ -380,7 +380,7 @@ static const struct cachedesc cacheinfo[] = { }, 8 }, - {ForeignDataWrapperRelationId, /* FOREIGNDATAWRAPPEROID */ + {ForeignDataWrapperRelationId, /* FOREIGNDATAWRAPPEROID */ ForeignDataWrapperOidIndexId, 0, 1, @@ -392,7 +392,7 @@ static const struct cachedesc cacheinfo[] = { }, 8 }, - {ForeignServerRelationId, /* FOREIGNSERVERNAME */ + {ForeignServerRelationId, /* FOREIGNSERVERNAME */ ForeignServerNameIndexId, 0, 1, @@ -404,7 +404,7 @@ static const struct cachedesc cacheinfo[] = { }, 32 }, - {ForeignServerRelationId, /* FOREIGNSERVEROID */ + {ForeignServerRelationId, /* FOREIGNSERVEROID */ ForeignServerOidIndexId, 0, 1, @@ -728,7 +728,7 @@ static const struct cachedesc cacheinfo[] = { }, 1024 }, - {UserMappingRelationId, /* USERMAPPINGOID */ + {UserMappingRelationId, /* USERMAPPINGOID */ UserMappingOidIndexId, 0, 1, @@ -740,7 +740,7 @@ static const struct cachedesc cacheinfo[] = { }, 128 }, - {UserMappingRelationId, /* USERMAPPINGUSERSERVER */ + {UserMappingRelationId, /* USERMAPPINGUSERSERVER */ UserMappingUserServerIndexId, 0, 2, diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index d93aaeb54d..ba529002f0 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -42,7 +42,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.214 2009/06/04 18:33:07 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.215 2009/06/11 14:49:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -92,7 +92,7 @@ int Log_destination = LOG_DESTINATION_STDERR; /* * Max string length to send to syslog(). Note that this doesn't count the * sequence-number prefix we add, and of course it doesn't count the prefix - * added by syslog itself. On many implementations it seems that the hard + * added by syslog itself. On many implementations it seems that the hard * limit is approximately 2K bytes including both those prefixes. */ #ifndef PG_SYSLOG_LIMIT @@ -298,8 +298,8 @@ errstart(int elevel, const char *filename, int lineno, MemoryContextReset(ErrorContext); /* - * Infinite error recursion might be due to something broken - * in a context traceback routine. Abandon them too. We also abandon + * Infinite error recursion might be due to something broken in a + * context traceback routine. Abandon them too. We also abandon * attempting to print the error statement (which, if long, could * itself be the source of the recursive failure). */ @@ -785,7 +785,7 @@ errmsg_internal(const char *fmt,...) */ int errmsg_plural(const char *fmt_singular, const char *fmt_plural, - unsigned long n, ...) + unsigned long n,...) { ErrorData *edata = &errordata[errordata_stack_depth]; MemoryContext oldcontext; @@ -850,7 +850,7 @@ errdetail_log(const char *fmt,...) */ int errdetail_plural(const char *fmt_singular, const char *fmt_plural, - unsigned long n, ...) + unsigned long n,...) { ErrorData *edata = &errordata[errordata_stack_depth]; MemoryContext oldcontext; @@ -1637,7 +1637,7 @@ setup_formatted_log_time(void) tz = log_timezone ? log_timezone : gmt_timezone; pg_strftime(formatted_log_time, FORMATTED_TS_LEN, - /* leave room for milliseconds... */ + /* leave room for milliseconds... */ "%Y-%m-%d %H:%M:%S %Z", pg_localtime(&stamp_time, tz)); @@ -1852,7 +1852,7 @@ static void write_csvlog(ErrorData *edata) { StringInfoData buf; - bool print_stmt = false; + bool print_stmt = false; /* static counter for line numbers */ static long log_line_number = 0; @@ -1934,7 +1934,7 @@ write_csvlog(ErrorData *edata) psdisp = get_ps_display(&displen); appendStringInfo(&msgbuf, "%.*s", displen, psdisp); appendCSVLiteral(&buf, msgbuf.data); - + pfree(msgbuf.data); } appendStringInfoChar(&buf, ','); @@ -2006,7 +2006,7 @@ write_csvlog(ErrorData *edata) /* file error location */ if (Log_error_verbosity >= PGERROR_VERBOSE) { - StringInfoData msgbuf; + StringInfoData msgbuf; initStringInfo(&msgbuf); diff --git a/src/backend/utils/fmgr/dfmgr.c b/src/backend/utils/fmgr/dfmgr.c index 125e880408..8b819df279 100644 --- a/src/backend/utils/fmgr/dfmgr.c +++ b/src/backend/utils/fmgr/dfmgr.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.98 2009/01/01 17:23:51 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.99 2009/06/11 14:49:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -73,7 +73,7 @@ char *Dynamic_library_path; static void *internal_load_library(const char *libname); static void incompatible_module_error(const char *libname, - const Pg_magic_struct *module_magic_data); + const Pg_magic_struct *module_magic_data); static void internal_unload_library(const char *libname); static bool file_exists(const char *name); static char *expand_dynamic_library_name(const char *name); @@ -301,7 +301,7 @@ static void incompatible_module_error(const char *libname, const Pg_magic_struct *module_magic_data) { - StringInfoData details; + StringInfoData details; /* * If the version doesn't match, just report that, because the rest of the @@ -311,11 +311,11 @@ incompatible_module_error(const char *libname, ereport(ERROR, (errmsg("incompatible library \"%s\": version mismatch", libname), - errdetail("Server is version %d.%d, library is version %d.%d.", - magic_data.version / 100, - magic_data.version % 100, - module_magic_data->version / 100, - module_magic_data->version % 100))); + errdetail("Server is version %d.%d, library is version %d.%d.", + magic_data.version / 100, + magic_data.version % 100, + module_magic_data->version / 100, + module_magic_data->version % 100))); /* * Otherwise, spell out which fields don't agree. @@ -357,7 +357,7 @@ incompatible_module_error(const char *libname, if (details.len) appendStringInfoChar(&details, '\n'); appendStringInfo(&details, - _("Server has FLOAT4PASSBYVAL = %s, library has %s."), + _("Server has FLOAT4PASSBYVAL = %s, library has %s."), magic_data.float4byval ? "true" : "false", module_magic_data->float4byval ? "true" : "false"); } @@ -366,14 +366,14 @@ incompatible_module_error(const char *libname, if (details.len) appendStringInfoChar(&details, '\n'); appendStringInfo(&details, - _("Server has FLOAT8PASSBYVAL = %s, library has %s."), + _("Server has FLOAT8PASSBYVAL = %s, library has %s."), magic_data.float8byval ? "true" : "false", module_magic_data->float8byval ? "true" : "false"); } if (details.len == 0) appendStringInfo(&details, - _("Magic block has unexpected length or padding difference.")); + _("Magic block has unexpected length or padding difference.")); ereport(ERROR, (errmsg("incompatible library \"%s\": magic block mismatch", diff --git a/src/backend/utils/fmgr/fmgr.c b/src/backend/utils/fmgr/fmgr.c index 34777b7606..1256e7c88d 100644 --- a/src/backend/utils/fmgr/fmgr.c +++ b/src/backend/utils/fmgr/fmgr.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/fmgr/fmgr.c,v 1.125 2009/01/07 20:38:56 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/fmgr/fmgr.c,v 1.126 2009/06/11 14:49:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -199,7 +199,7 @@ fmgr_info_cxt_security(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt, finfo->fn_nargs = fbp->nargs; finfo->fn_strict = fbp->strict; finfo->fn_retset = fbp->retset; - finfo->fn_stats = TRACK_FUNC_ALL; /* ie, never track */ + finfo->fn_stats = TRACK_FUNC_ALL; /* ie, never track */ finfo->fn_addr = fbp->func; finfo->fn_oid = functionId; return; @@ -219,23 +219,23 @@ fmgr_info_cxt_security(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt, /* * If it has prosecdef set, or non-null proconfig, use - * fmgr_security_definer call handler --- unless we are being called - * again by fmgr_security_definer. + * fmgr_security_definer call handler --- unless we are being called again + * by fmgr_security_definer. * * When using fmgr_security_definer, function stats tracking is always - * disabled at the outer level, and instead we set the flag properly - * in fmgr_security_definer's private flinfo and implement the tracking + * disabled at the outer level, and instead we set the flag properly in + * fmgr_security_definer's private flinfo and implement the tracking * inside fmgr_security_definer. This loses the ability to charge the * overhead of fmgr_security_definer to the function, but gains the - * ability to set the track_functions GUC as a local GUC parameter of - * an interesting function and have the right things happen. + * ability to set the track_functions GUC as a local GUC parameter of an + * interesting function and have the right things happen. */ if (!ignore_security && (procedureStruct->prosecdef || !heap_attisnull(procedureTuple, Anum_pg_proc_proconfig))) { finfo->fn_addr = fmgr_security_definer; - finfo->fn_stats = TRACK_FUNC_ALL; /* ie, never track */ + finfo->fn_stats = TRACK_FUNC_ALL; /* ie, never track */ finfo->fn_oid = functionId; ReleaseSysCache(procedureTuple); return; @@ -946,7 +946,7 @@ fmgr_security_definer(PG_FUNCTION_ARGS) /* * We don't need to restore GUC or userid settings on error, because the - * ensuing xact or subxact abort will do that. The PG_TRY block is only + * ensuing xact or subxact abort will do that. The PG_TRY block is only * needed to clean up the flinfo link. */ save_flinfo = fcinfo->flinfo; @@ -1850,7 +1850,7 @@ OidFunctionCall9(Oid functionId, Datum arg1, Datum arg2, * * One important difference from the bare function call is that we will * push any active SPI context, allowing SPI-using I/O functions to be - * called from other SPI functions without extra notation. This is a hack, + * called from other SPI functions without extra notation. This is a hack, * but the alternative of expecting all SPI functions to do SPI_push/SPI_pop * around I/O calls seems worse. */ @@ -2130,17 +2130,17 @@ Int64GetDatum(int64 X) return PointerGetDatum(retval); #endif /* INT64_IS_BUSTED */ } - -#endif /* USE_FLOAT8_BYVAL */ +#endif /* USE_FLOAT8_BYVAL */ Datum Float4GetDatum(float4 X) { #ifdef USE_FLOAT4_BYVAL - union { - float4 value; - int32 retval; - } myunion; + union + { + float4 value; + int32 retval; + } myunion; myunion.value = X; return SET_4_BYTES(myunion.retval); @@ -2157,25 +2157,26 @@ Float4GetDatum(float4 X) float4 DatumGetFloat4(Datum X) { - union { - int32 value; - float4 retval; - } myunion; + union + { + int32 value; + float4 retval; + } myunion; myunion.value = GET_4_BYTES(X); return myunion.retval; } - -#endif /* USE_FLOAT4_BYVAL */ +#endif /* USE_FLOAT4_BYVAL */ Datum Float8GetDatum(float8 X) { #ifdef USE_FLOAT8_BYVAL - union { - float8 value; - int64 retval; - } myunion; + union + { + float8 value; + int64 retval; + } myunion; myunion.value = X; return SET_8_BYTES(myunion.retval); @@ -2192,16 +2193,16 @@ Float8GetDatum(float8 X) float8 DatumGetFloat8(Datum X) { - union { - int64 value; - float8 retval; - } myunion; + union + { + int64 value; + float8 retval; + } myunion; myunion.value = GET_8_BYTES(X); return myunion.retval; } - -#endif /* USE_FLOAT8_BYVAL */ +#endif /* USE_FLOAT8_BYVAL */ /*------------------------------------------------------------------------- @@ -2408,9 +2409,9 @@ get_call_expr_arg_stable(Node *expr, int argnum) arg = (Node *) list_nth(args, argnum); /* - * Either a true Const or an external Param will have a value that - * doesn't change during the execution of the query. In future we - * might want to consider other cases too, e.g. now(). + * Either a true Const or an external Param will have a value that doesn't + * change during the execution of the query. In future we might want to + * consider other cases too, e.g. now(). */ if (IsA(arg, Const)) return true; diff --git a/src/backend/utils/fmgr/funcapi.c b/src/backend/utils/fmgr/funcapi.c index c0cd71419a..7ecd781220 100644 --- a/src/backend/utils/fmgr/funcapi.c +++ b/src/backend/utils/fmgr/funcapi.c @@ -7,7 +7,7 @@ * Copyright (c) 2002-2009, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/fmgr/funcapi.c,v 1.44 2009/01/01 17:23:51 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/fmgr/funcapi.c,v 1.45 2009/06/11 14:49:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -64,8 +64,8 @@ init_MultiFuncCall(PG_FUNCTION_ARGS) /* * First call */ - ReturnSetInfo *rsi = (ReturnSetInfo *) fcinfo->resultinfo; - MemoryContext multi_call_ctx; + ReturnSetInfo *rsi = (ReturnSetInfo *) fcinfo->resultinfo; + MemoryContext multi_call_ctx; /* * Create a suitably long-lived context to hold cross-call data diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c index 2fcb23628d..7bdfb67204 100644 --- a/src/backend/utils/init/miscinit.c +++ b/src/backend/utils/init/miscinit.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.174 2009/04/08 09:50:48 heikki Exp $ + * $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.175 2009/06/11 14:49:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -363,7 +363,7 @@ SetSessionUserId(Oid userid, bool is_superuser) * ever throw any kind of error. This is because they are used by * StartTransaction and AbortTransaction to save/restore the settings, * and during the first transaction within a backend, the value to be saved - * and perhaps restored is indeed invalid. We have to be able to get + * and perhaps restored is indeed invalid. We have to be able to get * through AbortTransaction without asserting in case InitPostgres fails. */ void @@ -1170,7 +1170,7 @@ load_libraries(const char *libraries, const char *gucname, bool restricted) /* * Choose notice level: avoid repeat messages when re-loading a library - * that was preloaded into the postmaster. (Only possible in EXEC_BACKEND + * that was preloaded into the postmaster. (Only possible in EXEC_BACKEND * configurations) */ #ifdef EXEC_BACKEND @@ -1238,7 +1238,7 @@ pg_bindtextdomain(const char *domain) #ifdef ENABLE_NLS if (my_exec_path[0] != '\0') { - char locale_path[MAXPGPATH]; + char locale_path[MAXPGPATH]; get_locale_path(my_exec_path, locale_path); bindtextdomain(domain, locale_path); diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c index 9b48b7671d..34685cba3c 100644 --- a/src/backend/utils/init/postinit.c +++ b/src/backend/utils/init/postinit.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/init/postinit.c,v 1.190 2009/04/08 13:08:09 heikki Exp $ + * $PostgreSQL: pgsql/src/backend/utils/init/postinit.c,v 1.191 2009/06/11 14:49:05 momjian Exp $ * * *------------------------------------------------------------------------- @@ -242,25 +242,25 @@ CheckMyDatabase(const char *name, bool am_superuser) /* If we have no other source of client_encoding, use server encoding */ SetConfigOption("client_encoding", GetDatabaseEncodingName(), PGC_BACKEND, PGC_S_DEFAULT); - - /* assign locale variables */ + + /* assign locale variables */ collate = NameStr(dbform->datcollate); ctype = NameStr(dbform->datctype); - + if (setlocale(LC_COLLATE, collate) == NULL) - ereport(FATAL, + ereport(FATAL, (errmsg("database locale is incompatible with operating system"), - errdetail("The database was initialized with LC_COLLATE \"%s\", " - " which is not recognized by setlocale().", collate), - errhint("Recreate the database with another locale or install the missing locale."))); - + errdetail("The database was initialized with LC_COLLATE \"%s\", " + " which is not recognized by setlocale().", collate), + errhint("Recreate the database with another locale or install the missing locale."))); + if (setlocale(LC_CTYPE, ctype) == NULL) - ereport(FATAL, + ereport(FATAL, (errmsg("database locale is incompatible with operating system"), - errdetail("The database was initialized with LC_CTYPE \"%s\", " - " which is not recognized by setlocale().", ctype), - errhint("Recreate the database with another locale or install the missing locale."))); - + errdetail("The database was initialized with LC_CTYPE \"%s\", " + " which is not recognized by setlocale().", ctype), + errhint("Recreate the database with another locale or install the missing locale."))); + /* Make the locale settings visible as GUC variables, too */ SetConfigOption("lc_collate", collate, PGC_INTERNAL, PGC_S_OVERRIDE); SetConfigOption("lc_ctype", ctype, PGC_INTERNAL, PGC_S_OVERRIDE); @@ -623,7 +623,7 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username, MyProcPort->canAcceptConnections == CAC_WAITBACKUP) ereport(FATAL, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - errmsg("must be superuser to connect during database shutdown"))); + errmsg("must be superuser to connect during database shutdown"))); /* * Check a normal user hasn't connected to a superuser reserved slot. diff --git a/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c b/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c index dfc1671604..ab149f7e39 100644 --- a/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c +++ b/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c,v 1.20 2009/02/28 18:49:42 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c,v 1.21 2009/06/11 14:49:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -278,8 +278,8 @@ win866_to_win1251(PG_FUNCTION_ARGS) /* * Note: There are a few characters like the "Numero" sign that exist in * all the other cyrillic encodings (win1251, ISO_8859-5 and cp866), but - * not in KOI8R. As we use MULE_INTERNAL/KOI8R as an intermediary, we - * will fail to convert those characters. + * not in KOI8R. As we use MULE_INTERNAL/KOI8R as an intermediary, we will + * fail to convert those characters. */ buf = palloc(len * ENCODING_GROWTH_RATE + 1); win8662mic(src, buf, len); diff --git a/src/backend/utils/mb/mbutils.c b/src/backend/utils/mb/mbutils.c index 5dcf922794..9a73901953 100644 --- a/src/backend/utils/mb/mbutils.c +++ b/src/backend/utils/mb/mbutils.c @@ -4,7 +4,7 @@ * * Tatsuo Ishii * - * $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.86 2009/04/24 08:43:50 mha Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.87 2009/06/11 14:49:05 momjian Exp $ */ #include "postgres.h" @@ -30,7 +30,7 @@ /* * We maintain a simple linked list caching the fmgr lookup info for the * currently selected conversion functions, as well as any that have been - * selected previously in the current session. (We remember previous + * selected previously in the current session. (We remember previous * settings because we must be able to restore a previous setting during * transaction rollback, without doing any fresh catalog accesses.) * @@ -40,7 +40,7 @@ typedef struct ConvProcInfo { int s_encoding; /* server and client encoding IDs */ int c_encoding; - FmgrInfo to_server_info; /* lookup info for conversion procs */ + FmgrInfo to_server_info; /* lookup info for conversion procs */ FmgrInfo to_client_info; } ConvProcInfo; @@ -119,9 +119,9 @@ SetClientEncoding(int encoding, bool doit) { /* * If we're in a live transaction, it's safe to access the catalogs, - * so look up the functions. We repeat the lookup even if the info - * is already cached, so that we can react to changes in the contents - * of pg_conversion. + * so look up the functions. We repeat the lookup even if the info is + * already cached, so that we can react to changes in the contents of + * pg_conversion. */ Oid to_server_proc, to_client_proc; @@ -168,8 +168,8 @@ SetClientEncoding(int encoding, bool doit) ToClientConvProc = &convinfo->to_client_info; /* - * Remove any older entry for the same encoding pair (this is just - * to avoid memory leakage). + * Remove any older entry for the same encoding pair (this is just to + * avoid memory leakage). */ foreach(lc, ConvProcList) { @@ -191,10 +191,10 @@ SetClientEncoding(int encoding, bool doit) else { /* - * If we're not in a live transaction, the only thing we can do - * is restore a previous setting using the cache. This covers all - * transaction-rollback cases. The only case it might not work for - * is trying to change client_encoding on the fly by editing + * If we're not in a live transaction, the only thing we can do is + * restore a previous setting using the cache. This covers all + * transaction-rollback cases. The only case it might not work for is + * trying to change client_encoding on the fly by editing * postgresql.conf and SIGHUP'ing. Which would probably be a stupid * thing to do anyway. */ @@ -275,7 +275,7 @@ pg_get_client_encoding_name(void) * * CAUTION: although the presence of a length argument means that callers * can pass non-null-terminated strings, care is required because the same - * string will be passed back if no conversion occurs. Such callers *must* + * string will be passed back if no conversion occurs. Such callers *must* * check whether result == src and handle that case differently. * * Note: we try to avoid raising error, since that could get us into @@ -622,21 +622,22 @@ perform_default_encoding_conversion(const char *src, int len, bool is_client_to_ size_t wchar2char(char *to, const wchar_t *from, size_t tolen) { - size_t result; - + size_t result; + if (tolen == 0) return 0; #ifdef WIN32 + /* - * On Windows, the "Unicode" locales assume UTF16 not UTF8 encoding, - * and for some reason mbstowcs and wcstombs won't do this for us, - * so we use MultiByteToWideChar(). + * On Windows, the "Unicode" locales assume UTF16 not UTF8 encoding, and + * for some reason mbstowcs and wcstombs won't do this for us, so we use + * MultiByteToWideChar(). */ if (GetDatabaseEncoding() == PG_UTF8) { result = WideCharToMultiByte(CP_UTF8, 0, from, -1, to, tolen, - NULL, NULL); + NULL, NULL); /* A zero return is failure */ if (result <= 0) result = -1; @@ -650,7 +651,7 @@ wchar2char(char *to, const wchar_t *from, size_t tolen) else #endif /* WIN32 */ { - Assert( !lc_ctype_is_c() ); + Assert(!lc_ctype_is_c()); result = wcstombs(to, from, tolen); } return result; @@ -701,7 +702,7 @@ char2wchar(wchar_t *to, size_t tolen, const char *from, size_t fromlen) /* mbstowcs requires ending '\0' */ char *str = pnstrdup(from, fromlen); - Assert( !lc_ctype_is_c() ); + Assert(!lc_ctype_is_c()); result = mbstowcs(to, str, tolen); pfree(str); } @@ -722,11 +723,10 @@ char2wchar(wchar_t *to, size_t tolen, const char *from, size_t fromlen) (errcode(ERRCODE_CHARACTER_NOT_IN_REPERTOIRE), errmsg("invalid multibyte character for locale"), errhint("The server's LC_CTYPE locale is probably incompatible with the database encoding."))); - } + } return result; } - #endif /* convert a multibyte string to a wchar */ @@ -907,19 +907,18 @@ void pg_bind_textdomain_codeset(const char *domainname) { #if defined(ENABLE_NLS) - int encoding = GetDatabaseEncoding(); - int i; + int encoding = GetDatabaseEncoding(); + int i; /* - * gettext() uses the codeset specified by LC_CTYPE by default, - * so if that matches the database encoding we don't need to do - * anything. In CREATE DATABASE, we enforce or trust that the - * locale's codeset matches database encoding, except for the C - * locale. In C locale, we bind gettext() explicitly to the right - * codeset. + * gettext() uses the codeset specified by LC_CTYPE by default, so if that + * matches the database encoding we don't need to do anything. In CREATE + * DATABASE, we enforce or trust that the locale's codeset matches + * database encoding, except for the C locale. In C locale, we bind + * gettext() explicitly to the right codeset. * - * On Windows, though, gettext() tends to get confused so we always - * bind it. + * On Windows, though, gettext() tends to get confused so we always bind + * it. */ #ifndef WIN32 const char *ctype = setlocale(LC_CTYPE, NULL); diff --git a/src/backend/utils/mb/wchar.c b/src/backend/utils/mb/wchar.c index 8da81b9f22..9bff635b88 100644 --- a/src/backend/utils/mb/wchar.c +++ b/src/backend/utils/mb/wchar.c @@ -1,7 +1,7 @@ /* * conversion functions between pg_wchar and multibyte streams. * Tatsuo Ishii - * $PostgreSQL: pgsql/src/backend/utils/mb/wchar.c,v 1.72 2009/03/02 21:18:43 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mb/wchar.c,v 1.73 2009/06/11 14:49:05 momjian Exp $ * */ /* can be used in either frontend or backend */ @@ -1339,7 +1339,7 @@ pg_utf8_islegal(const unsigned char *source, int length) *------------------------------------------------------------------- */ pg_wchar_tbl pg_wchar_table[] = { - {pg_ascii2wchar_with_len, pg_ascii_mblen, pg_ascii_dsplen, pg_ascii_verifier, 1}, /* PG_SQL_ASCII */ + {pg_ascii2wchar_with_len, pg_ascii_mblen, pg_ascii_dsplen, pg_ascii_verifier, 1}, /* PG_SQL_ASCII */ {pg_eucjp2wchar_with_len, pg_eucjp_mblen, pg_eucjp_dsplen, pg_eucjp_verifier, 3}, /* PG_EUC_JP */ {pg_euccn2wchar_with_len, pg_euccn_mblen, pg_euccn_dsplen, pg_euccn_verifier, 2}, /* PG_EUC_CN */ {pg_euckr2wchar_with_len, pg_euckr_mblen, pg_euckr_dsplen, pg_euckr_verifier, 3}, /* PG_EUC_KR */ @@ -1638,10 +1638,10 @@ report_untranslatable_char(int src_encoding, int dest_encoding, ereport(ERROR, (errcode(ERRCODE_UNTRANSLATABLE_CHARACTER), - errmsg("character 0x%s of encoding \"%s\" has no equivalent in \"%s\"", - buf, - pg_enc2name_tbl[src_encoding].name, - pg_enc2name_tbl[dest_encoding].name))); + errmsg("character 0x%s of encoding \"%s\" has no equivalent in \"%s\"", + buf, + pg_enc2name_tbl[src_encoding].name, + pg_enc2name_tbl[dest_encoding].name))); } #endif diff --git a/src/backend/utils/mb/wstrcmp.c b/src/backend/utils/mb/wstrcmp.c index 2bd55d1bee..22cd7e93c0 100644 --- a/src/backend/utils/mb/wstrcmp.c +++ b/src/backend/utils/mb/wstrcmp.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/src/backend/utils/mb/wstrcmp.c,v 1.9 2008/05/17 01:28:24 adunstan Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mb/wstrcmp.c,v 1.10 2009/06/11 14:49:06 momjian Exp $ * *- * Copyright (c) 1990, 1993 diff --git a/src/backend/utils/mb/wstrncmp.c b/src/backend/utils/mb/wstrncmp.c index 3de672c779..60400e903b 100644 --- a/src/backend/utils/mb/wstrncmp.c +++ b/src/backend/utils/mb/wstrncmp.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/src/backend/utils/mb/wstrncmp.c,v 1.9 2008/05/17 01:28:24 adunstan Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mb/wstrncmp.c,v 1.10 2009/06/11 14:49:06 momjian Exp $ * * * Copyright (c) 1989, 1993 diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 41368bf1e9..210bd6ba6a 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -10,7 +10,7 @@ * Written by Peter Eisentraut <peter_e@gmx.net>. * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.504 2009/05/03 20:09:54 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.505 2009/06/11 14:49:06 momjian Exp $ * *-------------------------------------------------------------------- */ @@ -139,7 +139,7 @@ static const char *assign_log_destination(const char *value, static int syslog_facility = LOG_LOCAL0; static bool assign_syslog_facility(int newval, - bool doit, GucSource source); + bool doit, GucSource source); static const char *assign_syslog_ident(const char *ident, bool doit, GucSource source); #endif @@ -169,9 +169,9 @@ static bool assign_autovacuum_max_workers(int newval, bool doit, GucSource sourc static bool assign_effective_io_concurrency(int newval, bool doit, GucSource source); static const char *assign_pgstat_temp_directory(const char *newval, bool doit, GucSource source); -static char *config_enum_get_options(struct config_enum *record, - const char *prefix, const char *suffix, - const char *separator); +static char *config_enum_get_options(struct config_enum * record, + const char *prefix, const char *suffix, + const char *separator); /* @@ -242,10 +242,10 @@ static const struct config_enum_entry log_statement_options[] = { }; static const struct config_enum_entry regex_flavor_options[] = { - {"advanced", REG_ADVANCED, false}, - {"extended", REG_EXTENDED, false}, - {"basic", REG_BASIC, false}, - {NULL, 0, false} + {"advanced", REG_ADVANCED, false}, + {"extended", REG_EXTENDED, false}, + {"basic", REG_BASIC, false}, + {NULL, 0, false} }; static const struct config_enum_entry isolation_level_options[] = { @@ -1715,11 +1715,11 @@ static struct config_int ConfigureNamesInt[] = { {"effective_io_concurrency", #ifdef USE_PREFETCH - PGC_USERSET, + PGC_USERSET, #else - PGC_INTERNAL, + PGC_INTERNAL, #endif - RESOURCES, + RESOURCES, gettext_noop("Number of simultaneous requests that can be handled efficiently by the disk subsystem."), gettext_noop("For RAID arrays, this should be approximately the number of drive spindles in the array.") }, @@ -1794,9 +1794,9 @@ static struct config_int ConfigureNamesInt[] = { {"segment_size", PGC_INTERNAL, PRESET_OPTIONS, - gettext_noop("Shows the number of pages per disk file."), - NULL, - GUC_UNIT_BLOCKS | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE + gettext_noop("Shows the number of pages per disk file."), + NULL, + GUC_UNIT_BLOCKS | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE }, &segment_size, RELSEG_SIZE, RELSEG_SIZE, RELSEG_SIZE, NULL, NULL @@ -1819,8 +1819,8 @@ static struct config_int ConfigureNamesInt[] = GUC_UNIT_XBLOCKS | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE }, &wal_segment_size, - (XLOG_SEG_SIZE / XLOG_BLCKSZ), - (XLOG_SEG_SIZE / XLOG_BLCKSZ), + (XLOG_SEG_SIZE / XLOG_BLCKSZ), + (XLOG_SEG_SIZE / XLOG_BLCKSZ), (XLOG_SEG_SIZE / XLOG_BLCKSZ), NULL, NULL }, @@ -2562,7 +2562,7 @@ static struct config_enum ConfigureNamesEnum[] = XACT_READ_COMMITTED, isolation_level_options, NULL, NULL }, - { + { {"IntervalStyle", PGC_USERSET, CLIENT_CONN_LOCALE, gettext_noop("Sets the display format for interval values."), NULL, @@ -2655,7 +2655,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &sync_method, - DEFAULT_SYNC_METHOD, sync_method_options, + DEFAULT_SYNC_METHOD, sync_method_options, assign_xlog_sync_method, NULL }, @@ -2722,7 +2722,7 @@ static int GUCNestLevel = 0; /* 1 when in main transaction */ static int guc_var_compare(const void *a, const void *b); static int guc_name_compare(const char *namea, const char *nameb); -static void InitializeOneGUCOption(struct config_generic *gconf); +static void InitializeOneGUCOption(struct config_generic * gconf); static void push_old_value(struct config_generic * gconf, GucAction action); static void ReportGUCOption(struct config_generic * record); static void ShowGUCConfigOption(const char *name, DestReceiver *dest); @@ -2853,7 +2853,7 @@ set_stack_value(struct config_generic * gconf, union config_var_value * val) *((struct config_string *) gconf)->variable); break; case PGC_ENUM: - val->enumval = + val->enumval = *((struct config_enum *) gconf)->variable; break; } @@ -3290,7 +3290,7 @@ InitializeGUCOptions(void) * Initialize one GUC option variable to its compiled-in default. */ static void -InitializeOneGUCOption(struct config_generic *gconf) +InitializeOneGUCOption(struct config_generic * gconf) { gconf->status = 0; gconf->reset_source = PGC_S_DEFAULT; @@ -3302,100 +3302,100 @@ InitializeOneGUCOption(struct config_generic *gconf) switch (gconf->vartype) { case PGC_BOOL: - { - struct config_bool *conf = (struct config_bool *) gconf; - - if (conf->assign_hook) - if (!(*conf->assign_hook) (conf->boot_val, true, - PGC_S_DEFAULT)) - elog(FATAL, "failed to initialize %s to %d", - conf->gen.name, (int) conf->boot_val); - *conf->variable = conf->reset_val = conf->boot_val; - break; - } - case PGC_INT: - { - struct config_int *conf = (struct config_int *) gconf; - - Assert(conf->boot_val >= conf->min); - Assert(conf->boot_val <= conf->max); - if (conf->assign_hook) - if (!(*conf->assign_hook) (conf->boot_val, true, - PGC_S_DEFAULT)) - elog(FATAL, "failed to initialize %s to %d", - conf->gen.name, conf->boot_val); - *conf->variable = conf->reset_val = conf->boot_val; - break; - } - case PGC_REAL: - { - struct config_real *conf = (struct config_real *) gconf; - - Assert(conf->boot_val >= conf->min); - Assert(conf->boot_val <= conf->max); - if (conf->assign_hook) - if (!(*conf->assign_hook) (conf->boot_val, true, - PGC_S_DEFAULT)) - elog(FATAL, "failed to initialize %s to %g", - conf->gen.name, conf->boot_val); - *conf->variable = conf->reset_val = conf->boot_val; - break; - } - case PGC_STRING: - { - struct config_string *conf = (struct config_string *) gconf; - char *str; - - *conf->variable = NULL; - conf->reset_val = NULL; - - if (conf->boot_val == NULL) { - /* leave the value NULL, do not call assign hook */ + struct config_bool *conf = (struct config_bool *) gconf; + + if (conf->assign_hook) + if (!(*conf->assign_hook) (conf->boot_val, true, + PGC_S_DEFAULT)) + elog(FATAL, "failed to initialize %s to %d", + conf->gen.name, (int) conf->boot_val); + *conf->variable = conf->reset_val = conf->boot_val; break; } + case PGC_INT: + { + struct config_int *conf = (struct config_int *) gconf; - str = guc_strdup(FATAL, conf->boot_val); - conf->reset_val = str; + Assert(conf->boot_val >= conf->min); + Assert(conf->boot_val <= conf->max); + if (conf->assign_hook) + if (!(*conf->assign_hook) (conf->boot_val, true, + PGC_S_DEFAULT)) + elog(FATAL, "failed to initialize %s to %d", + conf->gen.name, conf->boot_val); + *conf->variable = conf->reset_val = conf->boot_val; + break; + } + case PGC_REAL: + { + struct config_real *conf = (struct config_real *) gconf; - if (conf->assign_hook) + Assert(conf->boot_val >= conf->min); + Assert(conf->boot_val <= conf->max); + if (conf->assign_hook) + if (!(*conf->assign_hook) (conf->boot_val, true, + PGC_S_DEFAULT)) + elog(FATAL, "failed to initialize %s to %g", + conf->gen.name, conf->boot_val); + *conf->variable = conf->reset_val = conf->boot_val; + break; + } + case PGC_STRING: { - const char *newstr; + struct config_string *conf = (struct config_string *) gconf; + char *str; + + *conf->variable = NULL; + conf->reset_val = NULL; - newstr = (*conf->assign_hook) (str, true, - PGC_S_DEFAULT); - if (newstr == NULL) + if (conf->boot_val == NULL) { - elog(FATAL, "failed to initialize %s to \"%s\"", - conf->gen.name, str); + /* leave the value NULL, do not call assign hook */ + break; } - else if (newstr != str) + + str = guc_strdup(FATAL, conf->boot_val); + conf->reset_val = str; + + if (conf->assign_hook) { - free(str); + const char *newstr; - /* - * See notes in set_config_option about casting - */ - str = (char *) newstr; - conf->reset_val = str; + newstr = (*conf->assign_hook) (str, true, + PGC_S_DEFAULT); + if (newstr == NULL) + { + elog(FATAL, "failed to initialize %s to \"%s\"", + conf->gen.name, str); + } + else if (newstr != str) + { + free(str); + + /* + * See notes in set_config_option about casting + */ + str = (char *) newstr; + conf->reset_val = str; + } } + *conf->variable = str; + break; } - *conf->variable = str; - break; - } case PGC_ENUM: - { - struct config_enum *conf = (struct config_enum *) gconf; - - if (conf->assign_hook) - if (!(*conf->assign_hook) (conf->boot_val, true, - PGC_S_DEFAULT)) - elog(FATAL, "failed to initialize %s to %s", - conf->gen.name, - config_enum_lookup_by_value(conf, conf->boot_val)); - *conf->variable = conf->reset_val = conf->boot_val; - break; - } + { + struct config_enum *conf = (struct config_enum *) gconf; + + if (conf->assign_hook) + if (!(*conf->assign_hook) (conf->boot_val, true, + PGC_S_DEFAULT)) + elog(FATAL, "failed to initialize %s to %s", + conf->gen.name, + config_enum_lookup_by_value(conf, conf->boot_val)); + *conf->variable = conf->reset_val = conf->boot_val; + break; + } } } @@ -4009,13 +4009,13 @@ AtEOXact_GUC(bool isCommit, int nestLevel) case PGC_ENUM: { struct config_enum *conf = (struct config_enum *) gconf; - int newval = newvalue.enumval; + int newval = newvalue.enumval; if (*conf->variable != newval) { if (conf->assign_hook) if (!(*conf->assign_hook) (newval, - true, PGC_S_OVERRIDE)) + true, PGC_S_OVERRIDE)) elog(LOG, "failed to commit %s as %s", conf->gen.name, config_enum_lookup_by_value(conf, newval)); @@ -4351,7 +4351,7 @@ parse_real(const char *value, double *result) * allocated for modification. */ const char * -config_enum_lookup_by_value(struct config_enum *record, int val) +config_enum_lookup_by_value(struct config_enum * record, int val) { const struct config_enum_entry *entry; @@ -4363,7 +4363,7 @@ config_enum_lookup_by_value(struct config_enum *record, int val) elog(ERROR, "could not find enum option %d for %s", val, record->gen.name); - return NULL; /* silence compiler */ + return NULL; /* silence compiler */ } @@ -4374,7 +4374,7 @@ config_enum_lookup_by_value(struct config_enum *record, int val) * true. If it's not found, return FALSE and retval is set to 0. */ bool -config_enum_lookup_by_name(struct config_enum *record, const char *value, +config_enum_lookup_by_name(struct config_enum * record, const char *value, int *retval) { const struct config_enum_entry *entry; @@ -4400,16 +4400,16 @@ config_enum_lookup_by_name(struct config_enum *record, const char *value, * If suffix is non-NULL, it is added to the end of the string. */ static char * -config_enum_get_options(struct config_enum *record, const char *prefix, +config_enum_get_options(struct config_enum * record, const char *prefix, const char *suffix, const char *separator) { const struct config_enum_entry *entry; - StringInfoData retstr; + StringInfoData retstr; int seplen; initStringInfo(&retstr); appendStringInfoString(&retstr, prefix); - + seplen = strlen(separator); for (entry = record->options; entry && entry->name; entry++) { @@ -4421,11 +4421,11 @@ config_enum_get_options(struct config_enum *record, const char *prefix, } /* - * All the entries may have been hidden, leaving the string empty - * if no prefix was given. This indicates a broken GUC setup, since - * there is no use for an enum without any values, so we just check - * to make sure we don't write to invalid memory instead of actually - * trying to do something smart with it. + * All the entries may have been hidden, leaving the string empty if no + * prefix was given. This indicates a broken GUC setup, since there is no + * use for an enum without any values, so we just check to make sure we + * don't write to invalid memory instead of actually trying to do + * something smart with it. */ if (retstr.len >= seplen) { @@ -4565,8 +4565,8 @@ set_config_option(const char *name, const char *value, if (changeVal && !is_newvalue_equal(record, value)) ereport(elevel, (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM), - errmsg("attempted change of parameter \"%s\" ignored", - name), + errmsg("attempted change of parameter \"%s\" ignored", + name), errdetail("This parameter cannot be changed after server start."))); return true; } @@ -4574,8 +4574,8 @@ set_config_option(const char *name, const char *value, { ereport(elevel, (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM), - errmsg("attempted change of parameter \"%s\" ignored", - name), + errmsg("attempted change of parameter \"%s\" ignored", + name), errdetail("This parameter cannot be changed after server start."))); return false; } @@ -5004,16 +5004,16 @@ set_config_option(const char *name, const char *value, { if (!config_enum_lookup_by_name(conf, value, &newval)) { - char *hintmsg; - - hintmsg = config_enum_get_options(conf, - "Available values: ", + char *hintmsg; + + hintmsg = config_enum_get_options(conf, + "Available values: ", ".", ", "); ereport(elevel, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("invalid value for parameter \"%s\": \"%s\"", - name, value), + errmsg("invalid value for parameter \"%s\": \"%s\"", + name, value), hintmsg ? errhint("%s", _(hintmsg)) : 0)); if (hintmsg) @@ -5038,9 +5038,9 @@ set_config_option(const char *name, const char *value, { ereport(elevel, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("invalid value for parameter \"%s\": \"%s\"", - name, - config_enum_lookup_by_value(conf, newval)))); + errmsg("invalid value for parameter \"%s\": \"%s\"", + name, + config_enum_lookup_by_value(conf, newval)))); return false; } @@ -5088,8 +5088,8 @@ set_config_sourcefile(const char *name, char *sourcefile, int sourceline) int elevel; /* - * To avoid cluttering the log, only the postmaster bleats loudly - * about problems with the config file. + * To avoid cluttering the log, only the postmaster bleats loudly about + * problems with the config file. */ elevel = IsUnderPostmaster ? DEBUG3 : LOG; @@ -5166,7 +5166,7 @@ GetConfigOption(const char *name) case PGC_ENUM: return config_enum_lookup_by_value((struct config_enum *) record, - *((struct config_enum *) record)->variable); + *((struct config_enum *) record)->variable); } return NULL; } @@ -5214,7 +5214,7 @@ GetConfigOptionResetString(const char *name) case PGC_ENUM: return config_enum_lookup_by_value((struct config_enum *) record, - ((struct config_enum *) record)->reset_val); + ((struct config_enum *) record)->reset_val); } return NULL; } @@ -5244,7 +5244,7 @@ IsSuperuserConfigOption(const char *name) * report (in addition to the generic "invalid value for option FOO" that * guc.c will provide). Note that the result might be ERROR or a lower * level, so the caller must be prepared for control to return from ereport, - * or not. If control does return, return false/NULL from the hook function. + * or not. If control does return, return false/NULL from the hook function. * * At some point it'd be nice to replace this with a mechanism that allows * the custom message to become the DETAIL line of guc.c's generic message. @@ -5266,9 +5266,9 @@ GUC_complaint_elevel(GucSource source) { /* * If we're a postmaster child, this is probably "undo" during - * transaction abort, so we don't want to clutter the log. There's - * a small chance of a real problem with an OVERRIDE setting, - * though, so suppressing the message entirely wouldn't be desirable. + * transaction abort, so we don't want to clutter the log. There's a + * small chance of a real problem with an OVERRIDE setting, though, so + * suppressing the message entirely wouldn't be desirable. */ elevel = IsUnderPostmaster ? DEBUG5 : LOG; } @@ -5324,22 +5324,22 @@ flatten_set_variable_args(const char *name, List *args) /* * Each list member may be a plain A_Const node, or an A_Const within a - * TypeCast; the latter case is supported only for ConstInterval - * arguments (for SET TIME ZONE). + * TypeCast; the latter case is supported only for ConstInterval arguments + * (for SET TIME ZONE). */ foreach(l, args) { - Node *arg = (Node *) lfirst(l); + Node *arg = (Node *) lfirst(l); char *val; TypeName *typename = NULL; - A_Const *con; + A_Const *con; if (l != list_head(args)) appendStringInfo(&buf, ", "); if (IsA(arg, TypeCast)) { - TypeCast *tc = (TypeCast *) arg; + TypeCast *tc = (TypeCast *) arg; arg = tc->arg; typename = tc->typename; @@ -5597,11 +5597,11 @@ init_custom_variable(const char *name, struct config_generic *gen; /* - * Only allow custom PGC_POSTMASTER variables to be created during - * shared library preload; any later than that, we can't ensure that - * the value doesn't change after startup. This is a fatal elog if it - * happens; just erroring out isn't safe because we don't know what - * the calling loadable module might already have hooked into. + * Only allow custom PGC_POSTMASTER variables to be created during shared + * library preload; any later than that, we can't ensure that the value + * doesn't change after startup. This is a fatal elog if it happens; just + * erroring out isn't safe because we don't know what the calling loadable + * module might already have hooked into. */ if (context == PGC_POSTMASTER && !process_shared_preload_libraries_in_progress) @@ -5632,7 +5632,7 @@ define_custom_variable(struct config_generic * variable) const char **nameAddr = &name; const char *value; struct config_string *pHolder; - GucContext phcontext; + GucContext phcontext; struct config_generic **res; /* @@ -5679,9 +5679,9 @@ define_custom_variable(struct config_generic * variable) *res = variable; /* - * Infer context for assignment based on source of existing value. - * We can't tell this with exact accuracy, but we can at least do - * something reasonable in typical cases. + * Infer context for assignment based on source of existing value. We + * can't tell this with exact accuracy, but we can at least do something + * reasonable in typical cases. */ switch (pHolder->gen.source) { @@ -5689,10 +5689,11 @@ define_custom_variable(struct config_generic * variable) case PGC_S_ENV_VAR: case PGC_S_FILE: case PGC_S_ARGV: + /* - * If we got past the check in init_custom_variable, we can - * safely assume that any existing value for a PGC_POSTMASTER - * variable was set in postmaster context. + * If we got past the check in init_custom_variable, we can safely + * assume that any existing value for a PGC_POSTMASTER variable + * was set in postmaster context. */ if (variable->context == PGC_POSTMASTER) phcontext = PGC_POSTMASTER; @@ -5852,7 +5853,7 @@ DefineCustomEnumVariable(const char *name, const char *long_desc, int *valueAddr, int bootValue, - const struct config_enum_entry *options, + const struct config_enum_entry * options, GucContext context, int flags, GucEnumAssignHook assign_hook, @@ -6165,13 +6166,13 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow) /* enumvals */ values[11] = NULL; - /* boot_val */ - snprintf(buffer, sizeof(buffer), "%d", lconf->boot_val); - values[12] = pstrdup(buffer); + /* boot_val */ + snprintf(buffer, sizeof(buffer), "%d", lconf->boot_val); + values[12] = pstrdup(buffer); - /* reset_val */ - snprintf(buffer, sizeof(buffer), "%d", lconf->reset_val); - values[13] = pstrdup(buffer); + /* reset_val */ + snprintf(buffer, sizeof(buffer), "%d", lconf->reset_val); + values[13] = pstrdup(buffer); } break; @@ -6190,19 +6191,19 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow) /* enumvals */ values[11] = NULL; - /* boot_val */ - snprintf(buffer, sizeof(buffer), "%g", lconf->boot_val); - values[12] = pstrdup(buffer); + /* boot_val */ + snprintf(buffer, sizeof(buffer), "%g", lconf->boot_val); + values[12] = pstrdup(buffer); - /* reset_val */ - snprintf(buffer, sizeof(buffer), "%g", lconf->reset_val); - values[13] = pstrdup(buffer); + /* reset_val */ + snprintf(buffer, sizeof(buffer), "%g", lconf->reset_val); + values[13] = pstrdup(buffer); } break; case PGC_STRING: { - struct config_string *lconf = (struct config_string *) conf; + struct config_string *lconf = (struct config_string *) conf; /* min_val */ values[9] = NULL; @@ -6213,15 +6214,15 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow) /* enumvals */ values[11] = NULL; - /* boot_val */ - if (lconf->boot_val == NULL) - values[12] = NULL; + /* boot_val */ + if (lconf->boot_val == NULL) + values[12] = NULL; else values[12] = pstrdup(lconf->boot_val); - /* reset_val */ - if (lconf->reset_val == NULL) - values[13] = NULL; + /* reset_val */ + if (lconf->reset_val == NULL) + values[13] = NULL; else values[13] = pstrdup(lconf->reset_val); } @@ -6229,7 +6230,7 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow) case PGC_ENUM: { - struct config_enum *lconf = (struct config_enum *) conf; + struct config_enum *lconf = (struct config_enum *) conf; /* min_val */ values[9] = NULL; @@ -6238,17 +6239,21 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow) values[10] = NULL; /* enumvals */ - /* NOTE! enumvals with double quotes in them are not supported! */ + + /* + * NOTE! enumvals with double quotes in them are not + * supported! + */ values[11] = config_enum_get_options((struct config_enum *) conf, "{\"", "\"}", "\",\""); - /* boot_val */ + /* boot_val */ values[12] = pstrdup(config_enum_lookup_by_value(lconf, - lconf->boot_val)); + lconf->boot_val)); - /* reset_val */ + /* reset_val */ values[13] = pstrdup(config_enum_lookup_by_value(lconf, - lconf->reset_val)); + lconf->reset_val)); } break; @@ -6267,18 +6272,18 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow) /* enumvals */ values[11] = NULL; - /* boot_val */ - values[12] = NULL; + /* boot_val */ + values[12] = NULL; - /* reset_val */ - values[13] = NULL; + /* reset_val */ + values[13] = NULL; } break; } - /* - * If the setting came from a config file, set the source location. - * For security reasons, we don't show source file/line number for + /* + * If the setting came from a config file, set the source location. For + * security reasons, we don't show source file/line number for * non-superusers. */ if (conf->source == PGC_S_FILE && superuser()) @@ -6379,10 +6384,10 @@ show_all_settings(PG_FUNCTION_ARGS) TEXTOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber) 12, "enumvals", TEXTARRAYOID, -1, 0); - TupleDescInitEntry(tupdesc, (AttrNumber) 13, "boot_val", - TEXTOID, -1, 0); - TupleDescInitEntry(tupdesc, (AttrNumber) 14, "reset_val", - TEXTOID, -1, 0); + TupleDescInitEntry(tupdesc, (AttrNumber) 13, "boot_val", + TEXTOID, -1, 0); + TupleDescInitEntry(tupdesc, (AttrNumber) 14, "reset_val", + TEXTOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber) 15, "sourcefile", TEXTOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber) 16, "sourceline", @@ -6476,10 +6481,10 @@ _ShowOption(struct config_generic * record, bool use_units) { /* * Use int64 arithmetic to avoid overflows in units - * conversion. If INT64_IS_BUSTED we might overflow + * conversion. If INT64_IS_BUSTED we might overflow * anyway and print bogus answers, but there are few - * enough such machines that it doesn't seem worth - * trying harder. + * enough such machines that it doesn't seem worth trying + * harder. */ int64 result = *conf->variable; const char *unit; @@ -6592,7 +6597,7 @@ _ShowOption(struct config_generic * record, bool use_units) { struct config_enum *conf = (struct config_enum *) record; - if(conf->show_hook) + if (conf->show_hook) val = (*conf->show_hook) (); else val = config_enum_lookup_by_value(conf, *conf->variable); @@ -6681,7 +6686,7 @@ is_newvalue_equal(struct config_generic * record, const char *newvalue) * variable source, integer */ static void -write_one_nondefault_variable(FILE *fp, struct config_generic *gconf) +write_one_nondefault_variable(FILE *fp, struct config_generic * gconf) { if (gconf->source == PGC_S_DEFAULT) return; @@ -6692,49 +6697,49 @@ write_one_nondefault_variable(FILE *fp, struct config_generic *gconf) switch (gconf->vartype) { case PGC_BOOL: - { - struct config_bool *conf = (struct config_bool *) gconf; + { + struct config_bool *conf = (struct config_bool *) gconf; - if (*conf->variable) - fprintf(fp, "true"); - else - fprintf(fp, "false"); - } - break; + if (*conf->variable) + fprintf(fp, "true"); + else + fprintf(fp, "false"); + } + break; case PGC_INT: - { - struct config_int *conf = (struct config_int *) gconf; + { + struct config_int *conf = (struct config_int *) gconf; - fprintf(fp, "%d", *conf->variable); - } - break; + fprintf(fp, "%d", *conf->variable); + } + break; case PGC_REAL: - { - struct config_real *conf = (struct config_real *) gconf; + { + struct config_real *conf = (struct config_real *) gconf; - /* Could lose precision here? */ - fprintf(fp, "%f", *conf->variable); - } - break; + /* Could lose precision here? */ + fprintf(fp, "%f", *conf->variable); + } + break; case PGC_STRING: - { - struct config_string *conf = (struct config_string *) gconf; + { + struct config_string *conf = (struct config_string *) gconf; - fprintf(fp, "%s", *conf->variable); - } - break; + fprintf(fp, "%s", *conf->variable); + } + break; case PGC_ENUM: - { - struct config_enum *conf = (struct config_enum *) gconf; - - fprintf(fp, "%s", - config_enum_lookup_by_value(conf, *conf->variable)); - } - break; + { + struct config_enum *conf = (struct config_enum *) gconf; + + fprintf(fp, "%s", + config_enum_lookup_by_value(conf, *conf->variable)); + } + break; } fputc(0, fp); @@ -7157,7 +7162,7 @@ assign_log_destination(const char *value, bool doit, GucSource source) list_free(elemlist); ereport(GUC_complaint_elevel(source), (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("invalid list syntax for parameter \"log_destination\""))); + errmsg("invalid list syntax for parameter \"log_destination\""))); return NULL; } @@ -7573,11 +7578,11 @@ assign_effective_io_concurrency(int newval, bool doit, GucSource source) * * drives | I/O requests * -------+---------------- - * 1 | 1 - * 2 | 2/1 + 2/2 = 3 - * 3 | 3/1 + 3/2 + 3/3 = 5 1/2 - * 4 | 4/1 + 4/2 + 4/3 + 4/4 = 8 1/3 - * n | n * H(n) + * 1 | 1 + * 2 | 2/1 + 2/2 = 3 + * 3 | 3/1 + 3/2 + 3/3 = 5 1/2 + * 4 | 4/1 + 4/2 + 4/3 + 4/4 = 8 1/3 + * n | n * H(n) * * This is called the "coupon collector problem" and H(n) is called the * harmonic series. This could be approximated by n * ln(n), but for @@ -7610,7 +7615,7 @@ assign_effective_io_concurrency(int newval, bool doit, GucSource source) return false; #else return true; -#endif /* USE_PREFETCH */ +#endif /* USE_PREFETCH */ } static const char * @@ -7624,9 +7629,9 @@ assign_pgstat_temp_directory(const char *newval, bool doit, GucSource source) canonicalize_path(canon_val); - tname = guc_malloc(ERROR, strlen(canon_val) + 12); /* /pgstat.tmp */ + tname = guc_malloc(ERROR, strlen(canon_val) + 12); /* /pgstat.tmp */ sprintf(tname, "%s/pgstat.tmp", canon_val); - fname = guc_malloc(ERROR, strlen(canon_val) + 13); /* /pgstat.stat */ + fname = guc_malloc(ERROR, strlen(canon_val) + 13); /* /pgstat.stat */ sprintf(fname, "%s/pgstat.stat", canon_val); if (pgstat_stat_tmpname) diff --git a/src/backend/utils/misc/help_config.c b/src/backend/utils/misc/help_config.c index d0311f31b6..d3311669a0 100644 --- a/src/backend/utils/misc/help_config.c +++ b/src/backend/utils/misc/help_config.c @@ -10,7 +10,7 @@ * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/misc/help_config.c,v 1.22 2009/01/01 17:23:53 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/misc/help_config.c,v 1.23 2009/06/11 14:49:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -124,7 +124,7 @@ printMixedStruct(mixedStruct *structToPrint) case PGC_ENUM: printf("ENUM\t%s\t\t\t", config_enum_lookup_by_value(&structToPrint->_enum, - structToPrint->_enum.boot_val)); + structToPrint->_enum.boot_val)); break; default: diff --git a/src/backend/utils/mmgr/aset.c b/src/backend/utils/mmgr/aset.c index 5faf2ff760..f11e15d57c 100644 --- a/src/backend/utils/mmgr/aset.c +++ b/src/backend/utils/mmgr/aset.c @@ -11,7 +11,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/mmgr/aset.c,v 1.78 2009/01/01 17:23:53 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mmgr/aset.c,v 1.79 2009/06/11 14:49:06 momjian Exp $ * * NOTE: * This is a new (Feb. 05, 1999) implementation of the allocation set @@ -305,8 +305,7 @@ randomize_mem(char *ptr, size_t size) } save_ctr = ctr; } - -#endif /* RANDOMIZE_ALLOCATED_MEMORY */ +#endif /* RANDOMIZE_ALLOCATED_MEMORY */ /* diff --git a/src/backend/utils/resowner/resowner.c b/src/backend/utils/resowner/resowner.c index cd96f80d44..4ef47ca560 100644 --- a/src/backend/utils/resowner/resowner.c +++ b/src/backend/utils/resowner/resowner.c @@ -14,7 +14,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/resowner/resowner.c,v 1.31 2009/01/01 17:23:53 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/resowner/resowner.c,v 1.32 2009/06/11 14:49:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -312,8 +312,8 @@ ResourceOwnerReleaseInternal(ResourceOwner owner, while (owner->nsnapshots > 0) { if (isCommit) - PrintSnapshotLeakWarning(owner->snapshots[owner->nsnapshots -1]); - UnregisterSnapshot(owner->snapshots[owner->nsnapshots -1]); + PrintSnapshotLeakWarning(owner->snapshots[owner->nsnapshots - 1]); + UnregisterSnapshot(owner->snapshots[owner->nsnapshots - 1]); } /* Clean up index scans too */ @@ -1005,7 +1005,7 @@ void ResourceOwnerForgetSnapshot(ResourceOwner owner, Snapshot snapshot) { Snapshot *snapshots = owner->snapshots; - int ns1 = owner->nsnapshots -1; + int ns1 = owner->nsnapshots - 1; int i; for (i = ns1; i >= 0; i--) diff --git a/src/backend/utils/sort/tuplesort.c b/src/backend/utils/sort/tuplesort.c index 92c55219d3..6d07296d59 100644 --- a/src/backend/utils/sort/tuplesort.c +++ b/src/backend/utils/sort/tuplesort.c @@ -91,7 +91,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/sort/tuplesort.c,v 1.90 2009/03/11 23:19:25 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/sort/tuplesort.c,v 1.91 2009/06/11 14:49:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -451,9 +451,9 @@ static void readtup_heap(Tuplesortstate *state, SortTuple *stup, int tapenum, unsigned int len); static void reversedirection_heap(Tuplesortstate *state); static int comparetup_index_btree(const SortTuple *a, const SortTuple *b, - Tuplesortstate *state); + Tuplesortstate *state); static int comparetup_index_hash(const SortTuple *a, const SortTuple *b, - Tuplesortstate *state); + Tuplesortstate *state); static void copytup_index(Tuplesortstate *state, SortTuple *stup, void *tup); static void writetup_index(Tuplesortstate *state, int tapenum, SortTuple *stup); @@ -578,7 +578,7 @@ tuplesort_begin_heap(TupleDesc tupDesc, state->nKeys = nkeys; TRACE_POSTGRESQL_SORT_START(HEAP_SORT, - false, /* no unique check */ + false, /* no unique check */ nkeys, workMem, randomAccess); @@ -681,7 +681,7 @@ tuplesort_begin_index_hash(Relation indexRel, #ifdef TRACE_SORT if (trace_sort) elog(LOG, - "begin index sort: hash_mask = 0x%x, workMem = %d, randomAccess = %c", + "begin index sort: hash_mask = 0x%x, workMem = %d, randomAccess = %c", hash_mask, workMem, randomAccess ? 't' : 'f'); #endif @@ -727,7 +727,7 @@ tuplesort_begin_datum(Oid datumType, state->nKeys = 1; /* always a one-column sort */ TRACE_POSTGRESQL_SORT_START(DATUM_SORT, - false, /* no unique check */ + false, /* no unique check */ 1, workMem, randomAccess); @@ -844,8 +844,8 @@ tuplesort_end(Tuplesortstate *state) #else /* - * If you disabled TRACE_SORT, you can still probe sort__done, but - * you ain't getting space-used stats. + * If you disabled TRACE_SORT, you can still probe sort__done, but you + * ain't getting space-used stats. */ TRACE_POSTGRESQL_SORT_DONE(state->tapeset != NULL, 0L); #endif @@ -2653,9 +2653,11 @@ static void writetup_heap(Tuplesortstate *state, int tapenum, SortTuple *stup) { MinimalTuple tuple = (MinimalTuple) stup->tuple; + /* the part of the MinimalTuple we'll write: */ char *tupbody = (char *) tuple + MINIMAL_TUPLE_DATA_OFFSET; unsigned int tupbodylen = tuple->t_len - MINIMAL_TUPLE_DATA_OFFSET; + /* total on-disk footprint: */ unsigned int tuplen = tupbodylen + sizeof(int); @@ -2842,8 +2844,8 @@ comparetup_index_hash(const SortTuple *a, const SortTuple *b, CHECK_FOR_INTERRUPTS(); /* - * Fetch hash keys and mask off bits we don't want to sort by. - * We know that the first column of the index tuple is the hash key. + * Fetch hash keys and mask off bits we don't want to sort by. We know + * that the first column of the index tuple is the hash key. */ Assert(!a->isnull1); hash1 = DatumGetUInt32(a->datum1) & state->hash_mask; diff --git a/src/backend/utils/sort/tuplestore.c b/src/backend/utils/sort/tuplestore.c index 10afc4851b..5b900b7a5e 100644 --- a/src/backend/utils/sort/tuplestore.c +++ b/src/backend/utils/sort/tuplestore.c @@ -29,7 +29,7 @@ * When the caller requests backward-scan capability, we write the temp file * in a format that allows either forward or backward scan. Otherwise, only * forward scan is allowed. A request for backward scan must be made before - * putting any tuples into the tuplestore. Rewind is normally allowed but + * putting any tuples into the tuplestore. Rewind is normally allowed but * can be turned off via tuplestore_set_eflags; turning off rewind for all * read pointers enables truncation of the tuplestore at the oldest read point * for minimal memory usage. (The caller must explicitly call tuplestore_trim @@ -47,7 +47,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/sort/tuplestore.c,v 1.47 2009/03/27 18:30:21 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/sort/tuplestore.c,v 1.48 2009/06/11 14:49:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -81,7 +81,7 @@ typedef enum * * Special case: if eof_reached is true, then the pointer's read position is * implicitly equal to the write position, and current/file/offset aren't - * maintained. This way we need not update all the read pointers each time + * maintained. This way we need not update all the read pointers each time * we write. */ typedef struct @@ -161,7 +161,7 @@ struct Tuplestorestate int readptrsize; /* allocated length of readptrs array */ int writepos_file; /* file# (valid if READFILE state) */ - off_t writepos_offset; /* offset (valid if READFILE state) */ + off_t writepos_offset; /* offset (valid if READFILE state) */ }; #define COPYTUP(state,tup) ((*(state)->copytup) (state, tup)) @@ -363,7 +363,7 @@ tuplestore_alloc_read_pointer(Tuplestorestate *state, int eflags) /* Make room for another read pointer if needed */ if (state->readptrcount >= state->readptrsize) { - int newcnt = state->readptrsize * 2; + int newcnt = state->readptrsize * 2; state->readptrs = (TSReadPointer *) repalloc(state->readptrs, newcnt * sizeof(TSReadPointer)); @@ -460,9 +460,10 @@ tuplestore_select_read_pointer(Tuplestorestate *state, int ptr) /* no work */ break; case TSS_READFILE: + /* - * First, save the current read position in the pointer about - * to become inactive. + * First, save the current read position in the pointer about to + * become inactive. */ if (!oldptr->eof_reached) BufFileTell(state->myfile, @@ -635,10 +636,11 @@ tuplestore_puttuple_common(Tuplestorestate *state, void *tuple) */ PrepareTempTablespaces(); state->myfile = BufFileCreateTemp(state->interXact); + /* - * Freeze the decision about whether trailing length words - * will be used. We can't change this choice once data is on - * tape, even though callers might drop the requirement. + * Freeze the decision about whether trailing length words will be + * used. We can't change this choice once data is on tape, even + * though callers might drop the requirement. */ state->backward = (state->eflags & EXEC_FLAG_BACKWARD) != 0; state->status = TSS_WRITEFILE; @@ -647,9 +649,9 @@ tuplestore_puttuple_common(Tuplestorestate *state, void *tuple) case TSS_WRITEFILE: /* - * Update read pointers as needed; see API spec above. - * Note: BufFileTell is quite cheap, so not worth trying - * to avoid multiple calls. + * Update read pointers as needed; see API spec above. Note: + * BufFileTell is quite cheap, so not worth trying to avoid + * multiple calls. */ readptr = state->readptrs; for (i = 0; i < state->readptrcount; readptr++, i++) @@ -754,7 +756,7 @@ tuplestore_gettuple(Tuplestorestate *state, bool forward, Assert(!state->truncated); return NULL; } - readptr->current--; /* last returned tuple */ + readptr->current--; /* last returned tuple */ } if (readptr->current <= 0) { @@ -996,7 +998,7 @@ tuplestore_rescan(Tuplestorestate *state) } /* - * tuplestore_copy_read_pointer - copy a read pointer's state to another + * tuplestore_copy_read_pointer - copy a read pointer's state to another */ void tuplestore_copy_read_pointer(Tuplestorestate *state, @@ -1015,8 +1017,8 @@ tuplestore_copy_read_pointer(Tuplestorestate *state, if (dptr->eflags != sptr->eflags) { /* Possible change of overall eflags, so copy and then recompute */ - int eflags; - int i; + int eflags; + int i; *dptr = *sptr; eflags = state->readptrs[0].eflags; @@ -1034,6 +1036,7 @@ tuplestore_copy_read_pointer(Tuplestorestate *state, /* no work */ break; case TSS_READFILE: + /* * This case is a bit tricky since the active read pointer's * position corresponds to the seek point, not what is in its @@ -1093,7 +1096,8 @@ tuplestore_trim(Tuplestorestate *state) int i; /* - * Truncation is disallowed if any read pointer requires rewind capability. + * Truncation is disallowed if any read pointer requires rewind + * capability. */ if (state->eflags & EXEC_FLAG_REWIND) return; @@ -1115,14 +1119,13 @@ tuplestore_trim(Tuplestorestate *state) /* * Note: you might think we could remove all the tuples before the oldest - * "current", since that one is the next to be returned. However, - * since tuplestore_gettuple returns a direct pointer to our - * internal copy of the tuple, it's likely that the caller has - * still got the tuple just before "current" referenced in a slot. - * So we keep one extra tuple before the oldest "current". (Strictly - * speaking, we could require such callers to use the "copy" flag to - * tuplestore_gettupleslot, but for efficiency we allow this one case - * to not use "copy".) + * "current", since that one is the next to be returned. However, since + * tuplestore_gettuple returns a direct pointer to our internal copy of + * the tuple, it's likely that the caller has still got the tuple just + * before "current" referenced in a slot. So we keep one extra tuple + * before the oldest "current". (Strictly speaking, we could require such + * callers to use the "copy" flag to tuplestore_gettupleslot, but for + * efficiency we allow this one case to not use "copy".) */ nremove = oldest - 1; if (nremove <= 0) @@ -1222,9 +1225,11 @@ static void writetup_heap(Tuplestorestate *state, void *tup) { MinimalTuple tuple = (MinimalTuple) tup; + /* the part of the MinimalTuple we'll write: */ char *tupbody = (char *) tuple + MINIMAL_TUPLE_DATA_OFFSET; unsigned int tupbodylen = tuple->t_len - MINIMAL_TUPLE_DATA_OFFSET; + /* total on-disk footprint: */ unsigned int tuplen = tupbodylen + sizeof(int); @@ -1255,7 +1260,7 @@ readtup_heap(Tuplestorestate *state, unsigned int len) /* read in the tuple proper */ tuple->t_len = tuplen; if (BufFileRead(state->myfile, (void *) tupbody, - tupbodylen) != (size_t) tupbodylen) + tupbodylen) != (size_t) tupbodylen) elog(ERROR, "unexpected end of data"); if (state->backward) /* need trailing length word? */ if (BufFileRead(state->myfile, (void *) &tuplen, diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c index d5fa1355ee..73d597d7b3 100644 --- a/src/backend/utils/time/snapmgr.c +++ b/src/backend/utils/time/snapmgr.c @@ -8,9 +8,9 @@ * (tracked by separate refcounts on each snapshot), its memory can be freed. * * These arrangements let us reset MyProc->xmin when there are no snapshots - * referenced by this transaction. (One possible improvement would be to be + * referenced by this transaction. (One possible improvement would be to be * able to advance Xmin when the snapshot with the earliest Xmin is no longer - * referenced. That's a bit harder though, it requires more locking, and + * referenced. That's a bit harder though, it requires more locking, and * anyway it should be rather uncommon to keep snapshots referenced for too * long.) * @@ -19,7 +19,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/time/snapmgr.c,v 1.9 2009/01/01 17:23:53 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/time/snapmgr.c,v 1.10 2009/06/11 14:49:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -50,8 +50,8 @@ static SnapshotData CurrentSnapshotData = {HeapTupleSatisfiesMVCC}; static SnapshotData SecondarySnapshotData = {HeapTupleSatisfiesMVCC}; /* Pointers to valid snapshots */ -static Snapshot CurrentSnapshot = NULL; -static Snapshot SecondarySnapshot = NULL; +static Snapshot CurrentSnapshot = NULL; +static Snapshot SecondarySnapshot = NULL; /* * These are updated by GetSnapshotData. We initialize them this way @@ -59,7 +59,7 @@ static Snapshot SecondarySnapshot = NULL; * mode, we don't want it to say that BootstrapTransactionId is in progress. * * RecentGlobalXmin is initialized to InvalidTransactionId, to ensure that no - * one tries to use a stale value. Readers should ensure that it has been set + * one tries to use a stale value. Readers should ensure that it has been set * to something else before using it. */ TransactionId TransactionXmin = FirstNormalTransactionId; @@ -82,7 +82,7 @@ typedef struct ActiveSnapshotElt } ActiveSnapshotElt; /* Top of the stack of active snapshots */ -static ActiveSnapshotElt *ActiveSnapshot = NULL; +static ActiveSnapshotElt *ActiveSnapshot = NULL; /* * How many snapshots is resowner.c tracking for us? @@ -91,22 +91,22 @@ static ActiveSnapshotElt *ActiveSnapshot = NULL; * smarter about advancing our MyProc->xmin we will need to be more * sophisticated about this, perhaps keeping our own list of snapshots. */ -static int RegisteredSnapshots = 0; +static int RegisteredSnapshots = 0; /* first GetTransactionSnapshot call in a transaction? */ -bool FirstSnapshotSet = false; +bool FirstSnapshotSet = false; /* * Remembers whether this transaction registered a serializable snapshot at * start. We cannot trust FirstSnapshotSet in combination with * IsXactIsoLevelSerializable, because GUC may be reset before us. */ -static bool registered_serializable = false; +static bool registered_serializable = false; static Snapshot CopySnapshot(Snapshot snapshot); static void FreeSnapshot(Snapshot snapshot); -static void SnapshotResetXmin(void); +static void SnapshotResetXmin(void); /* @@ -130,14 +130,14 @@ GetTransactionSnapshot(void) FirstSnapshotSet = true; /* - * In serializable mode, the first snapshot must live until end of xact - * regardless of what the caller does with it, so we must register it - * internally here and unregister it at end of xact. + * In serializable mode, the first snapshot must live until end of + * xact regardless of what the caller does with it, so we must + * register it internally here and unregister it at end of xact. */ if (IsXactIsoLevelSerializable) { CurrentSnapshot = RegisterSnapshotOnOwner(CurrentSnapshot, - TopTransactionResourceOwner); + TopTransactionResourceOwner); registered_serializable = true; } @@ -171,7 +171,7 @@ GetLatestSnapshot(void) /* * SnapshotSetCommandId - * Propagate CommandCounterIncrement into the static snapshots, if set + * Propagate CommandCounterIncrement into the static snapshots, if set */ void SnapshotSetCommandId(CommandId curcid) @@ -253,7 +253,7 @@ FreeSnapshot(Snapshot snapshot) /* * PushActiveSnapshot - * Set the given snapshot as the current active snapshot + * Set the given snapshot as the current active snapshot * * If this is the first use of this snapshot, create a new long-lived copy with * active refcount=1. Otherwise, only increment the refcount. @@ -261,7 +261,7 @@ FreeSnapshot(Snapshot snapshot) void PushActiveSnapshot(Snapshot snap) { - ActiveSnapshotElt *newactive; + ActiveSnapshotElt *newactive; Assert(snap != InvalidSnapshot); @@ -278,7 +278,7 @@ PushActiveSnapshot(Snapshot snap) /* * PushUpdatedSnapshot - * As above, except we set the snapshot's CID to the current CID. + * As above, except we set the snapshot's CID to the current CID. */ void PushUpdatedSnapshot(Snapshot snapshot) @@ -304,7 +304,7 @@ PushUpdatedSnapshot(Snapshot snapshot) void PopActiveSnapshot(void) { - ActiveSnapshotElt *newstack; + ActiveSnapshotElt *newstack; newstack = ActiveSnapshot->as_next; @@ -324,7 +324,7 @@ PopActiveSnapshot(void) /* * GetActiveSnapshot - * Return the topmost snapshot in the Active stack. + * Return the topmost snapshot in the Active stack. */ Snapshot GetActiveSnapshot(void) @@ -336,7 +336,7 @@ GetActiveSnapshot(void) /* * ActiveSnapshotSet - * Return whether there is at least one snapshot in the Active stack + * Return whether there is at least one snapshot in the Active stack */ bool ActiveSnapshotSet(void) @@ -346,7 +346,7 @@ ActiveSnapshotSet(void) /* * RegisterSnapshot - * Register a snapshot as being in use by the current resource owner + * Register a snapshot as being in use by the current resource owner * * If InvalidSnapshot is passed, it is not registered. */ @@ -361,12 +361,12 @@ RegisterSnapshot(Snapshot snapshot) /* * RegisterSnapshotOnOwner - * As above, but use the specified resource owner + * As above, but use the specified resource owner */ Snapshot RegisterSnapshotOnOwner(Snapshot snapshot, ResourceOwner owner) { - Snapshot snap; + Snapshot snap; if (snapshot == InvalidSnapshot) return InvalidSnapshot; @@ -402,7 +402,7 @@ UnregisterSnapshot(Snapshot snapshot) /* * UnregisterSnapshotFromOwner - * As above, but use the specified resource owner + * As above, but use the specified resource owner */ void UnregisterSnapshotFromOwner(Snapshot snapshot, ResourceOwner owner) @@ -442,7 +442,7 @@ SnapshotResetXmin(void) void AtSubCommit_Snapshot(int level) { - ActiveSnapshotElt *active; + ActiveSnapshotElt *active; /* * Relabel the active snapshots set in this subtransaction as though they @@ -458,7 +458,7 @@ AtSubCommit_Snapshot(int level) /* * AtSubAbort_Snapshot - * Clean up snapshots after a subtransaction abort + * Clean up snapshots after a subtransaction abort */ void AtSubAbort_Snapshot(int level) @@ -466,7 +466,7 @@ AtSubAbort_Snapshot(int level) /* Forget the active snapshots set by this subtransaction */ while (ActiveSnapshot && ActiveSnapshot->as_level >= level) { - ActiveSnapshotElt *next; + ActiveSnapshotElt *next; next = ActiveSnapshot->as_next; @@ -500,8 +500,8 @@ void AtEarlyCommit_Snapshot(void) { /* - * On a serializable transaction we must unregister our private refcount to - * the serializable snapshot. + * On a serializable transaction we must unregister our private refcount + * to the serializable snapshot. */ if (registered_serializable) UnregisterSnapshotFromOwner(CurrentSnapshot, @@ -512,7 +512,7 @@ AtEarlyCommit_Snapshot(void) /* * AtEOXact_Snapshot - * Snapshot manager's cleanup function for end of transaction + * Snapshot manager's cleanup function for end of transaction */ void AtEOXact_Snapshot(bool isCommit) @@ -520,7 +520,7 @@ AtEOXact_Snapshot(bool isCommit) /* On commit, complain about leftover snapshots */ if (isCommit) { - ActiveSnapshotElt *active; + ActiveSnapshotElt *active; if (RegisteredSnapshots != 0) elog(WARNING, "%d registered snapshots seem to remain after cleanup", diff --git a/src/backend/utils/time/tqual.c b/src/backend/utils/time/tqual.c index 3f5f7de163..6d8f86acc9 100644 --- a/src/backend/utils/time/tqual.c +++ b/src/backend/utils/time/tqual.c @@ -28,29 +28,29 @@ * * Summary of visibility functions: * - * HeapTupleSatisfiesMVCC() - * visible to supplied snapshot, excludes current command - * HeapTupleSatisfiesNow() - * visible to instant snapshot, excludes current command - * HeapTupleSatisfiesUpdate() - * like HeapTupleSatisfiesNow(), but with user-supplied command - * counter and more complex result - * HeapTupleSatisfiesSelf() - * visible to instant snapshot and current command - * HeapTupleSatisfiesDirty() - * like HeapTupleSatisfiesSelf(), but includes open transactions - * HeapTupleSatisfiesVacuum() - * visible to any running transaction, used by VACUUM - * HeapTupleSatisfiesToast() - * visible unless part of interrupted vacuum, used for TOAST - * HeapTupleSatisfiesAny() - * all tuples are visible + * HeapTupleSatisfiesMVCC() + * visible to supplied snapshot, excludes current command + * HeapTupleSatisfiesNow() + * visible to instant snapshot, excludes current command + * HeapTupleSatisfiesUpdate() + * like HeapTupleSatisfiesNow(), but with user-supplied command + * counter and more complex result + * HeapTupleSatisfiesSelf() + * visible to instant snapshot and current command + * HeapTupleSatisfiesDirty() + * like HeapTupleSatisfiesSelf(), but includes open transactions + * HeapTupleSatisfiesVacuum() + * visible to any running transaction, used by VACUUM + * HeapTupleSatisfiesToast() + * visible unless part of interrupted vacuum, used for TOAST + * HeapTupleSatisfiesAny() + * all tuples are visible * * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/time/tqual.c,v 1.112 2009/03/09 13:08:05 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/time/tqual.c,v 1.113 2009/06/11 14:49:06 momjian Exp $ * *------------------------------------------------------------------------- */ |