I have tried using chunks technique when creating huge string for a stored 
procedure (C code). I work like charm for small string, but when i create 
large strings i get a "server closed the connection unexpectedly" :-( I use 
palloc and repalloc for memory handling. Note! I made a standard C program 
that just keept on making the chunk larger (read string), i never did crash 
any. So what is postgres doing? (ps. the same happens if I use standard malloc 
an realloc)

Any ideas why? (No continues block of memory is large enough or?)
And how does one normally handle Large strings in postgres?

\Steffen Nielsen

Tue, 23 Apr 2002 10:55:52 +0200
Steffen Nielsen <styf@cs.auc.dk>
Generating Huge String?
Steffen Nielsen <styf@cs.auc.dk> writes:
> I have tried using chunks technique when creating huge string for a stored 
> procedure (C code). I work like charm for small string, but when i create 
> large strings i get a "server closed the connection unexpectedly" :-(

Look for bugs in your code ;-).  I'd bet it's scribbling on memory that
doesn't belong to it.

> And how does one normally handle Large strings in postgres?

The StringInfo functions are moderately convenient in most cases.

			regards, tom lane

Tue, 23 Apr 2002 09:49:30 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: Generating Huge String? 
Hi!

I checked out the StringInfo functions, they are basicly the same as the 
Chunks functions I use, but I'll use the others instead even thought I don't 
think they will help me on my problem. But anyway, I've checked out the malloc 
and realloc function, and believe that they won't allow allocation into an 
allready occopied memory area (at least on freebsd).

But if not, maybe I should create a new Chunk (malloc again, and copy; But 
that would probably lead to heavy fragmentation of the memory) if realloc 
can't allocate more continuos memory space?

Sorry if these question seem trivially, I'm a C newbie :-)

/Steffen Nielsen

Quoting Tom Lane <tgl@sss.pgh.pa.us>:

> Steffen Nielsen <styf@cs.auc.dk> writes:
> > I have tried using chunks technique when creating huge string for a stored
> 
> > procedure (C code). I work like charm for small string, but when i create
> 
> > large strings i get a "server closed the connection unexpectedly" :-(
> 
> Look for bugs in your code ;-).  I'd bet it's scribbling on memory that
> doesn't belong to it.
> 
> > And how does one normally handle Large strings in postgres?
> 
> The StringInfo functions are moderately convenient in most cases.
> 
> 			regards, tom lane
> 




Tue, 23 Apr 2002 22:17:59 +0200
Steffen Nielsen <styf@cs.auc.dk>
Re: Generating Huge String? 