Commit c448839c authored by Olivier Bertrand's avatar Olivier Bertrand

- Fix crash on making an XML table with encoding=XXX

- Set parameters so libxml2 does not anymore add extra characters
  when retrieving several subnodes of a node.
- Make a CONNECT file header (was PlugDB)

modified:
  storage/connect/domdoc.cpp
  storage/connect/libdoc.cpp
  storage/connect/tabxml.cpp

- Change the version number

modified:
  storage/connect/ha_connect.cc

- Begin eliminate use of libmysql functions in MYSQL table type
  Not finished yet

modified:
  storage/connect/myconn.cpp
  storage/connect/myconn.h
parent 2f48842a
......@@ -217,10 +217,17 @@ PXLIST DOMDOC::NewPlist(PGLOBAL g)
/******************************************************************/
int DOMDOC::DumpDoc(PGLOBAL g, char *ofn)
{
if (TestHr(g, Docp->save(ofn)))
return -1;
int rc = 0;
return 0;
try {
Docp->save(ofn);
} catch(_com_error e) {
sprintf(g->Message, "%s: %s", MSG(COM_ERROR),
_com_util::ConvertBSTRToString(e.Description()));
rc = -1;
} catch(...) {}
return rc;
} // end of Dump
/******************************************************************/
......
......@@ -152,7 +152,7 @@ extern "C" char nmfile[];
extern "C" char pdebug[];
extern "C" {
char version[]= "Version 1.01.0001 February 08, 2013";
char version[]= "Version 1.01.0002 February 19, 2013";
#if defined(XMSG)
char msglang[]; // Default message language
......@@ -2923,7 +2923,9 @@ int ha_connect::external_lock(THD *thd, int lock_type)
} // endif Mode
rc= CloseTable(g);
if (CloseTable(g))
rc= HA_ERR_INTERNAL_ERROR;
} // endif tdbp
DBUG_RETURN(rc);
......
......@@ -92,7 +92,7 @@ LIBXMLDOC::LIBXMLDOC(char *nsl, char *nsdf, char *enc, PFBLOCK fp)
/******************************************************************/
bool LIBXMLDOC::Initialize(PGLOBAL g)
{
//int n = xmlKeepBlanksDefault(0);
int n = xmlKeepBlanksDefault(1);
return MakeNSlist(g);
} // end of Initialize
......@@ -221,7 +221,7 @@ PXLIST LIBXMLDOC::NewPlist(PGLOBAL g)
/******************************************************************/
int LIBXMLDOC::DumpDoc(PGLOBAL g, char *ofn)
{
int rc;
int rc = 0;
FILE *of;
if (!(of= global_fopen(g, MSGID_CANNOT_OPEN, ofn, "w")))
......@@ -229,7 +229,13 @@ int LIBXMLDOC::DumpDoc(PGLOBAL g, char *ofn)
#if 1
// This function does not crash (
rc = xmlSaveFormatFileEnc((const char *)ofn, Docp, Encoding, 0);
if (xmlSaveFormatFileEnc((const char *)ofn, Docp, Encoding, 0) < 0) {
xmlErrorPtr err = xmlGetLastError();
strcpy(g->Message, (err) ? err->message : "Error saving XML doc"
);
rc = -1;
} // endif Save
// rc = xmlDocDump(of, Docp);
#else // 0
// Until this function is fixed, do the job ourself
......@@ -465,6 +471,7 @@ char *XML2NODE::GetText(char *buf, int len)
bool b = false;
int rc = ((PXDOC2)Doc)->Decode(Content, buf, len);
#if 0
// Eliminate extra characters
for (p1 = p2 = buf; *p1; p1++)
if (strchr(" \t\r\n", *p1)) {
......@@ -482,6 +489,7 @@ char *XML2NODE::GetText(char *buf, int len)
*(p2 - 1) = 0;
else
*p2 = 0;
#endif // 0
if (trace)
htrc("GetText buf='%s' len=%d rc=%d\n", buf, len, rc);
......
......@@ -328,6 +328,7 @@ bool MYSQLC::Connected(void)
} // end of Connected
#if 0 // Not used
/***********************************************************************/
/* Returns the thread ID of the current MySQL connection. */
/***********************************************************************/
......@@ -353,6 +354,7 @@ ulong MYSQLC::ServerVersion(void)
{
return (m_DB) ? mysql_get_server_version(m_DB) : 0;
} // end of ServerVersion
#endif // 0
/**************************************************************************/
/* KillQuery: Send MySQL a Kill Query command. */
......@@ -421,7 +423,8 @@ int MYSQLC::ExecSQL(PGLOBAL g, const char *query, int *w)
if (m_Rows >= 0)
return RC_OK; // Already done
if (mysql_query(m_DB, query) != 0) {
//if (mysql_query(m_DB, query) != 0) {
if (mysql_real_query(m_DB, query, strlen(query))) {
char *msg = (char*)PlugSubAlloc(g, NULL, 512 + strlen(query));
sprintf(msg, "(%d) %s [%s]", mysql_errno(m_DB),
......
......@@ -62,8 +62,8 @@ class DllItem MYSQLC {
int Open(PGLOBAL g, const char *host, const char *db,
const char *user= "root", const char *pwd= "*",
int pt= 0);
ulong GetThreadID(void);
ulong ServerVersion(void);
//ulong GetThreadID(void);
//ulong ServerVersion(void);
const char *ServerInfo(void);
int KillQuery(ulong id);
int ExecSQL(PGLOBAL g, const char *query, int *w = NULL);
......
......@@ -496,8 +496,9 @@ bool TDBXML::Initialize(PGLOBAL g)
goto error;
} // endif NewDoc
// Add a PlugDB comment node
sprintf(buf, MSG(CREATED_PLUGDB), version);
// Add a CONNECT comment node
// sprintf(buf, MSG(CREATED_PLUGDB), version);
sprintf(buf, " Created by CONNECT %s ", version);
Docp->AddComment(g, buf);
if (XmlDB) {
......@@ -914,7 +915,14 @@ void TDBXML::CloseDB(PGLOBAL g)
TabNode->AddText(g, "\n");
// Save the modified document
int rc = Docp->DumpDoc(g, filename);
if (Docp->DumpDoc(g, filename)) {
PushWarning(g, this);
Docp->CloseDoc(g, To_Xb);
// This causes a crash in Diagnostics_area::set_error_status
// longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
} // endif DumpDoc
} // endif Changed
// Free the document and terminate XML processing
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment