From c079673dcb7f210617c9fc1470e6bf166d8a2971 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 16 May 2017 20:36:35 -0400 Subject: [PATCH] Preventive maintenance in advance of pgindent run. Reformat various places in which pgindent will make a mess, and fix a few small violations of coding style that I happened to notice while perusing the diffs from a pgindent dry run. There is one actual bug fix here: the need-to-enlarge-the-buffer code path in icu_convert_case was obviously broken. Perhaps it's unreachable in our usage? Or maybe this is just sadly undertested. --- contrib/btree_gist/btree_utils_num.c | 11 +++--- src/backend/catalog/pg_publication.c | 11 +++--- src/backend/commands/publicationcmds.c | 4 ++- src/backend/commands/subscriptioncmds.c | 1 + .../executor/nodeNamedtuplestorescan.c | 1 + src/backend/replication/logical/snapbuild.c | 2 +- src/backend/replication/pgoutput/pgoutput.c | 5 +-- src/backend/tsearch/wparser.c | 13 ++++--- src/backend/utils/adt/formatting.c | 35 +++++++++++++------ src/backend/utils/adt/pg_locale.c | 2 ++ src/bin/pg_basebackup/pg_basebackup.c | 24 ++++++------- src/bin/pg_dump/dumputils.c | 3 +- src/bin/pg_dump/pg_backup_archiver.h | 4 +-- src/bin/pg_waldump/pg_waldump.c | 18 +++++----- src/bin/psql/tab-complete.c | 7 ++-- src/common/scram-common.c | 3 +- src/include/catalog/pg_authid.h | 16 ++++----- src/include/catalog/pg_subscription_rel.h | 14 ++++---- src/include/replication/logicalproto.h | 6 ++-- src/interfaces/libpq/libpq-int.h | 4 +-- 20 files changed, 105 insertions(+), 79 deletions(-) diff --git a/contrib/btree_gist/btree_utils_num.c b/contrib/btree_gist/btree_utils_num.c index d4fee91ee1..bae32c4064 100644 --- a/contrib/btree_gist/btree_utils_num.c +++ b/contrib/btree_gist/btree_utils_num.c @@ -183,9 +183,11 @@ gbt_num_union(GBT_NUMKEY *out, const GistEntryVector *entryvec, const gbtree_nin cur = (GBT_NUMKEY *) DatumGetPointer((entryvec->vector[i].key)); c.lower = &cur[0]; c.upper = &cur[tinfo->size]; - if ((*tinfo->f_gt) (o.lower, c.lower, flinfo)) /* out->lower > cur->lower */ + /* if out->lower > cur->lower, adopt cur as lower */ + if ((*tinfo->f_gt) (o.lower, c.lower, flinfo)) memcpy((void *) o.lower, (void *) c.lower, tinfo->size); - if ((*tinfo->f_lt) (o.upper, c.upper, flinfo)) /* out->upper < cur->upper */ + /* if out->upper < cur->upper, adopt cur as upper */ + if ((*tinfo->f_lt) (o.upper, c.upper, flinfo)) memcpy((void *) o.upper, (void *) c.upper, tinfo->size); } @@ -274,7 +276,8 @@ gbt_num_consistent(const GBT_NUMKEY_R *key, if (is_leaf) retval = (*tinfo->f_eq) (query, key->lower, flinfo); else - retval = ((*tinfo->f_le) (key->lower, query, flinfo) && (*tinfo->f_le) (query, key->upper, flinfo)) ? true : false; + retval = ((*tinfo->f_le) (key->lower, query, flinfo) && + (*tinfo->f_le) (query, key->upper, flinfo)); break; case BTGreaterStrategyNumber: if (is_leaf) @@ -287,7 +290,7 @@ gbt_num_consistent(const GBT_NUMKEY_R *key, break; case BtreeGistNotEqualStrategyNumber: retval = (!((*tinfo->f_eq) (query, key->lower, flinfo) && - (*tinfo->f_eq) (query, key->upper, flinfo))) ? true : false; + (*tinfo->f_eq) (query, key->upper, flinfo))); break; default: retval = false; diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c index 493b3aba89..92f9902173 100644 --- a/src/backend/catalog/pg_publication.c +++ b/src/backend/catalog/pg_publication.c @@ -90,6 +90,11 @@ check_publication_add_relation(Relation targetrel) * * Does same checks as the above, but does not need relation to be opened * and also does not throw errors. + * + * Note this also excludes all tables with relid < FirstNormalObjectId, + * ie all tables created during initdb. This mainly affects the preinstalled + * information_schema. (IsCatalogClass() only checks for these inside + * pg_catalog and toast schemas.) */ static bool is_publishable_class(Oid relid, Form_pg_class reltuple) @@ -97,12 +102,6 @@ is_publishable_class(Oid relid, Form_pg_class reltuple) return reltuple->relkind == RELKIND_RELATION && !IsCatalogClass(relid, reltuple) && reltuple->relpersistence == RELPERSISTENCE_PERMANENT && - /* - * Also exclude any tables created as part of initdb. This mainly - * affects the preinstalled information_schema. - * Note that IsCatalogClass() only checks for these inside pg_catalog - * and toast schemas. - */ relid >= FirstNormalObjectId; } diff --git a/src/backend/commands/publicationcmds.c b/src/backend/commands/publicationcmds.c index 14c2f68d59..1c8d88d336 100644 --- a/src/backend/commands/publicationcmds.c +++ b/src/backend/commands/publicationcmds.c @@ -493,8 +493,10 @@ OpenTableList(List *tables) rel = heap_openrv(rv, ShareUpdateExclusiveLock); myrelid = RelationGetRelid(rel); + /* - * filter out duplicates when user specifies "foo, foo" + * Filter out duplicates if user specifies "foo, foo". + * * Note that this algorithm is known to not be very efficient (O(N^2)) * but given that it only works on list of tables given to us by user * it's deemed acceptable. diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c index 304ac842a5..b80af275da 100644 --- a/src/backend/commands/subscriptioncmds.c +++ b/src/backend/commands/subscriptioncmds.c @@ -296,6 +296,7 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel) /* * Parse and check options. + * * Connection and publication should not be specified here. */ parse_subscription_options(stmt->options, &connect, &enabled_given, diff --git a/src/backend/executor/nodeNamedtuplestorescan.c b/src/backend/executor/nodeNamedtuplestorescan.c index 44e0942669..62234869ab 100644 --- a/src/backend/executor/nodeNamedtuplestorescan.c +++ b/src/backend/executor/nodeNamedtuplestorescan.c @@ -117,6 +117,7 @@ ExecInitNamedTuplestoreScan(NamedTuplestoreScan *node, EState *estate, int eflag /* * XXX: Should we add a function to free that read pointer when done? + * * This was attempted, but it did not improve performance or memory usage * in any tested cases. */ diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.c index c2e3c85914..428d7aa55e 100644 --- a/src/backend/replication/logical/snapbuild.c +++ b/src/backend/replication/logical/snapbuild.c @@ -176,7 +176,7 @@ struct SnapBuild */ TransactionId initial_xmin_horizon; - /* Indicates if we are building full snapshot or just catalog one .*/ + /* Indicates if we are building full snapshot or just catalog one. */ bool building_full_snapshot; /* diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c index 4ddfbf7a98..694f351dd8 100644 --- a/src/backend/replication/pgoutput/pgoutput.c +++ b/src/backend/replication/pgoutput/pgoutput.c @@ -221,14 +221,15 @@ pgoutput_begin_txn(LogicalDecodingContext *ctx, ReorderBufferTXN *txn) OutputPluginWrite(ctx, false); OutputPluginPrepareWrite(ctx, true); - /* - * XXX: which behaviour we want here? + /*---------- + * XXX: which behaviour do we want here? * * Alternatives: * - don't send origin message if origin name not found * (that's what we do now) * - throw error - that will break replication, not good * - send some special "unknown" origin + *---------- */ if (replorigin_by_oid(txn->origin_id, true, &origin)) logicalrep_write_origin(ctx->out, origin, txn->origin_lsn); diff --git a/src/backend/tsearch/wparser.c b/src/backend/tsearch/wparser.c index c19937d644..9739558e42 100644 --- a/src/backend/tsearch/wparser.c +++ b/src/backend/tsearch/wparser.c @@ -303,6 +303,7 @@ ts_parse_byname(PG_FUNCTION_ARGS) Datum ts_headline_byid_opt(PG_FUNCTION_ARGS) { + Oid tsconfig = PG_GETARG_OID(0); text *in = PG_GETARG_TEXT_PP(1); TSQuery query = PG_GETARG_TSQUERY(2); text *opt = (PG_NARGS() > 3 && PG_GETARG_POINTER(3)) ? PG_GETARG_TEXT_PP(3) : NULL; @@ -312,7 +313,7 @@ ts_headline_byid_opt(PG_FUNCTION_ARGS) TSConfigCacheEntry *cfg; TSParserCacheEntry *prsobj; - cfg = lookup_ts_config_cache(PG_GETARG_OID(0)); + cfg = lookup_ts_config_cache(tsconfig); prsobj = lookup_ts_parser_cache(cfg->prsId); if (!OidIsValid(prsobj->headlineOid)) @@ -381,11 +382,12 @@ ts_headline_opt(PG_FUNCTION_ARGS) Datum ts_headline_jsonb_byid_opt(PG_FUNCTION_ARGS) { - Jsonb *out, *jb = PG_GETARG_JSONB(1); + Oid tsconfig = PG_GETARG_OID(0); + Jsonb *jb = PG_GETARG_JSONB(1); TSQuery query = PG_GETARG_TSQUERY(2); text *opt = (PG_NARGS() > 3 && PG_GETARG_POINTER(3)) ? PG_GETARG_TEXT_P(3) : NULL; + Jsonb *out; JsonTransformStringValuesAction action = (JsonTransformStringValuesAction) headline_json_value; - HeadlineParsedText prs; HeadlineJsonState *state = palloc0(sizeof(HeadlineJsonState)); @@ -394,7 +396,7 @@ ts_headline_jsonb_byid_opt(PG_FUNCTION_ARGS) prs.words = (HeadlineWordEntry *) palloc(sizeof(HeadlineWordEntry) * prs.lenwords); state->prs = &prs; - state->cfg = lookup_ts_config_cache(PG_GETARG_OID(0)); + state->cfg = lookup_ts_config_cache(tsconfig); state->prsobj = lookup_ts_parser_cache(state->cfg->prsId); state->query = query; if (opt) @@ -456,6 +458,7 @@ ts_headline_jsonb_opt(PG_FUNCTION_ARGS) Datum ts_headline_json_byid_opt(PG_FUNCTION_ARGS) { + Oid tsconfig = PG_GETARG_OID(0); text *json = PG_GETARG_TEXT_P(1); TSQuery query = PG_GETARG_TSQUERY(2); text *opt = (PG_NARGS() > 3 && PG_GETARG_POINTER(3)) ? PG_GETARG_TEXT_P(3) : NULL; @@ -470,7 +473,7 @@ ts_headline_json_byid_opt(PG_FUNCTION_ARGS) prs.words = (HeadlineWordEntry *) palloc(sizeof(HeadlineWordEntry) * prs.lenwords); state->prs = &prs; - state->cfg = lookup_ts_config_cache(PG_GETARG_OID(0)); + state->cfg = lookup_ts_config_cache(tsconfig); state->prsobj = lookup_ts_parser_cache(state->cfg->prsId); state->query = query; if (opt) diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c index 0566abd314..1e21dd5c68 100644 --- a/src/backend/utils/adt/formatting.c +++ b/src/backend/utils/adt/formatting.c @@ -1448,9 +1448,15 @@ str_numth(char *dest, char *num, int type) *****************************************************************************/ #ifdef USE_ICU + +typedef int32_t (*ICU_Convert_Func)(UChar *dest, int32_t destCapacity, + const UChar *src, int32_t srcLength, + const char *locale, + UErrorCode *pErrorCode); + static int32_t -icu_convert_case(int32_t (*func)(UChar *, int32_t, const UChar *, int32_t, const char *, UErrorCode *), - pg_locale_t mylocale, UChar **buff_dest, UChar *buff_source, int32_t len_source) +icu_convert_case(ICU_Convert_Func func, pg_locale_t mylocale, + UChar **buff_dest, UChar *buff_source, int32_t len_source) { UErrorCode status; int32_t len_dest; @@ -1458,14 +1464,16 @@ icu_convert_case(int32_t (*func)(UChar *, int32_t, const UChar *, int32_t, const len_dest = len_source; /* try first with same length */ *buff_dest = palloc(len_dest * sizeof(**buff_dest)); status = U_ZERO_ERROR; - len_dest = func(*buff_dest, len_dest, buff_source, len_source, mylocale->info.icu.locale, &status); + len_dest = func(*buff_dest, len_dest, buff_source, len_source, + mylocale->info.icu.locale, &status); if (status == U_BUFFER_OVERFLOW_ERROR) { /* try again with adjusted length */ - pfree(buff_dest); - buff_dest = palloc(len_dest * sizeof(**buff_dest)); + pfree(*buff_dest); + *buff_dest = palloc(len_dest * sizeof(**buff_dest)); status = U_ZERO_ERROR; - len_dest = func(*buff_dest, len_dest, buff_source, len_source, mylocale->info.icu.locale, &status); + len_dest = func(*buff_dest, len_dest, buff_source, len_source, + mylocale->info.icu.locale, &status); } if (U_FAILURE(status)) ereport(ERROR, @@ -1479,9 +1487,11 @@ u_strToTitle_default_BI(UChar *dest, int32_t destCapacity, const char *locale, UErrorCode *pErrorCode) { - return u_strToTitle(dest, destCapacity, src, srcLength, NULL, locale, pErrorCode); + return u_strToTitle(dest, destCapacity, src, srcLength, + NULL, locale, pErrorCode); } -#endif + +#endif /* USE_ICU */ /* * If the system provides the needed functions for wide-character manipulation @@ -1548,7 +1558,8 @@ str_tolower(const char *buff, size_t nbytes, Oid collid) UChar *buff_conv; len_uchar = icu_to_uchar(&buff_uchar, buff, nbytes); - len_conv = icu_convert_case(u_strToLower, mylocale, &buff_conv, buff_uchar, len_uchar); + len_conv = icu_convert_case(u_strToLower, mylocale, + &buff_conv, buff_uchar, len_uchar); icu_from_uchar(&result, buff_conv, len_conv); } else @@ -1666,7 +1677,8 @@ str_toupper(const char *buff, size_t nbytes, Oid collid) UChar *buff_conv; len_uchar = icu_to_uchar(&buff_uchar, buff, nbytes); - len_conv = icu_convert_case(u_strToUpper, mylocale, &buff_conv, buff_uchar, len_uchar); + len_conv = icu_convert_case(u_strToUpper, mylocale, + &buff_conv, buff_uchar, len_uchar); icu_from_uchar(&result, buff_conv, len_conv); } else @@ -1785,7 +1797,8 @@ str_initcap(const char *buff, size_t nbytes, Oid collid) UChar *buff_conv; len_uchar = icu_to_uchar(&buff_uchar, buff, nbytes); - len_conv = icu_convert_case(u_strToTitle_default_BI, mylocale, &buff_conv, buff_uchar, len_uchar); + len_conv = icu_convert_case(u_strToTitle_default_BI, mylocale, + &buff_conv, buff_uchar, len_uchar); icu_from_uchar(&result, buff_conv, len_conv); } else diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c index 2a2c9bc504..e2ccac2d2a 100644 --- a/src/backend/utils/adt/pg_locale.c +++ b/src/backend/utils/adt/pg_locale.c @@ -1381,12 +1381,14 @@ pg_newlocale_from_collation(Oid collid) actual_versionstr = get_collation_actual_version(collform->collprovider, collcollate); if (!actual_versionstr) + { /* This could happen when specifying a version in CREATE * COLLATION for a libc locale, or manually creating a mess * in the catalogs. */ ereport(ERROR, (errmsg("collation \"%s\" has no actual version, but a version was specified", NameStr(collform->collname)))); + } collversionstr = TextDatumGetCString(collversion); if (strcmp(actual_versionstr, collversionstr) != 0) diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c index a75d565843..866f88a017 100644 --- a/src/bin/pg_basebackup/pg_basebackup.c +++ b/src/bin/pg_basebackup/pg_basebackup.c @@ -331,22 +331,22 @@ usage(void) printf(_("\nOptions controlling the output:\n")); printf(_(" -D, --pgdata=DIRECTORY receive base backup into directory\n")); printf(_(" -F, --format=p|t output format (plain (default), tar)\n")); - printf(_(" -r, --max-rate=RATE maximum transfer rate to transfer data directory\n" - " (in kB/s, or use suffix \"k\" or \"M\")\n")); - printf(_(" -R, --write-recovery-conf\n" - " write recovery.conf for replication\n")); + printf(_(" -r, --max-rate=RATE maximum transfer rate to transfer data directory\n")); + printf(_(" (in kB/s, or use suffix \"k\" or \"M\")\n")); + printf(_(" -R, --write-recovery-conf\n")); + printf(_(" write recovery.conf for replication\n")); printf(_(" -S, --slot=SLOTNAME replication slot to use\n")); printf(_(" --no-slot prevent creation of temporary replication slot\n")); - printf(_(" -T, --tablespace-mapping=OLDDIR=NEWDIR\n" - " relocate tablespace in OLDDIR to NEWDIR\n")); - printf(_(" -X, --wal-method=none|fetch|stream\n" - " include required WAL files with specified method\n")); + printf(_(" -T, --tablespace-mapping=OLDDIR=NEWDIR\n")); + printf(_(" relocate tablespace in OLDDIR to NEWDIR\n")); + printf(_(" -X, --wal-method=none|fetch|stream\n")); + printf(_(" include required WAL files with specified method\n")); printf(_(" --waldir=WALDIR location for the write-ahead log directory\n")); printf(_(" -z, --gzip compress tar output\n")); printf(_(" -Z, --compress=0-9 compress tar output with given compression level\n")); printf(_("\nGeneral options:\n")); - printf(_(" -c, --checkpoint=fast|spread\n" - " set fast or spread checkpointing\n")); + printf(_(" -c, --checkpoint=fast|spread\n")); + printf(_(" set fast or spread checkpointing\n")); printf(_(" -l, --label=LABEL set backup label\n")); printf(_(" -n, --no-clean do not clean up after errors\n")); printf(_(" -N, --no-sync do not wait for changes to be written safely to disk\n")); @@ -358,8 +358,8 @@ usage(void) printf(_(" -d, --dbname=CONNSTR connection string\n")); printf(_(" -h, --host=HOSTNAME database server host or socket directory\n")); printf(_(" -p, --port=PORT database server port number\n")); - printf(_(" -s, --status-interval=INTERVAL\n" - " time between status packets sent to server (in seconds)\n")); + printf(_(" -s, --status-interval=INTERVAL\n")); + printf(_(" time between status packets sent to server (in seconds)\n")); printf(_(" -U, --username=NAME connect as specified database user\n")); printf(_(" -w, --no-password never prompt for password\n")); printf(_(" -W, --password force password prompt (should happen automatically)\n")); diff --git a/src/bin/pg_dump/dumputils.c b/src/bin/pg_dump/dumputils.c index 19534248ab..79eac8c7cf 100644 --- a/src/bin/pg_dump/dumputils.c +++ b/src/bin/pg_dump/dumputils.c @@ -527,8 +527,7 @@ do { \ else if (strcmp(type, "LANGUAGE") == 0) CONVERT_PRIV('U', "USAGE"); else if (strcmp(type, "SCHEMA") == 0 || - strcmp(type, "SCHEMAS") == 0 - ) + strcmp(type, "SCHEMAS") == 0) { CONVERT_PRIV('C', "CREATE"); CONVERT_PRIV('U', "USAGE"); diff --git a/src/bin/pg_dump/pg_backup_archiver.h b/src/bin/pg_dump/pg_backup_archiver.h index 04cbb45bdc..e7ab6a8fed 100644 --- a/src/bin/pg_dump/pg_backup_archiver.h +++ b/src/bin/pg_dump/pg_backup_archiver.h @@ -257,8 +257,8 @@ struct _archiveHandle WriteExtraTocPtrType WriteExtraTocPtr; /* Write extra TOC entry data * associated with the current archive * format */ - ReadExtraTocPtrType ReadExtraTocPtr; /* Read extr info associated with - * archie format */ + ReadExtraTocPtrType ReadExtraTocPtr; /* Read extra info associated with + * archive format */ PrintExtraTocPtrType PrintExtraTocPtr; /* Extra TOC info for format */ PrintTocDataPtrType PrintTocDataPtr; diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c index 77b36f60e1..56843a5d50 100644 --- a/src/bin/pg_waldump/pg_waldump.c +++ b/src/bin/pg_waldump/pg_waldump.c @@ -689,18 +689,18 @@ usage(void) printf(_(" -e, --end=RECPTR stop reading at WAL location RECPTR\n")); printf(_(" -f, --follow keep retrying after reaching end of WAL\n")); printf(_(" -n, --limit=N number of records to display\n")); - printf(_(" -p, --path=PATH directory in which to find log segment files or a\n" - " directory with a ./pg_wal that contains such files\n" - " (default: current directory, ./pg_wal, PGDATA/pg_wal)\n")); - printf(_(" -r, --rmgr=RMGR only show records generated by resource manager RMGR\n" - " use --rmgr=list to list valid resource manager names\n")); + printf(_(" -p, --path=PATH directory in which to find log segment files or a\n")); + printf(_(" directory with a ./pg_wal that contains such files\n")); + printf(_(" (default: current directory, ./pg_wal, PGDATA/pg_wal)\n")); + printf(_(" -r, --rmgr=RMGR only show records generated by resource manager RMGR\n")); + printf(_(" use --rmgr=list to list valid resource manager names\n")); printf(_(" -s, --start=RECPTR start reading at WAL location RECPTR\n")); - printf(_(" -t, --timeline=TLI timeline from which to read log records\n" - " (default: 1 or the value used in STARTSEG)\n")); + printf(_(" -t, --timeline=TLI timeline from which to read log records\n")); + printf(_(" (default: 1 or the value used in STARTSEG)\n")); printf(_(" -V, --version output version information, then exit\n")); printf(_(" -x, --xid=XID only show records with TransactionId XID\n")); - printf(_(" -z, --stats[=record] show statistics instead of records\n" - " (optionally, show per-record statistics)\n")); + printf(_(" -z, --stats[=record] show statistics instead of records\n")); + printf(_(" (optionally, show per-record statistics)\n")); printf(_(" -?, --help show this help, then exit\n")); } diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index b9e3491aec..c768a48e4d 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -2772,6 +2772,7 @@ psql_completion(const char *text, int start, int end) */ /* Complete GRANT/REVOKE with a list of roles and privileges */ else if (TailMatches1("GRANT|REVOKE")) + { /* * With ALTER DEFAULT PRIVILEGES, restrict completion * to grantable privileges (can't grant roles) @@ -2795,7 +2796,7 @@ psql_completion(const char *text, int start, int end) " UNION SELECT 'EXECUTE'" " UNION SELECT 'USAGE'" " UNION SELECT 'ALL'"); - + } /* * Complete GRANT/REVOKE with "ON", GRANT/REVOKE with * TO/FROM @@ -2822,6 +2823,7 @@ psql_completion(const char *text, int start, int end) * privilege. */ else if (TailMatches3("GRANT|REVOKE", MatchAny, "ON")) + { /* * With ALTER DEFAULT PRIVILEGES, restrict completion * to the kinds of objects supported. @@ -2845,11 +2847,10 @@ psql_completion(const char *text, int start, int end) " UNION SELECT 'TABLE'" " UNION SELECT 'TABLESPACE'" " UNION SELECT 'TYPE'"); - + } else if (TailMatches4("GRANT|REVOKE", MatchAny, "ON", "ALL")) COMPLETE_WITH_LIST3("FUNCTIONS IN SCHEMA", "SEQUENCES IN SCHEMA", "TABLES IN SCHEMA"); - else if (TailMatches4("GRANT|REVOKE", MatchAny, "ON", "FOREIGN")) COMPLETE_WITH_LIST2("DATA WRAPPER", "SERVER"); diff --git a/src/common/scram-common.c b/src/common/scram-common.c index 77b54c8a5e..295507a0ad 100644 --- a/src/common/scram-common.c +++ b/src/common/scram-common.c @@ -213,9 +213,10 @@ scram_build_verifier(const char *salt, int saltlen, int iterations, scram_ServerKey(salted_password, server_key); - /* + /*---------- * The format is: * SCRAM-SHA-256$:$: + *---------- */ maxlen = strlen("SCRAM-SHA-256") + 1 + 10 + 1 /* iteration count */ diff --git a/src/include/catalog/pg_authid.h b/src/include/catalog/pg_authid.h index a6c5c02ceb..82524242e1 100644 --- a/src/include/catalog/pg_authid.h +++ b/src/include/catalog/pg_authid.h @@ -94,23 +94,21 @@ typedef FormData_pg_authid *Form_pg_authid; * The uppercase quantities will be replaced at initdb time with * user choices. * - * If adding new default roles or changing the OIDs below, be sure to add or - * update the #defines which follow as appropriate. + * The C code typically refers to these roles using the #define symbols, + * so be sure to keep those in sync with the DATA lines. * ---------------- */ DATA(insert OID = 10 ( "POSTGRES" t t t t t t t -1 _null_ _null_)); -DATA(insert OID = 3373 ( "pg_monitor" f t f f f f f -1 _null_ _null_)); -DATA(insert OID = 3374 ( "pg_read_all_settings" f t f f f f f -1 _null_ _null_)); -DATA(insert OID = 3375 ( "pg_read_all_stats" f t f f f f f -1 _null_ _null_)); -DATA(insert OID = 3377 ( "pg_stat_scan_tables" f t f f f f f -1 _null_ _null_)); -DATA(insert OID = 4200 ( "pg_signal_backend" f t f f f f f -1 _null_ _null_)); - #define BOOTSTRAP_SUPERUSERID 10 - +DATA(insert OID = 3373 ( "pg_monitor" f t f f f f f -1 _null_ _null_)); #define DEFAULT_ROLE_MONITOR 3373 +DATA(insert OID = 3374 ( "pg_read_all_settings" f t f f f f f -1 _null_ _null_)); #define DEFAULT_ROLE_READ_ALL_SETTINGS 3374 +DATA(insert OID = 3375 ( "pg_read_all_stats" f t f f f f f -1 _null_ _null_)); #define DEFAULT_ROLE_READ_ALL_STATS 3375 +DATA(insert OID = 3377 ( "pg_stat_scan_tables" f t f f f f f -1 _null_ _null_)); #define DEFAULT_ROLE_STAT_SCAN_TABLES 3377 +DATA(insert OID = 4200 ( "pg_signal_backend" f t f f f f f -1 _null_ _null_)); #define DEFAULT_ROLE_SIGNAL_BACKENDID 4200 #endif /* PG_AUTHID_H */ diff --git a/src/include/catalog/pg_subscription_rel.h b/src/include/catalog/pg_subscription_rel.h index 9f4f152a11..f08fb528a2 100644 --- a/src/include/catalog/pg_subscription_rel.h +++ b/src/include/catalog/pg_subscription_rel.h @@ -51,15 +51,15 @@ typedef FormData_pg_subscription_rel *Form_pg_subscription_rel; * substate constants * ---------------- */ -#define SUBREL_STATE_INIT 'i' /* initializing (sublsn NULL) */ -#define SUBREL_STATE_DATASYNC 'd' /* data is being synchronized (sublsn NULL) */ -#define SUBREL_STATE_SYNCDONE 's' /* synchronization finished infront of apply (sublsn set) */ -#define SUBREL_STATE_READY 'r' /* ready (sublsn set) */ +#define SUBREL_STATE_INIT 'i' /* initializing (sublsn NULL) */ +#define SUBREL_STATE_DATASYNC 'd' /* data is being synchronized (sublsn NULL) */ +#define SUBREL_STATE_SYNCDONE 's' /* synchronization finished in front of apply (sublsn set) */ +#define SUBREL_STATE_READY 'r' /* ready (sublsn set) */ /* These are never stored in the catalog, we only use them for IPC. */ -#define SUBREL_STATE_UNKNOWN '\0' /* unknown state */ -#define SUBREL_STATE_SYNCWAIT 'w' /* waiting for sync */ -#define SUBREL_STATE_CATCHUP 'c' /* catching up with apply */ +#define SUBREL_STATE_UNKNOWN '\0' /* unknown state */ +#define SUBREL_STATE_SYNCWAIT 'w' /* waiting for sync */ +#define SUBREL_STATE_CATCHUP 'c' /* catching up with apply */ typedef struct SubscriptionRelState { diff --git a/src/include/replication/logicalproto.h b/src/include/replication/logicalproto.h index 0d8153c39d..9d0c15d403 100644 --- a/src/include/replication/logicalproto.h +++ b/src/include/replication/logicalproto.h @@ -30,8 +30,10 @@ /* Tuple coming via logical replication. */ typedef struct LogicalRepTupleData { - char *values[MaxTupleAttributeNumber]; /* value in out function format or NULL if values is NULL */ - bool changed[MaxTupleAttributeNumber]; /* marker for changed/unchanged values */ + /* column values in text format, or NULL for a null value: */ + char *values[MaxTupleAttributeNumber]; + /* markers for changed/unchanged column values: */ + bool changed[MaxTupleAttributeNumber]; } LogicalRepTupleData; typedef uint32 LogicalRepRelId; diff --git a/src/interfaces/libpq/libpq-int.h b/src/interfaces/libpq/libpq-int.h index 34d049262f..335568b790 100644 --- a/src/interfaces/libpq/libpq-int.h +++ b/src/interfaces/libpq/libpq-int.h @@ -360,8 +360,8 @@ struct pg_conn char *krbsrvname; /* Kerberos service name */ #endif - char *target_session_attrs; /* Type of connection to make - * Possible values any, read-write. */ + /* Type of connection to make. Possible values: any, read-write. */ + char *target_session_attrs; /* Optional file to write trace info to */ FILE *Pfdebug;