[odb-users] Cannot create schema

Boris Kolpackov boris at codesynthesis.com
Thu Oct 27 06:22:18 EDT 2011

Hi Michał,

Michał Snoch <kontakt at msnoch.pl> writes:

> and when I'm trying to create schema via
>    transaction t1(db->begin());
>    odb::schema_catalog::create_schema (*db);
>      t1.commit();
> I'm getting error that Node already exists
>    42P07: ERROR: relation "Node" already exists
> When I'm generating sql files and executing them
> by myself everything is ok. Of course there is no
> Node table in db when I'm doing that.

It seems that for some reason the code that creates the table is
called more than once. With embedded (into C++) schema, ODB uses
static initialization to register functions that must be called
during the schema creation. So the first step in understanding
what's going on is to set a breakpoint in such a function for the
Node class and see how many times it is called and by whom. Search
for CREATE TABLE \"Node in node-odb.cxx to find the place.

Note that this function is supposed to be called multiple times.
First to drop tables, and then to create them. It is also possible
that it will be called multiple times for each of these two steps
as part of a multi-pass process. However, it should never be called
more than once with the same pass number (second argument) and the
drop flag (third argument).

Let us know what you find.


More information about the odb-users mailing list