Laurenz Albe schreef op vr 25-02-2022 om 10:33 [+0100]: > On Thu, 2022-02-24 at 18:16 +0100, Wim Bertels wrote: > This was interpreted as if you had entered it in a single line: > > \set x 1 select :x > > So "x" is now "1select1;". yes > > I don't quite understand what you mean, but the behavior of \e > changed > (got more sane) in v14. yes, (this is just a summary of different cases) > > > variation of case 2: > > postgres=# \e > > > > -- enter the following the editor (the same code as above) > > > > \set x 1 > > select :x; > > > > -- save and quit > > > > postgres=# select :x; > > select1select1 > > ---------------- > > 1 > > Now "x" is "1select1select1;;", so you are running > > select 1select1select1;;; > > Here "select1select1" is interpreted as alias, so you get that column > heading. > > You can use "\echo :x" to see the value of a variable. > Thanks for the feedback Laurenz I guess the main remark is, it not so intuitive that \e behaves differently then \i From https://www.postgresql.org/docs/current/app-psql.html " \e.. Type semicolon or \g to send it, or \r to cancel it by clearing the query buffer. Treating the buffer as a single line primarily affects meta-commands: whatever is in the buffer after a meta-command will be taken as argument(s) to the meta-command, even if it spans multiple lines. (Thus you cannot make meta-command-using scripts this way. Use \i for that.) " ### case 1: (\e) \set x 1 select :x ; ### case 2: (\e) \set x 1 select :x \g resulting in the same value for x (\echo :x), but different intermediate output with case 1 and case 2, " \g.. If the current query buffer is empty, the most recently sent query is re-executed instead. Except for that behavior, \g without any arguments is essentially equivalent to a semicolon. " mvg, Wim