Thread:
We have implemented use of cursor in psql. The implementation is backwards compatible so that the old method for selecting/printing data is the default method. The cursor mode can be enabled by setting a new variable "USECURSOR" to true. The printout uses the usual "printQuery" function, but header is only printed first time and footer is printed seperately. In the functions "print_aligned_text" and "print_aligned_vertical" a trailing newline has been disabled. "printQuery" should have been split into these three components, but we have not done this. This means that the layout analysis is performed for each record printed (when using cursor). We use psql extensively for piping data into next levels of various scripts, selecting data from a 40+ million record table. Without the cursor method, PostgreSQL first determines the whole result set before any record is coming out of psql. With the cursor method, records come out for post processing in parrallel with PostgreSQL defining the actual result set. We use similar method when we work with Oracle and Informix databases. We hope that you can use our patches. Best Regards Bo Tveden Mads Madsen BTS Solutions _________________________________________________________________ Find din ferie p� MSN Rejser http://www.msn.dk/rejser
Attachment
"bts solutions" <bts_postgresql@hotmail.com> writes: > We have implemented use of cursor in psql. > + results =3D PQexec(pset.db, "begin work"); > + own_work =3D PQresultStatus(results) =3D=3D PGRES_COMMAND_OK; I do not believe this works for the case where one is already inside a transaction block. BEGIN will not report an error, so you'll end up improperly issuing a COMMIT. More generally, I'm not happy with having psql issue substantially different SQL commands than what I gave it. I think it should be the application's business to use a cursor, not psql's. regards, tom lane