Skip to content
This repository was archived by the owner on Sep 27, 2019. It is now read-only.

Commit fc998b9

Browse files
committed
make the changes suggested in review
1 parent f7fa102 commit fc998b9

File tree

4 files changed

+25
-29
lines changed

4 files changed

+25
-29
lines changed

src/include/catalog/query_history_catalog.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#pragma once
2424

2525
#include "catalog/abstract_catalog.h"
26-
#include "statistics/query_metric.h"
2726

2827
#define QUERY_HISTORY_CATALOG_NAME "pg_query_history"
2928

src/include/parser/pg_list.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ struct ListCell {
7373
* if supported by the compiler, or as regular functions otherwise.
7474
* See STATIC_IF_INLINE in c.h.
7575
*/
76-
7776
#ifndef PG_USE_INLINE
7877
extern ListCell *list_head(const List *l);
7978
extern ListCell *list_tail(List *l);

test/brain/query_logger_test.cpp

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,10 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#include <memory>
14-
15-
#include "catalog/catalog.h"
1613
#include "common/harness.h"
17-
#include "concurrency/transaction_manager_factory.h"
1814
#include "sql/testing_sql_util.h"
1915
#include "settings/settings_manager.h"
2016
#include "parser/pg_query.h"
21-
#include "threadpool/brain_thread_pool.h"
2217

2318
using std::vector;
2419
using std::string;
@@ -33,11 +28,11 @@ class QueryLoggerTests : public PelotonTest {
3328
PelotonInit::Initialize();
3429

3530
// query to check that logging is done
36-
select_query =
31+
select_query_ =
3732
"SELECT query_string, fingerprint FROM pg_catalog.pg_query_history;";
38-
select_query_fingerprint =
39-
pg_query_fingerprint(select_query.c_str()).hexdigest;
40-
wait_time = 2;
33+
select_query_fingerprint_ =
34+
pg_query_fingerprint(select_query_.c_str()).hexdigest;
35+
wait_time_ = 2;
4136
}
4237

4338
virtual void TearDown() override { PelotonInit::Shutdown(); }
@@ -52,13 +47,13 @@ class QueryLoggerTests : public PelotonTest {
5247
TestingSQLUtil::ExecuteSQLQuery(test_query.c_str());
5348

5449
// give some time to actually log this query
55-
sleep(wait_time);
50+
sleep(wait_time_);
5651

57-
TestingSQLUtil::ExecuteSQLQueryAndCheckResult(select_query.c_str(),
52+
TestingSQLUtil::ExecuteSQLQueryAndCheckResult(select_query_.c_str(),
5853
expected_result, true);
5954

6055
// the select query we used will also be logged for next time
61-
expected_result.push_back(select_query + "|" + select_query_fingerprint);
56+
expected_result.push_back(select_query_ + "|" + select_query_fingerprint_);
6257
}
6358

6459
// Executes the given query and then checks if the queries that are executed
@@ -75,37 +70,40 @@ class QueryLoggerTests : public PelotonTest {
7570
TestingSQLUtil::ExecuteSQLQuery(test_query.c_str());
7671

7772
// give some time to actually log this query
78-
sleep(wait_time);
73+
sleep(wait_time_);
7974

8075
// only check once the the transaction has committed
8176
if (committed) {
82-
// accounting for the select_query that happened before this txn
83-
expected_result.push_back(select_query + "|" + select_query_fingerprint);
77+
// accounting for the select_query_ that happened before this txn
78+
expected_result.push_back(select_query_ + "|" +
79+
select_query_fingerprint_);
8480

8581
expected_result.insert(expected_result.end(),
8682
temporary_expected_result.begin(),
8783
temporary_expected_result.end());
8884
temporary_expected_result.clear();
89-
TestingSQLUtil::ExecuteSQLQueryAndCheckResult(select_query.c_str(),
85+
TestingSQLUtil::ExecuteSQLQueryAndCheckResult(select_query_.c_str(),
9086
expected_result, true);
9187

9288
// the select query we used will also be logged for next time
93-
expected_result.push_back(select_query + "|" + select_query_fingerprint);
89+
expected_result.push_back(select_query_ + "|" +
90+
select_query_fingerprint_);
9491

9592
} else {
9693
// verify that the logging does not happen before the txn commit
97-
TestingSQLUtil::ExecuteSQLQueryAndCheckResult(select_query.c_str(),
94+
TestingSQLUtil::ExecuteSQLQueryAndCheckResult(select_query_.c_str(),
9895
expected_result, true);
9996
// the select query we used will also be logged for next time
100-
temporary_expected_result.push_back(select_query + "|" +
101-
select_query_fingerprint);
97+
temporary_expected_result.push_back(select_query_ + "|" +
98+
select_query_fingerprint_);
10299
}
103100
}
104101

105102
protected:
106-
string select_query; // fixed query to check the queries logged in the table
107-
string select_query_fingerprint; // fingerprint for the fixed query
108-
int wait_time; // time to wait in seconds for the query to log into the table
103+
string select_query_; // fixed query to check the queries logged in the table
104+
string select_query_fingerprint_; // fingerprint for the fixed query
105+
int wait_time_; // time to wait in seconds for the query to log into the
106+
// table
109107
};
110108

111109
// Testing the functionality of query logging
@@ -117,16 +115,17 @@ TEST_F(QueryLoggerTests, QueriesTest) {
117115
TestSimpleUtil("INSERT INTO test VALUES (1);", expected_result);
118116
TestSimpleUtil("INSERT INTO test VALUES (2);", expected_result);
119117

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
118+
expected_result
119+
.pop_back(); // the select_query_ done at the end of above test
120+
// won't be logged till the txn below commits
122121

123122
// check if the queries are logged only when the transaction actually commits
124123
TestTransactionUtil("BEGIN;", expected_result, false);
125124
TestTransactionUtil("INSERT INTO test VALUES (1);", expected_result, false);
126125
TestTransactionUtil("COMMIT;", expected_result, true);
127126

128127
// final check to see if everything is ok
129-
TestSimpleUtil(select_query, expected_result);
128+
TestSimpleUtil(select_query_, expected_result);
130129
}
131130

132131
} // namespace test

third_party/libpg_query/src/postgres/include/nodes/pg_list.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ struct ListCell
7878
* if supported by the compiler, or as regular functions otherwise.
7979
* See STATIC_IF_INLINE in c.h.
8080
*/
81-
8281
#ifndef PG_USE_INLINE
8382
extern ListCell *list_head(const List *l);
8483
extern ListCell *list_tail(List *l);

0 commit comments

Comments
 (0)