FAQ
Hi,

isn't it possible to create several
mysqlpp::Connections? Both of them use same db, host,
user. Code below doesn't work.

class A {
A() {
mysqlpp::Connection con;
con= mysqlpp::Connection::Connection(...);
}
};

class B {
B() {
mysqlpp::Connection con;
con= mysqlpp::Connection::Connection(...);
}
};

int main() {
A a;
B b;
return 0;
}

Using g++ 4.0.4
mysql++: Version: 2.0.7-2+b1 (Debian).

It doesn't matter if con are objects or pointers.

Best regards,
Tomas.


gdb trace-back:
#0 0x080498e9 in
mysqlpp::Connection::OptionInfo::operator= ()
#1 0x08049974 in std::__copy<false,
std::random_access_iterator_tag>::copy<std::_Deque_iterator<mysqlpp::Connection::OptionInfo,
mysqlpp::Connection::OptionInfo const&,
mysqlpp::Connection::OptionInfo const*>,
std::_Deque_iterator<mysqlpp::Connection::OptionInfo,
mysqlpp::Connection::OptionInfo&,
mysqlpp::Connection::OptionInfo*> >
()
#2 0x08049a4c in
std::__copy_aux<std::_Deque_iterator<mysqlpp::Connection::OptionInfo,
mysqlpp::Connection::OptionInfo const&,
mysqlpp::Connection::OptionInfo const*>,
std::_Deque_iterator<mysqlpp::Connection::OptionInfo,
mysqlpp::Connection::OptionInfo&,
mysqlpp::Connection::OptionInfo*> > ()
#3 0x08049af0 in std::__copy_normal<false,
false>::copy_n<std::_Deque_iterator<mysqlpp::Connection::OptionInfo,
mysqlpp::Connection::OptionInfo const&,
mysqlpp::Connection::OptionInfo const*>,
std::_Deque_iterator<mysqlpp::Connection::OptionInfo,
mysqlpp::Connection::OptionInfo&,
mysqlpp::Connection::OptionInfo*> > ()
#4 0x08049b9c in
std::copy<std::_Deque_iterator<mysqlpp::Connection::OptionInfo,
mysqlpp::Connection::OptionInfo const&,
mysqlpp::Connection::OptionInfo const*>,
std::_Deque_iterator<mysqlpp::Connection::OptionInfo,
mysqlpp::Connection::OptionInfo&,
mysqlpp::Connection::OptionInfo*> > ()
#5 0x0804c8ed in
std::deque<mysqlpp::Connection::OptionInfo,
std::allocator<mysqlpp::Connection::OptionInfo>
::operator= ()
#6 0x0804ca5f in mysqlpp::Connection::operator= ()
#7 0x0804caf2 in A::A ()
#8 0x08048afb in main ()


__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails.
http://mail.yahoo.com

Search Discussions

  • Drew M. at Jun 3, 2006 at 7:43 pm
    It would appear that the issue isn't so much multiple mysqlpp::Connections
    coexisting, but an issue with the assignment operator. The stack trace you
    provided indicates that your program isn't even getting to your declaration
    of b. I tried running the code you provided with a few modifications to get
    it to compile, and the code hung. However, by commenting out the two
    assignment lines (con= ...) it ran and exited fine.

    It appears to me that using an assignment operator on mysqlpp::Connection is
    a behavior which hasn't been accounted for. A few minutes of poking around
    leads me to suspect that the issue is actually with Lockable (which is
    inherited by Connection). In any case, I think the most expedient thing for
    you to do is not use the =operator. You should be able to supply whatever
    arguments you need directly to the constructor.

    -Drew

    On 6/2/06, Tomas Fischer wrote:

    Hi,

    isn't it possible to create several
    mysqlpp::Connections? Both of them use same db, host,
    user. Code below doesn't work.

    class A {
    A() {
    mysqlpp::Connection con;
    con= mysqlpp::Connection::Connection(...);
    }
    };

    class B {
    B() {
    mysqlpp::Connection con;
    con= mysqlpp::Connection::Connection(...);
    }
    };

    int main() {
    A a;
    B b;
    return 0;
    }

    Using g++ 4.0.4
    mysql++: Version: 2.0.7-2+b1 (Debian).

    It doesn't matter if con are objects or pointers.

    Best regards,
    Tomas.


    gdb trace-back:
    #0 0x080498e9 in
    mysqlpp::Connection::OptionInfo::operator= ()
    #1 0x08049974 in std::__copy<false,

    std::random_access_iterator_tag>::copy<std::_Deque_iterator<mysqlpp::Connection::OptionInfo,
    mysqlpp::Connection::OptionInfo const&,
    mysqlpp::Connection::OptionInfo const*>,
    std::_Deque_iterator<mysqlpp::Connection::OptionInfo,
    mysqlpp::Connection::OptionInfo&,
    mysqlpp::Connection::OptionInfo*> >
    ()
    #2 0x08049a4c in
    std::__copy_aux<std::_Deque_iterator<mysqlpp::Connection::OptionInfo,
    mysqlpp::Connection::OptionInfo const&,
    mysqlpp::Connection::OptionInfo const*>,
    std::_Deque_iterator<mysqlpp::Connection::OptionInfo,
    mysqlpp::Connection::OptionInfo&,
    mysqlpp::Connection::OptionInfo*> > ()
    #3 0x08049af0 in std::__copy_normal<false,
    false>::copy_n<std::_Deque_iterator<mysqlpp::Connection::OptionInfo,
    mysqlpp::Connection::OptionInfo const&,
    mysqlpp::Connection::OptionInfo const*>,
    std::_Deque_iterator<mysqlpp::Connection::OptionInfo,
    mysqlpp::Connection::OptionInfo&,
    mysqlpp::Connection::OptionInfo*> > ()
    #4 0x08049b9c in
    std::copy<std::_Deque_iterator<mysqlpp::Connection::OptionInfo,
    mysqlpp::Connection::OptionInfo const&,
    mysqlpp::Connection::OptionInfo const*>,
    std::_Deque_iterator<mysqlpp::Connection::OptionInfo,
    mysqlpp::Connection::OptionInfo&,
    mysqlpp::Connection::OptionInfo*> > ()
    #5 0x0804c8ed in
    std::deque<mysqlpp::Connection::OptionInfo,
    std::allocator<mysqlpp::Connection::OptionInfo>
    ::operator= ()
    #6 0x0804ca5f in mysqlpp::Connection::operator= ()
    #7 0x0804caf2 in A::A ()
    #8 0x08048afb in main ()


    __________________________________________________
    Do You Yahoo!?
    Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz
    gegen Massenmails.
    http://mail.yahoo.com

    --
    MySQL++ Mailing List
    For list archives: http://lists.mysql.com/plusplus
    To unsubscribe: http://lists.mysql.com/[email protected]
  • Tomas Fischer at Jun 3, 2006 at 9:45 pm
    Hi,

    now I using a singleton pointer and it seems to work.
    But I don't understand following code:

    struct A {
    A() {
    mysqlpp::Connection con(mysqlpp::use_exceptions);
    }
    };

    int main() {
    A a;
    }

    Again, a segmention fault occurs, why?
    If I use con to connect to a database with
    connect(...) it works.

    Best regards,
    Tomas

    __________________________________________________
    Do You Yahoo!?
    Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails.
    http://mail.yahoo.com
  • Warren Young at Jun 26, 2006 at 7:04 pm

    Drew M. wrote:
    It would appear that the issue isn't so much multiple mysqlpp::Connections
    coexisting, but an issue with the assignment operator.
    Yes. The problem is that it doesn't exist. :)

    With no defined assignment operator, you just get a bitwise copy, which
    is not the right thing with Connection. You don't want a clone of the
    existing connection down to the bit level, you want a new connection
    with the same parameters. I've added such semantics to Connection.
    This will appear in the next release of MySQL++.

    Tomas, I hope you can find the time to play with the version of MySQL++
    in the Subversion repository, to see if this works for you, before it
    gets into a release version.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupplusplus @
categoriesmysql
postedJun 2, '06 at 8:12p
activeJun 26, '06 at 7:04p
posts4
users3
websitemysql.com
irc#mysql

People

Translate

site design / logo © 2023 Grokbase