Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nNWyW-0002A9-Mz for pgsql-general@arkaria.postgresql.org; Fri, 25 Feb 2022 09:33:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nNWyV-0006ro-3Y for pgsql-general@arkaria.postgresql.org; Fri, 25 Feb 2022 09:33:19 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nNWyU-0006re-Lc for pgsql-general@lists.postgresql.org; Fri, 25 Feb 2022 09:33:18 +0000 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nNWyR-00011d-IL for pgsql-general@lists.postgresql.org; Fri, 25 Feb 2022 09:33:17 +0000 Received: by mail-wr1-x42f.google.com with SMTP id j22so3458377wrb.13 for ; Fri, 25 Feb 2022 01:33:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20210112.gappssmtp.com; s=20210112; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=xDiqOIA4YdU+G0JVuchjGQ7bUj9Ta7o+h//3Fakq5bg=; b=ltZJLdzmNYd74tlrWvQcKehD2SBdHMRze/36I1cFNXda/2VYx7+5lOZSdFXmySQ9dY gmLy3T6Az+K6fecxdmyIkB59AWDrIgH3S8zVq6ezDELC3erF/Zast+cm+WDBLELa6kiS JxOyPw0fySijfRu2WuyPGkhi1GwV0ylfNj+qxMMflK4de3OImSIP7tRsN1WnUKdr+Yck YkmdYlvDjxm71WobY9/bHvUfswIt4Aal7UgLjGJQZV7G5GsKfF8raj0PIYAhbwN5ERne eFCtaTOuHcdIDQgIYI/foeBTBwmqvCCRVfIg5VVkaecbGq8xj6DDIDV2Tk7TENMyzx6T dkmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=xDiqOIA4YdU+G0JVuchjGQ7bUj9Ta7o+h//3Fakq5bg=; b=w0TcWPdtlP2WlHrRrhG1Pr871c73EV28v1y4F47NyqALkPF9at0wXXmaABGFNRVK4V j/KvCvIF+QmFJTwjZuwk5ZEnL6vS2g5n7C7ah+qk0Ketb/Rm1UYZ1yKLh4cXc+5Blg7U mivQDwo37cuaOmWmXcRSX4iuFTdYXP7vCB8IxcwcgIBLq3bt4zAO993Xz45rpL127aqo MyGiWx+FI5lCqAb1VAozEBtsDo4UPZuSYjw9K6fipjKZJgIQ6b6nfz3MO6b0PumzPv+d d/LAKPRFxB6i778BoTuJoO5+qbbmzJFXLRILe60cpdSgsgEZugFtXQA/fI75jRLyhrJI oJcA== X-Gm-Message-State: AOAM531Qb+Se7hW+F3dXP1u2O7yhFg420ECtdwJYMy2xHk/CjuIKsl9o 8EGe/VhFQxpNURL3VqcLUBfwjA== X-Google-Smtp-Source: ABdhPJxJ5LHajWRDKYzXVwfP3gtqer6R/3PUahnI4F9YIAuz5JVIhZBcijib3G6pnQNmYRsuwtMG8A== X-Received: by 2002:a5d:64c9:0:b0:1e4:a048:8e1d with SMTP id f9-20020a5d64c9000000b001e4a0488e1dmr5351454wri.74.1645781593703; Fri, 25 Feb 2022 01:33:13 -0800 (PST) Received: from localhost.localdomain ([2001:871:5e:4d16:d43c:6e4c:a82c:38cd]) by smtp.gmail.com with ESMTPSA id bh7-20020a05600c3d0700b00380f6ec4d5asm4907980wmb.16.2022.02.25.01.33.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Feb 2022 01:33:13 -0800 (PST) Message-ID: <6ac5d86744518febe4bcf0bae5d1bc4cf09363f2.camel@cybertec.at> Subject: Re: \set \e and newline From: Laurenz Albe To: wim.bertels@ucll.be, pgsql-general@lists.postgresql.org Date: Fri, 25 Feb 2022 10:33:12 +0100 In-Reply-To: <75f2f22ccefef9ae79e550a660083b3fe6be038b.camel@ucll.be> References: <75f2f22ccefef9ae79e550a660083b3fe6be038b.camel@ucll.be> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.40.4 (3.40.4-2.fc34) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, 2022-02-24 at 18:16 +0100, Wim Bertels wrote: > it seems that \set does not interpret an 'enter' interactively the same > as an 'enter' in a short script made with \e > > * case 1: > postgres=# \set x 1 > postgres=# select :x; >  ?column? > ---------- >         1 Ok. > * case 2: > postgres=# \e > > -- enter the following the editor (the same code as above) > > \set x 1 > select :x; > > -- save and quit > > postgres=# > > -- no output This was interpreted as if you had entered it in a single line: \set x 1 select :x So "x" is now "1select1;". > -- curiosly: again \e > > postgres=#\e > > -- shows select 1; in the editor in v14 That was the last executed SQL statement. > -- shows nothing in the editor in v13 (or recursive the content being > cut off) I don't quite understand what you mean, but the behavior of \e changed (got more sane) in v14. > 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. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com