drogonframework / drogonframework/drogon
Running multiple sql querrys in single execSqlSync throws bad_function_call
- Dominant language
- C++
- Stars
- 14.3k
- Forks
- 1.4k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 14
Description
**Describe the bug**
when doing multiple sql statements in one `execSqlSync` call a `std::bad_function_call` is thrown after the sql did run (at some point i am unable to figure out as i am unable to catch it)
**To Reproduce**
minimalistic program to reproduce:
```
#include
int main(int argc, char* argv[]){
std::shared_ptr db_con = drogon::orm::DbClient::newPgClient("connection parameter", 10);
//both of the tables will be created
auto res = db_con->execSqlSync("CREATE TABLE IF NOT EXISTS test1(blub TEXT); CREATE TABLE IF NOT EXISTS test2(blubber TEXT);");
}
```
CMakeLists.txt
```
cmake_minimum_required(VERSION 3.10)
project(drogon-issue VERSION 0.0.1)
add_executable(drogon-issue test.cpp)
find_package(Drogon REQUIRED)
target_link_libraries(drogon-issue PRIVATE ${DROGON_LIBRARIES})
target_include_directories(drogon-issue PRIVATE ${DROGON_INCLUDE_DIRS})
```
**Expected behavior**
no exception is thrown
**Log**
```
terminate called after throwing an instance of 'std::bad_function_call'
what(): bad_function_call
Abgebrochen (Speicherabzug geschrieben)
```
**Backtrace**
```
#0 0x00007ffff7408615 in raise () from /usr/lib/libc.so.6
#1 0x00007ffff73f1862 in abort () from /usr/lib/libc.so.6
#2 0x00007ffff778a86a in __gnu_cxx::__verbose_terminate_handler () at /build/gcc/src/gcc/libstdc++-v3/libsupc++/vterminate.cc:95
#3 0x00007ffff7796d9a in __cxxabiv1::__terminate (handler=) at /build/gcc/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:48
#4 0x00007ffff7796e07 in std::terminate () at /build/gcc/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:58
#5 0x00007ffff77970ae in __cxxabiv1::__cxa_throw (obj=, tinfo=tinfo@entry=0x7ffff78c43b0 , dest=dest@entry=0x7ffff77c1520 ) at /build/gcc/src/gcc/libstdc++-v3/libsupc++/eh_throw.cc:95
#6 0x00007ffff778d7ac in std::__throw_bad_function_call () at /build/gcc/src/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/exception.h:63
#7 0x0000555555632450 in drogon::orm::PgConnection::handleRead() ()
#8 0x0000555555678c48 in trantor::Channel::handleEventSafely() ()
#9 0x000055555566f5f1 in trantor::EventLoop::loop() ()
#10 0x0000555555670c39 in trantor::EventLoopThread::loopFuncs() ()
#11 0x00007ffff77c3c24 in std::execute_native_thread_routine (__p=0x5555556f8f70) at /build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:80
#12 0x00007ffff7f573e9 in start_thread () from /usr/lib/libpthread.so.0
#13 0x00007ffff74cb293 in clone () from /usr/lib/libc.so.6
```
**Desktop (please complete the following information):**
- OS: linus
- Version: 1.0.0beta21
Contributor guide
Assessment
This issue has not been assessed yet.