diff --git a/sqlite/ext/comdb2/tranlog.c b/sqlite/ext/comdb2/tranlog.c index 6ff618068d..c6af8cd4c4 100644 --- a/sqlite/ext/comdb2/tranlog.c +++ b/sqlite/ext/comdb2/tranlog.c @@ -439,14 +439,21 @@ static u_int64_t get_timestamp_from_regop_rowlocks_record(char *data) static u_int32_t get_generation_from_regop_rowlocks_record(char *data) { - u_int32_t generation; + u_int32_t generation = 0; + off_t loff; + u_int32_t lflags; u_int32_t rectype; LOGCOPY_32(&rectype, data); if ((rectype < 10000 && rectype > 2000) || rectype > 12000) { - LOGCOPY_32( &generation, &data[4 + 4 + 8 + 8 + 4 + 8 + 8 + 8 + 8 + 8 + 4] ); + loff = 4 + 4 + 8 + 8 + 4 + 8 + 8 + 8 + 8 + 8; } else { - LOGCOPY_32( &generation, &data[4 + 4 + 8 + 4 + 8 + 8 + 8 + 8 + 8 + 4] ); + loff = 4 + 4 + 8 + 4 + 8 + 8 + 8 + 8 + 8; + } + LOGCOPY_32( &lflags, &data[loff] ); + if (lflags & DB_TXN_LOGICAL_GEN) { + LOGCOPY_32(&generation, &data[loff + 4]); } + return generation; } diff --git a/tests/nogensc.test/Makefile b/tests/nogensc.test/Makefile new file mode 100644 index 0000000000..c655c6f555 --- /dev/null +++ b/tests/nogensc.test/Makefile @@ -0,0 +1,9 @@ +ifeq ($(TESTSROOTDIR),) + include ../testcase.mk +else + include $(TESTSROOTDIR)/testcase.mk +endif + +ifeq ($(TEST_TIMEOUT),) + export TEST_TIMEOUT=10m +endif diff --git a/tests/nogensc.test/lrl.options b/tests/nogensc.test/lrl.options new file mode 100644 index 0000000000..827f0a5246 --- /dev/null +++ b/tests/nogensc.test/lrl.options @@ -0,0 +1,3 @@ +nowatch +logmsg level info +berkattr elect_highest_committed_gen 0 diff --git a/tests/nogensc.test/runit b/tests/nogensc.test/runit new file mode 100755 index 0000000000..7d94b3f258 --- /dev/null +++ b/tests/nogensc.test/runit @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +bash -n "$0" | exit 1 + +export debug=1 + +$CDB2SQL_EXE $CDB2_OPTIONS $DBNAME default "create table t1(a int)" + +g=$($CDB2SQL_EXE --tabs $CDB2_OPTIONS $DBNAME default "select generation from comdb2_transaction_logs where rectype=2015") + +if [[ "$DBNAME" == *"usegen"* ]]; then + if [[ "$g" == "NULL" ]]; then + echo "Committed-gen database should have non-NULL for generation" + exit 1 + fi +else + if [[ "$g" != "NULL" ]]; then + echo "No-gen database should have NULL for generation in regop_rowlocks record" + exit 1 + fi +fi + +echo "Success" diff --git a/tests/nogensc.test/usegen.testopts b/tests/nogensc.test/usegen.testopts new file mode 100644 index 0000000000..43754283ec --- /dev/null +++ b/tests/nogensc.test/usegen.testopts @@ -0,0 +1 @@ +berkattr elect_highest_committed_gen 1