Re: BUG #14338: Problems of quotes with very long text - Mailing list pgsql-bugs

From Pavel Stehule
Subject Re: BUG #14338: Problems of quotes with very long text
Date
Msg-id CAFj8pRBRE=SosmT4+LVOj5hyYAjQu4vCEhGzR0JNArLmFCMRDg@mail.gmail.com
Whole thread Raw
In response to BUG #14338: Problems of quotes with very long text  (belhaouane.eddy@gmail.com)
List pgsql-bugs
Hi

2016-09-25 15:50 GMT+02:00 <belhaouane.eddy@gmail.com>:

> The following bug has been logged on the website:
>
> Bug reference:      14338
> Logged by:          eddydev03
> Email address:      belhaouane.eddy@gmail.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@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs
>

pgsql-bugs by date:

Previous
From: belhaouane.eddy@gmail.com
Date:
Subject: BUG #14338: Problems of quotes with very long text
Next
From: Greg Stark
Date:
Subject: Re: "HDT" time zone not recognized by PostreSQL 9.5