Re: BUG #14338: Problems of quotes with very long text

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: belhaouane(dot)eddy(at)gmail(dot)com
Cc: "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #14338: Problems of quotes with very long text
Date: 2016-09-25 19:46:18
Message-ID: CAFj8pRBRE=SosmT4+LVOj5hyYAjQu4vCEhGzR0JNArLmFCMRDg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi

2016-09-25 15:50 GMT+02:00 <belhaouane(dot)eddy(at)gmail(dot)com>:

> The following bug has been logged on the website:
>
> Bug reference: 14338
> Logged by: eddydev03
> Email address: belhaouane(dot)eddy(at)gmail(dot)com
> PostgreSQL version: 9.5.4
> Operating system: Windows 7
> Description:
>
> I found something weird when I simply try to single quote a very long text
> like a text with 526366 characters.
>
> Example: In the SQL execution interface, I copied a text with 526366
> characters and then when I do '' and paste my_text inside the quote. the
> interface change the text like randomly. There is any solution to enter a
> very long text inside quotes?
>
> Thanks for helping guys!!!!!
>
>
>
500 kB is not too much for Postgres, but maybe is too for your client.

The most simple way is using Large Object interface - you can use psql
command \lo_import. Next step is converting imported large object to
string. An example is demonstration of import large JSON document.

postgres=# \lo_import ~/citylots.json
lo_import 16510
CREATE OR REPLACE FUNCTION public.bytea_to_text(bytea)
RETURNS text
LANGUAGE sql
AS $function$
SELECT convert_from($1, current_setting('server_encoding'))
$function$

CREATE TABLE city_text(data text);
INSERT INTO city_text SELECT bytea_to_text(lo_get(16510));
CREATE TABLE city_json(data json);
CREATE TABLE city_jsonb(data jsonb);
INSERT INTO city_json SELECT data::json FROM city_text;
INSERT INTO city_jsonb SELECT data::jsonb FROM city_text;

Probably this is not PostgreSQL bug - please, use psql-general mailing list.

Regards

Pavel

> --
> Sent via pgsql-bugs mailing list (pgsql-bugs(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs
>

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Greg Stark 2016-09-25 21:24:15 Re: "HDT" time zone not recognized by PostreSQL 9.5
Previous Message belhaouane.eddy 2016-09-25 13:50:51 BUG #14338: Problems of quotes with very long text