https://bugs.documentfoundation.org/show_bug.cgi?id=88796

Lionel Elie Mamane <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Whiteboard|                            |EasyHack DifficultyBeginner
                   |                            |SkillCpp SkillSql

--- Comment #5 from Lionel Elie Mamane <[email protected]> ---
For the native connector:

STEP 1
======

In file 
mysqlc/source/mysqlc_connection.cxx
around line 175 in OConnection::construct
add
connProps["MYSQL_OPT_RECONNECT"] = sql::ConnectPropertyVal(static_cast< my_bool
>(true));


This should work... If not,
http://stackoverflow.com/questions/4879467/how-to-set-autoreconnect-option-with-mysql-connector-c
says to add something like this to the connection code after whatever C++ code
calls mysql_init, but before whatever C++ code calls mysql_connect:

my_bool myTrue = true;
con->setClientOption("MYSQL_OPT_RECONNECT", &myTrue);

see also http://dev.mysql.com/doc/refman/5.5/en/mysql-options.html for the
option definition.


STEP 2
======

At the end of OConnection::construct, there is

    std::auto_ptr<sql::Statement>
stmt(m_settings.cppConnection->createStatement());
    stmt->executeUpdate("SET session sql_mode='ANSI_QUOTES'");
    stmt->executeUpdate("SET NAMES utf8");


So that these commands are automatically reexecuted at reconnection time, you
need to change this to something like (with the other connProps settings before
the actual connect):

connProps["MYSQL_INIT_COMMAND"] = sql::ConnectPropertyVal(std::string("SET
session sql_mode='ANSI_QUOTES'; SET NAMES utf8;"));


STEP 3
======

(That's probably a bit more than really meant by this EasyHack, but IMHO is
what is necessary to make this reconnection business really useful.)

The user needs to be able to add other commands to MYSQL_INIT_COMMAND. Add it
to the Edit / Database / Properties screen, and then concatenate the value of
what the user has set with the above:

Change
    OUString aUser, aPass, sUnixSocket, sNamedPipe;
to
    OUString aUser, aPass, sUnixSocket, sNamedPipe, sInitCmd;

In the
    for (;pIter != pEnd;++pIter) {
add a case (Replace "InitCommand" by whatever you called the option)
    } else if ( pIter->Name.equalsAscii("InitCommand")) {
            OSL_VERIFY( pIter->Value >>= sInitCmd );

and change what you created in STEP 2 to something like:

const std::string default_init_str("SET session sql_mode='ANSI_QUOTES'; SET
NAMES utf8; ");
std::string init_str(default_init_str + OUStringToOString(sInitCmd,
m_settings.encoding).getStr());

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs

Reply via email to