diff options
| author | Tom Lane | 2018-04-26 18:47:16 +0000 |
|---|---|---|
| committer | Tom Lane | 2018-04-26 18:47:16 +0000 |
| commit | bdf46af748d0f15f257c99bf06e9e25aba6a24f9 (patch) | |
| tree | 3637d69ad413fdc23098cc2cf94b2cd57fd44dab /src/bin | |
| parent | f83bf385c1dad4964e0d899174989a1668536182 (diff) | |
Post-feature-freeze pgindent run.
Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'src/bin')
| -rw-r--r-- | src/bin/pg_basebackup/streamutil.c | 6 | ||||
| -rw-r--r-- | src/bin/pg_ctl/pg_ctl.c | 3 | ||||
| -rw-r--r-- | src/bin/pg_dump/common.c | 18 | ||||
| -rw-r--r-- | src/bin/pg_dump/pg_dump.c | 10 | ||||
| -rw-r--r-- | src/bin/pg_rewind/filemap.c | 14 | ||||
| -rw-r--r-- | src/bin/pg_upgrade/exec.c | 2 | ||||
| -rw-r--r-- | src/bin/pg_upgrade/server.c | 4 | ||||
| -rw-r--r-- | src/bin/pgbench/pgbench.c | 404 | ||||
| -rw-r--r-- | src/bin/psql/common.c | 4 | ||||
| -rw-r--r-- | src/bin/psql/mainloop.c | 14 | ||||
| -rw-r--r-- | src/bin/psql/tab-complete.c | 11 |
11 files changed, 263 insertions, 227 deletions
diff --git a/src/bin/pg_basebackup/streamutil.c b/src/bin/pg_basebackup/streamutil.c index 77ae91fbe73..3394537d854 100644 --- a/src/bin/pg_basebackup/streamutil.c +++ b/src/bin/pg_basebackup/streamutil.c @@ -219,9 +219,9 @@ GetConnection(void) /* * Set always-secure search path, so malicious users can't get control. - * The capacity to run normal SQL queries was added in PostgreSQL - * 10, so the search path cannot be changed (by us or attackers) on - * earlier versions. + * The capacity to run normal SQL queries was added in PostgreSQL 10, so + * the search path cannot be changed (by us or attackers) on earlier + * versions. */ if (dbname != NULL && PQserverVersion(tmpconn) >= 100000) { diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 143021de05f..ed2396aa6c5 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -1846,7 +1846,8 @@ CreateRestrictedProcess(char *cmd, PROCESS_INFORMATION *processInfo, bool as_ser static PTOKEN_PRIVILEGES GetPrivilegesToDelete(HANDLE hToken) { - int i, j; + int i, + j; DWORD length; PTOKEN_PRIVILEGES tokenPrivs; LUID luidLockPages; diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index e7db78b0ff1..0d147cb08d1 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -350,8 +350,8 @@ flagInhTables(Archive *fout, TableInfo *tblinfo, int numTables, findParentsByOid(&tblinfo[i], inhinfo, numInherits); /* - * If needed, mark the parents as interesting for getTableAttrs - * and getIndexes. + * If needed, mark the parents as interesting for getTableAttrs and + * getIndexes. */ if (mark_parents) { @@ -372,9 +372,9 @@ flagInhTables(Archive *fout, TableInfo *tblinfo, int numTables, static void flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) { - int i, - j, - k; + int i, + j, + k; DumpableObject ***parentIndexArray; parentIndexArray = (DumpableObject ***) @@ -382,7 +382,7 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) for (i = 0; i < numTables; i++) { - TableInfo *parenttbl; + TableInfo *parenttbl; IndexAttachInfo *attachinfo; if (!tblinfo[i].ispartition || tblinfo[i].numParents == 0) @@ -430,9 +430,9 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) /* * We want dependencies from parent to partition (so that the - * partition index is created first), and another one from - * attach object to parent (so that the partition index is - * attached once the parent index has been created). + * partition index is created first), and another one from attach + * object to parent (so that the partition index is attached once + * the parent index has been created). */ addObjectDependency(&parentidx->dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index b11fe94212e..c5b49459cc4 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -16433,13 +16433,13 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo) } else if (coninfo->contype == 'f') { - char *only; + char *only; /* - * Foreign keys on partitioned tables are always declared as inheriting - * to partitions; for all other cases, emit them as applying ONLY - * directly to the named table, because that's how they work for - * regular inherited tables. + * Foreign keys on partitioned tables are always declared as + * inheriting to partitions; for all other cases, emit them as + * applying ONLY directly to the named table, because that's how they + * work for regular inherited tables. */ only = tbinfo->relkind == RELKIND_PARTITIONED_TABLE ? "" : "ONLY "; diff --git a/src/bin/pg_rewind/filemap.c b/src/bin/pg_rewind/filemap.c index e45e6d44ec7..8f49d346528 100644 --- a/src/bin/pg_rewind/filemap.c +++ b/src/bin/pg_rewind/filemap.c @@ -48,7 +48,7 @@ static const char *excludeDirContents[] = * when stats_temp_directory is set because PGSS_TEXT_FILE is always * created there. */ - "pg_stat_tmp", /* defined as PG_STAT_TMP_DIR */ + "pg_stat_tmp", /* defined as PG_STAT_TMP_DIR */ /* * It is generally not useful to backup the contents of this directory @@ -58,7 +58,7 @@ static const char *excludeDirContents[] = "pg_replslot", /* Contents removed on startup, see dsm_cleanup_for_mmap(). */ - "pg_dynshmem", /* defined as PG_DYNSHMEM_DIR */ + "pg_dynshmem", /* defined as PG_DYNSHMEM_DIR */ /* Contents removed on startup, see AsyncShmemInit(). */ "pg_notify", @@ -492,9 +492,9 @@ process_block_change(ForkNumber forknum, RelFileNode rnode, BlockNumber blkno) static bool check_file_excluded(const char *path, const char *type) { - char localpath[MAXPGPATH]; - int excludeIdx; - const char *filename; + char localpath[MAXPGPATH]; + int excludeIdx; + const char *filename; /* check individual files... */ for (excludeIdx = 0; excludeFiles[excludeIdx] != NULL; excludeIdx++) @@ -733,8 +733,8 @@ isRelDataFile(const char *path) /* * The sscanf tests above can match files that have extra characters at * the end. To eliminate such cases, cross-check that GetRelationPath - * creates the exact same filename, when passed the RelFileNode information - * we extracted from the filename. + * creates the exact same filename, when passed the RelFileNode + * information we extracted from the filename. */ if (matched) { diff --git a/src/bin/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c index 9122e2769e1..3d2de83a906 100644 --- a/src/bin/pg_upgrade/exec.c +++ b/src/bin/pg_upgrade/exec.c @@ -110,6 +110,7 @@ exec_prog(const char *log_file, const char *opt_log_file, pg_log(PG_VERBOSE, "%s\n", cmd); #ifdef WIN32 + /* * For some reason, Windows issues a file-in-use error if we write data to * the log file from a non-primary thread just before we create a @@ -191,6 +192,7 @@ exec_prog(const char *log_file, const char *opt_log_file, } #ifndef WIN32 + /* * We can't do this on Windows because it will keep the "pg_ctl start" * output filename open until the server stops, so we do the \n\n above on diff --git a/src/bin/pg_upgrade/server.c b/src/bin/pg_upgrade/server.c index 5273ef6681f..fccc21836a0 100644 --- a/src/bin/pg_upgrade/server.c +++ b/src/bin/pg_upgrade/server.c @@ -309,8 +309,8 @@ start_postmaster(ClusterInfo *cluster, bool report_and_exit_on_error) /* * If pg_ctl failed, and the connection didn't fail, and - * report_and_exit_on_error is enabled, fail now. This - * could happen if the server was already running. + * report_and_exit_on_error is enabled, fail now. This could happen if + * the server was already running. */ if (!pg_ctl_return) { diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c index fd1856837a2..78b8f1706ca 100644 --- a/src/bin/pgbench/pgbench.c +++ b/src/bin/pgbench/pgbench.c @@ -156,7 +156,7 @@ char *tablespace = NULL; char *index_tablespace = NULL; /* random seed used when calling srandom() */ -int64 random_seed = -1; +int64 random_seed = -1; /* * end of configurable parameters @@ -820,7 +820,7 @@ generalizedHarmonicNumber(int64 n, double s) /* set harmonicn and other parameters to cache cell */ static void -zipfSetCacheCell(ZipfCell * cell, int64 n, double s) +zipfSetCacheCell(ZipfCell *cell, int64 n, double s) { double harmonic2; @@ -840,7 +840,7 @@ zipfSetCacheCell(ZipfCell * cell, int64 n, double s) * and create new cell if it does not exist */ static ZipfCell * -zipfFindOrCreateCacheCell(ZipfCache * cache, int64 n, double s) +zipfFindOrCreateCacheCell(ZipfCache *cache, int64 n, double s) { int i, least_recently_used = 0; @@ -943,13 +943,13 @@ getZipfianRand(TState *thread, int64 min, int64 max, double s) static int64 getHashFnv1a(int64 val, uint64 seed) { - int64 result; - int i; + int64 result; + int i; result = FNV_OFFSET_BASIS ^ seed; for (i = 0; i < 8; ++i) { - int32 octet = val & 0xff; + int32 octet = val & 0xff; val = val >> 8; result = result ^ octet; @@ -968,8 +968,8 @@ getHashFnv1a(int64 val, uint64 seed) static int64 getHashMurmur2(int64 val, uint64 seed) { - uint64 result = seed ^ (sizeof(int64) * MM2_MUL); - uint64 k = (uint64) val; + uint64 result = seed ^ (sizeof(int64) * MM2_MUL); + uint64 k = (uint64) val; k *= MM2_MUL; k ^= k >> MM2_ROT; @@ -1236,7 +1236,7 @@ getVariable(CState *st, char *name) else if (var->value.type == PGBT_DOUBLE) snprintf(stringform, sizeof(stringform), "%.*g", DBL_DIG, var->value.u.dval); - else /* internal error, unexpected type */ + else /* internal error, unexpected type */ Assert(0); var->svalue = pg_strdup(stringform); return var->svalue; @@ -1246,7 +1246,7 @@ getVariable(CState *st, char *name) static bool makeVariableValue(Variable *var) { - size_t slen; + size_t slen; if (var->value.type != PGBT_NO_VALUE) return true; /* no work */ @@ -1261,10 +1261,10 @@ makeVariableValue(Variable *var) { setNullValue(&var->value); } + /* - * accept prefixes such as y, ye, n, no... but not for "o". - * 0/1 are recognized later as an int, which is converted - * to bool if needed. + * accept prefixes such as y, ye, n, no... but not for "o". 0/1 are + * recognized later as an int, which is converted to bool if needed. */ else if (pg_strncasecmp(var->svalue, "true", slen) == 0 || pg_strncasecmp(var->svalue, "yes", slen) == 0 || @@ -1410,7 +1410,7 @@ putVariable(CState *st, const char *context, char *name, const char *value) /* Returns false on failure (bad name) */ static bool putVariableValue(CState *st, const char *context, char *name, - const PgBenchValue *value) + const PgBenchValue *value) { Variable *var; @@ -1563,7 +1563,7 @@ coerceToBool(PgBenchValue *pval, bool *bval) *bval = pval->u.bval; return true; } - else /* NULL, INT or DOUBLE */ + else /* NULL, INT or DOUBLE */ { fprintf(stderr, "cannot coerce %s to boolean\n", valueTypeName(pval)); *bval = false; /* suppress uninitialized-variable warnings */ @@ -1616,7 +1616,7 @@ coerceToInt(PgBenchValue *pval, int64 *ival) *ival = (int64) dval; return true; } - else /* BOOLEAN or NULL */ + else /* BOOLEAN or NULL */ { fprintf(stderr, "cannot coerce %s to int\n", valueTypeName(pval)); return false; @@ -1637,7 +1637,7 @@ coerceToDouble(PgBenchValue *pval, double *dval) *dval = (double) pval->u.ival; return true; } - else /* BOOLEAN or NULL */ + else /* BOOLEAN or NULL */ { fprintf(stderr, "cannot coerce %s to double\n", valueTypeName(pval)); return false; @@ -1676,7 +1676,8 @@ setDoubleValue(PgBenchValue *pv, double dval) pv->u.dval = dval; } -static bool isLazyFunc(PgBenchFunction func) +static bool +isLazyFunc(PgBenchFunction func) { return func == PGBENCH_AND || func == PGBENCH_OR || func == PGBENCH_CASE; } @@ -1686,8 +1687,10 @@ static bool evalLazyFunc(TState *thread, CState *st, PgBenchFunction func, PgBenchExprLink *args, PgBenchValue *retval) { - PgBenchValue a1, a2; - bool ba1, ba2; + PgBenchValue a1, + a2; + bool ba1, + ba2; Assert(isLazyFunc(func) && args != NULL && args->next != NULL); @@ -1700,92 +1703,92 @@ evalLazyFunc(TState *thread, CState *st, switch (func) { - case PGBENCH_AND: - if (a1.type == PGBT_NULL) - { - setNullValue(retval); - return true; - } + case PGBENCH_AND: + if (a1.type == PGBT_NULL) + { + setNullValue(retval); + return true; + } - if (!coerceToBool(&a1, &ba1)) - return false; + if (!coerceToBool(&a1, &ba1)) + return false; - if (!ba1) - { - setBoolValue(retval, false); - return true; - } + if (!ba1) + { + setBoolValue(retval, false); + return true; + } - if (!evaluateExpr(thread, st, args->expr, &a2)) - return false; + if (!evaluateExpr(thread, st, args->expr, &a2)) + return false; - if (a2.type == PGBT_NULL) - { - setNullValue(retval); - return true; - } - else if (!coerceToBool(&a2, &ba2)) - return false; - else - { - setBoolValue(retval, ba2); - return true; - } + if (a2.type == PGBT_NULL) + { + setNullValue(retval); + return true; + } + else if (!coerceToBool(&a2, &ba2)) + return false; + else + { + setBoolValue(retval, ba2); + return true; + } - return true; + return true; - case PGBENCH_OR: + case PGBENCH_OR: - if (a1.type == PGBT_NULL) - { - setNullValue(retval); - return true; - } + if (a1.type == PGBT_NULL) + { + setNullValue(retval); + return true; + } - if (!coerceToBool(&a1, &ba1)) - return false; + if (!coerceToBool(&a1, &ba1)) + return false; - if (ba1) - { - setBoolValue(retval, true); - return true; - } + if (ba1) + { + setBoolValue(retval, true); + return true; + } - if (!evaluateExpr(thread, st, args->expr, &a2)) - return false; + if (!evaluateExpr(thread, st, args->expr, &a2)) + return false; - if (a2.type == PGBT_NULL) - { - setNullValue(retval); - return true; - } - else if (!coerceToBool(&a2, &ba2)) - return false; - else - { - setBoolValue(retval, ba2); - return true; - } + if (a2.type == PGBT_NULL) + { + setNullValue(retval); + return true; + } + else if (!coerceToBool(&a2, &ba2)) + return false; + else + { + setBoolValue(retval, ba2); + return true; + } - case PGBENCH_CASE: - /* when true, execute branch */ - if (valueTruth(&a1)) - return evaluateExpr(thread, st, args->expr, retval); + case PGBENCH_CASE: + /* when true, execute branch */ + if (valueTruth(&a1)) + return evaluateExpr(thread, st, args->expr, retval); - /* now args contains next condition or final else expression */ - args = args->next; + /* now args contains next condition or final else expression */ + args = args->next; - /* final else case? */ - if (args->next == NULL) - return evaluateExpr(thread, st, args->expr, retval); + /* final else case? */ + if (args->next == NULL) + return evaluateExpr(thread, st, args->expr, retval); - /* no, another when, proceed */ - return evalLazyFunc(thread, st, PGBENCH_CASE, args, retval); + /* no, another when, proceed */ + return evalLazyFunc(thread, st, PGBENCH_CASE, args, retval); - default: - /* internal error, cannot get here */ - Assert(0); - break; + default: + /* internal error, cannot get here */ + Assert(0); + break; } return false; } @@ -1803,10 +1806,10 @@ evalStandardFunc(TState *thread, CState *st, PgBenchValue *retval) { /* evaluate all function arguments */ - int nargs = 0; - PgBenchValue vargs[MAX_FARGS]; + int nargs = 0; + PgBenchValue vargs[MAX_FARGS]; PgBenchExprLink *l = args; - bool has_null = false; + bool has_null = false; for (nargs = 0; nargs < MAX_FARGS && l != NULL; nargs++, l = l->next) { @@ -1984,7 +1987,8 @@ evalStandardFunc(TState *thread, CState *st, case PGBENCH_LSHIFT: case PGBENCH_RSHIFT: { - int64 li, ri; + int64 li, + ri; if (!coerceToInt(&vargs[0], &li) || !coerceToInt(&vargs[1], &ri)) return false; @@ -1999,7 +2003,7 @@ evalStandardFunc(TState *thread, CState *st, setIntValue(retval, li << ri); else if (func == PGBENCH_RSHIFT) setIntValue(retval, li >> ri); - else /* cannot get here */ + else /* cannot get here */ Assert(0); return true; @@ -2008,7 +2012,8 @@ evalStandardFunc(TState *thread, CState *st, /* logical operators */ case PGBENCH_NOT: { - bool b; + bool b; + if (!coerceToBool(&vargs[0], &b)) return false; @@ -2062,7 +2067,7 @@ evalStandardFunc(TState *thread, CState *st, fprintf(stderr, "int " INT64_FORMAT "\n", varg->u.ival); else if (varg->type == PGBT_DOUBLE) fprintf(stderr, "double %.*g\n", DBL_DIG, varg->u.dval); - else /* internal error, unexpected type */ + else /* internal error, unexpected type */ Assert(0); *retval = *varg; @@ -2275,7 +2280,11 @@ evalStandardFunc(TState *thread, CState *st, case PGBENCH_IS: { Assert(nargs == 2); - /* note: this simple implementation is more permissive than SQL */ + + /* + * note: this simple implementation is more permissive than + * SQL + */ setBoolValue(retval, vargs[0].type == vargs[1].type && vargs[0].u.bval == vargs[1].u.bval); @@ -2286,8 +2295,8 @@ evalStandardFunc(TState *thread, CState *st, case PGBENCH_HASH_FNV1A: case PGBENCH_HASH_MURMUR2: { - int64 val, - seed; + int64 val, + seed; Assert(nargs == 2); @@ -2935,7 +2944,10 @@ doCustom(TState *thread, CState *st, StatsData *agg) if (command->meta == META_ELIF && conditional_stack_peek(st->cstack) == IFSTATE_TRUE) { - /* elif after executed block, skip eval and wait for endif */ + /* + * elif after executed block, skip eval and wait + * for endif + */ conditional_stack_poke(st->cstack, IFSTATE_IGNORED); goto move_to_end_command; } @@ -2956,18 +2968,21 @@ doCustom(TState *thread, CState *st, StatsData *agg) break; } } - else /* if and elif evaluated cases */ + else /* if and elif evaluated cases */ { - bool cond = valueTruth(&result); + bool cond = valueTruth(&result); /* execute or not depending on evaluated condition */ if (command->meta == META_IF) { conditional_stack_push(st->cstack, cond ? IFSTATE_TRUE : IFSTATE_FALSE); } - else /* elif */ + else /* elif */ { - /* we should get here only if the "elif" needed evaluation */ + /* + * we should get here only if the "elif" + * needed evaluation + */ Assert(conditional_stack_peek(st->cstack) == IFSTATE_FALSE); conditional_stack_poke(st->cstack, cond ? IFSTATE_TRUE : IFSTATE_FALSE); } @@ -2981,10 +2996,10 @@ doCustom(TState *thread, CState *st, StatsData *agg) conditional_stack_poke(st->cstack, IFSTATE_ELSE_FALSE); break; case IFSTATE_FALSE: /* inconsistent if active */ - case IFSTATE_IGNORED: /* inconsistent if active */ - case IFSTATE_NONE: /* else without if */ + case IFSTATE_IGNORED: /* inconsistent if active */ + case IFSTATE_NONE: /* else without if */ case IFSTATE_ELSE_TRUE: /* else after else */ - case IFSTATE_ELSE_FALSE: /* else after else */ + case IFSTATE_ELSE_FALSE: /* else after else */ default: /* dead code if conditional check is ok */ Assert(false); @@ -3038,11 +3053,11 @@ doCustom(TState *thread, CState *st, StatsData *agg) } } - move_to_end_command: + move_to_end_command: + /* - * executing the expression or shell command might - * take a non-negligible amount of time, so reset - * 'now' + * executing the expression or shell command might take a + * non-negligible amount of time, so reset 'now' */ INSTR_TIME_SET_ZERO(now); @@ -3063,7 +3078,10 @@ doCustom(TState *thread, CState *st, StatsData *agg) /* cannot reach end of script in that state */ Assert(command != NULL); - /* if this is conditional related, update conditional state */ + /* + * if this is conditional related, update conditional + * state + */ if (command->type == META_COMMAND && (command->meta == META_IF || command->meta == META_ELIF || @@ -3072,51 +3090,59 @@ doCustom(TState *thread, CState *st, StatsData *agg) { switch (conditional_stack_peek(st->cstack)) { - case IFSTATE_FALSE: - if (command->meta == META_IF || command->meta == META_ELIF) - { - /* we must evaluate the condition */ - st->state = CSTATE_START_COMMAND; - } - else if (command->meta == META_ELSE) - { - /* we must execute next command */ - conditional_stack_poke(st->cstack, IFSTATE_ELSE_TRUE); - st->state = CSTATE_START_COMMAND; - st->command++; - } - else if (command->meta == META_ENDIF) - { - Assert(!conditional_stack_empty(st->cstack)); - conditional_stack_pop(st->cstack); - if (conditional_active(st->cstack)) + case IFSTATE_FALSE: + if (command->meta == META_IF || command->meta == META_ELIF) + { + /* we must evaluate the condition */ + st->state = CSTATE_START_COMMAND; + } + else if (command->meta == META_ELSE) + { + /* we must execute next command */ + conditional_stack_poke(st->cstack, IFSTATE_ELSE_TRUE); st->state = CSTATE_START_COMMAND; - /* else state remains in CSTATE_SKIP_COMMAND */ + st->command++; + } + else if (command->meta == META_ENDIF) + { + Assert(!conditional_stack_empty(st->cstack)); + conditional_stack_pop(st->cstack); + if (conditional_active(st->cstack)) + st->state = CSTATE_START_COMMAND; + + /* + * else state remains in + * CSTATE_SKIP_COMMAND + */ + st->command++; + } + break; + + case IFSTATE_IGNORED: + case IFSTATE_ELSE_FALSE: + if (command->meta == META_IF) + conditional_stack_push(st->cstack, IFSTATE_IGNORED); + else if (command->meta == META_ENDIF) + { + Assert(!conditional_stack_empty(st->cstack)); + conditional_stack_pop(st->cstack); + if (conditional_active(st->cstack)) + st->state = CSTATE_START_COMMAND; + } + /* could detect "else" & "elif" after "else" */ st->command++; - } - break; + break; - case IFSTATE_IGNORED: - case IFSTATE_ELSE_FALSE: - if (command->meta == META_IF) - conditional_stack_push(st->cstack, IFSTATE_IGNORED); - else if (command->meta == META_ENDIF) - { - Assert(!conditional_stack_empty(st->cstack)); - conditional_stack_pop(st->cstack); - if (conditional_active(st->cstack)) - st->state = CSTATE_START_COMMAND; - } - /* could detect "else" & "elif" after "else" */ - st->command++; - break; + case IFSTATE_NONE: + case IFSTATE_TRUE: + case IFSTATE_ELSE_TRUE: + default: - case IFSTATE_NONE: - case IFSTATE_TRUE: - case IFSTATE_ELSE_TRUE: - default: - /* inconsistent if inactive, unreachable dead code */ - Assert(false); + /* + * inconsistent if inactive, unreachable dead + * code + */ + Assert(false); } } else @@ -4184,42 +4210,44 @@ CheckConditional(ParsedScript ps) { /* statically check conditional structure */ ConditionalStack cs = conditional_stack_create(); - int i; - for (i = 0 ; ps.commands[i] != NULL ; i++) + int i; + + for (i = 0; ps.commands[i] != NULL; i++) { - Command *cmd = ps.commands[i]; + Command *cmd = ps.commands[i]; + if (cmd->type == META_COMMAND) { switch (cmd->meta) { - case META_IF: - conditional_stack_push(cs, IFSTATE_FALSE); - break; - case META_ELIF: - if (conditional_stack_empty(cs)) - ConditionError(ps.desc, i+1, "\\elif without matching \\if"); - if (conditional_stack_peek(cs) == IFSTATE_ELSE_FALSE) - ConditionError(ps.desc, i+1, "\\elif after \\else"); - break; - case META_ELSE: - if (conditional_stack_empty(cs)) - ConditionError(ps.desc, i+1, "\\else without matching \\if"); - if (conditional_stack_peek(cs) == IFSTATE_ELSE_FALSE) - ConditionError(ps.desc, i+1, "\\else after \\else"); - conditional_stack_poke(cs, IFSTATE_ELSE_FALSE); - break; - case META_ENDIF: - if (!conditional_stack_pop(cs)) - ConditionError(ps.desc, i+1, "\\endif without matching \\if"); - break; - default: - /* ignore anything else... */ - break; + case META_IF: + conditional_stack_push(cs, IFSTATE_FALSE); + break; + case META_ELIF: + if (conditional_stack_empty(cs)) + ConditionError(ps.desc, i + 1, "\\elif without matching \\if"); + if (conditional_stack_peek(cs) == IFSTATE_ELSE_FALSE) + ConditionError(ps.desc, i + 1, "\\elif after \\else"); + break; + case META_ELSE: + if (conditional_stack_empty(cs)) + ConditionError(ps.desc, i + 1, "\\else without matching \\if"); + if (conditional_stack_peek(cs) == IFSTATE_ELSE_FALSE) + ConditionError(ps.desc, i + 1, "\\else after \\else"); + conditional_stack_poke(cs, IFSTATE_ELSE_FALSE); + break; + case META_ENDIF: + if (!conditional_stack_pop(cs)) + ConditionError(ps.desc, i + 1, "\\endif without matching \\if"); + break; + default: + /* ignore anything else... */ + break; } } } if (!conditional_stack_empty(cs)) - ConditionError(ps.desc, i+1, "\\if without matching \\endif"); + ConditionError(ps.desc, i + 1, "\\if without matching \\endif"); conditional_stack_destroy(cs); } @@ -4679,6 +4707,7 @@ set_random_seed(const char *seed) { /* rely on current time */ instr_time now; + INSTR_TIME_SET_CURRENT(now); iseed = (unsigned int) INSTR_TIME_GET_MICROSEC(now); } @@ -4698,7 +4727,8 @@ set_random_seed(const char *seed) else { /* parse seed unsigned int value */ - char garbage; + char garbage; + if (sscanf(seed, "%u%c", &iseed, &garbage) != 1) { fprintf(stderr, @@ -5307,7 +5337,7 @@ main(int argc, char **argv) if (var->value.type != PGBT_NO_VALUE) { if (!putVariableValue(&state[i], "startup", - var->name, &var->value)) + var->name, &var->value)) exit(1); } else @@ -5410,10 +5440,10 @@ main(int argc, char **argv) /* set default seed for hash functions */ if (lookupVariable(&state[0], "default_seed") == NULL) { - uint64 seed = ((uint64) (random() & 0xFFFF) << 48) | - ((uint64) (random() & 0xFFFF) << 32) | - ((uint64) (random() & 0xFFFF) << 16) | - (uint64) (random() & 0xFFFF); + uint64 seed = ((uint64) (random() & 0xFFFF) << 48) | + ((uint64) (random() & 0xFFFF) << 32) | + ((uint64) (random() & 0xFFFF) << 16) | + (uint64) (random() & 0xFFFF); for (i = 0; i < nclients; i++) if (!putVariableInt(&state[i], "startup", "default_seed", (int64) seed)) diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c index 2b1c4daceda..b56995925bd 100644 --- a/src/bin/psql/common.c +++ b/src/bin/psql/common.c @@ -2047,8 +2047,8 @@ command_no_begin(const char *query) /* * Commands not allowed within transactions. The statements checked for - * here should be exactly those that call PreventInTransactionBlock() in the - * backend. + * here should be exactly those that call PreventInTransactionBlock() in + * the backend. */ if (wordlen == 6 && pg_strncasecmp(query, "vacuum", 6) == 0) return true; diff --git a/src/bin/psql/mainloop.c b/src/bin/psql/mainloop.c index c06ce3ca09c..6caca2e575c 100644 --- a/src/bin/psql/mainloop.c +++ b/src/bin/psql/mainloop.c @@ -247,9 +247,8 @@ MainLoop(FILE *source) /* * If we found a command word, check whether the rest of the line * contains only whitespace plus maybe one semicolon. If not, - * ignore the command word after all. These commands are only - * for compatibility with other SQL clients and are not - * documented. + * ignore the command word after all. These commands are only for + * compatibility with other SQL clients and are not documented. */ if (rest_of_line != NULL) { @@ -330,18 +329,17 @@ MainLoop(FILE *source) } /* - * If they typed "\q" in a place where "\q" is not active, - * supply a hint. The text is still added to the query - * buffer. + * If they typed "\q" in a place where "\q" is not active, supply + * a hint. The text is still added to the query buffer. */ if (found_q && query_buf->len != 0 && prompt_status != PROMPT_READY && prompt_status != PROMPT_CONTINUE && prompt_status != PROMPT_PAREN) #ifndef WIN32 - puts(_("Use control-D to quit.")); + puts(_("Use control-D to quit.")); #else - puts(_("Use control-C to quit.")); + puts(_("Use control-C to quit.")); #endif } diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 264728212f6..b431efc9832 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -1856,13 +1856,13 @@ psql_completion(const char *text, int start, int end) /* ALTER INDEX <foo> SET|RESET ( */ else if (Matches5("ALTER", "INDEX", MatchAny, "RESET", "(")) COMPLETE_WITH_LIST7("fillfactor", "recheck_on_update", - "fastupdate", "gin_pending_list_limit", /* GIN */ + "fastupdate", "gin_pending_list_limit", /* GIN */ "buffering", /* GiST */ "pages_per_range", "autosummarize" /* BRIN */ ); else if (Matches5("ALTER", "INDEX", MatchAny, "SET", "(")) COMPLETE_WITH_LIST7("fillfactor =", "recheck_on_update =", - "fastupdate =", "gin_pending_list_limit =", /* GIN */ + "fastupdate =", "gin_pending_list_limit =", /* GIN */ "buffering =", /* GiST */ "pages_per_range =", "autosummarize =" /* BRIN */ ); @@ -2511,6 +2511,7 @@ psql_completion(const char *text, int start, int end) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexes, " UNION SELECT 'ON'" " UNION SELECT 'CONCURRENTLY'"); + /* * Complete ... INDEX|CONCURRENTLY [<name>] ON with a list of relations * that can indexes can be created on @@ -3458,7 +3459,11 @@ psql_completion(const char *text, int start, int end) /* Complete SET <var> with "TO" */ else if (Matches2("SET", MatchAny)) COMPLETE_WITH_CONST("TO"); - /* Complete ALTER DATABASE|FUNCTION||PROCEDURE|ROLE|ROUTINE|USER ... SET <name> */ + + /* + * Complete ALTER DATABASE|FUNCTION||PROCEDURE|ROLE|ROUTINE|USER ... SET + * <name> + */ else if (HeadMatches2("ALTER", "DATABASE|FUNCTION|PROCEDURE|ROLE|ROUTINE|USER") && TailMatches2("SET", MatchAny)) COMPLETE_WITH_LIST2("FROM CURRENT", "TO"); |
