rem: CON_RESULT(_h) = PQexec(CON_CONNECTION(_h), _s);  rv = 0; if(PQresultStatus(CON_RESULT(_h)) == 0) { PLOG("submit_query", "initial failure, FATAL");  rv = -3; } else {  switch(PQresultStatus(CON_RESULT(_h))) { case PGRES_EMPTY_QUERY: rv = -9; break; case PGRES_COMMAND_OK: rv = 0; break; case PGRES_TUPLES_OK: rv = 0; break; case PGRES_COPY_OUT: rv = -4; break; case PGRES_COPY_IN: rv = -5; break; case PGRES_BAD_RESPONSE: rv = -6; break; case PGRES_NONFATAL_ERROR: rv = -7; break; case PGRES_FATAL_ERROR: rv = -8; break; default: rv = -2; break; } } if(rv < 0) {  char buf[256]; sprintf(buf, "query '%s', result '%s'\n", _s, PQerrorMessage(CON_CONNECTION(_h))); PLOG("submit_query", buf); }  return(rv);
add: error: PQclear(pgres); return -1;
context: static int submit_query(db_con_t* _h, const char* _s){		int rv;	/*	** this bit of nonsense in case our connection get screwed up 	*/	switch(rv = PQstatus(CON_CONNECTION(_h)))	{		case CONNECTION_OK: break;		case CONNECTION_BAD:			PLOG("submit_query", "connection reset");			PQreset(CON_CONNECTION(_h));		break;	}	/*	** free any previous query that is laying about	*/	if(CON_RESULT(_h))	{		free_query(_h);	}	/*	** exec the query	*/	CON_RESULT(_h) = PQexec(CON_CONNECTION(_h), _s);	rv = 0;	if(PQresultStatus(CON_RESULT(_h)) == 0)	{		PLOG("submit_query", "initial failure, FATAL");		/* 		** terrible error??		*/		rv = -3;	}	else	{		/*		** the query ran, get the status		*/		switch(PQresultStatus(CON_RESULT(_h)))		{			case PGRES_EMPTY_QUERY: rv = -9; break;			case PGRES_COMMAND_OK: rv = 0; break;			case PGRES_TUPLES_OK: rv = 0; break;			case PGRES_COPY_OUT: rv = -4; break;			case PGRES_COPY_IN: rv = -5; break;			case PGRES_BAD_RESPONSE: rv = -6; break;			case PGRES_NONFATAL_ERROR: rv = -7; break;			case PGRES_FATAL_ERROR: rv = -8; break;			default: rv = -2; break;		}	}	if(rv < 0)	{		/*		** log the error		*/		char buf[256];		sprintf(buf, "query '%s', result '%s'\n",			_s, PQerrorMessage(CON_CONNECTION(_h)));		PLOG("submit_query", buf);	}	return(rv);}