Skip to Content.
Sympa Menu

freetds - [freetds] freetds ct-lib locale functions

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "David Nichols" <nicholsman AT gmail.com>
  • To: freetds AT lists.ibiblio.org
  • Subject: [freetds] freetds ct-lib locale functions
  • Date: Mon, 28 May 2007 11:13:55 +0200

Hi,

I need to be able to set the client character set from ct-lib using
the ct_loc_*() and cs_locale() functions, which are currently stubbed
in freetds cvs.

I have found a little hack that allows me to do it like this:

// create dummy cs_connection structure to point to tds_login
struct tds_cs_connection {
CS_CONTEXT *ctx;
TDSLOGIN *tds_login;
};
// m_connection is an already-allocated CS_CONNECTION *
tds_cs_connection *tconn = (tds_cs_connection *)m_connection;
tconn->tds_login->server_charset = (DSTR)strdup(db_encoding);

This works, but is ugly, dangerous and very hacky.

I believe I can make a patch for freetds' ct-lib to allow at least the
character set encoding to be set for the tds login.

With sybase's ct-lib, my code looks like this (error-handling removed):
CS_LOCALE* m_charset_locale;
ret = cs_loc_alloc(m_context, &m_charset_locale);
ret = cs_locale(m_context, CS_SET, m_charset_locale, CS_LC_ALL, 0,
CS_NULLTERM, 0);
ret = cs_locale(m_context, CS_SET, m_charset_locale,
CS_SYB_CHARSET, (CS_CHAR*)db_encoding, CS_NULLTERM, 0);
ret = ct_con_props(m_connection, CS_SET, CS_LOC_PROP,
m_charset_locale, CS_UNUSED, 0);

So I would develop code for the following functions:
cs_loc_alloc() cs_loc_drop()
cs_locale() (at least to handle the above, maybe also code to handle
setting tds_login.language as well?)
ct_con_props() CS_SET CS_LOC_PROP and CS_GET CS_LOC_PROP looks
non-functional to me as well; I would make this work as well

I just want to check before I make such a patch that the patch would
be welcome and that nobody else is already working on this.

Note that in my last message where I posted a bug report about getting
an Unknown marker client error message, I did not use the hack I
described above to reproduce the error or to generate the tds dump
file - I disabled the hack and set the encoding in freetds.conf
(altough FWIW the same results happen if I use my hack).

thanks,
David




Archive powered by MHonArc 2.6.24.

Top of Page