summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Momjian2007-11-15 23:23:44 +0000
committerBruce Momjian2007-11-15 23:23:44 +0000
commit5cf2611cab9001dd193c1ff86df16f4432523b05 (patch)
tree586143f4040574e0a4f303d277dc72796acb4be0
parent3aa6adb6e882b32621e3810a1d025692053e52ee (diff)
Fix pgindent to properly handle 'else' and single-line comments on the
same line; previous fix was only partial. Re-run pgindent on files that need it.
-rw-r--r--src/backend/access/transam/slru.c25
-rw-r--r--src/backend/commands/trigger.c107
-rw-r--r--src/backend/rewrite/rewriteHandler.c25
-rw-r--r--src/backend/utils/adt/tsvector_op.c58
-rw-r--r--src/backend/utils/mb/conv.c50
-rw-r--r--src/bin/psql/mbprint.c10
-rwxr-xr-xsrc/tools/pgindent/pgindent89
7 files changed, 202 insertions, 162 deletions
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index ba03913cb6..bad5f70db9 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -168,7 +168,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(LWLockId)); /* buffer_locks[] */
if (nlsns > 0)
- sz += MAXALIGN(nslots * nlsns * sizeof(XLogRecPtr)); /* group_lsn[] */
+ sz += MAXALIGN(nslots * nlsns * sizeof(XLogRecPtr)); /* group_lsn[] */
return BUFFERALIGN(sz) + BLCKSZ * nslots;
}
@@ -339,7 +339,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
/* indeed, the I/O must have failed */
if (shared->page_status[slotno] == SLRU_PAGE_READ_IN_PROGRESS)
shared->page_status[slotno] = SLRU_PAGE_EMPTY;
- else /* write_in_progress */
+ else /* write_in_progress */
{
shared->page_status[slotno] = SLRU_PAGE_VALID;
shared->page_dirty[slotno] = true;
@@ -669,21 +669,22 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruFlush fdata)
int fd = -1;
/*
- * Honor the write-WAL-before-data rule, if appropriate, so that we do
- * not write out data before associated WAL records. This is the same
- * action performed during FlushBuffer() in the main buffer manager.
+ * Honor the write-WAL-before-data rule, if appropriate, so that we do not
+ * write out data before associated WAL records. This is the same action
+ * performed during FlushBuffer() in the main buffer manager.
*/
if (shared->group_lsn != NULL)
{
/*
- * We must determine the largest async-commit LSN for the page.
- * This is a bit tedious, but since this entire function is a slow
- * path anyway, it seems better to do this here than to maintain
- * a per-page LSN variable (which'd need an extra comparison in the
+ * We must determine the largest async-commit LSN for the page. This
+ * is a bit tedious, but since this entire function is a slow path
+ * anyway, it seems better to do this here than to maintain a per-page
+ * LSN variable (which'd need an extra comparison in the
* transaction-commit path).
*/
XLogRecPtr max_lsn;
- int lsnindex, lsnoff;
+ int lsnindex,
+ lsnoff;
lsnindex = slotno * shared->lsn_groups_per_page;
max_lsn = shared->group_lsn[lsnindex++];
@@ -699,8 +700,8 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruFlush fdata)
{
/*
* As noted above, elog(ERROR) is not acceptable here, so if
- * XLogFlush were to fail, we must PANIC. This isn't much of
- * a restriction because XLogFlush is just about all critical
+ * XLogFlush were to fail, we must PANIC. This isn't much of a
+ * restriction because XLogFlush is just about all critical
* section anyway, but let's make sure.
*/
START_CRIT_SECTION();
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index e39a635e68..f7bc7d4f6d 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -42,7 +42,7 @@
/* GUC variables */
-int SessionReplicationRole = SESSION_REPLICATION_ROLE_ORIGIN;
+int SessionReplicationRole = SESSION_REPLICATION_ROLE_ORIGIN;
/* Local function prototypes */
@@ -67,7 +67,7 @@ static void AfterTriggerSaveEvent(ResultRelInfo *relinfo, int event,
*
* constraintOid, if nonzero, says that this trigger is being created
* internally to implement that constraint. A suitable pg_depend entry will
- * be made to link the trigger to that constraint. constraintOid is zero when
+ * be made to link the trigger to that constraint. constraintOid is zero when
* executing a user-entered CREATE TRIGGER command.
*
* Note: can return InvalidOid if we decided to not create a trigger at all,
@@ -211,11 +211,11 @@ CreateTrigger(CreateTrigStmt *stmt, Oid constraintOid)
}
/*
- * If the command is a user-entered CREATE CONSTRAINT TRIGGER command
- * that references one of the built-in RI_FKey trigger functions, assume
- * it is from a dump of a pre-7.3 foreign key constraint, and take steps
- * to convert this legacy representation into a regular foreign key
- * constraint. Ugly, but necessary for loading old dump files.
+ * If the command is a user-entered CREATE CONSTRAINT TRIGGER command that
+ * references one of the built-in RI_FKey trigger functions, assume it is
+ * from a dump of a pre-7.3 foreign key constraint, and take steps to
+ * convert this legacy representation into a regular foreign key
+ * constraint. Ugly, but necessary for loading old dump files.
*/
if (stmt->isconstraint && !OidIsValid(constraintOid) &&
list_length(stmt->args) >= 6 &&
@@ -421,8 +421,8 @@ CreateTrigger(CreateTrigStmt *stmt, Oid constraintOid)
{
/*
* It's for a constraint, so make it an internal dependency of the
- * constraint. We can skip depending on the relations, as there'll
- * be an indirect dependency via the constraint.
+ * constraint. We can skip depending on the relations, as there'll be
+ * an indirect dependency via the constraint.
*/
referenced.classId = ConstraintRelationId;
referenced.objectId = constraintOid;
@@ -461,7 +461,7 @@ CreateTrigger(CreateTrigStmt *stmt, Oid constraintOid)
* full-fledged foreign key constraints.
*
* The conversion is complex because a pre-7.3 foreign key involved three
- * separate triggers, which were reported separately in dumps. While the
+ * separate triggers, which were reported separately in dumps. While the
* single trigger on the referencing table adds no new information, we need
* to know the trigger functions of both of the triggers on the referenced
* table to build the constraint declaration. Also, due to lack of proper
@@ -469,13 +469,14 @@ CreateTrigger(CreateTrigStmt *stmt, Oid constraintOid)
* an incomplete set of triggers resulting in an only partially enforced
* FK constraint. (This would happen if one of the tables had been dropped
* and re-created, but only if the DB had been affected by a 7.0 pg_dump bug
- * that caused loss of tgconstrrelid information.) We choose to translate to
+ * that caused loss of tgconstrrelid information.) We choose to translate to
* an FK constraint only when we've seen all three triggers of a set. This is
* implemented by storing unmatched items in a list in TopMemoryContext.
* We match triggers together by comparing the trigger arguments (which
* include constraint name, table and column names, so should be good enough).
*/
-typedef struct {
+typedef struct
+{
List *args; /* list of (T_String) Values or NIL */
Oid funcoids[3]; /* OIDs of trigger functions */
/* The three function OIDs are stored in the order update, delete, child */
@@ -486,7 +487,7 @@ ConvertTriggerToFK(CreateTrigStmt *stmt, Oid funcoid)
{
static List *info_list = NIL;
- static const char * const funcdescr[3] = {
+ static const char *const funcdescr[3] = {
gettext_noop("Found referenced table's UPDATE trigger."),
gettext_noop("Found referenced table's DELETE trigger."),
gettext_noop("Found referencing table's trigger.")
@@ -511,7 +512,7 @@ ConvertTriggerToFK(CreateTrigStmt *stmt, Oid funcoid)
i = 0;
foreach(l, stmt->args)
{
- Value *arg = (Value *) lfirst(l);
+ Value *arg = (Value *) lfirst(l);
i++;
if (i < 4) /* skip constraint and table names */
@@ -537,7 +538,7 @@ ConvertTriggerToFK(CreateTrigStmt *stmt, Oid funcoid)
i = 0;
foreach(l, fk_attrs)
{
- Value *arg = (Value *) lfirst(l);
+ Value *arg = (Value *) lfirst(l);
if (i++ > 0)
appendStringInfoChar(&buf, ',');
@@ -548,7 +549,7 @@ ConvertTriggerToFK(CreateTrigStmt *stmt, Oid funcoid)
i = 0;
foreach(l, pk_attrs)
{
- Value *arg = (Value *) lfirst(l);
+ Value *arg = (Value *) lfirst(l);
if (i++ > 0)
appendStringInfoChar(&buf, ',');
@@ -598,9 +599,9 @@ ConvertTriggerToFK(CreateTrigStmt *stmt, Oid funcoid)
MemoryContext oldContext;
ereport(NOTICE,
- (errmsg("ignoring incomplete trigger group for constraint \"%s\" %s",
- constr_name, buf.data),
- errdetail(funcdescr[funcnum])));
+ (errmsg("ignoring incomplete trigger group for constraint \"%s\" %s",
+ constr_name, buf.data),
+ errdetail(funcdescr[funcnum])));
oldContext = MemoryContextSwitchTo(TopMemoryContext);
info = (OldTriggerInfo *) palloc0(sizeof(OldTriggerInfo));
info->args = copyObject(stmt->args);
@@ -614,9 +615,9 @@ ConvertTriggerToFK(CreateTrigStmt *stmt, Oid funcoid)
{
/* Second trigger of set */
ereport(NOTICE,
- (errmsg("ignoring incomplete trigger group for constraint \"%s\" %s",
- constr_name, buf.data),
- errdetail(funcdescr[funcnum])));
+ (errmsg("ignoring incomplete trigger group for constraint \"%s\" %s",
+ constr_name, buf.data),
+ errdetail(funcdescr[funcnum])));
}
else
{
@@ -1184,8 +1185,8 @@ RelationBuildTriggers(Relation relation)
int i;
val = DatumGetByteaP(fastgetattr(htup,
- Anum_pg_trigger_tgargs,
- tgrel->rd_att, &isnull));
+ Anum_pg_trigger_tgargs,
+ tgrel->rd_att, &isnull));
if (isnull)
elog(ERROR, "tgargs is null in trigger for relation \"%s\"",
RelationGetRelationName(relation));
@@ -1637,7 +1638,7 @@ ExecBSInsertTriggers(EState *estate, ResultRelInfo *relinfo)
trigger->tgenabled == TRIGGER_DISABLED)
continue;
}
- else /* ORIGIN or LOCAL role */
+ else /* ORIGIN or LOCAL role */
{
if (trigger->tgenabled == TRIGGER_FIRES_ON_REPLICA ||
trigger->tgenabled == TRIGGER_DISABLED)
@@ -1696,7 +1697,7 @@ ExecBRInsertTriggers(EState *estate, ResultRelInfo *relinfo,
trigger->tgenabled == TRIGGER_DISABLED)
continue;
}
- else /* ORIGIN or LOCAL role */
+ else /* ORIGIN or LOCAL role */
{
if (trigger->tgenabled == TRIGGER_FIRES_ON_REPLICA ||
trigger->tgenabled == TRIGGER_DISABLED)
@@ -1768,7 +1769,7 @@ ExecBSDeleteTriggers(EState *estate, ResultRelInfo *relinfo)
trigger->tgenabled == TRIGGER_DISABLED)
continue;
}
- else /* ORIGIN or LOCAL role */
+ else /* ORIGIN or LOCAL role */
{
if (trigger->tgenabled == TRIGGER_FIRES_ON_REPLICA ||
trigger->tgenabled == TRIGGER_DISABLED)
@@ -1834,7 +1835,7 @@ ExecBRDeleteTriggers(EState *estate, ResultRelInfo *relinfo,
trigger->tgenabled == TRIGGER_DISABLED)
continue;
}
- else /* ORIGIN or LOCAL role */
+ else /* ORIGIN or LOCAL role */
{
if (trigger->tgenabled == TRIGGER_FIRES_ON_REPLICA ||
trigger->tgenabled == TRIGGER_DISABLED)
@@ -1919,7 +1920,7 @@ ExecBSUpdateTriggers(EState *estate, ResultRelInfo *relinfo)
trigger->tgenabled == TRIGGER_DISABLED)
continue;
}
- else /* ORIGIN or LOCAL role */
+ else /* ORIGIN or LOCAL role */
{
if (trigger->tgenabled == TRIGGER_FIRES_ON_REPLICA ||
trigger->tgenabled == TRIGGER_DISABLED)
@@ -1990,7 +1991,7 @@ ExecBRUpdateTriggers(EState *estate, ResultRelInfo *relinfo,
trigger->tgenabled == TRIGGER_DISABLED)
continue;
}
- else /* ORIGIN or LOCAL role */
+ else /* ORIGIN or LOCAL role */
{
if (trigger->tgenabled == TRIGGER_FIRES_ON_REPLICA ||
trigger->tgenabled == TRIGGER_DISABLED)
@@ -2669,7 +2670,7 @@ afterTriggerInvokeEvents(AfterTriggerEventList *events,
trigdesc = rInfo->ri_TrigDesc;
finfo = rInfo->ri_TrigFunctions;
instr = rInfo->ri_TrigInstrument;
- if (trigdesc == NULL) /* should not happen */
+ if (trigdesc == NULL) /* should not happen */
elog(ERROR, "relation %u has no triggers",
event->ate_relid);
}
@@ -2725,7 +2726,7 @@ afterTriggerInvokeEvents(AfterTriggerEventList *events,
if (local_estate)
{
- ListCell *l;
+ ListCell *l;
foreach(l, estate->es_trig_target_relations)
{
@@ -2905,8 +2906,8 @@ AfterTriggerFireDeferred(void)
ActiveSnapshot = CopySnapshot(GetTransactionSnapshot());
/*
- * Run all the remaining triggers. Loop until they are all gone, in
- * case some trigger queues more for us to do.
+ * Run all the remaining triggers. Loop until they are all gone, in case
+ * some trigger queues more for us to do.
*/
while (afterTriggerMarkEvents(events, NULL, false))
{
@@ -2940,13 +2941,13 @@ AfterTriggerEndXact(bool isCommit)
*
* Since all the info is in TopTransactionContext or children thereof, we
* don't really need to do anything to reclaim memory. However, the
- * pending-events list could be large, and so it's useful to discard
- * it as soon as possible --- especially if we are aborting because we
- * ran out of memory for the list!
+ * pending-events list could be large, and so it's useful to discard it as
+ * soon as possible --- especially if we are aborting because we ran out
+ * of memory for the list!
*
- * (Note: any event_cxts of child subtransactions could also be
- * deleted here, but we have no convenient way to find them, so we
- * leave it to TopTransactionContext reset to clean them up.)
+ * (Note: any event_cxts of child subtransactions could also be deleted
+ * here, but we have no convenient way to find them, so we leave it to
+ * TopTransactionContext reset to clean them up.)
*/
if (afterTriggers && afterTriggers->event_cxt)
MemoryContextDelete(afterTriggers->event_cxt);
@@ -2973,9 +2974,8 @@ AfterTriggerBeginSubXact(void)
/*
* Allocate more space in the stacks if needed. (Note: because the
- * minimum nest level of a subtransaction is 2, we waste the first
- * couple entries of each array; not worth the notational effort to
- * avoid it.)
+ * minimum nest level of a subtransaction is 2, we waste the first couple
+ * entries of each array; not worth the notational effort to avoid it.)
*/
while (my_level >= afterTriggers->maxtransdepth)
{
@@ -3071,16 +3071,17 @@ AfterTriggerEndSubXact(bool isCommit)
afterTriggers->state_stack[my_level] = NULL;
Assert(afterTriggers->query_depth ==
afterTriggers->depth_stack[my_level]);
+
/*
* It's entirely possible that the subxact created an event_cxt but
* there is not anything left in it (because all the triggers were
- * fired at end-of-statement). If so, we should release the context
- * to prevent memory leakage in a long sequence of subtransactions.
- * We can detect whether there's anything of use in the context by
- * seeing if anything was added to the global events list since
- * subxact start. (This test doesn't catch every case where the
- * context is deletable; for instance maybe the only additions were
- * from a sub-sub-xact. But it handles the common case.)
+ * fired at end-of-statement). If so, we should release the context
+ * to prevent memory leakage in a long sequence of subtransactions. We
+ * can detect whether there's anything of use in the context by seeing
+ * if anything was added to the global events list since subxact
+ * start. (This test doesn't catch every case where the context is
+ * deletable; for instance maybe the only additions were from a
+ * sub-sub-xact. But it handles the common case.)
*/
if (afterTriggers->cxt_stack[my_level] &&
afterTriggers->events.tail == afterTriggers->events_stack[my_level].tail)
@@ -3615,7 +3616,7 @@ AfterTriggerSaveEvent(ResultRelInfo *relinfo, int event, bool row_trigger,
trigger->tgenabled == TRIGGER_DISABLED)
continue;
}
- else /* ORIGIN or LOCAL role */
+ else /* ORIGIN or LOCAL role */
{
if (trigger->tgenabled == TRIGGER_FIRES_ON_REPLICA ||
trigger->tgenabled == TRIGGER_DISABLED)
@@ -3668,10 +3669,10 @@ AfterTriggerSaveEvent(ResultRelInfo *relinfo, int event, bool row_trigger,
/*
* If we don't yet have an event context for the current (sub)xact,
- * create one. Make it a child of CurTransactionContext to ensure it
+ * create one. Make it a child of CurTransactionContext to ensure it
* will go away if the subtransaction aborts.
*/
- if (my_level > 1) /* subtransaction? */
+ if (my_level > 1) /* subtransaction? */
{
Assert(my_level < afterTriggers->maxtransdepth);
cxtptr = &afterTriggers->cxt_stack[my_level];
diff --git a/src/backend/rewrite/rewriteHandler.c b/src/backend/rewrite/rewriteHandler.c
index d83f21f256..82d1f239d1 100644
--- a/src/backend/rewrite/rewriteHandler.c
+++ b/src/backend/rewrite/rewriteHandler.c
@@ -53,7 +53,7 @@ static Node *get_assignment_input(Node *node);
static void rewriteValuesRTE(RangeTblEntry *rte, Relation target_relation,
List *attrnos);
static void markQueryForLocking(Query *qry, Node *jtnode,
- bool forUpdate, bool noWait);
+ bool forUpdate, bool noWait);
static List *matchLocks(CmdType event, RuleLock *rulelocks,
int varno, Query *parsetree);
static Query *fireRIRrules(Query *parsetree, List *activeRIRs);
@@ -1038,11 +1038,10 @@ matchLocks(CmdType event,
RewriteRule *oneLock = rulelocks->rules[i];
/*
- * Suppress ON INSERT/UPDATE/DELETE rules that are disabled
- * or configured to not fire during the current sessions
- * replication role. ON SELECT rules will always be applied
- * in order to keep views working even in LOCAL or REPLICA
- * role.
+ * Suppress ON INSERT/UPDATE/DELETE rules that are disabled or
+ * configured to not fire during the current sessions replication
+ * role. ON SELECT rules will always be applied in order to keep views
+ * working even in LOCAL or REPLICA role.
*/
if (oneLock->event != CMD_SELECT)
{
@@ -1052,7 +1051,7 @@ matchLocks(CmdType event,
oneLock->enabled == RULE_DISABLED)
continue;
}
- else /* ORIGIN or LOCAL ROLE */
+ else /* ORIGIN or LOCAL ROLE */
{
if (oneLock->enabled == RULE_FIRES_ON_REPLICA ||
oneLock->enabled == RULE_DISABLED)
@@ -1695,22 +1694,22 @@ RewriteQuery(Query *parsetree, List *rewrite_events)
case CMD_INSERT:
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("cannot perform INSERT RETURNING on relation \"%s\"",
- RelationGetRelationName(rt_entry_relation)),
+ errmsg("cannot perform INSERT RETURNING on relation \"%s\"",
+ RelationGetRelationName(rt_entry_relation)),
errhint("You need an unconditional ON INSERT DO INSTEAD rule with a RETURNING clause.")));
break;
case CMD_UPDATE:
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("cannot perform UPDATE RETURNING on relation \"%s\"",
- RelationGetRelationName(rt_entry_relation)),
+ errmsg("cannot perform UPDATE RETURNING on relation \"%s\"",
+ RelationGetRelationName(rt_entry_relation)),
errhint("You need an unconditional ON UPDATE DO INSTEAD rule with a RETURNING clause.")));
break;
case CMD_DELETE:
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("cannot perform DELETE RETURNING on relation \"%s\"",
- RelationGetRelationName(rt_entry_relation)),
+ errmsg("cannot perform DELETE RETURNING on relation \"%s\"",
+ RelationGetRelationName(rt_entry_relation)),
errhint("You need an unconditional ON DELETE DO INSTEAD rule with a RETURNING clause.")));
break;
default:
diff --git a/src/backend/utils/adt/tsvector_op.c b/src/backend/utils/adt/tsvector_op.c
index 7961e37fa5..d83f2cbfb2 100644
--- a/src/backend/utils/adt/tsvector_op.c
+++ b/src/backend/utils/adt/tsvector_op.c
@@ -254,7 +254,7 @@ tsvector_setweight(PG_FUNCTION_ARGS)
}
static int
-compareEntry(char *ptra, WordEntry * a, char *ptrb, WordEntry * b)
+compareEntry(char *ptra, WordEntry *a, char *ptrb, WordEntry *b)
{
if (a->len == b->len)
{
@@ -271,8 +271,8 @@ compareEntry(char *ptra, WordEntry * a, char *ptrb, WordEntry * b)
* Return the number added (might be less than expected due to overflow)
*/
static int4
-add_pos(TSVector src, WordEntry * srcptr,
- TSVector dest, WordEntry * destptr,
+add_pos(TSVector src, WordEntry *srcptr,
+ TSVector dest, WordEntry *destptr,
int4 maxpos)
{
uint16 *clen = &_POSVECPTR(dest, destptr)->npos;
@@ -288,7 +288,7 @@ add_pos(TSVector src, WordEntry * srcptr,
startlen = *clen;
for (i = 0;
i < slen && *clen < MAXNUMPOS &&
- (*clen == 0 || WEP_GETPOS(dpos[*clen - 1]) != MAXENTRYPOS - 1);
+ (*clen == 0 || WEP_GETPOS(dpos[*clen - 1]) != MAXENTRYPOS - 1);
i++)
{
WEP_SETWEIGHT(dpos[*clen], WEP_GETWEIGHT(spos[i]));
@@ -369,7 +369,7 @@ tsvector_concat(PG_FUNCTION_ARGS)
memcpy(data + dataoff, _POSVECPTR(in1, ptr1), POSDATALEN(in1, ptr1) * sizeof(WordEntryPos) + sizeof(uint16));
dataoff += POSDATALEN(in1, ptr1) * sizeof(WordEntryPos) + sizeof(uint16);
}
-
+
ptr++;
ptr1++;
i1--;
@@ -415,7 +415,7 @@ tsvector_concat(PG_FUNCTION_ARGS)
if (ptr2->haspos)
dataoff += add_pos(in2, ptr2, out, ptr, maxpos) * sizeof(WordEntryPos);
}
- else /* must have ptr2->haspos */
+ else /* must have ptr2->haspos */
{
int addlen = add_pos(in2, ptr2, out, ptr, maxpos);
@@ -482,8 +482,8 @@ tsvector_concat(PG_FUNCTION_ARGS)
}
/*
- * Instead of checking each offset individually, we check for overflow
- * of pos fields once at the end.
+ * Instead of checking each offset individually, we check for overflow of
+ * pos fields once at the end.
*/
if (dataoff > MAXSTRPOS)
ereport(ERROR,
@@ -504,7 +504,7 @@ tsvector_concat(PG_FUNCTION_ARGS)
* compare 2 string values
*/
static int4
-ValCompare(CHKVAL * chkval, WordEntry * ptr, QueryOperand * item)
+ValCompare(CHKVAL *chkval, WordEntry *ptr, QueryOperand *item)
{
if (ptr->len == item->length)
return strncmp(
@@ -525,7 +525,7 @@ checkclass_str(CHKVAL *chkval, WordEntry *val, QueryOperand *item)
WordEntryPos *ptr;
uint16 len;
- posvec = (WordEntryPosVector *)
+ posvec = (WordEntryPosVector *)
(chkval->values + SHORTALIGN(val->pos + val->len));
len = posvec->npos;
@@ -544,9 +544,9 @@ checkclass_str(CHKVAL *chkval, WordEntry *val, QueryOperand *item)
* is there value 'val' in array or not ?
*/
static bool
-checkcondition_str(void *checkval, QueryOperand * val)
+checkcondition_str(void *checkval, QueryOperand *val)
{
- CHKVAL *chkval = (CHKVAL *) checkval;
+ CHKVAL *chkval = (CHKVAL *) checkval;
WordEntry *StopLow = chkval->arrb;
WordEntry *StopHigh = chkval->arre;
WordEntry *StopMiddle;
@@ -580,8 +580,8 @@ checkcondition_str(void *checkval, QueryOperand * val)
*
*/
bool
-TS_execute(QueryItem * curitem, void *checkval, bool calcnot,
- bool (*chkcond) (void *checkval, QueryOperand * val))
+TS_execute(QueryItem *curitem, void *checkval, bool calcnot,
+ bool (*chkcond) (void *checkval, QueryOperand *val))
{
/* since this function recurses, it could be driven to stack overflow */
check_stack_depth();
@@ -589,7 +589,7 @@ TS_execute(QueryItem * curitem, void *checkval, bool calcnot,
if (curitem->type == QI_VAL)
return chkcond(checkval, (QueryOperand *) curitem);
- switch(curitem->operator.oper)
+ switch (curitem->operator.oper)
{
case OP_NOT:
if (calcnot)
@@ -710,7 +710,7 @@ ts_match_tq(PG_FUNCTION_ARGS)
* that have a weight equal to one of the weights in 'weight' bitmask.
*/
static int
-check_weight(TSVector txt, WordEntry * wptr, int8 weight)
+check_weight(TSVector txt, WordEntry *wptr, int8 weight)
{
int len = POSDATALEN(txt, wptr);
int num = 0;
@@ -726,7 +726,7 @@ check_weight(TSVector txt, WordEntry * wptr, int8 weight)
}
static WordEntry **
-SEI_realloc(WordEntry ** in, uint32 *len)
+SEI_realloc(WordEntry **in, uint32 *len)
{
if (*len == 0 || in == NULL)
{
@@ -742,7 +742,7 @@ SEI_realloc(WordEntry ** in, uint32 *len)
}
static int
-compareStatWord(StatEntry * a, WordEntry * b, tsstat * stat, TSVector txt)
+compareStatWord(StatEntry *a, WordEntry *b, tsstat *stat, TSVector txt)
{
if (a->len == b->len)
return strncmp(
@@ -754,7 +754,7 @@ compareStatWord(StatEntry * a, WordEntry * b, tsstat * stat, TSVector txt)
}
static tsstat *
-formstat(tsstat * stat, TSVector txt, WordEntry ** entry, uint32 len)
+formstat(tsstat *stat, TSVector txt, WordEntry **entry, uint32 len)
{
tsstat *newstat;
uint32 totallen,
@@ -861,16 +861,16 @@ formstat(tsstat * stat, TSVector txt, WordEntry ** entry, uint32 len)
* This is written like a custom aggregate function, because the
* original plan was to do just that. Unfortunately, an aggregate function
* can't return a set, so that plan was abandoned. If that limitation is
- * lifted in the future, ts_stat could be a real aggregate function so that
+ * lifted in the future, ts_stat could be a real aggregate function so that
* you could use it like this:
*
- * SELECT ts_stat(vector_column) FROM vector_table;
+ * SELECT ts_stat(vector_column) FROM vector_table;
*
- * where vector_column is a tsvector-type column in vector_table.
+ * where vector_column is a tsvector-type column in vector_table.
*/
static tsstat *
-ts_accum(tsstat * stat, Datum data)
+ts_accum(tsstat *stat, Datum data)
{
tsstat *newstat;
TSVector txt = DatumGetTSVector(data);
@@ -1012,7 +1012,7 @@ ts_accum(tsstat * stat, Datum data)
static void
ts_setup_firstcall(FunctionCallInfo fcinfo, FuncCallContext *funcctx,
- tsstat * stat)
+ tsstat *stat)
{
TupleDesc tupdesc;
MemoryContext oldcontext;
@@ -1232,11 +1232,11 @@ static bool
istexttype(Oid typid)
{
/* varchar(n) and char(n) are binary-compatible with text */
- if (typid==TEXTOID || typid==VARCHAROID || typid==BPCHAROID)
+ if (typid == TEXTOID || typid == VARCHAROID || typid == BPCHAROID)
return true;
/* Allow domains over these types, too */
typid = getBaseType(typid);
- if (typid==TEXTOID || typid==VARCHAROID || typid==BPCHAROID)
+ if (typid == TEXTOID || typid == VARCHAROID || typid == BPCHAROID)
return true;
return false;
}
@@ -1280,7 +1280,7 @@ tsvector_update_trigger(PG_FUNCTION_ARGS, bool config_column)
Oid cfgId;
/* Check call context */
- if (!CALLED_AS_TRIGGER(fcinfo)) /* internal error */
+ if (!CALLED_AS_TRIGGER(fcinfo)) /* internal error */
elog(ERROR, "tsvector_update_trigger: not fired by trigger manager");
trigdata = (TriggerData *) fcinfo->context;
@@ -1318,7 +1318,7 @@ tsvector_update_trigger(PG_FUNCTION_ARGS, bool config_column)
/* Find the configuration to use */
if (config_column)
{
- int config_attr_num;
+ int config_attr_num;
config_attr_num = SPI_fnumber(rel->rd_att, trigger->tgargs[1]);
if (config_attr_num == SPI_ERROR_NOATTRIBUTE)
@@ -1342,7 +1342,7 @@ tsvector_update_trigger(PG_FUNCTION_ARGS, bool config_column)
}
else
{
- List *names;
+ List *names;
names = stringToQualifiedNameList(trigger->tgargs[1]);
/* require a schema so that results are not search path dependent */
diff --git a/src/backend/utils/mb/conv.c b/src/backend/utils/mb/conv.c
index d09e903dd1..321c250b30 100644
--- a/src/backend/utils/mb/conv.c
+++ b/src/backend/utils/mb/conv.c
@@ -244,7 +244,7 @@ mic2latin_with_table(const unsigned char *mic,
static int
compare1(const void *p1, const void *p2)
{
- uint32 v1,
+ uint32 v1,
v2;
v1 = *(uint32 *) p1;
@@ -259,7 +259,7 @@ compare1(const void *p1, const void *p2)
static int
compare2(const void *p1, const void *p2)
{
- uint32 v1,
+ uint32 v1,
v2;
v1 = *(uint32 *) p1;
@@ -274,10 +274,13 @@ compare2(const void *p1, const void *p2)
static int
compare3(const void *p1, const void *p2)
{
- uint32 s1, s2, d1, d2;
+ uint32 s1,
+ s2,
+ d1,
+ d2;
- s1 = *(uint32 *)p1;
- s2 = *((uint32 *)p1 + 1);
+ s1 = *(uint32 *) p1;
+ s2 = *((uint32 *) p1 + 1);
d1 = ((pg_utf_to_local_combined *) p2)->utf1;
d2 = ((pg_utf_to_local_combined *) p2)->utf2;
return (s1 > d1 || (s1 == d1 && s2 > d2)) ? 1 : ((s1 == d1 && s2 == d2) ? 0 : -1);
@@ -290,7 +293,7 @@ compare3(const void *p1, const void *p2)
static int
compare4(const void *p1, const void *p2)
{
- uint32 v1,
+ uint32 v1,
v2;
v1 = *(uint32 *) p1;
@@ -301,7 +304,8 @@ compare4(const void *p1, const void *p2)
/*
* convert 32bit wide character to mutibye stream pointed to by iso
*/
-static unsigned char *set_iso_code(unsigned char *iso, uint32 code)
+static unsigned char *
+set_iso_code(unsigned char *iso, uint32 code)
{
if (code & 0xff000000)
*iso++ = code >> 24;
@@ -330,12 +334,12 @@ static unsigned char *set_iso_code(unsigned char *iso, uint32 code)
*/
void
UtfToLocal(const unsigned char *utf, unsigned char *iso,
- const pg_utf_to_local *map, const pg_utf_to_local_combined *cmap,
+ const pg_utf_to_local *map, const pg_utf_to_local_combined *cmap,
int size1, int size2, int encoding, int len)
{
- uint32 iutf;
- uint32 cutf[2];
- uint32 code;
+ uint32 iutf;
+ uint32 cutf[2];
+ uint32 code;
pg_utf_to_local *p;
pg_utf_to_local_combined *cp;
int l;
@@ -384,10 +388,10 @@ UtfToLocal(const unsigned char *utf, unsigned char *iso,
*/
if (cmap && len > l)
{
- const unsigned char *utf_save = utf;
- int len_save = len;
- int l_save = l;
-
+ const unsigned char *utf_save = utf;
+ int len_save = len;
+ int l_save = l;
+
len -= l;
l = pg_utf_mblen(utf);
@@ -407,7 +411,7 @@ UtfToLocal(const unsigned char *utf, unsigned char *iso,
sizeof(pg_utf_to_local), compare1);
if (p == NULL)
report_untranslatable_char(PG_UTF8, encoding,
- (const char *) (utf_save - l_save), len_save);
+ (const char *) (utf_save - l_save), len_save);
iso = set_iso_code(iso, p->code);
}
@@ -446,7 +450,7 @@ UtfToLocal(const unsigned char *utf, unsigned char *iso,
sizeof(pg_utf_to_local), compare1);
if (p == NULL)
report_untranslatable_char(PG_UTF8, encoding,
- (const char *) (utf_save - l_save), len_save);
+ (const char *) (utf_save - l_save), len_save);
iso = set_iso_code(iso, p->code);
p = bsearch(&cutf[1], map, size1,
@@ -457,13 +461,13 @@ UtfToLocal(const unsigned char *utf, unsigned char *iso,
code = p->code;
}
}
- else /* no cmap or no remaining data */
+ else /* no cmap or no remaining data */
{
p = bsearch(&iutf, map, size1,
sizeof(pg_utf_to_local), compare1);
if (p == NULL)
report_untranslatable_char(PG_UTF8, encoding,
- (const char *) (utf - l), len);
+ (const char *) (utf - l), len);
code = p->code;
}
iso = set_iso_code(iso, code);
@@ -491,7 +495,7 @@ UtfToLocal(const unsigned char *utf, unsigned char *iso,
*/
void
LocalToUtf(const unsigned char *iso, unsigned char *utf,
- const pg_local_to_utf *map, const pg_local_to_utf_combined *cmap,
+ const pg_local_to_utf *map, const pg_local_to_utf_combined *cmap,
int size1, int size2, int encoding, int len)
{
unsigned int iiso;
@@ -549,13 +553,13 @@ LocalToUtf(const unsigned char *iso, unsigned char *utf,
if (p == NULL)
{
/*
- * not found in the ordinary map. if there's a combined
- * character map, try with it
+ * not found in the ordinary map. if there's a combined character
+ * map, try with it
*/
if (cmap)
{
cp = bsearch(&iiso, cmap, size2,
- sizeof(pg_local_to_utf_combined), compare4);
+ sizeof(pg_local_to_utf_combined), compare4);
if (cp)
{
diff --git a/src/bin/psql/mbprint.c b/src/bin/psql/mbprint.c
index 0e05b3b280..6523079bbb 100644
--- a/src/bin/psql/mbprint.c
+++ b/src/bin/psql/mbprint.c
@@ -21,7 +21,7 @@
* To avoid version-skew problems, this file must not use declarations
* from pg_wchar.h: the encoding IDs we are dealing with are determined
* by the libpq.so we are linked with, and that might not match the
- * numbers we see at compile time. (If this file were inside libpq,
+ * numbers we see at compile time. (If this file were inside libpq,
* the problem would go away...)
*
* Hence, we have our own definition of pg_wchar, and we get the values
@@ -246,7 +246,7 @@ pg_wcssize(unsigned char *pwcs, size_t len, int encoding, int *result_width,
linewidth += 4;
format_size += 4;
}
- else /* Output it as-is */
+ else /* Output it as-is */
{
linewidth += w;
format_size += 1;
@@ -257,7 +257,7 @@ pg_wcssize(unsigned char *pwcs, size_t len, int encoding, int *result_width,
linewidth += 6; /* \u0000 */
format_size += 6;
}
- else /* All other chars */
+ else /* All other chars */
{
linewidth += w;
format_size += chlen;
@@ -321,7 +321,7 @@ pg_wcsformat(unsigned char *pwcs, size_t len, int encoding,
linewidth += 4;
ptr += 4;
}
- else /* Output it as-is */
+ else /* Output it as-is */
{
linewidth += w;
*ptr++ = *pwcs;
@@ -343,7 +343,7 @@ pg_wcsformat(unsigned char *pwcs, size_t len, int encoding,
ptr += 6;
linewidth += 6;
}
- else /* All other chars */
+ else /* All other chars */
{
int i;
diff --git a/src/tools/pgindent/pgindent b/src/tools/pgindent/pgindent
index 007e04ae70..abe0684d7e 100755
--- a/src/tools/pgindent/pgindent
+++ b/src/tools/pgindent/pgindent
@@ -33,22 +33,31 @@ fi
for FILE
do
cat "$FILE" |
-# convert // comments to /* */
+
+# Convert // comments to /* */
sed 's;^\([ ]*\)//\(.*\)$;\1/* \2 */;g' |
+
# Avoid bug that converts 'x =- 1' to 'x = -1'
sed 's;=- ;-= ;g' |
-# mark some comments for special treatment later
+
+# Mark some comments for special treatment later
sed 's;/\* *---;/*---X_X;g' |
-# workaround for indent bug with 'else' handling
-# trim trailing space after single-line after-'else' comment
-# so next test can be done easily
- sed 's;\([} ]\)else[ ]*\(/\*.*\*/\)[ ]*$;\1else \2;g' |
-# indent multi-line after-'else' comment so BSD indent will move it properly
- sed 's;\([} ]\)else[ ]*\(/\*.*[^\*][^/]\)$;\1else\
+
+# 'else' followed by a single-line comment, followed by
+# a brace on the next line confuses BSD indent, so we push
+# the comment down to the next line, then later pull it
+# back up again.
+ sed 's;\([} ]\)else[ ]*\(/\*\)\(.*\*/\)[ ]*$;\1else\
+ \2PGINDENT_MOVED\3;g' |
+
+# Indent multi-line after-'else' comment so BSD indent will move it properly.
+# We already moved down single-line comments above. Check for '*' to make
+# sure we are not in a single-line comment that has other text on the line.
+ sed 's;\([} ]\)else[ ]*\(/\*[^\*]*\)[ ]*$;\1else\
\2;g' |
detab -t4 -qc |
-# work around bug where function that defines no local variables misindents
+# Work around bug where function that defines no local variables misindents
# switch() case lines and line after #else. Do not do for struct/enum.
awk ' BEGIN {line1 = ""; line2 = ""}
{
@@ -71,7 +80,7 @@ do
print line1;
}' |
-# prevent indenting of code in 'extern "C"' blocks
+# Prevent indenting of code in 'extern "C"' blocks.
awk ' BEGIN {line1 = ""; line2 = ""; skips = 0}
{
line2 = $0;
@@ -106,10 +115,10 @@ do
print line1;
}' |
-# protect backslashes in DATA()
+# Protect backslashes in DATA().
sed 's;^DATA(.*$;/*&*/;' |
-# protect wrapping in CATALOG()
+# Protect wrapping in CATALOG().
sed 's;^CATALOG(.*$;/*&*/;' >/tmp/$$a
# We get the list of typedef's from /src/tools/find_typedef
@@ -2130,30 +2139,30 @@ do
fi
cat /tmp/$$a |
-# restore DATA/CATALOG lines
+# Restore DATA/CATALOG lines.
sed 's;^/\*\(DATA(.*\)\*/$;\1;' |
sed 's;^/\*\(CATALOG(.*\)\*/$;\1;' |
-# remove tabs and retab with four spaces
+# Remove tabs and retab with four spaces.
detab -t8 -qc |
entab -t4 -qc |
sed 's;^/\* Open extern \"C\" \*/$;{;' |
sed 's;^/\* Close extern \"C\" \*/$;};' |
sed 's;/\*---X_X;/* ---;g' |
-# workaround indent bug for 'static'
+# Workaround indent bug for 'static'.
sed 's;^static[ ][ ]*;static ;g' |
-# remove too much indenting after closing brace
+# Remove too much indenting after closing brace.
sed 's;^} [ ]*;} ;' |
-# indent single-line after-'else' comment by only one tab
+# Indent single-line after-'else' comment by only one tab.
sed 's;\([} ]\)else[ ]*\(/\*.*\*/\)[ ]*$;\1else \2;g' |
-# pull in #endif comments
+# Pull in #endif comments.
sed 's;^#endif[ ][ ]*/\*;#endif /*;' |
-# work around misindenting of function with no variables defined
+# Work around misindenting of function with no variables defined.
awk '
{
if ($0 ~ /^[ ]*int[ ]*pgindent_func_no_var_fix;/)
@@ -2164,13 +2173,13 @@ do
else print $0;
}' |
-# add space after comments that start on tab stops
+# Add space after comments that start on tab stops.
sed 's;\([^ ]\)\(/\*.*\*/\)$;\1 \2;' |
-# move trailing * in function return type
+# Move trailing * in function return type.
sed 's;^\([A-Za-z_][^ ]*\)[ ][ ]*\*$;\1 *;' |
-# remove un-needed braces around single statements
+# Remove un-needed braces around single statements.
# Do not use because it uglifies PG_TRY/PG_CATCH blocks and probably
# isn't needed for general use.
# awk '
@@ -2200,7 +2209,7 @@ do
# print line2;
# }' |
-# remove blank line between opening brace and block comment
+# Remove blank line between opening brace and block comment.
awk '
{
line3 = $0;
@@ -2229,7 +2238,33 @@ do
print line2;
}' |
-# remove trailing blank lines, helps with adding blank before trailing #endif
+# Pull up single-line comment after 'else' that was pulled down above
+ awk '
+ {
+ if (NR != 1)
+ {
+ if ($0 ~ "/\*PGINDENT_MOVED")
+ {
+ # remove tag
+ sub("PGINDENT_MOVED", "", $0);
+ # remove leading whitespace
+ sub("^[ ]*", "", $0);
+ # add comment with single tab prefix
+ print prev_line" "$0;
+ # throw away current line
+ getline;
+ }
+ else
+ print prev_line;
+ }
+ prev_line = $0;
+ }
+ END {
+ if (NR >= 1)
+ print prev_line;
+ }' |
+
+# Remove trailing blank lines, helps with adding blank before trailing #endif.
awk ' BEGIN {blank_lines = 0;}
{
line1 = $0;
@@ -2243,7 +2278,7 @@ do
}
}' |
-# remove blank line before #else, #elif, and #endif
+# Remove blank line before #else, #elif, and #endif.
awk ' BEGIN {line1 = ""; line2 = ""; skips = 0}
{
line2 = $0;
@@ -2268,7 +2303,7 @@ do
print line1;
}' |
-# add blank line before #endif if it is the last line in the file
+# Add blank line before #endif if it is the last line in the file.
awk ' BEGIN {line1 = ""; line2 = ""}
{
line2 = $0;
@@ -2326,7 +2361,7 @@ do
else print $0;
}' |
-# fix indenting of typedef caused by __cplusplus in libpq-fe.h
+# Fix indenting of typedef caused by __cplusplus in libpq-fe.h.
(
if echo "$FILE" | grep -q 'libpq-fe.h$'
then sed 's/^[ ]*typedef enum/typedef enum/'