@@ -209,16 +209,6 @@ worker_main(Datum main_arg)
209
209
SPI_connect ();
210
210
211
211
{
212
- int argCount = 2 ;
213
- Oid argTypes [2 ];
214
- Datum argValues [2 ];
215
-
216
- argTypes [0 ] = INTERVALOID ;
217
- argValues [0 ] = DirectFunctionCall3 (interval_in , CStringGetDatum (ttl ), ObjectIdGetDatum (InvalidOid ), Int32GetDatum (-1 ));
218
-
219
- argTypes [1 ] = INT4OID ;
220
- argValues [1 ] = Int32GetDatum (batch_size );
221
-
222
212
int ttl_query_rc = SPI_execute_with_args ("\
223
213
WITH\
224
214
rows AS (\
@@ -230,7 +220,12 @@ worker_main(Datum main_arg)
230
220
)\
231
221
DELETE FROM net._http_response r\
232
222
USING rows WHERE r.ctid = rows.ctid" ,
233
- argCount , argTypes , argValues , NULL , false, 0 );
223
+ 2 ,
224
+ (Oid []){INTERVALOID , INT4OID },
225
+ (Datum []){
226
+ DirectFunctionCall3 (interval_in , CStringGetDatum (ttl ), ObjectIdGetDatum (InvalidOid ), Int32GetDatum (-1 ))
227
+ , Int32GetDatum (batch_size )
228
+ }, NULL , false, 0 );
234
229
235
230
if (ttl_query_rc != SPI_OK_DELETE )
236
231
{
@@ -239,13 +234,6 @@ worker_main(Datum main_arg)
239
234
}
240
235
241
236
{
242
- int argCount = 1 ;
243
- Oid argTypes [1 ];
244
- Datum argValues [1 ];
245
-
246
- argTypes [0 ] = INT4OID ;
247
- argValues [0 ] = Int32GetDatum (batch_size );
248
-
249
237
int queue_query_rc = SPI_execute_with_args ("\
250
238
WITH\
251
239
rows AS (\
@@ -257,7 +245,10 @@ worker_main(Datum main_arg)
257
245
DELETE FROM net.http_request_queue q\
258
246
USING rows WHERE q.id = rows.id\
259
247
RETURNING q.id, q.method, q.url, timeout_milliseconds, array(select key || ': ' || value from jsonb_each_text(q.headers)), q.body" ,
260
- argCount , argTypes , argValues , NULL , false, 0 );
248
+ 1 ,
249
+ (Oid []){INT4OID },
250
+ (Datum []){Int32GetDatum (batch_size )},
251
+ NULL , false, 0 );
261
252
262
253
if (queue_query_rc == SPI_OK_DELETE_RETURNING )
263
254
{
@@ -337,75 +328,49 @@ worker_main(Datum main_arg)
337
328
eh = msg -> easy_handle ;
338
329
339
330
if (return_code != CURLE_OK ) {
340
- int argCount = 2 ;
341
- Oid argTypes [2 ];
342
- Datum argValues [2 ];
343
- const char * error_msg = curl_easy_strerror (return_code );
344
331
CurlData * cdata = NULL ;
345
332
346
333
curl_easy_getinfo (eh , CURLINFO_PRIVATE , & cdata );
347
334
348
- argTypes [0 ] = INT8OID ;
349
- argValues [0 ] = Int64GetDatum (cdata -> id );
350
-
351
- argTypes [1 ] = CSTRINGOID ;
352
- argValues [1 ] = CStringGetDatum (error_msg );
353
-
354
- int failed_query_rc = SPI_execute_with_args ("\
335
+ int failed_query_rc = SPI_execute_with_args ("\
355
336
insert into net._http_response(id, error_msg) values ($1, $2)" ,
356
- argCount , argTypes , argValues , NULL , false, 1 );
337
+ 2 ,
338
+ (Oid []){INT8OID , CSTRINGOID },
339
+ (Datum []){Int64GetDatum (cdata -> id ), CStringGetDatum (curl_easy_strerror (return_code ))},
340
+ NULL , false, 1 );
357
341
358
342
if (failed_query_rc != SPI_OK_INSERT )
359
343
{
360
344
ereport (ERROR , errmsg ("Error when inserting failed response: %s" , SPI_result_code_string (failed_query_rc )));
361
345
}
362
346
} else {
363
- int argCount = 6 ;
364
- Oid argTypes [6 ];
365
- Datum argValues [6 ];
366
- char nulls [6 ];
367
347
CurlData * cdata = NULL ;
368
348
char * contentType = NULL ;
369
- bool timedOut = false;
370
349
int http_status_code ;
371
350
372
351
curl_easy_getinfo (eh , CURLINFO_RESPONSE_CODE , & http_status_code );
373
352
curl_easy_getinfo (eh , CURLINFO_CONTENT_TYPE , & contentType );
374
353
curl_easy_getinfo (eh , CURLINFO_PRIVATE , & cdata );
375
354
376
- argTypes [0 ] = INT8OID ;
377
- argValues [0 ] = Int64GetDatum (cdata -> id );
378
- nulls [0 ] = ' ' ;
379
-
380
- argTypes [1 ] = INT4OID ;
381
- argValues [1 ] = Int32GetDatum (http_status_code );
382
- nulls [1 ] = ' ' ;
383
-
384
- argTypes [2 ] = CSTRINGOID ;
385
- argValues [2 ] = CStringGetDatum (cdata -> body -> data );
386
- if (cdata -> body -> data [0 ] == '\0' )
387
- nulls [2 ] = 'n' ;
388
- else
389
- nulls [2 ] = ' ' ;
390
-
391
- argTypes [3 ] = JSONBOID ;
392
- argValues [3 ] = JsonbPGetDatum (JsonbValueToJsonb (pushJsonbValue (& cdata -> response_headers , WJB_END_OBJECT , NULL )));
393
- nulls [3 ] = ' ' ;
394
-
395
- argTypes [4 ] = CSTRINGOID ;
396
- argValues [4 ] = CStringGetDatum (contentType );
397
- if (!contentType )
398
- nulls [4 ] = 'n' ;
399
- else
400
- nulls [4 ] = ' ' ;
401
-
402
- argTypes [5 ] = BOOLOID ;
403
- argValues [5 ] = BoolGetDatum (timedOut );
404
- nulls [5 ] = ' ' ;
405
-
406
355
int succ_query_rc = SPI_execute_with_args ("\
407
356
insert into net._http_response(id, status_code, content, headers, content_type, timed_out) values ($1, $2, $3, $4, $5, $6)" ,
408
- argCount , argTypes , argValues , nulls , false, 1 );
357
+ 6 ,
358
+ (Oid []){INT8OID , INT4OID , CSTRINGOID , JSONBOID , CSTRINGOID , BOOLOID },
359
+ (Datum []){
360
+ Int64GetDatum (cdata -> id )
361
+ , Int32GetDatum (http_status_code )
362
+ , CStringGetDatum (cdata -> body -> data )
363
+ , JsonbPGetDatum (JsonbValueToJsonb (pushJsonbValue (& cdata -> response_headers , WJB_END_OBJECT , NULL )))
364
+ , CStringGetDatum (contentType )
365
+ // TODO Why is this hardcoded?
366
+ , BoolGetDatum (false)
367
+ },
368
+ (char [6 ]){
369
+ ' '
370
+ , [2 ] = cdata -> body -> data [0 ] == '\0' ? 'n' : ' '
371
+ , [4 ] = !contentType ? 'n' :' '
372
+ },
373
+ false, 1 );
409
374
410
375
if ( succ_query_rc != SPI_OK_INSERT )
411
376
{
0 commit comments