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 1iUm7G-0006fZ-KV for pgsql-general@arkaria.postgresql.org; Wed, 13 Nov 2019 06:26:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iUm7F-0000mH-7s for pgsql-general@arkaria.postgresql.org; Wed, 13 Nov 2019 06:26:57 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iUm7E-0000mA-RQ for pgsql-general@lists.postgresql.org; Wed, 13 Nov 2019 06:26:56 +0000 Received: from ms-10.1blu.de ([178.254.4.101]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1iUm7B-0004Un-Ex for pgsql-general@lists.postgresql.org; Wed, 13 Nov 2019 06:26:55 +0000 Received: from [188.174.63.100] (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 1iUm76-0000Us-HT; Wed, 13 Nov 2019 07:26:48 +0100 Received: from localhost.my.domain (localhost [127.0.0.1]) by localhost.unixarea.de (8.15.2/8.14.9) with ESMTPS id xAD6QkM9003221 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 13 Nov 2019 07:26:46 +0100 (CET) (envelope-from guru@unixarea.de) Received: (from guru@localhost) by localhost.my.domain (8.15.2/8.14.9/Submit) id xAD6QkNW003220; Wed, 13 Nov 2019 07:26:46 +0100 (CET) (envelope-from guru@unixarea.de) X-Authentication-Warning: localhost.my.domain: guru set sender to guru@unixarea.de using -f Date: Wed, 13 Nov 2019 07:26:44 +0100 From: Matthias Apitz To: pgsql-general@lists.postgresql.org Subject: Re: type SERIAL in C host-struct Message-ID: <20191113062644.GA2989@c720-r342378> Reply-To: Matthias Apitz References: <20191107113939.GA130862@sh4-5.1blu.de> <20191107191447.GA2407@c720-r342378> <20191109153153.GA21937@hjp.at> <20191109184531.GA7291@c720-r342378> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Nq2Wo0NMKNjxTN9z" Content-Disposition: inline In-Reply-To: <20191109184531.GA7291@c720-r342378> 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.63.100 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Nq2Wo0NMKNjxTN9z Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable El d=C3=ADa s=C3=A1bado, noviembre 09, 2019 a las 07:45:31p. m. +0100, Matt= hias Apitz escribi=C3=B3: > 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 >=20 > ECPGdebug(int on, FILE *stream); >=20 > The resulting log is really fine for debugging our code: >=20 > ... I added time stamps to the logging as: /tmp/ecpg.log: =2E.. [18328] [12.11.2019 18:38:44:637]: ecpg_execute on line 120: query: insert = into mytypes values ( $1 , $2 , $3 , $4 , $5 ); with 5 parameter(s) on= connection newsisis [18328] [12.11.2019 18:38:46:881]: ecpg_execute on line 120: using PQexecPa= rams [18328] [12.11.2019 18:38:46:881]: ecpg_free_params on line 120: parameter = 1 =3D 99 [18328] [12.11.2019 18:38:46:881]: ecpg_free_params on line 120: parameter = 2 =3D [18328] [12.11.2019 18:38:46:881]: ecpg_free_params on line 120: parameter = 3 =3D 2000-01-01 [18328] [12.11.2019 18:38:46:881]: ecpg_free_params on line 120: parameter = 4 =3D [18328] [12.11.2019 18:38:46:881]: ecpg_free_params on line 120: parameter = 5 =3D \x6c696e6520.... =2E... [18328] [12.11.2019 18:38:47:084]: ecpg_process_output on line 120: OK: INS= ERT 0 1 [18328] [12.11.2019 18:38:47:084]: ECPGtrans on line 126: action "commit"; = connection "newsisis" [18328] [12.11.2019 18:38:47:260]: deallocate_one on line 0: name s_statena= me [18328] [12.11.2019 18:38:47:263]: ecpg_finish: connection newsisis closed The above shows an INSERT into a 'bytea' column of ~36 MByte (yes we have such large XML data for billing/accounting processes in the database). It takes ~0.2 sec to insert such a monster row. On INSERT/UPDATE the column data (XML) comes down from the application layer as a 'char *' pointer. I know with strlen(src) how long it is, I doub= le its length and add 3 (for the "\x" in front and the '\0' at the end) and ma= lloc the space for the host variable for INSERT/UPDATE and translate the octets to hex representation. When FETCH-ing such a column I do not know the resulting length of the bytea data for doing a malloc(). I could do before any FETCH a SELECT octet_length(myblob) FROM mytypes; but I do not know how expensive this would be. Any other idea to predict the needed space for the host variable on FETCH? matthias --=20 Matthias Apitz, =E2=9C=89 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 durc= hschaut" "Believe little, scrutinise all, think by your own: How see through manipul= ations" ISBN-10: 386489218X --Nq2Wo0NMKNjxTN9z Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEXmn7rBYYViyzy/vBR8z35Hb+nREFAl3LoiEACgkQR8z35Hb+ nRESGQ//bTZw66mGsjA+AASRF1wlR5IgMxwdfh9oIPh6UBSUKZJfIyTZEDxnmF51 PWfeNO5uLiEh4m6VdI3f+sd14+mVj/QGQe2LSMOxdDIieoFxhMpnWRA4dH/7eBMY hZJyTK+DTuf4Ymz5+FQqqFyg1U1c3LshK9Y98PWatPcbApco5NVw8tG5jG7Rb+4u sgWtxpzGg31zSxqGWPAANby4q6SiPHFOOQXp2iNcgIsXPUKlFdW1oZ/ZMQioBkyg JygFzjSiH5rxKWGMVQBC6iMMal0tYCelqofZzdPAdmJvlLUBw0MW+COeAWEZZ9La 77ktteocqDnM/rOsloCzON8rw5YRNNWjgufo+3n4NVba5YH6wIdiB489EGxNrPL5 QrY2t5dcdfhLYFzOvcSEte7kvnosaPvSWHyv7slbNvoENUnsHwNw0jQBfCuj8OJw j/HLw3b6OHsV470fIW7JiX7J7nAlmJBLaTwK1KfrcWa3DtZgtd6OWdZygbVy3AmT Pmm1Ieyb989y7Q1OMFlh3nvLDOQcS+t8scNJJUlsGNN7kAIgqR3L9hWhaQWnORUg xHWERtSRLfaX9KJsquAlhaPZK+eGYb8wQbMUsA1QDCzSwYactHkBcdDg5e3Jopyf 9vtk1HL2/feQ4wtMAvx42K5hvNc3fyE3yHYMQLdBpPtvk0bT3Us= =3YkP -----END PGP SIGNATURE----- --Nq2Wo0NMKNjxTN9z--