Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1emLBg-0003F9-41 for pgsql-interfaces@arkaria.postgresql.org; Thu, 15 Feb 2018 15:11:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1emLBf-0000ij-7V for pgsql-interfaces@arkaria.postgresql.org; Thu, 15 Feb 2018 15:11:03 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1emLBe-0007Au-7u for pgsql-interfaces@lists.postgresql.org; Thu, 15 Feb 2018 15:11:02 +0000 Received: from mail231.strasbourg.4js.com ([92.103.31.231]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1emL4S-0001I6-4r for pgsql-interfaces@lists.postgresql.org; Thu, 15 Feb 2018 15:03:39 +0000 Received: from [10.0.40.29] (orion.strasbourg.4js.com [10.0.40.29]) (authenticated bits=0) by mail231.strasbourg.4js.com (8.14.4/8.14.4/Debian-4+deb7u1) with ESMTP id w1FF3MwU030697 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT) for ; Thu, 15 Feb 2018 16:03:22 +0100 To: pgsql-interfaces@lists.postgresql.org From: Sebastien FLAESCH Subject: Type scale returned by PQfmod() 65531 for time/timestamp output parameter? Organization: Four Js Development Tools Message-ID: <093e1214-7057-f80c-5c3c-74076b7bb555@4js.com> Date: Thu, 15 Feb 2018 16:03:22 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Virus-Scanned: clamav-milter 0.99.3 at mail231 X-Virus-Status: Clean X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail231.strasbourg.4js.com [10.10.0.1]); Thu, 15 Feb 2018 16:03:22 +0100 (CET) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi all, (PostgreSQL 10.beta2) I am using the PQfmod() function to get type information of result set columns. When using a stored function returning output parameters defined with as time[(n)] or timestamp[(n)], PQfmod() always returns the same SCALE (65531/0xFFFB), no matter what time/timestamp precision is used. With a regular SELECT on the same table columns I get other scale values, that allow me to distinguish the time/timestamp fraction precision: 2/0x0002 for time/timestamp(6) 1/0x0001 for time/timestamp(5) 0/0x0000 for time/timestamp(4) 65535/0xFFFF for time/timestamp(3) 65534/0xFFFE for time/timestamp(2) 65533/0xFFFD for time/timestamp(1) 65532/0xFFFC for time/timestamp(0) etc I get the scale as follows: #define VARHDRSZ 4 ... int pgfmod = PQfmod(st->pgResult, i); int pgprec = (pgfmod >> 16); int pgscal = ((pgfmod - VARHDRSZ) & 0xffff); <-- here int pgleng = (pgfmod - VARHDRSZ); ... Is this correct? I Could not find detailed documentation about the interpretation of PQfmod()... Here the SQL code of the stored function: create function proc240( in p_pkey integer, out p_dt_y2i timestamp without time zone, out p_dt_y2s timestamp without time zone, out p_dt_y2f2 timestamp(2) without time zone, out p_dt_y2f3 timestamp(3) without time zone, out p_dt_y2f5 timestamp(5) without time zone, out p_dt_h2i time without time zone, out p_dt_h2s time without time zone, out p_dt_h2f2 time(2) without time zone, out p_dt_h2f3 time(3) without time zone, out p_dt_h2f5 time(5) without time zone ) as $$ begin select dt_y2i, dt_y2s, dt_y2f2, dt_y2f3, dt_y2f5, dt_h2i, dt_h2s, dt_h2f2, dt_h2f3, dt_h2f5 into p_dt_y2i, p_dt_y2s, p_dt_y2f2, p_dt_y2f3, p_dt_y2f5, p_dt_h2i, p_dt_h2s, p_dt_h2f2, p_dt_h2f3, p_dt_h2f5 from t240 where pkey = p_pkey; end; $$ language plpgsql Then I am doing this: select * from proc240(101) To get the output parameters. Thanks for you help! Seb