[odb-users] Problem with schema_catalog::migrate and postgresql
Otheontelth
otheontelth at protonmail.com
Sun Nov 12 16:36:27 EST 2017
Hello,
i got the following problem:
I am trying to create a database schema with odb::schema_catalog::migrate(*db).
Note: There are no tables on the database.
The code i use is:
{
odb
::
transaction
t
(
db
->
begin
());
odb
::
schema_catalog
::
migrate
(*
db
);
t
.
commit
();
}
I get the following exception:
terminate called after throwing an instance of 'odb::pgsql::database_exception'
what(): 25P02: ERROR: current transaction is aborted, commands ignored until end of transaction block
Stack trace (most recent call last):
#14 Object ", at 0xffffffffffffffff, in
#13 Object "/home/jr/src/csec/csec-dbg, at 0x43de79, in _start
#12 Source "../csu/libc-start.c", line 308, in __libc_start_main [0x7f4e6c1e21c0]
#11 Source "src/driver.cpp", line 36, in main [0x449f4e]
33: // if (!odb::schema_catalog::exists(*db)) {
34: // odb::schema_catalog::drop_schema(*db);
35: // odb::schema_catalog::create_schema(*db);
> 36: odb::schema_catalog::migrate(*db);
37: //}
38: t.commit();
39: }
#10 Object "/usr/lib/x86_64-linux-gnu/libodb-2.4.so, at 0x7f4e706fbb3b, in odb::schema_catalog::migrate(odb::database&, unsigned long long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
#9 Object "/usr/lib/x86_64-linux-gnu/libodb-2.4.so, at 0x7f4e706fb7e8, in odb::schema_catalog::create_schema(odb::database&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)
#8 Source "src/db/db-odb.cpp", line 929, in create_schema [0x43f853]
926: {
927: case 1:
928: {
> 929: db.execute ("CREATE TABLE \"func\" (\n"
930: " \"id\" SERIAL NOT NULL PRIMARY KEY,\n"
931: " \"name\" TEXT NOT NULL,\n"
932: " \"args\" INTEGER NOT NULL,\n"
#7 Object "/usr/lib/x86_64-linux-gnu/libodb-pgsql-2.4.so, at 0x7f4e70918b52, in odb::pgsql::connection::execute(char const*, unsigned long)
#6 Object "/usr/lib/x86_64-linux-gnu/libodb-pgsql-2.4.so, at 0x7f4e7091eb97, in odb::pgsql::translate_error(odb::pgsql::connection&, pg_result*)
#5 Object "/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.24, at 0x7f4e6cb9df13, in __cxa_throw
#4 Object "/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.24, at 0x7f4e6cb9dcd0, in std::terminate()
#3 Object "/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.24, at 0x7f4e6cb9dc85, in
#2 Object "/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.24, at 0x7f4e6cba0094, in __gnu_cxx::__verbose_terminate_handler()
#1 Source "/build/glibc-CxtIbX/glibc-2.26/stdlib/abort.c", line 90, in abort [0x7f4e6c1f9f5c]
#0 Source "../sysdeps/unix/sysv/linux/raise.c", line 51, in raise [0x7f4e6c1f80bb]
Aborted (Signal sent by tkill() 11534 1000)
The database log:
2017-11-12 22:31:23 CET [11535]: [1-1] user=[unknown],db=[unknown],app=[unknown],client=127.0.0.1 LOG: connection received: host=127.0.0.1 port=50072
2017-11-12 22:31:23 CET [11535]: [2-1] user=odb,db=odbdb,app=[unknown],client=127.0.0.1 LOG: connection authorized: user=odb database=odbdb SSL enabled (protocol=TLSv1.2, cipher=ECDHE-RSA-AES256-GCM-SHA384, compression=off)
2017-11-12 22:31:23 CET [11535]: [3-1] user=odb,db=odbdb,app=[unknown],client=127.0.0.1 LOG: duration: 0.037 ms statement: begin
2017-11-12 22:31:23 CET [11535]: [4-1] user=odb,db=odbdb,app=[unknown],client=127.0.0.1 ERROR: relation "schema_version" does not exist at character 36
2017-11-12 22:31:23 CET [11535]: [5-1] user=odb,db=odbdb,app=[unknown],client=127.0.0.1 STATEMENT: SELECT "version", "migration" FROM "schema_version" WHERE "name" = $1
2017-11-12 22:31:23 CET [11535]: [6-1] user=odb,db=odbdb,app=[unknown],client=127.0.0.1 ERROR: current transaction is aborted, commands ignored until end of transaction block
2017-11-12 22:31:23 CET [11535]: [7-1] user=odb,db=odbdb,app=[unknown],client=127.0.0.1 STATEMENT: CREATE TABLE "func" (
"id" SERIAL NOT NULL PRIMARY KEY,
"name" TEXT NOT NULL,
"args" INTEGER NOT NULL,
"system" BOOLEAN NOT NULL)
2017-11-12 22:31:23 CET [11535]: [8-1] user=odb,db=odbdb,app=[unknown],client=127.0.0.1 LOG: could not receive data from client: Connection reset by peer
2017-11-12 22:31:23 CET [11535]: [9-1] user=odb,db=odbdb,app=[unknown],client=127.0.0.1 LOG: disconnection: session time: 0:00:00.151 user=odb database=odbdb host=127.0.0.1 port=50072
Its interesting that the code works when i change it to:
{
odb
::
transaction
t
(
db
->
begin
());
odb
::
schema_catalog
::
drop_schema
(*
db
);
odb
::
schema_catalog
::
migrate
(*
db
);
t
.
commit
();
}
Thank you
More information about the odb-users
mailing list