Skip to content

Commit

Permalink
Implemented explain for postgresql
Browse files Browse the repository at this point in the history
  • Loading branch information
spanezz committed Nov 11, 2015
1 parent 3cac7f5 commit 9fd88f8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions dballe/db/postgresql/driver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,19 @@ void Driver::exec_no_data(const std::string& query)
conn.exec_no_data(query);
}

void Driver::explain(const std::string& query)
{
using namespace dballe::db::postgresql;

string explain_query = "EXPLAIN ";
explain_query += query;

fprintf(stderr, "%s\n", explain_query.c_str());
Result res = conn.exec(explain_query);
for (unsigned row = 0; row < res.rowcount(); ++row)
fprintf(stderr, " %s\n", res.get_string(row, 0));
}

}
}
}
1 change: 1 addition & 0 deletions dballe/db/postgresql/driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct Driver : public sql::Driver
void delete_tables_v6() override;
void vacuum_v6() override;
void exec_no_data(const std::string& query) override;
void explain(const std::string& query) override;
};

}
Expand Down

0 comments on commit 9fd88f8

Please sign in to comment.