Hi there I made some changes in postgresql source code to let the table function work in iteration fashion rather than materialization fashion. My main modifications are in 'exec_simple_query' function, I changed 'portalRunSelect' to return just one tuple instead of 'FETCH_ALL'. I made other variables static as the 'portal', 'receiver', etc. so that the program returns to them to continue execution from the last point. Then I added more calls to 'exec_simple_query' and it worked correctly. For example, if I added 4 calls to 'exec_simple_query' the 4th tuple is returned. My problem lies now in how to display the 1st, 2nd, 3rd tuples not just the 4th. I tried to call 'pq_flush' after each 'exec_simple_query' but nothing is displayed. I replaced 'pq_flush' with 'ReadyForQuery' but it gives the following error 'error 0x54 message received while system is idle'.
My question is how to inform the client that there is a tuple to display and return back to the backend to continue the query execution? Regards Islam Hegazy