@@ -933,7 +933,16 @@ void LocalServer::readArguments(int argc, char ** argv, Arguments & common_argum
933933// }
934934// }
935935
936- std::vector<char > * pyEntryClickHouseLocal (int argc, char ** argv)
936+ class query_result_
937+ {
938+ public:
939+ uint64_t rows;
940+ uint64_t bytes;
941+ double elapsed;
942+ std::vector<char > * buf;
943+ };
944+
945+ std::unique_ptr<query_result_> pyEntryClickHouseLocal (int argc, char ** argv)
937946{
938947 try
939948 {
@@ -942,10 +951,14 @@ std::vector<char> * pyEntryClickHouseLocal(int argc, char ** argv)
942951 int ret = app.run ();
943952 if (ret == 0 )
944953 {
945- auto buf = app.getQueryOutputVector ();
954+ auto result = std::make_unique<query_result_>();
955+ result->buf = app.getQueryOutputVector ();
956+ result->rows = app.getProcessedRows ();
957+ result->bytes = app.getProcessedBytes ();
958+ result->elapsed = app.getElapsedTime ();
946959
947960 // std::cerr << std::string(out->begin(), out->end()) << std::endl;
948- return buf ;
961+ return result ;
949962 }
950963 else
951964 {
@@ -970,15 +983,18 @@ std::vector<char> * pyEntryClickHouseLocal(int argc, char ** argv)
970983// todo fix the memory leak and unnecessary copy
971984local_result * query_stable (int argc, char ** argv)
972985{
973- std::vector< char > * result = pyEntryClickHouseLocal (argc, argv);
986+ auto result = pyEntryClickHouseLocal (argc, argv);
974987 if (!result)
975988 {
976989 return nullptr ;
977990 }
978991 local_result * res = new local_result;
979- res->len = result->size ();
980- res->buf = result->data ();
981- res->_vec = result;
992+ res->len = result->buf ->size ();
993+ res->buf = result->buf ->data ();
994+ res->_vec = result->buf ;
995+ res->rows_read = result->rows ;
996+ res->bytes_read = result->bytes ;
997+ res->elapsed = result->elapsed ;
982998 return res;
983999}
9841000
@@ -996,10 +1012,10 @@ void free_result(local_result * result)
9961012
9971013int mainEntryClickHouseLocal (int argc, char ** argv)
9981014{
999- auto buf = pyEntryClickHouseLocal (argc, argv);
1000- if (buf )
1015+ auto result = pyEntryClickHouseLocal (argc, argv);
1016+ if (result )
10011017 {
1002- std::cout << std::string (buf->begin (), buf->end ()) << std::endl;
1018+ std::cout << std::string (result-> buf ->begin (), result-> buf ->end ()) << std::endl;
10031019 return 0 ;
10041020 }
10051021 else
0 commit comments