Per a recent thread, these patches remove string literals split with \-escaped newlines. The first is for the message "materialize mode required, but it is not allowed in this context" where it's more prevalent, and we keep perpetuating it; the second is for other messages, whose bulk is in dblink and tablefunc. I think the split is pointless and therefore propose to push both together as a single commit, but maybe somebody would like me to leave those contrib modules alone.
There are many other error messages that are split with no \; I would prefer not to have them, but maybe it would be too intrusive to change them all. So let's do this for now and remove this one point of ugliness. -- Álvaro Herrera 39°49'30"S 73°17'W
>From 307d334046c62607e907a4f7a71e121c5c4b3dba Mon Sep 17 00:00:00 2001 From: Alvaro Herrera <alvhe...@alvh.no-ip.org> Date: Mon, 23 Dec 2019 16:23:57 -0300 Subject: [PATCH 1/2] Fix line continuation --- contrib/pg_stat_statements/pg_stat_statements.c | 3 +-- contrib/tablefunc/tablefunc.c | 12 ++++-------- src/backend/access/transam/xlogfuncs.c | 3 +-- src/backend/commands/extension.c | 9 +++------ src/backend/commands/prepare.c | 3 +-- src/backend/libpq/hba.c | 3 +-- src/backend/replication/logical/launcher.c | 3 +-- src/backend/replication/slotfuncs.c | 3 +-- src/backend/replication/walsender.c | 3 +-- src/backend/utils/adt/pgstatfuncs.c | 6 ++---- src/backend/utils/misc/guc.c | 3 +-- src/backend/utils/mmgr/portalmem.c | 3 +-- 12 files changed, 18 insertions(+), 36 deletions(-) diff --git a/contrib/pg_stat_statements/pg_stat_statements.c b/contrib/pg_stat_statements/pg_stat_statements.c index 63b5888ebb..0590a6769b 100644 --- a/contrib/pg_stat_statements/pg_stat_statements.c +++ b/contrib/pg_stat_statements/pg_stat_statements.c @@ -1415,8 +1415,7 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo, if (!(rsinfo->allowedModes & SFRM_Materialize)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("materialize mode required, but it is not " \ - "allowed in this context"))); + errmsg("materialize mode required, but it is not allowed in this context"))); /* Switch into long-lived context to construct returned data structures */ per_query_ctx = rsinfo->econtext->ecxt_per_query_memory; diff --git a/contrib/tablefunc/tablefunc.c b/contrib/tablefunc/tablefunc.c index 256d52fc62..30d94f5d90 100644 --- a/contrib/tablefunc/tablefunc.c +++ b/contrib/tablefunc/tablefunc.c @@ -373,8 +373,7 @@ crosstab(PG_FUNCTION_ARGS) if (!(rsinfo->allowedModes & SFRM_Materialize)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("materialize mode required, but it is not " \ - "allowed in this context"))); + errmsg("materialize mode required, but it is not allowed in this context"))); per_query_ctx = rsinfo->econtext->ecxt_per_query_memory; @@ -650,8 +649,7 @@ crosstab_hash(PG_FUNCTION_ARGS) rsinfo->expectedDesc == NULL) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("materialize mode required, but it is not " \ - "allowed in this context"))); + errmsg("materialize mode required, but it is not allowed in this context"))); per_query_ctx = rsinfo->econtext->ecxt_per_query_memory; oldcontext = MemoryContextSwitchTo(per_query_ctx); @@ -1006,8 +1004,7 @@ connectby_text(PG_FUNCTION_ARGS) rsinfo->expectedDesc == NULL) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("materialize mode required, but it is not " \ - "allowed in this context"))); + errmsg("materialize mode required, but it is not allowed in this context"))); if (fcinfo->nargs == 6) { @@ -1086,8 +1083,7 @@ connectby_text_serial(PG_FUNCTION_ARGS) rsinfo->expectedDesc == NULL) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("materialize mode required, but it is not " \ - "allowed in this context"))); + errmsg("materialize mode required, but it is not allowed in this context"))); if (fcinfo->nargs == 7) { diff --git a/src/backend/access/transam/xlogfuncs.c b/src/backend/access/transam/xlogfuncs.c index 5fd12152b2..d7d17efaf9 100644 --- a/src/backend/access/transam/xlogfuncs.c +++ b/src/backend/access/transam/xlogfuncs.c @@ -186,8 +186,7 @@ pg_stop_backup_v2(PG_FUNCTION_ARGS) if (!(rsinfo->allowedModes & SFRM_Materialize)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("materialize mode required, but it is not " \ - "allowed in this context"))); + errmsg("materialize mode required, but it is not allowed in this context"))); /* Build a tuple descriptor for our result type */ if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) diff --git a/src/backend/commands/extension.c b/src/backend/commands/extension.c index a04b0c9e57..6eaa9cc4f3 100644 --- a/src/backend/commands/extension.c +++ b/src/backend/commands/extension.c @@ -1921,8 +1921,7 @@ pg_available_extensions(PG_FUNCTION_ARGS) if (!(rsinfo->allowedModes & SFRM_Materialize)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("materialize mode required, but it is not " \ - "allowed in this context"))); + errmsg("materialize mode required, but it is not allowed in this context"))); /* Build a tuple descriptor for our result type */ if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) @@ -2030,8 +2029,7 @@ pg_available_extension_versions(PG_FUNCTION_ARGS) if (!(rsinfo->allowedModes & SFRM_Materialize)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("materialize mode required, but it is not " \ - "allowed in this context"))); + errmsg("materialize mode required, but it is not allowed in this context"))); /* Build a tuple descriptor for our result type */ if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) @@ -2254,8 +2252,7 @@ pg_extension_update_paths(PG_FUNCTION_ARGS) if (!(rsinfo->allowedModes & SFRM_Materialize)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("materialize mode required, but it is not " \ - "allowed in this context"))); + errmsg("materialize mode required, but it is not allowed in this context"))); /* Build a tuple descriptor for our result type */ if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c index 47bae957dc..d99890586c 100644 --- a/src/backend/commands/prepare.c +++ b/src/backend/commands/prepare.c @@ -714,8 +714,7 @@ pg_prepared_statement(PG_FUNCTION_ARGS) if (!(rsinfo->allowedModes & SFRM_Materialize)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("materialize mode required, but it is not " \ - "allowed in this context"))); + errmsg("materialize mode required, but it is not allowed in this context"))); /* need to build tuplestore in query context */ per_query_ctx = rsinfo->econtext->ecxt_per_query_memory; diff --git a/src/backend/libpq/hba.c b/src/backend/libpq/hba.c index 9989904769..b6de92783a 100644 --- a/src/backend/libpq/hba.c +++ b/src/backend/libpq/hba.c @@ -2667,8 +2667,7 @@ pg_hba_file_rules(PG_FUNCTION_ARGS) if (!(rsi->allowedModes & SFRM_Materialize)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("materialize mode required, but it is not " \ - "allowed in this context"))); + errmsg("materialize mode required, but it is not allowed in this context"))); rsi->returnMode = SFRM_Materialize; diff --git a/src/backend/replication/logical/launcher.c b/src/backend/replication/logical/launcher.c index 99cfa5d8b4..c57b578b48 100644 --- a/src/backend/replication/logical/launcher.c +++ b/src/backend/replication/logical/launcher.c @@ -1087,8 +1087,7 @@ pg_stat_get_subscription(PG_FUNCTION_ARGS) if (!(rsinfo->allowedModes & SFRM_Materialize)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("materialize mode required, but it is not " \ - "allowed in this context"))); + errmsg("materialize mode required, but it is not allowed in this context"))); /* Build a tuple descriptor for our result type */ if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) diff --git a/src/backend/replication/slotfuncs.c b/src/backend/replication/slotfuncs.c index 46e6dd4d12..6683fc3f9b 100644 --- a/src/backend/replication/slotfuncs.c +++ b/src/backend/replication/slotfuncs.c @@ -237,8 +237,7 @@ pg_get_replication_slots(PG_FUNCTION_ARGS) if (!(rsinfo->allowedModes & SFRM_Materialize)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("materialize mode required, but it is not " \ - "allowed in this context"))); + errmsg("materialize mode required, but it is not allowed in this context"))); /* Build a tuple descriptor for our result type */ if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c index 8e74177de4..1f23665432 100644 --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@ -3196,8 +3196,7 @@ pg_stat_get_wal_senders(PG_FUNCTION_ARGS) if (!(rsinfo->allowedModes & SFRM_Materialize)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("materialize mode required, but it is not " \ - "allowed in this context"))); + errmsg("materialize mode required, but it is not allowed in this context"))); /* Build a tuple descriptor for our result type */ if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c index 05240bfd14..d9f78221aa 100644 --- a/src/backend/utils/adt/pgstatfuncs.c +++ b/src/backend/utils/adt/pgstatfuncs.c @@ -459,8 +459,7 @@ pg_stat_get_progress_info(PG_FUNCTION_ARGS) if (!(rsinfo->allowedModes & SFRM_Materialize)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("materialize mode required, but it is not " \ - "allowed in this context"))); + errmsg("materialize mode required, but it is not allowed in this context"))); /* Build a tuple descriptor for our result type */ if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) @@ -564,8 +563,7 @@ pg_stat_get_activity(PG_FUNCTION_ARGS) if (!(rsinfo->allowedModes & SFRM_Materialize)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("materialize mode required, but it is not " \ - "allowed in this context"))); + errmsg("materialize mode required, but it is not allowed in this context"))); /* Build a tuple descriptor for our result type */ if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8d951ce404..4b4911d5ec 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -9507,8 +9507,7 @@ show_all_file_settings(PG_FUNCTION_ARGS) if (!(rsinfo->allowedModes & SFRM_Materialize)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("materialize mode required, but it is not " \ - "allowed in this context"))); + errmsg("materialize mode required, but it is not allowed in this context"))); /* Scan the config files using current context as workspace */ conf = ProcessConfigFileInternal(PGC_SIGHUP, false, DEBUG3); diff --git a/src/backend/utils/mmgr/portalmem.c b/src/backend/utils/mmgr/portalmem.c index 334e35bb6a..8c4118d654 100644 --- a/src/backend/utils/mmgr/portalmem.c +++ b/src/backend/utils/mmgr/portalmem.c @@ -1135,8 +1135,7 @@ pg_cursor(PG_FUNCTION_ARGS) if (!(rsinfo->allowedModes & SFRM_Materialize)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("materialize mode required, but it is not " \ - "allowed in this context"))); + errmsg("materialize mode required, but it is not allowed in this context"))); /* need to build tuplestore in query context */ per_query_ctx = rsinfo->econtext->ecxt_per_query_memory; -- 2.20.1
>From f43b3741d56305f47e639d447fc15783227f8654 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera <alvhe...@alvh.no-ip.org> Date: Mon, 23 Dec 2019 16:26:52 -0300 Subject: [PATCH 2/2] Fix line continuation --- contrib/dblink/dblink.c | 15 ++++-------- contrib/tablefunc/tablefunc.c | 35 +++++++++------------------ src/backend/access/transam/xlog.c | 4 +-- src/backend/executor/execExprInterp.c | 4 +-- 4 files changed, 20 insertions(+), 38 deletions(-) diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c index 7e225589a9..a28b080059 100644 --- a/contrib/dblink/dblink.c +++ b/contrib/dblink/dblink.c @@ -1639,8 +1639,7 @@ dblink_build_sql_insert(PG_FUNCTION_ARGS) if (src_nitems != pknumatts) ereport(ERROR, (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), - errmsg("source key array length must match number of key " \ - "attributes"))); + errmsg("source key array length must match number of key attributes"))); /* * Target array is made up of key values that will be used to build the @@ -1654,8 +1653,7 @@ dblink_build_sql_insert(PG_FUNCTION_ARGS) if (tgt_nitems != pknumatts) ereport(ERROR, (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), - errmsg("target key array length must match number of key " \ - "attributes"))); + errmsg("target key array length must match number of key attributes"))); /* * Prep work is finally done. Go get the SQL string. @@ -1727,8 +1725,7 @@ dblink_build_sql_delete(PG_FUNCTION_ARGS) if (tgt_nitems != pknumatts) ereport(ERROR, (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), - errmsg("target key array length must match number of key " \ - "attributes"))); + errmsg("target key array length must match number of key attributes"))); /* * Prep work is finally done. Go get the SQL string. @@ -1807,8 +1804,7 @@ dblink_build_sql_update(PG_FUNCTION_ARGS) if (src_nitems != pknumatts) ereport(ERROR, (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), - errmsg("source key array length must match number of key " \ - "attributes"))); + errmsg("source key array length must match number of key attributes"))); /* * Target array is made up of key values that will be used to build the @@ -1822,8 +1818,7 @@ dblink_build_sql_update(PG_FUNCTION_ARGS) if (tgt_nitems != pknumatts) ereport(ERROR, (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), - errmsg("target key array length must match number of key " \ - "attributes"))); + errmsg("target key array length must match number of key attributes"))); /* * Prep work is finally done. Go get the SQL string. diff --git a/contrib/tablefunc/tablefunc.c b/contrib/tablefunc/tablefunc.c index 30d94f5d90..db9885be1b 100644 --- a/contrib/tablefunc/tablefunc.c +++ b/contrib/tablefunc/tablefunc.c @@ -443,8 +443,7 @@ crosstab(PG_FUNCTION_ARGS) if (!compatCrosstabTupleDescs(tupdesc, spi_tupdesc)) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("return and sql tuple descriptions are " \ - "incompatible"))); + errmsg("return and sql tuple descriptions are incompatible"))); /* * switch to long-lived memory context @@ -667,8 +666,7 @@ crosstab_hash(PG_FUNCTION_ARGS) if (tupdesc->natts < 2) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("query-specified return tuple and " \ - "crosstab function are not compatible"))); + errmsg("query-specified return tuple and crosstab function are not compatible"))); /* load up the categories hash table */ crosstab_hash = load_categories_hash(cats_sql, per_query_ctx); @@ -746,8 +744,7 @@ load_categories_hash(char *cats_sql, MemoryContext per_query_ctx) if (spi_tupdesc->natts != 1) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("provided \"categories\" SQL must " \ - "return 1 column of at least one row"))); + errmsg("provided \"categories\" SQL must return 1 column of at least one row"))); for (i = 0; i < proc; i++) { @@ -829,8 +826,7 @@ get_crosstab_tuplestore(char *sql, /* no qualifying category tuples */ ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("provided \"categories\" SQL must " \ - "return 1 column of at least one row"))); + errmsg("provided \"categories\" SQL must return 1 column of at least one row"))); } /* @@ -850,8 +846,7 @@ get_crosstab_tuplestore(char *sql, ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("invalid source data SQL statement"), - errdetail("The provided SQL must return 3 " \ - " columns; rowid, category, and values."))); + errdetail("The provided SQL must return 3 columns; rowid, category, and values."))); result_ncols = (ncols - 2) + num_categories; @@ -860,9 +855,8 @@ get_crosstab_tuplestore(char *sql, ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("invalid return type"), - errdetail("Query-specified return " \ - "tuple has %d columns but crosstab " \ - "returns %d.", tupdesc->natts, result_ncols))); + errdetail("Query-specified return tuple has %d columns but crosstab returns %d.", + tupdesc->natts, result_ncols))); /* allocate space and make sure it's clear */ values = (char **) palloc0(result_ncols * sizeof(char *)); @@ -1427,8 +1421,7 @@ validateConnectbyTupleDesc(TupleDesc td, bool show_branch, bool show_serial) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("invalid return type"), - errdetail("Query-specified return tuple has " \ - "wrong number of columns."))); + errdetail("Query-specified return tuple has wrong number of columns."))); } else { @@ -1436,8 +1429,7 @@ validateConnectbyTupleDesc(TupleDesc td, bool show_branch, bool show_serial) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("invalid return type"), - errdetail("Query-specified return tuple has " \ - "wrong number of columns."))); + errdetail("Query-specified return tuple has wrong number of columns."))); } /* check that the types of the first two columns match */ @@ -1517,8 +1509,7 @@ compatConnectbyTupleDescs(TupleDesc ret_tupdesc, TupleDesc sql_tupdesc) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("invalid return type"), - errdetail("SQL key field type %s does " \ - "not match return key field type %s.", + errdetail("SQL key field type %s does not match return key field type %s.", format_type_with_typemod(ret_atttypid, ret_atttypmod), format_type_with_typemod(sql_atttypid, sql_atttypmod)))); @@ -1531,8 +1522,7 @@ compatConnectbyTupleDescs(TupleDesc ret_tupdesc, TupleDesc sql_tupdesc) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("invalid return type"), - errdetail("SQL parent key field type %s does " \ - "not match return parent key field type %s.", + errdetail("SQL parent key field type %s does not match return parent key field type %s.", format_type_with_typemod(ret_atttypid, ret_atttypmod), format_type_with_typemod(sql_atttypid, sql_atttypmod)))); @@ -1562,8 +1552,7 @@ compatCrosstabTupleDescs(TupleDesc ret_tupdesc, TupleDesc sql_tupdesc) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("invalid return type"), - errdetail("SQL rowid datatype does not match " \ - "return rowid datatype."))); + errdetail("SQL rowid datatype does not match return rowid datatype."))); /* * - attribute [1] of the sql tuple is the category; no need to check it - diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index edee0c0f22..5658971cb3 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -6135,9 +6135,7 @@ do { \ if ((currValue) < (minValue)) \ ereport(ERROR, \ (errcode(ERRCODE_INVALID_PARAMETER_VALUE), \ - errmsg("hot standby is not possible because " \ - "%s = %d is a lower setting than on the master server " \ - "(its value was %d)", \ + errmsg("hot standby is not possible because %s = %d is a lower setting than on the master server (its value was %d)", \ param_name, \ currValue, \ minValue))); \ diff --git a/src/backend/executor/execExprInterp.c b/src/backend/executor/execExprInterp.c index dbed597816..034970648f 100644 --- a/src/backend/executor/execExprInterp.c +++ b/src/backend/executor/execExprInterp.c @@ -2739,8 +2739,8 @@ ExecEvalArrayExpr(ExprState *state, ExprEvalStep *op) if (ndims <= 0 || ndims > MAXDIM) ereport(ERROR, (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), - errmsg("number of array dimensions (%d) exceeds " \ - "the maximum allowed (%d)", ndims, MAXDIM))); + errmsg("number of array dimensions (%d) exceeds the maximum allowed (%d)", + ndims, MAXDIM))); elem_dims = (int *) palloc(elem_ndims * sizeof(int)); memcpy(elem_dims, ARR_DIMS(array), elem_ndims * sizeof(int)); -- 2.20.1