Discussion:
[odb-users] PostgreSQL 42P01 error
Сергей Никонов
2018-06-13 15:49:50 UTC
Permalink
Hello everybody,

I encountered a curious problem with PostgreSQL error 42P01. My database schema is completely generated by ODB C++ schema code.
When I try to execute a view query generated by ODB I get the following error: ""errorMessage": "42P01: ERROR:  relation \"config_item_attribute_shape\" does not exist\nLINE 1: ...on\", \"s_config_item_attribute\".\"description\" FROM \"config_it...\n". At the same time the query works in PostgreSQL Admin panel 4. This issue is actually a "show stopper" in my project.

PREPARE SELECT DISTINCT "i"."id_code", "i"."id_customization", "i"."type", "i"."description", "s_config_item_attribute_shape"."kind", "s_config_item_attribute"."id", "s_config_item_attribute"."typeid", "s_config_item_attribute"."owner_code", "s_config_item_attribute"."owner_customization", "s_config_item_attribute"."description" FROM "config_item_attribute_shape" AS "s_config_item_attribute_shape" LEFT JOIN "config_item_attribute" AS "s_config_item_attribute" ON "s_config_item_attribute"."id"="s_config_item_attribute_shape"."id" LEFT JOIN "config_item" AS "i" ON "s_config_item_attribute"."owner_code"="i"."id_code" AND "s_config_item_attribute"."owner_customization"="i"."id_customization" WHERE ("s_config_item_attribute_shape"."id" IS NOT NULL) AND ("i"."id_code" LIKE $1)

{
    "errorCode": "ODB",
    "errorMessage": "42P01: ERROR:  relation \"config_item_attribute_shape\" does not exist\nLINE 1: ...on\", \"s_config_item_attribute\".\"description\" FROM \"config_it...\n                                                             ^",
}

This is the definition of the view:
#pragma db view object(item_attribute_shape = s) \
                object(item = i : s::m_owner) \
                query(s::m_id.is_not_null() && (?), distinct)
    struct shaped_items
    {
      std::shared_ptr<item> i;
      std::shared_ptr<item_attribute_shape> s;
    };

item_attribute_shape class is derived from abstract polymorhic item_attribute one.

Environment: MSVS 2013, O
Boris Kolpackov
2018-06-14 13:09:21 UTC
Permalink
Post by Сергей Никонов
When I try to execute a view query generated by ODB I get the following
error: ""errorMessage": "42P01: ERROR: relation \"config_item_attribute_shape\"
does not exist. At the same time the query works in PostgreSQL Admin panel 4.
PREPARE SELECT DISTINCT "i"."id_code", "i"."id_customization", "i"."type",
"i"."description", "s_config_item_attribute_shape"."kind",
"s_config_item_attribute"."id", "s_config_item_attribute"."typeid",
"s_config_item_attribute"."owner_code",
"s_config_item_attribute"."owner_customization",
"s_config_item_attribute"."description" FROM "config_item_attribute_shape"
AS "s_config_item_attribute_shape" LEFT JOIN "config_item_attribute" AS
"s_config_item_attribute" ON
"s_config_item_attribute"."id"="s_config_item_attribute_shape"."id" LEFT
JOIN "config_item" AS "i" ON
"s_config_item_attribute"."owner_code"="i"."id_code" AND
"s_config_item_attribute"."owner_customization"="i"."id_customization" WHERE
("s_config_item_attribute_shape"."id" IS NOT NULL) AND ("i"."id_code" LIKE
$1)
#pragma db view object(item_attribute_shape = s) \
object(item = i : s::m_owner) \
query(s::m_id.is_not_null() && (?), distinct)
struct shaped_items
{
std::shared_ptr<item> i;
std::shared_ptr<item_attribute_shape> s;
};
I don't see anything clearly wrong with this. What is 'config_item_attribute'?
In fact, if you could come up with a small test that reproduces the problem,
that would probably be the best way forward.

Loading...