Use more mundane 'int' type for cancel key lengths in libpq
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 8 May 2025 19:01:20 +0000 (22:01 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 8 May 2025 19:01:20 +0000 (22:01 +0300)
The documented max length of a cancel key is 256 bytes, so it fits in
uint8. It nevertheless seems weird to not just use 'int', like in
commit 0f1433f053 for the backend.

Discussion: https://www.postgresql.org/message-id/61be9e31-7b7d-49d5-bc11-721800d89d64%40eisentraut.org

src/interfaces/libpq/fe-protocol3.c
src/interfaces/libpq/libpq-int.h

index ca19e654a1cad2146a3b58ca553cc982dd23515c..3a1ac398fd0bf90e25f71525c55ffc96d944a738 100644 (file)
@@ -1532,7 +1532,7 @@ getParameterStatus(PGconn *conn)
 static int
 getBackendKeyData(PGconn *conn, int msgLength)
 {
-   uint8       cancel_key_len;
+   int         cancel_key_len;
 
    if (conn->be_cancel_key)
    {
index 9369c217fb56e402e4f5f20ff6f8ef3cbcb98616..3d8a5045b989ebb669b4817718c349dba38d037f 100644 (file)
@@ -547,8 +547,8 @@ struct pg_conn
 
    /* Miscellaneous stuff */
    int         be_pid;         /* PID of backend --- needed for cancels */
+   int         be_cancel_key_len;
    char       *be_cancel_key;  /* query cancellation key and its length */
-   uint16      be_cancel_key_len;
    pgParameterStatus *pstatus; /* ParameterStatus data */
    int         client_encoding;    /* encoding id */
    bool        std_strings;    /* standard_conforming_strings */