|
From: <do...@us...> - 2008-04-19 12:35:31
|
Update of /cvsroot/aolserver/nsfreetds In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv10954 Modified Files: nsfreetds.c Added Files: nsfreetds.html Log Message: Added parameters for 'clientcharset', 'language', 'packetsize' and 'tdsversion'. See nsfreetds.html for documentation. --- NEW FILE: nsfreetds.html --- <html> <head> <title>nsfreetds</title> </head> <body bgcolor="#ffffff"> <h2>nsfreetds -- TDS (Sybase, MS SQL Server) database driver using FreeTDS</h2> <p>$Header: /cvsroot/aolserver/nsfreetds/nsfreetds.html,v 1.1 2008/04/19 12:35:35 dossy Exp $</p> <ul> <li><a href="#Theory_of_Operation">Theory of Operation</a></li> <li><a href="#Known_Issues">Known Issues</a></li> <li><a href="#Configuration_Options">Configuration Options</a></li> <li><a href="#Sample_Configuration">Sample Configuration</a></li> </ul> <h3><a name="Theory_of_Operation">Theory of Operation</a></h3> <p>The nsfreetds module provides the database driver to nsdb for connecting to TDS-based databases such as Sybase or Microsoft's SQL Server, using the <a href="http://www.freetds.org/">FreeTDS</a> library.</p> <h3><a name="Known_Issues">Known Issues</a></h3> <p>As nsfreetds relies on FreeTDS for its underlying protocol implementation, any issues with FreeTDS will affect nsfreetds operation.</p> <h3><a name="Configuration_Options">Configuration Options</a></h3> <p>The following options are available for configuring a nsfreetds database pool:</p> <table border="1"> <tr> <th>Option</th> <th>Type</th> <th>Default</th> <th>Description</th> </tr> <tr> <td>clientcharset</td> <td>string</td> <td>iso_1</td> <td>The client character set to use when connecting to the database. The default is "iso_1" but may need to be set to "UTF-8". This setting is case-sensitive.</td> </tr> <tr> <td>language</td> <td>string</td> <td>us_english</td> <td>Controls the language for the session. Valid language names are listed in <b>syslanguages</b>.</td> </tr> <tr> <td>packetsize</td> <td>integer</td> <td>512</td> <td>Controls the size of TDS packets. Note: A TDS packet that is longer than 512 bytes is split on the 512 byte boundary and the "more packets" bit is set. [<a href="http://www.freetds.org/tds.html#packet">#</a>]</td> </tr> <tr> <td>tdsversion</td> <td>decimal</td> <td>8.0</td> <td>Selects the version of the TDS protocol to use when connecting to the database. The default is TDS 8.0.</td> </tr> </table> <h3><a name="Sample_Configuration">Sample Configuration</a></h3> <pre> # # TDS database pools -- nsfreetds # ns_section "ns/server/${servername}/modules" ns_param nsdb ${bindir}/nsdb.so ns_section "ns/server/${servername}/db" ns_param defaultpool test ns_param pools * ns_section "ns/db/drivers" ns_param nsfreetds ${bindir}/nsfreetds.so ns_section "ns/db/pools" ns_param test "nsfreetds" ns_section "ns/db/pool/test" ns_param driver nsfreetds ns_param connections 10 ns_param user USERNAME ns_param password PASSWORD ns_param datasource HOSTNAME:PORT:DATABASENAME ns_param tdsversion 8.0 ns_param clientcharset UTF-8 ns_param language us_english ns_param packetsize 512 </pre> </body> </html> Index: nsfreetds.c =================================================================== RCS file: /cvsroot/aolserver/nsfreetds/nsfreetds.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** nsfreetds.c 18 Apr 2008 01:38:18 -0000 1.8 --- nsfreetds.c 19 Apr 2008 12:35:35 -0000 1.9 *************** *** 72,77 **** #include <assert.h> - - #define MAX_IDENTIFIER 256 #define DRIVER_VERSION "Panoptic FreeTDS Driver v0.4" --- 72,75 ---- *************** *** 160,165 **** TDSSOCKET *tds; TDSCONNECTION *connect_info; ! const char *locale = NULL; ! char *charset = NULL; void **ctxArray; --- 158,165 ---- TDSSOCKET *tds; TDSCONNECTION *connect_info; ! char *path; ! // const char *locale = NULL; ! char *charset, *language, *tdsversion; ! int tds_major = 8, tds_minor = 0, packetsize = 512; void **ctxArray; *************** *** 186,189 **** --- 186,208 ---- } + path = Ns_ConfigGetPath(NULL, NULL, "db", "pool", handle->poolname, NULL); + if (!(charset = Ns_ConfigGetValue(path, "clientcharset"))) { + charset = "iso_1"; + } + if (!(language = Ns_ConfigGetValue(path, "language"))) { + language = "us_english"; + } + if (!Ns_ConfigGetInt(path, "packetsize", &packetsize) + || packetsize < 512) { + packetsize = 512; + } + if (!(tdsversion = Ns_ConfigGetValue(path, "tdsversion"))) { + if (sscanf(tdsversion, "%u.%u", &tds_major, &tds_minor) != 2) { + Ns_Log(Notice, "nsfreetds: DbOpen(%s): could not parse \"tdsversion\" database pool parameter '%s'.", + handle->datasource, tdsversion); + return NS_ERROR; + } + } + if (context->locale && !context->locale->date_fmt) { /* set default in case there's no locale file */ *************** *** 194,197 **** --- 213,218 ---- context->err_handler = Ns_FreeTDS_Err_Handler; + + #if 0 setlocale(LC_ALL, ""); locale = setlocale(LC_ALL, NULL); *************** *** 203,210 **** charset = "iso_1"; } ! tds_set_version(login, 8, 0); /* FIXME: Use ns_param tdsversion */ ! tds_set_app(login, DbName()); ! tds_set_library(login, "TDS-Library"); tds_set_server(login, handle->datasource); --- 224,232 ---- charset = "iso_1"; } + #endif ! tds_set_version(login, tds_major, tds_minor); ! tds_set_app(login, Ns_InfoServerName()); ! tds_set_library(login, DbName()); tds_set_server(login, handle->datasource); *************** *** 212,221 **** tds_set_passwd(login, handle->password); ! tds_set_host(login, "myhost"); /* FIXME: aolserver instance name? */ tds_set_client_charset(login, charset); ! tds_set_language(login, "us_english"); ! tds_set_packet(login, 512); ! tds = tds_alloc_socket(context, 512); if (!tds) { Ns_Log(Notice, "nsfreetds: DbOpen(%s): tds_alloc_socket() failed.", --- 234,243 ---- tds_set_passwd(login, handle->password); ! tds_set_host(login, Ns_InfoHostname()); tds_set_client_charset(login, charset); ! tds_set_language(login, language); ! tds_set_packet(login, packetsize); ! tds = tds_alloc_socket(context, packetsize); if (!tds) { Ns_Log(Notice, "nsfreetds: DbOpen(%s): tds_alloc_socket() failed.", *************** *** 252,258 **** void **ctxArray = (void **) handle->context; ! if (handle->verbose) { Ns_Log(Notice, "nsfreetds: DbClose(%s) called.", handle->datasource); - } tds_free_socket(GET_TDS(handle)); --- 274,279 ---- void **ctxArray = (void **) handle->context; ! if (handle->verbose) Ns_Log(Notice, "nsfreetds: DbClose(%s) called.", handle->datasource); tds_free_socket(GET_TDS(handle)); *************** *** 336,340 **** srclen = col->column_cur_size; - // Ns_Log(Notice, "nsfreetds: DbGetRow(%s): src = {%s}", handle->datasource, src); if ((destlen = tds_convert(GET_TDS(handle)->tds_ctx, ctype, (const TDS_CHAR *) src, (unsigned) srclen, --- 357,360 ---- |