Commit a38ae869 authored by Alexander Barkov's avatar Alexander Barkov

Removing iconv dependency.

Using MariaDB in-house character set conversion routines.

modified:
  storage/connect/CMakeLists.txt
  storage/connect/tabodbc.cpp
  storage/connect/tabodbc.h
parent dc6e20bd
...@@ -214,23 +214,6 @@ IF(CONNECT_WITH_ODBC) ...@@ -214,23 +214,6 @@ IF(CONNECT_WITH_ODBC)
ENDIF(CONNECT_WITH_ODBC) ENDIF(CONNECT_WITH_ODBC)
#
# iconv
#
OPTION(CONNECT_WITH_ICONV "Compile CONNECT with iconv support" ON)
IF(CONNECT_WITH_ICONV)
add_definitions(-DICONV_SUPPORT)
IF(UNIX)
SET(ICONV_LIBRARY "")
ELSE()
#Windows
# TODO: this is to be localized
SET(ICONV_LIBRARY "D:/libxml/lib/iconv.lib")
ENDIF(UNIX)
ENDIF(CONNECT_WITH_ICONV)
# #
# Plugin definition # Plugin definition
# #
......
...@@ -72,6 +72,9 @@ ...@@ -72,6 +72,9 @@
#include "tabcol.h" #include "tabcol.h"
#include "valblk.h" #include "valblk.h"
#include "sql_string.h"
/***********************************************************************/ /***********************************************************************/
/* DB static variables. */ /* DB static variables. */
/***********************************************************************/ /***********************************************************************/
...@@ -272,25 +275,21 @@ void TDBODBC::SetFile(PGLOBAL g, PSZ fn) ...@@ -272,25 +275,21 @@ void TDBODBC::SetFile(PGLOBAL g, PSZ fn)
DBQ = fn; DBQ = fn;
} // end of SetFile } // end of SetFile
#ifdef ICONV_SUPPORT
/******************************************************************/ /******************************************************************/
/* Convert an UTF-8 string to latin characters. */ /* Convert an UTF-8 string to latin characters. */
/******************************************************************/ /******************************************************************/
int TDBODBC::Decode(iconv_t cd, char *utf, char *buf, size_t n) int TDBODBC::Decode(char *txt, char *buf, size_t n)
{ {
#if defined(WIN32) || defined(AIX) uint dummy_errors;
const char *inp = (const char *)utf; uint32 len= copy_and_convert(buf, n, &my_charset_latin1,
#else txt, strlen(txt),
char *inp = (char *)utf; &my_charset_utf8_general_ci,
#endif &dummy_errors);
char *outp = buf; buf[len]= '\0';
size_t i = strlen(inp), o = n; return 0;
int rc = iconv(cd, &inp, &i, &outp, &o); } // end of Decode
buf[n - o] = '\0';
return rc;
} // end of Decode
#endif // ICONV_SUPPORT
/***********************************************************************/ /***********************************************************************/
/* MakeSQL: make the SQL statement use with ODBC connection. */ /* MakeSQL: make the SQL statement use with ODBC connection. */
...@@ -305,11 +304,6 @@ char *TDBODBC::MakeSQL(PGLOBAL g, bool cnt) ...@@ -305,11 +304,6 @@ char *TDBODBC::MakeSQL(PGLOBAL g, bool cnt)
bool first = true; bool first = true;
PTABLE tablep = To_Table; PTABLE tablep = To_Table;
PCOL colp; PCOL colp;
#ifdef ICONV_SUPPORT
iconv_t cd = iconv_open("ISO-8859-1", "UTF-8");
#else
void *cd = NULL;
#endif // ICONV_SUPPORT
if (!cnt) { if (!cnt) {
// Normal SQL statement to retrieve results // Normal SQL statement to retrieve results
...@@ -323,7 +317,7 @@ char *TDBODBC::MakeSQL(PGLOBAL g, bool cnt) ...@@ -323,7 +317,7 @@ char *TDBODBC::MakeSQL(PGLOBAL g, bool cnt)
for (colp = Columns; colp; colp = colp->GetNext()) for (colp = Columns; colp; colp = colp->GetNext())
if (!colp->IsSpecial()) { if (!colp->IsSpecial()) {
// Column name can be in UTF-8 encoding // Column name can be in UTF-8 encoding
rc = Decode(cd, colp->GetName(), buf, sizeof(buf)); rc= Decode(colp->GetName(), buf, sizeof(buf));
if (Quote) { if (Quote) {
if (first) { if (first) {
...@@ -358,7 +352,7 @@ char *TDBODBC::MakeSQL(PGLOBAL g, bool cnt) ...@@ -358,7 +352,7 @@ char *TDBODBC::MakeSQL(PGLOBAL g, bool cnt)
} // endif cnt } // endif cnt
// Table name can be encoded in UTF-8 // Table name can be encoded in UTF-8
rc = Decode(cd, TableName, buf, sizeof(buf)); rc = Decode(TableName, buf, sizeof(buf));
// Put table name between identifier quotes in case in contains blanks // Put table name between identifier quotes in case in contains blanks
tabname = (char*)PlugSubAlloc(g, NULL, strlen(buf) + 3); tabname = (char*)PlugSubAlloc(g, NULL, strlen(buf) + 3);
...@@ -405,9 +399,6 @@ char *TDBODBC::MakeSQL(PGLOBAL g, bool cnt) ...@@ -405,9 +399,6 @@ char *TDBODBC::MakeSQL(PGLOBAL g, bool cnt)
strcat(strcat(sql, ownp), "."); strcat(strcat(sql, ownp), ".");
strcat(sql, tabname); strcat(sql, tabname);
#ifdef ICONV_SUPPORT
iconv_close(cd);
#endif // ICONV_SUPPORT
if (To_Filter) if (To_Filter)
strcat(strcat(sql, " WHERE "), To_Filter); strcat(strcat(sql, " WHERE "), To_Filter);
......
...@@ -5,9 +5,6 @@ ...@@ -5,9 +5,6 @@
/* */ /* */
/* This file contains the TDBODBC classes declares. */ /* This file contains the TDBODBC classes declares. */
/***********************************************************************/ /***********************************************************************/
#ifdef ICONV_SUPPORT
#include <iconv.h>
#endif // ICONV_SUPPORT
#include "colblk.h" #include "colblk.h"
typedef class ODBCDEF *PODEF; typedef class ODBCDEF *PODEF;
...@@ -88,12 +85,7 @@ class TDBODBC : public TDBASE { ...@@ -88,12 +85,7 @@ class TDBODBC : public TDBASE {
protected: protected:
// Internal functions // Internal functions
#ifdef ICONV_SUPPORT int Decode(char *utf, char *buf, size_t n);
int Decode(iconv_t cd, char *utf, char *buf, size_t n);
#else // no ICONV_SUPPORT
inline int Decode(void *cd, char *str, char *buf, size_t n)
{strncpy(buf, str, n); return 0;}
#endif // ICONV_SUPPORT
char *MakeSQL(PGLOBAL g, bool cnt); char *MakeSQL(PGLOBAL g, bool cnt);
//bool MakeUpdate(PGLOBAL g, PSELECT selist); //bool MakeUpdate(PGLOBAL g, PSELECT selist);
//bool MakeInsert(PGLOBAL g); //bool MakeInsert(PGLOBAL g);
......
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