Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null pointer when trying to use Sqlite3 session #4842

Open
ReneMuala opened this issue Jan 9, 2025 · 1 comment
Open

Null pointer when trying to use Sqlite3 session #4842

ReneMuala opened this issue Jan 9, 2025 · 1 comment
Labels

Comments

@ReneMuala
Copy link

Describe the bug
Poco is raising a null pointer exception when trying to execute a query on a session.

To Reproduce
perform any operation on a sqlite3 session

Expected behavior
the respective query should be executed

Logs
stdout

PS C:\Users\dte\Documents\Playground\cpp\oikia-api> xmake ; xmake r
[ 50%]: compiling.release src\main.cpp
[ 75%]: linking.release oikia-api.exe
[100%]: build ok, spent 4.437s
main 22
Null pointer

Screenshots

#include <iostream>
#include <Poco/Data/Session.h>
#include <Poco/Data/SQLite/Connector.h>

using namespace Poco::Data::Keywords;
using Poco::Data::Session;
using Poco::Data::Statement;

struct Person
{
 std::string name;
 std::string address;
 int age;
};

int main(int argc, char** argv) try
{
 Poco::Data::SQLite::Connector::registerConnector();

 Session session("SQLite", "sample.sqlite3");

 std::cout << __FUNCTION__ << " " << __LINE__ << std::endl;
 session << "DROP TABLE IF EXISTS Person", now;

 std::cout << __FUNCTION__ << " " << __LINE__ << std::endl;
 session << "CREATE TABLE person (Name varchar(50), Address varchar(50), Age integer(3))", now;

 Person person = {
   "John Doe",
   "Beira",
   20,
 };

 Statement insert(session);

 insert << "INSERT INTO Person VALUES (?,?,?)",
   use(person.name),
   use(person.address),
   use(person.age);

 std::cout << __FUNCTION__ << " " << __LINE__ << std::endl;
 insert.execute();

 Statement select(session);

 select << "SELECT Name, Address, Age FROM person",
   into(person.name),
   into(person.address),
   into(person.age),
   range(0, 1);
 std::cout << __FUNCTION__ << " " << __LINE__ << std::endl;
 while (!select.done())
 {
   select.execute();
   std::cout << person.name << ", " << person.address << ", " << person.age << "\n";
 }
 return 0;
}
catch (std::exception& e)
{
 std::cout << e.what() << std::endl;
}

Please add relevant environment information:

  • OS Windows 11
  • POCO 1.13.3
  • SQlite3

Additional context
Im using xmake to get the depencency

@ReneMuala ReneMuala added the bug label Jan 9, 2025
@matejk
Copy link
Contributor

matejk commented Jan 9, 2025

@ReneMuala Does it work with Poco 1.14?

@ReneMuala ReneMuala changed the title Null pointer when trying to use Sqliete3 session Null pointer when trying to use Sqlite3 session Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants