Concat truncates at 257 characters

Started by Patrick Lademanover 12 years ago7 messagesbugs
Jump to latest
#1Patrick Lademan
mjfrog14@gmail.com

Hello,

My automated database unit tests compare the actual result to the expected
result then provides a pass or fail status. When it fails, it constructs a
difference string with an ^ pointing to each mismatching character between
the two. Some of my tests have very long strings of data used to validate
that a function is working correctly under very specific test conditions.
The problem is that the concat and || are truncating the result.

The following simple examples all truncate at 257 characters and add a
trailing " (...)".

select rpad('', 200, 'A') || rpad('', 200, 'B');

select rpad('', 200, 'A')::text || rpad('', 200, 'B')::text;

select cast( rpad('', 200, 'A')::text || rpad('', 200, 'B')::text as text );

select cast( rpad('', 200, 'A') as text ) || cast( rpad('', 200, 'B') as
text );

select cast( cast( rpad('', 200, 'A') as text ) || cast( rpad('', 200, 'B')
as text ) as text);

select concat( rpad('', 200, 'A'), rpad('', 200, 'B') );

select concat( rpad('', 200, 'A')::varchar(4000) , rpad('', 200,
'B')::varchar(4000) )::varchar(4000);

select concat( rpad('', 200, 'A')::text , rpad('', 200, 'B')::text )::text;

Database:
"PostgreSQL 9.3.1 on x86_64-apple-darwin, compiled by
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build
5658) (LLVM build 2336.9.00), 64-bit"

Mac:
System Version: OS X 10.9 (13A603)
Kernel Version: Darwin 13.0.0

How can I extend the concat beyond 257?

Thank you,

Pat

#2John R Pierce
pierce@hogranch.com
In reply to: Patrick Lademan (#1)
Re: Concat truncates at 257 characters

On 11/25/2013 3:09 PM, Patrick Lademan wrote:

The following simple examples all truncate at 257 characters and add a
trailing " (...)".

select rpad('', 200, 'A') || rpad('', 200, 'B');

hmmm?

$ psql scratch
....
scratch=# select rpad('', 200, 'A') || rpad('', 200, 'B');

?column?

------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------
------
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBB
(1 row)

not here.

--
john r pierce 37N 122W
somewhere on the middle of the left coast

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

#3David G. Johnston
david.g.johnston@gmail.com
In reply to: Patrick Lademan (#1)
Re: Concat truncates at 257 characters

More details please.

The problem is that the concat and || are truncating the result.

No, that is not the case:

select length(cast( rpad('', 200, 'A')::text || rpad('', 200, 'B')::text as
text )) -- output -> 400

SELECT length(repeat('a', 50) || repeat('b', 200) || repeat('c', 100)) --
output -> 350

My automated database unit tests compare the actual result to the expected
result then provides a pass or fail status.

So some client-side interface is where the problem resides. It is trying to
output more user-friendly content for extra-long strings.

David J.

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Concat-truncates-at-257-characters-tp5780244p5780248.html
Sent from the PostgreSQL - bugs mailing list archive at Nabble.com.

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

#4Patrick Lademan
mjfrog14@gmail.com
In reply to: John R Pierce (#2)
Re: Concat truncates at 257 characters

What is difference between pgadmin and psql that would cause one to
truncate?
On Nov 25, 2013 6:18 PM, "John R Pierce" <pierce@hogranch.com> wrote:

Show quoted text

On 11/25/2013 3:09 PM, Patrick Lademan wrote:

The following simple examples all truncate at 257 characters and add a
trailing " (...)".

select rpad('', 200, 'A') || rpad('', 200, 'B');

hmmm?

$ psql scratch
....
scratch=# select rpad('', 200, 'A') || rpad('', 200, 'B');

?column?

------------------------------------------------------------
------------------------------------------------------------------------
------------------------------------------------------------
------------------------------------------------------------------------
------------------------------------------------------------
------------------------------------------------------------------------
------
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBB
(1 row)

not here.

--
john r pierce 37N 122W
somewhere on the middle of the left coast

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

#5John R Pierce
pierce@hogranch.com
In reply to: Patrick Lademan (#4)
Re: Concat truncates at 257 characters

On 11/25/2013 3:53 PM, Patrick Lademan wrote:

What is difference between pgadmin and psql that would cause one to
truncate?

whats the difference between a GUI application thats putting data in
grid forms, vs a console application thats writing to stdout? there's
more differences than there are similarities.

--
john r pierce 37N 122W
somewhere on the middle of the left coast

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

#6David G. Johnston
david.g.johnston@gmail.com
In reply to: Patrick Lademan (#4)
Re: Concat truncates at 257 characters

Patrick Lademan wrote

What is difference between pgadmin and psql that would cause one to
truncate?
On Nov 25, 2013 6:18 PM, "John R Pierce" &lt;

pierce@

&gt; wrote:

On 11/25/2013 3:09 PM, Patrick Lademan wrote:

The following simple examples all truncate at 257 characters and add a
trailing " (...)".

select rpad('', 200, 'A') || rpad('', 200, 'B');

hmmm?

$ psql scratch
....
scratch=# select rpad('', 200, 'A') || rpad('', 200, 'B');

?column?

------------------------------------------------------------
------------------------------------------------------------------------
------------------------------------------------------------
------------------------------------------------------------------------
------------------------------------------------------------
------------------------------------------------------------------------
------
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBB
(1 row)

not here.

What usage pattern, specifically, are you implementing (not that it will
mean much to me personally since my use of both pgAdmin and psql is
minimal)?

pgAdmin's design premise is that the output it generates will be consumed by
a human during routine administrative tasks. psql provides that level of
interaction plus the ability to configure its output to be processed
consistently by other software.

I was actually somewhat surprised that you could even use pgAdmin given the
level of automation you describe but maybe I assumed too much or pgAdmin can
do more than I imagined - though really psql was designed to meet your
automation needs pgAdmin mostly is not even if it has some conveniences.

That said there should be (ideally, not sure in reality) some way to disable
that behavior and force pgAdmin to output full text contents (w/o
human-friendly truncation).

David J.

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Concat-truncates-at-257-characters-tp5780244p5780258.html
Sent from the PostgreSQL - bugs mailing list archive at Nabble.com.

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

#7Patrick Lademan
mjfrog14@gmail.com
In reply to: David G. Johnston (#6)
Re: Concat truncates at 257 characters

This appears to be a new behavior in pgAdmin between versions 9.2 and 9.3
because I have existing unit tests with 516 character strings that I copy
and pasted from the pgAdmin result column.

How can I configure pgAdmin to display more than 257 characters in a result
column?

On Mon, Nov 25, 2013 at 7:10 PM, David Johnston <polobo@yahoo.com> wrote:

Show quoted text

Patrick Lademan wrote

What is difference between pgadmin and psql that would cause one to
truncate?
On Nov 25, 2013 6:18 PM, "John R Pierce" <

pierce@

wrote:

On 11/25/2013 3:09 PM, Patrick Lademan wrote:

The following simple examples all truncate at 257 characters and add a
trailing " (...)".

select rpad('', 200, 'A') || rpad('', 200, 'B');

hmmm?

$ psql scratch
....
scratch=# select rpad('', 200, 'A') || rpad('', 200, 'B');

?column?

------------------------------------------------------------
------------------------------------------------------------------------
------------------------------------------------------------
------------------------------------------------------------------------
------------------------------------------------------------
------------------------------------------------------------------------
------
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBB
(1 row)

not here.

What usage pattern, specifically, are you implementing (not that it will
mean much to me personally since my use of both pgAdmin and psql is
minimal)?

pgAdmin's design premise is that the output it generates will be consumed
by
a human during routine administrative tasks. psql provides that level of
interaction plus the ability to configure its output to be processed
consistently by other software.

I was actually somewhat surprised that you could even use pgAdmin given the
level of automation you describe but maybe I assumed too much or pgAdmin
can
do more than I imagined - though really psql was designed to meet your
automation needs pgAdmin mostly is not even if it has some conveniences.

That said there should be (ideally, not sure in reality) some way to
disable
that behavior and force pgAdmin to output full text contents (w/o
human-friendly truncation).

David J.

--
View this message in context:
http://postgresql.1045698.n5.nabble.com/Concat-truncates-at-257-characters-tp5780244p5780258.html
Sent from the PostgreSQL - bugs mailing list archive at Nabble.com.

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