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 1k199j-0000wX-PE for pgsql-general@arkaria.postgresql.org; Thu, 30 Jul 2020 14:03:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k199i-0008PV-JA for pgsql-general@arkaria.postgresql.org; Thu, 30 Jul 2020 14:03:34 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k199i-0008PO-8Q for pgsql-general@lists.postgresql.org; Thu, 30 Jul 2020 14:03:34 +0000 Received: from mail-qk1-x742.google.com ([2607:f8b0:4864:20::742]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1k199f-0003lj-5t for pgsql-general@lists.postgresql.org; Thu, 30 Jul 2020 14:03:33 +0000 Received: by mail-qk1-x742.google.com with SMTP id l6so25632445qkc.6 for ; Thu, 30 Jul 2020 07:03:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:references:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=ZmE8Gu4mWZA8dK5Wad1DVdpG8odU2M8RtCu/1M5D8qk=; b=OdEllp7Me6i6A2dBcaItBbN12PS+5si7CBDap7iMS2++EBJcqk7jqsIIZbF9VJfY9Q nRBxFuQ4yU6g4BrWV5uIyz/ZL8n5NdURAsUxCJc0qK/c9ySJNVnYkoxXRldn3gnDPHyF RjdWmcHFVNbgl5830GViY2jU7Siq9NWervgOg4vr1AnN42+A0mHmnjUJ8Cc0q/wYAF9n ZyZyKRtx5q32mAjFIfncsGrkAYDMB6YmUVaJD8YC2WGS+kc0b8vKrGwbydRvwnkZlSBU GGqmFFOkgYywOHFykSAAmzXo8dNfGlK+UbWc7w4K5PRZ8v5xCvlJ7VAili4qwgBbj9IP yjzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:references:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=ZmE8Gu4mWZA8dK5Wad1DVdpG8odU2M8RtCu/1M5D8qk=; b=TooZmFAn4usGiNLUY1s7Lik8YjEIe1+w6U/flCbJ0Br0d4kBru9f2OUs5Fxtwr2XDI Q0fTh+cagvbPFQVAcS/EJixEgvhBQ+7j9YbInWuERxAjlJi2TlHYL+pg5fdapYe4cMyP 99n5Vzz8vMkoArhF5mjqDb8tdgjD6albmZ/G0sDQHmlIWZ/AerlUjI8dh2F0G5dlJ75R BqohAr203ZBH4daDn9URrVAHqxUt8XODcdrX9l+W+gn16fuO0DjLY0TF0nruPl9stAAY i48DW0N2F8wE0c4+ExJ1NEcMyW8CmiATXXLQCi2m3JPCmSvfXDGYhQKjxcvWFI3+Di1t p5JQ== X-Gm-Message-State: AOAM530fhFm7FXU2wLJ1fr+lRwfsR1rMlD9a/STG6r/fUr6LhlK66mGm 9aFqG99WmNWkNE2czdDxcppqf0Yu X-Google-Smtp-Source: ABdhPJysjPR9eGPk4Rupw1LmvARDyXB54i4VwsYV51Jmb/81f6cqXedy/NgWMctg5ggd47o+x138LQ== X-Received: by 2002:ae9:c20a:: with SMTP id j10mr16978111qkg.254.1596117808963; Thu, 30 Jul 2020 07:03:28 -0700 (PDT) Received: from [192.168.0.150] ([190.177.70.162]) by smtp.gmail.com with ESMTPSA id i66sm4318827qke.124.2020.07.30.07.03.26 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 30 Jul 2020 07:03:27 -0700 (PDT) From: Diego X-Google-Original-From: Diego Subject: Re: Track pgsql steps To: pgsql-general@lists.postgresql.org References: <080c01d665bf$370bfde0$a523f9a0$@gmail.com> <42850458-0e48-cad2-4c89-34296a6f0383@aklaver.com> <08c601d66672$e53c0870$afb41950$@noetika.com> Message-ID: <0d1358d6-61fd-d79b-51ab-7b4177584ad3@gmail.com> Date: Thu, 30 Jul 2020 11:03:24 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <08c601d66672$e53c0870$afb41950$@noetika.com> Content-Type: multipart/alternative; boundary="------------D274F22D3B36633940B5F201" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------D274F22D3B36633940B5F201 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit are you running the psql with -c or -f? add -o to put all in a file and -e to write the last query, and with a tail to the log, you can see where is the problem On 2020-07-30 10:11, Olivier Leprêtre wrote: > Hi, thanks for your answers, > > Application_name is a good tip, 64 chars are enough to code steps, I'll use that > I expected being able to write raise events to a table or to store data in another table but it doesn't appear to be possible due to transaction isolation. > > Thanks a lot. > > Olivier > > -----Message d'origine----- > De : Julien Rouhaud > Envoyé : jeudi 30 juillet 2020 12:19 > À : Adrian Klaver > Cc : Olivier Leprêtre ; pgsql-general > Objet : Re: Track pgsql steps > > On Wed, Jul 29, 2020 at 7:58 PM Adrian Klaver wrote: >> On 7/29/20 8:44 AM, Olivier Leprêtre wrote: >>> Hi, >>> >>> I have a rather long pgsql procedure and I would like to detect >>> which step is currently executing (subscript 1,2,3…). Due to >>> transaction isolation, it’s not possible to make it write in a table >>> or get nexval from a sequence because values become available only >>> after the complete end of the procedure. >>> >>> Do you see any solution in this purpose ? >> RAISE NOTICE?: >> >> https://www.postgresql.org/docs/12/plpgsql-errors-and-messages.html#PL >> PGSQL-STATEMENTS-RAISE > You can also abuse SET application_name, as the value will be directly seen by other transactions. You're quite limited in the number of bytes to use, but if you just need to do some quick testing it can be helpful. > > --------------D274F22D3B36633940B5F201 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

are you running the psql with -c or -f?

add -o to put all in a file and -e to write the last query, and with a tail to the log, you can see where is the problem

On 2020-07-30 10:11, Olivier Leprêtre wrote:
Hi, thanks for your answers,

Application_name is a good tip, 64 chars are enough to code steps, I'll use that
I expected being able to write raise events to a table or to store data in another table but it doesn't appear to be possible due to transaction isolation.

Thanks a lot.

Olivier 

-----Message d'origine-----
De : Julien Rouhaud <rjuju123@gmail.com> 
Envoyé : jeudi 30 juillet 2020 12:19
À : Adrian Klaver <adrian.klaver@aklaver.com>
Cc : Olivier Leprêtre <o.lepretre@gmail.com>; pgsql-general <pgsql-general@postgresql.org>
Objet : Re: Track pgsql steps

On Wed, Jul 29, 2020 at 7:58 PM Adrian Klaver <adrian.klaver@aklaver.com> wrote:
On 7/29/20 8:44 AM, Olivier Leprêtre wrote:
Hi,

I have a rather long pgsql procedure and I would like to detect 
which step is currently executing (subscript 1,2,3…). Due to 
transaction isolation, it’s not possible to make it write in a table 
or get nexval from a sequence because values become available only 
after the complete end of the procedure.

Do you see any solution in this purpose ?
RAISE NOTICE?:

https://www.postgresql.org/docs/12/plpgsql-errors-and-messages.html#PL
PGSQL-STATEMENTS-RAISE
You can also abuse SET application_name, as the value will be directly seen by other transactions.  You're quite limited in the number of bytes to use, but if you just need to do some quick testing it can be helpful.


--------------D274F22D3B36633940B5F201--