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 1iQBvf-0003vQ-RE for pgsql-general@arkaria.postgresql.org; Thu, 31 Oct 2019 15:00: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 1iQBvd-0006qc-Ez for pgsql-general@arkaria.postgresql.org; Thu, 31 Oct 2019 15:00:01 +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 1iQBvd-0006qT-4m for pgsql-general@lists.postgresql.org; Thu, 31 Oct 2019 15:00:01 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iQBva-0003Zh-UJ for pgsql-general@lists.postgresql.org; Thu, 31 Oct 2019 15:00:00 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x9VExo2U019216; Thu, 31 Oct 2019 10:59:51 -0400 From: Tom Lane To: Merlin Moncure cc: Andres Freund , Mitar , f.venchiarutti@ocado.com, Dave Cramer , "pgsql-generallists.postgresql.org" Subject: Re: Automatically parsing in-line composite types In-reply-to: References: <31567.1572373980@sss.pgh.pa.us> <20191030224105.dwej53kaklipfz5w@alap3.anarazel.de> Comments: In-reply-to Merlin Moncure message dated "Thu, 31 Oct 2019 09:22:19 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <19214.1572533990.1@sss.pgh.pa.us> Date: Thu, 31 Oct 2019 10:59:50 -0400 Message-ID: <19215.1572533990@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Merlin Moncure writes: > On Wed, Oct 30, 2019 at 5:41 PM Andres Freund wrote: >> Hm. Wouldn't it be fairly easy to allow the client to specify how much >> metadata they'd want? I.e. opt-in into getting more complete metadata? > Suppose you had a set of 1000 records, with an array of composites (10 > items per array). How many times would the extra metadata describing > get sent following this approach? Presumably once per Describe request (or once per simple Query) ... but that facile answer actually isn't very satisfactory. It's at least theoretically possible that a column of type "record" could have varying actual rowtype from one tuple to the next. I don't want to swear that every part of Postgres is capable of coping with that, but a lot is --- see record_out() itself for the prototypical coding pattern. The wire protocol is really pretty tightly bound to the assumption that every tuple in a resultset has the same description, but that's going to fall down if we want to transmit details about what "record" means. The same problem occurs with arrays, specifically anyarray --- and here I don't have to think hard to come up with a query that will break it. "select * from pg_stats" is enough to do that. It's not only the wire protocol that's going to have issues with varying rowtypes. How would we deal with that in libpq's resultset API, for example? I wonder whether the JDBC API could handle it either. tl;dr: there are a lot more worms in this can than you might guess. regards, tom lane