• Tom Lane's avatar
    Improve error messages about misuse of SELECT INTO. · 8f6a5219
    Tom Lane authored
    Improve two places in plpgsql, and one in spi.c, where an error
    message would confusingly tell you that you couldn't use a SELECT
    query, when what you had written *was* a SELECT query.  The actual
    problem is that you can't use SELECT ... INTO in these contexts,
    but the messages failed to make that apparent.  Special-case
    SELECT INTO to make these errors more helpful.
    
    Also, fix the same spots in plpgsql, as well as several messages
    in exec_eval_expr(), to not quote the entire complained-of query or
    expression in the primary error message.  That behavior very easily
    led to violating our message style guideline about keeping the primary
    error message short and single-line.  Also, since the important part
    of the message was after the inserted text, it could make the real
    problem very hard to see.  We can report the query or expression as
    the first line of errcontext instead.
    
    Per complaint from Roger Mason.  Back-patch to v14, since (a) some
    of these messages are new in v14 and (b) v14's translatable strings
    are still somewhat in flux.  The problem's older than that of
    course, but I'm hesitant to change the behavior further back.
    
    Discussion: https://postgr.es/m/1914708.1629474624@sss.pgh.pa.us
    8f6a5219
spi.c 79.9 KB