public inbox for [email protected]  
help / color / mirror / Atom feed
Re: ERROR: stack depth limit exceeded
5+ messages / 3 participants
[nested] [flat]

* Re: ERROR: stack depth limit exceeded
@ 2025-02-19 11:22  Laurenz Albe <[email protected]>
  0 siblings, 1 reply; 5+ messages in thread

From: Laurenz Albe @ 2025-02-19 11:22 UTC (permalink / raw)
  To: [email protected]; general pgsql <[email protected]>

On Wed, 2025-02-19 at 11:23 +0100, Csányi Pál wrote:
> I am running postgresql 15 on Debian 12 operating system.
> I also installed PgAdmin4 and am using the desktop version of it.
> I have created a trigger function and a trigger which will run the
> following code, see below.
> Before this trigger would run, I tried this code.
> When running the code I get the following error message:
> ERROR: stack depth limit exceeded HINT: Increase the configuration
> parameter "max_stack_depth" (currently 2048kB), after ensuring the
> platform's stack depth limit is adequate.
> 
> Where am I making a mistake, and what can I do to make this code and
> this trigger run successfully?

You don't show the entire functoin and the trigger definition,
but from the symptoms it is pretty clear that the trigger is
modifying the table on which it is defined.  That will call the
trigger again and lead to an endless recursion, which leads to
the observed error.

Yours,
Laurenz Albe

-- 

*E-Mail Disclaimer*
Der Inhalt dieser E-Mail ist ausschliesslich fuer den 
bezeichneten Adressaten bestimmt. Wenn Sie nicht der vorgesehene Adressat 
dieser E-Mail oder dessen Vertreter sein sollten, so beachten Sie bitte, 
dass jede Form der Kenntnisnahme, Veroeffentlichung, Vervielfaeltigung oder 
Weitergabe des Inhalts dieser E-Mail unzulaessig ist. Wir bitten Sie, sich 
in diesem Fall mit dem Absender der E-Mail in Verbindung zu setzen.

*CONFIDENTIALITY NOTICE & DISCLAIMER
*This message and any attachment are 
confidential and may be privileged or otherwise protected from disclosure 
and solely for the use of the person(s) or entity to whom it is intended. 
If you have received this message in error and are not the intended 
recipient, please notify the sender immediately and delete this message and 
any attachment from your system. If you are not the intended recipient, be 
advised that any use of this message is prohibited and may be unlawful, and 
you must not copy this message or attachment or disclose the contents to 
any other person.






^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: ERROR: stack depth limit exceeded
@ 2025-02-19 15:49  Csányi Pál <[email protected]>
  parent: Laurenz Albe <[email protected]>
  0 siblings, 2 replies; 5+ messages in thread

From: Csányi Pál @ 2025-02-19 15:49 UTC (permalink / raw)
  To: Laurenz Albe <[email protected]>; +Cc: general pgsql <[email protected]>

Laurenz Albe <[email protected]> ezt írta (időpont: 2025. febr.
19., Sze, 12:22):
>
> On Wed, 2025-02-19 at 11:23 +0100, Csányi Pál wrote:
> > I am running postgresql 15 on Debian 12 operating system.
> > I also installed PgAdmin4 and am using the desktop version of it.
> > I have created a trigger function and a trigger which will run the
> > following code, see below.
> > Before this trigger would run, I tried this code.
> > When running the code I get the following error message:
> > ERROR: stack depth limit exceeded HINT: Increase the configuration
> > parameter "max_stack_depth" (currently 2048kB), after ensuring the
> > platform's stack depth limit is adequate.
> >
> > Where am I making a mistake, and what can I do to make this code and
> > this trigger run successfully?
>
> You don't show the entire function and the trigger definition,

Hi Laurenz,

the trigger function definition is like:
BEGIN
INSERT INTO
    HAVONKENTI_MEGTAKARITASAINK (EZEN_IDOKOZBEN, MEGTAKARITVA_RSD, KELT)
VALUES ((tsrange((
        SELECT
            KELT
        FROM
            PUBLIC.JAVAINK_FORGALMA
        WHERE
            EN_KAPTAM = 'true'
            AND AZ_ARU_NEVE = 'nyugdíjam'
        ORDER BY
            KELT DESC
        LIMIT
            1
        OFFSET
            1
    ),(
        SELECT
            KELT
        FROM
            PUBLIC.JAVAINK_FORGALMA
        WHERE
            EN_KAPTAM = 'true'
            AND AZ_ARU_NEVE = 'nyugdíjam'
        ORDER BY
            KELT DESC
        LIMIT
            1
        OFFSET
            0
    ),'[)')),(SELECT
    SUM(EGYSEGAR * ENNYI_EGYSEG)
FROM
    PUBLIC.JAVAINK_FORGALMA
WHERE
    A_PENZNEM = 'RSD'
    AND KELT >= (
        SELECT
            KELT
        FROM
            PUBLIC.JAVAINK_FORGALMA
        WHERE
            EN_KAPTAM = 'true'
            AND AZ_ARU_NEVE = 'nyugdíjam'
        ORDER BY
            KELT DESC
        LIMIT
            1
        OFFSET
            1
    )
    AND KELT < (
        SELECT
            KELT
        FROM
            PUBLIC.JAVAINK_FORGALMA
        WHERE
            EN_KAPTAM = 'true'
            AND AZ_ARU_NEVE = 'nyugdíjam'
        ORDER BY
            KELT DESC
        LIMIT
            1
        OFFSET
            0
    )), DEFAULT)
;
END;

and the trigger definition is like:
CREATE OR REPLACE TRIGGER uj_nyugdij_beirasakor_kiold
    AFTER INSERT
    ON public.javaink_forgalma
    FOR EACH ROW
    EXECUTE FUNCTION public.ket_nyugdij_kozotti_megtakaritasaink();

COMMENT ON TRIGGER uj_nyugdij_beirasakor_kiold ON public.javaink_forgalma
    IS 'Új nyugdíj beírásakor kioldja a két nyugdíj közötti
megtakarításaink nevű szerepet.';

> but from the symptoms it is pretty clear that the trigger is
> modifying the table on which it is defined.  That will call the
> trigger again and lead to an endless recursion, which leads to
> the observed error.
>
> Yours,
> Laurenz Albe

Indeed I did, the trigger should have been assigned on
javaink_forgalma table, not on havonkenti_megtakaritasaink table.
Actually, this trigger has been assigned on both tables so far, and I
just deleted it from the havonkenti_megtakaritasaink table by using
PgAdmin4.

Now that I only have this trigger assigned on the javaink_forgalma
table, an INSERT command into this table will activate the trigger
function, which will then insert a new row in the
havonkenti_megtakaritasaink table.

However, by copying the code between BEGIN and END from the trigger
function, and inserting it into the Query tool and then running this
code there, it should insert a line in the havonkenti_megtakaritasaink
table.

But here I got the error message mentioned above. Hey! But now this
code snippet ran without any errors! So what happened here?

Thanks for all the advice!

-- 
Best wishes by Paul Chanyi!






^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: ERROR: stack depth limit exceeded
@ 2025-02-19 16:09  Sándor Daku <[email protected]>
  parent: Csányi Pál <[email protected]>
  1 sibling, 1 reply; 5+ messages in thread

From: Sándor Daku @ 2025-02-19 16:09 UTC (permalink / raw)
  To: [email protected]; +Cc: general pgsql <[email protected]>

On Wed, 19 Feb 2025 at 16:49, Csányi Pál <[email protected]> wrote:

> Indeed I did, the trigger should have been assigned on
> javaink_forgalma table, not on havonkenti_megtakaritasaink table.
> Actually, this trigger has been assigned on both tables so far, and I
> just deleted it from the havonkenti_megtakaritasaink table by using
> PgAdmin4.
>
> Now that I only have this trigger assigned on the javaink_forgalma
> table, an INSERT command into this table will activate the trigger
> function, which will then insert a new row in the
> havonkenti_megtakaritasaink table.
>
> However, by copying the code between BEGIN and END from the trigger
> function, and inserting it into the Query tool and then running this
> code there, it should insert a line in the havonkenti_megtakaritasaink
> table.
>
> But here I got the error message mentioned above. Hey! But now this
> code snippet ran without any errors! So what happened here?
>
> Thanks for all the advice!
>
> --
> Best wishes by Paul Chanyi!
>
>
Hi Pál,

I'm not sure that I follow the timeline correctly, but if the code snippet
works now after deleting the trigger on havonkenti_megtakaritasaink then
nothing to see here.
Before that the trigger activating on insert into
havonkenti_megtakaritasaink inserted a record into
havonkenti_megtakaritasaink which activated the trigger again and this
continued until it ran into the max_stack_depth wall.

Regards,
Sándor


^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: ERROR: stack depth limit exceeded
@ 2025-02-19 16:13  Csányi Pál <[email protected]>
  parent: Sándor Daku <[email protected]>
  0 siblings, 0 replies; 5+ messages in thread

From: Csányi Pál @ 2025-02-19 16:13 UTC (permalink / raw)
  To: Sándor Daku <[email protected]>; +Cc: general pgsql <[email protected]>

Sándor Daku <[email protected]> ezt írta (időpont: 2025. febr.
19., Sze, 17:09):
>
>
>
> On Wed, 19 Feb 2025 at 16:49, Csányi Pál <[email protected]> wrote:
>>
>> Indeed I did, the trigger should have been assigned on
>> javaink_forgalma table, not on havonkenti_megtakaritasaink table.
>> Actually, this trigger has been assigned on both tables so far, and I
>> just deleted it from the havonkenti_megtakaritasaink table by using
>> PgAdmin4.
>>
>> Now that I only have this trigger assigned on the javaink_forgalma
>> table, an INSERT command into this table will activate the trigger
>> function, which will then insert a new row in the
>> havonkenti_megtakaritasaink table.
>>
>> However, by copying the code between BEGIN and END from the trigger
>> function, and inserting it into the Query tool and then running this
>> code there, it should insert a line in the havonkenti_megtakaritasaink
>> table.
>>
>> But here I got the error message mentioned above. Hey! But now this
>> code snippet ran without any errors! So what happened here?
>>
>> Thanks for all the advice!
>>
>> --
>> Best wishes by Paul Chanyi!
>>
>
> Hi Pál,
>
> I'm not sure that I follow the timeline correctly, but if the code snippet works now after deleting the trigger on havonkenti_megtakaritasaink then nothing to see here.
> Before that the trigger activating on insert into havonkenti_megtakaritasaink inserted a record into havonkenti_megtakaritasaink which activated the trigger again and this continued until it ran into the max_stack_depth wall.
>
> Regards,
> Sándor

Hi Sándor,

Thank you very much to you and everyone else who helped me solve this problem!

-- 
Best wishes by Paul Chanyi!






^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: ERROR: stack depth limit exceeded
@ 2025-02-20 09:33  Laurenz Albe <[email protected]>
  parent: Csányi Pál <[email protected]>
  1 sibling, 0 replies; 5+ messages in thread

From: Laurenz Albe @ 2025-02-20 09:33 UTC (permalink / raw)
  To: [email protected]; +Cc: general pgsql <[email protected]>

On Wed, 2025-02-19 at 16:49 +0100, Csányi Pál wrote:
> the trigger function definition is like:
> [...]
> INSERT INTO
>     HAVONKENTI_MEGTAKARITASAINK (EZEN_IDOKOZBEN, MEGTAKARITVA_RSD, KELT)
> [...]
> 
> and the trigger definition is like:
> CREATE OR REPLACE TRIGGER uj_nyugdij_beirasakor_kiold
>     AFTER INSERT
>     ON public.javaink_forgalma
>     FOR EACH ROW
>     EXECUTE FUNCTION public.ket_nyugdij_kozotti_megtakaritasaink();

That does not look circular right away, but perhaps there is
a trigger on HAVONKENTI_MEGTAKARITASAINK, or perhaps there is
some other trigger on javaink_forgalma.

It must be something of that kind.

Yours,
Laurenz Albe

-- 

*E-Mail Disclaimer*
Der Inhalt dieser E-Mail ist ausschliesslich fuer den 
bezeichneten Adressaten bestimmt. Wenn Sie nicht der vorgesehene Adressat 
dieser E-Mail oder dessen Vertreter sein sollten, so beachten Sie bitte, 
dass jede Form der Kenntnisnahme, Veroeffentlichung, Vervielfaeltigung oder 
Weitergabe des Inhalts dieser E-Mail unzulaessig ist. Wir bitten Sie, sich 
in diesem Fall mit dem Absender der E-Mail in Verbindung zu setzen.

*CONFIDENTIALITY NOTICE & DISCLAIMER
*This message and any attachment are 
confidential and may be privileged or otherwise protected from disclosure 
and solely for the use of the person(s) or entity to whom it is intended. 
If you have received this message in error and are not the intended 
recipient, please notify the sender immediately and delete this message and 
any attachment from your system. If you are not the intended recipient, be 
advised that any use of this message is prohibited and may be unlawful, and 
you must not copy this message or attachment or disclose the contents to 
any other person.






^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2025-02-20 09:33 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-02-19 11:22 Re: ERROR: stack depth limit exceeded Laurenz Albe <[email protected]>
2025-02-19 15:49 ` Csányi Pál <[email protected]>
2025-02-19 16:09   ` Sándor Daku <[email protected]>
2025-02-19 16:13     ` Csányi Pál <[email protected]>
2025-02-20 09:33   ` Laurenz Albe <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox