pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedTrack pgsql steps
6+ messages / 6 participants
[nested] [flat]
* Track pgsql steps
@ 2020-07-29 15:44 Olivier Leprêtre <o.lepretre@gmail.com>
0 siblings, 2 replies; 6+ messages in thread
From: Olivier Leprêtre @ 2020-07-29 15:44 UTC (permalink / raw)
To: pgsql-general
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 ?
Thanks,
Olivier
--
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
https://www.avast.com/antivirus
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Track pgsql steps
@ 2020-07-29 17:58 Adrian Klaver <adrian.klaver@aklaver.com>
parent: Olivier Leprêtre <o.lepretre@gmail.com>
1 sibling, 1 reply; 6+ messages in thread
From: Adrian Klaver @ 2020-07-29 17:58 UTC (permalink / raw)
To: Olivier Leprêtre <o.lepretre@gmail.com>; pgsql-general
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#PLPGSQL-STATEMENTS-RAISE
>
> Thanks,
>
> Olivier
>
>
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&...;
> Garanti sans virus. www.avast.com
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&...;
>
>
> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Track pgsql steps
@ 2020-07-30 10:18 Julien Rouhaud <rjuju123@gmail.com>
parent: Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 1 reply; 6+ messages in thread
From: Julien Rouhaud @ 2020-07-30 10:18 UTC (permalink / raw)
To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: Olivier Leprêtre <o.lepretre@gmail.com>; pgsql-general
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#PLPGSQL-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.
^ permalink raw reply [nested|flat] 6+ messages in thread
* RE: Track pgsql steps
@ 2020-07-30 13:11 Olivier Leprêtre <Olivier.Lepretre@noetika.com>
parent: Julien Rouhaud <rjuju123@gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: Olivier Leprêtre @ 2020-07-30 13:11 UTC (permalink / raw)
To: 'Julien Rouhaud' <rjuju123@gmail.com>; 'Adrian Klaver' <adrian.klaver@aklaver.com>; +Cc: 'Olivier Leprêtre' <o.lepretre@gmail.com>; pgsql-general
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.
--
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
https://www.avast.com/antivirus
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Track pgsql steps
@ 2020-07-30 14:03 Diego <mrstephenamell@gmail.com>
parent: Olivier Leprêtre <Olivier.Lepretre@noetika.com>
0 siblings, 0 replies; 6+ messages in thread
From: Diego @ 2020-07-30 14:03 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
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.
>
>
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Track pgsql steps
@ 2020-08-05 09:28 Pavel Stehule <pavel.stehule@gmail.com>
parent: Olivier Leprêtre <o.lepretre@gmail.com>
1 sibling, 0 replies; 6+ messages in thread
From: Pavel Stehule @ 2020-08-05 09:28 UTC (permalink / raw)
To: Olivier Leprêtre <o.lepretre@gmail.com>; +Cc: pgsql-general
Hi
st 29. 7. 2020 v 19:55 odesílatel Olivier Leprêtre <o.lepretre@gmail.com>
napsal:
> 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 ?
>
I wrote tracing support to plpgsql_check
https://github.com/okbob/plpgsql_check#tracer
postgres=# set plpgsql_check.tracer_verbosity TO verbose;
SET
postgres=# do $$ begin perform fx(10,null, 'now', e'stěhule'); end; $$;
NOTICE: #0 ->> start of block inline_code_block (oid=0)
NOTICE: #0.1 1 --> start of PERFORM (expr='fx(10,null, 'now',
e'stěhule' ..')
NOTICE: #2 ->> start of function
fx(integer,integer,date,text) (oid=16405)
NOTICE: #2 call by inline_code_block line 1 at PERFORM
NOTICE: #2 "a" => '10', "b" => null, "c" => '2020-08-05',
"d" => 'stěhule'
NOTICE: #2.1 1 --> start of PERFORM (expr='fx(a)')
NOTICE: #2.1 "a" => '10'
NOTICE: #4 ->> start of function fx(integer) (oid=16404)
NOTICE: #4 call by fx(integer,integer,date,text) line
1 at PERFORM
NOTICE: #4 "a" => '10'
NOTICE: #4.3 6 --> start of IF (cond='a > 10')
NOTICE: #4.3 "a" => '10'
NOTICE: #4.3 8 ELSEIF (expr='a < 0')
NOTICE: #4.3 "a" => '10'
NOTICE: #4.3 <-- end of IF (elapsed time=0.056 ms)
NOTICE: #4.4 12 --> start of assignment (expr='100 + a + b')
NOTICE: #4.4 "a" => '10', "b" => '20'
NOTICE: #4.4 <-- end of assignment (elapsed time=0.024 ms)
NOTICE: #4.4 "res" => '130'
NOTICE: #4.5 13 --> start of RETURN
NOTICE: #4.5 "res" => '130'
NOTICE: #4.5 <-- end of RETURN (elapsed time=0.045 ms)
NOTICE: #4 <<- end of function fx (elapsed time=0.248 ms)
NOTICE: #2.1 <-- end of PERFORM (elapsed time=0.354 ms)
NOTICE: #2 <<- end of function fx (elapsed time=0.441 ms)
NOTICE: #0.1 <-- end of PERFORM (elapsed time=0.710 ms)
NOTICE: #0 <<- end of block (elapsed time=0.777 ms)
Regards
Pavel
>
>
> Thanks,
>
>
>
> Olivier
>
>
>
>
>
>
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&...; Garanti
> sans virus. www.avast.com
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&...;
> <#m_-9154849454718330009_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2020-08-05 09:28 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-07-29 15:44 Track pgsql steps Olivier Leprêtre <o.lepretre@gmail.com>
2020-07-29 17:58 ` Adrian Klaver <adrian.klaver@aklaver.com>
2020-07-30 10:18 ` Julien Rouhaud <rjuju123@gmail.com>
2020-07-30 13:11 ` Olivier Leprêtre <Olivier.Lepretre@noetika.com>
2020-07-30 14:03 ` Diego <mrstephenamell@gmail.com>
2020-08-05 09:28 ` Pavel Stehule <pavel.stehule@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox