Re: [pgsql-fr-generale] Re: [pgsql-fr-generale] problem fermeture de connection <signal 11> par un déclencheur

From: "thomas(dot)silvi" <thomas(dot)silvi(at)laposte(dot)net>
To: andy petrella <andy(dot)petrella(at)gmail(dot)com>
Cc: pgsql-fr-generale(at)postgresql(dot)org
Subject: Re: [pgsql-fr-generale] Re: [pgsql-fr-generale] problem fermeture de connection <signal 11> par un déclencheur
Date: 2005-10-05 21:36:40
Message-ID: 43444768.4020102@laposte.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-fr-generale


Hello,
pour l'erreur

ERROR: SET TRANSACTION ISOLATION LEVEL must be called before any query/
/
le message dit que le SET TRANSACTION ISOLATION LEVEL doit etre appele
avant toute requete
donc il est a mon avis impossible de changer le niveau d'isolation dans
une procedure SPI car la requete
qui appele/declenche la procedure est en cours.

Thomas

thomas.silvi a écrit :

>andy petrella a écrit :
>
>
>
>>Oui désolé j'y ai pensé trop tard... :-D
>>
>>je crois que ca venait d'un
>>SPI_exec("BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE, READ WRITE",0)
>>
>>
>>que j'ai changé en
>>
>>
>>ret = SPI_exec("SET TRANSACTION ISOLATION LEVEL SERIALIZABLE", 0);
>>if (ret < 0){
>> SPI_exec("ROLL BACK", 0);
>> elog(ERROR, "cote_expand: SPI_exec (SET TRANSACTION SERIALIZABLE...)
>>returned %d", ret);
>>}
>>
>>ret = SPI_exec("begin transaction", 0);
>>if (ret < 0){
>> SPI_exec("ROLL BACK", 0);
>> elog(ERROR, "cote_expand: SPI_exec (BEGIN ...) returned %d", ret);
>>}
>>
>>
>>
>>
>>
>1. Extrait de la page
>http://traduc.postgresqlfr.org/pgsql-8.0.2-fr/sql-set-transaction.html
>
>/ Si SET TRANSACTION est exécuté sans un START TRANSACTION ou un BEGIN
>le précédant,
>il est sans effet car la transaction se termine immédiatement.
>
>/donc il faut d'abord faire le begin transaction puis le SET TRANSACTION ...
>
>/
>/2. c'est ROLLBACK et non "ROLL BACK"
>
>
>3. Peux tu tester le code dans un psql pour determiner si c'est un
>probleme du au SQL pur ou
> si c'est un probleme dans le code C.
>
>
>Thomas
>
>
>
>>Et avant ca, j'ai ceci
>>
>>/**** on s'assure de la validité de l'appel et initialisation des tuples ****/
>>if (!CALLED_AS_TRIGGER(fcinfo))
>> elog(ERROR, "cote_expand: not called by trigger manager");
>>
>>if (TRIGGER_FIRED_FOR_STATEMENT(trigdata->tg_event))
>> elog(ERROR, "cote_expand: can't process STATEMENT events");
>> if (TRIGGER_FIRED_AFTER(trigdata->tg_event))
>> elog(ERROR, "cote_expand: must be fired before event");
>> if (TRIGGER_FIRED_BY_INSERT(trigdata->tg_event)){
>> insert = true;
>> rettuple = trigdata->tg_trigtuple;
>>}
>>else if (TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event)){
>> insert = false;
>> rettuple = trigdata->tg_newtuple;
>> oldtuple = trigdata->tg_trigtuple;
>>}
>>tupledesc = trigdata->tg_relation->rd_att;
>>
>>
>>/**** aller chercher dans les tuples les infos nécessaires ****/
>>/* prendre l'id du film */
>>film = DatumGetInt32(SPI_getbinval(rettuple, tupledesc, 4,
>>&isNull));//id du film
>>if (isNull)
>> elog(ERROR, "cote_expand: no film id references");
>>interets_cote = DatumGetInt16(SPI_getbinval(rettuple, tupledesc, 1,
>>&isNull)); //cote
>>if (isNull)
>> return PointerGetDatum(rettuple);
>>interets_visites = DatumGetInt32(SPI_getbinval(rettuple, tupledesc, 2,
>>&isNull)); /visites
>>if (isNull)
>> elog(ERROR, "cote_expand: value NULL for visites and NOT NULL for
>>cote an't happen");
>>
>>if (!insert){
>> /* aller chercher ancienne cote et visites dans oldtuple
>>*/ interets_cote_old = DatumGetInt16(SPI_getbinval(oldtuple,
>>tupledesc, 1, &isNull)); //cote
>> if (isNull)
>> return PointerGetDatum(rettuple);
>>}
>>
>>Ce qui n'est que de la récupération d'erreur et de données.
>>
>>Mais j'ai une erreur comme celle-ci
>>
>>ERROR: SET TRANSACTION ISOLATION LEVEL must be called before any query
>>CONTEXT: SQL statement "SET TRANSACTION ISOLATION LEVEL SERIALIZABLE"
>>
>>Je suis sous posgresql 8.0.3
>>
>>andy
>>
>>Le 02/10/05, thomas.silvi<thomas(dot)silvi(at)laposte(dot)net> a écrit :
>>
>>
>>
>>
>>>andy petrella a écrit :
>>>
>>>
>>>
>>>
>>>
>>>>Bonjour a tous,
>>>>
>>>>j'ai un trigger qui me coupe a chaque fois la connection, en renvoyant
>>>>un signal 11. Et je vois po pk !
>>>>
>>>>Voila le log....
>>>>
>>>>NOTICE: cote_expand: SPI_exec (begin ...) returned -8
>>>>LOG: server process (PID 14388) was terminated by signal 11
>>>>LOG: terminating any other active server processes
>>>>LOG: all server processes terminated; reinitializing
>>>>LOG: database system was interrupted at 2005-10-02 17:35:03 CEST
>>>>LOG: checkpoint record is at 0/FC0E88
>>>>LOG: redo record is at 0/FC0E88; undo record is at 0/0; shutdown TRUE
>>>>LOG: next transaction ID: 871; next OID: 26380
>>>>LOG: database system was not properly shut down; automatic recovery in progress
>>>>
>>>>
>>>>On voie qu'il me renvoie un beau -8 ??? d'un spi_exec.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>> Bonjour,
>>>Pouvez vous nous fournir
>>> - le code du trigger,
>>> - le code de la table qui est lie a ce trigger
>>> -l'action qui declenche cette erreur par exemple un INSERT avec les
>>>donnees ?
>>> - la version de PostgreSQL que vous utilisez ?
>>>
>>>
>>> Thomas
>>>
>>>
>>>
>>>
>>>
>>>>Merci de votre aide.
>>>>
>>>>---------------------------(end of broadcast)---------------------------
>>>>TIP 4: Have you searched our list archives?
>>>>
>>>> http://archives.postgresql.org
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>>
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
>
>
>

In response to

Browse pgsql-fr-generale by date

  From Date Subject
Next Message Didier BRETIN 2005-10-06 13:54:22 Comment retrouver le source d'une fonction utilisé par un trigger ?
Previous Message Jean-Max Reymond 2005-10-05 15:54:38 Sun regarde Postgres !!