Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZCZ5J-0004o4-HJ for pgsql-jdbc@arkaria.postgresql.org; Tue, 07 Jul 2015 20:03:17 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZCZ5J-0002Am-0r for pgsql-jdbc@arkaria.postgresql.org; Tue, 07 Jul 2015 20:03:17 +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) (envelope-from ) id 1ZCZ4d-0001bX-7w for pgsql-jdbc@postgresql.org; Tue, 07 Jul 2015 20:02:35 +0000 Received: from mail-wg0-x233.google.com ([2a00:1450:400c:c00::233]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1ZCZ4a-0002aM-NE for pgsql-jdbc@postgresql.org; Tue, 07 Jul 2015 20:02:34 +0000 Received: by wgjx7 with SMTP id x7so177349530wgj.2 for ; Tue, 07 Jul 2015 13:02:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:reply-to:user-agent:mime-version:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=T3UFTb5Gb2aRFip5OsNpsgGUg/X4zldFDa1pXeDzddM=; b=oOw1ShIvV85mAWwIqhYuw9fPoVueCaRilfzPdkw0T9gbwD8uckgz7TBhEQN2iIHk7t t5N62ACzCAI8RLX/7qLUIp4mvR/zCD+/NrYjMuvIo/VMcz2KDJKNPL+/54cMIuxo7yxe yoyqC3gc9rRWoOfunuaW+0p2RmSp6JKm89Q282n4ylAoN/i456H+8cn7hVs65JYyr3of jnpLZtu+up9vosqcwKnnyziWhu+IrExF8mx+IWeDKuUNmWW6OciCE0Tan97bwsSsbBYL K8bn+VBkpZ3nwOSz4UN/qcaAq/RFPKDOYHUNLyoCZ1HG9DirQncSMEFrPa/npuVdlxhr ZJ/w== X-Received: by 10.180.74.136 with SMTP id t8mr64291378wiv.21.1436299351192; Tue, 07 Jul 2015 13:02:31 -0700 (PDT) Received: from [192.168.1.110] (dsl-hkibrasgw1-58c38f-82.dhcp.inet.fi. [88.195.143.82]) by mx.google.com with ESMTPSA id ib9sm4668397wjb.2.2015.07.07.13.02.29 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jul 2015 13:02:30 -0700 (PDT) Message-ID: <559C3053.2060106@iki.fi> Date: Tue, 07 Jul 2015 23:02:27 +0300 From: Heikki Linnakangas Reply-To: hlinnaka@iki.fi User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.7.0 MIME-Version: 1.0 To: Dave Cramer CC: Kevin Wooten , List Subject: Re: PostgreSQL gaps wrt to java, and jdbc References: <80FEC5E5-DD36-46F4-A510-31E08415FBB1@me.com> <559C2CA8.6000200@iki.fi> In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -2.4 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org On 07/07/2015 10:51 PM, Dave Cramer wrote: > On 7 July 2015 at 15:46, Heikki Linnakangas wrote: > >> On 07/07/2015 09:31 PM, Kevin Wooten wrote: >> >>> == Binary type coercion == >>> The biggest impediment I’ve run into is the fact that PG will not >>> attempt coercion on binary types. If you specify a binary type in the >>> protocol, that’s the final word. A better system would be to have PG >>> perform the same coercion it does for text types and then send the >>> results back with coerced types, in binary; finally falling back to >>> text when binary cannot be produced. This would solve almost every >>> issue we have had to work around in the “ng” driver. >>> >> >> Can you elaborate? I'm confused, because the server can produce binary >> output for any datatype that has binary output functions. That covers all >> built-in datatypes and all extension datatypes people use in practice. >> >> What I've imagined to be a problem, though, is that you have to either >> understand the binary representation of all datatypes in the client, or you >> have to request binary for only those datatypes you can handle. And to know >> which datatype a result set's column has, you have to Describe it before >> fetching the results, which adds an extra round-trip. So it would be handy >> if the driver could provide the server a list of datatypes that should be >> sent as binary, as a one-time operation at the beginning of the session for >> example, rather than indicating for each column in each query separately. >> > Is there a way to get json and or xml out as binary ? Well, as far as the protocol is considered, yes. However, the "binary representation" of json and xml datatypes is not too exciting; here's the binary send function for json for example: /* * Binary send. */ Datum json_send(PG_FUNCTION_ARGS) { text *t = PG_GETARG_TEXT_PP(0); StringInfoData buf; pq_begintypsend(&buf); pq_sendtext(&buf, VARDATA_ANY(t), VARSIZE_ANY_EXHDR(t)); PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); } I.e. it just sends the string with a bytea header. There is no benefit to using that instead of the regular text representation. That dummy representation is used just so that e.g. binary-format pg_dump works. - Heikki -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc