Construct ctid string correctly for block no > 2^31.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 12 Nov 2013 20:35:56 +0000 (22:35 +0200)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 12 Nov 2013 20:35:56 +0000 (22:35 +0200)
Block number is unsigned. Other places where we construct ctid strings we
got this right, but not this one. I'm not sure how to trigger this codepath,
but I'm sure something funny would happen if you tried to use these functions
on large enough tables (> 16 TB).

results.c

index 056faaaffb878cc04cce71275efd2e8b7801280f..d53c5415c69d4b4d8ed4774a2064e5e728e6c68f 100644 (file)
--- a/results.c
+++ b/results.c
@@ -1989,7 +1989,7 @@ static void AddRollback(StatementClass *stmt, QResultClass *res, SQLLEN index, c
 
    if (!CC_is_in_trans(conn))
        return;
-inolog("AddRollback %d(%d,%d) %s\n", index, keyset->blocknum, keyset->offset, dmlcode == SQL_ADD ? "ADD" : (dmlcode == SQL_UPDATE ? "UPDATE" : (dmlcode == SQL_DELETE ? "DELETE" : "REFRESH")));
+inolog("AddRollback %d(%u,%u) %s\n", index, keyset->blocknum, keyset->offset, dmlcode == SQL_ADD ? "ADD" : (dmlcode == SQL_UPDATE ? "UPDATE" : (dmlcode == SQL_DELETE ? "DELETE" : "REFRESH")));
    if (!res->rollback)
    {
        res->rb_count = 0;
@@ -2095,7 +2095,7 @@ static BOOL   tupleExists(const StatementClass *stmt, const KeySet *keyset)
    RETCODE     ret = FALSE;
 
    snprintf(selstr, sizeof(selstr),
-            "select 1 from %s where ctid = '(%d,%d)'",
+            "select 1 from %s where ctid = '(%u,%u)'",
             quote_table(ti->schema_name, ti->table_name),
             keyset->blocknum, keyset->offset);
    res = CC_send_query(SC_get_conn(stmt), selstr, NULL, 0, NULL);
@@ -2527,7 +2527,7 @@ static void RemoveUpdatedAfterTheKey(QResultClass *res, SQLLEN index, const KeyS
    SQLLEN  pidx, midx, mv_count;
    int i, num_fields = res->num_fields, rm_count = 0;
 
-   mylog("RemoveUpdatedAfterTheKey %d,(%d,%d)\n", index, keyset ? keyset->blocknum : 0, keyset ? keyset->offset : 0);
+   mylog("RemoveUpdatedAfterTheKey %d,(%u,%u)\n", index, keyset ? keyset->blocknum : 0, keyset ? keyset->offset : 0);
    if (index < 0)
    {
        midx = index;
@@ -2826,7 +2826,7 @@ inolog("->(%u, %u)\n", wkey->blocknum, wkey->offset);
                    char    tidval[32];
 
                    snprintf(tidval, sizeof(tidval),
-                            "(%d,%d)", wkey->blocknum, wkey->offset);
+                            "(%u,%u)", wkey->blocknum, wkey->offset);
                    qres = positioned_load(stmt, 0, NULL, tidval);
                    if (QR_command_maybe_successful(qres) &&
                        QR_get_num_cached_tuples(qres) == 1)