Re: Yikes! Bitten by line length?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: ken(at)kencorey(dot)com
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Yikes! Bitten by line length?
Date: 2001-01-18 19:00:01
Message-ID: 4435.979844401@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Ken Corey <ken(at)kencorey(dot)com> writes:
> 1) Problem: Under Solaris, when entering a really long sql parameter
> into psql, the first bytes would be chopped off:

> GRE=# select
> I_SESSION(null,'1',2,'E2K','0x637B9C8B443E9AA0AF4C696D7E8AB27B4FA57B5A6DBDD29851B74BDE5D97A3995F8F8A825F8B4D95D7687CAE94E77F809B589363685A718B72A28C90AA872936297B4020360B46752B2E2042172232171C59F730193153466B2F4A42270E563A29FF4ED30C47E340396056691B1485512D1F3E2E2554124D2D47821E3BF86031335C24444E00063112644D41F09C6F00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
> GRE'# ');
> ERROR: parser: parse error at or near
> "000000000000000000000000000000000"
> GRE=#

> Cause:
> Solaris' fgets function *only* returns the last part of a string if the
> string is over 256 bytes! The test was this little program:

> #include <stdio.h>
> int main(int argc,char **argv) {
> char line[1024];
> while((fgets(line,1024,stdin)) != EOF) {
> printf("Got '%s'\n",line);
> }
> }

> Enter in really big lines (> 256 characters), and you'll see what I
> mean.

Yeesh. I wonder if any other Unixen are equally broken?

Perhaps we should reduce psql's fgets() buffers to 256 bytes or less to
avoid this problem?

regards, tom lane

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Ken Corey 2001-01-18 19:23:52 Re: Yikes! Bitten by line length?
Previous Message Ken Corey 2001-01-18 18:55:22 Re: Yikes! Bitten by line length?