mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Removing iconv dependency.
Using MariaDB in-house character set conversion routines. modified: storage/connect/CMakeLists.txt storage/connect/tabodbc.cpp storage/connect/tabodbc.h
This commit is contained in:
@@ -214,23 +214,6 @@ IF(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
|
||||
#
|
||||
|
@@ -72,6 +72,9 @@
|
||||
#include "tabcol.h"
|
||||
#include "valblk.h"
|
||||
|
||||
#include "sql_string.h"
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
/* DB static variables. */
|
||||
/***********************************************************************/
|
||||
@@ -272,25 +275,21 @@ void TDBODBC::SetFile(PGLOBAL g, PSZ fn)
|
||||
DBQ = fn;
|
||||
} // end of SetFile
|
||||
|
||||
#ifdef ICONV_SUPPORT
|
||||
|
||||
/******************************************************************/
|
||||
/* 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)
|
||||
const char *inp = (const char *)utf;
|
||||
#else
|
||||
char *inp = (char *)utf;
|
||||
#endif
|
||||
char *outp = buf;
|
||||
size_t i = strlen(inp), o = n;
|
||||
int rc = iconv(cd, &inp, &i, &outp, &o);
|
||||
|
||||
buf[n - o] = '\0';
|
||||
return rc;
|
||||
uint dummy_errors;
|
||||
uint32 len= copy_and_convert(buf, n, &my_charset_latin1,
|
||||
txt, strlen(txt),
|
||||
&my_charset_utf8_general_ci,
|
||||
&dummy_errors);
|
||||
buf[len]= '\0';
|
||||
return 0;
|
||||
} // end of Decode
|
||||
#endif // ICONV_SUPPORT
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
/* MakeSQL: make the SQL statement use with ODBC connection. */
|
||||
@@ -305,11 +304,6 @@ char *TDBODBC::MakeSQL(PGLOBAL g, bool cnt)
|
||||
bool first = true;
|
||||
PTABLE tablep = To_Table;
|
||||
PCOL colp;
|
||||
#ifdef ICONV_SUPPORT
|
||||
iconv_t cd = iconv_open("ISO-8859-1", "UTF-8");
|
||||
#else
|
||||
void *cd = NULL;
|
||||
#endif // ICONV_SUPPORT
|
||||
|
||||
if (!cnt) {
|
||||
// Normal SQL statement to retrieve results
|
||||
@@ -323,7 +317,7 @@ char *TDBODBC::MakeSQL(PGLOBAL g, bool cnt)
|
||||
for (colp = Columns; colp; colp = colp->GetNext())
|
||||
if (!colp->IsSpecial()) {
|
||||
// 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 (first) {
|
||||
@@ -358,7 +352,7 @@ char *TDBODBC::MakeSQL(PGLOBAL g, bool cnt)
|
||||
} // endif cnt
|
||||
|
||||
// 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
|
||||
tabname = (char*)PlugSubAlloc(g, NULL, strlen(buf) + 3);
|
||||
@@ -405,9 +399,6 @@ char *TDBODBC::MakeSQL(PGLOBAL g, bool cnt)
|
||||
strcat(strcat(sql, ownp), ".");
|
||||
|
||||
strcat(sql, tabname);
|
||||
#ifdef ICONV_SUPPORT
|
||||
iconv_close(cd);
|
||||
#endif // ICONV_SUPPORT
|
||||
|
||||
if (To_Filter)
|
||||
strcat(strcat(sql, " WHERE "), To_Filter);
|
||||
|
@@ -5,9 +5,6 @@
|
||||
/* */
|
||||
/* This file contains the TDBODBC classes declares. */
|
||||
/***********************************************************************/
|
||||
#ifdef ICONV_SUPPORT
|
||||
#include <iconv.h>
|
||||
#endif // ICONV_SUPPORT
|
||||
#include "colblk.h"
|
||||
|
||||
typedef class ODBCDEF *PODEF;
|
||||
@@ -88,12 +85,7 @@ class TDBODBC : public TDBASE {
|
||||
|
||||
protected:
|
||||
// Internal functions
|
||||
#ifdef ICONV_SUPPORT
|
||||
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
|
||||
int Decode(char *utf, char *buf, size_t n);
|
||||
char *MakeSQL(PGLOBAL g, bool cnt);
|
||||
//bool MakeUpdate(PGLOBAL g, PSELECT selist);
|
||||
//bool MakeInsert(PGLOBAL g);
|
||||
|
Reference in New Issue
Block a user