Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dPczV-0006un-CB for pgsql-bugs@arkaria.postgresql.org; Mon, 26 Jun 2017 23:00:21 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dPczU-0006UD-GU for pgsql-bugs@arkaria.postgresql.org; Mon, 26 Jun 2017 23:00:20 +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 1dPcym-00058Q-L2 for pgsql-bugs@postgresql.org; Mon, 26 Jun 2017 22:59:36 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dPcyk-0007fh-2I for pgsql-bugs@postgresql.org; Mon, 26 Jun 2017 22:59:35 +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 v5QMxRcf024941; Mon, 26 Jun 2017 18:59:27 -0400 From: Tom Lane To: =?UTF-8?B?0JDRgNGB0LXQvSDQkNGA0YPRgtGO0L3Rj9C9?= cc: pgsql-bugs@postgresql.org Subject: Re: =?UTF-8?B?RXJyb3IgaW4gU1BJX2V4ZWN1dGVfcGxhbiAod2hlbiBpbnNlcnRpbmcgSlNP?= =?UTF-8?B?TiBmcm9tIEMgY29kZSBmaXJzdCB7IHNpbWJvbGwgaXMgbG9zdCk=?= In-reply-to: <1498515664.231254063@f472.i.mail.ru> References: <1498515664.231254063@f472.i.mail.ru> Comments: In-reply-to =?UTF-8?B?0JDRgNGB0LXQvSDQkNGA0YPRgtGO0L3Rj9C9?= message dated "Tue, 27 Jun 2017 01:21:04 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <24939.1498517967.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 26 Jun 2017 18:59:27 -0400 Message-ID: <24940.1498517967@sss.pgh.pa.us> List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org =3D?UTF-8?B?0JDRgNGB0LXQvSDQkNGA0YPRgtGO0L3Rj9C9?=3D writes: > StringInfo JsonObject =3D makeStringInfo(); > appendStringInfoString(JsonObject, "{\"ObjectName\":\"Bug Json Object\",\= "Type\":227,\"Command\":88}"); > Datum Values[2]; > Values[0] =3D Int32GetDatum(227); > Values[1] =3D CStringGetDatum(JsonObject->data); That's certainly not going to work, because a CString datum doesn't have the same representation as a JSON datum. I think you could get away with using CStringGetTextDatum, relying on the equivalent physical representations of JSON and text. But it wouldn't be a terribly good idea IMO, partly because you'd be passing up validity checking on the JSON string; plus you could never make that work for JSONB. What you really should do instead is pass the CString to JSON's input function, say Values[1] =3D OidInputFunctionCall(F_JSON_IN, JsonObject->data, JSONOID, = -1); This is still cheating a bit --- it knows more than it ought to about what to pass for typioparam --- but it's unlikely to break. regards, tom lane --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs