Skip to content

Commit fa6bfec

Browse files
committed
uuid in connection info
1 parent 5754ad0 commit fa6bfec

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

db/sql.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,6 +1341,7 @@ struct connection_info {
13411341
enum connection_state state_int;
13421342
int64_t in_transaction;
13431343
int64_t in_local_cache;
1344+
char *uuid;
13441345
};
13451346

13461347
/* makes master swing verbose */

db/sqlinterfaces.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6728,6 +6728,10 @@ static void gather_connection_int(struct connection_info *c, struct sqlclntstate
67286728
c->in_transaction = clnt->in_client_trans;
67296729
c->in_local_cache = clnt->in_local_cache;
67306730
Pthread_mutex_unlock(&clnt->state_lk);
6731+
uuidstr_t us;
6732+
comdb2uuidstr(clnt->unifieduuid, us);
6733+
c->uuid = malloc(strlen(us) + 1);
6734+
snprintf(c->uuid, strlen(us) + 1, "%s", us);
67316735
}
67326736

67336737
static void gather_connections_evbuffer(struct connection_info **info, int *num_connections)
@@ -6757,8 +6761,9 @@ void free_connection_info(struct connection_info *info, int num_connections)
67576761
{
67586762
if (info == NULL) return;
67596763
for (int i = 0; i < num_connections; i++) {
6760-
if (info[i].sql) free(info[i].sql);
6761-
if (info[i].fingerprint) free(info[i].fingerprint);
6764+
free(info[i].sql);
6765+
free(info[i].fingerprint);
6766+
free(info[i].uuid);
67626767
/* state is static, don't free */
67636768
}
67646769
free(info);

sqlite/ext/comdb2/connections.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,6 @@ int systblConnectionsInit(sqlite3 *db) {
9898
CDB2_INTEGER, "has_cert", -1, offsetof(struct connection_info, has_cert),
9999
CDB2_CSTRING, "common_name", -1, offsetof(struct connection_info, common_name),
100100
CDB2_INTEGER, "in_local_cache", -1, offsetof(struct connection_info, in_local_cache),
101+
CDB2_CSTRING, "uuid", -1, offsetof(struct connection_info, uuid),
101102
SYSTABLE_END_OF_FIELDS);
102103
}

tests/unifiedcancel.test/test_cancel.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ S_CDB2_OPTIONS="--cdb2cfg ${a_cdb2config}"
2020
mach=`cdb2sql ${S_CDB2_OPTIONS} --tabs $a_dbname default "SELECT comdb2_host()"`
2121

2222
S_SQL="cdb2sql ${S_CDB2_OPTIONS} --host $mach $a_dbname"
23+
S_TSQL="cdb2sql --tabs ${S_CDB2_OPTIONS} --host $mach $a_dbname"
2324

2425
function header
2526
{
@@ -46,7 +47,7 @@ if [[ $? != 0 ]] ; then
4647
fi
4748

4849
echo "collecting the sleep uuid"
49-
uuid=`$S_SQL "select uuid from comdb2_connections where sql like '%sleep%' and sql not like '%connections%'"`
50+
uuid=`$S_TSQL "select uuid from comdb2_connections where sql like '%sleep%' and sql not like '%connections%'"`
5051
if [[ $? != 0 ]] ; then
5152
echo "Failed to select uuid"
5253
exit 1
@@ -65,14 +66,14 @@ if [[ $? != 0 ]] ; then
6566
exit 1
6667
fi
6768

68-
echo "check the ${uuid} is gone"
69-
found_uuid=`$S_SQL "select uuid from comdb2_connections where sql like '%sleep%' and sql not like '%connections%'"
69+
echo "check if the ${uuid} is gone"
70+
found_uuid=`$S_TSQL "select uuid from comdb2_connections where sql like '%sleep%' and sql not like '%connections%'"`
7071
if [[ $? != 0 ]] ; then
7172
echo "Failed to run cancel message"
7273
exit 1
7374
fi
7475

75-
if [[ ! =z ${found_uuid} ]] ; then
76+
if [[ ! -z ${found_uuid} ]] ; then
7677
echo "Failed to cancel the sleep select"
7778
exit 1
7879
fi

0 commit comments

Comments
 (0)