Summary:
The function `YBCBuildNonNullUniqueIndexYBTupleId` constructs a tuple ID for a given index tuple.
This function uses as input an array of values that correspond to the columns making up the index.
The supplied index may be a unique secondary index or a primary key.
In YugabyteDB, since the main table is clustered on the primary key, the primary key reuses the attribute numbers of the table.
Secondary indexes use sequential attribute numbers that go from [1 ... n] where 'n' is the number of columns making up the index.
A concrete example:
```
CREATE TABLE foo (a int, b int, c int, PRIMARY KEY (c, a));
CREATE UNIQUE INDEX ON foo (c, a);
The primary key will have the following attribute numbers: [c -> 3, a -> 1]
The secondary index will have the following attribute numbers: [c -> 1, a -> 2]
```
The function `YBCBuildNonNullUniqueIndexYBTupleId` produced incorrect results when the supplied index:
1. Was a primary key
2. Defined columns in an order that is different from the main table.
This was because the function incorrectly mapped the columns in the following order:
```
[a -> 1, c -> 3] rather than [c -> 3, a -> 1]
```
This revision fixes the above issue by constructing the column -> attribute number mapping in the order in which the columns were defined in the primary key.
Jira: DB-14200
Test Plan:
Run the following test:
```
./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressInsertOnConflict#schedule'
./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressInsertOnConflictBatch2#schedule'
```
Reviewers: aagrawal, jason
Reviewed By: aagrawal
Subscribers: yql, smishra
Tags: #jenkins-ready
Differential Revision: https://phorge.dev.yugabyte.com/D40504