conn.addWarning(stream.ReceiveString(4096));
conn.addWarning(stream.ReceiveString(conn.getEncoding()));
  public Object fastpath(int fnid,boolean resulttype,FastpathArg[] args) throws SQLException  {    // added Oct 7 1998 to give us thread safety    synchronized(stream) {          // send the function call    try {      // 70 is 'F' in ASCII. Note: don't use SendChar() here as it adds padding      // that confuses the backend. The 0 terminates the command line.      stream.SendInteger(70,1);      stream.SendInteger(0,1);      stream.SendInteger(fnid,4);      stream.SendInteger(args.length,4);            for(int i=0;i<args.length;i++)	args[i].send(stream);            // This is needed, otherwise data can be lost      stream.flush();          } catch(IOException ioe) {      throw new PSQLException("postgresql.fp.send",new Integer(fnid),ioe);    }        // Now handle the result        // We should get 'V' on sucess or 'E' on error. Anything else is treated    // as an error.    //int in = stream.ReceiveChar();    //DriverManager.println("ReceiveChar() = "+in+" '"+((char)in)+"'");    //if(in!='V') {    //if(in=='E')    //throw new SQLException(stream.ReceiveString(4096));    //throw new SQLException("Fastpath: expected 'V' from backend, got "+((char)in));    //}        // Now loop, reading the results    Object result = null; // our result    while(true) {      int in = stream.ReceiveChar();      //DriverManager.println("ReceiveChar() = "+in+" '"+((char)in)+"'");      switch(in)	{	case 'V':	  break;	  	  //------------------------------	  // Function returned properly	  //	case 'G':	  int sz = stream.ReceiveIntegerR(4);	  //DriverManager.println("G: size="+sz);  //debug	  	  // Return an Integer if	  if(resulttype)	    result = new Integer(stream.ReceiveIntegerR(sz));	  else {	    byte buf[] = new byte[sz];	    stream.Receive(buf,0,sz);	    result = buf;	  }	  break;	  	  //------------------------------	  // Error message returned	case 'E':	  throw new PSQLException("postgresql.fp.error",stream.ReceiveString(4096));	  	  //------------------------------	  // Notice from backend	case 'N':	  conn.addWarning(stream.ReceiveString(4096));	  break;	  	  //------------------------------	  // End of results	  //	  // Here we simply return res, which would contain the result	  // processed earlier. If no result, this already contains null	case '0':	  //DriverManager.println("returning "+result);	  return result;	  	case 'Z':	    break;	    	default:	  throw new PSQLException("postgresql.fp.protocol",new Character((char)in));	}    }    }  }