/*
 * MG_RETRY.pgc - mg 모듈 서비스 MG_RETRY (one service = one file).
 * Split out of the former inline mg_svr.pgc; runs on the caller's XA
 * branch (no EXEC SQL CONNECT). Advertised by mg_svr at tpsvrinit.
 */
#include "MG_RETRY.h"

/* 26. MG_RETRY - 큐 재시도: retry_cnt +1, status=Q. */
void MG_RETRY(TPSVCINFO *p)
{
    UBFH *b = (UBFH *)p->data;
    EXEC SQL BEGIN DECLARE SECTION;
    long h_qid, h_retry;
    EXEC SQL END DECLARE SECTION;
    h_qid = getl(b, T_ID2);
    EXEC SQL UPDATE mg_queue SET retry_cnt = retry_cnt + 1, status = 'Q', updated_at = now()
        WHERE queue_id = :h_qid;
    if (sqlca.sqlcode < 0 || sqlca.sqlcode == 100) FAIL(b);
    EXEC SQL SELECT retry_cnt INTO :h_retry FROM mg_queue WHERE queue_id = :h_qid;
    if (sqlca.sqlcode < 0 || sqlca.sqlcode == 100) FAIL(b);
    setl(b, T_COUNT, h_retry);
    OK(b);
}
