Skip to Content.
Sympa Menu

freetds - Re: [freetds] 0.64rc2 Debian prerelease packages available

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Steve Langasek <vorlon AT dodds.net>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] 0.64rc2 Debian prerelease packages available
  • Date: Fri, 31 Mar 2006 13:15:10 -0800

On Fri, Mar 31, 2006 at 12:06:44PM +0200, ZIGLIO, Frediano, VF-IT wrote:
> > The packages include two patches of significance. One is a
> > further fix for
> > 64-bit ODBC compatibility which I'd like to submit for
> > consideration for
> > 0.64; without it, FreeTDS fails to build on 64-bit Debian systems with
> > gcc-4.0. (On non-Debian systems, it may build successfully
> > only because
> > UnixODBC is currently not 64-bit clean by default upstream.)

> I don't see anything wrong in 64-bit patch, if it do not compile for
> some reason it should be included in 0.64. How do you compile unixODBC
> for 64-bit platforms?

Using the BUILD_REAL_64_BIT_MODE define, to get 64-bit data types where
they're needed.

> Well, the truth is that ODBC itself is not 64 bit clean!!!

Yes, I'm aware of that. I'm more concerned about working software than I am
about compliance with broken standards maintained by companies that haven't
been able to produce a 64-bit OS a decade after the advent of the DEC Alpha.
Building with BUILD_REAL_64_BIT_MODE in unixodbc gets me working software.
:)

> > The other is a re-worked locale patch, replacing the
> > ill-fated locale patch
> > in Debian sarge (yes, this means the Debian packages will no longer be
> > screwing up your date formats!); I think it's ready to be
> > submitted for
> > inclusion in FreeTDS, though probably not for 0.64.

> Mmmm... no I don't remember a patch, could you explain why your patch is
> needed? What are the problems in current implementation?

This was discussed a couple years back on the list, but I didn't really
follow through on it. My objection to the current locale handling in
FreeTDS is that it requires manual configuration, per-database (AFAICT), to
specify the client charset used for passing data back to the client
application. But locales already specify that charset preference, and on
systems with nl_langinfo() (which includes all modern GNU/Linux systems),
it's possible for applications/libs to programmatically query this charset
preference.

Bottom line is, I don't want to have to twiddle files in /etc/freetds/ in
order to get sqsh to display its output in my configured character set when
this should be completely unnecessary.

So I think the order of preference for charset configuration should be, from
highest to lowest:

- per-database client charset setting from /etc/freetds/freetds.conf
- locale-derived client charset setting
- per-locale client charset setting from /etc/freetds/locales.conf
- default client charset setting from /etc/freetds/locales.conf

The patch which I think does this is the one attached.

Thanks,
--
Steve Langasek Give me a lever long enough and a Free OS
Debian Developer to set it on, and I can move the world.
vorlon AT debian.org http://www.debian.org/
--- freetds-0.64~rc2.orig/include/tds.h
+++ freetds-0.64~rc2/include/tds.h
@@ -778,6 +778,7 @@
{
char *language;
char *char_set;
+ char *client_charset;
char *date_fmt;
} TDSLOCALE;

--- freetds-0.64~rc2.orig/src/tds/mem.c
+++ freetds-0.64~rc2/src/tds/mem.c
@@ -622,6 +622,9 @@
if (locale->char_set)
if (!tds_dstr_copy(&connection->server_charset,
locale->char_set))
goto Cleanup;
+ if (locale->client_charset)
+ if
(!tds_dstr_copy(&connection->client_charset,locale->client_charset))
+ goto Cleanup;
}
if (tds_dstr_isempty(&connection->language)) {
if (!tds_dstr_copy(&connection->language, TDS_DEF_LANG))
@@ -876,6 +879,8 @@
free(locale->char_set);
if (locale->date_fmt)
free(locale->date_fmt);
+ if (locale->client_charset)
+ free(locale->client_charset);
free(locale);
}

--- freetds-0.64~rc2.orig/src/tds/locale.c
+++ freetds-0.64~rc2/src/tds/locale.c
@@ -33,6 +33,10 @@
#include <stdlib.h>
#endif /* HAVE_STDLIB_H */

+#ifdef HAVE_LANGINFO_H
+#include <langinfo.h>
+#endif
+
#include "tds.h"
#include "tds_configs.h"
#include "replacements.h"
@@ -61,18 +65,27 @@
if (!locale)
return NULL;

+ locale->client_charset = NULL;
tdsdump_log(TDS_DBG_INFO1, "Attempting to read locales.conf file\n");

in = fopen(FREETDS_LOCALECONFFILE, "r");
if (in) {
tds_read_conf_section(in, "default", tds_parse_locale,
locale);
-
+ }
+#ifdef HAVE_NL_LANGINFO
+ if ((s = nl_langinfo(CODESET))) {
+ if (locale->char_set) free(locale->char_set);
+ if (locale->client_charset) free(locale->client_charset);
+ locale->client_charset = strdup(s);
+ locale->char_set = strdup(s);
+ }
+#endif
+ if (in) {
s = getenv("LANG");
if (s && s[0]) {
int found;
char buf[128];
const char *strip = "@._";
- const char *charset = NULL;

/* do not change environment !!! */
tds_strlcpy(buf, s, sizeof(buf));
@@ -95,18 +108,9 @@
if (!s)
continue;
*s = 0;
- if (*strip == '.')
- charset = s+1;
rewind(in);
found = tds_read_conf_section(in, buf,
tds_parse_locale, locale);
}
-
- /* charset specified in LANG ?? */
- if (charset) {
- if (locale->char_set)
- free(locale->char_set);
- locale->char_set = strdup(charset);
- }
}

fclose(in);
@@ -123,6 +127,10 @@
if (locale->char_set)
free(locale->char_set);
locale->char_set = strdup(value);
+ } else if (!strcmp(option, TDS_STR_CLCHARSET)) {
+ if (locale->client_charset)
+ free(locale->client_charset);
+ locale->client_charset = strdup(value);
} else if (!strcmp(option, TDS_STR_LANGUAGE)) {
if (locale->language)
free(locale->language);

Attachment: signature.asc
Description: Digital signature




Archive powered by MHonArc 2.6.24.

Top of Page