Skip to content

Poco::Data::Session constructor freezes when opening a non SQLite data file #4854

@xavier-caroff

Description

@xavier-caroff

To Reproduce

#include "Poco/Data/Session.h"

void test()
{
    Poco::Data::Session   theSession("SQLite", "myTextFile.txt");
}

Expected behavior

The statement shall throw an exception.

Please add relevant environment information:

  • OS Type and Version: Windows 11
  • POCO Version: 1.13.3

This is the code in SessionImpl::open() that freeze.
sqlite3_open returns an error code (rc = 14) that is not handled.

		while (true)
		{
			rc = sqlite3_open_v2(connectionString().c_str(), &_pDB,
				SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_URI, NULL);
			if (rc == SQLITE_OK) break;
			if (!_pDB)
				throw ConnectionFailedException(std::string(sqlite3_errstr(rc)));
			if (sw.elapsedSeconds() >= tout)
			{
				Utility::throwException(_pDB, rc);
			}
			Thread::sleep(10);
			close();
		}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions