Re: ESQL/C: a ROLLBACK rolls back a COMMITED transaction

From: Matthias Apitz <guru(at)unixarea(dot)de>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: ESQL/C: a ROLLBACK rolls back a COMMITED transaction
Date: 2020-05-13 05:27:31
Message-ID: 20200513052731.GA26063@sh4-5.1blu.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

El día Dienstag, Mai 12, 2020 a las 08:01:15 -0400, Tom Lane escribió:

> Matthias Apitz <guru(at)unixarea(dot)de> writes:
> > And in the log the line logged is:
> > [1471] [12.05.2020 15:48:50:476]: ecpg_process_output on line 1744: OK: INSERT 0 1
> > What I wanted to have is:
> > [1471] [12.05.2020 15:48:50:476]: ecpg_process_output on line 1744 of swd_daten.pgc: OK: INSERT 0 1
> > i.e. have added the file name to the line number as "on line 1744 of
> > swd_daten.pgc" to not always have to think, hey in which table we're
> > with this at the moment.
>
> Not an unreasonable suggestion, but it'd be more likely to happen if
> you send in a patch ;-).

I was already thinking somemonths ago in a change (and patch proposal).
The problem is, that the generated C-code for an ESQL/C statement looks
today like this:

{ ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into swd_daten ( katkey , aktion , reserv , id , ansetzung , nettodaten ) values ( $1 , $2 , $3 , $4 , $5 , $6 )",
ECPGt_long,&(new_value),(long)1,(long)1,sizeof(long),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_short,&(hrec_swd_daten.aktion),(long)1,(long)1,sizeof(short),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_char,(hrec_swd_daten.reserv),(long)2,(long)1,(2)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
...
ECPGt_char,(hrec_swd_daten.nettodaten),(long)SWD_DATEN_BUF_MAX,(long)1,(SWD_DATEN_BUF_MAX)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 1745 "swd_daten.pgc"

if (sqlca.sqlcode == ECPG_NOT_FOUND) posSqlNotFound ( );
#line 1745 "swd_daten.pgc"

if (sqlca.sqlwarn[0] == 'W') posSqlWarning ( );
#line 1745 "swd_daten.pgc"

if (sqlca.sqlcode < 0) posSqlError ( );}

and should be expanded to:

{ ECPGdo(__LINE__, __FILE__, 0, 0, NULL, 0, ECPGst_normal, "insert ...

as the first argument to ECPGdo() is of type int we can not do a hack
like "__LINE__:"__FILE__ (i.e. concatenating line number and filename
into one string. We have to change the call interface function ECPGdo()
and add a string argument. This would make fail all older compiled
applications when the new shared lib having this call is installed.

Here I'm stuck with the idea.

matthias

--
Matthias Apitz, ✉ guru(at)unixarea(dot)de, http://www.unixarea.de/ +49-176-38902045
Public GnuPG key: http://www.unixarea.de/key.pub

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Matthias Apitz 2020-05-13 05:34:05 Re: ESQL/C: a ROLLBACK rolls back a COMMITED transaction
Previous Message Mariya Rampurawala 2020-05-13 04:58:15 Re: [EXTERNAL] Re: PostgreSQL-12 replication failover, pg_rewind fails