Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f80969d

Browse files
committed
Bugfixes
1 parent fb0eaf3 commit f80969d

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

jsonbd_worker.c

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ jsonbd_get_key_id(Relation rel, Relation indrel, Oid cmoptoid, char *key)
340340
/*
341341
* Get key IDs using relation
342342
*/
343-
static void
343+
static bool
344344
jsonbd_get_key_ids(Oid cmoptoid, char *buf, uint32 *idsbuf, int nkeys)
345345
{
346346
Relation rel = NULL;
@@ -472,42 +472,35 @@ jsonbd_get_key_ids(Oid cmoptoid, char *buf, uint32 *idsbuf, int nkeys)
472472
{
473473
index_close(indrel, AccessShareLock);
474474
relation_close(rel, AccessShareLock);
475-
finish_xact_command();
476475
}
477476

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;
480483
}
481484

482485
static char *
483486
jsonbd_cmd_get_ids(int nkeys, Oid cmoptoid, char *buf, size_t *buflen)
484487
{
488+
bool ok;
485489
uint32 *idsbuf;
486490
MemoryContext old_mcxt = CurrentMemoryContext;;
487491

488492
*buflen = nkeys * sizeof(uint32);
489493
idsbuf = (uint32 *) palloc(*buflen);
490-
491-
PG_TRY();
494+
ok = jsonbd_get_key_ids(cmoptoid, buf, idsbuf, nkeys);
495+
if (!ok)
492496
{
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");
505498

506499
idsbuf[0] = 0;
507500
*buflen = 1;
508501
}
509-
PG_END_TRY();
510502

503+
MemoryContextSwitchTo(old_mcxt);
511504
return (char *) idsbuf;
512505
}
513506

0 commit comments

Comments
 (0)