@@ -340,7 +340,7 @@ jsonbd_get_key_id(Relation rel, Relation indrel, Oid cmoptoid, char *key)
340
340
/*
341
341
* Get key IDs using relation
342
342
*/
343
- static void
343
+ static bool
344
344
jsonbd_get_key_ids (Oid cmoptoid , char * buf , uint32 * idsbuf , int nkeys )
345
345
{
346
346
Relation rel = NULL ;
@@ -472,42 +472,35 @@ jsonbd_get_key_ids(Oid cmoptoid, char *buf, uint32 *idsbuf, int nkeys)
472
472
{
473
473
index_close (indrel , AccessShareLock );
474
474
relation_close (rel , AccessShareLock );
475
- finish_xact_command ();
476
475
}
477
476
478
- if (failed )
479
- elog (ERROR , "get key ids error" );
477
+ if (failed && xact_started )
478
+ AbortCurrentTransaction ();
479
+ else if (!failed )
480
+ finish_xact_command ();
481
+
482
+ return !failed ;
480
483
}
481
484
482
485
static char *
483
486
jsonbd_cmd_get_ids (int nkeys , Oid cmoptoid , char * buf , size_t * buflen )
484
487
{
488
+ bool ok ;
485
489
uint32 * idsbuf ;
486
490
MemoryContext old_mcxt = CurrentMemoryContext ;;
487
491
488
492
* buflen = nkeys * sizeof (uint32 );
489
493
idsbuf = (uint32 * ) palloc (* buflen );
490
-
491
- PG_TRY ();
494
+ ok = jsonbd_get_key_ids ( cmoptoid , buf , idsbuf , nkeys );
495
+ if (! ok )
492
496
{
493
- start_xact_command ();
494
- jsonbd_get_key_ids (cmoptoid , buf , idsbuf , nkeys );
495
- finish_xact_command ();
496
- }
497
- PG_CATCH ();
498
- {
499
- ErrorData * error ;
500
- MemoryContextSwitchTo (old_mcxt );
501
- error = CopyErrorData ();
502
- elog (LOG , "jsonbd: error occured: %s" , error -> message );
503
- FlushErrorState ();
504
- pfree (error );
497
+ elog (LOG , "jsonbd: cannot get ids" );
505
498
506
499
idsbuf [0 ] = 0 ;
507
500
* buflen = 1 ;
508
501
}
509
- PG_END_TRY ();
510
502
503
+ MemoryContextSwitchTo (old_mcxt );
511
504
return (char * ) idsbuf ;
512
505
}
513
506
0 commit comments