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)
131131 int bitcnt = 0 ; /* number of bits examined in current byte */
132132 int vlen ; /* length of the current field value */
133133 FILE * pfin = conn -> Pfin ;
134- FILE * Pfdebug = conn -> Pfdebug ;
134+ FILE * pfdebug = conn -> Pfdebug ;
135135
136136 PGresAttValue * tup ;
137137
@@ -145,7 +145,7 @@ getTuple(PGconn *conn, PGresult* result, int binary)
145145 if ( (nfields % BYTELEN ) > 0 )
146146 nbytes ++ ;
147147
148- if (pqGetnchar (bitmap , nbytes , pfin , Pfdebug ) == 1 ){
148+ if (pqGetnchar (bitmap , nbytes , pfin , pfdebug ) == 1 ){
149149 sprintf (conn -> errorMessage ,
150150 "Error reading null-values bitmap from tuple data stream\n" );
151151 return NULL ;
@@ -164,7 +164,7 @@ getTuple(PGconn *conn, PGresult* result, int binary)
164164 }
165165 else {
166166 /* get the value length (the first four bytes are for length) */
167- pqGetInt (& vlen , VARHDRSZ , pfin , Pfdebug );
167+ pqGetInt (& vlen , VARHDRSZ , pfin , pfdebug );
168168 if (binary == 0 ) {
169169 vlen = vlen - VARHDRSZ ;
170170 }
@@ -174,7 +174,7 @@ getTuple(PGconn *conn, PGresult* result, int binary)
174174 tup [i ].value = (char * ) malloc (vlen + 1 );
175175 /* read in the value; */
176176 if (vlen > 0 )
177- pqGetnchar ((char * )(tup [i ].value ), vlen , pfin , Pfdebug );
177+ pqGetnchar ((char * )(tup [i ].value ), vlen , pfin , pfdebug );
178178 tup [i ].value [vlen ] = '\0' ;
179179 }
180180 /* get the appropriate bitmap */
@@ -241,15 +241,15 @@ makePGresult(PGconn* conn, char* pname)
241241 PGresAttValue * newTup ;
242242
243243 FILE * pfin = conn -> Pfin ;
244- FILE * Pfdebug = conn -> Pfdebug ;
244+ FILE * pfdebug = conn -> Pfdebug ;
245245
246246 result = 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 ) {
253253 sprintf (conn -> errorMessage ,
254254 "could not get the number of fields from the 'T' message\n" );
255255 goto makePGresult_badResponse_return ;
@@ -268,9 +268,9 @@ makePGresult(PGconn* conn, char* pname)
268268 int adtid ;
269269 int 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 )) {
274274 sprintf (conn -> errorMessage ,
275275 "error reading type information from the 'T' message\n" );
276276 goto makePGresult_badResponse_return ;
@@ -281,7 +281,7 @@ makePGresult(PGconn* conn, char* pname)
281281 result -> 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 */
287287 while (!done ) {
@@ -306,20 +306,20 @@ makePGresult(PGconn* conn, char* pname)
306306 case 'C' : /* end of portal tuple stream */
307307 {
308308 char 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 */
310310 done = 1 ;
311311 }
312312 break ;
313313 case 'E' : /* errors */
314- if (pqGets (conn -> errorMessage , ERROR_MSG_LENGTH , pfin , Pfdebug ) == 1 ) {
314+ if (pqGets (conn -> errorMessage , ERROR_MSG_LENGTH , pfin , pfdebug ) == 1 ) {
315315 sprintf (conn -> errorMessage ,
316316 "Error return detected from backend, but error message cannot be read" );
317317 }
318318 result -> resultStatus = PGRES_FATAL_ERROR ;
319319 return result ;
320320 break ;
321321 case '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 ) {
323323 sprintf (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)
370370 char cmdStatus [MAX_MESSAGE_LEN ];
371371 char pname [MAX_MESSAGE_LEN ]; /* portal name */
372372 PGnotify * newNotify ;
373- FILE * pfin , * pfout , * Pfdebug ;
373+ FILE * pfin , * pfout , * pfdebug ;
374374
375375 pname [0 ]= '\0' ;
376376
@@ -380,9 +380,9 @@ PQexec(PGconn* conn, const char* query)
380380 return 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 */
388388 conn -> errorMessage [0 ] = '\0' ;
@@ -397,7 +397,7 @@ PQexec(PGconn* conn, const char* query)
397397 sprintf (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" ,
403403 query , errno ,strerror (errno ));
@@ -412,7 +412,7 @@ PQexec(PGconn* conn, const char* query)
412412 while (1 ) {
413413
414414 /* read the result id */
415- id = pqGetc (pfin ,Pfdebug );
415+ id = pqGetc (pfin ,pfdebug );
416416 if (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)
423423 switch (id ) {
424424 case 'A' :
425425 newNotify = (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 );
428428 DLAddTail (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 */
431431 break ;
432432 case '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 ) {
434434 sprintf (conn -> errorMessage ,
435435 "PQexec() -- query command completed, but return message from backend cannot be read" );
436436 return (PGresult * )NULL ;
@@ -444,10 +444,10 @@ PQexec(PGconn* conn, const char* query)
444444 */
445445 clear = 0 ;
446446
447- pqPuts ("Q " ,pfout ,Pfdebug ); /* send an empty query */
447+ pqPuts ("Q " ,pfout ,pfdebug ); /* send an empty query */
448448 while (!clear )
449449 {
450- if (pqGets (buffer ,ERROR_MSG_LENGTH ,pfin ,Pfdebug ) == 1 )
450+ if (pqGets (buffer ,ERROR_MSG_LENGTH ,pfin ,pfdebug ) == 1 )
451451 clear = 1 ;
452452 clear = (buffer [0 ] == 'I' );
453453 }
@@ -457,7 +457,7 @@ PQexec(PGconn* conn, const char* query)
457457 }
458458 break ;
459459 case '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 {
469469 int c ;
470- if ((c = pqGetc (pfin ,Pfdebug )) != '\0' ) {
470+ if ((c = pqGetc (pfin ,pfdebug )) != '\0' ) {
471471 fprintf (stderr ,"error!, unexpected character %c following 'I'\n" , c );
472472 }
473473 result = makeEmptyPGresult (conn , PGRES_EMPTY_QUERY );
474474 return result ;
475475 }
476476 break ;
477477 case '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 ) {
479479 sprintf (conn -> errorMessage ,
480480 "PQexec() -- error return detected from backend, but error message cannot be read" );
481481 return (PGresult * )NULL ;
@@ -484,7 +484,7 @@ PQexec(PGconn* conn, const char* query)
484484 fprintf (stderr ,"%s" , conn -> errorMessage );
485485 break ;
486486 case '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*/
488488 break ;
489489 case 'T' : /* actual tuple results: */
490490 return makePGresult (conn , pname );
@@ -605,21 +605,21 @@ int
605605PQendcopy (PGconn * conn )
606606{
607607 char id ;
608- FILE * pfin , * Pfdebug ;
608+ FILE * pfin , * pfdebug ;
609609
610610 if (!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 )
616616 return (0 );
617617 switch (id ) {
618618 case 'Z' : /* backend finished the copy */
619619 return (1 );
620620 case 'E' :
621621 case 'N' :
622- if (pqGets (conn -> errorMessage , ERROR_MSG_LENGTH , pfin , Pfdebug ) == 1 ) {
622+ if (pqGets (conn -> errorMessage , ERROR_MSG_LENGTH , pfin , pfdebug ) == 1 ) {
623623 sprintf (conn -> errorMessage ,
624624 "Error return detected from backend, but error message cannot be read" );
625625 }
@@ -1197,65 +1197,65 @@ PQfn(PGconn *conn,
11971197 PQArgBlock * args ,
11981198 int nargs )
11991199{
1200- FILE * pfin , * pfout , * Pfdebug ;
1200+ FILE * pfin , * pfout , * pfdebug ;
12011201 int id ;
12021202 int i ;
12031203
12041204 if (!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 */
12111211 conn -> 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
12171217 for (i = 0 ; i < nargs ; ++ i ) { /* len.int4 + contents */
1218- pqPutInt (args [i ].len , 4 , pfout , Pfdebug );
1218+ pqPutInt (args [i ].len , 4 , pfout , pfdebug );
12191219 if (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 );
12281228 if (id != 'V' ) {
12291229 if (id == 'E' ) {
1230- pqGets (conn -> errorMessage ,ERROR_MSG_LENGTH ,pfin ,Pfdebug );
1230+ pqGets (conn -> errorMessage ,ERROR_MSG_LENGTH ,pfin ,pfdebug );
12311231 } else
12321232 sprintf (conn -> errorMessage ,
12331233 "PQfn: expected a 'V' from the backend. Got '%c' instead" ,
12341234 id );
12351235 return makeEmptyPGresult (conn ,PGRES_FATAL_ERROR );
12361236 }
12371237
1238- id = pqGetc (pfin , Pfdebug );
1238+ id = pqGetc (pfin , pfdebug );
12391239 for (;;) {
12401240 int c ;
12411241 switch (id ) {
12421242 case 'G' : /* function returned properly */
1243- pqGetInt (actual_result_len ,4 ,pfin ,Pfdebug );
1243+ pqGetInt (actual_result_len ,4 ,pfin ,pfdebug );
12441244 if (result_is_int ) {
1245- pqGetInt (result_buf ,4 ,pfin ,Pfdebug );
1245+ pqGetInt (result_buf ,4 ,pfin ,pfdebug );
12461246 } else {
12471247 pqGetnchar ((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'*/
12511251 return makeEmptyPGresult (conn ,PGRES_COMMAND_OK );
12521252 case 'E' :
12531253 sprintf (conn -> errorMessage ,
12541254 "PQfn: returned an error" );
12551255 return makeEmptyPGresult (conn ,PGRES_FATAL_ERROR );
12561256 case '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 ) {
12591259 sprintf (conn -> errorMessage ,
12601260 "Notice return detected from backend, but error message cannot be read" );
12611261 } else
0 commit comments