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

Commit 26b3215

Browse files
Tianyi Chenapavlo
authored andcommitted
change the string construction to avoid memory corruption, remove duplicate include header
1 parent b8cc76d commit 26b3215

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/network/postgres_protocol_handler.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "common/macros.h"
2020
#include "common/portal.h"
2121
#include "expression/expression_util.h"
22-
#include "include/traffic_cop/traffic_cop.h"
2322
#include "network/marshal.h"
2423
#include "network/postgres_protocol_handler.h"
2524
#include "parser/postgresparser.h"

test/common/statement_cache_test.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@ TEST_F(StatementCacheTests, DisableTableTest) {
5656
std::vector<std::shared_ptr<Statement>> statements;
5757
std::set<oid_t> ref_table = {0, 1, 2, 3};
5858
std::string query = "SELECT * FROM TEST";
59+
60+
LOG_INFO("Pareparing statements");
5961
// Prepare the 4 statements
6062
for (size_t i = 0; i < 4; i++) {
61-
std::string name("" + i);
63+
std::string name = std::to_string(i);
6264
ref_table.erase(i);
6365
auto stmt = std::make_shared<Statement>(name, query);
6466
stmt->SetReferencedTables(ref_table);
@@ -67,7 +69,8 @@ TEST_F(StatementCacheTests, DisableTableTest) {
6769
}
6870

6971
oid_t table = 0;
70-
// Insert statements in to the table
72+
LOG_INFO("Putting statements into cache");
73+
// Insert statements in to the cache
7174
for (auto &stmt : statements) {
7275
EXPECT_EQ(3, stmt->GetReferencedTables().size());
7376
EXPECT_EQ(0, stmt->GetReferencedTables().count(table));
@@ -81,12 +84,13 @@ TEST_F(StatementCacheTests, DisableTableTest) {
8184
cache->AddStatement(stmt);
8285
}
8386

87+
LOG_INFO("Notify cache the disabled table oid 2");
8488
// Disable the cache
8589
cache->NotifyInvalidTable(2);
8690

8791
// plan 0 1 3 need to replan while 2 do not
8892
for (oid_t i = 0; i < 4; i++) {
89-
std::string name = "" + i;
93+
std::string name = std::to_string(i);
9094
auto stmt = cache->GetStatement(name);
9195
EXPECT_NE(nullptr, stmt);
9296
if (i != 2) {

0 commit comments

Comments
 (0)