Hello Martijin, Thx for u'r Suggetions.. Here is Complete source code.. Desc about following code:::: Code has a function named as queryDB, which makes a connection to our DB and then tries to query Particular table which has huge string in it's field. If this method called from main thread then it *DOES* work properly. But if we make that as routine function for a thread it doesn't work instead we will get that following status ::: ( PGRES_FATAL_ERROR ) ***could not receive data from server: Invalid argument*** ******************************CODE***************************** #include <iostream> #include "libpq-fe.h" #include "libpq/libpq-fs.h" #include <string> #include <stdlib.h> #include <netinet/in.h> #include <arpa/inet.h> #include <sys/timeb.h> #include <time.h> #include <unistd.h> #include <pwd.h> #include <sys/timeb.h> #include <errno.h> #include <sys/socket.h> #include <netdb.h> #include <netinet/in.h> #include "common/gs/utils/UtilsConsts.h" #include <utmp.h> #include <utmpx.h> #include <sys/stat.h> #include <cstdlib> #include <cstdio> void* queryDB(void* p) { cout<<"I Am in Routine Function *** "<<endl; PGconn *_conn; PGresult *_res; char *dbn,*usn; char *error; cout<<"i am connecting:"<<endl; _conn=PQconnectdb("dbname = LOGDB user = sfmdb port=10864 "); if(PQstatus(_conn)==CONNECTION_OK) cout<<"connection is ready"<<endl; dbn=PQdb(_conn); usn=PQuser(_conn); if(PQstatus(_conn)==CONNECTION_BAD) cout<<"the connection is not hapened"<<endl; string string1,string2,string3; _res=PQexec(_conn,"select * from throttlingconfig ;"); if (!( PQresultStatus(_res) == PGRES_COMMAND_OK ||PQresultStatus(_res) == PGRES_TUPLES_OK ) ) { /*If this Function is *NOT* called from main thread then we will end up by entering here. */ string msg = PQresultErrorMessage(_res); PQclear(_res); cout<<"Query Execution is Not OK **********"<<msg<<endl; } else { /*If this Function is called from main thread then we will end up by entering here. */ int no_of_tuples,no_of_columns; char *str1; string stg; no_of_columns=PQnfields(_res); no_of_tuples=PQntuples(_res); cout<<"no of tuples "<<no_of_tuples<<endl; cout<<"Number Of Columns "<<no_of_columns<<endl; for(int u=0;u<no_of_tuples;u++) { for(int y=0;y<no_of_columns;y++) { str1=PQgetvalue(_res,u,y); cout<<"*************Printing *** "<<u<<"th Row "<<y<<"th Column****************"<<endl; cout<<str1<<endl; } cout<<endl; } PQclear(_res); } PQfinish(_conn); return NULL; } int main() { //size_t _stackSize(512 * 1024 * 2); //calling queryDB from other thread ..DOESN'T Work here size_t _stackSize(512 * 1024 * 2 * 20) ; pthread_attr_t attr; pthread_attr_init ( &attr ) ; pthread_t thread_t; int ret = pthread_attr_setstacksize( &attr, _stackSize) ; pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); int retVal = pthread_create(&thread_t, &attr,queryDB,NULL ); int rc,status; rc = pthread_join(thread_t, (void **)&status); //calling queryDB from main thread WORKS here.. queryDB(NULL); return 1; } Thx a lot, And looking for u'r reply, Prasanna. -----Original Message----- From: Martijn van Oosterhout [mailto:kleptog@xxxxxxxxx] Sent: Saturday, April 15, 2006 7:22 PM To: Mavinakuli, Prasanna (STSD) Cc: pgsql-general@xxxxxxxxxxxxxx Subject: Re: [GENERAL] HUGE Stack space is gettiing consumed On Fri, Apr 14, 2006 at 09:13:26AM +0530, Mavinakuli, Prasanna (STSD) wrote: > Hello All, > > We are getting very strange problem .. > > ******************************************************** > We Have one data field in some table..type of this field Is *TEXT*. > We are storing around 1,000 (One Thousand) lines of text In that > field. > > If it's run though separate thread, > When we say select <columnname> from <tablename> We are getting *could > not receive data from server: No such file or directory * messages > without Result > > If it was in main thread, > It Works fine. > ******************************************************** So you have a multithreaded program. Have you setup something so that you don't have two threads trying to do things with libpq at the same time? Because that won't work. Secondly, it can't have anything to do with stack-space because when you run out of stack space you get a segmentation fault, not a nice error. Either post a complete example of the failure (with source code) or perhaps the strace output would be enough. -- Martijn van Oosterhout <kleptog@xxxxxxxxx> http://svana.org/kleptog/ > Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is > a tool for doing 5% of the work and then sitting around waiting for > someone else to do the other 95% so you can sue them.