Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iTVkJ-0007jx-Kl for pgsql-general@arkaria.postgresql.org; Sat, 09 Nov 2019 18:46:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iTVkI-0002oh-3w for pgsql-general@arkaria.postgresql.org; Sat, 09 Nov 2019 18:46:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iTVkH-0002oa-Q0 for pgsql-general@lists.postgresql.org; Sat, 09 Nov 2019 18:46:01 +0000 Received: from ms-10.1blu.de ([178.254.4.101]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iTVjr-0003wN-Vm for pgsql-general@lists.postgresql.org; Sat, 09 Nov 2019 18:46:01 +0000 Received: from [188.174.51.245] (helo=localhost.unixarea.de) by ms-10.1blu.de with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.86_2) (envelope-from ) id 1iTVjq-0002Ku-38 for pgsql-general@lists.postgresql.org; Sat, 09 Nov 2019 19:45:34 +0100 Received: from localhost.my.domain (localhost [127.0.0.1]) by localhost.unixarea.de (8.15.2/8.14.9) with ESMTPS id xA9IjWEQ007438 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO) for ; Sat, 9 Nov 2019 19:45:32 +0100 (CET) (envelope-from guru@unixarea.de) Received: (from guru@localhost) by localhost.my.domain (8.15.2/8.14.9/Submit) id xA9IjVh0007437 for pgsql-general@lists.postgresql.org; Sat, 9 Nov 2019 19:45:31 +0100 (CET) (envelope-from guru@unixarea.de) X-Authentication-Warning: localhost.my.domain: guru set sender to guru@unixarea.de using -f Date: Sat, 9 Nov 2019 19:45:31 +0100 From: Matthias Apitz To: pgsql-general@lists.postgresql.org Subject: Re: type SERIAL in C host-struct Message-ID: <20191109184531.GA7291@c720-r342378> Reply-To: Matthias Apitz References: <20191107113939.GA130862@sh4-5.1blu.de> <20191107191447.GA2407@c720-r342378> <20191109153153.GA21937@hjp.at> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20191109153153.GA21937@hjp.at> X-Operating-System: FreeBSD 13.0-CURRENT r342378 (amd64) X-message-flag: Mails containing HTML will not be read! Please send only plain text. User-Agent: Mutt/1.11.1 (2018-12-01) X-Con-Id: 51246 X-Con-U: 0-guru X-Originating-IP: 188.174.51.245 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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 FROM mytypes;; 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