Fix random crash and memory leak. Apparently, soci doesn't like when the...

Fix random crash and memory leak. Apparently, soci doesn't like when the rowset is used while the session is deleted.
13 jobs for master in 6 minutes and 49 seconds (queued for 5 seconds)
Status Job ID Name Coverage
  Build
passed #57235
docker-debian8
job-debian8-makefile-clang

00:02:37

passed #57236
docker-debian8
job-debian8-ninja-clang

00:02:14

passed #57237
docker-debian9
job-debian9-ninja-clang

00:02:20

failed #57239
docker-ubuntu-18.04
job-ubuntu-18.04-ninja-clang

00:01:57

failed #57238
docker-ubuntu-rolling
job-ubuntu-rolling-ninja-clang

00:01:53

 
  Package
skipped #57240
docker-centos7
job-centos7-rpm
skipped #57241
docker-debian8
job-debian8-deb
skipped #57242
docker-debian9
job-debian9-deb
skipped #57243
docker-ubuntu-18.04
job-ubuntu-18.04-deb
 
  Deploy
skipped #57244
deploy
job-centos7-rpm-deploy
skipped #57245
deploy
job-debian8-deb-deploy
skipped #57246
deploy
job-debian9-deb-deploy
skipped #57247
deploy
job-ubuntu-18.04-deb-deploy
 
Name Stage Failure
failed
job-ubuntu-18.04-ninja-clang Build
No job trace
failed
job-ubuntu-rolling-ninja-clang Build
No job trace