Message style improvements
authorPeter Eisentraut <peter@eisentraut.org>
Thu, 16 Sep 2021 12:48:52 +0000 (14:48 +0200)
committerPeter Eisentraut <peter@eisentraut.org>
Thu, 16 Sep 2021 13:36:44 +0000 (15:36 +0200)
src/backend/commands/typecmds.c
src/backend/libpq/auth.c
src/backend/libpq/be-secure-openssl.c
src/backend/utils/adt/jsonbsubs.c
src/backend/utils/adt/multirangetypes.c
src/test/regress/expected/jsonb.out

index 6bdb1a1660c3dcec8d576f9ee086d8f5b92f2996..b290629a4508c15a47c878e4a8a799c0781ac86f 100644 (file)
@@ -495,7 +495,7 @@ DefineType(ParseState *pstate, List *names, List *parameters)
        analyzeOid = findTypeAnalyzeFunction(analyzeName, typoid);
 
    /*
-    * Likewise look up the subscripting procedure if any.  If it is not
+    * Likewise look up the subscripting function if any.  If it is not
     * specified, but a typelem is specified, allow that if
     * raw_array_subscript_handler can be used.  (This is for backwards
     * compatibility; maybe someday we should throw an error instead.)
@@ -509,7 +509,7 @@ DefineType(ParseState *pstate, List *names, List *parameters)
        else
            ereport(ERROR,
                    (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-                    errmsg("element type cannot be specified without a valid subscripting procedure")));
+                    errmsg("element type cannot be specified without a subscripting function")));
    }
 
    /*
@@ -837,7 +837,7 @@ DefineDomain(CreateDomainStmt *stmt)
    analyzeProcedure = baseType->typanalyze;
 
    /*
-    * Domains don't need a subscript procedure, since they are not
+    * Domains don't need a subscript function, since they are not
     * subscriptable on their own.  If the base type is subscriptable, the
     * parser will reduce the type to the base type before subscripting.
     */
index 78e1ef3e6da382d1586d8b2c555196d5708ef2c9..a317aef1c92337771ee93310e28a80bb11cb00a5 100644 (file)
@@ -357,8 +357,8 @@ set_authn_id(Port *port, const char *id)
         * connection continue, either.
         */
        ereport(FATAL,
-               (errmsg("connection was re-authenticated"),
-                errdetail_log("previous ID: \"%s\"; new ID: \"%s\"",
+               (errmsg("authentication identifier set more than once"),
+                errdetail_log("previous identifier: \"%s\"; new identifier: \"%s\"",
                               port->authn_id, id)));
    }
 
index deedac29d74acd8eac6e6cc477bd59944e4200f6..e3b02b12f93b8aa0aa4fe7a3899904283f65c741 100644 (file)
@@ -1392,7 +1392,7 @@ X509_NAME_to_cstring(X509_NAME *name)
    if (membuf == NULL)
        ereport(ERROR,
                (errcode(ERRCODE_OUT_OF_MEMORY),
-                errmsg("failed to create BIO")));
+                errmsg("could not create BIO")));
 
    (void) BIO_set_close(membuf, BIO_CLOSE);
    for (i = 0; i < count; i++)
index 47a89457dbee158c36c9f9d405f636c9f1407b6f..0d160259d023974b81be5e7376d8155b76e343d3 100644 (file)
@@ -100,9 +100,8 @@ jsonb_subscript_transform(SubscriptingRef *sbsref,
                        if (targetType != UNKNOWNOID)
                            ereport(ERROR,
                                    (errcode(ERRCODE_DATATYPE_MISMATCH),
-                                    errmsg("subscript type is not supported"),
-                                    errhint("Jsonb subscript must be coerced "
-                                            "only to one type, integer or text."),
+                                    errmsg("subscript type %s is not supported", format_type_be(subExprType)),
+                                    errhint("jsonb subscript must be coercible to only one type, integer or text."),
                                     parser_errposition(pstate, exprLocation(subExpr))));
 
                        targetType = targets[i];
@@ -115,8 +114,8 @@ jsonb_subscript_transform(SubscriptingRef *sbsref,
                if (targetType == UNKNOWNOID)
                    ereport(ERROR,
                            (errcode(ERRCODE_DATATYPE_MISMATCH),
-                            errmsg("subscript type is not supported"),
-                            errhint("Jsonb subscript must be coerced to either integer or text"),
+                            errmsg("subscript type %s is not supported", format_type_be(subExprType)),
+                            errhint("jsonb subscript must be coercible to either integer or text."),
                             parser_errposition(pstate, exprLocation(subExpr))));
            }
            else
index 7076a60c32d7d120b2b339d12122ab59f72fff3d..77732155647a7901ac4691f32204f6511370a729 100644 (file)
@@ -961,7 +961,7 @@ multirange_constructor2(PG_FUNCTION_ARGS)
 
    if (PG_ARGISNULL(0))
        elog(ERROR,
-            "multirange values cannot contain NULL members");
+            "multirange values cannot contain null members");
 
    rangeArray = PG_GETARG_ARRAYTYPE_P(0);
 
@@ -973,9 +973,7 @@ multirange_constructor2(PG_FUNCTION_ARGS)
 
    rngtypid = ARR_ELEMTYPE(rangeArray);
    if (rngtypid != rangetyp->type_id)
-       ereport(ERROR,
-               (errcode(ERRCODE_DATATYPE_MISMATCH),
-                errmsg("type %u does not match constructor type", rngtypid)));
+       elog(ERROR, "type %u does not match constructor type", rngtypid);
 
    /*
     * Be careful: we can still be called with zero ranges, like this:
@@ -997,7 +995,7 @@ multirange_constructor2(PG_FUNCTION_ARGS)
            if (nulls[i])
                ereport(ERROR,
                        (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
-                        errmsg("multirange values cannot contain NULL members")));
+                        errmsg("multirange values cannot contain null members")));
 
            /* make_multirange will do its own copy */
            ranges[i] = DatumGetRangeTypeP(elements[i]);
@@ -1031,16 +1029,14 @@ multirange_constructor1(PG_FUNCTION_ARGS)
 
    if (PG_ARGISNULL(0))
        elog(ERROR,
-            "multirange values cannot contain NULL members");
+            "multirange values cannot contain null members");
 
    range = PG_GETARG_RANGE_P(0);
 
    /* Make sure the range type matches. */
    rngtypid = RangeTypeGetOid(range);
    if (rngtypid != rangetyp->type_id)
-       ereport(ERROR,
-               (errcode(ERRCODE_DATATYPE_MISMATCH),
-                errmsg("type %u does not match constructor type", rngtypid)));
+       elog(ERROR, "type %u does not match constructor type", rngtypid);
 
    PG_RETURN_MULTIRANGE_P(make_multirange(mltrngtypid, rangetyp, 1, &range));
 }
index 1add673968bfdad6b05c83746371c815e53197f2..a9cd145aeccf8ae5100887a25dadcac6803c4e65 100644 (file)
@@ -4822,10 +4822,10 @@ select ('[1, "2", null]'::jsonb)['1'];
 (1 row)
 
 select ('[1, "2", null]'::jsonb)[1.0];
-ERROR:  subscript type is not supported
+ERROR:  subscript type numeric is not supported
 LINE 1: select ('[1, "2", null]'::jsonb)[1.0];
                                          ^
-HINT:  Jsonb subscript must be coerced to either integer or text
+HINT:  jsonb subscript must be coercible to either integer or text.
 select ('[1, "2", null]'::jsonb)[2];
  jsonb 
 -------