Re: SPI_cursor_fetch Memory overrun

2018-08-22 Thread Tom Lane
Wu Ivy writes: > fprintf(fp, (i == tupdesc->natts) ? "%s\n" : "%s," , > SPI_getvalue(tuple, tupdesc, i)); That (specifically the SPI_getvalue call) is what's leaking memory. You could improve matters by pfree'ing the result string after each such call. Just to add insult t

SPI_cursor_fetch Memory overrun

2018-08-22 Thread Wu Ivy
Hi all, I’m creating a C extension to write data from the Postgres to a text file . Since the table can be very large, I only want to process one chunk of data per time to keep the memory stable. To achieve this, I use SPI cursor(https://www.postgresql.org/docs/current/static/spi-spi-cursor-f