summaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2017-05-16 20:36:35 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2017-05-16 20:36:35 -0400
commitc079673dcb7f210617c9fc1470e6bf166d8a2971 (patch)
treecd8a2c6834da8d1157f11a38cb6272dc48e42dd1 /src/backend
parentddd243584a0f353bbaba260d976cc41b251bbf21 (diff)
downloadpostgresql-c079673dcb7f210617c9fc1470e6bf166d8a2971.tar.gz
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.
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/catalog/pg_publication.c11
-rw-r--r--src/backend/commands/publicationcmds.c4
-rw-r--r--src/backend/commands/subscriptioncmds.c1
-rw-r--r--src/backend/executor/nodeNamedtuplestorescan.c1
-rw-r--r--src/backend/replication/logical/snapbuild.c2
-rw-r--r--src/backend/replication/pgoutput/pgoutput.c5
-rw-r--r--src/backend/tsearch/wparser.c13
-rw-r--r--src/backend/utils/adt/formatting.c35
-rw-r--r--src/backend/utils/adt/pg_locale.c2
9 files changed, 48 insertions, 26 deletions
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)