7
7
*
8
8
*
9
9
* 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 $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
@@ -131,7 +131,7 @@ getTuple(PGconn *conn, PGresult* result, int binary)
131
131
int bitcnt = 0 ; /* number of bits examined in current byte */
132
132
int vlen ; /* length of the current field value */
133
133
FILE * pfin = conn -> Pfin ;
134
- FILE * Pfdebug = conn -> Pfdebug ;
134
+ FILE * pfdebug = conn -> Pfdebug ;
135
135
136
136
PGresAttValue * tup ;
137
137
@@ -145,7 +145,7 @@ getTuple(PGconn *conn, PGresult* result, int binary)
145
145
if ( (nfields % BYTELEN ) > 0 )
146
146
nbytes ++ ;
147
147
148
- if (pqGetnchar (bitmap , nbytes , pfin , Pfdebug ) == 1 ){
148
+ if (pqGetnchar (bitmap , nbytes , pfin , pfdebug ) == 1 ){
149
149
sprintf (conn -> errorMessage ,
150
150
"Error reading null-values bitmap from tuple data stream\n" );
151
151
return NULL ;
@@ -164,7 +164,7 @@ getTuple(PGconn *conn, PGresult* result, int binary)
164
164
}
165
165
else {
166
166
/* get the value length (the first four bytes are for length) */
167
- pqGetInt (& vlen , VARHDRSZ , pfin , Pfdebug );
167
+ pqGetInt (& vlen , VARHDRSZ , pfin , pfdebug );
168
168
if (binary == 0 ) {
169
169
vlen = vlen - VARHDRSZ ;
170
170
}
@@ -174,7 +174,7 @@ getTuple(PGconn *conn, PGresult* result, int binary)
174
174
tup [i ].value = (char * ) malloc (vlen + 1 );
175
175
/* read in the value; */
176
176
if (vlen > 0 )
177
- pqGetnchar ((char * )(tup [i ].value ), vlen , pfin , Pfdebug );
177
+ pqGetnchar ((char * )(tup [i ].value ), vlen , pfin , pfdebug );
178
178
tup [i ].value [vlen ] = '\0' ;
179
179
}
180
180
/* get the appropriate bitmap */
@@ -241,15 +241,15 @@ makePGresult(PGconn* conn, char* pname)
241
241
PGresAttValue * newTup ;
242
242
243
243
FILE * pfin = conn -> Pfin ;
244
- FILE * Pfdebug = conn -> Pfdebug ;
244
+ FILE * pfdebug = conn -> Pfdebug ;
245
245
246
246
result = makeEmptyPGresult (conn , PGRES_TUPLES_OK );
247
247
248
248
/* makePGresult() should only be called when the */
249
249
/* id of the stream is 'T' to start with */
250
250
251
251
/* 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 ) {
253
253
sprintf (conn -> errorMessage ,
254
254
"could not get the number of fields from the 'T' message\n" );
255
255
goto makePGresult_badResponse_return ;
@@ -268,9 +268,9 @@ makePGresult(PGconn* conn, char* pname)
268
268
int adtid ;
269
269
int adtsize ;
270
270
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 )) {
274
274
sprintf (conn -> errorMessage ,
275
275
"error reading type information from the 'T' message\n" );
276
276
goto makePGresult_badResponse_return ;
@@ -281,7 +281,7 @@ makePGresult(PGconn* conn, char* pname)
281
281
result -> attDescs [i ].adtsize = adtsize ; /* casting from int to int2 here */
282
282
}
283
283
284
- id = pqGetc (pfin ,Pfdebug );
284
+ id = pqGetc (pfin ,pfdebug );
285
285
286
286
/* process the data stream until we're finished */
287
287
while (!done ) {
@@ -306,20 +306,20 @@ makePGresult(PGconn* conn, char* pname)
306
306
case 'C' : /* end of portal tuple stream */
307
307
{
308
308
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 */
310
310
done = 1 ;
311
311
}
312
312
break ;
313
313
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 ) {
315
315
sprintf (conn -> errorMessage ,
316
316
"Error return detected from backend, but error message cannot be read" );
317
317
}
318
318
result -> resultStatus = PGRES_FATAL_ERROR ;
319
319
return result ;
320
320
break ;
321
321
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 ) {
323
323
sprintf (conn -> errorMessage ,
324
324
"Notice return detected from backend, but error message cannot be read" );
325
325
} else
@@ -370,7 +370,7 @@ PQexec(PGconn* conn, const char* query)
370
370
char cmdStatus [MAX_MESSAGE_LEN ];
371
371
char pname [MAX_MESSAGE_LEN ]; /* portal name */
372
372
PGnotify * newNotify ;
373
- FILE * pfin , * pfout , * Pfdebug ;
373
+ FILE * pfin , * pfout , * pfdebug ;
374
374
375
375
pname [0 ]= '\0' ;
376
376
@@ -380,9 +380,9 @@ PQexec(PGconn* conn, const char* query)
380
380
return NULL ;
381
381
}
382
382
383
- Pfin = conn -> Pfin ;
384
- Pfout = conn -> Pfout ;
385
- Pfdebug = conn -> Pfdebug ;
383
+ pfin = conn -> Pfin ;
384
+ pfout = conn -> Pfout ;
385
+ pfdebug = conn -> Pfdebug ;
386
386
387
387
/*clear the error string */
388
388
conn -> errorMessage [0 ] = '\0' ;
@@ -397,7 +397,7 @@ PQexec(PGconn* conn, const char* query)
397
397
sprintf (buffer ,"Q%s" ,query );
398
398
399
399
/* send the query to the backend; */
400
- if (pqPuts (buffer ,pfout , Pfdebug ) == 1 ) {
400
+ if (pqPuts (buffer ,pfout , pfdebug ) == 1 ) {
401
401
(void ) sprintf (conn -> errorMessage ,
402
402
"PQexec() -- while sending query: %s\n-- fprintf to Pfout failed: errno=%d\n%s\n" ,
403
403
query , errno ,strerror (errno ));
@@ -412,7 +412,7 @@ PQexec(PGconn* conn, const char* query)
412
412
while (1 ) {
413
413
414
414
/* read the result id */
415
- id = pqGetc (pfin ,Pfdebug );
415
+ id = pqGetc (pfin ,pfdebug );
416
416
if (id == EOF ) {
417
417
/* hmm, no response from the backend-end, that's bad */
418
418
(void ) sprintf (conn -> errorMessage ,
@@ -423,14 +423,14 @@ PQexec(PGconn* conn, const char* query)
423
423
switch (id ) {
424
424
case 'A' :
425
425
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 );
428
428
DLAddTail (conn -> notifyList , DLNewElem (newNotify ));
429
429
/* async messages are piggy'ed back on other messages,
430
430
so we stay in the while loop for other messages */
431
431
break ;
432
432
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 ) {
434
434
sprintf (conn -> errorMessage ,
435
435
"PQexec() -- query command completed, but return message from backend cannot be read" );
436
436
return (PGresult * )NULL ;
@@ -444,10 +444,10 @@ PQexec(PGconn* conn, const char* query)
444
444
*/
445
445
clear = 0 ;
446
446
447
- pqPuts ("Q " ,pfout ,Pfdebug ); /* send an empty query */
447
+ pqPuts ("Q " ,pfout ,pfdebug ); /* send an empty query */
448
448
while (!clear )
449
449
{
450
- if (pqGets (buffer ,ERROR_MSG_LENGTH ,pfin ,Pfdebug ) == 1 )
450
+ if (pqGets (buffer ,ERROR_MSG_LENGTH ,pfin ,pfdebug ) == 1 )
451
451
clear = 1 ;
452
452
clear = (buffer [0 ] == 'I' );
453
453
}
@@ -457,7 +457,7 @@ PQexec(PGconn* conn, const char* query)
457
457
}
458
458
break ;
459
459
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 ) {
461
461
(void ) sprintf (conn -> errorMessage ,
462
462
"PQexec() -- error return detected from backend, but error message cannot be read" );
463
463
}
@@ -467,15 +467,15 @@ PQexec(PGconn* conn, const char* query)
467
467
/* read the throw away the closing '\0' */
468
468
{
469
469
int c ;
470
- if ((c = pqGetc (pfin ,Pfdebug )) != '\0' ) {
470
+ if ((c = pqGetc (pfin ,pfdebug )) != '\0' ) {
471
471
fprintf (stderr ,"error!, unexpected character %c following 'I'\n" , c );
472
472
}
473
473
result = makeEmptyPGresult (conn , PGRES_EMPTY_QUERY );
474
474
return result ;
475
475
}
476
476
break ;
477
477
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 ) {
479
479
sprintf (conn -> errorMessage ,
480
480
"PQexec() -- error return detected from backend, but error message cannot be read" );
481
481
return (PGresult * )NULL ;
@@ -484,7 +484,7 @@ PQexec(PGconn* conn, const char* query)
484
484
fprintf (stderr ,"%s" , conn -> errorMessage );
485
485
break ;
486
486
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*/
488
488
break ;
489
489
case 'T' : /* actual tuple results: */
490
490
return makePGresult (conn , pname );
@@ -605,21 +605,21 @@ int
605
605
PQendcopy (PGconn * conn )
606
606
{
607
607
char id ;
608
- FILE * pfin , * Pfdebug ;
608
+ FILE * pfin , * pfdebug ;
609
609
610
610
if (!conn ) return (int )NULL ;
611
611
612
- Pfin = conn -> Pfin ;
613
- Pfdebug = conn -> Pfdebug ;
612
+ pfin = conn -> Pfin ;
613
+ pfdebug = conn -> Pfdebug ;
614
614
615
- if ( (id = pqGetc (pfin ,Pfdebug )) > 0 )
615
+ if ( (id = pqGetc (pfin ,pfdebug )) > 0 )
616
616
return (0 );
617
617
switch (id ) {
618
618
case 'Z' : /* backend finished the copy */
619
619
return (1 );
620
620
case 'E' :
621
621
case 'N' :
622
- if (pqGets (conn -> errorMessage , ERROR_MSG_LENGTH , pfin , Pfdebug ) == 1 ) {
622
+ if (pqGets (conn -> errorMessage , ERROR_MSG_LENGTH , pfin , pfdebug ) == 1 ) {
623
623
sprintf (conn -> errorMessage ,
624
624
"Error return detected from backend, but error message cannot be read" );
625
625
}
@@ -1197,65 +1197,65 @@ PQfn(PGconn *conn,
1197
1197
PQArgBlock * args ,
1198
1198
int nargs )
1199
1199
{
1200
- FILE * pfin , * pfout , * Pfdebug ;
1200
+ FILE * pfin , * pfout , * pfdebug ;
1201
1201
int id ;
1202
1202
int i ;
1203
1203
1204
1204
if (!conn ) return NULL ;
1205
1205
1206
- Pfin = conn -> Pfin ;
1207
- Pfout = conn -> Pfout ;
1208
- Pfdebug = conn -> Pfdebug ;
1206
+ pfin = conn -> Pfin ;
1207
+ pfout = conn -> Pfout ;
1208
+ pfdebug = conn -> Pfdebug ;
1209
1209
1210
1210
/* clear the error string */
1211
1211
conn -> errorMessage [0 ] = '\0' ;
1212
1212
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 */
1216
1216
1217
1217
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 );
1219
1219
if (args [i ].isint ) {
1220
- pqPutInt (args [i ].u .integer , 4 , pfout , Pfdebug );
1220
+ pqPutInt (args [i ].u .integer , 4 , pfout , pfdebug );
1221
1221
} 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 );
1223
1223
}
1224
1224
}
1225
- pqFlush (pfout , Pfdebug );
1225
+ pqFlush (pfout , pfdebug );
1226
1226
1227
- id = pqGetc (pfin , Pfdebug );
1227
+ id = pqGetc (pfin , pfdebug );
1228
1228
if (id != 'V' ) {
1229
1229
if (id == 'E' ) {
1230
- pqGets (conn -> errorMessage ,ERROR_MSG_LENGTH ,pfin ,Pfdebug );
1230
+ pqGets (conn -> errorMessage ,ERROR_MSG_LENGTH ,pfin ,pfdebug );
1231
1231
} else
1232
1232
sprintf (conn -> errorMessage ,
1233
1233
"PQfn: expected a 'V' from the backend. Got '%c' instead" ,
1234
1234
id );
1235
1235
return makeEmptyPGresult (conn ,PGRES_FATAL_ERROR );
1236
1236
}
1237
1237
1238
- id = pqGetc (pfin , Pfdebug );
1238
+ id = pqGetc (pfin , pfdebug );
1239
1239
for (;;) {
1240
1240
int c ;
1241
1241
switch (id ) {
1242
1242
case 'G' : /* function returned properly */
1243
- pqGetInt (actual_result_len ,4 ,pfin ,Pfdebug );
1243
+ pqGetInt (actual_result_len ,4 ,pfin ,pfdebug );
1244
1244
if (result_is_int ) {
1245
- pqGetInt (result_buf ,4 ,pfin ,Pfdebug );
1245
+ pqGetInt (result_buf ,4 ,pfin ,pfdebug );
1246
1246
} else {
1247
1247
pqGetnchar ((char * ) result_buf , * actual_result_len ,
1248
- pfin , Pfdebug );
1248
+ pfin , pfdebug );
1249
1249
}
1250
- c = pqGetc (pfin , Pfdebug ); /* get the last '0'*/
1250
+ c = pqGetc (pfin , pfdebug ); /* get the last '0'*/
1251
1251
return makeEmptyPGresult (conn ,PGRES_COMMAND_OK );
1252
1252
case 'E' :
1253
1253
sprintf (conn -> errorMessage ,
1254
1254
"PQfn: returned an error" );
1255
1255
return makeEmptyPGresult (conn ,PGRES_FATAL_ERROR );
1256
1256
case 'N' :
1257
1257
/* 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 ) {
1259
1259
sprintf (conn -> errorMessage ,
1260
1260
"Notice return detected from backend, but error message cannot be read" );
1261
1261
} else
0 commit comments