@@ -79,14 +79,26 @@ class QueryLoggerTests : public PelotonTest {
79
79
80
80
// only check once the the transaction has committed
81
81
if (committed) {
82
+ // accounting for the select_query that happened before this txn
83
+ expected_result.push_back (select_query + " |" + select_query_fingerprint);
84
+
82
85
expected_result.insert (expected_result.end (),
83
86
temporary_expected_result.begin (),
84
87
temporary_expected_result.end ());
85
88
temporary_expected_result.clear ();
86
89
TestingSQLUtil::ExecuteSQLQueryAndCheckResult (select_query.c_str (),
87
90
expected_result, true );
91
+
88
92
// the select query we used will also be logged for next time
89
93
expected_result.push_back (select_query + " |" + select_query_fingerprint);
94
+
95
+ } else {
96
+ // verify that the logging does not happen before the txn commit
97
+ TestingSQLUtil::ExecuteSQLQueryAndCheckResult (select_query.c_str (),
98
+ expected_result, true );
99
+ // the select query we used will also be logged for next time
100
+ temporary_expected_result.push_back (select_query + " |" +
101
+ select_query_fingerprint);
90
102
}
91
103
}
92
104
@@ -105,6 +117,9 @@ TEST_F(QueryLoggerTests, QueriesTest) {
105
117
TestSimpleUtil (" INSERT INTO test VALUES (1);" , expected_result);
106
118
TestSimpleUtil (" INSERT INTO test VALUES (2);" , expected_result);
107
119
120
+ expected_result.pop_back (); // the select_query done at the end of above test
121
+ // won't be logged till the txn below commits
122
+
108
123
// check if the queries are logged only when the transaction actually commits
109
124
TestTransactionUtil (" BEGIN;" , expected_result, false );
110
125
TestTransactionUtil (" INSERT INTO test VALUES (1);" , expected_result, false );
0 commit comments