Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to get postgresql errors and messages outside Qt Creator "Application output" pane ?
Forum Updated to NodeBB v4.3 + New Features

How to get postgresql errors and messages outside Qt Creator "Application output" pane ?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Martin Fla
    wrote on last edited by
    #1

    Hi everyone,

    PostgreSQL server send some messages to client on some queries execution.
    Those messages are shown in the "Application Output" pane of Qt Creator.
    I'm trying to get those in my app but I can't figure out how to do this.

    Here is some query to emit such a message :

    @/* plpgsql function declaration */
    CREATE OR REPLACE FUNCTION pg_temp.test() RETURNS BOOLEAN AS $$
    BEGIN
    RAISE WARNING 'This is a warning';
    RETURN FALSE;
    END;
    $$ LANGUAGE plpgsql;

    /* Function call */
    SELECT * FROM pg_temp.test()@

    Executing this query I get :
    WARNING: This is a warning
    in the "Application Output" pane but either QSqlQuery.lastError() and QSqlDatabase.lastError() returns empty string.

    I've tried to use qInstallMessageHandler. It works for my qDebug() messages but I don't get my psql messages. They are still shown in QtCreator only.

    Does anyone know a possible way to do what I want ?

    I've tested this behavior with Qt 5.3.2 and 5.4

    1 Reply Last reply
    0
    • X Offline
      X Offline
      xpaolo
      wrote on last edited by
      #2

      I have the same request.
      It looks like qt manage only exceptions not warnings, notices, etc.

      1 Reply Last reply
      0
      • X Offline
        X Offline
        xpaolo
        wrote on last edited by
        #3

        I read this in the postgresql libpq documentation:

        31.12. Notice Processing
        Notice and warning messages generated by the server are not returned by the query execution functions, since they do not imply failure of the query. Instead they are passed to a notice handling function, and execution continues normally after the handler returns. The default notice handling function prints the message on stderr, but the application can override this behavior by supplying its own handling function.

        So it looks like only exceptions that stops the function executioin get back to the caller, other messages are passed to stderr. So there is no way to handle that messages other than looking at stderr

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved