77 *
88 *
99 * IDENTIFICATION
10- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.13 1996/08/06 16:16:46 scrappy Exp $
10+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.14 1996/08/10 00:22:48 scrappy Exp $
1111 *
1212 *-------------------------------------------------------------------------
1313 */
@@ -131,7 +131,7 @@ getTuple(PGconn *conn, PGresult* result, int binary)
131131int bitcnt = 0 ;/* number of bits examined in current byte */
132132int vlen ;/* length of the current field value */
133133FILE * pfin = conn -> Pfin ;
134- FILE * Pfdebug = conn -> Pfdebug ;
134+ FILE * pfdebug = conn -> Pfdebug ;
135135
136136PGresAttValue * tup ;
137137
@@ -145,7 +145,7 @@ getTuple(PGconn *conn, PGresult* result, int binary)
145145if ( (nfields %BYTELEN )> 0 )
146146nbytes ++ ;
147147
148- if (pqGetnchar (bitmap ,nbytes ,pfin ,Pfdebug )== 1 ){
148+ if (pqGetnchar (bitmap ,nbytes ,pfin ,pfdebug )== 1 ){
149149sprintf (conn -> errorMessage ,
150150"Error reading null-values bitmap from tuple data stream\n" );
151151return NULL ;
@@ -164,7 +164,7 @@ getTuple(PGconn *conn, PGresult* result, int binary)
164164 }
165165else {
166166/* get the value length (the first four bytes are for length) */
167- pqGetInt (& vlen ,VARHDRSZ ,pfin ,Pfdebug );
167+ pqGetInt (& vlen ,VARHDRSZ ,pfin ,pfdebug );
168168if (binary == 0 ) {
169169vlen = vlen - VARHDRSZ ;
170170}
@@ -174,7 +174,7 @@ getTuple(PGconn *conn, PGresult* result, int binary)
174174tup [i ].value = (char * )malloc (vlen + 1 );
175175/* read in the value; */
176176if (vlen > 0 )
177- pqGetnchar ((char * )(tup [i ].value ),vlen ,pfin ,Pfdebug );
177+ pqGetnchar ((char * )(tup [i ].value ),vlen ,pfin ,pfdebug );
178178tup [i ].value [vlen ]= '\0' ;
179179 }
180180/* get the appropriate bitmap */
@@ -241,15 +241,15 @@ makePGresult(PGconn* conn, char* pname)
241241PGresAttValue * newTup ;
242242
243243FILE * pfin = conn -> Pfin ;
244- FILE * Pfdebug = conn -> Pfdebug ;
244+ FILE * pfdebug = conn -> Pfdebug ;
245245
246246result = makeEmptyPGresult (conn ,PGRES_TUPLES_OK );
247247
248248/* makePGresult() should only be called when the */
249249/* id of the stream is 'T' to start with */
250250
251251/* the next two bytes are the number of fields */
252- if (pqGetInt (& nfields ,2 ,pfin ,Pfdebug )== 1 ) {
252+ if (pqGetInt (& nfields ,2 ,pfin ,pfdebug )== 1 ) {
253253sprintf (conn -> errorMessage ,
254254"could not get the number of fields from the 'T' message\n" );
255255 gotomakePGresult_badResponse_return ;
@@ -268,9 +268,9 @@ makePGresult(PGconn* conn, char* pname)
268268int adtid ;
269269int adtsize ;
270270
271- if (pqGets (typName ,MAX_MESSAGE_LEN ,pfin ,Pfdebug )||
272- pqGetInt (& adtid ,4 ,pfin ,Pfdebug )||
273- pqGetInt (& adtsize ,2 ,pfin ,Pfdebug )) {
271+ if (pqGets (typName ,MAX_MESSAGE_LEN ,pfin ,pfdebug )||
272+ pqGetInt (& adtid ,4 ,pfin ,pfdebug )||
273+ pqGetInt (& adtsize ,2 ,pfin ,pfdebug )) {
274274sprintf (conn -> errorMessage ,
275275"error reading type information from the 'T' message\n" );
276276 gotomakePGresult_badResponse_return ;
@@ -281,7 +281,7 @@ makePGresult(PGconn* conn, char* pname)
281281result -> attDescs [i ].adtsize = adtsize ;/* casting from int to int2 here */
282282 }
283283
284- id = pqGetc (pfin ,Pfdebug );
284+ id = pqGetc (pfin ,pfdebug );
285285
286286/* process the data stream until we're finished */
287287while (!done ) {
@@ -306,20 +306,20 @@ makePGresult(PGconn* conn, char* pname)
306306case 'C' :/* end of portal tuple stream */
307307 {
308308char command [MAX_MESSAGE_LEN ];
309- pqGets (command ,MAX_MESSAGE_LEN ,pfin ,Pfdebug );/* read the command tag */
309+ pqGets (command ,MAX_MESSAGE_LEN ,pfin ,pfdebug );/* read the command tag */
310310done = 1 ;
311311 }
312312break ;
313313case 'E' :/* errors */
314- if (pqGets (conn -> errorMessage ,ERROR_MSG_LENGTH ,pfin ,Pfdebug )== 1 ) {
314+ if (pqGets (conn -> errorMessage ,ERROR_MSG_LENGTH ,pfin ,pfdebug )== 1 ) {
315315sprintf (conn -> errorMessage ,
316316"Error return detected from backend, but error message cannot be read" );
317317 }
318318result -> resultStatus = PGRES_FATAL_ERROR ;
319319return result ;
320320break ;
321321case 'N' :/* notices from the backend */
322- if (pqGets (conn -> errorMessage ,ERROR_MSG_LENGTH ,pfin ,Pfdebug )== 1 ) {
322+ if (pqGets (conn -> errorMessage ,ERROR_MSG_LENGTH ,pfin ,pfdebug )== 1 ) {
323323sprintf (conn -> errorMessage ,
324324"Notice return detected from backend, but error message cannot be read" );
325325 }else
@@ -370,7 +370,7 @@ PQexec(PGconn* conn, const char* query)
370370char cmdStatus [MAX_MESSAGE_LEN ];
371371char pname [MAX_MESSAGE_LEN ];/* portal name */
372372PGnotify * newNotify ;
373- FILE * pfin ,* pfout ,* Pfdebug ;
373+ FILE * pfin ,* pfout ,* pfdebug ;
374374
375375pname [0 ]= '\0' ;
376376
@@ -380,9 +380,9 @@ PQexec(PGconn* conn, const char* query)
380380return NULL ;
381381 }
382382
383- Pfin = conn -> Pfin ;
384- Pfout = conn -> Pfout ;
385- Pfdebug = conn -> Pfdebug ;
383+ pfin = conn -> Pfin ;
384+ pfout = conn -> Pfout ;
385+ pfdebug = conn -> Pfdebug ;
386386
387387/*clear the error string */
388388conn -> errorMessage [0 ]= '\0' ;
@@ -397,7 +397,7 @@ PQexec(PGconn* conn, const char* query)
397397sprintf (buffer ,"Q%s" ,query );
398398
399399/* send the query to the backend; */
400- if (pqPuts (buffer ,pfout ,Pfdebug )== 1 ) {
400+ if (pqPuts (buffer ,pfout ,pfdebug )== 1 ) {
401401 (void )sprintf (conn -> errorMessage ,
402402"PQexec() -- while sending query: %s\n-- fprintf to Pfout failed: errno=%d\n%s\n" ,
403403query ,errno ,strerror (errno ));
@@ -412,7 +412,7 @@ PQexec(PGconn* conn, const char* query)
412412while (1 ) {
413413
414414/* read the result id */
415- id = pqGetc (pfin ,Pfdebug );
415+ id = pqGetc (pfin ,pfdebug );
416416if (id == EOF ) {
417417/* hmm, no response from the backend-end, that's bad */
418418 (void )sprintf (conn -> errorMessage ,
@@ -423,14 +423,14 @@ PQexec(PGconn* conn, const char* query)
423423switch (id ) {
424424case 'A' :
425425newNotify = (PGnotify * )malloc (sizeof (PGnotify ));
426- pqGetInt (& (newNotify -> be_pid ),4 ,pfin ,Pfdebug );
427- pqGets (newNotify -> relname ,NAMEDATALEN ,pfin ,Pfdebug );
426+ pqGetInt (& (newNotify -> be_pid ),4 ,pfin ,pfdebug );
427+ pqGets (newNotify -> relname ,NAMEDATALEN ,pfin ,pfdebug );
428428DLAddTail (conn -> notifyList ,DLNewElem (newNotify ));
429429/* async messages are piggy'ed back on other messages,
430430 so we stay in the while loop for other messages */
431431break ;
432432case 'C' :/* portal query command, no tuples returned */
433- if (pqGets (cmdStatus ,MAX_MESSAGE_LEN ,pfin ,Pfdebug )== 1 ) {
433+ if (pqGets (cmdStatus ,MAX_MESSAGE_LEN ,pfin ,pfdebug )== 1 ) {
434434sprintf (conn -> errorMessage ,
435435"PQexec() -- query command completed, but return message from backend cannot be read" );
436436return (PGresult * )NULL ;
@@ -444,10 +444,10 @@ PQexec(PGconn* conn, const char* query)
444444*/
445445clear = 0 ;
446446
447- pqPuts ("Q " ,pfout ,Pfdebug );/* send an empty query */
447+ pqPuts ("Q " ,pfout ,pfdebug );/* send an empty query */
448448while (!clear )
449449 {
450- if (pqGets (buffer ,ERROR_MSG_LENGTH ,pfin ,Pfdebug )== 1 )
450+ if (pqGets (buffer ,ERROR_MSG_LENGTH ,pfin ,pfdebug )== 1 )
451451clear = 1 ;
452452clear = (buffer [0 ]== 'I' );
453453 }
@@ -457,7 +457,7 @@ PQexec(PGconn* conn, const char* query)
457457 }
458458break ;
459459case 'E' :/* error return */
460- if (pqGets (conn -> errorMessage ,ERROR_MSG_LENGTH ,pfin ,Pfdebug )== 1 ) {
460+ if (pqGets (conn -> errorMessage ,ERROR_MSG_LENGTH ,pfin ,pfdebug )== 1 ) {
461461(void )sprintf (conn -> errorMessage ,
462462"PQexec() -- error return detected from backend, but error message cannot be read" );
463463 }
@@ -467,15 +467,15 @@ PQexec(PGconn* conn, const char* query)
467467/* read the throw away the closing '\0' */
468468 {
469469int c ;
470- if ((c = pqGetc (pfin ,Pfdebug ))!= '\0' ) {
470+ if ((c = pqGetc (pfin ,pfdebug ))!= '\0' ) {
471471fprintf (stderr ,"error!, unexpected character %c following 'I'\n" ,c );
472472}
473473result = makeEmptyPGresult (conn ,PGRES_EMPTY_QUERY );
474474return result ;
475475 }
476476break ;
477477case 'N' :/* notices from the backend */
478- if (pqGets (conn -> errorMessage ,ERROR_MSG_LENGTH ,pfin ,Pfdebug )== 1 ) {
478+ if (pqGets (conn -> errorMessage ,ERROR_MSG_LENGTH ,pfin ,pfdebug )== 1 ) {
479479sprintf (conn -> errorMessage ,
480480"PQexec() -- error return detected from backend, but error message cannot be read" );
481481return (PGresult * )NULL ;
@@ -484,7 +484,7 @@ PQexec(PGconn* conn, const char* query)
484484fprintf (stderr ,"%s" ,conn -> errorMessage );
485485break ;
486486case 'P' :/* synchronous (normal) portal */
487- pqGets (pname ,MAX_MESSAGE_LEN ,pfin ,Pfdebug );/* read in the portal name*/
487+ pqGets (pname ,MAX_MESSAGE_LEN ,pfin ,pfdebug );/* read in the portal name*/
488488break ;
489489case 'T' :/* actual tuple results: */
490490return makePGresult (conn ,pname );
@@ -605,21 +605,21 @@ int
605605PQendcopy (PGconn * conn )
606606{
607607char id ;
608- FILE * pfin ,* Pfdebug ;
608+ FILE * pfin ,* pfdebug ;
609609
610610if (!conn )return (int )NULL ;
611611
612- Pfin = conn -> Pfin ;
613- Pfdebug = conn -> Pfdebug ;
612+ pfin = conn -> Pfin ;
613+ pfdebug = conn -> Pfdebug ;
614614
615- if ( (id = pqGetc (pfin ,Pfdebug ))> 0 )
615+ if ( (id = pqGetc (pfin ,pfdebug ))> 0 )
616616return (0 );
617617switch (id ) {
618618case 'Z' :/* backend finished the copy */
619619return (1 );
620620case 'E' :
621621case 'N' :
622- if (pqGets (conn -> errorMessage ,ERROR_MSG_LENGTH ,pfin ,Pfdebug )== 1 ) {
622+ if (pqGets (conn -> errorMessage ,ERROR_MSG_LENGTH ,pfin ,pfdebug )== 1 ) {
623623sprintf (conn -> errorMessage ,
624624"Error return detected from backend, but error message cannot be read" );
625625}
@@ -1197,65 +1197,65 @@ PQfn(PGconn *conn,
11971197PQArgBlock * args ,
11981198int nargs )
11991199{
1200- FILE * pfin ,* pfout ,* Pfdebug ;
1200+ FILE * pfin ,* pfout ,* pfdebug ;
12011201int id ;
12021202int i ;
12031203
12041204if (!conn )return NULL ;
12051205
1206- Pfin = conn -> Pfin ;
1207- Pfout = conn -> Pfout ;
1208- Pfdebug = conn -> Pfdebug ;
1206+ pfin = conn -> Pfin ;
1207+ pfout = conn -> Pfout ;
1208+ pfdebug = conn -> Pfdebug ;
12091209
12101210/* clear the error string */
12111211conn -> errorMessage [0 ]= '\0' ;
12121212
1213- pqPuts ("F " ,pfout ,Pfdebug );/* function */
1214- pqPutInt (fnid ,4 ,pfout ,Pfdebug );/* function id */
1215- pqPutInt (nargs ,4 ,pfout ,Pfdebug );/*# of args */
1213+ pqPuts ("F " ,pfout ,pfdebug );/* function */
1214+ pqPutInt (fnid ,4 ,pfout ,pfdebug );/* function id */
1215+ pqPutInt (nargs ,4 ,pfout ,pfdebug );/*# of args */
12161216
12171217for (i = 0 ;i < nargs ;++ i ) {/*len.int4 + contents*/
1218- pqPutInt (args [i ].len ,4 ,pfout ,Pfdebug );
1218+ pqPutInt (args [i ].len ,4 ,pfout ,pfdebug );
12191219if (args [i ].isint ) {
1220- pqPutInt (args [i ].u .integer ,4 ,pfout ,Pfdebug );
1220+ pqPutInt (args [i ].u .integer ,4 ,pfout ,pfdebug );
12211221}else {
1222- pqPutnchar ((char * )args [i ].u .ptr ,args [i ].len ,pfout ,Pfdebug );
1222+ pqPutnchar ((char * )args [i ].u .ptr ,args [i ].len ,pfout ,pfdebug );
12231223}
12241224 }
1225- pqFlush (pfout ,Pfdebug );
1225+ pqFlush (pfout ,pfdebug );
12261226
1227- id = pqGetc (pfin ,Pfdebug );
1227+ id = pqGetc (pfin ,pfdebug );
12281228if (id != 'V' ) {
12291229if (id == 'E' ) {
1230- pqGets (conn -> errorMessage ,ERROR_MSG_LENGTH ,pfin ,Pfdebug );
1230+ pqGets (conn -> errorMessage ,ERROR_MSG_LENGTH ,pfin ,pfdebug );
12311231}else
12321232sprintf (conn -> errorMessage ,
12331233"PQfn: expected a 'V' from the backend. Got '%c' instead" ,
12341234id );
12351235return makeEmptyPGresult (conn ,PGRES_FATAL_ERROR );
12361236 }
12371237
1238- id = pqGetc (pfin ,Pfdebug );
1238+ id = pqGetc (pfin ,pfdebug );
12391239for (;;) {
12401240int c ;
12411241switch (id ) {
12421242case 'G' :/* function returned properly */
1243- pqGetInt (actual_result_len ,4 ,pfin ,Pfdebug );
1243+ pqGetInt (actual_result_len ,4 ,pfin ,pfdebug );
12441244if (result_is_int ) {
1245- pqGetInt (result_buf ,4 ,pfin ,Pfdebug );
1245+ pqGetInt (result_buf ,4 ,pfin ,pfdebug );
12461246 }else {
12471247pqGetnchar ((char * )result_buf ,* actual_result_len ,
1248- pfin ,Pfdebug );
1248+ pfin ,pfdebug );
12491249 }
1250- c = pqGetc (pfin ,Pfdebug );/* get the last '0'*/
1250+ c = pqGetc (pfin ,pfdebug );/* get the last '0'*/
12511251return makeEmptyPGresult (conn ,PGRES_COMMAND_OK );
12521252case 'E' :
12531253sprintf (conn -> errorMessage ,
12541254"PQfn: returned an error" );
12551255return makeEmptyPGresult (conn ,PGRES_FATAL_ERROR );
12561256case 'N' :
12571257/* print notice and go back to processing return values */
1258- if (pqGets (conn -> errorMessage ,ERROR_MSG_LENGTH ,pfin ,Pfdebug )== 1 ) {
1258+ if (pqGets (conn -> errorMessage ,ERROR_MSG_LENGTH ,pfin ,pfdebug )== 1 ) {
12591259sprintf (conn -> errorMessage ,
12601260"Notice return detected from backend, but error message cannot be read" );
12611261 }else