Thread

Commits

  1. Fix error message wording

  2. Add more SQL/JSON constructor functions

  1. strangely worded message

    Alvaro Herrera <alvherre@alvh.no-ip.org> — 2024-12-14T12:43:46Z

    Hello
    
    The following message introduced by commit 03734a7fed7d appears in two
    places:
    
            if (returning->typid != JSONOID && returning->typid != JSONBOID)
                ereport(ERROR,
                        (errcode(ERRCODE_DATATYPE_MISMATCH),
                         errmsg("cannot use RETURNING type %s in %s",
                                format_type_be(returning->typid), fname),
                         parser_errposition(pstate, output->typeName->location)));
    
    where fname is either JSON(), JSON_SCALAR(), JSON_SERIALIZE().  The
    wording seems a bit off to me.  What about the following?
    
    ERROR:  cannot use type %s in RETURNING clause of %s
    DETAIL:  Only types json and jsonb are allowed in the RETURNING clause.
    
    Other ideas I considered:
    
    ERROR:  cannot use RETURNING %s in %s
    ERROR:  cannot use "RETURNING %s" in %s
    
    DETAIL:  The type can be json or jsonb in RETURNING.
    DETAIL:  The RETURNING clause allows types json or jsonb.
    DETAIL:  Types json and jsonb are allowed in RETURNING.
    
    Thanks
    
    -- 
    Álvaro Herrera               48°01'N 7°57'E  —  https://www.EnterpriseDB.com/
    
    
    
    
  2. Re: strangely worded message

    Amit Langote <amitlangote09@gmail.com> — 2024-12-16T02:58:51Z

    Hi Alvaro,
    
    On Sat, Dec 14, 2024 at 9:43 PM Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:
    >
    > Hello
    >
    > The following message introduced by commit 03734a7fed7d appears in two
    > places:
    >
    >         if (returning->typid != JSONOID && returning->typid != JSONBOID)
    >             ereport(ERROR,
    >                     (errcode(ERRCODE_DATATYPE_MISMATCH),
    >                      errmsg("cannot use RETURNING type %s in %s",
    >                             format_type_be(returning->typid), fname),
    >                      parser_errposition(pstate, output->typeName->location)));
    >
    > where fname is either JSON(), JSON_SCALAR(), JSON_SERIALIZE().  The
    > wording seems a bit off to me.
    
    Yeah, I agree.
    
    >  What about the following?
    >
    > ERROR:  cannot use type %s in RETURNING clause of %s
    > DETAIL:  Only types json and jsonb are allowed in the RETURNING clause.
    
    +1
    
    > Other ideas I considered:
    >
    > ERROR:  cannot use RETURNING %s in %s
    > ERROR:  cannot use "RETURNING %s" in %s
    >
    > DETAIL:  The type can be json or jsonb in RETURNING.
    > DETAIL:  The RETURNING clause allows types json or jsonb.
    > DETAIL:  Types json and jsonb are allowed in RETURNING.
    
    I think I'd go with the one you chose.
    
    Are you planning to push a fix yourself or would you like me to?
    
    -- 
    Thanks, Amit Langote
    
    
    
    
  3. Re: strangely worded message

    Alvaro Herrera <alvherre@alvh.no-ip.org> — 2025-01-07T20:33:51Z

    Hi Amit,
    
    On 2024-Dec-16, Amit Langote wrote:
    
    > > ERROR:  cannot use type %s in RETURNING clause of %s
    > > DETAIL:  Only types json and jsonb are allowed in the RETURNING clause.
    
    > I think I'd go with the one you chose.
    
    Actually I noticed that the one in JSON_SERIALIZE() already has a
    different hint, "Try returning a string type or bytea.", so I made the
    other ones mimic that (and made it a hint rather than detail).
    
    > Are you planning to push a fix yourself or would you like me to?
    
    I just pushed it to both master and 17.
    
    Thanks for looking!
    
    -- 
    Álvaro Herrera               48°01'N 7°57'E  —  https://www.EnterpriseDB.com/
    "Si quieres ser creativo, aprende el arte de perder el tiempo"