Re: type SERIAL in C host-struct - Mailing list pgsql-general
From | Matthias Apitz |
---|---|
Subject | Re: type SERIAL in C host-struct |
Date | |
Msg-id | 20191109184531.GA7291@c720-r342378 Whole thread Raw |
In response to | Re: type SERIAL in C host-struct ("Peter J. Holzer" <hjp-pgsql@hjp.at>) |
Responses |
Re: type SERIAL in C host-struct
|
List | pgsql-general |
El día sábado, noviembre 09, 2019 a las 04:31:53p. m. +0100, Peter J. Holzer escribió: > On 2019-11-07 20:14:47 +0100, Matthias Apitz wrote: > > At the end of the day we came up with the following solution: > > > > strcpy(host_struct.name, "Sigrid"); > > EXEC SQL select nextval('lina_lid_seq') into :host_struct.ser; > > > > EXEC SQL INSERT INTO lina VALUES ( :host_struct ); > > > > which seems to work fine. Any comments about side effects? > > You are performing two queries instead of one, so you have to wait for > one extra round trip. Not a problem if client and server are on the same > network or you insert a few host_structs per second. May be a problem if > client and server are in different datacenters and you want to do > hundreds of inserts per second. Thanks for the feedback. Client and server run both on the same Linux host. I found also the debug log of ESQL/C i.e. how to enable it with ECPGdebug(int on, FILE *stream); The resulting log is really fine for debugging our code: [26301]: ECPGdebug: set to 1 [26301]: ECPGconnect: opening database newsisis on localhost port 5432 for user sisis [26301]: prepare_common on line 49: name s_statename; query: "SELECT myint, mychar, mydate, myvchar, myblob FROM mytypes;" [26301]: ecpg_execute on line 52: query: declare c_statename cursor for SELECT myint, mychar, mydate, myvchar, myblob FROMmytypes;; with 0 parameter(s) on connection newsisis [26301]: ecpg_execute on line 52: using PQexec [26301]: ecpg_process_output on line 52: OK: DECLARE CURSOR [26301]: ecpg_execute on line 60: query: fetch in c_statename; with 0 parameter(s) on connection newsisis [26301]: ecpg_execute on line 60: using PQexec [26301]: ecpg_process_output on line 60: correctly got 1 tuples with 5 fields [26301]: ecpg_get_data on line 60: RESULT: 1 offset: 4; array: no [26301]: ecpg_get_data on line 60: RESULT: char offset: 8; array: no [26301]: ecpg_get_data on line 60: RESULT: 08.05.1945 offset: 8; array: no [26301]: ecpg_get_data on line 60: RESULT: освобождение offset: 81; array: no ... What is missing are timestamps in enough precision. I will add this to the code in postgresql-11.4/src/interfaces/ecpg/ecpglib/misc.c where the implementation of ecpg_log() is. Thanks matthias -- Matthias Apitz, ✉ guru@unixarea.de, http://www.unixarea.de/ +49-176-38902045 Public GnuPG key: http://www.unixarea.de/key.pub "Glaube wenig, hinterfrage alles, denke selbst: Wie man Manipulationen durchschaut" "Believe little, scrutinise all, think by your own: How see through manipulations" ISBN-10: 386489218X
pgsql-general by date: