Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
Fix mismatched types. (#17348)
Browse files Browse the repository at this point in the history
This patch fixes several type mismatching issues.

1. The DistributedTransactionId is of type uint64, we shouldn't cast it
   to TransactionId which is of type uint32.

2. The Cost is of type Float8, we should use Float8GetDatum to cast it
   to Datum.
  • Loading branch information
higuoxing authored May 20, 2024
1 parent 8c56dca commit 6fa4800
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/backend/access/transam/gp_distributed_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ gp_distributed_log(PG_FUNCTION_ARGS)

values[0] = Int16GetDatum((int16)GpIdentity.segindex);
values[1] = Int16GetDatum((int16)GpIdentity.dbid);
values[2] = TransactionIdGetDatum(distribXid);
values[2] = UInt64GetDatum(distribXid);

/*
* For now, we only log committed distributed transactions.
Expand Down
4 changes: 2 additions & 2 deletions src/backend/cdb/cdbdistributedxacts.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ gp_distributed_xacts__(PG_FUNCTION_ARGS)
MemSet(values, 0, sizeof(values));
MemSet(nulls, false, sizeof(nulls));

values[0] = TransactionIdGetDatum(distributedXactStatus->gxid);
values[0] = UInt64GetDatum(distributedXactStatus->gxid);
values[1] = CStringGetTextDatum(DtxStateToString(distributedXactStatus->state));

values[2] = UInt32GetDatum(distributedXactStatus->sessionId);
values[3] = TransactionIdGetDatum(distributedXactStatus->xminDistributedSnapshot);
values[3] = UInt64GetDatum(distributedXactStatus->xminDistributedSnapshot);

tuple = heap_form_tuple(funcctx->tuple_desc, values, nulls);
result = HeapTupleGetDatum(tuple);
Expand Down
3 changes: 1 addition & 2 deletions src/backend/cdb/cdbdistributedxid.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,5 @@ gp_distributed_xid(PG_FUNCTION_ARGS pg_attribute_unused())
{
DistributedTransactionId xid = getDistributedTransactionId();

PG_RETURN_XID(xid);

PG_RETURN_UINT64(xid);
}
10 changes: 5 additions & 5 deletions src/backend/commands/queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -899,10 +899,10 @@ CreateQueue(CreateQueueStmt *stmt)
DirectFunctionCall1(namein, CStringGetDatum(stmt->queue));

new_record[Anum_pg_resqueue_rsqcountlimit - 1] =
Float4GetDatum(activelimit);
Float8GetDatum(activelimit);

new_record[Anum_pg_resqueue_rsqcostlimit - 1] =
Float4GetDatum(costlimit);
Float8GetDatum(costlimit);

new_record[Anum_pg_resqueue_rsqovercommit - 1] =
BoolGetDatum(overcommit);
Expand All @@ -912,7 +912,7 @@ CreateQueue(CreateQueueStmt *stmt)

queueid = GetNewOidForResQueue(pg_resqueue_rel, ResQueueOidIndexId, Anum_pg_resqueue_oid,
stmt->queue);
new_record[Anum_pg_resqueue_oid - 1] = queueid;
new_record[Anum_pg_resqueue_oid - 1] = ObjectIdGetDatum(queueid);

tuple = heap_form_tuple(pg_resqueue_dsc, new_record, new_record_nulls);

Expand Down Expand Up @@ -1276,7 +1276,7 @@ AlterQueue(AlterQueueStmt *stmt)
if (dactivelimit)
{
new_record[Anum_pg_resqueue_rsqcountlimit - 1] =
Float4GetDatum(activelimit);
Float8GetDatum(activelimit);
new_record_repl[Anum_pg_resqueue_rsqcountlimit - 1] = true;

thresholds[RES_COUNT_LIMIT] = activelimit;
Expand All @@ -1286,7 +1286,7 @@ AlterQueue(AlterQueueStmt *stmt)
if (dcostlimit)
{
new_record[Anum_pg_resqueue_rsqcostlimit - 1] =
Float4GetDatum(costlimit);
Float8GetDatum(costlimit);
new_record_repl[Anum_pg_resqueue_rsqcostlimit - 1] = true;

thresholds[RES_COST_LIMIT] = costlimit;
Expand Down

0 comments on commit 6fa4800

Please sign in to comment.