Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t8xHr-006ut6-CK for pgsql-admin@arkaria.postgresql.org; Thu, 07 Nov 2024 07:50:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1t8xHo-00DEnd-RR for pgsql-admin@arkaria.postgresql.org; Thu, 07 Nov 2024 07:50:37 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t8xHo-00DEnV-AZ for pgsql-admin@lists.postgresql.org; Thu, 07 Nov 2024 07:50:37 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1t8xHm-000bBZ-3D for pgsql-admin@lists.postgresql.org; Thu, 07 Nov 2024 07:50:35 +0000 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-20c714cd9c8so7329945ad.0 for ; Wed, 06 Nov 2024 23:50:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730965833; x=1731570633; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Df6bLU5jdN4dAI2V8wnqTlZUB7GYIRf9+mmwl6WgiIc=; b=AJPCD0zBkCaUfrboIvWg0GpxWjrBeE+yUh2aAFoSsZLIcLcKH0KOnFX8p4FGBSDgWe R4WU6MMH52H9BkUTKJbsH5K1TMCxZbMlHCTkEkoPMcz1d/730pE50+x633DvALlwmvMF /xd9bHJ21V2G0NOYT+bDNCLXF4Cy8tJyxeIqumWT9jxIdueDtnLBOawYc9+oA7QClnQZ YOAJgpNi6kdv7Mh+NpZTo+186/6RWxyFBMynbzPd6ypR6f+9lR9vXOjgF0a3QZHUyyxQ 6tt/iZtNlnv0/GM6uvGmncOWXeC4B6hc0IUEQPzsk7IJuchJ5fY3VyoX+IJNj8xRYrc+ cPPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730965833; x=1731570633; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Df6bLU5jdN4dAI2V8wnqTlZUB7GYIRf9+mmwl6WgiIc=; b=k/DKB3xJ/l8jyujIwkfPQlUJgkt2IsEozocv7esTmqAl11SxZ+2xZBzTSts4yv9yjo HUQvh3vwXRuEuwX9NTbBAjBUp1kJYJWUPBwFe9hhRMgVKugEmn4hesSzmwc7UfLYldE3 BtDFxceVNb4T0HcsxXhgKsLPDc7a26Lg6PZN66u6D86xMK79ExHdTBoXD/SM+lToWvB3 tRH284LB/HX9XCVX0ELSjqw6jx6VuhzA7crPWlo1F2tlJ51/WCq/mTxntg5sheBNUbcE INIeKATVHVz2firg0/7Fp/r5RuvOX0pAv1fznPT+t8ydyE4fh/38PXYEZfRFYI76LAhT 5ENg== X-Gm-Message-State: AOJu0YyiFXmcxEElVzJ8vNjDhLD7i+LRM4PIfts7SbPQ3gBQVmYVuOWd KbS2jMFgkI3HUxa9q/8LwMsjYPCClwC+8O2NS8cdvheoSEgcTd1vKeJsK4BJoFqOqKey/XZzRLI rcWF/xekVsf5Qzx9KUvkIuH1MwZs= X-Google-Smtp-Source: AGHT+IF5ODUZD+Hr9xIm/eZggQPSWylgOjDbESR3E4t1Uok+tFnA0mmaRW7OJ18i4AWmhFdxuq1jFGZR8O1akhiBfy0= X-Received: by 2002:a17:90b:4d0a:b0:2c9:b72:7a1f with SMTP id 98e67ed59e1d1-2e94c5175d5mr30911530a91.28.1730965832811; Wed, 06 Nov 2024 23:50:32 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Edwin UY Date: Thu, 7 Nov 2024 20:49:56 +1300 Message-ID: Subject: Re: \i and \watch To: "David G. Johnston" Cc: "pgsql-admin@lists.postgresql.org" Content-Type: multipart/alternative; boundary="000000000000954ad006264de324" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000954ad006264de324 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks for the explanation. Yeah, here's what's happening. So, yeah, we'll check on having to script it instead. ### =3D> select now() ; now ------------------------------- 2024-11-07 07:46:23.876888+00 (1 row) =3D> \! cat x.sql select version() ; =3D> \i x.sql version ---------------------------------------------------------------------------= ----------------------------------- PostgreSQL 14.12 on aarch64-unknown-linux-gnu, compiled by aarch64-unknown-linux-gnu-gcc (GCC) 9.5.0, 64-bit (1 row) =3D> \watch 5 Thu 07 Nov 2024 20:47:05 NZDT (every 5s) now ------------------------------- 2024-11-07 07:47:05.411747+00 (1 row) Thu 07 Nov 2024 20:47:10 NZDT (every 5s) now ------------------------------- 2024-11-07 07:47:10.418915+00 (1 row) ^C On Thu, Nov 7, 2024 at 6:26=E2=80=AFPM David G. Johnston wrote: > On Wednesday, November 6, 2024, Edwin UY wrote: > >> >> Is there no way to use \watch to let it run the last script that I just >> run? >> >> When do I do as below: >> >> select 1 ; >> \i x.sql >> \watch 20 >> >> It runs select 1 instead. >> >> > Watch is documented to act on either a non-empty query buffer or the last > sent command. I would expect that whatever the final SQL command present > in x.sql is would be the command that gets watched. If indeed the > preceding select 1 command is watched there would seem to be an > undocumented interaction going on. > > In any case, no, you cannot watch a meta-command. You=E2=80=99d have to = resort to > shell scripting the repeated execution of the psql program itself. > > David J. > > --000000000000954ad006264de324 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks for the explanation.
Yeah, here's what's happening. So, yeah, we'll check on having= to script it instead.

###
=3D> = select now() ;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 now
-= ------------------------------
=C2=A02024-11-07 07:46:23.876888+00
(1= row)

=3D> \! cat x.sql
select version() ;
=3D> \i x.sql=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0version
--------------------------= ---------------------------------------------------------------------------= ---------
=C2=A0PostgreSQL 14.12 on aarch64-unknown-linux-gnu, compiled = by aarch64-unknown-linux-gnu-gcc (GCC) 9.5.0, 64-bit
(1 row)

=3D&= gt; \watch 5
Thu 07 Nov 2024 20:47:05 NZDT (every 5s)

=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 now
-----------------------------= --
=C2=A02024-11-07 07:47:05.411747+00
(1 row)

Thu 07 Nov 2024= 20:47:10 NZDT (every 5s)

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 now
-------------------------------
=C2=A02024-11-07 07:47:10.= 418915+00
(1 row)

^C


On Thu, Nov 7, 2024 at 6= :26=E2=80=AFPM David G. Johnston <david.g.johnston@gmail.com> wrote:
On Wednesday, November 6, 2024, Edwin UY = <edwin.uy@gmail.= com> wrote:

Is there no way to use \watch to let it r= un the last script that I just run?

When do I do a= s below:

select 1 ;
\i x.sql
\= watch 20

It runs select 1 instead.

<= /div>

Watch is documented to act on e= ither a non-empty query buffer or the last sent command.=C2=A0 I would expe= ct that whatever the final SQL command present in x.sql is would be the com= mand that gets watched.=C2=A0 If indeed the preceding select 1 command is w= atched there would seem to be an undocumented interaction going on.

In any case, no, you cannot watch a meta-command.=C2=A0 Y= ou=E2=80=99d have to resort to shell scripting the repeated execution of th= e psql program itself.

David J.

--000000000000954ad006264de324--