diff options
Diffstat (limited to 'src/backend/utils')
45 files changed, 876 insertions, 850 deletions
diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c index 8457fc5e480..79ca6c13724 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.156 2010/02/14 18:42:16 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/acl.c,v 1.157 2010/02/26 02:01:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -78,7 +78,7 @@ static Acl *allocacl(int n); static void check_acl(const Acl *acl); static const char *aclparse(const char *s, AclItem *aip); static bool aclitem_match(const AclItem *a1, const AclItem *a2); -static int aclitemComparator(const void *arg1, const void *arg2); +static int aclitemComparator(const void *arg1, const void *arg2); static void check_circularity(const Acl *old_acl, const AclItem *mod_aip, Oid ownerId); static Acl *recursive_revoke(Acl *acl, Oid grantee, AclMode revoke_privs, @@ -470,7 +470,7 @@ aclmerge(const Acl *left_acl, const Acl *right_acl, Oid ownerId) for (i = 0; i < num; i++, aip++) { - Acl *tmp_acl; + Acl *tmp_acl; tmp_acl = aclupdate(result_acl, aip, ACL_MODECHG_ADD, ownerId, DROP_RESTRICT); @@ -1669,17 +1669,17 @@ convert_aclright_to_string(int aclright) * returns the table * * {{ OID(joe), 0::OID, 'SELECT', false }, - * { OID(joe), OID(foo), 'INSERT', true }, - * { OID(joe), OID(foo), 'UPDATE', false }} + * { OID(joe), OID(foo), 'INSERT', true }, + * { OID(joe), OID(foo), 'UPDATE', false }} *---------- */ Datum aclexplode(PG_FUNCTION_ARGS) { Acl *acl = PG_GETARG_ACL_P(0); - FuncCallContext *funcctx; + FuncCallContext *funcctx; int *idx; - AclItem *aidat; + AclItem *aidat; if (SRF_IS_FIRSTCALL()) { @@ -1692,8 +1692,8 @@ aclexplode(PG_FUNCTION_ARGS) oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); /* - * build tupdesc for result tuples (matches out parameters in - * pg_proc entry) + * build tupdesc for result tuples (matches out parameters in pg_proc + * entry) */ tupdesc = CreateTemplateTupleDesc(4, false); TupleDescInitEntry(tupdesc, (AttrNumber) 1, "grantor", @@ -1731,7 +1731,7 @@ aclexplode(PG_FUNCTION_ARGS) { idx[1] = 0; idx[0]++; - if (idx[0] >= ACL_NUM(acl)) /* done */ + if (idx[0] >= ACL_NUM(acl)) /* done */ break; } aidata = &aidat[idx[0]]; @@ -2003,8 +2003,8 @@ has_sequence_privilege_name_name(PG_FUNCTION_ARGS) if (get_rel_relkind(sequenceoid) != RELKIND_SEQUENCE) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("\"%s\" is not a sequence", - text_to_cstring(sequencename)))); + errmsg("\"%s\" is not a sequence", + text_to_cstring(sequencename)))); aclresult = pg_class_aclcheck(sequenceoid, roleid, mode); @@ -2033,8 +2033,8 @@ has_sequence_privilege_name(PG_FUNCTION_ARGS) if (get_rel_relkind(sequenceoid) != RELKIND_SEQUENCE) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("\"%s\" is not a sequence", - text_to_cstring(sequencename)))); + errmsg("\"%s\" is not a sequence", + text_to_cstring(sequencename)))); aclresult = pg_class_aclcheck(sequenceoid, roleid, mode); @@ -2065,8 +2065,8 @@ has_sequence_privilege_name_id(PG_FUNCTION_ARGS) else if (relkind != RELKIND_SEQUENCE) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("\"%s\" is not a sequence", - get_rel_name(sequenceoid)))); + errmsg("\"%s\" is not a sequence", + get_rel_name(sequenceoid)))); aclresult = pg_class_aclcheck(sequenceoid, roleid, mode); @@ -2097,8 +2097,8 @@ has_sequence_privilege_id(PG_FUNCTION_ARGS) else if (relkind != RELKIND_SEQUENCE) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("\"%s\" is not a sequence", - get_rel_name(sequenceoid)))); + errmsg("\"%s\" is not a sequence", + get_rel_name(sequenceoid)))); aclresult = pg_class_aclcheck(sequenceoid, roleid, mode); @@ -2125,8 +2125,8 @@ has_sequence_privilege_id_name(PG_FUNCTION_ARGS) if (get_rel_relkind(sequenceoid) != RELKIND_SEQUENCE) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("\"%s\" is not a sequence", - text_to_cstring(sequencename)))); + errmsg("\"%s\" is not a sequence", + text_to_cstring(sequencename)))); aclresult = pg_class_aclcheck(sequenceoid, roleid, mode); @@ -2155,8 +2155,8 @@ has_sequence_privilege_id_id(PG_FUNCTION_ARGS) else if (relkind != RELKIND_SEQUENCE) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("\"%s\" is not a sequence", - get_rel_name(sequenceoid)))); + errmsg("\"%s\" is not a sequence", + get_rel_name(sequenceoid)))); aclresult = pg_class_aclcheck(sequenceoid, roleid, mode); @@ -2171,10 +2171,10 @@ static AclMode convert_sequence_priv_string(text *priv_type_text) { static const priv_map sequence_priv_map[] = { - { "USAGE", ACL_USAGE }, - { "SELECT", ACL_SELECT }, - { "UPDATE", ACL_UPDATE }, - { NULL, 0 } + {"USAGE", ACL_USAGE}, + {"SELECT", ACL_SELECT}, + {"UPDATE", ACL_UPDATE}, + {NULL, 0} }; return convert_any_priv_string(priv_type_text, sequence_priv_map); diff --git a/src/backend/utils/adt/array_userfuncs.c b/src/backend/utils/adt/array_userfuncs.c index 7d4ea11bf8b..bca0b894422 100644 --- a/src/backend/utils/adt/array_userfuncs.c +++ b/src/backend/utils/adt/array_userfuncs.c @@ -6,7 +6,7 @@ * Copyright (c) 2003-2010, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/array_userfuncs.c,v 1.34 2010/02/08 20:39:51 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/array_userfuncs.c,v 1.35 2010/02/26 02:01:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -531,9 +531,9 @@ array_agg_finalfn(PG_FUNCTION_ARGS) /* * Make the result. We cannot release the ArrayBuildState because - * sometimes aggregate final functions are re-executed. Rather, it - * is nodeAgg.c's responsibility to reset the aggcontext when it's - * safe to do so. + * sometimes aggregate final functions are re-executed. Rather, it is + * nodeAgg.c's responsibility to reset the aggcontext when it's safe to do + * so. */ result = makeMdArrayResult(state, 1, dims, lbs, CurrentMemoryContext, diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c index aa110ce58fb..533b77c1cd0 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.163 2010/01/02 16:57:53 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.164 2010/02/26 02:01:07 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -328,10 +328,11 @@ array_in(PG_FUNCTION_ARGS) SET_VARSIZE(retval, nbytes); retval->ndim = ndim; retval->dataoffset = dataoffset; + /* - * This comes from the array's pg_type.typelem (which points to the - * base data type's pg_type.oid) and stores system oids in user tables. - * This oid must be preserved by binary upgrades. + * This comes from the array's pg_type.typelem (which points to the base + * data type's pg_type.oid) and stores system oids in user tables. This + * oid must be preserved by binary upgrades. */ retval->elemtype = element_type; memcpy(ARR_DIMS(retval), dim, ndim * sizeof(int)); @@ -1212,7 +1213,7 @@ array_recv(PG_FUNCTION_ARGS) for (i = 0; i < ndim; i++) { - int ub; + int ub; dim[i] = pq_getmsgint(buf, 4); lBound[i] = pq_getmsgint(buf, 4); @@ -4194,12 +4195,12 @@ accumArrayResult(ArrayBuildState *astate, } /* - * Ensure pass-by-ref stuff is copied into mcontext; and detoast it too - * if it's varlena. (You might think that detoasting is not needed here + * Ensure pass-by-ref stuff is copied into mcontext; and detoast it too if + * it's varlena. (You might think that detoasting is not needed here * because construct_md_array can detoast the array elements later. * However, we must not let construct_md_array modify the ArrayBuildState - * because that would mean array_agg_finalfn damages its input, which - * is verboten. Also, this way frequently saves one copying step.) + * because that would mean array_agg_finalfn damages its input, which is + * verboten. Also, this way frequently saves one copying step.) */ if (!disnull && !astate->typbyval) { diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c index 7985a644f3d..b5dfe08c9bb 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.151 2010/02/18 04:31:16 itagaki Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.152 2010/02/26 02:01:07 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -203,7 +203,7 @@ Datum date_recv(PG_FUNCTION_ARGS) { StringInfo buf = (StringInfo) PG_GETARG_POINTER(0); - DateADT result; + DateADT result; result = (DateADT) pq_getmsgint(buf, sizeof(DateADT)); diff --git a/src/backend/utils/adt/dbsize.c b/src/backend/utils/adt/dbsize.c index 2bb2427c060..8b5def4d15a 100644 --- a/src/backend/utils/adt/dbsize.c +++ b/src/backend/utils/adt/dbsize.c @@ -5,7 +5,7 @@ * Copyright (c) 2002-2010, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/dbsize.c,v 1.30 2010/02/14 18:42:16 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/dbsize.c,v 1.31 2010/02/26 02:01:07 momjian Exp $ * */ @@ -185,7 +185,7 @@ calculate_tablespace_size(Oid tblspcOid) snprintf(tblspcPath, MAXPGPATH, "global"); else snprintf(tblspcPath, MAXPGPATH, "pg_tblspc/%u/%s", tblspcOid, - TABLESPACE_VERSION_DIRECTORY); + TABLESPACE_VERSION_DIRECTORY); dirdesc = AllocateDir(tblspcPath); @@ -318,10 +318,10 @@ pg_relation_size(PG_FUNCTION_ARGS) static int64 calculate_toast_table_size(Oid toastrelid) { - int64 size = 0; - Relation toastRel; - Relation toastIdxRel; - ForkNumber forkNum; + int64 size = 0; + Relation toastRel; + Relation toastIdxRel; + ForkNumber forkNum; toastRel = relation_open(toastrelid, AccessShareLock); @@ -351,9 +351,9 @@ calculate_toast_table_size(Oid toastrelid) static int64 calculate_table_size(Oid relOid) { - int64 size = 0; - Relation rel; - ForkNumber forkNum; + int64 size = 0; + Relation rel; + ForkNumber forkNum; rel = relation_open(relOid, AccessShareLock); @@ -382,8 +382,8 @@ calculate_table_size(Oid relOid) static int64 calculate_indexes_size(Oid relOid) { - int64 size = 0; - Relation rel; + int64 size = 0; + Relation rel; rel = relation_open(relOid, AccessShareLock); @@ -392,14 +392,14 @@ calculate_indexes_size(Oid relOid) */ if (rel->rd_rel->relhasindex) { - List *index_oids = RelationGetIndexList(rel); - ListCell *cell; + List *index_oids = RelationGetIndexList(rel); + ListCell *cell; foreach(cell, index_oids) { Oid idxOid = lfirst_oid(cell); Relation idxRel; - ForkNumber forkNum; + ForkNumber forkNum; idxRel = relation_open(idxOid, AccessShareLock); @@ -443,9 +443,8 @@ calculate_total_relation_size(Oid Relid) int64 size; /* - * Aggregate the table size, this includes size of - * the heap, toast and toast index with free space - * and visibility map + * Aggregate the table size, this includes size of the heap, toast and + * toast index with free space and visibility map */ size = calculate_table_size(Relid); @@ -515,7 +514,7 @@ pg_size_pretty(PG_FUNCTION_ARGS) * This is expected to be used in queries like * SELECT pg_relation_filenode(oid) FROM pg_class; * That leads to a couple of choices. We work from the pg_class row alone - * rather than actually opening each relation, for efficiency. We don't + * rather than actually opening each relation, for efficiency. We don't * fail if we can't find the relation --- some rows might be visible in * the query's MVCC snapshot but already dead according to SnapshotNow. * (Note: we could avoid using the catcache, but there's little point @@ -545,7 +544,7 @@ pg_relation_filenode(PG_FUNCTION_ARGS) /* okay, these have storage */ if (relform->relfilenode) result = relform->relfilenode; - else /* Consult the relation mapper */ + else /* Consult the relation mapper */ result = RelationMapOidToFilenode(relid, relform->relisshared); break; @@ -602,9 +601,9 @@ pg_relation_filepath(PG_FUNCTION_ARGS) rnode.dbNode = MyDatabaseId; if (relform->relfilenode) rnode.relNode = relform->relfilenode; - else /* Consult the relation mapper */ + else /* Consult the relation mapper */ rnode.relNode = RelationMapOidToFilenode(relid, - relform->relisshared); + relform->relisshared); break; default: diff --git a/src/backend/utils/adt/domains.c b/src/backend/utils/adt/domains.c index 8bbe092ee99..97b047686f9 100644 --- a/src/backend/utils/adt/domains.c +++ b/src/backend/utils/adt/domains.c @@ -25,7 +25,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/domains.c,v 1.10 2010/01/02 16:57:53 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/domains.c,v 1.11 2010/02/26 02:01:07 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -305,7 +305,7 @@ domain_recv(PG_FUNCTION_ARGS) /* * domain_check - check that a datum satisfies the constraints of a - * domain. extra and mcxt can be passed if they are available from, + * domain. extra and mcxt can be passed if they are available from, * say, a FmgrInfo structure, or they can be NULL, in which case the * setup is repeated for each call. */ diff --git a/src/backend/utils/adt/enum.c b/src/backend/utils/adt/enum.c index ebee928f17c..9000d1ca160 100644 --- a/src/backend/utils/adt/enum.c +++ b/src/backend/utils/adt/enum.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/enum.c,v 1.10 2010/02/14 18:42:16 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/enum.c,v 1.11 2010/02/26 02:01:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -56,8 +56,8 @@ enum_in(PG_FUNCTION_ARGS) name))); /* - * This comes from pg_enum.oid and stores system oids in user tables. - * This oid must be preserved by binary upgrades. + * This comes from pg_enum.oid and stores system oids in user tables. This + * oid must be preserved by binary upgrades. */ enumoid = HeapTupleGetOid(tup); diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c index 2ca7f6a1fa8..e7e82a1b148 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.167 2010/02/25 18:36:14 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.168 2010/02/26 02:01:08 momjian Exp $ * * * Portions Copyright (c) 1999-2010, PostgreSQL Global Development Group @@ -1053,165 +1053,165 @@ NUMDesc_prepare(NUMDesc *num, FormatNode *n) */ PG_TRY(); { - if (IS_EEEE(num) && n->key->id != NUM_E) - ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("\"EEEE\" must be the last pattern used"))); + if (IS_EEEE(num) && n->key->id != NUM_E) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("\"EEEE\" must be the last pattern used"))); - switch (n->key->id) - { - case NUM_9: - if (IS_BRACKET(num)) - ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("\"9\" must be ahead of \"PR\""))); - if (IS_MULTI(num)) - { - ++num->multi; + switch (n->key->id) + { + case NUM_9: + if (IS_BRACKET(num)) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("\"9\" must be ahead of \"PR\""))); + if (IS_MULTI(num)) + { + ++num->multi; + break; + } + if (IS_DECIMAL(num)) + ++num->post; + else + ++num->pre; break; - } - if (IS_DECIMAL(num)) - ++num->post; - else - ++num->pre; - break; - case NUM_0: - if (IS_BRACKET(num)) - ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("\"0\" must be ahead of \"PR\""))); - if (!IS_ZERO(num) && !IS_DECIMAL(num)) - { - num->flag |= NUM_F_ZERO; - num->zero_start = num->pre + 1; - } - if (!IS_DECIMAL(num)) - ++num->pre; - else - ++num->post; + case NUM_0: + if (IS_BRACKET(num)) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("\"0\" must be ahead of \"PR\""))); + if (!IS_ZERO(num) && !IS_DECIMAL(num)) + { + num->flag |= NUM_F_ZERO; + num->zero_start = num->pre + 1; + } + if (!IS_DECIMAL(num)) + ++num->pre; + else + ++num->post; - num->zero_end = num->pre + num->post; - break; + num->zero_end = num->pre + num->post; + break; - case NUM_B: - if (num->pre == 0 && num->post == 0 && (!IS_ZERO(num))) - num->flag |= NUM_F_BLANK; - break; + case NUM_B: + if (num->pre == 0 && num->post == 0 && (!IS_ZERO(num))) + num->flag |= NUM_F_BLANK; + break; - case NUM_D: - num->flag |= NUM_F_LDECIMAL; - num->need_locale = TRUE; - case NUM_DEC: - if (IS_DECIMAL(num)) - ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("multiple decimal points"))); - if (IS_MULTI(num)) - ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), + case NUM_D: + num->flag |= NUM_F_LDECIMAL; + num->need_locale = TRUE; + case NUM_DEC: + if (IS_DECIMAL(num)) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("multiple decimal points"))); + if (IS_MULTI(num)) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), errmsg("cannot use \"V\" and decimal point together"))); - num->flag |= NUM_F_DECIMAL; - break; + num->flag |= NUM_F_DECIMAL; + break; - case NUM_FM: - num->flag |= NUM_F_FILLMODE; - break; + case NUM_FM: + num->flag |= NUM_F_FILLMODE; + break; - case NUM_S: - if (IS_LSIGN(num)) - ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("cannot use \"S\" twice"))); - if (IS_PLUS(num) || IS_MINUS(num) || IS_BRACKET(num)) - ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("cannot use \"S\" and \"PL\"/\"MI\"/\"SG\"/\"PR\" together"))); - if (!IS_DECIMAL(num)) - { - num->lsign = NUM_LSIGN_PRE; - num->pre_lsign_num = num->pre; - num->need_locale = TRUE; - num->flag |= NUM_F_LSIGN; - } - else if (num->lsign == NUM_LSIGN_NONE) - { - num->lsign = NUM_LSIGN_POST; + case NUM_S: + if (IS_LSIGN(num)) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("cannot use \"S\" twice"))); + if (IS_PLUS(num) || IS_MINUS(num) || IS_BRACKET(num)) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("cannot use \"S\" and \"PL\"/\"MI\"/\"SG\"/\"PR\" together"))); + if (!IS_DECIMAL(num)) + { + num->lsign = NUM_LSIGN_PRE; + num->pre_lsign_num = num->pre; + num->need_locale = TRUE; + num->flag |= NUM_F_LSIGN; + } + else if (num->lsign == NUM_LSIGN_NONE) + { + num->lsign = NUM_LSIGN_POST; + num->need_locale = TRUE; + num->flag |= NUM_F_LSIGN; + } + break; + + case NUM_MI: + if (IS_LSIGN(num)) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("cannot use \"S\" and \"MI\" together"))); + num->flag |= NUM_F_MINUS; + if (IS_DECIMAL(num)) + num->flag |= NUM_F_MINUS_POST; + break; + + case NUM_PL: + if (IS_LSIGN(num)) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("cannot use \"S\" and \"PL\" together"))); + num->flag |= NUM_F_PLUS; + if (IS_DECIMAL(num)) + num->flag |= NUM_F_PLUS_POST; + break; + + case NUM_SG: + if (IS_LSIGN(num)) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("cannot use \"S\" and \"SG\" together"))); + num->flag |= NUM_F_MINUS; + num->flag |= NUM_F_PLUS; + break; + + case NUM_PR: + if (IS_LSIGN(num) || IS_PLUS(num) || IS_MINUS(num)) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("cannot use \"PR\" and \"S\"/\"PL\"/\"MI\"/\"SG\" together"))); + num->flag |= NUM_F_BRACKET; + break; + + case NUM_rn: + case NUM_RN: + num->flag |= NUM_F_ROMAN; + break; + + case NUM_L: + case NUM_G: num->need_locale = TRUE; - num->flag |= NUM_F_LSIGN; - } - break; + break; - case NUM_MI: - if (IS_LSIGN(num)) - ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("cannot use \"S\" and \"MI\" together"))); - num->flag |= NUM_F_MINUS; - if (IS_DECIMAL(num)) - num->flag |= NUM_F_MINUS_POST; - break; - - case NUM_PL: - if (IS_LSIGN(num)) - ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("cannot use \"S\" and \"PL\" together"))); - num->flag |= NUM_F_PLUS; - if (IS_DECIMAL(num)) - num->flag |= NUM_F_PLUS_POST; - break; - - case NUM_SG: - if (IS_LSIGN(num)) - ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("cannot use \"S\" and \"SG\" together"))); - num->flag |= NUM_F_MINUS; - num->flag |= NUM_F_PLUS; - break; - - case NUM_PR: - if (IS_LSIGN(num) || IS_PLUS(num) || IS_MINUS(num)) - ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("cannot use \"PR\" and \"S\"/\"PL\"/\"MI\"/\"SG\" together"))); - num->flag |= NUM_F_BRACKET; - break; - - case NUM_rn: - case NUM_RN: - num->flag |= NUM_F_ROMAN; - break; - - case NUM_L: - case NUM_G: - num->need_locale = TRUE; - break; - - case NUM_V: - if (IS_DECIMAL(num)) - ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), + case NUM_V: + if (IS_DECIMAL(num)) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), errmsg("cannot use \"V\" and decimal point together"))); - num->flag |= NUM_F_MULTI; - break; + num->flag |= NUM_F_MULTI; + break; - case NUM_E: - if (IS_EEEE(num)) - ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("cannot use \"EEEE\" twice"))); - if (IS_BLANK(num) || IS_FILLMODE(num) || IS_LSIGN(num) || - IS_BRACKET(num) || IS_MINUS(num) || IS_PLUS(num) || - IS_ROMAN(num) || IS_MULTI(num)) - ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("\"EEEE\" is incompatible with other formats"), - errdetail("\"EEEE\" may only be used together with digit and decimal point patterns."))); - num->flag |= NUM_F_EEEE; - break; - } + case NUM_E: + if (IS_EEEE(num)) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("cannot use \"EEEE\" twice"))); + if (IS_BLANK(num) || IS_FILLMODE(num) || IS_LSIGN(num) || + IS_BRACKET(num) || IS_MINUS(num) || IS_PLUS(num) || + IS_ROMAN(num) || IS_MULTI(num)) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("\"EEEE\" is incompatible with other formats"), + errdetail("\"EEEE\" may only be used together with digit and decimal point patterns."))); + num->flag |= NUM_F_EEEE; + break; + } } PG_CATCH(); { @@ -2088,7 +2088,11 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out) break; case DCH_HH: case DCH_HH12: - /* display time as shown on a 12-hour clock, even for intervals */ + + /* + * display time as shown on a 12-hour clock, even for + * intervals + */ sprintf(s, "%0*d", S_FM(n->suffix) ? 0 : 2, tm->tm_hour % (HOURS_PER_DAY / 2) == 0 ? 12 : tm->tm_hour % (HOURS_PER_DAY / 2)); @@ -4652,8 +4656,8 @@ numeric_to_char(PG_FUNCTION_ARGS) if (strcmp(orgnum, "NaN") == 0) { /* - * Allow 6 characters for the leading sign, the decimal point, "e", - * the exponent's sign and two exponent digits. + * Allow 6 characters for the leading sign, the decimal point, + * "e", the exponent's sign and two exponent digits. */ numstr = (char *) palloc(Num.pre + Num.post + 7); fill_str(numstr, '#', Num.pre + Num.post + 6); @@ -4757,7 +4761,7 @@ int4_to_char(PG_FUNCTION_ARGS) else if (IS_EEEE(&Num)) { /* we can do it easily because float8 won't lose any precision */ - float8 val = (float8) value; + float8 val = (float8) value; orgnum = (char *) palloc(MAXDOUBLEWIDTH + 1); snprintf(orgnum, MAXDOUBLEWIDTH + 1, "%+.*e", Num.post, val); @@ -4852,7 +4856,7 @@ int8_to_char(PG_FUNCTION_ARGS) else if (IS_EEEE(&Num)) { /* to avoid loss of precision, must go via numeric not float8 */ - Numeric val; + Numeric val; val = DatumGetNumeric(DirectFunctionCall1(int8_numeric, Int64GetDatum(value))); @@ -4956,8 +4960,8 @@ float4_to_char(PG_FUNCTION_ARGS) if (isnan(value) || is_infinite(value)) { /* - * Allow 6 characters for the leading sign, the decimal point, "e", - * the exponent's sign and two exponent digits. + * Allow 6 characters for the leading sign, the decimal point, + * "e", the exponent's sign and two exponent digits. */ numstr = (char *) palloc(Num.pre + Num.post + 7); fill_str(numstr, '#', Num.pre + Num.post + 6); @@ -5060,8 +5064,8 @@ float8_to_char(PG_FUNCTION_ARGS) if (isnan(value) || is_infinite(value)) { /* - * Allow 6 characters for the leading sign, the decimal point, "e", - * the exponent's sign and two exponent digits. + * Allow 6 characters for the leading sign, the decimal point, + * "e", the exponent's sign and two exponent digits. */ numstr = (char *) palloc(Num.pre + Num.post + 7); fill_str(numstr, '#', Num.pre + Num.post + 6); diff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.c index 35f1a13ab67..cd1d6c2cc6b 100644 --- a/src/backend/utils/adt/geo_ops.c +++ b/src/backend/utils/adt/geo_ops.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/geo_ops.c,v 1.107 2010/01/14 16:31:09 teodor Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/geo_ops.c,v 1.108 2010/02/26 02:01:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -67,7 +67,7 @@ static double dist_pl_internal(Point *pt, LINE *line); static double dist_ps_internal(Point *pt, LSEG *lseg); static Point *line_interpt_internal(LINE *l1, LINE *l2); static bool lseg_inside_poly(Point *a, Point *b, POLYGON *poly, int start); -static Point* lseg_interpt_internal(LSEG *l1, LSEG *l2); +static Point *lseg_interpt_internal(LSEG *l1, LSEG *l2); /* @@ -2354,7 +2354,7 @@ lseg_center(PG_FUNCTION_ARGS) PG_RETURN_POINT_P(result); } -static Point* +static Point * lseg_interpt_internal(LSEG *l1, LSEG *l2) { Point *result; @@ -2411,7 +2411,7 @@ lseg_interpt(PG_FUNCTION_ARGS) LSEG *l1 = PG_GETARG_LSEG_P(0); LSEG *l2 = PG_GETARG_LSEG_P(1); Point *result; - + result = lseg_interpt_internal(l1, l2); if (!PointerIsValid(result)) PG_RETURN_NULL(); @@ -2466,8 +2466,8 @@ dist_ps_internal(Point *pt, LSEG *lseg) Point *ip; /* - * Construct a line perpendicular to the input segment - * and through the input point + * Construct a line perpendicular to the input segment and through the + * input point */ if (lseg->p[1].x == lseg->p[0].x) m = 0; @@ -3203,7 +3203,7 @@ on_pb(PG_FUNCTION_ARGS) } Datum -box_contain_pt(PG_FUNCTION_ARGS) +box_contain_pt(PG_FUNCTION_ARGS) { BOX *box = PG_GETARG_BOX_P(0); Point *pt = PG_GETARG_POINT_P(1); @@ -3768,7 +3768,7 @@ poly_same(PG_FUNCTION_ARGS) } /*----------------------------------------------------------------- - * Determine if polygon A overlaps polygon B + * Determine if polygon A overlaps polygon B *-----------------------------------------------------------------*/ Datum poly_overlap(PG_FUNCTION_ARGS) @@ -3778,51 +3778,51 @@ poly_overlap(PG_FUNCTION_ARGS) bool result; /* Quick check by bounding box */ - result = (polya->npts > 0 && polyb->npts > 0 && - box_ov(&polya->boundbox, &polyb->boundbox)) ? true : false; + result = (polya->npts > 0 && polyb->npts > 0 && + box_ov(&polya->boundbox, &polyb->boundbox)) ? true : false; /* - * Brute-force algorithm - try to find intersected edges, - * if so then polygons are overlapped else check is one - * polygon inside other or not by testing single point - * of them. + * Brute-force algorithm - try to find intersected edges, if so then + * polygons are overlapped else check is one polygon inside other or not + * by testing single point of them. */ if (result) { - int ia, ib; - LSEG sa, sb; + int ia, + ib; + LSEG sa, + sb; /* Init first of polya's edge with last point */ sa.p[0] = polya->p[polya->npts - 1]; result = false; - for(ia=0; ia<polya->npts && result == false; ia++) + for (ia = 0; ia < polya->npts && result == false; ia++) { - /* Second point of polya's edge is a current one */ + /* Second point of polya's edge is a current one */ sa.p[1] = polya->p[ia]; /* Init first of polyb's edge with last point */ sb.p[0] = polyb->p[polyb->npts - 1]; - for(ib=0; ib<polyb->npts && result == false; ib++) + for (ib = 0; ib < polyb->npts && result == false; ib++) { sb.p[1] = polyb->p[ib]; result = lseg_intersect_internal(&sa, &sb); sb.p[0] = sb.p[1]; } - /* - * move current endpoint to the first point - * of next edge + /* + * move current endpoint to the first point of next edge */ sa.p[0] = sa.p[1]; } - if (result==false) + if (result == false) { - result = ( point_inside(polya->p, polyb->npts, polyb->p) - || - point_inside(polyb->p, polya->npts, polya->p) ); + result = (point_inside(polya->p, polyb->npts, polyb->p) + || + point_inside(polyb->p, polya->npts, polya->p)); } } @@ -3838,93 +3838,93 @@ poly_overlap(PG_FUNCTION_ARGS) /* * Tests special kind of segment for in/out of polygon. * Special kind means: - * - point a should be on segment s - * - segment (a,b) should not be contained by s + * - point a should be on segment s + * - segment (a,b) should not be contained by s * Returns true if: - * - segment (a,b) is collinear to s and (a,b) is in polygon - * - segment (a,b) s not collinear to s. Note: that doesn't - * mean that segment is in polygon! - */ + * - segment (a,b) is collinear to s and (a,b) is in polygon + * - segment (a,b) s not collinear to s. Note: that doesn't + * mean that segment is in polygon! + */ static bool touched_lseg_inside_poly(Point *a, Point *b, LSEG *s, POLYGON *poly, int start) { /* point a is on s, b is not */ - LSEG t; + LSEG t; t.p[0] = *a; t.p[1] = *b; - -#define POINTEQ(pt1, pt2) (FPeq((pt1)->x, (pt2)->x) && FPeq((pt1)->y, (pt2)->y)) - if ( POINTEQ(a, s->p) ) + +#define POINTEQ(pt1, pt2) (FPeq((pt1)->x, (pt2)->x) && FPeq((pt1)->y, (pt2)->y)) + if (POINTEQ(a, s->p)) { - if ( on_ps_internal(s->p+1, &t) ) - return lseg_inside_poly(b, s->p+1, poly, start); + if (on_ps_internal(s->p + 1, &t)) + return lseg_inside_poly(b, s->p + 1, poly, start); } - else if (POINTEQ(a, s->p+1)) + else if (POINTEQ(a, s->p + 1)) { - if ( on_ps_internal(s->p, &t) ) + if (on_ps_internal(s->p, &t)) return lseg_inside_poly(b, s->p, poly, start); } - else if ( on_ps_internal(s->p, &t) ) + else if (on_ps_internal(s->p, &t)) { return lseg_inside_poly(b, s->p, poly, start); } - else if ( on_ps_internal(s->p+1, &t) ) + else if (on_ps_internal(s->p + 1, &t)) { - return lseg_inside_poly(b, s->p+1, poly, start); + return lseg_inside_poly(b, s->p + 1, poly, start); } - return true; /* may be not true, but that will check later */ + return true; /* may be not true, but that will check later */ } /* * Returns true if segment (a,b) is in polygon, option - * start is used for optimization - function checks + * start is used for optimization - function checks * polygon's edges started from start */ static bool lseg_inside_poly(Point *a, Point *b, POLYGON *poly, int start) { - LSEG s, - t; - int i; - bool res = true, - intersection = false; + LSEG s, + t; + int i; + bool res = true, + intersection = false; t.p[0] = *a; t.p[1] = *b; - s.p[0] = poly->p[( start == 0) ? (poly->npts - 1) : (start - 1)]; + s.p[0] = poly->p[(start == 0) ? (poly->npts - 1) : (start - 1)]; - for(i=start; i<poly->npts && res == true; i++) + for (i = start; i < poly->npts && res == true; i++) { - Point *interpt; + Point *interpt; s.p[1] = poly->p[i]; - if ( on_ps_internal(t.p, &s) ) + if (on_ps_internal(t.p, &s)) { - if ( on_ps_internal(t.p+1, &s) ) - return true; /* t is contained by s */ + if (on_ps_internal(t.p + 1, &s)) + return true; /* t is contained by s */ /* Y-cross */ - res = touched_lseg_inside_poly(t.p, t.p+1, &s, poly, i+1); - } - else if ( on_ps_internal(t.p+1, &s) ) + res = touched_lseg_inside_poly(t.p, t.p + 1, &s, poly, i + 1); + } + else if (on_ps_internal(t.p + 1, &s)) { /* Y-cross */ - res = touched_lseg_inside_poly(t.p+1, t.p, &s, poly, i+1); + res = touched_lseg_inside_poly(t.p + 1, t.p, &s, poly, i + 1); } - else if ( (interpt = lseg_interpt_internal(&t, &s)) != NULL ) + else if ((interpt = lseg_interpt_internal(&t, &s)) != NULL) { /* * segments are X-crossing, go to check each subsegment */ intersection = true; - res = lseg_inside_poly(t.p, interpt, poly, i+1); + res = lseg_inside_poly(t.p, interpt, poly, i + 1); if (res) - res = lseg_inside_poly(t.p+1, interpt, poly, i+1); + res = lseg_inside_poly(t.p + 1, interpt, poly, i + 1); pfree(interpt); } @@ -3933,17 +3933,16 @@ lseg_inside_poly(Point *a, Point *b, POLYGON *poly, int start) if (res && !intersection) { - Point p; + Point p; /* - * if X-intersection wasn't found then check central point - * of tested segment. In opposite case we already check all - * subsegments + * if X-intersection wasn't found then check central point of tested + * segment. In opposite case we already check all subsegments */ - p.x = (t.p[0].x + t.p[1].x) / 2.0; + p.x = (t.p[0].x + t.p[1].x) / 2.0; p.y = (t.p[0].y + t.p[1].y) / 2.0; - res = point_inside(&p, poly->npts, poly->p); + res = point_inside(&p, poly->npts, poly->p); } return res; @@ -3963,20 +3962,20 @@ poly_contain(PG_FUNCTION_ARGS) * Quick check to see if bounding box is contained. */ if (polya->npts > 0 && polyb->npts > 0 && - DatumGetBool(DirectFunctionCall2(box_contain, - BoxPGetDatum(&polya->boundbox), - BoxPGetDatum(&polyb->boundbox)))) + DatumGetBool(DirectFunctionCall2(box_contain, + BoxPGetDatum(&polya->boundbox), + BoxPGetDatum(&polyb->boundbox)))) { - int i; - LSEG s; + int i; + LSEG s; s.p[0] = polyb->p[polyb->npts - 1]; result = true; - for(i=0; i<polyb->npts && result == true; i++) + for (i = 0; i < polyb->npts && result == true; i++) { s.p[1] = polyb->p[i]; - result = lseg_inside_poly(s.p, s.p+1, polya, 0); + result = lseg_inside_poly(s.p, s.p + 1, polya, 0); s.p[0] = s.p[1]; } } diff --git a/src/backend/utils/adt/int.c b/src/backend/utils/adt/int.c index edb22e8cc6d..ab8476b68ae 100644 --- a/src/backend/utils/adt/int.c +++ b/src/backend/utils/adt/int.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/int.c,v 1.88 2010/01/02 16:57:54 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/int.c,v 1.89 2010/02/26 02:01:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -149,7 +149,7 @@ int2vectorin(PG_FUNCTION_ARGS) while (*intString && isspace((unsigned char) *intString)) intString++; if (*intString == '\0') - break; + break; result->values[n] = pg_atoi(intString, sizeof(int16), ' '); while (*intString && !isspace((unsigned char) *intString)) intString++; diff --git a/src/backend/utils/adt/int8.c b/src/backend/utils/adt/int8.c index 1482017561d..78bd5fb2b87 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.78 2010/02/08 20:39:51 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/int8.c,v 1.79 2010/02/26 02:01:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -654,9 +654,9 @@ int8inc(PG_FUNCTION_ARGS) /* * When int8 is pass-by-reference, we provide this special case to avoid * palloc overhead for COUNT(): when called as an aggregate, 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.) + * 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.) */ #ifndef USE_FLOAT8_BYVAL /* controls int8 too */ if (AggCheckCallContext(fcinfo, NULL)) diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c index ba7fb1ad674..66c8598d17b 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.74 2010/01/12 02:42:52 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/misc.c,v 1.75 2010/02/26 02:01:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -187,7 +187,7 @@ pg_tablespace_databases(PG_FUNCTION_ARGS) * size = tablespace dirname length + dir sep char + oid + terminator */ fctx->location = (char *) palloc(9 + 1 + OIDCHARS + 1 + - strlen(TABLESPACE_VERSION_DIRECTORY) + 1); + strlen(TABLESPACE_VERSION_DIRECTORY) + 1); if (tablespaceOid == GLOBALTABLESPACE_OID) { fctx->dirdesc = NULL; diff --git a/src/backend/utils/adt/nabstime.c b/src/backend/utils/adt/nabstime.c index e06f72d6932..3c744ad8bbd 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.163 2010/01/02 16:57:54 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.164 2010/02/26 02:01:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -786,7 +786,7 @@ tintervalrecv(PG_FUNCTION_ARGS) { StringInfo buf = (StringInfo) PG_GETARG_POINTER(0); TimeInterval tinterval; - int32 status; + int32 status; tinterval = (TimeInterval) palloc(sizeof(TimeIntervalData)); @@ -796,7 +796,7 @@ tintervalrecv(PG_FUNCTION_ARGS) if (tinterval->data[0] == INVALID_ABSTIME || tinterval->data[1] == INVALID_ABSTIME) - status = T_INTERVAL_INVAL; /* undefined */ + status = T_INTERVAL_INVAL; /* undefined */ else status = T_INTERVAL_VALID; diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c index 1b9f7944959..4b8271e45f5 100644 --- a/src/backend/utils/adt/numeric.c +++ b/src/backend/utils/adt/numeric.c @@ -14,7 +14,7 @@ * Copyright (c) 1998-2010, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.122 2010/02/08 20:39:51 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.123 2010/02/26 02:01:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -3403,7 +3403,7 @@ static char * get_str_from_var_sci(NumericVar *var, int rscale) { int32 exponent; - NumericVar denominator; + NumericVar denominator; NumericVar significand; int denom_scale; size_t len; @@ -3466,9 +3466,9 @@ get_str_from_var_sci(NumericVar *var, int rscale) /* * Allocate space for the result. * - * In addition to the significand, we need room for the exponent decoration - * ("e"), the sign of the exponent, up to 10 digits for the exponent - * itself, and of course the null terminator. + * In addition to the significand, we need room for the exponent + * decoration ("e"), the sign of the exponent, up to 10 digits for the + * exponent itself, and of course the null terminator. */ len = strlen(sig_out) + 13; str = palloc(len); diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c index 93fad320c16..8b13c8adf04 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.59 2010/01/28 14:25:41 mha Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/pgstatfuncs.c,v 1.60 2010/02/26 02:01:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1116,7 +1116,7 @@ pg_stat_reset(PG_FUNCTION_ARGS) Datum pg_stat_reset_shared(PG_FUNCTION_ARGS) { - char *target = text_to_cstring(PG_GETARG_TEXT_PP(0)); + char *target = text_to_cstring(PG_GETARG_TEXT_PP(0)); pgstat_reset_shared_counters(target); @@ -1127,7 +1127,7 @@ pg_stat_reset_shared(PG_FUNCTION_ARGS) Datum pg_stat_reset_single_table_counters(PG_FUNCTION_ARGS) { - Oid taboid = PG_GETARG_OID(0); + Oid taboid = PG_GETARG_OID(0); pgstat_reset_single_counter(taboid, RESET_TABLE); @@ -1137,7 +1137,7 @@ pg_stat_reset_single_table_counters(PG_FUNCTION_ARGS) Datum pg_stat_reset_single_function_counters(PG_FUNCTION_ARGS) { - Oid funcoid = PG_GETARG_OID(0); + Oid funcoid = PG_GETARG_OID(0); pgstat_reset_single_counter(funcoid, RESET_FUNCTION); diff --git a/src/backend/utils/adt/rowtypes.c b/src/backend/utils/adt/rowtypes.c index 750b0e3150d..50a54191280 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.27 2010/01/02 16:57:55 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/rowtypes.c,v 1.28 2010/02/26 02:01:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -97,10 +97,11 @@ record_in(PG_FUNCTION_ARGS) (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("input of anonymous composite types is not implemented"))); tupTypmod = -1; /* for all non-anonymous types */ + /* - * This comes from the composite type's pg_type.oid and - * stores system oids in user tables, specifically DatumTupleFields. - * This oid must be preserved by binary upgrades. + * This comes from the composite type's pg_type.oid and stores system oids + * in user tables, specifically DatumTupleFields. This oid must be + * preserved by binary upgrades. */ tupdesc = lookup_rowtype_tupdesc(tupType, tupTypmod); ncolumns = tupdesc->natts; diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 6bf03dacd36..316562537be 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.324 2010/02/18 22:43:31 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.325 2010/02/26 02:01:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -221,7 +221,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, List *argnames, - Oid *argtypes, bool *is_variadic); + Oid *argtypes, 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); @@ -549,12 +549,12 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty) /* tgattr is first var-width field, so OK to access directly */ if (trigrec->tgattr.dim1 > 0) { - int i; + int i; appendStringInfoString(&buf, " OF "); for (i = 0; i < trigrec->tgattr.dim1; i++) { - char *attname; + char *attname; if (i > 0) appendStringInfoString(&buf, ", "); @@ -579,7 +579,7 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty) { if (OidIsValid(trigrec->tgconstrrelid)) appendStringInfo(&buf, "FROM %s ", - generate_relation_name(trigrec->tgconstrrelid, NIL)); + generate_relation_name(trigrec->tgconstrrelid, NIL)); if (!trigrec->tgdeferrable) appendStringInfo(&buf, "NOT "); appendStringInfo(&buf, "DEFERRABLE INITIALLY "); @@ -599,11 +599,11 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty) tgrel->rd_att, &isnull); if (!isnull) { - Node *qual; - deparse_context context; - deparse_namespace dpns; - RangeTblEntry *oldrte; - RangeTblEntry *newrte; + Node *qual; + deparse_context context; + deparse_namespace dpns; + RangeTblEntry *oldrte; + RangeTblEntry *newrte; appendStringInfoString(&buf, "WHEN ("); @@ -848,7 +848,7 @@ pg_get_indexdef_worker(Oid indexrelid, int colno, quote_identifier(NameStr(idxrelrec->relname)), generate_relation_name(indrelid, NIL), quote_identifier(NameStr(amrec->amname))); - else /* currently, must be EXCLUDE constraint */ + else /* currently, must be EXCLUDE constraint */ appendStringInfo(&buf, "EXCLUDE USING %s (", quote_identifier(NameStr(amrec->amname))); } @@ -1262,23 +1262,24 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand, break; } case CONSTRAINT_TRIGGER: + /* * There isn't an ALTER TABLE syntax for creating a user-defined - * constraint trigger, but it seems better to print something - * than throw an error; if we throw error then this function - * couldn't safely be applied to all rows of pg_constraint. + * constraint trigger, but it seems better to print something than + * throw an error; if we throw error then this function couldn't + * safely be applied to all rows of pg_constraint. */ appendStringInfo(&buf, "TRIGGER"); break; case CONSTRAINT_EXCLUSION: { - Oid indexOid = conForm->conindid; - Datum val; - bool isnull; - Datum *elems; - int nElems; - int i; - Oid *operators; + Oid indexOid = conForm->conindid; + Datum val; + bool isnull; + Datum *elems; + int nElems; + int i; + Oid *operators; /* Extract operator OIDs from the pg_constraint tuple */ val = SysCacheGetAttr(CONSTROID, tup, @@ -3497,10 +3498,10 @@ push_plan(deparse_namespace *dpns, Plan *subplan) /* * We special-case Append to pretend that the first child plan is the * OUTER referent; we have to interpret OUTER Vars in the Append's tlist - * according to one of the children, and the first one is the most - * natural choice. Likewise special-case ModifyTable to pretend that the - * first child plan is the OUTER referent; this is to support RETURNING - * lists containing references to non-target relations. + * according to one of the children, and the first one is the most natural + * choice. Likewise special-case ModifyTable to pretend that the first + * child plan is the OUTER referent; this is to support RETURNING lists + * containing references to non-target relations. */ if (IsA(subplan, Append)) dpns->outer_plan = (Plan *) linitial(((Append *) subplan)->appendplans); @@ -4470,10 +4471,10 @@ get_rule_expr(Node *node, deparse_context *context, /* * If the argument is a CaseTestExpr, we must be inside a - * FieldStore, ie, we are assigning to an element of an - * array within a composite column. Since we already punted - * on displaying the FieldStore's target information, just - * punt here too, and display only the assignment source + * FieldStore, ie, we are assigning to an element of an array + * within a composite column. Since we already punted on + * displaying the FieldStore's target information, just punt + * here too, and display only the assignment source * expression. */ if (IsA(aref->refexpr, CaseTestExpr)) @@ -4498,23 +4499,23 @@ get_rule_expr(Node *node, deparse_context *context, appendStringInfoChar(buf, ')'); /* - * If there's a refassgnexpr, we want to print the node in - * the format "array[subscripts] := refassgnexpr". This is - * not legal SQL, so decompilation of INSERT or UPDATE - * statements should always use processIndirection as part - * of the statement-level syntax. We should only see this - * when EXPLAIN tries to print the targetlist of a plan - * resulting from such a statement. + * If there's a refassgnexpr, we want to print the node in the + * format "array[subscripts] := refassgnexpr". This is not + * legal SQL, so decompilation of INSERT or UPDATE statements + * should always use processIndirection as part of the + * statement-level syntax. We should only see this when + * EXPLAIN tries to print the targetlist of a plan resulting + * from such a statement. */ if (aref->refassgnexpr) { - Node *refassgnexpr; + Node *refassgnexpr; /* - * Use processIndirection to print this node's - * subscripts as well as any additional field selections - * or subscripting in immediate descendants. It returns - * the RHS expr that is actually being "assigned". + * Use processIndirection to print this node's subscripts + * as well as any additional field selections or + * subscripting in immediate descendants. It returns the + * RHS expr that is actually being "assigned". */ refassgnexpr = processIndirection(node, context, true); appendStringInfoString(buf, " := "); @@ -4724,14 +4725,14 @@ get_rule_expr(Node *node, deparse_context *context, * There is no good way to represent a FieldStore as real SQL, * so decompilation of INSERT or UPDATE statements should * always use processIndirection as part of the - * statement-level syntax. We should only get here when + * statement-level syntax. We should only get here when * EXPLAIN tries to print the targetlist of a plan resulting * from such a statement. The plan case is even harder than * ordinary rules would be, because the planner tries to * collapse multiple assignments to the same field or subfield * into one FieldStore; so we can see a list of target fields * not just one, and the arguments could be FieldStores - * themselves. We don't bother to try to print the target + * themselves. We don't bother to try to print the target * field names; we just print the source arguments, with a * ROW() around them if there's more than one. This isn't * terribly complete, but it's probably good enough for @@ -5474,7 +5475,7 @@ get_func_expr(FuncExpr *expr, deparse_context *context, argnames = NIL; foreach(l, expr->args) { - Node *arg = (Node *) lfirst(l); + Node *arg = (Node *) lfirst(l); if (IsA(arg, NamedArgExpr)) argnames = lappend(argnames, ((NamedArgExpr *) arg)->name); @@ -5506,7 +5507,7 @@ get_agg_expr(Aggref *aggref, deparse_context *context) { StringInfo buf = context->buf; Oid argtypes[FUNC_MAX_ARGS]; - List *arglist; + List *arglist; int nargs; ListCell *l; @@ -5516,12 +5517,12 @@ get_agg_expr(Aggref *aggref, deparse_context *context) foreach(l, aggref->args) { TargetEntry *tle = (TargetEntry *) lfirst(l); - Node *arg = (Node *) tle->expr; + Node *arg = (Node *) tle->expr; Assert(!IsA(arg, NamedArgExpr)); if (tle->resjunk) continue; - if (nargs >= FUNC_MAX_ARGS) /* paranoia */ + if (nargs >= FUNC_MAX_ARGS) /* paranoia */ ereport(ERROR, (errcode(ERRCODE_TOO_MANY_ARGUMENTS), errmsg("too many arguments"))); @@ -5565,7 +5566,7 @@ get_windowfunc_expr(WindowFunc *wfunc, deparse_context *context) nargs = 0; foreach(l, wfunc->args) { - Node *arg = (Node *) lfirst(l); + Node *arg = (Node *) lfirst(l); Assert(!IsA(arg, NamedArgExpr)); argtypes[nargs] = exprType(arg); @@ -6368,8 +6369,8 @@ processIndirection(Node *node, deparse_context *context, bool printit) format_type_be(fstore->resulttype)); /* - * Print the field name. There should only be one target field - * in stored rules. There could be more than that in executable + * Print the field name. There should only be one target field in + * stored rules. There could be more than that in executable * target lists, but this function cannot be used for that case. */ Assert(list_length(fstore->fieldnums) == 1); @@ -6598,7 +6599,7 @@ generate_relation_name(Oid relid, List *namespaces) * generate_function_name * Compute the name to display for a function specified by OID, * given that it is being called with the specified actual arg names and - * types. (Those matter because of ambiguous-function resolution rules.) + * types. (Those matter because of ambiguous-function resolution rules.) * * The result includes all necessary quoting and schema-prefixing. We can * also pass back an indication of whether the function is variadic. @@ -6628,7 +6629,7 @@ generate_function_name(Oid funcid, int nargs, List *argnames, /* * The idea here is to schema-qualify only if the parser would fail to * resolve the correct function given the unqualified func name with the - * specified argtypes. If the function is variadic, we should presume + * specified argtypes. If the function is variadic, we should presume * that VARIADIC will be included in the call. */ p_result = func_get_detail(list_make1(makeString(proname)), diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index b83cd45d7c7..5925a913739 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.269 2010/02/14 18:42:16 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.270 2010/02/26 02:01:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -167,9 +167,9 @@ 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); static bool get_actual_variable_range(PlannerInfo *root, - VariableStatData *vardata, - Oid sortop, - Datum *min, Datum *max); + VariableStatData *vardata, + Oid sortop, + Datum *min, Datum *max); static Selectivity prefix_selectivity(PlannerInfo *root, VariableStatData *vardata, Oid vartype, Oid opfamily, Const *prefixcon); @@ -749,13 +749,13 @@ ineq_histogram_selectivity(PlannerInfo *root, * results ... but probably not any more garbage-y than you would * from the old linear search.) * - * If the binary search accesses the first or last histogram entry, - * we try to replace that endpoint with the true column min or max - * as found by get_actual_variable_range(). This ameliorates - * misestimates when the min or max is moving as a result of - * changes since the last ANALYZE. Note that this could result - * in effectively including MCVs into the histogram that weren't - * there before, but we don't try to correct for that. + * If the binary search accesses the first or last histogram + * entry, we try to replace that endpoint with the true column min + * or max as found by get_actual_variable_range(). This + * ameliorates misestimates when the min or max is moving as a + * result of changes since the last ANALYZE. Note that this could + * result in effectively including MCVs into the histogram that + * weren't there before, but we don't try to correct for that. */ double histfrac; int lobound = 0; /* first possible slot to search */ @@ -3727,8 +3727,7 @@ convert_string_datum(Datum value, Oid typid) /* * * http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx? - * FeedbackID=99694 - */ + * FeedbackID=99694 */ { char x[1]; @@ -4118,8 +4117,8 @@ examine_variable(PlannerInfo *root, Node *node, int varRelid, else if (rte->rtekind == RTE_RELATION) { vardata->statsTuple = SearchSysCache3(STATRELATTINH, - ObjectIdGetDatum(rte->relid), - Int16GetDatum(var->varattno), + ObjectIdGetDatum(rte->relid), + Int16GetDatum(var->varattno), BoolGetDatum(rte->inh)); vardata->freefunc = ReleaseSysCache; } @@ -4259,8 +4258,8 @@ examine_variable(PlannerInfo *root, Node *node, int varRelid, vardata->statsTuple = SearchSysCache3(STATRELATTINH, ObjectIdGetDatum(index->indexoid), - Int16GetDatum(pos + 1), - BoolGetDatum(false)); + Int16GetDatum(pos + 1), + BoolGetDatum(false)); vardata->freefunc = ReleaseSysCache; } if (vardata->statsTuple) @@ -4407,11 +4406,11 @@ get_variable_range(PlannerInfo *root, VariableStatData *vardata, Oid sortop, int i; /* - * XXX It's very tempting to try to use the actual column min and max, - * if we can get them relatively-cheaply with an index probe. However, - * since this function is called many times during join planning, - * that could have unpleasant effects on planning speed. Need more - * investigation before enabling this. + * XXX It's very tempting to try to use the actual column min and max, if + * we can get them relatively-cheaply with an index probe. However, since + * this function is called many times during join planning, that could + * have unpleasant effects on planning speed. Need more investigation + * before enabling this. */ #ifdef NOT_USED if (get_actual_variable_range(root, vardata, sortop, min, max)) @@ -4550,8 +4549,8 @@ get_actual_variable_range(PlannerInfo *root, VariableStatData *vardata, continue; /* - * Ignore partial indexes --- we only want stats that cover the - * entire relation. + * Ignore partial indexes --- we only want stats that cover the entire + * relation. */ if (index->indpred != NIL) continue; @@ -4577,8 +4576,8 @@ get_actual_variable_range(PlannerInfo *root, VariableStatData *vardata, continue; /* - * Found a suitable index to extract data from. We'll need an - * EState and a bunch of other infrastructure. + * Found a suitable index to extract data from. We'll need an EState + * and a bunch of other infrastructure. */ { EState *estate; @@ -4622,7 +4621,7 @@ get_actual_variable_range(PlannerInfo *root, VariableStatData *vardata, /* set up an IS NOT NULL scan key so that we ignore nulls */ ScanKeyEntryInitialize(&scankeys[0], SK_ISNULL | SK_SEARCHNOTNULL, - 1, /* index col to scan */ + 1, /* index col to scan */ InvalidStrategy, /* no strategy */ InvalidOid, /* no strategy subtype */ InvalidOid, /* no reg proc for this */ @@ -4641,7 +4640,7 @@ get_actual_variable_range(PlannerInfo *root, VariableStatData *vardata, indexscandir)) != NULL) { /* Extract the index column values from the heap tuple */ - ExecStoreTuple(tup, slot, InvalidBuffer, false); + ExecStoreTuple(tup, slot, InvalidBuffer, false); FormIndexDatum(indexInfo, slot, estate, values, isnull); @@ -4672,7 +4671,7 @@ get_actual_variable_range(PlannerInfo *root, VariableStatData *vardata, -indexscandir)) != NULL) { /* Extract the index column values from the heap tuple */ - ExecStoreTuple(tup, slot, InvalidBuffer, false); + ExecStoreTuple(tup, slot, InvalidBuffer, false); FormIndexDatum(indexInfo, slot, estate, values, isnull); @@ -4872,8 +4871,8 @@ regex_fixed_prefix(Const *patt_const, bool case_insensitive, /* * Check for ARE director prefix. It's worth our trouble to recognize - * this because similar_escape() used to use it, and some other code - * might still use it, to force ARE mode. + * this because similar_escape() used to use it, and some other code might + * still use it, to force ARE mode. */ pos = 0; if (strncmp(patt, "***:", 4) == 0) @@ -5808,7 +5807,7 @@ genericcostestimate(PlannerInfo *root, * since that's internal to the indexscan.) */ *indexTotalCost = (pages_fetched * spc_random_page_cost) - / num_outer_scans; + / num_outer_scans; } else { diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c index 5289a2acfa1..a0c5a6ab66a 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.205 2010/01/02 16:57:55 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.206 2010/02/26 02:01:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -2780,11 +2780,11 @@ interval_mi(PG_FUNCTION_ARGS) } /* - * There is no interval_abs(): it is unclear what value to return: - * http://archives.postgresql.org/pgsql-general/2009-10/msg01031.php - * http://archives.postgresql.org/pgsql-general/2009-11/msg00041.php + * There is no interval_abs(): it is unclear what value to return: + * http://archives.postgresql.org/pgsql-general/2009-10/msg01031.php + * http://archives.postgresql.org/pgsql-general/2009-11/msg00041.php */ - + Datum interval_mul(PG_FUNCTION_ARGS) { diff --git a/src/backend/utils/adt/txid.c b/src/backend/utils/adt/txid.c index 31c78182017..db7ecd14b26 100644 --- a/src/backend/utils/adt/txid.c +++ b/src/backend/utils/adt/txid.c @@ -14,7 +14,7 @@ * Author: Jan Wieck, Afilias USA INC. * 64-bit txids: Marko Kreen, Skype Technologies * - * $PostgreSQL: pgsql/src/backend/utils/adt/txid.c,v 1.12 2010/02/20 21:24:02 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/txid.c,v 1.13 2010/02/26 02:01:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -330,11 +330,10 @@ txid_current(PG_FUNCTION_ARGS) TxidEpoch state; /* - * Must prevent during recovery because if an xid is - * not assigned we try to assign one, which would fail. - * Programs already rely on this function to always - * return a valid current xid, so we should not change - * this to return NULL or similar invalid xid. + * Must prevent during recovery because if an xid is not assigned we try + * to assign one, which would fail. Programs already rely on this function + * to always return a valid current xid, so we should not change this to + * return NULL or similar invalid xid. */ PreventCommandDuringRecovery("txid_current()"); diff --git a/src/backend/utils/adt/varbit.c b/src/backend/utils/adt/varbit.c index 4a550cdae29..d0cd0eba906 100644 --- a/src/backend/utils/adt/varbit.c +++ b/src/backend/utils/adt/varbit.c @@ -9,7 +9,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/varbit.c,v 1.64 2010/01/25 20:55:32 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/varbit.c,v 1.65 2010/02/26 02:01:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -25,7 +25,7 @@ static VarBit *bit_catenate(VarBit *arg1, VarBit *arg2); static VarBit *bitsubstring(VarBit *arg, int32 s, int32 l, - bool length_not_specified); + bool length_not_specified); static VarBit *bit_overlay(VarBit *t1, VarBit *t2, int sp, int sl); @@ -980,9 +980,10 @@ bitsubstring(VarBit *arg, int32 s, int32 l, bool length_not_specified) else { e = s + l; + /* - * A negative value for L is the only way for the end position - * to be before the start. SQL99 says to throw an error. + * A negative value for L is the only way for the end position to be + * before the start. SQL99 says to throw an error. */ if (e < s) ereport(ERROR, @@ -1055,8 +1056,8 @@ bitoverlay(PG_FUNCTION_ARGS) { VarBit *t1 = PG_GETARG_VARBIT_P(0); VarBit *t2 = PG_GETARG_VARBIT_P(1); - int sp = PG_GETARG_INT32(2); /* substring start position */ - int sl = PG_GETARG_INT32(3); /* substring length */ + int sp = PG_GETARG_INT32(2); /* substring start position */ + int sl = PG_GETARG_INT32(3); /* substring length */ PG_RETURN_VARBIT_P(bit_overlay(t1, t2, sp, sl)); } @@ -1066,10 +1067,10 @@ bitoverlay_no_len(PG_FUNCTION_ARGS) { VarBit *t1 = PG_GETARG_VARBIT_P(0); VarBit *t2 = PG_GETARG_VARBIT_P(1); - int sp = PG_GETARG_INT32(2); /* substring start position */ + int sp = PG_GETARG_INT32(2); /* substring start position */ int sl; - sl = VARBITLEN(t2); /* defaults to length(t2) */ + sl = VARBITLEN(t2); /* defaults to length(t2) */ PG_RETURN_VARBIT_P(bit_overlay(t1, t2, sp, sl)); } @@ -1082,9 +1083,9 @@ bit_overlay(VarBit *t1, VarBit *t2, int sp, int sl) int sp_pl_sl; /* - * Check for possible integer-overflow cases. For negative sp, - * throw a "substring length" error because that's what should be - * expected according to the spec's definition of OVERLAY(). + * Check for possible integer-overflow cases. For negative sp, throw a + * "substring length" error because that's what should be expected + * according to the spec's definition of OVERLAY(). */ if (sp <= 0) ereport(ERROR, @@ -1096,7 +1097,7 @@ bit_overlay(VarBit *t1, VarBit *t2, int sp, int sl) (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), errmsg("integer out of range"))); - s1 = bitsubstring(t1, 1, sp-1, false); + s1 = bitsubstring(t1, 1, sp - 1, false); s2 = bitsubstring(t1, sp_pl_sl, -1, true); result = bit_catenate(s1, t2); result = bit_catenate(result, s2); @@ -1446,7 +1447,7 @@ bitfromint4(PG_FUNCTION_ARGS) /* store first fractional byte */ if (destbitsleft > srcbitsleft) { - int val = (int) (a >> (destbitsleft - 8)); + int val = (int) (a >> (destbitsleft - 8)); /* Force sign-fill in case the compiler implements >> as zero-fill */ if (a < 0) @@ -1526,7 +1527,7 @@ bitfromint8(PG_FUNCTION_ARGS) /* store first fractional byte */ if (destbitsleft > srcbitsleft) { - int val = (int) (a >> (destbitsleft - 8)); + int val = (int) (a >> (destbitsleft - 8)); /* Force sign-fill in case the compiler implements >> as zero-fill */ if (a < 0) @@ -1708,6 +1709,7 @@ bitsetbit(PG_FUNCTION_ARGS) (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), errmsg("bit index %d out of valid range (0..%d)", n, bitlen - 1))); + /* * sanity check! */ diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c index 652e1e6add4..be41c977ffb 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.176 2010/02/08 20:39:51 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.177 2010/02/26 02:01:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,7 +30,7 @@ /* GUC variable */ -int bytea_output = BYTEA_OUTPUT_HEX; +int bytea_output = BYTEA_OUTPUT_HEX; typedef struct varlena unknown; @@ -205,12 +205,12 @@ byteain(PG_FUNCTION_ARGS) /* Recognize hex input */ if (inputText[0] == '\\' && inputText[1] == 'x') { - size_t len = strlen(inputText); + size_t len = strlen(inputText); - bc = (len - 2)/2 + VARHDRSZ; /* maximum possible length */ + bc = (len - 2) / 2 + VARHDRSZ; /* maximum possible length */ result = palloc(bc); bc = hex_decode(inputText + 2, len - 2, VARDATA(result)); - SET_VARSIZE(result, bc + VARHDRSZ); /* actual length */ + SET_VARSIZE(result, bc + VARHDRSZ); /* actual length */ PG_RETURN_BYTEA_P(result); } @@ -306,47 +306,47 @@ byteaout(PG_FUNCTION_ARGS) } else if (bytea_output == BYTEA_OUTPUT_ESCAPE) { - /* Print traditional escaped format */ - char *vp; - int len; - int i; + /* Print traditional escaped format */ + char *vp; + int len; + int i; - len = 1; /* empty string has 1 char */ - vp = VARDATA_ANY(vlena); - for (i = VARSIZE_ANY_EXHDR(vlena); i != 0; i--, vp++) - { - if (*vp == '\\') - len += 2; - else if ((unsigned char) *vp < 0x20 || (unsigned char) *vp > 0x7e) - len += 4; - else - len++; - } - rp = result = (char *) palloc(len); - vp = VARDATA_ANY(vlena); - for (i = VARSIZE_ANY_EXHDR(vlena); i != 0; i--, vp++) - { - if (*vp == '\\') + len = 1; /* empty string has 1 char */ + vp = VARDATA_ANY(vlena); + for (i = VARSIZE_ANY_EXHDR(vlena); i != 0; i--, vp++) { - *rp++ = '\\'; - *rp++ = '\\'; + if (*vp == '\\') + len += 2; + else if ((unsigned char) *vp < 0x20 || (unsigned char) *vp > 0x7e) + len += 4; + else + len++; } - else if ((unsigned char) *vp < 0x20 || (unsigned char) *vp > 0x7e) + rp = result = (char *) palloc(len); + vp = VARDATA_ANY(vlena); + for (i = VARSIZE_ANY_EXHDR(vlena); i != 0; i--, vp++) { - int val; /* holds unprintable chars */ - - val = *vp; - rp[0] = '\\'; - rp[3] = DIG(val & 07); - val >>= 3; - rp[2] = DIG(val & 07); - val >>= 3; - rp[1] = DIG(val & 03); - rp += 4; + if (*vp == '\\') + { + *rp++ = '\\'; + *rp++ = '\\'; + } + else if ((unsigned char) *vp < 0x20 || (unsigned char) *vp > 0x7e) + { + int val; /* holds unprintable chars */ + + val = *vp; + rp[0] = '\\'; + rp[3] = DIG(val & 07); + val >>= 3; + rp[2] = DIG(val & 07); + val >>= 3; + rp[1] = DIG(val & 03); + rp += 4; + } + else + *rp++ = *vp; } - else - *rp++ = *vp; - } } else { @@ -900,8 +900,8 @@ textoverlay(PG_FUNCTION_ARGS) { text *t1 = PG_GETARG_TEXT_PP(0); text *t2 = PG_GETARG_TEXT_PP(1); - int sp = PG_GETARG_INT32(2); /* substring start position */ - int sl = PG_GETARG_INT32(3); /* substring length */ + int sp = PG_GETARG_INT32(2); /* substring start position */ + int sl = PG_GETARG_INT32(3); /* substring length */ PG_RETURN_TEXT_P(text_overlay(t1, t2, sp, sl)); } @@ -911,10 +911,10 @@ textoverlay_no_len(PG_FUNCTION_ARGS) { text *t1 = PG_GETARG_TEXT_PP(0); text *t2 = PG_GETARG_TEXT_PP(1); - int sp = PG_GETARG_INT32(2); /* substring start position */ + int sp = PG_GETARG_INT32(2); /* substring start position */ int sl; - sl = text_length(PointerGetDatum(t2)); /* defaults to length(t2) */ + sl = text_length(PointerGetDatum(t2)); /* defaults to length(t2) */ PG_RETURN_TEXT_P(text_overlay(t1, t2, sp, sl)); } @@ -927,9 +927,9 @@ text_overlay(text *t1, text *t2, int sp, int sl) int sp_pl_sl; /* - * Check for possible integer-overflow cases. For negative sp, - * throw a "substring length" error because that's what should be - * expected according to the spec's definition of OVERLAY(). + * Check for possible integer-overflow cases. For negative sp, throw a + * "substring length" error because that's what should be expected + * according to the spec's definition of OVERLAY(). */ if (sp <= 0) ereport(ERROR, @@ -941,7 +941,7 @@ text_overlay(text *t1, text *t2, int sp, int sl) (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), errmsg("integer out of range"))); - s1 = text_substring(PointerGetDatum(t1), 1, sp-1, false); + s1 = text_substring(PointerGetDatum(t1), 1, sp - 1, false); s2 = text_substring(PointerGetDatum(t1), sp_pl_sl, -1, true); result = text_catenate(s1, t2); result = text_catenate(result, s2); @@ -1823,8 +1823,8 @@ bytea_substring(Datum str, if (length_not_specified) { /* - * Not passed a length - DatumGetByteaPSlice() grabs everything to - * the end of the string if we pass it a negative value for length. + * Not passed a length - DatumGetByteaPSlice() grabs everything to the + * end of the string if we pass it a negative value for length. */ L1 = -1; } @@ -1855,8 +1855,8 @@ bytea_substring(Datum str, /* * If the start position is past the end of the string, SQL99 says to - * return a zero-length string -- DatumGetByteaPSlice() will do that - * for us. Convert to zero-based starting position + * return a zero-length string -- DatumGetByteaPSlice() will do that for + * us. Convert to zero-based starting position */ return DatumGetByteaPSlice(str, S1 - 1, L1); } @@ -1873,8 +1873,8 @@ byteaoverlay(PG_FUNCTION_ARGS) { bytea *t1 = PG_GETARG_BYTEA_PP(0); bytea *t2 = PG_GETARG_BYTEA_PP(1); - int sp = PG_GETARG_INT32(2); /* substring start position */ - int sl = PG_GETARG_INT32(3); /* substring length */ + int sp = PG_GETARG_INT32(2); /* substring start position */ + int sl = PG_GETARG_INT32(3); /* substring length */ PG_RETURN_BYTEA_P(bytea_overlay(t1, t2, sp, sl)); } @@ -1884,10 +1884,10 @@ byteaoverlay_no_len(PG_FUNCTION_ARGS) { bytea *t1 = PG_GETARG_BYTEA_PP(0); bytea *t2 = PG_GETARG_BYTEA_PP(1); - int sp = PG_GETARG_INT32(2); /* substring start position */ + int sp = PG_GETARG_INT32(2); /* substring start position */ int sl; - sl = VARSIZE_ANY_EXHDR(t2); /* defaults to length(t2) */ + sl = VARSIZE_ANY_EXHDR(t2); /* defaults to length(t2) */ PG_RETURN_BYTEA_P(bytea_overlay(t1, t2, sp, sl)); } @@ -1900,9 +1900,9 @@ bytea_overlay(bytea *t1, bytea *t2, int sp, int sl) int sp_pl_sl; /* - * Check for possible integer-overflow cases. For negative sp, - * throw a "substring length" error because that's what should be - * expected according to the spec's definition of OVERLAY(). + * Check for possible integer-overflow cases. For negative sp, throw a + * "substring length" error because that's what should be expected + * according to the spec's definition of OVERLAY(). */ if (sp <= 0) ereport(ERROR, @@ -1914,7 +1914,7 @@ bytea_overlay(bytea *t1, bytea *t2, int sp, int sl) (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), errmsg("integer out of range"))); - s1 = bytea_substring(PointerGetDatum(t1), 1, sp-1, false); + s1 = bytea_substring(PointerGetDatum(t1), 1, sp - 1, false); s2 = bytea_substring(PointerGetDatum(t1), sp_pl_sl, -1, true); result = bytea_catenate(s1, t2); result = bytea_catenate(result, s2); @@ -3331,9 +3331,9 @@ pg_column_size(PG_FUNCTION_ARGS) static StringInfo makeStringAggState(FunctionCallInfo fcinfo) { - StringInfo state; - MemoryContext aggcontext; - MemoryContext oldcontext; + StringInfo state; + MemoryContext aggcontext; + MemoryContext oldcontext; if (!AggCheckCallContext(fcinfo, &aggcontext)) { @@ -3355,7 +3355,7 @@ makeStringAggState(FunctionCallInfo fcinfo) Datum string_agg_transfn(PG_FUNCTION_ARGS) { - StringInfo state; + StringInfo state; state = PG_ARGISNULL(0) ? NULL : (StringInfo) PG_GETARG_POINTER(0); @@ -3364,20 +3364,20 @@ string_agg_transfn(PG_FUNCTION_ARGS) { if (state == NULL) state = makeStringAggState(fcinfo); - appendStringInfoText(state, PG_GETARG_TEXT_PP(1)); /* value */ + appendStringInfoText(state, PG_GETARG_TEXT_PP(1)); /* value */ } /* - * The transition type for string_agg() is declared to be "internal", which - * is a pass-by-value type the same size as a pointer. + * The transition type for string_agg() is declared to be "internal", + * which is a pass-by-value type the same size as a pointer. */ PG_RETURN_POINTER(state); } -Datum +Datum string_agg_delim_transfn(PG_FUNCTION_ARGS) { - StringInfo state; + StringInfo state; state = PG_ARGISNULL(0) ? NULL : (StringInfo) PG_GETARG_POINTER(0); @@ -3390,12 +3390,12 @@ string_agg_delim_transfn(PG_FUNCTION_ARGS) else if (!PG_ARGISNULL(2)) appendStringInfoText(state, PG_GETARG_TEXT_PP(2)); /* delimiter */ - appendStringInfoText(state, PG_GETARG_TEXT_PP(1)); /* value */ + appendStringInfoText(state, PG_GETARG_TEXT_PP(1)); /* value */ } /* - * The transition type for string_agg() is declared to be "internal", which - * is a pass-by-value type the same size as a pointer. + * The transition type for string_agg() is declared to be "internal", + * which is a pass-by-value type the same size as a pointer. */ PG_RETURN_POINTER(state); } @@ -3403,7 +3403,7 @@ string_agg_delim_transfn(PG_FUNCTION_ARGS) Datum string_agg_finalfn(PG_FUNCTION_ARGS) { - StringInfo state; + StringInfo state; /* cannot be called directly because of internal-type argument */ Assert(AggCheckCallContext(fcinfo, NULL)); diff --git a/src/backend/utils/cache/attoptcache.c b/src/backend/utils/cache/attoptcache.c index e5f4dfcbbd4..335688606be 100644 --- a/src/backend/utils/cache/attoptcache.c +++ b/src/backend/utils/cache/attoptcache.c @@ -10,7 +10,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/cache/attoptcache.c,v 1.2 2010/02/14 18:42:17 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/attoptcache.c,v 1.3 2010/02/26 02:01:11 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -48,7 +48,7 @@ typedef struct * Flush all cache entries when pg_attribute is updated. * * When pg_attribute is updated, we must flush the cache entry at least - * for that attribute. Currently, we just flush them all. Since attribute + * for that attribute. Currently, we just flush them all. Since attribute * options are not currently used in performance-critical paths (such as * query execution), this seems OK. */ @@ -78,7 +78,7 @@ InvalidateAttoptCacheCallback(Datum arg, int cacheid, ItemPointer tuplePtr) static void InitializeAttoptCache(void) { - HASHCTL ctl; + HASHCTL ctl; /* Initialize the hash table. */ MemSet(&ctl, 0, sizeof(ctl)); @@ -87,7 +87,7 @@ InitializeAttoptCache(void) ctl.hash = tag_hash; AttoptCacheHash = hash_create("Attopt cache", 256, &ctl, - HASH_ELEM | HASH_FUNCTION); + HASH_ELEM | HASH_FUNCTION); /* Make sure we've initialized CacheMemoryContext. */ if (!CacheMemoryContext) @@ -108,18 +108,19 @@ get_attribute_options(Oid attrelid, int attnum) { AttoptCacheKey key; AttoptCacheEntry *attopt; - AttributeOpts *result; + AttributeOpts *result; HeapTuple tp; /* Find existing cache entry, if any. */ if (!AttoptCacheHash) InitializeAttoptCache(); - memset(&key, 0, sizeof(key)); /* make sure any padding bits are unset */ + memset(&key, 0, sizeof(key)); /* make sure any padding bits are + * unset */ key.attrelid = attrelid; key.attnum = attnum; attopt = (AttoptCacheEntry *) hash_search(AttoptCacheHash, - (void *) &key, + (void *) &key, HASH_FIND, NULL); @@ -141,8 +142,8 @@ get_attribute_options(Oid attrelid, int attnum) opts = NULL; else { - Datum datum; - bool isNull; + Datum datum; + bool isNull; datum = SysCacheGetAttr(ATTNUM, tp, @@ -152,7 +153,8 @@ get_attribute_options(Oid attrelid, int attnum) opts = NULL; else { - bytea *bytea_opts = attribute_reloptions(datum, false); + bytea *bytea_opts = attribute_reloptions(datum, false); + opts = MemoryContextAlloc(CacheMemoryContext, VARSIZE(bytea_opts)); memcpy(opts, bytea_opts, VARSIZE(bytea_opts)); @@ -161,13 +163,13 @@ get_attribute_options(Oid attrelid, int attnum) } /* - * It's important to create the actual cache entry only after - * reading pg_attribute, since the read could cause a cache flush. + * It's important to create the actual cache entry only after reading + * pg_attribute, since the read could cause a cache flush. */ attopt = (AttoptCacheEntry *) hash_search(AttoptCacheHash, - (void *) &key, - HASH_ENTER, - NULL); + (void *) &key, + HASH_ENTER, + NULL); attopt->opts = opts; } diff --git a/src/backend/utils/cache/inval.c b/src/backend/utils/cache/inval.c index 2f1aefcc34e..7a67f4a85e8 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.97 2010/02/14 18:42:17 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/inval.c,v 1.98 2010/02/26 02:01:11 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -158,8 +158,8 @@ typedef struct TransInvalidationInfo static TransInvalidationInfo *transInvalInfo = NULL; static SharedInvalidationMessage *SharedInvalidMessagesArray; -static int numSharedInvalidMessagesArray; -static int maxSharedInvalidMessagesArray; +static int numSharedInvalidMessagesArray; +static int maxSharedInvalidMessagesArray; /* @@ -775,7 +775,7 @@ MakeSharedInvalidMessagesArray(const SharedInvalidationMessage *msgs, int n) * We're so close to EOXact that we now we're going to lose it anyhow. */ SharedInvalidMessagesArray = palloc(maxSharedInvalidMessagesArray - * sizeof(SharedInvalidationMessage)); + * sizeof(SharedInvalidationMessage)); } if ((numSharedInvalidMessagesArray + n) > maxSharedInvalidMessagesArray) @@ -784,15 +784,15 @@ MakeSharedInvalidMessagesArray(const SharedInvalidationMessage *msgs, int n) maxSharedInvalidMessagesArray *= 2; SharedInvalidMessagesArray = repalloc(SharedInvalidMessagesArray, - maxSharedInvalidMessagesArray - * sizeof(SharedInvalidationMessage)); + maxSharedInvalidMessagesArray + * sizeof(SharedInvalidationMessage)); } /* * Append the next chunk onto the array */ memcpy(SharedInvalidMessagesArray + numSharedInvalidMessagesArray, - msgs, n * sizeof(SharedInvalidationMessage)); + msgs, n * sizeof(SharedInvalidationMessage)); numSharedInvalidMessagesArray += n; } @@ -820,18 +820,18 @@ xactGetCommittedInvalidationMessages(SharedInvalidationMessage **msgs, /* * Relcache init file invalidation requires processing both before and - * after we send the SI messages. However, we need not do anything - * unless we committed. + * after we send the SI messages. However, we need not do anything unless + * we committed. */ *RelcacheInitFileInval = transInvalInfo->RelcacheInitFileInval; /* - * Walk through TransInvalidationInfo to collect all the messages - * into a single contiguous array of invalidation messages. It must - * be contiguous so we can copy directly into WAL message. Maintain the - * order that they would be processed in by AtEOXact_Inval(), to ensure - * emulated behaviour in redo is as similar as possible to original. - * We want the same bugs, if any, not new ones. + * Walk through TransInvalidationInfo to collect all the messages into a + * single contiguous array of invalidation messages. It must be contiguous + * so we can copy directly into WAL message. Maintain the order that they + * would be processed in by AtEOXact_Inval(), to ensure emulated behaviour + * in redo is as similar as possible to original. We want the same bugs, + * if any, not new ones. */ oldcontext = MemoryContextSwitchTo(CurTransactionContext); @@ -877,7 +877,7 @@ ProcessCommittedInvalidationMessages(SharedInvalidationMessage *msgs, return; elog(trace_recovery(DEBUG4), "replaying commit with %d messages%s", nmsgs, - (RelcacheInitFileInval ? " and relcache file invalidation" : "")); + (RelcacheInitFileInval ? " and relcache file invalidation" : "")); if (RelcacheInitFileInval) RecoveryRelationCacheInitFileInvalidate(dbid, tsid, true); @@ -1149,7 +1149,7 @@ CacheInvalidateRelcacheByRelid(Oid relid) * * Sending this type of invalidation msg forces other backends to close open * smgr entries for the rel. This should be done to flush dangling open-file - * references when the physical rel is being dropped or truncated. Because + * references when the physical rel is being dropped or truncated. Because * these are nontransactional (i.e., not-rollback-able) operations, we just * send the inval message immediately without any queuing. * diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c index 4769f6f35eb..63dde8f9cb9 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.167 2010/02/14 18:42:17 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.168 2010/02/26 02:01:11 momjian Exp $ * * NOTES * Eventually, the index information should go through here, too. @@ -622,7 +622,7 @@ get_op_btree_interpretation(Oid opno, List **opfamilies, List **opstrats) { op_negated = true; ReleaseSysCacheList(catlist); - catlist = SearchSysCacheList1(AMOPOPID, + catlist = SearchSysCacheList1(AMOPOPID, ObjectIdGetDatum(op_negator)); } } diff --git a/src/backend/utils/cache/plancache.c b/src/backend/utils/cache/plancache.c index 114cd9b9756..95f010f682d 100644 --- a/src/backend/utils/cache/plancache.c +++ b/src/backend/utils/cache/plancache.c @@ -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.34 2010/01/15 22:36:34 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/plancache.c,v 1.35 2010/02/26 02:01:11 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -284,7 +284,7 @@ FastCreateCachedPlan(Node *raw_parse_tree, * CachedPlanSetParserHook: set up to use parser callback hooks * * Use this when a caller wants to manage parameter information via parser - * callbacks rather than a fixed parameter-types list. Beware that the + * callbacks rather than a fixed parameter-types list. Beware that the * information pointed to by parserSetupArg must be valid for as long as * the cached plan might be replanned! */ @@ -360,9 +360,9 @@ StoreCachedPlan(CachedPlanSource *plansource, if (plansource->fully_planned) { /* - * Planner already extracted dependencies, we don't have to ... - * except in the case of EXPLAIN. We assume here that EXPLAIN - * can't appear in a list with other commands. + * Planner already extracted dependencies, we don't have to ... except + * in the case of EXPLAIN. We assume here that EXPLAIN can't appear + * in a list with other commands. */ plan->relationOids = plan->invalItems = NIL; @@ -552,12 +552,12 @@ RevalidateCachedPlan(CachedPlanSource *plansource, bool useResOwner) /* * Generate plans for queries. * - * The planner may try to call SPI-using functions, which causes - * a problem if we're already inside one. Rather than expect - * all SPI-using code to do SPI_push whenever a replan could - * happen, it seems best to take care of the case here. + * The planner may try to call SPI-using functions, which causes a + * problem if we're already inside one. Rather than expect all + * SPI-using code to do SPI_push whenever a replan could happen, + * it seems best to take care of the case here. */ - bool pushed; + bool pushed; pushed = SPI_push_conditional(); @@ -1134,9 +1134,9 @@ ResetPlanCache(void) * aborted transactions when we can't revalidate them (cf bug #5269). * In general there is no point in invalidating utility statements * since they have no plans anyway. So mark it dead only if it - * contains at least one non-utility statement. (EXPLAIN counts as - * a non-utility statement, though, since it contains an analyzed - * query that might have dependencies.) + * contains at least one non-utility statement. (EXPLAIN counts as a + * non-utility statement, though, since it contains an analyzed query + * that might have dependencies.) */ if (plan->fully_planned) { diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index f015f5b842b..7075cdbb435 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.307 2010/02/17 04:19:39 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.308 2010/02/26 02:01:11 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -977,7 +977,7 @@ RelationInitIndexAccessInfo(Relation relation) * honestly rather than just treating it as a Form_pg_index struct. */ tuple = SearchSysCache1(INDEXRELID, - ObjectIdGetDatum(RelationGetRelid(relation))); + ObjectIdGetDatum(RelationGetRelid(relation))); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for index %u", RelationGetRelid(relation)); @@ -1427,9 +1427,9 @@ formrdesc(const char *relationName, Oid relationReltype, * * The data we insert here is pretty incomplete/bogus, but it'll serve to * get us launched. RelationCacheInitializePhase3() will read the real - * data from pg_class and replace what we've done here. Note in particular - * that relowner is left as zero; this cues RelationCacheInitializePhase3 - * that the real data isn't there yet. + * data from pg_class and replace what we've done here. Note in + * particular that relowner is left as zero; this cues + * RelationCacheInitializePhase3 that the real data isn't there yet. */ relation->rd_rel = (Form_pg_class) palloc0(CLASS_TUPLE_SIZE); @@ -1707,11 +1707,11 @@ RelationReloadIndexInfo(Relation relation) relation->rd_amcache = NULL; /* - * If it's a shared index, we might be called before backend startup - * has finished selecting a database, in which case we have no way to - * read pg_class yet. However, a shared index can never have any - * significant schema updates, so it's okay to ignore the invalidation - * signal. Just mark it valid and return without doing anything more. + * If it's a shared index, we might be called before backend startup has + * finished selecting a database, in which case we have no way to read + * pg_class yet. However, a shared index can never have any significant + * schema updates, so it's okay to ignore the invalidation signal. Just + * mark it valid and return without doing anything more. */ if (relation->rd_rel->relisshared && !criticalRelcachesBuilt) { @@ -1755,7 +1755,7 @@ RelationReloadIndexInfo(Relation relation) Form_pg_index index; tuple = SearchSysCache1(INDEXRELID, - ObjectIdGetDatum(RelationGetRelid(relation))); + ObjectIdGetDatum(RelationGetRelid(relation))); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for index %u", RelationGetRelid(relation)); @@ -1793,8 +1793,8 @@ RelationDestroyRelation(Relation relation) RelationCloseSmgr(relation); /* - * Free all the subsidiary data structures of the relcache entry, - * then the entry itself. + * Free all the subsidiary data structures of the relcache entry, then the + * entry itself. */ if (relation->rd_rel) pfree(relation->rd_rel); @@ -1908,21 +1908,21 @@ RelationClearRelation(Relation relation, bool rebuild) else { /* - * Our strategy for rebuilding an open relcache entry is to build - * a new entry from scratch, swap its contents with the old entry, - * and finally delete the new entry (along with any infrastructure - * swapped over from the old entry). This is to avoid trouble in case - * an error causes us to lose control partway through. The old entry + * Our strategy for rebuilding an open relcache entry is to build a + * new entry from scratch, swap its contents with the old entry, and + * finally delete the new entry (along with any infrastructure swapped + * over from the old entry). This is to avoid trouble in case an + * error causes us to lose control partway through. The old entry * will still be marked !rd_isvalid, so we'll try to rebuild it again - * on next access. Meanwhile it's not any less valid than it was + * on next access. Meanwhile it's not any less valid than it was * before, so any code that might expect to continue accessing it * isn't hurt by the rebuild failure. (Consider for example a * subtransaction that ALTERs a table and then gets cancelled partway * through the cache entry rebuild. The outer transaction should * still see the not-modified cache entry as valid.) The worst - * consequence of an error is leaking the necessarily-unreferenced - * new entry, and this shouldn't happen often enough for that to be - * a big problem. + * consequence of an error is leaking the necessarily-unreferenced new + * entry, and this shouldn't happen often enough for that to be a big + * problem. * * When rebuilding an open relcache entry, we must preserve ref count, * rd_createSubid/rd_newRelfilenodeSubid, and rd_toastoid state. Also @@ -1959,13 +1959,13 @@ RelationClearRelation(Relation relation, bool rebuild) /* * Perform swapping of the relcache entry contents. Within this - * process the old entry is momentarily invalid, so there *must* - * be no possibility of CHECK_FOR_INTERRUPTS within this sequence. - * Do it in all-in-line code for safety. + * process the old entry is momentarily invalid, so there *must* be no + * possibility of CHECK_FOR_INTERRUPTS within this sequence. Do it in + * all-in-line code for safety. * - * Since the vast majority of fields should be swapped, our method - * is to swap the whole structures and then re-swap those few fields - * we didn't want swapped. + * Since the vast majority of fields should be swapped, our method is + * to swap the whole structures and then re-swap those few fields we + * didn't want swapped. */ #define SWAPFIELD(fldtype, fldname) \ do { \ @@ -2536,8 +2536,8 @@ RelationBuildLocalRelation(const char *relname, * Insert relation physical and logical identifiers (OIDs) into the right * places. Note that the physical ID (relfilenode) is initially the same * as the logical ID (OID); except that for a mapped relation, we set - * relfilenode to zero and rely on RelationInitPhysicalAddr to consult - * the map. + * relfilenode to zero and rely on RelationInitPhysicalAddr to consult the + * map. */ rel->rd_rel->relisshared = shared_relation; rel->rd_rel->relistemp = rel->rd_istemp; @@ -2648,8 +2648,8 @@ RelationSetNewRelfilenode(Relation relation, TransactionId freezeXid) /* * Now update the pg_class row. However, if we're dealing with a mapped - * index, pg_class.relfilenode doesn't change; instead we have to send - * the update to the relation mapper. + * index, pg_class.relfilenode doesn't change; instead we have to send the + * update to the relation mapper. */ if (RelationIsMapped(relation)) RelationMapUpdateMap(RelationGetRelid(relation), @@ -2660,7 +2660,7 @@ RelationSetNewRelfilenode(Relation relation, TransactionId freezeXid) classform->relfilenode = newrelfilenode; /* These changes are safe even for a mapped relation */ - classform->relpages = 0; /* it's empty until further notice */ + classform->relpages = 0; /* it's empty until further notice */ classform->reltuples = 0; classform->relfrozenxid = freezeXid; @@ -2679,8 +2679,8 @@ RelationSetNewRelfilenode(Relation relation, TransactionId freezeXid) /* * Mark the rel as having been given a new relfilenode in the current - * (sub) transaction. This is a hint that can be used to optimize - * later operations on the rel in the same transaction. + * (sub) transaction. This is a hint that can be used to optimize later + * operations on the rel in the same transaction. */ relation->rd_newRelfilenodeSubid = GetCurrentSubTransactionId(); /* ... and now we have eoxact cleanup work to do */ @@ -2761,8 +2761,8 @@ RelationCacheInitializePhase2(void) oldcxt = MemoryContextSwitchTo(CacheMemoryContext); /* - * Try to load the shared relcache cache file. If unsuccessful, - * bootstrap the cache with a pre-made descriptor for pg_database. + * Try to load the shared relcache cache file. If unsuccessful, bootstrap + * the cache with a pre-made descriptor for pg_database. */ if (!load_relcache_init_file(true)) { @@ -2808,9 +2808,9 @@ RelationCacheInitializePhase3(void) oldcxt = MemoryContextSwitchTo(CacheMemoryContext); /* - * Try to load the local relcache cache file. If unsuccessful, - * bootstrap the cache with pre-made descriptors for the critical - * "nailed-in" system catalogs. + * Try to load the local relcache cache file. If unsuccessful, bootstrap + * the cache with pre-made descriptors for the critical "nailed-in" system + * catalogs. */ if (IsBootstrapProcessingMode() || !load_relcache_init_file(false)) @@ -2826,7 +2826,7 @@ RelationCacheInitializePhase3(void) formrdesc("pg_type", TypeRelation_Rowtype_Id, false, true, Natts_pg_type, Desc_pg_type); -#define NUM_CRITICAL_LOCAL_RELS 4 /* fix if you change list above */ +#define NUM_CRITICAL_LOCAL_RELS 4 /* fix if you change list above */ } MemoryContextSwitchTo(oldcxt); @@ -2881,7 +2881,7 @@ RelationCacheInitializePhase3(void) load_critical_index(TriggerRelidNameIndexId, TriggerRelationId); -#define NUM_CRITICAL_LOCAL_INDEXES 9 /* fix if you change list above */ +#define NUM_CRITICAL_LOCAL_INDEXES 9 /* fix if you change list above */ criticalRelcachesBuilt = true; } @@ -2889,10 +2889,10 @@ RelationCacheInitializePhase3(void) /* * Process critical shared indexes too. * - * DatabaseNameIndexId isn't critical for relcache loading, but rather - * for initial lookup of MyDatabaseId, without which we'll never find - * any non-shared catalogs at all. Autovacuum calls InitPostgres with - * a database OID, so it instead depends on DatabaseOidIndexId. + * DatabaseNameIndexId isn't critical for relcache loading, but rather for + * initial lookup of MyDatabaseId, without which we'll never find any + * non-shared catalogs at all. Autovacuum calls InitPostgres with a + * database OID, so it instead depends on DatabaseOidIndexId. */ if (!criticalSharedRelcachesBuilt) { @@ -2901,7 +2901,7 @@ RelationCacheInitializePhase3(void) load_critical_index(DatabaseOidIndexId, DatabaseRelationId); -#define NUM_CRITICAL_SHARED_INDEXES 2 /* fix if you change list above */ +#define NUM_CRITICAL_SHARED_INDEXES 2 /* fix if you change list above */ criticalSharedRelcachesBuilt = true; } @@ -2914,8 +2914,8 @@ RelationCacheInitializePhase3(void) * relcache entries have rules or triggers, load that info the hard way * since it isn't recorded in the cache file. * - * Whenever we access the catalogs to read data, there is a possibility - * of a shared-inval cache flush causing relcache entries to be removed. + * Whenever we access the catalogs to read data, there is a possibility of + * a shared-inval cache flush causing relcache entries to be removed. * Since hash_seq_search only guarantees to still work after the *current* * entry is removed, it's unsafe to continue the hashtable scan afterward. * We handle this by restarting the scan from scratch after each access. @@ -2943,7 +2943,7 @@ RelationCacheInitializePhase3(void) Form_pg_class relp; htup = SearchSysCache1(RELOID, - ObjectIdGetDatum(RelationGetRelid(relation))); + ObjectIdGetDatum(RelationGetRelid(relation))); if (!HeapTupleIsValid(htup)) elog(FATAL, "cache lookup failed for relation %u", RelationGetRelid(relation)); @@ -2962,9 +2962,9 @@ RelationCacheInitializePhase3(void) /* * Check the values in rd_att were set up correctly. (We cannot - * just copy them over now: formrdesc must have set up the - * rd_att data correctly to start with, because it may already - * have been copied into one or more catcache entries.) + * just copy them over now: formrdesc must have set up the rd_att + * data correctly to start with, because it may already have been + * copied into one or more catcache entries.) */ Assert(relation->rd_att->tdtypeid == relp->reltype); Assert(relation->rd_att->tdtypmod == -1); @@ -3701,8 +3701,8 @@ RelationGetExclusionInfo(Relation indexRelation, Oid *funcs; uint16 *strats; Relation conrel; - SysScanDesc conscan; - ScanKeyData skey[1]; + SysScanDesc conscan; + ScanKeyData skey[1]; HeapTuple htup; bool found; MemoryContext oldcxt; @@ -3723,9 +3723,9 @@ RelationGetExclusionInfo(Relation indexRelation, } /* - * Search pg_constraint for the constraint associated with the index. - * To make this not too painfully slow, we use the index on conrelid; - * that will hold the parent relation's OID not the index's own OID. + * Search pg_constraint for the constraint associated with the index. To + * make this not too painfully slow, we use the index on conrelid; that + * will hold the parent relation's OID not the index's own OID. */ ScanKeyInit(&skey[0], Anum_pg_constraint_conrelid, @@ -3739,7 +3739,7 @@ RelationGetExclusionInfo(Relation indexRelation, while (HeapTupleIsValid(htup = systable_getnext(conscan))) { - Form_pg_constraint conform = (Form_pg_constraint) GETSTRUCT(htup); + Form_pg_constraint conform = (Form_pg_constraint) GETSTRUCT(htup); Datum val; bool isnull; ArrayType *arr; @@ -4483,7 +4483,7 @@ RelationCacheInitFileInvalidate(bool beforeSend) * * We used to keep the init files across restarts, but that is unsafe in PITR * scenarios, and even in simple crash-recovery cases there are windows for - * the init files to become out-of-sync with the database. So now we just + * the init files to become out-of-sync with the database. So now we just * remove them during startup and expect the first backend launch to rebuild * them. Of course, this has to happen in each database of the cluster. */ diff --git a/src/backend/utils/cache/relmapper.c b/src/backend/utils/cache/relmapper.c index 4a34e7eb7e1..0320da113b4 100644 --- a/src/backend/utils/cache/relmapper.c +++ b/src/backend/utils/cache/relmapper.c @@ -23,7 +23,7 @@ * mapped catalogs can only be relocated by operations such as VACUUM FULL * and CLUSTER, which make no transactionally-significant changes: it must be * safe for the new file to replace the old, even if the transaction itself - * aborts. An important factor here is that the indexes and toast table of + * aborts. An important factor here is that the indexes and toast table of * a mapped catalog must also be mapped, so that the rewrites/relocations of * all these files commit in a single map file update rather than being tied * to transaction commit. @@ -33,7 +33,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/cache/relmapper.c,v 1.2 2010/02/07 22:00:53 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/relmapper.c,v 1.3 2010/02/26 02:01:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -58,21 +58,21 @@ /* * The map file is critical data: we have no automatic method for recovering * from loss or corruption of it. We use a CRC so that we can detect - * corruption. To minimize the risk of failed updates, the map file should + * corruption. To minimize the risk of failed updates, the map file should * be kept to no more than one standard-size disk sector (ie 512 bytes), * and we use overwrite-in-place rather than playing renaming games. * The struct layout below is designed to occupy exactly 512 bytes, which * might make filesystem updates a bit more efficient. * - * Entries in the mappings[] array are in no particular order. We could + * Entries in the mappings[] array are in no particular order. We could * speed searching by insisting on OID order, but it really shouldn't be * worth the trouble given the intended size of the mapping sets. */ #define RELMAPPER_FILENAME "pg_filenode.map" -#define RELMAPPER_FILEMAGIC 0x592717 /* version ID value */ +#define RELMAPPER_FILEMAGIC 0x592717 /* version ID value */ -#define MAX_MAPPINGS 62 /* 62 * 8 + 16 = 512 */ +#define MAX_MAPPINGS 62 /* 62 * 8 + 16 = 512 */ typedef struct RelMapping { @@ -91,7 +91,7 @@ typedef struct RelMapFile /* * The currently known contents of the shared map file and our database's - * local map file are stored here. These can be reloaded from disk + * local map file are stored here. These can be reloaded from disk * immediately whenever we receive an update sinval message. */ static RelMapFile shared_map; @@ -118,9 +118,9 @@ static RelMapFile pending_local_updates; /* non-export function prototypes */ static void apply_map_update(RelMapFile *map, Oid relationId, Oid fileNode, - bool add_okay); + bool add_okay); static void merge_map_updates(RelMapFile *map, const RelMapFile *updates, - bool add_okay); + bool add_okay); static void load_relmap_file(bool shared); static void write_relmap_file(bool shared, RelMapFile *newmap, bool write_wal, bool send_sinval, bool preserve_files, @@ -208,9 +208,9 @@ RelationMapUpdateMap(Oid relationId, Oid fileNode, bool shared, else { /* - * We don't currently support map changes within subtransactions. - * This could be done with more bookkeeping infrastructure, but it - * doesn't presently seem worth it. + * We don't currently support map changes within subtransactions. This + * could be done with more bookkeeping infrastructure, but it doesn't + * presently seem worth it. */ if (GetCurrentTransactionNestLevel() > 1) elog(ERROR, "cannot change relation mapping within subtransaction"); @@ -294,7 +294,7 @@ merge_map_updates(RelMapFile *map, const RelMapFile *updates, bool add_okay) * RelationMapRemoveMapping * * Remove a relation's entry in the map. This is only allowed for "active" - * (but not committed) local mappings. We need it so we can back out the + * (but not committed) local mappings. We need it so we can back out the * entry for the transient target file when doing VACUUM FULL/CLUSTER on * a mapped relation. */ @@ -322,7 +322,7 @@ RelationMapRemoveMapping(Oid relationId) * RelationMapInvalidate * * This routine is invoked for SI cache flush messages. We must re-read - * the indicated map file. However, we might receive a SI message in a + * the indicated map file. However, we might receive a SI message in a * process that hasn't yet, and might never, load the mapping files; * for example the autovacuum launcher, which *must not* try to read * a local map since it is attached to no particular database. @@ -390,7 +390,7 @@ AtCCI_RelationMap(void) * * During commit, this must be called as late as possible before the actual * transaction commit, so as to minimize the window where the transaction - * could still roll back after committing map changes. Although nothing + * could still roll back after committing map changes. Although nothing * critically bad happens in such a case, we still would prefer that it * not happen, since we'd possibly be losing useful updates to the relations' * pg_class row(s). @@ -457,7 +457,7 @@ AtPrepare_RelationMap(void) /* * CheckPointRelationMap * - * This is called during a checkpoint. It must ensure that any relation map + * This is called during a checkpoint. It must ensure that any relation map * updates that were WAL-logged before the start of the checkpoint are * securely flushed to disk and will not need to be replayed later. This * seems unlikely to be a performance-critical issue, so we use a simple @@ -599,10 +599,9 @@ load_relmap_file(bool shared) /* * Note: we could take RelationMappingLock in shared mode here, but it * seems unnecessary since our read() should be atomic against any - * concurrent updater's write(). If the file is updated shortly after - * we look, the sinval signaling mechanism will make us re-read it - * before we are able to access any relation that's affected by the - * change. + * concurrent updater's write(). If the file is updated shortly after we + * look, the sinval signaling mechanism will make us re-read it before we + * are able to access any relation that's affected by the change. */ if (read(fd, map, sizeof(RelMapFile)) != sizeof(RelMapFile)) ereport(FATAL, @@ -627,8 +626,8 @@ load_relmap_file(bool shared) if (!EQ_CRC32(crc, map->crc)) ereport(FATAL, - (errmsg("relation mapping file \"%s\" contains incorrect checksum", - mapfilename))); + (errmsg("relation mapping file \"%s\" contains incorrect checksum", + mapfilename))); } /* @@ -648,7 +647,7 @@ load_relmap_file(bool shared) * * Because this may be called during WAL replay when MyDatabaseId, * DatabasePath, etc aren't valid, we require the caller to pass in suitable - * values. The caller is also responsible for being sure no concurrent + * values. The caller is also responsible for being sure no concurrent * map update could be happening. */ static void @@ -676,10 +675,10 @@ write_relmap_file(bool shared, RelMapFile *newmap, * critical section, so that an open() failure need not force PANIC. * * Note: since we use BasicOpenFile, we are nominally responsible for - * ensuring the fd is closed on error. In practice, this isn't important - * because either an error happens inside the critical section, or we - * are in bootstrap or WAL replay; so an error past this point is always - * fatal anyway. + * ensuring the fd is closed on error. In practice, this isn't important + * because either an error happens inside the critical section, or we are + * in bootstrap or WAL replay; so an error past this point is always fatal + * anyway. */ if (shared) { @@ -773,11 +772,11 @@ write_relmap_file(bool shared, RelMapFile *newmap, CacheInvalidateRelmap(dbid); /* - * Make sure that the files listed in the map are not deleted if the - * outer transaction aborts. This had better be within the critical - * section too: it's not likely to fail, but if it did, we'd arrive - * at transaction abort with the files still vulnerable. PANICing - * will leave things in a good state on-disk. + * Make sure that the files listed in the map are not deleted if the outer + * transaction aborts. This had better be within the critical section + * too: it's not likely to fail, but if it did, we'd arrive at transaction + * abort with the files still vulnerable. PANICing will leave things in a + * good state on-disk. * * Note: we're cheating a little bit here by assuming that mapped files * are either in pg_global or the database's default tablespace. @@ -816,13 +815,13 @@ perform_relmap_update(bool shared, const RelMapFile *updates) RelMapFile newmap; /* - * Anyone updating a relation's mapping info should take exclusive lock - * on that rel and hold it until commit. This ensures that there will - * not be concurrent updates on the same mapping value; but there could - * easily be concurrent updates on different values in the same file. - * We cover that by acquiring the RelationMappingLock, re-reading the - * target file to ensure it's up to date, applying the updates, and - * writing the data before releasing RelationMappingLock. + * Anyone updating a relation's mapping info should take exclusive lock on + * that rel and hold it until commit. This ensures that there will not be + * concurrent updates on the same mapping value; but there could easily be + * concurrent updates on different values in the same file. We cover that + * by acquiring the RelationMappingLock, re-reading the target file to + * ensure it's up to date, applying the updates, and writing the data + * before releasing RelationMappingLock. * * There is only one RelationMappingLock. In principle we could try to * have one per mapping file, but it seems unlikely to be worth the @@ -866,8 +865,8 @@ relmap_redo(XLogRecPtr lsn, XLogRecord *record) if (info == XLOG_RELMAP_UPDATE) { xl_relmap_update *xlrec = (xl_relmap_update *) XLogRecGetData(record); - RelMapFile newmap; - char *dbpath; + RelMapFile newmap; + char *dbpath; if (xlrec->nbytes != sizeof(RelMapFile)) elog(PANIC, "relmap_redo: wrong size %u in relmap update record", @@ -878,14 +877,13 @@ relmap_redo(XLogRecPtr lsn, XLogRecord *record) dbpath = GetDatabasePath(xlrec->dbid, xlrec->tsid); /* - * Write out the new map and send sinval, but of course don't - * write a new WAL entry. There's no surrounding transaction - * to tell to preserve files, either. + * Write out the new map and send sinval, but of course don't write a + * new WAL entry. There's no surrounding transaction to tell to + * preserve files, either. * * There shouldn't be anyone else updating relmaps during WAL replay, - * so we don't bother to take the RelationMappingLock. We would - * need to do so if load_relmap_file needed to interlock against - * writers. + * so we don't bother to take the RelationMappingLock. We would need + * to do so if load_relmap_file needed to interlock against writers. */ write_relmap_file((xlrec->dbid == InvalidOid), &newmap, false, true, false, diff --git a/src/backend/utils/cache/spccache.c b/src/backend/utils/cache/spccache.c index 8a60fe4f428..3eaafe898c8 100644 --- a/src/backend/utils/cache/spccache.c +++ b/src/backend/utils/cache/spccache.c @@ -4,7 +4,7 @@ * Tablespace cache management. * * We cache the parsed version of spcoptions for each tablespace to avoid - * needing to reparse on every lookup. Right now, there doesn't appear to + * needing to reparse on every lookup. Right now, there doesn't appear to * be a measurable performance gain from doing this, but that might change * in the future as we add more options. * @@ -12,7 +12,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/cache/spccache.c,v 1.5 2010/02/14 18:42:17 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/spccache.c,v 1.6 2010/02/26 02:01:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -75,7 +75,7 @@ InvalidateTableSpaceCacheCallback(Datum arg, int cacheid, ItemPointer tuplePtr) static void InitializeTableSpaceCache(void) { - HASHCTL ctl; + HASHCTL ctl; /* Initialize the hash table. */ MemSet(&ctl, 0, sizeof(ctl)); @@ -84,7 +84,7 @@ InitializeTableSpaceCache(void) ctl.hash = oid_hash; TableSpaceCacheHash = hash_create("TableSpace cache", 16, &ctl, - HASH_ELEM | HASH_FUNCTION); + HASH_ELEM | HASH_FUNCTION); /* Make sure we've initialized CacheMemoryContext. */ if (!CacheMemoryContext) @@ -128,18 +128,18 @@ get_tablespace(Oid spcid) return spc; /* - * Not found in TableSpace cache. Check catcache. If we don't find a + * Not found in TableSpace cache. Check catcache. If we don't find a * valid HeapTuple, it must mean someone has managed to request tablespace - * details for a non-existent tablespace. We'll just treat that case as if - * no options were specified. + * details for a non-existent tablespace. We'll just treat that case as + * if no options were specified. */ tp = SearchSysCache1(TABLESPACEOID, ObjectIdGetDatum(spcid)); if (!HeapTupleIsValid(tp)) opts = NULL; else { - Datum datum; - bool isNull; + Datum datum; + bool isNull; datum = SysCacheGetAttr(TABLESPACEOID, tp, @@ -149,7 +149,8 @@ get_tablespace(Oid spcid) opts = NULL; else { - bytea *bytea_opts = tablespace_reloptions(datum, false); + bytea *bytea_opts = tablespace_reloptions(datum, false); + opts = MemoryContextAlloc(CacheMemoryContext, VARSIZE(bytea_opts)); memcpy(opts, bytea_opts, VARSIZE(bytea_opts)); } @@ -157,7 +158,7 @@ get_tablespace(Oid spcid) } /* - * Now create the cache entry. It's important to do this only after + * Now create the cache entry. It's important to do this only after * reading the pg_tablespace entry, since doing so could cause a cache * flush. */ diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index a689e302429..a6992e65d94 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.222 2010/02/17 04:19:39 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.223 2010/02/26 02:01:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -76,7 +76,8 @@ #undef _ #define _(x) err_gettext(x) -static const char *err_gettext(const char *str) +static const char * +err_gettext(const char *str) /* This extension allows gcc to check the format string for consistency with the supplied arguments. */ __attribute__((format_arg(1))); @@ -1572,9 +1573,9 @@ write_syslog(int level, const char *line) static void write_eventlog(int level, const char *line, int len) { - WCHAR *utf16; - int eventlevel = EVENTLOG_ERROR_TYPE; - static HANDLE evtHandle = INVALID_HANDLE_VALUE; + WCHAR *utf16; + int eventlevel = EVENTLOG_ERROR_TYPE; + static HANDLE evtHandle = INVALID_HANDLE_VALUE; if (evtHandle == INVALID_HANDLE_VALUE) { @@ -1611,11 +1612,11 @@ write_eventlog(int level, const char *line, int len) } /* - * Convert message to UTF16 text and write it with ReportEventW, - * but fall-back into ReportEventA if conversion failed. + * Convert message to UTF16 text and write it with ReportEventW, but + * fall-back into ReportEventA if conversion failed. * - * Also verify that we are not on our way into error recursion trouble - * due to error messages thrown deep inside pgwin32_toUTF16(). + * Also verify that we are not on our way into error recursion trouble due + * to error messages thrown deep inside pgwin32_toUTF16(). */ if (GetDatabaseEncoding() != GetPlatformEncoding() && !in_error_recursion_trouble()) @@ -1624,28 +1625,28 @@ write_eventlog(int level, const char *line, int len) if (utf16) { ReportEventW(evtHandle, - eventlevel, - 0, - 0, /* All events are Id 0 */ - NULL, - 1, - 0, - (LPCWSTR *) &utf16, - NULL); + eventlevel, + 0, + 0, /* All events are Id 0 */ + NULL, + 1, + 0, + (LPCWSTR *) &utf16, + NULL); pfree(utf16); return; } } ReportEventA(evtHandle, - eventlevel, - 0, - 0, /* All events are Id 0 */ - NULL, - 1, - 0, - &line, - NULL); + eventlevel, + 0, + 0, /* All events are Id 0 */ + NULL, + 1, + 0, + &line, + NULL); } #endif /* WIN32 */ @@ -1653,6 +1654,7 @@ static void write_console(const char *line, int len) { #ifdef WIN32 + /* * WriteConsoleW() will fail of stdout is redirected, so just fall through * to writing unconverted to the logfile in this case. @@ -1678,17 +1680,18 @@ write_console(const char *line, int len) } /* - * In case WriteConsoleW() failed, fall back to writing the message - * unconverted. + * In case WriteConsoleW() failed, fall back to writing the + * message unconverted. */ pfree(utf16); } } #else + /* - * Conversion on non-win32 platform is not implemented yet. - * It requires non-throw version of pg_do_encoding_conversion(), - * that converts unconvertable characters to '?' without errors. + * Conversion on non-win32 platform is not implemented yet. It requires + * non-throw version of pg_do_encoding_conversion(), that converts + * unconvertable characters to '?' without errors. */ #endif @@ -2733,8 +2736,9 @@ void write_stderr(const char *fmt,...) { va_list ap; + #ifdef WIN32 - char errbuf[2048]; /* Arbitrary size? */ + char errbuf[2048]; /* Arbitrary size? */ #endif fmt = _(fmt); @@ -2808,7 +2812,7 @@ trace_recovery(int trace_level) { if (trace_level < LOG && trace_level >= trace_recovery_messages) - return LOG; + return LOG; return trace_level; } diff --git a/src/backend/utils/fmgr/dfmgr.c b/src/backend/utils/fmgr/dfmgr.c index f98469801ea..c51d3d02229 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.101 2010/01/02 16:57:56 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.102 2010/02/26 02:01:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -443,7 +443,7 @@ internal_unload_library(const char *libname) else prv = file_scanner; } -#endif /* NOT_USED */ +#endif /* NOT_USED */ } static bool diff --git a/src/backend/utils/fmgr/fmgr.c b/src/backend/utils/fmgr/fmgr.c index 196fb2a0a42..04f91f1cea0 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.130 2010/02/14 18:42:17 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/utils/fmgr/fmgr.c,v 1.131 2010/02/26 02:01:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -930,7 +930,7 @@ fmgr_security_definer(PG_FUNCTION_ARGS) if (OidIsValid(fcache->userid)) SetUserIdAndSecContext(fcache->userid, - save_sec_context | SECURITY_LOCAL_USERID_CHANGE); + save_sec_context | SECURITY_LOCAL_USERID_CHANGE); if (fcache->proconfig) { diff --git a/src/backend/utils/fmgr/funcapi.c b/src/backend/utils/fmgr/funcapi.c index 6bb9e1da00b..d946aabbb58 100644 --- a/src/backend/utils/fmgr/funcapi.c +++ b/src/backend/utils/fmgr/funcapi.c @@ -7,7 +7,7 @@ * Copyright (c) 2002-2010, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/fmgr/funcapi.c,v 1.48 2010/02/14 18:42:17 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/utils/fmgr/funcapi.c,v 1.49 2010/02/26 02:01:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -795,8 +795,8 @@ get_func_input_arg_names(Datum proargnames, Datum proargmodes, /* * We expect the arrays to be 1-D arrays of the right types; verify that. - * For proargmodes, we don't need to use deconstruct_array() - * since the array data is just going to look like a C array of values. + * For proargmodes, we don't need to use deconstruct_array() since the + * array data is just going to look like a C array of values. */ arr = DatumGetArrayTypeP(proargnames); /* ensure not toasted */ if (ARR_NDIM(arr) != 1 || diff --git a/src/backend/utils/hash/pg_crc.c b/src/backend/utils/hash/pg_crc.c index cb317aa896d..0777faab4ec 100644 --- a/src/backend/utils/hash/pg_crc.c +++ b/src/backend/utils/hash/pg_crc.c @@ -19,7 +19,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/hash/pg_crc.c,v 1.23 2010/01/07 04:53:34 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/hash/pg_crc.c,v 1.24 2010/02/26 02:01:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -115,7 +115,7 @@ const uint32 pg_crc32_table[256] = { * (ECMA-182, available from http://www.ecma.ch/ecma1/STAND/ECMA-182.HTM) */ -#if SIZEOF_VOID_P < 8 /* this test must match the one in pg_crc.h */ +#if SIZEOF_VOID_P < 8 /* this test must match the one in pg_crc.h */ const uint32 pg_crc64_table0[256] = { 0x00000000, 0xA9EA3693, @@ -378,7 +378,6 @@ const uint32 pg_crc64_table1[256] = { 0x5DEDC41A, 0x1F1D25F1, 0xD80C07CD, 0x9AFCE626 }; - #else /* use int64 implementation */ const uint64 pg_crc64_table[256] = { diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c index fd653bcce58..2551e81bf7c 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.182 2010/02/14 18:42:17 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.183 2010/02/26 02:01:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -299,7 +299,7 @@ SetSessionUserId(Oid userid, bool is_superuser) * Currently there are two valid bits in SecurityRestrictionContext: * * SECURITY_LOCAL_USERID_CHANGE indicates that we are inside an operation - * that is temporarily changing CurrentUserId via these functions. This is + * that is temporarily changing CurrentUserId via these functions. This is * needed to indicate that the actual value of CurrentUserId is not in sync * with guc.c's internal state, so SET ROLE has to be disallowed. * @@ -360,7 +360,7 @@ InSecurityRestrictedOperation(void) /* * These are obsolete versions of Get/SetUserIdAndSecContext that are * only provided for bug-compatibility with some rather dubious code in - * pljava. We allow the userid to be set, but only when not inside a + * pljava. We allow the userid to be set, but only when not inside a * security restriction context. */ void @@ -690,9 +690,10 @@ CreateLockFile(const char *filename, bool amPostmaster, #ifndef WIN32 my_p_pid = getppid(); #else + /* - * Windows hasn't got getppid(), but doesn't need it since it's not - * using real kill() either... + * Windows hasn't got getppid(), but doesn't need it since it's not using + * real kill() either... */ my_p_pid = 0; #endif diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c index 034c615403d..01cb07da2d3 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.203 2010/02/14 18:42:18 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/utils/init/postinit.c,v 1.204 2010/02/26 02:01:13 momjian Exp $ * * *------------------------------------------------------------------------- @@ -75,7 +75,7 @@ static void process_settings(Oid databaseid, Oid roleid); * GetDatabaseTuple -- fetch the pg_database row for a database * * This is used during backend startup when we don't yet have any access to - * system catalogs in general. In the worst case, we can seqscan pg_database + * system catalogs in general. In the worst case, we can seqscan pg_database * using nothing but the hard-wired descriptor that relcache.c creates for * pg_database. In more typical cases, relcache.c was able to load * descriptors for both pg_database and its indexes from the shared relcache @@ -99,7 +99,7 @@ GetDatabaseTuple(const char *dbname) CStringGetDatum(dbname)); /* - * Open pg_database and fetch a tuple. Force heap scan if we haven't yet + * Open pg_database and fetch a tuple. Force heap scan if we haven't yet * built the critical shared relcache entries (i.e., we're starting up * without a shared relcache cache file). */ @@ -142,7 +142,7 @@ GetDatabaseTupleByOid(Oid dboid) ObjectIdGetDatum(dboid)); /* - * Open pg_database and fetch a tuple. Force heap scan if we haven't yet + * Open pg_database and fetch a tuple. Force heap scan if we haven't yet * built the critical shared relcache entries (i.e., we're starting up * without a shared relcache cache file). */ @@ -179,9 +179,9 @@ PerformAuthentication(Port *port) /* * In EXEC_BACKEND case, we didn't inherit the contents of pg_hba.conf - * etcetera from the postmaster, and have to load them ourselves. Note - * we are loading them into the startup transaction's memory context, - * not PostmasterContext, but that shouldn't matter. + * etcetera from the postmaster, and have to load them ourselves. Note we + * are loading them into the startup transaction's memory context, not + * PostmasterContext, but that shouldn't matter. * * FIXME: [fork/exec] Ugh. Is there a way around this overhead? */ @@ -377,7 +377,7 @@ InitCommunication(void) /* * pg_split_opts -- split a string of options and append it to an argv array * - * NB: the input string is destructively modified! Also, caller is responsible + * NB: the input string is destructively modified! Also, caller is responsible * for ensuring the argv array is large enough. The maximum possible number * of arguments added by this routine is (strlen(optstr) + 1) / 2. * @@ -495,8 +495,8 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username, InitBufferPoolBackend(); /* - * Initialize local process's access to XLOG, if appropriate. In bootstrap - * case we skip this since StartupXLOG() was run instead. + * Initialize local process's access to XLOG, if appropriate. In + * bootstrap case we skip this since StartupXLOG() was run instead. */ if (!bootstrap) (void) RecoveryInProgress(); @@ -519,8 +519,8 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username, pgstat_initialize(); /* - * Load relcache entries for the shared system catalogs. This must - * create at least an entry for pg_database. + * Load relcache entries for the shared system catalogs. This must create + * at least an entry for pg_database. */ RelationCacheInitializePhase2(); @@ -542,10 +542,10 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username, /* * Start a new transaction here before first access to db, and get a * snapshot. We don't have a use for the snapshot itself, but we're - * interested in the secondary effect that it sets RecentGlobalXmin. - * (This is critical for anything that reads heap pages, because HOT - * may decide to prune them even if the process doesn't attempt to - * modify any tuples.) + * interested in the secondary effect that it sets RecentGlobalXmin. (This + * is critical for anything that reads heap pages, because HOT may decide + * to prune them even if the process doesn't attempt to modify any + * tuples.) */ if (!bootstrap) { @@ -567,7 +567,7 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username, } else if (in_dbname != NULL) { - HeapTuple tuple; + HeapTuple tuple; Form_pg_database dbform; tuple = GetDatabaseTuple(in_dbname); @@ -584,7 +584,7 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username, else { /* caller specified database by OID */ - HeapTuple tuple; + HeapTuple tuple; Form_pg_database dbform; tuple = GetDatabaseTupleByOid(dboid); @@ -608,8 +608,8 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username, /* * Now, take a writer's lock on the database we are trying to connect to. - * If there is a concurrently running DROP DATABASE on that database, - * this will block us until it finishes (and has committed its update of + * If there is a concurrently running DROP DATABASE on that database, this + * will block us until it finishes (and has committed its update of * pg_database). * * Note that the lock is not held long, only until the end of this startup @@ -634,7 +634,7 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username, */ if (!bootstrap && !am_walsender) { - HeapTuple tuple; + HeapTuple tuple; tuple = GetDatabaseTuple(dbname); if (!HeapTupleIsValid(tuple) || @@ -722,8 +722,8 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username, process_settings(MyDatabaseId, GetSessionUserId()); /* - * Re-read the pg_database row for our database, check permissions and - * set up database-specific GUC settings. We can't do this until all the + * Re-read the pg_database row for our database, check permissions and set + * up database-specific GUC settings. We can't do this until all the * database-access infrastructure is up. (Also, it wants to know if the * user is a superuser, so the above stuff has to happen first.) */ @@ -752,7 +752,7 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username, /* * Now process any command-line switches that were included in the startup - * packet, if we are in a regular backend. We couldn't do this before + * packet, if we are in a regular backend. We couldn't do this before * because we didn't know if client is a superuser. */ gucctx = am_superuser ? PGC_SUSET : PGC_BACKEND; @@ -846,7 +846,7 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username, static void process_settings(Oid databaseid, Oid roleid) { - Relation relsetting; + Relation relsetting; if (!IsUnderPostmaster) return; diff --git a/src/backend/utils/mb/mbutils.c b/src/backend/utils/mb/mbutils.c index 9064c85fc6e..2dc537fd058 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.93 2010/02/14 18:42:18 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.94 2010/02/26 02:01:14 momjian Exp $ */ #include "postgres.h" @@ -484,7 +484,7 @@ length_in_encoding(PG_FUNCTION_ARGS) Datum pg_encoding_max_length_sql(PG_FUNCTION_ARGS) { - int encoding = PG_GETARG_INT32(0); + int encoding = PG_GETARG_INT32(0); if (PG_VALID_ENCODING(encoding)) PG_RETURN_INT32(pg_wchar_table[encoding].maxmblen); @@ -984,7 +984,7 @@ GetPlatformEncoding(void) if (PlatformEncoding == NULL) { /* try to determine encoding of server's environment locale */ - int encoding = pg_get_encoding_from_locale(""); + int encoding = pg_get_encoding_from_locale(""); if (encoding < 0) encoding = PG_SQL_ASCII; @@ -1016,7 +1016,7 @@ pgwin32_toUTF16(const char *str, int len, int *utf16len) { utf16 = (WCHAR *) palloc(sizeof(WCHAR) * (len + 1)); dstlen = MultiByteToWideChar(codepage, 0, str, len, utf16, len); - utf16[dstlen] = L'\0'; + utf16[dstlen] = L '\0'; } else { @@ -1029,7 +1029,7 @@ pgwin32_toUTF16(const char *str, int len, int *utf16len) utf16 = (WCHAR *) palloc(sizeof(WCHAR) * (len + 1)); dstlen = MultiByteToWideChar(CP_UTF8, 0, utf8, len, utf16, len); - utf16[dstlen] = L'\0'; + utf16[dstlen] = L '\0'; if (utf8 != str) pfree(utf8); @@ -1038,7 +1038,7 @@ pgwin32_toUTF16(const char *str, int len, int *utf16len) if (dstlen == 0 && len > 0) { pfree(utf16); - return NULL; /* error */ + return NULL; /* error */ } if (utf16len) diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index d5330788452..5aefacc8d72 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.542 2010/02/25 13:26:15 mha Exp $ + * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.543 2010/02/26 02:01:14 momjian Exp $ * *-------------------------------------------------------------------- */ @@ -119,7 +119,7 @@ extern bool fullPageWrites; extern int vacuum_defer_cleanup_age; extern int ssl_renegotiation_limit; -int trace_recovery_messages = LOG; +int trace_recovery_messages = LOG; #ifdef TRACE_SORT extern bool trace_sort; @@ -1215,8 +1215,8 @@ static struct config_bool ConfigureNamesBool[] = { {"recovery_connections", PGC_POSTMASTER, WAL_SETTINGS, gettext_noop("During recovery, allows connections and queries. " - " During normal running, causes additional info to be written" - " to WAL to enable hot standby mode on WAL standby nodes."), + " During normal running, causes additional info to be written" + " to WAL to enable hot standby mode on WAL standby nodes."), NULL }, &XLogRequestRecoveryConnections, @@ -1248,7 +1248,7 @@ static struct config_bool ConfigureNamesBool[] = {"lo_compat_privileges", PGC_SUSET, COMPAT_OPTIONS_PREVIOUS, gettext_noop("Enables backward compatibility mode for privilege checks on large objects"), gettext_noop("Skips privilege checks when reading or modifying large objects, " - "for compatibility with PostgreSQL releases prior to 9.0.") + "for compatibility with PostgreSQL releases prior to 9.0.") }, &lo_compat_privileges, false, NULL, NULL @@ -2614,9 +2614,9 @@ static struct config_string ConfigureNamesString[] = { {"application_name", PGC_USERSET, LOGGING, - gettext_noop("Sets the application name to be reported in statistics and logs."), - NULL, - GUC_IS_NAME | GUC_REPORT | GUC_NOT_IN_SAMPLE + gettext_noop("Sets the application name to be reported in statistics and logs."), + NULL, + GUC_IS_NAME | GUC_REPORT | GUC_NOT_IN_SAMPLE }, &application_name, "", assign_application_name, NULL @@ -4687,16 +4687,16 @@ 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("parameter \"%s\" cannot be changed without restarting the server", - name))); + errmsg("parameter \"%s\" cannot be changed without restarting the server", + name))); return true; } if (context != PGC_POSTMASTER) { ereport(elevel, (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM), - errmsg("parameter \"%s\" cannot be changed without restarting the server", - name))); + errmsg("parameter \"%s\" cannot be changed without restarting the server", + name))); return false; } break; @@ -4758,20 +4758,20 @@ set_config_option(const char *name, const char *value, /* * Disallow changing GUC_NOT_WHILE_SEC_REST values if we are inside a - * security restriction context. We can reject this regardless of - * the GUC context or source, mainly because sources that it might be - * reasonable to override for won't be seen while inside a function. + * security restriction context. We can reject this regardless of the GUC + * context or source, mainly because sources that it might be reasonable + * to override for won't be seen while inside a function. * * Note: variables marked GUC_NOT_WHILE_SEC_REST should usually be marked * GUC_NO_RESET_ALL as well, because ResetAllOptions() doesn't check this. * An exception might be made if the reset value is assumed to be "safe". * * Note: this flag is currently used for "session_authorization" and - * "role". We need to prohibit changing these inside a local userid + * "role". We need to prohibit changing these inside a local userid * context because when we exit it, GUC won't be notified, leaving things * out of sync. (This could be fixed by forcing a new GUC nesting level, - * but that would change behavior in possibly-undesirable ways.) Also, - * we prohibit changing these in a security-restricted operation because + * but that would change behavior in possibly-undesirable ways.) Also, we + * prohibit changing these in a security-restricted operation because * otherwise RESET could be used to regain the session user's privileges. */ if (record->flags & GUC_NOT_WHILE_SEC_REST) @@ -4779,8 +4779,8 @@ set_config_option(const char *name, const char *value, if (InLocalUserIdChange()) { /* - * Phrasing of this error message is historical, but it's the - * most common case. + * Phrasing of this error message is historical, but it's the most + * common case. */ ereport(elevel, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), @@ -6132,8 +6132,8 @@ ShowAllGUCConfig(DestReceiver *dest) int i; TupOutputState *tstate; TupleDesc tupdesc; - Datum values[3]; - bool isnull[3] = { false, false, false }; + Datum values[3]; + bool isnull[3] = {false, false, false}; /* need a tuple descriptor representing three TEXT columns */ tupdesc = CreateTemplateTupleDesc(3, false); @@ -6150,7 +6150,7 @@ ShowAllGUCConfig(DestReceiver *dest) for (i = 0; i < num_guc_variables; i++) { struct config_generic *conf = guc_variables[i]; - char *setting; + char *setting; if ((conf->flags & GUC_NO_SHOW_ALL) || ((conf->flags & GUC_SUPERUSER_ONLY) && !am_superuser)) @@ -7591,7 +7591,7 @@ assign_transaction_read_only(bool newval, bool doit, GucSource source) { ereport(GUC_complaint_elevel(source), (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("cannot set transaction read-write mode during recovery"))); + errmsg("cannot set transaction read-write mode during recovery"))); /* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */ if (source != PGC_S_OVERRIDE) return false; diff --git a/src/backend/utils/misc/rbtree.c b/src/backend/utils/misc/rbtree.c index 9211a8704b3..b5da48dd9c0 100644 --- a/src/backend/utils/misc/rbtree.c +++ b/src/backend/utils/misc/rbtree.c @@ -13,14 +13,14 @@ * * Red-black trees are a type of balanced binary tree wherein (1) any child of * a red node is always black, and (2) every path from root to leaf traverses - * an equal number of black nodes. From these properties, it follows that the + * an equal number of black nodes. From these properties, it follows that the * longest path from root to leaf is only about twice as long as the shortest, * so lookups are guaranteed to run in O(lg n) time. * * Copyright (c) 1996-2009, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/misc/rbtree.c,v 1.2 2010/02/11 22:17:27 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/misc/rbtree.c,v 1.3 2010/02/26 02:01:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -35,7 +35,7 @@ /* * Values for RBNode->iteratorState */ -#define InitialState (0) +#define InitialState (0) #define FirstStepDone (1) #define SecondStepDone (2) #define ThirdStepDone (3) @@ -49,13 +49,13 @@ typedef struct RBNode { uint32 iteratorState:2, - color: 1 , - unused: 29; + color: 1, + unused:29; struct RBNode *left; struct RBNode *right; struct RBNode *parent; void *data; -} RBNode; +} RBNode; struct RBTree { @@ -86,7 +86,7 @@ RBNode sentinel = {InitialState, RBBLACK, 0, RBNIL, RBNIL, NULL, NULL}; RBTree * rb_create(rb_comparator comparator, rb_appendator appendator, - rb_freefunc freefunc, void *arg) + rb_freefunc freefunc, void *arg) { RBTree *tree = palloc(sizeof(RBTree)); @@ -94,6 +94,7 @@ rb_create(rb_comparator comparator, rb_appendator appendator, tree->comparator = comparator; tree->appendator = appendator; tree->freefunc = freefunc; + tree->arg = arg; return tree; @@ -205,10 +206,10 @@ rb_rotate_right(RBTree *rb, RBNode *x) /* * Maintain Red-Black tree balance after inserting node x. * - * The newly inserted node is always initially marked red. That may lead to + * The newly inserted node is always initially marked red. That may lead to * a situation where a red node has a red child, which is prohibited. We can * always fix the problem by a series of color changes and/or "rotations", - * which move the problem progressively higher up in the tree. If one of the + * which move the problem progressively higher up in the tree. If one of the * two red nodes is the root, we can always fix the problem by changing the * root from red to black. * @@ -219,8 +220,8 @@ static void rb_insert_fixup(RBTree *rb, RBNode *x) { /* - * x is always a red node. Initially, it is the newly inserted node. - * Each iteration of this loop moves it higher up in the tree. + * x is always a red node. Initially, it is the newly inserted node. Each + * iteration of this loop moves it higher up in the tree. */ while (x != rb->root && x->parent->color == RBRED) { @@ -234,11 +235,11 @@ rb_insert_fixup(RBTree *rb, RBNode *x) * grandparent still has a problem. * * If the uncle is black, we will perform one or two "rotations" to - * balance the tree. Either x or x->parent will take the grandparent's - * position in the tree and recolored black, and the original - * grandparent will be recolored red and become a child of that node. - * This always leaves us with a valid red-black tree, so the loop - * will terminate. + * balance the tree. Either x or x->parent will take the + * grandparent's position in the tree and recolored black, and the + * original grandparent will be recolored red and become a child of + * that node. This always leaves us with a valid red-black tree, so + * the loop will terminate. */ if (x->parent == x->parent->parent->left) { @@ -250,6 +251,7 @@ rb_insert_fixup(RBTree *rb, RBNode *x) x->parent->color = RBBLACK; y->color = RBBLACK; x->parent->parent->color = RBRED; + x = x->parent->parent; } else @@ -265,6 +267,7 @@ rb_insert_fixup(RBTree *rb, RBNode *x) /* recolor and rotate */ x->parent->color = RBBLACK; x->parent->parent->color = RBRED; + rb_rotate_right(rb, x->parent->parent); } } @@ -279,6 +282,7 @@ rb_insert_fixup(RBTree *rb, RBNode *x) x->parent->color = RBBLACK; y->color = RBBLACK; x->parent->parent->color = RBRED; + x = x->parent->parent; } else @@ -291,6 +295,7 @@ rb_insert_fixup(RBTree *rb, RBNode *x) } x->parent->color = RBBLACK; x->parent->parent->color = RBRED; + rb_rotate_left(rb, x->parent->parent); } } @@ -355,6 +360,7 @@ rb_insert(RBTree *rb, void *data) x->left = RBNIL; x->right = RBNIL; x->color = RBRED; + x->iteratorState = InitialState; /* insert node in tree */ @@ -392,11 +398,11 @@ rb_delete_fixup(RBTree *rb, RBNode *x) while (x != rb->root && x->color == RBBLACK) { /* - * Left and right cases are symmetric. Any nodes that are children - * of x have a black-height one less than the remainder of the nodes - * in the tree. We rotate and recolor nodes to move the problem up - * the tree: at some stage we'll either fix the problem, or reach the - * root (where the black-height is allowed to decrease). + * Left and right cases are symmetric. Any nodes that are children of + * x have a black-height one less than the remainder of the nodes in + * the tree. We rotate and recolor nodes to move the problem up the + * tree: at some stage we'll either fix the problem, or reach the root + * (where the black-height is allowed to decrease). */ if (x == x->parent->left) { @@ -406,6 +412,7 @@ rb_delete_fixup(RBTree *rb, RBNode *x) { w->color = RBBLACK; x->parent->color = RBRED; + rb_rotate_left(rb, x->parent); w = x->parent->right; } @@ -413,6 +420,7 @@ rb_delete_fixup(RBTree *rb, RBNode *x) if (w->left->color == RBBLACK && w->right->color == RBBLACK) { w->color = RBRED; + x = x->parent; } else @@ -421,14 +429,16 @@ rb_delete_fixup(RBTree *rb, RBNode *x) { w->left->color = RBBLACK; w->color = RBRED; + rb_rotate_right(rb, w); w = x->parent->right; } w->color = x->parent->color; x->parent->color = RBBLACK; w->right->color = RBBLACK; + rb_rotate_left(rb, x->parent); - x = rb->root; /* Arrange for loop to terminate. */ + x = rb->root; /* Arrange for loop to terminate. */ } } else @@ -439,6 +449,7 @@ rb_delete_fixup(RBTree *rb, RBNode *x) { w->color = RBBLACK; x->parent->color = RBRED; + rb_rotate_right(rb, x->parent); w = x->parent->left; } @@ -446,6 +457,7 @@ rb_delete_fixup(RBTree *rb, RBNode *x) if (w->right->color == RBBLACK && w->left->color == RBBLACK) { w->color = RBRED; + x = x->parent; } else @@ -454,14 +466,16 @@ rb_delete_fixup(RBTree *rb, RBNode *x) { w->right->color = RBBLACK; w->color = RBRED; + rb_rotate_left(rb, w); w = x->parent->left; } w->color = x->parent->color; x->parent->color = RBBLACK; w->left->color = RBBLACK; + rb_rotate_right(rb, x->parent); - x = rb->root; /* Arrange for loop to terminate. */ + x = rb->root; /* Arrange for loop to terminate. */ } } } @@ -519,9 +533,8 @@ rb_delete_node(RBTree *rb, RBNode *z) } /* - * If we removed the tree successor of z rather than z itself, then - * attach the data for the removed node to the one we were supposed to - * remove. + * If we removed the tree successor of z rather than z itself, then attach + * the data for the removed node to the one we were supposed to remove. */ if (y != z) z->data = y->data; @@ -550,7 +563,8 @@ rb_delete(RBTree *rb, void *data) { /* found node to delete */ if (rb->freefunc) - rb->freefunc(node->data); + rb->freefunc (node->data); + node->data = NULL; rb_delete_node(rb, node); return; @@ -756,16 +770,16 @@ rb_begin_iterate(RBTree *rb, RBOrderControl ctrl) switch (ctrl) { - case LeftRightWalk: /* visit left, then self, then right */ + case LeftRightWalk: /* visit left, then self, then right */ iterator->iterate = rb_left_right_iterator; break; - case RightLeftWalk: /* visit right, then self, then left */ + case RightLeftWalk: /* visit right, then self, then left */ iterator->iterate = rb_right_left_iterator; break; - case DirectWalk: /* visit self, then left, then right */ + case DirectWalk: /* visit self, then left, then right */ iterator->iterate = rb_direct_iterator; break; - case InvertedWalk: /* visit left, then right, then self */ + case InvertedWalk: /* visit left, then right, then self */ iterator->iterate = rb_inverted_iterator; break; default: diff --git a/src/backend/utils/mmgr/aset.c b/src/backend/utils/mmgr/aset.c index 718451a2b4f..197f1fcd141 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.82 2010/01/02 16:57:58 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mmgr/aset.c,v 1.83 2010/02/26 02:01:14 momjian Exp $ * * NOTE: * This is a new (Feb. 05, 1999) implementation of the allocation set @@ -286,13 +286,13 @@ AllocSetFreeIndex(Size size) tsize = (size - 1) >> ALLOC_MINBITS; /* - * At this point we need to obtain log2(tsize)+1, ie, the number - * of not-all-zero bits at the right. We used to do this with a - * shift-and-count loop, but this function is enough of a hotspot - * to justify micro-optimization effort. The best approach seems - * to be to use a lookup table. Note that this code assumes that - * ALLOCSET_NUM_FREELISTS <= 17, since we only cope with two bytes - * of the tsize value. + * At this point we need to obtain log2(tsize)+1, ie, the number of + * not-all-zero bits at the right. We used to do this with a + * shift-and-count loop, but this function is enough of a hotspot to + * justify micro-optimization effort. The best approach seems to be + * to use a lookup table. Note that this code assumes that + * ALLOCSET_NUM_FREELISTS <= 17, since we only cope with two bytes of + * the tsize value. */ t = tsize >> 8; idx = t ? LogTable256[t] + 8 : LogTable256[tsize]; diff --git a/src/backend/utils/mmgr/portalmem.c b/src/backend/utils/mmgr/portalmem.c index 58d9da4301f..f7b26cdd974 100644 --- a/src/backend/utils/mmgr/portalmem.c +++ b/src/backend/utils/mmgr/portalmem.c @@ -12,7 +12,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/mmgr/portalmem.c,v 1.117 2010/02/18 03:06:46 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mmgr/portalmem.c,v 1.118 2010/02/26 02:01:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -330,9 +330,9 @@ PortalReleaseCachedPlan(Portal portal) portal->cplan = NULL; /* - * We must also clear portal->stmts which is now a dangling - * reference to the cached plan's plan list. This protects any - * code that might try to examine the Portal later. + * We must also clear portal->stmts which is now a dangling reference + * to the cached plan's plan list. This protects any code that might + * try to examine the Portal later. */ portal->stmts = NIL; } @@ -822,16 +822,16 @@ AtSubAbort_Portals(SubTransactionId mySubid, /* * Any resources belonging to the portal will be released in the - * upcoming transaction-wide cleanup; they will be gone before we - * run PortalDrop. + * upcoming transaction-wide cleanup; they will be gone before we run + * PortalDrop. */ portal->resowner = NULL; /* - * Although we can't delete the portal data structure proper, we - * can release any memory in subsidiary contexts, such as executor - * state. The cleanup hook was the last thing that might have - * needed data there. + * Although we can't delete the portal data structure proper, we can + * release any memory in subsidiary contexts, such as executor state. + * The cleanup hook was the last thing that might have needed data + * there. */ MemoryContextDeleteChildren(PortalGetHeapMemory(portal)); } diff --git a/src/backend/utils/sort/tuplesort.c b/src/backend/utils/sort/tuplesort.c index 08e19967876..11ce8edad5d 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.94 2010/01/02 16:57:58 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/sort/tuplesort.c,v 1.95 2010/02/26 02:01:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -2797,8 +2797,8 @@ comparetup_index_btree(const SortTuple *a, const SortTuple *b, */ if (state->enforceUnique && !equal_hasnull && tuple1 != tuple2) { - Datum values[INDEX_MAX_KEYS]; - bool isnull[INDEX_MAX_KEYS]; + Datum values[INDEX_MAX_KEYS]; + bool isnull[INDEX_MAX_KEYS]; index_deform_tuple(tuple1, tupDes, values, isnull); ereport(ERROR, diff --git a/src/backend/utils/sort/tuplestore.c b/src/backend/utils/sort/tuplestore.c index 6bc35153ab8..b752d677718 100644 --- a/src/backend/utils/sort/tuplestore.c +++ b/src/backend/utils/sort/tuplestore.c @@ -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.50 2010/01/02 16:57:58 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/sort/tuplestore.c,v 1.51 2010/02/26 02:01:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -586,7 +586,7 @@ tuplestore_putvalues(Tuplestorestate *state, TupleDesc tdesc, tuplestore_puttuple_common(state, (void *) tuple); - MemoryContextSwitchTo(oldcxt); + MemoryContextSwitchTo(oldcxt); } static void diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c index c10472b892c..6d22e6cd63c 100644 --- a/src/backend/utils/time/snapmgr.c +++ b/src/backend/utils/time/snapmgr.c @@ -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.14 2010/01/02 16:57:58 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/time/snapmgr.c,v 1.15 2010/02/26 02:01:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -226,9 +226,9 @@ CopySnapshot(Snapshot snapshot) /* * Setup subXID array. Don't bother to copy it if it had overflowed, - * though, because it's not used anywhere in that case. Except if it's - * a snapshot taken during recovery; all the top-level XIDs are in subxip - * as well in that case, so we mustn't lose them. + * though, because it's not used anywhere in that case. Except if it's a + * snapshot taken during recovery; all the top-level XIDs are in subxip as + * well in that case, so we mustn't lose them. */ if (snapshot->subxcnt > 0 && (!snapshot->suboverflowed || snapshot->takenDuringRecovery)) @@ -263,7 +263,7 @@ FreeSnapshot(Snapshot snapshot) * * If the passed snapshot is a statically-allocated one, or it is possibly * subject to a future command counter update, create a new long-lived copy - * with active refcount=1. Otherwise, only increment the refcount. + * with active refcount=1. Otherwise, only increment the refcount. */ void PushActiveSnapshot(Snapshot snap) @@ -275,8 +275,8 @@ PushActiveSnapshot(Snapshot snap) newactive = MemoryContextAlloc(TopTransactionContext, sizeof(ActiveSnapshotElt)); /* - * Checking SecondarySnapshot is probably useless here, but it seems better - * to be sure. + * Checking SecondarySnapshot is probably useless here, but it seems + * better to be sure. */ if (snap == CurrentSnapshot || snap == SecondarySnapshot || !snap->copied) newactive->as_snap = CopySnapshot(snap); diff --git a/src/backend/utils/time/tqual.c b/src/backend/utils/time/tqual.c index 794007c5e54..bc19df813f3 100644 --- a/src/backend/utils/time/tqual.c +++ b/src/backend/utils/time/tqual.c @@ -50,7 +50,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/time/tqual.c,v 1.117 2010/02/08 14:10:21 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/time/tqual.c,v 1.118 2010/02/26 02:01:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -93,7 +93,7 @@ static bool XidInMVCCSnapshot(TransactionId xid, Snapshot snapshot); * Also, if we are cleaning up HEAP_MOVED_IN or HEAP_MOVED_OFF entries, then * we can always set the hint bits, since pre-9.0 VACUUM FULL always used * synchronous commits and didn't move tuples that weren't previously - * hinted. (This is not known by this subroutine, but is applied by its + * hinted. (This is not known by this subroutine, but is applied by its * callers.) Note: old-style VACUUM FULL is gone, but we have to keep this * module's support for MOVED_OFF/MOVED_IN flag bits for as long as we * support in-place update from pre-9.0 databases. @@ -1274,17 +1274,17 @@ XidInMVCCSnapshot(TransactionId xid, Snapshot snapshot) return true; /* - * Snapshot information is stored slightly differently in snapshots - * taken during recovery. + * Snapshot information is stored slightly differently in snapshots taken + * during recovery. */ if (!snapshot->takenDuringRecovery) { /* - * If the snapshot contains full subxact data, the fastest way to check - * things is just to compare the given XID against both subxact XIDs and - * top-level XIDs. If the snapshot overflowed, we have to use pg_subtrans - * to convert a subxact XID to its parent XID, but then we need only look - * at top-level XIDs not subxacts. + * If the snapshot contains full subxact data, the fastest way to + * check things is just to compare the given XID against both subxact + * XIDs and top-level XIDs. If the snapshot overflowed, we have to + * use pg_subtrans to convert a subxact XID to its parent XID, but + * then we need only look at top-level XIDs not subxacts. */ if (!snapshot->suboverflowed) { @@ -1305,8 +1305,9 @@ XidInMVCCSnapshot(TransactionId xid, Snapshot snapshot) xid = SubTransGetTopmostTransaction(xid); /* - * If xid was indeed a subxact, we might now have an xid < xmin, so - * recheck to avoid an array scan. No point in rechecking xmax. + * If xid was indeed a subxact, we might now have an xid < xmin, + * so recheck to avoid an array scan. No point in rechecking + * xmax. */ if (TransactionIdPrecedes(xid, snapshot->xmin)) return false; @@ -1323,9 +1324,9 @@ XidInMVCCSnapshot(TransactionId xid, Snapshot snapshot) int32 j; /* - * In recovery we store all xids in the subxact array because it - * is by far the bigger array, and we mostly don't know which xids - * are top-level and which are subxacts. The xip array is empty. + * In recovery we store all xids in the subxact array because it is by + * far the bigger array, and we mostly don't know which xids are + * top-level and which are subxacts. The xip array is empty. * * We start by searching subtrans, if we overflowed. */ @@ -1335,8 +1336,9 @@ XidInMVCCSnapshot(TransactionId xid, Snapshot snapshot) xid = SubTransGetTopmostTransaction(xid); /* - * If xid was indeed a subxact, we might now have an xid < xmin, so - * recheck to avoid an array scan. No point in rechecking xmax. + * If xid was indeed a subxact, we might now have an xid < xmin, + * so recheck to avoid an array scan. No point in rechecking + * xmax. */ if (TransactionIdPrecedes(xid, snapshot->xmin)) return false; |