I'm working on implementing pg_check functions. Because I want to test
whole table I need catch a error and handle it myself. I use following
construct:



PG_TRY();
{
...
ereport(ERROR, (errmsg("Error test")));
...
}
PG_CATCH();
{
errcontext("Context error");
EmitErrorReport();
FlushErrorState();
}
PG_END_TRY();

At the end I got following message:

ERROR: Error test
CONTEXT: Context error
server sent data ("D" message) without prior row description ("T" message)

and also nothing appears in a log file. Similar concept is used in
autovacuum.c.


Any idea what is wrong?

Thanks for help Zdenek

Search Discussions

  • Alvaro Herrera at Mar 4, 2008 at 4:38 pm

    Zdenek Kotala wrote:

    PG_TRY();
    {
    ...
    ereport(ERROR, (errmsg("Error test")));
    ...
    }
    PG_CATCH();
    {
    errcontext("Context error");
    EmitErrorReport();
    FlushErrorState();
    }
    PG_END_TRY();

    At the end I got following message:

    ERROR: Error test
    CONTEXT: Context error
    server sent data ("D" message) without prior row description ("T" message)
    I don't see anything wrong with this code. Perhaps the problem is
    somewhere else?

    --
    Alvaro Herrera http://www.CommandPrompt.com/
    The PostgreSQL Company - Command Prompt, Inc.
  • Zdenek Kotala at Mar 4, 2008 at 4:56 pm

    Alvaro Herrera napsal(a):
    Zdenek Kotala wrote:
    PG_TRY();
    {
    ...
    ereport(ERROR, (errmsg("Error test")));
    ...
    }
    PG_CATCH();
    {
    errcontext("Context error");
    EmitErrorReport();
    FlushErrorState();
    }
    PG_END_TRY();

    At the end I got following message:

    ERROR: Error test
    CONTEXT: Context error
    server sent data ("D" message) without prior row description ("T" message)
    I don't see anything wrong with this code. Perhaps the problem is
    somewhere else?

    There is whole test code. It is store procedure and there are nothing
    special. The difference between this and autovacuum is that autovacuum
    works without client side.

    Datum
    pg_check(PG_FUNCTION_ARGS)
    {
    PG_TRY();
    {
    ereport(ERROR, (errmsg("Error test")));
    }
    PG_CATCH();
    {
    errcontext("Context error");
    EmitErrorReport();
    FlushErrorState();
    }
    PG_END_TRY();
    PG_RETURN_DATUM(0);
    }


    Zdenek
  • Tom Lane at Mar 4, 2008 at 5:29 pm

    Zdenek Kotala writes:
    Alvaro Herrera napsal(a):
    Zdenek Kotala wrote:
    At the end I got following message:

    ERROR: Error test
    CONTEXT: Context error
    server sent data ("D" message) without prior row description ("T" message)
    I don't see anything wrong with this code. Perhaps the problem is
    somewhere else?
    There is whole test code. It is store procedure and there are nothing
    special. The difference between this and autovacuum is that autovacuum
    works without client side.
    The problem with this is it's violating the wire protocol. Once you've
    sent the client an ERROR message, it no longer expects to see any result
    from the SELECT that called the function.

    regards, tom lane
  • Zdenek Kotala at Mar 4, 2008 at 7:32 pm

    Tom Lane napsal(a):
    Zdenek Kotala <Zdenek.Kotala@Sun.COM> writes:
    Alvaro Herrera napsal(a):
    Zdenek Kotala wrote:
    At the end I got following message:

    ERROR: Error test
    CONTEXT: Context error
    server sent data ("D" message) without prior row description ("T" message)
    I don't see anything wrong with this code. Perhaps the problem is
    somewhere else?
    There is whole test code. It is store procedure and there are nothing
    special. The difference between this and autovacuum is that autovacuum
    works without client side.
    The problem with this is it's violating the wire protocol. Once you've
    sent the client an ERROR message, it no longer expects to see any result
    from the SELECT that called the function.
    Thanks for explanation. I added extra error message at the end of
    function and it works now.


    Thanks Zdenek

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppgsql-hackers @
categoriespostgresql
postedMar 4, '08 at 9:12a
activeMar 4, '08 at 7:32p
posts5
users3
websitepostgresql.org...
irc#postgresql

People

Translate

site design / logo © 2022 Grokbase