Results 1 to 13 of 13

Thread: QThread and PostgreSQL - a problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QThread and PostgreSQL - a problem

    Quote Originally Posted by Lesiok View Post
    Qt Code:
    1. char miesiac[7];
    2. strcpy_s(miesiac,sizeof(miesiac),bazaDBF.mid(1,6).toLocal8Bit().data());
    To copy to clipboard, switch view to plain text mode 
    Doesn't this leave the last character uninitialized? What does KonwertBJM::robKonwersje() do? Why does it take char* and not QString in the first place?
    J-P Nurmi

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,540
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QThread and PostgreSQL - a problem

    Quote Originally Posted by jpn View Post
    Doesn't this leave the last character uninitialized? What does KonwertBJM::robKonwersje() do? Why does it take char* and not QString in the first place?
    1. No, strcpy_s writes to the new location string WITH ending 0x00 byte.

    2. KonwertBJM::robKonwersje() is a main method to doing conversion from DBF to SQL. It opens 3 DBF files named as Byyyymm.DBF, KByyyymm.DBF and Pyyyymm.DBF, where yyyymm is saved in var miesiac, and record by record convert it to SQL INSERT statements. A few records from KB and P is related to one record in B. So every record from B produce some INSERT statements in one transaction.

    As I wrote in post opening this thread, on Firebird I can do this in many threads and all is OK. Problem is only with PostgreSQL.

  3. #3
    Join Date
    Jan 2008
    Posts
    40
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QThread and PostgreSQL - a problem

    In addition, the third party libraries used by the QSqlDrivers can impose further restrictions on using the SQL Module in a multithreaded program. Consult the manual of your database client for more information
    This may be the problem

  4. #4
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,540
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QThread and PostgreSQL - a problem

    Quote Originally Posted by C167 View Post
    This may be the problem
    Yes I know.
    Theoretically libpq is compiled in thread-safe mode. PQisthreadsafe() returns 1 (the libpq is thread-safe).

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.