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 1sWrGI-0006DO-5g for pgsql-general@arkaria.postgresql.org; Thu, 25 Jul 2024 05:43:34 +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 1sWrFI-00BgwS-3i for pgsql-general@arkaria.postgresql.org; Thu, 25 Jul 2024 05:42:32 +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 1sWrFH-00BgwK-PD for pgsql-general@lists.postgresql.org; Thu, 25 Jul 2024 05:42:31 +0000 Received: from mail-lj1-x22c.google.com ([2a00:1450:4864:20::22c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sWrFE-001JzH-J0 for pgsql-general@lists.postgresql.org; Thu, 25 Jul 2024 05:42:30 +0000 Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2eeb1ba040aso8054011fa.1 for ; Wed, 24 Jul 2024 22:42:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721886147; x=1722490947; 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=14c0EGxXMJlTTI/Y58uufUt+UTcVnA99wEjHZXKGiGo=; b=TMWDNeD/2cxkwEcxX/ouYkKVWAs9czrBRNhOh0jlKs6L0buB/nSRPS8p3PV3P+NuES K2LRWzM4qsFvvzqquqvGrjqh6ipfnN2M3phXm+t0HE0fUzw2PiiYWdy3Dyr5ddNL9MAq WQjjaedCfr03sFZtDypqYaW6lvnQEb9Gv9mlcFBL8SNGJFjJHA2mUNyyNlL1222W66uL gafoGczheFjMZPMLkbpX/KzsUYvGe6NjUZMfP7yVRo1Fr7w9rPZEyVzXRGi2fKZZZn7C CKD0PJjKl3U8nTQ1SJr5nZB0aMr7fdy/IdoHXxcajX1hkaVQ8sGSSF/nuyqgcU+hEkeT 7OSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721886147; x=1722490947; 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=14c0EGxXMJlTTI/Y58uufUt+UTcVnA99wEjHZXKGiGo=; b=LnpNk5rLkBXuEYJ+eoz3iQuyYLF1YqKvHBfofX+2a1LqiyLIq6GgKxeji+GS7UM7Ds s1wPbLsiGlcnTLlrvylw9leqYOmBfLOcVPU9hJWhT8VlFCpkVwMse6gJaBAZMlP7sPw/ /p/d+2wCu7NDyg68KFCm2TOJsdcl+pU6U0kD/vyzQjD+2S6B3ciUupRNKgd9spHGEXuD sBxSapGzFtqNu6k5UucA6Sm3On68XjH+pHm5rHLXND/BAQhAH6zlaQOsMAvdPRZWH0zC pUI4DTh4UoB4JcSnLni0aKFJ0Tp++DDOFTGybtwt4/s0SDxJBKJyaKrKyHpErdT6AnVl O2Og== X-Forwarded-Encrypted: i=1; AJvYcCV1akoWCkZ240K55USPtWHhT2tgJKbWACKAWB2uUAG9sB28yz5CExr9le15T1BTUImVBbDRJ1tNkLlfIPS/bfxW8xJxDw6eIgLDi1K186pjy5RV X-Gm-Message-State: AOJu0YyaImQNjHlgswjLhXHf/M2DDE9nuXwDU28+qGJb+a+eMhrr1mdQ US6AMYaKdLVsWN8YFGIp0EfJBs8CL8WVsQ7nKYzVSEDI/hwuzWDlanZ27I4Gmfe40JeKiBgdTiP oHA+nQ6CwptNbWy1X/QEuKANe1LI= X-Google-Smtp-Source: AGHT+IH6GRNVXib1N7jfcb40h9P2WoJ9UDmp8qCcZp/Fkz2+8bkq/tsRdNeRwded3us6JrQUmX9Ziv9LCMv1Rgz+f80= X-Received: by 2002:a05:6512:b8f:b0:52c:de29:9ff with SMTP id 2adb3069b0e04-52fd3eef35bmr1239691e87.2.1721886146431; Wed, 24 Jul 2024 22:42:26 -0700 (PDT) MIME-Version: 1.0 References: <1085896.1721766747@sss.pgh.pa.us> In-Reply-To: <1085896.1721766747@sss.pgh.pa.us> From: veem v Date: Thu, 25 Jul 2024 11:12:15 +0530 Message-ID: Subject: Re: Issue while creating index dynamically To: Tom Lane Cc: Ron Johnson , pgsql-general Content-Type: multipart/alternative; boundary="0000000000001a11a7061e0bdc69" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000001a11a7061e0bdc69 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 24 Jul 2024 at 02:02, Tom Lane wrote: > Ron Johnson writes: > > On Tue, Jul 23, 2024 at 4:10=E2=80=AFPM veem v wr= ote: > >> But we are getting an error while executing saying it cant be executed > in > >> transaction block with "CONCURRENTLY". So I want to understand , is > there > >> any alternate way to get away with this? > > > I'd write that in bash, not in a DO block. > > Yeah. I thought for a bit about using contrib/dblink to carry out > the commands in a different session, but I don't think that'll work: > CREATE INDEX CONCURRENTLY would think it has to wait out the > transaction running the DO block at some steps. Shove the logic > over to the client side and you're good to go. > > regards, tom lane > > > Thank you . I was thinking the individual statement will work fine if I pull out those from the begin..end block, as those will then be not bounded by any outer transaction. However, When I was trying it from dbeaver by extracting individual index creation statements rather from within the "begin ..end;" block, it still failed with a different error as below. Why is it so? "SQL Error [25001]: Error: create index concurrently cannot be executed within a pipeline " --0000000000001a11a7061e0bdc69 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Wed, 24 Jul 2024 at 02:02, Tom Lane &l= t;tgl@sss.pgh.pa.us> wrote:
=
Ron Johnson <ronljohnsonjr@gmail.com> writes:
> On Tue, Jul 23, 2024 at 4:10=E2=80=AFPM veem v <veema0000@gmail.com> wrote: >> But we are getting an error while executing saying it cant be exec= uted in
>> transaction block with "CONCURRENTLY". So I want to unde= rstand , is there
>> any alternate way to get away with this?

> I'd write that in bash, not in a DO block.

Yeah.=C2=A0 I thought for a bit about using contrib/dblink to carry out
the commands in a different session, but I don't think that'll work= :
CREATE INDEX CONCURRENTLY would think it has to wait out the
transaction running the DO block at some steps.=C2=A0 Shove the logic
over to the client side and you're good to go.

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 regards, tom lane



Thank you .
I was thinking t= he=C2=A0individual statement will work fine if I pull out those from the be= gin..end block, as those will then be not bounded by any outer transaction.=
=C2=A0However, When I was trying it from dbeaver by extracting= =C2=A0individual index creation statements rather from within the "beg= in ..end;" block, it still failed with a different=C2=A0error as below= . Why is it so?

=C2=A0"SQL Error=C2=A0[25001]= : Error: create index concurrently cannot be executed within a pipeline &qu= ot;=C2=A0
--0000000000001a11a7061e0bdc69--