This file is part of mingw-cross-env. See doc/index.html for further information. Fast-forward to latest FreeTDS from cvs http://sourceforge.net/scm/?type=cvs&group.id=33106 Produced with this script: #--------------------------------------------------------------------# #!/bin/bash ( echo "This file is part of mingw-cross-env." echo "See doc/index.html for further information." echo echo "Fast-forward to latest FreeTDS from cvs" echo "http://sourceforge.net/scm/?type=cvs&group.id=33106" echo echo "Produced with this script:" echo "#--------------------------------------------------------------------#" cat "$0" echo "#--------------------------------------------------------------------#" ) > src/freetds-1-fastforward.patch GITDIR=~/projects/freetds.dev/git-freetds PKGDIR=freetds-0.82 # create or update clone (cd "$GITDIR" && git cvsimport -v -d:pserver:anonymous@freetds.cvs.sourceforge.net:/cvsroot/freetds freetds) rm -rf $PKGDIR tar xf pkg/$PKGDIR.tar.gz ( cd $GITDIR git reset --hard git checkout R0_82 ) lst="\ ChangeLog-0.82 \ INSTALL.CVS \ TODO.freddy \ configure.ac \ doc/htdoc/news.html \ doc/htdoc/faq.html \ doc/htdoc/contrib.html \ doc/htdoc/support.html \ doc/README.releasing \ doc/txt2man \ misc/bounce.c \ misc/freetds_autobuild \ misc/test-dist.sh \ misc/test-auto.sh \ misc/test-other.sh \ mkinstalldirs \ samples/odbc_rpc.pl \ src/pool/stream.c \ src/tds/alternative_character_sets.h \ src/tds/character_sets.h \ src/tds/encodings.pl \ src/tds/num_limits.pl \ src/tds/unittests/flags.c \ src/tds/tds_willconvert.pl \ src/odbc/unittests/rownumber.c \ src/odbc/checkexport.sh \ vms/Makefile.am \ win32/build_dsw.pl \ " lst="$lst $(cd $GITDIR && find -name .cvsignore)" for a in $lst; do if [ -f $PKGDIR/$a ]; then cp $PKGDIR/$a $GITDIR/$a else rm $GITDIR/$a fi done # write reset patch ( cd $GITDIR echo echo "======== reset files to match 0.82 tag" git diff -R R0_82 -- $lst ) >> src/freetds-1-fastforward.patch ( cd $GITDIR git reset --hard ) # write rewind commits ( cd $GITDIR echo echo "======== climb down out of branch" git log -R -p ^branch-0-82 R0_82 #git diff -R branch-0-82 R0_82 ) >> src/freetds-1-fastforward.patch ( cd $GITDIR git checkout master git reset --hard ) # write fast forward commits ( cd $GITDIR echo echo "======== fast forward to latest" git log --reverse -p ^branch-0-82 master #git diff branch-0-82 master ) >> src/freetds-1-fastforward.patch # check the results cat src/freetds-1-fastforward.patch \ | patch -d $PKGDIR -p1 -s diff -x Makefile.in -rq $GITDIR $PKGDIR #--------------------------------------------------------------------# ======== reset files to match 0.82 tag diff --git b/.cvsignore a/.cvsignore new file mode 100644 index 0000000..d6098e5 --- /dev/null +++ a/.cvsignore @@ -0,0 +1,21 @@ +config.log +config.cache +config.status +config.sub +config.guess +configure +Makefile +Makefile.in +libtool +ltmain.sh +ltconfig +ltcf-c.sh +aclocal.m4 +autom4te.cache +depcomp +so_locations +freetds.spec +PWD +doxyfile +test-dist.log +compile diff --git b/ChangeLog-0.82 a/ChangeLog-0.82 new file mode 100644 index 0000000..cc4cbea --- /dev/null +++ a/ChangeLog-0.82 @@ -0,0 +1,2289 @@ +Tue Jan 8 10:31:43 EST 2008 JK Lowden + * doc/Makefile.am added freetds.conf.5 + * src/dblib/bcp.c applied BCPKEEPIDENTIY patch + - from Jonathan Olson + +Tue Jan 8 14:28:09 CET 2008 Frediano Ziglio + * NEWS doc/README.releasing doc/userguide.sgml: + - updates for new release + +Tue Jan 8 10:33:26 CET 2008 Frediano Ziglio + * src/odbc/unittests/genparams.c: relax for no-dm + +Mon Jan 7 19:32:20 CET 2008 Frediano Ziglio + * src/odbc/sql2tds.c src/odbc/unittests/genparams.c: + - fix millisecond round off for TIMESTAMP + - improve genparams test to catch this problem + - make genparams works with MS ODBC + +Mon Jan 7 15:04:18 CET 2008 Frediano Ziglio + * include/tdssrv.h src/server/login.c src/server/server.c: + * src/server/unittest.c: + - small improves + * src/pool/user.c: style update + +Sun Jan 6 11:48:17 CET 2008 Frediano Ziglio + * src/odbc/odbc.c: even SQLExecDirect support parameters! + * src/odbc/unittests/genparams.c: improve + +Sat Jan 5 12:23:21 CET 2008 Frediano Ziglio + * src/tds/query.c: + - add parameterized flag calling sp_cursoropen if needed + +Wed Jan 2 00:08:45 CET 2008 Frediano Ziglio + * configure.ac src/apps/Makefile.am: + - remove GNU style + * src/dblib/dblib.c: make it compile + + +Mon Dec 31 15:05:16 EST 2007 JK Lowden + * src/dblib/dblib.c fixed DBPRPAD, maybe + +Mon Dec 31 11:29:50 CET 2007 Frediano Ziglio + * misc/test-other.sh src/odbc/odbc.c: + - relax test for cursor + +Mon Dec 31 11:06:13 CET 2007 Frediano Ziglio + * src/ctlib/blk.c src/odbc/unittests/attributes.c: + * src/odbc/unittests/describecol.c src/tds/convert.c: + * src/tds/login.c src/tds/mem.c: + - minor signed/unsigned fixes + * src/dblib/bcp.c: minor performance improve + * src/dblib/dblib.c: fix date portability + +Fri Dec 28 17:57:08 EST 2007 JK Lowden + * src/tds/token.c minor change + * src/tds/convert.c simpler tds_strftime + * src/dblib/unittests/done_handling.c no spurious messages + +Wed Dec 28 15:11:48 CET 2007 Frediano Ziglio + * doc/userguide.sgml: accepted patch #1854381 + +Wed Dec 28 14:44:16 CET 2007 Frediano Ziglio + * misc/freetds_autobuild misc/test-other.sh: + - make amd64 works + * misc/test-auto.sh: add --help option + * src/tds/convert.c: + - fix overflow in tds_convert_char + - minor fixes for tds_strftime + +Thu Dec 27 14:43:14 CET 2007 Frediano Ziglio + * doc/.cvsignore: ignore autogenerated + * include/tds.h src/replacements/vasprintf.c src/tds/convert.c: + * src/tds/login.c src/tds/query.c src/tds/read.c: + - remove some warnings + +Thu Dec 27 11:20:55 CET 2007 Frediano Ziglio + * src/odbc/unittests/common.c: make unixODBC happy + * win32/config.h: define TDS_I64_FORMAT + +Thu Dec 27 10:19:58 CET 2007 Frediano Ziglio + * src/dblib/buffering.h: + - remove warning if compiled with NDEBUG defined + +Wed Dec 26 21:57:12 CET 2007 Frediano Ziglio + * src/odbc/unittests/attributes.c: make it works + +Wed Dec 26 19:44:47 CET 2007 Frediano Ziglio + * doc/freetds.conf.5: typo fix + * src/ctlib/unittests/common.c: make tests compile + * src/odbc/odbc.c: add diagnostic for truncate + +Tue Dec 25 00:55:02 EST 2007 JK Lowden + * freetds.conf doc/Makefile.am doc/freetds.conf.5 (added) + - shortened default freetds.conf and moved documentation + - to a proper man page. Merry Christmas! + +Mon Dec 24 11:34:58 CET 2007 Frediano Ziglio + * include/tds.h: removed unused fields + +Sun Dec 23 16:08:29 EST 2007 JK Lowden + * src/apps/tsql.c + * src/ctlib/cs.c src/ctlib/unittests/common.c + * src/dblib/dblib.c + * src/tds/config.c src/tds/unittests/convert.c + - added STD_DATETIME_FMT to allow for WIN32 shortcomings + +Fri Dec 21 16:20:03 CET 2007 Frediano Ziglio + * include/tds.h src/ctlib/ct.c src/odbc/odbc.c src/tds/query.c: + - make odbc cursor test work using sp_cursoropen with parameters + +Fri Dec 21 11:38:47 CET 2007 Frediano Ziglio + * src/odbc/unittests/common.c src/odbc/unittests/common.h: + * src/odbc/unittests/cursor3.c src/odbc/unittests/cursor4.c: + * src/odbc/unittests/cursor5.c: + - cursor tests should work + +Fri Dec 21 10:05:12 CET 2007 Frediano Ziglio + * configure.ac include/replacements.h src/replacements/vasprintf.c: + * win32/config.h: + - applied modified patch #1848920 + +Thu Dec 20 22:56:34 CET 2007 Frediano Ziglio + * src/dblib/dblib.c src/dblib/unittests/common.h: + * src/dblib/unittests/setnull.c src/dblib/unittests/thread.c: + - remove warnings + +Thu Dec 20 17:46:03 CET 2007 Frediano Ziglio + * src/odbc/odbc.c: + - improve cursor attribute setting + - fix a small issue with unixODBC and 64 bit + +Wed Dec 19 16:08:17 CET 2007 Frediano Ziglio + * src/odbc/unittests/cursor3.c src/odbc/unittests/cursor4.c: + - remove warnings + +Wed Dec 19 15:35:22 CET 2007 Frediano Ziglio + * src/odbc/unittests/attributes.c(added) src/odbc/unittests/attributes.in(added): + * src/odbc/unittests/Makefile.am: add a test for statement attributes + * src/odbc/unittests/describecol.c: fix possible core + +Tue Dec 18 09:09:27 CET 2007 Frediano Ziglio + * src/odbc/unittests/Makefile.am src/odbc/unittests/cursor3.c(added): + * src/odbc/unittests/cursor4.c(added) src/odbc/unittests/cursor5.c(added): + - merged test from Sebastien FLAESCH + +Sun Dec 16 19:08:38 EST 2007 JK Lowden + * doc/api_status.txt + - set useless db-lib functions' status to 'never' + +Sun Dec 16 16:58:35 EST 2007 JK Lowden + * doc/Makefile.am doc/bsqlodbc.txt doc/osql.txt + * doc/userguide.sgml + - updated for next release + +Fri Dec 14 11:23:08 CET 2007 Frediano Ziglio + * misc/test-other.sh: fix some strange echo portability + * src/dblib/unittests/null.c src/dblib/unittests/null2.c: + - make ignore less verbose + +Thu Dec 13 23:45:55 EST 2007 JK Lowden + * src/apps/Makefile.am build bsqlodbc out-of-tree + * src/dblib/unittests/null.c prettier & correct, passes + +Thu Dec 13 21:12:20 CET 2007 Frediano Ziglio + * src/dblib/buffering.h: fix null2 + +Thu Dec 13 19:04:35 CET 2007 Frediano Ziglio + * src/apps/Makefile.am: + - fix bsqlodbc compile if not standard sql.h path + +Wed Dec 12 07:27:07 CET 2007 Frediano Ziglio + * src/tds/net.c: fix for 64bit + +Tue Dec 11 11:09:52 CET 2007 Frediano Ziglio + * doc/userguide.sgml: remove warning + * misc/freetds_autobuild: fix if password empty + +Tue Dec 11 00:02:16 EST 2007 JK Lowden + * doc/userguide.sgml minor touchups + * src/dblib/dblib.c src/dblib/unittests/setnull.c + - unittests/setnull.c passes. + +Mon Dec 10 14:05:06 CET 2007 Frediano Ziglio + * src/tds/convert.c: remove warning + +Mon Dec 10 00:08:45 EST 2007 JK Lowden + * doc/Makefile.am doc/userguide.sgml some improvements + doc/grep_sample_code doc/images/caution.gif + doc/images/warning.gif + doc/images/callouts/1.gif doc/images/callouts/2.gif + doc/images/callouts/3.gif doc/images/callouts/4.gif + doc/images/callouts/5.gif doc/images/callouts/6.gif + doc/images/callouts/7.gif doc/images/callouts/8.gif + doc/images/callouts/9.gif doc/images/callouts/10.gif + - added from http://tldp.org/LDP/abs/images/ + +Sun Dec 9 19:51:11 EST 2007 JK Lowden + * doc/userguide.sgml added tenderfoot tutorial + +Fri Dec 7 00:26:01 EST 2007 JK Lowden + * include/tds.h src/dblib/dblib.c + * src/dblib/dbutil.c src/tds/util.c + - pass errno via tdserror. + +Thu Dec 6 21:41:23 EST 2007 JK Lowden + * src/tds/convert.c tds_willconvert returns size + +Thu Dec 6 21:32:13 CET 2007 Frediano Ziglio + * src/dblib/dblib.c: fix for 64bit machines + * src/dblib/unittests/setnull.c: improve + +Thu Dec 6 19:59:59 CET 2007 Frediano Ziglio + * configure.ac include/replacements.h src/apps/bsqldb.c: + * src/dblib/unittests/setnull.c: + - use basename from MingW if available + * src/dblib/dblib.c: fix malloc portability problem + +Thu Dec 6 10:18:54 CET 2007 Frediano Ziglio + * src/dblib/rpc.c src/dblib/unittests/setnull.c: + - fix compile problems + +Thu Dec 6 01:00:42 EST 2007 JK Lowden + * src/dblib/buffering.h src/dblib/dblib.c: + - dbgetnull tolerates negative varlen, looks pretty good + +Wed Dec 5 10:38:55 EST 2007 JK Lowden + * src/dblib/dblib.c: + - t0011 passes but copy_data_to_host_var likely wrong + +Tue Dec 4 20:19:38 EST 2007 JK Lowden + * include/dblib.h src/dblib/buffering.h src/dblib/dblib.c: + - removed _db_set_null and associated mallocs + - dblib/unittest/t0011.c failing mysteriously + +Mon Dec 3 23:18:55 EST 2007 JK Lowden + * src/dblib/dblib.c src/dblib/unittests/setnull.c: + - corrected dbsetnull() + +Mon Dec 3 18:45:22 EST 2007 JK Lowden + * src/apps/bsqldb.c + * src/dblib/bcp.c src/dblib/dblib.c src/dblib/unittests/rpc.c + * src/dblib/unittests/setnull.c src/dblib/unittests/t0001.c + * src/dblib/unittests/t0002.c src/dblib/unittests/t0003.c + * src/dblib/unittests/t0004.c src/dblib/unittests/t0005.c + * src/dblib/unittests/t0006.c src/dblib/unittests/t0007.c + * src/dblib/unittests/t0008.c src/dblib/unittests/t0011.c + * src/dblib/unittests/t0015.c src/dblib/unittests/t0018.c + * src/dblib/unittests/t0023.c src/dblib/unittests/text_buffer.c + * src/dblib/unittests/thread.c src/dblib/unittests/timeout.c: + - dbbind uses zero, not -1 to indicate sufficient space. + +Mon Dec 3 17:57:54 EST 2007 JK Lowden + * src/dblib/bcp.c: don't cast malloc and don't assume it worked. + +Mon Dec 3 19:54:53 CET 2007 Frediano Ziglio + * src/odbc/Makefile.am: remove GNU make pattern + +Mon Dec 3 15:35:45 CET 2007 Frediano Ziglio + * src/dblib/dblib.c: + - do not call dbcolptr for compute result but call new dbacolptr + - dbcolptr return TDSCOLUMN* to optimize it + +Mon Dec 3 11:53:56 CET 2007 Frediano Ziglio + * src/dblib/dblib.c: remove a warning + +Mon Dec 3 10:18:39 CET 2007 Frediano Ziglio + * src/dblib/dblib.c src/dblib/unittests/.cvsignore: + * src/dblib/unittests/Makefile.am src/dblib/unittests/setnull.c(added): + - add a test for setnull + +Sun Dec 2 17:58:40 EST 2007 JK Lowden + * doc/api_status.txt + * include/dblib.h include/sybdb.h include/tds.h + * src/ctlib/blk.c src/dblib/bcp.c src/dblib/dblib.c + - full implementation of dbsetnull(). + - Replaced _DB_GETCOLINFO macro with dbcolptr(). + +Sat Dec 1 14:05:54 EST 2007 JK Lowden + * src/dblib/bcp.c src/dblib/unittests/null.c + - correct TDS 5.0 bcp offset table calcuation in presence of NULLs. + +Fri Nov 30 09:54:46 CET 2007 Frediano Ziglio + * src/dblib/unittests/common.c: missing new line + +Thu Nov 29 09:03:32 CET 2007 Frediano Ziglio + * src/dblib/unittests/null2.c: improve + +Wed Nov 28 15:15:43 CET 2007 Frediano Ziglio + * configure.ac: + - include windows.h under windows + - include sql.h directly to avoid MingW problems + * include/dblib.h src/dblib/bcp.c src/dblib/dblib.c src/dblib/rpc.c: + - avoid core checking for parameters if argument are expected + * src/dblib/unittests/null.c src/dblib/unittests/null2.c: + - avoid invalid references to deallocated stack + +Wed Nov 28 09:48:50 CET 2007 Frediano Ziglio + * src/dblib/bcp.c: remove warnings + +Wed Nov 28 00:27:36 EST 2007 JK Lowden + * src/dblib/bcp.c fixed TDS 5.0 null-column bug, cf. ML + * doc/tds.html Added BCP, made 4.01 strict, validated. + +Tue Nov 27 16:12:56 CET 2007 Frediano Ziglio + * src/dblib/unittests/Makefile.am src/dblib/unittests/null2.c(added): + - test dbbind/dbnullbind with NULLs + * src/dblib/unittests/null.c: add note + +Tue Nov 27 13:37:35 CET 2007 Frediano Ziglio + * src/dblib/unittests/t0001.c src/dblib/unittests/t0022.c: + - compile with Sybase libraries + * src/dblib/unittests/t0008.c: more verbose + +Mon Nov 26 21:02:57 CET 2007 Frediano Ziglio + * src/odbc/unittests/array_out.c: fix silly core + +Mon Nov 26 19:11:12 CET 2007 Frediano Ziglio + * configure.ac include/tdsodbc.h src/odbc/odbc.c: + * src/odbc/unittests/array_out.c src/odbc/unittests/common.h: + * src/odbc/unittests/describecol.c src/odbc/unittests/freeclose.c: + * src/odbc/unittests/insert_speed.c src/odbc/unittests/timeout.c: + * src/odbc/unittests/timeout3.c src/odbc/unittests/type.c: + - minor fixes for 64bit + +Mon Nov 26 16:47:34 CET 2007 Frediano Ziglio + * configure.ac src/apps/fisql/fisql.c: + - do not use functions not availables + +Mon Nov 26 09:43:03 EST 2007 JK Lowden + * src/dblib/bcp.c src/tds/unittests/iconv_fread.c + - small changes + +Mon Nov 26 09:51:21 CET 2007 Frediano Ziglio + * src/dblib/unittests/bcp.c: fix printf + +Mon Nov 26 07:24:43 CET 2007 Frediano Ziglio + * src/odbc/unittests/array.c src/odbc/unittests/array_out.c: + * src/odbc/unittests/const_params.c src/odbc/unittests/cursor1.c: + * src/odbc/unittests/describecol.c src/odbc/unittests/freeclose.c: + * src/odbc/unittests/insert_speed.c src/odbc/unittests/raiserror.c: + * src/odbc/unittests/rpc.c src/odbc/unittests/scroll.c: + * src/tds/challenge.c: + - fix minor issues with 64bit + +Thu Nov 22 09:43:58 CET 2007 Frediano Ziglio + * configure.ac src/ctlib/Makefile.am src/dblib/Makefile.am: + * src/odbc/Makefile.am: + - do not filter symbols under MacOsX (avoid libtool problems) + +Wed Nov 21 11:31:37 EST 2007 JK Lowden + * src/ctlib/blk.c: correctly test result of cs_convert + * src/dblib/rpc.c: minor edits + * src/dblib/unittests/bcp.c src/dblib/unittests/bcp.h: + - test works for TDS 7.0. + +Tue Nov 20 23:08:15 EST 2007 JK Lowden + * src/dblib/bcp.c src/dblib/unittests/bcp.c: + * src/dblib/dblib.c src/tds/convert.c src/tds/net.c: + - small changes + +Thu Nov 15 14:32:50 CET 2007 Frediano Ziglio + * src/dblib/unittests/.cvsignore src/dblib/dblib.c: + * src/dblib/unittests/Makefile.am src/dblib/unittests/null.c: + - fix problem with empty string and TEXT + - add a test to test empty/NULL behavior of dbdatlen/dbdata + +Thu Nov 15 10:18:40 CET 2007 Frediano Ziglio + * src/tds/login.c: return error if no username given and no Kerberos + +Tue Nov 13 10:13:06 CET 2007 Frediano Ziglio + * include/tds.h src/tds/challenge.c src/tds/gssapi.c: + * src/tds/login.c src/tds/token.c: + - port ntlm to new authentication code + - move all ntlm stuff to challenge.c + +Mon Nov 12 17:15:03 EST 2007 JK Lowden + * include/sybdb.h src/dblib/bcp.c + * src/dblib/dblib.c src/dblib/dbutil.c + * src/dblib/rpc.c + * src/tds/log.c src/tds/login.c + - trying to convince Doxygen not to ignore functions, + - e.g. dbinit + +Mon Nov 12 13:38:04 EST 2007 JK Lowden + * include/dblib.h src/dblib/dbutil.c + * src/dblib/dblib.c src/dblib/rpc.c src/dblib/bcp.c + - added DBDEAD test to all public functions + +Mon Nov 12 14:32:53 CET 2007 Frediano Ziglio + * configure.ac: cleanup + * src/tds/gssapi.c: compute fqdn name in service name + +Mon Nov 12 12:34:14 CET 2007 Frediano Ziglio + * configure.ac include/tds.h src/tds/gssapi.c: + * src/tds/login.c src/tds/mem.c src/tds/token.c: + - new TDSAUTHENTICATION structure + - new --enable-krb5 to enable Kerberos authentication + (disable by default) + +Fri Nov 09 11:29:21 CET 2007 Frediano Ziglio + * src/apps/tsql.c: remove some leaks + +Mon Nov 05 11:05:34 CET 2007 Frediano Ziglio + * src/apps/tsql.c: use pipes to avoid infinite counter + +Mon Nov 05 09:29:54 CET 2007 Frediano Ziglio + * src/tds/login.c: fix log avoidance for long logins + +Sun Nov 04 09:16:08 CET 2007 Frediano Ziglio + * src/tds/gssapi.c: small cleanup + +Sat Nov 03 14:31:40 CET 2007 Frediano Ziglio + * include/tds.h src/tds/config.c src/tds/mem.c: + - add server_host_name to TDSCONNECTION + * src/tds/gssapi.c: some improves + +Fri Nov 02 11:33:16 CET 2007 Frediano Ziglio + * src/tds/gssapi.c: add small comment + +Tue Oct 30 16:45:41 CET 2007 Frediano Ziglio + * src/tds/Makefile.am src/tds/gssapi.c src/tds/login.c: + - include developing code for GSSAPI + +Tue Oct 30 16:36:29 CET 2007 Frediano Ziglio + * include/tds.h src/tds/login.c src/ctlib/ct.c src/tds/read.c: + * src/tds/token.c: + - finish merging tds9 code as developing + +Tue Oct 30 16:02:04 CET 2007 Frediano Ziglio + * include/tdsodbc.h src/odbc/odbc.c: + - make odbc row_count 64bit + +Tue Oct 30 13:14:00 CET 2007 Frediano Ziglio + * src/tds/config.c src/tds/query.c: + - more merge for tds9 + +Tue Oct 30 11:31:30 CET 2007 Frediano Ziglio + * include/tds.h src/ctlib/blk.c src/dblib/bcp.c: + * src/server/server.c src/tds/token.c: + - merge partially tds9 patch + +Tue Oct 30 11:15:20 CET 2007 Frediano Ziglio + * src/tds/net.c: + - avoid wrong assert if error and tdserror called + * src/tds/query.c: limit data length to maximun allowed + +Wed Oct 24 17:55:56 EDT 2007 JK Lowden + * include/sqldb.h define dbfreelogin + * src/dblib/unittests/common.h add commentary + +Tue Oct 23 19:41:03 EDT 2007 JK Lowden + * src/tds/net.c src/tds/util.c + - ct-lib seems OK with EINTR (sqsh works) but db-lib + - applications get a weird message. + +Tue Oct 23 18:08:00 EDT 2007 JK Lowden + * src/tds/net.c + - return from tds_select as if timed out on EINTR. + - sqsh still unhappy when ^C pressed on long-running query. + +Thu Oct 18 16:48:23 CET 2007 Frediano Ziglio + * src/dblib/dblib.c: fix core + +Thu Oct 18 13:49:51 CET 2007 Frediano Ziglio + * src/tds/query.c src/tds/token.c: + - more free(NULL) + +Tue Oct 16 16:59:06 CET 2007 Frediano Ziglio + * src/apps/tsql.c src/ctlib/blk.c src/ctlib/cs.c src/ctlib/ct.c: + * src/dblib/bcp.c src/dblib/dblib.c src/dblib/rpc.c: + * src/dblib/unittests/rpc.c src/odbc/error.c src/odbc/odbc.c: + * src/odbc/sql2tds.c src/odbc/unittests/binary_test.c: + * src/pool/config.c src/tds/locale.c src/tds/login.c: + * src/tds/mem.c src/tds/query.c src/tds/token.c: + * src/tds/vstrbuild.c src/tds/unittests/dataread.c: + - do not check for free(NULL) + +Wed Oct 10 13:59:37 EDT 2007 JK Lowden + * src/apps/tsql.c + - added some error checking for malloc/realloc, more needed + +Tue Oct 09 13:40:24 CET 2007 Frediano Ziglio + * src/tds/mem.c: fix small memory leak + +Mon Sep 24 13:12:47 CET 2007 Frediano Ziglio + * src/tds/query.c: limit size preparing queries + +Mon Sep 24 12:01:46 CET 2007 Frediano Ziglio + * src/server/query.c src/server/server.c: + - small server improve + +Thu Sep 20 17:32:15 CET 2007 Frediano Ziglio + * include/sybdb.h src/dblib/dblib.c src/dblib/dbopen.c: + - apply constify patch #1786200 + +Thu Sep 20 17:02:20 CET 2007 Frediano Ziglio + * src/apps/tsql.c: do not strip empty lines + +Mon Sep 17 17:22:32 EDT 2007 JK Lowden + * src/dblib/bcp.c correct freebcp -L behavior + * src/tds/net.c TDSECONN on no socket failure + * src/tds/util.c change iconv messages + +Mon Sep 17 17:52:09 CET 2007 Frediano Ziglio + * doc/tds.html: update for tds9 + * src/server/login.c: remove warning + +Mon Sep 17 12:13:03 CET 2007 Frediano Ziglio + * src/apps/tsql.c: + - improve for very large query (from 9.2 to 0.3 seconds on my + test machine) + +Mon Sep 17 10:42:45 CET 2007 Frediano Ziglio + * doc/tds.html: update + * src/ctlib/unittests/get_send_data.c: small fix + * include/sybdb.h src/dblib/dblib.c src/dblib/unittests/t0022.c: + - small update for future tds9 + * src/pool/main.c src/pool/user.c src/server/login.c: + - improve portability and possible remote leakage + +Thu Sep 13 12:42:08 CET 2007 Frediano Ziglio + * src/odbc/unittests/freeclose.c: + - make it works even if login is quite long + +Thu Sep 13 08:57:26 CET 2007 Frediano Ziglio + * src/tds/unittests/dynamic1.c: use tds_set_param_type + +Thu Sep 06 13:15:54 CET 2007 Frediano Ziglio + * doc/tds.html: update for tds9 + * src/tds/read.c: work if initial in_pos is != 0 + +Sat Aug 25 12:32:01 CET 2007 Frediano Ziglio + * include/tdsodbc.h src/odbc/error.c src/odbc/odbc.c: + - use ODBC_API instead of SQL_API to allow combined compile + +Fri Aug 24 11:50:03 CET 2007 Frediano Ziglio + * include/tds.h src/ctlib/blk.c src/dblib/bcp.c src/tds/login.c: + * src/tds/query.c src/tds/token.c: + - small changes for TDS 9.0 + +Mon Aug 16 10:09:42 CET 2007 Frediano Ziglio + * src/ctlib/unittests/Makefile.am src/dblib/unittests/Makefile.am: + * src/odbc/unittests/Makefile.am src/tds/net.c: + * src/tds/unittests/Makefile.am: + - remove other warnings + +Mon Aug 16 08:29:38 CET 2007 Frediano Ziglio + * src/tds/unittests/convert.c win32/initnet.c: + - remove some warnings compiling with MingW + +Sat Aug 11 08:51:45 CET 2007 Frediano Ziglio + * src/dblib/dblib.c vms/config_h.vms vms/descrip_mms.template: + - applied Craig A. Berry patch #1772080 for VMS systems + +Fri Aug 10 11:17:32 CET 2007 Frediano Ziglio + * NEWS: updated + +Fri Aug 10 11:14:19 CET 2007 Frediano Ziglio + * win32/dev-cpp/Makefile.win: add missing file + +Thu Aug 09 14:52:45 CET 2007 Frediano Ziglio + * src/tds/net.c: small fixes + +Thu Aug 09 10:26:51 CET 2007 Frediano Ziglio + * doc/userguide.sgml: document port override syntax + +Thu Aug 09 09:49:34 CET 2007 Frediano Ziglio + * doc/htdoc/basic_jdbc_question.html doc/htdoc/contrib.html: + * doc/htdoc/docs.html doc/htdoc/index.html doc/htdoc/news.html: + * doc/htdoc/software.html doc/htdoc/support.html: + * doc/htdoc/vague_jdbc_question.html doc/htdoc/which_api.html: + - make xhtml compatible + +Wed Aug 08 15:24:16 CET 2007 Frediano Ziglio + * configure.ac src/odbc/Makefile.am win32/version.rc.in: + - fix odbc cross compile using MingW + +Wed Aug 08 11:34:40 CET 2007 Frediano Ziglio + * misc/freetds_autobuild: + - improved adding test for server:port and server\instance case + +Wed Aug 08 11:10:36 CET 2007 Frediano Ziglio + * src/tds/config.c: fix bug #1759652 (cannot use server\INSTANCE) + +Tue Aug 07 15:34:34 CET 2007 Frediano Ziglio + * src/odbc/odbc.c: improve cursor updates + * src/odbc/unittests/cursor1.c: improved and fixed + +Tue Aug 07 11:55:53 CET 2007 Frediano Ziglio + * src/tds/query.c: use table name for update + +Tue Aug 07 11:19:33 CET 2007 Frediano Ziglio + * include/tds.h src/odbc/odbc.c src/odbc/unittests/getdata.c: + - fix bug #1758831 + - additional fixes and checks for SQLGetData + +Tue Aug 07 10:29:55 CET 2007 Frediano Ziglio + * doc/userguide.sgml: update links + +Fri Aug 03 13:15:42 CET 2007 Frediano Ziglio + * src/tds/config.c: lookup server name correctly for instances + +Thu Aug 02 13:31:45 CET 2007 Frediano Ziglio + * include/sqlfront.h: small compatiblity improve with ms + +Fri Jul 13 18:56:56 CET 2007 Frediano Ziglio + * src/odbc/unittests/getdata.c: portability fix + +Thu Jul 12 16:31:05 CET 2007 Frediano Ziglio + * src/odbc/odbc.c: fix for SQLGetData using empty fields + * src/odbc/unittests/getdata.c: + - improve test to catch previous problem + +Sat Jul 07 19:55:30 CET 2007 Frediano Ziglio + * m4/sprintf_i64_format.m4: improve portability + +Sat Jul 07 19:09:59 CET 2007 Frediano Ziglio + * src/odbc/odbc.c: + - check cbValueMax in SQLGetData even if DM present + +Tue Jul 03 17:12:04 CET 2007 Frediano Ziglio + * src/odbc/unittests/compute.c src/odbc/unittests/tables.c: + * src/odbc/unittests/typeinfo.c: + - relax test for Sybase + * src/tds/token.c: fix length computation + +Tue Jul 03 15:37:03 CET 2007 Frediano Ziglio + * include/tds.h src/ctlib/blk.c src/dblib/bcp.c src/dblib/dblib.c: + * src/odbc/odbc.c src/tds/mem.c src/tds/token.c: + - add table_column_name to read real column name (if available), + read from wire and use when needed + +Sun Jul 01 12:10:31 CET 2007 Frediano Ziglio + * include/tdsstring.h src/odbc/connectparams.c: + * src/odbc/descriptor.c src/odbc/odbc.c src/tds/config.c: + * src/tds/tdsstring.c: + - added tds_dstr_dup to duplicate DSTR + - use tds_dstr_dup + - improve tds_dstr_set + +Wed Jun 27 16:51:30 CET 2007 Frediano Ziglio + * doc/tds.html: add Column Info token + * src/odbc/unittests/timeout2.c: portability fix + +Mon Jun 25 11:47:14 CET 2007 Frediano Ziglio + * doc/api_status.txt include/cspublic.h include/ctlib.h: + * src/ctlib/cs.c src/ctlib/ct.c: + - applied patch #1729392, it adds support for ctlib locale + +Mon Jun 25 10:20:00 CET 2007 Frediano Ziglio + * src/odbc/odbc.c: review cursors + +Thu Jun 21 09:19:32 CET 2007 Frediano Ziglio + * misc/freetds_autobuild: test for Sybase 15 + * src/odbc/unittests/data.c: bigint for Sybase + * src/tds/data.c src/tds/mem.c src/tds/read.c src/tds/tds_checks.c: + - add support for Sybase bigint + - do not check decault capabilities if not necessary + +Tue Jun 19 15:30:12 CET 2007 Frediano Ziglio + * include/tds.h src/ctlib/ct.c src/odbc/odbc_util.c: + * src/pool/stream.c src/tds/data.c src/tds/net.c: + * src/tds/tds_checks.c src/tds/tds_checks.h src/tds/token.c: + - fix problem with Sybase LONGCHAR + +Tue Jun 19 14:06:55 CET 2007 Frediano Ziglio + * src/ctlib/unittests/t0007.c src/odbc/unittests/prepare_results.c: + - more verbose + - fix for possible Sybase conversion + * src/odbc/odbc.c: additional check if no dm + +Mon Jun 18 15:20:00 CET 2007 Frediano Ziglio + * src/tds/convert.c: + - patch #1736289 for bcp/bulk insert problem + +Mon Jun 18 14:02:45 CET 2007 Frediano Ziglio + * src/apps/tsql.c src/tds/locale.c: + - use correct charset based on locale + +Mon Jun 18 13:58:34 CET 2007 Frediano Ziglio + * src/odbc/unittests/genparams.c: remove warning + +Sun Jun 17 19:38:27 CET 2007 Frediano Ziglio + * src/odbc/unittests/freeclose.c src/odbc/unittests/timeout3.c: + - fix small thread problem + - fix possible deadlock + +Sun Jun 17 09:45:55 CET 2007 Frediano Ziglio + * src/odbc/unittests/freeclose.c src/odbc/unittests/genparams.c: + - fix thread and small portability + +Sun Jun 17 09:08:03 CET 2007 Frediano Ziglio + * include/dblib.h src/dblib/buffering.h src/dblib/dblib.c: + - patch #1717123 for dbsetnull implementation (removed warnings) + +Sun Jun 17 08:16:50 CET 2007 Frediano Ziglio + * src/apps/tsql.c: + - patch #1703363 for delimiters (modified) + +Wed Jun 13 09:26:00 CET 2007 Frediano Ziglio + * src/apps/fisql/fisql.c: compile even if readline is not available + +Mon Jun 4 17:09:03 EDT 2007 JK Lowden + * src/apps/Makefile.am skip bsqlodb if ODBC disabled + +Mon Jun 04 10:03:25 CET 2007 Frediano Ziglio + * src/dblib/unittests/.cvsignore src/dblib/unittests/Makefile.am: + * src/dblib/unittests/hang.c(added) src/tds/net.c: + - fix problem with tds_select (detected by Perception Technologies) + +Fri Jun 01 10:52:46 CET 2007 Frediano Ziglio + * src/tds/token.c: avoid overflow leading to memory errors + +Thu May 31 17:02:43 CET 2007 Frediano Ziglio + * src/tds/net.c: + - fixes, partially from Brent of Perception Technologies Ltd + +Thu May 31 10:54:14 EDT 2007 JK Lowden + * TODO add recent potential bug reports + +Thu May 31 14:21:35 CET 2007 Frediano Ziglio + * m4/ac_nullzero.m4: fix cross compile test + +Wed May 30 09:55:52 CET 2007 Frediano Ziglio + * src/tds/threadsafe.c: + - implement gethostbyname_r with getaddrinfo (for UnixWare 7 and others) + +Tue May 29 10:48:45 CET 2007 Frediano Ziglio + * configure.ac win32/config.h: cleanup + +Fri May 25 11:07:04 CET 2007 Frediano Ziglio + * src/odbc/convert_tds2sql.c: + - remove a FIXME + * src/odbc/odbc.c: + - fix bug #1716594 ("SQLFreeStmt with SQL_CLOSE shouldn't + unprepare statement") + * src/odbc/unittests/Makefile.am src/odbc/unittests/freeclose.c(added) + * src/odbc/unittests/.cvsignore: + - add a test for bug #1716594 + +Mon May 21 14:01:13 CET 2007 Frediano Ziglio + * src/odbc/odbc.c: + - fix cursor updates, this undo part of change of src/odbc/odbc.c + from 1.331 to 1.332, log: + Wed Jul 21 16:50:11 CET 2004 + : some fix for SQLFetch and multiple rows + but tests works + * src/odbc/unittests/cursor1.c: improve + +Mon May 21 10:40:40 CET 2007 Frediano Ziglio + * src/odbc/unittests/cursor1.c: improve test + +Thu May 17 12:32:33 CET 2007 Frediano Ziglio + * include/tdsodbc.h src/odbc/odbc.c src/odbc/odbc_checks.c: + * src/odbc/odbc_util.c: + - avoid core + - fix and check invalid values of num_param_rows and curr_param_row + +Thu May 17 09:18:19 CET 2007 Frediano Ziglio + * src/odbc/unittests/warning.c: improve and comments + +Wed May 16 14:23:00 CET 2007 Frediano Ziglio + * include/tdsodbc.h src/odbc/odbc.c src/odbc/odbc_util.c: + * src/odbc/sql2tds.c: + - support row binding in RPC + - reuse new odbc_get_octet_len + +Wed May 16 14:23:00 CET 2007 Frediano Ziglio + * misc/freetds_autobuild: minor updates + +Mon May 14 16:04:08 CET 2007 Frediano Ziglio + * src/tds/login.c: remove copy error + +Mon May 14 10:16:37 CET 2007 Frediano Ziglio + * src/tds/login.c src/tds/mem.c src/tds/token.c src/tds/util.c: + - give proper errors on protocol autodiscovery + +Wed May 09 10:31:56 CET 2007 Frediano Ziglio + * src/odbc/odbc.c: finish ODBC timeout + +Fri May 03 14:54:58 CET 2007 Frediano Ziglio + * src/odbc/unittests/const_params.c: + - reset statement to be sure to cleanup + +Wed May 02 16:54:13 CET 2007 Frediano Ziglio + * include/tdsodbc.h src/odbc/odbc.c: + - use query timeout from freetds.conf + +Mon Apr 30 15:14:08 CET 2007 Frediano Ziglio + * src/odbc/odbc.c: use default linkage for static functions + +Mon Apr 30 15:02:27 CET 2007 Frediano Ziglio + * src/ctlib/blk.c: fix strange link error using gcc 4.1 + +Mon Apr 23 09:56:05 CET 2007 Frediano Ziglio + * src/tds/net.c: fix portability issue + +Fri Apr 20 15:26:15 CET 2007 Frediano Ziglio + * src/odbc/unittests/cursor1.c src/odbc/unittests/cursor2.c: + * src/odbc/unittests/scroll.c: + - make valgrind more happy if Sybase is used + +Fri Apr 20 11:13:40 CET 2007 Frediano Ziglio + * src/odbc/odbc.c src/odbc/unittests/Makefile.am: + * src/odbc/unittests/timeout4.c(added): + - add a test for timeout + - fix timeout on prepare (not detected) + - fix timeout if connection broken + +Thu Apr 19 11:11:55 CET 2007 Frediano Ziglio + * src/odbc/unittests/cursor1.c src/odbc/unittests/cursor2.c: + * src/odbc/unittests/scroll.c: + - give only warning for Sybase + +Thu Apr 19 10:45:15 CET 2007 Frediano Ziglio + * include/tdsodbc.h src/odbc/odbc.c: + - say we not still support cursors for sybase + +Wed Apr 18 16:28:29 CET 2007 Frediano Ziglio + * TODO.freddy include/tdsodbc.h src/odbc/odbc.c: + * src/odbc/odbc_util.c src/odbc/prepare_query.c src/odbc/sql2tds.c: + - fix cursor updates + +Mon Apr 16 22:08:07 EDT 2007 JK Lowden + * src/apps/bsqlodbc.c ODBC3 conformant + +Sun Apr 15 10:01:36 CET 2007 Frediano Ziglio + * src/odbc/odbc.c: fix leak + +Fri Apr 13 17:27:20 CET 2007 Frediano Ziglio + * src/odbc/odbc.c: cursor update + +Fri Apr 13 17:22:25 CET 2007 Frediano Ziglio + * include/tds.h src/tds/query.c: + - add cursor update to libTDS + +Fri Apr 13 10:08:07 CET 2007 Frediano Ziglio + * src/apps/bsqlodbc.c: + - catch all error + - fix some memory problems + +Thu Apr 12 15:33:15 CET 2007 Frediano Ziglio + * src/odbc/unittests/funccall.c: + - add test from ML + +Thu Apr 12 15:07:09 CET 2007 Frediano Ziglio + * freetds.spec.in: fix odbc directory + * src/dblib/unittests/Makefile.am: fix for make distcheck + * src/odbc/unittests/raiserror.c src/odbc/unittests/warning.c: + - relax if dm used + +Thu Apr 12 09:47:39 CET 2007 Frediano Ziglio + * src/odbc/odbc.c src/odbc/unittests/copydesc.c: + - test and fix a problem with SQLAllocHandle + * src/odbc/unittests/connect2.c: add test for not existing dbs + +Thu Apr 12 09:05:56 CET 2007 Frediano Ziglio + * src/ctlib/unittests/array_bind.c src/ctlib/unittests/ct_diagall.c: + * src/ctlib/unittests/ct_diagclient.c: + - fix buffer overflow leading in core + +Wed Apr 11 14:55:32 CET 2007 Frediano Ziglio + * src/dblib/unittests/common.c src/odbc/unittests/common.c: + - remove warning compiling with MingW + +Wed Apr 11 13:52:50 CET 2007 Frediano Ziglio + * src/odbc/connectparams.c src/odbc/odbc.c: + * src/odbc/unittests/connect2.c: + - finish and fix test for change_database + +Wed Apr 11 11:47:08 CET 2007 Frediano Ziglio + * src/odbc/unittests/connect2.c: fix test + * src/odbc/unittests/describecol.in: relax test + +Wed Apr 11 09:09:13 CET 2007 Frediano Ziglio + * src/odbc/unittests/connect2.c src/odbc/unittests/Makefile.am: + - add a test for change_database + +Tue Apr 10 16:00:47 CET 2007 Frediano Ziglio + * include/tdsodbc.h src/odbc/odbc.c src/odbc/odbc_util.c: + - fixes for describecol test + +Tue Apr 10 15:16:28 CET 2007 Frediano Ziglio + * misc/coverage.sh: remove system files + * src/odbc/unittests/describecol.in: relax test + +Fri Apr 06 10:52:25 CET 2007 Frediano Ziglio + * include/tdssrv.h src/server/login.c src/server/unittest.c: + - remove warning + +Fri Apr 06 10:29:31 CET 2007 Frediano Ziglio + * NEWS src/odbc/unittests/funccall.c src/tds/mem.c: + * src/tds/query.c: + - added some notes + +Thu Apr 05 16:16:47 CET 2007 Frediano Ziglio + * INSTALL INSTALL.CVS NEWS README doc/userguide.sgml: + - merge from 0.64 + +Wed Apr 04 13:39:27 CET 2007 Frediano Ziglio + * NEWS: updated + +Wed Apr 04 11:53:20 CET 2007 Frediano Ziglio + * include/tds.h include/tdsodbc.h src/ctlib/ct.c src/dblib/rpc.c: + * src/odbc/prepare_query.c src/odbc/sql2tds.c src/tds/mem.c: + * src/tds/token.c src/tds/unittests/dynamic1.c: + - removed unused paramter from tds_alloc_param_data + - fix possible problem in prepare_rpc + +Wed Apr 04 11:39:12 CET 2007 Frediano Ziglio + * vms/descrip_mms.template: add log.c + * src/server/query.c: use constants + +Wed Apr 04 09:14:47 CET 2007 Frediano Ziglio + * doc/userguide.sgml: improve slow check + +Tue Apr 03 16:23:17 CET 2007 Frediano Ziglio + * win32/dev-cpp/FreeTDS.dev win32/dev-cpp/Makefile.win: + - updated adding log.c + +Mon Apr 02 17:06:43 CET 2007 Frediano Ziglio + * doc/userguide.sgml: add encryption parameter + +Thu Mar 29 16:32:50 CET 2007 Frediano Ziglio + * src/ctlib/blk.c: initial fix for bcp state + +Thu Mar 29 16:25:24 CET 2007 Frediano Ziglio + * include/tds.h src/server/login.c src/tds/config.c: + * src/tds/login.c: + - added encryption setting in freetds.conf + +Thu Mar 29 12:17:34 CET 2007 Frediano Ziglio + * configure.ac: check includes for ODBC + +Thu Mar 29 09:44:11 CET 2007 Frediano Ziglio + * src/odbc/unittests/genparams.c: add test for money + +Wed Mar 28 14:43:34 CET 2007 Frediano Ziglio + * freetds.spec.in src/odbc/unittests/Makefile.am: + - fix test-dist test + +Mon Mar 26 13:27:51 CET 2007 Frediano Ziglio + * src/dblib/unittests/.cvsignore src/dblib/unittests/Makefile.am: + * src/odbc/unittests/.cvsignore src/odbc/unittests/Makefile.am: + * win32/build_dsw.pl: + - distribute projects for vc6 unittests + +Mon Mar 26 10:05:47 CET 2007 Frediano Ziglio + * doc/htdoc/news.html: validate page + +Sun Mar 24 09:23:21 CET 2007 Frediano Ziglio + * src/apps/bsqlodbc.c: + - avoid dangerous casts + +Tue Mar 20 16:24:26 CET 2007 Frediano Ziglio + * src/replacements/gettimeofday.c src/apps/datacopy.c: + - remove warning + +Mon Mar 19 11:01:05 CET 2007 Frediano Ziglio + * include/replacements.h: fix warning for win32 + +Sun Mar 18 12:37:47 CET 2007 Frediano Ziglio + * src/dblib/unittests/common.c src/odbc/unittests/timeout2.c: + * src/odbc/unittests/timeout3.c: + - fix cross-compile for win32 + +Sun Mar 18 12:09:57 CET 2007 Frediano Ziglio + * src/apps/Makefile.am src/apps/bsqlodbc.c src/apps/tsql.c: + * src/apps/fisql/Makefile.am win32/winsetup.c: + - fix cross-compile for win32 + +Fri Mar 16 16:32:08 CET 2007 Frediano Ziglio + * include/Makefile.am src/tds/Makefile.am: + - full libTDS privatization + * src/server/unittest.c: use mnemonic + +Wed Mar 14 17:18:23 CET 2007 Frediano Ziglio + * doc/tds.html: update + * include/tdssrv.h src/pool/user.c src/server/login.c: + * src/server/query.c src/server/server.c src/server/unittest.c: + - update server stuff, at least login works + * src/tds/tdsstring.c: fix possible mising NUL terminator + * src/apps/tsql.c: fix wrong error handler result + +Wed Mar 14 09:47:24 CET 2007 Frediano Ziglio + * doc/tds.html include/tds.h: update documentation + +Tue Mar 13 17:24:54 CET 2007 Frediano Ziglio + * include/tds.h src/pool/user.c src/server/login.c: + * src/server/unittest.c src/tds/login.c src/tds/query.c: + - use mnemonic for packet types + +Tue Mar 13 16:45:54 CET 2007 Frediano Ziglio + * doc/tds.html: added known tokens + +Tue Mar 13 14:18:03 CET 2007 Frediano Ziglio + * doc/tds.html: updated from code + +Mon Mar 12 14:27:14 CET 2007 Frediano Ziglio + * include/ctlib.h include/dblib.h include/des.h include/md4.h: + * include/md5.h include/replacements.h include/tdsiconv.h: + * include/tdsstring.h include/replacements/readpassphrase.h: + * src/server/Makefile.am: + - privatize functions using gcc visibility if available + - privatize server library + +Mon Mar 12 13:31:32 CET 2007 Frediano Ziglio + * src/ctlib/unittests/blk_in2.c(added) src/ctlib/unittests/Makefile.am: + - added test from ML to test cancel and bulk together + +Mon Mar 12 10:52:12 CET 2007 Frediano Ziglio + * doc/tds.html: improved, added types + +Fri Feb 16 14:52:10 CET 2007 Frediano Ziglio + * include/tds.h: improve documentation + +Mon Feb 12 14:29:53 EST 2007 Nick Castellano + * src/dblib/dblib.c: Increase size of dbprrow() conversion buffer to 8K. + +Mon Feb 12 10:53:54 CET 2007 Frediano Ziglio + * src/odbc/unittests/timeout3.c: + - use thread instead of fork + +Wed Feb 7 01:11:27 EST 2007 JK Lowden + * src/apps/bsqlodbc.c don't exit on SQL_SUCCESS_WITH_INFO + +Wed Feb 7 00:04:15 EST 2007 JK Lowden + * src/apps/bsqldb.c exit noisily on severe errors + * src/dblib/dblib.c src/tds/token.c + - fix timeout with buffering problem per yesterday's ML. + +Tue Feb 6 17:14:50 EST 2007 Nick Castellano + * src/dblib/dblib.c: + - Sybase docs for dbsqlok() says: "If the command buffer contains + multiple commands, a run-time error will not cause dbsqlok to + fail. Instead, failure will occur with the dbresults call that + processes the command causing the run-time error." + * src/apps/fisql/fisql.c: + - Correct result set processing. + +Tue Feb 6 14:11:02 EST 2007 Nick Castellano + * src/dblib/dblib.c: Don't print or store column separator after final result column + +Tue Feb 06 10:18:00 CET 2007 Frediano Ziglio + * configure.ac src/odbc/Makefile.am: + - use -module option only for darwin + +Tue Feb 06 09:53:14 CET 2007 Frediano Ziglio + * src/apps/bsqlodbc.c: + - make more functions static + - remove warning + * src/tds/net.c: remove warning + +Mon Feb 5 21:48:58 EST 2007 JK Lowden + * src/apps/Makefile.am src/apps/bsqlodbc.c src/apps/osql + - added bsqlodbc as general batch script processor. + +Mon Feb 05 09:41:02 CET 2007 Frediano Ziglio + * misc/test-other.sh phptests/null.php: + - fixed PHP check, updated test to PHP 5.2 + +Fri Feb 02 11:51:19 CET 2007 Frediano Ziglio + * configure.ac src/odbc/odbc.c src/odbc/unittests/.cvsignore: + * src/odbc/unittests/Makefile.am src/odbc/unittests/timeout3.c(added): + - added a test for connection timeout + - fix timeout connection in odbc + +Mon Jan 29 12:02:39 CET 2007 Frediano Ziglio + * include/tds_sysdep_private.h src/apps/fisql/fisql.c: + * src/tds/net.c: + - remove some warnings + +Fri Jan 26 18:19:57 CET 2007 Frediano Ziglio + * src/apps/fisql/fisql.c: + - remove warning + - reuse malloc + - fix compile error including config.h + * src/dblib/dblib.c: remove warning + +Fri Jan 26 18:06:44 CET 2007 Frediano Ziglio + * src/odbc/error.c src/odbc/odbc.c: + - remove warning compiling + +Wed Jan 24 14:14:55 EST 2007 Nick Castellano + * doc/fisql.txt: compute rows in fisql work now, remove BUGS entry + +Wed Jan 24 14:11:56 EST 2007 Nick Castellano + * src/apps/fisql/fisql.c: indent + +Wed Jan 24 14:08:09 EST 2007 Nick Castellano + * src/apps/fisql/fisql.c: good enough compute layout + +Wed Jan 24 12:24:30 EST 2007 Nick Castellano + * src/apps/fisql/fisql.c: almost correct compute layout + +Wed Jan 24 11:32:56 EST 2007 Nick Castellano + * src/apps/fisql/fisql.c: minor compute layout fixes, still more to do + +Tue Jan 23 17:15:33 EST 2007 Nick Castellano + * src/apps/fisql/fisql.c: better compute results, layout needs fixing + +Tue Jan 23 11:24:40 EST 2007 Nick Castellano + * src/dblib/dblib.c: fix off-by-one bug in dbbylist() + +Mon Jan 22 15:54:02 EST 2007 Nick Castellano + * src/apps/fisql/fisql.c: fix :r with unreadable file + +Mon Jan 22 15:50:31 EST 2007 Nick Castellano + * src/dblib/dblib.c: print line separator after compute results + +Mon Jan 22 00:56:12 EST 2007 JK Lowden + * src/odbc/connectparams.c src/odbc/error.c + * src/odbc/odbc.c + - added log entry for API functions + * src/odbc/unittests/common.c always use '/' separator + +Sat Jan 20 15:24:03 EST 2007 JK Lowden + * include/dblib.h include/sybdb.h src/dblib/dblib.c + - moved DBOPTION to dblib.h and removed unused members. + +Sat Jan 20 01:29:36 EST 2007 JK Lowden + * doc/defncopy.txt doc/fisql.txt cleanup formatting + * src/apps/bsqldb.c src/dblib/dblib.c fix compute row headers + +Sat Jan 20 01:30:22 EST 2007 Nick Castellano + * ChangeLog src/apps/fisql/edit.c src/apps/fisql/edit.h + * src/apps/fisql/fisql.c src/apps/fisql/handlers.c + * src/apps/fisql/handlers.h src/apps/fisql/interrupt.c + * src/apps/fisql/interrupt.h src/apps/fisql/terminal.c + * src/apps/fisql/terminal.h: + - Fix my name and the program name + +Sat Jan 20 01:20:39 EST 2007 Nick Castellano + * src/apps/fisql/fisql.c: + - Be slightly less stupid about compute rows. + +Sat Jan 20 00:54:57 EST 2007 Nick Castellano + * src/dblib/dblib.c: + - do not return bogus nul character in dbgetchar() + +Sat Jan 20 00:35:45 EST 2007 Nick Castellano + * src/dblib/dblib.c: + - dbspr*() functions get nul termination not line termination + +Fri Jan 19 22:39:00 EST 2007 Nick Castellano + * doc/fisql.txt: restore compute rows BUGS entry. + +Fri Jan 19 14:05:13 EST 2007 Nick Castellano + * src/apps/fisql/fisql.c: + - Provide xmalloc() and xrealloc() instead of relying on + libreadline for these. + +Fri Jan 19 13:47:42 EST 2007 Nick Castellano + * src/apps/fisql/Makefile.am + * src/apps/fisql/fisql.c + * src/apps/fisql/xgetpass.c(removed) + * src/apps/fisql/xgetpass.h(removed): + - use readpassphrase() in fisql application. + +Fri Jan 19 13:31:31 EST 2007 Nick Castellano + * src/apps/fisql/edit.c src/apps/fisql/fisql.c + * src/apps/fisql/handlers.c src/apps/fisql/handlers.h + * src/apps/fisql/interrupt.c src/apps/fisql/interrupt.h + * src/apps/fisql/terminal.c src/apps/fisql/terminal.h + * src/apps/fisql/xgetpass.c: + - Indent fisql to standard FreeTDS coding style + +Fri Jan 19 13:19:04 EST 2007 Nick Castellano + * src/apps/fisql/fisql.c: remove obsolete code + +Fri Jan 19 13:12:56 EST 2007 Nick Castellano + * doc/fisql.txt: fisql now works, update doc + +Fri Jan 19 13:01:53 EST 2007 Nick Castellano + * .cvsignore doc/.cvsignore: clean up + +Fri Jan 19 12:45:27 EST 2007 Nick Castellano + * src/dblib/dblib.c: fix dbspr1row(), fisql now works + +Fri Jan 19 11:17:13 EST 2007 JK Lowden + * doc/fisql.txt + * src/apps/fisql/edit.c src/apps/fisql/edit.h + * src/apps/fisql/handlers.c src/apps/fisql/handlers.h + * src/apps/fisql/interrupt.c src/apps/fisql/interrupt.h + * src/apps/fisql/terminal.c src/apps/fisql/terminal.h + * src/apps/fisql/xgetpass.c src/apps/fisql/xgetpass.h + * src/apps/fisql/fisql.c + - Added notice of copyright and GPL license + +Thu Jan 18 23:55:17 EST 2007 JK Lowden + * doc/Makefile.am doc/fisql.txt added man page for fisql + * src/apps/fisql/fisql.c fixed discarding const warnings + * doc/api_status.txt include/sybdb.h src/dblib/dblib.c + - added dbgettime() + +Thu Jan 18 17:57:52 EST 2007 Nick Castellano + * AUTHORS: credit myself as a contributor + +Thu Jan 18 17:50:18 EST 2007 Nick Castellano + * src/dblib/dblib.c: + - fix dbprrow() to print character data correctly + - fix dbprrow() to not loop endlessly on aggregate rows + +Thu Jan 18 08:57:10 CET 2007 Frediano Ziglio + * src/tds/unittests/utf8_2.c: fix error handler + +Wed Jan 17 09:48:45 CET 2007 Frediano Ziglio + * src/apps/fisql/fisql.c: use mkstemp instead of mktemp + * src/tds/util.c: cleanup + +Tue Jan 16 16:30:42 EDT 2007 Nick Castellano + * configure.ac + * src/apps/Makefile.am + * src/apps/fisql: contribute free DB-Libary isql application + +Tue Jan 16 09:57:35 CET 2007 Frediano Ziglio + * src/tds/util.c: fix messages + +Tue Jan 16 09:48:43 CET 2007 Frediano Ziglio + * misc/test-other.sh: fix problem with Perl 5.8.8 + * src/dblib/dblib.c: fix possible thread problem + +Tue Jan 16 00:28:28 EST 2007 JK Lowden + * include/dblib.h src/dblib/bcp.c + * src/dblib/dblib.c src/dblib/unittests/rpc.c + - support variadic form of dbperror + +Mon Jan 15 14:40:35 EST 2007 JK Lowden + * src/dblib/unittests/common.c + * src/dblib/unittests/rpc.c + * src/dblib/unittests/t0004.c + * src/dblib/unittests/t0005.c + * src/dblib/unittests/t0007.c + * src/dblib/unittests/t0019.c + * src/dblib/unittests/t0020.c + - fail if an unanticipated message/error is received + +Sun Jan 14 23:16:17 EST 2007 JK Lowden + * src/tds/config.c src/tds/login.c + - began work on autodetecting the server's TDSVER + - works with libtds, not db-lib + +Sun Jan 14 20:38:25 EST 2007 JK Lowden + * include/dblib.h include/tds.h + * src/dblib/dblib.c src/dblib/dbutil.c + * src/dblib/unittests/t0001.c src/dblib/unittests/t0012.c + * src/dblib/unittests/timeout.c + * src/tds/net.c TODO + - timeout unit test also works with dbsetinterrupt + +Sat Jan 13 17:09:05 EST 2007 JK Lowden + * src/dblib/unittests/timeout.c added + * src/dblib/dblib.c + * src/dblib/unittests/Makefile.am src/dblib/unittests/t0001.c + * src/tds/login.c src/tds/query.c src/tds/util.c + - new timeout unit test works. + +Fri Jan 12 14:28:32 CET 2007 Frediano Ziglio + * src/odbc/odbc.c: update code to new libTDS timeout code + * src/tds/net.c: handle send/recv errors + * src/tds/util.c: fix msgno if error not found in table + +Thu Jan 11 10:49:52 EST 2007 JK Lowden + * src/apps/osql + - fixed incorrect report when drivername is not a file + +Tue Jan 09 22:44:08 CET 2007 Frediano Ziglio + * src/apps/tsql.c: fix option problem + +Tue Jan 9 00:16:46 EST 2007 JK Lowden + * src/tds/net.c simpler tds_select, thanks Frediano + +Sun Jan 7 10:45:23 EST 2007 JK Lowden + * src/ctlib/ctutil.c works with tdserror() + +Sun Jan 7 00:41:19 EST 2007 JK Lowden + * include/tds.h + * src/dblib/dblib.c src/dblib/dbutil.c + * src/tds/net.c src/tds/query.c + * src/tds/token.c src/tds/util.c + - implement new timeout strategy using tds_select() and + - calling the client library's error handler (via tdserror). + - db-lib no worse than before, others not yet tested. + +Fri Jan 05 14:08:53 CET 2007 Frediano Ziglio + * include/tds.h src/tds/token.c: new token + * src/tds/util.c: optimize + +Fri Jan 5 02:08:54 EST 2007 JK Lowden + * include/tds.h src/tds/net.c src/tds/util.c + - begin new timeout strategy, not done. + +Thu Jan 4 18:47:46 EST 2007 JK Lowden + * doc/bsqldb.txt src/apps/bsqldb.c nicer headers + * doc/osql.txt src/apps/osql allow ini location override + +Tue Jan 2 15:42:09 EST 2007 JK Lowden + * include/dblib.h include/tds.h + * src/apps/tsql.c + * src/dblib/dblib.c src/dblib/dbutil.c + * src/tds/iconv.c src/tds/login.c src/tds/net.c + * src/tds/token.c src/tds/util.c + - replace tds_client_msg with tdserror() + +Mon Jan 01 12:56:50 CET 2007 Frediano Ziglio + * src/dblib/dblib.c src/tds/query.c: + - remove some warning compiling with SUN compiler + - Happy New Year + +Fri Dec 29 20:43:55 CET 2006 Frediano Ziglio + * src/tds/mem.c: remove warning and optimize + +Fri Dec 29 20:42:41 CET 2006 Frediano Ziglio + * src/apps/tsql.c: remove warnings + +Fri Dec 29 20:05:00 CET 2006 Frediano Ziglio + * include/tdsodbc.h: cleanup + +Fri Dec 29 20:03:30 CET 2006 Frediano Ziglio + * src/ctlib/unittests/rpc_ct_param.c: + * src/ctlib/unittests/rpc_ct_setparam.c src/odbc/odbc.c: + - remove warnings + +Fri Dec 29 17:18:42 CET 2006 Frediano Ziglio + * configure.ac src/tds/log.c: + - use localtime_r if available + +Fri Dec 29 10:06:56 CET 2006 Frediano Ziglio + * src/tds/log.c: + - avoid locking if no logging + +Tue Dec 26 15:57:38 CET 2006 Frediano Ziglio + * include/tds.h src/ctlib/unittests/array_bind.c: + * src/ctlib/unittests/ct_diagall.c: + * src/ctlib/unittests/get_send_data.c: + * src/ctlib/unittests/lang_ct_param.c: + * src/dblib/bcp.c src/dblib/dblib.c: + * src/dblib/dbutil.c src/dblib/rpc.c: + * src/dblib/xact.c src/dblib/unittests/common.h: + * src/dblib/unittests/t0016.c src/odbc/connectparams.c: + * src/odbc/descriptor.c src/odbc/error.c: + * src/odbc/odbc.c src/odbc/odbc_checks.c: + * src/odbc/prepare_query.c src/odbc/unittests/common.h: + * src/odbc/unittests/describecol.c src/pool/config.c: + * src/pool/main.c src/pool/member.c src/pool/stream.c: + * src/pool/user.c src/pool/util.c: + * src/replacements/readpassphrase.c: + * src/replacements/strtok_r.c src/replacements/vasprintf.c: + * src/server/login.c src/server/unittest.c: + * src/tds/config.c src/tds/convert.c src/tds/data.c: + * src/tds/getmac.c src/tds/iconv.c src/tds/locale.c: + * src/tds/login.c src/tds/net.c src/tds/numeric.c: + * src/tds/tds_checks.c src/tds/tdsstring.c src/tds/threadsafe.c: + * src/tds/write.c src/tds/unittests/common.h win32/winlogin.c: + * win32/winsetup.c: + - include stdarg.h always before stdio.h to fix portability + issues defining va_list + +Tue Dec 26 13:54:25 CET 2006 Frediano Ziglio + * src/tds/Makefile.am src/tds/util.c src/tds/log.c (added): + - separate log stuff + +Sun Dec 24 12:40:19 CET 2006 Frediano Ziglio + * src/odbc/descriptor.c: cleanup + +Fri Dec 22 09:34:37 CET 2006 Frediano Ziglio + * src/tds/convert.c: fix typo error + +Mon Dec 21 14:07:55 CET 2006 Frediano Ziglio + * src/tds/iconv.c: use cp1252 instead of iso8859-1 for mssql + +Wed Dec 20 22:47:36 EST 2006 JK Lowden + * src/tds/iconv.c src/tds/token.c log server charset changes + * src/tds/unittests/convert.c permit varbinary + +Mon Dec 18 10:50:34 CET 2006 Frediano Ziglio + * src/tds/Makefile.am: distribute enum_cap.h + +Fri Dec 15 14:41:14 EST 2006 JK Lowden + * src/tds/tds_willconvert.pl allow varbinary + +Thu Dec 14 22:18:16 EST 2006 JK Lowden + * src/tds/mem.c src/tds/unittests/t0001.c + - Added tds_capability_set and enumerated capabilities + * src/tds/enum_cap.h added + +Tue Dec 12 08:45:12 CET 2006 Frediano Ziglio + * include/tdsodbc.h src/odbc/odbc.c src/odbc/odbc_util.c: + - improve describecol test + +Sun Dec 10 16:04:02 EST 2006 JK Lowden + * doc/htdoc/faq.html minor fixes + * src/apps/tsql.c send *sybase* charset name in login record + * src/tds/net.c src/tds/read.c a little less logging + +Thu Dec 7 17:06:50 CET 2006 Frediano Ziglio + * src/tds/token.c: make get_send_data works + +Tue Dec 5 11:42:04 CET 2006 Frediano Ziglio + * src/odbc/unittests/funccall.c: add a test + +Fri Dec 1 16:45:59 EST 2006 JK Lowden + * include/sybdb.h src/dblib/bcp.c src/apps/freebcp.c + - Changed freetbcp batch-copied information messages to + - match the output of Sybase's bcp utility. + +Wed Nov 29 15:46:38 EST 2006 JK Lowden + * src/apps/tsql.c fixed broken "go" option handling. + +Tue Nov 28 11:52:27 EST 2006 JK Lowden + * src/apps/tsql.c fix -o option code + * src/tds/net.c reorganize tds_open_socket() + +Mon Nov 27 18:31:18 EST 2006 JK Lowden + * src/tds/net.c more detailed log of connect(2) + +Sun Nov 26 15:26:31 EST 2006 JK Lowden + * src/apps/tsql.c added connection timer feedback + * src/tds/login.c src/tds/net.c slightly better logging + +Thu Nov 23 09:43:00 CET 2006 Frediano Ziglio + * src/odbc/unittests/genparams.c: + - fix possible problem with very remote servers + +Thu Oct 26 15:09:48 EDT 2006 JK Lowden + * src/dblib/dbutil.c log error message from server + * src/tds/net.c log TDS version + +Thu Oct 26 14:26:27 EDT 2006 JK Lowden + * src/dblib/unittests/common.c src/dblib/unittests/common.h + * src/dblib/unittests/t0001.c + - corrected command-line option handling + +Sat Oct 21 16:42:08 EDT 2006 JK Lowden + * src/dblib/dblib.c src/dblib/unittests/t0022.c: + - dbresults succeeds if metadata or only return status is + - present, cf. ML yesterday. + +Sat Oct 21 14:22:44 CET 2006 Frediano Ziglio + * autogen.sh: fix some portability issues + +Wed Oct 18 21:38:57 CET 2006 Frediano Ziglio + * src/odbc/odbc.c src/odbc/unittests/tables.c: + - fix problem with mssql2005 and SQLTables + +Mon Oct 16 09:48:31 CET 2006 Frediano Ziglio + * src/tds/net.c: reduce system calls required + +Thu Oct 12 11:19:02 CET 2006 Frediano Ziglio + * src/tds/token.c: + - fix wrong assert + - return correctly RETURNSTATUS under Sybase + +Wed Oct 11 16:37:04 CET 2006 Frediano Ziglio + * src/tds/token.c: fix wrong assert using numerics + +Tue Oct 10 15:52:22 EDT 2006 JK Lowden + * doc/osql.txt clarified + +Fri Oct 6 17:08:43 EDT 2006 JK Lowden + * src/apps/freebcp.c src/apps/freebcp.h doc/freebcp.txt + - applied -0 patch from ML + - by Constantin Vasilyev + +Wed Oct 4 19:46:29 EDT 2006 JK Lowden + * src/apps/freebcp.c + - applied -P from stdin patch + - from ML Constantin Vasilyev + +Wed Oct 4 17:36:43 EDT 2006 JK Lowden + * src/apps/osql GNU sed does not support -E + +Wed Oct 4 14:48:20 EDT 2006 JK Lowden + * doc/Makefile.am doc/osql.txt added osql man page + +Wed Oct 4 14:12:25 EDT 2006 JK Lowden + * src/apps/Makefile.am add osql as installable script + +Tue Oct 3 15:40:12 EDT 2006 JK Lowden + * src/dblib/bcp.c test fwrite(3) correctly + +Tue Sep 26 16:57:42 EDT 2006 JK Lowden + * src/dblib/bcp.c src/dblib/dblib.c + * src/tds/convert.c src/tds/net.c src/tds/token.c + - added more user-level error checking, checking against + - known list of db-lib error messages + * src/apps/osql added + +Wed Sep 13 13:55:24 CET 2006 Frediano Ziglio + * samples/Makefile.am samples/unixodbc.freetds.driver.template.in: + - add Setup entry to unixODBC template + - unixODBC templates are not executables + +Wed Sep 13 13:52:40 CET 2006 Frediano Ziglio + * src/tds/mem.c: enable wide table + +Wed Sep 13 11:47:27 CET 2006 Frediano Ziglio + * src/tds/token.c: + - fix really broken tds5_process_result + +Fri Sep 08 11:58:24 CET 2006 Frediano Ziglio + * configure.ac src/tds/threadsafe.c: + - fix threadsafe problem on NetBSD + +Fri Sep 08 11:17:55 CET 2006 Frediano Ziglio + * include/tds.h src/tds/token.c: make splint a bit more happy + * src/odbc/odbc.c: small 64bit improvements + +Thu Sep 07 23:10:29 CET 2006 Frediano Ziglio + * src/odbc/sql2tds.c: fix paramset (Levente Tamási) + +Fri Sep 1 10:34:20 CET 2006 Frediano Ziglio + * include/tds.h include/tdsstring.h src/ctlib/ct.c: + * src/odbc/connectparams.c src/odbc/odbc.c src/server/login.c: + * src/tds/config.c src/tds/tdsstring.c: + - add dstr_size to DSTR + - add tds_dstr_alloc, tds_dstr_setlen, tds_dstr_buf + +Wed Aug 30 13:58:56 CET 2006 Frediano Ziglio + * include/tds.h src/tds/challenge.c src/tds/login.c: + - make tds_answer_challenge return flags + - tds_dstr fix + * src/dblib/dblib.c: small fix + * src/odbc/odbc.c: constification + * src/tds/query.c: + - some static functions rename + - do not convert string in tds7_build_param_def_from_query + * src/tds/threadsafe.c: cleanup + +Mon Aug 28 09:36:32 CET 2006 Frediano Ziglio + * include/cspublic.h: + - applied Norbert Sendetzky patch for ctlib compatibility + +Fri Aug 25 11:03:40 CET 2006 Frediano Ziglio + * src/dblib/unittests/Makefile.am src/dblib/unittests/t0017.c: + * src/dblib/unittests/t0017.in.be(added): + - fix big endian problem with t0017 test + +Fri Aug 25 09:17:37 CET 2006 Frediano Ziglio + * src/apps/tsql.c: remove 1024 char limit on tsql_readline + +Thu Aug 24 21:18:48 CET 2006 Frediano Ziglio + * src/apps/tsql.c: applied Christos Zoulas patch for no-tty + +Thu Aug 24 16:29:17 CET 2006 Frediano Ziglio + * include/sybdb.h src/dblib/dblib.c: + - do not change compatibility + * src/tds/config.c: small optimization + +Thu Aug 24 11:37:15 CET 2006 Frediano Ziglio + * m4/sprintf_i64_format.m4: fix 64bit problem for LP64 + +Thu Aug 24 11:17:26 CET 2006 Frediano Ziglio + * include/tds_sysdep_private.h src/apps/tsql.c src/ctlib/Makefile.am: + * src/dblib/Makefile.am src/tds/net.c win32/initnet.c: + * win32/winsetup.c win32/dev-cpp/FreeTDS.dev: + * win32/dev-cpp/Makefile.win win32/msvc6/FreeTDS.dsp: + - initialize socket library on win32 + +Thu Aug 24 08:32:07 CET 2006 Frediano Ziglio + * src/apps/tsql.c: + - do not print return status if quiet (patch from Christos Zoulas) + +Wed Aug 23 21:43:50 CET 2006 Frediano Ziglio + * doc/tsql.txt: applied Christos Zoulas updates + * doc/txt2man: updated + +Wed Aug 23 17:16:10 CET 2006 Frediano Ziglio + * src/tds/net.c: + - clean error before reading SO_ERROR, some system need this + * src/tds/util.c src/ctlib/ct.c: cross compile fixes + +Wed Aug 23 16:25:25 CET 2006 Frediano Ziglio + * m4/ac_tds_func_which_getpwuid_r.m4 m4/sprintf_i64_format.m4: + * configure.ac src/ctlib/cs.c src/apps/tsql.c: + * src/replacements/asprintf.c src/tds/query.c: + - fixes some cross compile issues with hp-ux + +Mon Aug 21 11:08:37 CET 2006 Frediano Ziglio + * src/dblib/dblib.c: remove small buffer overflow + +Thu Aug 17 11:13:40 CET 2006 Frediano Ziglio + * configure.ac include/tds.h src/dblib/unittests/Makefile.am: + * src/tds/net.c src/tds/query.c src/tds/token.c src/tds/util.c: + * m4/acx_pthread.m4(added): + - timeout more precise and use monotonic clock if available + - check pthread support more deeply + +Wed Aug 16 13:04:48 CET 2006 Frediano Ziglio + * src/tds/net.c: cleanup, fix possible problem under Linux + * src/tds/read.c: avoid invalid in_pos value on tds_peek + +Mon Aug 14 19:12:58 CET 2006 Frediano Ziglio + * src/ctlib/blk.c src/dblib/bcp.c src/dblib/dblib.c: + * src/dblib/unittests/common.c: + - fix warnings compiling with SUN cc + * src/dblib/unittests/thread.c: make error more verbose + +Sun Aug 13 15:02:40 CET 2006 Frediano Ziglio + * src/odbc/odbc.c src/odbc/unittests/data.c: + * src/odbc/unittests/transaction.c: + - fix minor issues with 64-bit machines + +Thu Aug 10 10:10:30 CET 2006 Frediano Ziglio + * src/ctlib/ct.c: fix possible buffer overflow + * src/replacements/gettimeofday.c: add comment + * src/tds/threadsafe.c: better and simple win implementation + * vms/descrip_mms.template win32/config.h: + * win32/dev-cpp/FreeTDS.dev win32/msvc6/libTDS.dsp: + - update build file + +Tue Aug 08 19:14:32 CET 2006 Frediano Ziglio + * doc/htdoc/index.html: update link + * src/tds/query.c: add comment + +Tue Aug 08 16:42:39 CET 2006 Frediano Ziglio + * src/tds/query.c src/tds/util.c: + - fix timeout problem setting correctly query_start_time + +Tue Aug 08 14:43:50 CET 2006 Frediano Ziglio + * src/odbc/unittests/Makefile.am: + * src/odbc/unittests/timeout2.c(added): + - added a test for timeout problem (cf "Query Time Out" on ML) + +Mon Aug 07 21:37:39 CET 2006 Frediano Ziglio + * include/tdsstring.h src/odbc/odbc_util.c: + * src/replacements/iconv.c src/tds/challenge.c: + * src/tds/config.c src/tds/convert.c: + * src/tds/iconv.c src/tds/mem.c src/tds/net.c: + * src/tds/query.c src/tds/read.c src/tds/tdsstring.c: + * src/tds/token.c src/tds/write.c: + - updated doxygen comments + +Sun Aug 06 17:54:11 CET 2006 Frediano Ziglio + * freetds.spec.in: fix rpm build on suse + +Thu Aug 03 20:30:07 CET 2006 Frediano Ziglio + * NEWS include/tds.h src/ctlib/ct.c src/odbc/odbc.c: + * src/tds/mem.c src/tds/query.c src/tds/tds_checks.c: + * src/tds/token.c src/tds/util.c: + - use reference counting for TDSCURSOR to avoid memory errors + +Thu Aug 03 10:32:37 CET 2006 Frediano Ziglio + * src/tds/unittests/iconv_fread.c(added): + * src/tds/iconv.c src/tds/unittests/.cvsignore: + * src/tds/unittests/Makefile.am: + - fix tds_iconv_fread and add a test for it + +Mon Jul 31 13:27:53 EDT 2006 JK Lowden + * src/dblib/bcp.c + - proper error message for using bcp with TDS version 4.2 + +Mon Jul 31 13:23:44 EDT 2006 JK Lowden + * include/sybdb.h src/dblib/dblib.c + - proper error message for using bcp with TDS version 4.2 + +Thu Jul 27 15:22:27 EDT 2006 JK Lowden + * samples/odbc_rpc.pl use fetchrow_array + * src/tds/unittests/Makefile.am include parent directory + +Tue Jul 25 10:16:45 CET 2006 Frediano Ziglio + * configure.ac m4/ac_nullzero.m4: add test for portability + +Tue Jul 25 10:10:22 CET 2006 Frediano Ziglio + * src/odbc/unittests/paramcore.c: updated + +Mon Jul 24 11:39:13 CET 2006 Frediano Ziglio + * src/odbc/unittests/prepclose.c: + - test with SQLExecDirect + +Mon Jul 17 15:18:48 CET 2006 Frediano Ziglio + * src/dblib/unittests/build_dsw.pl(removed): + * win32/build_dsw.pl(added) src/dblib/unittests/Makefile.am: + * src/odbc/unittests/Makefile.am: + - add a Makefile target to build projects for msvc6 + +Thu Jul 13 10:20:45 CET 2006 Frediano Ziglio + * include/tdsodbc.h src/odbc/odbc.c src/odbc/unittests/moreandcount.c: + - remove next_row_count, now useless... rpc.c works the same + +Wed Jul 12 13:23:43 EDT 2006 JK Lowden + * src/odbc/odbc.c src/tds/token.c: + - use TDS_NO_COUNT instead of bad rows_affected for next_row_count. + - src/odbc/unittests/rpc.c now works + +Wed Jul 12 16:15:14 CET 2006 Frediano Ziglio + * misc/test-other.sh: add file log + * src/odbc/unittests/rpc.c: fix uninitialized error + +Tue Jul 11 17:52:43 EDT 2006 JK Lowden + * src/odbc/odbc.c src/odbc/unittests/rpc.c: + - Better logging + +Tue Jul 11 17:28:34 CET 2006 Frediano Ziglio + * src/dblib/unittests/done_handling.c: improve + +Tue Jul 11 17:27:26 CET 2006 Frediano Ziglio + * src/odbc/unittests/paramcore.c: + - fix compatibility with sybase + +Tue Jul 11 11:56:53 CET 2006 Frediano Ziglio + * misc/online.pl: generate more friendly names + +Mon Jul 10 17:07:00 EDT 2006 JK Lowden + * src/tds/token.c src/dblib/dblib.c src/dblib/unittests/rpc.c + - dbresults does not return on DONEPROC + +Sun Jul 09 12:52:45 CET 2006 Frediano Ziglio + * doc/Makefile.am: fix compatibility problem + * src/odbc/unittests/rpc.c: fix warning + +Fri Jul 7 19:08:44 EDT 2006 JK Lowden + * include/sybdb.h src/dblib/dblib.c src/tds/token.c: + - Better logging + +Wed Jul 05 14:45:08 CET 2006 Frediano Ziglio + * src/dblib/unittests/Makefile.am src/dblib/unittests/bcp.c: + * src/dblib/unittests/common.c src/dblib/unittests/common.h: + * src/dblib/unittests/dbmorecmds.c: + * src/dblib/unittests/done_handling.c: + * src/dblib/unittests/rpc.c src/dblib/unittests/t0001.c: + * src/dblib/unittests/t0002.c src/dblib/unittests/t0003.c: + * src/dblib/unittests/t0004.c src/dblib/unittests/t0005.c: + * src/dblib/unittests/t0006.c src/dblib/unittests/t0007.c: + * src/dblib/unittests/t0008.c src/dblib/unittests/t0009.c: + * src/dblib/unittests/t0011.c src/dblib/unittests/t0012.c: + * src/dblib/unittests/t0013.c src/dblib/unittests/t0014.c: + * src/dblib/unittests/t0015.c src/dblib/unittests/t0016.c: + * src/dblib/unittests/t0017.c src/dblib/unittests/t0018.c: + * src/dblib/unittests/t0019.c src/dblib/unittests/t0020.c: + * src/dblib/unittests/t0021.c src/dblib/unittests/t0022.c: + * src/dblib/unittests/t0023.c src/dblib/unittests/text_buffer.c: + * src/dblib/unittests/thread.c: + * src/dblib/unittests/build_dsw.pl(added): + - put include stuff in common.h + - fix compile with ms dblib + - simplify testing under windows creating project files + +Wed Jul 5 18:29:21 EDT 2006 JK Lowden + * src/dblib/dblib.c src/dblib/rpc.c: + - removed nonprintable characters from TDSDUMP log + +Wed Jul 5 15:43:24 EDT 2006 JK Lowden + * src/dblib/unittests/rpc.c src/odbc/unittests/rpc.c: + - more thorough tests, currently fail + +Tue Jul 04 17:13:08 CET 2006 Frediano Ziglio + * src/odbc/unittests/Makefile.am: + * src/odbc/unittests/paramcore.c(added): + * src/odbc/unittests/.cvsignore src/odbc/sql2tds.c: + - test for core using SQLBindParameter, small fix + +Mon Jul 03 13:09:40 CET 2006 Frediano Ziglio + * src/odbc/odbc.c: + - assure there is always an error when SQL_ERROR is returned + - fix warning + +Fri Jun 30 10:31:49 EDT 2006 JK Lowden + * src/odbc/sql2tds.c assert good pointer in case user passed NULL + * src/odbc/unittests/Makefile.am src/odbc/unittests/rpc.c + - added new unit test, similar to that used in dblib. + +Thu Jun 29 17:05:35 CET 2006 Frediano Ziglio + * NEWS src/tds/challenge.c: + - fix small buffer overflow + - reuse buffer + +Thu Jun 29 14:07:42 CET 2006 Frediano Ziglio + * include/tds.h src/tds/Makefile.am src/tds/challenge.c: + * src/tds/login.c src/tds/token.c: + - add NTLM2 Session Response support + +Tue Jun 27 15:47:46 CET 2006 Frediano Ziglio + * src/dblib/unittests/done_handling.c: + - improve + - update style + - fix typo + +Mon Jun 26 16:10:02 CET 2006 Frediano Ziglio + * phptests/rpc2.php(added): + - test from Ellert van Koperen (cf "SP parameters" and + http://kb.vankoperen.nl/freetds-problems.html) + +Sun Jun 25 10:12:48 CET 2006 Frediano Ziglio + * src/odbc/unittests/warning.c: + - tested + - fix portability problem with former Sybase db + - test returned warning + +Sun Jun 25 09:50:00 CET 2006 Frediano Ziglio + * src/odbc/unittests/.cvsignore src/odbc/unittests/Makefile.am: + * src/odbc/unittests/warning.c(added): + - added warning test from John K. Hohm (cf + "Warning return as copy of last result row" on ML) + * src/odbc/unittests/describecol.c: compile fix + +Wed Jun 21 17:03:55 CET 2006 Frediano Ziglio + * src/odbc/unittests/describecol.c: + * src/odbc/unittests/describecol.in(added): + - rewrote describecol test + +Wed Jun 21 09:26:02 CET 2006 Frediano Ziglio + * src/odbc/odbc.c: improve column_length + * src/odbc/odbc_util.c: fix for odbc_sql_to_displaysize + * src/tds/iconv.c: invalid iconv_t is only -1, not NULL + +Tue Jun 20 17:52:19 EDT 2006 Nick Castellano + * src/odbc/unittests/array_out.c: + - rename variable to avoid libc symbol conflict + +Tue Jun 20 14:38:03 CET 2006 Frediano Ziglio + * src/tds/convert.c: use macro in sprintf + +Tue Jun 20 14:34:03 CET 2006 Frediano Ziglio + * src/tds/mem.c: small macro to allocate columns + +Tue Jun 20 14:33:09 CET 2006 Frediano Ziglio + * src/odbc/unittests/describecol.c: improved a lot + +Tue Jun 20 11:15:16 CET 2006 Frediano Ziglio + * src/odbc/odbc.c: catch error better + +Mon Jun 19 10:38:36 CET 2006 Frediano Ziglio + * freetds.spec.in misc/test-other.sh src/apps/Makefile.am: + * src/ctlib/Makefile.am src/dblib/Makefile.am src/odbc/Makefile.am: + * src/server/Makefile.am src/tds/Makefile.am: + * src/tds/unittests/Makefile.am: + - do not make libTDS shared library any more + +Mon Jun 19 09:57:23 CET 2006 Frediano Ziglio + * src/ctlib/ct.c src/odbc/sql2tds.c src/odbc/unittests/data.c: + * src/server/unittest.c: + - remove warning compiling with gcc4 + +Thu Jun 15 14:15:24 CET 2006 Frediano Ziglio + * configure.ac src/ctlib/unittests/cancel.c: + * src/dblib/unittests/common.c src/odbc/Makefile.am: + * src/replacements/readpassphrase.c: + - finished cross mingw32 + +Wed Jun 14 17:34:56 CET 2006 Frediano Ziglio + * src/odbc/convert_tds2sql.c: fix for date format + +Wed Jun 14 17:29:13 CET 2006 Frediano Ziglio + * configure.ac: add function + * src/apps/Makefile.am src/dblib/unittests/Makefile.am: + * src/dblib/unittests/bcp.c src/odbc/unittests/Makefile.am: + * src/replacements/Makefile.am src/replacements/gettimeofday.c: + * src/tds/unittests/Makefile.am: + - more fixes for cross mingw32 + +Wed Jun 14 13:26:42 CET 2006 Frediano Ziglio + * include/tds_sysdep_private.h src/apps/Makefile.am: + - fix for cross mingw32 + * src/odbc/unittests/describecol.c: report more clearly problems + +Tue Jun 13 20:17:16 CET 2006 Frediano Ziglio + * src/odbc/unittests/common.h src/server/unittest.c: + - small fixes for cross mingw + +Tue Jun 13 14:38:34 CET 2006 Frediano Ziglio + * src/odbc/unittests/prepclose.c(added) configure.ac: + * src/odbc/unittests/.cvsignore src/odbc/unittests/Makefile.am: + - add test to test error closing connection on SQLPrepare + +Mon Jun 12 22:02:57 CET 2006 Frediano Ziglio + * m4/sprintf_i64_format.m4: fix for cross mingw32 + +Mon Jun 12 21:52:24 CET 2006 Frediano Ziglio + * src/odbc/sql2tds.c: fix for possible uninitialized variable + +Mon Jun 12 21:48:15 CET 2006 Frediano Ziglio + * src/apps/datacopy.c src/apps/freebcp.c src/apps/freebcp.h: + * src/pool/main.c src/pool/pool.h: + - fix some issues cross compiling for mingw32 + +Mon Jun 12 16:55:59 CET 2006 Frediano Ziglio + * src/odbc/unittests/data.c: add test for date to char + +Fri Jun 9 14:33:31 EDT 2006 Nick Castellano + * src/apps/tsql.c: inhibit readline tab completion in tsql + +Fri Jun 09 11:50:55 EDT 2006 Nick Castellano + * locales.conf: use same date format as Sybase in default and en_US + +Thu Jun 08 10:18:50 CET 2006 Frediano Ziglio + * src/tds/unittests/t0007.c: + - improved to detect possible date problems + +Wed Jun 07 14:37:56 EDT 2006 Nick Castellano + * src/tds/convert.c: correctly convert dates in January + +Tue Jun 06 12:02:10 CET 2006 Frediano Ziglio + * configure.ac src/tds/config.c: + - fix tsql -C for sybase compatibility + +Tue Jun 06 11:32:24 CET 2006 Frediano Ziglio + * src/tds/mem.c: use calloc instead of malloc/memset + +Mon Jun 05 13:42:24 CET 2006 Frediano Ziglio + * src/ctlib/ct.c src/tds/token.c: + - style and cleanup + +Mon May 29 13:38:05 CET 2006 Frediano Ziglio + * m4/sprintf_i64_format.m4: fix quoting + +Mon May 29 12:58:38 CET 2006 Frediano Ziglio + * NEWS include/tds.h src/tds/token.c: + - make tds_alloc_get_string static + +Mon May 15 17:11:54 CET 2006 Frediano Ziglio + * src/odbc/odbc.c: + - applied fixes from Charlene Herring (cf. "Problems when + using odbc : SQLPutData, SQLExecDirect,Decimals" 2006/05/14 + +Sun May 14 14:34:04 CET 2006 Frediano Ziglio + * src/odbc/descriptor.c: fix memory error + +Sat May 13 10:49:40 CET 2006 Frediano Ziglio + * src/odbc/unittests/copydesc.c: improve + +Mon May 08 11:38:30 CET 2006 Frediano Ziglio + * src/odbc/descriptor.c src/odbc/unittests/Makefile.am: + * src/odbc/unittests/copydesc.c(added): add test for SQLCopyDesc + +Fri Apr 21 17:10:00 CET 2006 Frediano Ziglio + * src/odbc/sql2tds.c: use new tds_convert types + +Fri Apr 21 09:45:56 CET 2006 Frediano Ziglio + * doc/htdoc/faq.html: fix html compatibility + +Thu Apr 20 12:10:28 CET 2006 Frediano Ziglio + * src/ctlib/unittests/ct_dynamic.c: remove leak in test + +Tue Apr 17 19:47:57 CET 2006 Frediano Ziglio + * src/ctlib/ct.c: fix double free + +Mon Apr 17 10:51:09 CET 2006 Frediano Ziglio + * src/odbc/convert_tds2sql.c src/odbc/prepare_query.c: + - use new conversion style in ODBC + +Sun Apr 16 10:11:32 CET 2006 Frediano Ziglio + * include/tds.h src/tds/locale.c src/tds/mem.c: + - TDSLOCALE changes to keep ABI + +Sat Apr 15 10:18:29 CET 2006 Frediano Ziglio + * include/tdsconvert.h * src/tds/convert.c: + - add new type of conversion for copy optimizations + +Sat Apr 15 10:02:20 CET 2006 Frediano Ziglio + * src/odbc/unittests/describecol.c: fix for older Sybase versions + * src/tds/config.c: optimize option read + +Sat Apr 15 09:03:34 CET 2006 Frediano Ziglio + * src/odbc/unittests/describecol.c: remove warning + +Fri Apr 14 15:22:02 CET 2006 Frediano Ziglio + * src/odbc/unittests/describecol.c: + - improved + +Fri Apr 14 13:55:09 CET 2006 Frediano Ziglio + * src/odbc/unittests/describecol.c: + - add test for precision returned by SQLDescribeCol + +Wed Apr 12 21:41:51 CET 2006 Frediano Ziglio + * locales.conf: fix charset typo + * doc/userguide.sgml: fix attributes for locales.conf + +Wed Apr 12 15:53:18 CET 2006 Frediano Ziglio + * include/tds.h include/tds_sysdep_private.h: + * include/tds_sysdep_public.h.in include/tdsconvert.h: + * include/tdsver.h.in: + - avoid ident strings in all objects + * m4/sprintf_i64_format.m4: add Ld format + +Tue Apr 11 16:33:41 CET 2006 Frediano Ziglio + * include/tds_sysdep_public.h.in include/tdsver.h.in: + - small constification + +Tue Apr 11 13:51:43 CET 2006 Frediano Ziglio + * src/odbc/unittests/connect.c: do not fail if not FreeTDS + * src/odbc/unittests/raiserror.c: more verbose + +Mon Apr 10 18:14:17 EDT 2006 JK Lowden + * include/tds.h src/apps/tsql.c src/tds/config.c + - report sysconfdir with tsql -C + +Mon Apr 10 11:59:53 CET 2006 Frediano Ziglio + * src/odbc/odbc.c: cleanup + +Fri Apr 07 09:38:45 CET 2006 Frediano Ziglio + * misc/test-other.sh: update to php 5.1 + * phptests/nextres.php: a bit more verbose + +Thu Apr 06 11:37:45 CET 2006 Frediano Ziglio + * misc/coverage.sh: less verbose + * src/dblib/bcp.c: small change + +Wed Apr 05 08:42:54 CET 2006 Frediano Ziglio + * misc/full-test.sh: cleanup + * misc/test-auto.sh: allow configuration + * misc/test-other.sh: make output suitable for online.pl + * src/apps/tsql.c: + - improve documentation + - fix problem for multiple options + * src/odbc/odbc.c src/tds/token.c: avoid void message to application + +Wed Apr 05 07:09:32 CET 2006 Frediano Ziglio + * src/odbc/odbc.c: remove some warnings + +Wed Mar 29 18:25:54 CET 2006 Frediano Ziglio + * m4/ac_caolan_func_which_gethostbyname_r.m4: + * m4/ac_have_inaddr_none.m4 m4/ac_have_malloc_options.m4: + * m4/ac_raf_func_which_getservbyname_r.m4: + * m4/ac_tds_func_which_gethostbyaddr_r.m4: + * m4/ac_tds_func_which_getpwuid_r.m4: + * m4/ac_tds_func_which_localtime_r.m4: + * m4/ax_cflags_gcc_option.m4 m4/lib-link.m4: + * m4/sprintf_i64_format.m4 m4/type_socklen_t.m4: + - quote as necessary + +Mon Mar 27 19:01:05 EST 2006 JK Lowden + * configure.ac + * m4/ac_caolan_func_which_gethostbyname_r.m4 + * m4/ac_have_inaddr_none.m4 + * m4/ac_have_malloc_options.m4 + * m4/ac_raf_func_which_getservbyname_r.m4 + * m4/ac_tds_func_which_gethostbyaddr_r.m4 + * m4/ac_tds_func_which_getpwuid_r.m4 + * m4/ac_tds_func_which_localtime_r.m4 + * m4/ax_cflags_gcc_option.m4 + * m4/sprintf_i64_format.m4 + * m4/type_socklen_t.m4 + * src/ctlib/unittests/Makefile.am + * src/dblib/unittests/Makefile.am + * src/odbc/unittests/Makefile.am + * src/tds/unittests/Makefile.am + - removed/updated obsolete autoconf macros + * m4/am_iconv.m4 removed + * m4/README.iconv + * m4/iconv.m4 m4/lib-ld.m4 m4/lib-link.m4 m4/lib-prefix.m4 + - added from GNU libiconv + +Mon Mar 27 09:48:56 EST 2006 JK Lowden + * doc/htdoc/index.html corrected nightly test link + +Mon Mar 27 10:17:42 CET 2006 Frediano Ziglio + * src/dblib/rpc.c: allow again null for fixed types + +Mon Mar 27 02:20:16 EST 2006 JK Lowden + * configure.ac m4/am_iconv.m4 m4/check_openssl.m4 + * src/apps/Makefile.am src/ctlib/Makefile.am src/dblib/Makefile.am + * src/odbc/Makefile.am src/pool/Makefile.am src/replacements/Makefile.am + * src/server/Makefile.am src/tds/Makefile.am + - modernized autotool contructs + * configure.in removed + +Sun Mar 26 19:01:43 CET 2006 Frediano Ziglio + * src/odbc/prepare_query.c: + - fixed constant parameters after mssql 2005 patch + +Fri Mar 24 16:47:26 EST 2006 JK Lowden + * configure.in removed, is now configure.ac + * acinclude.m4 removed, added m4 directory + * Makefile.am include m4 directory + * m4/ac_caolan_func_which_gethostbyname_r.m4 m4/ac_have_inaddr_none.m4 + * m4/ac_have_malloc_options.m4 m4/ac_raf_func_which_getservbyname_r.m4 + * m4/ac_tds_func_which_gethostbyaddr_r.m4 + * m4/ac_tds_func_which_getpwuid_r.m4 + * m4/ac_tds_func_which_localtime_r.m4 m4/am_iconv.m4 + * m4/check_openssl.m4 m4/sprintf_i64_format.m4 m4/type_socklen_t.m4 + - Split acinclude.m4 into one macro defintion per file. + * m4/ax_cflags_gcc_option.m4 + - Check for gcc features e.g. the declaration-after-statement warning. + +Fri Mar 24 13:03:36 EST 2006 JK Lowden + * doc/htdoc/docs.html doc/htdoc/index.html updated + +Fri Mar 24 12:36:02 EST 2006 JK Lowden + * doc/htdoc/software.html fixed broken links added link to RC + +Fri Mar 24 16:27:27 CET 2006 Frediano Ziglio + * misc/full-test.sh misc/test-auto.sh misc/full-test-ol.sh(removed): + - use an "online" version for test + +Thu Mar 23 15:53:45 CET 2006 Frediano Ziglio + * src/odbc/sql2tds.c src/odbc/unittests/earlybind.c: + * src/odbc/unittests/norowset.c src/odbc/unittests/t0004.c: + * src/odbc/unittests/tables.c src/tds/data.c src/tds/tds_checks.c: + - fixes for mssql 2005 + +Thu Mar 23 13:48:23 CET 2006 Frediano Ziglio + * src/tds/query.c: partially fix problem with mssql2k5 + +Thu Mar 23 11:44:32 CET 2006 Frediano Ziglio + * misc/full-test-ol.sh misc/online.pl misc/test-auto.sh: + - changed online.pl with James hints + - enable Valgrind tests using online check + +Tue Mar 21 15:24:04 CET 2006 Frediano Ziglio + * src/odbc/unittests/cursor2.c(aded) src/odbc/unittests/Makefile.am: + - added test to check errors using cursor on no row statement + +Tue Mar 21 13:22:07 CET 2006 Frediano Ziglio + * src/odbc/native.c: + - applied patch from Richard Krehbiel (cf "ODBC datetime literal issue") + +Tue Mar 21 08:49:44 CET 2006 Frediano Ziglio + * configure.in src/dblib/dblib.c: + - fix declaration after statements + +Mon Mar 20 15:28:25 CET 2006 Frediano Ziglio + * src/dblib/bcp.c: fix error in bcp_colfmt + +Mon Mar 20 15:00:45 CET 2006 Frediano Ziglio + * src/dblib/bcp.c src/dblib/dblib.c src/dblib/rpc.c: + - remove some double checks + - return correct values from CHECK_PARAMETER + - fix some possible core if dbproc == NULL + +Mon Mar 20 09:42:55 CET 2006 Frediano Ziglio + * misc/full-test.sh: added timeout + +Sun Mar 19 18:34:47 CET 2006 Frediano Ziglio + * misc/test-auto.sh: fix typo in header + * src/dblib/dblib.c: remove double checks + +Sun Mar 19 18:33:14 CET 2006 Frediano Ziglio + * src/odbc/unittests/genparams.c src/odbc/unittests/transaction.c: + - remove warnings on 64bit int + +Sun Mar 19 09:27:09 EST 2006 JK Lowden + * src/dblib/bcp.c src/dblib/dblib.c more logging repairs + +Sat Mar 18 12:34:02 EST 2006 JK Lowden + * include/dblib.h src/dblib/bcp.c + - validate parameters. Unable to run unittest due to down server. + +Sat Mar 18 01:27:32 EST 2006 JK Lowden + * include/dblib.h src/dblib/dblib.c src/dblib/rpc.c + - test parameters for all public functions (except bcp) + +Fri Mar 17 01:35:17 EST 2006 JK Lowden + * src/dblib/dblib.c src/dblib/rpc.c + - added a TDSDUMP log entry for every public function + +Thu Mar 16 09:59:25 EST 2006 JK Lowden + * TODO add rpc error messages + * src/apps/bsqldb.c exit if severity > 10 + +Wed Mar 15 00:41:11 EST 2006 JK Lowden + * doc/freebcp.txt The freebcp manpage was seriously out of date. + * src/apps/freebcp.c give better error message. + +Thu Mar 9 14:33:37 CET 2006 Frediano Ziglio + * include/tdsodbc.h src/odbc/odbc.c: + - add cursor_type to connection attributes (required for DBD::ODBC) + - removed small TODO on error report + +Mon Mar 6 12:55:10 CET 2006 Frediano Ziglio + * include/tds.h src/ctlib/ct.c src/odbc/connectparams.c: + * src/pool/util.c src/server/login.c src/server/unittest.c: + * src/tds/config.c src/tds/login.c src/tds/mem.c: + - renamed host_name field to client_host_name + - optimize way strings are allocated + +Fri Feb 24 15:04:35 EST 2006 JK Lowden + * src/tds/config.c src/tds/login.c: + - nicer TDSDUMPCONFIG output, including a recap + +Sun Feb 19 14:56:15 CET 2006 Frediano Ziglio + * src/odbc/odbc.c: fix wrong declaration + +Thu Feb 16 08:30:00 CET 2006 Frediano Ziglio + * src/odbc/unittests/scroll.c src/odbc/unittests/raiserror.c: + * src/odbc/unittests/cursor1.c: + - remove warning compiling with gcc4 + * misc/test-other.sh: fix problem with DBD:ODBC test + +Mon Feb 13 17:11:30 CET 2006 Frediano Ziglio + * src/odbc/unittests/genparams.c: add BIGINT type to test + +Wed Feb 8 10:48:36 CET 2006 Frediano Ziglio + * include/tdsodbc.h src/odbc/error.c src/odbc/odbc.c: + * vms/odbc_driver_axp.opt win32/FreeTDS.def: + - start cursor stuff for odbc + - added SQLSetScrollOptions + * src/odbc/unittests/scroll.c: support more fetch types + +Tue Feb 7 15:42:56 CET 2006 Frediano Ziglio + * include/tds.h src/tds/query.c src/ctlib/ct.c NEWS: + - improve cursor support + +Tue Feb 7 14:22:50 CET 2006 Frediano Ziglio + * src/odbc/unittests/scroll.c(added): + * src/odbc/unittests/.cvsignore: + * src/odbc/unittests/Makefile.am: + * src/odbc/unittests/cursor1.c: + - add scroll test for cursor + - build msvc project for odbc unittests + * src/dblib/unittests/Makefile.am: add done_handling test + +Mon Feb 6 16:50:05 CET 2006 Frediano Ziglio + * include/sybdb.h src/apps/freebcp.c src/dblib/bcp.c: + - implemented BCPKEEPIDENTITY for bcp_control + - make freebcp do not depend on dblib internals + +Mon Feb 6 16:44:27 CET 2006 Frediano Ziglio + * src/odbc/unittests/.cvsignore src/odbc/unittests/cursor1.c: + - update cursor1 test + +Thu Feb 2 15:33:21 CET 2006 Frediano Ziglio + * NEWS: updated + * src/odbc/odbc.c vms/odbc_driver_axp.opt win32/FreeTDS.def: + - compile SQLSetPos function + * src/odbc/unittests/Makefile.am src/odbc/unittests/cursor1.c(added): + - added a test for cursors (do not work...) + +Tue Jan 31 14:27:51 CET 2006 Frediano Ziglio + * src/apps/freebcp.c src/dblib/bcp.c: + - fix broken charcater conversion + - use calloc instead of malloc/memset + - support 64bit file on win32 + +Tue Jan 31 09:59:28 CET 2006 Frediano Ziglio + * src/dblib/dblib.c: do more argument check + +Mon Jan 30 16:29:20 CET 2006 Frediano Ziglio + * src/ctlib/unittests/blk_out.c src/ctlib/unittests/ct_cursor.c: + * src/ctlib/unittests/ct_cursors.c src/ctlib/unittests/ct_dynamic.c: + * src/dblib/unittests/t0005.c src/dblib/unittests/t0014.c: + * src/dblib/unittests/t0022.c src/dblib/unittests/thread.c: + - reduce false errors + +Sat Jan 28 15:49:55 CET 2006 Frediano Ziglio + * src/dblib/bcp.c: + - update row allocation using new row_free + - fix native format + - correctly check and handle EOF + - change _bcp_build_bcp_record to direct send row (renamed to + _bcp_send_bcp_record) + - write error file only if needed + * src/dblib/unittests/t0016.c: improved + * src/dblib/unittests/t0016.in: + - make input same of output + * src/dblib/unittests/t0017.c: get all data + * src/tds/mem.c: reset pointer just freed + +Sat Jan 28 09:39:10 CET 2006 Frediano Ziglio + * src/dblib/unittests/t0017.c: reformat output + +Fri Jan 27 14:34:09 EST 2006 JK Lowden + * src/dblib/bcp.c recognize EOF errors from _bcp_read_hostfile + +Fri Jan 27 10:43:54 EST 2006 JK Lowden + * src/dblib/unittests/t0017.c better feedback + +Thu Jan 26 13:58:51 CET 2006 Frediano Ziglio + * src/apps/freebcp.c src/apps/freebcp.h: + - support for NUL in terminators + +Wed Jan 25 15:33:20 CET 2006 Frediano Ziglio + * src/dblib/bcp.c: fix return test for fseeko + +Wed Jan 25 15:01:51 CET 2006 Frediano Ziglio + * acinclude.m4 configure.in src/tds/numeric.c: + - use 64bit sprintf format if available + * misc/test-other.sh: redirect odbc to compiled driver + +Tue Jan 24 16:01:41 CET 2006 Frediano Ziglio + * NEWS include/tds.h src/apps/tsql.c src/ctlib/blk.c: + * src/ctlib/ct.c src/dblib/bcp.c src/dblib/buffering.h: + * src/dblib/dblib.c src/dblib/rpc.c src/odbc/odbc.c: + * src/odbc/odbc_util.c src/odbc/prepare_query.c: + * src/odbc/sql2tds.c src/pool/stream.c src/server/server.c: + * src/tds/mem.c src/tds/query.c src/tds/tds_checks.c: + * src/tds/token.c src/tds/unittests/dataread.c: + * src/tds/unittests/dynamic1.c src/tds/unittests/t0002.c: + * src/tds/unittests/t0004.c src/tds/unittests/t0005.c: + * src/tds/unittests/t0006.c src/tds/unittests/utf8_1.c: + * src/tds/unittests/utf8_2.c: + - use direct pointer column_data instead of old column_offset + +Mon Jan 23 17:30:38 EST 2006 JK Lowden + * src/apps/bsqldb.c bind to printable width, not column size + +Mon Jan 23 14:04:44 CET 2006 Frediano Ziglio + * configure.in: start developing 0.65 version +$Id: ChangeLog-0.82,v 1.1.2.2 2008/01/10 20:58:43 jklowden Exp $ diff --git b/INSTALL.CVS a/INSTALL.CVS new file mode 100644 index 0000000..c23f6b7 --- /dev/null +++ a/INSTALL.CVS @@ -0,0 +1,65 @@ +Building FreeTDS from CVS +James Cameron + +The CVS archive is maintained on Source Forge. See the User Guide or +start at http://sourceforge.net/projects/freetds/ for information on +connecting to the CVS server. Then follow these steps: + +1) satisfy build dependencies, ensure that the following packages are + installed: + + automake (GNU Automake, generates Makefile.in from Makefile.am) + autoconf (GNU Autoconf, generates configure from configure.in) + libtool (GNU Libtool, library creation support scripts) + make (GNU or BSD Make.) + gcc (GNU Compiler Collection, for C code compilation) + + Autotool versions that work: + $ (autoconf --version; automake --version; libtool --version) |grep GNU + autoconf (GNU Autoconf) 2.60 + automake (GNU automake) 1.9.6 + ltmain.sh (GNU libtool) 1.5.18 (1.1220.2.245 2005/05/16 08:55:27) + + The above are used to generate the distributions. + You may get away with older versions, as far back as 2.53 for autoconf. + +2) execute autogen.sh to run automake, autoconf and configure, + + ./autogen.sh + + Any switches provided to autogen.sh will be passed to the configure script. + +3) compile the source using make, + + make + +5) switch to a user that can write to the target installation + directory, usually root, + + su root + +4) install the package, + + make install + ++++ + +You are not required to rely on SourceForge's anonymous CVS server, which at +the present time (July 2004) runs up to 1 hour behind the development server. +You can fetch the CVS tarball (the basis for a CVS server, not a snapshot) from +SourceForge at: + +http://cvs.sourceforge.net/cvstarballs/freetds-cvsroot.tar.bz2 + +We have a backup location, too, via anonymous ftp: + + ftp://rt.fm/pub/freetds/ (thanks to Joshua Stein ) + +Nightly tarballs have been discontinued or deprecated, depending on which +Sourceforge document you believe. Either way, you can now fetch +the CVS tree via rsync: + +$ rsync -av rsync://freetds.cvs.sourceforge.net/cvsroot/freetds/* . + +-- +$Id: INSTALL.CVS,v 1.7.2.1 2008/01/10 20:58:43 jklowden Exp $ diff --git b/TODO.freddy a/TODO.freddy new file mode 100644 index 0000000..521a55a --- /dev/null +++ a/TODO.freddy @@ -0,0 +1,66 @@ +Well.. I don't know how to put these information so I'll put here +Probably I'm the only person who can fully understand these notes... + +Fixes +----- +IMPORTANT fix done_handling +ODBC RPC check (+chained rpcs?? see below) + +Cursor and dynamic +------------------ +libTDS should handle real cursor/dynamic memory deallocation +search for tds_alloc_cursor, tds_free_cursor and similar for dynamic +cursor too complicate... reduce all states, handle more in libTDS +Tests: + - multiple RPCs check returns (possible??) + (see odbc_set_return_status, odbc_set_return_params and odbc_get_param_len + calls) + add multiple chained RPCs for odbc and mssql7+... + - cursor update and multiple tables (using view) +ODBC cursor check (cfr "Progress on CVS") + search "TODO read results, set row count, check type and scroll returned" +http://support.microsoft.com/kb/246265/en-us +http://support.microsoft.com/kb/290413/en-us +http://support.microsoft.com/kb/238336/en-us + +Row handling +------------ +Upper layer should be able to read data from network and handle rows +Possibility to stop sending/receiving data for SQLPutData and similar +Allow upper layer to get if libTDS is sending a request (add new state??) +tds_process_tokens should "return" any row/done/other informations, +not only done_flags +libTDS should handle multiple reply from server (cursors and so on) + +Token handling +-------------- +Split token.c to one base token handling and another with higher +level (callbacks, state and so on) +See James propos about tds_read_results + +Done handling +------------- +Callback when state goes to IDLE +Free unused cursors and dynamic and/or reuse them + +Other +----- +Implement some sort of fast write to network writing directly to +wire buffer. It would be helpful to have "lock" length size, write to +wire, write length, "unlock". Also a function to get current position (to +compute lengths). + +build an array of "flags" to translate type -> flag like SYBCHAR -> +char, variable and so on + +Possibility to lock TDSSOCKET (see odbc, multiple RPCs) + +Support Unicode under ODBC, use iso8859-1 by default and large characters + + +Tests +----- +Rebuild all test support (virtual machines, chroot, msde+mssql2005) +Add a test for rpm (redhat, suse?) +disabling thread safety don't check for thread-safe functions +check cross compiled odbc driver, exports, resource version (test-dist) diff --git b/doc/.cvsignore a/doc/.cvsignore new file mode 100644 index 0000000..1138025 --- /dev/null +++ a/doc/.cvsignore @@ -0,0 +1,19 @@ +Makefile +Makefile.in +freebcp.1 +html +tsql.1 +bsqldb.1 +defncopy.1 +datacopy.1 +osql.1 +fisql.1 +libtds +reference +userguide.dsl +doc +ctlib.api.sgml +dblib.api.sgml +doxy.log +odbc.api.sgml +bsqlodbc.1 diff --git b/doc/README.releasing a/doc/README.releasing new file mode 100644 index 0000000..cae6dc0 --- /dev/null +++ a/doc/README.releasing @@ -0,0 +1,53 @@ +It's pretty simple, basically: + +0) Form a branch in cvs: + + $ cvs tag -b BRANCH0_xx + + Use the form BRANCH0_xx, where xx is the release number. This affects only + the repository, not the working directory. + +1) Change the version number in configure.ac and UG. +2) Update web pages regarding purpose and status of rc. +3) Put out a release candidates until everyone's happy. + jkl has a "make dist" script on /etc/nightly.freetds that works well. +4) ftp tarball to + ftp://login.ibiblio.org/pub/linux/ALPHA/freetds/current +5) ftp user guide to www.freetds.org/userguide/. + repeat 3-4 as necessary. +6) Log into ibiblio. Trim rc# from tarball. Update web site. +7) Create rpm with 'rpmbuild -ta freetds-0.61.tar.gz', post these to + ibiblio as well. + +Announcements to: + + freshmeat.net + comp.os.linux.announce + comp.databases.sybase + comp.databases.ms-sqlserver + linuxpr.com + + +We received this bit of advice on the mailing list on +Wed Oct 15 14:51:06 EDT 2003. + +Please, please, *please* follow the common rules of good release +engineering (in descending order of importance - two orders of magnitude +less important per step ;-) + +(A) (Priority 100) A release is STATIC. You NEVER EVER change the + contents of a release after the fact, such as replacing the + freetds-0.61.tgz archive with a DIFFERENT ARCHIVE containing + freetds-0.61.2. This breaks everybody that has a system in place + for using the tarballs - and I know of at least eight public open + source systems that do this, as well as a bunch of proprietary systems. + +(B) (Priority 1) Release engineering needs to include procedures to + make sure that the documentation in the release is up to date. + FreeTDS 0.61.2 refers to itself as FreeTDS 0.61.1. + +(C) (Priority 0.01) It'd be nice if the archive name followed the normal + convention for naming - .tar.gz for tar and gzip, rather than .tgz. + +-- +$Id: README.releasing,v 1.10 2008/01/08 13:29:40 freddy77 Exp $ diff --git b/doc/htdoc/contrib.html a/doc/htdoc/contrib.html new file mode 100644 index 0000000..284f3e1 --- /dev/null +++ a/doc/htdoc/contrib.html @@ -0,0 +1,71 @@ + + + + + +FreeTDS.org + + + + + + + + + +
FreeTDS.org +Home  |  +News  |  +Software  |  +Documentation  |  +Support  |  +Contribute +
+
+ + + +

+Contribute +
+
+

+ + + + + + + + + + + +
 
+So you want to help out the FreeTDS Project? We greatly appreciate all offers. There are a number of ways to help and this page will let you know about them. +
 
+If you are a programmer and wish to contribute code, please join our Mailing List. Preferred form for patches is a context diffs against the current CVS tree. If you have submitted patches in the past and want to get a CVS account for direct checkin ask James. +
 
+If your C skills aren't up to snuff, but you still want to help, consider pitching in on the FreeTDS documentation. If something didn't make sense when you read it, let us know. Or if you want to detail how you got a specific configuration working, send it in and we'll include it in the User Guide, so those that come after you will have an easier time. +
 
+If on the other hand you simply want to donate money to the FreeTDS Project, we also graciously accept donations via PayPal. Just click on the button below. These funds will be used for purchases of software and hardware specifically needed by those who work on FreeTDS. In particular, our current needs include VMWare, Win2K Server (to complete domain login support), and SQL Server 2000 (for TDS 8.0 support). We will provide a detailed accounting of how these funds are spent to any contributor who requests it. +
 
+ + +
+

+ + + + + + + + + +

+
+ + + + diff --git b/doc/htdoc/faq.html a/doc/htdoc/faq.html new file mode 100644 index 0000000..76126b3 --- /dev/null +++ a/doc/htdoc/faq.html @@ -0,0 +1,864 @@ + + + + + + + + + + FreeTDS Frequently Asked Questions + + + + + + + + + + + +
FreeTDS.orgHome  |  + News  |  Software  |  Documentation  |  Support  |  Contribute
+
+ + +

FAQ

+ +

The FreeTDS User Guide, + included in each release, is the appropriate place for new users + to start.

+ +

This list of frequently asked questions and answers about + FreeTDS is updated between releases to cover problems since the + last release, and to answer perennial questions (there are + some).

+ +
+ $Id: faq.html,v 1.18 2006/12/10 21:07:47 jklowden Exp $ +
+ +
    +
  1. General Questions + + +
  2. + +
  3. Documentation + + +
  4. + +
  5. Implementation + + +
  6. + +
  7. Programming: C++, Sybperl, SQSH, & PHP + + +
  8. + +
  9. Problems Running + + +
  10. +
+ +
+ +

General Questions

+ +

What is FreeTDS?

+ + +

FreeTDS is a free implementation of the TDS (Tabular Data + Stream) protocol that is used by Sybase and Microsoft for their + database products. It implements TDS 4.2, 5.0, 7.0 and + 8.0, and can communicate with any Sybase or Microsoft SQL + Server.

+ +

FreeTDS comes with a low level library (the TDS layer) along + with a number of APIs (Application Programming Interfaces). The + APIs are DB-Lib, CT-Lib, and ODBC.

+ +

A JDBC driver has also been contributed under a BSDish license + and is available from the download page. It does not require the + FreeTDS C libraries.

+ +

Where do I get FreeTDS?

+ + +

You can get the latest FreeTDS from + Ibiblio or its mirrors. See "Quick Links" on the FreeTDS home page. You may also use + the CVS + repository (on sourceforge.net); see the + User Guide for details.

+ +

Your favorite operating system may have a package of some kind + available. You might want to check there. Occasionally someone + contributes a package here, which we keep around. Post a message + to the list if you're looking for one and don't find one in the + usual places.

+ +

Does FreeTDS support Microsoft servers?

+ + +

Yes. Microsoft servers don't usually accept TDS 5.0 + connections. Use one of versions 4.2, 7.0 or 8.0 of the protocol. + See the User + Guide for details.

+ +

How can I get help (or support)?

+ + +

After reading this FAQ and the User Guide, you might want to + look at the mailing list archives. If + you don't see your question answered there (or, if you'd just + like to learn more about what's going on with FreeTDS), please + subscribe to the mailing list. Questions + new and old are cheerfully answered there. Traffic is not high, + normally around 10 messages a day.

+ +

Netiquette note: It's considered poor form to mail + "help me" questions directly to the developers of any free + software project, this one included. Please direct your question + to the list, where someone with the available time and expertise + can help you.

+ +

Who is responsible for FreeTDS?

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Brian + BrunsStarted this crazy thing
Gregg + JensenMessage handlers and extra datatype support and some + sybperl stuff?
Arno + PedusaarDonated his TDS4.2 code to the cause
Mihai + IbanescuGNUified the packet
Craig + SpannringJDBC driver and CVS repository.
Mark + SchaalCleaned up message handling, bug fixes, ctlib + unittests
Kevin + LyonsVarious TDS bug fixes
Sam + TetherowVarious TDS bug fixes
Geoff + WinklessLost connection stuff
Ken + SeymourODBC Driver Fixes
Scott + GrayTDS 7.0 numeric support and bug fixes
Bob + KlineNTEXT support
Koscheev + Andreynegative money patch
Dennis + NicklausvxWorks port and fixes for dbdata() and SYBVARBINARY
Brandon M. + Reynoldsfix for arbitrarily large queries under dblib.
Steve + Langasekoff by one fixes and autoconf byte size thing.
Mark J. + Lilbackimplementation of dbstrlen and dbstrcpy
Thanks go to the folks at A2i, Inc. http://www.a2i.com for funding the + development of dblib host file bulk copy and writetext + support, and to Dave Poyourow there for helping with the + debugging.
+ +

(These addresses have been mangled to defy "spamaton" programs + that mindlessly collect email addresses from the web. To send + email to anyone listed above, delete the "nospam." part of the + address.)

+ +

Why LGPL license?

+ + +

Brian Bruns started the project, and that's the choice he + made. LGPL was chosen because if you want a commercial client, + you can buy them from Sybase, Microsoft or others. "I do believe + BSDish licenses are better in some cases, but not for something + like this," he said.

+
+ + +

Documentation

+ + +

What sort of documentation is available?

+ +
    +
  • The FreeTDS User Guide + is the best place to start.
  • + +
  • FreeTDS , on Reference Manual is a + beginning at an independent description of the client APIs and + the TDS layer.
  • +
+ +

What about a Programmer's Reference Manual?

+ +

The best information is available from the vendors. FreeTDS + means to conform to the documented (and, in some cases, + undocumented) behavior of the vendors' offerings.

+ + + +

Is there any documentation on the TDS protocol?

+ + +

Yes, there is some preliminary + documentation available. The most up to date version is in + the User Guide.

+ +

Sybase publishes its TDS 5.0 Functional Specification.

+
+ + +

Implementation

+ + +

What is this SYBASE environment variable?

+ +

Many programs look for the SYBASE environment + variable in order to find the library's home. You will want to + set this to the main FreeTDS directory. For example, if + FreeTDS is installed in /usr/local/freetds + (meaning the libraries were installed in + /usr/local/freetds/lib), then your SYBASE + variable would be set to /usr/local/freetds.

+ +

How do I install the RPM?

+ + +

rpm -ivh freetds-0.52-1.i386.rpm (as root) will + install the libraries.

+ +

rpm -ivh freetds-devel-0.52-1.i386.rpm (as root) will + install the headers and other stuff needed to build other + stuff.

+
+ + +

Programming: C++, Sybperl, SQSH, & PHP

+ + +

How do I compile Sybperl with FreeTDS?

+

How do I compile SQSH with FreeTDS?

+

How do I compile PHP 3 with FreeTDS?

+ +

Please refer to the User Guide.

+ +

One small PHP hint, mailed to the FAQ master in May 2001:

+ +

In the mailing list archives I noticed a few people discussing + a problem I just had.

+ +
+

An attempt to make a connection to a MS SQL server from PHP + would fail, leaving a message in the Apache error log:

+
+        "connect: Network is unreachable
+         DB-Library: Login incorrect"
+
+ +

The problem turned out to be a very simple one to fix. In + the php.ini file under the sybase section, there is a directive + that sets the path to the sybase interfaces file + "sybase.interface_file = "

+ +

After uncommenting this and setting it to a reasonable value + (ie. /usr/local/freetds/interfaces), things started + working.

+
+ +

How should I choose among db-lib, ct-lib, + and ODBC

+ +

FreeTDS offers three client libraries and one + internal one (libtds). We generally encourage people to + use one of the client libraries, and discourage writing to + libtds, because the latter is evolving, more subject to + change, less well documented, and harder to use. In choosing + which client API to write to, you might want to peruse our + brief discussion.

+ +

Which Perl library should I use?

+ + +

There are four options for using TDS and Perl to connect to a + Sybase or MSSQL database, DBD::Sybase, DBD::ODBC, DBD::FreeTDS, + and Sybperl.

+ +

From Mark Schaal:

+ +

DBD::Sybase is the recommended option, and yes it does work + with MSSQL. You will need to install the perl DBI module and the + FreeTDS package, particularly the CTLib portion. Set your SYBASE + environment variable to /usr/local/freetds and install + DBD::Sybase. Don't worry too much if some of the tests fail. Do + worry if the module doesn't compile. Make sure you have the most + recent version of FreeTDS installed. You can check the mailing list + archives or ask the mailing list for help.

+ +

DBD::FreeTDS does not depend on the FreeTDS libraries. It is + minimally functional but it is considered alpha software and is + not being actively developed.

+ +

From Michael + Peppler:
+ Sybperl is a thin wrapper around the Sybase C APIs. It's a lot + more mature than DBI/DBD::Sybase (I've been working on it for 9 + years :-) and it's maybe more natural to use for someone who + already knows the Sybase APIs (or MS's DBlibrary). It's a little + more powerful/flexible than DBI, though obviously less portable. + It's still actively maintained and developed (by yours truly)

+ +

From Brian:
+ DBD::ODBC is the newest option available. Its primary advantage + is not having to load another DBI driver if you already have + DBI::ODBC load for other systems. On the downside, it may be a + little less robust than DBD::Sybase.

+ +

Are there any known issues?

+ +
    +
  • ODBC can be confusing to set up. See the samples + directory for example .ini files, and follow the User + Guide's instructions carefully.
  • + +
  • BCP of text and image types is broken for + Microsoft servers.
  • + +
  • BCP does not support TDS 4.2. You must use a more modern + protocol version.
  • + +
  • Server-side cursors work only in ct-lib.
  • + +
  • ODBC lacks a client-side cursor implementation.
  • + +
  • DBD::Sybase dynamic SQL placeholders don't work, pending a client-side SQL parser. (The ODBC ones do.)
  • + +
  • There are no plans to implement db-lib's browse mode.
  • +
+ +

Errors can sometimes be confusing. When an application uses + the library incorrectly, or when there are problems in a data + file being uploaded with BCP, the message returned by FreeTDS can + sometimes be misleading. In the latter case, it's often necessary + to examine the log file to understand what went wrong.

+ +

Why does each connection support only one query at a time?

+ + +

If you are accustomed to programming with other database + servers, you may be surprised when you first encounter this + aspect of the TDS protocol. When a TDS server—be it by + Microsoft or Sybase—responds to a query, it may send a result + set to the client. The server does not construct a complete + result set first, unless it needs to (say, to execute an + ORDER BY clause). Instead, it sends the rows as they're + selected/formed, in real time (if you will). Likewise, the client + libraries do not read all the rows from the server before + making them available to the client application.

+ +

The client library is tightly coupled to the server; they are + synchronized, share state information. The server requires the + client either to read all the results from a query, or to + indicate that no further rows are desired i.e., to issue a + cancellation. Until one of those two things happens, the server + will not accept new queries on that connection. It will complain + about "pending results".

+ +

How do mortal programmers cope with this strict + one-query-at-a-time limitation? For one thing, they become better + programmers.

+ +
    +
  • The solution often involves doing more SQL work, which + often results in less interaction with the server, which is + almost always faster.
  • + +
  • Even when that's not true, there's nothing to prevent the + application from caching the whole results set in its own + collection object.
  • + +
  • Sometimes, the best answer is to open a new connection. + That's not as bad as it sounds, and it certainly not unheard of + to have 4 or more simultaneous connections supporting an + application.
  • +
It's important to realize that the selection of rows and + their accumulation into a container of some sort are two + different functions. A TDS server issues its results a row at a + time, which the client library dutifully makes available to the + application on arrival. It's up to the application—or a + higher-level library—to form a "rowset" of some kind if + desired. + +

PHP note

If you use PHP, you will still run into this + problem even if you create a new connection. The reason is that + PHP is so nice that it will re-use the first connection if you + connect again with the same parameters. You my wish to refer to + this + post by Daniel Fazekas in the mailing list archives. + +

Is FreeTDS thread safe?

+ + +

Different threads may all use separate connections without + interfering with each other. Threads may not share a DBPROCESS or + CS_CONNECTION without controlling access via a mutex.

+ +

Are there plans to implement the OpenServer protocol/library?

+ + +

Not at this point, there is still much work to do on the + client protocol. But, libtdssrv will do the trick for + some applications.

+
+ + +

Problems Running

+ +

With DBD::Sybase, why do I sometimes get an + unexpected 1-column result set?

+ + +

Use a more recent release of FreeTDS. This problem was + corrected with version 0.63.

+ +

Output Parameters

+ + +

I'm not getting my output parameters returned, but I seem + to be doing everything right!

+

That's not a question!

+

Microsoft SQL Server 7 with SP3, and later versions, quietly changed (which is to say, broke) how they respond to queries that execute stored procedures with output parameters. Earlier servers let you send a query like EXECUTE A @P OUTPUT and fetch the output parameter as a special result row (technique varying by library). Newer servers simply don't send back that data. To elicit output parameters from them, you have to use the RPC protocols such as the db-lib dbrpcparam. +

+ +

What does this unknown marker message mean?

+ + +

Most of the time, it means you're not using the right protocol + version. That can happen even if your ./configure + was done correctly. Try setting the TDSVER variable to a + value appropriate for your server: normally 5.0 for + Sybase and 7.0 for Microsoft. If that works, double + check your work. If your freetds.conf file and + configure options were right, but you + needed the environment variable anyway, please post a message to + the list and help us track it down.

+ +

What if I get a connection + refused message?

+ + +

You want to make sure:

+ +
    +
  • your server is running,
  • + +
  • you can connect to it,
  • + +
  • your account has permissions in the database to execute + your query.
  • +
+ +

Steps:

+ +
    +
  1. Try telnet hostmachine port and + see if it's listening. You should get some form of response + from the server (actual text varies by vendor & + version).
  2. + +
  3. +

    Try tsql -H hostmachine -p port -U + username -P password

    + +

    That will connect to the server, bypassing the + freetds.conf file. If it doesn't work, the problem lies + upstream.

  4. + +
  5. +

    Try tsql -S servername -p port -U + username -P password

    + +

    That will connect to the server using freetds.conf. This + allows you to isolate freetds.conf mistakes. man + tsql for more.

  6. + +
  7. Check your ./configure and environment variables. The + --with-tdsver determines what flavor of the TDS + protocol your runs by default; the $TDSVER variable overrides + that default. The following combinations are reasonable; see + the User Guide + for details:
  8. + +
  9. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    VendorVersionTDS Version
    Sybase4.92+ 5.0
    Microsoft6.0, 6.54.2
    Microsoft7.0/20007.0
    +
  10. + +
  11. +

    Edit the PWD file and try make + check. It will call unittests for libtds, ctlib, dblib + and odbc in that order

    +
  12. + +
  13. +

    Compile sqsh and try that + before the more complicated stuff (PHP/Perl). If you can + connect with sqsh, you don't have a FreeTDS + problem.

    +
  14. +
+ +

The Microsoft SQL Server is listening, my configuration and + environment are set up per question 6.1, but logins still + fail.

+ + +

Microsoft supports two security models in three + permutations:

+ +
    +
  1. Windows NT Authentication Mode (Windows NT + Authentication)
  2. + +
  3. Standard Mode (SQL Server Authentication)
  4. + +
  5. Mixed Mode (Windows NT Authentication and SQL Server + Authentication)
  6. +
+ +

"Windows NT Authentication", often called "integrated + security", relies on Microsoft's domain logins, which establish a + user's network security attributes at network login time. When + connecting to the database server, SQL Server accepts an + encrypted password in the login packet, and uses Windows NT + facilities authenticate it, usually via the Primary Domain + Controller (PDC). The server then permits or denies login access + based on the response.

+ +

With traditional "Standard Mode" authentication, usernames and + passwords are stored within SQL Server. They are passed in the + login packet as plaintext, and connection requests are + authenticated without consulting the operating system.

+ +

FreeTDS supports both security models. Domain logins are + recognized by the presence of a backslash (\) character in the + username. See the User Guide for + details.

+ +

My text data are being truncated or are causing my + client to break.

+ +

The text data type is different from char + and varchar types. The maximum data length of a + text column is governed by the textsize + variable on the server. Microsoft claims in their + documentation to use a default textsize of 4000 + characters, but in fact their implementation is inconsistent. + Sometimes text columns are returned with a size of 4 + GB!

+ +

The best solution is to make sure you set textsize to + a reasonable value when establishing a connection. For + example:

+
+
+set textsize 10000
+
+ +

My dates aren't formatted right!

+ + +

Some dates turn out better than others.

+ +

If you think your dates should look like 2001-12-13 + 17:58:55.000, but you're seeing something like Dec 13 + 2001 05:58PM instead (or vice versa), you've bumped into + driver behavior. There's no standard governing the default + character string representation of a datetime + datatype. Different drivers make different choices, and your + driver has chosen a representation for you.

Microsoft's ODBC + driver (which is used by among other things the Query Analyzer + tool) converts datetime to an ISO format. That format + has the advantages of being all numeric: sortable, unambiguous, + and locale-independent. The vendors' db-lib and + ct-lib, in contrast, use the MMM DD YYYY + hh:mm format. + +

If you want to be sure your queries always return dates in a + particular format, don't leave the formatting up to the driver! + Use the convert function. For example:

+ +
+
+1> select convert( varchar(30), getdate(), 120 ) as Now
+2> go
+ Now
+ ------------------------------
+ 2002-07-02 12:36:31
+
+
+ +

As of version 0.60, the default datetime->string conversion + is controlled by the locale.conf file. See the User + Guide for details.

+
+ Updates and comments FreeTDS FAQ Master +
+

+ Valid XHTML 1.0 Transitional +

+ + diff --git b/doc/htdoc/news.html a/doc/htdoc/news.html new file mode 100644 index 0000000..ed0a8a9 --- /dev/null +++ a/doc/htdoc/news.html @@ -0,0 +1,239 @@ + + + + + +FreeTDS.org + + + + + + + + + +
FreeTDS.org +Home  |  +News  |  +Software  |  +Documentation  |  +Support  |  +Contribute +
+
+ + + +

+News and Press +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FreeTDS announces Version 0.63
+
+Version 0.63 is now available. The source tarball is freetds-0.63.tar.gz on Ibiblio. You may wish to read the announcement. (30 April 2005) +
+
+
FreeTDS announces Version 0.63 branch
+
+Version 0.63RC1 is now available in the stable directory on Ibiblio. Enjoy,and please test on your favorite architecture. +(27 November 2004) +
+
+
FreeTDS announces Version 0.62.1
+
+Includes a small but significant fix to token.c. Version 0.62.1 +(15 Jan 2004) +
+
+
FreeTDS announces Version 0.62
+
+In the year since the last release, FreeTDS has seen many improvements. Version 0.62 includes: +
    +
  • UTF-8 support, as well as most other client-side character sets
  • +
  • ODBC 3.0 compliance
  • +
  • many new ODBC functions
  • +
  • cursors, array binding, dynamic SQL, and RPC support in ct-lib
  • +
  • improved network performance through better socket and packet handling.
  • +
  • more Win32 development choices; VMS support
  • +
+(11 Jan 2004) +
+
+
FreeTDS announces Release Candidate 2 for Version 0.62
+
+We are in the process of releasing version 0.62. See main page for the latest release candidate (5 Jan 2004) +
+
+
FreeTDS announces Version 0.61.2
+
+This point release fixes some memory leaks. (3 August 2003) +
+
+
FreeTDS announces Version 0.61.1
+
+This point release offers bugfixes: +
    +
  • Segmentation fault with iODBC
  • +
  • Segmentation fault opening log file in append mode
  • +
  • binding parameters with NULL indicator
  • +
+ (20 May 2003) +
+
+
FreeTDS announces Version 0.61
+
+This release supersedes version 0.60 in all respects. It addresses all known +bugs except one, see README for details. Read the announcement and try out the new features. (1 March 2003) +
+
+
FreeTDS announces Version 0.61 Release Candidate
+
+Try out the new features. (20 February 2003) +
+
+
FreeTDS and PHP in Linux Journal
+
+A recent online article by David Perrin in the Linux Journal describes his good fortune using FreeTDS to connect his PHP-based web server to a Microsoft SQL Server. +
+
+
FreeTDS proudly announces Version 0.60
+
+The new version has better datatype handling and conversion capabilities, better BCP, better compatibility with Microsoft SQL Server 2000. It's just way better. More people have joined the project, and more better things are still in store. Read the announcement and try out the new features. (11 September 2002) +
+
+
FreeTDS and DBD::Sybase in Linux Journal
+
+This month's (April 2002) Linux Journal has an article about using DBD::Sybase and FreeTDS to talk to Microsoft SQL Server by Andrew Trice. +
+
+
FreeTDS.org gets a new look
+
+FreeTDS.org has been redesigned to provide new users an easier time of finding the resources they need to use FreeTDS successfully. Any comments (good or bad) should be directed to the Mailing List. +
+
+
CVS moves to SourceForge
+
+The CVS repository has been moved to the FreeTDS project on SourceForge. The old repository will stay active indefinately for tracking historical changes as the new repository starts with 0.53pre1. Consult the FAQ for details on using the new repository. +
+
+
FreeTDS version 0.53pre1
+
+FreeTDS 0.53pre1 is now available at iBiblio.org and it's mirrors. This release fixes some nasty host lookup bugs with 0.52 and it is recommend for those having troubles connecting with 0.52. This is a tarball-only release; RPM packages will be available with the full 0.53 release. +
+
+
FreeTDS version 0.52
+
+FreeTDS 0.52 is now available at iBiblio.org and it's mirrors. Both the source distribution and RPMs for Linux (i386) are available. Major features include a new configuration file format, much better ODBC support, and bug fixes. An announcement and some release notes are also available. +
+
+
The FreeTDS User Guide
+
+The FreeTDS Users Guide is an effort to provide better documentation for the FreeTDS user community, if it doesn't answer all your questions please submit your solutions so they may be included for the next person. +
+
+
FreeTDS Article on PHPBuilder
+
+PHPBuilder has an article on accessing SQL Server from Linux in which FreeTDS figures prominently. And it even points out some areas for us to improve in. ;-) +
+
+
+ + + diff --git b/doc/htdoc/support.html a/doc/htdoc/support.html new file mode 100644 index 0000000..0f67f31 --- /dev/null +++ a/doc/htdoc/support.html @@ -0,0 +1,53 @@ + + + + + +FreeTDS.org + + + + + + + + + +
FreeTDS.org +Home  |  +News  |  +Software  |  +Documentation  |  +Support  |  +Contribute +
+
+ + + +

+Support +

+ + + + + + + + + + +
 
+The first place you should look to resolve your problem is the documentation +
 
+The next step is to subscribe and post a question to the Mailing List . Please read the Getting Help section of the User Guide to ensure that the folks on the list can isolate and fix your problem. +
 
+Note: I often see people post what are really FreeTDS questions in a variety of forums such as the PHP list, LUG lists, and Usenet groups. Many times these queries go unanswered because no one in those forums knows FreeTDS. Your best bet for getting answers will generally be the FreeTDS mailing list. (I know this seems obvious, but you'd be surprised). +
 
+Blatant commercial plug! +If you are interested in having someone install and configure FreeTDS for you, you can contact Brian Bruns (camber@ais.org), the original author of FreeTDS, who offers consulting, custom programming, and support contracts for FreeTDS. +
 
+ + + diff --git b/doc/txt2man a/doc/txt2man new file mode 100755 index 0000000..ed5a6a4 --- /dev/null +++ a/doc/txt2man @@ -0,0 +1,314 @@ +#!/bin/sh +test "$HOME" = ~ || exec ksh $0 "$@" # try ksh if sh too old (not yet POSIX) + +# Copyright (C) 2001, 2002, 2003 Marc Vertes + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# txt2man-1.4.8 + +usage() +{ +cat << EOT +NAME + txt2man - convert flat ASCII text to man page format +SYNOPSIS + txt2man [-hpTX] [-t mytitle] [-P pname] [-r rel] [-s sect] + [-v vol] [-I txt] [-B txt] [ifile] +DESCRIPTION + txt2man converts the input text into nroff/troff standard man(7) + macros used to format Unix manual pages. Nice pages can be generated + specially for commands (section 1 or 8) or for C functions reference + (sections 2, 3), with the ability to recognize and format command and + function names, flags, types and arguments. + + txt2man is also able to recognize and format sections, paragraphs, + lists (standard, numbered, description, nested), cross references and + literal display blocks. + + If input file ifile is omitted, standard input is used. Result is + displayed on standard output. + + Here is how text patterns are recognized and processed: + Sections These headers are defined by a line in upper case, starting + column 1. If there is one or more leading spaces, a + sub-section will be generated instead. + Paragraphs They must be separated by a blank line, and left aligned. + Tag list The item definition is separated from the item description + by at least 2 blank spaces, even before a new line, if + definition is too long. Definition will be emphasized + by default. + Bullet list + Bullet list items are defined by the first word being "-" + or "*" or "o". + Enumerated list + The first word must be a number followed by a dot. + Literal display blocks + This paragraph type is used to display unmodified text, + for example source code. It must be separated by a blank + line, and be indented. It is primarily used to format + unmodified source code. It will be printed using fixed font + whenever possible (troff). + Cross references + A cross reference (another man page) is defined by a word + followed by a number in parenthesis. + + Special sections: + NAME The function or command name and short description are set in + this section. + SYNOPSIS This section receives a special treatment to identify command + name, flags and arguments, and propagate corresponding + attributes later in the text. If a C like function is recognized + (word immediately followed by an open parenthesis), txt2man will + print function name in bold font, types in normal font, and + variables in italic font. The whole section will be printed using + a fixed font family (courier) whenever possible (troff). + + It is a good practice to embed documentation into source code, by using + comments or constant text variables. txt2man allows to do that, keeping + the document source readable, usable even without further formatting + (i.e. for online help) and easy to write. The result is high quality + and standard complying document. +OPTIONS + -h The option -h displays help. + -P pname Set pname as project name in header. Default to uname -s. + -p Probe title, section name and volume. + -t mytitle Set mytitle as title of generated man page. + -r rel Set rel as project name and release. + -s sect Set sect as section in heading, ususally a value from 1 to 8. + -v vol Set vol as volume name, i.e. "Unix user 's manual". + -I txt Italicize txt in output. Can be specified more than once. + -B txt Emphasize (bold) txt in output. Can be specified more than once. + -T Text result previewing using PAGER, usually more(1). + -X X11 result previewing using gxditview(1). +ENVIRONMENT + PAGER name of paging command, usually more(1), or less(1). If not set + falls back to more(1). +EXAMPLE + Try this command to format this text itself: + + $ txt2man -h 2>&1 | txt2man -T +HINTS + To obtain an overall good formating of output document, keep paragraphs + indented correctly. If you have unwanted bold sections, search for + multiple spaces between words, which are used to identify a tag list + (term followed by a description). Choose also carefully the name of + command line or function parameters, as they will be emphasized each + time they are encountered in the document. +SEE ALSO + man(1), mandoc(7), rman(1), groff(1), more(1), gxditview(1), troff(1). +BUGS + - Automatic probe (-p option) works only if input is a regular file (i.e. + not stdin). +AUTHOR + Marc Vertes +EOT +} + +sys=$(uname -s) +rel= +volume= +section= +title=untitled +doprobe= +itxt= +btxt= +post=cat +while getopts :hpTXr:s:t:v:P:I:B: opt +do + case $opt in + r) rel=$OPTARG;; + t) title=$OPTARG;; + s) section=$OPTARG;; + v) volume=$OPTARG;; + P) sys=$OPTARG;; + p) doprobe=1;; + I) itxt="$OPTARG§$itxt";; + B) btxt=$OPTARG;; + T) post="groff -mandoc -Tlatin1 | ${PAGER:-more}";; + X) post="groff -mandoc -X";; + *) usage; exit;; + esac +done +shift $(($OPTIND - 1)) + +if test "$doprobe" +then + title=${1##*/}; title=${title%.txt} + grep -q '#include ' $1 && + { section=${section:-3}; + volume=${volume:-"$sys Programmer's Manual"}; } || + { section=${section:-1}; + volume=${volume:-"$sys Reference Manual"}; } + # get release from path + rel=$(pwd | sed 's:/.*[^0-9]/::g + s:/.*::g') +fi + +head=".\\\" Text automatically generated by txt2man-1.4.7 +.TH $title $section \"$(date +'%B %d, %Y')\" \"$rel\" \"$volume\"" + +# All tabs converted to spaces +expand $* | +# gawk is needed because use of non standard regexp +gawk --re-interval -v head="$head" -v itxt="$itxt" -v btxt="$btxt" ' +BEGIN { + print head + avar[1] = btxt; avar[2] = itxt + for (k in avar) { + mark = (k == 1 ? "\\fB" : "\\fI") + split(avar[k], tt, "§") + for (i in tt) + if (tt[i] != "") + subwords["\\<" tt[i] "\\>"] = mark tt[i] "\\fP" + for (i in tt) delete tt[i] + } + for (k in avar) delete avar[k] +} +{ + sub(/\.\.\./, "\\.\\.\\.") # to avoid some side effects in regexp + sub(/^ +$/,"") # remove spaces in empty lines +} +/^[[:upper:][:space:]]+$/ { # Section header + if ((in_bd + 0) == 1) { + in_bd = 0 + print ".fam T\n.fi" + } + if (section == "SYNOPSIS") { + print ".fam T\n.fi" + type["SYNOPSIS"] = "" + } + if ($0 ~/^[^[:space:]]/) print ".SH " $0 + else print ".SS" $0 + sub(/^ +/, "") + section = $0 + if (section == "SYNOPSIS") print ".nf\n.fam C" + ls = 0 # line start index + pls = 0 # previous line start index + pnzls = 0 # previous non zero line start index + ni = 0 # indent level + ind[0] = 0 # indent offset table + prevblankline = 0 + next +} +{ # compute line start index, handle start of example display block + pls = ls + if (ls != 0) pnzls = ls + match($0, /[^ ]/) + ls = RSTART + if (pls == 0 && pnzls > 0 && ls > pnzls && $1 !~ /^[0-9\-\*\o]\.*$/) { + # example display block + if (prevblankline == 1) { print ".PP"; prevblankline = 0 } + print ".nf\n.fam C" + in_bd = 1 + eoff = ls + } + if (ls > 0 && ind[0] == 0) ind[0] = ls +} +(in_bd + 0) == 1 { # In example display block + if (ls != 0 && ls < eoff) { # End of litteral display block + in_bd = 0 + print ".fam T\n.fi" + } else { print; next } +} +section == "NAME" { $1 = "\\fB" $1; sub(/ \- /, " \\fP- ") } +section == "SYNOPSIS" { # Identify arguments of fcts and cmds + if (type["SYNOPSIS"] == "") { + if (index($0, "(") == 0 && index($0, ")") == 0 && + index($0, "#include") == 0) + type["SYNOPSIS"] = "cmd" + else + type["SYNOPSIS"] = "fct" + } + if (type["SYNOPSIS"] == "cmd") { # Line is a command line + if ($1 !~ /^\[/) { + b = $1 + sub(/^\*/, "", b) + subwords["\\<" b "\\>"] = "\\fB" b "\\fP" + } + for (i = 2; i <= NF; i++) { + a = $i + gsub(/[\[\]\|]/, "", a) + if (a ~ /^[^\-]/) subwords["\\<" a "\\>"] = "\\fI" a "\\fP" + } + } else { # Line is a C function definition + if ($1 == "typedef") subwords["\\<" $2 "\\>"] = "\\fI" $2 "\\fP" + else if ($1 == "#define") subwords["\\<" $2 "\\>"] = "\\fI" $2 "\\fP" + for (i = 1; i <= NF; i++) + if ($i ~ /[\,\)]/) { + a = $i + sub(/.*\(/, "", a) + gsub(/\W/, "", a) + if (a !~ /^void$/) subwords["\\<" a "\\>"] = "\\fI" a "\\fP" + } + } +} +{ + while ($0 ~ /\w\.\w/) sub(/\./, "_dOt_") # protect dots inside words + for (i = 1; i <= NF; i++) { # identify func calls and cross refs + b = $i + sub(/^\*/, "", b) + if ((a = index(b, ")(")) > 3) { + w = substr(b, 3, a - 3) + subwords["\\<" w "\\>"] = "\\fI" w "\\fP" + } + if ((a = index(b, "(")) > 1) { + w = substr(b, 1, a - 1) + subwords["\\<" w "\\("] = "\\fB" w "\\fP(" + } + } + for (i in subwords) gsub(i, subwords[i]) # word attributes + gsub(/\B\-+\w+(\-\w+)*/, "\\fB&\\fP") # shell options + gsub(/_dOt_/, ".") # unprotect dots inside words + + if (match($0, /[^ ] +/) > 0) { # tag list item + adjust_indent() + tag = substr($0, 1, RSTART) + sub(/^ */, "", tag) + if (RSTART+RLENGTH < length()) $0 = substr($0, RSTART + RLENGTH) + else $0 = "" + print ".TP\n.B" + print tag + prevblankline = 0 + if (NF == 0) next + } else if ($1 == "-"||$1 == "o"||$1 == "*") { # bullet list item + adjust_indent() + print ".IP \\(bu 3" + prevblankline = 0 + $1 = "" + } else if ($1 ~ /^[0-9]+[\).]$/) { # enum list item + adjust_indent() + print ".IP " $1 " 4" + prevblankline = 0 + $1 = "" + } else if (pls == 0) { # new paragraph + adjust_indent() + } else if (NF == 0) { # blank line + prevblankline = 1; next + } else prevblankline = 0 # other + if (prevblankline == 1) { # flush vertical space + print ".PP"; prevblankline = 0 + } + if (section != "SYNOPSIS" || $0 ~ /^ {1,4}/) sub(/ */,"") + print +} +function adjust_indent() +{ + if (ls > ind[ni]) { ind[++ni] = ls; print ".RS" } + else if (ls < ind[ni]) + while (ls < ind[ni]) { ni--; print ".RE" } +} +' | eval $post diff --git b/include/.cvsignore a/include/.cvsignore new file mode 100644 index 0000000..0781079 --- /dev/null +++ a/include/.cvsignore @@ -0,0 +1,10 @@ +Makefile +Makefile.in +tdsver.h +config.h +stamp-h.in +config.h.in +stamp-h +stamp-h1 +tds_sysdep_public.h +freetds_sysconfdir.h diff --git b/misc/bounce.c a/misc/bounce.c new file mode 100644 index 0000000..93e9c5c --- /dev/null +++ a/misc/bounce.c @@ -0,0 +1,431 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* $Id: bounce.c,v 1.1 2007/10/23 10:08:52 freddy77 Exp $ */ + +/* This small application make man-in-the-middle with a crypted SQL Server + * to be able to see decrypted login + * It's just a small utility, at end of login it close connection and don't + * handle a lot of cases. Works only with mssql2k or later + * Based on GnuTLS echo example + * compile with: + * gcc -O2 -Wall -o bounce bounce.c -lgnutls + */ + +/* path to certificate, can be created with + * openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem + */ +#define CERTFILE "mycert.pem" + +/* port to listen to, you should connect to this port */ +#define LISTEN_PORT 1433 +/* server and port to connect to, the real server you want to tunnel */ +#define SERVER_IP "10.20.30.40" +#define SERVER_PORT 1433 + +#define SA struct sockaddr +#define SOCKET_ERR(err,s) if(err==-1) {perror(s);return(1);} +#define MAX_BUF 1024 +#define DH_BITS 1024 + +/* These are global */ +gnutls_certificate_credentials_t x509_cred; + +static void put_packet(int sd); +static void get_packet(int sd); + +typedef enum +{ + prelogin, + auth, + in_tls +} State; +static State state; + +static int server_sd = -1; +static int client_sd = -1; + +static unsigned char packet[4096 + 192]; +static int packet_len; +static int to_send = 0; +static unsigned char packet_type = 0x12; +static int pos = 0; + +static ssize_t +tds_pull_func(gnutls_transport_ptr ptr, void *data, size_t len) +{ + fprintf(stderr, "in tds_pull_func\n"); + + /* if we have some data send it */ + if (to_send && packet_len >= 8) { + packet[1] = 1; + put_packet(client_sd); + packet_len = 0; + to_send = 0; + } + + if (state == in_tls) { + return recv(client_sd, data, len, 0); + } + /* read from packet */ + if (!packet_len || pos >= packet_len) { + get_packet(client_sd); + pos = 8; + } + if (!packet_len) + exit(1); + if (len > (packet_len - pos)) + len = packet_len - pos; + memcpy(data, packet + pos, len); + pos += len; + printf("read %d bytes\n", len); + return len; +} + +static ssize_t +tds_push_func(gnutls_transport_ptr ptr, const void *data, size_t len) +{ + int left; + + if (state == in_tls) + return send(server_sd, data, len, 0); + + /* write to packet */ + if (!to_send) + packet_len = 8; + to_send = 1; + packet[0] = packet_type; + left = 4096 - packet_len; + if (left <= 0) { + packet[1] = 0; /* not last */ + put_packet(server_sd); + packet_len = 8; + left = 4096 - packet_len; + } + packet[1] = 1; /* last */ + if (len > left) + len = left; + memcpy(packet + packet_len, data, len); + packet_len += len; + packet[2] = packet_len >> 8; + packet[3] = packet_len; + return len; +} + +static gnutls_session_t +initialize_tls_session() +{ + gnutls_session_t session; + static const int cipher_priority[] = { + GNUTLS_CIPHER_ARCFOUR_40, + GNUTLS_CIPHER_DES_CBC, + GNUTLS_CIPHER_AES_256_CBC, GNUTLS_CIPHER_AES_128_CBC, + GNUTLS_CIPHER_3DES_CBC, GNUTLS_CIPHER_ARCFOUR_128, + 0 + }; + + + gnutls_init(&session, GNUTLS_SERVER); + gnutls_transport_set_pull_function(session, tds_pull_func); + gnutls_transport_set_push_function(session, tds_push_func); + + /* avoid calling all the priority functions, since the defaults + * are adequate. + */ + gnutls_set_default_priority(session); + gnutls_cipher_set_priority(session, cipher_priority); + + gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred); + + gnutls_dh_set_prime_bits(session, DH_BITS); + + return session; +} + +static gnutls_dh_params_t dh_params; + +static int +generate_dh_params(void) +{ + + /* Generate Diffie Hellman parameters - for use with DHE + * kx algorithms. These should be discarded and regenerated + * once a day, once a week or once a month. Depending on the + * security requirements. + */ + gnutls_dh_params_init(&dh_params); + gnutls_dh_params_generate2(dh_params, DH_BITS); + + return 0; +} + +static void +tds_tls_log(int level, const char *s) +{ + printf("(%d) %s", level, s); +} + +static int +tcp_connect(void) +{ + int err, sd; + struct sockaddr_in sa; + + /* connects to server + */ + sd = socket(AF_INET, SOCK_STREAM, 0); + + memset(&sa, '\0', sizeof(sa)); + sa.sin_family = AF_INET; + sa.sin_port = htons(SERVER_PORT); + inet_pton(AF_INET, SERVER_IP, &sa.sin_addr); + + err = connect(sd, (SA *) & sa, sizeof(sa)); + if (sd < 0 || err < 0) { + fprintf(stderr, "Connect error\n"); + exit(1); + } + + return sd; +} + +static void +get_packet(int sd) +{ + int full_len, l; + + printf("get_packet\n"); + packet_len = 0; + for (;;) { + full_len = 4; + if (packet_len >= 4) + full_len = (((int) packet[2]) << 8) + packet[3]; + + l = recv(sd, packet + packet_len, full_len - packet_len, 0); + if (l <= 0) { + fprintf(stderr, "error recv\n"); + exit(1); + } + packet_len += l; + + if (full_len >= 8 && packet_len == full_len) + break; + } +} + +static void +put_packet(int sd) +{ + int sent = 0; + + printf("put_packet\n"); + for (; sent < packet_len;) { + int l = send(sd, packet + sent, packet_len - sent, 0); + + if (l <= 0) { + fprintf(stderr, "error send\n"); + exit(1); + } + sent += l; + } + to_send = 0; +} + +static void +hexdump(char *buffer, int len) +{ + int i; + char hex[16 * 3 + 2], chars[20]; + + hex[0] = 0; + for (i = 0; len > 0 && i < len; ++i) { + if ((i & 15) == 0) { + hex[0] = 0; + chars[0] = 0; + } + sprintf(strchr(hex, 0), "%02x ", (unsigned char) buffer[i]); + chars[i & 15] = buffer[i] >= 32 && buffer[i] < 126 ? buffer[i] : ' '; + chars[(i & 15) + 1] = 0; + if ((i & 15) == 15) + printf("%04x: %-48s %s\n", i & 0xfff0, hex, chars); + } + if ((i & 15) != 0) + printf("%04x: %-48s %s\n", i & 0xfff0, hex, chars); +} + +int +main() +{ + int err, listen_sd, i; + int sd, ret; + struct sockaddr_in sa_serv; + struct sockaddr_in sa_cli; + int client_len; + char topbuf[512]; + gnutls_session_t session; + char buffer[MAX_BUF + 1]; + int optval = 1; + + /* this must be called once in the program + */ + gnutls_global_init(); + gnutls_global_set_log_level(11); + gnutls_global_set_log_function(tds_tls_log); + + + gnutls_certificate_allocate_credentials(&x509_cred); + + ret = gnutls_certificate_set_x509_key_file(x509_cred, /* CERTFILE */ CERTFILE, /* KEYFILE */ CERTFILE, + GNUTLS_X509_FMT_PEM); + if (ret < 0) { + fprintf(stderr, "certificate failed (%s)\n", gnutls_strerror(ret)); + exit(1); + } + + generate_dh_params(); + + gnutls_certificate_set_dh_params(x509_cred, dh_params); + + /* Socket operations + */ + listen_sd = socket(AF_INET, SOCK_STREAM, 0); + SOCKET_ERR(listen_sd, "socket"); + + memset(&sa_serv, '\0', sizeof(sa_serv)); + sa_serv.sin_family = AF_INET; + sa_serv.sin_addr.s_addr = INADDR_ANY; + sa_serv.sin_port = htons(LISTEN_PORT); /* Server Port number */ + + setsockopt(listen_sd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(int)); + + err = bind(listen_sd, (SA *) & sa_serv, sizeof(sa_serv)); + SOCKET_ERR(err, "bind"); + err = listen(listen_sd, 1024); + SOCKET_ERR(err, "listen"); + + printf("Server ready. Listening to port '%d'.\n\n", LISTEN_PORT); + + client_len = sizeof(sa_cli); + for (;;) { + session = initialize_tls_session(); + + client_sd = sd = accept(listen_sd, (SA *) & sa_cli, &client_len); + + printf("- connection from %s, port %d\n", + inet_ntop(AF_INET, &sa_cli.sin_addr, topbuf, sizeof(topbuf)), ntohs(sa_cli.sin_port)); + + /* now do prelogin */ + /* connect to real peer */ + printf("connect to real peer\n"); + server_sd = tcp_connect(); + + /* get prelogin packet from client */ + printf("get prelogin packet from client\n"); + get_packet(client_sd); + + /* send prelogin packet to server */ + printf("send prelogin packet to server\n"); + put_packet(server_sd); + + /* get prelogin reply from server */ + printf("get prelogin reply from server\n"); + get_packet(server_sd); + + /* reply with same prelogin packet */ + printf("reply with same prelogin packet\n"); + put_packet(client_sd); + + /* now we must do authentication with client and with server */ + state = auth; + packet_len = 0; + + /* do with client */ + gnutls_transport_set_ptr(session, (gnutls_transport_ptr_t) sd); + ret = gnutls_handshake(session); + if (ret < 0) { + close(sd); + gnutls_deinit(session); + fprintf(stderr, "*** Handshake has failed (%s)\n\n", gnutls_strerror(ret)); + continue; + } + printf("- Handshake was completed\n"); + + /* flush last packet */ + packet[0] = 4; + packet[1] = 1; + put_packet(client_sd); + + /* on, reset all */ + state = in_tls; + to_send = 0; + packet_len = 0; + + /* do with server */ + + /* now log and do man-in-the-middle to see decrypted data !!! */ + for (;;) { + /* wait all packet */ + sleep(2); + + /* get client */ + ret = gnutls_record_recv(session, buffer, MAX_BUF); + if (ret > 0) { + hexdump(buffer, ret); + + gnutls_record_send(session, buffer, ret); + + ret = gnutls_record_recv(session, buffer, MAX_BUF); + if (ret > 0) + hexdump(buffer, ret); + } + /* for the moment.. */ + exit(1); + + /* send to server */ + } + + /* see the Getting peer's information example */ + /* print_info(session); */ + + i = 0; + for (;;) { + bzero(buffer, MAX_BUF + 1); + ret = gnutls_record_recv(session, buffer, MAX_BUF); + + if (ret == 0) { + printf("\n- Peer has closed the GNUTLS connection\n"); + break; + } else if (ret < 0) { + fprintf(stderr, "\n*** Received corrupted " "data(%d). Closing the connection.\n\n", ret); + break; + } else if (ret > 0) { + /* echo data back to the client */ + hexdump(buffer, ret); + gnutls_record_send(session, buffer, ret); + } + } + printf("\n"); + /* do not wait for the peer to close the connection. */ + gnutls_bye(session, GNUTLS_SHUT_WR); + + close(sd); + gnutls_deinit(session); + + } + close(listen_sd); + + gnutls_certificate_free_credentials(x509_cred); + + gnutls_global_deinit(); + + return 0; +} + diff --git b/misc/freetds_autobuild a/misc/freetds_autobuild new file mode 100755 index 0000000..a78d6f4 --- /dev/null +++ a/misc/freetds_autobuild @@ -0,0 +1,245 @@ +#!/bin/bash + +export PATH="/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/lib/jre/bin:$HOME/bin:$HOME/install/bin" + +. $HOME/.bashrc + +# do not use ccache, not work well woth profile informations +export PATH="/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:$HOME/bin:$HOME/install/bin" + +GROUPDIR=/home/groups/f/fr/freetds/htdocs +# directory to compile +FTDSDIR=freetds82 +# output directory on server +OUTDIR=out +# additional flags for Autogen (current version) +#FLAGS_ADD=--enable-developing +FLAGS_ADD= +# additional flags for Autogen (old version) +FLAGS_ADD_OLD= +WORKDIR=ftds_comp + +upload() +{ + mkdir -p "$HOME/cpp/freetds/html/$1" + rm -rf "$HOME/cpp/freetds/html/$1" + mkdir -p "$HOME/cpp/freetds/html/$1" + cp -r $2 "$HOME/cpp/freetds/html/$1" +# tar zcf - $2 | ssh -p 443 freddy77@shell-ssh.sourceforge.net "cd $GROUPDIR/$1 && rm -rf * && { tar zxf -; find . -type d -print0 | xargs -0 chmod 2775; find . -type f -print0 | xargs -0 chmod 0664; }" +} + +upload_file() +{ + mkdir -p `dirname "$HOME/cpp/freetds/html/$1"` + cp $2 "$HOME/cpp/freetds/html/$1" +# ssh -p 443 freddy77@shell-ssh.sourceforge.net "cd $GROUPDIR && cat - > $1 && chmod 0664 $1" < $2 +} + +save_coverage() +{ + find include/ src/ -name \*.da -o -name \*.gc\* | tar zcf - -T - > covsave.tgz +} + +restore_coverage() +{ + find include/ src/ -name \*.da -o -name \*.gc\* -exec rm {} \; + tar zxf covsave.tgz + rm -f covsave.tgz +} + +handle_exit() +{ + echo Exiting... + cd $HOME/cpp/freetds + rm -f freetds + ln -s "$FTDSDIR" freetds + rm -rf $WORKDIR +} + +read_pwd_fields() +{ + tUID=`grep '^UID=' < PWD | sed 's,^....,,'` + tPWD=`grep '^PWD=' < PWD | sed 's,^....,,'` + tSRV=`grep '^SRV=' < PWD | sed 's,^....,,'` + tDB=`grep '^DB=' < PWD | sed 's,^...,,'` +} + +rm ~/freetds.log /tmp/sql.log + +for param +do + case $param in + --previous) + OUTDIR=out0 + FTDSDIR=freetds64 + FLAGS_ADD="$FLAGS_ADD_OLD" + WORKDIR=ftds_comp_old + ;; + *) + echo 'Option not supported!' 1>&2 + exit 1 + ;; + esac +done + +set -e + +DOMAIN_UID= +DOMAIN_PWD= +MSSQL_PORT= +MSSQL_INSTANCE= +if test -r "$HOME/freetds_autobuild.sh"; then + . "$HOME/freetds_autobuild.sh" +fi + +cd $HOME/cpp/freetds/$FTDSDIR +# cvs up || { sleep 5; cvs up; } || { sleep 5; cvs up; } +cd .. +rm -rf $WORKDIR +trap handle_exit EXIT +cp -rp $FTDSDIR $WORKDIR +rm -f freetds +ln -s $WORKDIR freetds +cd $WORKDIR +find . \( -name \*.bb -o -name \*.bbg -o -name \*.da -o -name \*.gc\* \) -exec rm -f {} \; +rm -rf autom4te.cache doc/doc covtmp coverage DBD-* +cvsclean || true +if test "$(uname -m)" = "x86_64"; then + cp ../DBD-ODBC-1.15_2.tar.gz . +else + cp ../DBD-ODBC-1.13.tar.gz . +fi +cp ../php5.2-latest.tar.bz2 . + +LDFLAGS='-lgcov' CFLAGS='-O0 -pipe -g -fprofile-arcs -ftest-coverage' sh autogen.sh --enable-extra-checks --prefix=$HOME/install --with-odbc-nodm=/usr --with-gnutls $FLAGS_ADD + +# compile, test with mssql server +cp -f ../PWD PWD +read_pwd_fields +make clean +export LD_LIBRARY_PATH=$PWD/src/odbc/.libs/ +rm -rf logs +mkdir logs +./misc/test-auto.sh > logs/log.txt + +if test "$OUTDIR" = "out" -a -r doc/doxy.log; then + fixdoxyres < doc/doxy.log > doc/doxy.html + upload_file "doxy.html" "doc/doxy.html" + if test -d doc/doc/freetds-*/reference; then + (cd doc/doc/freetds-*/reference; upload doxy '*') + fi +fi + +# save logs for debug +rm -f $HOME/log_tds.txt +ln logs/log.txt $HOME/log_tds.txt + +# test Perl +save_coverage +RES=0 +# setting LANG avoid strange characters +LANG=en_US ./misc/test-other.sh --perl-only --verbose >> logs/log.txt || RES=$? +if test $RES != 0; then + echo "Perl test failed" + restore_coverage +fi + +./misc/test-other.sh --php-only >> logs/log.txt || true + +# upload our test results +cd logs +perl -pe "\$_ = '' if \$_ =~ /^2:bcp.c: In function 'bcp_colfmt'|^2:bcp.c:\\d+: warning: suggest parentheses around && within \\|\\|/" < log.txt | ../misc/online.pl +upload "$OUTDIR/test" '*.html' +cd .. + +# test domain password and TDSPORT with service name +if test "$DOMAIN_UID" != ""; then + save_coverage + # using tsql directly with grep do not update coverage informations + echo -e 'select @@version\ngo\nbye' | TDSPORT=ms-sql-s TDSDUMP=stdout ./src/apps/tsql -S $tSRV -U "$DOMAIN_UID" -P "$DOMAIN_PWD" > out.txt || true + if grep -q 'Microsoft Corporation' out.txt; then + echo "domain password ok" + else + echo "domain password failed!" + restore_coverage + fi + rm -f out.txt +fi + +if test "$MSSQL_PORT" != ""; then + save_coverage + # using tsql directly with grep do not update coverage informations + echo -e 'select @@version\ngo\nbye' | ./src/apps/tsql -S "$tSRV:$MSSQL_PORT" -U "$tUID" -P "$tPWD" > out.txt || true + if grep -q 'Microsoft Corporation' out.txt; then + echo "override port ok" + else + echo "override port failed!" + restore_coverage + fi + rm -f out.txt +fi + +if test "$MSSQL_INSTANCE" != ""; then + save_coverage + # using tsql directly with grep do not update coverage informations + echo -e 'select @@version\ngo\nbye' | ./src/apps/tsql -S "$tSRV\\$MSSQL_INSTANCE" -U "$tUID" -P "$tPWD" > out.txt || true + if grep -q 'Microsoft Corporation' out.txt; then + echo "override instance ok" + else + echo "override instance failed!" + restore_coverage + fi + rm -f out.txt +fi + +# do tests with sybase server +cp -f ../PWD.sybase PWD +read_pwd_fields +rm -rf logs +mkdir logs +./misc/test-auto.sh --no-build > logs/log.txt +cd logs +../misc/online.pl < log.txt +upload "$OUTDIR/test2" '*.html' +cd .. + +# do tests with sybase 15 server +if test "$OUTDIR" = "out"; then + cp -f ../PWD.sybase15 PWD + read_pwd_fields + rm -rf logs + mkdir logs + ./misc/test-auto.sh --no-build > logs/log.txt + cd logs + ../misc/online.pl < log.txt + upload "$OUTDIR/test3" '*.html' + cd .. +fi + +# test autodiscovery +if test "$OUTDIR" = "out"; then + save_coverage + # using tsql directly with grep do not update coverage informations + echo -e 'select @@version\ngo\nbye' | TDSVER=0.0 ./src/apps/tsql -S "$tSRV" -U "$tUID" -P "$tPWD" > out.txt || true + if grep -q 'Adaptive Server Enterprise' out.txt; then + echo "autodiscovery ok" + else + echo "autodiscovery failed!" + restore_coverage + fi + rm -f out.txt +fi + +# restore PWD file +cp -f ../PWD PWD + +# build coverage and upload it +rm -rf coverage +./misc/coverage.sh +cd coverage +upload "$OUTDIR/coverage" '*' +cd .. + +# cleanup +rm -f ~/freetds.log /tmp/sql.log covsave.tgz +rm -rf logs diff --git b/misc/test-auto.sh a/misc/test-auto.sh new file mode 100755 index 0000000..14d54e6 --- /dev/null +++ a/misc/test-auto.sh @@ -0,0 +1,103 @@ +#!/bin/sh + +# automatic test and report + +# set -e + +BUILD=1 +CONFIGURE=0 +for param +do + case $param in + --help) + echo $0 [--help] [--no-build] [--configure] + exit 0 + ;; + --no-build) + BUILD=0 + ;; + --configure) + CONFIGURE=1 + ;; + esac +done + +# go to main distro dir +DIR=`dirname $0` +cd "$DIR/.." + +DIR="$PWD/misc" +LANG=C +export LANG + +log () { + echo "@!@!@!@!@!@!@!@!@!@!@!@!@!@!@!@- $1 -@!@!@!@!@!@!@!@!@!@!@!@!@!@!@!@" +} + +# function to save output +output_save () { + COMMENT=$1 + shift + OUT=$1 + shift + log "START $OUT" + classifier "$@" + RES=$? + log "RESULT $RES" + log "END $OUT" +} + +# output informations +XXX=`hostname` +log "INFO HOSTNAME `echo $XXX`" +VER=`gcc --version 2> /dev/null | grep 'GCC'` +log "INFO GCC $VER" +XXX=`uname -a` +log "INFO UNAME `echo $XXX`" +log "INFO DATE `date '+%Y-%m-%d'`" + +MAKE=make +if gmake --help 2> /dev/null > /dev/null; then + MAKE=gmake +fi + +# execute configure +if test $CONFIGURE = 1; then + BUILD=1 + output_save "configuration" conf ./configure --enable-extra-checks $TDS_AUTO_CONFIG + if test $RES != 0; then + echo "error during configure" + exit 1 + fi +fi + +if test $BUILD = 1; then + + echo Making ... + $MAKE clean > /dev/null 2> /dev/null + output_save "make" make $MAKE + if test $RES != 0; then + echo "error during make" + exit 1 + fi + + echo Making tests ... + TESTS_ENVIRONMENT=true + export TESTS_ENVIRONMENT + output_save "make tests" maketest $MAKE check + if test $RES != 0; then + echo "error during make test" + exit 1; + fi +fi + +echo Testing ... +TESTS_ENVIRONMENT="$DIR/full-test.sh" +export TESTS_ENVIRONMENT +$MAKE check 2> /dev/null +if test $? != 0; then + echo "error during make check" + exit 1; +fi + +exit 0 diff --git b/misc/test-dist.sh a/misc/test-dist.sh new file mode 100755 index 0000000..73cbf7f --- /dev/null +++ a/misc/test-dist.sh @@ -0,0 +1,150 @@ +#!/bin/sh + +# This script test that Makefiles are able to produre a good +# distribution +# +# It create a test-dist.log file in the mail directory, you +# can tail this file to see the progress + +# stop on errors +set -e + +for param +do + case $param in + --no-unittests) + TESTS_ENVIRONMENT=true + export TESTS_ENVIRONMENT + ;; + --help) + echo "Usage: $0 [OPTION]..." + echo ' --help this help' + echo ' --no-unittests do not execute unittests' + exit 0 + ;; + *) + echo 'Option not supported!' 1>&2 + exit 1 + ;; + esac +done + +# do not create logs so diskcheck test do not fails +unset TDSDUMP || true + +# set correct directory +DIR=`dirname $0` +cd "$DIR/.." + +# remove old distributions +touch freetds-dummy +find freetds-* -type d ! -perm -200 -exec chmod u+w {} ';' +rm -rf freetds-* + +# save directory +ORIGDIR="$PWD" + +# init log +LOG="$PWD/test-dist.log" +rm -f "$LOG" +echo "log started" >> "$LOG" + +# make distribution +test -f Makefile || sh autogen.sh +make dist +echo "make distribution ok" >> "$LOG" + +# untar to test it, should already contains documentation +DIR=`echo freetds-* | sed s,.tar.gz$,,g` +gunzip -dc freetds-*.tar.gz | tar xf - +test -d "$DIR" +cd "$DIR" +echo "untar ok" >> "$LOG" + +# assure you do not compile documentation again +mkdir fakebin +PATH="$PWD/fakebin:$PATH" +export PATH +cd fakebin +echo "#!/bin/sh +exit 1" > openjade +cp openjade doxygen +# gawk it's used by txt2man +cp openjade gawk +cp openjade autoheader +# perl is used by some perl rules +cp openjade perl +chmod +x openjade doxygen gawk autoheader perl +cd .. +if ! openjade --help; then true; else echo 'succedeed ?'; false; fi +if ! doxygen --help; then true; else echo 'succeeded ?'; false; fi +if ! gawk --help; then true; else echo 'succeeded ?'; false; fi +if ! autoheader --help; then true; else echo 'succeeded ?'; false; fi +if ! perl --help; then true; else echo 'succeeded ?'; false; fi +echo "fakebin ok" >> "$LOG" + +# direct make install (without make all) +mkdir install +INSTALLDIR="$PWD/install" +mkdir build +cd build +# --enable-msdblib --enable-sybase-compat can cause also problems, try to compile with both +../configure --prefix="$INSTALLDIR" --enable-msdblib --enable-sybase-compat --disable-libiconv +# make clean should not cause problems here +make clean +make install +cd .. +echo "direct make install ok" >> "$LOG" + +# cleanup +rm -rf install build + +# again with dist and autogen +mkdir build +cd build +../autogen.sh +make dist +cd .. +rm -rf build +echo "make dist ok" >> "$LOG" + +# test if make clean clean too much +mkdir install +./configure --prefix="$PWD/install" +make clean +make dist + +# finally big test. I hope you have a fast machine :) +cd .. +rm -rf "$DIR" +gunzip -dc freetds-*.tar.gz | tar xf - +cd "$DIR" +./configure +if test ! -e PWD -a -e "$ORIGDIR/../PWD"; then + cp "$ORIGDIR/../PWD" . +fi +if test ! -e PWD -a -e "$ORIGDIR/PWD"; then + cp "$ORIGDIR/PWD" . +fi +make distcheck +echo "make distcheck ok" >> "$LOG" + +# cleanup +cd "$ORIGDIR" +chmod -R 777 "$DIR" +rm -rf "$DIR" + +# check rpm +RPMCMD=rpm +if rpmbuild --help > /dev/null 2>&1; then + RPMCMD=rpmbuild +fi +if $RPMCMD --help > /dev/null 2>&1; then + $RPMCMD -ta freetds-*.tar.gz || exit 1 + echo "rpm test ok" >> "$LOG" +else + echo "rpm test skipped, no rpm detected" >> "$LOG" +fi + +echo "all tests ok!!!" >> "$LOG" + diff --git b/misc/test-other.sh a/misc/test-other.sh new file mode 100755 index 0000000..d20591a --- /dev/null +++ a/misc/test-other.sh @@ -0,0 +1,223 @@ +#!/bin/sh + +# Additional make check test +# check other tools (like Perl and PHP) +# odbc MUST be configured to point to source driver + +# stop on errors +set -e + +verbose=no +do_perl=no +do_php=yes + +# check for perl existence +if perl -e 'exit 0' > /dev/null 2>&1; then + do_perl=yes +fi + +for param +do + case $param in + --verbose) + verbose=yes ;; + --no-perl) + do_perl=no ;; + --no-php) + do_php=no ;; + --perl-only) + do_perl=yes + do_php=no + ;; + --php-only) + do_perl=no + do_php=yes + ;; + *) + echo 'Option not supported!' 1>&2 + exit 1 + ;; + esac +done + +log () { + echo "@!@!@!@!@!@!@!@!@!@!@!@!@!@!@!@- $1 -@!@!@!@!@!@!@!@!@!@!@!@!@!@!@!@" +} + +# set correct directory +DIR=`dirname $0` +cd "$DIR/.." + +# save directory +ORIGDIR="$PWD" + +# init log +LOG="$PWD/test-other.log" +rm -f "$LOG" +echo "log started" >> "$LOG" + +## assure make +#make all +#echo "make all ok" >> "$LOG" + +tUID=`cat PWD | grep '^UID=' | sed 's,^....,,g'` +tPWD=`cat PWD | grep '^PWD=' | sed 's,^....,,g'` +tSRV=`cat PWD | grep '^SRV=' | sed 's,^....,,g'` +tDB=`cat PWD | grep '^DB=' | sed 's,^...,,g'` + +# prepare odbc.ini redirection +rm -f odbc.ini +for f in .libs/libtdsodbc.so .libs/libtdsodbc.sl .libs/libtdsodbc.dll .libs/libtdsodbc.dylib; do + if test -r "$PWD/src/odbc/$f"; then + echo "[$tSRV] +Driver = $PWD/src/odbc/$f +Database = $tDB +Servername = $tSRV + +[xx_$tSRV] +Driver = $PWD/src/odbc/$f +Database = $tDB +Servername = $tSRV" > odbc.ini + ODBCINI="$PWD/odbc.ini" + SYSODBCINI="$PWD/odbc.ini" + export ODBCINI SYSODBCINI + break; + fi +done + +# Perl +if test $do_perl = yes; then + DBI_DSN="dbi:ODBC:$tSRV" + DBI_USER="$tUID" + DBI_PASS="$tPWD" + export DBI_DSN DBI_USER DBI_PASS + # TODO better way + ODBCHOME=/usr + export ODBCHOME + for f in DBD-ODBC-*.tar.gz; do + DIR=`echo "$f" | sed s,.tar.gz$,,g` + echo Testing $DIR + if ! test -d "$DIR"; then + tar zxvf "$DIR.tar.gz" + # try to apply patch for Sybase + cd "$DIR" + { patch -p1 || true ; } <[2]) { ++ if (\$row[2] ne \$_->[2] && (\$dbname ne "sql server" || \$row[2] ne " ") ) { + print "Column C value failed! bind value = \$bind_val, returned values = \$row[0]|\$row[1]|\$row[2]|\$row[3]\\n"; + return undef; + } +EOF + # fix for DBD::ODBC and Perl 5.8.8 + echo "--- DBD-ODBC-1.13.orig/dbdimp.c 2004-11-05 04:19:36.000000000 +0100 ++++ DBD-ODBC-1.13/dbdimp.c 2007-01-16 09:38:20.477774620 +0100 +@@ -2921,11 +2921,11 @@ + * */ + else if (is_inout != phs->is_inout) { + croak(\"Can't rebind or change param %s in/out mode after first bind (%d => %d)\", + phs->name, phs->is_inout, is_inout); + } +- else if (maxlen && maxlen != phs->maxlen) { ++ else if (maxlen && maxlen > phs->maxlen) { + croak(\"Can't change param %s maxlen (%ld->%ld) after first bind\", + phs->name, phs->maxlen, maxlen); + } + + if (!is_inout) { /* normal bind to take a (new) copy of current value */ +" | patch -p1 || true + cd t + { patch -p0 || true ; } <{odbc_async_exec} = 1; + # print "odbc_async_exec is: \$dbh->{odbc_async_exec}\\n"; +- is(\$dbh->{odbc_async_exec}, 1, "test odbc_async_exec attribute set"); ++ is(\$dbh->{odbc_async_exec}, 0, "test odbc_async_exec attribute NOT set"); + + # not sure if this should be a test. May have permissions problems, but it's the only sample + # of the error handler stuff I have. +EOF + cd ../.. + fi + test -d "$DIR" + cd "$DIR" + grep -v 'prompt(' Makefile.PL > Makefile.PL.tmp + cat Makefile.PL.tmp > Makefile.PL + test -r Makefile || LANG=C perl Makefile.PL + LANG=C make clean + RES=0 + log "START DBD::ODBC make" + test -r Makefile || LANG=C classifier perl Makefile.PL || RES=$? + if test $RES = 0; then + LANG=C classifier make || RES=$? + fi + log "RESULT $RES" + log "END DBD::ODBC make" + if test $RES = 0; then + log "START DBD::ODBC test" + if test $verbose = yes; then + LANG=C classifier make test TEST_VERBOSE=1 || RES=$? + else + LANG=C classifier make test || RES=$? + fi + log "RESULT $RES" + log "END DBD::ODBC test" + fi + if test $RES != 0; then + exit $RES + fi + done +fi + +# PHP +cd "$ORIGDIR" +FILE='php5.2-latest.tar.bz2' +if test $do_php = yes -a -f "$FILE"; then + # need to recompile ?? + if test ! -x phpinst/bin/php -o "$FILE" -nt phpinst/bin/php; then + rm -rf php5.2-200* phpinst lib + bunzip2 -c "$FILE" | tar xvf - + DIR=`echo php5.2-200*` + MAINDIR=$PWD + mkdir lib + cp src/dblib/.libs/lib*.s[ol]* lib + cp src/tds/.libs/libtds.a lib +# cp src/tds/.libs/lib*.s[ol]* lib + cd $DIR + CFLAGS='-O0 -pipe' ./configure --prefix=$MAINDIR/phpinst --disable-all --with-mssql=$MAINDIR --with-unixODBC=/usr + make -j4 + make install + cd .. + fi + + cd phptests + echo "" > pwd.inc + + ERR="" + for f in *.php; do + echo Testing PHP script $f + log "START PHP test $f" + RES=0 + ../phpinst/bin/php -q $f 2>&1 || { RES=$?; ERR="$ERR $f"; } + log "RESULT $RES" + log "FILE $PWD/$f" + log "END PHP test $f" + done + if test "$ERR" != ""; then + echo "Some script failed:$ERR" + exit 1 + fi +fi + +echo "all tests ok!!!" >> "$LOG" +exit 0 + diff --git b/mkinstalldirs a/mkinstalldirs index ce6c2d3..4d8662b 100755 --- b/mkinstalldirs +++ a/mkinstalldirs @@ -4,7 +4,7 @@ # Created: 1993-05-16 # Public domain -# $Id: mkinstalldirs,v 1.1.1.1 2001/10/12 23:28:53 brianb Exp $ +# $Id: mkinstalldirs,v 1.1 2001/10/12 23:28:53 brianb Exp $ errstatus=0 diff --git b/phptests/.cvsignore a/phptests/.cvsignore new file mode 100644 index 0000000..03a7a33 --- /dev/null +++ a/phptests/.cvsignore @@ -0,0 +1 @@ +pwd.inc diff --git b/samples/.cvsignore a/samples/.cvsignore new file mode 100644 index 0000000..f24dd77 --- /dev/null +++ a/samples/.cvsignore @@ -0,0 +1,3 @@ +Makefile +Makefile.in +unixodbc.freetds.driver.template diff --git b/samples/odbc_rpc.pl a/samples/odbc_rpc.pl new file mode 100755 index 0000000..cc93942 --- /dev/null +++ a/samples/odbc_rpc.pl @@ -0,0 +1,123 @@ +#!/usr/local/bin/perl +# $Id: odbc_rpc.pl,v 1.7 2006/07/27 19:24:42 jklowden Exp $ +# +# Contributed by James K. Lowden and is hereby placed in +# the public domain. No rights reserved. +# +# This program demonstrates calling the ODBC "dynamic" functions, using +# placeholders and prepared statements. +# +# By default, arguments are bound to type SQL_VARCHAR. If the stored procedure +# uses other types, they may be specified in the form :TYPE:data, where TYPE is one +# of the DBI symbolic constants. If your data happen to begin with a colon, +# prefix the string with ':SQL_VARCHAR:'. +# +# Example: a datetime parameter: ':SQL_DATETIME:2005-04-01 16:46:00' +# (Unfortunately, it appears DBD::ODBC has difficulty with SQL_DATETIME: +# http://www.opensubscriber.com/message/perl-win32-users@listserv.ActiveState.com/108164.html +# +# +# To find the symbolic constants for DBI, perldoc DBI recommends: +# use DBI; +# foreach (@{ $DBI::EXPORT_TAGS{sql_types} }) { +# printf "%s=%d\n", $_, &{"DBI::$_"}; +# } +# + +use DBI qw(:sql_types); +use Getopt::Std; +use File::Basename; + +# Stolen shamelessly from DBI: testerrhandler.pl + +sub err_handler { + my ($state, $msg) = @_; + # Strip out all of the driver ID stuff + $msg =~ s/^(\[[\w\s]*\])+//; + print "===> state: $state msg: $msg\n"; + return 0; +} + +sub setup_error_handler($) +{ my ($dbh) = @_; + + $dbh->{odbc_err_handler} = \&err_handler; + $dbh->{odbc_async_exec} = 1; + print "odbc_async_exec is: $dbh->{odbc_async_exec}\n"; +} + +$program = basename($0); + +Getopt::Std::getopts('U:P:D:d:h', \%opts); + +my ($dsn, $user, $pass, $database); +$dsn = $opts{D}? $opts{D} : "dbi:ODBC:JDBC"; +$user = $opts{U}? $opts{U} : 'guest'; +$pass = $opts{P}? $opts{P} : 'sybase'; + +die qq(Syntax: \t$program [-D dsn] [-U username] [-P password] procedure [arg1[, argn]]\n) + if( $opts{h} || 0 == @ARGV ); + +# Connect +my $dbh = DBI->connect($dsn, $user, $pass, {RaiseError => 0, PrintError => 1, AutoCommit => 1}) + or die "Unable for connect to $dsn $DBI::errstr"; + +setup_error_handler($dbh); + +# Construct an odbc placeholder list like (?, ?, ?) +# for any arguments after $ARGV[0]. +my $placeholders = ''; +if( @ARGV > 1 ) { + my @placeholders = ('?') x (@ARGV - 1); + $placeholders = '(' . join( q(, ), @placeholders ) . ')'; + printf STDERR qq(%d arguments found for procedure "$ARGV[0]"\n), scalar(@placeholders); +} + +# Ready the odbc call +my $sql = "{? = call $ARGV[0] $placeholders}"; +my $sth = $dbh->prepare( $sql ); + +# Bind the return code as "inout". +my $rc; +print STDERR qq(Binding parameter #1, the return code\n); +$sth->bind_param_inout(1, \$rc, SQL_INTEGER); + +# Bind the input parameters (we don't do outputs in this example). +# Placeholder numbers are 1-based; the first "parameter" +# is the return code, $rc, above. +for( my $i=1; $i < @ARGV; $i++ ) { + my $type = SQL_VARCHAR; + my $typename = 'SQL_VARCHAR'; + my $data = $ARGV[$i]; + if( $data =~ /^:([[:upper:]_]+):(.+)/ ) { # parse out the datatype, if any + $typename = $1; + $data = $2; + $type = eval($typename); + warn qq("$typename" will probably cause a "can't rebind parameter" message\n) + if $type == SQL_DATETIME; + } + printf STDERR qq(Binding parameter #%d (%s): "$data"\n), ($i+1), $typename; + $sth->bind_param( 1 + $i, $data, $type ); +} + +print STDERR qq(\nExecuting: "$sth->{Statement}" with parameters '), + join(q(', '), @ARGV[1..$#ARGV]), qq('\n); + +# Execute the SQL and print the (possibly several) results +$rc = $sth->execute; +print STDERR qq(execute returned: '$rc'\n) if $rc; + +$i = 1; +while ( $sth->{Active} ) { + printf "Result #%d:\n", $i++; + my @names = @{$sth->{NAME}}; # print column names for each result set + print '[', join("], [", @{$sth->{NAME}}), "]\n" if @names; + while(@dat = $sth->fetchrow_array) { + print q('), join(q(', '), @dat), qq('\n); + } +} + +$dbh->disconnect(); + +exit 0; + diff --git b/src/.cvsignore a/src/.cvsignore new file mode 100644 index 0000000..282522d --- /dev/null +++ a/src/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git b/src/apps/.cvsignore a/src/apps/.cvsignore new file mode 100644 index 0000000..36f7973 --- /dev/null +++ a/src/apps/.cvsignore @@ -0,0 +1,11 @@ +Makefile +Makefile.in +tsql +freebcp +bsqldb +defncopy +.libs +.deps +datacopy +bsqlodbc + diff --git b/src/apps/fisql/.cvsignore a/src/apps/fisql/.cvsignore new file mode 100644 index 0000000..ecef2f6 --- /dev/null +++ a/src/apps/fisql/.cvsignore @@ -0,0 +1,5 @@ +Makefile +Makefile.in +.libs +.deps +fisql diff --git b/src/ctlib/.cvsignore a/src/ctlib/.cvsignore new file mode 100644 index 0000000..aee705c --- /dev/null +++ a/src/ctlib/.cvsignore @@ -0,0 +1,6 @@ +Makefile +Makefile.in +.libs +*.lo +*.la +.deps diff --git b/src/ctlib/unittests/.cvsignore a/src/ctlib/unittests/.cvsignore new file mode 100644 index 0000000..4682152 --- /dev/null +++ a/src/ctlib/unittests/.cvsignore @@ -0,0 +1,34 @@ +Makefile +Makefile.in +.deps +.libs +t0001 +t0002 +t0003 +t0004 +t0005 +t0006 +t0007 +t0008 +t0009 +connect_fail +tdsdump.out +ct_options +rpc_ct_setparam +rpc_ct_param +lang_ct_param +get_send_data +cs_diag +array_bind +ct_diagall +ct_diagclient +ct_diagserver +cs_config +cancel +blk_in +blk_out +ct_cursor +ct_cursors +ct_dynamic +blk_in2 + diff --git b/src/dblib/.cvsignore a/src/dblib/.cvsignore new file mode 100644 index 0000000..aee705c --- /dev/null +++ a/src/dblib/.cvsignore @@ -0,0 +1,6 @@ +Makefile +Makefile.in +.libs +*.lo +*.la +.deps diff --git b/src/dblib/unittests/.cvsignore a/src/dblib/unittests/.cvsignore new file mode 100644 index 0000000..691f42b --- /dev/null +++ a/src/dblib/unittests/.cvsignore @@ -0,0 +1,48 @@ +Makefile +Makefile.in +.deps +.libs +t0001 +t0002 +t0003 +t0004 +t0005 +t0006 +t0007 +t0008 +t0009 +t0011 +t0012 +t0013 +t0013.out +t0014 +t0014.out +t0015 +t0016 +t0016.out +t0017 +t0018 +t0019 +t0020 +t0021 +t0022 +tdsdump.out +t0023 +t0016.err +t0017.err +t0017.out +rpc +dbmorecmds +bcp +thread +text_buffer +done_handling +timeout +dblib.dsw +dblib.mak +vc6 +hang +null +null2 +setnull + diff --git b/src/odbc/.cvsignore a/src/odbc/.cvsignore new file mode 100644 index 0000000..c9a04fd --- /dev/null +++ a/src/odbc/.cvsignore @@ -0,0 +1,7 @@ +Makefile +Makefile.in +.libs +.deps +*.lo +*.la + diff --git b/src/odbc/checkexport.sh a/src/odbc/checkexport.sh new file mode 100755 index 0000000..142cd4e --- /dev/null +++ a/src/odbc/checkexport.sh @@ -0,0 +1,10 @@ +#!/bin/sh +echo Function not exported by VMS driver +(nm .libs/libtdsodbc.so | grep ' T ' | sed 's,.* T ,,g' | grep '^\(SQL\|ODBC\)'; cat ../../vms/odbc_driver_axp.opt | grep -v '^!' | grep 'SQL' | sed 's,.*SQL\(.*\)=PROCEDURE.*,SQL\1,g') | sort | uniq -u | grep -v ODBCINSTGetProperties + +echo Function not exported by windows driver +(nm .libs/libtdsodbc.so | grep ' T ' | sed 's,.* T ,,g' | grep '^\(SQL\|ODBC\)'; cat ../../win32/FreeTDS.def | grep -v '^;' | grep 'SQL' | sed 's,.*SQL,SQL,g' | perl -pe 's,\r,,g') | sort | uniq -u | grep -v ODBCINSTGetProperties + +echo Function not declared as implemented +(nm .libs/libtdsodbc.so | grep ' T ' | sed 's,.* T ,,g' | grep '^SQL' | perl -pe 'tr/a-z/A-Z/'; cat odbc.c | grep 'X(SQL_API_' | sed 's,.*SQL_API_SQL,SQL,g; s,).*,,g' | sort | uniq) | sort | uniq -u +(nm .libs/libtdsodbc.so | grep ' T ' | sed 's,.* T ,,g' | grep '^SQL' | perl -pe 'tr/a-z/A-Z/'; cat odbc.c | grep '_(SQL_API_' | sed 's,.*SQL_API_SQL,SQL,g; s,).*,,g' | sort | uniq) | sort | uniq -d diff --git b/src/odbc/unittests/.cvsignore a/src/odbc/unittests/.cvsignore new file mode 100644 index 0000000..2da9b2c --- /dev/null +++ a/src/odbc/unittests/.cvsignore @@ -0,0 +1,67 @@ +.libs +Makefile +Makefile.in +t0001 +t0002 +t0003 +t0004 +tdsdump.out +.deps +connect +print +date +norowset +funccall +lang_error +tables +binary_test +moreandcount +earlybind +putdata +params +raiserror +getdata +type +genparams +transaction +preperror +odbc.ini +odbcinst.ini +prepare_results +data +testodbc +error +rebindpar +convert_error +typeinfo +const_params +compute +insert_speed +timeout +array +array_out +cursor1 +cursor2 +scroll +describecol +copydesc +msvc.mak +prepclose +warning +paramcore +rpc +timeout2 +timeout3 +odbc.dsw +odbc.mak +vc6 +connect2 +timeout4 +freeclose +cursor3 +cursor4 +cursor5 +attributes +hidden +blob1 +rowset diff --git b/src/odbc/unittests/rownumber.c a/src/odbc/unittests/rownumber.c new file mode 100644 index 0000000..d2c213f --- /dev/null +++ a/src/odbc/unittests/rownumber.c @@ -0,0 +1,110 @@ +#include "common.h" + +/* Test for SQL_ATTR_ROW_NUMBER */ + +/* + * This works under MS ODBC however I don't know if it's correct... + * TODO make it work and add to Makefile.am + */ + +static char software_version[] = "$Id: rownumber.c,v 1.2 2005/01/14 15:03:12 freddy77 Exp $"; +static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; + +static void +CheckRowNum(int n, int line) +{ + SQLRETURN res; + SQLUINTEGER value; + + res = SQLGetStmtAttr(Statement, SQL_ATTR_ROW_NUMBER, &value, sizeof(value), NULL); + if (res != SQL_SUCCESS) { + if (res == SQL_ERROR && n < 0) + return; + ODBC_REPORT_ERROR("SQLGetStmtAttr failed"); + } + if (value != n) { + fprintf(stderr, "Expected %d rows returned %d line %d\n", n, (int) value, line); + exit(1); + } +} + +#undef CHECK_ROWS +#define CHECK_ROWS(n) CheckRowNum(n,__LINE__) + +static void +NextResults(SQLRETURN expected) +{ + if (SQLMoreResults(Statement) != expected) { + if (expected == SQL_SUCCESS) + fprintf(stderr, "Expected another recordset\n"); + else + fprintf(stderr, "Not expected another recordset\n"); + exit(1); + } +} + +static void +Fetch(SQLRETURN expected) +{ + if (SQLFetch(Statement) != expected) { + if (expected == SQL_SUCCESS) + fprintf(stderr, "Expected another record\n"); + else + fprintf(stderr, "Not expected another record\n"); + exit(1); + } +} + +static void +DoTest() +{ + int n = 0; + static const char query[] = "SELECT * FROM #tmp1 ORDER BY i SELECT * FROM #tmp1 WHERE i < 3 ORDER BY i"; + + /* execute a batch command and check row number */ + if (SQLExecDirect(Statement, (SQLCHAR *) query, SQL_NTS) != SQL_SUCCESS) + ODBC_REPORT_ERROR("Unable to execute direct statement"); + CHECK_ROWS(-1); + printf("Result %d\n", ++n); + Fetch(SQL_SUCCESS); + CHECK_ROWS(0); + Fetch(SQL_SUCCESS); + CHECK_ROWS(0); + Fetch(SQL_SUCCESS); + CHECK_ROWS(0); + Fetch(SQL_NO_DATA); + CHECK_ROWS(-1); + NextResults(SQL_SUCCESS); + CHECK_ROWS(-1); + + printf("Result %d\n", ++n); + Fetch(SQL_SUCCESS); + CHECK_ROWS(0); + Fetch(SQL_SUCCESS); + CHECK_ROWS(0); + Fetch(SQL_NO_DATA); + CHECK_ROWS(-1); + NextResults(SQL_NO_DATA); + CHECK_ROWS(-1); +} + +int +main(int argc, char *argv[]) +{ + use_odbc_version3 = 1; + + Connect(); + + Command(Statement, "create table #tmp1 (i int)"); + Command(Statement, "create table #tmp2 (i int)"); + Command(Statement, "insert into #tmp1 values(1)"); + Command(Statement, "insert into #tmp1 values(2)"); + Command(Statement, "insert into #tmp1 values(5)"); + + DoTest(); + + Disconnect(); + + printf("Done.\n"); + return 0; +} diff --git b/src/pool/.cvsignore a/src/pool/.cvsignore new file mode 100644 index 0000000..7cdd226 --- /dev/null +++ a/src/pool/.cvsignore @@ -0,0 +1,5 @@ +Makefile +Makefile.in +.deps +.libs +tdspool diff --git b/src/pool/stream.c a/src/pool/stream.c new file mode 100644 index 0000000..8823cd9 --- /dev/null +++ a/src/pool/stream.c @@ -0,0 +1,455 @@ +/* TDSPool - Connection pooling for TDS based databases + * Copyright (C) 2001, 2002, 2003, 2004, 2005 Brian Bruns + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +/* + * Name: stream.c + * Description: Controls the result stream processing. + */ + +#if HAVE_CONFIG_H +#include +#endif /* HAVE_CONFIG_H */ + +#include +#include + +#if HAVE_STDLIB_H +#include +#endif /* HAVE_STDLIB_H */ + +#if HAVE_STRING_H +#include +#endif /* HAVE_STDLIB_H */ + +#include "pool.h" +#include "tds.h" + +TDS_RCSID(var, "$Id: stream.c,v 1.25 2007/06/19 13:31:34 freddy77 Exp $"); + +int pool_find_end_token(TDS_POOL_MEMBER * pmbr, const unsigned char *buf, int len); + +struct tmp_col_struct +{ + char *column_name; + struct tmp_col_struct *next; +}; + +/* + * returns 1 if this end token has the final bit set + */ +static int +is_final_token(const unsigned char *buf) +{ + return buf[1] & 0x01 ? 0 : 1; +} + +/* + * computes the number of bytes left to be read from the input stream + * after this packet is completely processed. + * returns 1 if token overruns the current packet, 0 otherwise. + */ +static int +bytes_left(TDS_POOL_MEMBER * pmbr, const unsigned char *buf, int pos, int maxlen, int need) +{ + if (pos + need > maxlen) { + return 1; + } else + return 0; +} + +/* + * attempts to read a fixed length token, returns 1 if successful + * bytes_read is set to the number of bytes read fromt the input stream. + */ +static int +read_fixed_token(TDS_POOL_MEMBER * pmbr, const unsigned char *buf, int maxlen, int *bytes_read) +{ + TDS_SMALLINT sz; + int marker; + int pos = 0; + + if (bytes_left(pmbr, buf, pos, maxlen, 1)) { + *bytes_read = maxlen; + return 0; + } + marker = buf[pos++]; + sz = tds_get_token_size(marker); + if (bytes_left(pmbr, buf, pos, maxlen, sz)) { + *bytes_read = maxlen; + return 0; + } else { + *bytes_read = sz + 1; + return 1; + } +} + +static int +read_variable_token(TDS_POOL_MEMBER * pmbr, const unsigned char *buf, int maxlen, int *bytes_read) +{ + TDS_SMALLINT sz; + int pos = 0; + + if (bytes_left(pmbr, buf, pos, maxlen, 3)) { + *bytes_read = maxlen; + return 0; + } + + /* memcpy(&sz,&buf[1],2); */ + /* FIX ME -- works only in emul little endian mode on bigend boxen */ + sz = buf[1] + buf[2] * 256; + pos += 3; + if (bytes_left(pmbr, buf, pos, maxlen, sz)) { + *bytes_read = maxlen; + return 0; + } else { + *bytes_read = sz + 3; + return 1; + } +} + +static int +read_row(TDS_POOL_MEMBER * pmbr, const unsigned char *buf, int maxlen, int *bytes_read) +{ + TDSCOLUMN *curcol; + TDSRESULTINFO *info; + int i, colsize; + int pos = 1; /* skip marker */ + + info = pmbr->tds->res_info; + + die_if((!info), "Entered read_row() without a res_info structure."); + + for (i = 0; i < info->num_cols; i++) { + curcol = info->columns[i]; + if (!is_fixed_type(curcol->column_type)) { + if (bytes_left(pmbr, buf, pos, maxlen, 1)) { + *bytes_read = maxlen; + return 0; + } + colsize = buf[pos++]; + } else { + colsize = tds_get_size_by_type(curcol->column_type); + } + if (bytes_left(pmbr, buf, pos, maxlen, colsize)) { + *bytes_read = maxlen; + return 0; + } + pos += colsize; + } + + *bytes_read = pos; + + return 1; +} + +static int +read_col_name(TDS_POOL_MEMBER * pmbr, const unsigned char *buf, int maxlen, int *bytes_read) +{ + TDS_SMALLINT hdrsize; + int pos = 0; + int stop = 0, num_cols = 0; + int namelen; + struct tmp_col_struct *head = NULL, *cur = NULL, *prev; + int col; + TDSCOLUMN *curcol; + TDSRESULTINFO *info; + + /* header size */ + if (bytes_left(pmbr, buf, pos, maxlen, 3)) { + *bytes_read = maxlen; + return 0; + } + /* FIX ME -- endian */ + hdrsize = buf[1] + buf[2] * 256; + pos += 3; + + while (!stop) { + prev = cur; + cur = (struct tmp_col_struct *) + malloc(sizeof(struct tmp_col_struct)); + if (prev) + prev->next = cur; + if (!head) + head = cur; + + if (bytes_left(pmbr, buf, pos, maxlen, 1)) { + *bytes_read = maxlen; + return 0; + } + namelen = buf[pos++]; + + + if (bytes_left(pmbr, buf, pos, maxlen, namelen)) { + *bytes_read = maxlen; + return 0; + } + cur->column_name = (char *) malloc(namelen + 1); + strncpy(cur->column_name, (char *) &buf[pos], namelen); + cur->column_name[namelen] = '\0'; + cur->next = NULL; + + pos += namelen; + + num_cols++; + + if (pos >= hdrsize) + stop = 1; + } + + tds_free_all_results(pmbr->tds); + pmbr->tds->res_info = tds_alloc_results(num_cols); + info = pmbr->tds->res_info; + + cur = head; + + for (col = 0; col < info->num_cols; col++) { + curcol = info->columns[col]; + strncpy(curcol->column_name, cur->column_name, sizeof(curcol->column_name)); + /* FIXME ucs2 client and others */ + curcol->column_name[sizeof(curcol->column_name) - 1] = 0; + curcol->column_namelen = strlen(curcol->column_name); + prev = cur; + cur = cur->next; + free(prev->column_name); + free(prev); + } + + + *bytes_read = pos; + return 1; +} + +static int +read_col_info(TDS_POOL_MEMBER * pmbr, const unsigned char *buf, int maxlen, int *bytes_read) +{ + TDS_SMALLINT hdrsize; + int pos = 0; + int col, rest; + TDSCOLUMN *curcol; + TDSRESULTINFO *info; + TDSSOCKET *tds = pmbr->tds; + + /* header size */ + if (bytes_left(pmbr, buf, pos, maxlen, 3)) { + *bytes_read = maxlen; + return 0; + } + /* FIX ME -- endian */ + hdrsize = buf[1] + buf[2] * 256; + pos += 3; + + info = tds->res_info; + for (col = 0; col < info->num_cols; col++) { + curcol = info->columns[col]; + if (bytes_left(pmbr, buf, pos, maxlen, 5)) { + *bytes_read = maxlen; + return 0; + } + pos += 4; + curcol->column_type = buf[pos++]; + + /* FIX ME -- blob types */ + if (!is_fixed_type(curcol->column_type)) { + if (bytes_left(pmbr, buf, pos, maxlen, 1)) { + *bytes_read = maxlen; + return 0; + } + curcol->column_size = buf[pos++]; + } else { + curcol->column_size = tds_get_size_by_type(curcol->column_type); + } + } + + rest = hdrsize + 3 - pos; + if (rest > 0) { + if (bytes_left(pmbr, buf, pos, maxlen, rest)) { + *bytes_read = maxlen; + return 0; + } + fprintf(stderr, "read_col_info: draining %d bytes\n", rest); + pos += rest; + } + *bytes_read = pos; + + return 1; +} + +/* + * TDS 5 style result sets + */ +static int +read_result(TDS_POOL_MEMBER * pmbr, const unsigned char *buf, int maxlen, int *bytes_read) +{ + TDS_SMALLINT hdrsize; + int pos = 0; + int namelen; + int col; + TDSSOCKET *tds = pmbr->tds; + int num_cols; + TDSCOLUMN *curcol; + TDSRESULTINFO *info; + + if (bytes_left(pmbr, buf, pos, maxlen, 3)) { + *bytes_read = maxlen; + return 0; + } + /* FIX ME -- endian */ + hdrsize = buf[1] + buf[2] * 256; + pos += 3; + + /* read number of columns and allocate the columns structure */ + num_cols = buf[pos] + buf[pos+1] * 256; + pos += 2; + + tds_free_all_results(tds); + + tds->res_info = tds_alloc_results(num_cols); + info = pmbr->tds->res_info; + + /* + * loop through the columns populating COLINFO struct from + * server response + */ + + for (col = 0; col < info->num_cols; col++) { + curcol = info->columns[col]; + + namelen = buf[pos++]; + + strncpy(curcol->column_name, (char *) &buf[pos], namelen); + curcol->column_name[namelen] = '\0'; + pos += namelen; + + curcol->column_namelen = namelen; + + pos++; /* flags */ + pos += 4; /* user type */ + + tds_set_column_type(tds, curcol, (int)buf[pos]); + switch(curcol->column_varint_size) { + /* FIX ME - endian */ + case 2: curcol->column_size = buf[pos] + buf[pos+1]*256; break; + case 1: curcol->column_size = buf[pos]; break; + case 0: break; + } + pos+=curcol->column_varint_size; + if (is_numeric_type(curcol->column_type)) + pos+=2; + + /* skip locale information */ + pos += buf[pos]; + } + return tds_alloc_row(info); +} + +/* + * is_end_token processes one token and returns 0 for an incomplete token + * or -1 if this is the END token, and 1 for successful processing of token. + * The number of bytes read from the stream is returned in 'bytes_read'. + */ +static int +pool_is_end_token(TDS_POOL_MEMBER * pmbr, const unsigned char *buf, int maxlen, int *bytes_read) +{ + TDS_SMALLINT sz; + int marker; + int ret; + + if (maxlen == 0) + return 0; + + marker = buf[0]; + sz = tds_get_token_size(marker); + + if (sz) { + ret = read_fixed_token(pmbr, buf, maxlen, bytes_read); + } else if (marker == TDS_ROW_TOKEN) { + ret = read_row(pmbr, buf, maxlen, bytes_read); + } else if (marker == TDS_COLNAME_TOKEN) { + ret = read_col_name(pmbr, buf, maxlen, bytes_read); + } else if (marker == TDS_COLFMT_TOKEN) { + ret = read_col_info(pmbr, buf, maxlen, bytes_read); + } else if (marker == TDS_RESULT_TOKEN) { + ret = read_result(pmbr, buf, maxlen, bytes_read); + } else { + ret = read_variable_token(pmbr, buf, maxlen, bytes_read); + } + + /* fprintf(stderr,"bytes_read = %d\n",*bytes_read); */ + if (!ret) { + return 0; + } + + if (is_end_token(marker)) { + if (is_final_token(buf)) { + /* clean up */ + return -1; + } + } + + return 1; +} + +int +pool_find_end_token(TDS_POOL_MEMBER * pmbr, const unsigned char *buf, int len) +{ + int pos = 0, startpos, ret; + int bytes_read; + int stop = 0; + const unsigned char *curbuf; + unsigned char tmpbuf[PGSIZ + BLOCKSIZ]; + int totlen; + static int last_mark; + + /* + * if we had part of a token left over, copy to tmpbuf + */ + if (pmbr->num_bytes_left) { + /* fprintf(stderr,"%d bytes left from last packet\n",pmbr->num_bytes_left); */ + if (pmbr->num_bytes_left > 2000) { + fprintf(stderr, "marker is %d last mark was %d\n", pmbr->fragment[0], last_mark); + } + memcpy(tmpbuf, pmbr->fragment, pmbr->num_bytes_left); + memcpy(&tmpbuf[pmbr->num_bytes_left], buf, len); + curbuf = tmpbuf; + totlen = len + pmbr->num_bytes_left; + } else { + curbuf = buf; + totlen = len; + } + + do { + startpos = pos; + + ret = pool_is_end_token(pmbr, &curbuf[pos], totlen - pos, &bytes_read); + if (ret <= 0) + stop = 1; + + pos += bytes_read; + } while (!stop); + + if (ret == -1) { + pmbr->num_bytes_left = 0; + return 1; /* found end token */ + } else { + last_mark = buf[0]; + pmbr->num_bytes_left = totlen - startpos; + memcpy(pmbr->fragment, &curbuf[startpos], pmbr->num_bytes_left); + return 0; /* exhausted the stream */ + } +} diff --git b/src/replacements/.cvsignore a/src/replacements/.cvsignore new file mode 100644 index 0000000..aee705c --- /dev/null +++ a/src/replacements/.cvsignore @@ -0,0 +1,6 @@ +Makefile +Makefile.in +.libs +*.lo +*.la +.deps diff --git b/src/server/.cvsignore a/src/server/.cvsignore new file mode 100644 index 0000000..276eddd --- /dev/null +++ a/src/server/.cvsignore @@ -0,0 +1,7 @@ +Makefile +Makefile.in +.libs +*.lo +*.la +.deps +tdssrv diff --git b/src/tds/.cvsignore a/src/tds/.cvsignore new file mode 100644 index 0000000..f9b4f83 --- /dev/null +++ a/src/tds/.cvsignore @@ -0,0 +1,11 @@ +Makefile +Makefile.in +.libs +*.lo +*.la +.deps +num_limits.h +sybase_character_sets.h +tds_willconvert.h +encodings.h + diff --git b/src/tds/alternative_character_sets.h a/src/tds/alternative_character_sets.h new file mode 100644 index 0000000..662abd4 --- /dev/null +++ a/src/tds/alternative_character_sets.h @@ -0,0 +1,428 @@ +/* + * Copyright 2003 James K. Lowden + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that redistributions of source + * code retain the above copyright notice. + */ + + /* + * The purpose of this file is to help look up character set names. + * + * Any given encoding may be known by several (usually similar) aliases. + * For example, a system using ASCII encoding may report the character set as + * "ASCII", "US-ASCII", or "ISO646-US", among others. For details on what your system + * uses, you may wish to consult the nl_langinfo(3) manual page. + * + * GNU iconv converts a byte sequence from one encoding to another, but before it can do + * so, it must be told which is which. In the list below, the preferred GNU iconv(3) name + * is on the left and an alias is on the right. It is a simple exercise, left to the reader, + * to write a function that uses these data to look up the canonical name when provided + * an alias. + */ + +#ifndef _ALTERNATIVE_CHARACTER_SETS_H_ +#define _ALTERNATIVE_CHARACTER_SETS_H_ + +/* + * $Id: alternative_character_sets.h,v 1.10 2005/02/26 13:08:32 freddy77 Exp $ + */ + +/* + * This list is sorted alphabetically, except that the most + * commonly used character sets are first. + */ + /* ASCII */ + { "US-ASCII", "US-ASCII" } + , { "US-ASCII", "ANSI_X3.4-1968" } + , { "US-ASCII", "ANSI_X3.4-1986" } + , { "US-ASCII", "ASCII" } + , { "US-ASCII", "CP367" } + , { "US-ASCII", "CSASCII" } + , { "US-ASCII", "IBM367" } + , { "US-ASCII", "ISO-IR-6" } + , { "US-ASCII", "ISO646-US" } + , { "US-ASCII", "ISO_646.IRV:1991" } + , { "US-ASCII", "US" } + , { "US-ASCII", "646" } /* NetBSD default */ + /* ISO_8859-1 */ + , { "ISO-8859-1", "ISO-8859-1" } + , { "ISO-8859-1", "CP819" } + , { "ISO-8859-1", "CSISOLATIN1" } + , { "ISO-8859-1", "IBM819" } + , { "ISO-8859-1", "ISO-IR-100" } + , { "ISO-8859-1", "ISO8859-1" } + , { "ISO-8859-1", "ISO_8859-1" } + , { "ISO-8859-1", "ISO_8859-1:1987" } + , { "ISO-8859-1", "L1" } + , { "ISO-8859-1", "LATIN1" } + , { "ISO-8859-1", "iso81" } + , { "ISO-8859-1", "iso88591" } + /* UCS-2 */ + , { "UCS-2", "UCS-2" } + , { "UCS-2", "CSUNICODE" } + , { "UCS-2", "ISO-10646-UCS-2" } + , { "UCS-2", "UCS2" } + , { "UCS-2", "ucs2" } + , { "UCS-2-INTERNAL", "UCS-2-INTERNAL" } + , { "UCS-2-SWAPPED", "UCS-2-SWAPPED" } + , { "UCS-2BE", "UCS-2BE" } + , { "UCS-2BE", "CSUNICODE11" } + , { "UCS-2BE", "UNICODE-1-1" } + , { "UCS-2BE", "UNICODEBIG" } + , { "UCS-2LE", "UCS-2LE" } + , { "UCS-2LE", "UNICODELITTLE" } + /* UTF-8 */ + , { "UTF-8", "UTF-8" } + , { "UTF-8", "UTF8" } + , { "UTF-8", "utf8" } + + /* Basically alphabetical from here */ + , { "ARMSCII-8", "ARMSCII-8" } + , { "BIG-5", "BIG-5" } + , { "BIG-5", "BIG-FIVE" } + , { "BIG-5", "BIG5" } + , { "BIG-5", "BIGFIVE" } + , { "BIG-5", "CN-BIG5" } + , { "BIG-5", "CSBIG5" } + , { "BIG-5", "big5" } + , { "BIG5-HKSCS", "BIG5-HKSCS" } + , { "BIG5-HKSCS", "BIG5HKSCS" } + , { "C99", "C99" } + , { "CHINESE", "CHINESE" } + , { "CHINESE", "CSISO58GB231280" } + , { "CHINESE", "GB_2312-80" } + , { "CHINESE", "ISO-IR-58" } + , { "CHINESE", "hp15CN" } + , { "CN", "CN" } + , { "CN", "CSISO57GB1988" } + , { "CN", "GB_1988-80" } + , { "CN", "ISO-IR-57" } + , { "CN", "ISO646-CN" } + , { "CN-GB", "CN-GB" } + , { "CN-GB", "CSGB2312" } + , { "CN-GB", "EUC-CN" } + , { "CN-GB", "EUCCN" } + , { "CN-GB", "GB2312" } + , { "CN-GB-ISOIR165", "CN-GB-ISOIR165" } + , { "CN-GB-ISOIR165", "ISO-IR-165" } + , { "CP1133", "CP1133" } + , { "CP1133", "IBM-CP1133" } + , { "CP1250", "CP1250" } + , { "CP1250", "MS-EE" } + , { "CP1250", "WINDOWS-1250" } + , { "CP1250", "cp1250" } + , { "CP1251", "CP1251" } + , { "CP1251", "MS-CYRL" } + , { "CP1251", "WINDOWS-1251" } + , { "CP1251", "cp1251" } + , { "CP1252", "CP1252" } + , { "CP1252", "MS-ANSI" } + , { "CP1252", "WINDOWS-1252" } + , { "CP1252", "cp1252" } + , { "CP1253", "CP1253" } + , { "CP1253", "MS-GREEK" } + , { "CP1253", "WINDOWS-1253" } + , { "CP1253", "cp1253" } + , { "CP1254", "CP1254" } + , { "CP1254", "MS-TURK" } + , { "CP1254", "WINDOWS-1254" } + , { "CP1254", "cp1254" } + , { "CP1255", "CP1255" } + , { "CP1255", "MS-HEBR" } + , { "CP1255", "WINDOWS-1255" } + , { "CP1255", "cp1255" } + , { "CP1256", "CP1256" } + , { "CP1256", "MS-ARAB" } + , { "CP1256", "WINDOWS-1256" } + , { "CP1256", "cp1256" } + , { "CP1257", "CP1257" } + , { "CP1257", "WINBALTRIM" } + , { "CP1257", "WINDOWS-1257" } + , { "CP1257", "cp1257" } + , { "CP1258", "CP1258" } + , { "CP1258", "WINDOWS-1258" } + , { "CP1258", "cp1258" } + , { "CP1361", "CP1361" } + , { "CP1361", "JOHAB" } + , { "CP850", "CP850" } + , { "CP850", "850" } + , { "CP850", "CSPC850MULTILINGUAL" } + , { "CP850", "IBM850" } + , { "CP850", "cp850" } + , { "CP862", "CP862" } + , { "CP862", "862" } + , { "CP862", "CSPC862LATINHEBREW" } + , { "CP862", "IBM862" } + , { "CP862", "cp862" } + , { "CP866", "CP866" } + , { "CP866", "866" } + , { "CP866", "CSIBM866" } + , { "CP866", "IBM866" } + , { "CP866", "cp866" } + , { "CP874", "CP874" } + , { "CP874", "WINDOWS-874" } + , { "CP874", "cp874" } + , { "CP932", "CP932" } + , { "CP936", "CP936" } + , { "CP936", "GBK" } + , { "CP949", "CP949" } + , { "CP949", "UHC" } + , { "CP950", "CP950" } + , { "CP437", "CP437" } + , { "CP437", "cp437" } + , { "CP437", "IBM437" } + , { "EUC-JP", "EUC-JP" } + , { "EUC-JP", "CSEUCPKDFMTJAPANESE" } + , { "EUC-JP", "EUCJP" } + , { "EUC-JP", "EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE"} + , { "EUC-JP", "eucJP" } + , { "EUC-KR", "EUC-KR" } + , { "EUC-KR", "CSEUCKR" } + , { "EUC-KR", "EUCKR" } + , { "EUC-KR", "eucKR" } + , { "EUC-TW", "CSEUCTW" } + , { "EUC-TW", "EUC-TW" } + , { "EUC-TW", "EUCTW" } + , { "EUC-TW", "eucTW" } + , { "GB18030", "GB18030" } + , { "GEORGIAN-ACADEMY", "GEORGIAN-ACADEMY" } + , { "GEORGIAN-PS", "GEORGIAN-PS" } + , { "HZ", "HZ" } + , { "HZ", "HZ-GB-2312" } + , { "ISO-2022-CN", "ISO-2022-CN" } + , { "ISO-2022-CN", "CSISO2022CN" } + , { "ISO-2022-CN-EXT", "ISO-2022-CN-EXT" } + , { "ISO-2022-JP", "ISO-2022-JP" } + , { "ISO-2022-JP", "CSISO2022JP" } + , { "ISO-2022-JP-1", "ISO-2022-JP-1" } + , { "ISO-2022-JP-2", "ISO-2022-JP-2" } + , { "ISO-2022-JP-2", "CSISO2022JP2" } + , { "ISO-2022-KR", "ISO-2022-KR" } + , { "ISO-2022-KR", "CSISO2022KR" } + , { "ISO-8859-10", "ISO-8859-10" } + , { "ISO-8859-10", "CSISOLATIN6" } + , { "ISO-8859-10", "ISO-IR-157" } + , { "ISO-8859-10", "ISO8859-10" } + , { "ISO-8859-10", "ISO_8859-10" } + , { "ISO-8859-10", "ISO_8859-10:1992" } + , { "ISO-8859-10", "L6" } + , { "ISO-8859-10", "LATIN6" } + , { "ISO-8859-13", "ISO-8859-13" } + , { "ISO-8859-13", "ISO-IR-179" } + , { "ISO-8859-13", "ISO_8859-13" } + , { "ISO-8859-13", "L7" } + , { "ISO-8859-13", "LATIN7" } + , { "ISO-8859-14", "ISO-8859-14" } + , { "ISO-8859-14", "ISO-CELTIC" } + , { "ISO-8859-14", "ISO-IR-199" } + , { "ISO-8859-14", "ISO_8859-14" } + , { "ISO-8859-14", "ISO_8859-14:1998" } + , { "ISO-8859-14", "L8" } + , { "ISO-8859-14", "LATIN8" } + , { "ISO-8859-15", "ISO8859-15" } + , { "ISO-8859-15", "ISO-8859-15" } + , { "ISO-8859-15", "ISO-IR-203" } + , { "ISO-8859-15", "ISO_8859-15" } + , { "ISO-8859-15", "ISO_8859-15:1998" } + , { "ISO-8859-15", "iso815" } + , { "ISO-8859-15", "iso885915" } + , { "ISO-8859-16", "ISO-8859-16" } + , { "ISO-8859-16", "ISO-IR-226" } + , { "ISO-8859-16", "ISO_8859-16" } + , { "ISO-8859-16", "ISO_8859-16:2000" } + , { "ISO-8859-2", "ISO-8859-2" } + , { "ISO-8859-2", "CSISOLATIN2" } + , { "ISO-8859-2", "ISO8859-2" } + , { "ISO-8859-2", "ISO-IR-101" } + , { "ISO-8859-2", "ISO_8859-2" } + , { "ISO-8859-2", "ISO_8859-2:1987" } + , { "ISO-8859-2", "L2" } + , { "ISO-8859-2", "LATIN2" } + , { "ISO-8859-2", "iso82" } + , { "ISO-8859-2", "iso88592" } + , { "ISO-8859-3", "ISO-8859-3" } + , { "ISO-8859-3", "CSISOLATIN3" } + , { "ISO-8859-3", "ISO-IR-109" } + , { "ISO-8859-3", "ISO_8859-3" } + , { "ISO-8859-3", "ISO_8859-3:1988" } + , { "ISO-8859-3", "L3" } + , { "ISO-8859-3", "LATIN3" } + , { "ISO-8859-3", "iso83" } + , { "ISO-8859-3", "iso88593" } + , { "ISO-8859-4", "ISO8859-4" } + , { "ISO-8859-4", "CSISOLATIN4" } + , { "ISO-8859-4", "ISO-8859-4" } + , { "ISO-8859-4", "ISO-IR-110" } + , { "ISO-8859-4", "ISO_8859-4" } + , { "ISO-8859-4", "ISO_8859-4:1988" } + , { "ISO-8859-4", "L4" } + , { "ISO-8859-4", "LATIN4" } + , { "ISO-8859-4", "iso84" } + , { "ISO-8859-4", "iso88594" } + , { "ISO-8859-5", "ISO-8859-5" } + , { "ISO-8859-5", "CSISOLATINCYRILLIC" } + , { "ISO-8859-5", "CYRILLIC" } + , { "ISO-8859-5", "ISO8859-5" } + , { "ISO-8859-5", "ISO-IR-144" } + , { "ISO-8859-5", "ISO8859-5" } + , { "ISO-8859-5", "ISO_8859-5" } + , { "ISO-8859-5", "ISO_8859-5:1988" } + , { "ISO-8859-5", "iso85" } + , { "ISO-8859-5", "iso88595" } + , { "ISO-8859-6", "ISO-8859-6" } + , { "ISO-8859-6", "ARABIC" } + , { "ISO-8859-6", "ASMO-708" } + , { "ISO-8859-6", "CSISOLATINARABIC" } + , { "ISO-8859-6", "ECMA-114" } + , { "ISO-8859-6", "ISO-IR-127" } + , { "ISO-8859-6", "ISO8859-6" } + , { "ISO-8859-6", "ISO_8859-6" } + , { "ISO-8859-6", "ISO_8859-6:1987" } + , { "ISO-8859-6", "iso86" } + , { "ISO-8859-6", "iso88596" } + , { "ISO-8859-7", "ISO-8859-7" } + , { "ISO-8859-7", "CSISOLATINGREEK" } + , { "ISO-8859-7", "ECMA-118" } + , { "ISO-8859-7", "ELOT_928" } + , { "ISO-8859-7", "GREEK" } + , { "ISO-8859-7", "GREEK8" } + , { "ISO-8859-7", "ISO-IR-126" } + , { "ISO-8859-7", "ISO8859-7" } + , { "ISO-8859-7", "ISO_8859-7" } + , { "ISO-8859-7", "ISO_8859-7:1987" } + , { "ISO-8859-7", "iso87" } + , { "ISO-8859-7", "iso88597" } + , { "ISO-8859-8", "ISO-8859-8" } + , { "ISO-8859-8", "CSISOLATINHEBREW" } + , { "ISO-8859-8", "HEBREW" } + , { "ISO-8859-8", "ISO8859-8" } + , { "ISO-8859-8", "ISO-IR-138" } + , { "ISO-8859-8", "ISO_8859-8" } + , { "ISO-8859-8", "ISO_8859-8:1988" } + , { "ISO-8859-8", "iso88" } + , { "ISO-8859-8", "iso88598" } + , { "ISO-8859-9", "ISO-8859-9" } + , { "ISO-8859-9", "CSISOLATIN5" } + , { "ISO-8859-9", "ISO-IR-148" } + , { "ISO-8859-9", "ISO8859-9" } + , { "ISO-8859-9", "ISO_8859-9" } + , { "ISO-8859-9", "ISO_8859-9:1989" } + , { "ISO-8859-9", "L5" } + , { "ISO-8859-9", "LATIN5" } + , { "ISO-8859-9", "iso88599" } + , { "ISO-8859-9", "iso89" } + , { "ISO-IR-14", "ISO-IR-14" } + , { "ISO-IR-14", "CSISO14JISC6220RO" } + , { "ISO-IR-14", "ISO646-JP" } + , { "ISO-IR-14", "JIS_C6220-1969-RO" } + , { "ISO-IR-14", "JP" } + , { "ISO-IR-149", "ISO-IR-149" } + , { "ISO-IR-149", "CSKSC56011987" } + , { "ISO-IR-149", "KOREAN" } + , { "ISO-IR-149", "KSC_5601" } + , { "ISO-IR-149", "KS_C_5601-1987" } + , { "ISO-IR-149", "KS_C_5601-1989" } + , { "ISO-IR-159", "ISO-IR-159" } + , { "ISO-IR-159", "CSISO159JISX02121990" } + , { "ISO-IR-159", "JIS_X0212" } + , { "ISO-IR-159", "JIS_X0212-1990" } + , { "ISO-IR-159", "JIS_X0212.1990-0" } + , { "ISO-IR-159", "X0212" } + , { "ISO-IR-166", "ISO-IR-166" } + , { "ISO-IR-166", "TIS-620" } + , { "ISO-IR-166", "TIS620" } + , { "ISO-IR-166", "TIS620-0" } + , { "ISO-IR-166", "TIS620.2529-1" } + , { "ISO-IR-166", "TIS620.2533-0" } + , { "ISO-IR-166", "TIS620.2533-1" } + , { "ISO-IR-166", "thai8" } + , { "ISO-IR-166", "tis620" } + , { "ISO-IR-87", "ISO-IR-87" } + , { "ISO-IR-87", "CSISO87JISX0208" } + , { "ISO-IR-87", "JIS0208" } + , { "ISO-IR-87", "JIS_C6226-1983" } + , { "ISO-IR-87", "JIS_X0208" } + , { "ISO-IR-87", "JIS_X0208-1983" } + , { "ISO-IR-87", "JIS_X0208-1990" } + , { "ISO-IR-87", "X0208" } + , { "JAVA", "JAVA" } + , { "JISX0201-1976", "JISX0201-1976" } + , { "JISX0201-1976", "CSHALFWIDTHKATAKANA" } + , { "JISX0201-1976", "JIS_X0201" } + , { "JISX0201-1976", "X0201" } + , { "KOI8-R", "KOI8-R" } + , { "KOI8-R", "CSKOI8R" } + , { "KOI8-RU", "KOI8-RU" } + , { "KOI8-T", "KOI8-T" } + , { "KOI8-U", "KOI8-U" } + , { "MAC", "MAC" } + , { "MAC", "CSMACINTOSH" } + , { "MAC", "MACINTOSH" } + , { "MAC", "MACROMAN" } + , { "MACARABIC", "MACARABIC" } + , { "MACCENTRALEUROPE", "MACCENTRALEUROPE" } + , { "MACCROATIAN", "MACCROATIAN" } + , { "MACCYRILLIC", "MACCYRILLIC" } + , { "MACGREEK", "MACGREEK" } + , { "MACHEBREW", "MACHEBREW" } + , { "MACICELAND", "MACICELAND" } + , { "MACROMANIA", "MACROMANIA" } + , { "MACTHAI", "MACTHAI" } + , { "MACTURKISH", "MACTURKISH" } + , { "MACUKRAINE", "MACUKRAINE" } + , { "MULELAO-1", "MULELAO-1" } + , { "NEXTSTEP", "NEXTSTEP" } + , { "ROMAN8", "ROMAN8" } + , { "ROMAN8", "CSHPROMAN8" } + , { "ROMAN8", "HP-ROMAN8" } + , { "ROMAN8", "R8" } + , { "ROMAN8", "roma8" } + , { "ROMAN8", "roman8" } + , { "SJIS", "SJIS" } + , { "SJIS", "CSSHIFTJIS" } + , { "SJIS", "MS_KANJI" } + , { "SJIS", "SHIFT-JIS" } + , { "SJIS", "SHIFT_JIS" } + , { "SJIS", "sjis" } + , { "TCVN", "TCVN" } + , { "TCVN", "TCVN-5712" } + , { "TCVN", "TCVN5712-1" } + , { "TCVN", "TCVN5712-1:1993" } + , { "UCS-4", "UCS-4" } + , { "UCS-4", "CSUCS4" } + , { "UCS-4", "ISO-10646-UCS-4" } + , { "UCS-4", "UCS4" } + , { "UCS-4", "ucs4" } + , { "UCS-4-INTERNAL", "UCS-4-INTERNAL" } + , { "UCS-4-SWAPPED", "UCS-4-SWAPPED" } + , { "UCS-4BE", "UCS-4BE" } + , { "UCS-4LE", "UCS-4LE" } + , { "UTF-16", "UTF-16" } + , { "UTF-16", "UTF16" } + , { "UTF-16BE", "UTF-16BE" } + , { "UTF-16LE", "UTF-16LE" } + , { "UTF-32", "UTF-32" } + , { "UTF-32BE", "UTF-32BE" } + , { "UTF-32LE", "UTF-32LE" } + , { "UTF-7", "UTF-7" } + , { "UTF-7", "CSUNICODE11UTF7" } + , { "UTF-7", "UNICODE-1-1-UTF-7" } + , { "UTF-7", "UTF7" } + , { "VISCII", "VISCII" } + , { "VISCII", "CSVISCII" } + , { "VISCII", "VISCII1.1-1" } + + /* + * The following are noted in Tru64 manuals, but + * have no canonical names in FreeTDS + * + * TACTIS TACTIS codeset + * dechanyu DEC Hanyu codeset + * dechanzi DEC Hanzi codeset + * deckanji DEC Kanji codeset + * deckorean DEC Korean codeset + * sdeckanji Super DEC Kanji codeset + */ + + /* no stopper row; add your own */ +#endif diff --git b/src/tds/character_sets.h a/src/tds/character_sets.h new file mode 100644 index 0000000..2f6d1c7 --- /dev/null +++ a/src/tds/character_sets.h @@ -0,0 +1,125 @@ +/* + * These are the canonical names for character sets accepted by GNU iconv. + * See its documentation for the standard it follows. + * + * GNU iconv accepts other character set names, too, and your favorite operating system + * very likely uses still other names to represent the _same_ character set. + * + * Alternative character set names are mapped to these canonical ones in + * alternative_character_sets.h and are accessed with canonical_charset(); + */ + {"ISO-8859-1", 1, 1} + , {"UTF-8", 1, 4} + , {"UCS-2LE", 2, 2} + , {"UCS-2BE", 2, 2} + , {"UCS-2", 2, 2} + , {"US-ASCII", 1, 1} + , {"UCS-4", 4, 4} + , {"UCS-4BE", 4, 4} + , {"UCS-4LE", 4, 4} + , {"UTF-16", 2, 4} + , {"UTF-16BE", 2, 4} + , {"UTF-16LE", 2, 4} + , {"UTF-32", 4, 4} + , {"UTF-32BE", 4, 4} + , {"UTF-32LE", 4, 4} + , {"UTF-7", 1, 4} + , {"UCS-2-INTERNAL", 2, 2} + , {"UCS-2-SWAPPED", 2, 2} + , {"UCS-4-INTERNAL", 4, 4} + , {"UCS-4-SWAPPED", 4, 4} + , {"C99", 1, 1} + , {"JAVA", 1, 1} + , {"ISO-8859-2", 1, 1} + , {"ISO-8859-3", 1, 1} + , {"ISO-8859-4", 1, 1} + , {"ISO-8859-5", 1, 1} + , {"ISO-8859-6", 1, 1} + , {"ISO-8859-7", 1, 1} + , {"ISO-8859-8", 1, 1} + , {"ISO-8859-9", 1, 1} + , {"ISO-8859-10", 1, 1} + , {"ISO-8859-13", 1, 1} + , {"ISO-8859-14", 1, 1} + , {"ISO-8859-15", 1, 1} + , {"ISO-8859-16", 1, 1} + , {"KOI8-R", 1, 1} + , {"KOI8-U", 1, 1} + , {"KOI8-RU", 1, 1} + , {"CP1250", 1, 1} + , {"CP1251", 1, 1} + , {"CP1252", 1, 1} + , {"CP1253", 1, 1} + , {"CP1254", 1, 1} + , {"CP1255", 1, 1} + , {"CP1256", 1, 1} + , {"CP1257", 1, 1} + , {"CP1258", 1, 1} + , {"CP850", 1, 1} + , {"CP862", 1, 1} + , {"CP866", 1, 1} + , {"CP437", 1, 1} + , {"MAC", 1, 1} + , {"MACCENTRALEUROPE", 1, 1} + , {"MACICELAND", 1, 1} + , {"MACCROATIAN", 1, 1} + , {"MACROMANIA", 1, 1} + , {"MACCYRILLIC", 1, 1} + , {"MACUKRAINE", 1, 1} + , {"MACGREEK", 1, 1} + , {"MACTURKISH", 1, 1} + , {"MACHEBREW", 1, 1} + , {"MACARABIC", 1, 1} + , {"MACTHAI", 1, 1} + , {"ROMAN8", 1, 1} + , {"NEXTSTEP", 1, 1} + , {"ARMSCII-8", 1, 1} + , {"GEORGIAN-ACADEMY", 1, 1} + , {"GEORGIAN-PS", 1, 1} + , {"KOI8-T", 1, 1} + , {"MULELAO-1", 1, 1} + , {"CP1133", 1, 1} + , {"ISO-IR-166", 1, 1} + , {"CP874", 1, 1} + , {"CP936", 1, 2} + , {"CN", 1, 1} + , {"CP932", 1, 2} + , {"CN-GB", 1, 2} + , {"CP950", 1, 2} + , {"CP949", 1, 2} + , {"CP1361", 1, 2} + , {"BIG-5", 1, 2} + , {"BIG5-HKSCS", 1, 2} + , {"SJIS", 1, 2} + , {"EUC-KR", 1, 2} + , {"VISCII", 1, 1} + , {"ISO-IR-14", 1, 1} + , {"EUC-JP", 1, 3} + , {"EUC-TW", 1, 4} + , {"ISO-2022-JP", 1, 1} + , {"ISO-2022-KR", 1, 2} + , {"ISO-2022-CN", 1, 4} + , {"ISO-2022-CN-EXT", 1, 4} + , {"ISO-2022-JP-2", 1, 1} + , {"GB18030", 1, 4} + /* + * Beyond this point, I don't know the right answers. + * If you can provide the correct min/max (byte/char) values, please + * correct them if necessary and move them above the stopper row. + * Will the person vetting the last unknown row please turn off the lights? + * --jkl April 2003 + */ + , {"", 0, 0} /* stopper row */ + + , {"TCVN", 1, 1} + , {"JISX0201-1976", 1, 1} + , {"ISO-IR-87", 1, 1} + , {"ISO-IR-159", 1, 1} + , {"CHINESE", 1, 1} + , {"CN-GB-ISOIR165", 1, 1} + , {"ISO-IR-149", 1, 1} + , {"ISO-2022-JP-1", 1, 1} + , {"HZ", 1, 1} + /* stopper row */ + , {"", 0, 0} + diff --git b/src/tds/encodings.pl a/src/tds/encodings.pl new file mode 100755 index 0000000..1017836 --- /dev/null +++ a/src/tds/encodings.pl @@ -0,0 +1,290 @@ +#!/usr/bin/perl +## This file is in the public domain. +use File::Basename; + +$basename = basename($0); +$srcdir = "$ARGV[0]/"; + +# get list of character sets we know about +$filename = "${srcdir}alternative_character_sets.h"; +open ALT, $filename or die qq($basename: could not open "$filename"\n); +while(){ + next unless /^\t[, ] {\s+"(.+?)", "(.+?)"/; + $alternates{$2} = $1; +} +close ALT; + +$alternates{'UTF8'} = 'UTF-8'; +$alternates{'ISO_1'} = 'ISO-8859-1'; +$alternates{'ASCII_8'} = 'ISO-8859-1'; +$alternates{'ISO_1'} = 'ISO-8859-1'; +$alternates{'ISO646'} = 'ANSI_X3.4-1968'; + +$alternates{'MAC_CYR'} = 'MACCYRILLIC'; +#alternates{'MAC_EE'} = ''; +$alternates{'MACTURK'} = 'MACTURKISH'; + +$alternates{'KOI8'} = 'KOI8-R'; + +$filename = "${srcdir}sybase_character_sets.h"; +open(OUT, ">$filename") or die qq($basename: could not open "$filename"\n); +print OUT "/*\n"; +print OUT " * This file produced from $0\n"; +print OUT ' * $Id: encodings.pl,v 1.10.4.1 2008/03/10 10:07:22 freddy77 Exp $', "\n"; +print OUT " */\n"; + +# look up the canonical name +$comma = ' '; +while(){ + next if /^#/; + next if /^\s*$/; + ($name) = split; + $Name = uc $name; + $iconv_name = $alternates{$Name}; + + if( !$iconv_name ) { # try predictable transformations + $Name =~ s/ISO8859(\d{1,2})$/ISO-8859-$1/; + $Name =~ s/ISO(\d{1,2})$/ISO-8859-$1/; + + $iconv_name = $alternates{$Name}; + } + + if( !$iconv_name ) { # try crude transformation + $Name =~ s/[\-\_]+//g; + $iconv_name = $alternates{$Name}; + } + + $name = qq/"$name"/; + if( $iconv_name ) { # found, print element + $iconv_name = qq/"$iconv_name",/; + printf OUT "\t$comma { %20s %-15s }\n", $iconv_name , $name; + } else { # not found, print comment + $iconv_name = qq/"",/; + printf OUT "\t /* %20s %-15s */\n", $iconv_name , $name; + + # grep for similar names, as an aid to the to programmer. + $name =~ s/[\-\_]+//g; + print STDERR $Name.": $name alternative_character_sets.h\n"; + } + $comma = ','; +} +print OUT "\t/* stopper row */\n"; +printf OUT "\t$comma { %20s %-15s }\n", 'NULL,' , 'NULL'; +close(OUT); + + + +print "/*\n"; +$date = localtime; +print " * This file produced from $0 on $date\n"; +print ' * $Id: encodings.pl,v 1.10.4.1 2008/03/10 10:07:22 freddy77 Exp $', "\n"; +print " */\n"; + +%charsets = (); +$filename = "${srcdir}character_sets.h"; +open(IN, "<$filename") or die qq($basename: could not open "$filename"\n); +while() +{ + if (/{.*"(.*)".*,\s*([0-9]+)\s*,\s*([0-9]+)\s*}/) + { + next if !$1; + $charsets{$1} = [$2,$3]; + } +} +close(IN); + +# from all iconv to canonic +%alternates = (); +$filename = "${srcdir}alternative_character_sets.h"; +open(IN, "<$filename") or die qq($basename: could not open "$filename"\n); +while() +{ + if (/{\s*"(.+)"\s*,\s*"(.+)"\s*}/) + { + $alternates{$2} = $1; + } +} +close(IN); + +# from sybase to canonic +%sybase = (); +$filename = "${srcdir}sybase_character_sets.h"; +open(IN, "<$filename") or die qq($basename: could not open "$filename"\n); +while() +{ + if (/{\s*"(.+)"\s*,\s*"(.+)"\s*}/) + { + $sybase{$2} = $alternates{$1}; + } +} +close(IN); + +# give an index to all canonic +%index = (); +$i = 0; +$index{"ISO-8859-1"} = $i++; +$index{"UTF-8"} = $i++; +$index{"UCS-2LE"} = $i++; +$index{"UCS-2BE"} = $i++; +foreach $n (sort grep(!/^(ISO-8859-1|UTF-8|UCS-2LE|UCS-2BE)$/,keys %charsets)) +{ + $index{$n} = $i; + $i++ if $n; +} + +# output all charset +print "static const TDS_ENCODING canonic_charsets[] = {\n"; +$i=0; +foreach $n (sort { $index{$a} <=> $index{$b} } keys %charsets) +{ + my ($a, $b) = @{$charsets{$n}}; + my $index = ($n)? (sprintf "/* %3d */", $i) : "\t"; + printf "\t{%20s,\t$a, $b},\t%s\n", qq/"$n"/, $index; + $i++ if $n; +} +print "\t{\"\",\t0, 0}\n"; +print "};\n\n"; + +# output enumerated charset indexes +print "enum {\n"; +$i=0; +foreach $n (sort { $index{$a} <=> $index{$b} } keys %charsets) +{ + $n =~ tr/-a-z/_A-Z/; + printf "\t%30s =%4d,\n", "TDS_CHARSET_$n", $i++; +} +printf "\t%30s =%4d\n};\n\n", "TDS_NUM_CHARSETS", $i++; + +# output all alias +print "static const CHARACTER_SET_ALIAS iconv_aliases[] = {\n"; +foreach $n (sort keys %alternates) +{ + $a = $index{$alternates{$n}}; + next if ("$a" eq ""); + printf "\t{%25s, %3d },\n", qq/"$n"/, $a; +} +print "\t{NULL,\t0}\n"; +print "};\n\n"; + +# output all sybase +print "static const CHARACTER_SET_ALIAS sybase_aliases[] = {\n"; +foreach $n (sort keys %sybase) +{ + $a = $index{$sybase{$n}}; + next if ("$a" eq ""); + printf "\t{%20s, %3d },\n", qq/"$n"/, $a; +} +print "\t{NULL,\t0}\n"; +print "};\n\n"; + +exit 0; +__DATA__ +#http://www.sybase.com/detail/1,6904,1016214,00.html + +ascii_8 +big5 +big5hk +cp1026 +cp1047 +cp1140 +cp1141 +cp1142 +cp1143 +cp1144 +cp1145 +cp1146 +cp1147 +cp1148 +cp1149 +cp1250 +cp1251 +cp1252 +cp1253 +cp1254 +cp1255 +cp1256 +cp1257 +cp1258 +cp273 +cp277 +cp278 +cp280 +cp284 +cp285 +cp297 +cp420 +cp424 +cp437 +cp500 +cp5026 +cp5026yen +cp5035 +cp5035yen +cp737 +cp775 +cp850 +cp852 +cp855 +cp857 +cp858 +cp860 +cp861 +cp862 +cp863 +cp864 +cp865 +cp866 +cp869 +cp870 +cp871 +cp874 +cp874ibm +cp875 +cp921 +cp923 +cp930 +cp930yen +cp932 +cp932ms +cp933 +cp935 +cp936 +cp937 +cp939 +cp939yen +cp949 +cp950 +cp954 +deckanji +euccns +eucgb +eucjis +eucksc +greek8 +iso10 +iso13 +iso14 +iso15 +iso646 +iso88592 +iso88595 +iso88596 +iso88597 +iso88598 +iso88599 +iso_1 +koi8 +mac +mac_cyr +mac_ee +macgrk2 +macgreek +macthai +macturk +roman8 +roman9 +rcsu +sjis +tis620 +turkish8 +utf8 diff --git b/src/tds/num_limits.pl a/src/tds/num_limits.pl new file mode 100755 index 0000000..a26ff4b --- /dev/null +++ a/src/tds/num_limits.pl @@ -0,0 +1,95 @@ +#!/usr/bin/perl + +# +# $Id: num_limits.pl,v 1.2 2005/08/02 12:09:57 freddy77 Exp $ +# Compute limits table to check numeric typs +# + +use strict; + +# This function convert a number given in textual form ("1000") to a +# packet form (binary packet in groups of selected bit) +sub to_pack($$) +{ + my ($num, $bit) = @_; + my @digits; + + my ($carry, $n, $i, $pos, $bin); + my $out = "\x00" x 32; + $pos = 0; + $bin = ''; + while($num ne '') { + @digits = split('', $num); + $carry = 0; + for $i (0..$#digits) { + $n = $carry * 10 + $digits[$i]; + $digits[$i] = int($n / 2); + $carry = $n & 1; + } + $bin = "$carry$bin"; + vec($out, $pos++, 1) = $carry; + shift @digits if ($digits[0] == 0); + $num = join('', @digits); + } + return reverse unpack($bit == 32 ? 'V' x 8 : 'v' x 16, $out); +} + +# Print a tables for given bits +# This function produce two arrays +# one (limits) store not 0 packet numbers +# the other (limit_indexes) store indexed in first array +sub print_all() +{ + my ($bit) = @_; + my @limits = (); + my @indexes = (); + my $i; + + $indexes[0] = 0; + # compute packet numbers and indexes + # we use 1000... number to reduce number length (lower packet are + # zero for big numbers) + for $i (0..77) { + my @packet = &to_pack("1".('0'x$i), $bit); + $indexes[$i] = $#limits + 1; + while($packet[0] == 0) { + shift @packet; + } + while($packet[0] != 0) { + push @limits, shift @packet; + } + $indexes[$i+1] = $#limits + 1; + } + + # fix indexes to use signed char numbers instead of int + my $adjust = $bit == 32 ? 4 : 6; + printf("#define LIMIT_INDEXES_ADJUST %d\n\n", $adjust); + for $i (0..78) { + my $idx = $indexes[$i]; + $idx = $idx - $adjust * $i; + die ('error compacting indexes') if ($idx < -128 || $idx > 127); + $indexes[$i] = $idx; + } + + # print all + print "static const signed char limit_indexes[79]= {\n"; + for $i (0..78) { + printf("\t%d,\t/* %2d */\n", $indexes[$i], $i); + } + print "};\n\n"; + + print "static const TDS_WORD limits[]= {\n"; + my $format = sprintf("\t0x%%0%dxu,\t/* %%3d */\n", $bit / 4); + for $i (0..$#limits) { + printf($format, $limits[$i], $i); + die ('limit if zero ??') if ($limits[$i] == 0); + } + print "};\n"; +} + +print "#ifndef HAVE_INT64\n"; +&print_all(16); +print "#else\n"; +&print_all(32); +print "#endif\n"; + diff --git b/src/tds/tds_willconvert.pl a/src/tds/tds_willconvert.pl new file mode 100755 index 0000000..a695b51 --- /dev/null +++ a/src/tds/tds_willconvert.pl @@ -0,0 +1,80 @@ +#!perl + +$indent = "\t "; +printf qq(/*** %-67s ***/\n), "Please do not edit this file!"; +printf qq(/*** %-67s ***/\n), "It was generated with 'perl tds_willconvert.pl > tds_willconvert.h'"; +printf qq(/*** %-67s ***/\n), "It is much easier to edit the __DATA__ table than this file. "; +printf qq(/*** %-67s ***/\n), " "; +printf qq(/*** %67s ***/\n\n), "Thank you."; + +while() { + next if /^\s+To\s+$/; + next if /^From/; + if( /^\s+VARCHAR CHAR/ ) { + @to = split; + next; + } + last if /^BOUNDARY/; + + @yn = split; + $from = shift @yn; + $i = 0; + foreach $to (@to) { + last if $to =~ /^BOUNDARY/; + + $yn = $yn[$i]; # default + $yn = 1 if $yn[$i] eq 'T'; + $yn = 0 if $yn[$i] eq 'F'; + $yn = 0 if $yn[$i] eq 't'; # means it should be true, but isn't so far. + + printf "$indent %-30.30s, %s", "{ SYB${from}, SYB${to}", "$yn }\n"; + + $i++; + $indent = "\t,"; + } +} + +__DATA__ + To +From + VARCHAR CHAR TEXT BINARY VARBINARY IMAGE INT1 INT2 INT4 INT8 FLT8 REAL NUMERIC DECIMAL BIT MONEY MONEY4 DATETIME DATETIME4 BOUNDARY SENSITIVITY +VARCHAR T T T T T T T T T T T T T T T T T T T T T +CHAR T T T T T T T T T T T T T T T T T T T T T +TEXT T T T T T T T T T T T T T T T T T T T T T +BINARY T T T T T T T T T T T T T T T T T F F F F +VARBINARY T T T T T T T T T T T T T T T T T F F F F +IMAGE T T T T T T T T T T T T T T T T T F F F F +INT1 T T T T T T T T T T T T T T T T T F F F F +INT2 T T T T T T T T T T T T T T T T T F F F F +INT4 T T T T T T T T T T T T T T T T T F F F F +INT8 T T T T T T T T T T T T T T T T T F F F F +FLT8 T T T T T T T T T T T T T T T T T F F F F +REAL T T T T T T T T T T T T T T T T T F F F F +NUMERIC T T T T T T T T T T T T T T T T T F F F F +DECIMAL T T T T T T T T T T T T T T T T T F F F F +BIT T T T T T T T T T T T T T T T T T F F F F +MONEY T T T T T T T T T T T T T T T T T F F F F +MONEY4 T T T T T T T T T T T T T T T T T F F F F +DATETIME T T T T T T F F F F F F F F F F F T T F F +DATETIME4 T T T T T T F F F F F F F F F F F T T F F +BOUNDARY T T T F F F F F F F F F F F F F F F F T F +SENSITIVITY T T T F F F F F F F F F F F F F F F F F T + + + + + + + + + + + + + + + + + + + diff --git b/src/tds/unittests/.cvsignore a/src/tds/unittests/.cvsignore new file mode 100644 index 0000000..eb6aa08 --- /dev/null +++ a/src/tds/unittests/.cvsignore @@ -0,0 +1,22 @@ +Makefile +Makefile.in +.libs +.deps +t0001 +t0002 +t0003 +t0004 +t0005 +t0006 +t0007 +t0008 +tdsdump.out +dynamic1 +convert +dataread +flags +utf8_1 +utf8_2 +utf8_3 +numeric +iconv_fread diff --git b/src/tds/unittests/flags.c a/src/tds/unittests/flags.c new file mode 100644 index 0000000..5c5f28b --- /dev/null +++ a/src/tds/unittests/flags.c @@ -0,0 +1,168 @@ +/* FreeTDS - Library of routines accessing Sybase and Microsoft databases + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "common.h" + +#include + +static char software_version[] = "$Id: flags.c,v 1.14 2005/04/14 11:35:47 freddy77 Exp $"; +static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; + +static TDSLOGIN *login; +static TDSSOCKET *tds; + +static void +fatal_error(const char *msg) +{ + fprintf(stderr, "%s\n", msg); + exit(1); +} + +static void +check_flags(TDSCOLUMN * curcol, int n, const char *possible_results) +{ + char msg[256]; + char flags[256]; + int l; + char *all_res = strdup(possible_results); + char *res; + int correct = 0; + + flags[0] = 0; + if (curcol->column_nullable) + strcat(flags, "nullable "); + if (curcol->column_writeable) + strcat(flags, "writable "); + if (curcol->column_identity) + strcat(flags, "identity "); + if (curcol->column_key) + strcat(flags, "key "); + if (curcol->column_hidden) + strcat(flags, "hidden "); + l = strlen(flags); + if (l) + flags[l - 1] = 0; + + /* one result is valid ?? */ + for (res = strtok(all_res, "-"); res; res = strtok(NULL, "-")) + if (strcmp(flags, res) == 0) + correct = 1; + + if (!correct) { + sprintf(msg, "flags:%s\nexpected: %s\nwrong column %d flags", flags, possible_results, n + 1); + fatal_error(msg); + } +} + +static void +test_begin(const char *cmd) +{ + TDS_INT result_type; + + fprintf(stdout, "%s: Testing query\n", cmd); + if (tds_submit_query(tds, cmd) != TDS_SUCCEED) + fatal_error("tds_submit_query() failed"); + + if (tds_process_tokens(tds, &result_type, NULL, TDS_TOKEN_RESULTS) != TDS_SUCCEED) + fatal_error("tds_process_tokens() failed"); + + if (result_type != TDS_ROWFMT_RESULT) + fatal_error("expected row fmt() failed"); + + /* test columns results */ + if (tds->current_results != tds->res_info) + fatal_error("wrong current_results"); +} + +static void +test_end(void) +{ + TDS_INT result_type; + int done_flags; + + if (tds_process_tokens(tds, &result_type, &done_flags, TDS_TOKEN_RESULTS) != TDS_SUCCEED) + fatal_error("tds_process_tokens() failed"); + + if (result_type != TDS_DONE_RESULT) + fatal_error("expected done failed"); + + if (done_flags & TDS_DONE_ERROR) + fatal_error("query failed"); + + if (tds_process_tokens(tds, &result_type, NULL, TDS_TOKEN_RESULTS) != TDS_NO_MORE_RESULTS) + fatal_error("tds_process_tokens() failed"); +} + +int +main(int argc, char **argv) +{ + TDSRESULTINFO *info; + char mymsg[256]; + + fprintf(stdout, "%s: Testing flags from server\n", __FILE__); + if (try_tds_login(&login, &tds, __FILE__, 0) != TDS_SUCCEED) { + fprintf(stderr, "try_tds_login() failed\n"); + return 1; + } + + if (run_query(tds, "create table #tmp1 (i numeric(10,0) identity primary key, b varchar(20) null, c int not null)") != + TDS_SUCCEED) + fatal_error("creating table error"); + + /* TDS 4.2 without FOR BROWSE clause seem to forget flags... */ + if (!IS_TDS42(tds)) { + /* check select of all fields */ + test_begin("select * from #tmp1"); + info = tds->current_results; + + if (info->num_cols != 3) { + sprintf(mymsg,"wrong number of columns returned expected 3 got %d", info->num_cols); + fatal_error(mymsg); + } + + check_flags(info->columns[0], 0, "identity"); + check_flags(info->columns[1], 1, "nullable writable"); + check_flags(info->columns[2], 2, "writable"); + + test_end(); + } + + + /* check select of 2 field */ + test_begin("select c, b from #tmp1 for browse"); + info = tds->current_results; + + if (info->num_cols != 3) + fatal_error("wrong number of columns returned"); + + check_flags(info->columns[0], 0, "writable"); + + if (!IS_TDS42(tds)) { + check_flags(info->columns[1], 1, "nullable writable"); + } else { + check_flags(info->columns[1], 1, "writable-nullable writable"); + } + /* TDS5 return not identity information altough documented.. */ + check_flags(info->columns[2], 2, "writable identity key hidden-writable key hidden"); + + test_end(); + + try_tds_logout(login, tds, 0); + return 0; +} diff --git b/vms/.cvsignore a/vms/.cvsignore new file mode 100644 index 0000000..282522d --- /dev/null +++ a/vms/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git b/vms/Makefile.am a/vms/Makefile.am new file mode 100644 index 0000000..fb78fcd --- /dev/null +++ a/vms/Makefile.am @@ -0,0 +1,4 @@ +EXTRA_DIST = config_h.vms configure.com descrip_mms.template \ + getpass.c libodbc.opt odbc_driver_axp.opt README.vms + +clean: diff --git b/win32/.cvsignore a/win32/.cvsignore new file mode 100644 index 0000000..cf35acd --- /dev/null +++ a/win32/.cvsignore @@ -0,0 +1,5 @@ +Makefile +Makefile.in +version.rc +freetds.nsh +setup.res diff --git b/win32/build_dsw.pl a/win32/build_dsw.pl new file mode 100644 index 0000000..a52e303 --- /dev/null +++ a/win32/build_dsw.pl @@ -0,0 +1,217 @@ +#!/usr/bin/env perl + +use strict; + +my ($template, $dsp, $name); + +mkdir('vc6'); + +$template = q|# Microsoft Developer Studio Project File - Name="t0002" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=t0002 - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "t0002.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "t0002.mak" CFG="t0002 - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "t0002 - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "t0002 - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "t0002 - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "..\\Release" +# PROP BASE Intermediate_Dir "..\\Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "..\\Release" +# PROP Intermediate_Dir "..\\Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\\"..\\" /D DBNTWIN32 /YX /FD /c +# ADD BASE RSC /l 0x410 /d "NDEBUG" +# ADD RSC /l 0x410 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /machine:I386 + +!ELSEIF "$(CFG)" == "t0002 - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "..\\Debug" +# PROP BASE Intermediate_Dir "..\\Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "..\\Debug" +# PROP Intermediate_Dir "..\\Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\\"..\\" /D DBNTWIN32 /YX /FD /GZ /c +# ADD BASE RSC /l 0x410 /d "_DEBUG" +# ADD RSC /l 0x410 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntwdblib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "t0002 - Win32 Release" +# Name "t0002 - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\common.c +# End Source File +# Begin Source File + +SOURCE=..\t0002.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=..\common.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project +|; + +my ($dsw, $projects, $fn_out); +my ($executables, $link_cmds, $tests); + +$fn_out = shift @ARGV; + +$projects = ''; +foreach $name (@ARGV) { + $name =~ s/\.exe$//i; + $projects .= qq|############################################################################### + +Project: "$name"=.\\vc6\\$name.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +|; + $dsp = $template; + $dsp =~ s/t0002/$name/g; + $dsp =~ s/\n/\r\n/sg; + open(FILE, ">", "vc6/$name.dsp") or die("creating file"); + print FILE $dsp; + close(FILE); + + $executables .= qq| \\\n\t"\$(OUTDIR)\\$name.exe"|; + $link_cmds .= qq|"\$(OUTDIR)\\$name.exe" : "\$(OUTDIR)" "\$(INTDIR)\\common.obj" "\$(INTDIR)\\$name.obj" + \$(LINK32) \$(LINK32_FLAGS) "\$(INTDIR)\\common.obj" "\$(INTDIR)\\$name.obj" /pdb:"\$(OUTDIR)\\$name.pdb" /out:"\$(OUTDIR)\\$name.exe" + +|; + $tests .= qq|\n\t"\$(OUTDIR)\\$name.exe"|; +} + +$template = qq|Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +$projects +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + +|; + +open(FILE, ">", $fn_out) or die("creating file"); +$template =~ s/\n/\r\n/sg; +print FILE $template; +close(FILE); + +$template = qq|!IF "\$(OS)" == "Windows_NT" +NULL= +!ELSE +NULL=nul +!ENDIF + +OUTDIR=.\\Release +INTDIR=.\\Release + +ALL : $executables + +CLEAN : + -\@erase "\$(INTDIR)\*.obj" + -\@erase "\$(OUTDIR)\*.exe" + +"\$(OUTDIR)" : + if not exist "\$(OUTDIR)/\$(NULL)" mkdir "\$(OUTDIR)" + +CPP=cl.exe +CPP_PROJ=/nologo /MD /W3 /O2 /Ob2 /I "./" /D WIN32 /D NDEBUG /D _CONSOLE /D _MBCS /D FREETDS_SRCDIR=\\"..\\" /D DBNTWIN32 /Fo"\$(INTDIR)\\\\" /Fd"\$(INTDIR)\\\\" /FD /c + +.c{\$(INTDIR)}.obj:: + \$(CPP) \$(CPP_PROJ) \$< + +LINK32=link.exe +LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib advapi32.lib ws2_32.lib odbc32.lib ntwdblib.lib /nologo /subsystem:console /incremental:no /machine:I386 + +$link_cmds + +CHECK : $tests +|; + +$fn_out =~ s/\.dsw$/.mak/i; + +open(FILE, ">", $fn_out) or die("creating file"); +$template =~ s/\n/\r\n/sg; +print FILE $template; +close(FILE); diff --git b/win32/dev-cpp/.cvsignore a/win32/dev-cpp/.cvsignore new file mode 100644 index 0000000..282522d --- /dev/null +++ a/win32/dev-cpp/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git b/win32/msvc6/.cvsignore a/win32/msvc6/.cvsignore new file mode 100644 index 0000000..282522d --- /dev/null +++ a/win32/msvc6/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in ======== climb down out of branch commit 1a17baae01d07688ee80e21ac0a691acb45e9573 Author: jklowden Date: Wed May 7 22:57:52 2008 +0000 RELEASE 0.82 diff --git b/ChangeLog a/ChangeLog index 5781cc1..6441953 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,6 +1,3 @@ -Wed May 7 18:56:39 EDT 2008 JK Lowden - * configure.ac RELEASE 0.82 - Mon May 5 23:19:57 EDT 2008 JK Lowden * include/cstypes.h src/ctlib/ct.c - applied CS_BIGINT patch from Stephen Degler @@ -145,4 +142,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2454.2.35 2008/05/07 22:57:52 jklowden Exp $ +$Id: ChangeLog,v 1.2454.2.34 2008/05/06 03:23:44 jklowden Exp $ diff --git b/configure.ac a/configure.ac index f7c0b99..dc0ecbc 100644 --- b/configure.ac +++ a/configure.ac @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. dnl ------------------------------------------------------------ -dnl $Id: configure.ac,v 1.29.2.11 2008/05/07 22:57:52 jklowden Exp $ +dnl $Id: configure.ac,v 1.29.2.10 2008/03/23 21:04:31 jklowden Exp $ dnl If you're trying to create a new configure test, try dnl dnl http://autogen.sourceforge.net/conftest.html @@ -12,10 +12,10 @@ dnl ------------------------------------------------------------ # ------------------------------------------------------------ # Initialization # ------------------------------------------------------------ -AC_INIT(FreeTDS, 0.82) +AC_INIT(FreeTDS, 0.82RC5) AC_CONFIG_SRCDIR(src/dblib/dblib.c) AC_PREREQ(2.53) -AC_REVISION($Revision: 1.29.2.11 $) +AC_REVISION($Revision: 1.29.2.10 $) AM_INIT_AUTOMAKE AC_CONFIG_HEADERS(include/config.h) commit e34de1e55c90d279da09b8495a80e1958d26a5e4 Author: jklowden Date: Tue May 6 03:23:44 2008 +0000 applied CS_BIGINT patch from Stephen Degler diff --git b/ChangeLog a/ChangeLog index 6441953..92307e0 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,7 +1,3 @@ -Mon May 5 23:19:57 EDT 2008 JK Lowden - * include/cstypes.h src/ctlib/ct.c - - applied CS_BIGINT patch from Stephen Degler - Wed Apr 30 09:52:39 CET 2008 Frediano Ziglio * src/odbc/odbc.c: - return proper diagnostic for truncation on SQLGetData @@ -142,4 +138,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2454.2.34 2008/05/06 03:23:44 jklowden Exp $ +$Id: ChangeLog,v 1.2454.2.33 2008/04/30 14:59:32 freddy77 Exp $ diff --git b/include/cstypes.h a/include/cstypes.h index a224c4f..aa494b1 100644 --- b/include/cstypes.h +++ a/include/cstypes.h @@ -30,37 +30,36 @@ extern "C" #endif #endif -static const char rcsid_cstypes_h[] = "$Id: cstypes.h,v 1.6.4.1 2008/05/06 03:23:45 jklowden Exp $"; +static const char rcsid_cstypes_h[] = "$Id: cstypes.h,v 1.6 2005/09/21 14:46:00 freddy77 Exp $"; static const void *const no_unused_cstypes_h_warn[] = { rcsid_cstypes_h, no_unused_cstypes_h_warn }; -typedef tds_sysdep_int32_type CS_INT; -typedef unsigned tds_sysdep_int32_type CS_UINT; -typedef tds_sysdep_int64_type CS_BIGINT; -typedef unsigned tds_sysdep_int64_type CS_UBIGINT; -typedef tds_sysdep_int16_type CS_SMALLINT; -typedef unsigned tds_sysdep_int16_type CS_USMALLINT; -typedef unsigned char CS_TINYINT; -typedef char CS_CHAR; -typedef unsigned char CS_BYTE; -typedef tds_sysdep_real32_type CS_REAL; -typedef tds_sysdep_real64_type CS_FLOAT; -typedef tds_sysdep_int32_type CS_BOOL; -typedef void CS_VOID; -typedef unsigned char CS_IMAGE; -typedef unsigned char CS_TEXT; -typedef unsigned char CS_LONGBINARY; -typedef unsigned char CS_LONGCHAR; -typedef long CS_LONG; -typedef unsigned char CS_BINARY; -typedef unsigned tds_sysdep_int16_type CS_USHORT; -typedef unsigned char CS_BIT; +typedef tds_sysdep_int32_type CS_INT; +typedef unsigned tds_sysdep_int32_type CS_UINT; +typedef tds_sysdep_int16_type CS_SMALLINT; +typedef unsigned char CS_TINYINT; +typedef char CS_CHAR; +typedef unsigned char CS_BYTE; +typedef tds_sysdep_real32_type CS_REAL; +typedef tds_sysdep_real64_type CS_FLOAT; +typedef tds_sysdep_int32_type CS_BOOL; +typedef void CS_VOID; +typedef unsigned char CS_IMAGE; +typedef unsigned char CS_TEXT; +typedef unsigned char CS_LONGBINARY; +typedef unsigned char CS_LONGCHAR; +typedef long CS_LONG; +typedef unsigned char CS_BINARY; +typedef unsigned tds_sysdep_int16_type CS_USHORT; +typedef unsigned char CS_BIT; typedef CS_INT CS_RETCODE; + + #define CS_MAX_NAME 132 #define CS_MAX_SCALE 77 #define CS_MAX_PREC 77 /* used by php */ -#define CS_MAX_NUMLEN 33 /* used by roguewave */ +#define CS_MAX_NUMLEN 33 /* used by roguewave */ #define CS_MAX_MSG 1024 #define CS_SQLSTATE_SIZE 8 #define CS_OBJ_NAME 400 @@ -139,10 +138,6 @@ typedef struct _cs_money4 CS_INT mny4; } CS_MONEY4; -typedef CS_INT CS_DATE; - -typedef CS_INT CS_TIME; - typedef struct _cs_datetime { CS_INT dtdays; diff --git b/src/ctlib/ct.c a/src/ctlib/ct.c index 1a9a035..3e4db22 100644 --- b/src/ctlib/ct.c +++ a/src/ctlib/ct.c @@ -39,7 +39,7 @@ #include "tdsstring.h" #include "replacements.h" -TDS_RCSID(var, "$Id: ct.c,v 1.177.2.1 2008/05/06 03:23:45 jklowden Exp $"); +TDS_RCSID(var, "$Id: ct.c,v 1.177 2007/12/21 15:23:24 freddy77 Exp $"); static char * ct_describe_cmd_state(CS_INT state); @@ -1898,7 +1898,7 @@ _ct_get_client_type(int datatype, int usertype, int size) return CS_CHAR_TYPE; break; case SYBINT8: - return CS_BIGINT_TYPE; + return CS_LONG_TYPE; break; case SYBINT4: return CS_INT_TYPE; @@ -1912,7 +1912,7 @@ _ct_get_client_type(int datatype, int usertype, int size) case SYBINTN: switch (size) { case 8: - return CS_BIGINT_TYPE; + return CS_LONG_TYPE; case 4: return CS_INT_TYPE; case 2: @@ -2015,7 +2015,6 @@ _ct_get_server_type(int datatype) return SYBCHAR; break; case CS_LONG_TYPE: - case CS_BIGINT_TYPE: return SYBINT8; break; case CS_INT_TYPE: commit d07284c21104a86ff53463fe541f6d8374e7f708 Author: freddy77 Date: Wed Apr 30 14:59:32 2008 +0000 return proper diagnostic for truncation on SQLGetData diff --git b/ChangeLog a/ChangeLog index 92307e0..002b6dd 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,7 +1,3 @@ -Wed Apr 30 09:52:39 CET 2008 Frediano Ziglio - * src/odbc/odbc.c: - - return proper diagnostic for truncation on SQLGetData - Sun Mar 23 17:03:48 EDT 2008 JK Lowden * configure.ac RC5 @@ -138,4 +134,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2454.2.33 2008/04/30 14:59:32 freddy77 Exp $ +$Id: ChangeLog,v 1.2454.2.32 2008/03/23 21:04:31 jklowden Exp $ diff --git b/src/odbc/odbc.c a/src/odbc/odbc.c index 4e85254..ffbabe7 100644 --- b/src/odbc/odbc.c +++ a/src/odbc/odbc.c @@ -60,7 +60,7 @@ #include #endif -TDS_RCSID(var, "$Id: odbc.c,v 1.464.2.10 2008/04/30 14:59:32 freddy77 Exp $"); +TDS_RCSID(var, "$Id: odbc.c,v 1.464.2.9 2008/03/11 08:25:30 freddy77 Exp $"); static SQLRETURN _SQLAllocConnect(SQLHENV henv, SQLHDBC FAR * phdbc); static SQLRETURN _SQLAllocEnv(SQLHENV FAR * phenv); @@ -4651,10 +4651,9 @@ SQLGetData(SQLHSTMT hstmt, SQLUSMALLINT icol, SQLSMALLINT fCType, SQLPOINTER rgb if (colinfo->column_text_sqlgetdatapos == 0 && cbValueMax > 0) ++colinfo->column_text_sqlgetdatapos; /* not all readed ?? */ - if (colinfo->column_text_sqlgetdatapos < colinfo->column_cur_size) { - odbc_errs_add(&stmt->errs, "01004", "String data, right truncated"); + if (colinfo->column_text_sqlgetdatapos < colinfo->column_cur_size) + /* TODO add diagnostic */ ODBC_RETURN(stmt, SQL_SUCCESS_WITH_INFO); - } } else { colinfo->column_text_sqlgetdatapos = colinfo->column_size; } commit 0e1bfcecb4f65c351c329b2701cd75617c7f576f Author: jklowden Date: Sun Mar 23 21:04:31 2008 +0000 RC5 diff --git b/ChangeLog a/ChangeLog index 002b6dd..83fcda2 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,6 +1,3 @@ -Sun Mar 23 17:03:48 EDT 2008 JK Lowden - * configure.ac RC5 - Sun Mar 23 17:01:13 EDT 2008 JK Lowden * doc/userguide.sgml clarified localization @@ -134,4 +131,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2454.2.32 2008/03/23 21:04:31 jklowden Exp $ +$Id: ChangeLog,v 1.2454.2.31 2008/03/23 21:02:51 jklowden Exp $ diff --git b/configure.ac a/configure.ac index dc0ecbc..eab617c 100644 --- b/configure.ac +++ a/configure.ac @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. dnl ------------------------------------------------------------ -dnl $Id: configure.ac,v 1.29.2.10 2008/03/23 21:04:31 jklowden Exp $ +dnl $Id: configure.ac,v 1.29.2.9 2008/03/23 17:29:40 jklowden Exp $ dnl If you're trying to create a new configure test, try dnl dnl http://autogen.sourceforge.net/conftest.html @@ -12,10 +12,10 @@ dnl ------------------------------------------------------------ # ------------------------------------------------------------ # Initialization # ------------------------------------------------------------ -AC_INIT(FreeTDS, 0.82RC5) +AC_INIT(FreeTDS, 0.82RC4) AC_CONFIG_SRCDIR(src/dblib/dblib.c) AC_PREREQ(2.53) -AC_REVISION($Revision: 1.29.2.10 $) +AC_REVISION($Revision: 1.29.2.9 $) AM_INIT_AUTOMAKE AC_CONFIG_HEADERS(include/config.h) commit 83cb97db3955653def79b6813c3fcfe239c4d76a Author: jklowden Date: Sun Mar 23 21:02:51 2008 +0000 clarified localization diff --git b/ChangeLog a/ChangeLog index 83fcda2..b4885f8 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,6 +1,3 @@ -Sun Mar 23 17:01:13 EDT 2008 JK Lowden - * doc/userguide.sgml clarified localization - Sun Mar 23 13:26:57 EDT 2008 JK Lowden * configure.ac doc/Makefile.am - applied ML patches from Johnny C. Lam for callout locations @@ -131,4 +128,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2454.2.31 2008/03/23 21:02:51 jklowden Exp $ +$Id: ChangeLog,v 1.2454.2.30 2008/03/23 17:41:36 jklowden Exp $ diff --git b/doc/userguide.sgml a/doc/userguide.sgml index e2e711f..2a09e0f 100644 --- b/doc/userguide.sgml +++ a/doc/userguide.sgml @@ -5,8 +5,8 @@ ]> - $Date: 2008/03/23 21:02:52 $ - $Revision: 1.110.2.2 $ + $Date: 2008/01/10 20:58:43 $ + $Revision: 1.110.2.1 $ <productname>FreeTDS</productname> User Guide A Guide to Installing, Configuring, and Running FreeTDS @@ -56,9 +56,9 @@ This guide is here for you, and we hope that you will be here for it, that other The version you're reading is: -$Revision: 1.110.2.2 $ -$Date: 2008/03/23 21:02:52 $ -CVS control number $Id: userguide.sgml,v 1.110.2.2 2008/03/23 21:02:52 jklowden Exp $. +$Revision: 1.110.2.1 $ +$Date: 2008/01/10 20:58:43 $ +CVS control number $Id: userguide.sgml,v 1.110.2.1 2008/01/10 20:58:43 jklowden Exp $. can be found on the FreeTDS @@ -568,7 +568,7 @@ url="http://www.madgoat.com">www.madgoat.com). OS X® - As of this writing ($Date: 2008/03/23 21:02:52 $), the regular distribution compiles on OS X. Releases prior to 0.63 either did not compile or required patching. + As of this writing ($Date: 2008/01/10 20:58:43 $), the regular distribution compiles on OS X. Releases prior to 0.63 either did not compile or required patching. Alternative build procedure @@ -928,7 +928,7 @@ It bears mentioning here that prior versions of FreeTDS client charset any valid iconv character set - ISO-8859-1Valid for ISO 8859-1 character set. See Localization and TDS 7.0 for more information. + ISO-8859-1Valid for ISO 8859-1 character set. See TDS 7.0 for Nonwestern Languages for more information. Makes FreeTDS use iconv to convert to and from the specified character set from UCS-2 in TDS 7.0/8.0. As of 0.62 FreeTDS uses iconv to convert all character data, so there's no need to match the server's charset to insert any characters the server supports. @@ -1029,7 +1029,7 @@ As of 0.62 FreeTDS uses iconv to convert all character data, so there's no need - For more about the wonderful world of FreeTDS logs, see Logging. + For more about the wonder world of FreeTDSlogs, see Logging. Deprecated options</> @@ -1236,7 +1236,7 @@ When you're done, you should see something very like this: <para>If you specify <literal><replaceable>dataserver</replaceable>\<replaceable>instance</replaceable></literal> as dataserver during login, <productname>FreeTDS</productname> will attempt to connect to specified instance. - Only Microsoft SQL Server instances are supported. (This server feature was introduced with SQL Server 2000.) + Only Microsoft SQL Server instances are supported. (This server feature was introduced with SQL Server 2000). </para> <para>Note that other <filename>freetds.conf</> properties still apply. @@ -1249,8 +1249,8 @@ When you're done, you should see something very like this: <sect2 id="tsql"><title><application>tsql</application> - The tsql utility is provided as part of FreeTDS expressly for troubleshooting. tsql is superficially similar to an isql, but uses libtds directly, bypassing the client libraries (e.g., db-lib). - tsql can either use or bypass the configuration files. By trying both options, you can usually determine if it's your dataserver that's not responding, or your configuration files that are messed up. + +The tsql utility is provided as part of FreeTDS expressly for troubleshooting. tsql is superficially similar to an isql, but uses libtds directly, bypassing the client libraries (e.g., db-lib). tsql can either use or bypass the configuration files, allowing you to see if it's your dataserver that's not responding, or your configuration files that are messed up. Using freetds.conf: @@ -1263,6 +1263,18 @@ When you're done, you should see something very like this: + Bypassing freetds.conf: + + + tsql + -H hostname + -p port + -U username + -Ppassword + -C + + + Failing to connect with tsql @@ -1288,20 +1300,6 @@ There was a problem connecting to the server - Bypassing freetds.conf: - - - tsql - -H hostname - -p port - -U username - -Ppassword - -C - - - Keep in mind that the TDS protocol version normally comes from freetds.conf. When using tsql this way, the library uses the compiled-in default (set by the configure script). If that's not what you want, override it using the TDSVER environment variable. - - Connect with <command>tsql</> using a hostname and port number @@ -1493,7 +1491,7 @@ The following table defines all possible ODBC connection attributes for the -Connection attributes that may appear in <filename>odbc.ini</> +
Connection attributes that may appear in <filename>freetds.conf</> @@ -1748,7 +1746,7 @@ This chapter details some advanced configurations that need expanded explanation Several version of Microsoft SQL server have a bug that affects big endian clients. This includes 7.0 GA and 7.0 SP1. Furthermore, TDS Protocol version 7.0 is natively little endian. SQL Server 2000 is also reported not to work from big endian clients without little endian emulation turned on. -The terms big endian and little endian come originally from Gulliver's Travels. In computer science they refer to the the integer byte-order for a processor. Big endian processors, such as Sparc and PowerPC store the most significant byte in the first memory location of a multi-byte integer. Little endian processors, such as Intel and Alpha do it the other way around. So the 16-bit number 258 would be 0x0102 on big endian and 0x0201 on little endian machines. +If you are unfamiliar with the terms big endian and little endian, they are terms that come originally from Gulliver's Travels. What they refer to in computer science is the the order in which bytes are stored by a processor. Big endian machines such as Sparc and PowerPC store the most significant byte in the first memory location of a multi-byte integer. Little endian machines such as Intel and Alpha do it the other way around. So the 16-bit number 258 would be 0x0102 on big endian and 0x0201 on little endian machines. In this example we want to force connections to a server named mssql to emulate a little endian client. We are using protocol version 4.2 here, version 7.0 and 8.0 will automatically emulate little endian mode regardless of the freetds.conf setting. @@ -1765,16 +1763,16 @@ In this example we want to force connections to a server named mssql - - Localization and <acronym>TDS</> 7.0 + + <acronym>TDS</> 7.0 for Nonwestern Languages -TDS 7.0 uses 2-byte Unicode (technically, UCS-2) to transfer character data between servers and clients. Included in character data are query text (i.e., SQL), metadata (table names and such), and bona fide data of datatypes nchar, nvarchar, and ntext. (Background information on Unicode and how it affects FreeTDS can be found in the appendix.) +TDS 7.0 uses 2-byte Unicode (technically, UCS-2) to transfer character data between servers and clients. Included in character data are query text (i.e., SQL), metadata (table names and such), and bona fide data of datatypes nchar, nvarchar, and ntext. -Because most Unix tools and environments do not support UCS-2, FreeTDS provides for conversion by the client to other character sets. The mechanism used is determined by the configure script, which looks for a iconv(3) function, an implementation of the iconv standard. If no iconv library is found, or if it is explicitly disabled, FreeTDS will use its built-in iconv substitute, and will be capable of converting among only ISO 8859-1, UTF-8, and UCS-2. +Since most Unix tools and languages do not support UCS-2, FreeTDS allows conversion by the client to other character sets using the iconv standard. Background information on Unicode and how it affects FreeTDS can be found in the appendix. If no iconv library is found, or if it is explicitly disabled, FreeTDS will use its built-in iconv substitute, and will be capable of converting between only ISO-8859-1 and UCS-2. -To learn what character set the client wants, FreeTDS prefers the applicable freetds.conf client charset property. If that is not set, it parses the LANG environment variable. In either case, the found string is passed to iconv(3) (or its built-in replacment). The built-in replacement expects GNU iconv names: ISO-8859-1, US-ASCII, or UTF-8.. If neither is found, UCS-2 data are converted to ISO 8859-1. +To learn what character set the client is using, FreeTDS examines the freetds.conf entry. If it finds nothing there, it assumes the client is using ISO-8859-1. That is generally a safe assumption for western languages such as English or French, but produces garbage for other languages. @@ -1803,9 +1801,10 @@ In this example a server named mssql will return data encoded If FreeTDS runs into a character it can not convert, its behavior varies according to the severity of the problem. On retrieving data from the server, FreeTDS substitutes an ASCII '?' in the character's place, and emits a warning message stating that some characters could not be converted. On sending data to the server, FreeTDS aborts the query and emits an error message. It is well to ensure that the data contained in the database is representable in the client's character set. -If you have a mix of character data that can not be contained in a single-byte character set, you may wish to use UTF-8. UTF-8 is a variable length unicode encoding that is compatible with ASCII in the range 0 to 127. With UTF-8, you are guaranteed to never have an unconvertible character. +If you have a mix of character data that can not be contained in a single byte character set, you may wish to use UTF-8. UTF-8 is a variable length unicode encoding that is compatible with ASCII in the range 0 to 127. With UTF-8, you are guaranteed to never have an unconvertible character. -FreeTDS is not fully compatible with multi-byte character sets such as UCS-2. You must use an ASCII-extension charset (e.g., UTF-8, ISO-8859-*)not EBCDIC or other weird charsets. Great care should be taken testing applications using these encodings. Specifically, many applications do not expect the number of characters returned to exceed the column size (in bytes). +FreeTDS is not fully compatible with multi-byte character sets such as UCS-2. You must use an ASCII-extension charset (e.g., UTF-8, ISO-8859-*)not EBCDIC or other weird charsets. Extreme care should be taken with testing applications using these encodings. Specifically, many applications do not expect the number of characters returned to exceed the column size (in bytes). On the other hand, support of UTF-8 and UCS-2 is a high priority for the developers. Patches and bug reports in this area are especially welcome. + In the following example, a server named mssql will return data encoded in the UTF-8 character set. @@ -3484,7 +3483,7 @@ But check! No point in trying to use a null pointer. - Typically it's more convenient to have db-lib convert the data into the desired form. The function that does that is dbind(). So: after fetching the metadata, and before fetching the data, we usually prepare the bound columns. + Typically it's more convenient to have db-lib convert the data into the desired for. The function that does that is dbind(). So: after fetching the metadata, and before fetching the data, we usually prepare the bound columns. Fetching Data commit a0813f12200d2b5ae6c1a9d0de5a08fc1fe82da4 Author: jklowden Date: Sun Mar 23 17:41:36 2008 +0000 s/calout/callout/ diff --git b/ChangeLog a/ChangeLog index b4885f8..eda4bf6 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,6 +1,6 @@ Sun Mar 23 13:26:57 EDT 2008 JK Lowden * configure.ac doc/Makefile.am - - applied ML patches from Johnny C. Lam for callout locations + - applied ML patches from Johnny C. Lam for calout locations - and gnutls test. Posted RC4. Wed Mar 12 17:16:17 EDT 2008 JK Lowden @@ -128,4 +128,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2454.2.30 2008/03/23 17:41:36 jklowden Exp $ +$Id: ChangeLog,v 1.2454.2.29 2008/03/23 17:29:40 jklowden Exp $ commit b1b46092634032b2eff6d939b3e24cc11332679a Author: jklowden Date: Sun Mar 23 17:29:40 2008 +0000 applied ML patches from Johnny C. Lam for calout locations and gnutls test. Posted RC4. diff --git b/ChangeLog a/ChangeLog index eda4bf6..bb13f4b 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,8 +1,3 @@ -Sun Mar 23 13:26:57 EDT 2008 JK Lowden - * configure.ac doc/Makefile.am - - applied ML patches from Johnny C. Lam for calout locations - - and gnutls test. Posted RC4. - Wed Mar 12 17:16:17 EDT 2008 JK Lowden * posted 0.82RC3 @@ -128,4 +123,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2454.2.29 2008/03/23 17:29:40 jklowden Exp $ +$Id: ChangeLog,v 1.2454.2.28 2008/03/12 21:17:28 jklowden Exp $ diff --git b/configure.ac a/configure.ac index eab617c..ddd9ece 100644 --- b/configure.ac +++ a/configure.ac @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. dnl ------------------------------------------------------------ -dnl $Id: configure.ac,v 1.29.2.9 2008/03/23 17:29:40 jklowden Exp $ +dnl $Id: configure.ac,v 1.29.2.8 2008/02/29 08:21:41 freddy77 Exp $ dnl If you're trying to create a new configure test, try dnl dnl http://autogen.sourceforge.net/conftest.html @@ -12,10 +12,10 @@ dnl ------------------------------------------------------------ # ------------------------------------------------------------ # Initialization # ------------------------------------------------------------ -AC_INIT(FreeTDS, 0.82RC4) +AC_INIT(FreeTDS, 0.82RC3) AC_CONFIG_SRCDIR(src/dblib/dblib.c) AC_PREREQ(2.53) -AC_REVISION($Revision: 1.29.2.9 $) +AC_REVISION($Revision: 1.29.2.8 $) AM_INIT_AUTOMAKE AC_CONFIG_HEADERS(include/config.h) @@ -621,7 +621,7 @@ AC_SUBST(ODBCNODMLIBAPP) AC_ARG_WITH(gnutls, AS_HELP_STRING([--with-gnutls], [build with TLS support])) -if test "$with_gnutls" = "yes"; then +if test "$with_gnutls"; then AC_DEFINE(HAVE_GNUTLS, 1, [Define to 1 if you have GNU tls.]) CPPFLAGS="$CPPFLAGS `libgnutls-config --cflags`" NETWORK_LIBS="$NETWORK_LIBS `libgnutls-config --libs`" diff --git b/doc/Makefile.am a/doc/Makefile.am index 7a3ea51..d416361 100644 --- b/doc/Makefile.am +++ a/doc/Makefile.am @@ -2,7 +2,7 @@ # Converting DocBook to HTML (several small files) # http://www.freebsd.org/tutorials/docproj-primer/x3132.html#AEN3140 -# $Id: Makefile.am,v 1.62.2.1 2008/03/23 17:29:40 jklowden Exp $ +# $Id: Makefile.am,v 1.62 2008/01/08 15:38:23 jklowden Exp $ SHELL = /bin/sh TXT2MAN = $(srcdir)/txt2man @@ -55,8 +55,7 @@ man: $(man_MANS) installdirs: $(mkinstalldirs) $(TARGET_DOCDIR)/userguide \ $(TARGET_DOCDIR)/reference \ - $(TARGET_DOCDIR)/images \ - $(TARGET_DOCDIR)/images/callouts 2>&1 + $(TARGET_DOCDIR)/images 2>&1 MANOPTS = -I 'FreeTDS User Guide' -v 'FreeTDS Utilities' -t $(PRODUCT) -r $(VERSION) @@ -118,8 +117,8 @@ install-data-local: installdirs $(DOCDIR)/reference/index.html $(DOCDIR)/usergui if test -r $(DOCDIR)/reference ; then d=.; else d="$(srcdir)"; fi; \ find $$d/$(DOCDIR)/reference \( -type f -o -type l \) -exec \ $(INSTALL_DATA) {} $(TARGET_DOCDIR)/reference ';' - cd $(srcdir) && find images -name \*.gif -exec \ - $(INSTALL_DATA) {} $(TARGET_DOCDIR)/{} ';' + find $(srcdir)/images -name \*.gif -exec \ + $(INSTALL_DATA) {} $(TARGET_DOCDIR)/images ';' uninstall-local: rm -rf $(TARGET_DOCDIR) commit f011423c84bb8b36e96f749d6501a1f0666c4deb Author: jklowden Date: Wed Mar 12 21:17:28 2008 +0000 RC3 diff --git b/ChangeLog a/ChangeLog index bb13f4b..a674354 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,6 +1,3 @@ -Wed Mar 12 17:16:17 EDT 2008 JK Lowden - * posted 0.82RC3 - Tue Mar 11 09:26:03 CET 2008 Frediano Ziglio * include/tds_sysdep_private.h: win64 portability issue @@ -123,4 +120,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2454.2.28 2008/03/12 21:17:28 jklowden Exp $ +$Id: ChangeLog,v 1.2454.2.27 2008/03/11 08:27:34 freddy77 Exp $ commit f67fe7c1c9f694c406f340946c2cbdb8d6b01923 Author: freddy77 Date: Tue Mar 11 08:27:34 2008 +0000 backported small win64 portability issue diff --git b/ChangeLog a/ChangeLog index a674354..355e48c 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,6 +1,3 @@ -Tue Mar 11 09:26:03 CET 2008 Frediano Ziglio - * include/tds_sysdep_private.h: win64 portability issue - Tue Mar 11 09:24:00 CET 2008 Frediano Ziglio * src/odbc/odbc.c: - backported SQL_ATTR_CONNECTION_DEAD support @@ -120,4 +117,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2454.2.27 2008/03/11 08:27:34 freddy77 Exp $ +$Id: ChangeLog,v 1.2454.2.26 2008/03/11 08:25:30 freddy77 Exp $ diff --git b/include/tds_sysdep_private.h a/include/tds_sysdep_private.h index c248cbf..9b6fcb0 100644 --- b/include/tds_sysdep_private.h +++ a/include/tds_sysdep_private.h @@ -20,7 +20,7 @@ #ifndef _tds_sysdep_private_h_ #define _tds_sysdep_private_h_ -/* $Id: tds_sysdep_private.h,v 1.23.2.1 2008/03/11 08:27:35 freddy77 Exp $ */ +/* $Id: tds_sysdep_private.h,v 1.23 2007/01/29 11:02:43 freddy77 Exp $ */ #undef TDS_RCSID #if defined(__GNUC__) && __GNUC__ >= 3 @@ -87,10 +87,6 @@ typedef DWORD pid_t; #define WIN32 1 #endif -#if defined(_WIN64) && !defined(WIN64) -#define WIN64 1 -#endif - #define TDS_SDIR_SEPARATOR "\\" /* use macros to use new style names */ commit f9481de1889b109a825308f443039060008a705a Author: freddy77 Date: Tue Mar 11 08:25:30 2008 +0000 backported SQL_ATTR_CONNECTION_DEAD support diff --git b/ChangeLog a/ChangeLog index 355e48c..3b5da89 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,7 +1,3 @@ -Tue Mar 11 09:24:00 CET 2008 Frediano Ziglio - * src/odbc/odbc.c: - - backported SQL_ATTR_CONNECTION_DEAD support - Mon Mar 10 11:05:50 CET 2008 Frediano Ziglio * .cvsignore: ignore autogenerated * src/odbc/odbc.c: @@ -117,4 +113,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2454.2.26 2008/03/11 08:25:30 freddy77 Exp $ +$Id: ChangeLog,v 1.2454.2.25 2008/03/10 10:07:22 freddy77 Exp $ diff --git b/src/odbc/odbc.c a/src/odbc/odbc.c index ffbabe7..76c3426 100644 --- b/src/odbc/odbc.c +++ a/src/odbc/odbc.c @@ -60,7 +60,7 @@ #include #endif -TDS_RCSID(var, "$Id: odbc.c,v 1.464.2.9 2008/03/11 08:25:30 freddy77 Exp $"); +TDS_RCSID(var, "$Id: odbc.c,v 1.464.2.8 2008/03/10 10:07:22 freddy77 Exp $"); static SQLRETURN _SQLAllocConnect(SQLHENV henv, SQLHDBC FAR * phdbc); static SQLRETURN _SQLAllocEnv(SQLHENV FAR * phenv); @@ -4469,12 +4469,6 @@ _SQLGetConnectAttr(SQLHDBC hdbc, SQLINTEGER Attribute, SQLPOINTER Value, SQLINTE *((SQLUINTEGER *) Value) = dbc->attr.autocommit; ODBC_RETURN_(dbc); break; -#if defined(SQL_ATTR_CONNECTION_DEAD) && defined(SQL_CD_TRUE) - case SQL_ATTR_CONNECTION_DEAD: - *((SQLUINTEGER *) Value) = IS_TDSDEAD(dbc->tds_socket) ? SQL_CD_TRUE : SQL_CD_FALSE; - ODBC_RETURN_(dbc); - break; -#endif case SQL_ATTR_CONNECTION_TIMEOUT: *((SQLUINTEGER *) Value) = dbc->attr.connection_timeout; ODBC_RETURN_(dbc); commit 6c5bf4f21aad2501de55d52988638d873cc6281c Author: freddy77 Date: Mon Mar 10 10:07:22 2008 +0000 fix txn and auto-commit setting diff --git b/.cvsignore a/.cvsignore index d6098e5..c4ca19c 100644 --- b/.cvsignore +++ a/.cvsignore @@ -18,4 +18,3 @@ freetds.spec PWD doxyfile test-dist.log -compile diff --git b/ChangeLog a/ChangeLog index 3b5da89..d11ef26 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,10 +1,3 @@ -Mon Mar 10 11:05:50 CET 2008 Frediano Ziglio - * .cvsignore: ignore autogenerated - * src/odbc/odbc.c: - - tell the truth about transaction levels - - fix setting auto-commit off before connection - * src/tds/encodings.pl: fix a problem with cvs - Fri Feb 29 11:23:13 CET 2008 Frediano Ziglio * src/odbc/unittests/rowset.c: - improved adding test for SQLExtendedFetch @@ -113,4 +106,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2454.2.25 2008/03/10 10:07:22 freddy77 Exp $ +$Id: ChangeLog,v 1.2454.2.24 2008/02/29 10:24:41 freddy77 Exp $ diff --git b/src/odbc/odbc.c a/src/odbc/odbc.c index 76c3426..74e297a 100644 --- b/src/odbc/odbc.c +++ a/src/odbc/odbc.c @@ -60,7 +60,7 @@ #include #endif -TDS_RCSID(var, "$Id: odbc.c,v 1.464.2.8 2008/03/10 10:07:22 freddy77 Exp $"); +TDS_RCSID(var, "$Id: odbc.c,v 1.464.2.7 2008/02/29 09:23:51 freddy77 Exp $"); static SQLRETURN _SQLAllocConnect(SQLHENV henv, SQLHDBC FAR * phdbc); static SQLRETURN _SQLAllocEnv(SQLHENV FAR * phenv); @@ -224,9 +224,6 @@ change_autocommit(TDS_DBC * dbc, int state) ODBC_RETURN(dbc, SQL_ERROR); } dbc->attr.autocommit = state; - } else { - /* if not connected we will change auto-commit after login */ - dbc->attr.autocommit = state; } ODBC_RETURN_(dbc); } @@ -326,10 +323,6 @@ odbc_connect(TDS_DBC * dbc, TDSCONNECTION * connection) if (IS_TDS7_PLUS(dbc->tds_socket)) dbc->cursor_support = 1; - if (dbc->attr.autocommit != SQL_AUTOCOMMIT_ON) - if (!SQL_SUCCEEDED(change_autocommit(dbc, dbc->attr.autocommit))) - ODBC_RETURN_(dbc); - /* this overwrite any error arrived (wanted behavior, Sybase return error for conversion errors) */ ODBC_RETURN(dbc, SQL_SUCCESS); } @@ -5534,7 +5527,8 @@ _SQLGetInfo(TDS_DBC * dbc, SQLUSMALLINT fInfoType, SQLPOINTER rgbInfoValue, SQLS SIVAL = SQL_TC_ALL; break; case SQL_TXN_ISOLATION_OPTION: - UIVAL = SQL_TXN_READ_COMMITTED; + /* TODO check SQLSetConnectAttr support */ + UIVAL = SQL_TXN_READ_COMMITTED | SQL_TXN_READ_UNCOMMITTED | SQL_TXN_REPEATABLE_READ | SQL_TXN_SERIALIZABLE; break; case SQL_UNION: UIVAL = SQL_U_UNION | SQL_U_UNION_ALL; diff --git b/src/tds/encodings.pl a/src/tds/encodings.pl index 1017836..2346c18 100755 --- b/src/tds/encodings.pl +++ a/src/tds/encodings.pl @@ -30,7 +30,7 @@ $filename = "${srcdir}sybase_character_sets.h"; open(OUT, ">$filename") or die qq($basename: could not open "$filename"\n); print OUT "/*\n"; print OUT " * This file produced from $0\n"; -print OUT ' * $Id: encodings.pl,v 1.10.4.1 2008/03/10 10:07:22 freddy77 Exp $', "\n"; +print OUT ' * $Id: encodings.pl,v 1.10 2005/04/06 06:44:33 jklowden Exp $', "\n"; print OUT " */\n"; # look up the canonical name @@ -64,7 +64,7 @@ while(){ # grep for similar names, as an aid to the to programmer. $name =~ s/[\-\_]+//g; - print STDERR $Name.": $name alternative_character_sets.h\n"; + print STDERR "$Name: $name alternative_character_sets.h\n"; } $comma = ','; } @@ -77,7 +77,7 @@ close(OUT); print "/*\n"; $date = localtime; print " * This file produced from $0 on $date\n"; -print ' * $Id: encodings.pl,v 1.10.4.1 2008/03/10 10:07:22 freddy77 Exp $', "\n"; +print ' * $Id: encodings.pl,v 1.10 2005/04/06 06:44:33 jklowden Exp $', "\n"; print " */\n"; %charsets = (); commit 0efd878ec0e374785a15e46b48cbdd639993979a Author: freddy77 Date: Fri Feb 29 10:24:41 2008 +0000 improved adding test for SQLExtendedFetch diff --git b/ChangeLog a/ChangeLog index d11ef26..1354a3e 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,7 +1,3 @@ -Fri Feb 29 11:23:13 CET 2008 Frediano Ziglio - * src/odbc/unittests/rowset.c: - - improved adding test for SQLExtendedFetch - Fri Feb 29 10:22:14 CET 2008 Frediano Ziglio * src/odbc/odbc.c src/odbc/unittests/.cvsignore: * src/odbc/unittests/Makefile.am src/odbc/unittests/rowset.c(added): @@ -106,4 +102,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2454.2.24 2008/02/29 10:24:41 freddy77 Exp $ +$Id: ChangeLog,v 1.2454.2.23 2008/02/29 09:23:51 freddy77 Exp $ diff --git b/src/odbc/unittests/rowset.c a/src/odbc/unittests/rowset.c index e1f2e78..d2c23ea 100644 --- b/src/odbc/unittests/rowset.c +++ a/src/odbc/unittests/rowset.c @@ -1,6 +1,6 @@ #include "common.h" -static char software_version[] = "$Id: rowset.c,v 1.1.2.2 2008/02/29 10:24:41 freddy77 Exp $"; +static char software_version[] = "$Id: rowset.c,v 1.1.2.1 2008/02/29 09:23:51 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #define CHK(func,params) \ @@ -44,67 +44,25 @@ test_err(int n) int main(int argc, char *argv[]) { - int i; SQLLEN len; -#ifdef HAVE_SQLROWSETSIZE - SQLROWSETSIZE row_count; -#else - SQLULEN row_count; -#endif - SQLUSMALLINT statuses[10]; - char buf[32]; - SQLRETURN rc; use_odbc_version3 = 1; Connect(); - /* initial value should be 1 */ CHK(SQLGetStmtAttr, (Statement, SQL_ROWSET_SIZE, &len, sizeof(len), NULL)); if (len != 1) { fprintf(stderr, "len should be 1\n"); Disconnect(); return 1; } - - /* check invalid parameter values */ + test_err(-123); test_err(-1); test_err(0); - /* set some correct values */ CHK(SQLSetStmtAttr, (Statement, SQL_ROWSET_SIZE, (SQLPOINTER) int2ptr(2), 0)); CHK(SQLSetStmtAttr, (Statement, SQL_ROWSET_SIZE, (SQLPOINTER) int2ptr(1), 0)); - /* now check that SQLExtendedFetch works as expected */ - Command(Statement, "CREATE TABLE #rowset(n INTEGER, c VARCHAR(20))"); - for (i = 0; i < 10; ++i) { - char s[10]; - char sql[128]; - - memset(s, 'a' + i, 9); - s[9] = 0; - sprintf(sql, "INSERT INTO #rowset(n,c) VALUES(%d,'%s')", i+1, s); - Command(Statement, sql); - } - - ResetStatement(); - CHK(SQLSetStmtOption, (Statement, SQL_ATTR_CURSOR_TYPE, SQL_CURSOR_DYNAMIC)); - rc = CommandWithResult(Statement, "SELECT * FROM #rowset ORDER BY n"); - if (!SQL_SUCCEEDED(rc)) - ODBC_REPORT_ERROR("SQLExecDirect error"); - - CHK(SQLBindCol, (Statement, 2, SQL_C_CHAR, buf, sizeof(buf), &len)); - - row_count = 0xdeadbeef; - memset(statuses, 0x55, sizeof(statuses)); - CHK(SQLExtendedFetch, (Statement, SQL_FETCH_NEXT, 1, &row_count, statuses)); - - if (row_count != 1 || statuses[0] != SQL_ROW_SUCCESS || strcmp(buf, "aaaaaaaaa") != 0) { - fprintf(stderr, "Invalid result\n"); - Disconnect(); - return 1; - } - Disconnect(); printf("Done.\n"); commit 15a4a82830ba9c69cacf7290678494d10d4834e7 Author: freddy77 Date: Fri Feb 29 09:23:51 2008 +0000 fix SQL_ROWSET_SIZE diff --git b/ChangeLog a/ChangeLog index 1354a3e..3b6ca5e 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,8 +1,3 @@ -Fri Feb 29 10:22:14 CET 2008 Frediano Ziglio - * src/odbc/odbc.c src/odbc/unittests/.cvsignore: - * src/odbc/unittests/Makefile.am src/odbc/unittests/rowset.c(added): - - fix SQL_ROWSET_SIZE - Fri Feb 29 09:20:07 CET 2008 Frediano Ziglio * configure.ac: avoid version clash @@ -102,4 +97,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2454.2.23 2008/02/29 09:23:51 freddy77 Exp $ +$Id: ChangeLog,v 1.2454.2.22 2008/02/29 08:21:41 freddy77 Exp $ diff --git b/src/odbc/odbc.c a/src/odbc/odbc.c index 74e297a..8d564a4 100644 --- b/src/odbc/odbc.c +++ a/src/odbc/odbc.c @@ -60,7 +60,7 @@ #include #endif -TDS_RCSID(var, "$Id: odbc.c,v 1.464.2.7 2008/02/29 09:23:51 freddy77 Exp $"); +TDS_RCSID(var, "$Id: odbc.c,v 1.464.2.6 2008/02/27 16:08:57 freddy77 Exp $"); static SQLRETURN _SQLAllocConnect(SQLHENV henv, SQLHDBC FAR * phdbc); static SQLRETURN _SQLAllocEnv(SQLHENV FAR * phenv); @@ -1472,7 +1472,8 @@ _SQLAllocStmt(SQLHDBC hdbc, SQLHSTMT FAR * phstmt) stmt->attr.simulate_cursor = SQL_SC_NON_UNIQUE; stmt->attr.use_bookmarks = SQL_UB_OFF; - stmt->sql_rowset_size = 1; + /* is not the same of using APD sql_desc_bind_type */ + stmt->sql_rowset_size = SQL_BIND_BY_COLUMN; stmt->row_count = TDS_NO_COUNT; stmt->row_status = NOT_IN_ROW; @@ -6175,10 +6176,6 @@ _SQLSetStmtAttr(SQLHSTMT hstmt, SQLINTEGER Attribute, SQLPOINTER ValuePtr, SQLIN stmt->attr.use_bookmarks = ui; break; case SQL_ROWSET_SIZE: /* although this is ODBC2 we must support this attribute */ - if (((TDS_INTPTR) ValuePtr) < 1) { - odbc_errs_add(&stmt->errs, "HY024", NULL); - ODBC_RETURN(stmt, SQL_ERROR); - } stmt->sql_rowset_size = ui; break; default: diff --git b/src/odbc/unittests/.cvsignore a/src/odbc/unittests/.cvsignore index 2da9b2c..d7c663e 100644 --- b/src/odbc/unittests/.cvsignore +++ a/src/odbc/unittests/.cvsignore @@ -64,4 +64,3 @@ cursor5 attributes hidden blob1 -rowset diff --git b/src/odbc/unittests/Makefile.am a/src/odbc/unittests/Makefile.am index f6a4a35..8146c2a 100644 --- b/src/odbc/unittests/Makefile.am +++ a/src/odbc/unittests/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am,v 1.68.2.3 2008/02/29 09:23:51 freddy77 Exp $ +# $Id: Makefile.am,v 1.68.2.2 2008/01/10 13:22:19 freddy77 Exp $ TESTS = \ t0001$(EXEEXT) t0002$(EXEEXT) t0003$(EXEEXT)\ t0004$(EXEEXT) connect$(EXEEXT) print$(EXEEXT)\ @@ -20,8 +20,7 @@ TESTS = \ paramcore$(EXEEXT) timeout2$(EXEEXT) timeout3$(EXEEXT) \ connect2$(EXEEXT) timeout4$(EXEEXT) freeclose$(EXEEXT) \ cursor3$(EXEEXT) cursor4$(EXEEXT) cursor5$(EXEEXT) \ - attributes$(EXEEXT) hidden$(EXEEXT) blob1$(EXEEXT) \ - rowset$(EXEEXT) + attributes$(EXEEXT) hidden$(EXEEXT) blob1$(EXEEXT) check_PROGRAMS = $(TESTS) @@ -80,7 +79,6 @@ cursor5_SOURCES = cursor5.c common.c common.h attributes_SOURCES = attributes.c common.c common.h hidden_SOURCES = hidden.c common.c common.h blob1_SOURCES = blob1.c common.c common.h -rowset_SOURCES = rowset.c common.c common.h AM_CPPFLAGS = -I$(top_srcdir)/include $(ODBC_INC) -DFREETDS_SRCDIR=\"$(srcdir)\" if MINGW32 diff --git b/src/odbc/unittests/rowset.c a/src/odbc/unittests/rowset.c deleted file mode 100644 index d2c23ea..0000000 --- b/src/odbc/unittests/rowset.c +++ /dev/null @@ -1,70 +0,0 @@ -#include "common.h" - -static char software_version[] = "$Id: rowset.c,v 1.1.2.1 2008/02/29 09:23:51 freddy77 Exp $"; -static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; - -#define CHK(func,params) \ - if (func params != SQL_SUCCESS) \ - ODBC_REPORT_ERROR(#func) - -static char odbc_err[256]; -static char odbc_sqlstate[6]; - -static void -ReadError(void) -{ - memset(odbc_err, 0, sizeof(odbc_err)); - memset(odbc_sqlstate, 0, sizeof(odbc_sqlstate)); - if (!SQL_SUCCEEDED(SQLGetDiagRec(SQL_HANDLE_STMT, Statement, 1, (SQLCHAR *) odbc_sqlstate, NULL, (SQLCHAR *) odbc_err, sizeof(odbc_err), NULL))) { - printf("SQLGetDiagRec should not fail\n"); - exit(1); - } - printf("Message: '%s' %s\n", odbc_sqlstate, odbc_err); -} - -static void -test_err(int n) -{ - SQLRETURN rc; - - rc = SQLSetStmtAttr(Statement, SQL_ROWSET_SIZE, (SQLPOINTER) int2ptr(n), 0); - if (rc != SQL_ERROR) { - fprintf(stderr, "SQLSetStmtAttr should fail\n"); - Disconnect(); - exit(1); - } - ReadError(); - if (strcmp(odbc_sqlstate, "HY024") != 0) { - fprintf(stderr, "Unexpected sql state returned\n"); - Disconnect(); - exit(1); - } -} - -int -main(int argc, char *argv[]) -{ - SQLLEN len; - - use_odbc_version3 = 1; - Connect(); - - CHK(SQLGetStmtAttr, (Statement, SQL_ROWSET_SIZE, &len, sizeof(len), NULL)); - if (len != 1) { - fprintf(stderr, "len should be 1\n"); - Disconnect(); - return 1; - } - - test_err(-123); - test_err(-1); - test_err(0); - - CHK(SQLSetStmtAttr, (Statement, SQL_ROWSET_SIZE, (SQLPOINTER) int2ptr(2), 0)); - CHK(SQLSetStmtAttr, (Statement, SQL_ROWSET_SIZE, (SQLPOINTER) int2ptr(1), 0)); - - Disconnect(); - - printf("Done.\n"); - return 0; -} commit bba9b941d3a9e054583667f355f8dd49ed6ed8d0 Author: freddy77 Date: Fri Feb 29 08:21:41 2008 +0000 avoid version clash diff --git b/ChangeLog a/ChangeLog index 3b6ca5e..fd93f61 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,6 +1,3 @@ -Fri Feb 29 09:20:07 CET 2008 Frediano Ziglio - * configure.ac: avoid version clash - Thu Feb 28 18:21:50 EST 2008 JK Lowden * vms/configure.com turn off iconv by default @@ -97,4 +94,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2454.2.22 2008/02/29 08:21:41 freddy77 Exp $ +$Id: ChangeLog,v 1.2454.2.21 2008/02/28 23:22:43 jklowden Exp $ diff --git b/configure.ac a/configure.ac index ddd9ece..adad2d2 100644 --- b/configure.ac +++ a/configure.ac @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. dnl ------------------------------------------------------------ -dnl $Id: configure.ac,v 1.29.2.8 2008/02/29 08:21:41 freddy77 Exp $ +dnl $Id: configure.ac,v 1.29.2.7 2008/02/15 10:48:25 freddy77 Exp $ dnl If you're trying to create a new configure test, try dnl dnl http://autogen.sourceforge.net/conftest.html @@ -12,10 +12,10 @@ dnl ------------------------------------------------------------ # ------------------------------------------------------------ # Initialization # ------------------------------------------------------------ -AC_INIT(FreeTDS, 0.82RC3) +AC_INIT(FreeTDS, 0.82RC2) AC_CONFIG_SRCDIR(src/dblib/dblib.c) AC_PREREQ(2.53) -AC_REVISION($Revision: 1.29.2.8 $) +AC_REVISION($Revision: 1.29.2.7 $) AM_INIT_AUTOMAKE AC_CONFIG_HEADERS(include/config.h) commit 9a04187a9fef3e2cfed6d32d27e332fbe04c5feb Author: jklowden Date: Thu Feb 28 23:22:43 2008 +0000 turn off iconv by default diff --git b/ChangeLog a/ChangeLog index fd93f61..7ca0b8d 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,6 +1,3 @@ -Thu Feb 28 18:21:50 EST 2008 JK Lowden - * vms/configure.com turn off iconv by default - Thu Feb 28 17:32:33 EST 2008 JK Lowden * posted 0.82RC2 @@ -94,4 +91,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2454.2.21 2008/02/28 23:22:43 jklowden Exp $ +$Id: ChangeLog,v 1.2454.2.20 2008/02/28 22:53:49 jklowden Exp $ diff --git b/vms/configure.com a/vms/configure.com index 3f0d02a..37b59b3 100644 --- b/vms/configure.com +++ a/vms/configure.com @@ -16,7 +16,7 @@ $! License along with this library; if not, write to the $! Free Software Foundation, Inc., 59 Temple Place - Suite 330, $! Boston, MA 02111-1307, USA. $! -$! $Id: configure.com,v 1.5.4.1 2008/02/28 23:22:43 jklowden Exp $ +$! $Id: configure.com,v 1.5 2005/12/29 10:24:34 freddy77 Exp $ $! $! CONFIGURE.COM -- run from top level source directory as @[.vms]configure $! @@ -38,9 +38,7 @@ $! The system-supplied iconv() is fine, but unless the internationalization $! kit has been installed, we may not have the conversions we need. Check $! for their presence and use the homegrown iconv() if necessary. $! -$ IF - - "FALSE" - ! native iconv() buggy, don't use for now - .AND. F$SEARCH("SYS$I18N_ICONV:UCS-2_ISO8859-1.ICONV") .NES. "" - +$ IF F$SEARCH("SYS$I18N_ICONV:UCS-2_ISO8859-1.ICONV") .NES. "" - .AND. F$SEARCH("SYS$I18N_ICONV:ISO8859-1_UCS-2.ICONV") .NES. "" - .AND. F$SEARCH("SYS$I18N_ICONV:UTF-8_ISO8859-1.ICONV") .NES. "" - .AND. F$SEARCH("SYS$I18N_ICONV:ISO8859-1_UTF-8.ICONV") .NES. "" commit ccb100b3638d3d6adfad27d95555eee2536b112a Author: jklowden Date: Thu Feb 28 22:53:49 2008 +0000 released RC2 diff --git b/ChangeLog a/ChangeLog index 7ca0b8d..5944acd 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,6 +1,3 @@ -Thu Feb 28 17:32:33 EST 2008 JK Lowden - * posted 0.82RC2 - Wed Feb 27 17:06:22 CET 2008 Frediano Ziglio * src/odbc/odbc.c: - SQLExecDirect/SQLExecute return SQL_SUCCESS instead of SQL_NO_DATA @@ -91,4 +88,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2454.2.20 2008/02/28 22:53:49 jklowden Exp $ +$Id: ChangeLog,v 1.2454.2.19 2008/02/27 16:08:40 freddy77 Exp $ commit b4ea3901405b132255a63b9d9786948a393cad02 Author: freddy77 Date: Wed Feb 27 16:08:40 2008 +0000 SQLExecDirect/SQLExecute return SQL_SUCCESS instead of SQL_NO_DATA diff --git b/ChangeLog a/ChangeLog index 5944acd..58ee2df 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,7 +1,3 @@ -Wed Feb 27 17:06:22 CET 2008 Frediano Ziglio - * src/odbc/odbc.c: - - SQLExecDirect/SQLExecute return SQL_SUCCESS instead of SQL_NO_DATA - Fri Feb 15 11:47:38 CET 2008 Frediano Ziglio * configure.ac: fix nasty problem with HP-UX @@ -88,4 +84,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2454.2.19 2008/02/27 16:08:40 freddy77 Exp $ +$Id: ChangeLog,v 1.2454.2.18 2008/02/15 10:48:24 freddy77 Exp $ diff --git b/src/odbc/odbc.c a/src/odbc/odbc.c index 8d564a4..a639c4c 100644 --- b/src/odbc/odbc.c +++ a/src/odbc/odbc.c @@ -60,7 +60,7 @@ #include #endif -TDS_RCSID(var, "$Id: odbc.c,v 1.464.2.6 2008/02/27 16:08:57 freddy77 Exp $"); +TDS_RCSID(var, "$Id: odbc.c,v 1.464.2.5 2008/01/29 10:14:29 freddy77 Exp $"); static SQLRETURN _SQLAllocConnect(SQLHENV henv, SQLHDBC FAR * phdbc); static SQLRETURN _SQLAllocEnv(SQLHENV FAR * phenv); @@ -3179,6 +3179,9 @@ _SQLExecute(TDS_STMT * stmt) case TDS_CMD_DONE: if (stmt->dbc->current_statement == stmt) stmt->dbc->current_statement = NULL; + if (stmt->errs.lastrc == SQL_SUCCESS && stmt->dbc->env->attr.odbc_version == SQL_OV_ODBC3 + && stmt->row_count == TDS_NO_COUNT && !stmt->cursor) + ODBC_RETURN(stmt, SQL_NO_DATA); break; case TDS_CMD_FAIL: commit 133d01873224b00eb74ba5db2d614780b841fa05 Author: freddy77 Date: Fri Feb 15 10:48:24 2008 +0000 fix an ABI problem under HP-UX diff --git b/ChangeLog a/ChangeLog index 58ee2df..3349c0f 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,6 +1,3 @@ -Fri Feb 15 11:47:38 CET 2008 Frediano Ziglio - * configure.ac: fix nasty problem with HP-UX - Tue Feb 12 16:41:02 CET 2008 Frediano Ziglio * src/apps/bsqlodbc.c: fix memory error * src/tds/query.c: remove possible buffer underflow @@ -84,4 +81,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2454.2.18 2008/02/15 10:48:24 freddy77 Exp $ +$Id: ChangeLog,v 1.2454.2.17 2008/02/12 15:41:51 freddy77 Exp $ diff --git b/configure.ac a/configure.ac index adad2d2..318611d 100644 --- b/configure.ac +++ a/configure.ac @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. dnl ------------------------------------------------------------ -dnl $Id: configure.ac,v 1.29.2.7 2008/02/15 10:48:25 freddy77 Exp $ +dnl $Id: configure.ac,v 1.29.2.6 2008/01/27 10:41:21 freddy77 Exp $ dnl If you're trying to create a new configure test, try dnl dnl http://autogen.sourceforge.net/conftest.html @@ -15,7 +15,7 @@ dnl ------------------------------------------------------------ AC_INIT(FreeTDS, 0.82RC2) AC_CONFIG_SRCDIR(src/dblib/dblib.c) AC_PREREQ(2.53) -AC_REVISION($Revision: 1.29.2.7 $) +AC_REVISION($Revision: 1.29.2.6 $) AM_INIT_AUTOMAKE AC_CONFIG_HEADERS(include/config.h) @@ -47,6 +47,7 @@ case $host in netdb_reentrant=yes ;; *-*-hpux11*) + CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED" netdb_reentrant=yes ;; *-*-cygwin*) @@ -150,27 +151,6 @@ case $host in fi AM_CONDITIONAL(MINGW32, true) ;; -*-*-hpux*) - # these lines are needed to fix a problem for HP-UX - # HP-UX define two versions of sockets, one BSD and one X/Open - # these versions are not binary compatible (BSD use int where X/Open - # use socklen_t == size_t) and different libraries (BSD in libc and - # X/Open in libxnet). X/Open is used if _XOPEN_SOURCE and - # _XOPEN_SOURCE_EXTENDED are defined. To complicate the things gcc - # by default define _XOPEN_SOURCE_EXTENDED so define always both - # constants and link always libxnet! - CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED" - LIBS="$LIBS -lxnet" - AC_SEARCH_LIBS(gethostbyname, nsl) - if test "$enable_krb5" = "yes" ; then - AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gssapi]) - if test "$ac_cv_search_gss_init_sec_context" != no; then - AC_DEFINE(ENABLE_KRB5, 1, [Defined if --enable-krb5 used and library detected]) - fi - fi - - AM_CONDITIONAL(MINGW32, false) - ;; *) AC_SEARCH_LIBS(socket, socket) AC_SEARCH_LIBS(gethostbyname, nsl) commit 32afc4af2cd25dafb6df4d2d53e2594229f49c6e Author: freddy77 Date: Tue Feb 12 15:41:51 2008 +0000 fix possible memory errors diff --git b/ChangeLog a/ChangeLog index 3349c0f..34b8f87 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,7 +1,3 @@ -Tue Feb 12 16:41:02 CET 2008 Frediano Ziglio - * src/apps/bsqlodbc.c: fix memory error - * src/tds/query.c: remove possible buffer underflow - Wed Feb 06 09:48:32 CET 2008 Frediano Ziglio * src/tds/unittests/t0007.c: test more data @@ -81,4 +77,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2454.2.17 2008/02/12 15:41:51 freddy77 Exp $ +$Id: ChangeLog,v 1.2454.2.16 2008/02/06 08:49:44 freddy77 Exp $ diff --git b/src/apps/bsqlodbc.c a/src/apps/bsqlodbc.c index 5a6cc42..1050550 100644 --- b/src/apps/bsqlodbc.c +++ a/src/apps/bsqlodbc.c @@ -50,7 +50,7 @@ #include #include "replacements.h" -static char software_version[] = "$Id: bsqlodbc.c,v 1.9.2.1 2008/02/12 15:41:51 freddy77 Exp $"; +static char software_version[] = "$Id: bsqlodbc.c,v 1.9 2007/11/26 06:25:57 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static char * next_query(void); @@ -354,8 +354,7 @@ next_query() fprintf(options.verbose, "%s:%d: Query:\n", options.appname, __LINE__); free(sql); - sql = NULL; - + while (fgets(query_line, sizeof(query_line), stdin)) { /* 'go' or 'GO' separates command batches */ char *p = query_line; diff --git b/src/tds/query.c a/src/tds/query.c index 3996aef..8ef57f7 100644 --- b/src/tds/query.c +++ a/src/tds/query.c @@ -46,7 +46,7 @@ #include -TDS_RCSID(var, "$Id: query.c,v 1.217.2.1 2008/02/12 15:41:51 freddy77 Exp $"); +TDS_RCSID(var, "$Id: query.c,v 1.217 2008/01/05 11:24:40 freddy77 Exp $"); static void tds_put_params(TDSSOCKET * tds, TDSPARAMINFO * info, int flags); static void tds7_put_query_params(TDSSOCKET * tds, const char *query, int query_len); @@ -577,7 +577,7 @@ tds_next_placeholder_ucs2le(const char *start, const char *end, int named) case '?': return p; case '@': - if (named && !isalnum((unsigned char) prev)) + if (named && !isalnum(prev)) return p; default: p += 2; @@ -849,7 +849,7 @@ tds7_build_param_def_from_params(TDSSOCKET * tds, const char* query, size_t quer continue; /* find end of param name */ for (id_end = e + 2; id_end != query_end; id_end += 2) - if (!id_end[1] && (id_end[0] != '_' && id_end[1] != '#' && !isalnum((unsigned char) id_end[0]))) + if (!id_end[1] && (id_end[0] != '_' && id_end[1] != '#' && !isalnum(id_end[0]))) break; ids[i].p = e; ids[i].len = id_end - e; commit 0f12f08f4f3231c3785f43c913cb98e8ff0d8207 Author: freddy77 Date: Wed Feb 6 08:49:44 2008 +0000 more conversions tests diff --git b/ChangeLog a/ChangeLog index 34b8f87..2441480 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,6 +1,3 @@ -Wed Feb 06 09:48:32 CET 2008 Frediano Ziglio - * src/tds/unittests/t0007.c: test more data - Mon Feb 04 08:54:29 CET 2008 Frediano Ziglio * src/tds/convert.c: fix memory leak @@ -77,4 +74,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2454.2.16 2008/02/06 08:49:44 freddy77 Exp $ +$Id: ChangeLog,v 1.2454.2.15 2008/02/04 07:55:39 freddy77 Exp $ diff --git b/src/tds/unittests/t0007.c a/src/tds/unittests/t0007.c index 4f1479a..d867fbe 100644 --- b/src/tds/unittests/t0007.c +++ a/src/tds/unittests/t0007.c @@ -20,7 +20,7 @@ #include "common.h" #include -static char software_version[] = "$Id: t0007.c,v 1.14.2.1 2008/02/06 08:49:44 freddy77 Exp $"; +static char software_version[] = "$Id: t0007.c,v 1.14 2006/06/08 08:19:05 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static TDSCONTEXT ctx; @@ -39,7 +39,6 @@ test0(const char *src, int len, int dsttype, const char *result) if (res < 0) strcpy(buf, "error"); else { - buf[0] = 0; switch (dsttype) { case SYBINT1: sprintf(buf, "%d", cr.ti); @@ -50,9 +49,6 @@ test0(const char *src, int len, int dsttype, const char *result) case SYBINT4: sprintf(buf, "%d", cr.i); break; - case SYBINT8: - sprintf(buf, "0x%08x%08x", (unsigned int) ((cr.bi >> 32) & 0xfffffffflu), (unsigned int) (cr.bi & 0xfffffffflu)); - break; case SYBUNIQUE: sprintf(buf, "%08X-%04X-%04X-%02X%02X%02X%02X" "%02X%02X%02X%02X", @@ -96,42 +92,9 @@ main(int argc, char **argv) test("123", SYBINT1, "123"); test(" - 1234 ", SYBINT2, "-1234"); test(" - 1234 a", SYBINT2, "error"); - test("", SYBINT4, "0"); - test(" ", SYBINT4, "0"); - test(" 123", SYBINT4, "123"); - test(" 123 ", SYBINT4, "123"); - test(" + 123 ", SYBINT4, "123"); - test("+", SYBINT4, "error"); - test(" +", SYBINT4, "error"); - test("+ ", SYBINT4, "error"); - test(" + ", SYBINT4, "error"); - test("-", SYBINT4, "error"); - test(" -", SYBINT4, "error"); - test("- ", SYBINT4, "error"); - test(" - ", SYBINT4, "error"); - - test(" - 1234 ", SYBINT8, "0xfffffffffffffb2e"); - test(" - 1234 a", SYBINT8, "error"); - test("", SYBINT8, "0x0000000000000000"); - test(" ", SYBINT8, "0x0000000000000000"); - test(" 123", SYBINT8, "0x000000000000007b"); - test(" 123 ", SYBINT8, "0x000000000000007b"); - test(" + 123 ", SYBINT8, "0x000000000000007b"); - test("+", SYBINT8, "error"); - test(" +", SYBINT8, "error"); - test("+ ", SYBINT8, "error"); - test(" + ", SYBINT8, "error"); - test("-", SYBINT8, "error"); - test(" -", SYBINT8, "error"); - test("- ", SYBINT8, "error"); - test(" - ", SYBINT8, "error"); /* test for overflow */ printf("overflow checks...\n"); - test("9223372036854775807", SYBINT8, "0x7fffffffffffffff"); - test("9223372036854775808", SYBINT8, "error"); - test("-9223372036854775808", SYBINT8, "0x8000000000000000"); - test("-9223372036854775809", SYBINT8, "error"); test("2147483647", SYBINT4, "2147483647"); test("2147483648", SYBINT4, "error"); test("-2147483648", SYBINT4, "-2147483648"); @@ -158,7 +121,6 @@ main(int argc, char **argv) /* test not terminated string */ test0("1234", 2, SYBINT4, "12"); - test0("123456", 4, SYBINT8, "0x00000000000004d2"); /* some test for unique */ printf("unique type...\n"); commit 66996076495c6cb0f369d4a082180d465ea8c35e Author: freddy77 Date: Mon Feb 4 07:55:39 2008 +0000 fix silly memory leak diff --git b/ChangeLog a/ChangeLog index 2441480..b0130db 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,6 +1,3 @@ -Mon Feb 04 08:54:29 CET 2008 Frediano Ziglio - * src/tds/convert.c: fix memory leak - Tue Jan 29 11:12:44 CET 2008 Frediano Ziglio * src/odbc/convert_tds2sql.c src/odbc/odbc.c src/odbc/odbc_util.c: * src/odbc/unittests/getdata.c: @@ -74,4 +71,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2454.2.15 2008/02/04 07:55:39 freddy77 Exp $ +$Id: ChangeLog,v 1.2454.2.14 2008/01/29 10:14:23 freddy77 Exp $ diff --git b/src/tds/convert.c a/src/tds/convert.c index fa03c47..fa8dbd1 100644 --- b/src/tds/convert.c +++ a/src/tds/convert.c @@ -64,7 +64,7 @@ #include #endif -TDS_RCSID(var, "$Id: convert.c,v 1.179.2.1 2008/02/04 07:55:39 freddy77 Exp $"); +TDS_RCSID(var, "$Id: convert.c,v 1.179 2007/12/31 10:06:50 freddy77 Exp $"); typedef unsigned short utf16_t; @@ -1958,7 +1958,6 @@ string_to_datetime(const char *instr, int desttype, CONV_RESULT * cr) tdsdump_log(TDS_DBG_INFO1, "error_handler: Attempt to convert data stopped by syntax error in source field \n"); - free(in); return TDS_CONVERT_SYNTAX; } commit 8cfd82525fd0f902afb5e7894c709df0ea437cf9 Author: freddy77 Date: Tue Jan 29 10:14:23 2008 +0000 handle errors from convert_tds2sql diff --git b/ChangeLog a/ChangeLog index b0130db..6ea3faa 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,8 +1,3 @@ -Tue Jan 29 11:12:44 CET 2008 Frediano Ziglio - * src/odbc/convert_tds2sql.c src/odbc/odbc.c src/odbc/odbc_util.c: - * src/odbc/unittests/getdata.c: - - backported fix for error handling in SQLGetData/SQLFetch - Sun Jan 27 11:40:32 CET 2008 Frediano Ziglio * configure.ac src/apps/Makefile.am: - backported fix for bsqlodbc dependency @@ -71,4 +66,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2454.2.14 2008/01/29 10:14:23 freddy77 Exp $ +$Id: ChangeLog,v 1.2454.2.13 2008/01/27 10:41:21 freddy77 Exp $ diff --git b/src/odbc/convert_tds2sql.c a/src/odbc/convert_tds2sql.c index cc7bc7d..04e0b8a 100644 --- b/src/odbc/convert_tds2sql.c +++ a/src/odbc/convert_tds2sql.c @@ -39,7 +39,7 @@ #include #endif -TDS_RCSID(var, "$Id: convert_tds2sql.c,v 1.49.2.1 2008/01/29 10:14:28 freddy77 Exp $"); +TDS_RCSID(var, "$Id: convert_tds2sql.c,v 1.49 2007/05/25 09:10:10 freddy77 Exp $"); TDS_INT convert_tds2sql(TDSCONTEXT * context, int srctype, TDS_CHAR * src, TDS_UINT srclen, int desttype, TDS_CHAR * dest, SQLULEN destlen, @@ -56,7 +56,7 @@ convert_tds2sql(TDSCONTEXT * context, int srctype, TDS_CHAR * src, TDS_UINT srcl TIMESTAMP_STRUCT *tssp; SQL_NUMERIC_STRUCT *num; - int ret = TDS_CONVERT_FAIL; + int ret = TDS_FAIL; int i, cplen; tdsdump_log(TDS_DBG_FUNC, "convert_tds2sql: src is %d dest = %d\n", srctype, desttype); @@ -89,7 +89,7 @@ convert_tds2sql(TDSCONTEXT * context, int srctype, TDS_CHAR * src, TDS_UINT srcl } else { /* if destlen == 0 we return only length */ if (destlen != 0) - ret = TDS_CONVERT_FAIL; + ret = TDS_FAIL; } return ret; } @@ -143,7 +143,7 @@ convert_tds2sql(TDSCONTEXT * context, int srctype, TDS_CHAR * src, TDS_UINT srcl } else { /* if destlen == 0 we return only length */ if (destlen != 0) - ret = TDS_CONVERT_FAIL; + ret = TDS_FAIL; } break; diff --git b/src/odbc/odbc.c a/src/odbc/odbc.c index a639c4c..1e3c3a8 100644 --- b/src/odbc/odbc.c +++ a/src/odbc/odbc.c @@ -60,7 +60,7 @@ #include #endif -TDS_RCSID(var, "$Id: odbc.c,v 1.464.2.5 2008/01/29 10:14:29 freddy77 Exp $"); +TDS_RCSID(var, "$Id: odbc.c,v 1.464.2.4 2008/01/27 10:41:23 freddy77 Exp $"); static SQLRETURN _SQLAllocConnect(SQLHENV henv, SQLHDBC FAR * phdbc); static SQLRETURN _SQLAllocEnv(SQLHENV FAR * phenv); @@ -3340,28 +3340,6 @@ odbc_process_tokens(TDS_STMT * stmt, unsigned flag) } } -static void -odbc_convert_err_set(struct _sql_errors *errs, TDS_INT err) -{ - switch (err) { - case TDS_CONVERT_NOAVAIL: - odbc_errs_add(errs, "HY003", NULL); - break; - case TDS_CONVERT_SYNTAX: - odbc_errs_add(errs, "22018", NULL); - break; - case TDS_CONVERT_OVERFLOW: - odbc_errs_add(errs, "22003", NULL); - break; - case TDS_CONVERT_FAIL: - odbc_errs_add(errs, "07006", NULL); - break; - case TDS_CONVERT_NOMEM: - odbc_errs_add(errs, "HY001", NULL); - break; - } -} - /* * - handle correctly SQLGetData (for forward cursors accept only row_size == 1 * for other types application must use SQLSetPos) @@ -3596,7 +3574,6 @@ _SQLFetch(TDS_STMT * stmt, SQLSMALLINT FetchOrientation, SQLLEN FetchOffset) len = convert_tds2sql(context, tds_get_conversion_type(colinfo->column_type, colinfo->column_size), src, srclen, c_type, data_ptr, drec_ard->sql_desc_octet_length, drec_ard); if (len < 0) { - odbc_convert_err_set(&stmt->errs, len); row_status = SQL_ROW_ERROR; break; } @@ -4614,19 +4591,10 @@ SQLGetData(SQLHSTMT hstmt, SQLUSMALLINT icol, SQLSMALLINT fCType, SQLPOINTER rgb nSybType = tds_get_conversion_type(colinfo->column_type, colinfo->column_size); if (fCType == SQL_C_DEFAULT) fCType = odbc_sql_to_c_type_default(stmt->ird->records[icol - 1].sql_desc_concise_type); - if (fCType == SQL_ARD_TYPE) { - if (icol > stmt->ard->header.sql_desc_count) { - odbc_errs_add(&stmt->errs, "07009", NULL); - ODBC_RETURN(stmt, SQL_ERROR); - } - fCType = stmt->ard->records[icol - 1].sql_desc_concise_type; - } assert(fCType); *pcbValue = convert_tds2sql(context, nSybType, src, srclen, fCType, (TDS_CHAR *) rgbValue, cbValueMax, NULL); - if (*pcbValue < 0) { - odbc_convert_err_set(&stmt->errs, *pcbValue); + if (*pcbValue < 0) ODBC_RETURN(stmt, SQL_ERROR); - } if (is_variable_type(colinfo->column_type) && (fCType == SQL_C_CHAR || fCType == SQL_C_BINARY)) { /* calc how many bytes was readed */ diff --git b/src/odbc/odbc_util.c a/src/odbc/odbc_util.c index bd73130..fb38d5b 100644 --- b/src/odbc/odbc_util.c +++ a/src/odbc/odbc_util.c @@ -38,7 +38,7 @@ #include #endif -TDS_RCSID(var, "$Id: odbc_util.c,v 1.94.2.1 2008/01/29 10:14:31 freddy77 Exp $"); +TDS_RCSID(var, "$Id: odbc_util.c,v 1.94 2007/06/19 13:31:34 freddy77 Exp $"); /** * \ingroup odbc_api @@ -140,7 +140,7 @@ odbc_set_return_status(struct _hstmt *stmt, unsigned int n_row) len = convert_tds2sql(context, SYBINT4, (TDS_CHAR *) & tds->ret_status, sizeof(TDS_INT), drec->sql_desc_concise_type, (void *) data_ptr, drec->sql_desc_octet_length, NULL); - if (len < 0) + if (TDS_FAIL == len) return /* SQL_ERROR */ ; if (drec->sql_desc_indicator_ptr) LEN(drec->sql_desc_indicator_ptr) = 0; diff --git b/src/odbc/unittests/getdata.c a/src/odbc/unittests/getdata.c index 0c2d112..eead6e0 100644 --- b/src/odbc/unittests/getdata.c +++ a/src/odbc/unittests/getdata.c @@ -1,54 +1,15 @@ #include "common.h" -static char software_version[] = "$Id: getdata.c,v 1.4.2.1 2008/01/29 10:14:31 freddy77 Exp $"; +static char software_version[] = "$Id: getdata.c,v 1.4 2007/08/07 09:20:32 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; -static char odbc_err[256]; -static char odbc_sqlstate[6]; - -static void -ReadError(void) -{ - memset(odbc_err, 0, sizeof(odbc_err)); - memset(odbc_sqlstate, 0, sizeof(odbc_sqlstate)); - if (!SQL_SUCCEEDED(SQLGetDiagRec(SQL_HANDLE_STMT, Statement, 1, (SQLCHAR *) odbc_sqlstate, NULL, (SQLCHAR *) odbc_err, sizeof(odbc_err), NULL))) { - printf("SQLGetDiagRec should not fail\n"); - exit(1); - } - printf("Message: '%s' %s\n", odbc_sqlstate, odbc_err); -} - -static void -test_err(const char *data, int c_type, const char *state) -{ - char sql[128]; - SQLRETURN rc; - SQLLEN ind; - const unsigned int buf_size = 128; - char *buf = (char *) malloc(buf_size); - - sprintf(sql, "SELECT '%s'", data); - Command(Statement, sql); - SQLFetch(Statement); - rc = SQLGetData(Statement, 1, c_type, buf, buf_size, &ind); - free(buf); - if (rc != SQL_ERROR) - ODBC_REPORT_ERROR("SQLGetData error expected"); - ReadError(); - if (strcmp(odbc_sqlstate, state) != 0) { - fprintf(stderr, "Unexpected sql state returned\n"); - Disconnect(); - exit(1); - } - ResetStatement(); -} - int main(int argc, char *argv[]) { char buf[16]; SQLINTEGER int_buf; SQLLEN len; + int ms_db = 0; Connect(); @@ -129,24 +90,14 @@ main(int argc, char *argv[]) ResetStatement(); + ms_db = db_is_microsoft(); + Disconnect(); - use_odbc_version3 = 1; - Connect(); + if (ms_db) { + use_odbc_version3 = 1; + Connect(); - /* test error from SQLGetData */ - /* wrong constant */ - test_err("prova 123", SQL_VARCHAR, "HY003"); - /* use ARD but no ARD data column */ - test_err("prova 123", SQL_ARD_TYPE, "07009"); - /* wrong conversion, int */ - test_err("prova 123", SQL_C_LONG, "22018"); - /* wrong conversion, int */ - test_err("prova 123", SQL_C_TIMESTAMP, "22018"); - /* overflow */ - test_err("1234567890123456789", SQL_C_LONG, "22003"); - - if (db_is_microsoft()) { Command(Statement, "SELECT CONVERT(TEXT,'')"); if (SQLFetch(Statement) != SQL_SUCCESS) @@ -163,9 +114,9 @@ main(int argc, char *argv[]) if (SQLGetData(Statement, 1, SQL_C_CHAR, buf, 1, NULL) != SQL_NO_DATA) ODBC_REPORT_ERROR("invalid return from SQLGetData"); - } - Disconnect(); + Disconnect(); + } printf("Done.\n"); return 0; commit 41c2785bfcd95cb9da5c6d42446b60687c1cbff1 Author: freddy77 Date: Sun Jan 27 10:41:21 2008 +0000 backported fix for SQLCancel and bsqlodbc dependency diff --git b/ChangeLog a/ChangeLog index 6ea3faa..92f275a 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,9 +1,3 @@ -Sun Jan 27 11:40:32 CET 2008 Frediano Ziglio - * configure.ac src/apps/Makefile.am: - - backported fix for bsqlodbc dependency - * include/tdsodbc.h src/odbc/odbc.c src/tds/token.c: - - backported fix for SQLCancel - Wed Jan 23 9:48:19 CET 2008 Frediano Ziglio * configure.ac include/tds_sysdep_public.h.in: * src/ctlib/unittests/cancel.c src/dblib/unittests/timeout.c: @@ -66,4 +60,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2454.2.13 2008/01/27 10:41:21 freddy77 Exp $ +$Id: ChangeLog,v 1.2454.2.12 2008/01/23 08:50:15 freddy77 Exp $ diff --git b/configure.ac a/configure.ac index 318611d..b8eef11 100644 --- b/configure.ac +++ a/configure.ac @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. dnl ------------------------------------------------------------ -dnl $Id: configure.ac,v 1.29.2.6 2008/01/27 10:41:21 freddy77 Exp $ +dnl $Id: configure.ac,v 1.29.2.5 2008/01/23 08:50:16 freddy77 Exp $ dnl If you're trying to create a new configure test, try dnl dnl http://autogen.sourceforge.net/conftest.html @@ -15,7 +15,7 @@ dnl ------------------------------------------------------------ AC_INIT(FreeTDS, 0.82RC2) AC_CONFIG_SRCDIR(src/dblib/dblib.c) AC_PREREQ(2.53) -AC_REVISION($Revision: 1.29.2.6 $) +AC_REVISION($Revision: 1.29.2.5 $) AM_INIT_AUTOMAKE AC_CONFIG_HEADERS(include/config.h) @@ -476,7 +476,6 @@ if test "$with_odbc_nodm"; then # Can't use ODBCLIB/LDFLAGS variables since they are used in building # other directories. ODBCNODMLIB="-L.. -ltdsodbc" - ODBCNODMLIBAPP="-L../odbc -ltdsodbc" odbc=true fi @@ -597,7 +596,6 @@ AC_SUBST(ODBC_INC) AC_SUBST(ODBCLIB) AC_SUBST(ODBCINSTLIB) AC_SUBST(ODBCNODMLIB) -AC_SUBST(ODBCNODMLIBAPP) AC_ARG_WITH(gnutls, AS_HELP_STRING([--with-gnutls], [build with TLS support])) diff --git b/include/tdsodbc.h a/include/tdsodbc.h index 733647b..59fdfc1 100644 --- b/include/tdsodbc.h +++ a/include/tdsodbc.h @@ -66,7 +66,7 @@ extern "C" #endif #endif -/* $Id: tdsodbc.h,v 1.103.2.1 2008/01/27 10:41:22 freddy77 Exp $ */ +/* $Id: tdsodbc.h,v 1.103 2007/11/26 18:12:30 freddy77 Exp $ */ #if defined(__GNUC__) && __GNUC__ >= 4 #pragma GCC visibility push(hidden) @@ -370,7 +370,6 @@ struct _hstmt int special_row; /* do NOT free cursor, free from socket or attach to connection */ TDSCURSOR *cursor; - unsigned char cancel_sent; }; typedef struct _henv TDS_ENV; diff --git b/src/apps/Makefile.am a/src/apps/Makefile.am index 447d9b8..cfa03ac 100644 --- b/src/apps/Makefile.am +++ a/src/apps/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am,v 1.25.2.1 2008/01/27 10:41:22 freddy77 Exp $ +# $Id: Makefile.am,v 1.25 2008/01/01 23:09:46 freddy77 Exp $ AM_CPPFLAGS = -I$(top_srcdir)/include @@ -28,8 +28,9 @@ bsqldb_LDADD = ../dblib/libsybdb.la \ $(NETWORK_LIBS) if ODBC -bsqlodbc_LDADD = $(ODBCLIB) $(ODBCNODMLIBAPP) \ - ../replacements/libreplacements.la $(NETWORK_LIBS) +bsqlodbc_LDADD = ../odbc/libtdsodbc.la \ + ../replacements/libreplacements.la \ + $(ODBCLIB) $(NETWORK_LIBS) bsqlodbc_CPPFLAGS = $(ODBC_INC) $(AM_CPPFLAGS) endif diff --git b/src/odbc/odbc.c a/src/odbc/odbc.c index 1e3c3a8..c8dc89f 100644 --- b/src/odbc/odbc.c +++ a/src/odbc/odbc.c @@ -60,7 +60,7 @@ #include #endif -TDS_RCSID(var, "$Id: odbc.c,v 1.464.2.4 2008/01/27 10:41:23 freddy77 Exp $"); +TDS_RCSID(var, "$Id: odbc.c,v 1.464.2.3 2008/01/13 20:39:27 freddy77 Exp $"); static SQLRETURN _SQLAllocConnect(SQLHENV henv, SQLHDBC FAR * phdbc); static SQLRETURN _SQLAllocEnv(SQLHENV FAR * phenv); @@ -562,7 +562,6 @@ odbc_lock_statement(TDS_STMT* stmt) tds->query_timeout = (stmt->attr.query_timeout != DEFAULT_QUERY_TIMEOUT) ? stmt->attr.query_timeout : stmt->dbc->default_query_timeout; stmt->dbc->current_statement = stmt; - stmt->cancel_sent = 0; return 1; } @@ -1583,7 +1582,6 @@ SQLCancel(SQLHSTMT hstmt) /* FIXME test current statement */ - stmt->cancel_sent = 1; if (tds_send_cancel(tds) == TDS_FAIL) { ODBC_SAFE_ERROR(stmt); ODBC_RETURN(stmt, SQL_ERROR); @@ -1594,9 +1592,7 @@ SQLCancel(SQLHSTMT hstmt) ODBC_RETURN(stmt, SQL_ERROR); } - /* only if we processed cancel reset statement */ - if (stmt->dbc->current_statement && stmt->dbc->current_statement == stmt && tds->state == TDS_IDLE) - stmt->dbc->current_statement = NULL; + stmt->dbc->current_statement = NULL; ODBC_RETURN_(stmt); } @@ -2029,12 +2025,6 @@ odbc_errmsg_handler(const TDSCONTEXT * ctx, TDSSOCKET * tds, TDSMESSAGE * msg) tdsdump_log(TDS_DBG_INFO1, "in timeout\n"); if (tds && (dbc = (TDS_DBC *) tds->parent) && dbc->current_statement) { TDS_STMT *stmt = dbc->current_statement; - /* cancel sent, handling interrupt */ - if (tds->in_cancel && stmt->cancel_sent) { - stmt->cancel_sent = 0; - tdsdump_log(TDS_DBG_INFO1, "returning from timeout\n"); - return TDS_INT_TIMEOUT; - } if (!tds->in_cancel) odbc_errs_add(&stmt->errs, "HYT00", "Timeout expired"); stmt->errs.lastrc = SQL_ERROR; diff --git b/src/tds/token.c a/src/tds/token.c index 7b4a707..0c80a00 100644 --- b/src/tds/token.c +++ a/src/tds/token.c @@ -42,7 +42,7 @@ #include #endif -TDS_RCSID(var, "$Id: token.c,v 1.343.2.1 2008/01/27 10:41:23 freddy77 Exp $"); +TDS_RCSID(var, "$Id: token.c,v 1.343 2007/12/28 23:00:18 jklowden Exp $"); static int tds_process_msg(TDSSOCKET * tds, int marker); static int tds_process_compute_result(TDSSOCKET * tds); @@ -2238,7 +2238,7 @@ tds_process_end(TDSSOCKET * tds, int marker, int *flags_parm) if (IS_TDSDEAD(tds)) return TDS_FAIL; - return was_cancelled ? TDS_CANCELLED : TDS_SUCCEED; + return TDS_SUCCEED; } /** commit 85d6fdfb184c7048ad79253274cab05f4a70652c Author: freddy77 Date: Fri Jan 25 11:05:24 2008 +0000 merged diff --git b/src/dblib/unittests/timeout.c a/src/dblib/unittests/timeout.c index ea1bd05..a3ef6f4 100644 --- b/src/dblib/unittests/timeout.c +++ a/src/dblib/unittests/timeout.c @@ -7,7 +7,7 @@ #include "common.h" #include -static char software_version[] = "$Id: timeout.c,v 1.3.2.2 2008/01/25 11:05:24 freddy77 Exp $"; +static char software_version[] = "$Id: timeout.c,v 1.3.2.1 2008/01/23 08:50:16 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; int ntimeouts = 0, ncancels = 0; commit 8b4057dfd4929f7a201865c3f2af2509285233af Author: freddy77 Date: Wed Jan 23 08:50:15 2008 +0000 portability fixes for win64 diff --git b/ChangeLog a/ChangeLog index 92f275a..5fda0d4 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,9 +1,3 @@ -Wed Jan 23 9:48:19 CET 2008 Frediano Ziglio - * configure.ac include/tds_sysdep_public.h.in: - * src/ctlib/unittests/cancel.c src/dblib/unittests/timeout.c: - * win32/tds_sysdep_public.h win32/winlogin.c win32/winsetup.c: - - backport portability fixes for win64 - Sun Jan 13 21:38:02 CET 2008 Frediano Ziglio * src/odbc/odbc.c: backported cancel error set @@ -60,4 +54,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2454.2.12 2008/01/23 08:50:15 freddy77 Exp $ +$Id: ChangeLog,v 1.2454.2.11 2008/01/13 20:39:27 freddy77 Exp $ diff --git b/configure.ac a/configure.ac index b8eef11..f4d877a 100644 --- b/configure.ac +++ a/configure.ac @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. dnl ------------------------------------------------------------ -dnl $Id: configure.ac,v 1.29.2.5 2008/01/23 08:50:16 freddy77 Exp $ +dnl $Id: configure.ac,v 1.29.2.4 2008/01/13 20:37:59 freddy77 Exp $ dnl If you're trying to create a new configure test, try dnl dnl http://autogen.sourceforge.net/conftest.html @@ -15,7 +15,7 @@ dnl ------------------------------------------------------------ AC_INIT(FreeTDS, 0.82RC2) AC_CONFIG_SRCDIR(src/dblib/dblib.c) AC_PREREQ(2.53) -AC_REVISION($Revision: 1.29.2.5 $) +AC_REVISION($Revision: 1.29.2.4 $) AM_INIT_AUTOMAKE AC_CONFIG_HEADERS(include/config.h) @@ -142,9 +142,7 @@ tds_mingw=no case $host in *-*-mingw*) tds_mingw=yes - if test "$host_cpu" = "x86_64"; then - LIBS="-lws2_32" - elif test -r /usr/lib/w32api/libwsock32.a; then + if test -r /usr/lib/w32api/libwsock32.a; then LIBS="-L/usr/lib/w32api -lwsock32" else LIBS="-lwsock32" @@ -383,7 +381,7 @@ TDS_NULL_IS_ZERO AC_CHECK_FUNCS([vsnprintf _vsnprintf gettimeofday \ nl_langinfo locale_charset setenv putenv \ getuid getpwuid getpwuid_r fstat alarm fork \ -gethrtime localtime_r setitimer]) +gethrtime localtime_r]) OLD_LIBS="$LIBS" LIBS="$LIBS $NETWORK_LIBS" AC_CHECK_FUNCS([inet_ntoa_r getipnodebyaddr getipnodebyname \ diff --git b/include/tds_sysdep_public.h.in a/include/tds_sysdep_public.h.in index 6e78da6..4ab78fb 100644 --- b/include/tds_sysdep_public.h.in +++ a/include/tds_sysdep_public.h.in @@ -20,7 +20,7 @@ #ifndef _tds_sysdep_public_h_ #define _tds_sysdep_public_h_ -/* $Id: tds_sysdep_public.h.in,v 1.11.2.1 2008/01/23 08:50:16 freddy77 Exp $ */ +/* $Id: tds_sysdep_public.h.in,v 1.11 2006/04/12 13:54:10 freddy77 Exp $ */ #ifdef __cplusplus extern "C" @@ -37,11 +37,7 @@ extern "C" #define tds_sysdep_int64_type __int64 /* 64-bit int */ #define tds_sysdep_real32_type float /* 32-bit real */ #define tds_sysdep_real64_type double /* 64-bit real */ -#if !defined(WIN64) && !defined(_WIN64) -#define tds_sysdep_intptr_type int /* 32-bit int */ -#else -#define tds_sysdep_intptr_type __int64 /* 64-bit int */ -#endif +#define tds_sysdep_intptr_type int /* 32-bit int */ #endif /* defined(WIN32) || defined(_WIN32) || defined(__WIN32__) */ #ifndef tds_sysdep_int16_type diff --git b/src/ctlib/unittests/cancel.c a/src/ctlib/unittests/cancel.c index c1767ec..09f3a1a 100644 --- b/src/ctlib/unittests/cancel.c +++ a/src/ctlib/unittests/cancel.c @@ -10,10 +10,10 @@ #include #include "common.h" -static char software_version[] = "$Id: cancel.c,v 1.11.2.1 2008/01/23 08:50:16 freddy77 Exp $"; +static char software_version[] = "$Id: cancel.c,v 1.11 2006/06/15 12:17:47 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; -#if defined(HAVE_ALARM) && defined(HAVE_SETITIMER) +#ifdef HAVE_ALARM /* protos */ int do_fetch(CS_COMMAND * cmd, int *cnt); diff --git b/src/dblib/unittests/timeout.c a/src/dblib/unittests/timeout.c index a3ef6f4..736f968 100644 --- b/src/dblib/unittests/timeout.c +++ a/src/dblib/unittests/timeout.c @@ -7,7 +7,7 @@ #include "common.h" #include -static char software_version[] = "$Id: timeout.c,v 1.3.2.1 2008/01/23 08:50:16 freddy77 Exp $"; +static char software_version[] = "$Id: timeout.c,v 1.3 2007/12/04 02:06:38 jklowden Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; int ntimeouts = 0, ncancels = 0; @@ -29,7 +29,7 @@ timeout_err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char return INT_CANCEL; if (dberr == SYBETIME) { - fprintf(stderr, "%d timeouts received in %ld seconds, ", ++ntimeouts, (long int) (time(NULL) - start_time)); + fprintf(stderr, "%d timeouts received in %ld seconds, ", ++ntimeouts, time(NULL) - start_time); if (ntimeouts > max_timeouts) { if (++ncancels > 1) { fprintf(stderr, "could not timeout cleanly, breaking connection\n"); @@ -73,14 +73,14 @@ timeout_err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char int chkintr(DBPROCESS * dbproc) { - printf("in chkintr, %ld seconds elapsed\n", (long int) (time(NULL) - start_time)); + printf("in chkintr, %ld seconds elapsed\n", time(NULL) - start_time); return FALSE; } int hndlintr(DBPROCESS * dbproc) { - printf("in hndlintr, %ld seconds elapsed\n", (long int) (time(NULL) - start_time)); + printf("in hndlintr, %ld seconds elapsed\n", time(NULL) - start_time); return INT_CONTINUE; } diff --git b/win32/tds_sysdep_public.h a/win32/tds_sysdep_public.h index 9d7f815..048c409 100644 --- b/win32/tds_sysdep_public.h +++ a/win32/tds_sysdep_public.h @@ -20,7 +20,7 @@ #ifndef _tds_sysdep_public_h_ #define _tds_sysdep_public_h_ -static char rcsid_tds_sysdep_public_h[] = "$Id: tds_sysdep_public.h,v 1.5.6.1 2008/01/23 08:50:17 freddy77 Exp $"; +static char rcsid_tds_sysdep_public_h[] = "$Id: tds_sysdep_public.h,v 1.5 2004/02/03 19:28:12 jklowden Exp $"; static void *no_unused_tds_sysdep_public_h_warn[] = { rcsid_tds_sysdep_public_h, no_unused_tds_sysdep_public_h_warn }; #ifdef __cplusplus @@ -34,23 +34,12 @@ extern "C" #define tds_sysdep_int64_type __int64 /* 64-bit int */ #define tds_sysdep_real32_type float /* 32-bit real */ #define tds_sysdep_real64_type double /* 64-bit real */ -#if !defined(WIN64) && !defined(_WIN64) #define tds_sysdep_intptr_type int /* 32-bit int */ -#else -#define tds_sysdep_intptr_type __int64 /* 64-bit int */ -#endif typedef SOCKET TDS_SYS_SOCKET; #ifndef TDS_IS_SOCKET_INVALID #define TDS_IS_SOCKET_INVALID(s) ((s) == INVALID_SOCKET) #endif -#if !defined(MSDBLIB) && !defined(SYBDBLIB) -#define SYBDBLIB 1 -#endif -#if defined(MSDBLIB) && defined(SYBDBLIB) -#error MSDBLIB and SYBDBLIB cannot both be defined -#endif - #ifdef __cplusplus } #endif diff --git b/win32/winlogin.c a/win32/winlogin.c index 9e5969d..4a2c2aa 100644 --- b/win32/winlogin.c +++ a/win32/winlogin.c @@ -88,14 +88,6 @@ get_desktop_file(const char *file) return res; } -#ifndef WIN64 -#define GetWindowUserData(wnd) GetWindowLong((wnd), GWL_USERDATA) -#define SetWindowUserData(wnd, data) SetWindowLong((wnd), GWL_USERDATA, (data)) -#else -#define GetWindowUserData(wnd) GetWindowLongPtr((wnd), GWLP_USERDATA) -#define SetWindowUserData(wnd, data) SetWindowLongPtr((wnd), GWLP_USERDATA, (data)) -#endif - /** * Callback function for the DSN Configuration dialog * \param hDlg identifies the dialog @@ -115,7 +107,7 @@ LoginDlgProc(HWND hDlg, UINT message, WPARAM wParam, /* */ case WM_INITDIALOG: /* lParam points to the TDSCONNECTION */ connection = (TDSCONNECTION *) lParam; - SetWindowUserData(hDlg, lParam); + SetWindowLong(hDlg, GWL_USERDATA, lParam); /* copy info from TDSCONNECTION to the dialog */ SendDlgItemMessage(hDlg, IDC_LOGINSERVER, WM_SETTEXT, 0, (LPARAM) tds_dstr_cstr(&connection->server_name)); @@ -130,7 +122,7 @@ LoginDlgProc(HWND hDlg, UINT message, WPARAM wParam, /* */ case WM_COMMAND: /* Dialog's user data points to TDSCONNECTION */ - connection = (TDSCONNECTION *) GetWindowUserData(hDlg); + connection = (TDSCONNECTION *) GetWindowLong(hDlg, GWL_USERDATA); /* The wParam indicates which button was pressed */ if (LOWORD(wParam) == IDCANCEL) { diff --git b/win32/winsetup.c a/win32/winsetup.c index e33dc76..20585f0 100644 --- b/win32/winsetup.c +++ a/win32/winsetup.c @@ -192,13 +192,6 @@ validate(DSNINFO * di) return NULL; } -#ifndef WIN64 -#define GetWindowUserData(wnd) GetWindowLong((wnd), GWL_USERDATA) -#define SetWindowUserData(wnd, data) SetWindowLong((wnd), GWL_USERDATA, (data)) -#else -#define GetWindowUserData(wnd) GetWindowLongPtr((wnd), GWLP_USERDATA) -#define SetWindowUserData(wnd, data) SetWindowLongPtr((wnd), GWLP_USERDATA, (data)) -#endif /** * Callback function for the DSN Configuration dialog @@ -223,7 +216,7 @@ DSNDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_INITDIALOG: /* lParam points to the DSNINFO */ di = (DSNINFO *) lParam; - SetWindowUserData(hDlg, lParam); + SetWindowLong(hDlg, GWL_USERDATA, lParam); /* Stuff legal protocol names into IDC_PROTOCOL */ for (i = 0; protocols[i]; i++) { @@ -243,7 +236,7 @@ DSNDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_COMMAND: /* Dialog's user data points to DSNINFO */ - di = (DSNINFO *) GetWindowUserData(hDlg); + di = (DSNINFO *) GetWindowLong(hDlg, GWL_USERDATA); /* The wParam indicates which button was pressed */ if (LOWORD(wParam) == IDCANCEL) { commit d9abbc45b533464c7d5305d8f36cbd2269d1ad73 Author: freddy77 Date: Sun Jan 13 20:39:27 2008 +0000 backported cancel error set diff --git b/ChangeLog a/ChangeLog index 5fda0d4..403a684 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,6 +1,3 @@ -Sun Jan 13 21:38:02 CET 2008 Frediano Ziglio - * src/odbc/odbc.c: backported cancel error set - Sun Jan 13 21:36:56 CET 2008 Frediano Ziglio * configure.ac: add missing tests for heavy loads backport @@ -54,4 +51,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2454.2.11 2008/01/13 20:39:27 freddy77 Exp $ +$Id: ChangeLog,v 1.2454.2.10 2008/01/13 20:37:59 freddy77 Exp $ diff --git b/src/odbc/odbc.c a/src/odbc/odbc.c index c8dc89f..60c8e00 100644 --- b/src/odbc/odbc.c +++ a/src/odbc/odbc.c @@ -60,7 +60,7 @@ #include #endif -TDS_RCSID(var, "$Id: odbc.c,v 1.464.2.3 2008/01/13 20:39:27 freddy77 Exp $"); +TDS_RCSID(var, "$Id: odbc.c,v 1.464.2.2 2008/01/10 13:13:46 freddy77 Exp $"); static SQLRETURN _SQLAllocConnect(SQLHENV henv, SQLHDBC FAR * phdbc); static SQLRETURN _SQLAllocEnv(SQLHENV FAR * phenv); @@ -3260,7 +3260,6 @@ odbc_process_tokens(TDS_STMT * stmt, unsigned flag) case TDS_NO_MORE_RESULTS: return TDS_CMD_DONE; case TDS_CANCELLED: - odbc_errs_add(&stmt->errs, "HY008", NULL); case TDS_FAIL: return TDS_CMD_FAIL; } @@ -4188,8 +4187,6 @@ SQLPrepare(SQLHSTMT hstmt, SQLCHAR FAR * szSqlStr, SQLINTEGER cbSqlStr) continue; case TDS_NO_MORE_RESULTS: break; - case TDS_CANCELLED: - odbc_errs_add(&stmt->errs, "HY008", NULL); default: stmt->errs.lastrc = SQL_ERROR; break; @@ -4591,7 +4588,7 @@ SQLGetData(SQLHSTMT hstmt, SQLUSMALLINT icol, SQLSMALLINT fCType, SQLPOINTER rgb int readed = cbValueMax; /* FIXME test on destination char ??? */ - if (stmt->dbc->env->attr.output_nts != SQL_FALSE && fCType == SQL_C_CHAR && readed > 0) + if (stmt->dbc->env->attr.output_nts != SQL_FALSE && fCType == SQL_C_CHAR /* is_char_type(nSybType) */ && readed > 0) --readed; if (readed > *pcbValue) readed = *pcbValue; @@ -5686,9 +5683,6 @@ SQLGetTypeInfo(SQLHSTMT hstmt, SQLSMALLINT fSqlType) if (n >= varchar_pos && varchar_pos > 0) goto redo; break; - case TDS_CANCELLED: - odbc_errs_add(&stmt->errs, "HY008", NULL); - break; } if (!tds->current_results) break; commit ac9fc48b5f019af9b5bf4b41c8193acf821a1525 Author: freddy77 Date: Sun Jan 13 20:37:59 2008 +0000 Add missing tests diff --git b/ChangeLog a/ChangeLog index 403a684..9ce0774 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,6 +1,3 @@ -Sun Jan 13 21:36:56 CET 2008 Frediano Ziglio - * configure.ac: add missing tests for heavy loads backport - Sat Jan 12 1:21:09 CET 2008 Frediano Ziglio * src/odbc/unittests/blob1.c: small fix for 64bit * src/tds/net.c: fix for heavy loads @@ -51,4 +48,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2454.2.10 2008/01/13 20:37:59 freddy77 Exp $ +$Id: ChangeLog,v 1.2454.2.9 2008/01/12 00:21:39 freddy77 Exp $ diff --git b/configure.ac a/configure.ac index f4d877a..d9bfaec 100644 --- b/configure.ac +++ a/configure.ac @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. dnl ------------------------------------------------------------ -dnl $Id: configure.ac,v 1.29.2.4 2008/01/13 20:37:59 freddy77 Exp $ +dnl $Id: configure.ac,v 1.29.2.3 2008/01/11 12:46:52 freddy77 Exp $ dnl If you're trying to create a new configure test, try dnl dnl http://autogen.sourceforge.net/conftest.html @@ -15,7 +15,7 @@ dnl ------------------------------------------------------------ AC_INIT(FreeTDS, 0.82RC2) AC_CONFIG_SRCDIR(src/dblib/dblib.c) AC_PREREQ(2.53) -AC_REVISION($Revision: 1.29.2.4 $) +AC_REVISION($Revision: 1.29.2.3 $) AM_INIT_AUTOMAKE AC_CONFIG_HEADERS(include/config.h) @@ -217,8 +217,7 @@ AC_CHECK_MEMBERS([struct tm.__tm_zone],,,[#include #include <$ac_cv_struct_tm> ]) AC_CHECK_HEADERS([unistd.h errno.h wchar.h sys/time.h sys/types.h \ -sys/param.h sys/stat.h sys/wait.h limits.h locale.h odbcss.h readpassphrase.h \ -signal.h libgen.h poll.h]) +sys/param.h sys/stat.h sys/wait.h limits.h locale.h odbcss.h readpassphrase.h signal.h libgen.h]) if test $tds_mingw = no; then AC_CHECK_HEADERS([sys/socket.h arpa/inet.h netdb.h netinet/in.h \ netinet/tcp.h paths.h sys/ioctl.h langinfo.h]) @@ -385,7 +384,7 @@ gethrtime localtime_r]) OLD_LIBS="$LIBS" LIBS="$LIBS $NETWORK_LIBS" AC_CHECK_FUNCS([inet_ntoa_r getipnodebyaddr getipnodebyname \ -getaddrinfo getnameinfo inet_ntop gethostname poll]) +getaddrinfo getnameinfo inet_ntop gethostname]) LIBS="$OLD_LIBS" AC_REPLACE_FUNCS([asprintf vasprintf atoll strtok_r readpassphrase \ strlcpy strlcat basename]) commit 606c262bc5a4513a67789f3186207869c6ba2c6b Author: freddy77 Date: Sun Jan 13 20:36:05 2008 +0000 update version diff --git b/misc/freetds_autobuild a/misc/freetds_autobuild index a78d6f4..7217a27 100755 --- b/misc/freetds_autobuild +++ a/misc/freetds_autobuild @@ -9,7 +9,7 @@ export PATH="/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:$HOME GROUPDIR=/home/groups/f/fr/freetds/htdocs # directory to compile -FTDSDIR=freetds82 +FTDSDIR=freetds65 # output directory on server OUTDIR=out # additional flags for Autogen (current version) commit 09c5cdaf1cc430a40dd58b9915f769953e92cdbf Author: freddy77 Date: Sat Jan 12 00:21:39 2008 +0000 fix for heavy load on server diff --git b/ChangeLog a/ChangeLog index 9ce0774..5cd7d29 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,7 +1,3 @@ -Sat Jan 12 1:21:09 CET 2008 Frediano Ziglio - * src/odbc/unittests/blob1.c: small fix for 64bit - * src/tds/net.c: fix for heavy loads - Fri Jan 11 13:46:32 CET 2008 Frediano Ziglio * configure.ac src/apps/tsql.c: backport fix for MacOSX @@ -48,4 +44,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2454.2.9 2008/01/12 00:21:39 freddy77 Exp $ +$Id: ChangeLog,v 1.2454.2.8 2008/01/11 12:46:52 freddy77 Exp $ diff --git b/src/odbc/unittests/blob1.c a/src/odbc/unittests/blob1.c index e5d0344..0ac14c0 100755 --- b/src/odbc/unittests/blob1.c +++ a/src/odbc/unittests/blob1.c @@ -3,7 +3,7 @@ #include "common.h" -static char software_version[] = "$Id: blob1.c,v 1.1.2.5 2008/01/12 00:21:39 freddy77 Exp $"; +static char software_version[] = "$Id: blob1.c,v 1.1.2.4 2008/01/11 12:44:39 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #define CHECK_RCODE(t,h,m) \ @@ -101,11 +101,11 @@ main(int argc, char **argv) int i; int key; - SQLLEN vind0; + SQLINTEGER vind0; char buf1[NBYTES]; - SQLLEN vind1; + SQLINTEGER vind1; char buf2[NBYTES]; - SQLLEN vind2; + SQLINTEGER vind2; int cnt = 2; use_odbc_version3 = 1; diff --git b/src/tds/net.c a/src/tds/net.c index 62c0705..c551127 100644 --- b/src/tds/net.c +++ a/src/tds/net.c @@ -82,10 +82,6 @@ #include #endif /* HAVE_SELECT_H */ -#if HAVE_POLL_H -#include -#endif /* HAVE_POLL_H */ - #include "tds.h" #include "tdsstring.h" #include "replacements.h" @@ -103,23 +99,9 @@ #include #endif -TDS_RCSID(var, "$Id: net.c,v 1.71.2.1 2008/01/12 00:21:39 freddy77 Exp $"); +TDS_RCSID(var, "$Id: net.c,v 1.71 2007/12/12 06:27:38 freddy77 Exp $"); -#undef USE_POLL -#if defined(HAVE_POLL_H) && defined(HAVE_POLL) -# define USE_POLL 1 -# define TDSSELREAD POLLIN -# define TDSSELWRITE POLLOUT -/* error is always returned */ -# define TDSSELERR 0 -#else -# define USE_POLL 0 -# define TDSSELREAD 1 -# define TDSSELWRITE 2 -# define TDSSELERR 4 -#endif - -static int tds_select(TDSSOCKET * tds, unsigned tds_sel, int timeout_seconds); +static int tds_select(TDSSOCKET * tds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, int timeout_seconds); /** @@ -261,6 +243,8 @@ tds_open_socket(TDSSOCKET * tds, const char *ip_addr, unsigned int port, int tim if (retval == 0) { tdsdump_log(TDS_DBG_INFO2, "connection established\n"); } else { + fd_set fds; + tdsdump_log(TDS_DBG_ERROR, "tds_open_socket: connect(2) returned \"%s\"\n", strerror(sock_errno)); #if DEBUGGING_CONNECTING_PROBLEM if (sock_errno != ECONNREFUSED && sock_errno != ENETUNREACH && sock_errno != EINPROGRESS) { @@ -280,7 +264,8 @@ tds_open_socket(TDSSOCKET * tds, const char *ip_addr, unsigned int port, int tim if (sock_errno != TDSSOCK_EINPROGRESS) goto not_available; - if (tds_select(tds, TDSSELWRITE|TDSSELERR, timeout) <= 0) { + FD_ZERO(&fds); + if (tds_select(tds, NULL, &fds, &fds, timeout) <= 0) { tds_error = TDSESOCK; goto not_available; } @@ -335,39 +320,13 @@ tds_close_socket(TDSSOCKET * tds) * This function does not call tdserror or close the socket because it can't know the context in which it's being called. */ static int -tds_select(TDSSOCKET * tds, unsigned tds_sel, int timeout_seconds) +tds_select(TDSSOCKET * tds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, int timeout_seconds) { int rc, seconds; unsigned int poll_seconds; -#if !USE_POLL - fd_set fds[3]; - fd_set *readfds = NULL, *writefds = NULL, *exceptfds = NULL; -#endif assert(tds != NULL); assert(timeout_seconds >= 0); - -#if !USE_POLL -#if !defined(WIN32) && defined(FD_SETSIZE) - if (tds->s >= FD_SETSIZE) { - sock_errno = EINVAL; - return -1; - } -#endif - if ((tds_sel & TDSSELREAD) != 0) { - FD_ZERO(&fds[0]); - readfds = &fds[0]; - } - if ((tds_sel & TDSSELWRITE) != 0) { - FD_ZERO(&fds[1]); - writefds = &fds[1]; - } - if ((tds_sel & TDSSELERR) != 0) { - FD_ZERO(&fds[2]); - exceptfds = &fds[2]; - } -#endif - /* * The select loop. * If an interrupt handler is installed, we iterate once per second, @@ -385,16 +344,8 @@ tds_select(TDSSOCKET * tds, unsigned tds_sel, int timeout_seconds) */ poll_seconds = (tds->tds_ctx && tds->tds_ctx->int_handler)? 1 : timeout_seconds; for (seconds = timeout_seconds; timeout_seconds == 0 || seconds > 0; seconds -= poll_seconds) { -#if USE_POLL - struct pollfd fd; - int timeout = poll_seconds ? poll_seconds * 1000 : -1; - - fd.fd = tds->s; - fd.events = tds_sel; - fd.revents = 0; - rc = poll(&fd, 1, timeout); -#else struct timeval tv, *ptv = poll_seconds? &tv : NULL; + tv.tv_sec = poll_seconds; tv.tv_usec = 0; @@ -406,7 +357,6 @@ tds_select(TDSSOCKET * tds, unsigned tds_sel, int timeout_seconds) FD_SET(tds->s, exceptfds); rc = select(tds->s + 1, readfds, writefds, exceptfds, ptv); -#endif if (rc > 0 ) { return rc; @@ -471,6 +421,7 @@ static int tds_goodread(TDSSOCKET * tds, unsigned char *buf, int buflen, unsigned char unfinished) { int rc, got = 0; + fd_set rfds; if (buf == NULL || buflen < 1 || tds == NULL) return 0; @@ -481,19 +432,23 @@ tds_goodread(TDSSOCKET * tds, unsigned char *buf, int buflen, unsigned char unfi if (IS_TDSDEAD(tds)) return -1; - if ((len = tds_select(tds, TDSSELREAD, tds->query_timeout)) > 0) { + FD_ZERO(&rfds); + if ((len = tds_select(tds, &rfds, NULL, NULL, tds->query_timeout)) > 0) { + len = 0; + if (FD_ISSET(tds->s, &rfds)) { #ifndef MSG_NOSIGNAL - len = READSOCKET(tds->s, buf + got, buflen); + len = READSOCKET(tds->s, buf + got, buflen); #else - len = recv(tds->s, buf + got, buflen, MSG_NOSIGNAL); + len = recv(tds->s, buf + got, buflen, MSG_NOSIGNAL); #endif - if (len < 0 && sock_errno == EAGAIN) - continue; - /* detect connection close */ - if (len <= 0) { - tdserror(tds->tds_ctx, tds, len == 0 ? TDSESEOF : TDSEREAD, sock_errno); - tds_close_socket(tds); - return -1; + if (len < 0 && sock_errno == EAGAIN) + continue; + /* detect connection close */ + if (len <= 0) { + tdserror(tds->tds_ctx, tds, len == 0 ? TDSESEOF : TDSEREAD, sock_errno); + tds_close_socket(tds); + return -1; + } } } else if (len < 0) { if (sock_errno == EAGAIN) /* shouldn't happen, but OK */ @@ -685,30 +640,35 @@ tds_goodwrite(TDSSOCKET * tds, const unsigned char *p, int len, unsigned char la { int remaining = len; int nput, rc, err=0; + fd_set fds; /* Fix of SIGSEGV when FD_SET() called with negative fd (Sergey A. Cherukhin, 23/09/2005) */ if (TDS_IS_SOCKET_INVALID(tds->s)) return -1; while (remaining > 0) { - if ((rc = tds_select(tds, TDSSELWRITE, tds->query_timeout)) > 0) { + FD_ZERO(&fds); + if ((rc = tds_select(tds, NULL, &fds, NULL, tds->query_timeout)) > 0) { + nput = 0; + if (FD_ISSET(tds->s, &fds)) { #ifdef USE_MSGMORE - nput = send(tds->s, p, remaining, last ? MSG_NOSIGNAL : MSG_NOSIGNAL|MSG_MORE); - /* In case the kernel does not support MSG_MORE, try again without it */ - if (nput < 0 && errno == EINVAL && !last) - nput = send(tds->s, p, remaining, MSG_NOSIGNAL); + nput = send(tds->s, p, remaining, last ? MSG_NOSIGNAL : MSG_NOSIGNAL|MSG_MORE); + /* In case the kernel does not support MSG_MORE, try again without it */ + if (nput < 0 && errno == EINVAL && !last) + nput = send(tds->s, p, remaining, MSG_NOSIGNAL); #elif !defined(MSG_NOSIGNAL) - nput = WRITESOCKET(tds->s, p, remaining); + nput = WRITESOCKET(tds->s, p, remaining); #else - nput = send(tds->s, p, remaining, MSG_NOSIGNAL); + nput = send(tds->s, p, remaining, MSG_NOSIGNAL); #endif - if (nput < 0 && sock_errno == EAGAIN) - continue; - /* detect connection close */ - if (nput <= 0) { - tdserror(tds->tds_ctx, tds, nput == 0 ? TDSESEOF : TDSEWRIT, sock_errno); - tds_close_socket(tds); - return -1; + if (nput < 0 && sock_errno == EAGAIN) + continue; + /* detect connection close */ + if (nput <= 0) { + tdserror(tds->tds_ctx, tds, nput == 0 ? TDSESEOF : TDSEWRIT, sock_errno); + tds_close_socket(tds); + return -1; + } } } else if (rc < 0) { if (sock_errno == EAGAIN) /* shouldn't happen, but OK, retry */ @@ -821,12 +781,8 @@ tds7_get_instance_port(const char *ip_addr, const char *instance) int num_try; struct sockaddr_in sin; ioctl_nonblocking_t ioctl_nonblocking; -#if USE_POLL - struct pollfd fd; -#else struct timeval selecttimeout; fd_set fds; -#endif int retval; TDS_SYS_SOCKET s; char msg[1024]; @@ -850,15 +806,6 @@ tds7_get_instance_port(const char *ip_addr, const char *instance) return 0; } -#if !USE_POLL -#if !defined(WIN32) && defined(FD_SETSIZE) - if (s >= FD_SETSIZE) { - sock_errno = EINVAL; - return 0; - } -#endif -#endif - /* * on cluster environment is possible that reply packet came from * different IP so do not filter by ip with connect @@ -881,20 +828,12 @@ tds7_get_instance_port(const char *ip_addr, const char *instance) tds_strlcpy(msg + 1, instance, sizeof(msg) - 1); sendto(s, msg, strlen(msg) + 1, 0, (struct sockaddr *) &sin, sizeof(sin)); -#if USE_POLL - fd.fd = s; - fd.events = POLLIN; - fd.revents = 0; - - retval = poll(&fd, 1, 1000); -#else FD_ZERO(&fds); FD_SET(s, &fds); selecttimeout.tv_sec = 1; selecttimeout.tv_usec = 0; retval = select(s + 1, &fds, NULL, NULL, &selecttimeout); -#endif /* on interrupt ignore */ if (retval < 0 && sock_errno == TDSSOCK_EINTR) commit 385bf5239dbd89559c437b8a7252ee88ba9b4a5f Author: freddy77 Date: Fri Jan 11 12:46:52 2008 +0000 backport fix for MacOSX diff --git b/ChangeLog a/ChangeLog index 5cd7d29..851bd0f 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,6 +1,3 @@ -Fri Jan 11 13:46:32 CET 2008 Frediano Ziglio - * configure.ac src/apps/tsql.c: backport fix for MacOSX - Fri Jan 11 13:43:08 CET 2008 Frediano Ziglio * src/odbc/unittests/blob1.c: backport fix for Sybase @@ -44,4 +41,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2454.2.8 2008/01/11 12:46:52 freddy77 Exp $ +$Id: ChangeLog,v 1.2454.2.7 2008/01/11 12:44:39 freddy77 Exp $ diff --git b/configure.ac a/configure.ac index d9bfaec..1b9cc43 100644 --- b/configure.ac +++ a/configure.ac @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. dnl ------------------------------------------------------------ -dnl $Id: configure.ac,v 1.29.2.3 2008/01/11 12:46:52 freddy77 Exp $ +dnl $Id: configure.ac,v 1.29.2.2 2008/01/11 06:48:38 freddy77 Exp $ dnl If you're trying to create a new configure test, try dnl dnl http://autogen.sourceforge.net/conftest.html @@ -15,7 +15,7 @@ dnl ------------------------------------------------------------ AC_INIT(FreeTDS, 0.82RC2) AC_CONFIG_SRCDIR(src/dblib/dblib.c) AC_PREREQ(2.53) -AC_REVISION($Revision: 1.29.2.3 $) +AC_REVISION($Revision: 1.29.2.2 $) AM_INIT_AUTOMAKE AC_CONFIG_HEADERS(include/config.h) @@ -178,24 +178,7 @@ if test $tds_mingw = no; then AC_CHECK_LIB([readline], [readline], [LIBS="$LIBS -lreadline" AC_DEFINE(HAVE_READLINE, 1, [Define to 1 if you have the GNU Readline library.])], [LIBS=""] ) AC_CHECK_FUNCS([rl_on_new_line rl_reset_line_state]) - AC_LINK_IFELSE([AC_LANG_SOURCE([[ -#include -#ifdef HAVE_STDLIB_H -#include -#endif - -#ifdef HAVE_READLINE -#include -#include -#endif /* HAVE_READLINE */ - -int main() -{ - rl_inhibit_completion = 1; - return 0; -} -]])],AC_DEFINE(HAVE_RL_INHIBIT_COMPLETION, 1, [Define to 1 if you have rl_inhibit_completion.])) READLINE_LIBS="$LIBS" LIBS="$OLDLIBS" AC_SUBST(READLINE_LIBS) diff --git b/src/apps/tsql.c a/src/apps/tsql.c index 2081212..6a04027 100644 --- b/src/apps/tsql.c +++ a/src/apps/tsql.c @@ -85,7 +85,7 @@ #include "tdsconvert.h" #include "replacements.h" -TDS_RCSID(var, "$Id: tsql.c,v 1.112.2.1 2008/01/11 12:46:52 freddy77 Exp $"); +TDS_RCSID(var, "$Id: tsql.c,v 1.112 2007/12/23 21:12:02 jklowden Exp $"); enum { @@ -683,7 +683,7 @@ main(int argc, char **argv) mybuf[0] = '\0'; buflen = 0; -#if defined(HAVE_READLINE) && HAVE_RL_INHIBIT_COMPLETION +#ifdef HAVE_READLINE rl_inhibit_completion = 1; #endif commit 9c10c557cb4e0955466b37dd61879563ef447c99 Author: freddy77 Date: Fri Jan 11 12:44:39 2008 +0000 backported fix for Sybase diff --git b/ChangeLog a/ChangeLog index 851bd0f..c9b46cc 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,6 +1,3 @@ -Fri Jan 11 13:43:08 CET 2008 Frediano Ziglio - * src/odbc/unittests/blob1.c: backport fix for Sybase - Fri Jan 11 9:32:44 CET 2008 Frediano Ziglio * src/odbc/unittests/blob1.c src/odbc/unittests/cursor3.c: * src/odbc/unittests/cursor4.c src/odbc/unittests/cursor5.c: @@ -41,4 +38,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2454.2.7 2008/01/11 12:44:39 freddy77 Exp $ +$Id: ChangeLog,v 1.2454.2.6 2008/01/11 08:33:18 freddy77 Exp $ diff --git b/src/odbc/unittests/blob1.c a/src/odbc/unittests/blob1.c index 0ac14c0..dfa8319 100755 --- b/src/odbc/unittests/blob1.c +++ a/src/odbc/unittests/blob1.c @@ -3,7 +3,7 @@ #include "common.h" -static char software_version[] = "$Id: blob1.c,v 1.1.2.4 2008/01/11 12:44:39 freddy77 Exp $"; +static char software_version[] = "$Id: blob1.c,v 1.1.2.3 2008/01/11 08:33:18 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #define CHECK_RCODE(t,h,m) \ @@ -167,7 +167,7 @@ main(int argc, char **argv) } - /* Now fetch rows ... */ + /* No fetch rows ... */ for (i = 0; i < cnt; i++) { @@ -175,12 +175,10 @@ main(int argc, char **argv) rcode = SQLAllocHandle(SQL_HANDLE_STMT, Connection, &m_hstmt); CHECK_RCODE(SQL_HANDLE_DBC, Connection, "SQLAllocHandle StmtH"); - if (db_is_microsoft()) { - rcode = SQLSetStmtAttr(m_hstmt, SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_NONSCROLLABLE, SQL_IS_UINTEGER); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLSetStmtAttr SQL_ATTR_CURSOR_SCROLLABLE"); - rcode = SQLSetStmtAttr(m_hstmt, SQL_ATTR_CURSOR_SENSITIVITY, (SQLPOINTER) SQL_SENSITIVE, SQL_IS_UINTEGER); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLSetStmtAttr SQL_ATTR_CURSOR_SENSITIVITY"); - } + rcode = SQLSetStmtAttr(m_hstmt, SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_NONSCROLLABLE, SQL_IS_UINTEGER); + CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLSetStmtAttr SQL_ATTR_CURSOR_SCROLLABLE"); + rcode = SQLSetStmtAttr(m_hstmt, SQL_ATTR_CURSOR_SENSITIVITY, (SQLPOINTER) SQL_SENSITIVE, SQL_IS_UINTEGER); + CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLSetStmtAttr SQL_ATTR_CURSOR_SENSITIVITY"); rcode = SQLPrepare(m_hstmt, (SQLCHAR *) "SELECT t, b, v FROM #tt WHERE k = ?", SQL_NTS); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLPrepare"); commit f42f2399b3c5dd1e67f36dda7702be5b81310ca8 Author: freddy77 Date: Fri Jan 11 08:33:18 2008 +0000 merged changes for tests diff --git b/ChangeLog a/ChangeLog index c9b46cc..30783d8 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,9 +1,3 @@ -Fri Jan 11 9:32:44 CET 2008 Frediano Ziglio - * src/odbc/unittests/blob1.c src/odbc/unittests/cursor3.c: - * src/odbc/unittests/cursor4.c src/odbc/unittests/cursor5.c: - * src/odbc/unittests/hidden.c: - - merged changes for tests - Fri Jan 11 7:48:23 CET 2008 Frediano Ziglio * configure.ac: avoid clash @@ -38,4 +32,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2454.2.6 2008/01/11 08:33:18 freddy77 Exp $ +$Id: ChangeLog,v 1.2454.2.5 2008/01/11 06:48:37 freddy77 Exp $ diff --git b/src/odbc/unittests/blob1.c a/src/odbc/unittests/blob1.c index dfa8319..b8c45b0 100755 --- b/src/odbc/unittests/blob1.c +++ a/src/odbc/unittests/blob1.c @@ -3,7 +3,7 @@ #include "common.h" -static char software_version[] = "$Id: blob1.c,v 1.1.2.3 2008/01/11 08:33:18 freddy77 Exp $"; +static char software_version[] = "$Id: blob1.c,v 1.1.2.2 2008/01/10 13:13:46 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #define CHECK_RCODE(t,h,m) \ @@ -111,7 +111,8 @@ main(int argc, char **argv) use_odbc_version3 = 1; Connect(); - Command(Statement, "CREATE TABLE #tt ( k INT, t TEXT, b IMAGE, v INT )"); + Command(Statement, "IF OBJECT_ID('tt') IS NOT NULL DROP TABLE tt"); + Command(Statement, "CREATE TABLE tt ( k INT, t TEXT, b IMAGE, v INT )"); /* Insert rows ... */ @@ -121,7 +122,7 @@ main(int argc, char **argv) rcode = SQLAllocHandle(SQL_HANDLE_STMT, Connection, &m_hstmt); CHECK_RCODE(SQL_HANDLE_DBC, Connection, "SQLAllocHandle StmtH"); - rcode = SQLPrepare(m_hstmt, (SQLCHAR *) "INSERT INTO #tt VALUES ( ?, ?, ?, ? )", SQL_NTS); + rcode = SQLPrepare(m_hstmt, (SQLCHAR *) "insert into tt values ( ?, ?, ?, ? )", SQL_NTS); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLPrepare"); SQLBindParameter(m_hstmt, 1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &key, 0, &vind0); @@ -180,7 +181,7 @@ main(int argc, char **argv) rcode = SQLSetStmtAttr(m_hstmt, SQL_ATTR_CURSOR_SENSITIVITY, (SQLPOINTER) SQL_SENSITIVE, SQL_IS_UINTEGER); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLSetStmtAttr SQL_ATTR_CURSOR_SENSITIVITY"); - rcode = SQLPrepare(m_hstmt, (SQLCHAR *) "SELECT t, b, v FROM #tt WHERE k = ?", SQL_NTS); + rcode = SQLPrepare(m_hstmt, (SQLCHAR *) "SELECT t, b, v FROM tt WHERE k = ?", SQL_NTS); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLPrepare"); SQLBindParameter(m_hstmt, 1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &i, 0, &vind0); diff --git b/src/odbc/unittests/cursor3.c a/src/odbc/unittests/cursor3.c index 18c2f1d..791783a 100644 --- b/src/odbc/unittests/cursor3.c +++ a/src/odbc/unittests/cursor3.c @@ -1,7 +1,7 @@ /* Tests 2 active statements */ #include "common.h" -static char software_version[] = "$Id: cursor3.c,v 1.3.2.1 2008/01/11 08:33:18 freddy77 Exp $"; +static char software_version[] = "$Id: cursor3.c,v 1.3 2007/12/21 10:39:10 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static SQLHDBC m_hdbc; @@ -69,11 +69,12 @@ main(int argc, char **argv) m_hdbc = Connection; - exec_direct(1, "CREATE TABLE #t1 ( k INT, c VARCHAR(20))"); - exec_direct(1, "INSERT INTO #t1 VALUES (1, 'aaa')"); - exec_direct(1, "INSERT INTO #t1 VALUES (2, 'bbbbb')"); - exec_direct(1, "INSERT INTO #t1 VALUES (3, 'ccccccccc')"); - exec_direct(1, "INSERT INTO #t1 VALUES (4, 'dd')"); + exec_direct(0, "DROP TABLE t1"); + exec_direct(1, "CREATE TABLE t1 ( k INT, c VARCHAR(20))"); + exec_direct(1, "INSERT INTO t1 VALUES (1, 'aaa')"); + exec_direct(1, "INSERT INTO t1 VALUES (2, 'bbbbb')"); + exec_direct(1, "INSERT INTO t1 VALUES (3, 'ccccccccc')"); + exec_direct(1, "INSERT INTO t1 VALUES (4, 'dd')"); m_hstmt1 = NULL; rcode = SQLAllocHandle(SQL_HANDLE_STMT, m_hdbc, &m_hstmt1); @@ -113,10 +114,10 @@ main(int argc, char **argv) rcode = SQLSetCursorName(m_hstmt2, (SQLCHAR *) "c2", SQL_NTS); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt2, "SetCursorName c2"); - rcode = SQLPrepare(m_hstmt1, (SQLCHAR *) "SELECT * FROM #t1", SQL_NTS); + rcode = SQLPrepare(m_hstmt1, (SQLCHAR *) "SELECT * FROM t1", SQL_NTS); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "Prepare 1"); - rcode = SQLPrepare(m_hstmt2, (SQLCHAR *) "SELECT * FROM #t1", SQL_NTS); + rcode = SQLPrepare(m_hstmt2, (SQLCHAR *) "SELECT * FROM t1", SQL_NTS); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt2, "Prepare 2"); rcode = SQLExecute(m_hstmt1); @@ -151,6 +152,8 @@ main(int argc, char **argv) rcode = SQLFreeHandle(SQL_HANDLE_STMT, (SQLHANDLE) m_hstmt2); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt2, "SQLFreeHandle 2"); + exec_direct(1, "DROP TABLE t1"); + Disconnect(); return 0; diff --git b/src/odbc/unittests/cursor4.c a/src/odbc/unittests/cursor4.c index 58c249d..b352644 100755 --- b/src/odbc/unittests/cursor4.c +++ a/src/odbc/unittests/cursor4.c @@ -5,7 +5,7 @@ #include "common.h" -static char software_version[] = "$Id: cursor4.c,v 1.3.2.1 2008/01/11 08:33:18 freddy77 Exp $"; +static char software_version[] = "$Id: cursor4.c,v 1.3 2007/12/21 10:39:10 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static SQLHDBC m_hdbc; @@ -72,8 +72,9 @@ main(int argc, char **argv) m_hdbc = Connection; - exec_direct(1, "CREATE TABLE #t1 ( k INT, c VARCHAR(20))"); - exec_direct(1, "INSERT INTO #t1 VALUES (1, 'aaa')"); + exec_direct(0, "DROP TABLE t1"); + exec_direct(1, "CREATE TABLE t1 ( k INT, c VARCHAR(20))"); + exec_direct(1, "INSERT INTO t1 VALUES (1, 'aaa')"); m_hstmt1 = NULL; rcode = SQLAllocHandle(SQL_HANDLE_STMT, m_hdbc, &m_hstmt1); @@ -85,7 +86,7 @@ main(int argc, char **argv) rcode = SQLSetCursorName(m_hstmt1, (SQLCHAR *) "c112", SQL_NTS); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SetCursorName c112"); - rcode = SQLPrepare(m_hstmt1, (SQLCHAR *) "SELECT * FROM #t1 FOR UPDATE", SQL_NTS); + rcode = SQLPrepare(m_hstmt1, (SQLCHAR *) "SELECT * FROM t1 FOR UPDATE", SQL_NTS); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "Prepare 2"); exec_direct(1, "BEGIN TRANSACTION"); @@ -96,14 +97,14 @@ main(int argc, char **argv) rcode = SQLFetch(m_hstmt1); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLFetch 1"); - exec_direct(1, "UPDATE #t1 SET c = 'xxx' WHERE CURRENT OF c112"); + exec_direct(1, "UPDATE t1 SET c = 'xxx' WHERE CURRENT OF c112"); rcode = SQLCloseCursor(m_hstmt1); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLCloseCursor 2"); exec_direct(1, "COMMIT TRANSACTION"); - rcode = SQLExecDirect(m_hstmt1, (SQLCHAR *) "SELECT c FROM #t1 WHERE k = 1", SQL_NTS); + rcode = SQLExecDirect(m_hstmt1, (SQLCHAR *) "SELECT c FROM t1 WHERE k = 1", SQL_NTS); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLExecDirect 2"); rcode = SQLFetch(m_hstmt1); @@ -117,6 +118,8 @@ main(int argc, char **argv) rcode = SQLFreeHandle(SQL_HANDLE_STMT, (SQLHANDLE) m_hstmt1); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLFreeHandle 1"); + exec_direct(1, "DROP TABLE t1"); + Disconnect(); return 0; diff --git b/src/odbc/unittests/cursor5.c a/src/odbc/unittests/cursor5.c index 5e73dc6..c7be7e4 100755 --- b/src/odbc/unittests/cursor5.c +++ a/src/odbc/unittests/cursor5.c @@ -1,6 +1,6 @@ #include "common.h" -static char software_version[] = "$Id: cursor5.c,v 1.2.2.1 2008/01/11 08:33:18 freddy77 Exp $"; +static char software_version[] = "$Id: cursor5.c,v 1.2 2007/12/21 10:39:10 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #define CHECK_RCODE(t,h,m) \ @@ -76,14 +76,15 @@ main(int argc, char **argv) rcode = SQLAllocHandle(SQL_HANDLE_STMT, m_hdbc, &m_hstmt2); CHECK_RCODE(SQL_HANDLE_DBC, m_hdbc, "SQLAllocHandle StmtH 2"); - rcode = SQLExecDirect(m_hstmt1, (SQLCHAR *) "create table #mytab1 (k int, c char(30))", SQL_NTS); + rcode = SQLExecDirect(m_hstmt1, (SQLCHAR *) "drop table mytab1", SQL_NTS); + rcode = SQLExecDirect(m_hstmt1, (SQLCHAR *) "create table mytab1 (k int, c char(30))", SQL_NTS); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLExecDirect 1.1"); - rcode = SQLExecDirect(m_hstmt1, (SQLCHAR *) "insert into #mytab1 values (1,'aaa')", SQL_NTS); + rcode = SQLExecDirect(m_hstmt1, (SQLCHAR *) "insert into mytab1 values (1,'aaa')", SQL_NTS); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLExecDirect 1.2"); - rcode = SQLExecDirect(m_hstmt1, (SQLCHAR *) "insert into #mytab1 values (2,'bbb')", SQL_NTS); + rcode = SQLExecDirect(m_hstmt1, (SQLCHAR *) "insert into mytab1 values (2,'bbb')", SQL_NTS); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLExecDirect 1.3"); - rcode = SQLExecDirect(m_hstmt1, (SQLCHAR *) "insert into #mytab1 values (3,'ccc')", SQL_NTS); + rcode = SQLExecDirect(m_hstmt1, (SQLCHAR *) "insert into mytab1 values (3,'ccc')", SQL_NTS); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLExecDirect 1.4"); /* @@ -94,7 +95,7 @@ main(int argc, char **argv) rcode = SQLSetStmtAttr(m_hstmt2, SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_SCROLLABLE, SQL_IS_UINTEGER); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt2, "SQLSetStmtAttr 1"); - rcode = SQLPrepare(m_hstmt2, (SQLCHAR *) "select k, c from #mytab1 order by k", SQL_NTS); + rcode = SQLPrepare(m_hstmt2, (SQLCHAR *) "select k, c from mytab1 order by k", SQL_NTS); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt2, "SQLPrepare 3"); rcode = SQLBindCol(m_hstmt2, 1, SQL_C_LONG, &v_int_3, 0, &v_ind_3_1); @@ -125,6 +126,9 @@ main(int argc, char **argv) rcode = SQLCloseCursor(m_hstmt2); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt2, "SQLCloseCursor StmtH 2"); + rcode = SQLExecDirect(m_hstmt1, (SQLCHAR *) "drop table mytab1", SQL_NTS); + CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLExecDirect 1.3"); + rcode = SQLFreeHandle(SQL_HANDLE_STMT, (SQLHANDLE) m_hstmt1); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLFreeHandle StmtH 1"); diff --git b/src/odbc/unittests/hidden.c a/src/odbc/unittests/hidden.c index ad75433..66be442 100755 --- b/src/odbc/unittests/hidden.c +++ a/src/odbc/unittests/hidden.c @@ -3,7 +3,7 @@ #include "common.h" -static char software_version[] = "$Id: hidden.c,v 1.1.2.2 2008/01/11 08:33:18 freddy77 Exp $"; +static char software_version[] = "$Id: hidden.c,v 1.1.2.1 2008/01/10 08:52:46 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #define CHECK_RCODE(t,h,m) \ @@ -70,7 +70,6 @@ main(int argc, char **argv) /* test hidden column with cursors*/ CheckCursor(); - m_hstmt1 = Statement; rcode = SQLSetStmtAttr(m_hstmt1, SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_NONSCROLLABLE, SQL_IS_UINTEGER); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLSetStmtAttr SQL_ATTR_CURSOR_SCROLLABLE"); commit 4e976741808d4e336d864d45da07626ae502ce69 Author: freddy77 Date: Fri Jan 11 06:48:37 2008 +0000 avoid version clash diff --git b/ChangeLog a/ChangeLog index 30783d8..fbe59e4 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,6 +1,3 @@ -Fri Jan 11 7:48:23 CET 2008 Frediano Ziglio - * configure.ac: avoid clash - Thu Jan 10 15:55:32 EST 2008 JK Lowden * INSTALL.CVS NEWS README TODO ChangeLog-0.82 * ChangeLog doc/userguide.sgml documentation updates @@ -32,4 +29,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2454.2.5 2008/01/11 06:48:37 freddy77 Exp $ +$Id: ChangeLog,v 1.2454.2.4 2008/01/10 20:58:42 jklowden Exp $ diff --git b/configure.ac a/configure.ac index 1b9cc43..d2d0fed 100644 --- b/configure.ac +++ a/configure.ac @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. dnl ------------------------------------------------------------ -dnl $Id: configure.ac,v 1.29.2.2 2008/01/11 06:48:38 freddy77 Exp $ +dnl $Id: configure.ac,v 1.29.2.1 2008/01/09 06:50:55 freddy77 Exp $ dnl If you're trying to create a new configure test, try dnl dnl http://autogen.sourceforge.net/conftest.html @@ -12,10 +12,10 @@ dnl ------------------------------------------------------------ # ------------------------------------------------------------ # Initialization # ------------------------------------------------------------ -AC_INIT(FreeTDS, 0.82RC2) +AC_INIT(FreeTDS, 0.82RC1) AC_CONFIG_SRCDIR(src/dblib/dblib.c) AC_PREREQ(2.53) -AC_REVISION($Revision: 1.29.2.2 $) +AC_REVISION($Revision: 1.29.2.1 $) AM_INIT_AUTOMAKE AC_CONFIG_HEADERS(include/config.h) commit ea5b7edd6dbc01f152e91e23bf80070355bfe0dc Author: jklowden Date: Thu Jan 10 20:58:42 2008 +0000 documentation updates diff --git b/ChangeLog a/ChangeLog index fbe59e4..d054e6f 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,32 +1,49 @@ -Thu Jan 10 15:55:32 EST 2008 JK Lowden - * INSTALL.CVS NEWS README TODO ChangeLog-0.82 - * ChangeLog doc/userguide.sgml documentation updates - -Thu Jan 10 17:04:15 CET 2008 Frediano Ziglio - * src/odbc/unittests/.cvsignore src/odbc/unittests/Makefile.am: - * src/odbc/unittests/cancel.c(added): - - add test for SQLCancel - -Thu Jan 10 16:28:44 CET 2008 Frediano Ziglio - * src/odbc/unittests/blob1.c src/odbc/unittests/cursor3.c: - * src/odbc/unittests/cursor4.c src/odbc/unittests/cursor5.c: - - use temporary tables - -Thu Jan 10 16:25:19 CET 2008 Frediano Ziglio - * doc/README.releasing misc/freetds_autobuild: updates - -Thu Jan 10 14:10:28 CET 2008 Frediano Ziglio +Thu Jan 10 14:12:32 CET 2008 Frediano Ziglio * src/odbc/odbc.c src/odbc/unittests/.cvsignore: * src/odbc/unittests/Makefile.am src/odbc/unittests/blob1.c(added): - fix problem with SQLGetData and blobs -Thu Jan 10 09:46:41 CET 2008 Frediano Ziglio +Thu Jan 10 09:51:23 CET 2008 Frediano Ziglio * TODO src/odbc/odbc.c src/odbc/unittests/.cvsignore: * src/odbc/unittests/Makefile.am: - small fix for hidden fields (ignore them entirely) -Wed Jan 9 19:54:43 EST 2008 JK Lowden - * ChangeLog truncated because of release - * ChangeLog-0.82 added because of release - -$Id: ChangeLog,v 1.2454.2.4 2008/01/10 20:58:42 jklowden Exp $ +Wed Jan 9 7:50:39 CET 2008 Frediano Ziglio + * configure.ac: preparing 0.82 + +Tue Jan 8 10:31:43 EST 2008 JK Lowden + * doc/Makefile.am added freetds.conf.5 + * src/dblib/bcp.c applied BCPKEEPIDENTIY patch from [email] + +Tue Jan 8 14:28:09 CET 2008 Frediano Ziglio + * NEWS doc/README.releasing doc/userguide.sgml: + - updates for new release + +Tue Jan 8 10:33:26 CET 2008 Frediano Ziglio + * src/odbc/unittests/genparams.c: relax for no-dm + +Mon Jan 7 19:32:20 CET 2008 Frediano Ziglio + * src/odbc/sql2tds.c src/odbc/unittests/genparams.c: + - fix millisecond round off for TIMESTAMP + - improve genparams test to catch this problem + - make genparams works with MS ODBC + +Mon Jan 7 15:04:18 CET 2008 Frediano Ziglio + * include/tdssrv.h src/server/login.c src/server/server.c: + * src/server/unittest.c: + - small improves + * src/pool/user.c: style update + +Sun Jan 6 11:48:17 CET 2008 Frediano Ziglio + * src/odbc/odbc.c: even SQLExecDirect support parameters! + * src/odbc/unittests/genparams.c: improve + +Sat Jan 5 12:23:21 CET 2008 Frediano Ziglio + * src/tds/query.c: + - add parameterized flag calling sp_cursoropen if needed + +Wed Jan 2 00:08:45 CET 2008 Frediano Ziglio + * configure.ac src/apps/Makefile.am: + - remove GNU style + * src/dblib/dblib.c: make it compile + diff --git b/ChangeLog-0.82 a/ChangeLog-0.82 deleted file mode 100644 index cc4cbea..0000000 --- b/ChangeLog-0.82 +++ /dev/null @@ -1,2289 +0,0 @@ -Tue Jan 8 10:31:43 EST 2008 JK Lowden - * doc/Makefile.am added freetds.conf.5 - * src/dblib/bcp.c applied BCPKEEPIDENTIY patch - - from Jonathan Olson - -Tue Jan 8 14:28:09 CET 2008 Frediano Ziglio - * NEWS doc/README.releasing doc/userguide.sgml: - - updates for new release - -Tue Jan 8 10:33:26 CET 2008 Frediano Ziglio - * src/odbc/unittests/genparams.c: relax for no-dm - -Mon Jan 7 19:32:20 CET 2008 Frediano Ziglio - * src/odbc/sql2tds.c src/odbc/unittests/genparams.c: - - fix millisecond round off for TIMESTAMP - - improve genparams test to catch this problem - - make genparams works with MS ODBC - -Mon Jan 7 15:04:18 CET 2008 Frediano Ziglio - * include/tdssrv.h src/server/login.c src/server/server.c: - * src/server/unittest.c: - - small improves - * src/pool/user.c: style update - -Sun Jan 6 11:48:17 CET 2008 Frediano Ziglio - * src/odbc/odbc.c: even SQLExecDirect support parameters! - * src/odbc/unittests/genparams.c: improve - -Sat Jan 5 12:23:21 CET 2008 Frediano Ziglio - * src/tds/query.c: - - add parameterized flag calling sp_cursoropen if needed - -Wed Jan 2 00:08:45 CET 2008 Frediano Ziglio - * configure.ac src/apps/Makefile.am: - - remove GNU style - * src/dblib/dblib.c: make it compile - - -Mon Dec 31 15:05:16 EST 2007 JK Lowden - * src/dblib/dblib.c fixed DBPRPAD, maybe - -Mon Dec 31 11:29:50 CET 2007 Frediano Ziglio - * misc/test-other.sh src/odbc/odbc.c: - - relax test for cursor - -Mon Dec 31 11:06:13 CET 2007 Frediano Ziglio - * src/ctlib/blk.c src/odbc/unittests/attributes.c: - * src/odbc/unittests/describecol.c src/tds/convert.c: - * src/tds/login.c src/tds/mem.c: - - minor signed/unsigned fixes - * src/dblib/bcp.c: minor performance improve - * src/dblib/dblib.c: fix date portability - -Fri Dec 28 17:57:08 EST 2007 JK Lowden - * src/tds/token.c minor change - * src/tds/convert.c simpler tds_strftime - * src/dblib/unittests/done_handling.c no spurious messages - -Wed Dec 28 15:11:48 CET 2007 Frediano Ziglio - * doc/userguide.sgml: accepted patch #1854381 - -Wed Dec 28 14:44:16 CET 2007 Frediano Ziglio - * misc/freetds_autobuild misc/test-other.sh: - - make amd64 works - * misc/test-auto.sh: add --help option - * src/tds/convert.c: - - fix overflow in tds_convert_char - - minor fixes for tds_strftime - -Thu Dec 27 14:43:14 CET 2007 Frediano Ziglio - * doc/.cvsignore: ignore autogenerated - * include/tds.h src/replacements/vasprintf.c src/tds/convert.c: - * src/tds/login.c src/tds/query.c src/tds/read.c: - - remove some warnings - -Thu Dec 27 11:20:55 CET 2007 Frediano Ziglio - * src/odbc/unittests/common.c: make unixODBC happy - * win32/config.h: define TDS_I64_FORMAT - -Thu Dec 27 10:19:58 CET 2007 Frediano Ziglio - * src/dblib/buffering.h: - - remove warning if compiled with NDEBUG defined - -Wed Dec 26 21:57:12 CET 2007 Frediano Ziglio - * src/odbc/unittests/attributes.c: make it works - -Wed Dec 26 19:44:47 CET 2007 Frediano Ziglio - * doc/freetds.conf.5: typo fix - * src/ctlib/unittests/common.c: make tests compile - * src/odbc/odbc.c: add diagnostic for truncate - -Tue Dec 25 00:55:02 EST 2007 JK Lowden - * freetds.conf doc/Makefile.am doc/freetds.conf.5 (added) - - shortened default freetds.conf and moved documentation - - to a proper man page. Merry Christmas! - -Mon Dec 24 11:34:58 CET 2007 Frediano Ziglio - * include/tds.h: removed unused fields - -Sun Dec 23 16:08:29 EST 2007 JK Lowden - * src/apps/tsql.c - * src/ctlib/cs.c src/ctlib/unittests/common.c - * src/dblib/dblib.c - * src/tds/config.c src/tds/unittests/convert.c - - added STD_DATETIME_FMT to allow for WIN32 shortcomings - -Fri Dec 21 16:20:03 CET 2007 Frediano Ziglio - * include/tds.h src/ctlib/ct.c src/odbc/odbc.c src/tds/query.c: - - make odbc cursor test work using sp_cursoropen with parameters - -Fri Dec 21 11:38:47 CET 2007 Frediano Ziglio - * src/odbc/unittests/common.c src/odbc/unittests/common.h: - * src/odbc/unittests/cursor3.c src/odbc/unittests/cursor4.c: - * src/odbc/unittests/cursor5.c: - - cursor tests should work - -Fri Dec 21 10:05:12 CET 2007 Frediano Ziglio - * configure.ac include/replacements.h src/replacements/vasprintf.c: - * win32/config.h: - - applied modified patch #1848920 - -Thu Dec 20 22:56:34 CET 2007 Frediano Ziglio - * src/dblib/dblib.c src/dblib/unittests/common.h: - * src/dblib/unittests/setnull.c src/dblib/unittests/thread.c: - - remove warnings - -Thu Dec 20 17:46:03 CET 2007 Frediano Ziglio - * src/odbc/odbc.c: - - improve cursor attribute setting - - fix a small issue with unixODBC and 64 bit - -Wed Dec 19 16:08:17 CET 2007 Frediano Ziglio - * src/odbc/unittests/cursor3.c src/odbc/unittests/cursor4.c: - - remove warnings - -Wed Dec 19 15:35:22 CET 2007 Frediano Ziglio - * src/odbc/unittests/attributes.c(added) src/odbc/unittests/attributes.in(added): - * src/odbc/unittests/Makefile.am: add a test for statement attributes - * src/odbc/unittests/describecol.c: fix possible core - -Tue Dec 18 09:09:27 CET 2007 Frediano Ziglio - * src/odbc/unittests/Makefile.am src/odbc/unittests/cursor3.c(added): - * src/odbc/unittests/cursor4.c(added) src/odbc/unittests/cursor5.c(added): - - merged test from Sebastien FLAESCH - -Sun Dec 16 19:08:38 EST 2007 JK Lowden - * doc/api_status.txt - - set useless db-lib functions' status to 'never' - -Sun Dec 16 16:58:35 EST 2007 JK Lowden - * doc/Makefile.am doc/bsqlodbc.txt doc/osql.txt - * doc/userguide.sgml - - updated for next release - -Fri Dec 14 11:23:08 CET 2007 Frediano Ziglio - * misc/test-other.sh: fix some strange echo portability - * src/dblib/unittests/null.c src/dblib/unittests/null2.c: - - make ignore less verbose - -Thu Dec 13 23:45:55 EST 2007 JK Lowden - * src/apps/Makefile.am build bsqlodbc out-of-tree - * src/dblib/unittests/null.c prettier & correct, passes - -Thu Dec 13 21:12:20 CET 2007 Frediano Ziglio - * src/dblib/buffering.h: fix null2 - -Thu Dec 13 19:04:35 CET 2007 Frediano Ziglio - * src/apps/Makefile.am: - - fix bsqlodbc compile if not standard sql.h path - -Wed Dec 12 07:27:07 CET 2007 Frediano Ziglio - * src/tds/net.c: fix for 64bit - -Tue Dec 11 11:09:52 CET 2007 Frediano Ziglio - * doc/userguide.sgml: remove warning - * misc/freetds_autobuild: fix if password empty - -Tue Dec 11 00:02:16 EST 2007 JK Lowden - * doc/userguide.sgml minor touchups - * src/dblib/dblib.c src/dblib/unittests/setnull.c - - unittests/setnull.c passes. - -Mon Dec 10 14:05:06 CET 2007 Frediano Ziglio - * src/tds/convert.c: remove warning - -Mon Dec 10 00:08:45 EST 2007 JK Lowden - * doc/Makefile.am doc/userguide.sgml some improvements - doc/grep_sample_code doc/images/caution.gif - doc/images/warning.gif - doc/images/callouts/1.gif doc/images/callouts/2.gif - doc/images/callouts/3.gif doc/images/callouts/4.gif - doc/images/callouts/5.gif doc/images/callouts/6.gif - doc/images/callouts/7.gif doc/images/callouts/8.gif - doc/images/callouts/9.gif doc/images/callouts/10.gif - - added from http://tldp.org/LDP/abs/images/ - -Sun Dec 9 19:51:11 EST 2007 JK Lowden - * doc/userguide.sgml added tenderfoot tutorial - -Fri Dec 7 00:26:01 EST 2007 JK Lowden - * include/tds.h src/dblib/dblib.c - * src/dblib/dbutil.c src/tds/util.c - - pass errno via tdserror. - -Thu Dec 6 21:41:23 EST 2007 JK Lowden - * src/tds/convert.c tds_willconvert returns size - -Thu Dec 6 21:32:13 CET 2007 Frediano Ziglio - * src/dblib/dblib.c: fix for 64bit machines - * src/dblib/unittests/setnull.c: improve - -Thu Dec 6 19:59:59 CET 2007 Frediano Ziglio - * configure.ac include/replacements.h src/apps/bsqldb.c: - * src/dblib/unittests/setnull.c: - - use basename from MingW if available - * src/dblib/dblib.c: fix malloc portability problem - -Thu Dec 6 10:18:54 CET 2007 Frediano Ziglio - * src/dblib/rpc.c src/dblib/unittests/setnull.c: - - fix compile problems - -Thu Dec 6 01:00:42 EST 2007 JK Lowden - * src/dblib/buffering.h src/dblib/dblib.c: - - dbgetnull tolerates negative varlen, looks pretty good - -Wed Dec 5 10:38:55 EST 2007 JK Lowden - * src/dblib/dblib.c: - - t0011 passes but copy_data_to_host_var likely wrong - -Tue Dec 4 20:19:38 EST 2007 JK Lowden - * include/dblib.h src/dblib/buffering.h src/dblib/dblib.c: - - removed _db_set_null and associated mallocs - - dblib/unittest/t0011.c failing mysteriously - -Mon Dec 3 23:18:55 EST 2007 JK Lowden - * src/dblib/dblib.c src/dblib/unittests/setnull.c: - - corrected dbsetnull() - -Mon Dec 3 18:45:22 EST 2007 JK Lowden - * src/apps/bsqldb.c - * src/dblib/bcp.c src/dblib/dblib.c src/dblib/unittests/rpc.c - * src/dblib/unittests/setnull.c src/dblib/unittests/t0001.c - * src/dblib/unittests/t0002.c src/dblib/unittests/t0003.c - * src/dblib/unittests/t0004.c src/dblib/unittests/t0005.c - * src/dblib/unittests/t0006.c src/dblib/unittests/t0007.c - * src/dblib/unittests/t0008.c src/dblib/unittests/t0011.c - * src/dblib/unittests/t0015.c src/dblib/unittests/t0018.c - * src/dblib/unittests/t0023.c src/dblib/unittests/text_buffer.c - * src/dblib/unittests/thread.c src/dblib/unittests/timeout.c: - - dbbind uses zero, not -1 to indicate sufficient space. - -Mon Dec 3 17:57:54 EST 2007 JK Lowden - * src/dblib/bcp.c: don't cast malloc and don't assume it worked. - -Mon Dec 3 19:54:53 CET 2007 Frediano Ziglio - * src/odbc/Makefile.am: remove GNU make pattern - -Mon Dec 3 15:35:45 CET 2007 Frediano Ziglio - * src/dblib/dblib.c: - - do not call dbcolptr for compute result but call new dbacolptr - - dbcolptr return TDSCOLUMN* to optimize it - -Mon Dec 3 11:53:56 CET 2007 Frediano Ziglio - * src/dblib/dblib.c: remove a warning - -Mon Dec 3 10:18:39 CET 2007 Frediano Ziglio - * src/dblib/dblib.c src/dblib/unittests/.cvsignore: - * src/dblib/unittests/Makefile.am src/dblib/unittests/setnull.c(added): - - add a test for setnull - -Sun Dec 2 17:58:40 EST 2007 JK Lowden - * doc/api_status.txt - * include/dblib.h include/sybdb.h include/tds.h - * src/ctlib/blk.c src/dblib/bcp.c src/dblib/dblib.c - - full implementation of dbsetnull(). - - Replaced _DB_GETCOLINFO macro with dbcolptr(). - -Sat Dec 1 14:05:54 EST 2007 JK Lowden - * src/dblib/bcp.c src/dblib/unittests/null.c - - correct TDS 5.0 bcp offset table calcuation in presence of NULLs. - -Fri Nov 30 09:54:46 CET 2007 Frediano Ziglio - * src/dblib/unittests/common.c: missing new line - -Thu Nov 29 09:03:32 CET 2007 Frediano Ziglio - * src/dblib/unittests/null2.c: improve - -Wed Nov 28 15:15:43 CET 2007 Frediano Ziglio - * configure.ac: - - include windows.h under windows - - include sql.h directly to avoid MingW problems - * include/dblib.h src/dblib/bcp.c src/dblib/dblib.c src/dblib/rpc.c: - - avoid core checking for parameters if argument are expected - * src/dblib/unittests/null.c src/dblib/unittests/null2.c: - - avoid invalid references to deallocated stack - -Wed Nov 28 09:48:50 CET 2007 Frediano Ziglio - * src/dblib/bcp.c: remove warnings - -Wed Nov 28 00:27:36 EST 2007 JK Lowden - * src/dblib/bcp.c fixed TDS 5.0 null-column bug, cf. ML - * doc/tds.html Added BCP, made 4.01 strict, validated. - -Tue Nov 27 16:12:56 CET 2007 Frediano Ziglio - * src/dblib/unittests/Makefile.am src/dblib/unittests/null2.c(added): - - test dbbind/dbnullbind with NULLs - * src/dblib/unittests/null.c: add note - -Tue Nov 27 13:37:35 CET 2007 Frediano Ziglio - * src/dblib/unittests/t0001.c src/dblib/unittests/t0022.c: - - compile with Sybase libraries - * src/dblib/unittests/t0008.c: more verbose - -Mon Nov 26 21:02:57 CET 2007 Frediano Ziglio - * src/odbc/unittests/array_out.c: fix silly core - -Mon Nov 26 19:11:12 CET 2007 Frediano Ziglio - * configure.ac include/tdsodbc.h src/odbc/odbc.c: - * src/odbc/unittests/array_out.c src/odbc/unittests/common.h: - * src/odbc/unittests/describecol.c src/odbc/unittests/freeclose.c: - * src/odbc/unittests/insert_speed.c src/odbc/unittests/timeout.c: - * src/odbc/unittests/timeout3.c src/odbc/unittests/type.c: - - minor fixes for 64bit - -Mon Nov 26 16:47:34 CET 2007 Frediano Ziglio - * configure.ac src/apps/fisql/fisql.c: - - do not use functions not availables - -Mon Nov 26 09:43:03 EST 2007 JK Lowden - * src/dblib/bcp.c src/tds/unittests/iconv_fread.c - - small changes - -Mon Nov 26 09:51:21 CET 2007 Frediano Ziglio - * src/dblib/unittests/bcp.c: fix printf - -Mon Nov 26 07:24:43 CET 2007 Frediano Ziglio - * src/odbc/unittests/array.c src/odbc/unittests/array_out.c: - * src/odbc/unittests/const_params.c src/odbc/unittests/cursor1.c: - * src/odbc/unittests/describecol.c src/odbc/unittests/freeclose.c: - * src/odbc/unittests/insert_speed.c src/odbc/unittests/raiserror.c: - * src/odbc/unittests/rpc.c src/odbc/unittests/scroll.c: - * src/tds/challenge.c: - - fix minor issues with 64bit - -Thu Nov 22 09:43:58 CET 2007 Frediano Ziglio - * configure.ac src/ctlib/Makefile.am src/dblib/Makefile.am: - * src/odbc/Makefile.am: - - do not filter symbols under MacOsX (avoid libtool problems) - -Wed Nov 21 11:31:37 EST 2007 JK Lowden - * src/ctlib/blk.c: correctly test result of cs_convert - * src/dblib/rpc.c: minor edits - * src/dblib/unittests/bcp.c src/dblib/unittests/bcp.h: - - test works for TDS 7.0. - -Tue Nov 20 23:08:15 EST 2007 JK Lowden - * src/dblib/bcp.c src/dblib/unittests/bcp.c: - * src/dblib/dblib.c src/tds/convert.c src/tds/net.c: - - small changes - -Thu Nov 15 14:32:50 CET 2007 Frediano Ziglio - * src/dblib/unittests/.cvsignore src/dblib/dblib.c: - * src/dblib/unittests/Makefile.am src/dblib/unittests/null.c: - - fix problem with empty string and TEXT - - add a test to test empty/NULL behavior of dbdatlen/dbdata - -Thu Nov 15 10:18:40 CET 2007 Frediano Ziglio - * src/tds/login.c: return error if no username given and no Kerberos - -Tue Nov 13 10:13:06 CET 2007 Frediano Ziglio - * include/tds.h src/tds/challenge.c src/tds/gssapi.c: - * src/tds/login.c src/tds/token.c: - - port ntlm to new authentication code - - move all ntlm stuff to challenge.c - -Mon Nov 12 17:15:03 EST 2007 JK Lowden - * include/sybdb.h src/dblib/bcp.c - * src/dblib/dblib.c src/dblib/dbutil.c - * src/dblib/rpc.c - * src/tds/log.c src/tds/login.c - - trying to convince Doxygen not to ignore functions, - - e.g. dbinit - -Mon Nov 12 13:38:04 EST 2007 JK Lowden - * include/dblib.h src/dblib/dbutil.c - * src/dblib/dblib.c src/dblib/rpc.c src/dblib/bcp.c - - added DBDEAD test to all public functions - -Mon Nov 12 14:32:53 CET 2007 Frediano Ziglio - * configure.ac: cleanup - * src/tds/gssapi.c: compute fqdn name in service name - -Mon Nov 12 12:34:14 CET 2007 Frediano Ziglio - * configure.ac include/tds.h src/tds/gssapi.c: - * src/tds/login.c src/tds/mem.c src/tds/token.c: - - new TDSAUTHENTICATION structure - - new --enable-krb5 to enable Kerberos authentication - (disable by default) - -Fri Nov 09 11:29:21 CET 2007 Frediano Ziglio - * src/apps/tsql.c: remove some leaks - -Mon Nov 05 11:05:34 CET 2007 Frediano Ziglio - * src/apps/tsql.c: use pipes to avoid infinite counter - -Mon Nov 05 09:29:54 CET 2007 Frediano Ziglio - * src/tds/login.c: fix log avoidance for long logins - -Sun Nov 04 09:16:08 CET 2007 Frediano Ziglio - * src/tds/gssapi.c: small cleanup - -Sat Nov 03 14:31:40 CET 2007 Frediano Ziglio - * include/tds.h src/tds/config.c src/tds/mem.c: - - add server_host_name to TDSCONNECTION - * src/tds/gssapi.c: some improves - -Fri Nov 02 11:33:16 CET 2007 Frediano Ziglio - * src/tds/gssapi.c: add small comment - -Tue Oct 30 16:45:41 CET 2007 Frediano Ziglio - * src/tds/Makefile.am src/tds/gssapi.c src/tds/login.c: - - include developing code for GSSAPI - -Tue Oct 30 16:36:29 CET 2007 Frediano Ziglio - * include/tds.h src/tds/login.c src/ctlib/ct.c src/tds/read.c: - * src/tds/token.c: - - finish merging tds9 code as developing - -Tue Oct 30 16:02:04 CET 2007 Frediano Ziglio - * include/tdsodbc.h src/odbc/odbc.c: - - make odbc row_count 64bit - -Tue Oct 30 13:14:00 CET 2007 Frediano Ziglio - * src/tds/config.c src/tds/query.c: - - more merge for tds9 - -Tue Oct 30 11:31:30 CET 2007 Frediano Ziglio - * include/tds.h src/ctlib/blk.c src/dblib/bcp.c: - * src/server/server.c src/tds/token.c: - - merge partially tds9 patch - -Tue Oct 30 11:15:20 CET 2007 Frediano Ziglio - * src/tds/net.c: - - avoid wrong assert if error and tdserror called - * src/tds/query.c: limit data length to maximun allowed - -Wed Oct 24 17:55:56 EDT 2007 JK Lowden - * include/sqldb.h define dbfreelogin - * src/dblib/unittests/common.h add commentary - -Tue Oct 23 19:41:03 EDT 2007 JK Lowden - * src/tds/net.c src/tds/util.c - - ct-lib seems OK with EINTR (sqsh works) but db-lib - - applications get a weird message. - -Tue Oct 23 18:08:00 EDT 2007 JK Lowden - * src/tds/net.c - - return from tds_select as if timed out on EINTR. - - sqsh still unhappy when ^C pressed on long-running query. - -Thu Oct 18 16:48:23 CET 2007 Frediano Ziglio - * src/dblib/dblib.c: fix core - -Thu Oct 18 13:49:51 CET 2007 Frediano Ziglio - * src/tds/query.c src/tds/token.c: - - more free(NULL) - -Tue Oct 16 16:59:06 CET 2007 Frediano Ziglio - * src/apps/tsql.c src/ctlib/blk.c src/ctlib/cs.c src/ctlib/ct.c: - * src/dblib/bcp.c src/dblib/dblib.c src/dblib/rpc.c: - * src/dblib/unittests/rpc.c src/odbc/error.c src/odbc/odbc.c: - * src/odbc/sql2tds.c src/odbc/unittests/binary_test.c: - * src/pool/config.c src/tds/locale.c src/tds/login.c: - * src/tds/mem.c src/tds/query.c src/tds/token.c: - * src/tds/vstrbuild.c src/tds/unittests/dataread.c: - - do not check for free(NULL) - -Wed Oct 10 13:59:37 EDT 2007 JK Lowden - * src/apps/tsql.c - - added some error checking for malloc/realloc, more needed - -Tue Oct 09 13:40:24 CET 2007 Frediano Ziglio - * src/tds/mem.c: fix small memory leak - -Mon Sep 24 13:12:47 CET 2007 Frediano Ziglio - * src/tds/query.c: limit size preparing queries - -Mon Sep 24 12:01:46 CET 2007 Frediano Ziglio - * src/server/query.c src/server/server.c: - - small server improve - -Thu Sep 20 17:32:15 CET 2007 Frediano Ziglio - * include/sybdb.h src/dblib/dblib.c src/dblib/dbopen.c: - - apply constify patch #1786200 - -Thu Sep 20 17:02:20 CET 2007 Frediano Ziglio - * src/apps/tsql.c: do not strip empty lines - -Mon Sep 17 17:22:32 EDT 2007 JK Lowden - * src/dblib/bcp.c correct freebcp -L behavior - * src/tds/net.c TDSECONN on no socket failure - * src/tds/util.c change iconv messages - -Mon Sep 17 17:52:09 CET 2007 Frediano Ziglio - * doc/tds.html: update for tds9 - * src/server/login.c: remove warning - -Mon Sep 17 12:13:03 CET 2007 Frediano Ziglio - * src/apps/tsql.c: - - improve for very large query (from 9.2 to 0.3 seconds on my - test machine) - -Mon Sep 17 10:42:45 CET 2007 Frediano Ziglio - * doc/tds.html: update - * src/ctlib/unittests/get_send_data.c: small fix - * include/sybdb.h src/dblib/dblib.c src/dblib/unittests/t0022.c: - - small update for future tds9 - * src/pool/main.c src/pool/user.c src/server/login.c: - - improve portability and possible remote leakage - -Thu Sep 13 12:42:08 CET 2007 Frediano Ziglio - * src/odbc/unittests/freeclose.c: - - make it works even if login is quite long - -Thu Sep 13 08:57:26 CET 2007 Frediano Ziglio - * src/tds/unittests/dynamic1.c: use tds_set_param_type - -Thu Sep 06 13:15:54 CET 2007 Frediano Ziglio - * doc/tds.html: update for tds9 - * src/tds/read.c: work if initial in_pos is != 0 - -Sat Aug 25 12:32:01 CET 2007 Frediano Ziglio - * include/tdsodbc.h src/odbc/error.c src/odbc/odbc.c: - - use ODBC_API instead of SQL_API to allow combined compile - -Fri Aug 24 11:50:03 CET 2007 Frediano Ziglio - * include/tds.h src/ctlib/blk.c src/dblib/bcp.c src/tds/login.c: - * src/tds/query.c src/tds/token.c: - - small changes for TDS 9.0 - -Mon Aug 16 10:09:42 CET 2007 Frediano Ziglio - * src/ctlib/unittests/Makefile.am src/dblib/unittests/Makefile.am: - * src/odbc/unittests/Makefile.am src/tds/net.c: - * src/tds/unittests/Makefile.am: - - remove other warnings - -Mon Aug 16 08:29:38 CET 2007 Frediano Ziglio - * src/tds/unittests/convert.c win32/initnet.c: - - remove some warnings compiling with MingW - -Sat Aug 11 08:51:45 CET 2007 Frediano Ziglio - * src/dblib/dblib.c vms/config_h.vms vms/descrip_mms.template: - - applied Craig A. Berry patch #1772080 for VMS systems - -Fri Aug 10 11:17:32 CET 2007 Frediano Ziglio - * NEWS: updated - -Fri Aug 10 11:14:19 CET 2007 Frediano Ziglio - * win32/dev-cpp/Makefile.win: add missing file - -Thu Aug 09 14:52:45 CET 2007 Frediano Ziglio - * src/tds/net.c: small fixes - -Thu Aug 09 10:26:51 CET 2007 Frediano Ziglio - * doc/userguide.sgml: document port override syntax - -Thu Aug 09 09:49:34 CET 2007 Frediano Ziglio - * doc/htdoc/basic_jdbc_question.html doc/htdoc/contrib.html: - * doc/htdoc/docs.html doc/htdoc/index.html doc/htdoc/news.html: - * doc/htdoc/software.html doc/htdoc/support.html: - * doc/htdoc/vague_jdbc_question.html doc/htdoc/which_api.html: - - make xhtml compatible - -Wed Aug 08 15:24:16 CET 2007 Frediano Ziglio - * configure.ac src/odbc/Makefile.am win32/version.rc.in: - - fix odbc cross compile using MingW - -Wed Aug 08 11:34:40 CET 2007 Frediano Ziglio - * misc/freetds_autobuild: - - improved adding test for server:port and server\instance case - -Wed Aug 08 11:10:36 CET 2007 Frediano Ziglio - * src/tds/config.c: fix bug #1759652 (cannot use server\INSTANCE) - -Tue Aug 07 15:34:34 CET 2007 Frediano Ziglio - * src/odbc/odbc.c: improve cursor updates - * src/odbc/unittests/cursor1.c: improved and fixed - -Tue Aug 07 11:55:53 CET 2007 Frediano Ziglio - * src/tds/query.c: use table name for update - -Tue Aug 07 11:19:33 CET 2007 Frediano Ziglio - * include/tds.h src/odbc/odbc.c src/odbc/unittests/getdata.c: - - fix bug #1758831 - - additional fixes and checks for SQLGetData - -Tue Aug 07 10:29:55 CET 2007 Frediano Ziglio - * doc/userguide.sgml: update links - -Fri Aug 03 13:15:42 CET 2007 Frediano Ziglio - * src/tds/config.c: lookup server name correctly for instances - -Thu Aug 02 13:31:45 CET 2007 Frediano Ziglio - * include/sqlfront.h: small compatiblity improve with ms - -Fri Jul 13 18:56:56 CET 2007 Frediano Ziglio - * src/odbc/unittests/getdata.c: portability fix - -Thu Jul 12 16:31:05 CET 2007 Frediano Ziglio - * src/odbc/odbc.c: fix for SQLGetData using empty fields - * src/odbc/unittests/getdata.c: - - improve test to catch previous problem - -Sat Jul 07 19:55:30 CET 2007 Frediano Ziglio - * m4/sprintf_i64_format.m4: improve portability - -Sat Jul 07 19:09:59 CET 2007 Frediano Ziglio - * src/odbc/odbc.c: - - check cbValueMax in SQLGetData even if DM present - -Tue Jul 03 17:12:04 CET 2007 Frediano Ziglio - * src/odbc/unittests/compute.c src/odbc/unittests/tables.c: - * src/odbc/unittests/typeinfo.c: - - relax test for Sybase - * src/tds/token.c: fix length computation - -Tue Jul 03 15:37:03 CET 2007 Frediano Ziglio - * include/tds.h src/ctlib/blk.c src/dblib/bcp.c src/dblib/dblib.c: - * src/odbc/odbc.c src/tds/mem.c src/tds/token.c: - - add table_column_name to read real column name (if available), - read from wire and use when needed - -Sun Jul 01 12:10:31 CET 2007 Frediano Ziglio - * include/tdsstring.h src/odbc/connectparams.c: - * src/odbc/descriptor.c src/odbc/odbc.c src/tds/config.c: - * src/tds/tdsstring.c: - - added tds_dstr_dup to duplicate DSTR - - use tds_dstr_dup - - improve tds_dstr_set - -Wed Jun 27 16:51:30 CET 2007 Frediano Ziglio - * doc/tds.html: add Column Info token - * src/odbc/unittests/timeout2.c: portability fix - -Mon Jun 25 11:47:14 CET 2007 Frediano Ziglio - * doc/api_status.txt include/cspublic.h include/ctlib.h: - * src/ctlib/cs.c src/ctlib/ct.c: - - applied patch #1729392, it adds support for ctlib locale - -Mon Jun 25 10:20:00 CET 2007 Frediano Ziglio - * src/odbc/odbc.c: review cursors - -Thu Jun 21 09:19:32 CET 2007 Frediano Ziglio - * misc/freetds_autobuild: test for Sybase 15 - * src/odbc/unittests/data.c: bigint for Sybase - * src/tds/data.c src/tds/mem.c src/tds/read.c src/tds/tds_checks.c: - - add support for Sybase bigint - - do not check decault capabilities if not necessary - -Tue Jun 19 15:30:12 CET 2007 Frediano Ziglio - * include/tds.h src/ctlib/ct.c src/odbc/odbc_util.c: - * src/pool/stream.c src/tds/data.c src/tds/net.c: - * src/tds/tds_checks.c src/tds/tds_checks.h src/tds/token.c: - - fix problem with Sybase LONGCHAR - -Tue Jun 19 14:06:55 CET 2007 Frediano Ziglio - * src/ctlib/unittests/t0007.c src/odbc/unittests/prepare_results.c: - - more verbose - - fix for possible Sybase conversion - * src/odbc/odbc.c: additional check if no dm - -Mon Jun 18 15:20:00 CET 2007 Frediano Ziglio - * src/tds/convert.c: - - patch #1736289 for bcp/bulk insert problem - -Mon Jun 18 14:02:45 CET 2007 Frediano Ziglio - * src/apps/tsql.c src/tds/locale.c: - - use correct charset based on locale - -Mon Jun 18 13:58:34 CET 2007 Frediano Ziglio - * src/odbc/unittests/genparams.c: remove warning - -Sun Jun 17 19:38:27 CET 2007 Frediano Ziglio - * src/odbc/unittests/freeclose.c src/odbc/unittests/timeout3.c: - - fix small thread problem - - fix possible deadlock - -Sun Jun 17 09:45:55 CET 2007 Frediano Ziglio - * src/odbc/unittests/freeclose.c src/odbc/unittests/genparams.c: - - fix thread and small portability - -Sun Jun 17 09:08:03 CET 2007 Frediano Ziglio - * include/dblib.h src/dblib/buffering.h src/dblib/dblib.c: - - patch #1717123 for dbsetnull implementation (removed warnings) - -Sun Jun 17 08:16:50 CET 2007 Frediano Ziglio - * src/apps/tsql.c: - - patch #1703363 for delimiters (modified) - -Wed Jun 13 09:26:00 CET 2007 Frediano Ziglio - * src/apps/fisql/fisql.c: compile even if readline is not available - -Mon Jun 4 17:09:03 EDT 2007 JK Lowden - * src/apps/Makefile.am skip bsqlodb if ODBC disabled - -Mon Jun 04 10:03:25 CET 2007 Frediano Ziglio - * src/dblib/unittests/.cvsignore src/dblib/unittests/Makefile.am: - * src/dblib/unittests/hang.c(added) src/tds/net.c: - - fix problem with tds_select (detected by Perception Technologies) - -Fri Jun 01 10:52:46 CET 2007 Frediano Ziglio - * src/tds/token.c: avoid overflow leading to memory errors - -Thu May 31 17:02:43 CET 2007 Frediano Ziglio - * src/tds/net.c: - - fixes, partially from Brent of Perception Technologies Ltd - -Thu May 31 10:54:14 EDT 2007 JK Lowden - * TODO add recent potential bug reports - -Thu May 31 14:21:35 CET 2007 Frediano Ziglio - * m4/ac_nullzero.m4: fix cross compile test - -Wed May 30 09:55:52 CET 2007 Frediano Ziglio - * src/tds/threadsafe.c: - - implement gethostbyname_r with getaddrinfo (for UnixWare 7 and others) - -Tue May 29 10:48:45 CET 2007 Frediano Ziglio - * configure.ac win32/config.h: cleanup - -Fri May 25 11:07:04 CET 2007 Frediano Ziglio - * src/odbc/convert_tds2sql.c: - - remove a FIXME - * src/odbc/odbc.c: - - fix bug #1716594 ("SQLFreeStmt with SQL_CLOSE shouldn't - unprepare statement") - * src/odbc/unittests/Makefile.am src/odbc/unittests/freeclose.c(added) - * src/odbc/unittests/.cvsignore: - - add a test for bug #1716594 - -Mon May 21 14:01:13 CET 2007 Frediano Ziglio - * src/odbc/odbc.c: - - fix cursor updates, this undo part of change of src/odbc/odbc.c - from 1.331 to 1.332, log: - Wed Jul 21 16:50:11 CET 2004 - : some fix for SQLFetch and multiple rows - but tests works - * src/odbc/unittests/cursor1.c: improve - -Mon May 21 10:40:40 CET 2007 Frediano Ziglio - * src/odbc/unittests/cursor1.c: improve test - -Thu May 17 12:32:33 CET 2007 Frediano Ziglio - * include/tdsodbc.h src/odbc/odbc.c src/odbc/odbc_checks.c: - * src/odbc/odbc_util.c: - - avoid core - - fix and check invalid values of num_param_rows and curr_param_row - -Thu May 17 09:18:19 CET 2007 Frediano Ziglio - * src/odbc/unittests/warning.c: improve and comments - -Wed May 16 14:23:00 CET 2007 Frediano Ziglio - * include/tdsodbc.h src/odbc/odbc.c src/odbc/odbc_util.c: - * src/odbc/sql2tds.c: - - support row binding in RPC - - reuse new odbc_get_octet_len - -Wed May 16 14:23:00 CET 2007 Frediano Ziglio - * misc/freetds_autobuild: minor updates - -Mon May 14 16:04:08 CET 2007 Frediano Ziglio - * src/tds/login.c: remove copy error - -Mon May 14 10:16:37 CET 2007 Frediano Ziglio - * src/tds/login.c src/tds/mem.c src/tds/token.c src/tds/util.c: - - give proper errors on protocol autodiscovery - -Wed May 09 10:31:56 CET 2007 Frediano Ziglio - * src/odbc/odbc.c: finish ODBC timeout - -Fri May 03 14:54:58 CET 2007 Frediano Ziglio - * src/odbc/unittests/const_params.c: - - reset statement to be sure to cleanup - -Wed May 02 16:54:13 CET 2007 Frediano Ziglio - * include/tdsodbc.h src/odbc/odbc.c: - - use query timeout from freetds.conf - -Mon Apr 30 15:14:08 CET 2007 Frediano Ziglio - * src/odbc/odbc.c: use default linkage for static functions - -Mon Apr 30 15:02:27 CET 2007 Frediano Ziglio - * src/ctlib/blk.c: fix strange link error using gcc 4.1 - -Mon Apr 23 09:56:05 CET 2007 Frediano Ziglio - * src/tds/net.c: fix portability issue - -Fri Apr 20 15:26:15 CET 2007 Frediano Ziglio - * src/odbc/unittests/cursor1.c src/odbc/unittests/cursor2.c: - * src/odbc/unittests/scroll.c: - - make valgrind more happy if Sybase is used - -Fri Apr 20 11:13:40 CET 2007 Frediano Ziglio - * src/odbc/odbc.c src/odbc/unittests/Makefile.am: - * src/odbc/unittests/timeout4.c(added): - - add a test for timeout - - fix timeout on prepare (not detected) - - fix timeout if connection broken - -Thu Apr 19 11:11:55 CET 2007 Frediano Ziglio - * src/odbc/unittests/cursor1.c src/odbc/unittests/cursor2.c: - * src/odbc/unittests/scroll.c: - - give only warning for Sybase - -Thu Apr 19 10:45:15 CET 2007 Frediano Ziglio - * include/tdsodbc.h src/odbc/odbc.c: - - say we not still support cursors for sybase - -Wed Apr 18 16:28:29 CET 2007 Frediano Ziglio - * TODO.freddy include/tdsodbc.h src/odbc/odbc.c: - * src/odbc/odbc_util.c src/odbc/prepare_query.c src/odbc/sql2tds.c: - - fix cursor updates - -Mon Apr 16 22:08:07 EDT 2007 JK Lowden - * src/apps/bsqlodbc.c ODBC3 conformant - -Sun Apr 15 10:01:36 CET 2007 Frediano Ziglio - * src/odbc/odbc.c: fix leak - -Fri Apr 13 17:27:20 CET 2007 Frediano Ziglio - * src/odbc/odbc.c: cursor update - -Fri Apr 13 17:22:25 CET 2007 Frediano Ziglio - * include/tds.h src/tds/query.c: - - add cursor update to libTDS - -Fri Apr 13 10:08:07 CET 2007 Frediano Ziglio - * src/apps/bsqlodbc.c: - - catch all error - - fix some memory problems - -Thu Apr 12 15:33:15 CET 2007 Frediano Ziglio - * src/odbc/unittests/funccall.c: - - add test from ML - -Thu Apr 12 15:07:09 CET 2007 Frediano Ziglio - * freetds.spec.in: fix odbc directory - * src/dblib/unittests/Makefile.am: fix for make distcheck - * src/odbc/unittests/raiserror.c src/odbc/unittests/warning.c: - - relax if dm used - -Thu Apr 12 09:47:39 CET 2007 Frediano Ziglio - * src/odbc/odbc.c src/odbc/unittests/copydesc.c: - - test and fix a problem with SQLAllocHandle - * src/odbc/unittests/connect2.c: add test for not existing dbs - -Thu Apr 12 09:05:56 CET 2007 Frediano Ziglio - * src/ctlib/unittests/array_bind.c src/ctlib/unittests/ct_diagall.c: - * src/ctlib/unittests/ct_diagclient.c: - - fix buffer overflow leading in core - -Wed Apr 11 14:55:32 CET 2007 Frediano Ziglio - * src/dblib/unittests/common.c src/odbc/unittests/common.c: - - remove warning compiling with MingW - -Wed Apr 11 13:52:50 CET 2007 Frediano Ziglio - * src/odbc/connectparams.c src/odbc/odbc.c: - * src/odbc/unittests/connect2.c: - - finish and fix test for change_database - -Wed Apr 11 11:47:08 CET 2007 Frediano Ziglio - * src/odbc/unittests/connect2.c: fix test - * src/odbc/unittests/describecol.in: relax test - -Wed Apr 11 09:09:13 CET 2007 Frediano Ziglio - * src/odbc/unittests/connect2.c src/odbc/unittests/Makefile.am: - - add a test for change_database - -Tue Apr 10 16:00:47 CET 2007 Frediano Ziglio - * include/tdsodbc.h src/odbc/odbc.c src/odbc/odbc_util.c: - - fixes for describecol test - -Tue Apr 10 15:16:28 CET 2007 Frediano Ziglio - * misc/coverage.sh: remove system files - * src/odbc/unittests/describecol.in: relax test - -Fri Apr 06 10:52:25 CET 2007 Frediano Ziglio - * include/tdssrv.h src/server/login.c src/server/unittest.c: - - remove warning - -Fri Apr 06 10:29:31 CET 2007 Frediano Ziglio - * NEWS src/odbc/unittests/funccall.c src/tds/mem.c: - * src/tds/query.c: - - added some notes - -Thu Apr 05 16:16:47 CET 2007 Frediano Ziglio - * INSTALL INSTALL.CVS NEWS README doc/userguide.sgml: - - merge from 0.64 - -Wed Apr 04 13:39:27 CET 2007 Frediano Ziglio - * NEWS: updated - -Wed Apr 04 11:53:20 CET 2007 Frediano Ziglio - * include/tds.h include/tdsodbc.h src/ctlib/ct.c src/dblib/rpc.c: - * src/odbc/prepare_query.c src/odbc/sql2tds.c src/tds/mem.c: - * src/tds/token.c src/tds/unittests/dynamic1.c: - - removed unused paramter from tds_alloc_param_data - - fix possible problem in prepare_rpc - -Wed Apr 04 11:39:12 CET 2007 Frediano Ziglio - * vms/descrip_mms.template: add log.c - * src/server/query.c: use constants - -Wed Apr 04 09:14:47 CET 2007 Frediano Ziglio - * doc/userguide.sgml: improve slow check - -Tue Apr 03 16:23:17 CET 2007 Frediano Ziglio - * win32/dev-cpp/FreeTDS.dev win32/dev-cpp/Makefile.win: - - updated adding log.c - -Mon Apr 02 17:06:43 CET 2007 Frediano Ziglio - * doc/userguide.sgml: add encryption parameter - -Thu Mar 29 16:32:50 CET 2007 Frediano Ziglio - * src/ctlib/blk.c: initial fix for bcp state - -Thu Mar 29 16:25:24 CET 2007 Frediano Ziglio - * include/tds.h src/server/login.c src/tds/config.c: - * src/tds/login.c: - - added encryption setting in freetds.conf - -Thu Mar 29 12:17:34 CET 2007 Frediano Ziglio - * configure.ac: check includes for ODBC - -Thu Mar 29 09:44:11 CET 2007 Frediano Ziglio - * src/odbc/unittests/genparams.c: add test for money - -Wed Mar 28 14:43:34 CET 2007 Frediano Ziglio - * freetds.spec.in src/odbc/unittests/Makefile.am: - - fix test-dist test - -Mon Mar 26 13:27:51 CET 2007 Frediano Ziglio - * src/dblib/unittests/.cvsignore src/dblib/unittests/Makefile.am: - * src/odbc/unittests/.cvsignore src/odbc/unittests/Makefile.am: - * win32/build_dsw.pl: - - distribute projects for vc6 unittests - -Mon Mar 26 10:05:47 CET 2007 Frediano Ziglio - * doc/htdoc/news.html: validate page - -Sun Mar 24 09:23:21 CET 2007 Frediano Ziglio - * src/apps/bsqlodbc.c: - - avoid dangerous casts - -Tue Mar 20 16:24:26 CET 2007 Frediano Ziglio - * src/replacements/gettimeofday.c src/apps/datacopy.c: - - remove warning - -Mon Mar 19 11:01:05 CET 2007 Frediano Ziglio - * include/replacements.h: fix warning for win32 - -Sun Mar 18 12:37:47 CET 2007 Frediano Ziglio - * src/dblib/unittests/common.c src/odbc/unittests/timeout2.c: - * src/odbc/unittests/timeout3.c: - - fix cross-compile for win32 - -Sun Mar 18 12:09:57 CET 2007 Frediano Ziglio - * src/apps/Makefile.am src/apps/bsqlodbc.c src/apps/tsql.c: - * src/apps/fisql/Makefile.am win32/winsetup.c: - - fix cross-compile for win32 - -Fri Mar 16 16:32:08 CET 2007 Frediano Ziglio - * include/Makefile.am src/tds/Makefile.am: - - full libTDS privatization - * src/server/unittest.c: use mnemonic - -Wed Mar 14 17:18:23 CET 2007 Frediano Ziglio - * doc/tds.html: update - * include/tdssrv.h src/pool/user.c src/server/login.c: - * src/server/query.c src/server/server.c src/server/unittest.c: - - update server stuff, at least login works - * src/tds/tdsstring.c: fix possible mising NUL terminator - * src/apps/tsql.c: fix wrong error handler result - -Wed Mar 14 09:47:24 CET 2007 Frediano Ziglio - * doc/tds.html include/tds.h: update documentation - -Tue Mar 13 17:24:54 CET 2007 Frediano Ziglio - * include/tds.h src/pool/user.c src/server/login.c: - * src/server/unittest.c src/tds/login.c src/tds/query.c: - - use mnemonic for packet types - -Tue Mar 13 16:45:54 CET 2007 Frediano Ziglio - * doc/tds.html: added known tokens - -Tue Mar 13 14:18:03 CET 2007 Frediano Ziglio - * doc/tds.html: updated from code - -Mon Mar 12 14:27:14 CET 2007 Frediano Ziglio - * include/ctlib.h include/dblib.h include/des.h include/md4.h: - * include/md5.h include/replacements.h include/tdsiconv.h: - * include/tdsstring.h include/replacements/readpassphrase.h: - * src/server/Makefile.am: - - privatize functions using gcc visibility if available - - privatize server library - -Mon Mar 12 13:31:32 CET 2007 Frediano Ziglio - * src/ctlib/unittests/blk_in2.c(added) src/ctlib/unittests/Makefile.am: - - added test from ML to test cancel and bulk together - -Mon Mar 12 10:52:12 CET 2007 Frediano Ziglio - * doc/tds.html: improved, added types - -Fri Feb 16 14:52:10 CET 2007 Frediano Ziglio - * include/tds.h: improve documentation - -Mon Feb 12 14:29:53 EST 2007 Nick Castellano - * src/dblib/dblib.c: Increase size of dbprrow() conversion buffer to 8K. - -Mon Feb 12 10:53:54 CET 2007 Frediano Ziglio - * src/odbc/unittests/timeout3.c: - - use thread instead of fork - -Wed Feb 7 01:11:27 EST 2007 JK Lowden - * src/apps/bsqlodbc.c don't exit on SQL_SUCCESS_WITH_INFO - -Wed Feb 7 00:04:15 EST 2007 JK Lowden - * src/apps/bsqldb.c exit noisily on severe errors - * src/dblib/dblib.c src/tds/token.c - - fix timeout with buffering problem per yesterday's ML. - -Tue Feb 6 17:14:50 EST 2007 Nick Castellano - * src/dblib/dblib.c: - - Sybase docs for dbsqlok() says: "If the command buffer contains - multiple commands, a run-time error will not cause dbsqlok to - fail. Instead, failure will occur with the dbresults call that - processes the command causing the run-time error." - * src/apps/fisql/fisql.c: - - Correct result set processing. - -Tue Feb 6 14:11:02 EST 2007 Nick Castellano - * src/dblib/dblib.c: Don't print or store column separator after final result column - -Tue Feb 06 10:18:00 CET 2007 Frediano Ziglio - * configure.ac src/odbc/Makefile.am: - - use -module option only for darwin - -Tue Feb 06 09:53:14 CET 2007 Frediano Ziglio - * src/apps/bsqlodbc.c: - - make more functions static - - remove warning - * src/tds/net.c: remove warning - -Mon Feb 5 21:48:58 EST 2007 JK Lowden - * src/apps/Makefile.am src/apps/bsqlodbc.c src/apps/osql - - added bsqlodbc as general batch script processor. - -Mon Feb 05 09:41:02 CET 2007 Frediano Ziglio - * misc/test-other.sh phptests/null.php: - - fixed PHP check, updated test to PHP 5.2 - -Fri Feb 02 11:51:19 CET 2007 Frediano Ziglio - * configure.ac src/odbc/odbc.c src/odbc/unittests/.cvsignore: - * src/odbc/unittests/Makefile.am src/odbc/unittests/timeout3.c(added): - - added a test for connection timeout - - fix timeout connection in odbc - -Mon Jan 29 12:02:39 CET 2007 Frediano Ziglio - * include/tds_sysdep_private.h src/apps/fisql/fisql.c: - * src/tds/net.c: - - remove some warnings - -Fri Jan 26 18:19:57 CET 2007 Frediano Ziglio - * src/apps/fisql/fisql.c: - - remove warning - - reuse malloc - - fix compile error including config.h - * src/dblib/dblib.c: remove warning - -Fri Jan 26 18:06:44 CET 2007 Frediano Ziglio - * src/odbc/error.c src/odbc/odbc.c: - - remove warning compiling - -Wed Jan 24 14:14:55 EST 2007 Nick Castellano - * doc/fisql.txt: compute rows in fisql work now, remove BUGS entry - -Wed Jan 24 14:11:56 EST 2007 Nick Castellano - * src/apps/fisql/fisql.c: indent - -Wed Jan 24 14:08:09 EST 2007 Nick Castellano - * src/apps/fisql/fisql.c: good enough compute layout - -Wed Jan 24 12:24:30 EST 2007 Nick Castellano - * src/apps/fisql/fisql.c: almost correct compute layout - -Wed Jan 24 11:32:56 EST 2007 Nick Castellano - * src/apps/fisql/fisql.c: minor compute layout fixes, still more to do - -Tue Jan 23 17:15:33 EST 2007 Nick Castellano - * src/apps/fisql/fisql.c: better compute results, layout needs fixing - -Tue Jan 23 11:24:40 EST 2007 Nick Castellano - * src/dblib/dblib.c: fix off-by-one bug in dbbylist() - -Mon Jan 22 15:54:02 EST 2007 Nick Castellano - * src/apps/fisql/fisql.c: fix :r with unreadable file - -Mon Jan 22 15:50:31 EST 2007 Nick Castellano - * src/dblib/dblib.c: print line separator after compute results - -Mon Jan 22 00:56:12 EST 2007 JK Lowden - * src/odbc/connectparams.c src/odbc/error.c - * src/odbc/odbc.c - - added log entry for API functions - * src/odbc/unittests/common.c always use '/' separator - -Sat Jan 20 15:24:03 EST 2007 JK Lowden - * include/dblib.h include/sybdb.h src/dblib/dblib.c - - moved DBOPTION to dblib.h and removed unused members. - -Sat Jan 20 01:29:36 EST 2007 JK Lowden - * doc/defncopy.txt doc/fisql.txt cleanup formatting - * src/apps/bsqldb.c src/dblib/dblib.c fix compute row headers - -Sat Jan 20 01:30:22 EST 2007 Nick Castellano - * ChangeLog src/apps/fisql/edit.c src/apps/fisql/edit.h - * src/apps/fisql/fisql.c src/apps/fisql/handlers.c - * src/apps/fisql/handlers.h src/apps/fisql/interrupt.c - * src/apps/fisql/interrupt.h src/apps/fisql/terminal.c - * src/apps/fisql/terminal.h: - - Fix my name and the program name - -Sat Jan 20 01:20:39 EST 2007 Nick Castellano - * src/apps/fisql/fisql.c: - - Be slightly less stupid about compute rows. - -Sat Jan 20 00:54:57 EST 2007 Nick Castellano - * src/dblib/dblib.c: - - do not return bogus nul character in dbgetchar() - -Sat Jan 20 00:35:45 EST 2007 Nick Castellano - * src/dblib/dblib.c: - - dbspr*() functions get nul termination not line termination - -Fri Jan 19 22:39:00 EST 2007 Nick Castellano - * doc/fisql.txt: restore compute rows BUGS entry. - -Fri Jan 19 14:05:13 EST 2007 Nick Castellano - * src/apps/fisql/fisql.c: - - Provide xmalloc() and xrealloc() instead of relying on - libreadline for these. - -Fri Jan 19 13:47:42 EST 2007 Nick Castellano - * src/apps/fisql/Makefile.am - * src/apps/fisql/fisql.c - * src/apps/fisql/xgetpass.c(removed) - * src/apps/fisql/xgetpass.h(removed): - - use readpassphrase() in fisql application. - -Fri Jan 19 13:31:31 EST 2007 Nick Castellano - * src/apps/fisql/edit.c src/apps/fisql/fisql.c - * src/apps/fisql/handlers.c src/apps/fisql/handlers.h - * src/apps/fisql/interrupt.c src/apps/fisql/interrupt.h - * src/apps/fisql/terminal.c src/apps/fisql/terminal.h - * src/apps/fisql/xgetpass.c: - - Indent fisql to standard FreeTDS coding style - -Fri Jan 19 13:19:04 EST 2007 Nick Castellano - * src/apps/fisql/fisql.c: remove obsolete code - -Fri Jan 19 13:12:56 EST 2007 Nick Castellano - * doc/fisql.txt: fisql now works, update doc - -Fri Jan 19 13:01:53 EST 2007 Nick Castellano - * .cvsignore doc/.cvsignore: clean up - -Fri Jan 19 12:45:27 EST 2007 Nick Castellano - * src/dblib/dblib.c: fix dbspr1row(), fisql now works - -Fri Jan 19 11:17:13 EST 2007 JK Lowden - * doc/fisql.txt - * src/apps/fisql/edit.c src/apps/fisql/edit.h - * src/apps/fisql/handlers.c src/apps/fisql/handlers.h - * src/apps/fisql/interrupt.c src/apps/fisql/interrupt.h - * src/apps/fisql/terminal.c src/apps/fisql/terminal.h - * src/apps/fisql/xgetpass.c src/apps/fisql/xgetpass.h - * src/apps/fisql/fisql.c - - Added notice of copyright and GPL license - -Thu Jan 18 23:55:17 EST 2007 JK Lowden - * doc/Makefile.am doc/fisql.txt added man page for fisql - * src/apps/fisql/fisql.c fixed discarding const warnings - * doc/api_status.txt include/sybdb.h src/dblib/dblib.c - - added dbgettime() - -Thu Jan 18 17:57:52 EST 2007 Nick Castellano - * AUTHORS: credit myself as a contributor - -Thu Jan 18 17:50:18 EST 2007 Nick Castellano - * src/dblib/dblib.c: - - fix dbprrow() to print character data correctly - - fix dbprrow() to not loop endlessly on aggregate rows - -Thu Jan 18 08:57:10 CET 2007 Frediano Ziglio - * src/tds/unittests/utf8_2.c: fix error handler - -Wed Jan 17 09:48:45 CET 2007 Frediano Ziglio - * src/apps/fisql/fisql.c: use mkstemp instead of mktemp - * src/tds/util.c: cleanup - -Tue Jan 16 16:30:42 EDT 2007 Nick Castellano - * configure.ac - * src/apps/Makefile.am - * src/apps/fisql: contribute free DB-Libary isql application - -Tue Jan 16 09:57:35 CET 2007 Frediano Ziglio - * src/tds/util.c: fix messages - -Tue Jan 16 09:48:43 CET 2007 Frediano Ziglio - * misc/test-other.sh: fix problem with Perl 5.8.8 - * src/dblib/dblib.c: fix possible thread problem - -Tue Jan 16 00:28:28 EST 2007 JK Lowden - * include/dblib.h src/dblib/bcp.c - * src/dblib/dblib.c src/dblib/unittests/rpc.c - - support variadic form of dbperror - -Mon Jan 15 14:40:35 EST 2007 JK Lowden - * src/dblib/unittests/common.c - * src/dblib/unittests/rpc.c - * src/dblib/unittests/t0004.c - * src/dblib/unittests/t0005.c - * src/dblib/unittests/t0007.c - * src/dblib/unittests/t0019.c - * src/dblib/unittests/t0020.c - - fail if an unanticipated message/error is received - -Sun Jan 14 23:16:17 EST 2007 JK Lowden - * src/tds/config.c src/tds/login.c - - began work on autodetecting the server's TDSVER - - works with libtds, not db-lib - -Sun Jan 14 20:38:25 EST 2007 JK Lowden - * include/dblib.h include/tds.h - * src/dblib/dblib.c src/dblib/dbutil.c - * src/dblib/unittests/t0001.c src/dblib/unittests/t0012.c - * src/dblib/unittests/timeout.c - * src/tds/net.c TODO - - timeout unit test also works with dbsetinterrupt - -Sat Jan 13 17:09:05 EST 2007 JK Lowden - * src/dblib/unittests/timeout.c added - * src/dblib/dblib.c - * src/dblib/unittests/Makefile.am src/dblib/unittests/t0001.c - * src/tds/login.c src/tds/query.c src/tds/util.c - - new timeout unit test works. - -Fri Jan 12 14:28:32 CET 2007 Frediano Ziglio - * src/odbc/odbc.c: update code to new libTDS timeout code - * src/tds/net.c: handle send/recv errors - * src/tds/util.c: fix msgno if error not found in table - -Thu Jan 11 10:49:52 EST 2007 JK Lowden - * src/apps/osql - - fixed incorrect report when drivername is not a file - -Tue Jan 09 22:44:08 CET 2007 Frediano Ziglio - * src/apps/tsql.c: fix option problem - -Tue Jan 9 00:16:46 EST 2007 JK Lowden - * src/tds/net.c simpler tds_select, thanks Frediano - -Sun Jan 7 10:45:23 EST 2007 JK Lowden - * src/ctlib/ctutil.c works with tdserror() - -Sun Jan 7 00:41:19 EST 2007 JK Lowden - * include/tds.h - * src/dblib/dblib.c src/dblib/dbutil.c - * src/tds/net.c src/tds/query.c - * src/tds/token.c src/tds/util.c - - implement new timeout strategy using tds_select() and - - calling the client library's error handler (via tdserror). - - db-lib no worse than before, others not yet tested. - -Fri Jan 05 14:08:53 CET 2007 Frediano Ziglio - * include/tds.h src/tds/token.c: new token - * src/tds/util.c: optimize - -Fri Jan 5 02:08:54 EST 2007 JK Lowden - * include/tds.h src/tds/net.c src/tds/util.c - - begin new timeout strategy, not done. - -Thu Jan 4 18:47:46 EST 2007 JK Lowden - * doc/bsqldb.txt src/apps/bsqldb.c nicer headers - * doc/osql.txt src/apps/osql allow ini location override - -Tue Jan 2 15:42:09 EST 2007 JK Lowden - * include/dblib.h include/tds.h - * src/apps/tsql.c - * src/dblib/dblib.c src/dblib/dbutil.c - * src/tds/iconv.c src/tds/login.c src/tds/net.c - * src/tds/token.c src/tds/util.c - - replace tds_client_msg with tdserror() - -Mon Jan 01 12:56:50 CET 2007 Frediano Ziglio - * src/dblib/dblib.c src/tds/query.c: - - remove some warning compiling with SUN compiler - - Happy New Year - -Fri Dec 29 20:43:55 CET 2006 Frediano Ziglio - * src/tds/mem.c: remove warning and optimize - -Fri Dec 29 20:42:41 CET 2006 Frediano Ziglio - * src/apps/tsql.c: remove warnings - -Fri Dec 29 20:05:00 CET 2006 Frediano Ziglio - * include/tdsodbc.h: cleanup - -Fri Dec 29 20:03:30 CET 2006 Frediano Ziglio - * src/ctlib/unittests/rpc_ct_param.c: - * src/ctlib/unittests/rpc_ct_setparam.c src/odbc/odbc.c: - - remove warnings - -Fri Dec 29 17:18:42 CET 2006 Frediano Ziglio - * configure.ac src/tds/log.c: - - use localtime_r if available - -Fri Dec 29 10:06:56 CET 2006 Frediano Ziglio - * src/tds/log.c: - - avoid locking if no logging - -Tue Dec 26 15:57:38 CET 2006 Frediano Ziglio - * include/tds.h src/ctlib/unittests/array_bind.c: - * src/ctlib/unittests/ct_diagall.c: - * src/ctlib/unittests/get_send_data.c: - * src/ctlib/unittests/lang_ct_param.c: - * src/dblib/bcp.c src/dblib/dblib.c: - * src/dblib/dbutil.c src/dblib/rpc.c: - * src/dblib/xact.c src/dblib/unittests/common.h: - * src/dblib/unittests/t0016.c src/odbc/connectparams.c: - * src/odbc/descriptor.c src/odbc/error.c: - * src/odbc/odbc.c src/odbc/odbc_checks.c: - * src/odbc/prepare_query.c src/odbc/unittests/common.h: - * src/odbc/unittests/describecol.c src/pool/config.c: - * src/pool/main.c src/pool/member.c src/pool/stream.c: - * src/pool/user.c src/pool/util.c: - * src/replacements/readpassphrase.c: - * src/replacements/strtok_r.c src/replacements/vasprintf.c: - * src/server/login.c src/server/unittest.c: - * src/tds/config.c src/tds/convert.c src/tds/data.c: - * src/tds/getmac.c src/tds/iconv.c src/tds/locale.c: - * src/tds/login.c src/tds/net.c src/tds/numeric.c: - * src/tds/tds_checks.c src/tds/tdsstring.c src/tds/threadsafe.c: - * src/tds/write.c src/tds/unittests/common.h win32/winlogin.c: - * win32/winsetup.c: - - include stdarg.h always before stdio.h to fix portability - issues defining va_list - -Tue Dec 26 13:54:25 CET 2006 Frediano Ziglio - * src/tds/Makefile.am src/tds/util.c src/tds/log.c (added): - - separate log stuff - -Sun Dec 24 12:40:19 CET 2006 Frediano Ziglio - * src/odbc/descriptor.c: cleanup - -Fri Dec 22 09:34:37 CET 2006 Frediano Ziglio - * src/tds/convert.c: fix typo error - -Mon Dec 21 14:07:55 CET 2006 Frediano Ziglio - * src/tds/iconv.c: use cp1252 instead of iso8859-1 for mssql - -Wed Dec 20 22:47:36 EST 2006 JK Lowden - * src/tds/iconv.c src/tds/token.c log server charset changes - * src/tds/unittests/convert.c permit varbinary - -Mon Dec 18 10:50:34 CET 2006 Frediano Ziglio - * src/tds/Makefile.am: distribute enum_cap.h - -Fri Dec 15 14:41:14 EST 2006 JK Lowden - * src/tds/tds_willconvert.pl allow varbinary - -Thu Dec 14 22:18:16 EST 2006 JK Lowden - * src/tds/mem.c src/tds/unittests/t0001.c - - Added tds_capability_set and enumerated capabilities - * src/tds/enum_cap.h added - -Tue Dec 12 08:45:12 CET 2006 Frediano Ziglio - * include/tdsodbc.h src/odbc/odbc.c src/odbc/odbc_util.c: - - improve describecol test - -Sun Dec 10 16:04:02 EST 2006 JK Lowden - * doc/htdoc/faq.html minor fixes - * src/apps/tsql.c send *sybase* charset name in login record - * src/tds/net.c src/tds/read.c a little less logging - -Thu Dec 7 17:06:50 CET 2006 Frediano Ziglio - * src/tds/token.c: make get_send_data works - -Tue Dec 5 11:42:04 CET 2006 Frediano Ziglio - * src/odbc/unittests/funccall.c: add a test - -Fri Dec 1 16:45:59 EST 2006 JK Lowden - * include/sybdb.h src/dblib/bcp.c src/apps/freebcp.c - - Changed freetbcp batch-copied information messages to - - match the output of Sybase's bcp utility. - -Wed Nov 29 15:46:38 EST 2006 JK Lowden - * src/apps/tsql.c fixed broken "go" option handling. - -Tue Nov 28 11:52:27 EST 2006 JK Lowden - * src/apps/tsql.c fix -o option code - * src/tds/net.c reorganize tds_open_socket() - -Mon Nov 27 18:31:18 EST 2006 JK Lowden - * src/tds/net.c more detailed log of connect(2) - -Sun Nov 26 15:26:31 EST 2006 JK Lowden - * src/apps/tsql.c added connection timer feedback - * src/tds/login.c src/tds/net.c slightly better logging - -Thu Nov 23 09:43:00 CET 2006 Frediano Ziglio - * src/odbc/unittests/genparams.c: - - fix possible problem with very remote servers - -Thu Oct 26 15:09:48 EDT 2006 JK Lowden - * src/dblib/dbutil.c log error message from server - * src/tds/net.c log TDS version - -Thu Oct 26 14:26:27 EDT 2006 JK Lowden - * src/dblib/unittests/common.c src/dblib/unittests/common.h - * src/dblib/unittests/t0001.c - - corrected command-line option handling - -Sat Oct 21 16:42:08 EDT 2006 JK Lowden - * src/dblib/dblib.c src/dblib/unittests/t0022.c: - - dbresults succeeds if metadata or only return status is - - present, cf. ML yesterday. - -Sat Oct 21 14:22:44 CET 2006 Frediano Ziglio - * autogen.sh: fix some portability issues - -Wed Oct 18 21:38:57 CET 2006 Frediano Ziglio - * src/odbc/odbc.c src/odbc/unittests/tables.c: - - fix problem with mssql2005 and SQLTables - -Mon Oct 16 09:48:31 CET 2006 Frediano Ziglio - * src/tds/net.c: reduce system calls required - -Thu Oct 12 11:19:02 CET 2006 Frediano Ziglio - * src/tds/token.c: - - fix wrong assert - - return correctly RETURNSTATUS under Sybase - -Wed Oct 11 16:37:04 CET 2006 Frediano Ziglio - * src/tds/token.c: fix wrong assert using numerics - -Tue Oct 10 15:52:22 EDT 2006 JK Lowden - * doc/osql.txt clarified - -Fri Oct 6 17:08:43 EDT 2006 JK Lowden - * src/apps/freebcp.c src/apps/freebcp.h doc/freebcp.txt - - applied -0 patch from ML - - by Constantin Vasilyev - -Wed Oct 4 19:46:29 EDT 2006 JK Lowden - * src/apps/freebcp.c - - applied -P from stdin patch - - from ML Constantin Vasilyev - -Wed Oct 4 17:36:43 EDT 2006 JK Lowden - * src/apps/osql GNU sed does not support -E - -Wed Oct 4 14:48:20 EDT 2006 JK Lowden - * doc/Makefile.am doc/osql.txt added osql man page - -Wed Oct 4 14:12:25 EDT 2006 JK Lowden - * src/apps/Makefile.am add osql as installable script - -Tue Oct 3 15:40:12 EDT 2006 JK Lowden - * src/dblib/bcp.c test fwrite(3) correctly - -Tue Sep 26 16:57:42 EDT 2006 JK Lowden - * src/dblib/bcp.c src/dblib/dblib.c - * src/tds/convert.c src/tds/net.c src/tds/token.c - - added more user-level error checking, checking against - - known list of db-lib error messages - * src/apps/osql added - -Wed Sep 13 13:55:24 CET 2006 Frediano Ziglio - * samples/Makefile.am samples/unixodbc.freetds.driver.template.in: - - add Setup entry to unixODBC template - - unixODBC templates are not executables - -Wed Sep 13 13:52:40 CET 2006 Frediano Ziglio - * src/tds/mem.c: enable wide table - -Wed Sep 13 11:47:27 CET 2006 Frediano Ziglio - * src/tds/token.c: - - fix really broken tds5_process_result - -Fri Sep 08 11:58:24 CET 2006 Frediano Ziglio - * configure.ac src/tds/threadsafe.c: - - fix threadsafe problem on NetBSD - -Fri Sep 08 11:17:55 CET 2006 Frediano Ziglio - * include/tds.h src/tds/token.c: make splint a bit more happy - * src/odbc/odbc.c: small 64bit improvements - -Thu Sep 07 23:10:29 CET 2006 Frediano Ziglio - * src/odbc/sql2tds.c: fix paramset (Levente Tamási) - -Fri Sep 1 10:34:20 CET 2006 Frediano Ziglio - * include/tds.h include/tdsstring.h src/ctlib/ct.c: - * src/odbc/connectparams.c src/odbc/odbc.c src/server/login.c: - * src/tds/config.c src/tds/tdsstring.c: - - add dstr_size to DSTR - - add tds_dstr_alloc, tds_dstr_setlen, tds_dstr_buf - -Wed Aug 30 13:58:56 CET 2006 Frediano Ziglio - * include/tds.h src/tds/challenge.c src/tds/login.c: - - make tds_answer_challenge return flags - - tds_dstr fix - * src/dblib/dblib.c: small fix - * src/odbc/odbc.c: constification - * src/tds/query.c: - - some static functions rename - - do not convert string in tds7_build_param_def_from_query - * src/tds/threadsafe.c: cleanup - -Mon Aug 28 09:36:32 CET 2006 Frediano Ziglio - * include/cspublic.h: - - applied Norbert Sendetzky patch for ctlib compatibility - -Fri Aug 25 11:03:40 CET 2006 Frediano Ziglio - * src/dblib/unittests/Makefile.am src/dblib/unittests/t0017.c: - * src/dblib/unittests/t0017.in.be(added): - - fix big endian problem with t0017 test - -Fri Aug 25 09:17:37 CET 2006 Frediano Ziglio - * src/apps/tsql.c: remove 1024 char limit on tsql_readline - -Thu Aug 24 21:18:48 CET 2006 Frediano Ziglio - * src/apps/tsql.c: applied Christos Zoulas patch for no-tty - -Thu Aug 24 16:29:17 CET 2006 Frediano Ziglio - * include/sybdb.h src/dblib/dblib.c: - - do not change compatibility - * src/tds/config.c: small optimization - -Thu Aug 24 11:37:15 CET 2006 Frediano Ziglio - * m4/sprintf_i64_format.m4: fix 64bit problem for LP64 - -Thu Aug 24 11:17:26 CET 2006 Frediano Ziglio - * include/tds_sysdep_private.h src/apps/tsql.c src/ctlib/Makefile.am: - * src/dblib/Makefile.am src/tds/net.c win32/initnet.c: - * win32/winsetup.c win32/dev-cpp/FreeTDS.dev: - * win32/dev-cpp/Makefile.win win32/msvc6/FreeTDS.dsp: - - initialize socket library on win32 - -Thu Aug 24 08:32:07 CET 2006 Frediano Ziglio - * src/apps/tsql.c: - - do not print return status if quiet (patch from Christos Zoulas) - -Wed Aug 23 21:43:50 CET 2006 Frediano Ziglio - * doc/tsql.txt: applied Christos Zoulas updates - * doc/txt2man: updated - -Wed Aug 23 17:16:10 CET 2006 Frediano Ziglio - * src/tds/net.c: - - clean error before reading SO_ERROR, some system need this - * src/tds/util.c src/ctlib/ct.c: cross compile fixes - -Wed Aug 23 16:25:25 CET 2006 Frediano Ziglio - * m4/ac_tds_func_which_getpwuid_r.m4 m4/sprintf_i64_format.m4: - * configure.ac src/ctlib/cs.c src/apps/tsql.c: - * src/replacements/asprintf.c src/tds/query.c: - - fixes some cross compile issues with hp-ux - -Mon Aug 21 11:08:37 CET 2006 Frediano Ziglio - * src/dblib/dblib.c: remove small buffer overflow - -Thu Aug 17 11:13:40 CET 2006 Frediano Ziglio - * configure.ac include/tds.h src/dblib/unittests/Makefile.am: - * src/tds/net.c src/tds/query.c src/tds/token.c src/tds/util.c: - * m4/acx_pthread.m4(added): - - timeout more precise and use monotonic clock if available - - check pthread support more deeply - -Wed Aug 16 13:04:48 CET 2006 Frediano Ziglio - * src/tds/net.c: cleanup, fix possible problem under Linux - * src/tds/read.c: avoid invalid in_pos value on tds_peek - -Mon Aug 14 19:12:58 CET 2006 Frediano Ziglio - * src/ctlib/blk.c src/dblib/bcp.c src/dblib/dblib.c: - * src/dblib/unittests/common.c: - - fix warnings compiling with SUN cc - * src/dblib/unittests/thread.c: make error more verbose - -Sun Aug 13 15:02:40 CET 2006 Frediano Ziglio - * src/odbc/odbc.c src/odbc/unittests/data.c: - * src/odbc/unittests/transaction.c: - - fix minor issues with 64-bit machines - -Thu Aug 10 10:10:30 CET 2006 Frediano Ziglio - * src/ctlib/ct.c: fix possible buffer overflow - * src/replacements/gettimeofday.c: add comment - * src/tds/threadsafe.c: better and simple win implementation - * vms/descrip_mms.template win32/config.h: - * win32/dev-cpp/FreeTDS.dev win32/msvc6/libTDS.dsp: - - update build file - -Tue Aug 08 19:14:32 CET 2006 Frediano Ziglio - * doc/htdoc/index.html: update link - * src/tds/query.c: add comment - -Tue Aug 08 16:42:39 CET 2006 Frediano Ziglio - * src/tds/query.c src/tds/util.c: - - fix timeout problem setting correctly query_start_time - -Tue Aug 08 14:43:50 CET 2006 Frediano Ziglio - * src/odbc/unittests/Makefile.am: - * src/odbc/unittests/timeout2.c(added): - - added a test for timeout problem (cf "Query Time Out" on ML) - -Mon Aug 07 21:37:39 CET 2006 Frediano Ziglio - * include/tdsstring.h src/odbc/odbc_util.c: - * src/replacements/iconv.c src/tds/challenge.c: - * src/tds/config.c src/tds/convert.c: - * src/tds/iconv.c src/tds/mem.c src/tds/net.c: - * src/tds/query.c src/tds/read.c src/tds/tdsstring.c: - * src/tds/token.c src/tds/write.c: - - updated doxygen comments - -Sun Aug 06 17:54:11 CET 2006 Frediano Ziglio - * freetds.spec.in: fix rpm build on suse - -Thu Aug 03 20:30:07 CET 2006 Frediano Ziglio - * NEWS include/tds.h src/ctlib/ct.c src/odbc/odbc.c: - * src/tds/mem.c src/tds/query.c src/tds/tds_checks.c: - * src/tds/token.c src/tds/util.c: - - use reference counting for TDSCURSOR to avoid memory errors - -Thu Aug 03 10:32:37 CET 2006 Frediano Ziglio - * src/tds/unittests/iconv_fread.c(added): - * src/tds/iconv.c src/tds/unittests/.cvsignore: - * src/tds/unittests/Makefile.am: - - fix tds_iconv_fread and add a test for it - -Mon Jul 31 13:27:53 EDT 2006 JK Lowden - * src/dblib/bcp.c - - proper error message for using bcp with TDS version 4.2 - -Mon Jul 31 13:23:44 EDT 2006 JK Lowden - * include/sybdb.h src/dblib/dblib.c - - proper error message for using bcp with TDS version 4.2 - -Thu Jul 27 15:22:27 EDT 2006 JK Lowden - * samples/odbc_rpc.pl use fetchrow_array - * src/tds/unittests/Makefile.am include parent directory - -Tue Jul 25 10:16:45 CET 2006 Frediano Ziglio - * configure.ac m4/ac_nullzero.m4: add test for portability - -Tue Jul 25 10:10:22 CET 2006 Frediano Ziglio - * src/odbc/unittests/paramcore.c: updated - -Mon Jul 24 11:39:13 CET 2006 Frediano Ziglio - * src/odbc/unittests/prepclose.c: - - test with SQLExecDirect - -Mon Jul 17 15:18:48 CET 2006 Frediano Ziglio - * src/dblib/unittests/build_dsw.pl(removed): - * win32/build_dsw.pl(added) src/dblib/unittests/Makefile.am: - * src/odbc/unittests/Makefile.am: - - add a Makefile target to build projects for msvc6 - -Thu Jul 13 10:20:45 CET 2006 Frediano Ziglio - * include/tdsodbc.h src/odbc/odbc.c src/odbc/unittests/moreandcount.c: - - remove next_row_count, now useless... rpc.c works the same - -Wed Jul 12 13:23:43 EDT 2006 JK Lowden - * src/odbc/odbc.c src/tds/token.c: - - use TDS_NO_COUNT instead of bad rows_affected for next_row_count. - - src/odbc/unittests/rpc.c now works - -Wed Jul 12 16:15:14 CET 2006 Frediano Ziglio - * misc/test-other.sh: add file log - * src/odbc/unittests/rpc.c: fix uninitialized error - -Tue Jul 11 17:52:43 EDT 2006 JK Lowden - * src/odbc/odbc.c src/odbc/unittests/rpc.c: - - Better logging - -Tue Jul 11 17:28:34 CET 2006 Frediano Ziglio - * src/dblib/unittests/done_handling.c: improve - -Tue Jul 11 17:27:26 CET 2006 Frediano Ziglio - * src/odbc/unittests/paramcore.c: - - fix compatibility with sybase - -Tue Jul 11 11:56:53 CET 2006 Frediano Ziglio - * misc/online.pl: generate more friendly names - -Mon Jul 10 17:07:00 EDT 2006 JK Lowden - * src/tds/token.c src/dblib/dblib.c src/dblib/unittests/rpc.c - - dbresults does not return on DONEPROC - -Sun Jul 09 12:52:45 CET 2006 Frediano Ziglio - * doc/Makefile.am: fix compatibility problem - * src/odbc/unittests/rpc.c: fix warning - -Fri Jul 7 19:08:44 EDT 2006 JK Lowden - * include/sybdb.h src/dblib/dblib.c src/tds/token.c: - - Better logging - -Wed Jul 05 14:45:08 CET 2006 Frediano Ziglio - * src/dblib/unittests/Makefile.am src/dblib/unittests/bcp.c: - * src/dblib/unittests/common.c src/dblib/unittests/common.h: - * src/dblib/unittests/dbmorecmds.c: - * src/dblib/unittests/done_handling.c: - * src/dblib/unittests/rpc.c src/dblib/unittests/t0001.c: - * src/dblib/unittests/t0002.c src/dblib/unittests/t0003.c: - * src/dblib/unittests/t0004.c src/dblib/unittests/t0005.c: - * src/dblib/unittests/t0006.c src/dblib/unittests/t0007.c: - * src/dblib/unittests/t0008.c src/dblib/unittests/t0009.c: - * src/dblib/unittests/t0011.c src/dblib/unittests/t0012.c: - * src/dblib/unittests/t0013.c src/dblib/unittests/t0014.c: - * src/dblib/unittests/t0015.c src/dblib/unittests/t0016.c: - * src/dblib/unittests/t0017.c src/dblib/unittests/t0018.c: - * src/dblib/unittests/t0019.c src/dblib/unittests/t0020.c: - * src/dblib/unittests/t0021.c src/dblib/unittests/t0022.c: - * src/dblib/unittests/t0023.c src/dblib/unittests/text_buffer.c: - * src/dblib/unittests/thread.c: - * src/dblib/unittests/build_dsw.pl(added): - - put include stuff in common.h - - fix compile with ms dblib - - simplify testing under windows creating project files - -Wed Jul 5 18:29:21 EDT 2006 JK Lowden - * src/dblib/dblib.c src/dblib/rpc.c: - - removed nonprintable characters from TDSDUMP log - -Wed Jul 5 15:43:24 EDT 2006 JK Lowden - * src/dblib/unittests/rpc.c src/odbc/unittests/rpc.c: - - more thorough tests, currently fail - -Tue Jul 04 17:13:08 CET 2006 Frediano Ziglio - * src/odbc/unittests/Makefile.am: - * src/odbc/unittests/paramcore.c(added): - * src/odbc/unittests/.cvsignore src/odbc/sql2tds.c: - - test for core using SQLBindParameter, small fix - -Mon Jul 03 13:09:40 CET 2006 Frediano Ziglio - * src/odbc/odbc.c: - - assure there is always an error when SQL_ERROR is returned - - fix warning - -Fri Jun 30 10:31:49 EDT 2006 JK Lowden - * src/odbc/sql2tds.c assert good pointer in case user passed NULL - * src/odbc/unittests/Makefile.am src/odbc/unittests/rpc.c - - added new unit test, similar to that used in dblib. - -Thu Jun 29 17:05:35 CET 2006 Frediano Ziglio - * NEWS src/tds/challenge.c: - - fix small buffer overflow - - reuse buffer - -Thu Jun 29 14:07:42 CET 2006 Frediano Ziglio - * include/tds.h src/tds/Makefile.am src/tds/challenge.c: - * src/tds/login.c src/tds/token.c: - - add NTLM2 Session Response support - -Tue Jun 27 15:47:46 CET 2006 Frediano Ziglio - * src/dblib/unittests/done_handling.c: - - improve - - update style - - fix typo - -Mon Jun 26 16:10:02 CET 2006 Frediano Ziglio - * phptests/rpc2.php(added): - - test from Ellert van Koperen (cf "SP parameters" and - http://kb.vankoperen.nl/freetds-problems.html) - -Sun Jun 25 10:12:48 CET 2006 Frediano Ziglio - * src/odbc/unittests/warning.c: - - tested - - fix portability problem with former Sybase db - - test returned warning - -Sun Jun 25 09:50:00 CET 2006 Frediano Ziglio - * src/odbc/unittests/.cvsignore src/odbc/unittests/Makefile.am: - * src/odbc/unittests/warning.c(added): - - added warning test from John K. Hohm (cf - "Warning return as copy of last result row" on ML) - * src/odbc/unittests/describecol.c: compile fix - -Wed Jun 21 17:03:55 CET 2006 Frediano Ziglio - * src/odbc/unittests/describecol.c: - * src/odbc/unittests/describecol.in(added): - - rewrote describecol test - -Wed Jun 21 09:26:02 CET 2006 Frediano Ziglio - * src/odbc/odbc.c: improve column_length - * src/odbc/odbc_util.c: fix for odbc_sql_to_displaysize - * src/tds/iconv.c: invalid iconv_t is only -1, not NULL - -Tue Jun 20 17:52:19 EDT 2006 Nick Castellano - * src/odbc/unittests/array_out.c: - - rename variable to avoid libc symbol conflict - -Tue Jun 20 14:38:03 CET 2006 Frediano Ziglio - * src/tds/convert.c: use macro in sprintf - -Tue Jun 20 14:34:03 CET 2006 Frediano Ziglio - * src/tds/mem.c: small macro to allocate columns - -Tue Jun 20 14:33:09 CET 2006 Frediano Ziglio - * src/odbc/unittests/describecol.c: improved a lot - -Tue Jun 20 11:15:16 CET 2006 Frediano Ziglio - * src/odbc/odbc.c: catch error better - -Mon Jun 19 10:38:36 CET 2006 Frediano Ziglio - * freetds.spec.in misc/test-other.sh src/apps/Makefile.am: - * src/ctlib/Makefile.am src/dblib/Makefile.am src/odbc/Makefile.am: - * src/server/Makefile.am src/tds/Makefile.am: - * src/tds/unittests/Makefile.am: - - do not make libTDS shared library any more - -Mon Jun 19 09:57:23 CET 2006 Frediano Ziglio - * src/ctlib/ct.c src/odbc/sql2tds.c src/odbc/unittests/data.c: - * src/server/unittest.c: - - remove warning compiling with gcc4 - -Thu Jun 15 14:15:24 CET 2006 Frediano Ziglio - * configure.ac src/ctlib/unittests/cancel.c: - * src/dblib/unittests/common.c src/odbc/Makefile.am: - * src/replacements/readpassphrase.c: - - finished cross mingw32 - -Wed Jun 14 17:34:56 CET 2006 Frediano Ziglio - * src/odbc/convert_tds2sql.c: fix for date format - -Wed Jun 14 17:29:13 CET 2006 Frediano Ziglio - * configure.ac: add function - * src/apps/Makefile.am src/dblib/unittests/Makefile.am: - * src/dblib/unittests/bcp.c src/odbc/unittests/Makefile.am: - * src/replacements/Makefile.am src/replacements/gettimeofday.c: - * src/tds/unittests/Makefile.am: - - more fixes for cross mingw32 - -Wed Jun 14 13:26:42 CET 2006 Frediano Ziglio - * include/tds_sysdep_private.h src/apps/Makefile.am: - - fix for cross mingw32 - * src/odbc/unittests/describecol.c: report more clearly problems - -Tue Jun 13 20:17:16 CET 2006 Frediano Ziglio - * src/odbc/unittests/common.h src/server/unittest.c: - - small fixes for cross mingw - -Tue Jun 13 14:38:34 CET 2006 Frediano Ziglio - * src/odbc/unittests/prepclose.c(added) configure.ac: - * src/odbc/unittests/.cvsignore src/odbc/unittests/Makefile.am: - - add test to test error closing connection on SQLPrepare - -Mon Jun 12 22:02:57 CET 2006 Frediano Ziglio - * m4/sprintf_i64_format.m4: fix for cross mingw32 - -Mon Jun 12 21:52:24 CET 2006 Frediano Ziglio - * src/odbc/sql2tds.c: fix for possible uninitialized variable - -Mon Jun 12 21:48:15 CET 2006 Frediano Ziglio - * src/apps/datacopy.c src/apps/freebcp.c src/apps/freebcp.h: - * src/pool/main.c src/pool/pool.h: - - fix some issues cross compiling for mingw32 - -Mon Jun 12 16:55:59 CET 2006 Frediano Ziglio - * src/odbc/unittests/data.c: add test for date to char - -Fri Jun 9 14:33:31 EDT 2006 Nick Castellano - * src/apps/tsql.c: inhibit readline tab completion in tsql - -Fri Jun 09 11:50:55 EDT 2006 Nick Castellano - * locales.conf: use same date format as Sybase in default and en_US - -Thu Jun 08 10:18:50 CET 2006 Frediano Ziglio - * src/tds/unittests/t0007.c: - - improved to detect possible date problems - -Wed Jun 07 14:37:56 EDT 2006 Nick Castellano - * src/tds/convert.c: correctly convert dates in January - -Tue Jun 06 12:02:10 CET 2006 Frediano Ziglio - * configure.ac src/tds/config.c: - - fix tsql -C for sybase compatibility - -Tue Jun 06 11:32:24 CET 2006 Frediano Ziglio - * src/tds/mem.c: use calloc instead of malloc/memset - -Mon Jun 05 13:42:24 CET 2006 Frediano Ziglio - * src/ctlib/ct.c src/tds/token.c: - - style and cleanup - -Mon May 29 13:38:05 CET 2006 Frediano Ziglio - * m4/sprintf_i64_format.m4: fix quoting - -Mon May 29 12:58:38 CET 2006 Frediano Ziglio - * NEWS include/tds.h src/tds/token.c: - - make tds_alloc_get_string static - -Mon May 15 17:11:54 CET 2006 Frediano Ziglio - * src/odbc/odbc.c: - - applied fixes from Charlene Herring (cf. "Problems when - using odbc : SQLPutData, SQLExecDirect,Decimals" 2006/05/14 - -Sun May 14 14:34:04 CET 2006 Frediano Ziglio - * src/odbc/descriptor.c: fix memory error - -Sat May 13 10:49:40 CET 2006 Frediano Ziglio - * src/odbc/unittests/copydesc.c: improve - -Mon May 08 11:38:30 CET 2006 Frediano Ziglio - * src/odbc/descriptor.c src/odbc/unittests/Makefile.am: - * src/odbc/unittests/copydesc.c(added): add test for SQLCopyDesc - -Fri Apr 21 17:10:00 CET 2006 Frediano Ziglio - * src/odbc/sql2tds.c: use new tds_convert types - -Fri Apr 21 09:45:56 CET 2006 Frediano Ziglio - * doc/htdoc/faq.html: fix html compatibility - -Thu Apr 20 12:10:28 CET 2006 Frediano Ziglio - * src/ctlib/unittests/ct_dynamic.c: remove leak in test - -Tue Apr 17 19:47:57 CET 2006 Frediano Ziglio - * src/ctlib/ct.c: fix double free - -Mon Apr 17 10:51:09 CET 2006 Frediano Ziglio - * src/odbc/convert_tds2sql.c src/odbc/prepare_query.c: - - use new conversion style in ODBC - -Sun Apr 16 10:11:32 CET 2006 Frediano Ziglio - * include/tds.h src/tds/locale.c src/tds/mem.c: - - TDSLOCALE changes to keep ABI - -Sat Apr 15 10:18:29 CET 2006 Frediano Ziglio - * include/tdsconvert.h * src/tds/convert.c: - - add new type of conversion for copy optimizations - -Sat Apr 15 10:02:20 CET 2006 Frediano Ziglio - * src/odbc/unittests/describecol.c: fix for older Sybase versions - * src/tds/config.c: optimize option read - -Sat Apr 15 09:03:34 CET 2006 Frediano Ziglio - * src/odbc/unittests/describecol.c: remove warning - -Fri Apr 14 15:22:02 CET 2006 Frediano Ziglio - * src/odbc/unittests/describecol.c: - - improved - -Fri Apr 14 13:55:09 CET 2006 Frediano Ziglio - * src/odbc/unittests/describecol.c: - - add test for precision returned by SQLDescribeCol - -Wed Apr 12 21:41:51 CET 2006 Frediano Ziglio - * locales.conf: fix charset typo - * doc/userguide.sgml: fix attributes for locales.conf - -Wed Apr 12 15:53:18 CET 2006 Frediano Ziglio - * include/tds.h include/tds_sysdep_private.h: - * include/tds_sysdep_public.h.in include/tdsconvert.h: - * include/tdsver.h.in: - - avoid ident strings in all objects - * m4/sprintf_i64_format.m4: add Ld format - -Tue Apr 11 16:33:41 CET 2006 Frediano Ziglio - * include/tds_sysdep_public.h.in include/tdsver.h.in: - - small constification - -Tue Apr 11 13:51:43 CET 2006 Frediano Ziglio - * src/odbc/unittests/connect.c: do not fail if not FreeTDS - * src/odbc/unittests/raiserror.c: more verbose - -Mon Apr 10 18:14:17 EDT 2006 JK Lowden - * include/tds.h src/apps/tsql.c src/tds/config.c - - report sysconfdir with tsql -C - -Mon Apr 10 11:59:53 CET 2006 Frediano Ziglio - * src/odbc/odbc.c: cleanup - -Fri Apr 07 09:38:45 CET 2006 Frediano Ziglio - * misc/test-other.sh: update to php 5.1 - * phptests/nextres.php: a bit more verbose - -Thu Apr 06 11:37:45 CET 2006 Frediano Ziglio - * misc/coverage.sh: less verbose - * src/dblib/bcp.c: small change - -Wed Apr 05 08:42:54 CET 2006 Frediano Ziglio - * misc/full-test.sh: cleanup - * misc/test-auto.sh: allow configuration - * misc/test-other.sh: make output suitable for online.pl - * src/apps/tsql.c: - - improve documentation - - fix problem for multiple options - * src/odbc/odbc.c src/tds/token.c: avoid void message to application - -Wed Apr 05 07:09:32 CET 2006 Frediano Ziglio - * src/odbc/odbc.c: remove some warnings - -Wed Mar 29 18:25:54 CET 2006 Frediano Ziglio - * m4/ac_caolan_func_which_gethostbyname_r.m4: - * m4/ac_have_inaddr_none.m4 m4/ac_have_malloc_options.m4: - * m4/ac_raf_func_which_getservbyname_r.m4: - * m4/ac_tds_func_which_gethostbyaddr_r.m4: - * m4/ac_tds_func_which_getpwuid_r.m4: - * m4/ac_tds_func_which_localtime_r.m4: - * m4/ax_cflags_gcc_option.m4 m4/lib-link.m4: - * m4/sprintf_i64_format.m4 m4/type_socklen_t.m4: - - quote as necessary - -Mon Mar 27 19:01:05 EST 2006 JK Lowden - * configure.ac - * m4/ac_caolan_func_which_gethostbyname_r.m4 - * m4/ac_have_inaddr_none.m4 - * m4/ac_have_malloc_options.m4 - * m4/ac_raf_func_which_getservbyname_r.m4 - * m4/ac_tds_func_which_gethostbyaddr_r.m4 - * m4/ac_tds_func_which_getpwuid_r.m4 - * m4/ac_tds_func_which_localtime_r.m4 - * m4/ax_cflags_gcc_option.m4 - * m4/sprintf_i64_format.m4 - * m4/type_socklen_t.m4 - * src/ctlib/unittests/Makefile.am - * src/dblib/unittests/Makefile.am - * src/odbc/unittests/Makefile.am - * src/tds/unittests/Makefile.am - - removed/updated obsolete autoconf macros - * m4/am_iconv.m4 removed - * m4/README.iconv - * m4/iconv.m4 m4/lib-ld.m4 m4/lib-link.m4 m4/lib-prefix.m4 - - added from GNU libiconv - -Mon Mar 27 09:48:56 EST 2006 JK Lowden - * doc/htdoc/index.html corrected nightly test link - -Mon Mar 27 10:17:42 CET 2006 Frediano Ziglio - * src/dblib/rpc.c: allow again null for fixed types - -Mon Mar 27 02:20:16 EST 2006 JK Lowden - * configure.ac m4/am_iconv.m4 m4/check_openssl.m4 - * src/apps/Makefile.am src/ctlib/Makefile.am src/dblib/Makefile.am - * src/odbc/Makefile.am src/pool/Makefile.am src/replacements/Makefile.am - * src/server/Makefile.am src/tds/Makefile.am - - modernized autotool contructs - * configure.in removed - -Sun Mar 26 19:01:43 CET 2006 Frediano Ziglio - * src/odbc/prepare_query.c: - - fixed constant parameters after mssql 2005 patch - -Fri Mar 24 16:47:26 EST 2006 JK Lowden - * configure.in removed, is now configure.ac - * acinclude.m4 removed, added m4 directory - * Makefile.am include m4 directory - * m4/ac_caolan_func_which_gethostbyname_r.m4 m4/ac_have_inaddr_none.m4 - * m4/ac_have_malloc_options.m4 m4/ac_raf_func_which_getservbyname_r.m4 - * m4/ac_tds_func_which_gethostbyaddr_r.m4 - * m4/ac_tds_func_which_getpwuid_r.m4 - * m4/ac_tds_func_which_localtime_r.m4 m4/am_iconv.m4 - * m4/check_openssl.m4 m4/sprintf_i64_format.m4 m4/type_socklen_t.m4 - - Split acinclude.m4 into one macro defintion per file. - * m4/ax_cflags_gcc_option.m4 - - Check for gcc features e.g. the declaration-after-statement warning. - -Fri Mar 24 13:03:36 EST 2006 JK Lowden - * doc/htdoc/docs.html doc/htdoc/index.html updated - -Fri Mar 24 12:36:02 EST 2006 JK Lowden - * doc/htdoc/software.html fixed broken links added link to RC - -Fri Mar 24 16:27:27 CET 2006 Frediano Ziglio - * misc/full-test.sh misc/test-auto.sh misc/full-test-ol.sh(removed): - - use an "online" version for test - -Thu Mar 23 15:53:45 CET 2006 Frediano Ziglio - * src/odbc/sql2tds.c src/odbc/unittests/earlybind.c: - * src/odbc/unittests/norowset.c src/odbc/unittests/t0004.c: - * src/odbc/unittests/tables.c src/tds/data.c src/tds/tds_checks.c: - - fixes for mssql 2005 - -Thu Mar 23 13:48:23 CET 2006 Frediano Ziglio - * src/tds/query.c: partially fix problem with mssql2k5 - -Thu Mar 23 11:44:32 CET 2006 Frediano Ziglio - * misc/full-test-ol.sh misc/online.pl misc/test-auto.sh: - - changed online.pl with James hints - - enable Valgrind tests using online check - -Tue Mar 21 15:24:04 CET 2006 Frediano Ziglio - * src/odbc/unittests/cursor2.c(aded) src/odbc/unittests/Makefile.am: - - added test to check errors using cursor on no row statement - -Tue Mar 21 13:22:07 CET 2006 Frediano Ziglio - * src/odbc/native.c: - - applied patch from Richard Krehbiel (cf "ODBC datetime literal issue") - -Tue Mar 21 08:49:44 CET 2006 Frediano Ziglio - * configure.in src/dblib/dblib.c: - - fix declaration after statements - -Mon Mar 20 15:28:25 CET 2006 Frediano Ziglio - * src/dblib/bcp.c: fix error in bcp_colfmt - -Mon Mar 20 15:00:45 CET 2006 Frediano Ziglio - * src/dblib/bcp.c src/dblib/dblib.c src/dblib/rpc.c: - - remove some double checks - - return correct values from CHECK_PARAMETER - - fix some possible core if dbproc == NULL - -Mon Mar 20 09:42:55 CET 2006 Frediano Ziglio - * misc/full-test.sh: added timeout - -Sun Mar 19 18:34:47 CET 2006 Frediano Ziglio - * misc/test-auto.sh: fix typo in header - * src/dblib/dblib.c: remove double checks - -Sun Mar 19 18:33:14 CET 2006 Frediano Ziglio - * src/odbc/unittests/genparams.c src/odbc/unittests/transaction.c: - - remove warnings on 64bit int - -Sun Mar 19 09:27:09 EST 2006 JK Lowden - * src/dblib/bcp.c src/dblib/dblib.c more logging repairs - -Sat Mar 18 12:34:02 EST 2006 JK Lowden - * include/dblib.h src/dblib/bcp.c - - validate parameters. Unable to run unittest due to down server. - -Sat Mar 18 01:27:32 EST 2006 JK Lowden - * include/dblib.h src/dblib/dblib.c src/dblib/rpc.c - - test parameters for all public functions (except bcp) - -Fri Mar 17 01:35:17 EST 2006 JK Lowden - * src/dblib/dblib.c src/dblib/rpc.c - - added a TDSDUMP log entry for every public function - -Thu Mar 16 09:59:25 EST 2006 JK Lowden - * TODO add rpc error messages - * src/apps/bsqldb.c exit if severity > 10 - -Wed Mar 15 00:41:11 EST 2006 JK Lowden - * doc/freebcp.txt The freebcp manpage was seriously out of date. - * src/apps/freebcp.c give better error message. - -Thu Mar 9 14:33:37 CET 2006 Frediano Ziglio - * include/tdsodbc.h src/odbc/odbc.c: - - add cursor_type to connection attributes (required for DBD::ODBC) - - removed small TODO on error report - -Mon Mar 6 12:55:10 CET 2006 Frediano Ziglio - * include/tds.h src/ctlib/ct.c src/odbc/connectparams.c: - * src/pool/util.c src/server/login.c src/server/unittest.c: - * src/tds/config.c src/tds/login.c src/tds/mem.c: - - renamed host_name field to client_host_name - - optimize way strings are allocated - -Fri Feb 24 15:04:35 EST 2006 JK Lowden - * src/tds/config.c src/tds/login.c: - - nicer TDSDUMPCONFIG output, including a recap - -Sun Feb 19 14:56:15 CET 2006 Frediano Ziglio - * src/odbc/odbc.c: fix wrong declaration - -Thu Feb 16 08:30:00 CET 2006 Frediano Ziglio - * src/odbc/unittests/scroll.c src/odbc/unittests/raiserror.c: - * src/odbc/unittests/cursor1.c: - - remove warning compiling with gcc4 - * misc/test-other.sh: fix problem with DBD:ODBC test - -Mon Feb 13 17:11:30 CET 2006 Frediano Ziglio - * src/odbc/unittests/genparams.c: add BIGINT type to test - -Wed Feb 8 10:48:36 CET 2006 Frediano Ziglio - * include/tdsodbc.h src/odbc/error.c src/odbc/odbc.c: - * vms/odbc_driver_axp.opt win32/FreeTDS.def: - - start cursor stuff for odbc - - added SQLSetScrollOptions - * src/odbc/unittests/scroll.c: support more fetch types - -Tue Feb 7 15:42:56 CET 2006 Frediano Ziglio - * include/tds.h src/tds/query.c src/ctlib/ct.c NEWS: - - improve cursor support - -Tue Feb 7 14:22:50 CET 2006 Frediano Ziglio - * src/odbc/unittests/scroll.c(added): - * src/odbc/unittests/.cvsignore: - * src/odbc/unittests/Makefile.am: - * src/odbc/unittests/cursor1.c: - - add scroll test for cursor - - build msvc project for odbc unittests - * src/dblib/unittests/Makefile.am: add done_handling test - -Mon Feb 6 16:50:05 CET 2006 Frediano Ziglio - * include/sybdb.h src/apps/freebcp.c src/dblib/bcp.c: - - implemented BCPKEEPIDENTITY for bcp_control - - make freebcp do not depend on dblib internals - -Mon Feb 6 16:44:27 CET 2006 Frediano Ziglio - * src/odbc/unittests/.cvsignore src/odbc/unittests/cursor1.c: - - update cursor1 test - -Thu Feb 2 15:33:21 CET 2006 Frediano Ziglio - * NEWS: updated - * src/odbc/odbc.c vms/odbc_driver_axp.opt win32/FreeTDS.def: - - compile SQLSetPos function - * src/odbc/unittests/Makefile.am src/odbc/unittests/cursor1.c(added): - - added a test for cursors (do not work...) - -Tue Jan 31 14:27:51 CET 2006 Frediano Ziglio - * src/apps/freebcp.c src/dblib/bcp.c: - - fix broken charcater conversion - - use calloc instead of malloc/memset - - support 64bit file on win32 - -Tue Jan 31 09:59:28 CET 2006 Frediano Ziglio - * src/dblib/dblib.c: do more argument check - -Mon Jan 30 16:29:20 CET 2006 Frediano Ziglio - * src/ctlib/unittests/blk_out.c src/ctlib/unittests/ct_cursor.c: - * src/ctlib/unittests/ct_cursors.c src/ctlib/unittests/ct_dynamic.c: - * src/dblib/unittests/t0005.c src/dblib/unittests/t0014.c: - * src/dblib/unittests/t0022.c src/dblib/unittests/thread.c: - - reduce false errors - -Sat Jan 28 15:49:55 CET 2006 Frediano Ziglio - * src/dblib/bcp.c: - - update row allocation using new row_free - - fix native format - - correctly check and handle EOF - - change _bcp_build_bcp_record to direct send row (renamed to - _bcp_send_bcp_record) - - write error file only if needed - * src/dblib/unittests/t0016.c: improved - * src/dblib/unittests/t0016.in: - - make input same of output - * src/dblib/unittests/t0017.c: get all data - * src/tds/mem.c: reset pointer just freed - -Sat Jan 28 09:39:10 CET 2006 Frediano Ziglio - * src/dblib/unittests/t0017.c: reformat output - -Fri Jan 27 14:34:09 EST 2006 JK Lowden - * src/dblib/bcp.c recognize EOF errors from _bcp_read_hostfile - -Fri Jan 27 10:43:54 EST 2006 JK Lowden - * src/dblib/unittests/t0017.c better feedback - -Thu Jan 26 13:58:51 CET 2006 Frediano Ziglio - * src/apps/freebcp.c src/apps/freebcp.h: - - support for NUL in terminators - -Wed Jan 25 15:33:20 CET 2006 Frediano Ziglio - * src/dblib/bcp.c: fix return test for fseeko - -Wed Jan 25 15:01:51 CET 2006 Frediano Ziglio - * acinclude.m4 configure.in src/tds/numeric.c: - - use 64bit sprintf format if available - * misc/test-other.sh: redirect odbc to compiled driver - -Tue Jan 24 16:01:41 CET 2006 Frediano Ziglio - * NEWS include/tds.h src/apps/tsql.c src/ctlib/blk.c: - * src/ctlib/ct.c src/dblib/bcp.c src/dblib/buffering.h: - * src/dblib/dblib.c src/dblib/rpc.c src/odbc/odbc.c: - * src/odbc/odbc_util.c src/odbc/prepare_query.c: - * src/odbc/sql2tds.c src/pool/stream.c src/server/server.c: - * src/tds/mem.c src/tds/query.c src/tds/tds_checks.c: - * src/tds/token.c src/tds/unittests/dataread.c: - * src/tds/unittests/dynamic1.c src/tds/unittests/t0002.c: - * src/tds/unittests/t0004.c src/tds/unittests/t0005.c: - * src/tds/unittests/t0006.c src/tds/unittests/utf8_1.c: - * src/tds/unittests/utf8_2.c: - - use direct pointer column_data instead of old column_offset - -Mon Jan 23 17:30:38 EST 2006 JK Lowden - * src/apps/bsqldb.c bind to printable width, not column size - -Mon Jan 23 14:04:44 CET 2006 Frediano Ziglio - * configure.in: start developing 0.65 version -$Id: ChangeLog-0.82,v 1.1.2.2 2008/01/10 20:58:43 jklowden Exp $ diff --git b/INSTALL.CVS a/INSTALL.CVS index c23f6b7..d42c3aa 100644 --- b/INSTALL.CVS +++ a/INSTALL.CVS @@ -16,9 +16,9 @@ connecting to the CVS server. Then follow these steps: Autotool versions that work: $ (autoconf --version; automake --version; libtool --version) |grep GNU - autoconf (GNU Autoconf) 2.60 - automake (GNU automake) 1.9.6 - ltmain.sh (GNU libtool) 1.5.18 (1.1220.2.245 2005/05/16 08:55:27) + autoconf (GNU Autoconf) 2.59 + automake (GNU automake) 1.9.5 + ltmain.sh (GNU libtool) 1.5.14 (1.1220.2.195 2005/02/12 12:12:33) The above are used to generate the distributions. You may get away with older versions, as far back as 2.53 for autoconf. @@ -44,10 +44,10 @@ connecting to the CVS server. Then follow these steps: +++ -You are not required to rely on SourceForge's anonymous CVS server, which at +You are not required to rely on Source Forge's anonymous CVS server, which at the present time (July 2004) runs up to 1 hour behind the development server. You can fetch the CVS tarball (the basis for a CVS server, not a snapshot) from -SourceForge at: +Source Forge at: http://cvs.sourceforge.net/cvstarballs/freetds-cvsroot.tar.bz2 @@ -62,4 +62,4 @@ the CVS tree via rsync: $ rsync -av rsync://freetds.cvs.sourceforge.net/cvsroot/freetds/* . -- -$Id: INSTALL.CVS,v 1.7.2.1 2008/01/10 20:58:43 jklowden Exp $ +$Id: INSTALL.CVS,v 1.7 2007/04/05 14:17:05 freddy77 Exp $ diff --git b/NEWS a/NEWS index fd44001..851fbce 100644 --- b/NEWS +++ a/NEWS @@ -1,63 +1,33 @@ -$Id: NEWS,v 1.43.2.1 2008/01/10 20:58:43 jklowden Exp $ - -Executive Summary of Changes in release 0.82 --------------------------------------------- - -1. timeout handling -2. encrypted connections -3. fisql (and odbc utilities) -4. autoconf improvements -5. 23,710 lines added or deleted (101,022 total). -6. 85 files added -7. 21 unit tests added - -Details -------- - -db-lib -- timeouts work! -- corrected dbnextrow -- implemented dbsetnull and dbsetinterrupt -- improved error reporting and checking -- fixed rpc parameter processing, now php works correctly - -ct-lib -- added cs_loc_alloc, cs_loc_drop, cs_locale implementations - -odbc -- cursors (mssql) -- fixed database setting -- return error always if odbc returns SQL_ERROR -- fixed SQLGetData result - -utilities -- added support for NUL characters inside terminators in freebcp -- added row termination and column termination option to tsql -- new fisql application -- new ODBC utilities - -documentation -- significant updates to TDS protocol documentation -- freetds.conf man page -- added tenderfoot sample code - -general -- fixed timeout handling -- added freetds.conf option for encryption -- added protocol version discovery +$Id: NEWS,v 1.43 2008/01/08 13:29:40 freddy77 Exp $ +* 0.82 +- support NUL characters inside terminators in freebcp +- cursors under ODBC (mssql) - NTLM2 session response -- read table and real column name from wire -- experimental Kerberos support using gssapi +- lot of update to TDS protocol documentation - some optimizations for GCC4 - optimized conversions avoiding some memory copy - minor improves to server stuff -- improved MingW compile (even cross one) +- add row termination and column termination option to tsql +- improve locale stuff on ctlib + added cs_loc_alloc, cs_loc_drop, cs_locale implementations +- improve MingW compile (even cross one) +- implement dbsetnull on dblib +- improve dblib error reporting and check - more verbose log for dblib and odbc +- fix rpc parameter on dblib, now php works correctly - many test added 1 test for libTDS 1 test for ctlib 3 tests for dblib 13 tests for odbc +- fix database setting on odbc +- fix timeout stuff +- return always an error if odbc return SQL_ERROR +- fix SQLGetData result +- add freetds.conf option for encryption +- add protocol version discovery +- read table and real column name from wire +- experimental Kerberos support using gssapi libTDS API changes - tds_add_row_column_size removed @@ -68,7 +38,7 @@ libTDS API changes - added TDSCURSOR->type and TDSCURSOR->concurrency for mssql support - added fetch_type and i_row parameters to tds_cursor_fetch - added tds_cursor_update and tds_cursor_setname functions -- made tds_alloc_get_string static +- make tds_alloc_get_string static - removed tds_free_cursor - added TDSCURSOR->ref_count - added tds_cursor_deallocated and tds_release_cursor to handle @@ -78,8 +48,8 @@ libTDS API changes to trace pointer owner between libTDS and upper libraries - added TDS_COMPILETIME_SETTINGS->sysconfdir - changed DSTR_STRUCT structure to include dstr_size -- changed DSTR type -- error handler cannot return TDS_INT_EXIT +- change DSTR type +- error handler cannot return TDS_INT_EXIT (no more defined) - removed TDSSOCKET->query_timeout_func TDSSOCKET->query_timeout_param, TDSSOCKET->query_start_time - changed TDSLOGIN->host_name to client_host_name @@ -113,6 +83,7 @@ libTDS API changes - added TDSSOCKET->tds9_transaction (used internally for TDS9) - added TDSCONNECTION->server_host_name needed for Kerberos support + * 0.64 - core library - reduced network bandwidth use on Linux and *BSD diff --git b/README a/README index 2de3e4c..33da879 100644 --- b/README +++ a/README @@ -1,11 +1,12 @@ -README for FreeTDS 0.82 -Thusday 10 January 2008 +$Id: README,v 1.11 2007/04/05 14:17:05 freddy77 Exp $ +README for FreeTDS 0.64 +Saturday 1 July 2006 -* to build FreeTDS read the file INSTALL or - the FreeTDS Users Guide (doc/userguide.tgz) and +* to build FreeTDS read the file INSTALL, +* see also the FreeTDS Users Guide, http://www.freetds.org/userguide/ -FreeTDS is a free implementation of Sybase's db-lib, +FreeTDS is a free (open source) implementation of Sybase's db-lib, ct-lib, and ODBC libraries. FreeTDS builds and runs on every flavor of unix-like systems we've heard of, as well as Win32 (with or without Cygwin), VMS, and Mac OS X. Failure to build on your system is probably @@ -26,8 +27,60 @@ TODO The roadmap, such as it is Also, doc/api_status.txt shows which functions are implemented. -For details on what's new in this version, see NEWS. For unbearable -detail, see ChangeLog-0.82. +************************************ +** Warning regarding Sybase 12.5! ** +************************************ + +Do Not Use TDS version 4.2 to connect to Sybase 12.5. Please! + +While we don't like to put the bad news first, neither do we want you to +hurt your server. We know that our implementation of TDS 4.2 gives +Sybase 12.5 a bad case of heartburn. In short: it crashes the server. + +We don't know what it is about our version of TDS 4.2 that Sybase 12.5 +doesn't like, and we'd like to figure it out eventually. But in the +meanwhile, until we can find the problem and fix it, please don't use +that combination. Unless you want to help us test it, that is. + +FreeTDS 0.63 works fine with Sybase 12.5 if you use TDS version 5.0. + +If you are using Sybase 12.5 and anything above is not clear to you, +please see the User Guide. If it is still not clear after that, please +write to the FreeTDS mailing list. We'd rather answer your questions +while your server is still running. + +Thank you. We return now to your regularly scheduled README, already in +progress. + +New in this version +=================== + +ct-lib +------ + +Ct-lib now sports bcp and cursors. The largest missing feature is now +placeholder support compatible with Perl's DBD::Sybase. + +ODBC +---- + +ODBC continues to be improved. It is now compatible with OpenOffice.org, for +example, and even works with Oracle's OTL libary. It has better 64-bit +support. + +Applications +------------ + +This version includes two new applications, bsqldb and defncopy. See their man +pages for details. + +etc. +---- + +Naturally, there have been other improvements as well. This version compiles +and runs better than its predecessors. + + Documentation ============= @@ -86,6 +139,3 @@ Side note: Brian, as many free software authors, appreciates postcards from all over. So if you live someplace neat (read: not Michigan) and want to send one, email him (brian@bruns.org) for his current snail mail address. - -$Id: README,v 1.11.2.1 2008/01/10 20:58:43 jklowden Exp $ - diff --git b/TODO a/TODO index 9b7c295..6b770b4 100644 --- b/TODO +++ a/TODO @@ -4,11 +4,11 @@ followed by things that should work before the next release, followed by features that should be added/fixed/reworked (grouped by library). Everyone is encouraged to add to the list. Developers can do it directly; -anyone else can post a patch to SourceForge. +anyone else can post a patch to Source Forge. In this way we can communicate with each other about the project's priorities and needs. -To Do List $Id: TODO,v 1.165.2.1 2008/01/10 20:58:43 jklowden Exp $ +To Do List $Id: TODO,v 1.165 2007/12/26 20:56:00 freddy77 Exp $ ------------ Bug? ML 2007-05-30 "dbsqlexec() never returns" @@ -30,13 +30,20 @@ Broken: Work in progress: +Postponed to 0.65 version . log and call error handler on problems with tds_iconv_init(). . iconv - support string conversions for Sybase + - add test for locale_charset() to configure.in. Use it if available + instead of nl_langinfo, because it implies we're using GNU iconv . add doc/htdoc/Makefile with "publish" target to commit cvs and update freetds.org . drop txt2man from cvs, skip building man pages without it. . be able to disable iconv for BCP (see Sybase documentation) +. userguide + - update table of working configurations + server (vendor, version, platform) - client (freetds version, platform) + - protocol - charsets - date For future versions (in priority order within library): All: @@ -52,6 +59,7 @@ For future versions (in priority order within library): . Add missing constants needed for python and verify working . Add missing constants needed for Gnome-DB and verify working . conversion from ucs2 to utf8, provide for 2+ bytes/character +. tdsping program for testing purposes . Finish off the TDS dissector for ethereal . more solid. handle out of memory conditions (started, we must test all allocation and all function that return allocated data and be able to @@ -73,8 +81,8 @@ For future versions (in priority order within library): (too complicate, see ctlib bulk, cf "bulk copy and row buffer") . improve cursor support on dblib and ctlib . support for VARIANT type (requested one time, 2003-8-1) -. support for NT named pipe (requested long ago for mssql6.5 server, only - for completeness). If the reader knows a library to handle named pipes +. support for NT named pipe (requested many time ago for mssql6.5 server, only + for completeness). If anybody knows a library to handle named pipes compatible with LGPL please tell us. . read on partial packet, do not wait entire one . detect if realloc/free accepts NULL pointers (in configure.in) @@ -123,14 +131,6 @@ For future versions (in priority order within library): . report error just before returning SQL_ERROR from inner function? . test and fix: hidden fields (FOR BROWSE select, see flag test on tds) - - what happen if we bind to an hidden field?? - - if we use SQLGetData?? - - if we request informations with SQLDescribeCol/SQLColAttribute(s)/ - SQLGetDescField?? - - as you noted returning # columns hidden fields are not counted (there - is however a setting which is a mssql extension which threat hidden - columns as normal) - (cfr "SQLNumResultCols() is wrong (+1)" Jan 8 2008) . test: all binding types (input and output) . test: descriptors work - ODBC 2 type returned (datetime) diff --git b/doc/userguide.sgml a/doc/userguide.sgml index 2a09e0f..d26bb2e 100644 --- b/doc/userguide.sgml +++ a/doc/userguide.sgml @@ -5,8 +5,8 @@ ]> - $Date: 2008/01/10 20:58:43 $ - $Revision: 1.110.2.1 $ + $Date: 2008/01/08 13:29:40 $ + $Revision: 1.110 $ <productname>FreeTDS</productname> User Guide A Guide to Installing, Configuring, and Running FreeTDS @@ -26,7 +26,6 @@ 2005 2006 2007 - 2008 Brian Bruns and James K. Lowden @@ -56,9 +55,9 @@ This guide is here for you, and we hope that you will be here for it, that other The version you're reading is: -$Revision: 1.110.2.1 $ -$Date: 2008/01/10 20:58:43 $ -CVS control number $Id: userguide.sgml,v 1.110.2.1 2008/01/10 20:58:43 jklowden Exp $. +$Revision: 1.110 $ +$Date: 2008/01/08 13:29:40 $ +CVS control number $Id: userguide.sgml,v 1.110 2008/01/08 13:29:40 freddy77 Exp $. can be found on the FreeTDS @@ -202,7 +201,7 @@ project on SourceForge. It is a fork of the Status -The db-lib and ct-lib APIs have been usable for several years. They have been successfully substituted for Sybase's own libraries in a variety of venues, including Perl and PHP. That is not to say that these drivers are complete; they're not. But they faithfully implement a useful — and widely used — subset of their APIs. +The db-lib and ct-lib APIs have been usable for several years. They have been successfully substituted for Sybase's own libraries in a variety of venues, including Perl and PHP. That is not to say that these drivers are complete; they're not. But they faithfully implement an important subset of their APIs, enough to be useful. This 0.64 version boasts support for server-side cursors in ct-lib. In addition to the core db-lib API, FreeTDS includes a full implementation of db-lib's bcp functions, as well as freebcp, a replacement for Sybase's bcp utility. @@ -568,7 +567,7 @@ url="http://www.madgoat.com">www.madgoat.com). OS X® - As of this writing ($Date: 2008/01/10 20:58:43 $), the regular distribution compiles on OS X. Releases prior to 0.63 either did not compile or required patching. + As of this writing ($Date: 2008/01/08 13:29:40 $), the regular distribution compiles on OS X. Releases prior to 0.63 either did not compile or required patching. Alternative build procedure @@ -942,7 +941,8 @@ As of 0.62 FreeTDS uses iconv to convert all character data, so there's no need instance instance name none - Name of Microsoft SQL Server instance to connect to. The port will be detected automatically. + Name of Microsoft SQL Server instance to connect to. The port will be detected automatically. + This requires an extra round-trip with server and may thus slightly delay making the connection. debug flags @@ -1512,7 +1512,7 @@ The following table defines all possible ODBC connection attributes for the Server A server name or (ip) address none - Hostname of a server. Used in an ODBC-only configuration. To specify a Microsoft SQL Server instance, use the form server\instance. + Hostname of a server. Used in an ODBC-only configuration. As of version 0.64 you can specify a Microsoft SQL Server instance in the form of server\instance. Port commit b8d8661289abc8745b33e8e24da31decdf21c1bd Author: freddy77 Date: Thu Jan 10 13:22:19 2008 +0000 fix SQLGetData problem diff --git b/src/odbc/unittests/Makefile.am a/src/odbc/unittests/Makefile.am index 8146c2a..8f38676 100644 --- b/src/odbc/unittests/Makefile.am +++ a/src/odbc/unittests/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am,v 1.68.2.2 2008/01/10 13:22:19 freddy77 Exp $ +# $Id: Makefile.am,v 1.68.2.1 2008/01/10 08:52:46 freddy77 Exp $ TESTS = \ t0001$(EXEEXT) t0002$(EXEEXT) t0003$(EXEEXT)\ t0004$(EXEEXT) connect$(EXEEXT) print$(EXEEXT)\ @@ -20,7 +20,7 @@ TESTS = \ paramcore$(EXEEXT) timeout2$(EXEEXT) timeout3$(EXEEXT) \ connect2$(EXEEXT) timeout4$(EXEEXT) freeclose$(EXEEXT) \ cursor3$(EXEEXT) cursor4$(EXEEXT) cursor5$(EXEEXT) \ - attributes$(EXEEXT) hidden$(EXEEXT) blob1$(EXEEXT) + attributes$(EXEEXT) hidden$(EXEEXT) check_PROGRAMS = $(TESTS) @@ -78,7 +78,6 @@ cursor4_SOURCES = cursor4.c common.c common.h cursor5_SOURCES = cursor5.c common.c common.h attributes_SOURCES = attributes.c common.c common.h hidden_SOURCES = hidden.c common.c common.h -blob1_SOURCES = blob1.c common.c common.h AM_CPPFLAGS = -I$(top_srcdir)/include $(ODBC_INC) -DFREETDS_SRCDIR=\"$(srcdir)\" if MINGW32 commit 9fbbe664420fa49e8611bfede300a90dd293229e Author: freddy77 Date: Thu Jan 10 13:13:46 2008 +0000 fix SQLGetData problem diff --git b/ChangeLog a/ChangeLog index d054e6f..ecb6523 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,8 +1,3 @@ -Thu Jan 10 14:12:32 CET 2008 Frediano Ziglio - * src/odbc/odbc.c src/odbc/unittests/.cvsignore: - * src/odbc/unittests/Makefile.am src/odbc/unittests/blob1.c(added): - - fix problem with SQLGetData and blobs - Thu Jan 10 09:51:23 CET 2008 Frediano Ziglio * TODO src/odbc/odbc.c src/odbc/unittests/.cvsignore: * src/odbc/unittests/Makefile.am: diff --git b/src/odbc/odbc.c a/src/odbc/odbc.c index 60c8e00..7d33b27 100644 --- b/src/odbc/odbc.c +++ a/src/odbc/odbc.c @@ -60,7 +60,7 @@ #include #endif -TDS_RCSID(var, "$Id: odbc.c,v 1.464.2.2 2008/01/10 13:13:46 freddy77 Exp $"); +TDS_RCSID(var, "$Id: odbc.c,v 1.464.2.1 2008/01/10 08:52:45 freddy77 Exp $"); static SQLRETURN _SQLAllocConnect(SQLHENV henv, SQLHDBC FAR * phdbc); static SQLRETURN _SQLAllocEnv(SQLHENV FAR * phenv); @@ -4583,12 +4583,12 @@ SQLGetData(SQLHSTMT hstmt, SQLUSMALLINT icol, SQLSMALLINT fCType, SQLPOINTER rgb if (*pcbValue < 0) ODBC_RETURN(stmt, SQL_ERROR); - if (is_variable_type(colinfo->column_type) && (fCType == SQL_C_CHAR || fCType == SQL_C_BINARY)) { + if (is_variable_type(colinfo->column_type)) { /* calc how many bytes was readed */ int readed = cbValueMax; /* FIXME test on destination char ??? */ - if (stmt->dbc->env->attr.output_nts != SQL_FALSE && fCType == SQL_C_CHAR /* is_char_type(nSybType) */ && readed > 0) + if (stmt->dbc->env->attr.output_nts != SQL_FALSE && is_char_type(nSybType) && readed > 0) --readed; if (readed > *pcbValue) readed = *pcbValue; diff --git b/src/odbc/unittests/.cvsignore a/src/odbc/unittests/.cvsignore index d7c663e..1316adb 100644 --- b/src/odbc/unittests/.cvsignore +++ a/src/odbc/unittests/.cvsignore @@ -63,4 +63,3 @@ cursor4 cursor5 attributes hidden -blob1 diff --git b/src/odbc/unittests/blob1.c a/src/odbc/unittests/blob1.c deleted file mode 100755 index b8c45b0..0000000 --- b/src/odbc/unittests/blob1.c +++ /dev/null @@ -1,224 +0,0 @@ -/* Testing large objects */ -/* Test from Sebastien Flaesch */ - -#include "common.h" - -static char software_version[] = "$Id: blob1.c,v 1.1.2.2 2008/01/10 13:13:46 freddy77 Exp $"; -static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; - -#define CHECK_RCODE(t,h,m) \ - if ( rcode != SQL_SUCCESS && rcode != SQL_SUCCESS_WITH_INFO && rcode != SQL_NO_DATA && rcode != SQL_NEED_DATA ) { \ - fprintf(stderr,"Error %d at: %s\n",rcode,m); \ - getErrorInfo(t,h); \ - exit(1); \ - } - -#define NBYTES 10000 - -static int failed = 0; - -static void -getErrorInfo(SQLSMALLINT sqlhdltype, SQLHANDLE sqlhandle) -{ - SQLRETURN rcode = 0; - SQLCHAR sqlstate[SQL_SQLSTATE_SIZE + 1]; - SQLINTEGER naterror = 0; - SQLCHAR msgtext[SQL_MAX_MESSAGE_LENGTH + 1]; - SQLSMALLINT msgtextl = 0; - - rcode = SQLGetDiagRec((SQLSMALLINT) sqlhdltype, - (SQLHANDLE) sqlhandle, - (SQLSMALLINT) 1, - (SQLCHAR *) sqlstate, - (SQLINTEGER *) & naterror, - (SQLCHAR *) msgtext, (SQLSMALLINT) sizeof(msgtext), (SQLSMALLINT *) & msgtextl); - fprintf(stderr, "Diagnostic info:\n"); - fprintf(stderr, " SQL State: %s\n", (char *) sqlstate); - fprintf(stderr, " SQL code : %d\n", (int) naterror); - fprintf(stderr, " Message : %s\n", (char *) msgtext); -} - -static void -fill_chars(char *buf, size_t len, unsigned int start, unsigned int step) -{ - size_t n; - - for (n = 0; n < len; ++n) - buf[n] = 'a' + ((start+n) * step % ('z' - 'a' + 1)); -} - -static int -check_chars(const char *buf, size_t len, unsigned int start, unsigned int step) -{ - size_t n; - - for (n = 0; n < len; ++n) - if (buf[n] != 'a' + ((start+n) * step % ('z' - 'a' + 1))) - return 0; - - return 1; -} - -static int -readBlob(SQLHSTMT * stmth, SQLUSMALLINT pos) -{ - SQLRETURN rcode; - char buf[4096]; - SQLLEN len, total = 0; - int i = 0; - int check; - - printf(">> readBlob field %d\n", pos); - while (1) { - i++; - rcode = SQLGetData(stmth, pos, SQL_C_BINARY, (SQLPOINTER) buf, (SQLINTEGER) sizeof(buf), &len); - if (!SQL_SUCCEEDED(rcode) || len <= 0) - break; - if (len > (SQLLEN) sizeof(buf)) - len = (SQLLEN) sizeof(buf); - printf(">> step %d: %d bytes readed\n", i, (int) len); - if (pos == 1) - check = check_chars(buf, len, 123 + total, 1); - else - check = check_chars(buf, len, 987 + total, 25); - if (!check) { - fprintf(stderr, "Wrong buffer content\n"); - failed = 1; - } - total += len; - } - printf(">> total bytes read = %d \n", (int) total); - if (total != 10000) - failed = 1; - return rcode; -} - -int -main(int argc, char **argv) -{ - SQLRETURN rcode; - SQLHSTMT m_hstmt = NULL; - int i; - - int key; - SQLINTEGER vind0; - char buf1[NBYTES]; - SQLINTEGER vind1; - char buf2[NBYTES]; - SQLINTEGER vind2; - int cnt = 2; - - use_odbc_version3 = 1; - Connect(); - - Command(Statement, "IF OBJECT_ID('tt') IS NOT NULL DROP TABLE tt"); - Command(Statement, "CREATE TABLE tt ( k INT, t TEXT, b IMAGE, v INT )"); - - /* Insert rows ... */ - - for (i = 0; i < cnt; i++) { - - m_hstmt = NULL; - rcode = SQLAllocHandle(SQL_HANDLE_STMT, Connection, &m_hstmt); - CHECK_RCODE(SQL_HANDLE_DBC, Connection, "SQLAllocHandle StmtH"); - - rcode = SQLPrepare(m_hstmt, (SQLCHAR *) "insert into tt values ( ?, ?, ?, ? )", SQL_NTS); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLPrepare"); - - SQLBindParameter(m_hstmt, 1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &key, 0, &vind0); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLBindParameter 1"); - - SQLBindParameter(m_hstmt, 2, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_LONGVARCHAR, 0x10000000, 0, buf1, 0, &vind1); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLBindParameter 2"); - - SQLBindParameter(m_hstmt, 3, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_LONGVARBINARY, 0x10000000, 0, buf2, 0, &vind2); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLBindParameter 3"); - - SQLBindParameter(m_hstmt, 4, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &key, 0, &vind0); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLBindParameter 4"); - - key = i; - vind0 = 0; - - fill_chars(buf1, NBYTES, 123, 1); - vind1 = SQL_LEN_DATA_AT_EXEC(NBYTES); - - fill_chars(buf2, NBYTES, 987, 25); - vind2 = SQL_LEN_DATA_AT_EXEC(NBYTES); - - printf(">> insert... %d\n", i); - rcode = SQLExecute(m_hstmt); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLExecute StmtH"); - while (rcode == SQL_NEED_DATA) { - char *p; - - rcode = SQLParamData(m_hstmt, (SQLPOINTER) & p); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLParamData StmtH"); - printf(">> SQLParamData: ptr = %p rcode = %d\n", (void *) p, rcode); - if (rcode == SQL_NEED_DATA) { - SQLRETURN rcode = SQLPutData(m_hstmt, p, NBYTES); - - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLPutData StmtH"); - printf(">> param %p: total bytes written = %d\n", (void *) p, NBYTES); - } - } - - rcode = SQLFreeHandle(SQL_HANDLE_STMT, (SQLHANDLE) m_hstmt); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLFreeHandle StmtH"); - - } - - /* No fetch rows ... */ - - for (i = 0; i < cnt; i++) { - - m_hstmt = NULL; - rcode = SQLAllocHandle(SQL_HANDLE_STMT, Connection, &m_hstmt); - CHECK_RCODE(SQL_HANDLE_DBC, Connection, "SQLAllocHandle StmtH"); - - rcode = SQLSetStmtAttr(m_hstmt, SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_NONSCROLLABLE, SQL_IS_UINTEGER); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLSetStmtAttr SQL_ATTR_CURSOR_SCROLLABLE"); - rcode = SQLSetStmtAttr(m_hstmt, SQL_ATTR_CURSOR_SENSITIVITY, (SQLPOINTER) SQL_SENSITIVE, SQL_IS_UINTEGER); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLSetStmtAttr SQL_ATTR_CURSOR_SENSITIVITY"); - - rcode = SQLPrepare(m_hstmt, (SQLCHAR *) "SELECT t, b, v FROM tt WHERE k = ?", SQL_NTS); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLPrepare"); - - SQLBindParameter(m_hstmt, 1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &i, 0, &vind0); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLBindParameter 1"); - - SQLBindCol(m_hstmt, 1, SQL_C_BINARY, NULL, 0, &vind1); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLBindCol 2"); - SQLBindCol(m_hstmt, 2, SQL_C_BINARY, NULL, 0, &vind2); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLBindCol 3"); - SQLBindCol(m_hstmt, 3, SQL_C_LONG, &key, 0, &vind0); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLBindCol 1"); - - vind0 = 0; - vind1 = SQL_DATA_AT_EXEC; - vind2 = SQL_DATA_AT_EXEC; - - rcode = SQLExecute(m_hstmt); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLExecute StmtH"); - - rcode = SQLFetchScroll(m_hstmt, SQL_FETCH_NEXT, 0); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLFetchScroll StmtH"); - printf(">> fetch... %d rcode = %d\n", i, rcode); - - rcode = readBlob(m_hstmt, 1); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "readBlob 1"); - rcode = readBlob(m_hstmt, 2); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "readBlob 2"); - - rcode = SQLCloseCursor(m_hstmt); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLCloseCursor StmtH"); - - rcode = SQLFreeHandle(SQL_HANDLE_STMT, (SQLHANDLE) m_hstmt); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLFreeHandle StmtH"); - } - - Disconnect(); - - return failed ? 1 : 0; -} - commit d3d27cd44a61133054de7ee4fa93690d4245c6a1 Author: freddy77 Date: Thu Jan 10 13:11:08 2008 +0000 file blob1.c was added on branch BRANCH0_82 on 2008-01-10 13:13:46 +0000 commit 0b60151b80495fbe39b6b027189a871f889ea980 Author: freddy77 Date: Thu Jan 10 08:52:45 2008 +0000 fix SQLNumResultCols() is wrong (+1) problem diff --git b/ChangeLog a/ChangeLog index ecb6523..edcfcba 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,8 +1,3 @@ -Thu Jan 10 09:51:23 CET 2008 Frediano Ziglio - * TODO src/odbc/odbc.c src/odbc/unittests/.cvsignore: - * src/odbc/unittests/Makefile.am: - - small fix for hidden fields (ignore them entirely) - Wed Jan 9 7:50:39 CET 2008 Frediano Ziglio * configure.ac: preparing 0.82 diff --git b/src/odbc/odbc.c a/src/odbc/odbc.c index 7d33b27..7180d23 100644 --- b/src/odbc/odbc.c +++ a/src/odbc/odbc.c @@ -60,7 +60,7 @@ #include #endif -TDS_RCSID(var, "$Id: odbc.c,v 1.464.2.1 2008/01/10 08:52:45 freddy77 Exp $"); +TDS_RCSID(var, "$Id: odbc.c,v 1.464 2008/01/06 10:48:43 freddy77 Exp $"); static SQLRETURN _SQLAllocConnect(SQLHENV henv, SQLHDBC FAR * phdbc); static SQLRETURN _SQLAllocEnv(SQLHENV FAR * phenv); @@ -2652,7 +2652,7 @@ odbc_ird_check(TDS_STMT * stmt) return; /* check columns number */ - assert(ird->header.sql_desc_count <= cols || ird->header.sql_desc_count == 0); + assert(ird->header.sql_desc_count == cols || ird->header.sql_desc_count == 0); /* check all columns */ @@ -2717,10 +2717,6 @@ odbc_populate_ird(TDS_STMT * stmt) return SQL_SUCCESS; num_cols = res_info->num_cols; - /* ignore hidden columns... TODO correct? */ - while (num_cols > 0 && res_info->columns[num_cols - 1]->column_hidden == 1) - --num_cols; - if (desc_alloc_records(ird, num_cols) != SQL_SUCCESS) { odbc_errs_add(&stmt->errs, "HY001", NULL); return SQL_ERROR; diff --git b/src/odbc/unittests/.cvsignore a/src/odbc/unittests/.cvsignore index 1316adb..d6eea5a 100644 --- b/src/odbc/unittests/.cvsignore +++ a/src/odbc/unittests/.cvsignore @@ -62,4 +62,3 @@ cursor3 cursor4 cursor5 attributes -hidden diff --git b/src/odbc/unittests/Makefile.am a/src/odbc/unittests/Makefile.am index 8f38676..e68b0a4 100644 --- b/src/odbc/unittests/Makefile.am +++ a/src/odbc/unittests/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am,v 1.68.2.1 2008/01/10 08:52:46 freddy77 Exp $ +# $Id: Makefile.am,v 1.68 2007/12/19 14:36:05 freddy77 Exp $ TESTS = \ t0001$(EXEEXT) t0002$(EXEEXT) t0003$(EXEEXT)\ t0004$(EXEEXT) connect$(EXEEXT) print$(EXEEXT)\ @@ -20,7 +20,7 @@ TESTS = \ paramcore$(EXEEXT) timeout2$(EXEEXT) timeout3$(EXEEXT) \ connect2$(EXEEXT) timeout4$(EXEEXT) freeclose$(EXEEXT) \ cursor3$(EXEEXT) cursor4$(EXEEXT) cursor5$(EXEEXT) \ - attributes$(EXEEXT) hidden$(EXEEXT) + attributes$(EXEEXT) check_PROGRAMS = $(TESTS) @@ -77,7 +77,6 @@ cursor3_SOURCES = cursor3.c common.c common.h cursor4_SOURCES = cursor4.c common.c common.h cursor5_SOURCES = cursor5.c common.c common.h attributes_SOURCES = attributes.c common.c common.h -hidden_SOURCES = hidden.c common.c common.h AM_CPPFLAGS = -I$(top_srcdir)/include $(ODBC_INC) -DFREETDS_SRCDIR=\"$(srcdir)\" if MINGW32 diff --git b/src/odbc/unittests/hidden.c a/src/odbc/unittests/hidden.c deleted file mode 100755 index 66be442..0000000 --- b/src/odbc/unittests/hidden.c +++ /dev/null @@ -1,96 +0,0 @@ -/* Testing result column numbers having hidden columns */ -/* Test from Sebastien Flaesch */ - -#include "common.h" - -static char software_version[] = "$Id: hidden.c,v 1.1.2.1 2008/01/10 08:52:46 freddy77 Exp $"; -static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; - -#define CHECK_RCODE(t,h,m) \ - if ( rcode != SQL_NO_DATA \ - && rcode != SQL_SUCCESS \ - && rcode != SQL_SUCCESS_WITH_INFO \ - && rcode != SQL_NEED_DATA ) { \ - fprintf(stderr,"Error %d at: %s\n",rcode,m); \ - getErrorInfo(t,h); \ - exit(1); \ - } - -static void -getErrorInfo(SQLSMALLINT sqlhdltype, SQLHANDLE sqlhandle) -{ - SQLRETURN rcode = 0; - SQLCHAR sqlstate[SQL_SQLSTATE_SIZE + 1]; - SQLINTEGER naterror = 0; - SQLCHAR msgtext[SQL_MAX_MESSAGE_LENGTH + 1]; - SQLSMALLINT msgtextl = 0; - - rcode = SQLGetDiagRec((SQLSMALLINT) sqlhdltype, - (SQLHANDLE) sqlhandle, - (SQLSMALLINT) 1, - (SQLCHAR *) sqlstate, - (SQLINTEGER *) & naterror, - (SQLCHAR *) msgtext, (SQLSMALLINT) sizeof(msgtext), (SQLSMALLINT *) & msgtextl); - fprintf(stderr, "Diagnostic info:\n"); - fprintf(stderr, " SQL State: %s\n", (char *) sqlstate); - fprintf(stderr, " SQL code : %d\n", (int) naterror); - fprintf(stderr, " Message : %s\n", (char *) msgtext); -} - -int -main(int argc, char **argv) -{ - SQLRETURN rcode; - SQLHSTMT m_hstmt1; - SQLSMALLINT cnt = 0; - int failed = 0; - - use_odbc_version3 = 1; - Connect(); - - Command(Statement, "CREATE TABLE #t1 ( k INT, c CHAR(10), vc VARCHAR(10) )"); - Command(Statement, "CREATE TABLE #tmp1 (i NUMERIC(10,0) IDENTITY PRIMARY KEY, b VARCHAR(20) NULL, c INT NOT NULL)"); - - /* test hidden column with FOR BROWSE */ - ResetStatement(); - - m_hstmt1 = Statement; - - rcode = SQLExecDirect(m_hstmt1, (SQLCHAR *) "SELECT c, b FROM #tmp1", SQL_NTS); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLExecDirect"); - - rcode = SQLNumResultCols(m_hstmt1, &cnt); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLNumResultCols 1"); - - if (cnt != 2) { - fprintf(stderr, "Wrong number of columns in result set: %d\n", (int) cnt); - failed = 1; - } - ResetStatement(); - - /* test hidden column with cursors*/ - CheckCursor(); - - rcode = SQLSetStmtAttr(m_hstmt1, SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_NONSCROLLABLE, SQL_IS_UINTEGER); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLSetStmtAttr SQL_ATTR_CURSOR_SCROLLABLE"); - rcode = SQLSetStmtAttr(m_hstmt1, SQL_ATTR_CURSOR_SENSITIVITY, (SQLPOINTER) SQL_SENSITIVE, SQL_IS_UINTEGER); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLSetStmtAttr SQL_ATTR_CURSOR_SENSITIVITY"); - - rcode = SQLPrepare(m_hstmt1, (SQLCHAR *) "SELECT * FROM #t1", SQL_NTS); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLPrepare 1"); - - rcode = SQLExecute(m_hstmt1); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLExecute 1"); - - rcode = SQLNumResultCols(m_hstmt1, &cnt); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLNumResultCols 1"); - - if (cnt != 3) { - fprintf(stderr, "Wrong number of columns in result set: %d\n", (int) cnt); - failed = 1; - } - - Disconnect(); - - return failed ? 1: 0; -} commit bf3e39dbca6bef460127ccd1e1d8995e4594dfe9 Author: jklowden Date: Thu Jan 10 01:01:38 2008 +0000 file ChangeLog-0.82 was added on branch BRANCH0_82 on 2008-01-10 20:58:43 +0000 commit 298297ad5f7523d814293426ece4eb93b68e2304 Author: freddy77 Date: Wed Jan 9 06:50:55 2008 +0000 start preparing release diff --git b/ChangeLog a/ChangeLog index edcfcba..69bc581 100644 --- b/ChangeLog +++ a/ChangeLog @@ -1,6 +1,3 @@ -Wed Jan 9 7:50:39 CET 2008 Frediano Ziglio - * configure.ac: preparing 0.82 - Tue Jan 8 10:31:43 EST 2008 JK Lowden * doc/Makefile.am added freetds.conf.5 * src/dblib/bcp.c applied BCPKEEPIDENTIY patch from [email] diff --git b/configure.ac a/configure.ac index d2d0fed..2ba93f3 100644 --- b/configure.ac +++ a/configure.ac @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. dnl ------------------------------------------------------------ -dnl $Id: configure.ac,v 1.29.2.1 2008/01/09 06:50:55 freddy77 Exp $ +dnl $Id: configure.ac,v 1.29 2008/01/01 23:09:46 freddy77 Exp $ dnl If you're trying to create a new configure test, try dnl dnl http://autogen.sourceforge.net/conftest.html @@ -12,10 +12,10 @@ dnl ------------------------------------------------------------ # ------------------------------------------------------------ # Initialization # ------------------------------------------------------------ -AC_INIT(FreeTDS, 0.82RC1) +AC_INIT(FreeTDS, 0.65.dev.esyscmd(echo -n $(date +"%Y%m%d"))) AC_CONFIG_SRCDIR(src/dblib/dblib.c) AC_PREREQ(2.53) -AC_REVISION($Revision: 1.29.2.1 $) +AC_REVISION($Revision: 1.29 $) AM_INIT_AUTOMAKE AC_CONFIG_HEADERS(include/config.h) ======== fast forward to latest commit a6da12218e249babe568d2879324e4ac80b5f8db Author: freddy77 Date: Wed Jan 9 06:51:45 2008 +0000 avoid clash diff --git a/configure.ac b/configure.ac index 2ba93f3..96ec6c5 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. dnl ------------------------------------------------------------ -dnl $Id: configure.ac,v 1.29 2008/01/01 23:09:46 freddy77 Exp $ +dnl $Id: configure.ac,v 1.30 2008/01/09 06:51:45 freddy77 Exp $ dnl If you're trying to create a new configure test, try dnl dnl http://autogen.sourceforge.net/conftest.html @@ -12,10 +12,10 @@ dnl ------------------------------------------------------------ # ------------------------------------------------------------ # Initialization # ------------------------------------------------------------ -AC_INIT(FreeTDS, 0.65.dev.esyscmd(echo -n $(date +"%Y%m%d"))) +AC_INIT(FreeTDS, 0.83.dev.esyscmd(echo -n $(date +"%Y%m%d"))) AC_CONFIG_SRCDIR(src/dblib/dblib.c) AC_PREREQ(2.53) -AC_REVISION($Revision: 1.29 $) +AC_REVISION($Revision: 1.30 $) AM_INIT_AUTOMAKE AC_CONFIG_HEADERS(include/config.h) commit 1d1d90ef07268fa4a231f07390ae1677a83e0a33 Author: jklowden Date: Thu Jan 10 01:01:31 2008 +0000 truncated because of release diff --git a/ChangeLog b/ChangeLog index 69bc581..ad8d878 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,36 +1,5 @@ -Tue Jan 8 10:31:43 EST 2008 JK Lowden - * doc/Makefile.am added freetds.conf.5 - * src/dblib/bcp.c applied BCPKEEPIDENTIY patch from [email] - -Tue Jan 8 14:28:09 CET 2008 Frediano Ziglio - * NEWS doc/README.releasing doc/userguide.sgml: - - updates for new release - -Tue Jan 8 10:33:26 CET 2008 Frediano Ziglio - * src/odbc/unittests/genparams.c: relax for no-dm - -Mon Jan 7 19:32:20 CET 2008 Frediano Ziglio - * src/odbc/sql2tds.c src/odbc/unittests/genparams.c: - - fix millisecond round off for TIMESTAMP - - improve genparams test to catch this problem - - make genparams works with MS ODBC - -Mon Jan 7 15:04:18 CET 2008 Frediano Ziglio - * include/tdssrv.h src/server/login.c src/server/server.c: - * src/server/unittest.c: - - small improves - * src/pool/user.c: style update - -Sun Jan 6 11:48:17 CET 2008 Frediano Ziglio - * src/odbc/odbc.c: even SQLExecDirect support parameters! - * src/odbc/unittests/genparams.c: improve - -Sat Jan 5 12:23:21 CET 2008 Frediano Ziglio - * src/tds/query.c: - - add parameterized flag calling sp_cursoropen if needed - -Wed Jan 2 00:08:45 CET 2008 Frediano Ziglio - * configure.ac src/apps/Makefile.am: - - remove GNU style - * src/dblib/dblib.c: make it compile - +Wed Jan 9 19:54:43 EST 2008 JK Lowden + * ChangeLog truncated because of release + - ChangeLog-0.82 added because of release + +$Id: ChangeLog,v 1.2455 2008/01/10 01:01:31 jklowden Exp $ commit 2b04c9b9720eec10e4822ebfb479bec00de49492 Author: jklowden Date: Thu Jan 10 01:01:38 2008 +0000 ChangeLog-0.82 added because of release diff --git a/ChangeLog-0.82 b/ChangeLog-0.82 new file mode 100644 index 0000000..c17b0cf --- /dev/null +++ b/ChangeLog-0.82 @@ -0,0 +1,2289 @@ +Tue Jan 8 10:31:43 EST 2008 JK Lowden + * doc/Makefile.am added freetds.conf.5 + * src/dblib/bcp.c applied BCPKEEPIDENTIY patch + - from Jonathan Olson + +Tue Jan 8 14:28:09 CET 2008 Frediano Ziglio + * NEWS doc/README.releasing doc/userguide.sgml: + - updates for new release + +Tue Jan 8 10:33:26 CET 2008 Frediano Ziglio + * src/odbc/unittests/genparams.c: relax for no-dm + +Mon Jan 7 19:32:20 CET 2008 Frediano Ziglio + * src/odbc/sql2tds.c src/odbc/unittests/genparams.c: + - fix millisecond round off for TIMESTAMP + - improve genparams test to catch this problem + - make genparams works with MS ODBC + +Mon Jan 7 15:04:18 CET 2008 Frediano Ziglio + * include/tdssrv.h src/server/login.c src/server/server.c: + * src/server/unittest.c: + - small improves + * src/pool/user.c: style update + +Sun Jan 6 11:48:17 CET 2008 Frediano Ziglio + * src/odbc/odbc.c: even SQLExecDirect support parameters! + * src/odbc/unittests/genparams.c: improve + +Sat Jan 5 12:23:21 CET 2008 Frediano Ziglio + * src/tds/query.c: + - add parameterized flag calling sp_cursoropen if needed + +Wed Jan 2 00:08:45 CET 2008 Frediano Ziglio + * configure.ac src/apps/Makefile.am: + - remove GNU style + * src/dblib/dblib.c: make it compile + + +Mon Dec 31 15:05:16 EST 2007 JK Lowden + * src/dblib/dblib.c fixed DBPRPAD, maybe + +Mon Dec 31 11:29:50 CET 2007 Frediano Ziglio + * misc/test-other.sh src/odbc/odbc.c: + - relax test for cursor + +Mon Dec 31 11:06:13 CET 2007 Frediano Ziglio + * src/ctlib/blk.c src/odbc/unittests/attributes.c: + * src/odbc/unittests/describecol.c src/tds/convert.c: + * src/tds/login.c src/tds/mem.c: + - minor signed/unsigned fixes + * src/dblib/bcp.c: minor performance improve + * src/dblib/dblib.c: fix date portability + +Fri Dec 28 17:57:08 EST 2007 JK Lowden + * src/tds/token.c minor change + * src/tds/convert.c simpler tds_strftime + * src/dblib/unittests/done_handling.c no spurious messages + +Wed Dec 28 15:11:48 CET 2007 Frediano Ziglio + * doc/userguide.sgml: accepted patch #1854381 + +Wed Dec 28 14:44:16 CET 2007 Frediano Ziglio + * misc/freetds_autobuild misc/test-other.sh: + - make amd64 works + * misc/test-auto.sh: add --help option + * src/tds/convert.c: + - fix overflow in tds_convert_char + - minor fixes for tds_strftime + +Thu Dec 27 14:43:14 CET 2007 Frediano Ziglio + * doc/.cvsignore: ignore autogenerated + * include/tds.h src/replacements/vasprintf.c src/tds/convert.c: + * src/tds/login.c src/tds/query.c src/tds/read.c: + - remove some warnings + +Thu Dec 27 11:20:55 CET 2007 Frediano Ziglio + * src/odbc/unittests/common.c: make unixODBC happy + * win32/config.h: define TDS_I64_FORMAT + +Thu Dec 27 10:19:58 CET 2007 Frediano Ziglio + * src/dblib/buffering.h: + - remove warning if compiled with NDEBUG defined + +Wed Dec 26 21:57:12 CET 2007 Frediano Ziglio + * src/odbc/unittests/attributes.c: make it works + +Wed Dec 26 19:44:47 CET 2007 Frediano Ziglio + * doc/freetds.conf.5: typo fix + * src/ctlib/unittests/common.c: make tests compile + * src/odbc/odbc.c: add diagnostic for truncate + +Tue Dec 25 00:55:02 EST 2007 JK Lowden + * freetds.conf doc/Makefile.am doc/freetds.conf.5 (added) + - shortened default freetds.conf and moved documentation + - to a proper man page. Merry Christmas! + +Mon Dec 24 11:34:58 CET 2007 Frediano Ziglio + * include/tds.h: removed unused fields + +Sun Dec 23 16:08:29 EST 2007 JK Lowden + * src/apps/tsql.c + * src/ctlib/cs.c src/ctlib/unittests/common.c + * src/dblib/dblib.c + * src/tds/config.c src/tds/unittests/convert.c + - added STD_DATETIME_FMT to allow for WIN32 shortcomings + +Fri Dec 21 16:20:03 CET 2007 Frediano Ziglio + * include/tds.h src/ctlib/ct.c src/odbc/odbc.c src/tds/query.c: + - make odbc cursor test work using sp_cursoropen with parameters + +Fri Dec 21 11:38:47 CET 2007 Frediano Ziglio + * src/odbc/unittests/common.c src/odbc/unittests/common.h: + * src/odbc/unittests/cursor3.c src/odbc/unittests/cursor4.c: + * src/odbc/unittests/cursor5.c: + - cursor tests should work + +Fri Dec 21 10:05:12 CET 2007 Frediano Ziglio + * configure.ac include/replacements.h src/replacements/vasprintf.c: + * win32/config.h: + - applied modified patch #1848920 + +Thu Dec 20 22:56:34 CET 2007 Frediano Ziglio + * src/dblib/dblib.c src/dblib/unittests/common.h: + * src/dblib/unittests/setnull.c src/dblib/unittests/thread.c: + - remove warnings + +Thu Dec 20 17:46:03 CET 2007 Frediano Ziglio + * src/odbc/odbc.c: + - improve cursor attribute setting + - fix a small issue with unixODBC and 64 bit + +Wed Dec 19 16:08:17 CET 2007 Frediano Ziglio + * src/odbc/unittests/cursor3.c src/odbc/unittests/cursor4.c: + - remove warnings + +Wed Dec 19 15:35:22 CET 2007 Frediano Ziglio + * src/odbc/unittests/attributes.c(added) src/odbc/unittests/attributes.in(added): + * src/odbc/unittests/Makefile.am: add a test for statement attributes + * src/odbc/unittests/describecol.c: fix possible core + +Tue Dec 18 09:09:27 CET 2007 Frediano Ziglio + * src/odbc/unittests/Makefile.am src/odbc/unittests/cursor3.c(added): + * src/odbc/unittests/cursor4.c(added) src/odbc/unittests/cursor5.c(added): + - merged test from Sebastien FLAESCH + +Sun Dec 16 19:08:38 EST 2007 JK Lowden + * doc/api_status.txt + - set useless db-lib functions' status to 'never' + +Sun Dec 16 16:58:35 EST 2007 JK Lowden + * doc/Makefile.am doc/bsqlodbc.txt doc/osql.txt + * doc/userguide.sgml + - updated for next release + +Fri Dec 14 11:23:08 CET 2007 Frediano Ziglio + * misc/test-other.sh: fix some strange echo portability + * src/dblib/unittests/null.c src/dblib/unittests/null2.c: + - make ignore less verbose + +Thu Dec 13 23:45:55 EST 2007 JK Lowden + * src/apps/Makefile.am build bsqlodbc out-of-tree + * src/dblib/unittests/null.c prettier & correct, passes + +Thu Dec 13 21:12:20 CET 2007 Frediano Ziglio + * src/dblib/buffering.h: fix null2 + +Thu Dec 13 19:04:35 CET 2007 Frediano Ziglio + * src/apps/Makefile.am: + - fix bsqlodbc compile if not standard sql.h path + +Wed Dec 12 07:27:07 CET 2007 Frediano Ziglio + * src/tds/net.c: fix for 64bit + +Tue Dec 11 11:09:52 CET 2007 Frediano Ziglio + * doc/userguide.sgml: remove warning + * misc/freetds_autobuild: fix if password empty + +Tue Dec 11 00:02:16 EST 2007 JK Lowden + * doc/userguide.sgml minor touchups + * src/dblib/dblib.c src/dblib/unittests/setnull.c + - unittests/setnull.c passes. + +Mon Dec 10 14:05:06 CET 2007 Frediano Ziglio + * src/tds/convert.c: remove warning + +Mon Dec 10 00:08:45 EST 2007 JK Lowden + * doc/Makefile.am doc/userguide.sgml some improvements + doc/grep_sample_code doc/images/caution.gif + doc/images/warning.gif + doc/images/callouts/1.gif doc/images/callouts/2.gif + doc/images/callouts/3.gif doc/images/callouts/4.gif + doc/images/callouts/5.gif doc/images/callouts/6.gif + doc/images/callouts/7.gif doc/images/callouts/8.gif + doc/images/callouts/9.gif doc/images/callouts/10.gif + - added from http://tldp.org/LDP/abs/images/ + +Sun Dec 9 19:51:11 EST 2007 JK Lowden + * doc/userguide.sgml added tenderfoot tutorial + +Fri Dec 7 00:26:01 EST 2007 JK Lowden + * include/tds.h src/dblib/dblib.c + * src/dblib/dbutil.c src/tds/util.c + - pass errno via tdserror. + +Thu Dec 6 21:41:23 EST 2007 JK Lowden + * src/tds/convert.c tds_willconvert returns size + +Thu Dec 6 21:32:13 CET 2007 Frediano Ziglio + * src/dblib/dblib.c: fix for 64bit machines + * src/dblib/unittests/setnull.c: improve + +Thu Dec 6 19:59:59 CET 2007 Frediano Ziglio + * configure.ac include/replacements.h src/apps/bsqldb.c: + * src/dblib/unittests/setnull.c: + - use basename from MingW if available + * src/dblib/dblib.c: fix malloc portability problem + +Thu Dec 6 10:18:54 CET 2007 Frediano Ziglio + * src/dblib/rpc.c src/dblib/unittests/setnull.c: + - fix compile problems + +Thu Dec 6 01:00:42 EST 2007 JK Lowden + * src/dblib/buffering.h src/dblib/dblib.c: + - dbgetnull tolerates negative varlen, looks pretty good + +Wed Dec 5 10:38:55 EST 2007 JK Lowden + * src/dblib/dblib.c: + - t0011 passes but copy_data_to_host_var likely wrong + +Tue Dec 4 20:19:38 EST 2007 JK Lowden + * include/dblib.h src/dblib/buffering.h src/dblib/dblib.c: + - removed _db_set_null and associated mallocs + - dblib/unittest/t0011.c failing mysteriously + +Mon Dec 3 23:18:55 EST 2007 JK Lowden + * src/dblib/dblib.c src/dblib/unittests/setnull.c: + - corrected dbsetnull() + +Mon Dec 3 18:45:22 EST 2007 JK Lowden + * src/apps/bsqldb.c + * src/dblib/bcp.c src/dblib/dblib.c src/dblib/unittests/rpc.c + * src/dblib/unittests/setnull.c src/dblib/unittests/t0001.c + * src/dblib/unittests/t0002.c src/dblib/unittests/t0003.c + * src/dblib/unittests/t0004.c src/dblib/unittests/t0005.c + * src/dblib/unittests/t0006.c src/dblib/unittests/t0007.c + * src/dblib/unittests/t0008.c src/dblib/unittests/t0011.c + * src/dblib/unittests/t0015.c src/dblib/unittests/t0018.c + * src/dblib/unittests/t0023.c src/dblib/unittests/text_buffer.c + * src/dblib/unittests/thread.c src/dblib/unittests/timeout.c: + - dbbind uses zero, not -1 to indicate sufficient space. + +Mon Dec 3 17:57:54 EST 2007 JK Lowden + * src/dblib/bcp.c: don't cast malloc and don't assume it worked. + +Mon Dec 3 19:54:53 CET 2007 Frediano Ziglio + * src/odbc/Makefile.am: remove GNU make pattern + +Mon Dec 3 15:35:45 CET 2007 Frediano Ziglio + * src/dblib/dblib.c: + - do not call dbcolptr for compute result but call new dbacolptr + - dbcolptr return TDSCOLUMN* to optimize it + +Mon Dec 3 11:53:56 CET 2007 Frediano Ziglio + * src/dblib/dblib.c: remove a warning + +Mon Dec 3 10:18:39 CET 2007 Frediano Ziglio + * src/dblib/dblib.c src/dblib/unittests/.cvsignore: + * src/dblib/unittests/Makefile.am src/dblib/unittests/setnull.c(added): + - add a test for setnull + +Sun Dec 2 17:58:40 EST 2007 JK Lowden + * doc/api_status.txt + * include/dblib.h include/sybdb.h include/tds.h + * src/ctlib/blk.c src/dblib/bcp.c src/dblib/dblib.c + - full implementation of dbsetnull(). + - Replaced _DB_GETCOLINFO macro with dbcolptr(). + +Sat Dec 1 14:05:54 EST 2007 JK Lowden + * src/dblib/bcp.c src/dblib/unittests/null.c + - correct TDS 5.0 bcp offset table calcuation in presence of NULLs. + +Fri Nov 30 09:54:46 CET 2007 Frediano Ziglio + * src/dblib/unittests/common.c: missing new line + +Thu Nov 29 09:03:32 CET 2007 Frediano Ziglio + * src/dblib/unittests/null2.c: improve + +Wed Nov 28 15:15:43 CET 2007 Frediano Ziglio + * configure.ac: + - include windows.h under windows + - include sql.h directly to avoid MingW problems + * include/dblib.h src/dblib/bcp.c src/dblib/dblib.c src/dblib/rpc.c: + - avoid core checking for parameters if argument are expected + * src/dblib/unittests/null.c src/dblib/unittests/null2.c: + - avoid invalid references to deallocated stack + +Wed Nov 28 09:48:50 CET 2007 Frediano Ziglio + * src/dblib/bcp.c: remove warnings + +Wed Nov 28 00:27:36 EST 2007 JK Lowden + * src/dblib/bcp.c fixed TDS 5.0 null-column bug, cf. ML + * doc/tds.html Added BCP, made 4.01 strict, validated. + +Tue Nov 27 16:12:56 CET 2007 Frediano Ziglio + * src/dblib/unittests/Makefile.am src/dblib/unittests/null2.c(added): + - test dbbind/dbnullbind with NULLs + * src/dblib/unittests/null.c: add note + +Tue Nov 27 13:37:35 CET 2007 Frediano Ziglio + * src/dblib/unittests/t0001.c src/dblib/unittests/t0022.c: + - compile with Sybase libraries + * src/dblib/unittests/t0008.c: more verbose + +Mon Nov 26 21:02:57 CET 2007 Frediano Ziglio + * src/odbc/unittests/array_out.c: fix silly core + +Mon Nov 26 19:11:12 CET 2007 Frediano Ziglio + * configure.ac include/tdsodbc.h src/odbc/odbc.c: + * src/odbc/unittests/array_out.c src/odbc/unittests/common.h: + * src/odbc/unittests/describecol.c src/odbc/unittests/freeclose.c: + * src/odbc/unittests/insert_speed.c src/odbc/unittests/timeout.c: + * src/odbc/unittests/timeout3.c src/odbc/unittests/type.c: + - minor fixes for 64bit + +Mon Nov 26 16:47:34 CET 2007 Frediano Ziglio + * configure.ac src/apps/fisql/fisql.c: + - do not use functions not availables + +Mon Nov 26 09:43:03 EST 2007 JK Lowden + * src/dblib/bcp.c src/tds/unittests/iconv_fread.c + - small changes + +Mon Nov 26 09:51:21 CET 2007 Frediano Ziglio + * src/dblib/unittests/bcp.c: fix printf + +Mon Nov 26 07:24:43 CET 2007 Frediano Ziglio + * src/odbc/unittests/array.c src/odbc/unittests/array_out.c: + * src/odbc/unittests/const_params.c src/odbc/unittests/cursor1.c: + * src/odbc/unittests/describecol.c src/odbc/unittests/freeclose.c: + * src/odbc/unittests/insert_speed.c src/odbc/unittests/raiserror.c: + * src/odbc/unittests/rpc.c src/odbc/unittests/scroll.c: + * src/tds/challenge.c: + - fix minor issues with 64bit + +Thu Nov 22 09:43:58 CET 2007 Frediano Ziglio + * configure.ac src/ctlib/Makefile.am src/dblib/Makefile.am: + * src/odbc/Makefile.am: + - do not filter symbols under MacOsX (avoid libtool problems) + +Wed Nov 21 11:31:37 EST 2007 JK Lowden + * src/ctlib/blk.c: correctly test result of cs_convert + * src/dblib/rpc.c: minor edits + * src/dblib/unittests/bcp.c src/dblib/unittests/bcp.h: + - test works for TDS 7.0. + +Tue Nov 20 23:08:15 EST 2007 JK Lowden + * src/dblib/bcp.c src/dblib/unittests/bcp.c: + * src/dblib/dblib.c src/tds/convert.c src/tds/net.c: + - small changes + +Thu Nov 15 14:32:50 CET 2007 Frediano Ziglio + * src/dblib/unittests/.cvsignore src/dblib/dblib.c: + * src/dblib/unittests/Makefile.am src/dblib/unittests/null.c: + - fix problem with empty string and TEXT + - add a test to test empty/NULL behavior of dbdatlen/dbdata + +Thu Nov 15 10:18:40 CET 2007 Frediano Ziglio + * src/tds/login.c: return error if no username given and no Kerberos + +Tue Nov 13 10:13:06 CET 2007 Frediano Ziglio + * include/tds.h src/tds/challenge.c src/tds/gssapi.c: + * src/tds/login.c src/tds/token.c: + - port ntlm to new authentication code + - move all ntlm stuff to challenge.c + +Mon Nov 12 17:15:03 EST 2007 JK Lowden + * include/sybdb.h src/dblib/bcp.c + * src/dblib/dblib.c src/dblib/dbutil.c + * src/dblib/rpc.c + * src/tds/log.c src/tds/login.c + - trying to convince Doxygen not to ignore functions, + - e.g. dbinit + +Mon Nov 12 13:38:04 EST 2007 JK Lowden + * include/dblib.h src/dblib/dbutil.c + * src/dblib/dblib.c src/dblib/rpc.c src/dblib/bcp.c + - added DBDEAD test to all public functions + +Mon Nov 12 14:32:53 CET 2007 Frediano Ziglio + * configure.ac: cleanup + * src/tds/gssapi.c: compute fqdn name in service name + +Mon Nov 12 12:34:14 CET 2007 Frediano Ziglio + * configure.ac include/tds.h src/tds/gssapi.c: + * src/tds/login.c src/tds/mem.c src/tds/token.c: + - new TDSAUTHENTICATION structure + - new --enable-krb5 to enable Kerberos authentication + (disable by default) + +Fri Nov 09 11:29:21 CET 2007 Frediano Ziglio + * src/apps/tsql.c: remove some leaks + +Mon Nov 05 11:05:34 CET 2007 Frediano Ziglio + * src/apps/tsql.c: use pipes to avoid infinite counter + +Mon Nov 05 09:29:54 CET 2007 Frediano Ziglio + * src/tds/login.c: fix log avoidance for long logins + +Sun Nov 04 09:16:08 CET 2007 Frediano Ziglio + * src/tds/gssapi.c: small cleanup + +Sat Nov 03 14:31:40 CET 2007 Frediano Ziglio + * include/tds.h src/tds/config.c src/tds/mem.c: + - add server_host_name to TDSCONNECTION + * src/tds/gssapi.c: some improves + +Fri Nov 02 11:33:16 CET 2007 Frediano Ziglio + * src/tds/gssapi.c: add small comment + +Tue Oct 30 16:45:41 CET 2007 Frediano Ziglio + * src/tds/Makefile.am src/tds/gssapi.c src/tds/login.c: + - include developing code for GSSAPI + +Tue Oct 30 16:36:29 CET 2007 Frediano Ziglio + * include/tds.h src/tds/login.c src/ctlib/ct.c src/tds/read.c: + * src/tds/token.c: + - finish merging tds9 code as developing + +Tue Oct 30 16:02:04 CET 2007 Frediano Ziglio + * include/tdsodbc.h src/odbc/odbc.c: + - make odbc row_count 64bit + +Tue Oct 30 13:14:00 CET 2007 Frediano Ziglio + * src/tds/config.c src/tds/query.c: + - more merge for tds9 + +Tue Oct 30 11:31:30 CET 2007 Frediano Ziglio + * include/tds.h src/ctlib/blk.c src/dblib/bcp.c: + * src/server/server.c src/tds/token.c: + - merge partially tds9 patch + +Tue Oct 30 11:15:20 CET 2007 Frediano Ziglio + * src/tds/net.c: + - avoid wrong assert if error and tdserror called + * src/tds/query.c: limit data length to maximun allowed + +Wed Oct 24 17:55:56 EDT 2007 JK Lowden + * include/sqldb.h define dbfreelogin + * src/dblib/unittests/common.h add commentary + +Tue Oct 23 19:41:03 EDT 2007 JK Lowden + * src/tds/net.c src/tds/util.c + - ct-lib seems OK with EINTR (sqsh works) but db-lib + - applications get a weird message. + +Tue Oct 23 18:08:00 EDT 2007 JK Lowden + * src/tds/net.c + - return from tds_select as if timed out on EINTR. + - sqsh still unhappy when ^C pressed on long-running query. + +Thu Oct 18 16:48:23 CET 2007 Frediano Ziglio + * src/dblib/dblib.c: fix core + +Thu Oct 18 13:49:51 CET 2007 Frediano Ziglio + * src/tds/query.c src/tds/token.c: + - more free(NULL) + +Tue Oct 16 16:59:06 CET 2007 Frediano Ziglio + * src/apps/tsql.c src/ctlib/blk.c src/ctlib/cs.c src/ctlib/ct.c: + * src/dblib/bcp.c src/dblib/dblib.c src/dblib/rpc.c: + * src/dblib/unittests/rpc.c src/odbc/error.c src/odbc/odbc.c: + * src/odbc/sql2tds.c src/odbc/unittests/binary_test.c: + * src/pool/config.c src/tds/locale.c src/tds/login.c: + * src/tds/mem.c src/tds/query.c src/tds/token.c: + * src/tds/vstrbuild.c src/tds/unittests/dataread.c: + - do not check for free(NULL) + +Wed Oct 10 13:59:37 EDT 2007 JK Lowden + * src/apps/tsql.c + - added some error checking for malloc/realloc, more needed + +Tue Oct 09 13:40:24 CET 2007 Frediano Ziglio + * src/tds/mem.c: fix small memory leak + +Mon Sep 24 13:12:47 CET 2007 Frediano Ziglio + * src/tds/query.c: limit size preparing queries + +Mon Sep 24 12:01:46 CET 2007 Frediano Ziglio + * src/server/query.c src/server/server.c: + - small server improve + +Thu Sep 20 17:32:15 CET 2007 Frediano Ziglio + * include/sybdb.h src/dblib/dblib.c src/dblib/dbopen.c: + - apply constify patch #1786200 + +Thu Sep 20 17:02:20 CET 2007 Frediano Ziglio + * src/apps/tsql.c: do not strip empty lines + +Mon Sep 17 17:22:32 EDT 2007 JK Lowden + * src/dblib/bcp.c correct freebcp -L behavior + * src/tds/net.c TDSECONN on no socket failure + * src/tds/util.c change iconv messages + +Mon Sep 17 17:52:09 CET 2007 Frediano Ziglio + * doc/tds.html: update for tds9 + * src/server/login.c: remove warning + +Mon Sep 17 12:13:03 CET 2007 Frediano Ziglio + * src/apps/tsql.c: + - improve for very large query (from 9.2 to 0.3 seconds on my + test machine) + +Mon Sep 17 10:42:45 CET 2007 Frediano Ziglio + * doc/tds.html: update + * src/ctlib/unittests/get_send_data.c: small fix + * include/sybdb.h src/dblib/dblib.c src/dblib/unittests/t0022.c: + - small update for future tds9 + * src/pool/main.c src/pool/user.c src/server/login.c: + - improve portability and possible remote leakage + +Thu Sep 13 12:42:08 CET 2007 Frediano Ziglio + * src/odbc/unittests/freeclose.c: + - make it works even if login is quite long + +Thu Sep 13 08:57:26 CET 2007 Frediano Ziglio + * src/tds/unittests/dynamic1.c: use tds_set_param_type + +Thu Sep 06 13:15:54 CET 2007 Frediano Ziglio + * doc/tds.html: update for tds9 + * src/tds/read.c: work if initial in_pos is != 0 + +Sat Aug 25 12:32:01 CET 2007 Frediano Ziglio + * include/tdsodbc.h src/odbc/error.c src/odbc/odbc.c: + - use ODBC_API instead of SQL_API to allow combined compile + +Fri Aug 24 11:50:03 CET 2007 Frediano Ziglio + * include/tds.h src/ctlib/blk.c src/dblib/bcp.c src/tds/login.c: + * src/tds/query.c src/tds/token.c: + - small changes for TDS 9.0 + +Mon Aug 16 10:09:42 CET 2007 Frediano Ziglio + * src/ctlib/unittests/Makefile.am src/dblib/unittests/Makefile.am: + * src/odbc/unittests/Makefile.am src/tds/net.c: + * src/tds/unittests/Makefile.am: + - remove other warnings + +Mon Aug 16 08:29:38 CET 2007 Frediano Ziglio + * src/tds/unittests/convert.c win32/initnet.c: + - remove some warnings compiling with MingW + +Sat Aug 11 08:51:45 CET 2007 Frediano Ziglio + * src/dblib/dblib.c vms/config_h.vms vms/descrip_mms.template: + - applied Craig A. Berry patch #1772080 for VMS systems + +Fri Aug 10 11:17:32 CET 2007 Frediano Ziglio + * NEWS: updated + +Fri Aug 10 11:14:19 CET 2007 Frediano Ziglio + * win32/dev-cpp/Makefile.win: add missing file + +Thu Aug 09 14:52:45 CET 2007 Frediano Ziglio + * src/tds/net.c: small fixes + +Thu Aug 09 10:26:51 CET 2007 Frediano Ziglio + * doc/userguide.sgml: document port override syntax + +Thu Aug 09 09:49:34 CET 2007 Frediano Ziglio + * doc/htdoc/basic_jdbc_question.html doc/htdoc/contrib.html: + * doc/htdoc/docs.html doc/htdoc/index.html doc/htdoc/news.html: + * doc/htdoc/software.html doc/htdoc/support.html: + * doc/htdoc/vague_jdbc_question.html doc/htdoc/which_api.html: + - make xhtml compatible + +Wed Aug 08 15:24:16 CET 2007 Frediano Ziglio + * configure.ac src/odbc/Makefile.am win32/version.rc.in: + - fix odbc cross compile using MingW + +Wed Aug 08 11:34:40 CET 2007 Frediano Ziglio + * misc/freetds_autobuild: + - improved adding test for server:port and server\instance case + +Wed Aug 08 11:10:36 CET 2007 Frediano Ziglio + * src/tds/config.c: fix bug #1759652 (cannot use server\INSTANCE) + +Tue Aug 07 15:34:34 CET 2007 Frediano Ziglio + * src/odbc/odbc.c: improve cursor updates + * src/odbc/unittests/cursor1.c: improved and fixed + +Tue Aug 07 11:55:53 CET 2007 Frediano Ziglio + * src/tds/query.c: use table name for update + +Tue Aug 07 11:19:33 CET 2007 Frediano Ziglio + * include/tds.h src/odbc/odbc.c src/odbc/unittests/getdata.c: + - fix bug #1758831 + - additional fixes and checks for SQLGetData + +Tue Aug 07 10:29:55 CET 2007 Frediano Ziglio + * doc/userguide.sgml: update links + +Fri Aug 03 13:15:42 CET 2007 Frediano Ziglio + * src/tds/config.c: lookup server name correctly for instances + +Thu Aug 02 13:31:45 CET 2007 Frediano Ziglio + * include/sqlfront.h: small compatiblity improve with ms + +Fri Jul 13 18:56:56 CET 2007 Frediano Ziglio + * src/odbc/unittests/getdata.c: portability fix + +Thu Jul 12 16:31:05 CET 2007 Frediano Ziglio + * src/odbc/odbc.c: fix for SQLGetData using empty fields + * src/odbc/unittests/getdata.c: + - improve test to catch previous problem + +Sat Jul 07 19:55:30 CET 2007 Frediano Ziglio + * m4/sprintf_i64_format.m4: improve portability + +Sat Jul 07 19:09:59 CET 2007 Frediano Ziglio + * src/odbc/odbc.c: + - check cbValueMax in SQLGetData even if DM present + +Tue Jul 03 17:12:04 CET 2007 Frediano Ziglio + * src/odbc/unittests/compute.c src/odbc/unittests/tables.c: + * src/odbc/unittests/typeinfo.c: + - relax test for Sybase + * src/tds/token.c: fix length computation + +Tue Jul 03 15:37:03 CET 2007 Frediano Ziglio + * include/tds.h src/ctlib/blk.c src/dblib/bcp.c src/dblib/dblib.c: + * src/odbc/odbc.c src/tds/mem.c src/tds/token.c: + - add table_column_name to read real column name (if available), + read from wire and use when needed + +Sun Jul 01 12:10:31 CET 2007 Frediano Ziglio + * include/tdsstring.h src/odbc/connectparams.c: + * src/odbc/descriptor.c src/odbc/odbc.c src/tds/config.c: + * src/tds/tdsstring.c: + - added tds_dstr_dup to duplicate DSTR + - use tds_dstr_dup + - improve tds_dstr_set + +Wed Jun 27 16:51:30 CET 2007 Frediano Ziglio + * doc/tds.html: add Column Info token + * src/odbc/unittests/timeout2.c: portability fix + +Mon Jun 25 11:47:14 CET 2007 Frediano Ziglio + * doc/api_status.txt include/cspublic.h include/ctlib.h: + * src/ctlib/cs.c src/ctlib/ct.c: + - applied patch #1729392, it adds support for ctlib locale + +Mon Jun 25 10:20:00 CET 2007 Frediano Ziglio + * src/odbc/odbc.c: review cursors + +Thu Jun 21 09:19:32 CET 2007 Frediano Ziglio + * misc/freetds_autobuild: test for Sybase 15 + * src/odbc/unittests/data.c: bigint for Sybase + * src/tds/data.c src/tds/mem.c src/tds/read.c src/tds/tds_checks.c: + - add support for Sybase bigint + - do not check decault capabilities if not necessary + +Tue Jun 19 15:30:12 CET 2007 Frediano Ziglio + * include/tds.h src/ctlib/ct.c src/odbc/odbc_util.c: + * src/pool/stream.c src/tds/data.c src/tds/net.c: + * src/tds/tds_checks.c src/tds/tds_checks.h src/tds/token.c: + - fix problem with Sybase LONGCHAR + +Tue Jun 19 14:06:55 CET 2007 Frediano Ziglio + * src/ctlib/unittests/t0007.c src/odbc/unittests/prepare_results.c: + - more verbose + - fix for possible Sybase conversion + * src/odbc/odbc.c: additional check if no dm + +Mon Jun 18 15:20:00 CET 2007 Frediano Ziglio + * src/tds/convert.c: + - patch #1736289 for bcp/bulk insert problem + +Mon Jun 18 14:02:45 CET 2007 Frediano Ziglio + * src/apps/tsql.c src/tds/locale.c: + - use correct charset based on locale + +Mon Jun 18 13:58:34 CET 2007 Frediano Ziglio + * src/odbc/unittests/genparams.c: remove warning + +Sun Jun 17 19:38:27 CET 2007 Frediano Ziglio + * src/odbc/unittests/freeclose.c src/odbc/unittests/timeout3.c: + - fix small thread problem + - fix possible deadlock + +Sun Jun 17 09:45:55 CET 2007 Frediano Ziglio + * src/odbc/unittests/freeclose.c src/odbc/unittests/genparams.c: + - fix thread and small portability + +Sun Jun 17 09:08:03 CET 2007 Frediano Ziglio + * include/dblib.h src/dblib/buffering.h src/dblib/dblib.c: + - patch #1717123 for dbsetnull implementation (removed warnings) + +Sun Jun 17 08:16:50 CET 2007 Frediano Ziglio + * src/apps/tsql.c: + - patch #1703363 for delimiters (modified) + +Wed Jun 13 09:26:00 CET 2007 Frediano Ziglio + * src/apps/fisql/fisql.c: compile even if readline is not available + +Mon Jun 4 17:09:03 EDT 2007 JK Lowden + * src/apps/Makefile.am skip bsqlodb if ODBC disabled + +Mon Jun 04 10:03:25 CET 2007 Frediano Ziglio + * src/dblib/unittests/.cvsignore src/dblib/unittests/Makefile.am: + * src/dblib/unittests/hang.c(added) src/tds/net.c: + - fix problem with tds_select (detected by Perception Technologies) + +Fri Jun 01 10:52:46 CET 2007 Frediano Ziglio + * src/tds/token.c: avoid overflow leading to memory errors + +Thu May 31 17:02:43 CET 2007 Frediano Ziglio + * src/tds/net.c: + - fixes, partially from Brent of Perception Technologies Ltd + +Thu May 31 10:54:14 EDT 2007 JK Lowden + * TODO add recent potential bug reports + +Thu May 31 14:21:35 CET 2007 Frediano Ziglio + * m4/ac_nullzero.m4: fix cross compile test + +Wed May 30 09:55:52 CET 2007 Frediano Ziglio + * src/tds/threadsafe.c: + - implement gethostbyname_r with getaddrinfo (for UnixWare 7 and others) + +Tue May 29 10:48:45 CET 2007 Frediano Ziglio + * configure.ac win32/config.h: cleanup + +Fri May 25 11:07:04 CET 2007 Frediano Ziglio + * src/odbc/convert_tds2sql.c: + - remove a FIXME + * src/odbc/odbc.c: + - fix bug #1716594 ("SQLFreeStmt with SQL_CLOSE shouldn't + unprepare statement") + * src/odbc/unittests/Makefile.am src/odbc/unittests/freeclose.c(added) + * src/odbc/unittests/.cvsignore: + - add a test for bug #1716594 + +Mon May 21 14:01:13 CET 2007 Frediano Ziglio + * src/odbc/odbc.c: + - fix cursor updates, this undo part of change of src/odbc/odbc.c + from 1.331 to 1.332, log: + Wed Jul 21 16:50:11 CET 2004 + : some fix for SQLFetch and multiple rows + but tests works + * src/odbc/unittests/cursor1.c: improve + +Mon May 21 10:40:40 CET 2007 Frediano Ziglio + * src/odbc/unittests/cursor1.c: improve test + +Thu May 17 12:32:33 CET 2007 Frediano Ziglio + * include/tdsodbc.h src/odbc/odbc.c src/odbc/odbc_checks.c: + * src/odbc/odbc_util.c: + - avoid core + - fix and check invalid values of num_param_rows and curr_param_row + +Thu May 17 09:18:19 CET 2007 Frediano Ziglio + * src/odbc/unittests/warning.c: improve and comments + +Wed May 16 14:23:00 CET 2007 Frediano Ziglio + * include/tdsodbc.h src/odbc/odbc.c src/odbc/odbc_util.c: + * src/odbc/sql2tds.c: + - support row binding in RPC + - reuse new odbc_get_octet_len + +Wed May 16 14:23:00 CET 2007 Frediano Ziglio + * misc/freetds_autobuild: minor updates + +Mon May 14 16:04:08 CET 2007 Frediano Ziglio + * src/tds/login.c: remove copy error + +Mon May 14 10:16:37 CET 2007 Frediano Ziglio + * src/tds/login.c src/tds/mem.c src/tds/token.c src/tds/util.c: + - give proper errors on protocol autodiscovery + +Wed May 09 10:31:56 CET 2007 Frediano Ziglio + * src/odbc/odbc.c: finish ODBC timeout + +Fri May 03 14:54:58 CET 2007 Frediano Ziglio + * src/odbc/unittests/const_params.c: + - reset statement to be sure to cleanup + +Wed May 02 16:54:13 CET 2007 Frediano Ziglio + * include/tdsodbc.h src/odbc/odbc.c: + - use query timeout from freetds.conf + +Mon Apr 30 15:14:08 CET 2007 Frediano Ziglio + * src/odbc/odbc.c: use default linkage for static functions + +Mon Apr 30 15:02:27 CET 2007 Frediano Ziglio + * src/ctlib/blk.c: fix strange link error using gcc 4.1 + +Mon Apr 23 09:56:05 CET 2007 Frediano Ziglio + * src/tds/net.c: fix portability issue + +Fri Apr 20 15:26:15 CET 2007 Frediano Ziglio + * src/odbc/unittests/cursor1.c src/odbc/unittests/cursor2.c: + * src/odbc/unittests/scroll.c: + - make valgrind more happy if Sybase is used + +Fri Apr 20 11:13:40 CET 2007 Frediano Ziglio + * src/odbc/odbc.c src/odbc/unittests/Makefile.am: + * src/odbc/unittests/timeout4.c(added): + - add a test for timeout + - fix timeout on prepare (not detected) + - fix timeout if connection broken + +Thu Apr 19 11:11:55 CET 2007 Frediano Ziglio + * src/odbc/unittests/cursor1.c src/odbc/unittests/cursor2.c: + * src/odbc/unittests/scroll.c: + - give only warning for Sybase + +Thu Apr 19 10:45:15 CET 2007 Frediano Ziglio + * include/tdsodbc.h src/odbc/odbc.c: + - say we not still support cursors for sybase + +Wed Apr 18 16:28:29 CET 2007 Frediano Ziglio + * TODO.freddy include/tdsodbc.h src/odbc/odbc.c: + * src/odbc/odbc_util.c src/odbc/prepare_query.c src/odbc/sql2tds.c: + - fix cursor updates + +Mon Apr 16 22:08:07 EDT 2007 JK Lowden + * src/apps/bsqlodbc.c ODBC3 conformant + +Sun Apr 15 10:01:36 CET 2007 Frediano Ziglio + * src/odbc/odbc.c: fix leak + +Fri Apr 13 17:27:20 CET 2007 Frediano Ziglio + * src/odbc/odbc.c: cursor update + +Fri Apr 13 17:22:25 CET 2007 Frediano Ziglio + * include/tds.h src/tds/query.c: + - add cursor update to libTDS + +Fri Apr 13 10:08:07 CET 2007 Frediano Ziglio + * src/apps/bsqlodbc.c: + - catch all error + - fix some memory problems + +Thu Apr 12 15:33:15 CET 2007 Frediano Ziglio + * src/odbc/unittests/funccall.c: + - add test from ML + +Thu Apr 12 15:07:09 CET 2007 Frediano Ziglio + * freetds.spec.in: fix odbc directory + * src/dblib/unittests/Makefile.am: fix for make distcheck + * src/odbc/unittests/raiserror.c src/odbc/unittests/warning.c: + - relax if dm used + +Thu Apr 12 09:47:39 CET 2007 Frediano Ziglio + * src/odbc/odbc.c src/odbc/unittests/copydesc.c: + - test and fix a problem with SQLAllocHandle + * src/odbc/unittests/connect2.c: add test for not existing dbs + +Thu Apr 12 09:05:56 CET 2007 Frediano Ziglio + * src/ctlib/unittests/array_bind.c src/ctlib/unittests/ct_diagall.c: + * src/ctlib/unittests/ct_diagclient.c: + - fix buffer overflow leading in core + +Wed Apr 11 14:55:32 CET 2007 Frediano Ziglio + * src/dblib/unittests/common.c src/odbc/unittests/common.c: + - remove warning compiling with MingW + +Wed Apr 11 13:52:50 CET 2007 Frediano Ziglio + * src/odbc/connectparams.c src/odbc/odbc.c: + * src/odbc/unittests/connect2.c: + - finish and fix test for change_database + +Wed Apr 11 11:47:08 CET 2007 Frediano Ziglio + * src/odbc/unittests/connect2.c: fix test + * src/odbc/unittests/describecol.in: relax test + +Wed Apr 11 09:09:13 CET 2007 Frediano Ziglio + * src/odbc/unittests/connect2.c src/odbc/unittests/Makefile.am: + - add a test for change_database + +Tue Apr 10 16:00:47 CET 2007 Frediano Ziglio + * include/tdsodbc.h src/odbc/odbc.c src/odbc/odbc_util.c: + - fixes for describecol test + +Tue Apr 10 15:16:28 CET 2007 Frediano Ziglio + * misc/coverage.sh: remove system files + * src/odbc/unittests/describecol.in: relax test + +Fri Apr 06 10:52:25 CET 2007 Frediano Ziglio + * include/tdssrv.h src/server/login.c src/server/unittest.c: + - remove warning + +Fri Apr 06 10:29:31 CET 2007 Frediano Ziglio + * NEWS src/odbc/unittests/funccall.c src/tds/mem.c: + * src/tds/query.c: + - added some notes + +Thu Apr 05 16:16:47 CET 2007 Frediano Ziglio + * INSTALL INSTALL.CVS NEWS README doc/userguide.sgml: + - merge from 0.64 + +Wed Apr 04 13:39:27 CET 2007 Frediano Ziglio + * NEWS: updated + +Wed Apr 04 11:53:20 CET 2007 Frediano Ziglio + * include/tds.h include/tdsodbc.h src/ctlib/ct.c src/dblib/rpc.c: + * src/odbc/prepare_query.c src/odbc/sql2tds.c src/tds/mem.c: + * src/tds/token.c src/tds/unittests/dynamic1.c: + - removed unused paramter from tds_alloc_param_data + - fix possible problem in prepare_rpc + +Wed Apr 04 11:39:12 CET 2007 Frediano Ziglio + * vms/descrip_mms.template: add log.c + * src/server/query.c: use constants + +Wed Apr 04 09:14:47 CET 2007 Frediano Ziglio + * doc/userguide.sgml: improve slow check + +Tue Apr 03 16:23:17 CET 2007 Frediano Ziglio + * win32/dev-cpp/FreeTDS.dev win32/dev-cpp/Makefile.win: + - updated adding log.c + +Mon Apr 02 17:06:43 CET 2007 Frediano Ziglio + * doc/userguide.sgml: add encryption parameter + +Thu Mar 29 16:32:50 CET 2007 Frediano Ziglio + * src/ctlib/blk.c: initial fix for bcp state + +Thu Mar 29 16:25:24 CET 2007 Frediano Ziglio + * include/tds.h src/server/login.c src/tds/config.c: + * src/tds/login.c: + - added encryption setting in freetds.conf + +Thu Mar 29 12:17:34 CET 2007 Frediano Ziglio + * configure.ac: check includes for ODBC + +Thu Mar 29 09:44:11 CET 2007 Frediano Ziglio + * src/odbc/unittests/genparams.c: add test for money + +Wed Mar 28 14:43:34 CET 2007 Frediano Ziglio + * freetds.spec.in src/odbc/unittests/Makefile.am: + - fix test-dist test + +Mon Mar 26 13:27:51 CET 2007 Frediano Ziglio + * src/dblib/unittests/.cvsignore src/dblib/unittests/Makefile.am: + * src/odbc/unittests/.cvsignore src/odbc/unittests/Makefile.am: + * win32/build_dsw.pl: + - distribute projects for vc6 unittests + +Mon Mar 26 10:05:47 CET 2007 Frediano Ziglio + * doc/htdoc/news.html: validate page + +Sun Mar 24 09:23:21 CET 2007 Frediano Ziglio + * src/apps/bsqlodbc.c: + - avoid dangerous casts + +Tue Mar 20 16:24:26 CET 2007 Frediano Ziglio + * src/replacements/gettimeofday.c src/apps/datacopy.c: + - remove warning + +Mon Mar 19 11:01:05 CET 2007 Frediano Ziglio + * include/replacements.h: fix warning for win32 + +Sun Mar 18 12:37:47 CET 2007 Frediano Ziglio + * src/dblib/unittests/common.c src/odbc/unittests/timeout2.c: + * src/odbc/unittests/timeout3.c: + - fix cross-compile for win32 + +Sun Mar 18 12:09:57 CET 2007 Frediano Ziglio + * src/apps/Makefile.am src/apps/bsqlodbc.c src/apps/tsql.c: + * src/apps/fisql/Makefile.am win32/winsetup.c: + - fix cross-compile for win32 + +Fri Mar 16 16:32:08 CET 2007 Frediano Ziglio + * include/Makefile.am src/tds/Makefile.am: + - full libTDS privatization + * src/server/unittest.c: use mnemonic + +Wed Mar 14 17:18:23 CET 2007 Frediano Ziglio + * doc/tds.html: update + * include/tdssrv.h src/pool/user.c src/server/login.c: + * src/server/query.c src/server/server.c src/server/unittest.c: + - update server stuff, at least login works + * src/tds/tdsstring.c: fix possible mising NUL terminator + * src/apps/tsql.c: fix wrong error handler result + +Wed Mar 14 09:47:24 CET 2007 Frediano Ziglio + * doc/tds.html include/tds.h: update documentation + +Tue Mar 13 17:24:54 CET 2007 Frediano Ziglio + * include/tds.h src/pool/user.c src/server/login.c: + * src/server/unittest.c src/tds/login.c src/tds/query.c: + - use mnemonic for packet types + +Tue Mar 13 16:45:54 CET 2007 Frediano Ziglio + * doc/tds.html: added known tokens + +Tue Mar 13 14:18:03 CET 2007 Frediano Ziglio + * doc/tds.html: updated from code + +Mon Mar 12 14:27:14 CET 2007 Frediano Ziglio + * include/ctlib.h include/dblib.h include/des.h include/md4.h: + * include/md5.h include/replacements.h include/tdsiconv.h: + * include/tdsstring.h include/replacements/readpassphrase.h: + * src/server/Makefile.am: + - privatize functions using gcc visibility if available + - privatize server library + +Mon Mar 12 13:31:32 CET 2007 Frediano Ziglio + * src/ctlib/unittests/blk_in2.c(added) src/ctlib/unittests/Makefile.am: + - added test from ML to test cancel and bulk together + +Mon Mar 12 10:52:12 CET 2007 Frediano Ziglio + * doc/tds.html: improved, added types + +Fri Feb 16 14:52:10 CET 2007 Frediano Ziglio + * include/tds.h: improve documentation + +Mon Feb 12 14:29:53 EST 2007 Nick Castellano + * src/dblib/dblib.c: Increase size of dbprrow() conversion buffer to 8K. + +Mon Feb 12 10:53:54 CET 2007 Frediano Ziglio + * src/odbc/unittests/timeout3.c: + - use thread instead of fork + +Wed Feb 7 01:11:27 EST 2007 JK Lowden + * src/apps/bsqlodbc.c don't exit on SQL_SUCCESS_WITH_INFO + +Wed Feb 7 00:04:15 EST 2007 JK Lowden + * src/apps/bsqldb.c exit noisily on severe errors + * src/dblib/dblib.c src/tds/token.c + - fix timeout with buffering problem per yesterday's ML. + +Tue Feb 6 17:14:50 EST 2007 Nick Castellano + * src/dblib/dblib.c: + - Sybase docs for dbsqlok() says: "If the command buffer contains + multiple commands, a run-time error will not cause dbsqlok to + fail. Instead, failure will occur with the dbresults call that + processes the command causing the run-time error." + * src/apps/fisql/fisql.c: + - Correct result set processing. + +Tue Feb 6 14:11:02 EST 2007 Nick Castellano + * src/dblib/dblib.c: Don't print or store column separator after final result column + +Tue Feb 06 10:18:00 CET 2007 Frediano Ziglio + * configure.ac src/odbc/Makefile.am: + - use -module option only for darwin + +Tue Feb 06 09:53:14 CET 2007 Frediano Ziglio + * src/apps/bsqlodbc.c: + - make more functions static + - remove warning + * src/tds/net.c: remove warning + +Mon Feb 5 21:48:58 EST 2007 JK Lowden + * src/apps/Makefile.am src/apps/bsqlodbc.c src/apps/osql + - added bsqlodbc as general batch script processor. + +Mon Feb 05 09:41:02 CET 2007 Frediano Ziglio + * misc/test-other.sh phptests/null.php: + - fixed PHP check, updated test to PHP 5.2 + +Fri Feb 02 11:51:19 CET 2007 Frediano Ziglio + * configure.ac src/odbc/odbc.c src/odbc/unittests/.cvsignore: + * src/odbc/unittests/Makefile.am src/odbc/unittests/timeout3.c(added): + - added a test for connection timeout + - fix timeout connection in odbc + +Mon Jan 29 12:02:39 CET 2007 Frediano Ziglio + * include/tds_sysdep_private.h src/apps/fisql/fisql.c: + * src/tds/net.c: + - remove some warnings + +Fri Jan 26 18:19:57 CET 2007 Frediano Ziglio + * src/apps/fisql/fisql.c: + - remove warning + - reuse malloc + - fix compile error including config.h + * src/dblib/dblib.c: remove warning + +Fri Jan 26 18:06:44 CET 2007 Frediano Ziglio + * src/odbc/error.c src/odbc/odbc.c: + - remove warning compiling + +Wed Jan 24 14:14:55 EST 2007 Nick Castellano + * doc/fisql.txt: compute rows in fisql work now, remove BUGS entry + +Wed Jan 24 14:11:56 EST 2007 Nick Castellano + * src/apps/fisql/fisql.c: indent + +Wed Jan 24 14:08:09 EST 2007 Nick Castellano + * src/apps/fisql/fisql.c: good enough compute layout + +Wed Jan 24 12:24:30 EST 2007 Nick Castellano + * src/apps/fisql/fisql.c: almost correct compute layout + +Wed Jan 24 11:32:56 EST 2007 Nick Castellano + * src/apps/fisql/fisql.c: minor compute layout fixes, still more to do + +Tue Jan 23 17:15:33 EST 2007 Nick Castellano + * src/apps/fisql/fisql.c: better compute results, layout needs fixing + +Tue Jan 23 11:24:40 EST 2007 Nick Castellano + * src/dblib/dblib.c: fix off-by-one bug in dbbylist() + +Mon Jan 22 15:54:02 EST 2007 Nick Castellano + * src/apps/fisql/fisql.c: fix :r with unreadable file + +Mon Jan 22 15:50:31 EST 2007 Nick Castellano + * src/dblib/dblib.c: print line separator after compute results + +Mon Jan 22 00:56:12 EST 2007 JK Lowden + * src/odbc/connectparams.c src/odbc/error.c + * src/odbc/odbc.c + - added log entry for API functions + * src/odbc/unittests/common.c always use '/' separator + +Sat Jan 20 15:24:03 EST 2007 JK Lowden + * include/dblib.h include/sybdb.h src/dblib/dblib.c + - moved DBOPTION to dblib.h and removed unused members. + +Sat Jan 20 01:29:36 EST 2007 JK Lowden + * doc/defncopy.txt doc/fisql.txt cleanup formatting + * src/apps/bsqldb.c src/dblib/dblib.c fix compute row headers + +Sat Jan 20 01:30:22 EST 2007 Nick Castellano + * ChangeLog src/apps/fisql/edit.c src/apps/fisql/edit.h + * src/apps/fisql/fisql.c src/apps/fisql/handlers.c + * src/apps/fisql/handlers.h src/apps/fisql/interrupt.c + * src/apps/fisql/interrupt.h src/apps/fisql/terminal.c + * src/apps/fisql/terminal.h: + - Fix my name and the program name + +Sat Jan 20 01:20:39 EST 2007 Nick Castellano + * src/apps/fisql/fisql.c: + - Be slightly less stupid about compute rows. + +Sat Jan 20 00:54:57 EST 2007 Nick Castellano + * src/dblib/dblib.c: + - do not return bogus nul character in dbgetchar() + +Sat Jan 20 00:35:45 EST 2007 Nick Castellano + * src/dblib/dblib.c: + - dbspr*() functions get nul termination not line termination + +Fri Jan 19 22:39:00 EST 2007 Nick Castellano + * doc/fisql.txt: restore compute rows BUGS entry. + +Fri Jan 19 14:05:13 EST 2007 Nick Castellano + * src/apps/fisql/fisql.c: + - Provide xmalloc() and xrealloc() instead of relying on + libreadline for these. + +Fri Jan 19 13:47:42 EST 2007 Nick Castellano + * src/apps/fisql/Makefile.am + * src/apps/fisql/fisql.c + * src/apps/fisql/xgetpass.c(removed) + * src/apps/fisql/xgetpass.h(removed): + - use readpassphrase() in fisql application. + +Fri Jan 19 13:31:31 EST 2007 Nick Castellano + * src/apps/fisql/edit.c src/apps/fisql/fisql.c + * src/apps/fisql/handlers.c src/apps/fisql/handlers.h + * src/apps/fisql/interrupt.c src/apps/fisql/interrupt.h + * src/apps/fisql/terminal.c src/apps/fisql/terminal.h + * src/apps/fisql/xgetpass.c: + - Indent fisql to standard FreeTDS coding style + +Fri Jan 19 13:19:04 EST 2007 Nick Castellano + * src/apps/fisql/fisql.c: remove obsolete code + +Fri Jan 19 13:12:56 EST 2007 Nick Castellano + * doc/fisql.txt: fisql now works, update doc + +Fri Jan 19 13:01:53 EST 2007 Nick Castellano + * .cvsignore doc/.cvsignore: clean up + +Fri Jan 19 12:45:27 EST 2007 Nick Castellano + * src/dblib/dblib.c: fix dbspr1row(), fisql now works + +Fri Jan 19 11:17:13 EST 2007 JK Lowden + * doc/fisql.txt + * src/apps/fisql/edit.c src/apps/fisql/edit.h + * src/apps/fisql/handlers.c src/apps/fisql/handlers.h + * src/apps/fisql/interrupt.c src/apps/fisql/interrupt.h + * src/apps/fisql/terminal.c src/apps/fisql/terminal.h + * src/apps/fisql/xgetpass.c src/apps/fisql/xgetpass.h + * src/apps/fisql/fisql.c + - Added notice of copyright and GPL license + +Thu Jan 18 23:55:17 EST 2007 JK Lowden + * doc/Makefile.am doc/fisql.txt added man page for fisql + * src/apps/fisql/fisql.c fixed discarding const warnings + * doc/api_status.txt include/sybdb.h src/dblib/dblib.c + - added dbgettime() + +Thu Jan 18 17:57:52 EST 2007 Nick Castellano + * AUTHORS: credit myself as a contributor + +Thu Jan 18 17:50:18 EST 2007 Nick Castellano + * src/dblib/dblib.c: + - fix dbprrow() to print character data correctly + - fix dbprrow() to not loop endlessly on aggregate rows + +Thu Jan 18 08:57:10 CET 2007 Frediano Ziglio + * src/tds/unittests/utf8_2.c: fix error handler + +Wed Jan 17 09:48:45 CET 2007 Frediano Ziglio + * src/apps/fisql/fisql.c: use mkstemp instead of mktemp + * src/tds/util.c: cleanup + +Tue Jan 16 16:30:42 EDT 2007 Nick Castellano + * configure.ac + * src/apps/Makefile.am + * src/apps/fisql: contribute free DB-Libary isql application + +Tue Jan 16 09:57:35 CET 2007 Frediano Ziglio + * src/tds/util.c: fix messages + +Tue Jan 16 09:48:43 CET 2007 Frediano Ziglio + * misc/test-other.sh: fix problem with Perl 5.8.8 + * src/dblib/dblib.c: fix possible thread problem + +Tue Jan 16 00:28:28 EST 2007 JK Lowden + * include/dblib.h src/dblib/bcp.c + * src/dblib/dblib.c src/dblib/unittests/rpc.c + - support variadic form of dbperror + +Mon Jan 15 14:40:35 EST 2007 JK Lowden + * src/dblib/unittests/common.c + * src/dblib/unittests/rpc.c + * src/dblib/unittests/t0004.c + * src/dblib/unittests/t0005.c + * src/dblib/unittests/t0007.c + * src/dblib/unittests/t0019.c + * src/dblib/unittests/t0020.c + - fail if an unanticipated message/error is received + +Sun Jan 14 23:16:17 EST 2007 JK Lowden + * src/tds/config.c src/tds/login.c + - began work on autodetecting the server's TDSVER + - works with libtds, not db-lib + +Sun Jan 14 20:38:25 EST 2007 JK Lowden + * include/dblib.h include/tds.h + * src/dblib/dblib.c src/dblib/dbutil.c + * src/dblib/unittests/t0001.c src/dblib/unittests/t0012.c + * src/dblib/unittests/timeout.c + * src/tds/net.c TODO + - timeout unit test also works with dbsetinterrupt + +Sat Jan 13 17:09:05 EST 2007 JK Lowden + * src/dblib/unittests/timeout.c added + * src/dblib/dblib.c + * src/dblib/unittests/Makefile.am src/dblib/unittests/t0001.c + * src/tds/login.c src/tds/query.c src/tds/util.c + - new timeout unit test works. + +Fri Jan 12 14:28:32 CET 2007 Frediano Ziglio + * src/odbc/odbc.c: update code to new libTDS timeout code + * src/tds/net.c: handle send/recv errors + * src/tds/util.c: fix msgno if error not found in table + +Thu Jan 11 10:49:52 EST 2007 JK Lowden + * src/apps/osql + - fixed incorrect report when drivername is not a file + +Tue Jan 09 22:44:08 CET 2007 Frediano Ziglio + * src/apps/tsql.c: fix option problem + +Tue Jan 9 00:16:46 EST 2007 JK Lowden + * src/tds/net.c simpler tds_select, thanks Frediano + +Sun Jan 7 10:45:23 EST 2007 JK Lowden + * src/ctlib/ctutil.c works with tdserror() + +Sun Jan 7 00:41:19 EST 2007 JK Lowden + * include/tds.h + * src/dblib/dblib.c src/dblib/dbutil.c + * src/tds/net.c src/tds/query.c + * src/tds/token.c src/tds/util.c + - implement new timeout strategy using tds_select() and + - calling the client library's error handler (via tdserror). + - db-lib no worse than before, others not yet tested. + +Fri Jan 05 14:08:53 CET 2007 Frediano Ziglio + * include/tds.h src/tds/token.c: new token + * src/tds/util.c: optimize + +Fri Jan 5 02:08:54 EST 2007 JK Lowden + * include/tds.h src/tds/net.c src/tds/util.c + - begin new timeout strategy, not done. + +Thu Jan 4 18:47:46 EST 2007 JK Lowden + * doc/bsqldb.txt src/apps/bsqldb.c nicer headers + * doc/osql.txt src/apps/osql allow ini location override + +Tue Jan 2 15:42:09 EST 2007 JK Lowden + * include/dblib.h include/tds.h + * src/apps/tsql.c + * src/dblib/dblib.c src/dblib/dbutil.c + * src/tds/iconv.c src/tds/login.c src/tds/net.c + * src/tds/token.c src/tds/util.c + - replace tds_client_msg with tdserror() + +Mon Jan 01 12:56:50 CET 2007 Frediano Ziglio + * src/dblib/dblib.c src/tds/query.c: + - remove some warning compiling with SUN compiler + - Happy New Year + +Fri Dec 29 20:43:55 CET 2006 Frediano Ziglio + * src/tds/mem.c: remove warning and optimize + +Fri Dec 29 20:42:41 CET 2006 Frediano Ziglio + * src/apps/tsql.c: remove warnings + +Fri Dec 29 20:05:00 CET 2006 Frediano Ziglio + * include/tdsodbc.h: cleanup + +Fri Dec 29 20:03:30 CET 2006 Frediano Ziglio + * src/ctlib/unittests/rpc_ct_param.c: + * src/ctlib/unittests/rpc_ct_setparam.c src/odbc/odbc.c: + - remove warnings + +Fri Dec 29 17:18:42 CET 2006 Frediano Ziglio + * configure.ac src/tds/log.c: + - use localtime_r if available + +Fri Dec 29 10:06:56 CET 2006 Frediano Ziglio + * src/tds/log.c: + - avoid locking if no logging + +Tue Dec 26 15:57:38 CET 2006 Frediano Ziglio + * include/tds.h src/ctlib/unittests/array_bind.c: + * src/ctlib/unittests/ct_diagall.c: + * src/ctlib/unittests/get_send_data.c: + * src/ctlib/unittests/lang_ct_param.c: + * src/dblib/bcp.c src/dblib/dblib.c: + * src/dblib/dbutil.c src/dblib/rpc.c: + * src/dblib/xact.c src/dblib/unittests/common.h: + * src/dblib/unittests/t0016.c src/odbc/connectparams.c: + * src/odbc/descriptor.c src/odbc/error.c: + * src/odbc/odbc.c src/odbc/odbc_checks.c: + * src/odbc/prepare_query.c src/odbc/unittests/common.h: + * src/odbc/unittests/describecol.c src/pool/config.c: + * src/pool/main.c src/pool/member.c src/pool/stream.c: + * src/pool/user.c src/pool/util.c: + * src/replacements/readpassphrase.c: + * src/replacements/strtok_r.c src/replacements/vasprintf.c: + * src/server/login.c src/server/unittest.c: + * src/tds/config.c src/tds/convert.c src/tds/data.c: + * src/tds/getmac.c src/tds/iconv.c src/tds/locale.c: + * src/tds/login.c src/tds/net.c src/tds/numeric.c: + * src/tds/tds_checks.c src/tds/tdsstring.c src/tds/threadsafe.c: + * src/tds/write.c src/tds/unittests/common.h win32/winlogin.c: + * win32/winsetup.c: + - include stdarg.h always before stdio.h to fix portability + issues defining va_list + +Tue Dec 26 13:54:25 CET 2006 Frediano Ziglio + * src/tds/Makefile.am src/tds/util.c src/tds/log.c (added): + - separate log stuff + +Sun Dec 24 12:40:19 CET 2006 Frediano Ziglio + * src/odbc/descriptor.c: cleanup + +Fri Dec 22 09:34:37 CET 2006 Frediano Ziglio + * src/tds/convert.c: fix typo error + +Mon Dec 21 14:07:55 CET 2006 Frediano Ziglio + * src/tds/iconv.c: use cp1252 instead of iso8859-1 for mssql + +Wed Dec 20 22:47:36 EST 2006 JK Lowden + * src/tds/iconv.c src/tds/token.c log server charset changes + * src/tds/unittests/convert.c permit varbinary + +Mon Dec 18 10:50:34 CET 2006 Frediano Ziglio + * src/tds/Makefile.am: distribute enum_cap.h + +Fri Dec 15 14:41:14 EST 2006 JK Lowden + * src/tds/tds_willconvert.pl allow varbinary + +Thu Dec 14 22:18:16 EST 2006 JK Lowden + * src/tds/mem.c src/tds/unittests/t0001.c + - Added tds_capability_set and enumerated capabilities + * src/tds/enum_cap.h added + +Tue Dec 12 08:45:12 CET 2006 Frediano Ziglio + * include/tdsodbc.h src/odbc/odbc.c src/odbc/odbc_util.c: + - improve describecol test + +Sun Dec 10 16:04:02 EST 2006 JK Lowden + * doc/htdoc/faq.html minor fixes + * src/apps/tsql.c send *sybase* charset name in login record + * src/tds/net.c src/tds/read.c a little less logging + +Thu Dec 7 17:06:50 CET 2006 Frediano Ziglio + * src/tds/token.c: make get_send_data works + +Tue Dec 5 11:42:04 CET 2006 Frediano Ziglio + * src/odbc/unittests/funccall.c: add a test + +Fri Dec 1 16:45:59 EST 2006 JK Lowden + * include/sybdb.h src/dblib/bcp.c src/apps/freebcp.c + - Changed freetbcp batch-copied information messages to + - match the output of Sybase's bcp utility. + +Wed Nov 29 15:46:38 EST 2006 JK Lowden + * src/apps/tsql.c fixed broken "go" option handling. + +Tue Nov 28 11:52:27 EST 2006 JK Lowden + * src/apps/tsql.c fix -o option code + * src/tds/net.c reorganize tds_open_socket() + +Mon Nov 27 18:31:18 EST 2006 JK Lowden + * src/tds/net.c more detailed log of connect(2) + +Sun Nov 26 15:26:31 EST 2006 JK Lowden + * src/apps/tsql.c added connection timer feedback + * src/tds/login.c src/tds/net.c slightly better logging + +Thu Nov 23 09:43:00 CET 2006 Frediano Ziglio + * src/odbc/unittests/genparams.c: + - fix possible problem with very remote servers + +Thu Oct 26 15:09:48 EDT 2006 JK Lowden + * src/dblib/dbutil.c log error message from server + * src/tds/net.c log TDS version + +Thu Oct 26 14:26:27 EDT 2006 JK Lowden + * src/dblib/unittests/common.c src/dblib/unittests/common.h + * src/dblib/unittests/t0001.c + - corrected command-line option handling + +Sat Oct 21 16:42:08 EDT 2006 JK Lowden + * src/dblib/dblib.c src/dblib/unittests/t0022.c: + - dbresults succeeds if metadata or only return status is + - present, cf. ML yesterday. + +Sat Oct 21 14:22:44 CET 2006 Frediano Ziglio + * autogen.sh: fix some portability issues + +Wed Oct 18 21:38:57 CET 2006 Frediano Ziglio + * src/odbc/odbc.c src/odbc/unittests/tables.c: + - fix problem with mssql2005 and SQLTables + +Mon Oct 16 09:48:31 CET 2006 Frediano Ziglio + * src/tds/net.c: reduce system calls required + +Thu Oct 12 11:19:02 CET 2006 Frediano Ziglio + * src/tds/token.c: + - fix wrong assert + - return correctly RETURNSTATUS under Sybase + +Wed Oct 11 16:37:04 CET 2006 Frediano Ziglio + * src/tds/token.c: fix wrong assert using numerics + +Tue Oct 10 15:52:22 EDT 2006 JK Lowden + * doc/osql.txt clarified + +Fri Oct 6 17:08:43 EDT 2006 JK Lowden + * src/apps/freebcp.c src/apps/freebcp.h doc/freebcp.txt + - applied -0 patch from ML + - by Constantin Vasilyev + +Wed Oct 4 19:46:29 EDT 2006 JK Lowden + * src/apps/freebcp.c + - applied -P from stdin patch + - from ML Constantin Vasilyev + +Wed Oct 4 17:36:43 EDT 2006 JK Lowden + * src/apps/osql GNU sed does not support -E + +Wed Oct 4 14:48:20 EDT 2006 JK Lowden + * doc/Makefile.am doc/osql.txt added osql man page + +Wed Oct 4 14:12:25 EDT 2006 JK Lowden + * src/apps/Makefile.am add osql as installable script + +Tue Oct 3 15:40:12 EDT 2006 JK Lowden + * src/dblib/bcp.c test fwrite(3) correctly + +Tue Sep 26 16:57:42 EDT 2006 JK Lowden + * src/dblib/bcp.c src/dblib/dblib.c + * src/tds/convert.c src/tds/net.c src/tds/token.c + - added more user-level error checking, checking against + - known list of db-lib error messages + * src/apps/osql added + +Wed Sep 13 13:55:24 CET 2006 Frediano Ziglio + * samples/Makefile.am samples/unixodbc.freetds.driver.template.in: + - add Setup entry to unixODBC template + - unixODBC templates are not executables + +Wed Sep 13 13:52:40 CET 2006 Frediano Ziglio + * src/tds/mem.c: enable wide table + +Wed Sep 13 11:47:27 CET 2006 Frediano Ziglio + * src/tds/token.c: + - fix really broken tds5_process_result + +Fri Sep 08 11:58:24 CET 2006 Frediano Ziglio + * configure.ac src/tds/threadsafe.c: + - fix threadsafe problem on NetBSD + +Fri Sep 08 11:17:55 CET 2006 Frediano Ziglio + * include/tds.h src/tds/token.c: make splint a bit more happy + * src/odbc/odbc.c: small 64bit improvements + +Thu Sep 07 23:10:29 CET 2006 Frediano Ziglio + * src/odbc/sql2tds.c: fix paramset (Levente Tamási) + +Fri Sep 1 10:34:20 CET 2006 Frediano Ziglio + * include/tds.h include/tdsstring.h src/ctlib/ct.c: + * src/odbc/connectparams.c src/odbc/odbc.c src/server/login.c: + * src/tds/config.c src/tds/tdsstring.c: + - add dstr_size to DSTR + - add tds_dstr_alloc, tds_dstr_setlen, tds_dstr_buf + +Wed Aug 30 13:58:56 CET 2006 Frediano Ziglio + * include/tds.h src/tds/challenge.c src/tds/login.c: + - make tds_answer_challenge return flags + - tds_dstr fix + * src/dblib/dblib.c: small fix + * src/odbc/odbc.c: constification + * src/tds/query.c: + - some static functions rename + - do not convert string in tds7_build_param_def_from_query + * src/tds/threadsafe.c: cleanup + +Mon Aug 28 09:36:32 CET 2006 Frediano Ziglio + * include/cspublic.h: + - applied Norbert Sendetzky patch for ctlib compatibility + +Fri Aug 25 11:03:40 CET 2006 Frediano Ziglio + * src/dblib/unittests/Makefile.am src/dblib/unittests/t0017.c: + * src/dblib/unittests/t0017.in.be(added): + - fix big endian problem with t0017 test + +Fri Aug 25 09:17:37 CET 2006 Frediano Ziglio + * src/apps/tsql.c: remove 1024 char limit on tsql_readline + +Thu Aug 24 21:18:48 CET 2006 Frediano Ziglio + * src/apps/tsql.c: applied Christos Zoulas patch for no-tty + +Thu Aug 24 16:29:17 CET 2006 Frediano Ziglio + * include/sybdb.h src/dblib/dblib.c: + - do not change compatibility + * src/tds/config.c: small optimization + +Thu Aug 24 11:37:15 CET 2006 Frediano Ziglio + * m4/sprintf_i64_format.m4: fix 64bit problem for LP64 + +Thu Aug 24 11:17:26 CET 2006 Frediano Ziglio + * include/tds_sysdep_private.h src/apps/tsql.c src/ctlib/Makefile.am: + * src/dblib/Makefile.am src/tds/net.c win32/initnet.c: + * win32/winsetup.c win32/dev-cpp/FreeTDS.dev: + * win32/dev-cpp/Makefile.win win32/msvc6/FreeTDS.dsp: + - initialize socket library on win32 + +Thu Aug 24 08:32:07 CET 2006 Frediano Ziglio + * src/apps/tsql.c: + - do not print return status if quiet (patch from Christos Zoulas) + +Wed Aug 23 21:43:50 CET 2006 Frediano Ziglio + * doc/tsql.txt: applied Christos Zoulas updates + * doc/txt2man: updated + +Wed Aug 23 17:16:10 CET 2006 Frediano Ziglio + * src/tds/net.c: + - clean error before reading SO_ERROR, some system need this + * src/tds/util.c src/ctlib/ct.c: cross compile fixes + +Wed Aug 23 16:25:25 CET 2006 Frediano Ziglio + * m4/ac_tds_func_which_getpwuid_r.m4 m4/sprintf_i64_format.m4: + * configure.ac src/ctlib/cs.c src/apps/tsql.c: + * src/replacements/asprintf.c src/tds/query.c: + - fixes some cross compile issues with hp-ux + +Mon Aug 21 11:08:37 CET 2006 Frediano Ziglio + * src/dblib/dblib.c: remove small buffer overflow + +Thu Aug 17 11:13:40 CET 2006 Frediano Ziglio + * configure.ac include/tds.h src/dblib/unittests/Makefile.am: + * src/tds/net.c src/tds/query.c src/tds/token.c src/tds/util.c: + * m4/acx_pthread.m4(added): + - timeout more precise and use monotonic clock if available + - check pthread support more deeply + +Wed Aug 16 13:04:48 CET 2006 Frediano Ziglio + * src/tds/net.c: cleanup, fix possible problem under Linux + * src/tds/read.c: avoid invalid in_pos value on tds_peek + +Mon Aug 14 19:12:58 CET 2006 Frediano Ziglio + * src/ctlib/blk.c src/dblib/bcp.c src/dblib/dblib.c: + * src/dblib/unittests/common.c: + - fix warnings compiling with SUN cc + * src/dblib/unittests/thread.c: make error more verbose + +Sun Aug 13 15:02:40 CET 2006 Frediano Ziglio + * src/odbc/odbc.c src/odbc/unittests/data.c: + * src/odbc/unittests/transaction.c: + - fix minor issues with 64-bit machines + +Thu Aug 10 10:10:30 CET 2006 Frediano Ziglio + * src/ctlib/ct.c: fix possible buffer overflow + * src/replacements/gettimeofday.c: add comment + * src/tds/threadsafe.c: better and simple win implementation + * vms/descrip_mms.template win32/config.h: + * win32/dev-cpp/FreeTDS.dev win32/msvc6/libTDS.dsp: + - update build file + +Tue Aug 08 19:14:32 CET 2006 Frediano Ziglio + * doc/htdoc/index.html: update link + * src/tds/query.c: add comment + +Tue Aug 08 16:42:39 CET 2006 Frediano Ziglio + * src/tds/query.c src/tds/util.c: + - fix timeout problem setting correctly query_start_time + +Tue Aug 08 14:43:50 CET 2006 Frediano Ziglio + * src/odbc/unittests/Makefile.am: + * src/odbc/unittests/timeout2.c(added): + - added a test for timeout problem (cf "Query Time Out" on ML) + +Mon Aug 07 21:37:39 CET 2006 Frediano Ziglio + * include/tdsstring.h src/odbc/odbc_util.c: + * src/replacements/iconv.c src/tds/challenge.c: + * src/tds/config.c src/tds/convert.c: + * src/tds/iconv.c src/tds/mem.c src/tds/net.c: + * src/tds/query.c src/tds/read.c src/tds/tdsstring.c: + * src/tds/token.c src/tds/write.c: + - updated doxygen comments + +Sun Aug 06 17:54:11 CET 2006 Frediano Ziglio + * freetds.spec.in: fix rpm build on suse + +Thu Aug 03 20:30:07 CET 2006 Frediano Ziglio + * NEWS include/tds.h src/ctlib/ct.c src/odbc/odbc.c: + * src/tds/mem.c src/tds/query.c src/tds/tds_checks.c: + * src/tds/token.c src/tds/util.c: + - use reference counting for TDSCURSOR to avoid memory errors + +Thu Aug 03 10:32:37 CET 2006 Frediano Ziglio + * src/tds/unittests/iconv_fread.c(added): + * src/tds/iconv.c src/tds/unittests/.cvsignore: + * src/tds/unittests/Makefile.am: + - fix tds_iconv_fread and add a test for it + +Mon Jul 31 13:27:53 EDT 2006 JK Lowden + * src/dblib/bcp.c + - proper error message for using bcp with TDS version 4.2 + +Mon Jul 31 13:23:44 EDT 2006 JK Lowden + * include/sybdb.h src/dblib/dblib.c + - proper error message for using bcp with TDS version 4.2 + +Thu Jul 27 15:22:27 EDT 2006 JK Lowden + * samples/odbc_rpc.pl use fetchrow_array + * src/tds/unittests/Makefile.am include parent directory + +Tue Jul 25 10:16:45 CET 2006 Frediano Ziglio + * configure.ac m4/ac_nullzero.m4: add test for portability + +Tue Jul 25 10:10:22 CET 2006 Frediano Ziglio + * src/odbc/unittests/paramcore.c: updated + +Mon Jul 24 11:39:13 CET 2006 Frediano Ziglio + * src/odbc/unittests/prepclose.c: + - test with SQLExecDirect + +Mon Jul 17 15:18:48 CET 2006 Frediano Ziglio + * src/dblib/unittests/build_dsw.pl(removed): + * win32/build_dsw.pl(added) src/dblib/unittests/Makefile.am: + * src/odbc/unittests/Makefile.am: + - add a Makefile target to build projects for msvc6 + +Thu Jul 13 10:20:45 CET 2006 Frediano Ziglio + * include/tdsodbc.h src/odbc/odbc.c src/odbc/unittests/moreandcount.c: + - remove next_row_count, now useless... rpc.c works the same + +Wed Jul 12 13:23:43 EDT 2006 JK Lowden + * src/odbc/odbc.c src/tds/token.c: + - use TDS_NO_COUNT instead of bad rows_affected for next_row_count. + - src/odbc/unittests/rpc.c now works + +Wed Jul 12 16:15:14 CET 2006 Frediano Ziglio + * misc/test-other.sh: add file log + * src/odbc/unittests/rpc.c: fix uninitialized error + +Tue Jul 11 17:52:43 EDT 2006 JK Lowden + * src/odbc/odbc.c src/odbc/unittests/rpc.c: + - Better logging + +Tue Jul 11 17:28:34 CET 2006 Frediano Ziglio + * src/dblib/unittests/done_handling.c: improve + +Tue Jul 11 17:27:26 CET 2006 Frediano Ziglio + * src/odbc/unittests/paramcore.c: + - fix compatibility with sybase + +Tue Jul 11 11:56:53 CET 2006 Frediano Ziglio + * misc/online.pl: generate more friendly names + +Mon Jul 10 17:07:00 EDT 2006 JK Lowden + * src/tds/token.c src/dblib/dblib.c src/dblib/unittests/rpc.c + - dbresults does not return on DONEPROC + +Sun Jul 09 12:52:45 CET 2006 Frediano Ziglio + * doc/Makefile.am: fix compatibility problem + * src/odbc/unittests/rpc.c: fix warning + +Fri Jul 7 19:08:44 EDT 2006 JK Lowden + * include/sybdb.h src/dblib/dblib.c src/tds/token.c: + - Better logging + +Wed Jul 05 14:45:08 CET 2006 Frediano Ziglio + * src/dblib/unittests/Makefile.am src/dblib/unittests/bcp.c: + * src/dblib/unittests/common.c src/dblib/unittests/common.h: + * src/dblib/unittests/dbmorecmds.c: + * src/dblib/unittests/done_handling.c: + * src/dblib/unittests/rpc.c src/dblib/unittests/t0001.c: + * src/dblib/unittests/t0002.c src/dblib/unittests/t0003.c: + * src/dblib/unittests/t0004.c src/dblib/unittests/t0005.c: + * src/dblib/unittests/t0006.c src/dblib/unittests/t0007.c: + * src/dblib/unittests/t0008.c src/dblib/unittests/t0009.c: + * src/dblib/unittests/t0011.c src/dblib/unittests/t0012.c: + * src/dblib/unittests/t0013.c src/dblib/unittests/t0014.c: + * src/dblib/unittests/t0015.c src/dblib/unittests/t0016.c: + * src/dblib/unittests/t0017.c src/dblib/unittests/t0018.c: + * src/dblib/unittests/t0019.c src/dblib/unittests/t0020.c: + * src/dblib/unittests/t0021.c src/dblib/unittests/t0022.c: + * src/dblib/unittests/t0023.c src/dblib/unittests/text_buffer.c: + * src/dblib/unittests/thread.c: + * src/dblib/unittests/build_dsw.pl(added): + - put include stuff in common.h + - fix compile with ms dblib + - simplify testing under windows creating project files + +Wed Jul 5 18:29:21 EDT 2006 JK Lowden + * src/dblib/dblib.c src/dblib/rpc.c: + - removed nonprintable characters from TDSDUMP log + +Wed Jul 5 15:43:24 EDT 2006 JK Lowden + * src/dblib/unittests/rpc.c src/odbc/unittests/rpc.c: + - more thorough tests, currently fail + +Tue Jul 04 17:13:08 CET 2006 Frediano Ziglio + * src/odbc/unittests/Makefile.am: + * src/odbc/unittests/paramcore.c(added): + * src/odbc/unittests/.cvsignore src/odbc/sql2tds.c: + - test for core using SQLBindParameter, small fix + +Mon Jul 03 13:09:40 CET 2006 Frediano Ziglio + * src/odbc/odbc.c: + - assure there is always an error when SQL_ERROR is returned + - fix warning + +Fri Jun 30 10:31:49 EDT 2006 JK Lowden + * src/odbc/sql2tds.c assert good pointer in case user passed NULL + * src/odbc/unittests/Makefile.am src/odbc/unittests/rpc.c + - added new unit test, similar to that used in dblib. + +Thu Jun 29 17:05:35 CET 2006 Frediano Ziglio + * NEWS src/tds/challenge.c: + - fix small buffer overflow + - reuse buffer + +Thu Jun 29 14:07:42 CET 2006 Frediano Ziglio + * include/tds.h src/tds/Makefile.am src/tds/challenge.c: + * src/tds/login.c src/tds/token.c: + - add NTLM2 Session Response support + +Tue Jun 27 15:47:46 CET 2006 Frediano Ziglio + * src/dblib/unittests/done_handling.c: + - improve + - update style + - fix typo + +Mon Jun 26 16:10:02 CET 2006 Frediano Ziglio + * phptests/rpc2.php(added): + - test from Ellert van Koperen (cf "SP parameters" and + http://kb.vankoperen.nl/freetds-problems.html) + +Sun Jun 25 10:12:48 CET 2006 Frediano Ziglio + * src/odbc/unittests/warning.c: + - tested + - fix portability problem with former Sybase db + - test returned warning + +Sun Jun 25 09:50:00 CET 2006 Frediano Ziglio + * src/odbc/unittests/.cvsignore src/odbc/unittests/Makefile.am: + * src/odbc/unittests/warning.c(added): + - added warning test from John K. Hohm (cf + "Warning return as copy of last result row" on ML) + * src/odbc/unittests/describecol.c: compile fix + +Wed Jun 21 17:03:55 CET 2006 Frediano Ziglio + * src/odbc/unittests/describecol.c: + * src/odbc/unittests/describecol.in(added): + - rewrote describecol test + +Wed Jun 21 09:26:02 CET 2006 Frediano Ziglio + * src/odbc/odbc.c: improve column_length + * src/odbc/odbc_util.c: fix for odbc_sql_to_displaysize + * src/tds/iconv.c: invalid iconv_t is only -1, not NULL + +Tue Jun 20 17:52:19 EDT 2006 Nick Castellano + * src/odbc/unittests/array_out.c: + - rename variable to avoid libc symbol conflict + +Tue Jun 20 14:38:03 CET 2006 Frediano Ziglio + * src/tds/convert.c: use macro in sprintf + +Tue Jun 20 14:34:03 CET 2006 Frediano Ziglio + * src/tds/mem.c: small macro to allocate columns + +Tue Jun 20 14:33:09 CET 2006 Frediano Ziglio + * src/odbc/unittests/describecol.c: improved a lot + +Tue Jun 20 11:15:16 CET 2006 Frediano Ziglio + * src/odbc/odbc.c: catch error better + +Mon Jun 19 10:38:36 CET 2006 Frediano Ziglio + * freetds.spec.in misc/test-other.sh src/apps/Makefile.am: + * src/ctlib/Makefile.am src/dblib/Makefile.am src/odbc/Makefile.am: + * src/server/Makefile.am src/tds/Makefile.am: + * src/tds/unittests/Makefile.am: + - do not make libTDS shared library any more + +Mon Jun 19 09:57:23 CET 2006 Frediano Ziglio + * src/ctlib/ct.c src/odbc/sql2tds.c src/odbc/unittests/data.c: + * src/server/unittest.c: + - remove warning compiling with gcc4 + +Thu Jun 15 14:15:24 CET 2006 Frediano Ziglio + * configure.ac src/ctlib/unittests/cancel.c: + * src/dblib/unittests/common.c src/odbc/Makefile.am: + * src/replacements/readpassphrase.c: + - finished cross mingw32 + +Wed Jun 14 17:34:56 CET 2006 Frediano Ziglio + * src/odbc/convert_tds2sql.c: fix for date format + +Wed Jun 14 17:29:13 CET 2006 Frediano Ziglio + * configure.ac: add function + * src/apps/Makefile.am src/dblib/unittests/Makefile.am: + * src/dblib/unittests/bcp.c src/odbc/unittests/Makefile.am: + * src/replacements/Makefile.am src/replacements/gettimeofday.c: + * src/tds/unittests/Makefile.am: + - more fixes for cross mingw32 + +Wed Jun 14 13:26:42 CET 2006 Frediano Ziglio + * include/tds_sysdep_private.h src/apps/Makefile.am: + - fix for cross mingw32 + * src/odbc/unittests/describecol.c: report more clearly problems + +Tue Jun 13 20:17:16 CET 2006 Frediano Ziglio + * src/odbc/unittests/common.h src/server/unittest.c: + - small fixes for cross mingw + +Tue Jun 13 14:38:34 CET 2006 Frediano Ziglio + * src/odbc/unittests/prepclose.c(added) configure.ac: + * src/odbc/unittests/.cvsignore src/odbc/unittests/Makefile.am: + - add test to test error closing connection on SQLPrepare + +Mon Jun 12 22:02:57 CET 2006 Frediano Ziglio + * m4/sprintf_i64_format.m4: fix for cross mingw32 + +Mon Jun 12 21:52:24 CET 2006 Frediano Ziglio + * src/odbc/sql2tds.c: fix for possible uninitialized variable + +Mon Jun 12 21:48:15 CET 2006 Frediano Ziglio + * src/apps/datacopy.c src/apps/freebcp.c src/apps/freebcp.h: + * src/pool/main.c src/pool/pool.h: + - fix some issues cross compiling for mingw32 + +Mon Jun 12 16:55:59 CET 2006 Frediano Ziglio + * src/odbc/unittests/data.c: add test for date to char + +Fri Jun 9 14:33:31 EDT 2006 Nick Castellano + * src/apps/tsql.c: inhibit readline tab completion in tsql + +Fri Jun 09 11:50:55 EDT 2006 Nick Castellano + * locales.conf: use same date format as Sybase in default and en_US + +Thu Jun 08 10:18:50 CET 2006 Frediano Ziglio + * src/tds/unittests/t0007.c: + - improved to detect possible date problems + +Wed Jun 07 14:37:56 EDT 2006 Nick Castellano + * src/tds/convert.c: correctly convert dates in January + +Tue Jun 06 12:02:10 CET 2006 Frediano Ziglio + * configure.ac src/tds/config.c: + - fix tsql -C for sybase compatibility + +Tue Jun 06 11:32:24 CET 2006 Frediano Ziglio + * src/tds/mem.c: use calloc instead of malloc/memset + +Mon Jun 05 13:42:24 CET 2006 Frediano Ziglio + * src/ctlib/ct.c src/tds/token.c: + - style and cleanup + +Mon May 29 13:38:05 CET 2006 Frediano Ziglio + * m4/sprintf_i64_format.m4: fix quoting + +Mon May 29 12:58:38 CET 2006 Frediano Ziglio + * NEWS include/tds.h src/tds/token.c: + - make tds_alloc_get_string static + +Mon May 15 17:11:54 CET 2006 Frediano Ziglio + * src/odbc/odbc.c: + - applied fixes from Charlene Herring (cf. "Problems when + using odbc : SQLPutData, SQLExecDirect,Decimals" 2006/05/14 + +Sun May 14 14:34:04 CET 2006 Frediano Ziglio + * src/odbc/descriptor.c: fix memory error + +Sat May 13 10:49:40 CET 2006 Frediano Ziglio + * src/odbc/unittests/copydesc.c: improve + +Mon May 08 11:38:30 CET 2006 Frediano Ziglio + * src/odbc/descriptor.c src/odbc/unittests/Makefile.am: + * src/odbc/unittests/copydesc.c(added): add test for SQLCopyDesc + +Fri Apr 21 17:10:00 CET 2006 Frediano Ziglio + * src/odbc/sql2tds.c: use new tds_convert types + +Fri Apr 21 09:45:56 CET 2006 Frediano Ziglio + * doc/htdoc/faq.html: fix html compatibility + +Thu Apr 20 12:10:28 CET 2006 Frediano Ziglio + * src/ctlib/unittests/ct_dynamic.c: remove leak in test + +Tue Apr 17 19:47:57 CET 2006 Frediano Ziglio + * src/ctlib/ct.c: fix double free + +Mon Apr 17 10:51:09 CET 2006 Frediano Ziglio + * src/odbc/convert_tds2sql.c src/odbc/prepare_query.c: + - use new conversion style in ODBC + +Sun Apr 16 10:11:32 CET 2006 Frediano Ziglio + * include/tds.h src/tds/locale.c src/tds/mem.c: + - TDSLOCALE changes to keep ABI + +Sat Apr 15 10:18:29 CET 2006 Frediano Ziglio + * include/tdsconvert.h * src/tds/convert.c: + - add new type of conversion for copy optimizations + +Sat Apr 15 10:02:20 CET 2006 Frediano Ziglio + * src/odbc/unittests/describecol.c: fix for older Sybase versions + * src/tds/config.c: optimize option read + +Sat Apr 15 09:03:34 CET 2006 Frediano Ziglio + * src/odbc/unittests/describecol.c: remove warning + +Fri Apr 14 15:22:02 CET 2006 Frediano Ziglio + * src/odbc/unittests/describecol.c: + - improved + +Fri Apr 14 13:55:09 CET 2006 Frediano Ziglio + * src/odbc/unittests/describecol.c: + - add test for precision returned by SQLDescribeCol + +Wed Apr 12 21:41:51 CET 2006 Frediano Ziglio + * locales.conf: fix charset typo + * doc/userguide.sgml: fix attributes for locales.conf + +Wed Apr 12 15:53:18 CET 2006 Frediano Ziglio + * include/tds.h include/tds_sysdep_private.h: + * include/tds_sysdep_public.h.in include/tdsconvert.h: + * include/tdsver.h.in: + - avoid ident strings in all objects + * m4/sprintf_i64_format.m4: add Ld format + +Tue Apr 11 16:33:41 CET 2006 Frediano Ziglio + * include/tds_sysdep_public.h.in include/tdsver.h.in: + - small constification + +Tue Apr 11 13:51:43 CET 2006 Frediano Ziglio + * src/odbc/unittests/connect.c: do not fail if not FreeTDS + * src/odbc/unittests/raiserror.c: more verbose + +Mon Apr 10 18:14:17 EDT 2006 JK Lowden + * include/tds.h src/apps/tsql.c src/tds/config.c + - report sysconfdir with tsql -C + +Mon Apr 10 11:59:53 CET 2006 Frediano Ziglio + * src/odbc/odbc.c: cleanup + +Fri Apr 07 09:38:45 CET 2006 Frediano Ziglio + * misc/test-other.sh: update to php 5.1 + * phptests/nextres.php: a bit more verbose + +Thu Apr 06 11:37:45 CET 2006 Frediano Ziglio + * misc/coverage.sh: less verbose + * src/dblib/bcp.c: small change + +Wed Apr 05 08:42:54 CET 2006 Frediano Ziglio + * misc/full-test.sh: cleanup + * misc/test-auto.sh: allow configuration + * misc/test-other.sh: make output suitable for online.pl + * src/apps/tsql.c: + - improve documentation + - fix problem for multiple options + * src/odbc/odbc.c src/tds/token.c: avoid void message to application + +Wed Apr 05 07:09:32 CET 2006 Frediano Ziglio + * src/odbc/odbc.c: remove some warnings + +Wed Mar 29 18:25:54 CET 2006 Frediano Ziglio + * m4/ac_caolan_func_which_gethostbyname_r.m4: + * m4/ac_have_inaddr_none.m4 m4/ac_have_malloc_options.m4: + * m4/ac_raf_func_which_getservbyname_r.m4: + * m4/ac_tds_func_which_gethostbyaddr_r.m4: + * m4/ac_tds_func_which_getpwuid_r.m4: + * m4/ac_tds_func_which_localtime_r.m4: + * m4/ax_cflags_gcc_option.m4 m4/lib-link.m4: + * m4/sprintf_i64_format.m4 m4/type_socklen_t.m4: + - quote as necessary + +Mon Mar 27 19:01:05 EST 2006 JK Lowden + * configure.ac + * m4/ac_caolan_func_which_gethostbyname_r.m4 + * m4/ac_have_inaddr_none.m4 + * m4/ac_have_malloc_options.m4 + * m4/ac_raf_func_which_getservbyname_r.m4 + * m4/ac_tds_func_which_gethostbyaddr_r.m4 + * m4/ac_tds_func_which_getpwuid_r.m4 + * m4/ac_tds_func_which_localtime_r.m4 + * m4/ax_cflags_gcc_option.m4 + * m4/sprintf_i64_format.m4 + * m4/type_socklen_t.m4 + * src/ctlib/unittests/Makefile.am + * src/dblib/unittests/Makefile.am + * src/odbc/unittests/Makefile.am + * src/tds/unittests/Makefile.am + - removed/updated obsolete autoconf macros + * m4/am_iconv.m4 removed + * m4/README.iconv + * m4/iconv.m4 m4/lib-ld.m4 m4/lib-link.m4 m4/lib-prefix.m4 + - added from GNU libiconv + +Mon Mar 27 09:48:56 EST 2006 JK Lowden + * doc/htdoc/index.html corrected nightly test link + +Mon Mar 27 10:17:42 CET 2006 Frediano Ziglio + * src/dblib/rpc.c: allow again null for fixed types + +Mon Mar 27 02:20:16 EST 2006 JK Lowden + * configure.ac m4/am_iconv.m4 m4/check_openssl.m4 + * src/apps/Makefile.am src/ctlib/Makefile.am src/dblib/Makefile.am + * src/odbc/Makefile.am src/pool/Makefile.am src/replacements/Makefile.am + * src/server/Makefile.am src/tds/Makefile.am + - modernized autotool contructs + * configure.in removed + +Sun Mar 26 19:01:43 CET 2006 Frediano Ziglio + * src/odbc/prepare_query.c: + - fixed constant parameters after mssql 2005 patch + +Fri Mar 24 16:47:26 EST 2006 JK Lowden + * configure.in removed, is now configure.ac + * acinclude.m4 removed, added m4 directory + * Makefile.am include m4 directory + * m4/ac_caolan_func_which_gethostbyname_r.m4 m4/ac_have_inaddr_none.m4 + * m4/ac_have_malloc_options.m4 m4/ac_raf_func_which_getservbyname_r.m4 + * m4/ac_tds_func_which_gethostbyaddr_r.m4 + * m4/ac_tds_func_which_getpwuid_r.m4 + * m4/ac_tds_func_which_localtime_r.m4 m4/am_iconv.m4 + * m4/check_openssl.m4 m4/sprintf_i64_format.m4 m4/type_socklen_t.m4 + - Split acinclude.m4 into one macro defintion per file. + * m4/ax_cflags_gcc_option.m4 + - Check for gcc features e.g. the declaration-after-statement warning. + +Fri Mar 24 13:03:36 EST 2006 JK Lowden + * doc/htdoc/docs.html doc/htdoc/index.html updated + +Fri Mar 24 12:36:02 EST 2006 JK Lowden + * doc/htdoc/software.html fixed broken links added link to RC + +Fri Mar 24 16:27:27 CET 2006 Frediano Ziglio + * misc/full-test.sh misc/test-auto.sh misc/full-test-ol.sh(removed): + - use an "online" version for test + +Thu Mar 23 15:53:45 CET 2006 Frediano Ziglio + * src/odbc/sql2tds.c src/odbc/unittests/earlybind.c: + * src/odbc/unittests/norowset.c src/odbc/unittests/t0004.c: + * src/odbc/unittests/tables.c src/tds/data.c src/tds/tds_checks.c: + - fixes for mssql 2005 + +Thu Mar 23 13:48:23 CET 2006 Frediano Ziglio + * src/tds/query.c: partially fix problem with mssql2k5 + +Thu Mar 23 11:44:32 CET 2006 Frediano Ziglio + * misc/full-test-ol.sh misc/online.pl misc/test-auto.sh: + - changed online.pl with James hints + - enable Valgrind tests using online check + +Tue Mar 21 15:24:04 CET 2006 Frediano Ziglio + * src/odbc/unittests/cursor2.c(aded) src/odbc/unittests/Makefile.am: + - added test to check errors using cursor on no row statement + +Tue Mar 21 13:22:07 CET 2006 Frediano Ziglio + * src/odbc/native.c: + - applied patch from Richard Krehbiel (cf "ODBC datetime literal issue") + +Tue Mar 21 08:49:44 CET 2006 Frediano Ziglio + * configure.in src/dblib/dblib.c: + - fix declaration after statements + +Mon Mar 20 15:28:25 CET 2006 Frediano Ziglio + * src/dblib/bcp.c: fix error in bcp_colfmt + +Mon Mar 20 15:00:45 CET 2006 Frediano Ziglio + * src/dblib/bcp.c src/dblib/dblib.c src/dblib/rpc.c: + - remove some double checks + - return correct values from CHECK_PARAMETER + - fix some possible core if dbproc == NULL + +Mon Mar 20 09:42:55 CET 2006 Frediano Ziglio + * misc/full-test.sh: added timeout + +Sun Mar 19 18:34:47 CET 2006 Frediano Ziglio + * misc/test-auto.sh: fix typo in header + * src/dblib/dblib.c: remove double checks + +Sun Mar 19 18:33:14 CET 2006 Frediano Ziglio + * src/odbc/unittests/genparams.c src/odbc/unittests/transaction.c: + - remove warnings on 64bit int + +Sun Mar 19 09:27:09 EST 2006 JK Lowden + * src/dblib/bcp.c src/dblib/dblib.c more logging repairs + +Sat Mar 18 12:34:02 EST 2006 JK Lowden + * include/dblib.h src/dblib/bcp.c + - validate parameters. Unable to run unittest due to down server. + +Sat Mar 18 01:27:32 EST 2006 JK Lowden + * include/dblib.h src/dblib/dblib.c src/dblib/rpc.c + - test parameters for all public functions (except bcp) + +Fri Mar 17 01:35:17 EST 2006 JK Lowden + * src/dblib/dblib.c src/dblib/rpc.c + - added a TDSDUMP log entry for every public function + +Thu Mar 16 09:59:25 EST 2006 JK Lowden + * TODO add rpc error messages + * src/apps/bsqldb.c exit if severity > 10 + +Wed Mar 15 00:41:11 EST 2006 JK Lowden + * doc/freebcp.txt The freebcp manpage was seriously out of date. + * src/apps/freebcp.c give better error message. + +Thu Mar 9 14:33:37 CET 2006 Frediano Ziglio + * include/tdsodbc.h src/odbc/odbc.c: + - add cursor_type to connection attributes (required for DBD::ODBC) + - removed small TODO on error report + +Mon Mar 6 12:55:10 CET 2006 Frediano Ziglio + * include/tds.h src/ctlib/ct.c src/odbc/connectparams.c: + * src/pool/util.c src/server/login.c src/server/unittest.c: + * src/tds/config.c src/tds/login.c src/tds/mem.c: + - renamed host_name field to client_host_name + - optimize way strings are allocated + +Fri Feb 24 15:04:35 EST 2006 JK Lowden + * src/tds/config.c src/tds/login.c: + - nicer TDSDUMPCONFIG output, including a recap + +Sun Feb 19 14:56:15 CET 2006 Frediano Ziglio + * src/odbc/odbc.c: fix wrong declaration + +Thu Feb 16 08:30:00 CET 2006 Frediano Ziglio + * src/odbc/unittests/scroll.c src/odbc/unittests/raiserror.c: + * src/odbc/unittests/cursor1.c: + - remove warning compiling with gcc4 + * misc/test-other.sh: fix problem with DBD:ODBC test + +Mon Feb 13 17:11:30 CET 2006 Frediano Ziglio + * src/odbc/unittests/genparams.c: add BIGINT type to test + +Wed Feb 8 10:48:36 CET 2006 Frediano Ziglio + * include/tdsodbc.h src/odbc/error.c src/odbc/odbc.c: + * vms/odbc_driver_axp.opt win32/FreeTDS.def: + - start cursor stuff for odbc + - added SQLSetScrollOptions + * src/odbc/unittests/scroll.c: support more fetch types + +Tue Feb 7 15:42:56 CET 2006 Frediano Ziglio + * include/tds.h src/tds/query.c src/ctlib/ct.c NEWS: + - improve cursor support + +Tue Feb 7 14:22:50 CET 2006 Frediano Ziglio + * src/odbc/unittests/scroll.c(added): + * src/odbc/unittests/.cvsignore: + * src/odbc/unittests/Makefile.am: + * src/odbc/unittests/cursor1.c: + - add scroll test for cursor + - build msvc project for odbc unittests + * src/dblib/unittests/Makefile.am: add done_handling test + +Mon Feb 6 16:50:05 CET 2006 Frediano Ziglio + * include/sybdb.h src/apps/freebcp.c src/dblib/bcp.c: + - implemented BCPKEEPIDENTITY for bcp_control + - make freebcp do not depend on dblib internals + +Mon Feb 6 16:44:27 CET 2006 Frediano Ziglio + * src/odbc/unittests/.cvsignore src/odbc/unittests/cursor1.c: + - update cursor1 test + +Thu Feb 2 15:33:21 CET 2006 Frediano Ziglio + * NEWS: updated + * src/odbc/odbc.c vms/odbc_driver_axp.opt win32/FreeTDS.def: + - compile SQLSetPos function + * src/odbc/unittests/Makefile.am src/odbc/unittests/cursor1.c(added): + - added a test for cursors (do not work...) + +Tue Jan 31 14:27:51 CET 2006 Frediano Ziglio + * src/apps/freebcp.c src/dblib/bcp.c: + - fix broken charcater conversion + - use calloc instead of malloc/memset + - support 64bit file on win32 + +Tue Jan 31 09:59:28 CET 2006 Frediano Ziglio + * src/dblib/dblib.c: do more argument check + +Mon Jan 30 16:29:20 CET 2006 Frediano Ziglio + * src/ctlib/unittests/blk_out.c src/ctlib/unittests/ct_cursor.c: + * src/ctlib/unittests/ct_cursors.c src/ctlib/unittests/ct_dynamic.c: + * src/dblib/unittests/t0005.c src/dblib/unittests/t0014.c: + * src/dblib/unittests/t0022.c src/dblib/unittests/thread.c: + - reduce false errors + +Sat Jan 28 15:49:55 CET 2006 Frediano Ziglio + * src/dblib/bcp.c: + - update row allocation using new row_free + - fix native format + - correctly check and handle EOF + - change _bcp_build_bcp_record to direct send row (renamed to + _bcp_send_bcp_record) + - write error file only if needed + * src/dblib/unittests/t0016.c: improved + * src/dblib/unittests/t0016.in: + - make input same of output + * src/dblib/unittests/t0017.c: get all data + * src/tds/mem.c: reset pointer just freed + +Sat Jan 28 09:39:10 CET 2006 Frediano Ziglio + * src/dblib/unittests/t0017.c: reformat output + +Fri Jan 27 14:34:09 EST 2006 JK Lowden + * src/dblib/bcp.c recognize EOF errors from _bcp_read_hostfile + +Fri Jan 27 10:43:54 EST 2006 JK Lowden + * src/dblib/unittests/t0017.c better feedback + +Thu Jan 26 13:58:51 CET 2006 Frediano Ziglio + * src/apps/freebcp.c src/apps/freebcp.h: + - support for NUL in terminators + +Wed Jan 25 15:33:20 CET 2006 Frediano Ziglio + * src/dblib/bcp.c: fix return test for fseeko + +Wed Jan 25 15:01:51 CET 2006 Frediano Ziglio + * acinclude.m4 configure.in src/tds/numeric.c: + - use 64bit sprintf format if available + * misc/test-other.sh: redirect odbc to compiled driver + +Tue Jan 24 16:01:41 CET 2006 Frediano Ziglio + * NEWS include/tds.h src/apps/tsql.c src/ctlib/blk.c: + * src/ctlib/ct.c src/dblib/bcp.c src/dblib/buffering.h: + * src/dblib/dblib.c src/dblib/rpc.c src/odbc/odbc.c: + * src/odbc/odbc_util.c src/odbc/prepare_query.c: + * src/odbc/sql2tds.c src/pool/stream.c src/server/server.c: + * src/tds/mem.c src/tds/query.c src/tds/tds_checks.c: + * src/tds/token.c src/tds/unittests/dataread.c: + * src/tds/unittests/dynamic1.c src/tds/unittests/t0002.c: + * src/tds/unittests/t0004.c src/tds/unittests/t0005.c: + * src/tds/unittests/t0006.c src/tds/unittests/utf8_1.c: + * src/tds/unittests/utf8_2.c: + - use direct pointer column_data instead of old column_offset + +Mon Jan 23 17:30:38 EST 2006 JK Lowden + * src/apps/bsqldb.c bind to printable width, not column size + +Mon Jan 23 14:04:44 CET 2006 Frediano Ziglio + * configure.in: start developing 0.65 version +$Id: ChangeLog-0.82,v 1.1 2008/01/10 01:01:38 jklowden Exp $ commit b10c0ecf799e3db6bf8e2617fd29aba4e5000e57 Author: jklowden Date: Thu Jan 10 01:02:20 2008 +0000 formatting diff --git a/ChangeLog b/ChangeLog index ad8d878..1bfbe78 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,5 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release - - ChangeLog-0.82 added because of release + * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2455 2008/01/10 01:01:31 jklowden Exp $ +$Id: ChangeLog,v 1.2456 2008/01/10 01:02:20 jklowden Exp $ commit b9bbaa400d6a758e9dd6896035f971fc41dacf7b Author: freddy77 Date: Thu Jan 10 08:47:37 2008 +0000 fix SQLNumResultCols() is wrong (+1) problem diff --git a/ChangeLog b/ChangeLog index 1bfbe78..d1d80dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ +Thu Jan 10 09:46:41 CET 2008 Frediano Ziglio + * TODO src/odbc/odbc.c src/odbc/unittests/.cvsignore: + * src/odbc/unittests/Makefile.am: + - small fix for hidden fields (ignore them entirely) + Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2456 2008/01/10 01:02:20 jklowden Exp $ +$Id: ChangeLog,v 1.2457 2008/01/10 08:47:37 freddy77 Exp $ diff --git a/TODO b/TODO index 6b770b4..49074e8 100644 --- a/TODO +++ b/TODO @@ -8,7 +8,7 @@ anyone else can post a patch to Source Forge. In this way we can communicate with each other about the project's priorities and needs. -To Do List $Id: TODO,v 1.165 2007/12/26 20:56:00 freddy77 Exp $ +To Do List $Id: TODO,v 1.166 2008/01/10 08:47:37 freddy77 Exp $ ------------ Bug? ML 2007-05-30 "dbsqlexec() never returns" @@ -131,6 +131,14 @@ For future versions (in priority order within library): . report error just before returning SQL_ERROR from inner function? . test and fix: hidden fields (FOR BROWSE select, see flag test on tds) + - what happen if we bind to an hidden field?? + - if we use SQLGetData?? + - if we request informations with SQLDescribeCol/SQLColAttribute(s)/ + SQLGetDescField?? + - as you noted returning # columns hidden fields are not counted (there + is however a setting which is a mssql extension which threat hidden + columns as normal) + (cfr "SQLNumResultCols() is wrong (+1)" Jan 8 2008) . test: all binding types (input and output) . test: descriptors work - ODBC 2 type returned (datetime) diff --git a/src/odbc/odbc.c b/src/odbc/odbc.c index 7180d23..a19f734 100644 --- a/src/odbc/odbc.c +++ b/src/odbc/odbc.c @@ -60,7 +60,7 @@ #include #endif -TDS_RCSID(var, "$Id: odbc.c,v 1.464 2008/01/06 10:48:43 freddy77 Exp $"); +TDS_RCSID(var, "$Id: odbc.c,v 1.465 2008/01/10 08:47:37 freddy77 Exp $"); static SQLRETURN _SQLAllocConnect(SQLHENV henv, SQLHDBC FAR * phdbc); static SQLRETURN _SQLAllocEnv(SQLHENV FAR * phenv); @@ -2652,7 +2652,7 @@ odbc_ird_check(TDS_STMT * stmt) return; /* check columns number */ - assert(ird->header.sql_desc_count == cols || ird->header.sql_desc_count == 0); + assert(ird->header.sql_desc_count <= cols || ird->header.sql_desc_count == 0); /* check all columns */ @@ -2717,6 +2717,10 @@ odbc_populate_ird(TDS_STMT * stmt) return SQL_SUCCESS; num_cols = res_info->num_cols; + /* ignore hidden columns... TODO correct? */ + while (num_cols > 0 && res_info->columns[num_cols - 1]->column_hidden == 1) + --num_cols; + if (desc_alloc_records(ird, num_cols) != SQL_SUCCESS) { odbc_errs_add(&stmt->errs, "HY001", NULL); return SQL_ERROR; diff --git a/src/odbc/unittests/.cvsignore b/src/odbc/unittests/.cvsignore index d6eea5a..1316adb 100644 --- a/src/odbc/unittests/.cvsignore +++ b/src/odbc/unittests/.cvsignore @@ -62,3 +62,4 @@ cursor3 cursor4 cursor5 attributes +hidden diff --git a/src/odbc/unittests/Makefile.am b/src/odbc/unittests/Makefile.am index e68b0a4..14726b2 100644 --- a/src/odbc/unittests/Makefile.am +++ b/src/odbc/unittests/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am,v 1.68 2007/12/19 14:36:05 freddy77 Exp $ +# $Id: Makefile.am,v 1.69 2008/01/10 08:47:38 freddy77 Exp $ TESTS = \ t0001$(EXEEXT) t0002$(EXEEXT) t0003$(EXEEXT)\ t0004$(EXEEXT) connect$(EXEEXT) print$(EXEEXT)\ @@ -20,7 +20,7 @@ TESTS = \ paramcore$(EXEEXT) timeout2$(EXEEXT) timeout3$(EXEEXT) \ connect2$(EXEEXT) timeout4$(EXEEXT) freeclose$(EXEEXT) \ cursor3$(EXEEXT) cursor4$(EXEEXT) cursor5$(EXEEXT) \ - attributes$(EXEEXT) + attributes$(EXEEXT) hidden$(EXEEXT) check_PROGRAMS = $(TESTS) @@ -77,6 +77,7 @@ cursor3_SOURCES = cursor3.c common.c common.h cursor4_SOURCES = cursor4.c common.c common.h cursor5_SOURCES = cursor5.c common.c common.h attributes_SOURCES = attributes.c common.c common.h +hidden_SOURCES = hidden.c common.c common.h AM_CPPFLAGS = -I$(top_srcdir)/include $(ODBC_INC) -DFREETDS_SRCDIR=\"$(srcdir)\" if MINGW32 commit 49951943657f47fb003342a116ec3e77a833bed4 Author: freddy77 Date: Thu Jan 10 08:54:46 2008 +0000 fix SQLNumResultCols() is wrong (+1) problem diff --git a/src/odbc/unittests/hidden.c b/src/odbc/unittests/hidden.c new file mode 100755 index 0000000..d9b6b25 --- /dev/null +++ b/src/odbc/unittests/hidden.c @@ -0,0 +1,96 @@ +/* Testing result column numbers having hidden columns */ +/* Test from Sebastien Flaesch */ + +#include "common.h" + +static char software_version[] = "$Id: hidden.c,v 1.2 2008/01/10 08:54:46 freddy77 Exp $"; +static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; + +#define CHECK_RCODE(t,h,m) \ + if ( rcode != SQL_NO_DATA \ + && rcode != SQL_SUCCESS \ + && rcode != SQL_SUCCESS_WITH_INFO \ + && rcode != SQL_NEED_DATA ) { \ + fprintf(stderr,"Error %d at: %s\n",rcode,m); \ + getErrorInfo(t,h); \ + exit(1); \ + } + +static void +getErrorInfo(SQLSMALLINT sqlhdltype, SQLHANDLE sqlhandle) +{ + SQLRETURN rcode = 0; + SQLCHAR sqlstate[SQL_SQLSTATE_SIZE + 1]; + SQLINTEGER naterror = 0; + SQLCHAR msgtext[SQL_MAX_MESSAGE_LENGTH + 1]; + SQLSMALLINT msgtextl = 0; + + rcode = SQLGetDiagRec((SQLSMALLINT) sqlhdltype, + (SQLHANDLE) sqlhandle, + (SQLSMALLINT) 1, + (SQLCHAR *) sqlstate, + (SQLINTEGER *) & naterror, + (SQLCHAR *) msgtext, (SQLSMALLINT) sizeof(msgtext), (SQLSMALLINT *) & msgtextl); + fprintf(stderr, "Diagnostic info:\n"); + fprintf(stderr, " SQL State: %s\n", (char *) sqlstate); + fprintf(stderr, " SQL code : %d\n", (int) naterror); + fprintf(stderr, " Message : %s\n", (char *) msgtext); +} + +int +main(int argc, char **argv) +{ + SQLRETURN rcode; + SQLHSTMT m_hstmt1; + SQLSMALLINT cnt = 0; + int failed = 0; + + use_odbc_version3 = 1; + Connect(); + + Command(Statement, "CREATE TABLE #t1 ( k INT, c CHAR(10), vc VARCHAR(10) )"); + Command(Statement, "CREATE TABLE #tmp1 (i NUMERIC(10,0) IDENTITY PRIMARY KEY, b VARCHAR(20) NULL, c INT NOT NULL)"); + + /* test hidden column with FOR BROWSE */ + ResetStatement(); + + m_hstmt1 = Statement; + + rcode = SQLExecDirect(m_hstmt1, (SQLCHAR *) "SELECT c, b FROM #tmp1", SQL_NTS); + CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLExecDirect"); + + rcode = SQLNumResultCols(m_hstmt1, &cnt); + CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLNumResultCols 1"); + + if (cnt != 2) { + fprintf(stderr, "Wrong number of columns in result set: %d\n", (int) cnt); + failed = 1; + } + ResetStatement(); + + /* test hidden column with cursors*/ + CheckCursor(); + + rcode = SQLSetStmtAttr(m_hstmt1, SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_NONSCROLLABLE, SQL_IS_UINTEGER); + CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLSetStmtAttr SQL_ATTR_CURSOR_SCROLLABLE"); + rcode = SQLSetStmtAttr(m_hstmt1, SQL_ATTR_CURSOR_SENSITIVITY, (SQLPOINTER) SQL_SENSITIVE, SQL_IS_UINTEGER); + CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLSetStmtAttr SQL_ATTR_CURSOR_SENSITIVITY"); + + rcode = SQLPrepare(m_hstmt1, (SQLCHAR *) "SELECT * FROM #t1", SQL_NTS); + CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLPrepare 1"); + + rcode = SQLExecute(m_hstmt1); + CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLExecute 1"); + + rcode = SQLNumResultCols(m_hstmt1, &cnt); + CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLNumResultCols 1"); + + if (cnt != 3) { + fprintf(stderr, "Wrong number of columns in result set: %d\n", (int) cnt); + failed = 1; + } + + Disconnect(); + + return failed ? 1: 0; +} commit ea3ce27c24032abbdd44c8453cc23d291b466583 Author: freddy77 Date: Thu Jan 10 13:11:07 2008 +0000 fix SQLGetData problem diff --git a/ChangeLog b/ChangeLog index d1d80dd..bb41c3d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Jan 10 14:10:28 CET 2008 Frediano Ziglio + * src/odbc/odbc.c src/odbc/unittests/.cvsignore: + * src/odbc/unittests/Makefile.am src/odbc/unittests/blob1.c(added): + - fix problem with SQLGetData and blobs + Thu Jan 10 09:46:41 CET 2008 Frediano Ziglio * TODO src/odbc/odbc.c src/odbc/unittests/.cvsignore: * src/odbc/unittests/Makefile.am: @@ -7,4 +12,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2457 2008/01/10 08:47:37 freddy77 Exp $ +$Id: ChangeLog,v 1.2458 2008/01/10 13:11:07 freddy77 Exp $ diff --git a/src/odbc/odbc.c b/src/odbc/odbc.c index a19f734..a638dc7 100644 --- a/src/odbc/odbc.c +++ b/src/odbc/odbc.c @@ -60,7 +60,7 @@ #include #endif -TDS_RCSID(var, "$Id: odbc.c,v 1.465 2008/01/10 08:47:37 freddy77 Exp $"); +TDS_RCSID(var, "$Id: odbc.c,v 1.466 2008/01/10 13:11:07 freddy77 Exp $"); static SQLRETURN _SQLAllocConnect(SQLHENV henv, SQLHDBC FAR * phdbc); static SQLRETURN _SQLAllocEnv(SQLHENV FAR * phenv); @@ -4583,12 +4583,12 @@ SQLGetData(SQLHSTMT hstmt, SQLUSMALLINT icol, SQLSMALLINT fCType, SQLPOINTER rgb if (*pcbValue < 0) ODBC_RETURN(stmt, SQL_ERROR); - if (is_variable_type(colinfo->column_type)) { + if (is_variable_type(colinfo->column_type) && (fCType == SQL_C_CHAR || fCType == SQL_C_BINARY)) { /* calc how many bytes was readed */ int readed = cbValueMax; /* FIXME test on destination char ??? */ - if (stmt->dbc->env->attr.output_nts != SQL_FALSE && is_char_type(nSybType) && readed > 0) + if (stmt->dbc->env->attr.output_nts != SQL_FALSE && fCType == SQL_C_CHAR && readed > 0) --readed; if (readed > *pcbValue) readed = *pcbValue; diff --git a/src/odbc/unittests/.cvsignore b/src/odbc/unittests/.cvsignore index 1316adb..d7c663e 100644 --- a/src/odbc/unittests/.cvsignore +++ b/src/odbc/unittests/.cvsignore @@ -63,3 +63,4 @@ cursor4 cursor5 attributes hidden +blob1 diff --git a/src/odbc/unittests/blob1.c b/src/odbc/unittests/blob1.c new file mode 100755 index 0000000..838a507 --- /dev/null +++ b/src/odbc/unittests/blob1.c @@ -0,0 +1,224 @@ +/* Testing large objects */ +/* Test from Sebastien Flaesch */ + +#include "common.h" + +static char software_version[] = "$Id: blob1.c,v 1.1 2008/01/10 13:11:08 freddy77 Exp $"; +static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; + +#define CHECK_RCODE(t,h,m) \ + if ( rcode != SQL_SUCCESS && rcode != SQL_SUCCESS_WITH_INFO && rcode != SQL_NO_DATA && rcode != SQL_NEED_DATA ) { \ + fprintf(stderr,"Error %d at: %s\n",rcode,m); \ + getErrorInfo(t,h); \ + exit(1); \ + } + +#define NBYTES 10000 + +static int failed = 0; + +static void +getErrorInfo(SQLSMALLINT sqlhdltype, SQLHANDLE sqlhandle) +{ + SQLRETURN rcode = 0; + SQLCHAR sqlstate[SQL_SQLSTATE_SIZE + 1]; + SQLINTEGER naterror = 0; + SQLCHAR msgtext[SQL_MAX_MESSAGE_LENGTH + 1]; + SQLSMALLINT msgtextl = 0; + + rcode = SQLGetDiagRec((SQLSMALLINT) sqlhdltype, + (SQLHANDLE) sqlhandle, + (SQLSMALLINT) 1, + (SQLCHAR *) sqlstate, + (SQLINTEGER *) & naterror, + (SQLCHAR *) msgtext, (SQLSMALLINT) sizeof(msgtext), (SQLSMALLINT *) & msgtextl); + fprintf(stderr, "Diagnostic info:\n"); + fprintf(stderr, " SQL State: %s\n", (char *) sqlstate); + fprintf(stderr, " SQL code : %d\n", (int) naterror); + fprintf(stderr, " Message : %s\n", (char *) msgtext); +} + +static void +fill_chars(char *buf, size_t len, unsigned int start, unsigned int step) +{ + size_t n; + + for (n = 0; n < len; ++n) + buf[n] = 'a' + ((start+n) * step % ('z' - 'a' + 1)); +} + +static int +check_chars(const char *buf, size_t len, unsigned int start, unsigned int step) +{ + size_t n; + + for (n = 0; n < len; ++n) + if (buf[n] != 'a' + ((start+n) * step % ('z' - 'a' + 1))) + return 0; + + return 1; +} + +static int +readBlob(SQLHSTMT * stmth, SQLUSMALLINT pos) +{ + SQLRETURN rcode; + char buf[4096]; + SQLLEN len, total = 0; + int i = 0; + int check; + + printf(">> readBlob field %d\n", pos); + while (1) { + i++; + rcode = SQLGetData(stmth, pos, SQL_C_BINARY, (SQLPOINTER) buf, (SQLINTEGER) sizeof(buf), &len); + if (!SQL_SUCCEEDED(rcode) || len <= 0) + break; + if (len > (SQLLEN) sizeof(buf)) + len = (SQLLEN) sizeof(buf); + printf(">> step %d: %d bytes readed\n", i, (int) len); + if (pos == 1) + check = check_chars(buf, len, 123 + total, 1); + else + check = check_chars(buf, len, 987 + total, 25); + if (!check) { + fprintf(stderr, "Wrong buffer content\n"); + failed = 1; + } + total += len; + } + printf(">> total bytes read = %d \n", (int) total); + if (total != 10000) + failed = 1; + return rcode; +} + +int +main(int argc, char **argv) +{ + SQLRETURN rcode; + SQLHSTMT m_hstmt = NULL; + int i; + + int key; + SQLINTEGER vind0; + char buf1[NBYTES]; + SQLINTEGER vind1; + char buf2[NBYTES]; + SQLINTEGER vind2; + int cnt = 2; + + use_odbc_version3 = 1; + Connect(); + + Command(Statement, "IF OBJECT_ID('tt') IS NOT NULL DROP TABLE tt"); + Command(Statement, "CREATE TABLE tt ( k INT, t TEXT, b IMAGE, v INT )"); + + /* Insert rows ... */ + + for (i = 0; i < cnt; i++) { + + m_hstmt = NULL; + rcode = SQLAllocHandle(SQL_HANDLE_STMT, Connection, &m_hstmt); + CHECK_RCODE(SQL_HANDLE_DBC, Connection, "SQLAllocHandle StmtH"); + + rcode = SQLPrepare(m_hstmt, (SQLCHAR *) "insert into tt values ( ?, ?, ?, ? )", SQL_NTS); + CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLPrepare"); + + SQLBindParameter(m_hstmt, 1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &key, 0, &vind0); + CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLBindParameter 1"); + + SQLBindParameter(m_hstmt, 2, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_LONGVARCHAR, 0x10000000, 0, buf1, 0, &vind1); + CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLBindParameter 2"); + + SQLBindParameter(m_hstmt, 3, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_LONGVARBINARY, 0x10000000, 0, buf2, 0, &vind2); + CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLBindParameter 3"); + + SQLBindParameter(m_hstmt, 4, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &key, 0, &vind0); + CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLBindParameter 4"); + + key = i; + vind0 = 0; + + fill_chars(buf1, NBYTES, 123, 1); + vind1 = SQL_LEN_DATA_AT_EXEC(NBYTES); + + fill_chars(buf2, NBYTES, 987, 25); + vind2 = SQL_LEN_DATA_AT_EXEC(NBYTES); + + printf(">> insert... %d\n", i); + rcode = SQLExecute(m_hstmt); + CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLExecute StmtH"); + while (rcode == SQL_NEED_DATA) { + char *p; + + rcode = SQLParamData(m_hstmt, (SQLPOINTER) & p); + CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLParamData StmtH"); + printf(">> SQLParamData: ptr = %p rcode = %d\n", (void *) p, rcode); + if (rcode == SQL_NEED_DATA) { + SQLRETURN rcode = SQLPutData(m_hstmt, p, NBYTES); + + CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLPutData StmtH"); + printf(">> param %p: total bytes written = %d\n", (void *) p, NBYTES); + } + } + + rcode = SQLFreeHandle(SQL_HANDLE_STMT, (SQLHANDLE) m_hstmt); + CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLFreeHandle StmtH"); + + } + + /* No fetch rows ... */ + + for (i = 0; i < cnt; i++) { + + m_hstmt = NULL; + rcode = SQLAllocHandle(SQL_HANDLE_STMT, Connection, &m_hstmt); + CHECK_RCODE(SQL_HANDLE_DBC, Connection, "SQLAllocHandle StmtH"); + + rcode = SQLSetStmtAttr(m_hstmt, SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_NONSCROLLABLE, SQL_IS_UINTEGER); + CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLSetStmtAttr SQL_ATTR_CURSOR_SCROLLABLE"); + rcode = SQLSetStmtAttr(m_hstmt, SQL_ATTR_CURSOR_SENSITIVITY, (SQLPOINTER) SQL_SENSITIVE, SQL_IS_UINTEGER); + CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLSetStmtAttr SQL_ATTR_CURSOR_SENSITIVITY"); + + rcode = SQLPrepare(m_hstmt, (SQLCHAR *) "SELECT t, b, v FROM tt WHERE k = ?", SQL_NTS); + CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLPrepare"); + + SQLBindParameter(m_hstmt, 1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &i, 0, &vind0); + CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLBindParameter 1"); + + SQLBindCol(m_hstmt, 1, SQL_C_BINARY, NULL, 0, &vind1); + CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLBindCol 2"); + SQLBindCol(m_hstmt, 2, SQL_C_BINARY, NULL, 0, &vind2); + CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLBindCol 3"); + SQLBindCol(m_hstmt, 3, SQL_C_LONG, &key, 0, &vind0); + CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLBindCol 1"); + + vind0 = 0; + vind1 = SQL_DATA_AT_EXEC; + vind2 = SQL_DATA_AT_EXEC; + + rcode = SQLExecute(m_hstmt); + CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLExecute StmtH"); + + rcode = SQLFetchScroll(m_hstmt, SQL_FETCH_NEXT, 0); + CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLFetchScroll StmtH"); + printf(">> fetch... %d rcode = %d\n", i, rcode); + + rcode = readBlob(m_hstmt, 1); + CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "readBlob 1"); + rcode = readBlob(m_hstmt, 2); + CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "readBlob 2"); + + rcode = SQLCloseCursor(m_hstmt); + CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLCloseCursor StmtH"); + + rcode = SQLFreeHandle(SQL_HANDLE_STMT, (SQLHANDLE) m_hstmt); + CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLFreeHandle StmtH"); + } + + Disconnect(); + + return failed ? 1 : 0; +} + commit 53181ec91693d58dfee70e7c1ce4bc66b05de712 Author: freddy77 Date: Thu Jan 10 13:21:12 2008 +0000 fix SQLGetData problem diff --git a/src/odbc/unittests/Makefile.am b/src/odbc/unittests/Makefile.am index 14726b2..830c6c5 100644 --- a/src/odbc/unittests/Makefile.am +++ b/src/odbc/unittests/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am,v 1.69 2008/01/10 08:47:38 freddy77 Exp $ +# $Id: Makefile.am,v 1.70 2008/01/10 13:21:12 freddy77 Exp $ TESTS = \ t0001$(EXEEXT) t0002$(EXEEXT) t0003$(EXEEXT)\ t0004$(EXEEXT) connect$(EXEEXT) print$(EXEEXT)\ @@ -20,7 +20,7 @@ TESTS = \ paramcore$(EXEEXT) timeout2$(EXEEXT) timeout3$(EXEEXT) \ connect2$(EXEEXT) timeout4$(EXEEXT) freeclose$(EXEEXT) \ cursor3$(EXEEXT) cursor4$(EXEEXT) cursor5$(EXEEXT) \ - attributes$(EXEEXT) hidden$(EXEEXT) + attributes$(EXEEXT) hidden$(EXEEXT) blob1$(EXEEXT) check_PROGRAMS = $(TESTS) @@ -78,6 +78,7 @@ cursor4_SOURCES = cursor4.c common.c common.h cursor5_SOURCES = cursor5.c common.c common.h attributes_SOURCES = attributes.c common.c common.h hidden_SOURCES = hidden.c common.c common.h +blob1_SOURCES = blob1.c common.c common.h AM_CPPFLAGS = -I$(top_srcdir)/include $(ODBC_INC) -DFREETDS_SRCDIR=\"$(srcdir)\" if MINGW32 commit e88fe96932f46fb3b1db41e1c967373ec153a831 Author: freddy77 Date: Thu Jan 10 15:26:51 2008 +0000 updates for new version diff --git a/ChangeLog b/ChangeLog index bb41c3d..1a6b943 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +Thu Jan 10 16:25:19 CET 2008 Frediano Ziglio + * doc/README.releasing misc/freetds_autobuild: updates + Thu Jan 10 14:10:28 CET 2008 Frediano Ziglio * src/odbc/odbc.c src/odbc/unittests/.cvsignore: * src/odbc/unittests/Makefile.am src/odbc/unittests/blob1.c(added): @@ -12,4 +15,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2458 2008/01/10 13:11:07 freddy77 Exp $ +$Id: ChangeLog,v 1.2459 2008/01/10 15:26:51 freddy77 Exp $ diff --git a/doc/README.releasing b/doc/README.releasing index cae6dc0..a4c60df 100644 --- a/doc/README.releasing +++ b/doc/README.releasing @@ -2,11 +2,12 @@ It's pretty simple, basically: 0) Form a branch in cvs: - $ cvs tag -b BRANCH0_xx - - Use the form BRANCH0_xx, where xx is the release number. This affects only + $ cvs tag branch-0_xx + $ cvs tag -b Branch-0_xx + + Use the form Branch-0_xx, where xx is the release number. This affects only the repository, not the working directory. - + 1) Change the version number in configure.ac and UG. 2) Update web pages regarding purpose and status of rc. 3) Put out a release candidates until everyone's happy. @@ -50,4 +51,4 @@ less important per step ;-) convention for naming - .tar.gz for tar and gzip, rather than .tgz. -- -$Id: README.releasing,v 1.10 2008/01/08 13:29:40 freddy77 Exp $ +$Id: README.releasing,v 1.11 2008/01/10 15:26:51 freddy77 Exp $ diff --git a/misc/freetds_autobuild b/misc/freetds_autobuild index 7217a27..a78d6f4 100755 --- a/misc/freetds_autobuild +++ b/misc/freetds_autobuild @@ -9,7 +9,7 @@ export PATH="/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:$HOME GROUPDIR=/home/groups/f/fr/freetds/htdocs # directory to compile -FTDSDIR=freetds65 +FTDSDIR=freetds82 # output directory on server OUTDIR=out # additional flags for Autogen (current version) commit 637220d3666abf47363cb5217e96796bbc6ba3ab Author: freddy77 Date: Thu Jan 10 15:29:03 2008 +0000 use temporary tables diff --git a/ChangeLog b/ChangeLog index 1a6b943..238d403 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Jan 10 16:28:44 CET 2008 Frediano Ziglio + * src/odbc/unittests/blob1.c src/odbc/unittests/cursor3.c: + * src/odbc/unittests/cursor4.c src/odbc/unittests/cursor5.c: + - use temporary tables + Thu Jan 10 16:25:19 CET 2008 Frediano Ziglio * doc/README.releasing misc/freetds_autobuild: updates @@ -15,4 +20,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2459 2008/01/10 15:26:51 freddy77 Exp $ +$Id: ChangeLog,v 1.2460 2008/01/10 15:29:03 freddy77 Exp $ diff --git a/src/odbc/unittests/blob1.c b/src/odbc/unittests/blob1.c index 838a507..9e4be47 100755 --- a/src/odbc/unittests/blob1.c +++ b/src/odbc/unittests/blob1.c @@ -3,7 +3,7 @@ #include "common.h" -static char software_version[] = "$Id: blob1.c,v 1.1 2008/01/10 13:11:08 freddy77 Exp $"; +static char software_version[] = "$Id: blob1.c,v 1.2 2008/01/10 15:29:03 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #define CHECK_RCODE(t,h,m) \ @@ -111,8 +111,7 @@ main(int argc, char **argv) use_odbc_version3 = 1; Connect(); - Command(Statement, "IF OBJECT_ID('tt') IS NOT NULL DROP TABLE tt"); - Command(Statement, "CREATE TABLE tt ( k INT, t TEXT, b IMAGE, v INT )"); + Command(Statement, "CREATE TABLE #tt ( k INT, t TEXT, b IMAGE, v INT )"); /* Insert rows ... */ @@ -122,7 +121,7 @@ main(int argc, char **argv) rcode = SQLAllocHandle(SQL_HANDLE_STMT, Connection, &m_hstmt); CHECK_RCODE(SQL_HANDLE_DBC, Connection, "SQLAllocHandle StmtH"); - rcode = SQLPrepare(m_hstmt, (SQLCHAR *) "insert into tt values ( ?, ?, ?, ? )", SQL_NTS); + rcode = SQLPrepare(m_hstmt, (SQLCHAR *) "INSERT INTO #tt VALUES ( ?, ?, ?, ? )", SQL_NTS); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLPrepare"); SQLBindParameter(m_hstmt, 1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &key, 0, &vind0); @@ -181,7 +180,7 @@ main(int argc, char **argv) rcode = SQLSetStmtAttr(m_hstmt, SQL_ATTR_CURSOR_SENSITIVITY, (SQLPOINTER) SQL_SENSITIVE, SQL_IS_UINTEGER); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLSetStmtAttr SQL_ATTR_CURSOR_SENSITIVITY"); - rcode = SQLPrepare(m_hstmt, (SQLCHAR *) "SELECT t, b, v FROM tt WHERE k = ?", SQL_NTS); + rcode = SQLPrepare(m_hstmt, (SQLCHAR *) "SELECT t, b, v FROM #tt WHERE k = ?", SQL_NTS); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLPrepare"); SQLBindParameter(m_hstmt, 1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &i, 0, &vind0); diff --git a/src/odbc/unittests/cursor3.c b/src/odbc/unittests/cursor3.c index 791783a..d44fe3c 100644 --- a/src/odbc/unittests/cursor3.c +++ b/src/odbc/unittests/cursor3.c @@ -1,7 +1,7 @@ /* Tests 2 active statements */ #include "common.h" -static char software_version[] = "$Id: cursor3.c,v 1.3 2007/12/21 10:39:10 freddy77 Exp $"; +static char software_version[] = "$Id: cursor3.c,v 1.4 2008/01/10 15:29:03 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static SQLHDBC m_hdbc; @@ -69,12 +69,11 @@ main(int argc, char **argv) m_hdbc = Connection; - exec_direct(0, "DROP TABLE t1"); - exec_direct(1, "CREATE TABLE t1 ( k INT, c VARCHAR(20))"); - exec_direct(1, "INSERT INTO t1 VALUES (1, 'aaa')"); - exec_direct(1, "INSERT INTO t1 VALUES (2, 'bbbbb')"); - exec_direct(1, "INSERT INTO t1 VALUES (3, 'ccccccccc')"); - exec_direct(1, "INSERT INTO t1 VALUES (4, 'dd')"); + exec_direct(1, "CREATE TABLE #t1 ( k INT, c VARCHAR(20))"); + exec_direct(1, "INSERT INTO #t1 VALUES (1, 'aaa')"); + exec_direct(1, "INSERT INTO #t1 VALUES (2, 'bbbbb')"); + exec_direct(1, "INSERT INTO #t1 VALUES (3, 'ccccccccc')"); + exec_direct(1, "INSERT INTO #t1 VALUES (4, 'dd')"); m_hstmt1 = NULL; rcode = SQLAllocHandle(SQL_HANDLE_STMT, m_hdbc, &m_hstmt1); @@ -114,10 +113,10 @@ main(int argc, char **argv) rcode = SQLSetCursorName(m_hstmt2, (SQLCHAR *) "c2", SQL_NTS); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt2, "SetCursorName c2"); - rcode = SQLPrepare(m_hstmt1, (SQLCHAR *) "SELECT * FROM t1", SQL_NTS); + rcode = SQLPrepare(m_hstmt1, (SQLCHAR *) "SELECT * FROM #t1", SQL_NTS); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "Prepare 1"); - rcode = SQLPrepare(m_hstmt2, (SQLCHAR *) "SELECT * FROM t1", SQL_NTS); + rcode = SQLPrepare(m_hstmt2, (SQLCHAR *) "SELECT * FROM #t1", SQL_NTS); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt2, "Prepare 2"); rcode = SQLExecute(m_hstmt1); @@ -152,8 +151,6 @@ main(int argc, char **argv) rcode = SQLFreeHandle(SQL_HANDLE_STMT, (SQLHANDLE) m_hstmt2); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt2, "SQLFreeHandle 2"); - exec_direct(1, "DROP TABLE t1"); - Disconnect(); return 0; diff --git a/src/odbc/unittests/cursor4.c b/src/odbc/unittests/cursor4.c index b352644..ef67014 100755 --- a/src/odbc/unittests/cursor4.c +++ b/src/odbc/unittests/cursor4.c @@ -5,7 +5,7 @@ #include "common.h" -static char software_version[] = "$Id: cursor4.c,v 1.3 2007/12/21 10:39:10 freddy77 Exp $"; +static char software_version[] = "$Id: cursor4.c,v 1.4 2008/01/10 15:29:03 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static SQLHDBC m_hdbc; @@ -72,9 +72,8 @@ main(int argc, char **argv) m_hdbc = Connection; - exec_direct(0, "DROP TABLE t1"); - exec_direct(1, "CREATE TABLE t1 ( k INT, c VARCHAR(20))"); - exec_direct(1, "INSERT INTO t1 VALUES (1, 'aaa')"); + exec_direct(1, "CREATE TABLE #t1 ( k INT, c VARCHAR(20))"); + exec_direct(1, "INSERT INTO #t1 VALUES (1, 'aaa')"); m_hstmt1 = NULL; rcode = SQLAllocHandle(SQL_HANDLE_STMT, m_hdbc, &m_hstmt1); @@ -86,7 +85,7 @@ main(int argc, char **argv) rcode = SQLSetCursorName(m_hstmt1, (SQLCHAR *) "c112", SQL_NTS); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SetCursorName c112"); - rcode = SQLPrepare(m_hstmt1, (SQLCHAR *) "SELECT * FROM t1 FOR UPDATE", SQL_NTS); + rcode = SQLPrepare(m_hstmt1, (SQLCHAR *) "SELECT * FROM #t1 FOR UPDATE", SQL_NTS); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "Prepare 2"); exec_direct(1, "BEGIN TRANSACTION"); @@ -97,14 +96,14 @@ main(int argc, char **argv) rcode = SQLFetch(m_hstmt1); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLFetch 1"); - exec_direct(1, "UPDATE t1 SET c = 'xxx' WHERE CURRENT OF c112"); + exec_direct(1, "UPDATE #t1 SET c = 'xxx' WHERE CURRENT OF c112"); rcode = SQLCloseCursor(m_hstmt1); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLCloseCursor 2"); exec_direct(1, "COMMIT TRANSACTION"); - rcode = SQLExecDirect(m_hstmt1, (SQLCHAR *) "SELECT c FROM t1 WHERE k = 1", SQL_NTS); + rcode = SQLExecDirect(m_hstmt1, (SQLCHAR *) "SELECT c FROM #t1 WHERE k = 1", SQL_NTS); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLExecDirect 2"); rcode = SQLFetch(m_hstmt1); @@ -118,8 +117,6 @@ main(int argc, char **argv) rcode = SQLFreeHandle(SQL_HANDLE_STMT, (SQLHANDLE) m_hstmt1); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLFreeHandle 1"); - exec_direct(1, "DROP TABLE t1"); - Disconnect(); return 0; diff --git a/src/odbc/unittests/cursor5.c b/src/odbc/unittests/cursor5.c index c7be7e4..53f380b 100755 --- a/src/odbc/unittests/cursor5.c +++ b/src/odbc/unittests/cursor5.c @@ -1,6 +1,6 @@ #include "common.h" -static char software_version[] = "$Id: cursor5.c,v 1.2 2007/12/21 10:39:10 freddy77 Exp $"; +static char software_version[] = "$Id: cursor5.c,v 1.3 2008/01/10 15:29:03 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #define CHECK_RCODE(t,h,m) \ @@ -76,15 +76,14 @@ main(int argc, char **argv) rcode = SQLAllocHandle(SQL_HANDLE_STMT, m_hdbc, &m_hstmt2); CHECK_RCODE(SQL_HANDLE_DBC, m_hdbc, "SQLAllocHandle StmtH 2"); - rcode = SQLExecDirect(m_hstmt1, (SQLCHAR *) "drop table mytab1", SQL_NTS); - rcode = SQLExecDirect(m_hstmt1, (SQLCHAR *) "create table mytab1 (k int, c char(30))", SQL_NTS); + rcode = SQLExecDirect(m_hstmt1, (SQLCHAR *) "create table #mytab1 (k int, c char(30))", SQL_NTS); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLExecDirect 1.1"); - rcode = SQLExecDirect(m_hstmt1, (SQLCHAR *) "insert into mytab1 values (1,'aaa')", SQL_NTS); + rcode = SQLExecDirect(m_hstmt1, (SQLCHAR *) "insert into #mytab1 values (1,'aaa')", SQL_NTS); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLExecDirect 1.2"); - rcode = SQLExecDirect(m_hstmt1, (SQLCHAR *) "insert into mytab1 values (2,'bbb')", SQL_NTS); + rcode = SQLExecDirect(m_hstmt1, (SQLCHAR *) "insert into #mytab1 values (2,'bbb')", SQL_NTS); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLExecDirect 1.3"); - rcode = SQLExecDirect(m_hstmt1, (SQLCHAR *) "insert into mytab1 values (3,'ccc')", SQL_NTS); + rcode = SQLExecDirect(m_hstmt1, (SQLCHAR *) "insert into #mytab1 values (3,'ccc')", SQL_NTS); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLExecDirect 1.4"); /* @@ -95,7 +94,7 @@ main(int argc, char **argv) rcode = SQLSetStmtAttr(m_hstmt2, SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_SCROLLABLE, SQL_IS_UINTEGER); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt2, "SQLSetStmtAttr 1"); - rcode = SQLPrepare(m_hstmt2, (SQLCHAR *) "select k, c from mytab1 order by k", SQL_NTS); + rcode = SQLPrepare(m_hstmt2, (SQLCHAR *) "select k, c from #mytab1 order by k", SQL_NTS); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt2, "SQLPrepare 3"); rcode = SQLBindCol(m_hstmt2, 1, SQL_C_LONG, &v_int_3, 0, &v_ind_3_1); @@ -126,9 +125,6 @@ main(int argc, char **argv) rcode = SQLCloseCursor(m_hstmt2); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt2, "SQLCloseCursor StmtH 2"); - rcode = SQLExecDirect(m_hstmt1, (SQLCHAR *) "drop table mytab1", SQL_NTS); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLExecDirect 1.3"); - rcode = SQLFreeHandle(SQL_HANDLE_STMT, (SQLHANDLE) m_hstmt1); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLFreeHandle StmtH 1"); commit 7f82734a2bd3cb45de9711bc31a48a2ae3b7113d Author: freddy77 Date: Thu Jan 10 16:05:59 2008 +0000 add a test for SQLCancel which seems broken diff --git a/ChangeLog b/ChangeLog index 238d403..30115b3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Jan 10 17:04:15 CET 2008 Frediano Ziglio + * src/odbc/unittests/.cvsignore src/odbc/unittests/Makefile.am: + * src/odbc/unittests/cancel.c(added): + - add test for SQLCancel + Thu Jan 10 16:28:44 CET 2008 Frediano Ziglio * src/odbc/unittests/blob1.c src/odbc/unittests/cursor3.c: * src/odbc/unittests/cursor4.c src/odbc/unittests/cursor5.c: @@ -20,4 +25,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2460 2008/01/10 15:29:03 freddy77 Exp $ +$Id: ChangeLog,v 1.2461 2008/01/10 16:05:59 freddy77 Exp $ diff --git a/src/odbc/unittests/.cvsignore b/src/odbc/unittests/.cvsignore index d7c663e..ae23946 100644 --- a/src/odbc/unittests/.cvsignore +++ b/src/odbc/unittests/.cvsignore @@ -64,3 +64,4 @@ cursor5 attributes hidden blob1 +cancel diff --git a/src/odbc/unittests/Makefile.am b/src/odbc/unittests/Makefile.am index 830c6c5..7fca97b 100644 --- a/src/odbc/unittests/Makefile.am +++ b/src/odbc/unittests/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am,v 1.70 2008/01/10 13:21:12 freddy77 Exp $ +# $Id: Makefile.am,v 1.71 2008/01/10 16:05:59 freddy77 Exp $ TESTS = \ t0001$(EXEEXT) t0002$(EXEEXT) t0003$(EXEEXT)\ t0004$(EXEEXT) connect$(EXEEXT) print$(EXEEXT)\ @@ -20,7 +20,8 @@ TESTS = \ paramcore$(EXEEXT) timeout2$(EXEEXT) timeout3$(EXEEXT) \ connect2$(EXEEXT) timeout4$(EXEEXT) freeclose$(EXEEXT) \ cursor3$(EXEEXT) cursor4$(EXEEXT) cursor5$(EXEEXT) \ - attributes$(EXEEXT) hidden$(EXEEXT) blob1$(EXEEXT) + attributes$(EXEEXT) hidden$(EXEEXT) blob1$(EXEEXT) \ + cancel$(EXEEXT) check_PROGRAMS = $(TESTS) @@ -79,6 +80,7 @@ cursor5_SOURCES = cursor5.c common.c common.h attributes_SOURCES = attributes.c common.c common.h hidden_SOURCES = hidden.c common.c common.h blob1_SOURCES = blob1.c common.c common.h +cancel_SOURCES = cancel.c common.c common.h AM_CPPFLAGS = -I$(top_srcdir)/include $(ODBC_INC) -DFREETDS_SRCDIR=\"$(srcdir)\" if MINGW32 diff --git a/src/odbc/unittests/cancel.c b/src/odbc/unittests/cancel.c new file mode 100644 index 0000000..b01630f --- /dev/null +++ b/src/odbc/unittests/cancel.c @@ -0,0 +1,96 @@ +/* Testing SQLCancel() */ + +#include "common.h" +#include + +#ifdef HAVE_ALARM + +#define CHECK_RCODE(t,h,m) \ + if ( rcode != SQL_NO_DATA \ + && rcode != SQL_SUCCESS \ + && rcode != SQL_SUCCESS_WITH_INFO \ + && rcode != SQL_NEED_DATA ) { \ + fprintf(stderr,"Error %d at: %s\n",rcode,m); \ + getErrorInfo(t,h); \ + exit(1); \ + } + +static SQLCHAR sqlstate[SQL_SQLSTATE_SIZE + 1]; + +static void +getErrorInfo(SQLSMALLINT sqlhdltype, SQLHANDLE sqlhandle) +{ + SQLRETURN rcode = 0; + SQLINTEGER naterror = 0; + SQLCHAR msgtext[SQL_MAX_MESSAGE_LENGTH + 1]; + SQLSMALLINT msgtextl = 0; + + rcode = SQLGetDiagRec((SQLSMALLINT) sqlhdltype, + (SQLHANDLE) sqlhandle, + (SQLSMALLINT) 1, + (SQLCHAR *) sqlstate, + (SQLINTEGER *) & naterror, + (SQLCHAR *) msgtext, (SQLSMALLINT) sizeof(msgtext), (SQLSMALLINT *) & msgtextl); + fprintf(stderr, "Diagnostic info:\n"); + fprintf(stderr, " SQL State: %s\n", (char *) sqlstate); + fprintf(stderr, " SQL code : %d\n", (int) naterror); + fprintf(stderr, " Message : %s\n", (char *) msgtext); +} + +static void +exit_forced(int s) +{ + exit(1); +} + +static void +sigalrm_handler(int s) +{ + SQLRETURN rcode; + + printf(">>>> SQLCancel() ...\n"); + rcode = SQLCancel(Statement); + printf(">>>> ... SQLCancel done rcode = %d\n", rcode); + CHECK_RCODE(SQL_HANDLE_STMT, Statement, "SQLCancel failed"); + + alarm(4); + signal(SIGALRM, exit_forced); +} + +int +main(int argc, char **argv) +{ + SQLRETURN rcode; + + use_odbc_version3 = 1; + Connect(); + + printf(">> Select tab1...\n"); + alarm(4); + signal(SIGALRM, sigalrm_handler); + rcode = SQLExecDirect(Statement, (SQLCHAR *) "WAITFOR DELAY '000:05:00'", SQL_NTS); + if (rcode != SQL_ERROR) { + fprintf(stderr, "SQLExecDirect should return error\n"); + return 1; + } + getErrorInfo(SQL_HANDLE_STMT, Statement); + if (strcmp(sqlstate, "HY008") != 0) { + fprintf(stderr, "Unexpected sql state returned\n"); + return 1; + } + printf(">> ... done rcode = %d\n", rcode); + signal(SIGINT, NULL); + + Disconnect(); + return 0; +} + +#else +int +main(void) +{ + printf("Not possible for this platform.\n"); + return 0; +} +#endif + commit 4457549eba093983d80f1cfdcfa44e35310c2ce0 Author: freddy77 Date: Thu Jan 10 21:19:47 2008 +0000 memory fixes diff --git a/ChangeLog b/ChangeLog index 30115b3..1fa8966 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Thu Jan 10 22:19:26 CET 2008 Frediano Ziglio + * src/odbc/unittests/cancel.c src/odbc/unittests/hidden.c: + - memory fixes + Thu Jan 10 17:04:15 CET 2008 Frediano Ziglio * src/odbc/unittests/.cvsignore src/odbc/unittests/Makefile.am: * src/odbc/unittests/cancel.c(added): @@ -25,4 +29,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2461 2008/01/10 16:05:59 freddy77 Exp $ +$Id: ChangeLog,v 1.2462 2008/01/10 21:19:47 freddy77 Exp $ diff --git a/src/odbc/unittests/cancel.c b/src/odbc/unittests/cancel.c index b01630f..6aa5e3f 100644 --- a/src/odbc/unittests/cancel.c +++ b/src/odbc/unittests/cancel.c @@ -25,6 +25,7 @@ getErrorInfo(SQLSMALLINT sqlhdltype, SQLHANDLE sqlhandle) SQLCHAR msgtext[SQL_MAX_MESSAGE_LENGTH + 1]; SQLSMALLINT msgtextl = 0; + msgtext[0] = 0; rcode = SQLGetDiagRec((SQLSMALLINT) sqlhdltype, (SQLHANDLE) sqlhandle, (SQLSMALLINT) 1, @@ -76,6 +77,7 @@ main(int argc, char **argv) getErrorInfo(SQL_HANDLE_STMT, Statement); if (strcmp(sqlstate, "HY008") != 0) { fprintf(stderr, "Unexpected sql state returned\n"); + Disconnect(); return 1; } printf(">> ... done rcode = %d\n", rcode); diff --git a/src/odbc/unittests/hidden.c b/src/odbc/unittests/hidden.c index d9b6b25..71124a6 100755 --- a/src/odbc/unittests/hidden.c +++ b/src/odbc/unittests/hidden.c @@ -3,7 +3,7 @@ #include "common.h" -static char software_version[] = "$Id: hidden.c,v 1.2 2008/01/10 08:54:46 freddy77 Exp $"; +static char software_version[] = "$Id: hidden.c,v 1.3 2008/01/10 21:19:47 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #define CHECK_RCODE(t,h,m) \ @@ -70,6 +70,7 @@ main(int argc, char **argv) /* test hidden column with cursors*/ CheckCursor(); + m_hstmt1 = Statement; rcode = SQLSetStmtAttr(m_hstmt1, SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_NONSCROLLABLE, SQL_IS_UINTEGER); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLSetStmtAttr SQL_ATTR_CURSOR_SCROLLABLE"); commit e28c151956bedc82ff4a97b8a90e083a026dcb1e Author: jklowden Date: Thu Jan 10 22:57:33 2008 +0000 moved some preprocessor logic to the header file diff --git a/ChangeLog b/ChangeLog index 1fa8966..f508d56 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Thu Jan 10 17:55:41 EST 2008 JK Lowden + * include/tds_sysdep_private.h src/tds/net.c + - moved some preprocessor logic to the header file + * INSTALL.CVS NEWS TODO doc/userguide.sgml + - updated documentation + Thu Jan 10 22:19:26 CET 2008 Frediano Ziglio * src/odbc/unittests/cancel.c src/odbc/unittests/hidden.c: - memory fixes @@ -29,4 +35,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2462 2008/01/10 21:19:47 freddy77 Exp $ +$Id: ChangeLog,v 1.2463 2008/01/10 22:57:33 jklowden Exp $ diff --git a/include/tds_sysdep_private.h b/include/tds_sysdep_private.h index 9b6fcb0..8adfb9b 100644 --- a/include/tds_sysdep_private.h +++ b/include/tds_sysdep_private.h @@ -20,7 +20,7 @@ #ifndef _tds_sysdep_private_h_ #define _tds_sysdep_private_h_ -/* $Id: tds_sysdep_private.h,v 1.23 2007/01/29 11:02:43 freddy77 Exp $ */ +/* $Id: tds_sysdep_private.h,v 1.24 2008/01/10 22:57:33 jklowden Exp $ */ #undef TDS_RCSID #if defined(__GNUC__) && __GNUC__ >= 3 @@ -34,6 +34,12 @@ #define TDS_ADDITIONAL_SPACE 0 +#ifdef MSG_NOSIGNAL +# define TDS_NOSIGNAL MSG_NOSIGNAL +#else +# define TDS_NOSIGNAL 0L +#endif + #ifdef __cplusplus extern "C" { @@ -47,10 +53,11 @@ extern "C" #endif /* __INCvxWorksh */ #if defined(DOS32X) -#define READSOCKET(a,b,c) recv((a), (b), (c), 0L) -#define WRITESOCKET(a,b,c) send((a), (b), (c), 0L) +#define READSOCKET(a,b,c) recv((a), (b), (c), TDS_NOSIGNAL) +#define WRITESOCKET(a,b,c) send((a), (b), (c), TDS_NOSIGNAL) #define CLOSESOCKET(a) closesocket((a)) #define IOCTLSOCKET(a,b,c) ioctlsocket((a), (b), (char*)(c)) +#define SOCKLEN_T int #define select select_s typedef int pid_t; #define strcasecmp stricmp @@ -62,10 +69,11 @@ typedef int pid_t; #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) #include -#define READSOCKET(a,b,c) recv((a), (b), (c), 0L) -#define WRITESOCKET(a,b,c) send((a), (b), (c), 0L) +#define READSOCKET(a,b,c) recv((a), (b), (c), TDS_NOSIGNAL) +#define WRITESOCKET(a,b,c) send((a), (b), (c), TDS_NOSIGNAL) #define CLOSESOCKET(a) closesocket((a)) #define IOCTLSOCKET(a,b,c) ioctlsocket((a), (b), (c)) +#define SOCKLEN_T int int _tds_socket_init(void); #define INITSOCKET() _tds_socket_init() void _tds_socket_done(void); @@ -120,21 +128,33 @@ typedef DWORD pid_t; #endif /* !DONESOCKET */ #ifndef READSOCKET -#define READSOCKET(a,b,c) read((a), (b), (c)) +# ifdef MSG_NOSIGNAL +# define READSOCKET(s,b,l) recv((s), (b), (l), MSG_NOSIGNAL) +# else +# define READSOCKET(s,b,l) read((s), (b), (l)) +# endif #endif /* !READSOCKET */ #ifndef WRITESOCKET -#define WRITESOCKET(a,b,c) write((a), (b), (c)) +# ifdef MSG_NOSIGNAL +# define WRITESOCKET(s,b,l) send((s), (b), (l), MSG_NOSIGNAL) +# else +# define WRITESOCKET(s,b,l) write((s), (b), (l)) +# endif #endif /* !WRITESOCKET */ #ifndef CLOSESOCKET -#define CLOSESOCKET(a) close((a)) +#define CLOSESOCKET(s) close((s)) #endif /* !CLOSESOCKET */ #ifndef IOCTLSOCKET -#define IOCTLSOCKET(a,b,c) ioctl((a), (b), (c)) +#define IOCTLSOCKET(s,b,l) ioctl((s), (b), (l)) #endif /* !IOCTLSOCKET */ +#ifndef SOCKLEN_T +# define SOCKLEN_T socklen_t +#endif + #ifndef TDS_SDIR_SEPARATOR #define TDS_SDIR_SEPARATOR "/" #endif /* !TDS_SDIR_SEPARATOR */ diff --git a/src/tds/net.c b/src/tds/net.c index c551127..741f9b4 100644 --- a/src/tds/net.c +++ b/src/tds/net.c @@ -99,7 +99,7 @@ #include #endif -TDS_RCSID(var, "$Id: net.c,v 1.71 2007/12/12 06:27:38 freddy77 Exp $"); +TDS_RCSID(var, "$Id: net.c,v 1.72 2008/01/10 22:57:33 jklowden Exp $"); static int tds_select(TDSSOCKET * tds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, int timeout_seconds); @@ -165,18 +165,12 @@ int tds_open_socket(TDSSOCKET * tds, const char *ip_addr, unsigned int port, int timeout) { struct sockaddr_in sin; -#if !defined(DOS32X) ioctl_nonblocking_t ioctl_nonblocking; - int retval; -#endif - int len; + SOCKLEN_T optlen; + + int retval, len; int tds_error = TDSECONN; char ip[20]; -#if defined(DOS32X) || defined(WIN32) - int optlen; -#else - socklen_t optlen; -#endif memset(&sin, 0, sizeof(sin)); @@ -270,8 +264,7 @@ tds_open_socket(TDSSOCKET * tds, const char *ip_addr, unsigned int port, int tim goto not_available; } } - -#endif +#endif /* not DOS32X */ /* check socket error */ optlen = sizeof(len); @@ -436,11 +429,9 @@ tds_goodread(TDSSOCKET * tds, unsigned char *buf, int buflen, unsigned char unfi if ((len = tds_select(tds, &rfds, NULL, NULL, tds->query_timeout)) > 0) { len = 0; if (FD_ISSET(tds->s, &rfds)) { -#ifndef MSG_NOSIGNAL + len = READSOCKET(tds->s, buf + got, buflen); -#else - len = recv(tds->s, buf + got, buflen, MSG_NOSIGNAL); -#endif + if (len < 0 && sock_errno == EAGAIN) continue; /* detect connection close */ @@ -656,10 +647,8 @@ tds_goodwrite(TDSSOCKET * tds, const unsigned char *p, int len, unsigned char la /* In case the kernel does not support MSG_MORE, try again without it */ if (nput < 0 && errno == EINVAL && !last) nput = send(tds->s, p, remaining, MSG_NOSIGNAL); -#elif !defined(MSG_NOSIGNAL) - nput = WRITESOCKET(tds->s, p, remaining); #else - nput = send(tds->s, p, remaining, MSG_NOSIGNAL); + nput = WRITESOCKET(tds->s, p, remaining); #endif if (nput < 0 && sock_errno == EAGAIN) continue; commit 998e0c0a7e8a6305acb7a20748dba6fe9c212081 Author: jklowden Date: Thu Jan 10 22:57:39 2008 +0000 updated documentation diff --git a/INSTALL.CVS b/INSTALL.CVS index d42c3aa..53d62d6 100644 --- a/INSTALL.CVS +++ b/INSTALL.CVS @@ -16,9 +16,9 @@ connecting to the CVS server. Then follow these steps: Autotool versions that work: $ (autoconf --version; automake --version; libtool --version) |grep GNU - autoconf (GNU Autoconf) 2.59 - automake (GNU automake) 1.9.5 - ltmain.sh (GNU libtool) 1.5.14 (1.1220.2.195 2005/02/12 12:12:33) + autoconf (GNU Autoconf) 2.60 + automake (GNU automake) 1.9.6 + ltmain.sh (GNU libtool) 1.5.18 (1.1220.2.245 2005/05/16 08:55:27) The above are used to generate the distributions. You may get away with older versions, as far back as 2.53 for autoconf. @@ -44,10 +44,10 @@ connecting to the CVS server. Then follow these steps: +++ -You are not required to rely on Source Forge's anonymous CVS server, which at +You are not required to rely on SourceForge's anonymous CVS server, which at the present time (July 2004) runs up to 1 hour behind the development server. You can fetch the CVS tarball (the basis for a CVS server, not a snapshot) from -Source Forge at: +SourceForge at: http://cvs.sourceforge.net/cvstarballs/freetds-cvsroot.tar.bz2 @@ -62,4 +62,4 @@ the CVS tree via rsync: $ rsync -av rsync://freetds.cvs.sourceforge.net/cvsroot/freetds/* . -- -$Id: INSTALL.CVS,v 1.7 2007/04/05 14:17:05 freddy77 Exp $ +$Id: INSTALL.CVS,v 1.8 2008/01/10 22:57:39 jklowden Exp $ diff --git a/NEWS b/NEWS index 851fbce..bc2fdf3 100644 --- a/NEWS +++ b/NEWS @@ -1,33 +1,63 @@ -$Id: NEWS,v 1.43 2008/01/08 13:29:40 freddy77 Exp $ -* 0.82 -- support NUL characters inside terminators in freebcp -- cursors under ODBC (mssql) +$Id: NEWS,v 1.44 2008/01/10 22:57:39 jklowden Exp $ + +Executive Summary of Changes in release 0.82 +-------------------------------------------- + +1. timeout handling +2. encrypted connections +3. fisql (and odbc utilities) +4. autoconf improvements +5. 23,710 lines added or deleted (101,022 total). +6. 85 files added +7. 21 unit tests added + +Details +------- + +db-lib +- timeouts work! +- corrected dbnextrow +- implemented dbsetnull and dbsetinterrupt +- improved error reporting and checking +- fixed rpc parameter processing, now php works correctly + +ct-lib +- added cs_loc_alloc, cs_loc_drop, cs_locale implementations + +odbc +- cursors (mssql) +- fixed database setting +- return error always if odbc returns SQL_ERROR +- fixed SQLGetData result + +utilities +- added support for NUL characters inside terminators in freebcp +- added row termination and column termination option to tsql +- new fisql application +- new ODBC utilities + +documentation +- significant updates to TDS protocol documentation +- freetds.conf man page +- added tenderfoot sample code + +general +- fixed timeout handling +- added freetds.conf option for encryption +- added protocol version discovery - NTLM2 session response -- lot of update to TDS protocol documentation +- read table and real column name from wire +- experimental Kerberos support using gssapi - some optimizations for GCC4 - optimized conversions avoiding some memory copy - minor improves to server stuff -- add row termination and column termination option to tsql -- improve locale stuff on ctlib - added cs_loc_alloc, cs_loc_drop, cs_locale implementations -- improve MingW compile (even cross one) -- implement dbsetnull on dblib -- improve dblib error reporting and check +- improved MingW compile (even cross one) - more verbose log for dblib and odbc -- fix rpc parameter on dblib, now php works correctly - many test added 1 test for libTDS 1 test for ctlib 3 tests for dblib 13 tests for odbc -- fix database setting on odbc -- fix timeout stuff -- return always an error if odbc return SQL_ERROR -- fix SQLGetData result -- add freetds.conf option for encryption -- add protocol version discovery -- read table and real column name from wire -- experimental Kerberos support using gssapi libTDS API changes - tds_add_row_column_size removed @@ -38,7 +68,7 @@ libTDS API changes - added TDSCURSOR->type and TDSCURSOR->concurrency for mssql support - added fetch_type and i_row parameters to tds_cursor_fetch - added tds_cursor_update and tds_cursor_setname functions -- make tds_alloc_get_string static +- made tds_alloc_get_string static - removed tds_free_cursor - added TDSCURSOR->ref_count - added tds_cursor_deallocated and tds_release_cursor to handle @@ -48,8 +78,8 @@ libTDS API changes to trace pointer owner between libTDS and upper libraries - added TDS_COMPILETIME_SETTINGS->sysconfdir - changed DSTR_STRUCT structure to include dstr_size -- change DSTR type -- error handler cannot return TDS_INT_EXIT (no more defined) +- changed DSTR type +- error handler cannot return TDS_INT_EXIT - removed TDSSOCKET->query_timeout_func TDSSOCKET->query_timeout_param, TDSSOCKET->query_start_time - changed TDSLOGIN->host_name to client_host_name @@ -83,7 +113,6 @@ libTDS API changes - added TDSSOCKET->tds9_transaction (used internally for TDS9) - added TDSCONNECTION->server_host_name needed for Kerberos support - * 0.64 - core library - reduced network bandwidth use on Linux and *BSD diff --git a/TODO b/TODO index 49074e8..55b0fbf 100644 --- a/TODO +++ b/TODO @@ -4,11 +4,11 @@ followed by things that should work before the next release, followed by features that should be added/fixed/reworked (grouped by library). Everyone is encouraged to add to the list. Developers can do it directly; -anyone else can post a patch to Source Forge. +anyone else can post a patch to SourceForge. In this way we can communicate with each other about the project's priorities and needs. -To Do List $Id: TODO,v 1.166 2008/01/10 08:47:37 freddy77 Exp $ +To Do List $Id: TODO,v 1.167 2008/01/10 22:57:39 jklowden Exp $ ------------ Bug? ML 2007-05-30 "dbsqlexec() never returns" @@ -30,20 +30,13 @@ Broken: Work in progress: -Postponed to 0.65 version . log and call error handler on problems with tds_iconv_init(). . iconv - support string conversions for Sybase - - add test for locale_charset() to configure.in. Use it if available - instead of nl_langinfo, because it implies we're using GNU iconv . add doc/htdoc/Makefile with "publish" target to commit cvs and update freetds.org . drop txt2man from cvs, skip building man pages without it. . be able to disable iconv for BCP (see Sybase documentation) -. userguide - - update table of working configurations - server (vendor, version, platform) - client (freetds version, platform) - - protocol - charsets - date For future versions (in priority order within library): All: @@ -59,7 +52,6 @@ For future versions (in priority order within library): . Add missing constants needed for python and verify working . Add missing constants needed for Gnome-DB and verify working . conversion from ucs2 to utf8, provide for 2+ bytes/character -. tdsping program for testing purposes . Finish off the TDS dissector for ethereal . more solid. handle out of memory conditions (started, we must test all allocation and all function that return allocated data and be able to @@ -81,8 +73,8 @@ For future versions (in priority order within library): (too complicate, see ctlib bulk, cf "bulk copy and row buffer") . improve cursor support on dblib and ctlib . support for VARIANT type (requested one time, 2003-8-1) -. support for NT named pipe (requested many time ago for mssql6.5 server, only - for completeness). If anybody knows a library to handle named pipes +. support for NT named pipe (requested long ago for mssql6.5 server, only + for completeness). If the reader knows a library to handle named pipes compatible with LGPL please tell us. . read on partial packet, do not wait entire one . detect if realloc/free accepts NULL pointers (in configure.in) diff --git a/doc/userguide.sgml b/doc/userguide.sgml index d26bb2e..e8d4c79 100644 --- a/doc/userguide.sgml +++ b/doc/userguide.sgml @@ -5,8 +5,8 @@ ]> - $Date: 2008/01/08 13:29:40 $ - $Revision: 1.110 $ + $Date: 2008/01/10 22:57:39 $ + $Revision: 1.111 $ <productname>FreeTDS</productname> User Guide A Guide to Installing, Configuring, and Running FreeTDS @@ -26,6 +26,7 @@ 2005 2006 2007 + 2008 Brian Bruns and James K. Lowden @@ -55,9 +56,9 @@ This guide is here for you, and we hope that you will be here for it, that other The version you're reading is: -$Revision: 1.110 $ -$Date: 2008/01/08 13:29:40 $ -CVS control number $Id: userguide.sgml,v 1.110 2008/01/08 13:29:40 freddy77 Exp $. +$Revision: 1.111 $ +$Date: 2008/01/10 22:57:39 $ +CVS control number $Id: userguide.sgml,v 1.111 2008/01/10 22:57:39 jklowden Exp $. can be found on the FreeTDS @@ -201,7 +202,7 @@ project on SourceForge. It is a fork of the Status -The db-lib and ct-lib APIs have been usable for several years. They have been successfully substituted for Sybase's own libraries in a variety of venues, including Perl and PHP. That is not to say that these drivers are complete; they're not. But they faithfully implement an important subset of their APIs, enough to be useful. This 0.64 version boasts support for server-side cursors in ct-lib. +The db-lib and ct-lib APIs have been usable for several years. They have been successfully substituted for Sybase's own libraries in a variety of venues, including Perl and PHP. That is not to say that these drivers are complete; they're not. But they faithfully implement a useful — and widely used — subset of their APIs. In addition to the core db-lib API, FreeTDS includes a full implementation of db-lib's bcp functions, as well as freebcp, a replacement for Sybase's bcp utility. @@ -567,7 +568,7 @@ url="http://www.madgoat.com">www.madgoat.com). OS X® - As of this writing ($Date: 2008/01/08 13:29:40 $), the regular distribution compiles on OS X. Releases prior to 0.63 either did not compile or required patching. + As of this writing ($Date: 2008/01/10 22:57:39 $), the regular distribution compiles on OS X. Releases prior to 0.63 either did not compile or required patching. Alternative build procedure @@ -941,8 +942,7 @@ As of 0.62 FreeTDS uses iconv to convert all character data, so there's no need instance instance name none - Name of Microsoft SQL Server instance to connect to. The port will be detected automatically. - This requires an extra round-trip with server and may thus slightly delay making the connection. + Name of Microsoft SQL Server instance to connect to. The port will be detected automatically. debug flags @@ -1512,7 +1512,7 @@ The following table defines all possible ODBC connection attributes for the Server A server name or (ip) address none - Hostname of a server. Used in an ODBC-only configuration. As of version 0.64 you can specify a Microsoft SQL Server instance in the form of server\instance. + Hostname of a server. Used in an ODBC-only configuration. To specify a Microsoft SQL Server instance, use the form server\instance. Port commit 296c62697062c312476ce658ef7e22913008a877 Author: freddy77 Date: Fri Jan 11 08:30:09 2008 +0000 merged notes diff --git a/ChangeLog b/ChangeLog index f508d56..d8678f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +Fri Jan 11 9:29:44 CET 2008 Frediano Ziglio + * README: merged + Thu Jan 10 17:55:41 EST 2008 JK Lowden * include/tds_sysdep_private.h src/tds/net.c - moved some preprocessor logic to the header file @@ -35,4 +38,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2463 2008/01/10 22:57:33 jklowden Exp $ +$Id: ChangeLog,v 1.2464 2008/01/11 08:30:09 freddy77 Exp $ diff --git a/README b/README index 33da879..d7509e6 100644 --- a/README +++ b/README @@ -1,12 +1,11 @@ -$Id: README,v 1.11 2007/04/05 14:17:05 freddy77 Exp $ -README for FreeTDS 0.64 -Saturday 1 July 2006 +README for FreeTDS 0.82 +Thusday 10 January 2008 -* to build FreeTDS read the file INSTALL, -* see also the FreeTDS Users Guide, +* to build FreeTDS read the file INSTALL or + the FreeTDS Users Guide (doc/userguide.tgz) and http://www.freetds.org/userguide/ -FreeTDS is a free (open source) implementation of Sybase's db-lib, +FreeTDS is a free implementation of Sybase's db-lib, ct-lib, and ODBC libraries. FreeTDS builds and runs on every flavor of unix-like systems we've heard of, as well as Win32 (with or without Cygwin), VMS, and Mac OS X. Failure to build on your system is probably @@ -27,60 +26,8 @@ TODO The roadmap, such as it is Also, doc/api_status.txt shows which functions are implemented. -************************************ -** Warning regarding Sybase 12.5! ** -************************************ - -Do Not Use TDS version 4.2 to connect to Sybase 12.5. Please! - -While we don't like to put the bad news first, neither do we want you to -hurt your server. We know that our implementation of TDS 4.2 gives -Sybase 12.5 a bad case of heartburn. In short: it crashes the server. - -We don't know what it is about our version of TDS 4.2 that Sybase 12.5 -doesn't like, and we'd like to figure it out eventually. But in the -meanwhile, until we can find the problem and fix it, please don't use -that combination. Unless you want to help us test it, that is. - -FreeTDS 0.63 works fine with Sybase 12.5 if you use TDS version 5.0. - -If you are using Sybase 12.5 and anything above is not clear to you, -please see the User Guide. If it is still not clear after that, please -write to the FreeTDS mailing list. We'd rather answer your questions -while your server is still running. - -Thank you. We return now to your regularly scheduled README, already in -progress. - -New in this version -=================== - -ct-lib ------- - -Ct-lib now sports bcp and cursors. The largest missing feature is now -placeholder support compatible with Perl's DBD::Sybase. - -ODBC ----- - -ODBC continues to be improved. It is now compatible with OpenOffice.org, for -example, and even works with Oracle's OTL libary. It has better 64-bit -support. - -Applications ------------- - -This version includes two new applications, bsqldb and defncopy. See their man -pages for details. - -etc. ----- - -Naturally, there have been other improvements as well. This version compiles -and runs better than its predecessors. - - +For details on what's new in this version, see NEWS. For unbearable +detail, see ChangeLog-0.82. Documentation ============= @@ -139,3 +86,6 @@ Side note: Brian, as many free software authors, appreciates postcards from all over. So if you live someplace neat (read: not Michigan) and want to send one, email him (brian@bruns.org) for his current snail mail address. + +$Id: README,v 1.12 2008/01/11 08:30:10 freddy77 Exp $ + commit 239ad2280de52827b19c5d05e923165bcc8e6ddb Author: freddy77 Date: Fri Jan 11 09:44:26 2008 +0000 make test work with Sybase, add test for poll diff --git a/ChangeLog b/ChangeLog index d8678f2..3f540fa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Fri Jan 11 10:42:58 CET 2008 Frediano Ziglio + * src/odbc/unittests/blob1.c: make it work with Sybase + * configure.ac: test for poll function + Fri Jan 11 9:29:44 CET 2008 Frediano Ziglio * README: merged @@ -38,4 +42,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2464 2008/01/11 08:30:09 freddy77 Exp $ +$Id: ChangeLog,v 1.2465 2008/01/11 09:44:26 freddy77 Exp $ diff --git a/configure.ac b/configure.ac index 96ec6c5..6d0bff4 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. dnl ------------------------------------------------------------ -dnl $Id: configure.ac,v 1.30 2008/01/09 06:51:45 freddy77 Exp $ +dnl $Id: configure.ac,v 1.31 2008/01/11 09:44:26 freddy77 Exp $ dnl If you're trying to create a new configure test, try dnl dnl http://autogen.sourceforge.net/conftest.html @@ -15,7 +15,7 @@ dnl ------------------------------------------------------------ AC_INIT(FreeTDS, 0.83.dev.esyscmd(echo -n $(date +"%Y%m%d"))) AC_CONFIG_SRCDIR(src/dblib/dblib.c) AC_PREREQ(2.53) -AC_REVISION($Revision: 1.30 $) +AC_REVISION($Revision: 1.31 $) AM_INIT_AUTOMAKE AC_CONFIG_HEADERS(include/config.h) @@ -200,7 +200,8 @@ AC_CHECK_MEMBERS([struct tm.__tm_zone],,,[#include #include <$ac_cv_struct_tm> ]) AC_CHECK_HEADERS([unistd.h errno.h wchar.h sys/time.h sys/types.h \ -sys/param.h sys/stat.h sys/wait.h limits.h locale.h odbcss.h readpassphrase.h signal.h libgen.h]) +sys/param.h sys/stat.h sys/wait.h limits.h locale.h odbcss.h readpassphrase.h \ +signal.h libgen.h poll.h]) if test $tds_mingw = no; then AC_CHECK_HEADERS([sys/socket.h arpa/inet.h netdb.h netinet/in.h \ netinet/tcp.h paths.h sys/ioctl.h langinfo.h]) @@ -367,7 +368,7 @@ gethrtime localtime_r]) OLD_LIBS="$LIBS" LIBS="$LIBS $NETWORK_LIBS" AC_CHECK_FUNCS([inet_ntoa_r getipnodebyaddr getipnodebyname \ -getaddrinfo getnameinfo inet_ntop gethostname]) +getaddrinfo getnameinfo inet_ntop gethostname poll]) LIBS="$OLD_LIBS" AC_REPLACE_FUNCS([asprintf vasprintf atoll strtok_r readpassphrase \ strlcpy strlcat basename]) diff --git a/src/odbc/unittests/blob1.c b/src/odbc/unittests/blob1.c index 9e4be47..6b7b99c 100755 --- a/src/odbc/unittests/blob1.c +++ b/src/odbc/unittests/blob1.c @@ -3,7 +3,7 @@ #include "common.h" -static char software_version[] = "$Id: blob1.c,v 1.2 2008/01/10 15:29:03 freddy77 Exp $"; +static char software_version[] = "$Id: blob1.c,v 1.3 2008/01/11 09:44:26 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #define CHECK_RCODE(t,h,m) \ @@ -167,7 +167,7 @@ main(int argc, char **argv) } - /* No fetch rows ... */ + /* Now fetch rows ... */ for (i = 0; i < cnt; i++) { @@ -175,10 +175,12 @@ main(int argc, char **argv) rcode = SQLAllocHandle(SQL_HANDLE_STMT, Connection, &m_hstmt); CHECK_RCODE(SQL_HANDLE_DBC, Connection, "SQLAllocHandle StmtH"); - rcode = SQLSetStmtAttr(m_hstmt, SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_NONSCROLLABLE, SQL_IS_UINTEGER); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLSetStmtAttr SQL_ATTR_CURSOR_SCROLLABLE"); - rcode = SQLSetStmtAttr(m_hstmt, SQL_ATTR_CURSOR_SENSITIVITY, (SQLPOINTER) SQL_SENSITIVE, SQL_IS_UINTEGER); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLSetStmtAttr SQL_ATTR_CURSOR_SENSITIVITY"); + if (db_is_microsoft()) { + rcode = SQLSetStmtAttr(m_hstmt, SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_NONSCROLLABLE, SQL_IS_UINTEGER); + CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLSetStmtAttr SQL_ATTR_CURSOR_SCROLLABLE"); + rcode = SQLSetStmtAttr(m_hstmt, SQL_ATTR_CURSOR_SENSITIVITY, (SQLPOINTER) SQL_SENSITIVE, SQL_IS_UINTEGER); + CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLSetStmtAttr SQL_ATTR_CURSOR_SENSITIVITY"); + } rcode = SQLPrepare(m_hstmt, (SQLCHAR *) "SELECT t, b, v FROM #tt WHERE k = ?", SQL_NTS); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLPrepare"); commit 1c7684ceba4779e1eb04c13197bcd9ece2a3cb47 Author: freddy77 Date: Fri Jan 11 12:43:39 2008 +0000 fix compile for MacOSX diff --git a/ChangeLog b/ChangeLog index 3f540fa..120eda3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Fri Jan 11 13:42:06 CET 2008 Frediano Ziglio + * configure.ac src/apps/tsql.c: + - fix compile problem for MacOSX + Fri Jan 11 10:42:58 CET 2008 Frediano Ziglio * src/odbc/unittests/blob1.c: make it work with Sybase * configure.ac: test for poll function @@ -42,4 +46,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2465 2008/01/11 09:44:26 freddy77 Exp $ +$Id: ChangeLog,v 1.2466 2008/01/11 12:43:39 freddy77 Exp $ diff --git a/configure.ac b/configure.ac index 6d0bff4..4a0f729 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. dnl ------------------------------------------------------------ -dnl $Id: configure.ac,v 1.31 2008/01/11 09:44:26 freddy77 Exp $ +dnl $Id: configure.ac,v 1.32 2008/01/11 12:43:39 freddy77 Exp $ dnl If you're trying to create a new configure test, try dnl dnl http://autogen.sourceforge.net/conftest.html @@ -15,7 +15,7 @@ dnl ------------------------------------------------------------ AC_INIT(FreeTDS, 0.83.dev.esyscmd(echo -n $(date +"%Y%m%d"))) AC_CONFIG_SRCDIR(src/dblib/dblib.c) AC_PREREQ(2.53) -AC_REVISION($Revision: 1.31 $) +AC_REVISION($Revision: 1.32 $) AM_INIT_AUTOMAKE AC_CONFIG_HEADERS(include/config.h) @@ -178,7 +178,24 @@ if test $tds_mingw = no; then AC_CHECK_LIB([readline], [readline], [LIBS="$LIBS -lreadline" AC_DEFINE(HAVE_READLINE, 1, [Define to 1 if you have the GNU Readline library.])], [LIBS=""] ) AC_CHECK_FUNCS([rl_on_new_line rl_reset_line_state]) + AC_LINK_IFELSE([AC_LANG_SOURCE([[ +#include +#ifdef HAVE_STDLIB_H +#include +#endif + +#ifdef HAVE_READLINE +#include +#include +#endif /* HAVE_READLINE */ + +int main() +{ + rl_inhibit_completion = 1; + return 0; +} +]])],AC_DEFINE(HAVE_RL_INHIBIT_COMPLETION, 1, [Define to 1 if you have rl_inhibit_completion.])) READLINE_LIBS="$LIBS" LIBS="$OLDLIBS" AC_SUBST(READLINE_LIBS) diff --git a/src/apps/tsql.c b/src/apps/tsql.c index 6a04027..17268ef 100644 --- a/src/apps/tsql.c +++ b/src/apps/tsql.c @@ -85,7 +85,7 @@ #include "tdsconvert.h" #include "replacements.h" -TDS_RCSID(var, "$Id: tsql.c,v 1.112 2007/12/23 21:12:02 jklowden Exp $"); +TDS_RCSID(var, "$Id: tsql.c,v 1.113 2008/01/11 12:43:39 freddy77 Exp $"); enum { @@ -683,7 +683,7 @@ main(int argc, char **argv) mybuf[0] = '\0'; buflen = 0; -#ifdef HAVE_READLINE +#if defined(HAVE_READLINE) && HAVE_RL_INHIBIT_COMPLETION rl_inhibit_completion = 1; #endif commit 3ee05c86c5e0af66287ccd0d67dfc3aa5de0755d Author: freddy77 Date: Sat Jan 12 00:14:11 2008 +0000 fix for heavy load on server diff --git a/ChangeLog b/ChangeLog index 120eda3..bd33ef6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sat Jan 12 1:13:30 CET 2008 Frediano Ziglio + * src/odbc/unittests/blob1.c: small fix for 64bit + * src/tds/net.c: fix for heavy loads + Fri Jan 11 13:42:06 CET 2008 Frediano Ziglio * configure.ac src/apps/tsql.c: - fix compile problem for MacOSX @@ -46,4 +50,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2466 2008/01/11 12:43:39 freddy77 Exp $ +$Id: ChangeLog,v 1.2467 2008/01/12 00:14:11 freddy77 Exp $ diff --git a/src/odbc/unittests/blob1.c b/src/odbc/unittests/blob1.c index 6b7b99c..379930d 100755 --- a/src/odbc/unittests/blob1.c +++ b/src/odbc/unittests/blob1.c @@ -3,7 +3,7 @@ #include "common.h" -static char software_version[] = "$Id: blob1.c,v 1.3 2008/01/11 09:44:26 freddy77 Exp $"; +static char software_version[] = "$Id: blob1.c,v 1.4 2008/01/12 00:14:11 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #define CHECK_RCODE(t,h,m) \ @@ -101,11 +101,11 @@ main(int argc, char **argv) int i; int key; - SQLINTEGER vind0; + SQLLEN vind0; char buf1[NBYTES]; - SQLINTEGER vind1; + SQLLEN vind1; char buf2[NBYTES]; - SQLINTEGER vind2; + SQLLEN vind2; int cnt = 2; use_odbc_version3 = 1; diff --git a/src/tds/net.c b/src/tds/net.c index 741f9b4..196af9b 100644 --- a/src/tds/net.c +++ b/src/tds/net.c @@ -82,6 +82,10 @@ #include #endif /* HAVE_SELECT_H */ +#if HAVE_POLL_H +#include +#endif /* HAVE_POLL_H */ + #include "tds.h" #include "tdsstring.h" #include "replacements.h" @@ -99,9 +103,23 @@ #include #endif -TDS_RCSID(var, "$Id: net.c,v 1.72 2008/01/10 22:57:33 jklowden Exp $"); +TDS_RCSID(var, "$Id: net.c,v 1.73 2008/01/12 00:14:11 freddy77 Exp $"); + +#undef USE_POLL +#if defined(HAVE_POLL_H) && defined(HAVE_POLL) +# define USE_POLL 1 +# define TDSSELREAD POLLIN +# define TDSSELWRITE POLLOUT +/* error is always returned */ +# define TDSSELERR 0 +#else +# define USE_POLL 0 +# define TDSSELREAD 1 +# define TDSSELWRITE 2 +# define TDSSELERR 4 +#endif -static int tds_select(TDSSOCKET * tds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, int timeout_seconds); +static int tds_select(TDSSOCKET * tds, unsigned tds_sel, int timeout_seconds); /** @@ -237,8 +255,6 @@ tds_open_socket(TDSSOCKET * tds, const char *ip_addr, unsigned int port, int tim if (retval == 0) { tdsdump_log(TDS_DBG_INFO2, "connection established\n"); } else { - fd_set fds; - tdsdump_log(TDS_DBG_ERROR, "tds_open_socket: connect(2) returned \"%s\"\n", strerror(sock_errno)); #if DEBUGGING_CONNECTING_PROBLEM if (sock_errno != ECONNREFUSED && sock_errno != ENETUNREACH && sock_errno != EINPROGRESS) { @@ -258,8 +274,7 @@ tds_open_socket(TDSSOCKET * tds, const char *ip_addr, unsigned int port, int tim if (sock_errno != TDSSOCK_EINPROGRESS) goto not_available; - FD_ZERO(&fds); - if (tds_select(tds, NULL, &fds, &fds, timeout) <= 0) { + if (tds_select(tds, TDSSELWRITE|TDSSELERR, timeout) <= 0) { tds_error = TDSESOCK; goto not_available; } @@ -313,13 +328,39 @@ tds_close_socket(TDSSOCKET * tds) * This function does not call tdserror or close the socket because it can't know the context in which it's being called. */ static int -tds_select(TDSSOCKET * tds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, int timeout_seconds) +tds_select(TDSSOCKET * tds, unsigned tds_sel, int timeout_seconds) { int rc, seconds; unsigned int poll_seconds; +#if !USE_POLL + fd_set fds[3]; + fd_set *readfds = NULL, *writefds = NULL, *exceptfds = NULL; +#endif assert(tds != NULL); assert(timeout_seconds >= 0); + +#if !USE_POLL +#if !defined(WIN32) && defined(FD_SETSIZE) + if (tds->s >= FD_SETSIZE) { + sock_errno = EINVAL; + return -1; + } +#endif + if ((tds_sel & TDSSELREAD) != 0) { + FD_ZERO(&fds[0]); + readfds = &fds[0]; + } + if ((tds_sel & TDSSELWRITE) != 0) { + FD_ZERO(&fds[1]); + writefds = &fds[1]; + } + if ((tds_sel & TDSSELERR) != 0) { + FD_ZERO(&fds[2]); + exceptfds = &fds[2]; + } +#endif + /* * The select loop. * If an interrupt handler is installed, we iterate once per second, @@ -337,8 +378,17 @@ tds_select(TDSSOCKET * tds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds */ poll_seconds = (tds->tds_ctx && tds->tds_ctx->int_handler)? 1 : timeout_seconds; for (seconds = timeout_seconds; timeout_seconds == 0 || seconds > 0; seconds -= poll_seconds) { +#if USE_POLL + struct pollfd fd; + int timeout = poll_seconds ? poll_seconds * 1000 : -1; + + fd.fd = tds->s; + fd.events = tds_sel; + fd.revents = 0; + rc = poll(&fd, 1, timeout); +#else struct timeval tv, *ptv = poll_seconds? &tv : NULL; - + tv.tv_sec = poll_seconds; tv.tv_usec = 0; @@ -350,6 +400,7 @@ tds_select(TDSSOCKET * tds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds FD_SET(tds->s, exceptfds); rc = select(tds->s + 1, readfds, writefds, exceptfds, ptv); +#endif if (rc > 0 ) { return rc; @@ -414,7 +465,6 @@ static int tds_goodread(TDSSOCKET * tds, unsigned char *buf, int buflen, unsigned char unfinished) { int rc, got = 0; - fd_set rfds; if (buf == NULL || buflen < 1 || tds == NULL) return 0; @@ -425,21 +475,17 @@ tds_goodread(TDSSOCKET * tds, unsigned char *buf, int buflen, unsigned char unfi if (IS_TDSDEAD(tds)) return -1; - FD_ZERO(&rfds); - if ((len = tds_select(tds, &rfds, NULL, NULL, tds->query_timeout)) > 0) { - len = 0; - if (FD_ISSET(tds->s, &rfds)) { - - len = READSOCKET(tds->s, buf + got, buflen); - - if (len < 0 && sock_errno == EAGAIN) - continue; - /* detect connection close */ - if (len <= 0) { - tdserror(tds->tds_ctx, tds, len == 0 ? TDSESEOF : TDSEREAD, sock_errno); - tds_close_socket(tds); - return -1; - } + if ((len = tds_select(tds, TDSSELREAD, tds->query_timeout)) > 0) { + + len = READSOCKET(tds->s, buf + got, buflen); + + if (len < 0 && sock_errno == EAGAIN) + continue; + /* detect connection close */ + if (len <= 0) { + tdserror(tds->tds_ctx, tds, len == 0 ? TDSESEOF : TDSEREAD, sock_errno); + tds_close_socket(tds); + return -1; } } else if (len < 0) { if (sock_errno == EAGAIN) /* shouldn't happen, but OK */ @@ -631,34 +677,29 @@ tds_goodwrite(TDSSOCKET * tds, const unsigned char *p, int len, unsigned char la { int remaining = len; int nput, rc, err=0; - fd_set fds; /* Fix of SIGSEGV when FD_SET() called with negative fd (Sergey A. Cherukhin, 23/09/2005) */ if (TDS_IS_SOCKET_INVALID(tds->s)) return -1; while (remaining > 0) { - FD_ZERO(&fds); - if ((rc = tds_select(tds, NULL, &fds, NULL, tds->query_timeout)) > 0) { - nput = 0; - if (FD_ISSET(tds->s, &fds)) { + if ((rc = tds_select(tds, TDSSELWRITE, tds->query_timeout)) > 0) { #ifdef USE_MSGMORE - nput = send(tds->s, p, remaining, last ? MSG_NOSIGNAL : MSG_NOSIGNAL|MSG_MORE); - /* In case the kernel does not support MSG_MORE, try again without it */ - if (nput < 0 && errno == EINVAL && !last) - nput = send(tds->s, p, remaining, MSG_NOSIGNAL); + nput = send(tds->s, p, remaining, last ? MSG_NOSIGNAL : MSG_NOSIGNAL|MSG_MORE); + /* In case the kernel does not support MSG_MORE, try again without it */ + if (nput < 0 && errno == EINVAL && !last) + nput = send(tds->s, p, remaining, MSG_NOSIGNAL); #else - nput = WRITESOCKET(tds->s, p, remaining); + nput = WRITESOCKET(tds->s, p, remaining); #endif - if (nput < 0 && sock_errno == EAGAIN) - continue; - /* detect connection close */ - if (nput <= 0) { - tdserror(tds->tds_ctx, tds, nput == 0 ? TDSESEOF : TDSEWRIT, sock_errno); - tds_close_socket(tds); - return -1; - } - } + if (nput < 0 && sock_errno == EAGAIN) + continue; + /* detect connection close */ + if (nput <= 0) { + tdserror(tds->tds_ctx, tds, nput == 0 ? TDSESEOF : TDSEWRIT, sock_errno); + tds_close_socket(tds); + return -1; + } } else if (rc < 0) { if (sock_errno == EAGAIN) /* shouldn't happen, but OK, retry */ continue; @@ -770,8 +811,12 @@ tds7_get_instance_port(const char *ip_addr, const char *instance) int num_try; struct sockaddr_in sin; ioctl_nonblocking_t ioctl_nonblocking; +#if USE_POLL + struct pollfd fd; +#else struct timeval selecttimeout; fd_set fds; +#endif int retval; TDS_SYS_SOCKET s; char msg[1024]; @@ -795,6 +840,15 @@ tds7_get_instance_port(const char *ip_addr, const char *instance) return 0; } +#if !USE_POLL +#if !defined(WIN32) && defined(FD_SETSIZE) + if (s >= FD_SETSIZE) { + sock_errno = EINVAL; + return 0; + } +#endif +#endif + /* * on cluster environment is possible that reply packet came from * different IP so do not filter by ip with connect @@ -817,12 +871,20 @@ tds7_get_instance_port(const char *ip_addr, const char *instance) tds_strlcpy(msg + 1, instance, sizeof(msg) - 1); sendto(s, msg, strlen(msg) + 1, 0, (struct sockaddr *) &sin, sizeof(sin)); +#if USE_POLL + fd.fd = s; + fd.events = POLLIN; + fd.revents = 0; + + retval = poll(&fd, 1, 1000); +#else FD_ZERO(&fds); FD_SET(s, &fds); selecttimeout.tv_sec = 1; selecttimeout.tv_usec = 0; retval = select(s + 1, &fds, NULL, NULL, &selecttimeout); +#endif /* on interrupt ignore */ if (retval < 0 && sock_errno == TDSSOCK_EINTR) commit ff4edf2fa2b3b326b0930093675d0269b90081bb Author: freddy77 Date: Sun Jan 13 20:01:43 2008 +0000 detect cancellation error on ODBC diff --git a/ChangeLog b/ChangeLog index bd33ef6..021efb9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Jan 13 20:59:55 CET 2008 Frediano Ziglio + * src/odbc/odbc.c src/odbc/unittests/cancel.c src/tds/token.c: + - detect cancellation and add proper error + - remove errors from cancel test + Sat Jan 12 1:13:30 CET 2008 Frediano Ziglio * src/odbc/unittests/blob1.c: small fix for 64bit * src/tds/net.c: fix for heavy loads @@ -50,4 +55,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2467 2008/01/12 00:14:11 freddy77 Exp $ +$Id: ChangeLog,v 1.2468 2008/01/13 20:01:43 freddy77 Exp $ diff --git a/src/odbc/odbc.c b/src/odbc/odbc.c index a638dc7..df2cc9a 100644 --- a/src/odbc/odbc.c +++ b/src/odbc/odbc.c @@ -60,7 +60,7 @@ #include #endif -TDS_RCSID(var, "$Id: odbc.c,v 1.466 2008/01/10 13:11:07 freddy77 Exp $"); +TDS_RCSID(var, "$Id: odbc.c,v 1.467 2008/01/13 20:01:44 freddy77 Exp $"); static SQLRETURN _SQLAllocConnect(SQLHENV henv, SQLHDBC FAR * phdbc); static SQLRETURN _SQLAllocEnv(SQLHENV FAR * phenv); @@ -3260,6 +3260,7 @@ odbc_process_tokens(TDS_STMT * stmt, unsigned flag) case TDS_NO_MORE_RESULTS: return TDS_CMD_DONE; case TDS_CANCELLED: + odbc_errs_add(&stmt->errs, "HY008", NULL); case TDS_FAIL: return TDS_CMD_FAIL; } @@ -4187,6 +4188,8 @@ SQLPrepare(SQLHSTMT hstmt, SQLCHAR FAR * szSqlStr, SQLINTEGER cbSqlStr) continue; case TDS_NO_MORE_RESULTS: break; + case TDS_CANCELLED: + odbc_errs_add(&stmt->errs, "HY008", NULL); default: stmt->errs.lastrc = SQL_ERROR; break; @@ -5683,6 +5686,9 @@ SQLGetTypeInfo(SQLHSTMT hstmt, SQLSMALLINT fSqlType) if (n >= varchar_pos && varchar_pos > 0) goto redo; break; + case TDS_CANCELLED: + odbc_errs_add(&stmt->errs, "HY008", NULL); + break; } if (!tds->current_results) break; diff --git a/src/odbc/unittests/cancel.c b/src/odbc/unittests/cancel.c index 6aa5e3f..a43db5b 100644 --- a/src/odbc/unittests/cancel.c +++ b/src/odbc/unittests/cancel.c @@ -1,8 +1,15 @@ /* Testing SQLCancel() */ #include "common.h" + +/* TODO port to windows, use thread */ + #include +#if HAVE_UNISTD_H +#include +#endif /* HAVE_UNISTD_H */ + #ifdef HAVE_ALARM #define CHECK_RCODE(t,h,m) \ @@ -15,7 +22,7 @@ exit(1); \ } -static SQLCHAR sqlstate[SQL_SQLSTATE_SIZE + 1]; +static char sqlstate[SQL_SQLSTATE_SIZE + 1]; static void getErrorInfo(SQLSMALLINT sqlhdltype, SQLHANDLE sqlhandle) @@ -32,8 +39,9 @@ getErrorInfo(SQLSMALLINT sqlhdltype, SQLHANDLE sqlhandle) (SQLCHAR *) sqlstate, (SQLINTEGER *) & naterror, (SQLCHAR *) msgtext, (SQLSMALLINT) sizeof(msgtext), (SQLSMALLINT *) & msgtextl); + sqlstate[sizeof(sqlstate)-1] = 0; fprintf(stderr, "Diagnostic info:\n"); - fprintf(stderr, " SQL State: %s\n", (char *) sqlstate); + fprintf(stderr, " SQL State: %s\n", sqlstate); fprintf(stderr, " SQL code : %d\n", (int) naterror); fprintf(stderr, " Message : %s\n", (char *) msgtext); } @@ -66,10 +74,11 @@ main(int argc, char **argv) use_odbc_version3 = 1; Connect(); - printf(">> Select tab1...\n"); + printf(">> Wait 5 minutes...\n"); alarm(4); signal(SIGALRM, sigalrm_handler); rcode = SQLExecDirect(Statement, (SQLCHAR *) "WAITFOR DELAY '000:05:00'", SQL_NTS); + alarm(0); if (rcode != SQL_ERROR) { fprintf(stderr, "SQLExecDirect should return error\n"); return 1; @@ -81,7 +90,10 @@ main(int argc, char **argv) return 1; } printf(">> ... done rcode = %d\n", rcode); - signal(SIGINT, NULL); + + ResetStatement(); + + Command(Statement, "SELECT name FROM sysobjects WHERE 0=1"); Disconnect(); return 0; diff --git a/src/tds/token.c b/src/tds/token.c index 0c80a00..e6d5a6d 100644 --- a/src/tds/token.c +++ b/src/tds/token.c @@ -42,7 +42,7 @@ #include #endif -TDS_RCSID(var, "$Id: token.c,v 1.343 2007/12/28 23:00:18 jklowden Exp $"); +TDS_RCSID(var, "$Id: token.c,v 1.344 2008/01/13 20:01:45 freddy77 Exp $"); static int tds_process_msg(TDSSOCKET * tds, int marker); static int tds_process_compute_result(TDSSOCKET * tds); @@ -2238,7 +2238,7 @@ tds_process_end(TDSSOCKET * tds, int marker, int *flags_parm) if (IS_TDSDEAD(tds)) return TDS_FAIL; - return TDS_SUCCEED; + return was_cancelled ? TDS_CANCELLED : TDS_SUCCEED; } /** commit f9912e0d61c0c0f225d8d910c4b506135cc408db Author: freddy77 Date: Mon Jan 14 19:21:06 2008 +0000 finish patch for HY008 diff --git a/ChangeLog b/ChangeLog index 021efb9..f318306 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Mon Jan 14 20:20:31 CET 2008 Frediano Ziglio + * include/tdsodbc.h src/odbc/odbc.c: + - handle SQLCancel in signal handlers + Sun Jan 13 20:59:55 CET 2008 Frediano Ziglio * src/odbc/odbc.c src/odbc/unittests/cancel.c src/tds/token.c: - detect cancellation and add proper error @@ -55,4 +59,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2468 2008/01/13 20:01:43 freddy77 Exp $ +$Id: ChangeLog,v 1.2469 2008/01/14 19:21:06 freddy77 Exp $ diff --git a/include/tdsodbc.h b/include/tdsodbc.h index 59fdfc1..a58d547 100644 --- a/include/tdsodbc.h +++ b/include/tdsodbc.h @@ -66,7 +66,7 @@ extern "C" #endif #endif -/* $Id: tdsodbc.h,v 1.103 2007/11/26 18:12:30 freddy77 Exp $ */ +/* $Id: tdsodbc.h,v 1.104 2008/01/14 19:21:06 freddy77 Exp $ */ #if defined(__GNUC__) && __GNUC__ >= 4 #pragma GCC visibility push(hidden) @@ -370,6 +370,7 @@ struct _hstmt int special_row; /* do NOT free cursor, free from socket or attach to connection */ TDSCURSOR *cursor; + unsigned char cancel_sent; }; typedef struct _henv TDS_ENV; diff --git a/src/odbc/odbc.c b/src/odbc/odbc.c index df2cc9a..74f8057 100644 --- a/src/odbc/odbc.c +++ b/src/odbc/odbc.c @@ -60,7 +60,7 @@ #include #endif -TDS_RCSID(var, "$Id: odbc.c,v 1.467 2008/01/13 20:01:44 freddy77 Exp $"); +TDS_RCSID(var, "$Id: odbc.c,v 1.468 2008/01/14 19:21:06 freddy77 Exp $"); static SQLRETURN _SQLAllocConnect(SQLHENV henv, SQLHDBC FAR * phdbc); static SQLRETURN _SQLAllocEnv(SQLHENV FAR * phenv); @@ -562,6 +562,7 @@ odbc_lock_statement(TDS_STMT* stmt) tds->query_timeout = (stmt->attr.query_timeout != DEFAULT_QUERY_TIMEOUT) ? stmt->attr.query_timeout : stmt->dbc->default_query_timeout; stmt->dbc->current_statement = stmt; + stmt->cancel_sent = 0; return 1; } @@ -1582,6 +1583,7 @@ SQLCancel(SQLHSTMT hstmt) /* FIXME test current statement */ + stmt->cancel_sent = 1; if (tds_send_cancel(tds) == TDS_FAIL) { ODBC_SAFE_ERROR(stmt); ODBC_RETURN(stmt, SQL_ERROR); @@ -1592,7 +1594,9 @@ SQLCancel(SQLHSTMT hstmt) ODBC_RETURN(stmt, SQL_ERROR); } - stmt->dbc->current_statement = NULL; + /* only if we processed cancel reset statement */ + if (stmt->dbc->current_statement && stmt->dbc->current_statement == stmt && tds->state == TDS_IDLE) + stmt->dbc->current_statement = NULL; ODBC_RETURN_(stmt); } @@ -2025,6 +2029,12 @@ odbc_errmsg_handler(const TDSCONTEXT * ctx, TDSSOCKET * tds, TDSMESSAGE * msg) tdsdump_log(TDS_DBG_INFO1, "in timeout\n"); if (tds && (dbc = (TDS_DBC *) tds->parent) && dbc->current_statement) { TDS_STMT *stmt = dbc->current_statement; + /* cancel sent, handling interrupt */ + if (tds->in_cancel && stmt ->cancel_sent) { + stmt ->cancel_sent = 0; + tdsdump_log(TDS_DBG_INFO1, "returning from timeout\n"); + return TDS_INT_TIMEOUT; + } if (!tds->in_cancel) odbc_errs_add(&stmt->errs, "HYT00", "Timeout expired"); stmt->errs.lastrc = SQL_ERROR; commit f5d35b8af351e12aca845f27441c970a27cc45a7 Author: freddy77 Date: Thu Jan 17 06:56:50 2008 +0000 do not dump received header diff --git a/ChangeLog b/ChangeLog index f318306..06276f3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +Thu Jan 17 7:56:02 CET 2008 Frediano Ziglio + * src/tds/net.c: do not dump received header + Mon Jan 14 20:20:31 CET 2008 Frediano Ziglio * include/tdsodbc.h src/odbc/odbc.c: - handle SQLCancel in signal handlers @@ -59,4 +62,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2469 2008/01/14 19:21:06 freddy77 Exp $ +$Id: ChangeLog,v 1.2470 2008/01/17 06:56:50 freddy77 Exp $ diff --git a/src/tds/net.c b/src/tds/net.c index 196af9b..867c8f5 100644 --- a/src/tds/net.c +++ b/src/tds/net.c @@ -103,7 +103,7 @@ #include #endif -TDS_RCSID(var, "$Id: net.c,v 1.73 2008/01/12 00:14:11 freddy77 Exp $"); +TDS_RCSID(var, "$Id: net.c,v 1.74 2008/01/17 06:56:50 freddy77 Exp $"); #undef USE_POLL #if defined(HAVE_POLL_H) && defined(HAVE_POLL) @@ -581,7 +581,6 @@ tds_read_packet(TDSSOCKET * tds) } return -1; } - tdsdump_dump_buf(TDS_DBG_NETWORK, "Received header", header, sizeof(header)); #if 0 /* @@ -606,7 +605,7 @@ tds_read_packet(TDSSOCKET * tds) #endif /* Convert our packet length from network to host byte order */ - len = ((((unsigned int) header[2]) << 8) | header[3]) - 8; + len = (((unsigned int) header[2]) << 8) | header[3]; /* * If this packet size is the largest we have gotten allocate space for it @@ -630,9 +629,10 @@ tds_read_packet(TDSSOCKET * tds) /* Clean out the in_buf so we don't use old stuff by mistake */ memset(tds->in_buf, 0, tds->in_buf_max); + memcpy(tds->in_buf, header, 8); /* Now get exactly how many bytes the server told us to get */ - have = 0; + have = 8; while (have < len) { int nbytes = goodread(tds, tds->in_buf + have, len - have); if (nbytes < 1) { @@ -659,7 +659,7 @@ tds_read_packet(TDSSOCKET * tds) /* Set the length and pos (not sure what pos is used for now */ tds->in_len = have; - tds->in_pos = 0; + tds->in_pos = 8; tdsdump_dump_buf(TDS_DBG_NETWORK, "Received packet", tds->in_buf, tds->in_len); return (tds->in_len); commit 510c7865cd8f8a44029d975beaf30a92f4d8a2c0 Author: freddy77 Date: Thu Jan 17 06:59:28 2008 +0000 add param for version diff --git a/misc/freetds_autobuild b/misc/freetds_autobuild index a78d6f4..4ba053d 100755 --- a/misc/freetds_autobuild +++ b/misc/freetds_autobuild @@ -9,7 +9,7 @@ export PATH="/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:$HOME GROUPDIR=/home/groups/f/fr/freetds/htdocs # directory to compile -FTDSDIR=freetds82 +FTDSDIR=freetds83 # output directory on server OUTDIR=out # additional flags for Autogen (current version) @@ -66,15 +66,26 @@ read_pwd_fields() rm ~/freetds.log /tmp/sql.log +ignore= for param do - case $param in + shift + case "$param" in + $ignore) + ignore= + ;; --previous) OUTDIR=out0 FTDSDIR=freetds64 FLAGS_ADD="$FLAGS_ADD_OLD" WORKDIR=ftds_comp_old ;; + --version) + ignore=$1 + OUTDIR=out$1 + FTDSDIR=freetds$1 + WORKDIR=ftds_comp$1 + ;; *) echo 'Option not supported!' 1>&2 exit 1 commit 953a096fb706599772e0828dc9c22cf5a9c7a8e0 Author: jklowden Date: Thu Jan 17 22:45:50 2008 +0000 announce 0.82RC1 diff --git a/ChangeLog b/ChangeLog index 06276f3..9c3fb34 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +Thu Jan 17 17:44:43 EST 2008 JK Lowden + * doc/htdoc/news.html announce 0.82RC1 + Thu Jan 17 7:56:02 CET 2008 Frediano Ziglio * src/tds/net.c: do not dump received header @@ -62,4 +65,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2470 2008/01/17 06:56:50 freddy77 Exp $ +$Id: ChangeLog,v 1.2471 2008/01/17 22:45:50 jklowden Exp $ diff --git a/doc/htdoc/news.html b/doc/htdoc/news.html index ed0a8a9..c4f8434 100644 --- a/doc/htdoc/news.html +++ b/doc/htdoc/news.html @@ -1,7 +1,7 @@ - + FreeTDS.org @@ -24,11 +24,31 @@ News  | 
- +

News and Press

+ + + + + + + commit a8b3aa76401d5ba7c1f858cedb015a7619666d8f Author: jklowden Date: Thu Jan 17 22:55:33 2008 +0000 no comment diff --git a/doc/htdoc/news.html b/doc/htdoc/news.html index c4f8434..0e26056 100644 --- a/doc/htdoc/news.html +++ b/doc/htdoc/news.html @@ -1,7 +1,7 @@ - + FreeTDS.org @@ -25,7 +25,7 @@ News  | 

News and Press commit 33c555f4d9ccb9203c80176e2548ba2cb33a4059 Author: jklowden Date: Thu Jan 17 22:57:27 2008 +0000 fixed link diff --git a/doc/htdoc/news.html b/doc/htdoc/news.html index 0e26056..5dbbcee 100644 --- a/doc/htdoc/news.html +++ b/doc/htdoc/news.html @@ -1,7 +1,7 @@ - + FreeTDS.org @@ -38,7 +38,7 @@ News  | 

FreeTDS enters release process for Version 0.82
+
+Version 0.82RC1 is now available from + +ftp.ibiblio.org. This important release will incorporate many new features, involving some +23,710 lines of code. Detailed information can be found in the NEWS file included in the +the distribution. +

Version 0.82 will be the successor to 0.64, released in July 2006. The jump in version +number represents the progress toward version 1.0. +
+
+

FreeTDS announces Version 0.63

Version 0.82RC1 is now available from - + ftp.ibiblio.org. This important release will incorporate many new features, involving some 23,710 lines of code. Detailed information can be found in the NEWS file included in the the distribution. commit 3a6980a9d331be4a918460a4075b616754943ba5 Author: freddy77 Date: Fri Jan 18 13:37:11 2008 +0000 merge Sebastien Flaesch patch improving ODBC parameters diff --git a/ChangeLog b/ChangeLog index 9c3fb34..05d433d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Fri Jan 18 14:33:09 CET 2008 Frediano Ziglio + * include/tds.h src/odbc/connectparams.c src/tds/config.c: + - merge Sebastien Flaesch patch for ODBC parameters + - add ClientCharset, DumpFile, DumpFileAppend, DebugFlags, Encryption + - rewrote ODBCINSTGetProperties + Thu Jan 17 17:44:43 EST 2008 JK Lowden * doc/htdoc/news.html announce 0.82RC1 @@ -65,4 +71,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2471 2008/01/17 22:45:50 jklowden Exp $ +$Id: ChangeLog,v 1.2472 2008/01/18 13:37:11 freddy77 Exp $ diff --git a/include/tds.h b/include/tds.h index 4a63ca1..1a5eafa 100644 --- a/include/tds.h +++ b/include/tds.h @@ -20,7 +20,7 @@ #ifndef _tds_h_ #define _tds_h_ -/* $Id: tds.h,v 1.284 2007/12/27 13:45:22 freddy77 Exp $ */ +/* $Id: tds.h,v 1.285 2008/01/18 13:37:12 freddy77 Exp $ */ #include #include @@ -1387,6 +1387,7 @@ const TDS_COMPILETIME_SETTINGS *tds_get_compiletime_settings(void); typedef void (*TDSCONFPARSE) (const char *option, const char *value, void *param); int tds_read_conf_section(FILE * in, const char *section, TDSCONFPARSE tds_conf_parse, void *parse_param); int tds_read_conf_file(TDSCONNECTION * connection, const char *server); +void tds_parse_conf_section(const char *option, const char *value, void *param); TDSCONNECTION *tds_read_config_info(TDSSOCKET * tds, TDSLOGIN * login, TDSLOCALE * locale); void tds_fix_connection(TDSCONNECTION * connection); void tds_config_verstr(const char *tdsver, TDSCONNECTION * connection); diff --git a/src/odbc/connectparams.c b/src/odbc/connectparams.c index 7221a67..657062c 100644 --- a/src/odbc/connectparams.c +++ b/src/odbc/connectparams.c @@ -37,7 +37,22 @@ #include #endif -TDS_RCSID(var, "$Id: connectparams.c,v 1.72 2007/07/01 10:10:52 freddy77 Exp $"); +TDS_RCSID(var, "$Id: connectparams.c,v 1.73 2008/01/18 13:37:12 freddy77 Exp $"); + +static const char odbc_param_Servername[] = "Servername"; +static const char odbc_param_Address[] = "Address"; +static const char odbc_param_Server[] = "Server"; +static const char odbc_param_Port[] = "Port"; +static const char odbc_param_TDS_Version[] = "TDS_Version"; +static const char odbc_param_Language[] = "Language"; +static const char odbc_param_Database[] = "Database"; +static const char odbc_param_TextSize[] = "TextSize"; +static const char odbc_param_PacketSize[] = "PacketSize"; +static const char odbc_param_ClientCharset[] = "ClientCharset"; +static const char odbc_param_DumpFile[] = "DumpFile"; +static const char odbc_param_DumpFileAppend[] = "DumpFileAppend"; +static const char odbc_param_DebugFlags[] = "DebugFlags"; +static const char odbc_param_Encryption[] = "Encryption"; #if !HAVE_SQLGETPRIVATEPROFILESTRING @@ -114,6 +129,13 @@ parse_server(char *server, TDSCONNECTION * connection) return 1; } +static int +myGetPrivateProfileString(const char *DSN, const char *key, char *buf) +{ + buf[0] = '\0'; + return SQLGetPrivateProfileString(DSN, key, "", buf, FILENAME_MAX, "odbc.ini"); +} + /** * Read connection information from given DSN * @param DSN DSN name @@ -128,8 +150,7 @@ odbc_get_dsn_info(const char *DSN, TDSCONNECTION * connection) int address_specified = 0; /* use old servername */ - tmp[0] = '\0'; - if (SQLGetPrivateProfileString(DSN, "Servername", "", tmp, FILENAME_MAX, "odbc.ini") > 0) { + if (myGetPrivateProfileString(DSN, odbc_param_Servername, tmp) > 0) { freetds_conf_less = 0; tds_dstr_copy(&connection->server_name, tmp); tds_read_conf_file(connection, tmp); @@ -137,16 +158,13 @@ odbc_get_dsn_info(const char *DSN, TDSCONNECTION * connection) /* search for server (compatible with ms one) */ if (freetds_conf_less) { - tmp[0] = '\0'; - if (SQLGetPrivateProfileString(DSN, "Address", "", tmp, FILENAME_MAX, "odbc.ini") > 0) { + if (myGetPrivateProfileString(DSN, odbc_param_Address, tmp) > 0) { address_specified = 1; /* TODO parse like MS */ tds_lookup_host(tmp, tmp); tds_dstr_copy(&connection->ip_addr, tmp); } - - tmp[0] = '\0'; - if (SQLGetPrivateProfileString(DSN, "Server", "", tmp, FILENAME_MAX, "odbc.ini") > 0) { + if (myGetPrivateProfileString(DSN, odbc_param_Server, tmp) > 0) { tds_dstr_copy(&connection->server_name, tmp); if (!address_specified) { if (!parse_server(tmp, connection)) @@ -155,35 +173,39 @@ odbc_get_dsn_info(const char *DSN, TDSCONNECTION * connection) } } - tmp[0] = '\0'; - if (SQLGetPrivateProfileString(DSN, "Port", "", tmp, FILENAME_MAX, "odbc.ini") > 0) { - connection->port = atoi(tmp); - } + if (myGetPrivateProfileString(DSN, odbc_param_Port, tmp) > 0) + tds_parse_conf_section(TDS_STR_PORT, tmp, connection); - tmp[0] = '\0'; - if (SQLGetPrivateProfileString(DSN, "TDS_Version", "", tmp, FILENAME_MAX, "odbc.ini") > 0) { - tds_config_verstr(tmp, connection); - } + if (myGetPrivateProfileString(DSN, odbc_param_TDS_Version, tmp) > 0) + tds_parse_conf_section(TDS_STR_VERSION, tmp, connection); - tmp[0] = '\0'; - if (SQLGetPrivateProfileString(DSN, "Language", "", tmp, FILENAME_MAX, "odbc.ini") > 0) { - tds_dstr_copy(&connection->language, tmp); - } + if (myGetPrivateProfileString(DSN, odbc_param_Language, tmp) > 0) + tds_parse_conf_section(TDS_STR_LANGUAGE, tmp, connection); - tmp[0] = '\0'; if (tds_dstr_isempty(&connection->database) - && SQLGetPrivateProfileString(DSN, "Database", "", tmp, FILENAME_MAX, "odbc.ini") > 0) + && myGetPrivateProfileString(DSN, odbc_param_Database, tmp) > 0) tds_dstr_copy(&connection->database, tmp); - tmp[0] = '\0'; - if (SQLGetPrivateProfileString(DSN, "TextSize", "", tmp, FILENAME_MAX, "odbc.ini") > 0) { - connection->text_size = atoi(tmp); - } + if (myGetPrivateProfileString(DSN, odbc_param_TextSize, tmp) > 0) + tds_parse_conf_section(TDS_STR_TEXTSZ, tmp, connection); - tmp[0] = '\0'; - if (SQLGetPrivateProfileString(DSN, "PacketSize", "", tmp, FILENAME_MAX, "odbc.ini") > 0) { - connection->block_size = atoi(tmp); - } + if (myGetPrivateProfileString(DSN, odbc_param_PacketSize, tmp) > 0) + tds_parse_conf_section(TDS_STR_BLKSZ, tmp, connection); + + if (myGetPrivateProfileString(DSN, odbc_param_ClientCharset, tmp) > 0) + tds_parse_conf_section(TDS_STR_CLCHARSET, tmp, connection); + + if (myGetPrivateProfileString(DSN, odbc_param_DumpFile, tmp) > 0) + tds_parse_conf_section(TDS_STR_DUMPFILE, tmp, connection); + + if (myGetPrivateProfileString(DSN, odbc_param_DumpFileAppend, tmp) > 0) + tds_parse_conf_section(TDS_STR_APPENDMODE, tmp, connection); + + if (myGetPrivateProfileString(DSN, odbc_param_DebugFlags, tmp) > 0) + tds_parse_conf_section(TDS_STR_DEBUGFLAGS, tmp, connection); + + if (myGetPrivateProfileString(DSN, odbc_param_Encryption, tmp) > 0) + tds_parse_conf_section(TDS_STR_ENCRYPTION, tmp, connection); return 1; } @@ -279,16 +301,26 @@ odbc_parse_connect_string(const char *connect_string, const char *connect_string } else if (strcasecmp(option, "WSID") == 0) { dest_s = &connection->client_host_name; } else if (strcasecmp(option, "LANGUAGE") == 0) { - dest_s = &connection->language; - } else if (strcasecmp(option, "Port") == 0) { - connection->port = atoi(tds_dstr_cstr(&value)); - } else if (strcasecmp(option, "TDS_Version") == 0) { - tds_config_verstr(tds_dstr_cstr(&value), connection); - } else if (strcasecmp(option, "TextSize") == 0) { - connection->text_size = atoi(tds_dstr_cstr(&value)); - } else if (strcasecmp(option, "PacketSize") == 0) { - connection->block_size = atoi(tds_dstr_cstr(&value)); - /* TODO "Address" field */ + tds_parse_conf_section(TDS_STR_LANGUAGE, tds_dstr_cstr(&value), connection); + } else if (strcasecmp(option, odbc_param_Port) == 0) { + tds_parse_conf_section(TDS_STR_PORT, tds_dstr_cstr(&value), connection); + } else if (strcasecmp(option, odbc_param_TDS_Version) == 0) { + tds_parse_conf_section(TDS_STR_VERSION, tds_dstr_cstr(&value), connection); + } else if (strcasecmp(option, odbc_param_TextSize) == 0) { + tds_parse_conf_section(TDS_STR_TEXTSZ, tds_dstr_cstr(&value), connection); + } else if (strcasecmp(option, odbc_param_PacketSize) == 0) { + tds_parse_conf_section(TDS_STR_BLKSZ, tds_dstr_cstr(&value), connection); + } else if (strcasecmp(option, odbc_param_ClientCharset) == 0) { + tds_parse_conf_section(TDS_STR_CLCHARSET, tds_dstr_cstr(&value), connection); + } else if (strcasecmp(option, odbc_param_DumpFile) == 0) { + tds_parse_conf_section(TDS_STR_DUMPFILE, tds_dstr_cstr(&value), connection); + } else if (strcasecmp(option, odbc_param_DumpFileAppend) == 0) { + tds_parse_conf_section(TDS_STR_APPENDMODE, tds_dstr_cstr(&value), connection); + } else if (strcasecmp(option, odbc_param_DebugFlags) == 0) { + tds_parse_conf_section(TDS_STR_DEBUGFLAGS, tds_dstr_cstr(&value), connection); + } else if (strcasecmp(option, odbc_param_Encryption) == 0) { + tds_parse_conf_section(TDS_STR_ENCRYPTION, tds_dstr_cstr(&value), connection); + /* TODO odbc_param_Address field */ } /* copy to destination */ @@ -487,6 +519,19 @@ static const char *const aLanguage[] = { NULL }; +static const char *const aEncryption[] = { + TDS_STR_ENCRYPTION_OFF, + TDS_STR_ENCRYPTION_REQUEST, + TDS_STR_ENCRYPTION_REQUIRE, + NULL +}; + +static const char *const aBoolean[] = { + "Yes", + "No", + NULL +}; + /* static const char *aAuth[] = { "Server", @@ -496,129 +541,132 @@ static const char *aAuth[] = { }; */ -int -ODBCINSTGetProperties(HODBCINSTPROPERTY hLastProperty) +static HODBCINSTPROPERTY +addProperty(HODBCINSTPROPERTY hLastProperty) { hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY)); hLastProperty = hLastProperty->pNext; memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY)); - hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT; - tds_strlcpy(hLastProperty->szName, "Servername", INI_MAX_PROPERTY_NAME); - tds_strlcpy(hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE); - hLastProperty->pszHelp = (char *) strdup("Name of FreeTDS connection to connect to.\n" - "This server name refer to entry in freetds.conf file, not real server name.\n" - "This property cannot be used with Server property."); - - hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY)); - hLastProperty = hLastProperty->pNext; - memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY)); - hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT; - tds_strlcpy(hLastProperty->szName, "Server", INI_MAX_PROPERTY_NAME); - tds_strlcpy(hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE); - hLastProperty->pszHelp = (char *) strdup("Name of server to connect to.\n" - "This should be the name of real server.\n" - "This property cannot be used with Servername property."); + return hLastProperty; +} - hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY)); - hLastProperty = hLastProperty->pNext; - memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY)); +static HODBCINSTPROPERTY +definePropertyString(HODBCINSTPROPERTY hLastProperty, const char *name, const char *value, const char *comment) +{ + hLastProperty = addProperty(hLastProperty); hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT; - tds_strlcpy(hLastProperty->szName, "Address", INI_MAX_PROPERTY_NAME); - tds_strlcpy(hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE); - hLastProperty->pszHelp = (char *) strdup("The hostname or ip address of the server."); + tds_strlcpy(hLastProperty->szName, name, INI_MAX_PROPERTY_NAME); + tds_strlcpy(hLastProperty->szValue, value, INI_MAX_PROPERTY_VALUE); + hLastProperty->pszHelp = (char *) strdup(comment); + return hLastProperty; +} - hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY)); - hLastProperty = hLastProperty->pNext; - memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY)); - hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT; - tds_strlcpy(hLastProperty->szName, "Port", INI_MAX_PROPERTY_NAME); - tds_strlcpy(hLastProperty->szValue, "1433", INI_MAX_PROPERTY_VALUE); - hLastProperty->pszHelp = (char *) strdup("TCP/IP Port to connect to."); +static HODBCINSTPROPERTY +definePropertyBoolean(HODBCINSTPROPERTY hLastProperty, const char *name, const char *value, const char *comment) +{ + hLastProperty = addProperty(hLastProperty); + hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_LISTBOX; + hLastProperty->aPromptData = malloc(sizeof(aBoolean)); + memcpy(hLastProperty->aPromptData, aBoolean, sizeof(aBoolean)); + tds_strlcpy(hLastProperty->szName, name, INI_MAX_PROPERTY_NAME); + tds_strlcpy(hLastProperty->szValue, value, INI_MAX_PROPERTY_VALUE); + hLastProperty->pszHelp = (char *) strdup(comment); + return hLastProperty; +} - hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY)); - hLastProperty = hLastProperty->pNext; - memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY)); - hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT; - tds_strlcpy(hLastProperty->szName, "Database", INI_MAX_PROPERTY_NAME); - tds_strlcpy(hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE); - hLastProperty->pszHelp = (char *) strdup("Default database."); +static HODBCINSTPROPERTY +definePropertyHidden(HODBCINSTPROPERTY hLastProperty, const char *name, const char *value, const char *comment) +{ + hLastProperty = addProperty(hLastProperty); + hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_HIDDEN; + tds_strlcpy(hLastProperty->szName, name, INI_MAX_PROPERTY_NAME); + tds_strlcpy(hLastProperty->szValue, value, INI_MAX_PROPERTY_VALUE); + hLastProperty->pszHelp = (char *) strdup(comment); + return hLastProperty; +} - hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY)); - hLastProperty = hLastProperty->pNext; - memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY)); +static HODBCINSTPROPERTY +definePropertyList(HODBCINSTPROPERTY hLastProperty, const char *name, const char *value, void *list, int size, const char *comment) +{ + hLastProperty = addProperty(hLastProperty); hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_LISTBOX; - hLastProperty->aPromptData = malloc(sizeof(aTDSver)); - memcpy(hLastProperty->aPromptData, aTDSver, sizeof(aTDSver)); - tds_strlcpy(hLastProperty->szName, "TDS_Version", INI_MAX_PROPERTY_NAME); - tds_strlcpy(hLastProperty->szValue, "4.2", INI_MAX_PROPERTY_VALUE); - hLastProperty->pszHelp = (char *) strdup("The TDS protocol version.\n" - " 4.2 MSSQL 6.5 or Sybase < 10.x\n" - " 5.0 Sybase >= 10.x\n" " 7.0 MSSQL 7 or MSSQL 2000\n" " 8.0 MSSQL 2000"); + hLastProperty->aPromptData = malloc(size); + memcpy(hLastProperty->aPromptData, list, size); + tds_strlcpy(hLastProperty->szName, name, INI_MAX_PROPERTY_NAME); + tds_strlcpy(hLastProperty->szValue, value, INI_MAX_PROPERTY_VALUE); + hLastProperty->pszHelp = (char *) strdup(comment); + return hLastProperty; +} - hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY)); - hLastProperty = hLastProperty->pNext; - memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY)); - hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_COMBOBOX; - hLastProperty->aPromptData = malloc(sizeof(aLanguage)); - memcpy(hLastProperty->aPromptData, aLanguage, sizeof(aLanguage)); - tds_strlcpy(hLastProperty->szName, "Language", INI_MAX_PROPERTY_NAME); - tds_strlcpy(hLastProperty->szValue, "us_english", INI_MAX_PROPERTY_VALUE); - hLastProperty->pszHelp = (char *) strdup("The default language setting."); +int +ODBCINSTGetProperties(HODBCINSTPROPERTY hLastProperty) +{ + hLastProperty = definePropertyString(hLastProperty, odbc_param_Servername, "", + "Name of FreeTDS connection to connect to.\n" + "This server name refer to entry in freetds.conf file, not real server name.\n" + "This property cannot be used with Server property."); - hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY)); - hLastProperty = hLastProperty->pNext; - memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY)); - hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_HIDDEN; - tds_strlcpy(hLastProperty->szName, "TextSize", INI_MAX_PROPERTY_NAME); - tds_strlcpy(hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE); - hLastProperty->pszHelp = (char *) strdup("Text datatype limit."); + hLastProperty = definePropertyString(hLastProperty, odbc_param_Server, "", + "Name of server to connect to.\n" + "This should be the name of real server.\n" + "This property cannot be used with Servername property."); + + hLastProperty = definePropertyString(hLastProperty, odbc_param_Address, "", + "The hostname or ip address of the server."); + + hLastProperty = definePropertyString(hLastProperty, odbc_param_Port, "1433", + "TCP/IP Port to connect to."); + + hLastProperty = definePropertyString(hLastProperty, odbc_param_Database, "", + "Default database."); + + hLastProperty = definePropertyList(hLastProperty, odbc_param_TDS_Version, "4.2", (void*) aTDSver, sizeof(aTDSver), + "The TDS protocol version.\n" + " 4.2 MSSQL 6.5 or Sybase < 10.x\n" + " 5.0 Sybase >= 10.x\n" + " 7.0 MSSQL 7 or MSSQL 2000\n" + " 8.0 MSSQL 2000"); + + hLastProperty = definePropertyList(hLastProperty, odbc_param_Language, "us_english", (void*) aLanguage, sizeof(aLanguage), + "The default language setting."); + + hLastProperty = definePropertyHidden(hLastProperty, odbc_param_TextSize, "", + "Text datatype limit."); /* ??? in odbc.ini ??? */ /* - hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY)); - hLastProperty = hLastProperty->pNext; - memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY)); - hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT; - tds_strlcpy(hLastProperty->szName, "UID", INI_MAX_PROPERTY_NAME); - tds_strlcpy(hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE); - hLastProperty->pszHelp = (char *) strdup("User ID (Beware of security issues)."); + hLastProperty = definePropertyString(hLastProperty, odbc_param_UID, "", + "User ID (Beware of security issues)."); - hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY)); - hLastProperty = hLastProperty->pNext; - memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY)); - hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT; - tds_strlcpy(hLastProperty->szName, "PWD", INI_MAX_PROPERTY_NAME); - tds_strlcpy(hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE); - hLastProperty->pszHelp = (char *) strdup("Password (Beware of security issues)."); + hLastProperty = definePropertyString(hLastProperty, odbc_param_PWD, "", + "Password (Beware of security issues)."); */ /* - hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY)); - hLastProperty = hLastProperty->pNext; - memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY)); - hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_LISTBOX; - hLastProperty->aPromptData = malloc(sizeof(aAuth)); - memcpy(hLastProperty->aPromptData, aAuth, sizeof(aAuth)); - tds_strlcpy(hLastProperty->szName, "Authentication", INI_MAX_PROPERTY_NAME); - tds_strlcpy(hLastProperty->szValue, "Server", INI_MAX_PROPERTY_VALUE); - hLastProperty->pszHelp = (char *) strdup("The server authentication mechanism."); + hLastProperty = definePropertyList(hLastProperty, odbc_param_Authentication, "Server", aAuth, sizeof(aAuth), + "The server authentication mechanism."); + + hLastProperty = definePropertyString(hLastProperty, odbc_param_Domain, "", + "The default domain to use when using Domain Authentication."); */ - hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY)); - hLastProperty = hLastProperty->pNext; - memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY)); - hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT; - tds_strlcpy(hLastProperty->szName, "Domain", INI_MAX_PROPERTY_NAME); - tds_strlcpy(hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE); - hLastProperty->pszHelp = (char *) strdup("The default domain to use when using Domain Authentication."); + hLastProperty = definePropertyString(hLastProperty, odbc_param_PacketSize, "", + "Size of network packets."); - hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY)); - hLastProperty = hLastProperty->pNext; - memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY)); - hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT; - tds_strlcpy(hLastProperty->szName, "PacketSize", INI_MAX_PROPERTY_NAME); - tds_strlcpy(hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE); - hLastProperty->pszHelp = (char *) strdup("Size of network packets."); + hLastProperty = definePropertyString(hLastProperty, odbc_param_ClientCharset, "", + "The client character set name to convert application characters to UCS-2 in TDS 7.0 and higher."); + + hLastProperty = definePropertyString(hLastProperty, odbc_param_DumpFile, "", + "Specifies the location of a tds dump file and turns on logging."); + + hLastProperty = definePropertyBoolean(hLastProperty, odbc_param_DumpFileAppend, "", + "Appends dump file instead of overwriting it. Useful for debugging when many processes are active."); + + hLastProperty = definePropertyString(hLastProperty, odbc_param_DebugFlags, "", + "Sets granularity of logging. A set of bit that specify levels and informations. See table below for bit specification."); + + hLastProperty = definePropertyList(hLastProperty, odbc_param_Encryption, TDS_STR_ENCRYPTION_OFF, aEncryption, sizeof(aEncryption), + "The encryption method."); return 1; } diff --git a/src/tds/config.c b/src/tds/config.c index f88b268..9be062a 100644 --- a/src/tds/config.c +++ b/src/tds/config.c @@ -76,7 +76,7 @@ #include #endif -TDS_RCSID(var, "$Id: config.c,v 1.132 2007/12/23 21:12:02 jklowden Exp $"); +TDS_RCSID(var, "$Id: config.c,v 1.133 2008/01/18 13:37:12 freddy77 Exp $"); static void tds_config_login(TDSCONNECTION * connection, TDSLOGIN * login); static void tds_config_env_tdsdump(TDSCONNECTION * connection); @@ -84,7 +84,6 @@ static void tds_config_env_tdsver(TDSCONNECTION * connection); static void tds_config_env_tdsport(TDSCONNECTION * connection); static void tds_config_env_tdshost(TDSCONNECTION * connection); static int tds_read_conf_sections(FILE * in, const char *server, TDSCONNECTION * connection); -static void tds_parse_conf_section(const char *option, const char *value, void *param); static void tds_read_interfaces(const char *server, TDSCONNECTION * connection); static int tds_config_boolean(const char *value); static int parse_server_name_for_port(TDSCONNECTION * connection, TDSLOGIN * login); @@ -349,13 +348,27 @@ tds_read_conf_sections(FILE * in, const char *server, TDSCONNECTION * connection return tds_read_conf_section(in, server, tds_parse_conf_section, connection); } +static const struct { + char value[7]; + unsigned char to_return; +} boolean_values[] = { + { "yes", 1 }, + { "no", 0 }, + { "on", 1 }, + { "off", 0 }, + { "true", 1 }, + { "false", 0 } +}; + static int tds_config_boolean(const char *value) { - if (!strcmp(value, "yes") || !strcmp(value, "on") || !strcmp(value, "true") || !strcmp(value, "1")) - return 1; - if (!strcmp(value, "no") || !strcmp(value, "off") || !strcmp(value, "false") || !strcmp(value, "0")) - return 0; + int p; + + for (p = 0; p < TDS_VECTOR_SIZE(boolean_values); ++p) { + if (!strcasecmp(value, boolean_values[p].value)) + return boolean_values[p].to_return; + } tdsdump_log(TDS_DBG_INFO1, "UNRECOGNIZED boolean value: '%s'. Treating as 'no'.\n", value); return 0; } @@ -471,7 +484,8 @@ tds_read_conf_section(FILE * in, const char *section, TDSCONFPARSE tds_conf_pars #undef option } -static void +/* Also used to scan ODBC.INI entries */ +void tds_parse_conf_section(const char *option, const char *value, void *param) { TDSCONNECTION *connection = (TDSCONNECTION *) param; commit fbd7bff7112f0353f1bab471cd166369e18ab6a3 Author: freddy77 Date: Sun Jan 20 14:23:58 2008 +0000 port to win64 diff --git a/ChangeLog b/ChangeLog index 05d433d..468a3bf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Sun Jan 20 15:23:16 CET 2008 Frediano Ziglio + * configure.ac include/tds_sysdep_private.h: + * include/tds_sysdep_public.h.in src/apps/Makefile.am: + * src/ctlib/unittests/cancel.c src/dblib/unittests/timeout.c: + * src/odbc/unittests/describecol.c src/replacements/iconv.c: + * src/tds/query.c win32/tds_sysdep_public.h win32/winlogin.c: + * win32/winsetup.c: + - port to win64 + Fri Jan 18 14:33:09 CET 2008 Frediano Ziglio * include/tds.h src/odbc/connectparams.c src/tds/config.c: - merge Sebastien Flaesch patch for ODBC parameters @@ -71,4 +80,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2472 2008/01/18 13:37:11 freddy77 Exp $ +$Id: ChangeLog,v 1.2473 2008/01/20 14:23:58 freddy77 Exp $ diff --git a/configure.ac b/configure.ac index 4a0f729..77740fc 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. dnl ------------------------------------------------------------ -dnl $Id: configure.ac,v 1.32 2008/01/11 12:43:39 freddy77 Exp $ +dnl $Id: configure.ac,v 1.33 2008/01/20 14:23:58 freddy77 Exp $ dnl If you're trying to create a new configure test, try dnl dnl http://autogen.sourceforge.net/conftest.html @@ -15,7 +15,7 @@ dnl ------------------------------------------------------------ AC_INIT(FreeTDS, 0.83.dev.esyscmd(echo -n $(date +"%Y%m%d"))) AC_CONFIG_SRCDIR(src/dblib/dblib.c) AC_PREREQ(2.53) -AC_REVISION($Revision: 1.32 $) +AC_REVISION($Revision: 1.33 $) AM_INIT_AUTOMAKE AC_CONFIG_HEADERS(include/config.h) @@ -142,7 +142,9 @@ tds_mingw=no case $host in *-*-mingw*) tds_mingw=yes - if test -r /usr/lib/w32api/libwsock32.a; then + if test "$host_cpu" = "x86_64"; then + LIBS="-lws2_32" + elif test -r /usr/lib/w32api/libwsock32.a; then LIBS="-L/usr/lib/w32api -lwsock32" else LIBS="-lwsock32" @@ -381,7 +383,7 @@ TDS_NULL_IS_ZERO AC_CHECK_FUNCS([vsnprintf _vsnprintf gettimeofday \ nl_langinfo locale_charset setenv putenv \ getuid getpwuid getpwuid_r fstat alarm fork \ -gethrtime localtime_r]) +gethrtime localtime_r setitimer]) OLD_LIBS="$LIBS" LIBS="$LIBS $NETWORK_LIBS" AC_CHECK_FUNCS([inet_ntoa_r getipnodebyaddr getipnodebyname \ @@ -474,6 +476,7 @@ if test "$with_odbc_nodm"; then # Can't use ODBCLIB/LDFLAGS variables since they are used in building # other directories. ODBCNODMLIB="-L.. -ltdsodbc" + ODBCNODMLIBAPP="-L../odbc -ltdsodbc" odbc=true fi @@ -594,6 +597,7 @@ AC_SUBST(ODBC_INC) AC_SUBST(ODBCLIB) AC_SUBST(ODBCINSTLIB) AC_SUBST(ODBCNODMLIB) +AC_SUBST(ODBCNODMLIBAPP) AC_ARG_WITH(gnutls, AS_HELP_STRING([--with-gnutls], [build with TLS support])) diff --git a/include/tds_sysdep_private.h b/include/tds_sysdep_private.h index 8adfb9b..bce25a0 100644 --- a/include/tds_sysdep_private.h +++ b/include/tds_sysdep_private.h @@ -20,7 +20,7 @@ #ifndef _tds_sysdep_private_h_ #define _tds_sysdep_private_h_ -/* $Id: tds_sysdep_private.h,v 1.24 2008/01/10 22:57:33 jklowden Exp $ */ +/* $Id: tds_sysdep_private.h,v 1.25 2008/01/20 14:23:59 freddy77 Exp $ */ #undef TDS_RCSID #if defined(__GNUC__) && __GNUC__ >= 3 @@ -95,6 +95,10 @@ typedef DWORD pid_t; #define WIN32 1 #endif +#if defined(_WIN64) && !defined(WIN64) +#define WIN64 1 +#endif + #define TDS_SDIR_SEPARATOR "\\" /* use macros to use new style names */ diff --git a/include/tds_sysdep_public.h.in b/include/tds_sysdep_public.h.in index 4ab78fb..96a782c 100644 --- a/include/tds_sysdep_public.h.in +++ b/include/tds_sysdep_public.h.in @@ -20,7 +20,7 @@ #ifndef _tds_sysdep_public_h_ #define _tds_sysdep_public_h_ -/* $Id: tds_sysdep_public.h.in,v 1.11 2006/04/12 13:54:10 freddy77 Exp $ */ +/* $Id: tds_sysdep_public.h.in,v 1.12 2008/01/20 14:23:59 freddy77 Exp $ */ #ifdef __cplusplus extern "C" @@ -37,7 +37,11 @@ extern "C" #define tds_sysdep_int64_type __int64 /* 64-bit int */ #define tds_sysdep_real32_type float /* 32-bit real */ #define tds_sysdep_real64_type double /* 64-bit real */ -#define tds_sysdep_intptr_type int /* 32-bit int */ +#if !defined(WIN64) && !defined(_WIN64) +#define tds_sysdep_intptr_type int /* 32-bit int */ +#else +#define tds_sysdep_intptr_type __int64 /* 64-bit int */ +#endif #endif /* defined(WIN32) || defined(_WIN32) || defined(__WIN32__) */ #ifndef tds_sysdep_int16_type diff --git a/src/apps/Makefile.am b/src/apps/Makefile.am index cfa03ac..6b03ce8 100644 --- a/src/apps/Makefile.am +++ b/src/apps/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am,v 1.25 2008/01/01 23:09:46 freddy77 Exp $ +# $Id: Makefile.am,v 1.26 2008/01/20 14:23:59 freddy77 Exp $ AM_CPPFLAGS = -I$(top_srcdir)/include @@ -28,9 +28,8 @@ bsqldb_LDADD = ../dblib/libsybdb.la \ $(NETWORK_LIBS) if ODBC -bsqlodbc_LDADD = ../odbc/libtdsodbc.la \ - ../replacements/libreplacements.la \ - $(ODBCLIB) $(NETWORK_LIBS) +bsqlodbc_LDADD = ../replacements/libreplacements.la \ + $(ODBCLIB) $(ODBCNODMLIBAPP) $(NETWORK_LIBS) bsqlodbc_CPPFLAGS = $(ODBC_INC) $(AM_CPPFLAGS) endif diff --git a/src/ctlib/unittests/cancel.c b/src/ctlib/unittests/cancel.c index 09f3a1a..74e4da9 100644 --- a/src/ctlib/unittests/cancel.c +++ b/src/ctlib/unittests/cancel.c @@ -10,10 +10,10 @@ #include #include "common.h" -static char software_version[] = "$Id: cancel.c,v 1.11 2006/06/15 12:17:47 freddy77 Exp $"; +static char software_version[] = "$Id: cancel.c,v 1.12 2008/01/20 14:23:59 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; -#ifdef HAVE_ALARM +#if defined(HAVE_ALARM) && defined(HAVE_SETITIMER) /* protos */ int do_fetch(CS_COMMAND * cmd, int *cnt); diff --git a/src/dblib/unittests/timeout.c b/src/dblib/unittests/timeout.c index 736f968..7de6013 100644 --- a/src/dblib/unittests/timeout.c +++ b/src/dblib/unittests/timeout.c @@ -7,7 +7,7 @@ #include "common.h" #include -static char software_version[] = "$Id: timeout.c,v 1.3 2007/12/04 02:06:38 jklowden Exp $"; +static char software_version[] = "$Id: timeout.c,v 1.4 2008/01/20 14:23:59 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; int ntimeouts = 0, ncancels = 0; @@ -29,7 +29,7 @@ timeout_err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char return INT_CANCEL; if (dberr == SYBETIME) { - fprintf(stderr, "%d timeouts received in %ld seconds, ", ++ntimeouts, time(NULL) - start_time); + fprintf(stderr, "%d timeouts received in %ld seconds, ", ++ntimeouts, (long int) (time(NULL) - start_time)); if (ntimeouts > max_timeouts) { if (++ncancels > 1) { fprintf(stderr, "could not timeout cleanly, breaking connection\n"); @@ -73,14 +73,14 @@ timeout_err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char int chkintr(DBPROCESS * dbproc) { - printf("in chkintr, %ld seconds elapsed\n", time(NULL) - start_time); + printf("in chkintr, %ld seconds elapsed\n", (long int) (time(NULL) - start_time)); return FALSE; } int hndlintr(DBPROCESS * dbproc) { - printf("in hndlintr, %ld seconds elapsed\n", time(NULL) - start_time); + printf("in hndlintr, %ld seconds elapsed\n", (long int) (time(NULL) - start_time)); return INT_CONTINUE; } diff --git a/src/odbc/unittests/describecol.c b/src/odbc/unittests/describecol.c index cd1de67..3739957 100644 --- a/src/odbc/unittests/describecol.c +++ b/src/odbc/unittests/describecol.c @@ -6,7 +6,7 @@ * test what say SQLDescribeCol about precision using some type */ -static char software_version[] = "$Id: describecol.c,v 1.13 2007/12/31 10:06:50 freddy77 Exp $"; +static char software_version[] = "$Id: describecol.c,v 1.14 2008/01/20 14:23:59 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static int g_result = 0; @@ -78,6 +78,9 @@ static struct lookup_int sql_types[] = { TYPE(SQL_BINARY), TYPE(SQL_VARBINARY), TYPE(SQL_LONGVARBINARY), + TYPE(SQL_DATE), + TYPE(SQL_TIME), + TYPE(SQL_TIMESTAMP), TYPE(SQL_TYPE_DATE), TYPE(SQL_TYPE_TIME), TYPE(SQL_TYPE_TIMESTAMP), @@ -140,7 +143,7 @@ typedef int (*get_attr_t) (ATTR_PARAMS); static int get_attr_ird(ATTR_PARAMS) { - SQLINTEGER i; + SQLLEN i; SQLRETURN ret; if (attr->type == type_CHARP) diff --git a/src/replacements/iconv.c b/src/replacements/iconv.c index c709275..80fe192 100644 --- a/src/replacements/iconv.c +++ b/src/replacements/iconv.c @@ -53,7 +53,7 @@ #include #endif -TDS_RCSID(var, "$Id: iconv.c,v 1.15 2006/08/07 19:37:59 freddy77 Exp $"); +TDS_RCSID(var, "$Id: iconv.c,v 1.16 2008/01/20 14:23:59 freddy77 Exp $"); /** * \addtogroup conv @@ -116,7 +116,7 @@ tds_sys_iconv_open (const char* tocode, const char* fromcode) case UTF8_ASCII: case UCS2LE_UTF8: case UTF8_UCS2LE: - return (iconv_t)fromto; + return (iconv_t) (TDS_INTPTR) fromto; break; default: break; @@ -144,7 +144,7 @@ tds_sys_iconv (iconv_t cd, const char* * inbuf, size_t *inbytesleft, char* * out int local_errno; #undef CD -#define CD ((int)cd) +#define CD ((int) (TDS_INTPTR) cd) /* iconv defines valid semantics for NULL inputs, but we don't support them. */ if (!inbuf || !*inbuf || !inbytesleft || !outbuf || !*outbuf || !outbytesleft) diff --git a/src/tds/query.c b/src/tds/query.c index 8ef57f7..61c266d 100644 --- a/src/tds/query.c +++ b/src/tds/query.c @@ -46,7 +46,7 @@ #include -TDS_RCSID(var, "$Id: query.c,v 1.217 2008/01/05 11:24:40 freddy77 Exp $"); +TDS_RCSID(var, "$Id: query.c,v 1.218 2008/01/20 14:23:59 freddy77 Exp $"); static void tds_put_params(TDSSOCKET * tds, TDSPARAMINFO * info, int flags); static void tds7_put_query_params(TDSSOCKET * tds, const char *query, int query_len); @@ -1729,7 +1729,7 @@ tds_get_dynid(TDSSOCKET * tds, char **id) inc_num = (inc_num + 1) & 0xffff; /* some version of Sybase require length <= 10, so we code id */ - n = (unsigned long) tds; + n = (unsigned long) (TDS_INTPTR) tds; if (!(p = (char *) malloc(16))) return TDS_FAIL; *id = p; diff --git a/win32/tds_sysdep_public.h b/win32/tds_sysdep_public.h index 048c409..d86e324 100644 --- a/win32/tds_sysdep_public.h +++ b/win32/tds_sysdep_public.h @@ -20,7 +20,7 @@ #ifndef _tds_sysdep_public_h_ #define _tds_sysdep_public_h_ -static char rcsid_tds_sysdep_public_h[] = "$Id: tds_sysdep_public.h,v 1.5 2004/02/03 19:28:12 jklowden Exp $"; +static char rcsid_tds_sysdep_public_h[] = "$Id: tds_sysdep_public.h,v 1.6 2008/01/20 14:23:59 freddy77 Exp $"; static void *no_unused_tds_sysdep_public_h_warn[] = { rcsid_tds_sysdep_public_h, no_unused_tds_sysdep_public_h_warn }; #ifdef __cplusplus @@ -34,12 +34,23 @@ extern "C" #define tds_sysdep_int64_type __int64 /* 64-bit int */ #define tds_sysdep_real32_type float /* 32-bit real */ #define tds_sysdep_real64_type double /* 64-bit real */ +#if !defined(WIN64) && !defined(_WIN64) #define tds_sysdep_intptr_type int /* 32-bit int */ +#else +#define tds_sysdep_intptr_type __int64 /* 64-bit int */ +#endif typedef SOCKET TDS_SYS_SOCKET; #ifndef TDS_IS_SOCKET_INVALID #define TDS_IS_SOCKET_INVALID(s) ((s) == INVALID_SOCKET) #endif +#if !defined(MSDBLIB) && !defined(SYBDBLIB) +#define SYBDBLIB 1 +#endif +#if defined(MSDBLIB) && defined(SYBDBLIB) +#error MSDBLIB and SYBDBLIB cannot both be defined +#endif + #ifdef __cplusplus } #endif diff --git a/win32/winlogin.c b/win32/winlogin.c index 4a2c2aa..9e5969d 100644 --- a/win32/winlogin.c +++ b/win32/winlogin.c @@ -88,6 +88,14 @@ get_desktop_file(const char *file) return res; } +#ifndef WIN64 +#define GetWindowUserData(wnd) GetWindowLong((wnd), GWL_USERDATA) +#define SetWindowUserData(wnd, data) SetWindowLong((wnd), GWL_USERDATA, (data)) +#else +#define GetWindowUserData(wnd) GetWindowLongPtr((wnd), GWLP_USERDATA) +#define SetWindowUserData(wnd, data) SetWindowLongPtr((wnd), GWLP_USERDATA, (data)) +#endif + /** * Callback function for the DSN Configuration dialog * \param hDlg identifies the dialog @@ -107,7 +115,7 @@ LoginDlgProc(HWND hDlg, UINT message, WPARAM wParam, /* */ case WM_INITDIALOG: /* lParam points to the TDSCONNECTION */ connection = (TDSCONNECTION *) lParam; - SetWindowLong(hDlg, GWL_USERDATA, lParam); + SetWindowUserData(hDlg, lParam); /* copy info from TDSCONNECTION to the dialog */ SendDlgItemMessage(hDlg, IDC_LOGINSERVER, WM_SETTEXT, 0, (LPARAM) tds_dstr_cstr(&connection->server_name)); @@ -122,7 +130,7 @@ LoginDlgProc(HWND hDlg, UINT message, WPARAM wParam, /* */ case WM_COMMAND: /* Dialog's user data points to TDSCONNECTION */ - connection = (TDSCONNECTION *) GetWindowLong(hDlg, GWL_USERDATA); + connection = (TDSCONNECTION *) GetWindowUserData(hDlg); /* The wParam indicates which button was pressed */ if (LOWORD(wParam) == IDCANCEL) { diff --git a/win32/winsetup.c b/win32/winsetup.c index 20585f0..e33dc76 100644 --- a/win32/winsetup.c +++ b/win32/winsetup.c @@ -192,6 +192,13 @@ validate(DSNINFO * di) return NULL; } +#ifndef WIN64 +#define GetWindowUserData(wnd) GetWindowLong((wnd), GWL_USERDATA) +#define SetWindowUserData(wnd, data) SetWindowLong((wnd), GWL_USERDATA, (data)) +#else +#define GetWindowUserData(wnd) GetWindowLongPtr((wnd), GWLP_USERDATA) +#define SetWindowUserData(wnd, data) SetWindowLongPtr((wnd), GWLP_USERDATA, (data)) +#endif /** * Callback function for the DSN Configuration dialog @@ -216,7 +223,7 @@ DSNDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_INITDIALOG: /* lParam points to the DSNINFO */ di = (DSNINFO *) lParam; - SetWindowLong(hDlg, GWL_USERDATA, lParam); + SetWindowUserData(hDlg, lParam); /* Stuff legal protocol names into IDC_PROTOCOL */ for (i = 0; protocols[i]; i++) { @@ -236,7 +243,7 @@ DSNDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_COMMAND: /* Dialog's user data points to DSNINFO */ - di = (DSNINFO *) GetWindowLong(hDlg, GWL_USERDATA); + di = (DSNINFO *) GetWindowUserData(hDlg); /* The wParam indicates which button was pressed */ if (LOWORD(wParam) == IDCANCEL) { commit efed20c5ed4afafa6f782e90904bf213871b9370 Author: freddy77 Date: Sun Jan 20 16:36:51 2008 +0000 remove warning diff --git a/ChangeLog b/ChangeLog index 468a3bf..f8be023 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +Sun Jan 20 17:36:34 CET 2008 Frediano Ziglio + * src/odbc/connectparams.c: remove warning + Sun Jan 20 15:23:16 CET 2008 Frediano Ziglio * configure.ac include/tds_sysdep_private.h: * include/tds_sysdep_public.h.in src/apps/Makefile.am: @@ -80,4 +83,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2473 2008/01/20 14:23:58 freddy77 Exp $ +$Id: ChangeLog,v 1.2474 2008/01/20 16:36:51 freddy77 Exp $ diff --git a/src/odbc/connectparams.c b/src/odbc/connectparams.c index 657062c..d16e218 100644 --- a/src/odbc/connectparams.c +++ b/src/odbc/connectparams.c @@ -37,7 +37,7 @@ #include #endif -TDS_RCSID(var, "$Id: connectparams.c,v 1.73 2008/01/18 13:37:12 freddy77 Exp $"); +TDS_RCSID(var, "$Id: connectparams.c,v 1.74 2008/01/20 16:36:51 freddy77 Exp $"); static const char odbc_param_Servername[] = "Servername"; static const char odbc_param_Address[] = "Address"; @@ -586,7 +586,7 @@ definePropertyHidden(HODBCINSTPROPERTY hLastProperty, const char *name, const ch } static HODBCINSTPROPERTY -definePropertyList(HODBCINSTPROPERTY hLastProperty, const char *name, const char *value, void *list, int size, const char *comment) +definePropertyList(HODBCINSTPROPERTY hLastProperty, const char *name, const char *value, const void *list, int size, const char *comment) { hLastProperty = addProperty(hLastProperty); hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_LISTBOX; commit 4f125fbe4a6beb3be0d617634f1de2698cd60be6 Author: freddy77 Date: Sun Jan 20 20:47:45 2008 +0000 test for 64bit diff --git a/src/odbc/unittests/test64.c b/src/odbc/unittests/test64.c new file mode 100644 index 0000000..2f81731 --- /dev/null +++ b/src/odbc/unittests/test64.c @@ -0,0 +1,257 @@ +/* test win64 consistency */ +#include "common.h" + +static char software_version[] = "$Id: test64.c,v 1.1 2008/01/20 20:47:45 freddy77 Exp $"; +static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; + +#define CHK(func,params) \ + if (func params != SQL_SUCCESS) \ + ODBC_REPORT_ERROR(#func) + +/* +set ipd processed_ptr with +SQLParamOptions/SQLSetDescField/SQL_ATTR_PARAMS_PROCESSED_PTR +check always same value IPD->processed_ptr attr +*/ + +static void +check_ipd_params(void) +{ + void *ptr, *ptr2; + SQLHDESC desc; + SQLINTEGER ind; + + CHK(SQLGetStmtAttr,(Statement, SQL_ATTR_PARAMS_PROCESSED_PTR, &ptr, sizeof(ptr), NULL)); + + /* get IPD */ + CHK(SQLGetStmtAttr, (Statement, SQL_ATTR_IMP_PARAM_DESC, &desc, sizeof(desc), &ind)); + + CHK(SQLGetDescField, (desc, 1, SQL_DESC_ROWS_PROCESSED_PTR, &ptr2, sizeof(ptr2), &ind)); + + if (ptr != ptr2) { + fprintf(stderr, "IPD inconsistency ptr %p ptr2 %p\n", ptr, ptr2); + exit(1); + } +} + +static void +set_ipd_params1(SQLULEN *ptr) +{ + CHK(SQLSetStmtAttr,(Statement, SQL_ATTR_PARAMS_PROCESSED_PTR, ptr, 0)); +} + +static void +set_ipd_params2(SQLULEN *ptr) +{ + SQLHDESC desc; + SQLINTEGER ind; + + /* get IPD */ + CHK(SQLGetStmtAttr, (Statement, SQL_ATTR_IMP_PARAM_DESC, &desc, sizeof(desc), &ind)); + + CHK(SQLSetDescField, (desc, 1, SQL_DESC_ROWS_PROCESSED_PTR, ptr, 0)); +} + +static void +set_ipd_params3(SQLULEN *ptr) +{ + CHK(SQLParamOptions, (Statement, 2, ptr)); +} + +typedef void (*rows_set_t)(SQLULEN*); + +static const rows_set_t param_set[] = { + set_ipd_params1, + set_ipd_params2, + set_ipd_params3, + NULL +}; + +#define MALLOC_N(t, n) (t*) malloc(n*sizeof(t)) + +static void +test_params(void) +{ +#define ARRAY_SIZE 2 + const rows_set_t *p; + SQLULEN len; + SQLUINTEGER *ids = MALLOC_N(SQLUINTEGER,ARRAY_SIZE); + SQLLEN *id_lens = MALLOC_N(SQLLEN,ARRAY_SIZE); + unsigned long int h, l; + unsigned int n; + + for (n = 0; n < ARRAY_SIZE; ++n) { + ids[n] = n; + id_lens[n] = 0; + } + + /* test setting just some test pointers */ + set_ipd_params1(int2ptr(0x01020304)); + check_ipd_params(); + set_ipd_params2(int2ptr(0xabcdef12)); + check_ipd_params(); + set_ipd_params3(int2ptr(0x87654321)); + check_ipd_params(); + + /* now see results */ + for (p = param_set; *p != NULL; ++p) { + ResetStatement(); + len = 0xdeadbeef; + len <<= 16; + len <<= 16; + len |= 12345678; + + (*p)(&len); + check_ipd_params(); + + CHK(SQLSetStmtAttr, (Statement, SQL_ATTR_PARAMSET_SIZE, (void *) int2ptr(ARRAY_SIZE), 0)); + CHK(SQLBindParameter, (Statement, 1, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_INTEGER, 5, 0, ids, 0, id_lens)); + + Command(Statement, "INSERT INTO #tmp1(i) VALUES(?)"); + SQLMoreResults(Statement); + for (n = 0; n < ARRAY_SIZE; ++n) + SQLMoreResults(Statement); + l = len; + len >>= 16; + h = len >> 16; + if (h != 0 || l != 2) { + fprintf(stderr, "Wrong number returned in param rows high %lu low %lu\n", h, l); + exit(1); + } + } + + free(ids); + free(id_lens); +} + +/* +set ird processed_ptr with +SQLExtendedFetch/SQLSetDescField/SQL_ATTR_ROWS_FETCHED_PTR +check always same value IRD->processed_ptr attr +*/ + +static void +check_ird_params(void) +{ + void *ptr, *ptr2; + SQLHDESC desc; + SQLINTEGER ind; + + CHK(SQLGetStmtAttr,(Statement, SQL_ATTR_ROWS_FETCHED_PTR, &ptr, sizeof(ptr), NULL)); + + /* get IRD */ + CHK(SQLGetStmtAttr, (Statement, SQL_ATTR_IMP_ROW_DESC, &desc, sizeof(desc), &ind)); + + CHK(SQLGetDescField, (desc, 1, SQL_DESC_ROWS_PROCESSED_PTR, &ptr2, sizeof(ptr2), &ind)); + + if (ptr != ptr2) { + fprintf(stderr, "IRD inconsistency ptr %p ptr2 %p\n", ptr, ptr2); + exit(1); + } +} + +static void +set_ird_params1(SQLULEN *ptr) +{ + CHK(SQLSetStmtAttr,(Statement, SQL_ATTR_ROWS_FETCHED_PTR, ptr, 0)); +} + +static void +set_ird_params2(SQLULEN *ptr) +{ + SQLHDESC desc; + SQLINTEGER ind; + + /* get IRD */ + CHK(SQLGetStmtAttr, (Statement, SQL_ATTR_IMP_ROW_DESC, &desc, sizeof(desc), &ind)); + + CHK(SQLSetDescField, (desc, 1, SQL_DESC_ROWS_PROCESSED_PTR, ptr, 0)); +} + +static const rows_set_t row_set[] = { + set_ird_params1, + set_ird_params2, + NULL +}; + +#define MALLOC_N(t, n) (t*) malloc(n*sizeof(t)) + +static void +test_rows(void) +{ + const rows_set_t *p; + SQLULEN len; + SQLUINTEGER *ids = MALLOC_N(SQLUINTEGER,ARRAY_SIZE); + SQLLEN *id_lens = MALLOC_N(SQLLEN,ARRAY_SIZE); + unsigned long int h, l; + unsigned int n; + + for (n = 0; n < ARRAY_SIZE; ++n) { + ids[n] = n; + id_lens[n] = 0; + } + + /* test setting just some test pointers */ + set_ird_params1(int2ptr(0x01020304)); + check_ird_params(); + set_ird_params2(int2ptr(0xabcdef12)); + check_ird_params(); + + /* now see results */ + for (p = row_set; ; ++p) { + ResetStatement(); + len = 0xdeadbeef; + len <<= 16; + len <<= 16; + len |= 12345678; + if (*p) + (*p)(&len); + check_ird_params(); + +// CHK(SQLSetStmtAttr, (Statement, SQL_ATTR_PARAMSET_SIZE, (void *) int2ptr(ARRAY_SIZE), 0)); +// CHK(SQLBindParameter, (Statement, 1, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_INTEGER, 5, 0, ids, 0, id_lens)); + + CHK(SQLBindCol, (Statement, 1, SQL_C_ULONG, ids, 0, id_lens)); + if (*p) { + CHK(SQLSetStmtAttr, (Statement, SQL_ATTR_ROW_ARRAY_SIZE, (void *) int2ptr(ARRAY_SIZE), 0)); + + Command(Statement, "SELECT DISTINCT i FROM #tmp1"); + SQLFetch(Statement); + } else { + CHK(SQLSetStmtAttr, (Statement, SQL_ROWSET_SIZE, (void *) int2ptr(ARRAY_SIZE), 0)); + Command(Statement, "SELECT DISTINCT i FROM #tmp1"); + CHK(SQLExtendedFetch, (Statement, SQL_FETCH_NEXT, 0, &len, NULL)); + } + SQLMoreResults(Statement); + + l = len; + len >>= 16; + h = len >> 16; + if (h != 0 || l != 2) { + fprintf(stderr, "Wrong number returned in rows high %lu(0x%lx) low %lu(0x%lx)\n", h, h, l, l); + exit(1); + } + + if (!*p) + break; + } + + free(ids); + free(id_lens); +} + +int +main() +{ + use_odbc_version3 = 1; + Connect(); + + Command(Statement, "create table #tmp1 (i int)"); + + test_params(); + test_rows(); + + Disconnect(); + return 0; +} + commit 9d07f193e704910aefc7dbd96d6bc0614864d0e3 Author: freddy77 Date: Sun Jan 20 21:48:00 2008 +0000 fix ms odbc problem with SQLGetDescField diff --git a/src/odbc/unittests/test64.c b/src/odbc/unittests/test64.c index 2f81731..dc88ed8 100644 --- a/src/odbc/unittests/test64.c +++ b/src/odbc/unittests/test64.c @@ -1,7 +1,7 @@ /* test win64 consistency */ #include "common.h" -static char software_version[] = "$Id: test64.c,v 1.1 2008/01/20 20:47:45 freddy77 Exp $"; +static char software_version[] = "$Id: test64.c,v 1.2 2008/01/20 21:48:00 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #define CHK(func,params) \ @@ -22,11 +22,11 @@ check_ipd_params(void) SQLINTEGER ind; CHK(SQLGetStmtAttr,(Statement, SQL_ATTR_PARAMS_PROCESSED_PTR, &ptr, sizeof(ptr), NULL)); - + /* get IPD */ CHK(SQLGetStmtAttr, (Statement, SQL_ATTR_IMP_PARAM_DESC, &desc, sizeof(desc), &ind)); - CHK(SQLGetDescField, (desc, 1, SQL_DESC_ROWS_PROCESSED_PTR, &ptr2, sizeof(ptr2), &ind)); + CHK(SQLGetDescField, (desc, 0, SQL_DESC_ROWS_PROCESSED_PTR, &ptr2, sizeof(ptr2), &ind)); if (ptr != ptr2) { fprintf(stderr, "IPD inconsistency ptr %p ptr2 %p\n", ptr, ptr2); @@ -138,11 +138,11 @@ check_ird_params(void) SQLINTEGER ind; CHK(SQLGetStmtAttr,(Statement, SQL_ATTR_ROWS_FETCHED_PTR, &ptr, sizeof(ptr), NULL)); - + /* get IRD */ CHK(SQLGetStmtAttr, (Statement, SQL_ATTR_IMP_ROW_DESC, &desc, sizeof(desc), &ind)); - CHK(SQLGetDescField, (desc, 1, SQL_DESC_ROWS_PROCESSED_PTR, &ptr2, sizeof(ptr2), &ind)); + CHK(SQLGetDescField, (desc, 0, SQL_DESC_ROWS_PROCESSED_PTR, &ptr2, sizeof(ptr2), &ind)); if (ptr != ptr2) { fprintf(stderr, "IRD inconsistency ptr %p ptr2 %p\n", ptr, ptr2); commit 39e3951a5a51fa75a5b79b1f06fcdeb62bc859a2 Author: freddy77 Date: Mon Jan 21 15:34:32 2008 +0000 merge fix for date/time from Dann Corbit diff --git a/ChangeLog b/ChangeLog index f8be023..1b49d15 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Mon Jan 21 16:33:58 CET 2008 Frediano Ziglio + * src/odbc/odbc_util.c: + - merge fix for date/time from Dann Corbit + Sun Jan 20 17:36:34 CET 2008 Frediano Ziglio * src/odbc/connectparams.c: remove warning @@ -83,4 +87,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2474 2008/01/20 16:36:51 freddy77 Exp $ +$Id: ChangeLog,v 1.2475 2008/01/21 15:34:32 freddy77 Exp $ diff --git a/src/odbc/odbc_util.c b/src/odbc/odbc_util.c index fb38d5b..06a4d07 100644 --- a/src/odbc/odbc_util.c +++ b/src/odbc/odbc_util.c @@ -38,7 +38,7 @@ #include #endif -TDS_RCSID(var, "$Id: odbc_util.c,v 1.94 2007/06/19 13:31:34 freddy77 Exp $"); +TDS_RCSID(var, "$Id: odbc_util.c,v 1.95 2008/01/21 15:34:32 freddy77 Exp $"); /** * \ingroup odbc_api @@ -562,10 +562,12 @@ odbc_sql_to_displaysize(int sqltype, TDSCOLUMN *col) size = col->column_prec + 2; break; case SQL_DATE: + case SQL_TYPE_DATE: /* FIXME check always yyyy-mm-dd ?? */ size = 19; break; case SQL_TIME: + case SQL_TYPE_TIME: /* FIXME check always hh:mm:ss[.fff] */ size = 19; break; commit c0a4f6c10da784231e110c95d1d16454d30e09ca Author: freddy77 Date: Thu Jan 24 21:02:14 2008 +0000 add test on type diff --git a/ChangeLog b/ChangeLog index 1b49d15..e88e56c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Thu Jan 24 22:01:41 CET 2008 Frediano Ziglio + * src/odbc/unittests/describecol.in: + - some additional tests + Mon Jan 21 16:33:58 CET 2008 Frediano Ziglio * src/odbc/odbc_util.c: - merge fix for date/time from Dann Corbit @@ -87,4 +91,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2475 2008/01/21 15:34:32 freddy77 Exp $ +$Id: ChangeLog,v 1.2476 2008/01/24 21:02:14 freddy77 Exp $ diff --git a/src/odbc/unittests/describecol.in b/src/odbc/unittests/describecol.in index 4f1d874..aa6a63a 100644 --- a/src/odbc/unittests/describecol.in +++ b/src/odbc/unittests/describecol.in @@ -119,6 +119,7 @@ attr SQL_DESC_OCTET_LENGTH 16 attr SQL_DESC_PRECISION 3 attr SQL_DESC_SCALE 3 attr SQL_DESC_DISPLAY_SIZE 23 +attr SQL_DESC_CONCISE_TYPE SQL_TIMESTAMP select smalldatetime '2006-04-14' attr SQL_COLUMN_LENGTH 16 @@ -129,6 +130,7 @@ attr SQL_DESC_OCTET_LENGTH 16 attr SQL_DESC_PRECISION 0 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 19 +attr SQL_DESC_CONCISE_TYPE SQL_TIMESTAMP select char(10) 'hi!' attr SQL_COLUMN_LENGTH 10 @@ -349,6 +351,7 @@ attr SQL_DESC_OCTET_LENGTH 16 attr SQL_DESC_PRECISION 3 attr SQL_DESC_SCALE 3 attr SQL_DESC_DISPLAY_SIZE 23 +attr SQL_DESC_CONCISE_TYPE SQL_TYPE_TIMESTAMP select smalldatetime '2006-04-14' attr SQL_COLUMN_LENGTH 16 @@ -359,6 +362,7 @@ attr SQL_DESC_OCTET_LENGTH 16 attr SQL_DESC_PRECISION 0 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 19 +attr SQL_DESC_CONCISE_TYPE SQL_TYPE_TIMESTAMP select char(10) 'hi!' attr SQL_COLUMN_LENGTH 10 commit ede2f0bed2728757f3bef5f664adfaf921fe88b9 Author: freddy77 Date: Thu Jan 24 21:14:55 2008 +0000 va_list cleanups diff --git a/ChangeLog b/ChangeLog index e88e56c..fd76f3b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Thu Jan 24 22:14:31 CET 2008 Frediano Ziglio + * src/dblib/dblib.c src/tds/vstrbuild.c: + - va_list cleanups + Thu Jan 24 22:01:41 CET 2008 Frediano Ziglio * src/odbc/unittests/describecol.in: - some additional tests @@ -91,4 +95,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2476 2008/01/24 21:02:14 freddy77 Exp $ +$Id: ChangeLog,v 1.2477 2008/01/24 21:14:55 freddy77 Exp $ diff --git a/src/dblib/dblib.c b/src/dblib/dblib.c index 59b3a49..b6950aa 100644 --- a/src/dblib/dblib.c +++ b/src/dblib/dblib.c @@ -76,7 +76,7 @@ #include #endif -TDS_RCSID(var, "$Id: dblib.c,v 1.320 2008/01/01 23:09:46 freddy77 Exp $"); +TDS_RCSID(var, "$Id: dblib.c,v 1.321 2008/01/24 21:14:55 freddy77 Exp $"); static RETCODE _dbresults(DBPROCESS * dbproc); static int _db_get_server_type(int bindtype); @@ -7775,7 +7775,6 @@ dbperror (DBPROCESS *dbproc, DBINT msgno, long errnum, ...) DBLIB_ERROR_MESSAGE constructed_message = { 0, EXCONSISTENCY, NULL }; const DBLIB_ERROR_MESSAGE *msg = &default_message; - va_list ap; int i, rc = INT_CANCEL; char *os_msgtext = strerror(errnum), *rc_name; @@ -7811,17 +7810,16 @@ dbperror (DBPROCESS *dbproc, DBINT msgno, long errnum, ...) msg = &dblib_error_messages[i]; assert(*(pformats - 1) == '\0'); if(*pformats != '\0') { + va_list ap; int result_len, len = 2 * strlen(ptext); char * buffer = calloc(1, len); - long save_errnum = errnum; - errnum = (long) pformats; + if (buffer == NULL) break; va_start(ap, errnum); rc = tds_vstrbuild(buffer, len, &result_len, ptext, TDS_NULLTERM, pformats, TDS_NULLTERM, ap); buffer[result_len] = '\0'; va_end(ap); - errnum = save_errnum; if (TDS_FAIL == rc) { free(buffer); break; diff --git a/src/tds/vstrbuild.c b/src/tds/vstrbuild.c index ff521d3..af7a519 100644 --- a/src/tds/vstrbuild.c +++ b/src/tds/vstrbuild.c @@ -35,7 +35,7 @@ #include "tds.h" #include "replacements.h" -TDS_RCSID(var, "$Id: vstrbuild.c,v 1.14 2007/10/16 15:12:23 freddy77 Exp $"); +TDS_RCSID(var, "$Id: vstrbuild.c,v 1.15 2008/01/24 21:14:55 freddy77 Exp $"); struct string_linked_list { @@ -206,6 +206,5 @@ tds_vstrbuild(char *buffer, int buflen, int *resultlen, char *text, int textlen, } free(params); - va_end(ap); return rc; } commit e95d57532bc55c15fe948cda91224ed2a854bbd1 Author: freddy77 Date: Fri Jan 25 17:35:52 2008 +0000 fix problems with some linker diff --git a/src/apps/Makefile.am b/src/apps/Makefile.am index 6b03ce8..9e5c4d1 100644 --- a/src/apps/Makefile.am +++ b/src/apps/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am,v 1.26 2008/01/20 14:23:59 freddy77 Exp $ +# $Id: Makefile.am,v 1.27 2008/01/25 17:35:52 freddy77 Exp $ AM_CPPFLAGS = -I$(top_srcdir)/include @@ -28,8 +28,8 @@ bsqldb_LDADD = ../dblib/libsybdb.la \ $(NETWORK_LIBS) if ODBC -bsqlodbc_LDADD = ../replacements/libreplacements.la \ - $(ODBCLIB) $(ODBCNODMLIBAPP) $(NETWORK_LIBS) +bsqlodbc_LDADD = $(ODBCLIB) $(ODBCNODMLIBAPP) \ + ../replacements/libreplacements.la $(NETWORK_LIBS) bsqlodbc_CPPFLAGS = $(ODBC_INC) $(AM_CPPFLAGS) endif commit 78b44066acdd787d1b81bcdab135403efc5ade6f Author: freddy77 Date: Sat Jan 26 21:47:26 2008 +0000 remove warning diff --git a/src/odbc/unittests/test64.c b/src/odbc/unittests/test64.c index dc88ed8..f29e745 100644 --- a/src/odbc/unittests/test64.c +++ b/src/odbc/unittests/test64.c @@ -1,7 +1,7 @@ /* test win64 consistency */ #include "common.h" -static char software_version[] = "$Id: test64.c,v 1.2 2008/01/20 21:48:00 freddy77 Exp $"; +static char software_version[] = "$Id: test64.c,v 1.3 2008/01/26 21:47:26 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #define CHK(func,params) \ @@ -241,7 +241,7 @@ test_rows(void) } int -main() +main(void) { use_odbc_version3 = 1; Connect(); commit 7671d563ca2b7a2ce589d8b5fd1b7c2837e38fd6 Author: freddy77 Date: Sun Jan 27 10:25:03 2008 +0000 *** empty log message *** diff --git a/src/odbc/unittests/.cvsignore b/src/odbc/unittests/.cvsignore index ae23946..2aea2d3 100644 --- a/src/odbc/unittests/.cvsignore +++ b/src/odbc/unittests/.cvsignore @@ -65,3 +65,4 @@ attributes hidden blob1 cancel +test64 commit 1de1a0984a75a2a6f7e532ebe3e0f584ffc06c28 Author: freddy77 Date: Sun Jan 27 10:25:39 2008 +0000 add generated diff --git a/.cvsignore b/.cvsignore index c4ca19c..d6098e5 100644 --- a/.cvsignore +++ b/.cvsignore @@ -18,3 +18,4 @@ freetds.spec PWD doxyfile test-dist.log +compile commit 12190adda9d9522577554554ad07080ba3e9a474 Author: freddy77 Date: Sun Jan 27 17:36:17 2008 +0000 implemented SQL_ATTR_CONNECTION_DEAD diff --git a/ChangeLog b/ChangeLog index fd76f3b..1f7e2b8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sun Jan 27 18:35:55 CET 2008 Frediano Ziglio + * src/odbc/odbc.c: + - implemented SQL_ATTR_CONNECTION_DEAD + Thu Jan 24 22:14:31 CET 2008 Frediano Ziglio * src/dblib/dblib.c src/tds/vstrbuild.c: - va_list cleanups @@ -95,4 +99,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2477 2008/01/24 21:14:55 freddy77 Exp $ +$Id: ChangeLog,v 1.2478 2008/01/27 17:36:17 freddy77 Exp $ diff --git a/src/odbc/odbc.c b/src/odbc/odbc.c index 74f8057..937a8d7 100644 --- a/src/odbc/odbc.c +++ b/src/odbc/odbc.c @@ -60,7 +60,7 @@ #include #endif -TDS_RCSID(var, "$Id: odbc.c,v 1.468 2008/01/14 19:21:06 freddy77 Exp $"); +TDS_RCSID(var, "$Id: odbc.c,v 1.469 2008/01/27 17:36:17 freddy77 Exp $"); static SQLRETURN _SQLAllocConnect(SQLHENV henv, SQLHDBC FAR * phdbc); static SQLRETURN _SQLAllocEnv(SQLHENV FAR * phenv); @@ -2030,8 +2030,8 @@ odbc_errmsg_handler(const TDSCONTEXT * ctx, TDSSOCKET * tds, TDSMESSAGE * msg) if (tds && (dbc = (TDS_DBC *) tds->parent) && dbc->current_statement) { TDS_STMT *stmt = dbc->current_statement; /* cancel sent, handling interrupt */ - if (tds->in_cancel && stmt ->cancel_sent) { - stmt ->cancel_sent = 0; + if (tds->in_cancel && stmt->cancel_sent) { + stmt->cancel_sent = 0; tdsdump_log(TDS_DBG_INFO1, "returning from timeout\n"); return TDS_INT_TIMEOUT; } @@ -4443,6 +4443,11 @@ _SQLGetConnectAttr(SQLHDBC hdbc, SQLINTEGER Attribute, SQLPOINTER Value, SQLINTE *((SQLUINTEGER *) Value) = dbc->attr.autocommit; ODBC_RETURN_(dbc); break; +#if defined(SQL_ATTR_CONNECTION_DEAD) && defined(SQL_CD_TRUE) + *((SQLUINTEGER *) Value) = IS_TDSDEAD(dbc->tds_socket) ? SQL_CD_TRUE : SQL_CD_FALSE; + ODBC_RETURN_(dbc); + break; +#endif case SQL_ATTR_CONNECTION_TIMEOUT: *((SQLUINTEGER *) Value) = dbc->attr.connection_timeout; ODBC_RETURN_(dbc); commit d9c30d6e29dc23b76eb3341471e6f1f3d87bdab8 Author: freddy77 Date: Mon Jan 28 13:36:07 2008 +0000 base test diff --git a/src/odbc/unittests/base.c b/src/odbc/unittests/base.c new file mode 100644 index 0000000..f4b365f --- /dev/null +++ b/src/odbc/unittests/base.c @@ -0,0 +1,19 @@ +#include "common.h" + +/* TODO place comment here */ + +static char software_version[] = "$Id: base.c,v 1.1 2008/01/28 13:36:07 freddy77 Exp $"; +static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; + +int +main(int argc, char *argv[]) +{ + /* TODO remove if not neeeded */ + use_odbc_version3 = 1; + Connect(); + + /* TODO write your test */ + + Disconnect(); + return 0; +} commit de0657f9227f964ce8db4b66bee483dc871df0ff Author: freddy77 Date: Tue Jan 29 09:35:24 2008 +0000 handle errors from convert_tds2sql diff --git a/ChangeLog b/ChangeLog index 1f7e2b8..09c3d0d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Jan 29 10:34:41 CET 2008 Frediano Ziglio + * src/odbc/convert_tds2sql.c src/odbc/odbc.c src/odbc/odbc_util.c: + * src/odbc/unittests/getdata.c: + - handle errors from convert_tds2sql + Sun Jan 27 18:35:55 CET 2008 Frediano Ziglio * src/odbc/odbc.c: - implemented SQL_ATTR_CONNECTION_DEAD @@ -99,4 +104,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2478 2008/01/27 17:36:17 freddy77 Exp $ +$Id: ChangeLog,v 1.2479 2008/01/29 09:35:24 freddy77 Exp $ diff --git a/src/odbc/convert_tds2sql.c b/src/odbc/convert_tds2sql.c index 04e0b8a..f29df5b 100644 --- a/src/odbc/convert_tds2sql.c +++ b/src/odbc/convert_tds2sql.c @@ -39,7 +39,7 @@ #include #endif -TDS_RCSID(var, "$Id: convert_tds2sql.c,v 1.49 2007/05/25 09:10:10 freddy77 Exp $"); +TDS_RCSID(var, "$Id: convert_tds2sql.c,v 1.50 2008/01/29 09:35:24 freddy77 Exp $"); TDS_INT convert_tds2sql(TDSCONTEXT * context, int srctype, TDS_CHAR * src, TDS_UINT srclen, int desttype, TDS_CHAR * dest, SQLULEN destlen, @@ -56,7 +56,7 @@ convert_tds2sql(TDSCONTEXT * context, int srctype, TDS_CHAR * src, TDS_UINT srcl TIMESTAMP_STRUCT *tssp; SQL_NUMERIC_STRUCT *num; - int ret = TDS_FAIL; + int ret = TDS_CONVERT_FAIL; int i, cplen; tdsdump_log(TDS_DBG_FUNC, "convert_tds2sql: src is %d dest = %d\n", srctype, desttype); @@ -89,7 +89,7 @@ convert_tds2sql(TDSCONTEXT * context, int srctype, TDS_CHAR * src, TDS_UINT srcl } else { /* if destlen == 0 we return only length */ if (destlen != 0) - ret = TDS_FAIL; + ret = TDS_CONVERT_FAIL; } return ret; } @@ -143,7 +143,7 @@ convert_tds2sql(TDSCONTEXT * context, int srctype, TDS_CHAR * src, TDS_UINT srcl } else { /* if destlen == 0 we return only length */ if (destlen != 0) - ret = TDS_FAIL; + ret = TDS_CONVERT_FAIL; } break; diff --git a/src/odbc/odbc.c b/src/odbc/odbc.c index 937a8d7..b7b8235 100644 --- a/src/odbc/odbc.c +++ b/src/odbc/odbc.c @@ -60,7 +60,7 @@ #include #endif -TDS_RCSID(var, "$Id: odbc.c,v 1.469 2008/01/27 17:36:17 freddy77 Exp $"); +TDS_RCSID(var, "$Id: odbc.c,v 1.470 2008/01/29 09:35:25 freddy77 Exp $"); static SQLRETURN _SQLAllocConnect(SQLHENV henv, SQLHDBC FAR * phdbc); static SQLRETURN _SQLAllocEnv(SQLHENV FAR * phenv); @@ -3340,6 +3340,28 @@ odbc_process_tokens(TDS_STMT * stmt, unsigned flag) } } +static void +odbc_convert_err_set(struct _sql_errors *errs, TDS_INT err) +{ + switch (err) { + case TDS_CONVERT_NOAVAIL: + odbc_errs_add(errs, "HY003", NULL); + break; + case TDS_CONVERT_SYNTAX: + odbc_errs_add(errs, "22018", NULL); + break; + case TDS_CONVERT_OVERFLOW: + odbc_errs_add(errs, "22003", NULL); + break; + case TDS_CONVERT_FAIL: + odbc_errs_add(errs, "07006", NULL); + break; + case TDS_CONVERT_NOMEM: + odbc_errs_add(errs, "HY001", NULL); + break; + } +} + /* * - handle correctly SQLGetData (for forward cursors accept only row_size == 1 * for other types application must use SQLSetPos) @@ -3574,6 +3596,7 @@ _SQLFetch(TDS_STMT * stmt, SQLSMALLINT FetchOrientation, SQLLEN FetchOffset) len = convert_tds2sql(context, tds_get_conversion_type(colinfo->column_type, colinfo->column_size), src, srclen, c_type, data_ptr, drec_ard->sql_desc_octet_length, drec_ard); if (len < 0) { + odbc_convert_err_set(&stmt->errs, len); row_status = SQL_ROW_ERROR; break; } @@ -4596,10 +4619,19 @@ SQLGetData(SQLHSTMT hstmt, SQLUSMALLINT icol, SQLSMALLINT fCType, SQLPOINTER rgb nSybType = tds_get_conversion_type(colinfo->column_type, colinfo->column_size); if (fCType == SQL_C_DEFAULT) fCType = odbc_sql_to_c_type_default(stmt->ird->records[icol - 1].sql_desc_concise_type); + if (fCType == SQL_ARD_TYPE) { + if (icol > stmt->ard->header.sql_desc_count) { + odbc_errs_add(&stmt->errs, "07009", NULL); + ODBC_RETURN(stmt, SQL_ERROR); + } + fCType = stmt->ard->records[icol - 1].sql_desc_concise_type; + } assert(fCType); *pcbValue = convert_tds2sql(context, nSybType, src, srclen, fCType, (TDS_CHAR *) rgbValue, cbValueMax, NULL); - if (*pcbValue < 0) + if (*pcbValue < 0) { + odbc_convert_err_set(&stmt->errs, *pcbValue); ODBC_RETURN(stmt, SQL_ERROR); + } if (is_variable_type(colinfo->column_type) && (fCType == SQL_C_CHAR || fCType == SQL_C_BINARY)) { /* calc how many bytes was readed */ diff --git a/src/odbc/odbc_util.c b/src/odbc/odbc_util.c index 06a4d07..b5e5e7c 100644 --- a/src/odbc/odbc_util.c +++ b/src/odbc/odbc_util.c @@ -38,7 +38,7 @@ #include #endif -TDS_RCSID(var, "$Id: odbc_util.c,v 1.95 2008/01/21 15:34:32 freddy77 Exp $"); +TDS_RCSID(var, "$Id: odbc_util.c,v 1.96 2008/01/29 09:35:25 freddy77 Exp $"); /** * \ingroup odbc_api @@ -140,7 +140,7 @@ odbc_set_return_status(struct _hstmt *stmt, unsigned int n_row) len = convert_tds2sql(context, SYBINT4, (TDS_CHAR *) & tds->ret_status, sizeof(TDS_INT), drec->sql_desc_concise_type, (void *) data_ptr, drec->sql_desc_octet_length, NULL); - if (TDS_FAIL == len) + if (len < 0) return /* SQL_ERROR */ ; if (drec->sql_desc_indicator_ptr) LEN(drec->sql_desc_indicator_ptr) = 0; diff --git a/src/odbc/unittests/getdata.c b/src/odbc/unittests/getdata.c index eead6e0..1752423 100644 --- a/src/odbc/unittests/getdata.c +++ b/src/odbc/unittests/getdata.c @@ -1,15 +1,54 @@ #include "common.h" -static char software_version[] = "$Id: getdata.c,v 1.4 2007/08/07 09:20:32 freddy77 Exp $"; +static char software_version[] = "$Id: getdata.c,v 1.5 2008/01/29 09:35:25 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; +static char odbc_err[256]; +static char odbc_sqlstate[6]; + +static void +ReadError(void) +{ + memset(odbc_err, 0, sizeof(odbc_err)); + memset(odbc_sqlstate, 0, sizeof(odbc_sqlstate)); + if (!SQL_SUCCEEDED(SQLGetDiagRec(SQL_HANDLE_STMT, Statement, 1, (SQLCHAR *) odbc_sqlstate, NULL, (SQLCHAR *) odbc_err, sizeof(odbc_err), NULL))) { + printf("SQLGetDiagRec should not fail\n"); + exit(1); + } + printf("Message: '%s' %s\n", odbc_sqlstate, odbc_err); +} + +static void +test_err(const char *data, int c_type, const char *state) +{ + char sql[128]; + SQLRETURN rc; + SQLLEN ind; + const unsigned int buf_size = 128; + char *buf = (char *) malloc(buf_size); + + sprintf(sql, "SELECT '%s'", data); + Command(Statement, sql); + SQLFetch(Statement); + rc = SQLGetData(Statement, 1, c_type, buf, buf_size, &ind); + free(buf); + if (rc != SQL_ERROR) + ODBC_REPORT_ERROR("SQLGetData error expected"); + ReadError(); + if (strcmp(odbc_sqlstate, state) != 0) { + fprintf(stderr, "Unexpected sql state returned\n"); + Disconnect(); + exit(1); + } + ResetStatement(); +} + int main(int argc, char *argv[]) { char buf[16]; SQLINTEGER int_buf; SQLLEN len; - int ms_db = 0; Connect(); @@ -90,14 +129,24 @@ main(int argc, char *argv[]) ResetStatement(); - ms_db = db_is_microsoft(); - Disconnect(); - if (ms_db) { - use_odbc_version3 = 1; - Connect(); + use_odbc_version3 = 1; + Connect(); + /* test error from SQLGetData */ + /* wrong constant */ + test_err("prova 123", SQL_VARCHAR, "HY003"); + /* use ARD but no ARD data column */ + test_err("prova 123", SQL_ARD_TYPE, "07009"); + /* wrong conversion, int */ + test_err("prova 123", SQL_C_LONG, "22018"); + /* wrong conversion, int */ + test_err("prova 123", SQL_C_TIMESTAMP, "22018"); + /* overflow */ + test_err("1234567890123456789", SQL_C_LONG, "22003"); + + if (db_is_microsoft()) { Command(Statement, "SELECT CONVERT(TEXT,'')"); if (SQLFetch(Statement) != SQL_SUCCESS) @@ -114,10 +163,10 @@ main(int argc, char *argv[]) if (SQLGetData(Statement, 1, SQL_C_CHAR, buf, 1, NULL) != SQL_NO_DATA) ODBC_REPORT_ERROR("invalid return from SQLGetData"); - - Disconnect(); } + Disconnect(); + printf("Done.\n"); return 0; } commit 6b2f6d934757cb502817665692b1005b84331037 Author: freddy77 Date: Tue Jan 29 14:30:48 2008 +0000 reuse code diff --git a/ChangeLog b/ChangeLog index 09c3d0d..800bfc2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,27 @@ +Tue Jan 29 15:28:32 CET 2008 Frediano Ziglio + * src/odbc/unittests/array_out.c src/odbc/unittests/common.c: + * src/odbc/unittests/common.h src/odbc/unittests/compute.c: + * src/odbc/unittests/connect2.c src/odbc/unittests/const_params.c: + * src/odbc/unittests/copydesc.c src/odbc/unittests/cursor1.c: + * src/odbc/unittests/cursor2.c src/odbc/unittests/cursor3.c: + * src/odbc/unittests/cursor4.c src/odbc/unittests/cursor5.c: + * src/odbc/unittests/data.c src/odbc/unittests/date.c: + * src/odbc/unittests/error.c src/odbc/unittests/funccall.c: + * src/odbc/unittests/genparams.c src/odbc/unittests/getdata.c: + * src/odbc/unittests/hidden.c src/odbc/unittests/lang_error.c: + * src/odbc/unittests/moreandcount.c src/odbc/unittests/norowset.c: + * src/odbc/unittests/params.c src/odbc/unittests/prepare_results.c: + * src/odbc/unittests/print.c src/odbc/unittests/putdata.c: + * src/odbc/unittests/raiserror.c src/odbc/unittests/rebindpar.c: + * src/odbc/unittests/scroll.c src/odbc/unittests/t0001.c: + * src/odbc/unittests/t0002.c src/odbc/unittests/t0003.c: + * src/odbc/unittests/t0004.c src/odbc/unittests/tables.c: + * src/odbc/unittests/test64.c src/odbc/unittests/timeout.c: + * src/odbc/unittests/timeout2.c src/odbc/unittests/timeout4.c: + * src/odbc/unittests/transaction.c src/odbc/unittests/typeinfo.c: + * src/odbc/unittests/warning.c: + - reuse reuse reuse! + Tue Jan 29 10:34:41 CET 2008 Frediano Ziglio * src/odbc/convert_tds2sql.c src/odbc/odbc.c src/odbc/odbc_util.c: * src/odbc/unittests/getdata.c: @@ -104,4 +128,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2479 2008/01/29 09:35:24 freddy77 Exp $ +$Id: ChangeLog,v 1.2480 2008/01/29 14:30:48 freddy77 Exp $ diff --git a/src/odbc/unittests/array_out.c b/src/odbc/unittests/array_out.c index f99918d..1bbb852 100644 --- a/src/odbc/unittests/array_out.c +++ b/src/odbc/unittests/array_out.c @@ -3,7 +3,7 @@ /* Test using array binding */ -static char software_version[] = "$Id: array_out.c,v 1.11 2007/11/26 20:03:17 freddy77 Exp $"; +static char software_version[] = "$Id: array_out.c,v 1.12 2008/01/29 14:30:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static const char *test_query = NULL; @@ -74,9 +74,7 @@ query_test(SQLRETURN expected, const char *expected_status) SQLBindCol(Statement, 1, SQL_C_ULONG, &IDS(0), 0, &ID_LENS(0)); SQLBindCol(Statement, 2, SQL_C_CHAR, DESCS(0), desc_len, &DESC_LENS(0)); - ret = SQLExecDirect(Statement, (SQLCHAR *) test_query, SQL_NTS); - if (ret != SQL_SUCCESS) - ODBC_REPORT_ERROR("Invalid result"); + CHK(SQLExecDirect, (Statement, (SQLCHAR *) test_query, SQL_NTS)); ret = SQLFetch(Statement); if (ret != expected) diff --git a/src/odbc/unittests/common.c b/src/odbc/unittests/common.c index 0fde53d..78f58fe 100644 --- a/src/odbc/unittests/common.c +++ b/src/odbc/unittests/common.c @@ -12,7 +12,7 @@ #define TDS_SDIR_SEPARATOR "\\" #endif -static char software_version[] = "$Id: common.c,v 1.42 2007/12/27 10:22:18 freddy77 Exp $"; +static char software_version[] = "$Id: common.c,v 1.43 2008/01/29 14:30:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; HENV Environment; @@ -251,9 +251,8 @@ Command(HSTMT stmt, const char *command) printf("%s\n", command); result = SQLExecDirect(stmt, (SQLCHAR *) command, SQL_NTS); if (result != SQL_SUCCESS && result != SQL_NO_DATA) { - printf("Unable to execute statement\n"); + fprintf(stderr, "Unable to execute statement\n"); CheckReturn(); - exit(1); } } diff --git a/src/odbc/unittests/common.h b/src/odbc/unittests/common.h index 175b164..b74e162 100644 --- a/src/odbc/unittests/common.h +++ b/src/odbc/unittests/common.h @@ -21,7 +21,7 @@ #include #include -static char rcsid_common_h[] = "$Id: common.h,v 1.21 2007/12/21 10:39:10 freddy77 Exp $"; +static char rcsid_common_h[] = "$Id: common.h,v 1.22 2008/01/29 14:30:48 freddy77 Exp $"; static void *no_unused_common_h_warn[] = { rcsid_common_h, no_unused_common_h_warn }; #ifndef HAVE_SQLLEN @@ -56,6 +56,12 @@ void ResetStatement(void); void CheckCursor(void); #define ODBC_REPORT_ERROR(msg) ReportError(msg, __LINE__, __FILE__) + +#define CHK(func,params) \ + do { if (func params != SQL_SUCCESS) \ + ODBC_REPORT_ERROR(#func); \ + } while(0) + int Connect(void); int Disconnect(void); void Command(HSTMT stmt, const char *command); diff --git a/src/odbc/unittests/compute.c b/src/odbc/unittests/compute.c index dfa0f58..11c0548 100644 --- a/src/odbc/unittests/compute.c +++ b/src/odbc/unittests/compute.c @@ -9,7 +9,7 @@ * and declared in odbcss.h */ -static char software_version[] = "$Id: compute.c,v 1.9 2007/07/03 15:13:55 freddy77 Exp $"; +static char software_version[] = "$Id: compute.c,v 1.10 2008/01/29 14:30:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static char col1[256], col2[256]; @@ -23,12 +23,9 @@ TestName(SQLSMALLINT index, const char *expected_name) char name[128]; char buf[256]; SQLSMALLINT len, type; - SQLRETURN rc; #define NAME_TEST \ do { \ - if (rc != SQL_SUCCESS) \ - ODBC_REPORT_ERROR("SQLDescribeCol failed"); \ if (strcmp(name, expected_name) != 0) \ { \ sprintf(buf, "line %d: wrong name in column %d expected '%s' got '%s'", \ @@ -38,14 +35,14 @@ TestName(SQLSMALLINT index, const char *expected_name) } while(0) /* retrieve with SQLDescribeCol */ - rc = SQLDescribeCol(Statement, index, (SQLCHAR *) name, sizeof(name), &len, &type, NULL, NULL, NULL); + CHK(SQLDescribeCol, (Statement, index, (SQLCHAR *) name, sizeof(name), &len, &type, NULL, NULL, NULL)); NAME_TEST; /* retrieve with SQLColAttribute */ - rc = SQLColAttribute(Statement, index, SQL_DESC_NAME, name, sizeof(name), &len, NULL); + CHK(SQLColAttribute, (Statement, index, SQL_DESC_NAME, name, sizeof(name), &len, NULL)); if (db_is_microsoft()) NAME_TEST; - rc = SQLColAttribute(Statement, index, SQL_DESC_LABEL, name, sizeof(name), &len, NULL); + CHK(SQLColAttribute, (Statement, index, SQL_DESC_LABEL, name, sizeof(name), &len, NULL)); NAME_TEST; } @@ -56,8 +53,7 @@ CheckFetch(const char *c1name, const char *c1, const char *c2) TestName(1, c1name); - if (SQLFetch(Statement) != SQL_SUCCESS) - ODBC_REPORT_ERROR("error fetching"); + CHK(SQLFetch, (Statement)); if (strlen(c1) != ind1 || strcmp(c1, col1) != 0) { fprintf(stderr, "%s:%d: Column 1 error '%s' (%d) expected '%s' (%d)\n", __FILE__, main_line, col1, (int) ind1, c1, @@ -107,8 +103,7 @@ main(int argc, char *argv[]) CheckFetch("c", "pluto", "3"); if (SQLFetch(Statement) != SQL_NO_DATA) ODBC_REPORT_ERROR("Still data ??"); - if (SQLMoreResults(Statement) != SQL_SUCCESS) - ODBC_REPORT_ERROR("No more data ??"); + CHK(SQLMoreResults, (Statement)); /* why I need to rebind ?? ms bug of feature ?? */ SQLBindCol(Statement, 1, SQL_C_CHAR, col1, sizeof(col1), &ind1); @@ -131,8 +126,7 @@ main(int argc, char *argv[]) CheckFetch("mao", "pippo", "34"); if (SQLFetch(Statement) != SQL_NO_DATA) ODBC_REPORT_ERROR("Still data ??"); - if (SQLMoreResults(Statement) != SQL_SUCCESS) - ODBC_REPORT_ERROR("No more data ??"); + CHK(SQLMoreResults, (Statement)); SQLBindCol(Statement, 1, SQL_C_CHAR, col1, sizeof(col1), &ind1); SQLBindCol(Statement, 2, SQL_C_CHAR, col2, sizeof(col2), &ind2); @@ -140,8 +134,7 @@ main(int argc, char *argv[]) CheckFetch("sum", "46", "##"); if (SQLFetch(Statement) != SQL_NO_DATA) ODBC_REPORT_ERROR("Still data ??"); - if (SQLMoreResults(Statement) != SQL_SUCCESS) - ODBC_REPORT_ERROR("No more data ??"); + CHK(SQLMoreResults, (Statement)); SQLBindCol(Statement, 1, SQL_C_CHAR, col1, sizeof(col1), &ind1); SQLBindCol(Statement, 2, SQL_C_CHAR, col2, sizeof(col2), &ind2); @@ -150,8 +143,7 @@ main(int argc, char *argv[]) CheckFetch("mao", "pluto", "3"); if (SQLFetch(Statement) != SQL_NO_DATA) ODBC_REPORT_ERROR("Still data ??"); - if (SQLMoreResults(Statement) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Still data ??"); + CHK(SQLMoreResults, (Statement)); SQLBindCol(Statement, 1, SQL_C_CHAR, col1, sizeof(col1), &ind1); SQLBindCol(Statement, 2, SQL_C_CHAR, col2, sizeof(col2), &ind2); @@ -159,8 +151,7 @@ main(int argc, char *argv[]) CheckFetch("sum", "6", "%"); if (SQLFetch(Statement) != SQL_NO_DATA) ODBC_REPORT_ERROR("Still data ??"); - if (SQLMoreResults(Statement) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Still data ??"); + CHK(SQLMoreResults, (Statement)); SQLBindCol(Statement, 1, SQL_C_CHAR, col1, sizeof(col1), &ind1); SQLBindCol(Statement, 2, SQL_C_CHAR, col2, sizeof(col2), &ind2); @@ -182,21 +173,17 @@ main(int argc, char *argv[]) CheckFetch("c", "pippo", "34"); if (SQLFetch(Statement) != SQL_NO_DATA) ODBC_REPORT_ERROR("Still data ??"); - if (SQLMoreResults(Statement) != SQL_SUCCESS) - ODBC_REPORT_ERROR("No more data ??"); + CHK(SQLMoreResults, (Statement)); /* here just skip results, before a row */ - if (SQLMoreResults(Statement) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Still data ??"); - + CHK(SQLMoreResults, (Statement)); SQLBindCol(Statement, 1, SQL_C_CHAR, col1, sizeof(col1), &ind1); SQLBindCol(Statement, 2, SQL_C_CHAR, col2, sizeof(col2), &ind2); CheckFetch("c", "pluto", "2"); if (SQLFetch(Statement) != SQL_NO_DATA) ODBC_REPORT_ERROR("Still data ??"); - if (SQLMoreResults(Statement) != SQL_SUCCESS) - ODBC_REPORT_ERROR("No more data ??"); + CHK(SQLMoreResults, (Statement)); /* here just skip results, before done */ if (SQLMoreResults(Statement) != SQL_NO_DATA) diff --git a/src/odbc/unittests/connect2.c b/src/odbc/unittests/connect2.c index c7f01a9..0f00546 100644 --- a/src/odbc/unittests/connect2.c +++ b/src/odbc/unittests/connect2.c @@ -5,7 +5,7 @@ * either SQLConnect and SQLDriverConnect */ -static char software_version[] = "$Id: connect2.c,v 1.4 2007/04/12 07:49:30 freddy77 Exp $"; +static char software_version[] = "$Id: connect2.c,v 1.5 2008/01/29 14:30:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static int failed = 0; @@ -35,7 +35,6 @@ normal_connect(void) if (!SQL_SUCCEEDED(res)) { fprintf(stderr, "Unable to open data source (ret=%d)\n", res); CheckReturn(); - exit(1); } } @@ -50,7 +49,6 @@ driver_connect(const char *conn_str) if (!SQL_SUCCEEDED(res)) { fprintf(stderr, "Unable to open data source (ret=%d)\n", res); CheckReturn(); - exit(1); } } @@ -66,7 +64,6 @@ check_dbname(const char *dbname) if (!SQL_SUCCEEDED(res)) { fprintf(stderr, "Unable to get database name to %s\n", dbname); CheckReturn(); - exit(1); } if (strcmp(out, dbname) != 0) { @@ -84,7 +81,6 @@ set_dbname(const char *dbname) if (!SQL_SUCCEEDED(res)) { fprintf(stderr, "Unable to set database name to %s\n", dbname); CheckReturn(); - exit(1); } } diff --git a/src/odbc/unittests/const_params.c b/src/odbc/unittests/const_params.c index a9fabfe..a1482e1 100644 --- a/src/odbc/unittests/const_params.c +++ b/src/odbc/unittests/const_params.c @@ -2,7 +2,7 @@ /* Test for {?=call store(?,123,'foo')} syntax and run */ -static char software_version[] = "$Id: const_params.c,v 1.13 2007/11/26 06:25:11 freddy77 Exp $"; +static char software_version[] = "$Id: const_params.c,v 1.14 2008/01/29 14:30:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; int @@ -26,22 +26,17 @@ main(int argc, char *argv[]) " return 24680\n" "end"); - if (SQLBindParameter(Statement, 1, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &input, 0, &ind) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to bind input parameter"); + CHK(SQLBindParameter, (Statement, 1, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &input, 0, &ind)); - if (SQLBindParameter(Statement, 2, SQL_PARAM_OUTPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &out1, 0, &ind2) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to bind output parameter"); + CHK(SQLBindParameter, (Statement, 2, SQL_PARAM_OUTPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &out1, 0, &ind2)); /* TODO use {ts ...} for date */ - if (SQLPrepare(Statement, (SQLCHAR *) "{call const_param(?, 13579, '2004-10-15 12:09:08', 'foo', ?)}", SQL_NTS) != - SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to prepare statement"); + CHK(SQLPrepare, (Statement, (SQLCHAR *) "{call const_param(?, 13579, '2004-10-15 12:09:08', 'foo', ?)}", SQL_NTS)); input = 13579; ind = sizeof(input); out1 = output = 0xdeadbeef; - if (SQLExecute(Statement) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to execute statement"); + CHK(SQLExecute, (Statement)); if (out1 != 7654321) { fprintf(stderr, "Invalid output %d (0x%x)\n", (int) out1, (int) out1); @@ -51,25 +46,17 @@ main(int argc, char *argv[]) /* just to reset some possible buffers */ Command(Statement, "DECLARE @i INT"); - if (SQLBindParameter(Statement, 1, SQL_PARAM_OUTPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &output, 0, &ind) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to bind output parameter"); - - if (SQLBindParameter(Statement, 2, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &input, 0, &ind2) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to bind input parameter"); - - if (SQLBindParameter(Statement, 3, SQL_PARAM_OUTPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &out1, 0, &ind3) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to bind output parameter"); + CHK(SQLBindParameter, (Statement, 1, SQL_PARAM_OUTPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &output, 0, &ind)); + CHK(SQLBindParameter, (Statement, 2, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &input, 0, &ind2)); + CHK(SQLBindParameter, (Statement, 3, SQL_PARAM_OUTPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &out1, 0, &ind3)); /* TODO use {ts ...} for date */ - if (SQLPrepare(Statement, (SQLCHAR *) "{?=call const_param(?, , '2004-10-15 12:09:08', 'foo', ?)}", SQL_NTS) != - SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to prepare statement"); + CHK(SQLPrepare, (Statement, (SQLCHAR *) "{?=call const_param(?, , '2004-10-15 12:09:08', 'foo', ?)}", SQL_NTS)); input = 13579; ind2 = sizeof(input); out1 = output = 0xdeadbeef; - if (SQLExecute(Statement) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to execute statement"); + CHK(SQLExecute, (Statement)); if (out1 != 7654321) { fprintf(stderr, "Invalid output %d (0x%x)\n", (int) out1, (int) out1); @@ -81,8 +68,7 @@ main(int argc, char *argv[]) exit(1); } - if (CommandWithResult(Statement, "drop proc const_param") != SQL_SUCCESS) - printf("Unable to execute statement\n"); + Command(Statement, "IF OBJECT_ID('const_param') IS NOT NULL DROP PROC const_param"); Command(Statement, "create proc const_param @in1 float, @in2 varbinary(100) as\n" "begin\n" @@ -91,24 +77,19 @@ main(int argc, char *argv[]) " return 54321\n" "end"); - if (SQLBindParameter(Statement, 1, SQL_PARAM_OUTPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &output, 0, &ind) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to bind output parameter"); + CHK(SQLBindParameter, (Statement, 1, SQL_PARAM_OUTPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &output, 0, &ind)); - if (SQLPrepare(Statement, (SQLCHAR *) "{?=call const_param(12.5, 0x0102030405060708)}", SQL_NTS) != - SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to prepare statement"); + CHK(SQLPrepare, (Statement, (SQLCHAR *) "{?=call const_param(12.5, 0x0102030405060708)}", SQL_NTS)); output = 0xdeadbeef; - if (SQLExecute(Statement) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to execute statement"); + CHK(SQLExecute, (Statement)); if (output != 54321) { fprintf(stderr, "Invalid result %d (0x%x) expected 54321\n", (int) output, (int) output); return 1; } - if (CommandWithResult(Statement, "drop proc const_param") != SQL_SUCCESS) - printf("Unable to execute statement\n"); + Command(Statement, "drop proc const_param"); Command(Statement, "create proc const_param @in varchar(20) as\n" "begin\n" @@ -119,7 +100,7 @@ main(int argc, char *argv[]) /* catch problem reported by Peter Deacon */ output = 0xdeadbeef; Command(Statement, "{CALL const_param('value')}"); - SQLBindCol(Statement, 1, SQL_C_SLONG, &output, 0, &ind); + CHK(SQLBindCol, (Statement, 1, SQL_C_SLONG, &output, 0, &ind)); SQLFetch(Statement); if (output != 8421) { @@ -129,8 +110,7 @@ main(int argc, char *argv[]) ResetStatement(); - if (CommandWithResult(Statement, "drop proc const_param") != SQL_SUCCESS) - printf("Unable to execute statement\n"); + Command(Statement, "drop proc const_param"); Disconnect(); diff --git a/src/odbc/unittests/copydesc.c b/src/odbc/unittests/copydesc.c index a92d2d9..75380bc 100644 --- a/src/odbc/unittests/copydesc.c +++ b/src/odbc/unittests/copydesc.c @@ -2,7 +2,7 @@ /* Test SQLCopyDesc and SQLAllocHandle(SQL_HANDLE_DESC) */ -static char software_version[] = "$Id: copydesc.c,v 1.3 2007/04/12 07:49:30 freddy77 Exp $"; +static char software_version[] = "$Id: copydesc.c,v 1.4 2008/01/29 14:30:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; int @@ -15,24 +15,20 @@ main(int argc, char *argv[]) Connect(); - if (SQLGetStmtAttr(Statement, SQL_ATTR_APP_ROW_DESC, &ard, 0, NULL) != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLGetStmtAttr"); + CHK(SQLGetStmtAttr, (Statement, SQL_ATTR_APP_ROW_DESC, &ard, 0, NULL)); - SQLBindCol(Statement, 1, SQL_C_SLONG, &id, sizeof(SQLINTEGER), &ind1); - SQLBindCol(Statement, 2, SQL_C_CHAR, name, sizeof(name), &ind2); + CHK(SQLBindCol, (Statement, 1, SQL_C_SLONG, &id, sizeof(SQLINTEGER), &ind1)); + CHK(SQLBindCol, (Statement, 2, SQL_C_CHAR, name, sizeof(name), &ind2)); - if (SQLAllocHandle(SQL_HANDLE_DESC, Connection, &ard2) != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLAllocHandle"); + CHK(SQLAllocHandle, (SQL_HANDLE_DESC, Connection, &ard2)); /* * this is an additional test to test additional allocation * As of 0.64 for a bug in SQLAllocDesc we only allow to allocate one */ - if (SQLAllocHandle(SQL_HANDLE_DESC, Connection, &ard3) != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLAllocHandle"); + CHK(SQLAllocHandle, (SQL_HANDLE_DESC, Connection, &ard3)); - if (SQLCopyDesc(ard, ard2) != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLCopyDesc"); + CHK(SQLCopyDesc, (ard, ard2)); Disconnect(); diff --git a/src/odbc/unittests/cursor1.c b/src/odbc/unittests/cursor1.c index d10e777..28e4609 100644 --- a/src/odbc/unittests/cursor1.c +++ b/src/odbc/unittests/cursor1.c @@ -2,14 +2,9 @@ /* Test cursors */ -static char software_version[] = "$Id: cursor1.c,v 1.12 2007/11/26 06:25:11 freddy77 Exp $"; +static char software_version[] = "$Id: cursor1.c,v 1.13 2008/01/29 14:30:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; -#define CHK(func,params) \ - do { if (func params != SQL_SUCCESS) \ - ODBC_REPORT_ERROR(#func); \ - } while(0) - #define CHK_INFO(func,params) \ do { if (!SQL_SUCCEEDED(func params)) \ ODBC_REPORT_ERROR(#func); \ @@ -145,11 +140,7 @@ Test0(int use_sql, const char *create_sql, const char *insert_sql, const char *s exit(1); } - retcode = SQLGetDiagRec(SQL_HANDLE_STMT, Statement, 1, sqlstate, NULL, msg, sizeof(msg), NULL); - if (retcode != SQL_SUCCESS) { - fprintf(stderr, "Error not expected at line %d\n", __LINE__); - exit(1); - } + CHK(SQLGetDiagRec, (SQL_HANDLE_STMT, Statement, 1, sqlstate, NULL, msg, sizeof(msg), NULL)); if (strstr((char *) msg, "Invalid column name 'c'") == NULL) { fprintf(stderr, "Expected message not found at line %d\n", __LINE__); exit(1); diff --git a/src/odbc/unittests/cursor2.c b/src/odbc/unittests/cursor2.c index d5fd48d..ac1d1db 100644 --- a/src/odbc/unittests/cursor2.c +++ b/src/odbc/unittests/cursor2.c @@ -2,13 +2,9 @@ /* Test cursor do not give error for statement that do not return rows */ -static char software_version[] = "$Id: cursor2.c,v 1.3 2007/04/20 13:27:14 freddy77 Exp $"; +static char software_version[] = "$Id: cursor2.c,v 1.4 2008/01/29 14:30:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; -#define CHK(func,params) \ - if (func params != SQL_SUCCESS) \ - ODBC_REPORT_ERROR(#func) - int main(int argc, char *argv[]) { diff --git a/src/odbc/unittests/cursor3.c b/src/odbc/unittests/cursor3.c index d44fe3c..6ef62c8 100644 --- a/src/odbc/unittests/cursor3.c +++ b/src/odbc/unittests/cursor3.c @@ -1,11 +1,9 @@ /* Tests 2 active statements */ #include "common.h" -static char software_version[] = "$Id: cursor3.c,v 1.4 2008/01/10 15:29:03 freddy77 Exp $"; +static char software_version[] = "$Id: cursor3.c,v 1.5 2008/01/29 14:30:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; -static SQLHDBC m_hdbc; - #define CHECK_RCODE(t,h,m) \ if ( rcode != SQL_NO_DATA \ && rcode != SQL_SUCCESS \ @@ -43,7 +41,7 @@ exec_direct(int check, const char *stmt) SQLRETURN rcode; SQLHSTMT stmth = 0; - rcode = SQLAllocHandle(SQL_HANDLE_STMT, (SQLHANDLE) m_hdbc, (SQLHANDLE *) & stmth); + rcode = SQLAllocHandle(SQL_HANDLE_STMT, (SQLHANDLE) Connection, (SQLHANDLE *) & stmth); CHECK_RCODE(SQL_HANDLE_STMT, stmth, "SQLAllocHandle"); rcode = SQLExecDirect(stmth, (SQLCHAR *) stmt, SQL_NTS); if (check) { @@ -67,8 +65,6 @@ main(int argc, char **argv) CheckCursor(); - m_hdbc = Connection; - exec_direct(1, "CREATE TABLE #t1 ( k INT, c VARCHAR(20))"); exec_direct(1, "INSERT INTO #t1 VALUES (1, 'aaa')"); exec_direct(1, "INSERT INTO #t1 VALUES (2, 'bbbbb')"); @@ -76,12 +72,12 @@ main(int argc, char **argv) exec_direct(1, "INSERT INTO #t1 VALUES (4, 'dd')"); m_hstmt1 = NULL; - rcode = SQLAllocHandle(SQL_HANDLE_STMT, m_hdbc, &m_hstmt1); - CHECK_RCODE(SQL_HANDLE_DBC, m_hdbc, "SQLAllocHandle 1"); + rcode = SQLAllocHandle(SQL_HANDLE_STMT, Connection, &m_hstmt1); + CHECK_RCODE(SQL_HANDLE_DBC, Connection, "SQLAllocHandle 1"); m_hstmt2 = NULL; - rcode = SQLAllocHandle(SQL_HANDLE_STMT, m_hdbc, &m_hstmt2); - CHECK_RCODE(SQL_HANDLE_DBC, m_hdbc, "SQLAllocHandle 2"); + rcode = SQLAllocHandle(SQL_HANDLE_STMT, Connection, &m_hstmt2); + CHECK_RCODE(SQL_HANDLE_DBC, Connection, "SQLAllocHandle 2"); /* rcode = SQLSetStmtAttr(m_hstmt1, SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_NONSCROLLABLE, SQL_IS_UINTEGER); diff --git a/src/odbc/unittests/cursor4.c b/src/odbc/unittests/cursor4.c index ef67014..363ebfd 100755 --- a/src/odbc/unittests/cursor4.c +++ b/src/odbc/unittests/cursor4.c @@ -5,11 +5,9 @@ #include "common.h" -static char software_version[] = "$Id: cursor4.c,v 1.4 2008/01/10 15:29:03 freddy77 Exp $"; +static char software_version[] = "$Id: cursor4.c,v 1.5 2008/01/29 14:30:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; -static SQLHDBC m_hdbc; - #define CHECK_RCODE(t,h,m) \ if ( rcode != SQL_NO_DATA \ && rcode != SQL_SUCCESS \ @@ -47,7 +45,7 @@ exec_direct(int check, const char *stmt) SQLRETURN rcode; SQLHSTMT stmth = 0; - rcode = SQLAllocHandle(SQL_HANDLE_STMT, (SQLHANDLE) m_hdbc, (SQLHANDLE *) & stmth); + rcode = SQLAllocHandle(SQL_HANDLE_STMT, (SQLHANDLE) Connection, (SQLHANDLE *) & stmth); CHECK_RCODE(SQL_HANDLE_STMT, stmth, "SQLAllocHandle"); rcode = SQLExecDirect(stmth, (SQLCHAR *) stmt, SQL_NTS); if (check) { @@ -70,14 +68,12 @@ main(int argc, char **argv) CheckCursor(); - m_hdbc = Connection; - exec_direct(1, "CREATE TABLE #t1 ( k INT, c VARCHAR(20))"); exec_direct(1, "INSERT INTO #t1 VALUES (1, 'aaa')"); m_hstmt1 = NULL; - rcode = SQLAllocHandle(SQL_HANDLE_STMT, m_hdbc, &m_hstmt1); - CHECK_RCODE(SQL_HANDLE_DBC, m_hdbc, "SQLAllocHandle 1"); + rcode = SQLAllocHandle(SQL_HANDLE_STMT, Connection, &m_hstmt1); + CHECK_RCODE(SQL_HANDLE_DBC, Connection, "SQLAllocHandle 1"); rcode = SQLSetStmtAttr(m_hstmt1, SQL_ATTR_CONCURRENCY, (SQLPOINTER) SQL_CONCUR_LOCK, SQL_IS_UINTEGER); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "Set attribute SQL_ATTR_CONCURRENCY"); diff --git a/src/odbc/unittests/cursor5.c b/src/odbc/unittests/cursor5.c index 53f380b..d8c4540 100755 --- a/src/odbc/unittests/cursor5.c +++ b/src/odbc/unittests/cursor5.c @@ -1,6 +1,6 @@ #include "common.h" -static char software_version[] = "$Id: cursor5.c,v 1.3 2008/01/10 15:29:03 freddy77 Exp $"; +static char software_version[] = "$Id: cursor5.c,v 1.4 2008/01/29 14:30:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #define CHECK_RCODE(t,h,m) \ @@ -56,25 +56,23 @@ int main(int argc, char **argv) { SQLRETURN rcode; - SQLHDBC m_hdbc; SQLHSTMT m_hstmt1; SQLHSTMT m_hstmt2; use_odbc_version3 = 1; Connect(); CheckCursor(); - m_hdbc = Connection; - rcode = SQLSetConnectAttr(m_hdbc, SQL_ATTR_AUTOCOMMIT, (SQLPOINTER) SQL_AUTOCOMMIT_ON, SQL_IS_UINTEGER); - CHECK_RCODE(SQL_HANDLE_ENV, m_hdbc, "SQLSetConnectAttr(autocommit)"); + rcode = SQLSetConnectAttr(Connection, SQL_ATTR_AUTOCOMMIT, (SQLPOINTER) SQL_AUTOCOMMIT_ON, SQL_IS_UINTEGER); + CHECK_RCODE(SQL_HANDLE_ENV, Connection, "SQLSetConnectAttr(autocommit)"); m_hstmt1 = NULL; - rcode = SQLAllocHandle(SQL_HANDLE_STMT, m_hdbc, &m_hstmt1); - CHECK_RCODE(SQL_HANDLE_DBC, m_hdbc, "SQLAllocHandle StmtH 1"); + rcode = SQLAllocHandle(SQL_HANDLE_STMT, Connection, &m_hstmt1); + CHECK_RCODE(SQL_HANDLE_DBC, Connection, "SQLAllocHandle StmtH 1"); m_hstmt2 = NULL; - rcode = SQLAllocHandle(SQL_HANDLE_STMT, m_hdbc, &m_hstmt2); - CHECK_RCODE(SQL_HANDLE_DBC, m_hdbc, "SQLAllocHandle StmtH 2"); + rcode = SQLAllocHandle(SQL_HANDLE_STMT, Connection, &m_hstmt2); + CHECK_RCODE(SQL_HANDLE_DBC, Connection, "SQLAllocHandle StmtH 2"); rcode = SQLExecDirect(m_hstmt1, (SQLCHAR *) "create table #mytab1 (k int, c char(30))", SQL_NTS); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLExecDirect 1.1"); diff --git a/src/odbc/unittests/data.c b/src/odbc/unittests/data.c index 7b60d86..640510e 100644 --- a/src/odbc/unittests/data.c +++ b/src/odbc/unittests/data.c @@ -3,7 +3,7 @@ /* Test various bind type */ -static char software_version[] = "$Id: data.c,v 1.13 2007/06/21 07:21:21 freddy77 Exp $"; +static char software_version[] = "$Id: data.c,v 1.14 2008/01/29 14:30:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static int result = 0; @@ -24,10 +24,7 @@ Test(const char *type, const char *value_to_convert, SQLSMALLINT out_c_type, con sprintf(sbuf, "SELECT CONVERT(%s, '%s') AS data", type, value_to_convert); Command(Statement, sbuf); SQLBindCol(Statement, 1, out_c_type, out_buf, sizeof(out_buf), &out_len); - if (SQLFetch(Statement) != SQL_SUCCESS) { - fprintf(stderr, "Expected row\n"); - exit(1); - } + CHK(SQLFetch, (Statement)); if (SQLFetch(Statement) != SQL_NO_DATA) { fprintf(stderr, "Row not expected\n"); exit(1); diff --git a/src/odbc/unittests/date.c b/src/odbc/unittests/date.c index 320e8b1..a37360f 100644 --- a/src/odbc/unittests/date.c +++ b/src/odbc/unittests/date.c @@ -1,7 +1,7 @@ #include "common.h" -static char software_version[] = "$Id: date.c,v 1.9 2004/10/28 13:16:18 freddy77 Exp $"; +static char software_version[] = "$Id: date.c,v 1.10 2008/01/29 14:30:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static void @@ -18,35 +18,25 @@ DoTest(int n) TIMESTAMP_STRUCT ts; - if (CommandWithResult(Statement, "select convert(datetime, '2002-12-27 18:43:21')") != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to execute statement"); + Command(Statement, "select convert(datetime, '2002-12-27 18:43:21')"); res = SQLFetch(Statement); if (res != SQL_SUCCESS && res != SQL_SUCCESS_WITH_INFO) ODBC_REPORT_ERROR("Unable to fetch row"); - if (SQLDescribeCol(Statement, 1, output, sizeof(output), NULL, &colType, &colSize, &colScale, &colNullable) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Error getting data"); + CHK(SQLDescribeCol, (Statement, 1, output, sizeof(output), NULL, &colType, &colSize, &colScale, &colNullable)); if (n == 0) { memset(&ts, 0, sizeof(ts)); - if (SQLGetData(Statement, 1, SQL_C_TIMESTAMP, &ts, sizeof(ts), &dataSize) != SQL_SUCCESS) { - printf("Unable to get data col %d\n", 1); - CheckReturn(); - exit(1); - } + CHK(SQLGetData, (Statement, 1, SQL_C_TIMESTAMP, &ts, sizeof(ts), &dataSize)); sprintf((char *) output, "%04d-%02d-%02d %02d:%02d:%02d.000", ts.year, ts.month, ts.day, ts.hour, ts.minute, ts.second); } else { - if (SQLGetData(Statement, 1, SQL_C_CHAR, output, sizeof(output), &dataSize) != SQL_SUCCESS) { - printf("Unable to get data col %d\n", 1); - CheckReturn(); - exit(1); - } + CHK(SQLGetData, (Statement, 1, SQL_C_CHAR, output, sizeof(output), &dataSize)); } printf("Date returned: %s\n", output); if (strcmp((char *) output, "2002-12-27 18:43:21.000") != 0) { - printf("Invalid returned date\n"); + fprintf(stderr, "Invalid returned date\n"); exit(1); } diff --git a/src/odbc/unittests/error.c b/src/odbc/unittests/error.c index 125d002..d8cffb2 100644 --- a/src/odbc/unittests/error.c +++ b/src/odbc/unittests/error.c @@ -2,7 +2,7 @@ /* some tests on error reporting */ -static char software_version[] = "$Id: error.c,v 1.3 2004/05/22 17:25:27 freddy77 Exp $"; +static char software_version[] = "$Id: error.c,v 1.4 2008/01/29 14:30:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static SQLCHAR output[256]; @@ -45,17 +45,15 @@ main(int argc, char *argv[]) /* TODO when multiple row fetch available test for error on some columns */ - if (SQLFetch(Statement) != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLFetch failed when it shouldn't"); - if (SQLFetch(Statement) != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLFetch failed when it shouldn't"); + CHK(SQLFetch, (Statement)); + CHK(SQLFetch, (Statement)); if (SQLFetch(Statement) != SQL_ERROR) ODBC_REPORT_ERROR("SQLFetch succeed when it shouldn't"); } ReadError(); if (!strstr((char *) output, "zero")) { - printf("Message invalid\n"); + fprintf(stderr, "Message invalid\n"); return 1; } @@ -64,8 +62,7 @@ main(int argc, char *argv[]) SQLFetch(Statement); SQLMoreResults(Statement); - if (SQLAllocStmt(Connection, &stmt) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to allocate statement"); + CHK(SQLAllocStmt, (Connection, &stmt)); Command(Statement, "SELECT * FROM sysobjects"); diff --git a/src/odbc/unittests/funccall.c b/src/odbc/unittests/funccall.c index 0773818..bf80de9 100644 --- a/src/odbc/unittests/funccall.c +++ b/src/odbc/unittests/funccall.c @@ -2,7 +2,7 @@ /* Test for {?=call store(?)} syntax and run */ -static char software_version[] = "$Id: funccall.c,v 1.14 2007/04/12 13:36:14 freddy77 Exp $"; +static char software_version[] = "$Id: funccall.c,v 1.15 2008/01/29 14:30:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; int @@ -15,29 +15,20 @@ main(int argc, char *argv[]) Connect(); - if (CommandWithResult(Statement, "drop proc simpleresult") != SQL_SUCCESS) - printf("Unable to execute statement\n"); + Command(Statement, "IF OBJECT_ID('simpleresult') IS NOT NULL DROP PROC simpleresult"); Command(Statement, "create proc simpleresult @i int as begin return @i end"); - if (SQLBindParameter(Statement, 2, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &input, 0, &ind2) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to bind input parameter"); + CHK(SQLBindParameter, (Statement, 2, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &input, 0, &ind2)); - if (SQLBindParameter(Statement, 1, SQL_PARAM_OUTPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &output, 0, &ind) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to bind output parameter"); + CHK(SQLBindParameter, (Statement, 1, SQL_PARAM_OUTPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &output, 0, &ind)); - if (SQLPrepare(Statement, (SQLCHAR *) "{ \n?\t\r= call simpleresult(?)}", SQL_NTS) != SQL_SUCCESS) { - printf("Unable to prepare statement\n"); - exit(1); - } + CHK(SQLPrepare, (Statement, (SQLCHAR *) "{ \n?\t\r= call simpleresult(?)}", SQL_NTS)); input = 123; ind2 = sizeof(input); output = 0xdeadbeef; - if (SQLExecute(Statement) != SQL_SUCCESS) { - printf("Unable to execute statement\n"); - exit(1); - } + CHK(SQLExecute, (Statement)); if (output != 123) { printf("Invalid result\n"); @@ -57,26 +48,22 @@ main(int argc, char *argv[]) input = 567; ind2 = sizeof(input); output = 0xdeadbeef; - if (SQLExecDirect(Statement, (SQLCHAR *) "{?=call simpleresult(?)}", SQL_NTS) != SQL_SUCCESS) { - printf("Unable to execure direct statement\n"); - exit(1); - } + CHK(SQLExecDirect, (Statement, (SQLCHAR *) "{?=call simpleresult(?)}", SQL_NTS)); if (output != 567) { - printf("Invalid result\n"); + fprintf(stderr, "Invalid result\n"); exit(1); } /* should return "Invalid cursor state" */ if (SQLFetch(Statement) != SQL_ERROR) { - printf("Data not expected\n"); + fprintf(stderr, "Data not expected\n"); exit(1); } Command(Statement, "drop proc simpleresult"); - if (CommandWithResult(Statement, "drop proc simpleresult2") != SQL_SUCCESS) - printf("Unable to execute statement\n"); + Command(Statement, "IF OBJECT_ID('simpleresult2') IS NOT NULL DROP PROC simpleresult2"); /* force cursor close */ SQLCloseCursor(Statement); @@ -85,31 +72,12 @@ main(int argc, char *argv[]) Command(Statement, "create proc simpleresult2 @i int, @x int output, @y varchar(20) output as begin select @x = 6789 select @y = 'test foo' return @i end"); - if (SQLBindParameter(Statement, 1, SQL_PARAM_OUTPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &output, 0, &ind) != SQL_SUCCESS) { - printf("Unable to bind output parameter\n"); - exit(1); - } + CHK(SQLBindParameter, (Statement, 1, SQL_PARAM_OUTPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &output, 0, &ind)); + CHK(SQLBindParameter, (Statement, 2, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &input, 0, &ind2)); + CHK(SQLBindParameter, (Statement, 3, SQL_PARAM_OUTPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &out1, 0, &ind3)); + CHK(SQLBindParameter, (Statement, 4, SQL_PARAM_OUTPUT, SQL_C_CHAR, SQL_VARCHAR, 20, 0, out2, sizeof(out2), &ind4)); - if (SQLBindParameter(Statement, 2, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &input, 0, &ind2) != SQL_SUCCESS) { - printf("Unable to bind input parameter\n"); - exit(1); - } - - if (SQLBindParameter(Statement, 3, SQL_PARAM_OUTPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &out1, 0, &ind3) != SQL_SUCCESS) { - printf("Unable to bind output parameter\n"); - exit(1); - } - - if (SQLBindParameter(Statement, 4, SQL_PARAM_OUTPUT, SQL_C_CHAR, SQL_VARCHAR, 20, 0, out2, sizeof(out2), &ind4) != - SQL_SUCCESS) { - printf("Unable to bind output parameter\n"); - exit(1); - } - - if (SQLPrepare(Statement, (SQLCHAR *) "{ \n?\t\r= call simpleresult2(?,?,?)}", SQL_NTS) != SQL_SUCCESS) { - printf("Unable to prepare statement\n"); - exit(1); - } + CHK(SQLPrepare, (Statement, (SQLCHAR *) "{ \n?\t\r= call simpleresult2(?,?,?)}", SQL_NTS)); input = 987; ind2 = sizeof(input); @@ -117,10 +85,7 @@ main(int argc, char *argv[]) output = 0xdeadbeef; ind3 = SQL_DATA_AT_EXEC; ind4 = SQL_DEFAULT_PARAM; - if (SQLExecute(Statement) != SQL_SUCCESS) { - printf("Unable to execute statement\n"); - exit(1); - } + CHK(SQLExecute, (Statement)); if (output != 987 || ind3 <= 0 || ind4 <= 0 || out1 != 6789 || strcmp(out2, "test foo") != 0) { printf("ouput = %d ind3 = %d ind4 = %d out1 = %d out2 = %s\n", (int) output, (int) ind3, (int) ind4, (int) out1, @@ -131,7 +96,7 @@ main(int argc, char *argv[]) /* should return "Invalid cursor state" */ if (SQLFetch(Statement) != SQL_ERROR) { - printf("Data not expected\n"); + fprintf(stderr, "Data not expected\n"); exit(1); } @@ -142,42 +107,33 @@ main(int argc, char *argv[]) * Cfr ML 2006-11-21 "specifying a 0 for the StrLen_or_IndPtr in the * SQLBindParameter call is not working on AIX" */ - if (CommandWithResult(Statement, "drop proc rpc_read") != SQL_SUCCESS) - printf("Unable to execute statement\n"); + Command(Statement, "IF OBJECT_ID('rpc_read') IS NOT NULL DROP PROC rpc_read"); - SQLCloseCursor(Statement); + ResetStatement(); Command(Statement, "create proc rpc_read @i int, @x timestamp as begin select 1 return 1234 end"); SQLCloseCursor(Statement); - SQLFreeStmt(Statement, SQL_CLOSE); - SQLFreeStmt(Statement, SQL_UNBIND); - if (SQLPrepare(Statement, (SQLCHAR *) "{ ? = CALL rpc_read ( ?, ? ) }" , SQL_NTS) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to prepare statement\n"); + CHK(SQLPrepare, (Statement, (SQLCHAR *) "{ ? = CALL rpc_read ( ?, ? ) }" , SQL_NTS)); ind = 0; - if (SQLBindParameter(Statement, 1, SQL_PARAM_OUTPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &output, 0, &ind) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to bind output parameter\n"); + CHK(SQLBindParameter, (Statement, 1, SQL_PARAM_OUTPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &output, 0, &ind)); ind2 = 0; - if (SQLBindParameter(Statement, 2, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &input, 0, &ind2) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to bind input parameter\n"); + CHK(SQLBindParameter, (Statement, 2, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &input, 0, &ind2)); ind3 = 8; - if (SQLBindParameter(Statement, 3, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_VARBINARY, 8, 0, out2, 8, &ind3) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to bind output parameter\n"); + CHK(SQLBindParameter, (Statement, 3, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_VARBINARY, 8, 0, out2, 8, &ind3)); - if (SQLExecute(Statement) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to execute statement\n"); + CHK(SQLExecute, (Statement)); - if (SQLFetch(Statement) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Data not expected\n"); + CHK(SQLFetch, (Statement)); if (SQLFetch(Statement) != SQL_NO_DATA) ODBC_REPORT_ERROR("Data not expected\n"); ResetStatement(); - CommandWithResult(Statement, "drop proc rpc_read"); + Command(Statement, "drop proc rpc_read"); /* * Test from Joao Amaral @@ -190,19 +146,16 @@ main(int argc, char *argv[]) ResetStatement(); - CommandWithResult(Statement, "drop proc sp_test"); + Command(Statement, "IF OBJECT_ID('sp_test') IS NOT NULL DROP PROC sp_test"); Command(Statement, "create proc sp_test @res int output as set @res = 456"); ResetStatement(); - if (SQLPrepare(Statement, (SQLCHAR *) "{ call sp_test(?)}", SQL_NTS) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to prepare statement\n"); - if (SQLBindParameter(Statement, 1, SQL_PARAM_OUTPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &output, 0, &ind) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to bind output parameter\n"); + CHK(SQLPrepare, (Statement, (SQLCHAR *) "{ call sp_test(?)}", SQL_NTS)); + CHK(SQLBindParameter, (Statement, 1, SQL_PARAM_OUTPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &output, 0, &ind)); output = 0xdeadbeef; - if (SQLExecute(Statement) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to execute statement\n"); + CHK(SQLExecute, (Statement)); if (output != 456) { fprintf(stderr, "Invalid result %d(%x)\n", (int) output, (int) output); diff --git a/src/odbc/unittests/genparams.c b/src/odbc/unittests/genparams.c index 6b783c9..9eb1b4f 100644 --- a/src/odbc/unittests/genparams.c +++ b/src/odbc/unittests/genparams.c @@ -4,7 +4,7 @@ /* Test various type from odbc and to odbc */ -static char software_version[] = "$Id: genparams.c,v 1.23 2008/01/08 09:33:32 freddy77 Exp $"; +static char software_version[] = "$Id: genparams.c,v 1.24 2008/01/29 14:30:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #ifdef TDS_NO_DM @@ -37,34 +37,28 @@ Test(const char *type, const char *value_to_convert, SQLSMALLINT out_c_type, SQL if (use_cursors) { ResetStatement(); - if (SQLSetStmtAttr(Statement, SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_SCROLLABLE, 0) != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLSetStmtAttr error"); - if (SQLSetStmtAttr(Statement, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_DYNAMIC, 0) != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLSetStmtAttr error"); + CHK(SQLSetStmtAttr, (Statement, SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_SCROLLABLE, 0)); + CHK(SQLSetStmtAttr, (Statement, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_DYNAMIC, 0)); } /* bind parameter */ if (exec_direct) { - if (SQLBindParameter(Statement, 1, SQL_PARAM_OUTPUT, out_c_type, out_sql_type, precision, 0, out_buf, - sizeof(out_buf), &out_len) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to bind output parameter"); + CHK(SQLBindParameter, (Statement, 1, SQL_PARAM_OUTPUT, out_c_type, out_sql_type, precision, 0, out_buf, + sizeof(out_buf), &out_len)); /* call store procedure */ - if (SQLExecDirect(Statement, (SQLCHAR *) "{call spTestProc(?)}", SQL_NTS) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to execute store statement"); + CHK(SQLExecDirect, (Statement, (SQLCHAR *) "{call spTestProc(?)}", SQL_NTS)); } else { - if (prepare_before && SQLPrepare(Statement, (SQLCHAR *) "{call spTestProc(?)}", SQL_NTS) != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLPrepare() failure!"); + if (prepare_before) + CHK(SQLPrepare, (Statement, (SQLCHAR *) "{call spTestProc(?)}", SQL_NTS)); - if (SQLBindParameter(Statement, 1, SQL_PARAM_OUTPUT, out_c_type, out_sql_type, precision, 0, out_buf, - sizeof(out_buf), &out_len) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to bind output parameter"); + CHK(SQLBindParameter, (Statement, 1, SQL_PARAM_OUTPUT, out_c_type, out_sql_type, precision, 0, out_buf, + sizeof(out_buf), &out_len)); - if (!prepare_before && SQLPrepare(Statement, (SQLCHAR *) "{call spTestProc(?)}", SQL_NTS) != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLPrepare() failure!"); + if (!prepare_before) + CHK(SQLPrepare, (Statement, (SQLCHAR *) "{call spTestProc(?)}", SQL_NTS)); - if (SQLExecute(Statement) != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLExecute() failure!"); + CHK(SQLExecute, (Statement)); } /* test results */ @@ -152,16 +146,14 @@ TestInput(SQLSMALLINT out_c_type, const char *type, SQLSMALLINT out_sql_type, co } else { SQLRETURN rc; - if (prepare_before && SQLPrepare(Statement, (SQLCHAR *) sbuf, SQL_NTS) != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLPrepare() failure!"); + if (prepare_before) + CHK(SQLPrepare, (Statement, (SQLCHAR *) sbuf, SQL_NTS)); out_len = 1; - if (SQLBindParameter(Statement, 1, SQL_PARAM_INPUT, out_c_type, out_sql_type, 20, 0, out_buf, sizeof(out_buf), &out_len) != - SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to bind input parameter"); + CHK(SQLBindParameter, (Statement, 1, SQL_PARAM_INPUT, out_c_type, out_sql_type, 20, 0, out_buf, sizeof(out_buf), &out_len)); - if (!prepare_before && SQLPrepare(Statement, (SQLCHAR *) sbuf, SQL_NTS) != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLPrepare() failure!"); + if (!prepare_before) + CHK(SQLPrepare, (Statement, (SQLCHAR *) sbuf, SQL_NTS)); rc = SQLExecute(Statement); if (rc != SQL_SUCCESS && rc != SQL_NO_DATA) @@ -173,8 +165,7 @@ TestInput(SQLSMALLINT out_c_type, const char *type, SQLSMALLINT out_sql_type, co sprintf(sbuf, "SELECT * FROM #tmp_insert WHERE col = CONVERT(%s, '%s')", param_type, expected); Command(Statement, sbuf); - if (SQLFetch(Statement) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Expected row"); + CHK(SQLFetch, (Statement)); if (SQLFetch(Statement) != SQL_NO_DATA) ODBC_REPORT_ERROR("Row not expected"); if (SQLMoreResults(Statement) != SQL_NO_DATA) diff --git a/src/odbc/unittests/getdata.c b/src/odbc/unittests/getdata.c index 1752423..8520ca1 100644 --- a/src/odbc/unittests/getdata.c +++ b/src/odbc/unittests/getdata.c @@ -1,6 +1,6 @@ #include "common.h" -static char software_version[] = "$Id: getdata.c,v 1.5 2008/01/29 09:35:25 freddy77 Exp $"; +static char software_version[] = "$Id: getdata.c,v 1.6 2008/01/29 14:30:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static char odbc_err[256]; @@ -55,11 +55,7 @@ main(int argc, char *argv[]) /* TODO test with VARCHAR too */ Command(Statement, "SELECT CONVERT(TEXT,'Prova')"); - if (SQLFetch(Statement) != SQL_SUCCESS) { - printf("Unable to fetch row\n"); - CheckReturn(); - exit(1); - } + CHK(SQLFetch, (Statement)); /* these 2 tests test an old severe BUG in FreeTDS */ if (SQLGetData(Statement, 1, SQL_C_CHAR, buf, 0, NULL) != SQL_SUCCESS_WITH_INFO) @@ -75,8 +71,7 @@ main(int argc, char *argv[]) exit(1); } - if (SQLGetData(Statement, 1, SQL_C_CHAR, buf, 16, NULL) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to get data"); + CHK(SQLGetData, (Statement, 1, SQL_C_CHAR, buf, 16, NULL)); if (strcmp(buf, "ova") != 0) { printf("Wrong data result 2 res = '%s'\n", buf); exit(1); @@ -87,8 +82,7 @@ main(int argc, char *argv[]) /* test with varchar, not blob but variable */ Command(Statement, "SELECT CONVERT(VARCHAR(100), 'Other test')"); - if (SQLFetch(Statement) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to fetch row"); + CHK(SQLFetch, (Statement)); if (SQLGetData(Statement, 1, SQL_C_CHAR, buf, 7, NULL) != SQL_SUCCESS_WITH_INFO) ODBC_REPORT_ERROR("Unable to get data"); @@ -97,8 +91,7 @@ main(int argc, char *argv[]) exit(1); } - if (SQLGetData(Statement, 1, SQL_C_CHAR, buf, 16, NULL) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to get data"); + CHK(SQLGetData, (Statement, 1, SQL_C_CHAR, buf, 16, NULL)); if (strcmp(buf, "test") != 0) { printf("Wrong data result 2 res = '%s'\n", buf); exit(1); @@ -109,12 +102,10 @@ main(int argc, char *argv[]) /* test with fixed length */ Command(Statement, "SELECT CONVERT(INT, 12345)"); - if (SQLFetch(Statement) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to fetch row"); + CHK(SQLFetch, (Statement)); int_buf = 0xdeadbeef; - if (SQLGetData(Statement, 1, SQL_C_SLONG, &int_buf, 0, NULL) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to get data"); + CHK(SQLGetData, (Statement, 1, SQL_C_SLONG, &int_buf, 0, NULL)); if (int_buf != 12345) { printf("Wrong data result\n"); exit(1); @@ -149,12 +140,10 @@ main(int argc, char *argv[]) if (db_is_microsoft()) { Command(Statement, "SELECT CONVERT(TEXT,'')"); - if (SQLFetch(Statement) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to fetch row"); + CHK(SQLFetch, (Statement)); len = 1234; - if (SQLGetData(Statement, 1, SQL_C_CHAR, buf, 1, &len) != SQL_SUCCESS) - ODBC_REPORT_ERROR("invalid return from SQLGetData"); + CHK(SQLGetData, (Statement, 1, SQL_C_CHAR, buf, 1, &len)); if (len != 0) { fprintf(stderr, "Wrong len returned, returned %ld\n", (long) len); diff --git a/src/odbc/unittests/hidden.c b/src/odbc/unittests/hidden.c index 71124a6..b02881e 100755 --- a/src/odbc/unittests/hidden.c +++ b/src/odbc/unittests/hidden.c @@ -3,7 +3,7 @@ #include "common.h" -static char software_version[] = "$Id: hidden.c,v 1.3 2008/01/10 21:19:47 freddy77 Exp $"; +static char software_version[] = "$Id: hidden.c,v 1.4 2008/01/29 14:30:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #define CHECK_RCODE(t,h,m) \ @@ -41,7 +41,6 @@ int main(int argc, char **argv) { SQLRETURN rcode; - SQLHSTMT m_hstmt1; SQLSMALLINT cnt = 0; int failed = 0; @@ -54,13 +53,10 @@ main(int argc, char **argv) /* test hidden column with FOR BROWSE */ ResetStatement(); - m_hstmt1 = Statement; + Command(Statement, "SELECT c, b FROM #tmp1"); - rcode = SQLExecDirect(m_hstmt1, (SQLCHAR *) "SELECT c, b FROM #tmp1", SQL_NTS); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLExecDirect"); - - rcode = SQLNumResultCols(m_hstmt1, &cnt); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLNumResultCols 1"); + rcode = SQLNumResultCols(Statement, &cnt); + CHECK_RCODE(SQL_HANDLE_STMT, Statement, "SQLNumResultCols 1"); if (cnt != 2) { fprintf(stderr, "Wrong number of columns in result set: %d\n", (int) cnt); @@ -70,21 +66,20 @@ main(int argc, char **argv) /* test hidden column with cursors*/ CheckCursor(); - m_hstmt1 = Statement; - rcode = SQLSetStmtAttr(m_hstmt1, SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_NONSCROLLABLE, SQL_IS_UINTEGER); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLSetStmtAttr SQL_ATTR_CURSOR_SCROLLABLE"); - rcode = SQLSetStmtAttr(m_hstmt1, SQL_ATTR_CURSOR_SENSITIVITY, (SQLPOINTER) SQL_SENSITIVE, SQL_IS_UINTEGER); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLSetStmtAttr SQL_ATTR_CURSOR_SENSITIVITY"); + rcode = SQLSetStmtAttr(Statement, SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_NONSCROLLABLE, SQL_IS_UINTEGER); + CHECK_RCODE(SQL_HANDLE_STMT, Statement, "SQLSetStmtAttr SQL_ATTR_CURSOR_SCROLLABLE"); + rcode = SQLSetStmtAttr(Statement, SQL_ATTR_CURSOR_SENSITIVITY, (SQLPOINTER) SQL_SENSITIVE, SQL_IS_UINTEGER); + CHECK_RCODE(SQL_HANDLE_STMT, Statement, "SQLSetStmtAttr SQL_ATTR_CURSOR_SENSITIVITY"); - rcode = SQLPrepare(m_hstmt1, (SQLCHAR *) "SELECT * FROM #t1", SQL_NTS); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLPrepare 1"); + rcode = SQLPrepare(Statement, (SQLCHAR *) "SELECT * FROM #t1", SQL_NTS); + CHECK_RCODE(SQL_HANDLE_STMT, Statement, "SQLPrepare 1"); - rcode = SQLExecute(m_hstmt1); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLExecute 1"); + rcode = SQLExecute(Statement); + CHECK_RCODE(SQL_HANDLE_STMT, Statement, "SQLExecute 1"); - rcode = SQLNumResultCols(m_hstmt1, &cnt); - CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLNumResultCols 1"); + rcode = SQLNumResultCols(Statement, &cnt); + CHECK_RCODE(SQL_HANDLE_STMT, Statement, "SQLNumResultCols 1"); if (cnt != 3) { fprintf(stderr, "Wrong number of columns in result set: %d\n", (int) cnt); diff --git a/src/odbc/unittests/lang_error.c b/src/odbc/unittests/lang_error.c index 7634934..90192b4 100644 --- a/src/odbc/unittests/lang_error.c +++ b/src/odbc/unittests/lang_error.c @@ -2,7 +2,7 @@ /* Test if SQLExecDirect return error if a error in row is returned */ -static char software_version[] = "$Id: lang_error.c,v 1.2 2003/11/08 18:00:33 freddy77 Exp $"; +static char software_version[] = "$Id: lang_error.c,v 1.3 2008/01/29 14:30:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; int @@ -12,7 +12,7 @@ main(int argc, char *argv[]) /* issue print statement and test message returned */ if (CommandWithResult(Statement, "SELECT DATEADD(dd,-100000,getdate())") != SQL_ERROR) { - printf("SQLExecDirect should return SQL_ERROR\n"); + fprintf(stderr, "SQLExecDirect should return SQL_ERROR\n"); return 1; } diff --git a/src/odbc/unittests/moreandcount.c b/src/odbc/unittests/moreandcount.c index 4c922dc..95ae329 100644 --- a/src/odbc/unittests/moreandcount.c +++ b/src/odbc/unittests/moreandcount.c @@ -2,7 +2,7 @@ /* Test for SQLMoreResults and SQLRowCount on batch */ -static char software_version[] = "$Id: moreandcount.c,v 1.14 2006/07/13 08:21:56 freddy77 Exp $"; +static char software_version[] = "$Id: moreandcount.c,v 1.15 2008/01/29 14:30:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static void @@ -45,21 +45,12 @@ DoTest(int prepare) "UPDATE #tmp1 SET i=i+1 WHERE i >= 2"; if (prepare) { - if (SQLPrepare(Statement, (SQLCHAR *) query, SQL_NTS) != SQL_SUCCESS) { - printf("Unable to prepare statement\n"); - exit(1); - } - if (SQLExecute(Statement) != SQL_SUCCESS) { - printf("Unable to execute statement\n"); - exit(1); - } + CHK(SQLPrepare, (Statement, (SQLCHAR *) query, SQL_NTS)); + CHK(SQLExecute, (Statement)); } else { /* execute a batch command select insert insert select and check rows */ - if (SQLExecDirect(Statement, (SQLCHAR *) query, SQL_NTS) != SQL_SUCCESS) { - printf("Unable to execute direct statement\n"); - exit(1); - } + CHK(SQLExecDirect, (Statement, (SQLCHAR *) query, SQL_NTS)); } if (!prepare) { printf("Result %d\n", ++n); diff --git a/src/odbc/unittests/norowset.c b/src/odbc/unittests/norowset.c index 6a6afb3..b18245c 100644 --- a/src/odbc/unittests/norowset.c +++ b/src/odbc/unittests/norowset.c @@ -1,6 +1,6 @@ #include "common.h" -static char software_version[] = "$Id: norowset.c,v 1.5 2006/03/23 14:53:44 freddy77 Exp $"; +static char software_version[] = "$Id: norowset.c,v 1.6 2008/01/29 14:30:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; /* Test that a select following a store procedure execution return results */ @@ -22,18 +22,9 @@ main(int argc, char *argv[]) /* note, mssql 2005 seems to not return row for tempdb, use always master */ Command(Statement, "select name from master..sysobjects where name = 'sysobjects'"); - res = SQLFetch(Statement); - if (res != SQL_SUCCESS) { - printf("Unable to fetch row\n"); - CheckReturn(); - exit(1); - } + CHK(SQLFetch, (Statement)); - if (SQLGetData(Statement, 1, SQL_C_CHAR, output, sizeof(output), &dataSize) != SQL_SUCCESS) { - printf("Unable to get data col %d\n", 1); - CheckReturn(); - exit(1); - } + CHK(SQLGetData, (Statement, 1, SQL_C_CHAR, output, sizeof(output), &dataSize)); if (strcmp(output, "sysobjects") != 0) { printf("Unexpected result\n"); @@ -42,13 +33,12 @@ main(int argc, char *argv[]) res = SQLFetch(Statement); if (res != SQL_NO_DATA) { - printf("Row not expected\n"); + fprintf(stderr, "Row not expected\n"); CheckReturn(); - exit(1); } if (SQLMoreResults(Statement) != SQL_NO_DATA) { - printf("Not expected another recordset\n"); + fprintf(stderr, "Not expected another recordset\n"); exit(1); } diff --git a/src/odbc/unittests/params.c b/src/odbc/unittests/params.c index cbf01ee..191066c 100644 --- a/src/odbc/unittests/params.c +++ b/src/odbc/unittests/params.c @@ -3,7 +3,7 @@ /* Test for store procedure and params */ /* Test from Tom Rogers */ -static char software_version[] = "$Id: params.c,v 1.7 2005/03/29 15:19:36 freddy77 Exp $"; +static char software_version[] = "$Id: params.c,v 1.8 2008/01/29 14:30:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; /* SP definition */ @@ -39,51 +39,22 @@ Test(int bind_before) /* create proc */ Command(Statement, sp_define); - if (!bind_before) { - if (SQLPrepare(Statement, (SQLCHAR *) SP_TEXT, strlen(SP_TEXT)) != SQL_SUCCESS) { - fprintf(stderr, "Unable to prepare statement\n"); - return 1; - } - } - - if (SQLBindParameter(Statement, 1, SQL_PARAM_OUTPUT, SQL_C_SSHORT, SQL_INTEGER, 0, 0, &ReturnCode, 0, &cbReturnCode) != - SQL_SUCCESS) { - fprintf(stderr, "Unable to bind input parameter\n"); - return 1; - } - - if (SQLBindParameter(Statement, 2, SQL_PARAM_INPUT, SQL_C_SSHORT, SQL_INTEGER, 0, 0, &InParam, 0, &cbInParam) != - SQL_SUCCESS) { - fprintf(stderr, "Unable to bind input parameter\n"); - return 1; - } + if (!bind_before) + CHK(SQLPrepare, (Statement, (SQLCHAR *) SP_TEXT, strlen(SP_TEXT))); - if (SQLBindParameter(Statement, 3, SQL_PARAM_OUTPUT, SQL_C_SSHORT, SQL_INTEGER, 0, 0, &OutParam, 0, &cbOutParam) != - SQL_SUCCESS) { - fprintf(stderr, "Unable to bind input parameter\n"); - return 1; - } + CHK(SQLBindParameter, (Statement, 1, SQL_PARAM_OUTPUT, SQL_C_SSHORT, SQL_INTEGER, 0, 0, &ReturnCode, 0, &cbReturnCode)); + CHK(SQLBindParameter, (Statement, 2, SQL_PARAM_INPUT, SQL_C_SSHORT, SQL_INTEGER, 0, 0, &InParam, 0, &cbInParam)); + CHK(SQLBindParameter, (Statement, 3, SQL_PARAM_OUTPUT, SQL_C_SSHORT, SQL_INTEGER, 0, 0, &OutParam, 0, &cbOutParam)); OutString[0] = '\0'; strcpy(OutString, "Test"); /* Comment this line and we get an error! Why? */ - if (SQLBindParameter - (Statement, 4, SQL_PARAM_OUTPUT, SQL_C_CHAR, SQL_VARCHAR, OUTSTRING_LEN, 0, OutString, OUTSTRING_LEN, - &cbOutString) != SQL_SUCCESS) { - fprintf(stderr, "Unable to bind input parameter\n"); - return 1; - } + CHK(SQLBindParameter, (Statement, 4, SQL_PARAM_OUTPUT, SQL_C_CHAR, SQL_VARCHAR, OUTSTRING_LEN, 0, OutString, + OUTSTRING_LEN, &cbOutString)); - if (bind_before) { - if (SQLPrepare(Statement, (SQLCHAR *) SP_TEXT, strlen(SP_TEXT)) != SQL_SUCCESS) { - fprintf(stderr, "Unable to prepare statement\n"); - return 1; - } - } + if (bind_before) + CHK(SQLPrepare, (Statement, (SQLCHAR *) SP_TEXT, strlen(SP_TEXT))); - if (SQLExecute(Statement) != SQL_SUCCESS) { - fprintf(stderr, "Unable to execute statement\n"); - return 1; - } + CHK(SQLExecute, (Statement)); Command(Statement, "drop proc spTestProc"); diff --git a/src/odbc/unittests/prepare_results.c b/src/odbc/unittests/prepare_results.c index 651ce0a..8ebdb4e 100644 --- a/src/odbc/unittests/prepare_results.c +++ b/src/odbc/unittests/prepare_results.c @@ -2,7 +2,7 @@ /* Test for data format returned from SQLPrepare */ -static char software_version[] = "$Id: prepare_results.c,v 1.8 2007/06/19 12:07:59 freddy77 Exp $"; +static char software_version[] = "$Id: prepare_results.c,v 1.9 2008/01/29 14:30:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; int @@ -22,11 +22,9 @@ main(int argc, char *argv[]) SQLMoreResults(Statement); /* test query returns column information for update */ - if (SQLPrepare(Statement, (SQLCHAR *) "update #odbctestdata set i = 20", SQL_NTS) != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLPrepare return failure"); + CHK(SQLPrepare, (Statement, (SQLCHAR *) "update #odbctestdata set i = 20", SQL_NTS)); - if (SQLNumResultCols(Statement, &count) != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLNumResultCols return failure"); + CHK(SQLNumResultCols, (Statement, &count)); if (count != 0) { fprintf(stderr, "Wrong number of columns returned. Got %d expected 0\n", (int) count); @@ -34,35 +32,30 @@ main(int argc, char *argv[]) } /* test query returns column information */ - if (SQLPrepare(Statement, (SQLCHAR *) "select * from #odbctestdata select * from #odbctestdata", SQL_NTS) != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLPrepare return failure"); + CHK(SQLPrepare, (Statement, (SQLCHAR *) "select * from #odbctestdata select * from #odbctestdata", SQL_NTS)); - if (SQLNumResultCols(Statement, &count) != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLNumResultCols return failure"); + CHK(SQLNumResultCols, (Statement, &count)); if (count != 3) { fprintf(stderr, "Wrong number of columns returned. Got %d expected 3\n", (int) count); exit(1); } - if (SQLDescribeCol(Statement, 1, (SQLCHAR *) name, sizeof(name), &namelen, &type, &size, &digits, &nullable) != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLDescribeCol failure for column 1"); + CHK(SQLDescribeCol, (Statement, 1, (SQLCHAR *) name, sizeof(name), &namelen, &type, &size, &digits, &nullable)); if (type != SQL_INTEGER || strcmp(name, "i") != 0) { fprintf(stderr, "wrong column 1 informations (type %d name '%s' size %d)\n", (int) type, name, (int) size); exit(1); } - if (SQLDescribeCol(Statement, 2, (SQLCHAR *) name, sizeof(name), &namelen, &type, &size, &digits, &nullable) != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLDescribeCol failure for column 2"); + CHK(SQLDescribeCol, (Statement, 2, (SQLCHAR *) name, sizeof(name), &namelen, &type, &size, &digits, &nullable)); if (type != SQL_CHAR || strcmp(name, "c") != 0 || (size != 20 && (db_is_microsoft() || size != 40))) { fprintf(stderr, "wrong column 2 informations (type %d name '%s' size %d)\n", (int) type, name, (int) size); exit(1); } - if (SQLDescribeCol(Statement, 3, (SQLCHAR *) name, sizeof(name), &namelen, &type, &size, &digits, &nullable) != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLDescribeCol failure for column 3"); + CHK(SQLDescribeCol, (Statement, 3, (SQLCHAR *) name, sizeof(name), &namelen, &type, &size, &digits, &nullable)); if (type != SQL_NUMERIC || strcmp(name, "n") != 0 || size != 34 || digits != 12) { fprintf(stderr, "wrong column 3 informations (type %d name '%s' size %d)\n", (int) type, name, (int) size); diff --git a/src/odbc/unittests/print.c b/src/odbc/unittests/print.c index 4033d5b..45f33dd 100644 --- a/src/odbc/unittests/print.c +++ b/src/odbc/unittests/print.c @@ -1,6 +1,6 @@ #include "common.h" -static char software_version[] = "$Id: print.c,v 1.18 2005/12/04 11:16:30 freddy77 Exp $"; +static char software_version[] = "$Id: print.c,v 1.19 2008/01/29 14:30:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static SQLCHAR output[256]; @@ -53,16 +53,13 @@ test(int odbc3) rc = SQLFetch(Statement); if (rc != SQL_ERROR) ODBC_REPORT_ERROR("Still data?"); - rc = SQLMoreResults(Statement); - if (rc != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLMoreResults failed"); + CHK(SQLMoreResults, (Statement)); } CHECK_COLS(1); CHECK_ROWS(-1); - if (SQLFetch(Statement) != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLFetch no succeeded"); + CHK(SQLFetch, (Statement)); CHECK_COLS(1); CHECK_ROWS(-1); if (SQLFetch(Statement) != SQL_NO_DATA) diff --git a/src/odbc/unittests/putdata.c b/src/odbc/unittests/putdata.c index b199b9d..a9d3878 100644 --- a/src/odbc/unittests/putdata.c +++ b/src/odbc/unittests/putdata.c @@ -2,7 +2,7 @@ /* Test for SQLPutData */ -static char software_version[] = "$Id: putdata.c,v 1.9 2004/10/28 13:16:18 freddy77 Exp $"; +static char software_version[] = "$Id: putdata.c,v 1.10 2008/01/29 14:30:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static const char test_text[] = @@ -25,9 +25,7 @@ main(int argc, char *argv[]) /* create table to hold data */ Command(Statement, "CREATE TABLE #putdata (c TEXT NULL, b IMAGE NULL)"); - if (SQLBindParameter(Statement, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, 0, 0, (SQLPOINTER) 123, 0, &ind) != - SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to bind output parameter"); + CHK(SQLBindParameter, (Statement, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, 0, 0, (SQLPOINTER) 123, 0, &ind)); /* length required */ ind = SQL_LEN_DATA_AT_EXEC(len); @@ -35,8 +33,7 @@ main(int argc, char *argv[]) * test for char */ - if (SQLPrepare(Statement, (SQLCHAR *) "INSERT INTO #putdata(c) VALUES(?)", SQL_NTS) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to prepare statement"); + CHK(SQLPrepare, (Statement, (SQLCHAR *) "INSERT INTO #putdata(c) VALUES(?)", SQL_NTS)); if (SQLExecute(Statement) != SQL_NEED_DATA) ODBC_REPORT_ERROR("Wrong result executing statement"); @@ -57,8 +54,7 @@ main(int argc, char *argv[]) p += n; n *= 2; } - if (SQLParamData(Statement, &ptr) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Wrong result from SQLParamData"); + CHK(SQLParamData, (Statement, &ptr)); if (SQLParamData(Statement, &ptr) != SQL_ERROR) ODBC_REPORT_ERROR("Wrong result from SQLParamData"); @@ -74,13 +70,10 @@ main(int argc, char *argv[]) * test for binary */ - if (SQLBindParameter(Statement, 1, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_LONGVARBINARY, 0, 0, (SQLPOINTER) 4567, 0, &ind) != - SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to bind output parameter"); + CHK(SQLBindParameter, (Statement, 1, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_LONGVARBINARY, 0, 0, (SQLPOINTER) 4567, 0, &ind)); ind = SQL_LEN_DATA_AT_EXEC(254); - if (SQLPrepare(Statement, (SQLCHAR *) "UPDATE #putdata SET b = ?", SQL_NTS) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to prepare statement"); + CHK(SQLPrepare, (Statement, (SQLCHAR *) "UPDATE #putdata SET b = ?", SQL_NTS)); if (SQLExecute(Statement) != SQL_NEED_DATA) ODBC_REPORT_ERROR("Wrong result executing statement"); @@ -96,13 +89,11 @@ main(int argc, char *argv[]) if (l < n) n = l; - if (SQLPutData(Statement, (char *) p, n) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Wrong result from SQLPutData"); + CHK(SQLPutData, (Statement, (char *) p, n)); pb += n; n *= 2; } - if (SQLParamData(Statement, &ptr) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Wrong result from SQLParamData"); + CHK(SQLParamData, (Statement, &ptr)); if (SQLParamData(Statement, &ptr) != SQL_ERROR) ODBC_REPORT_ERROR("Wrong result from SQLParamData"); @@ -112,14 +103,11 @@ main(int argc, char *argv[]) /* test len == 0 case from ML */ - if (SQLFreeStmt(Statement, SQL_RESET_PARAMS) != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLFreeStmt error"); + CHK(SQLFreeStmt, (Statement, SQL_RESET_PARAMS)); - if (SQLPrepare(Statement, (SQLCHAR *) "INSERT INTO #putdata(c) VALUES(?)", SQL_NTS) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to prepare statement"); + CHK(SQLPrepare, (Statement, (SQLCHAR *) "INSERT INTO #putdata(c) VALUES(?)", SQL_NTS)); - if (SQLBindParameter(Statement, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, 0, 0, (PTR) 2, 0, &ind) != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLBindParameter error"); + CHK(SQLBindParameter, (Statement, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, 0, 0, (PTR) 2, 0, &ind)); ind = SQL_LEN_DATA_AT_EXEC(0); diff --git a/src/odbc/unittests/raiserror.c b/src/odbc/unittests/raiserror.c index 94bb486..76fd66f 100644 --- a/src/odbc/unittests/raiserror.c +++ b/src/odbc/unittests/raiserror.c @@ -4,7 +4,7 @@ /* TODO add support for Sybase */ -static char software_version[] = "$Id: raiserror.c,v 1.19 2007/11/26 06:25:11 freddy77 Exp $"; +static char software_version[] = "$Id: raiserror.c,v 1.20 2008/01/29 14:30:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #define SP_TEXT "{?=call #tmp1(?,?,?)}" @@ -153,14 +153,10 @@ Test(int level) SQLBindParameter(Statement, 4, SQL_PARAM_OUTPUT, SQL_C_CHAR, SQL_VARCHAR, OUTSTRING_LEN, 0, OutString, OUTSTRING_LEN, &cbOutString); - result = SQLExecute(Statement); - - if (result != SQL_SUCCESS) - ODBC_REPORT_ERROR("query should success"); + CHK(SQLExecute, (Statement)); CheckData(""); - if (SQLFetch(Statement) != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLFetch returned failure"); + CHK(SQLFetch, (Statement)); CheckData("Here is the first row"); result = SQLFetch(Statement); @@ -221,8 +217,7 @@ Test(int level) CheckReturnCode(result, INVALID_RETURN); CheckData(""); - if (SQLFetch(Statement) != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLFetch returned failure"); + CHK(SQLFetch, (Statement)); CheckData("Here is the last row"); if (SQLFetch(Statement) != SQL_NO_DATA) diff --git a/src/odbc/unittests/rebindpar.c b/src/odbc/unittests/rebindpar.c index d8f0c21..d814b1c 100644 --- a/src/odbc/unittests/rebindpar.c +++ b/src/odbc/unittests/rebindpar.c @@ -2,7 +2,7 @@ /* Test for executing SQLExecute and rebinding parameters */ -static char software_version[] = "$Id: rebindpar.c,v 1.6 2004/12/01 13:11:35 freddy77 Exp $"; +static char software_version[] = "$Id: rebindpar.c,v 1.7 2008/01/29 14:30:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static void @@ -13,16 +13,15 @@ TestInsert(HSTMT stmt, char *buf) char sql[200]; /* insert some data and test success */ - if (SQLBindParameter(stmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, l, 0, buf, l, &ind) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to bind"); + CHK(SQLBindParameter, (stmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, l, 0, buf, l, &ind)); ind = l; - if (SQLExecute(stmt) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to execute"); + CHK(SQLExecute, (stmt)); sprintf(sql, "SELECT 1 FROM #tmp1 WHERE c = '%s'", buf); Command(Statement, sql); - if (SQLFetch(Statement) != SQL_SUCCESS || SQLFetch(Statement) != SQL_NO_DATA || SQLMoreResults(Statement) != SQL_NO_DATA) { + CHK(SQLFetch, (Statement)); + if (SQLFetch(Statement) != SQL_NO_DATA || SQLMoreResults(Statement) != SQL_NO_DATA) { fprintf(stderr, "One row expected!\n"); exit(1); } @@ -43,15 +42,12 @@ Test(int prebind) Command(Statement, "DELETE FROM #tmp1"); - if (SQLAllocStmt(Connection, &stmt) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to allocate statement"); + CHK(SQLAllocStmt, (Connection, &stmt)); if (prebind) - if (SQLBindParameter(stmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 1, 0, buf, 1, &ind) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to bind"); + CHK(SQLBindParameter, (stmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 1, 0, buf, 1, &ind)); - if (SQLPrepare(stmt, (SQLCHAR *) "INSERT INTO #tmp1(c) VALUES(?)", SQL_NTS) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to prepare statement"); + CHK(SQLPrepare, (stmt, (SQLCHAR *) "INSERT INTO #tmp1(c) VALUES(?)", SQL_NTS)); /* try to insert al empty string, should not fail */ /* NOTE this is currently the only test for insert a empty string using rpc */ @@ -61,8 +57,7 @@ Test(int prebind) TestInsert(stmt, "bb"); TestInsert(stmt, buf); - if (SQLFreeStmt(stmt, SQL_DROP) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to free statement"); + CHK(SQLFreeStmt, (stmt, SQL_DROP)); } int diff --git a/src/odbc/unittests/scroll.c b/src/odbc/unittests/scroll.c index 9ba8e5f..f3ff03f 100644 --- a/src/odbc/unittests/scroll.c +++ b/src/odbc/unittests/scroll.c @@ -2,13 +2,9 @@ /* Test cursors */ -static char software_version[] = "$Id: scroll.c,v 1.6 2007/11/26 06:25:11 freddy77 Exp $"; +static char software_version[] = "$Id: scroll.c,v 1.7 2008/01/29 14:30:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; -#define CHK(func,params) \ - if (func params != SQL_SUCCESS) \ - ODBC_REPORT_ERROR(#func) - int main(int argc, char *argv[]) { diff --git a/src/odbc/unittests/t0001.c b/src/odbc/unittests/t0001.c index 399e30c..6ca6c8d 100644 --- a/src/odbc/unittests/t0001.c +++ b/src/odbc/unittests/t0001.c @@ -1,6 +1,6 @@ #include "common.h" -static char software_version[] = "$Id: t0001.c,v 1.14 2004/10/28 13:16:18 freddy77 Exp $"; +static char software_version[] = "$Id: t0001.c,v 1.15 2008/01/29 14:30:49 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; int @@ -24,40 +24,23 @@ main(int argc, char *argv[]) "col1 varchar(30) not null," "col2 int not null," "col3 float not null," "col4 numeric(18,6) not null," "col5 datetime not null," "col6 text not null)"; - if (CommandWithResult(Statement, command) != SQL_SUCCESS) { - printf("Unable to execute statement\n"); - CheckReturn(); - exit(1); - } + CHK(CommandWithResult, (Statement, command)); command = "insert #odbctestdata values (" "'ABCDEFGHIJKLMNOP'," "123456," "1234.56," "123456.78," "'Sep 11 2001 10:00AM'," "'just to check returned length...')"; - if (CommandWithResult(Statement, command) != SQL_SUCCESS) { - printf("Unable to execute statement\n"); - CheckReturn(); - exit(1); - } + CHK(CommandWithResult, (Statement, command)); - if (CommandWithResult(Statement, "select * from #odbctestdata") != SQL_SUCCESS) { - printf("Unable to execute statement\n"); - CheckReturn(); - exit(1); - } + CHK(CommandWithResult, (Statement, "select * from #odbctestdata")); res = SQLFetch(Statement); if (res != SQL_SUCCESS && res != SQL_SUCCESS_WITH_INFO) { - printf("Unable to fetch row\n"); + fprintf(stderr, "Unable to fetch row\n"); CheckReturn(); - exit(1); } for (i = 1; i <= 6; i++) { - if (SQLGetData(Statement, i, SQL_C_CHAR, output, sizeof(output), &cnamesize) != SQL_SUCCESS) { - printf("Unable to get data col %d\n", i); - CheckReturn(); - exit(1); - } + CHK(SQLGetData, (Statement, i, SQL_C_CHAR, output, sizeof(output), &cnamesize)); printf("output data >%s< len_or_ind = %d\n", output, (int) cnamesize); if (cnamesize != strlen((char *) output)) @@ -66,23 +49,17 @@ main(int argc, char *argv[]) res = SQLFetch(Statement); if (res != SQL_NO_DATA) { - printf("Unable to fetch row\n"); + fprintf(stderr, "Unable to fetch row\n"); CheckReturn(); - exit(1); } res = SQLCloseCursor(Statement); if (!SQL_SUCCEEDED(res)) { - printf("Unable to close cursr\n"); + fprintf(stderr, "Unable to close cursor\n"); CheckReturn(); - exit(1); } - if (CommandWithResult(Statement, "drop table #odbctestdata") != SQL_SUCCESS) { - printf("Unable to drop table #odbctestdata \n"); - CheckReturn(); - exit(1); - } + Command(Statement, "drop table #odbctestdata"); Disconnect(); diff --git a/src/odbc/unittests/t0002.c b/src/odbc/unittests/t0002.c index 5da1784..8fa2830 100644 --- a/src/odbc/unittests/t0002.c +++ b/src/odbc/unittests/t0002.c @@ -1,6 +1,6 @@ #include "common.h" -static char software_version[] = "$Id: t0002.c,v 1.12 2005/06/29 07:21:24 freddy77 Exp $"; +static char software_version[] = "$Id: t0002.c,v 1.13 2008/01/29 14:30:49 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; int @@ -24,53 +24,42 @@ main(int argc, char *argv[]) * result should not disappear (required for DBD::ODBC) */ - if (SQLAllocStmt(Connection, &stmt) != SQL_SUCCESS) { - printf("Unable to allocate statement\n"); - CheckReturn(); - exit(1); - } + CHK(SQLAllocStmt, (Connection, &stmt)); Command(stmt, "select * from #odbctestdata where 0=1"); if (SQLFetch(stmt) != SQL_NO_DATA) { - printf("Data not expected\n"); + fprintf(stderr, "Data not expected\n"); exit(1); } res = SQLCloseCursor(stmt); if (!SQL_SUCCEEDED(res)) { - printf("Unable to close cursr\n"); + fprintf(stderr, "Unable to close cursor\n"); CheckReturn(); - exit(1); } Command(Statement, "select * from #odbctestdata"); /* drop first statement .. data should not disappear */ - if (SQLFreeStmt(stmt, SQL_DROP) != SQL_SUCCESS) { - printf("Error dropping??\n"); - exit(1); - } + CHK(SQLFreeStmt, (stmt, SQL_DROP)); res = SQLFetch(Statement); if (res != SQL_SUCCESS && res != SQL_SUCCESS_WITH_INFO) { - printf("Unable to fetch row. Drop of previous statement discard results... bad!\n"); + fprintf(stderr, "Unable to fetch row. Drop of previous statement discard results... bad!\n"); CheckReturn(); - exit(1); } res = SQLFetch(Statement); if (res != SQL_NO_DATA) { - printf("Unable to fetch row\n"); + fprintf(stderr, "Unable to fetch row\n"); CheckReturn(); - exit(1); } res = SQLCloseCursor(Statement); if (!SQL_SUCCEEDED(res)) { - printf("Unable to close cursr\n"); + fprintf(stderr, "Unable to close cursr\n"); CheckReturn(); - exit(1); } Command(Statement, "drop table #odbctestdata"); diff --git a/src/odbc/unittests/t0003.c b/src/odbc/unittests/t0003.c index c36947e..d9e6640 100644 --- a/src/odbc/unittests/t0003.c +++ b/src/odbc/unittests/t0003.c @@ -2,7 +2,7 @@ /* Test for SQLMoreResults */ -static char software_version[] = "$Id: t0003.c,v 1.16 2005/03/29 15:19:36 freddy77 Exp $"; +static char software_version[] = "$Id: t0003.c,v 1.17 2008/01/29 14:30:49 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static void @@ -14,17 +14,14 @@ DoTest(int prepared) if (!prepared) { Command(Statement, "select * from #odbctestdata select * from #odbctestdata"); } else { - if (SQLPrepare(Statement, (SQLCHAR *)"select * from #odbctestdata select * from #odbctestdata", SQL_NTS) != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLPrepare return failure"); - if (SQLExecute(Statement) != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLExecure return failure"); + CHK(SQLPrepare, (Statement, (SQLCHAR *)"select * from #odbctestdata select * from #odbctestdata", SQL_NTS)); + CHK(SQLExecute, (Statement)); } if (SQLFetch(Statement) != SQL_NO_DATA) ODBC_REPORT_ERROR("Data not expected"); - if (SQLMoreResults(Statement) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Expected another recordset"); + CHK(SQLMoreResults, (Statement)); printf("Getting next recordset\n"); if (SQLFetch(Statement) != SQL_NO_DATA) @@ -38,18 +35,14 @@ DoTest(int prepared) if (!prepared) { Command(Statement, "select * from #odbctestdata select * from #odbctestdata"); } else { - if (SQLPrepare(Statement, (SQLCHAR *)"select * from #odbctestdata select * from #odbctestdata", SQL_NTS) != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLPrepare return failure"); - if (SQLExecute(Statement) != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLExecure return failure"); + CHK(SQLPrepare, (Statement, (SQLCHAR *)"select * from #odbctestdata select * from #odbctestdata", SQL_NTS)); + CHK(SQLExecute, (Statement)); } - if (SQLMoreResults(Statement) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Expected another recordset"); + CHK(SQLMoreResults, (Statement)); printf("Getting next recordset\n"); - if (SQLFetch(Statement) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Expecting a row"); + CHK(SQLFetch, (Statement)); if (SQLFetch(Statement) != SQL_NO_DATA) ODBC_REPORT_ERROR("Data not expected"); diff --git a/src/odbc/unittests/t0004.c b/src/odbc/unittests/t0004.c index 60cbddb..839fa60 100644 --- a/src/odbc/unittests/t0004.c +++ b/src/odbc/unittests/t0004.c @@ -2,7 +2,7 @@ /* Test for SQLMoreResults */ -static char software_version[] = "$Id: t0004.c,v 1.15 2006/03/23 14:53:44 freddy77 Exp $"; +static char software_version[] = "$Id: t0004.c,v 1.16 2008/01/29 14:30:49 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static void @@ -15,28 +15,19 @@ Test(int use_indicator) strcpy(buf, "I don't exist"); ind = strlen(buf); - if (SQLBindParameter(Statement, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 20, 0, buf, 128, pind) != SQL_SUCCESS) { - printf("Unable to bind parameter\n"); - exit(1); - } + CHK(SQLBindParameter, (Statement, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 20, 0, buf, 128, pind)); - if (SQLPrepare(Statement, (SQLCHAR *) "SELECT id, name FROM master..sysobjects WHERE name = ?", SQL_NTS) != SQL_SUCCESS) { - printf("Unable to prepare statement\n"); - exit(1); - } + CHK(SQLPrepare, (Statement, (SQLCHAR *) "SELECT id, name FROM master..sysobjects WHERE name = ?", SQL_NTS)); - if (SQLExecute(Statement) != SQL_SUCCESS) { - printf("Unable to execute statement\n"); - exit(1); - } + CHK(SQLExecute, (Statement)); if (SQLFetch(Statement) != SQL_NO_DATA) { - printf("Data not expected\n"); + fprintf(stderr, "Data not expected\n"); exit(1); } if (SQLMoreResults(Statement) != SQL_NO_DATA) { - printf("Not expected another recordset\n"); + fprintf(stderr, "Not expected another recordset\n"); exit(1); } @@ -44,23 +35,17 @@ Test(int use_indicator) strcpy(buf, "sysobjects"); ind = strlen(buf); - if (SQLExecute(Statement) != SQL_SUCCESS) { - printf("Unable to execute statement\n"); - exit(1); - } + CHK(SQLExecute, (Statement)); - if (SQLFetch(Statement) != SQL_SUCCESS) { - printf("Data expected\n"); - exit(1); - } + CHK(SQLFetch, (Statement)); if (SQLFetch(Statement) != SQL_NO_DATA) { - printf("Data not expected\n"); + fprintf(stderr, "Data not expected\n"); exit(1); } if (SQLMoreResults(Statement) != SQL_NO_DATA) { - printf("Not expected another recordset\n"); + fprintf(stderr, "Not expected another recordset\n"); exit(1); } } diff --git a/src/odbc/unittests/tables.c b/src/odbc/unittests/tables.c index 011a377..671ef79 100644 --- a/src/odbc/unittests/tables.c +++ b/src/odbc/unittests/tables.c @@ -1,6 +1,6 @@ #include "common.h" -static char software_version[] = "$Id: tables.c,v 1.13 2007/07/03 15:13:55 freddy77 Exp $"; +static char software_version[] = "$Id: tables.c,v 1.14 2008/01/29 14:30:49 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #ifdef WIN32 @@ -15,11 +15,7 @@ static void ReadCol(int i) { strcpy(output, "NULL"); - if (SQLGetData(Statement, i, SQL_C_CHAR, output, sizeof(output), &cnamesize) != SQL_SUCCESS) { - printf("Unable to get data col %d\n", i); - CheckReturn(); - exit(1); - } + CHK(SQLGetData, (Statement, i, SQL_C_CHAR, output, sizeof(output), &cnamesize)); } static void @@ -28,12 +24,9 @@ TestName(int index, const char *expected_name) char name[128]; char buf[256]; SQLSMALLINT len, type; - SQLRETURN rc; #define NAME_TEST \ do { \ - if (rc != SQL_SUCCESS) \ - ODBC_REPORT_ERROR("SQLDescribeCol failed"); \ if (strcmp(name, expected_name) != 0) \ { \ sprintf(buf, "wrong name in column %d expected '%s' got '%s'", index, expected_name, name); \ @@ -42,14 +35,14 @@ TestName(int index, const char *expected_name) } while(0) /* retrieve with SQLDescribeCol */ - rc = SQLDescribeCol(Statement, index, (SQLCHAR *) name, sizeof(name), &len, &type, NULL, NULL, NULL); + CHK(SQLDescribeCol, (Statement, index, (SQLCHAR *) name, sizeof(name), &len, &type, NULL, NULL, NULL)); NAME_TEST; /* retrieve with SQLColAttribute */ - rc = SQLColAttribute(Statement, index, SQL_DESC_NAME, name, sizeof(name), &len, NULL); + CHK(SQLColAttribute, (Statement, index, SQL_DESC_NAME, name, sizeof(name), &len, NULL)); if (db_is_microsoft()) NAME_TEST; - rc = SQLColAttribute(Statement, index, SQL_DESC_LABEL, name, sizeof(name), &len, NULL); + CHK(SQLColAttribute, (Statement, index, SQL_DESC_LABEL, name, sizeof(name), &len, NULL)); NAME_TEST; } diff --git a/src/odbc/unittests/test64.c b/src/odbc/unittests/test64.c index f29e745..8d0dd75 100644 --- a/src/odbc/unittests/test64.c +++ b/src/odbc/unittests/test64.c @@ -1,13 +1,9 @@ /* test win64 consistency */ #include "common.h" -static char software_version[] = "$Id: test64.c,v 1.3 2008/01/26 21:47:26 freddy77 Exp $"; +static char software_version[] = "$Id: test64.c,v 1.4 2008/01/29 14:30:49 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; -#define CHK(func,params) \ - if (func params != SQL_SUCCESS) \ - ODBC_REPORT_ERROR(#func) - /* set ipd processed_ptr with SQLParamOptions/SQLSetDescField/SQL_ATTR_PARAMS_PROCESSED_PTR diff --git a/src/odbc/unittests/timeout.c b/src/odbc/unittests/timeout.c index a1b7385..f8a7ddf 100644 --- a/src/odbc/unittests/timeout.c +++ b/src/odbc/unittests/timeout.c @@ -3,27 +3,19 @@ /* Test timeout of query */ -static char software_version[] = "$Id: timeout.c,v 1.7 2007/11/26 18:12:31 freddy77 Exp $"; +static char software_version[] = "$Id: timeout.c,v 1.8 2008/01/29 14:30:49 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static void AutoCommit(int onoff) { - SQLRETURN ret; - - ret = SQLSetConnectAttr(Connection, SQL_ATTR_AUTOCOMMIT, int2ptr(onoff), 0); - if (ret != SQL_SUCCESS) - ODBC_REPORT_ERROR("Enabling AutoCommit"); + CHK(SQLSetConnectAttr, (Connection, SQL_ATTR_AUTOCOMMIT, int2ptr(onoff), 0)); } static void EndTransaction(SQLSMALLINT type) { - SQLRETURN ret; - - ret = SQLEndTran(SQL_HANDLE_DBC, Connection, type); - if (ret != SQL_SUCCESS) - ODBC_REPORT_ERROR("Can't commit transaction"); + CHK(SQLEndTran, (SQL_HANDLE_DBC, Connection, type)); } int @@ -58,17 +50,12 @@ main(int argc, char *argv[]) Connect(); AutoCommit(SQL_AUTOCOMMIT_OFF); - ret = SQLSetStmtAttr(Statement, SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER) 2, 0); - if (ret != SQL_SUCCESS) - ODBC_REPORT_ERROR("Error setting timeout"); + CHK(SQLSetStmtAttr, (Statement, SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER) 2, 0)); i = 1; - ret = SQLBindParameter(Statement, 1, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &i, 0, NULL); - if (ret != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLBindParameter failure"); + CHK(SQLBindParameter, (Statement, 1, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &i, 0, NULL)); - if (SQLPrepare(Statement, (SQLCHAR *) "update test_timeout set t = 'bad' where n = ?", SQL_NTS) != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLPrepare failure"); + CHK(SQLPrepare, (Statement, (SQLCHAR *) "update test_timeout set t = 'bad' where n = ?", SQL_NTS)); ret = SQLExecute(Statement); if (ret != SQL_ERROR) ODBC_REPORT_ERROR("SQLExecute success ??"); diff --git a/src/odbc/unittests/timeout2.c b/src/odbc/unittests/timeout2.c index 3cded35..1c61565 100644 --- a/src/odbc/unittests/timeout2.c +++ b/src/odbc/unittests/timeout2.c @@ -14,17 +14,13 @@ * Test from Ou Liu, cf "Query Time Out", 2006-08-08 */ -static char software_version[] = "$Id: timeout2.c,v 1.4 2007/06/27 14:52:25 freddy77 Exp $"; +static char software_version[] = "$Id: timeout2.c,v 1.5 2008/01/29 14:30:49 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #if defined(__MINGW32__) || defined(WIN32) #define sleep(s) Sleep((s)*1000) #endif -#define CHK(func,params) \ - if (func params != SQL_SUCCESS) \ - ODBC_REPORT_ERROR(#func) - int main(int argc, char *argv[]) { diff --git a/src/odbc/unittests/timeout4.c b/src/odbc/unittests/timeout4.c index 3738dc8..be9c6f9 100644 --- a/src/odbc/unittests/timeout4.c +++ b/src/odbc/unittests/timeout4.c @@ -39,7 +39,7 @@ * prepare or execute a query. This should fail and return an error message. */ -static char software_version[] = "$Id: timeout4.c,v 1.1 2007/04/20 09:15:06 freddy77 Exp $"; +static char software_version[] = "$Id: timeout4.c,v 1.2 2008/01/29 14:30:49 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #if HAVE_FSTAT && defined(S_IFSOCK) @@ -91,9 +91,7 @@ Test(int direct) return 1; } - ret = SQLSetStmtAttr(Statement, SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER) 10, SQL_IS_UINTEGER); - if (ret != SQL_SUCCESS) - ODBC_REPORT_ERROR("Error setting timeout"); + CHK(SQLSetStmtAttr, (Statement, SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER) 10, SQL_IS_UINTEGER)); alarm(30); start_time = time(NULL); diff --git a/src/odbc/unittests/transaction.c b/src/odbc/unittests/transaction.c index a166f63..e7b507a 100644 --- a/src/odbc/unittests/transaction.c +++ b/src/odbc/unittests/transaction.c @@ -1,6 +1,6 @@ #include "common.h" -static char software_version[] = "$Id: transaction.c,v 1.12 2006/08/13 13:03:19 freddy77 Exp $"; +static char software_version[] = "$Id: transaction.c,v 1.13 2008/01/29 14:30:49 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static int @@ -27,96 +27,48 @@ Test(int discard_test) /* create stored proc */ CommandWithResult(Statement, "DROP PROCEDURE testinsert"); - result = CommandWithResult(Statement, createProcedure); - if (result != SQL_SUCCESS) { - ODBC_REPORT_ERROR("Can't create proc testinsert"); - retcode = 1; - goto cleanup; - } + Command(Statement, createProcedure); /* create stored proc that generates an error */ CommandWithResult(Statement, "DROP PROCEDURE testerror"); - result = CommandWithResult(Statement, createErrorProcedure); - if (result != SQL_SUCCESS) { - ODBC_REPORT_ERROR("Can't create proc testerror"); - retcode = 1; - goto cleanup; - } + Command(Statement, createErrorProcedure); /* Start transaction */ - result = SQLSetConnectAttr(Connection, SQL_ATTR_AUTOCOMMIT, (void *) SQL_AUTOCOMMIT_OFF, 0); - if (result != SQL_SUCCESS) { - ODBC_REPORT_ERROR("Can't start transaction"); - retcode = 1; - goto cleanup; - } + CHK(SQLSetConnectAttr, (Connection, SQL_ATTR_AUTOCOMMIT, (void *) SQL_AUTOCOMMIT_OFF, 0)); /* Insert a value */ Command(Statement, "EXEC testinsert 1"); /* we should be able to read row count */ - if (SQLRowCount(Statement, &rows) != SQL_SUCCESS) { - ODBC_REPORT_ERROR("Can't get row counts"); - retcode = 1; - goto cleanup; - } + CHK(SQLRowCount, (Statement, &rows)); /* Commit transaction */ - result = SQLEndTran(SQL_HANDLE_DBC, Connection, SQL_COMMIT); - if (result != SQL_SUCCESS) { - ODBC_REPORT_ERROR("Can't commit transaction"); - retcode = 1; - goto cleanup; - } + CHK(SQLEndTran, (SQL_HANDLE_DBC, Connection, SQL_COMMIT)); SQLCloseCursor(Statement); /* Start transaction */ - result = SQLSetConnectAttr(Connection, SQL_ATTR_AUTOCOMMIT, (void *) SQL_AUTOCOMMIT_OFF, 0); - if (result != SQL_SUCCESS) { - ODBC_REPORT_ERROR("Can't start transaction"); - retcode = 1; - goto cleanup; - } + CHK(SQLSetConnectAttr, (Connection, SQL_ATTR_AUTOCOMMIT, (void *) SQL_AUTOCOMMIT_OFF, 0)); /* Insert another value */ Command(Statement, "EXEC testinsert 2"); /* Roll back transaction */ - result = SQLEndTran(SQL_HANDLE_DBC, Connection, SQL_ROLLBACK); - if (result != SQL_SUCCESS) { - ODBC_REPORT_ERROR("Can't roll back transaction"); - retcode = 1; - goto cleanup; - } + CHK(SQLEndTran, (SQL_HANDLE_DBC, Connection, SQL_ROLLBACK)); /* TODO test row inserted */ - result = SQLSetConnectAttr(Connection, SQL_ATTR_AUTOCOMMIT, (void *) SQL_AUTOCOMMIT_ON, 0); - if (result != SQL_SUCCESS) { - ODBC_REPORT_ERROR("Can't stop transaction"); - retcode = 1; - goto cleanup; - } + CHK(SQLSetConnectAttr, (Connection, SQL_ATTR_AUTOCOMMIT, (void *) SQL_AUTOCOMMIT_ON, 0)); /* generate an error */ - result = CommandWithResult(Statement, "EXEC testerror"); - if (result != SQL_SUCCESS) { - ODBC_REPORT_ERROR("error: SQLExecDirect: testerror"); - retcode = 1; - goto cleanup; - } - if (SQLBindCol(Statement, 1, SQL_C_SLONG, &out_buf, sizeof(out_buf), &out_len) != SQL_SUCCESS) { - ODBC_REPORT_ERROR("error: SQLBindCol: testerror"); - retcode = 1; - goto cleanup; - } + Command(Statement, "EXEC testerror"); + CHK(SQLBindCol, (Statement, 1, SQL_C_SLONG, &out_buf, sizeof(out_buf), &out_len)); while ((result = SQLFetch(Statement)) == SQL_SUCCESS) { printf("\t%ld\n", (long int) out_buf); if (out_buf != 1) { - printf("error: expected to select 1 got %ld\n", (long int) out_buf); + fprintf(stderr, "error: expected to select 1 got %ld\n", (long int) out_buf); retcode = 1; goto cleanup; } @@ -131,7 +83,7 @@ Test(int discard_test) printf("SQLMoreResults returned %d\n", result); if (result != SQL_ERROR) { - printf("SQLMoreResults should return error\n"); + fprintf(stderr, "SQLMoreResults should return error\n"); retcode = 1; goto cleanup; } @@ -147,7 +99,7 @@ Test(int discard_test) result = SQLMoreResults(Statement); printf("SQLMoreResults returned %d\n", result); if (result != SQL_NO_DATA) { - printf("SQLMoreResults should return error"); + fprintf(stderr, "SQLMoreResults should return error"); retcode = 1; goto cleanup; } @@ -163,26 +115,19 @@ Test(int discard_test) int main(int argc, char *argv[]) { - int result; int retcode = 0; Connect(); /* create table */ CommandWithResult(Statement, "DROP TABLE TestTransaction"); - result = CommandWithResult(Statement, "CREATE TABLE TestTransaction ( value INT )"); - if (result != SQL_SUCCESS) { - ODBC_REPORT_ERROR("Can't create table TestTransaction"); - retcode = 1; - goto cleanup; - } + Command(Statement, "CREATE TABLE TestTransaction ( value INT )"); if (!retcode) retcode = Test(1); if (!retcode) retcode = Test(0); - cleanup: /* drop table */ CommandWithResult(Statement, "DROP TABLE TestTransaction"); diff --git a/src/odbc/unittests/typeinfo.c b/src/odbc/unittests/typeinfo.c index cae15e5..c9539c9 100644 --- a/src/odbc/unittests/typeinfo.c +++ b/src/odbc/unittests/typeinfo.c @@ -1,6 +1,6 @@ #include "common.h" -static char software_version[] = "$Id: typeinfo.c,v 1.8 2007/07/03 15:13:55 freddy77 Exp $"; +static char software_version[] = "$Id: typeinfo.c,v 1.9 2008/01/29 14:30:49 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static void @@ -9,12 +9,9 @@ TestName(int index, const char *expected_name) char name[128]; char buf[256]; SQLSMALLINT len, type; - SQLRETURN rc; #define NAME_TEST \ do { \ - if (rc != SQL_SUCCESS) \ - ODBC_REPORT_ERROR("SQLDescribeCol failed"); \ if (strcmp(name, expected_name) != 0) \ { \ sprintf(buf, "wrong name in column %d expected '%s' got '%s'", index, expected_name, name); \ @@ -23,14 +20,14 @@ TestName(int index, const char *expected_name) } while(0) /* retrieve with SQLDescribeCol */ - rc = SQLDescribeCol(Statement, index, (SQLCHAR *) name, sizeof(name), &len, &type, NULL, NULL, NULL); + CHK(SQLDescribeCol, (Statement, index, (SQLCHAR *) name, sizeof(name), &len, &type, NULL, NULL, NULL)); NAME_TEST; /* retrieve with SQLColAttribute */ - rc = SQLColAttribute(Statement, index, SQL_DESC_NAME, name, sizeof(name), &len, NULL); + CHK(SQLColAttribute, (Statement, index, SQL_DESC_NAME, name, sizeof(name), &len, NULL)); if (db_is_microsoft()) NAME_TEST; - rc = SQLColAttribute(Statement, index, SQL_DESC_LABEL, name, sizeof(name), &len, NULL); + CHK(SQLColAttribute, (Statement, index, SQL_DESC_LABEL, name, sizeof(name), &len, NULL)); NAME_TEST; } diff --git a/src/odbc/unittests/warning.c b/src/odbc/unittests/warning.c index 05f3353..741a250 100644 --- a/src/odbc/unittests/warning.c +++ b/src/odbc/unittests/warning.c @@ -14,7 +14,7 @@ * inside recordset * Sybase do not return warning but test works the same */ -static char software_version[] = "$Id: warning.c,v 1.5 2007/05/17 13:11:56 freddy77 Exp $"; +static char software_version[] = "$Id: warning.c,v 1.6 2008/01/29 14:30:49 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static const char one_null_with_warning[] = "select max(a) as foo from (select convert(int, null) as a) as test"; @@ -30,15 +30,9 @@ Test(const char *query) { int res; - if (SQLPrepare(Statement, (SQLCHAR *) query, SQL_NTS) != SQL_SUCCESS) { - fprintf(stderr, "Unable to prepare statement\n"); - exit(1); - } + CHK(SQLPrepare, (Statement, (SQLCHAR *) query, SQL_NTS)); - if (SQLExecute(Statement) != SQL_SUCCESS) { - fprintf(stderr, "Unable to execute statement\n"); - exit(1); - } + CHK(SQLExecute, (Statement)); res = SQLFetch(Statement); if (res != SQL_SUCCESS && res != SQL_SUCCESS_WITH_INFO) { commit d49abfe40b4b73fc27676fcd5ef742493cdda99a Author: freddy77 Date: Thu Jan 31 09:13:05 2008 +0000 reuse code diff --git a/ChangeLog b/ChangeLog index 800bfc2..0e5bc0f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Thu Jan 21 10:12:42 CET 2008 Frediano Ziglio + * src/odbc/unittests/convert_error.c src/odbc/unittests/genparams.c: + - more reuse + Tue Jan 29 15:28:32 CET 2008 Frediano Ziglio * src/odbc/unittests/array_out.c src/odbc/unittests/common.c: * src/odbc/unittests/common.h src/odbc/unittests/compute.c: @@ -128,4 +132,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2480 2008/01/29 14:30:48 freddy77 Exp $ +$Id: ChangeLog,v 1.2481 2008/01/31 09:13:05 freddy77 Exp $ diff --git a/src/odbc/unittests/convert_error.c b/src/odbc/unittests/convert_error.c index 29c8c93..68a70ef 100644 --- a/src/odbc/unittests/convert_error.c +++ b/src/odbc/unittests/convert_error.c @@ -4,33 +4,11 @@ */ #include "common.h" -static char software_version[] = "$Id: convert_error.c,v 1.7 2005/08/03 06:24:50 freddy77 Exp $"; +static char software_version[] = "$Id: convert_error.c,v 1.8 2008/01/31 09:13:08 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static int test_num = 0; -static int -success(int ident, SQLRETURN r) -{ - if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) - return 1; - printf("failed: num:%d ident:%d sqlreturn:%d\n", test_num, ident, (int) r); - - if (Statement) { - SQLCHAR buf[4096]; - SQLCHAR state[6]; - SQLINTEGER nativeerrorcode; - SQLSMALLINT tmp; - - memset(state, 0, sizeof(state)); - memset(buf, 0, sizeof(buf)); - SQLGetDiagRec(SQL_HANDLE_STMT, Statement, 1, state, &nativeerrorcode, buf, 4096, &tmp); - printf("%s\n", buf); - } - Disconnect(); - exit(1); -} - static void Test(const char *bind1, SQLSMALLINT type1, const char *bind2, SQLSMALLINT type2) { @@ -44,14 +22,13 @@ Test(const char *bind1, SQLSMALLINT type1, const char *bind2, SQLSMALLINT type2) ++test_num; sprintf(sql, "insert into #test_output values (%s, %s)", bind1, bind2); - success(2, SQLPrepare(Statement, (SQLCHAR *) sql, strlen(sql))); + CHK(SQLPrepare, (Statement, (SQLCHAR *) sql, strlen(sql))); if (bind1[0] == '?') - success(3, SQLBindParameter(Statement, id++, SQL_PARAM_INPUT, SQL_C_LONG, type1, 3, 0, &test_num, 0, &ind)); + CHK(SQLBindParameter, (Statement, id++, SQL_PARAM_INPUT, SQL_C_LONG, type1, 3, 0, &test_num, 0, &ind)); if (bind2[0] == '?') - success(4, - SQLBindParameter(Statement, id++, SQL_PARAM_INPUT, SQL_C_CHAR, type2, strlen(val) + 1, 0, (SQLCHAR *) val, + CHK(SQLBindParameter, (Statement, id++, SQL_PARAM_INPUT, SQL_C_CHAR, type2, strlen(val) + 1, 0, (SQLCHAR *) val, 0, &ind)); - success(5, SQLExecute(Statement)); + CHK(SQLExecute, (Statement)); } int diff --git a/src/odbc/unittests/genparams.c b/src/odbc/unittests/genparams.c index 9eb1b4f..96f153b 100644 --- a/src/odbc/unittests/genparams.c +++ b/src/odbc/unittests/genparams.c @@ -4,7 +4,7 @@ /* Test various type from odbc and to odbc */ -static char software_version[] = "$Id: genparams.c,v 1.24 2008/01/29 14:30:48 freddy77 Exp $"; +static char software_version[] = "$Id: genparams.c,v 1.25 2008/01/31 09:13:08 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #ifdef TDS_NO_DM @@ -124,10 +124,8 @@ TestInput(SQLSMALLINT out_c_type, const char *type, SQLSMALLINT out_sql_type, co if (use_cursors) { ResetStatement(); - if (SQLSetStmtAttr(Statement, SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_SCROLLABLE, 0) != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLSetStmtAttr error"); - if (SQLSetStmtAttr(Statement, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_DYNAMIC, 0) != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLSetStmtAttr error"); + CHK(SQLSetStmtAttr, (Statement, SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_SCROLLABLE, 0)); + CHK(SQLSetStmtAttr, (Statement, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_DYNAMIC, 0)); } /* insert data using prepared statements */ @@ -136,9 +134,7 @@ TestInput(SQLSMALLINT out_c_type, const char *type, SQLSMALLINT out_sql_type, co SQLRETURN rc; out_len = 1; - if (SQLBindParameter(Statement, 1, SQL_PARAM_INPUT, out_c_type, out_sql_type, 20, 0, out_buf, sizeof(out_buf), &out_len) != - SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to bind input parameter"); + CHK(SQLBindParameter, (Statement, 1, SQL_PARAM_INPUT, out_c_type, out_sql_type, 20, 0, out_buf, sizeof(out_buf), &out_len)); rc = SQLExecDirect(Statement, (SQLCHAR *) sbuf, SQL_NTS); if (rc != SQL_SUCCESS && rc != SQL_NO_DATA) commit d55aa0695496bec96daf4d7fb01a91431e0462b5 Author: freddy77 Date: Mon Feb 4 07:51:10 2008 +0000 fix silly memory leak diff --git a/ChangeLog b/ChangeLog index 0e5bc0f..8256c3a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +Mon Feb 04 08:49:58 CET 2008 Frediano Ziglio + * src/tds/convert.c: fix silly memory leak + Thu Jan 21 10:12:42 CET 2008 Frediano Ziglio * src/odbc/unittests/convert_error.c src/odbc/unittests/genparams.c: - more reuse @@ -132,4 +135,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2481 2008/01/31 09:13:05 freddy77 Exp $ +$Id: ChangeLog,v 1.2482 2008/02/04 07:51:10 freddy77 Exp $ diff --git a/src/tds/convert.c b/src/tds/convert.c index fa8dbd1..67ea545 100644 --- a/src/tds/convert.c +++ b/src/tds/convert.c @@ -64,7 +64,7 @@ #include #endif -TDS_RCSID(var, "$Id: convert.c,v 1.179 2007/12/31 10:06:50 freddy77 Exp $"); +TDS_RCSID(var, "$Id: convert.c,v 1.180 2008/02/04 07:51:11 freddy77 Exp $"); typedef unsigned short utf16_t; @@ -1958,6 +1958,7 @@ string_to_datetime(const char *instr, int desttype, CONV_RESULT * cr) tdsdump_log(TDS_DBG_INFO1, "error_handler: Attempt to convert data stopped by syntax error in source field \n"); + free(in); return TDS_CONVERT_SYNTAX; } commit 18dedd394149a835f6f90602af7c56cdc9482a10 Author: freddy77 Date: Tue Feb 5 09:46:33 2008 +0000 deal with SQLWCHAR type diff --git a/src/odbc/sqlwchar.c b/src/odbc/sqlwchar.c new file mode 100644 index 0000000..61eb5a7 --- /dev/null +++ b/src/odbc/sqlwchar.c @@ -0,0 +1,40 @@ +/* FreeTDS - Library of routines accessing Sybase and Microsoft databases + * Copyright (C) 2008 Ziglio Frediano + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#if HAVE_CONFIG_H +#include +#endif /* HAVE_CONFIG_H */ + +#include +#include + +#include "tdsodbc.h" + +TDS_RCSID(var, "$Id: sqlwchar.c,v 1.1 2008/02/05 09:46:33 freddy77 Exp $"); + +#if SIZEOF_SQLWCHAR != SIZEOF_WCHAR_T +size_t sqlwcslen(const SQLWCHAR * s) +{ + size_t res = 0; + while (*s) + ++s, ++res; + return res; +} +#endif + commit 1f108b0482cd647bb38ad17a0bed1b301682b06a Author: freddy77 Date: Tue Feb 5 10:03:57 2008 +0000 test NCHAR and SQL_C_DEFAULT diff --git a/src/odbc/unittests/wchar.c b/src/odbc/unittests/wchar.c new file mode 100644 index 0000000..92bb084 --- /dev/null +++ b/src/odbc/unittests/wchar.c @@ -0,0 +1,38 @@ +#include "common.h" + +/* test SQL_C_DEFAULT with NCHAR type */ + +static char software_version[] = "$Id: wchar.c,v 1.1 2008/02/05 10:03:57 freddy77 Exp $"; +static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; + +int +main(int argc, char *argv[]) +{ + char buf[102]; + SQLLEN ind; + int failed = 0; + + /* TODO remove if not neeeded */ + use_odbc_version3 = 1; + Connect(); + + SQLBindCol(Statement, 1, SQL_C_DEFAULT, buf, 100, &ind); + Command(Statement, "SELECT CONVERT(NCHAR(10), 'Pippo 123')"); + + /* get data */ + memset(buf, 0, sizeof(buf)); + SQLFetch(Statement); + + SQLMoreResults(Statement); + SQLMoreResults(Statement); + + Disconnect(); + + if (strcmp(buf, "Pippo 123 ") != 0) { + fprintf(stderr, "Wrong results '%s'\n", buf); + failed = 1; + } + + return failed ? 1 : 0; +} + commit 332bf81cc62288f01164db84b316a01f7e8bce8f Author: freddy77 Date: Tue Feb 5 15:01:28 2008 +0000 conversion test improve diff --git a/ChangeLog b/ChangeLog index 8256c3a..f167c34 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Tue Feb 05 15:59:04 CET 2008 Frediano Ziglio + * src/tds/unittests/t0007.c: + - improve SYBINT8 conversions testing + Mon Feb 04 08:49:58 CET 2008 Frediano Ziglio * src/tds/convert.c: fix silly memory leak @@ -135,4 +139,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2482 2008/02/04 07:51:10 freddy77 Exp $ +$Id: ChangeLog,v 1.2483 2008/02/05 15:01:28 freddy77 Exp $ diff --git a/src/tds/unittests/t0007.c b/src/tds/unittests/t0007.c index d867fbe..1c20101 100644 --- a/src/tds/unittests/t0007.c +++ b/src/tds/unittests/t0007.c @@ -20,7 +20,7 @@ #include "common.h" #include -static char software_version[] = "$Id: t0007.c,v 1.14 2006/06/08 08:19:05 freddy77 Exp $"; +static char software_version[] = "$Id: t0007.c,v 1.15 2008/02/05 15:01:29 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static TDSCONTEXT ctx; @@ -39,6 +39,7 @@ test0(const char *src, int len, int dsttype, const char *result) if (res < 0) strcpy(buf, "error"); else { + buf[0] = 0; switch (dsttype) { case SYBINT1: sprintf(buf, "%d", cr.ti); @@ -49,6 +50,9 @@ test0(const char *src, int len, int dsttype, const char *result) case SYBINT4: sprintf(buf, "%d", cr.i); break; + case SYBINT8: + sprintf(buf, "0x%08x%08x", (unsigned int) ((cr.bi >> 32) & 0xfffffffflu), (unsigned int) (cr.bi & 0xfffffffflu)); + break; case SYBUNIQUE: sprintf(buf, "%08X-%04X-%04X-%02X%02X%02X%02X" "%02X%02X%02X%02X", @@ -92,9 +96,42 @@ main(int argc, char **argv) test("123", SYBINT1, "123"); test(" - 1234 ", SYBINT2, "-1234"); test(" - 1234 a", SYBINT2, "error"); + test("", SYBINT4, "0"); + test(" ", SYBINT4, "0"); + test(" 123", SYBINT4, "123"); + test(" 123 ", SYBINT4, "123"); + test(" + 123 ", SYBINT4, "123"); + test("+", SYBINT4, "error"); + test(" +", SYBINT4, "error"); + test("+ ", SYBINT4, "error"); + test(" + ", SYBINT4, "error"); + test("-", SYBINT4, "error"); + test(" -", SYBINT4, "error"); + test("- ", SYBINT4, "error"); + test(" - ", SYBINT4, "error"); + + test(" - 1234 ", SYBINT8, "0xfffffffffffffb2e"); + test(" - 1234 a", SYBINT8, "error"); + test("", SYBINT8, "0x0000000000000000"); + test(" ", SYBINT8, "0x0000000000000000"); + test(" 123", SYBINT8, "0x000000000000007b"); + test(" 123 ", SYBINT8, "0x000000000000007b"); + test(" + 123 ", SYBINT8, "0x000000000000007b"); + test("+", SYBINT8, "error"); + test(" +", SYBINT8, "error"); + test("+ ", SYBINT8, "error"); + test(" + ", SYBINT8, "error"); + test("-", SYBINT8, "error"); + test(" -", SYBINT8, "error"); + test("- ", SYBINT8, "error"); + test(" - ", SYBINT8, "error"); /* test for overflow */ printf("overflow checks...\n"); + test("9223372036854775807", SYBINT8, "0x7fffffffffffffff"); + test("9223372036854775808", SYBINT8, "error"); + test("-9223372036854775808", SYBINT8, "0x8000000000000000"); + test("-9223372036854775809", SYBINT8, "error"); test("2147483647", SYBINT4, "2147483647"); test("2147483648", SYBINT4, "error"); test("-2147483648", SYBINT4, "-2147483648"); @@ -121,6 +158,7 @@ main(int argc, char **argv) /* test not terminated string */ test0("1234", 2, SYBINT4, "12"); + test0("123456", 4, SYBINT8, "0x00000000000004d2"); /* some test for unique */ printf("unique type...\n"); commit 21dd3e0ae79e8b08d30c0553d19c359127307cc1 Author: freddy77 Date: Wed Feb 6 08:28:10 2008 +0000 use printf instead of fprintf(stdout...) diff --git a/ChangeLog b/ChangeLog index f167c34..d6e621a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Feb 06 09:27:10 CET 2008 Frediano Ziglio + * src/odbc/unittests/rpc.c src/odbc/unittests/cursor5.c: + * src/odbc/unittests/cursor4.c src/odbc/unittests/cursor3.c: + - use printf instead of fprintf(stdout...) + Tue Feb 05 15:59:04 CET 2008 Frediano Ziglio * src/tds/unittests/t0007.c: - improve SYBINT8 conversions testing @@ -139,4 +144,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2483 2008/02/05 15:01:28 freddy77 Exp $ +$Id: ChangeLog,v 1.2484 2008/02/06 08:28:10 freddy77 Exp $ diff --git a/src/odbc/unittests/cursor3.c b/src/odbc/unittests/cursor3.c index 6ef62c8..5a6849f 100644 --- a/src/odbc/unittests/cursor3.c +++ b/src/odbc/unittests/cursor3.c @@ -1,7 +1,7 @@ /* Tests 2 active statements */ #include "common.h" -static char software_version[] = "$Id: cursor3.c,v 1.5 2008/01/29 14:30:48 freddy77 Exp $"; +static char software_version[] = "$Id: cursor3.c,v 1.6 2008/02/06 08:28:10 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #define CHECK_RCODE(t,h,m) \ @@ -126,14 +126,14 @@ main(int argc, char **argv) rcode = SQLGetData(m_hstmt1, 2, SQL_C_CHAR, (SQLPOINTER) buff, sizeof(buff), &ind); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLGetData 1"); - fprintf(stdout, ">> Fetch from 1: [%s]\n", buff); + printf(">> Fetch from 1: [%s]\n", buff); rcode = SQLFetch(m_hstmt2); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt2, "SQLFetch 2"); rcode = SQLGetData(m_hstmt2, 2, SQL_C_CHAR, (SQLPOINTER) buff, sizeof(buff), &ind); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt2, "SQLGetData 2"); - fprintf(stdout, ">> Fetch from 2: [%s]\n", buff); + printf(">> Fetch from 2: [%s]\n", buff); rcode = SQLCloseCursor(m_hstmt1); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLCloseCursor 1"); diff --git a/src/odbc/unittests/cursor4.c b/src/odbc/unittests/cursor4.c index 363ebfd..c1ac6cd 100755 --- a/src/odbc/unittests/cursor4.c +++ b/src/odbc/unittests/cursor4.c @@ -5,7 +5,7 @@ #include "common.h" -static char software_version[] = "$Id: cursor4.c,v 1.5 2008/01/29 14:30:48 freddy77 Exp $"; +static char software_version[] = "$Id: cursor4.c,v 1.6 2008/02/06 08:28:10 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #define CHECK_RCODE(t,h,m) \ @@ -108,7 +108,7 @@ main(int argc, char **argv) rcode = SQLGetData(m_hstmt1, 1, SQL_C_CHAR, buff, sizeof(buff), &ind); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLGetData"); - fprintf(stdout, ">> New value after update = [%s] (should be [xxx]) \n", buff); + printf(">> New value after update = [%s] (should be [xxx]) \n", buff); rcode = SQLFreeHandle(SQL_HANDLE_STMT, (SQLHANDLE) m_hstmt1); CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt1, "SQLFreeHandle 1"); diff --git a/src/odbc/unittests/cursor5.c b/src/odbc/unittests/cursor5.c index d8c4540..9b300f5 100755 --- a/src/odbc/unittests/cursor5.c +++ b/src/odbc/unittests/cursor5.c @@ -1,6 +1,6 @@ #include "common.h" -static char software_version[] = "$Id: cursor5.c,v 1.4 2008/01/29 14:30:48 freddy77 Exp $"; +static char software_version[] = "$Id: cursor5.c,v 1.5 2008/02/06 08:28:10 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #define CHECK_RCODE(t,h,m) \ @@ -47,9 +47,9 @@ doFetch(SQLHSTMT m_hstmt, int dir, int pos) CHECK_RCODE(SQL_HANDLE_STMT, m_hstmt, "SQLFetchScroll"); if (rcode != SQL_NO_DATA) - fprintf(stdout, ">> fetch %2d %10d : %d [%s]\n", dir, pos, v_ind_3_1 ? (int) v_int_3 : -1, v_ind_3_2 ? v_char_3 : "null"); + printf(">> fetch %2d %10d : %d [%s]\n", dir, pos, v_ind_3_1 ? (int) v_int_3 : -1, v_ind_3_2 ? v_char_3 : "null"); else - fprintf(stdout, ">> fetch %2d %10d : no data found\n", dir, pos); + printf(">> fetch %2d %10d : no data found\n", dir, pos); } int diff --git a/src/odbc/unittests/rpc.c b/src/odbc/unittests/rpc.c index 5543dd4..23d8436 100644 --- a/src/odbc/unittests/rpc.c +++ b/src/odbc/unittests/rpc.c @@ -6,7 +6,7 @@ #include "common.h" #include -static char software_version[] = "$Id: rpc.c,v 1.8 2007/11/26 06:25:11 freddy77 Exp $"; +static char software_version[] = "$Id: rpc.c,v 1.9 2008/02/06 08:28:10 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static const char procedure_sql[] = @@ -38,7 +38,7 @@ init_proc(const char *name) static char cmd[4096]; if (name[0] != '#') { - fprintf(stdout, "Dropping procedure %s\n", name); + printf("Dropping procedure %s\n", name); sprintf(cmd, "if exists (select 1 from sysobjects where name = '%s' and type = 'P') " "DROP PROCEDURE %s", name, name); if (!SQL_SUCCEEDED(SQLExecDirect(Statement, (SQLCHAR *) cmd, SQL_NTS))) { @@ -47,14 +47,14 @@ init_proc(const char *name) } } - fprintf(stdout, "Creating procedure %s\n", name); + printf("Creating procedure %s\n", name); sprintf(cmd, procedure_sql, name); if (!SQL_SUCCEEDED(SQLExecDirect(Statement, (SQLCHAR *) cmd, SQL_NTS))) { if (name[0] == '#') - fprintf(stdout, "Failed to create procedure %s. Wrong permission or not MSSQL.\n", name); + printf("Failed to create procedure %s. Wrong permission or not MSSQL.\n", name); else - fprintf(stdout, "Failed to create procedure %s. Wrong permission.\n", name); + printf("Failed to create procedure %s. Wrong permission.\n", name); CheckReturn(); exit(1); } commit 33ba1e2143a8cdf5a80e28dc0b3e1641d1190c2c Author: freddy77 Date: Wed Feb 6 08:29:53 2008 +0000 simplify test diff --git a/ChangeLog b/ChangeLog index d6e621a..49811a7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +Wed Feb 06 09:28:55 CET 2008 Frediano Ziglio + * src/odbc/unittests/testodbc.c: simplify + Wed Feb 06 09:27:10 CET 2008 Frediano Ziglio * src/odbc/unittests/rpc.c src/odbc/unittests/cursor5.c: * src/odbc/unittests/cursor4.c src/odbc/unittests/cursor3.c: @@ -144,4 +147,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2484 2008/02/06 08:28:10 freddy77 Exp $ +$Id: ChangeLog,v 1.2485 2008/02/06 08:29:53 freddy77 Exp $ diff --git a/src/odbc/unittests/testodbc.c b/src/odbc/unittests/testodbc.c index c800bcb..5ab9325 100644 --- a/src/odbc/unittests/testodbc.c +++ b/src/odbc/unittests/testodbc.c @@ -10,7 +10,7 @@ #include "common.h" -static char software_version[] = "$Id: testodbc.c,v 1.9 2005/06/29 07:21:24 freddy77 Exp $"; +static char software_version[] = "$Id: testodbc.c,v 1.10 2008/02/06 08:29:53 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #ifdef DEBUG @@ -40,25 +40,25 @@ typedef struct * Output ODBC errors. */ static void -DispODBCErrs(SQLHENV envHandle, SQLHDBC connHandle, SQLHSTMT statementHandle) +DispODBCErrs(void) { SQLCHAR buffer[256]; SQLCHAR sqlState[16]; /* Statement errors */ - if (statementHandle) { - while (SQLError(envHandle, connHandle, statementHandle, sqlState, 0, buffer, sizeof(buffer), 0) == SQL_SUCCESS) { + if (Statement) { + while (SQLError(Environment, Connection, Statement, sqlState, 0, buffer, sizeof(buffer), 0) == SQL_SUCCESS) { AB_ERROR(("%s, SQLSTATE=%s", buffer, sqlState)); } } /* Connection errors */ - while (SQLError(envHandle, connHandle, SQL_NULL_HSTMT, sqlState, 0, buffer, sizeof(buffer), 0) == SQL_SUCCESS) { + while (SQLError(Environment, Connection, SQL_NULL_HSTMT, sqlState, 0, buffer, sizeof(buffer), 0) == SQL_SUCCESS) { AB_ERROR(("%s, SQLSTATE=%s", buffer, sqlState)); } /* Environmental errors */ - while (SQLError(envHandle, SQL_NULL_HDBC, SQL_NULL_HSTMT, sqlState, 0, buffer, sizeof(buffer), 0) == SQL_SUCCESS) { + while (SQLError(Environment, SQL_NULL_HDBC, SQL_NULL_HSTMT, sqlState, 0, buffer, sizeof(buffer), 0) == SQL_SUCCESS) { AB_ERROR(("%s, SQLSTATE=%s", buffer, sqlState)); } } @@ -67,7 +67,7 @@ DispODBCErrs(SQLHENV envHandle, SQLHDBC connHandle, SQLHSTMT statementHandle) * Output ODBC diagnostics. Only used for 'raw' ODBC tests. */ static void -DispODBCDiags(SQLHSTMT statementHandle) +DispODBCDiags(void) { SQLSMALLINT recNumber; SQLCHAR sqlState[10]; @@ -82,7 +82,7 @@ DispODBCDiags(SQLHSTMT statementHandle) AB_FUNCT(("DispODBCDiags (in)")); do { - status = SQLGetDiagRec(SQL_HANDLE_STMT, statementHandle, recNumber, + status = SQLGetDiagRec(SQL_HANDLE_STMT, Statement, recNumber, sqlState, &nativeError, messageText, bufferLength, &textLength); if (status != SQL_SUCCESS) { /* No data mean normal end of iteration. Anything else is error. */ @@ -137,13 +137,13 @@ TestRawODBCPreparedQuery(void) "INSERT INTO #Products(ProductID,ProductName,SupplierID,CategoryID,QuantityPerUnit,UnitPrice,UnitsInStock,UnitsOnOrder,ReorderLevel,Discontinued) VALUES(12,'Queso Manchego La Pastora',5,4,'10 - 500 g pkgs.',38.00,86,0,0,0)"); while (SQLMoreResults(Statement) == SQL_SUCCESS); - strcpy((char *) (queryString), "SELECT * FROM #Products WHERE SupplierID = ?"); + strcpy((char *) queryString, "SELECT * FROM #Products WHERE SupplierID = ?"); status = SQLBindParameter(Statement, 1, SQL_PARAM_INPUT, SQL_C_SSHORT, SQL_INTEGER, 0, 0, &supplierId, 0, &lenOrInd); if (status != SQL_SUCCESS) { AB_ERROR(("SQLBindParameter failed")); - DispODBCErrs(Environment, Connection, Statement); - DispODBCDiags(Statement); + DispODBCErrs(); + DispODBCDiags(); AB_FUNCT(("TestRawODBCPreparedQuery (out): error")); return FALSE; } @@ -158,8 +158,8 @@ TestRawODBCPreparedQuery(void) status = SQLExecute(Statement); if (status != SQL_SUCCESS) { AB_ERROR(("Execute failed")); - DispODBCErrs(Environment, Connection, Statement); - DispODBCDiags(Statement); + DispODBCErrs(); + DispODBCDiags(); AB_FUNCT(("TestRawODBCPreparedQuery (out): error")); return FALSE; } @@ -228,13 +228,13 @@ TestRawODBCDirectQuery(void) "INSERT INTO #Products(ProductID,ProductName,SupplierID,CategoryID,QuantityPerUnit,UnitPrice,UnitsInStock,UnitsOnOrder,ReorderLevel,Discontinued) VALUES(5,'Chef Anton''s Gumbo Mix',2,2,'36 boxes',21.35,0,0,0,1) "); while (SQLMoreResults(Statement) == SQL_SUCCESS); - strcpy((char *) (queryString), "SELECT * FROM #Products WHERE SupplierID = ?"); + strcpy((char *) queryString, "SELECT * FROM #Products WHERE SupplierID = ?"); status = SQLBindParameter(Statement, 1, SQL_PARAM_INPUT, SQL_C_SSHORT, SQL_INTEGER, 0, 0, &supplierId, 0, &lenOrInd); if (status != SQL_SUCCESS) { AB_ERROR(("SQLBindParameter failed")); - DispODBCErrs(Environment, Connection, Statement); - DispODBCDiags(Statement); + DispODBCErrs(); + DispODBCDiags(); AB_FUNCT(("TestRawODBCDirectQuery (out): error")); return FALSE; } @@ -242,8 +242,8 @@ TestRawODBCDirectQuery(void) status = SQLExecDirect(Statement, queryString, SQL_NTS); if (status != SQL_SUCCESS) { AB_ERROR(("Execute failed")); - DispODBCErrs(Environment, Connection, Statement); - DispODBCDiags(Statement); + DispODBCErrs(); + DispODBCDiags(); AB_FUNCT(("TestRawODBCDirectQuery (out): error")); return FALSE; } @@ -581,8 +581,8 @@ TestRawODBCGuid(void) return TRUE; odbcfail: - DispODBCErrs(Environment, Connection, Statement); - DispODBCDiags(Statement); + DispODBCErrs(); + DispODBCDiags(); AB_FUNCT(("TestRawODBCGuid (out): error")); return FALSE; } commit d7c53b3a37cdfc0160316ccfb2f86d0668b2fbbd Author: freddy77 Date: Thu Feb 7 22:05:36 2008 +0000 improve bigint test diff --git a/src/tds/unittests/t0007.c b/src/tds/unittests/t0007.c index 1c20101..161280b 100644 --- a/src/tds/unittests/t0007.c +++ b/src/tds/unittests/t0007.c @@ -20,7 +20,7 @@ #include "common.h" #include -static char software_version[] = "$Id: t0007.c,v 1.15 2008/02/05 15:01:29 freddy77 Exp $"; +static char software_version[] = "$Id: t0007.c,v 1.16 2008/02/07 22:05:36 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static TDSCONTEXT ctx; @@ -111,6 +111,7 @@ main(int argc, char **argv) test(" - ", SYBINT4, "error"); test(" - 1234 ", SYBINT8, "0xfffffffffffffb2e"); + test("1234x", SYBINT8, "error"); test(" - 1234 a", SYBINT8, "error"); test("", SYBINT8, "0x0000000000000000"); test(" ", SYBINT8, "0x0000000000000000"); @@ -155,6 +156,10 @@ main(int argc, char **argv) test("63147483647", SYBINT4, "error"); test("64147483647", SYBINT4, "error"); test("65147483647", SYBINT4, "error"); + test("53248632876323876761", SYBINT8, "error"); + test("56248632876323876761", SYBINT8, "error"); + test("59248632876323876761", SYBINT8, "error"); + test("12248632876323876761", SYBINT8, "error"); /* test not terminated string */ test0("1234", 2, SYBINT4, "12"); commit 47a97f5e23af4b3281f5f710d0ee14e3541b949f Author: freddy77 Date: Fri Feb 8 08:31:19 2008 +0000 reuse code and macros diff --git a/ChangeLog b/ChangeLog index 49811a7..cc65a1b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +Fri Feb 08 09:30:48 CET 2008 Frediano Ziglio + * src/odbc/unittests/rpc.c: reuse code and macros + Wed Feb 06 09:28:55 CET 2008 Frediano Ziglio * src/odbc/unittests/testodbc.c: simplify @@ -147,4 +150,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2485 2008/02/06 08:29:53 freddy77 Exp $ +$Id: ChangeLog,v 1.2486 2008/02/08 08:31:19 freddy77 Exp $ diff --git a/src/odbc/unittests/rpc.c b/src/odbc/unittests/rpc.c index 23d8436..3b58e29 100644 --- a/src/odbc/unittests/rpc.c +++ b/src/odbc/unittests/rpc.c @@ -6,7 +6,7 @@ #include "common.h" #include -static char software_version[] = "$Id: rpc.c,v 1.9 2008/02/06 08:28:10 freddy77 Exp $"; +static char software_version[] = "$Id: rpc.c,v 1.10 2008/02/08 08:31:19 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static const char procedure_sql[] = @@ -97,8 +97,7 @@ Test(const char *name) printf("executing SQLAllocStmt\n"); - if (SQLAllocStmt(Connection, &stmt) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to allocate statement"); + CHK(SQLAllocStmt, (Connection, &stmt)); for( ipar=0; ipar < sizeof(args)/sizeof(args[0]); ipar++ ) { printf("executing SQLBindParameter for parameter %d\n", 1+ipar); @@ -108,7 +107,7 @@ Test(const char *name) memset(args[ipar].ParameterValuePtr, 0, args[ipar].BufferLength); memset(args[ipar].ParameterValuePtr, 'a', args[ipar].BufferLength - 1); } - erc = SQLBindParameter ( stmt, 1+ipar + CHK(SQLBindParameter, ( stmt, 1+ipar , args[ipar].InputOutputType , args[ipar].ValueType , args[ipar].ParameterType @@ -117,58 +116,41 @@ Test(const char *name) , args[ipar].ParameterValuePtr , args[ipar].BufferLength , &args[ipar].ind - ); - if (erc != SQL_SUCCESS) { - fprintf(stderr, "Failed: SQLBindParameter\n"); - exit(1); - } + )); } - - sprintf(call_cmd, "{?=call %s(?,?,?,?,?)}", name ); printf("executing SQLPrepare: %s\n", call_cmd); - if (SQLPrepare(stmt, (SQLCHAR *) call_cmd, SQL_NTS) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to prepare statement"); + CHK(SQLPrepare, (stmt, (SQLCHAR *) call_cmd, SQL_NTS)); printf("executing SQLExecute\n"); if (! SQL_SUCCEEDED(SQLExecute(stmt))) { erc = SQLGetDiagRec(SQL_HANDLE_STMT, stmt, 1, sqlstate, NULL, msg, sizeof(msg), NULL); fprintf(stderr, "SQL error %s -- %s\n", sqlstate, msg); ODBC_REPORT_ERROR("Unable to execute SQLExecute\n"); - } do { - static const char dashes[] = "------------------------------", - *dashes5 = &dashes[25], - *dashes15 = &dashes[15]; + static const char dashes[] = "------------------------------"; int nrows; SQLSMALLINT icol, ncols; - SQLCHAR name[256] = ""; - SQLSMALLINT namelen; - SQLSMALLINT type; - SQLSMALLINT scale; - SQLSMALLINT nullable; - + SQLCHAR name[256] = ""; + SQLSMALLINT namelen; + SQLSMALLINT type; + SQLSMALLINT scale; + SQLSMALLINT nullable; + printf("executing SQLNumResultCols for result set %d\n", ++iresults); - if((erc = SQLNumResultCols(stmt, &ncols)) != SQL_SUCCESS) { - ODBC_REPORT_ERROR("Unable to execute SQLNumResultCols\n"); - } + CHK(SQLNumResultCols, (stmt, &ncols)); printf("executing SQLDescribeCol for %d column%c\n", ncols, (ncols == 1? ' ' : 's')); - printf("%-5s %-15s %5s %5s %5s %8s\n", "col", "name", "type", "size", "scale", "nullable"); - printf("%-5s %-15s %5s %5s %5s %8s\n", dashes5, dashes15, dashes5, dashes5, dashes5, &dashes[30-8]); + printf("%-5.5s %-15.15s %5.5s %5.5s %5.5s %8.8s\n", "col", "name", "type", "size", "scale", "nullable"); + printf("%-5.5s %-15.15s %5.5s %5.5s %5.5s %8.8s\n", dashes, dashes, dashes, dashes, dashes, dashes); for (icol=ncols; icol > 0; icol--) { - SQLULEN size; - erc = SQLDescribeCol( stmt, icol, name, sizeof(name), - &namelen, &type, &size, &scale, &nullable); - if (erc != SQL_SUCCESS) { - erc = SQLGetDiagRec(SQL_HANDLE_STMT, stmt, 1, sqlstate, NULL, msg, sizeof(msg), NULL); - fprintf(stderr, "SQL error %s -- %s\n", sqlstate, msg); - ODBC_REPORT_ERROR("Unable to execute SQLDescribeCol\n"); - } + SQLULEN size; + CHK(SQLDescribeCol, (stmt, icol, name, sizeof(name), + &namelen, &type, &size, &scale, &nullable)); printf("%-5d %-15s %5d %5ld %5d %8c\n", icol, name, type, (long int)size, scale, (nullable? 'Y' : 'N')); } @@ -238,8 +220,7 @@ Test(const char *name) } printf("executing SQLFreeStmt\n"); - if (SQLFreeStmt(stmt, SQL_DROP) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to free statement"); + CHK(SQLFreeStmt, (stmt, SQL_DROP)); for (ipar = 0; ipar < sizeof(args)/sizeof(args[0]); ++ipar) if (args[ipar].BufferLength > 0) @@ -268,12 +249,7 @@ main(int argc, char *argv[]) Test(proc_name); printf("dropping procedure\n"); - if (!SQL_SUCCEEDED(SQLExecDirect(Statement, (SQLCHAR *) drop_proc, SQL_NTS))) { - printf("Unable to drop procedure\n"); - CheckReturn(); - exit(1); - } - + Command(Statement, drop_proc); Disconnect(); commit 4c9b9c1626339d75cbf2cc077fbdebd3674408c8 Author: freddy77 Date: Fri Feb 8 08:33:09 2008 +0000 *** empty log message *** diff --git a/src/odbc/unittests/.cvsignore b/src/odbc/unittests/.cvsignore index 2aea2d3..fb6855d 100644 --- a/src/odbc/unittests/.cvsignore +++ b/src/odbc/unittests/.cvsignore @@ -66,3 +66,4 @@ hidden blob1 cancel test64 +wchar commit 656c4bad229439cc87140c70429165dcfa1881ea Author: freddy77 Date: Fri Feb 8 09:28:01 2008 +0000 more reuse in tests diff --git a/ChangeLog b/ChangeLog index cc65a1b..393b4a0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Fri Feb 08 10:26:36 CET 2008 Frediano Ziglio + * src/odbc/unittests/Makefile.am src/odbc/unittests/describecol.in: + * src/odbc/unittests/params.c src/odbc/unittests/putdata.c: + * src/odbc/unittests/raiserror.c src/odbc/unittests/rownumber.c: + * src/odbc/unittests/t0001.c src/odbc/unittests/t0002.c: + * src/odbc/unittests/testodbc.c src/odbc/unittests/timeout3.c: + - more reuse and unification + Fri Feb 08 09:30:48 CET 2008 Frediano Ziglio * src/odbc/unittests/rpc.c: reuse code and macros @@ -150,4 +158,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2486 2008/02/08 08:31:19 freddy77 Exp $ +$Id: ChangeLog,v 1.2487 2008/02/08 09:28:01 freddy77 Exp $ diff --git a/src/odbc/unittests/Makefile.am b/src/odbc/unittests/Makefile.am index 7fca97b..f9e14f9 100644 --- a/src/odbc/unittests/Makefile.am +++ b/src/odbc/unittests/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am,v 1.71 2008/01/10 16:05:59 freddy77 Exp $ +# $Id: Makefile.am,v 1.72 2008/02/08 09:28:03 freddy77 Exp $ TESTS = \ t0001$(EXEEXT) t0002$(EXEEXT) t0003$(EXEEXT)\ t0004$(EXEEXT) connect$(EXEEXT) print$(EXEEXT)\ @@ -21,7 +21,7 @@ TESTS = \ connect2$(EXEEXT) timeout4$(EXEEXT) freeclose$(EXEEXT) \ cursor3$(EXEEXT) cursor4$(EXEEXT) cursor5$(EXEEXT) \ attributes$(EXEEXT) hidden$(EXEEXT) blob1$(EXEEXT) \ - cancel$(EXEEXT) + cancel$(EXEEXT) wchar$(EXEEXT) check_PROGRAMS = $(TESTS) @@ -81,6 +81,7 @@ attributes_SOURCES = attributes.c common.c common.h hidden_SOURCES = hidden.c common.c common.h blob1_SOURCES = blob1.c common.c common.h cancel_SOURCES = cancel.c common.c common.h +wchar_SOURCES = wchar.c common.c common.h AM_CPPFLAGS = -I$(top_srcdir)/include $(ODBC_INC) -DFREETDS_SRCDIR=\"$(srcdir)\" if MINGW32 diff --git a/src/odbc/unittests/describecol.in b/src/odbc/unittests/describecol.in index aa6a63a..b1aaa7f 100644 --- a/src/odbc/unittests/describecol.in +++ b/src/odbc/unittests/describecol.in @@ -153,25 +153,21 @@ attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 11 select nchar(12) 'hi!' -## TODO -#attr SQL_COLUMN_LENGTH 24 +attr SQL_COLUMN_LENGTH 24 attr SQL_COLUMN_PRECISION 12 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 12 -## TODO -#attr SQL_DESC_OCTET_LENGTH 24 +attr SQL_DESC_OCTET_LENGTH 24 attr SQL_DESC_PRECISION 12 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 12 select nvarchar(13) 'hi!' -## TODO -#attr SQL_COLUMN_LENGTH 26 +attr SQL_COLUMN_LENGTH 26 attr SQL_COLUMN_PRECISION 13 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 13 -## TODO -#attr SQL_DESC_OCTET_LENGTH 26 +attr SQL_DESC_OCTET_LENGTH 26 attr SQL_DESC_PRECISION 13 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 13 @@ -187,13 +183,11 @@ attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 4096 select ntext 'hi!' -## TODO -#attr SQL_COLUMN_LENGTH 4096 +attr SQL_COLUMN_LENGTH 4096 attr SQL_COLUMN_PRECISION 2048 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 2048 -## TODO -#attr SQL_DESC_OCTET_LENGTH 4096 +attr SQL_DESC_OCTET_LENGTH 4096 attr SQL_DESC_PRECISION 2048 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 2048 @@ -385,25 +379,21 @@ attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 11 select nchar(12) 'hi!' -## TODO -#attr SQL_COLUMN_LENGTH 24 +attr SQL_COLUMN_LENGTH 24 attr SQL_COLUMN_PRECISION 12 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 12 -## TODO -#attr SQL_DESC_OCTET_LENGTH 24 +attr SQL_DESC_OCTET_LENGTH 24 attr SQL_DESC_PRECISION 12 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 12 select nvarchar(13) 'hi!' -## TODO -#attr SQL_COLUMN_LENGTH 26 +attr SQL_COLUMN_LENGTH 26 attr SQL_COLUMN_PRECISION 13 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 13 -## TODO -#attr SQL_DESC_OCTET_LENGTH 26 +attr SQL_DESC_OCTET_LENGTH 26 attr SQL_DESC_PRECISION 13 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 13 @@ -419,13 +409,11 @@ attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 4096 select ntext 'hi!' -## TODO -#attr SQL_COLUMN_LENGTH 4096 +attr SQL_COLUMN_LENGTH 4096 attr SQL_COLUMN_PRECISION 2048 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 2048 -## TODO -#attr SQL_DESC_OCTET_LENGTH 4096 +attr SQL_DESC_OCTET_LENGTH 4096 attr SQL_DESC_PRECISION 2048 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 2048 diff --git a/src/odbc/unittests/params.c b/src/odbc/unittests/params.c index 191066c..dc382cb 100644 --- a/src/odbc/unittests/params.c +++ b/src/odbc/unittests/params.c @@ -3,7 +3,7 @@ /* Test for store procedure and params */ /* Test from Tom Rogers */ -static char software_version[] = "$Id: params.c,v 1.8 2008/01/29 14:30:48 freddy77 Exp $"; +static char software_version[] = "$Id: params.c,v 1.9 2008/02/08 09:28:03 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; /* SP definition */ @@ -33,8 +33,7 @@ Test(int bind_before) Connect(); /* drop proc */ - if (CommandWithResult(Statement, "drop proc spTestProc") != SQL_SUCCESS) - printf("Unable to execute statement\n"); + Command(Statement, "IF OBJECT_ID('spTestProc') IS NOT NULL DROP PROC spTestProc"); /* create proc */ Command(Statement, sp_define); @@ -56,7 +55,7 @@ Test(int bind_before) CHK(SQLExecute, (Statement)); - Command(Statement, "drop proc spTestProc"); + Command(Statement, "DROP PROC spTestProc"); printf("Output:\n"); printf(" Return Code = %d\n", (int) ReturnCode); diff --git a/src/odbc/unittests/putdata.c b/src/odbc/unittests/putdata.c index a9d3878..3eff23f 100644 --- a/src/odbc/unittests/putdata.c +++ b/src/odbc/unittests/putdata.c @@ -2,7 +2,7 @@ /* Test for SQLPutData */ -static char software_version[] = "$Id: putdata.c,v 1.10 2008/01/29 14:30:48 freddy77 Exp $"; +static char software_version[] = "$Id: putdata.c,v 1.11 2008/02/08 09:28:04 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static const char test_text[] = @@ -49,8 +49,7 @@ main(int argc, char *argv[]) if (l < n) n = l; - if (SQLPutData(Statement, (char *) p, n) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Wrong result from SQLPutData"); + CHK(SQLPutData, (Statement, (char *) p, n)); p += n; n *= 2; } diff --git a/src/odbc/unittests/raiserror.c b/src/odbc/unittests/raiserror.c index 76fd66f..3395ad4 100644 --- a/src/odbc/unittests/raiserror.c +++ b/src/odbc/unittests/raiserror.c @@ -4,7 +4,7 @@ /* TODO add support for Sybase */ -static char software_version[] = "$Id: raiserror.c,v 1.20 2008/01/29 14:30:48 freddy77 Exp $"; +static char software_version[] = "$Id: raiserror.c,v 1.21 2008/02/08 09:28:04 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #define SP_TEXT "{?=call #tmp1(?,?,?)}" @@ -209,9 +209,8 @@ Test(int level) } if (!use_odbc_version3 || !g_nocount) { - result = SQLMoreResults(Statement); - if (result != SQL_SUCCESS) - ODBC_REPORT_ERROR("SQLMoreResults returned failure"); + CHK(SQLMoreResults, (Statement)); + result = SQL_SUCCESS; } CheckReturnCode(result, INVALID_RETURN); diff --git a/src/odbc/unittests/rownumber.c b/src/odbc/unittests/rownumber.c index d2c213f..55eddaf 100644 --- a/src/odbc/unittests/rownumber.c +++ b/src/odbc/unittests/rownumber.c @@ -7,7 +7,7 @@ * TODO make it work and add to Makefile.am */ -static char software_version[] = "$Id: rownumber.c,v 1.2 2005/01/14 15:03:12 freddy77 Exp $"; +static char software_version[] = "$Id: rownumber.c,v 1.3 2008/02/08 09:28:04 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static void @@ -62,8 +62,8 @@ DoTest() static const char query[] = "SELECT * FROM #tmp1 ORDER BY i SELECT * FROM #tmp1 WHERE i < 3 ORDER BY i"; /* execute a batch command and check row number */ - if (SQLExecDirect(Statement, (SQLCHAR *) query, SQL_NTS) != SQL_SUCCESS) - ODBC_REPORT_ERROR("Unable to execute direct statement"); + CHK(SQLExecDirect, (Statement, (SQLCHAR *) query, SQL_NTS)); + CHECK_ROWS(-1); printf("Result %d\n", ++n); Fetch(SQL_SUCCESS); diff --git a/src/odbc/unittests/t0001.c b/src/odbc/unittests/t0001.c index 6ca6c8d..a51adea 100644 --- a/src/odbc/unittests/t0001.c +++ b/src/odbc/unittests/t0001.c @@ -1,6 +1,6 @@ #include "common.h" -static char software_version[] = "$Id: t0001.c,v 1.15 2008/01/29 14:30:49 freddy77 Exp $"; +static char software_version[] = "$Id: t0001.c,v 1.16 2008/02/08 09:28:04 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; int @@ -17,8 +17,7 @@ main(int argc, char *argv[]) Connect(); - if (CommandWithResult(Statement, "drop table #odbctestdata") != SQL_SUCCESS) - printf("Unable to execute statement\n"); + Command(Statement, "if object_id('tempdb..#odbctestdata') is not null drop table #odbctestdata"); command = "create table #odbctestdata (" "col1 varchar(30) not null," diff --git a/src/odbc/unittests/t0002.c b/src/odbc/unittests/t0002.c index 8fa2830..af7cfc3 100644 --- a/src/odbc/unittests/t0002.c +++ b/src/odbc/unittests/t0002.c @@ -1,6 +1,6 @@ #include "common.h" -static char software_version[] = "$Id: t0002.c,v 1.13 2008/01/29 14:30:49 freddy77 Exp $"; +static char software_version[] = "$Id: t0002.c,v 1.14 2008/02/08 09:28:04 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; int @@ -12,8 +12,7 @@ main(int argc, char *argv[]) Connect(); - if (CommandWithResult(Statement, "drop table #odbctestdata") != SQL_SUCCESS) - printf("Unable to execute statement\n"); + Command(Statement, "if object_id('tempdb..#odbctestdata') is not null drop table #odbctestdata"); Command(Statement, "create table #odbctestdata (i int)"); Command(Statement, "insert #odbctestdata values (123)"); diff --git a/src/odbc/unittests/testodbc.c b/src/odbc/unittests/testodbc.c index 5ab9325..61e80bb 100644 --- a/src/odbc/unittests/testodbc.c +++ b/src/odbc/unittests/testodbc.c @@ -10,7 +10,7 @@ #include "common.h" -static char software_version[] = "$Id: testodbc.c,v 1.10 2008/02/06 08:29:53 freddy77 Exp $"; +static char software_version[] = "$Id: testodbc.c,v 1.11 2008/02/08 09:28:04 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #ifdef DEBUG @@ -139,30 +139,11 @@ TestRawODBCPreparedQuery(void) strcpy((char *) queryString, "SELECT * FROM #Products WHERE SupplierID = ?"); - status = SQLBindParameter(Statement, 1, SQL_PARAM_INPUT, SQL_C_SSHORT, SQL_INTEGER, 0, 0, &supplierId, 0, &lenOrInd); - if (status != SQL_SUCCESS) { - AB_ERROR(("SQLBindParameter failed")); - DispODBCErrs(); - DispODBCDiags(); - AB_FUNCT(("TestRawODBCPreparedQuery (out): error")); - return FALSE; - } + CHK(SQLBindParameter, (Statement, 1, SQL_PARAM_INPUT, SQL_C_SSHORT, SQL_INTEGER, 0, 0, &supplierId, 0, &lenOrInd)); - status = SQLPrepare(Statement, queryString, SQL_NTS); - if (status != SQL_SUCCESS) { - AB_ERROR(("Prepare failed")); - AB_FUNCT(("TestRawODBCPreparedQuery (out): error")); - return FALSE; - } + CHK(SQLPrepare, (Statement, queryString, SQL_NTS)); - status = SQLExecute(Statement); - if (status != SQL_SUCCESS) { - AB_ERROR(("Execute failed")); - DispODBCErrs(); - DispODBCDiags(); - AB_FUNCT(("TestRawODBCPreparedQuery (out): error")); - return FALSE; - } + CHK(SQLExecute, (Statement)); count = 0; @@ -230,23 +211,9 @@ TestRawODBCDirectQuery(void) strcpy((char *) queryString, "SELECT * FROM #Products WHERE SupplierID = ?"); - status = SQLBindParameter(Statement, 1, SQL_PARAM_INPUT, SQL_C_SSHORT, SQL_INTEGER, 0, 0, &supplierId, 0, &lenOrInd); - if (status != SQL_SUCCESS) { - AB_ERROR(("SQLBindParameter failed")); - DispODBCErrs(); - DispODBCDiags(); - AB_FUNCT(("TestRawODBCDirectQuery (out): error")); - return FALSE; - } + CHK(SQLBindParameter, (Statement, 1, SQL_PARAM_INPUT, SQL_C_SSHORT, SQL_INTEGER, 0, 0, &supplierId, 0, &lenOrInd)); - status = SQLExecDirect(Statement, queryString, SQL_NTS); - if (status != SQL_SUCCESS) { - AB_ERROR(("Execute failed")); - DispODBCErrs(); - DispODBCDiags(); - AB_FUNCT(("TestRawODBCDirectQuery (out): error")); - return FALSE; - } + CHK(SQLExecDirect, (Statement, queryString, SQL_NTS)); count = 0; @@ -326,11 +293,7 @@ TestRawODBCGuid(void) strcpy((char *) (queryString), "INSERT INTO #pet( name, owner, species, sex, age ) \ VALUES ( 'Fang', 'Mike', 'dog', 'm', 12 );"); - status = SQLExecDirect(Statement, queryString, SQL_NTS); - if (status != SQL_SUCCESS) { - AB_ERROR(("Insert row 1 failed")); - goto odbcfail; - } + CHK(SQLExecDirect, (Statement, queryString, SQL_NTS)); AB_PRINT(("Insert row 2")); @@ -343,21 +306,10 @@ TestRawODBCGuid(void) lenOrInd = 0; age = 3; - if (SQLBindParameter(Statement, 1, SQL_PARAM_INPUT, SQL_C_SSHORT, SQL_INTEGER, 0, 0, &age, 0, &lenOrInd) - != SQL_SUCCESS) { - AB_ERROR(("SQLBindParameter failed")); - goto odbcfail; - } + CHK(SQLBindParameter, (Statement, 1, SQL_PARAM_INPUT, SQL_C_SSHORT, SQL_INTEGER, 0, 0, &age, 0, &lenOrInd)); - status = SQLExecDirect(Statement, queryString, SQL_NTS); - if (status != SQL_SUCCESS) { - AB_ERROR(("Insert row 2 failed")); - goto odbcfail; - } - if (SQLFreeStmt(Statement, SQL_CLOSE) != SQL_SUCCESS) { - AB_ERROR(("Free statement failed (5)")); - goto odbcfail; - } + CHK(SQLExecDirect, (Statement, queryString, SQL_NTS)); + CHK(SQLFreeStmt, (Statement, SQL_CLOSE)); AB_PRINT(("Insert row 3")); /* @@ -369,16 +321,8 @@ TestRawODBCGuid(void) lenOrInd = SQL_NTS; strcpy((char *) (guid), "87654321-4321-4321-4321-123456789abc"); - if (SQLBindParameter(Statement, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_GUID, 0, 0, guid, 0, &lenOrInd) - != SQL_SUCCESS) { - AB_ERROR(("SQLBindParameter failed")); - goto odbcfail; - } - status = SQLExecDirect(Statement, queryString, SQL_NTS); - if (status != SQL_SUCCESS) { - AB_ERROR(("Insert row 3 failed")); - goto odbcfail; - } + CHK(SQLBindParameter, (Statement, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_GUID, 0, 0, guid, 0, &lenOrInd)); + CHK(SQLExecDirect, (Statement, queryString, SQL_NTS)); AB_PRINT(("Insert row 4")); /* @@ -390,16 +334,8 @@ TestRawODBCGuid(void) lenOrInd = SQL_NTS; strcpy((char *) (guid), "1234abcd-abcd-abcd-abcd-123456789abc"); - if (SQLBindParameter(Statement, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 36, 0, guid, 0, &lenOrInd) - != SQL_SUCCESS) { - AB_ERROR(("SQLBindParameter failed")); - goto odbcfail; - } - status = SQLExecDirect(Statement, queryString, SQL_NTS); - if (status != SQL_SUCCESS) { - AB_ERROR(("Insert row 4 failed")); - goto odbcfail; - } + CHK(SQLBindParameter, (Statement, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 36, 0, guid, 0, &lenOrInd)); + CHK(SQLExecDirect, (Statement, queryString, SQL_NTS)); AB_PRINT(("Insert row 5")); /* @@ -423,11 +359,7 @@ TestRawODBCGuid(void) lenOrInd = 16; strcpy((char *) (guid), "1234abcd-abcd-abcd-abcd-123456789abc"); - if (SQLBindParameter(Statement, 1, SQL_PARAM_INPUT, SQL_C_GUID, SQL_GUID, 16, 0, &sqlguid, 16, &lenOrInd) - != SQL_SUCCESS) { - AB_ERROR(("SQLBindParameter failed")); - goto odbcfail; - } + CHK(SQLBindParameter(Statement, 1, SQL_PARAM_INPUT, SQL_C_GUID, SQL_GUID, 16, 0, &sqlguid, 16, &lenOrInd)); status = SQLExecDirect(Statement, queryString, SQL_NTS); if (status != SQL_SUCCESS) { AB_ERROR(("Insert row 5 failed")); @@ -439,23 +371,11 @@ TestRawODBCGuid(void) */ AB_PRINT(("retrieving name and guid")); strcpy((char *) (queryString), "SELECT name, guid FROM #pet"); - status = SQLExecDirect(Statement, queryString, SQL_NTS); - if (status != SQL_SUCCESS) { - AB_ERROR(("SELECT failed")); - goto odbcfail; - } + CHK(SQLExecDirect, (Statement, queryString, SQL_NTS)); while (SQLFetch(Statement) == SQL_SUCCESS) { count++; - if (SQLGetData(Statement, 1, SQL_CHAR, name, 20, 0) - != SQL_SUCCESS) { - AB_ERROR(("Get row %d, name column failed", count)); - goto odbcfail; - } - if (SQLGetData(Statement, 2, SQL_CHAR, guid, 37, 0) - != SQL_SUCCESS) { - AB_ERROR(("Get row %d, guid column failed", count)); - goto odbcfail; - } + CHK(SQLGetData, (Statement, 1, SQL_CHAR, name, 20, 0)); + CHK(SQLGetData, (Statement, 2, SQL_CHAR, guid, 37, 0)); AB_PRINT(("name: %-10s guid: %s", name, guid)); } @@ -464,15 +384,8 @@ TestRawODBCGuid(void) * Realloc cursor handle - (Windows ODBC considers it an invalid cursor * state if we try SELECT again). */ - if (SQLFreeStmt(Statement, SQL_CLOSE) != SQL_SUCCESS) { - AB_ERROR(("Free statement failed (5)")); - goto odbcfail; - } - if (SQLAllocHandle(SQL_HANDLE_STMT, Connection, &Statement) - != SQL_SUCCESS) { - AB_ERROR(("SQLAllocStmt failed(1)")); - goto odbcfail; - } + CHK(SQLFreeStmt, (Statement, SQL_CLOSE)); + CHK(SQLAllocHandle, (SQL_HANDLE_STMT, Connection, &Statement)); /* @@ -481,23 +394,11 @@ TestRawODBCGuid(void) AB_PRINT(("retrieving name and guid again")); strcpy((char *) (queryString), "SELECT name, guid FROM #pet"); - status = SQLExecDirect(Statement, queryString, SQL_NTS); - if (status != SQL_SUCCESS) { - AB_ERROR(("SELECT failed")); - goto odbcfail; - } + CHK(SQLExecDirect, (Statement, queryString, SQL_NTS)); while (SQLFetch(Statement) == SQL_SUCCESS) { count++; - if (SQLGetData(Statement, 1, SQL_CHAR, name, 20, 0) - != SQL_SUCCESS) { - AB_ERROR(("Get row %d, name column failed", count)); - goto odbcfail; - } - if (SQLGetData(Statement, 2, SQL_GUID, &sqlguid, 16, 0) - != SQL_SUCCESS) { - AB_ERROR(("Get row %d, guid column failed", count)); - goto odbcfail; - } + CHK(SQLGetData, (Statement, 1, SQL_CHAR, name, 20, 0)); + CHK(SQLGetData, (Statement, 2, SQL_GUID, &sqlguid, 16, 0)); AB_PRINT(("%-10s %08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", name, @@ -511,15 +412,8 @@ TestRawODBCGuid(void) * Realloc cursor handle - (Windows ODBC considers it an invalid cursor * state if we try SELECT again). */ - if (SQLFreeStmt(Statement, SQL_CLOSE) != SQL_SUCCESS) { - AB_ERROR(("Free statement failed (5)")); - goto odbcfail; - } - if (SQLAllocHandle(SQL_HANDLE_STMT, Connection, &Statement) - != SQL_SUCCESS) { - AB_ERROR(("SQLAllocStmt failed(1)")); - goto odbcfail; - } + CHK(SQLFreeStmt, (Statement, SQL_CLOSE)); + CHK(SQLAllocHandle, (SQL_HANDLE_STMT, Connection, &Statement)); /* * Now retrieve rows via stored procedure passing GUID as param. @@ -530,28 +424,12 @@ TestRawODBCGuid(void) lenOrInd = SQL_NTS; strcpy((char *) (guid), "87654321-4321-4321-4321-123456789abc"); - if (SQLBindParameter(Statement, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_GUID, 0, 0, guid, 0, &lenOrInd) - != SQL_SUCCESS) { - AB_ERROR(("SQLBindParameter failed")); - goto odbcfail; - } - status = SQLExecDirect(Statement, queryString, SQL_NTS); - if (status != SQL_SUCCESS) { - AB_ERROR(("SELECT failed")); - goto odbcfail; - } + CHK(SQLBindParameter, (Statement, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_GUID, 0, 0, guid, 0, &lenOrInd)); + CHK(SQLExecDirect, (Statement, queryString, SQL_NTS)); while (SQLFetch(Statement) == SQL_SUCCESS) { count++; - if (SQLGetData(Statement, 1, SQL_CHAR, name, 20, 0) - != SQL_SUCCESS) { - AB_ERROR(("Get row %d, name column failed", count)); - goto odbcfail; - } - if (SQLGetData(Statement, 2, SQL_CHAR, guid, 37, 0) - != SQL_SUCCESS) { - AB_ERROR(("Get row %d, guid column failed", count)); - goto odbcfail; - } + CHK(SQLGetData, (Statement, 1, SQL_CHAR, name, 20, 0)); + CHK(SQLGetData, (Statement, 2, SQL_CHAR, guid, 37, 0)); AB_PRINT(("%-10s %s", name, guid)); } @@ -560,15 +438,8 @@ TestRawODBCGuid(void) * Realloc cursor handle - (Windows ODBC considers it an invalid cursor * state after a previous SELECT has occurred). */ - if (SQLFreeStmt(Statement, SQL_CLOSE) != SQL_SUCCESS) { - AB_ERROR(("Free statement failed (5)")); - goto odbcfail; - } - if (SQLAllocHandle(SQL_HANDLE_STMT, Connection, &Statement) - != SQL_SUCCESS) { - AB_ERROR(("SQLAllocStmt failed(1)")); - goto odbcfail; - } + CHK(SQLFreeStmt, (Statement, SQL_CLOSE)); + CHK(SQLAllocHandle, (SQL_HANDLE_STMT, Connection, &Statement)); /* cleanup */ CommandWithResult(Statement, "DROP PROC GetGUIDRows"); diff --git a/src/odbc/unittests/timeout3.c b/src/odbc/unittests/timeout3.c index edb7d37..8fdeff3 100644 --- a/src/odbc/unittests/timeout3.c +++ b/src/odbc/unittests/timeout3.c @@ -40,7 +40,7 @@ test connection timeout */ -static char software_version[] = "$Id: timeout3.c,v 1.6 2007/11/26 18:12:31 freddy77 Exp $"; +static char software_version[] = "$Id: timeout3.c,v 1.7 2008/02/08 09:28:05 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static void init_connect(void); @@ -49,14 +49,14 @@ static void init_connect(void) { if (SQLAllocEnv(&Environment) != SQL_SUCCESS) { - printf("Unable to allocate env\n"); + fprintf(stderr, "Unable to allocate env\n"); exit(1); } SQLSetEnvAttr(Environment, SQL_ATTR_ODBC_VERSION, (SQLPOINTER) (SQL_OV_ODBC3), SQL_IS_UINTEGER); if (SQLAllocConnect(Environment, &Connection) != SQL_SUCCESS) { - printf("Unable to allocate connection\n"); + fprintf(stderr, "Unable to allocate connection\n"); SQLFreeEnv(Environment); exit(1); } commit 1f0c7cafa73fb9e09ea9ebdceef4099fae62cca1 Author: freddy77 Date: Fri Feb 8 09:32:06 2008 +0000 add a comment diff --git a/src/odbc/odbc.c b/src/odbc/odbc.c index b7b8235..a897f93 100644 --- a/src/odbc/odbc.c +++ b/src/odbc/odbc.c @@ -60,7 +60,7 @@ #include #endif -TDS_RCSID(var, "$Id: odbc.c,v 1.470 2008/01/29 09:35:25 freddy77 Exp $"); +TDS_RCSID(var, "$Id: odbc.c,v 1.471 2008/02/08 09:32:06 freddy77 Exp $"); static SQLRETURN _SQLAllocConnect(SQLHENV henv, SQLHDBC FAR * phdbc); static SQLRETURN _SQLAllocEnv(SQLHENV FAR * phenv); @@ -3343,6 +3343,10 @@ odbc_process_tokens(TDS_STMT * stmt, unsigned flag) static void odbc_convert_err_set(struct _sql_errors *errs, TDS_INT err) { + /* + * TODO we really need a column offset in the _sql_error structure so that caller can + * invoke SQLGetDiagField to learn which column is failing + */ switch (err) { case TDS_CONVERT_NOAVAIL: odbc_errs_add(errs, "HY003", NULL); commit 7b994c7e6ac231e2f269b028fe3ca0cfe74d095b Author: freddy77 Date: Fri Feb 8 10:20:23 2008 +0000 let it compile diff --git a/src/odbc/unittests/testodbc.c b/src/odbc/unittests/testodbc.c index 61e80bb..96c28f5 100644 --- a/src/odbc/unittests/testodbc.c +++ b/src/odbc/unittests/testodbc.c @@ -10,7 +10,7 @@ #include "common.h" -static char software_version[] = "$Id: testodbc.c,v 1.11 2008/02/08 09:28:04 freddy77 Exp $"; +static char software_version[] = "$Id: testodbc.c,v 1.12 2008/02/08 10:20:23 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #ifdef DEBUG @@ -104,7 +104,6 @@ DispODBCDiags(void) static int TestRawODBCPreparedQuery(void) { - SQLRETURN status; SQLCHAR queryString[200]; SQLLEN lenOrInd = 0; SQLSMALLINT supplierId = 4; @@ -176,7 +175,6 @@ TestRawODBCPreparedQuery(void) static int TestRawODBCDirectQuery(void) { - SQLRETURN status; SQLCHAR queryString[200]; SQLLEN lenOrInd = 0; SQLSMALLINT supplierId = 1; @@ -359,7 +357,7 @@ TestRawODBCGuid(void) lenOrInd = 16; strcpy((char *) (guid), "1234abcd-abcd-abcd-abcd-123456789abc"); - CHK(SQLBindParameter(Statement, 1, SQL_PARAM_INPUT, SQL_C_GUID, SQL_GUID, 16, 0, &sqlguid, 16, &lenOrInd)); + CHK(SQLBindParameter, (Statement, 1, SQL_PARAM_INPUT, SQL_C_GUID, SQL_GUID, 16, 0, &sqlguid, 16, &lenOrInd)); status = SQLExecDirect(Statement, queryString, SQL_NTS); if (status != SQL_SUCCESS) { AB_ERROR(("Insert row 5 failed")); commit 862f3b5f92558517a616e14fab0a83ad6fcc24ef Author: freddy77 Date: Wed Feb 13 08:52:08 2008 +0000 merged small memory issues, fix test64 test output diff --git a/ChangeLog b/ChangeLog index 393b4a0..bd126d0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Feb 13 09:50:35 CET 2008 Frediano Ziglio + * src/apps/bsqlodbc.c: fix memory error + * src/tds/query.c: remove possible buffer underflow + * src/odbc/unittests/test64.c: truncate upper part for low + Fri Feb 08 10:26:36 CET 2008 Frediano Ziglio * src/odbc/unittests/Makefile.am src/odbc/unittests/describecol.in: * src/odbc/unittests/params.c src/odbc/unittests/putdata.c: @@ -158,4 +163,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2487 2008/02/08 09:28:01 freddy77 Exp $ +$Id: ChangeLog,v 1.2488 2008/02/13 08:52:08 freddy77 Exp $ diff --git a/src/apps/bsqlodbc.c b/src/apps/bsqlodbc.c index 1050550..89d9c19 100644 --- a/src/apps/bsqlodbc.c +++ b/src/apps/bsqlodbc.c @@ -50,7 +50,7 @@ #include #include "replacements.h" -static char software_version[] = "$Id: bsqlodbc.c,v 1.9 2007/11/26 06:25:57 freddy77 Exp $"; +static char software_version[] = "$Id: bsqlodbc.c,v 1.10 2008/02/13 08:52:09 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static char * next_query(void); @@ -339,6 +339,10 @@ main(int argc, char *argv[]) } } + SQLDisconnect(hDbc); + SQLFreeHandle(SQL_HANDLE_DBC, hDbc); + SQLFreeHandle(SQL_HANDLE_ENV, hEnv); + return 0; } @@ -347,14 +351,15 @@ next_query() { char query_line[4096]; static char *sql = NULL; - + if (feof(stdin)) return NULL; - + fprintf(options.verbose, "%s:%d: Query:\n", options.appname, __LINE__); - + free(sql); - + sql = NULL; + while (fgets(query_line, sizeof(query_line), stdin)) { /* 'go' or 'GO' separates command batches */ char *p = query_line; diff --git a/src/odbc/unittests/test64.c b/src/odbc/unittests/test64.c index 8d0dd75..4078cd8 100644 --- a/src/odbc/unittests/test64.c +++ b/src/odbc/unittests/test64.c @@ -1,7 +1,7 @@ /* test win64 consistency */ #include "common.h" -static char software_version[] = "$Id: test64.c,v 1.4 2008/01/29 14:30:49 freddy77 Exp $"; +static char software_version[] = "$Id: test64.c,v 1.5 2008/02/13 08:52:09 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; /* @@ -110,6 +110,7 @@ test_params(void) l = len; len >>= 16; h = len >> 16; + l &= 0xfffffffflu; if (h != 0 || l != 2) { fprintf(stderr, "Wrong number returned in param rows high %lu low %lu\n", h, l); exit(1); @@ -223,6 +224,7 @@ test_rows(void) l = len; len >>= 16; h = len >> 16; + l &= 0xfffffffflu; if (h != 0 || l != 2) { fprintf(stderr, "Wrong number returned in rows high %lu(0x%lx) low %lu(0x%lx)\n", h, h, l, l); exit(1); diff --git a/src/tds/query.c b/src/tds/query.c index 61c266d..3cd8c5f 100644 --- a/src/tds/query.c +++ b/src/tds/query.c @@ -46,7 +46,7 @@ #include -TDS_RCSID(var, "$Id: query.c,v 1.218 2008/01/20 14:23:59 freddy77 Exp $"); +TDS_RCSID(var, "$Id: query.c,v 1.219 2008/02/13 08:52:09 freddy77 Exp $"); static void tds_put_params(TDSSOCKET * tds, TDSPARAMINFO * info, int flags); static void tds7_put_query_params(TDSSOCKET * tds, const char *query, int query_len); @@ -577,7 +577,7 @@ tds_next_placeholder_ucs2le(const char *start, const char *end, int named) case '?': return p; case '@': - if (named && !isalnum(prev)) + if (named && !isalnum((unsigned char) prev)) return p; default: p += 2; @@ -849,7 +849,7 @@ tds7_build_param_def_from_params(TDSSOCKET * tds, const char* query, size_t quer continue; /* find end of param name */ for (id_end = e + 2; id_end != query_end; id_end += 2) - if (!id_end[1] && (id_end[0] != '_' && id_end[1] != '#' && !isalnum(id_end[0]))) + if (!id_end[1] && (id_end[0] != '_' && id_end[1] != '#' && !isalnum((unsigned char) id_end[0]))) break; ids[i].p = e; ids[i].len = id_end - e; commit e0694937b57d4d27978d4866298b98410d9c68e8 Author: freddy77 Date: Fri Feb 15 11:00:40 2008 +0000 fix an ABI problem under HP-UX diff --git a/ChangeLog b/ChangeLog index bd126d0..2dec974 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +Fri Feb 15 11:53:41 CET 2008 Frediano Ziglio + * configure.ac: fix nasty problem with HP-UX + Wed Feb 13 09:50:35 CET 2008 Frediano Ziglio * src/apps/bsqlodbc.c: fix memory error * src/tds/query.c: remove possible buffer underflow @@ -163,4 +166,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2488 2008/02/13 08:52:08 freddy77 Exp $ +$Id: ChangeLog,v 1.2489 2008/02/15 11:00:40 freddy77 Exp $ diff --git a/configure.ac b/configure.ac index 77740fc..26bf18f 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. dnl ------------------------------------------------------------ -dnl $Id: configure.ac,v 1.33 2008/01/20 14:23:58 freddy77 Exp $ +dnl $Id: configure.ac,v 1.34 2008/02/15 11:00:40 freddy77 Exp $ dnl If you're trying to create a new configure test, try dnl dnl http://autogen.sourceforge.net/conftest.html @@ -15,7 +15,7 @@ dnl ------------------------------------------------------------ AC_INIT(FreeTDS, 0.83.dev.esyscmd(echo -n $(date +"%Y%m%d"))) AC_CONFIG_SRCDIR(src/dblib/dblib.c) AC_PREREQ(2.53) -AC_REVISION($Revision: 1.33 $) +AC_REVISION($Revision: 1.34 $) AM_INIT_AUTOMAKE AC_CONFIG_HEADERS(include/config.h) @@ -47,7 +47,6 @@ case $host in netdb_reentrant=yes ;; *-*-hpux11*) - CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED" netdb_reentrant=yes ;; *-*-cygwin*) @@ -151,6 +150,27 @@ case $host in fi AM_CONDITIONAL(MINGW32, true) ;; +*-*-hpux*) + # these lines are needed to fix a problem for HP-UX + # HP-UX define two versions of sockets, one BSD and one X/Open + # these versions are not binary compatible (BSD use int where X/Open + # use socklen_t == size_t) and different libraries (BSD in libc and + # X/Open in libxnet). X/Open is used if _XOPEN_SOURCE and + # _XOPEN_SOURCE_EXTENDED are defined. To complicate the things gcc + # by default define _XOPEN_SOURCE_EXTENDED so define always both + # constants and link always libxnet! + CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED" + LIBS="$LIBS -lxnet" + AC_SEARCH_LIBS(gethostbyname, nsl) + if test "$enable_krb5" = "yes" ; then + AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gssapi]) + if test "$ac_cv_search_gss_init_sec_context" != no; then + AC_DEFINE(ENABLE_KRB5, 1, [Defined if --enable-krb5 used and library detected]) + fi + fi + + AM_CONDITIONAL(MINGW32, false) + ;; *) AC_SEARCH_LIBS(socket, socket) AC_SEARCH_LIBS(gethostbyname, nsl) commit 03780ab494ed3fe0192268b97fdbc595f3f5fd0a Author: freddy77 Date: Fri Feb 15 11:06:39 2008 +0000 fix SQL_ATTR_CONNECTION_DEAD diff --git a/ChangeLog b/ChangeLog index 2dec974..0373661 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +Fri Feb 15 12:05:48 CET 2008 Frediano Ziglio + * src/odbc/odbc.c: fix SQL_ATTR_CONNECTION_DEAD + Fri Feb 15 11:53:41 CET 2008 Frediano Ziglio * configure.ac: fix nasty problem with HP-UX @@ -166,4 +169,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2489 2008/02/15 11:00:40 freddy77 Exp $ +$Id: ChangeLog,v 1.2490 2008/02/15 11:06:39 freddy77 Exp $ diff --git a/src/odbc/odbc.c b/src/odbc/odbc.c index a897f93..9438336 100644 --- a/src/odbc/odbc.c +++ b/src/odbc/odbc.c @@ -60,7 +60,7 @@ #include #endif -TDS_RCSID(var, "$Id: odbc.c,v 1.471 2008/02/08 09:32:06 freddy77 Exp $"); +TDS_RCSID(var, "$Id: odbc.c,v 1.472 2008/02/15 11:06:39 freddy77 Exp $"); static SQLRETURN _SQLAllocConnect(SQLHENV henv, SQLHDBC FAR * phdbc); static SQLRETURN _SQLAllocEnv(SQLHENV FAR * phenv); @@ -4471,6 +4471,7 @@ _SQLGetConnectAttr(SQLHDBC hdbc, SQLINTEGER Attribute, SQLPOINTER Value, SQLINTE ODBC_RETURN_(dbc); break; #if defined(SQL_ATTR_CONNECTION_DEAD) && defined(SQL_CD_TRUE) + case SQL_ATTR_CONNECTION_DEAD: *((SQLUINTEGER *) Value) = IS_TDSDEAD(dbc->tds_socket) ? SQL_CD_TRUE : SQL_CD_FALSE; ODBC_RETURN_(dbc); break; commit e355230cc6c9e491c13a7cd2fbeb9828109a0f2a Author: jklowden Date: Fri Feb 15 16:27:38 2008 +0000 support SYBUNIQUE printable width diff --git a/ChangeLog b/ChangeLog index 0373661..77bc6c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Fri Feb 15 11:25:46 EST 2008 JK Lowden + * src/dblib/dblib.c src/tds/convert.c + - support SYBUNIQUE printable width + Fri Feb 15 12:05:48 CET 2008 Frediano Ziglio * src/odbc/odbc.c: fix SQL_ATTR_CONNECTION_DEAD @@ -169,4 +173,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2490 2008/02/15 11:06:39 freddy77 Exp $ +$Id: ChangeLog,v 1.2491 2008/02/15 16:27:38 jklowden Exp $ diff --git a/src/dblib/dblib.c b/src/dblib/dblib.c index b6950aa..b9baa7e 100644 --- a/src/dblib/dblib.c +++ b/src/dblib/dblib.c @@ -76,7 +76,7 @@ #include #endif -TDS_RCSID(var, "$Id: dblib.c,v 1.321 2008/01/24 21:14:55 freddy77 Exp $"); +TDS_RCSID(var, "$Id: dblib.c,v 1.322 2008/02/15 16:27:38 jklowden Exp $"); static RETCODE _dbresults(DBPROCESS * dbproc); static int _db_get_server_type(int bindtype); @@ -3469,6 +3469,10 @@ dbprrow(DBPROCESS * dbproc) return SUCCEED; } +/* + * src/tds/convert.c::tds_willconvert() returns same information. + * Available to user via dbwillconvert(). + */ static int _get_printable_size(TDSCOLUMN * colinfo) { @@ -3496,17 +3500,16 @@ _get_printable_size(TDSCOLUMN * colinfo) case SYBCHAR: return colinfo->column_size; case SYBFLT8: - return 11; /* FIX ME -- we do not track precision */ case SYBREAL: return 11; /* FIX ME -- we do not track precision */ case SYBMONEY: - return 12; /* FIX ME */ case SYBMONEY4: - return 12; /* FIX ME */ + return 12; case SYBDATETIME: - return 26; /* FIX ME */ case SYBDATETIME4: - return 26; /* FIX ME */ + return 26; + case SYBUNIQUE: + return 36; case SYBBIT: case SYBBITN: return 1; @@ -3514,7 +3517,6 @@ _get_printable_size(TDSCOLUMN * colinfo) default: return 0; } - } /** diff --git a/src/tds/convert.c b/src/tds/convert.c index 67ea545..2283097 100644 --- a/src/tds/convert.c +++ b/src/tds/convert.c @@ -64,7 +64,7 @@ #include #endif -TDS_RCSID(var, "$Id: convert.c,v 1.180 2008/02/04 07:51:11 freddy77 Exp $"); +TDS_RCSID(var, "$Id: convert.c,v 1.181 2008/02/15 16:27:39 jklowden Exp $"); typedef unsigned short utf16_t; @@ -2896,6 +2896,8 @@ tds_willconvert(int srctype, int desttype) case SYBMONEY: case SYBMONEY4: return 12; + case SYBUNIQUE: + return 36; /* non-fixed types have variable data sizes, just return 0xff */ case SYBCHAR: case SYBBINARY: @@ -2919,7 +2921,6 @@ tds_willconvert(int srctype, int desttype) case SYBINTERVAL: case SYBSENSITIVITY: case SYBTIME: - case SYBUNIQUE: case SYBUNITEXT: case SYBVARIANT: case SYBVOID: commit b0a20c0ee8ab8a10f8a189c8f8963870b49e245d Author: freddy77 Date: Wed Feb 20 08:04:31 2008 +0000 avoid duplicate case diff --git a/ChangeLog b/ChangeLog index 77bc6c3..96cd21e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +Wed Feb 20 09:04:58 CET 2008 Frediano Ziglio + * src/tds/convert.c: avoid duplicate case + Fri Feb 15 11:25:46 EST 2008 JK Lowden * src/dblib/dblib.c src/tds/convert.c - support SYBUNIQUE printable width @@ -173,4 +176,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2491 2008/02/15 16:27:38 jklowden Exp $ +$Id: ChangeLog,v 1.2492 2008/02/20 08:04:31 freddy77 Exp $ diff --git a/src/tds/convert.c b/src/tds/convert.c index 2283097..6c6b985 100644 --- a/src/tds/convert.c +++ b/src/tds/convert.c @@ -64,7 +64,7 @@ #include #endif -TDS_RCSID(var, "$Id: convert.c,v 1.181 2008/02/15 16:27:39 jklowden Exp $"); +TDS_RCSID(var, "$Id: convert.c,v 1.182 2008/02/20 08:04:32 freddy77 Exp $"); typedef unsigned short utf16_t; @@ -2896,12 +2896,12 @@ tds_willconvert(int srctype, int desttype) case SYBMONEY: case SYBMONEY4: return 12; + /* TODO SYBBLOB has the same value */ case SYBUNIQUE: return 36; /* non-fixed types have variable data sizes, just return 0xff */ case SYBCHAR: case SYBBINARY: - case SYBBLOB: case SYBLONGBINARY: case SYBLONGCHAR: case SYBTEXT: commit 85f0d20666452ef19da29d3d368bc04e121603b2 Author: jklowden Date: Thu Feb 28 23:27:10 2008 +0000 announced 0.82RC2 diff --git a/ChangeLog b/ChangeLog index 96cd21e..da12d08 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Thu Feb 28 18:24:31 EST 2008 JK Lowden + * doc/htdoc/news.html announced 0.82RC2 + * vms/configure.com turn off iconv by default + Wed Feb 20 09:04:58 CET 2008 Frediano Ziglio * src/tds/convert.c: avoid duplicate case @@ -176,4 +180,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2492 2008/02/20 08:04:31 freddy77 Exp $ +$Id: ChangeLog,v 1.2493 2008/02/28 23:27:10 jklowden Exp $ diff --git a/doc/htdoc/news.html b/doc/htdoc/news.html index 5dbbcee..b940620 100644 --- a/doc/htdoc/news.html +++ b/doc/htdoc/news.html @@ -1,7 +1,7 @@ - + FreeTDS.org @@ -33,6 +33,19 @@ News  |  + + + + + + + + + + + + @@ -56,7 +70,7 @@ ftp.ibiblio.org. This important release will incorporate many new features, 23,710 lines of code. Detailed information can be found in the NEWS file included in the the distribution.

Version 0.82 will be the successor to 0.64, released in July 2006. The jump in version -number represents the progress toward version 1.0. +number represents the progress toward version 1.0. (17 January 2008)

commit 0e00d0b2474183daa11ee1f18cab3e6fba2ebc18 Author: freddy77 Date: Thu Mar 13 13:23:30 2008 +0000 simplify error.c diff --git a/ChangeLog b/ChangeLog index 0735575..cfa0bba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Thu Mar 13 14:22:28 CET 2008 Frediano Ziglio + * include/tdsodbc.h src/odbc/error.c: + - make errs offset constant in all odbc structures to make + error.c simpler + - support SQL_HANDLE_DESC in SQLGetDiagField + * src/odbc/odbc.c: remove TODO comment + * src/odbc/odbc_checks.c: typo + Wed Mar 12 15:25:11 CET 2008 Frediano Ziglio * src/odbc/error.c: check proper handle type @@ -219,4 +227,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2503 2008/03/12 14:26:07 freddy77 Exp $ +$Id: ChangeLog,v 1.2504 2008/03/13 13:23:30 freddy77 Exp $ diff --git a/include/tdsodbc.h b/include/tdsodbc.h index a58d547..5efd600 100644 --- a/include/tdsodbc.h +++ b/include/tdsodbc.h @@ -66,7 +66,7 @@ extern "C" #endif #endif -/* $Id: tdsodbc.h,v 1.104 2008/01/14 19:21:06 freddy77 Exp $ */ +/* $Id: tdsodbc.h,v 1.105 2008/03/13 13:23:31 freddy77 Exp $ */ #if defined(__GNUC__) && __GNUC__ >= 4 #pragma GCC visibility push(hidden) @@ -177,11 +177,11 @@ struct _drecord struct _hdesc { SQLSMALLINT htype; /* do not reorder this field */ + struct _sql_errors errs; /* do not reorder this field */ int type; SQLHANDLE parent; struct _dheader header; struct _drecord *records; - struct _sql_errors errs; }; typedef struct _hdesc TDS_DESC; @@ -202,13 +202,14 @@ struct _heattr struct _hchk { SQLSMALLINT htype; /* do not reorder this field */ + struct _sql_errors errs; /* do not reorder this field */ }; struct _henv { SQLSMALLINT htype; /* do not reorder this field */ + struct _sql_errors errs; /* do not reorder this field */ TDSCONTEXT *tds_ctx; - struct _sql_errors errs; struct _heattr attr; }; @@ -242,6 +243,7 @@ struct _hstmt; struct _hdbc { SQLSMALLINT htype; /* do not reorder this field */ + struct _sql_errors errs; /* do not reorder this field */ struct _henv *env; TDSSOCKET *tds_socket; DSTR dsn; @@ -254,7 +256,6 @@ struct _hdbc struct _hstmt *current_statement; /** list of all statements allocated from this connection */ struct _hstmt *stmt_list; - struct _sql_errors errs; struct _hcattr attr; /** descriptors associated to connection */ TDS_DESC *uad[TDS_MAX_APP_DESC]; @@ -326,6 +327,7 @@ typedef enum struct _hstmt { SQLSMALLINT htype; /* do not reorder this field */ + struct _sql_errors errs; /* do not reorder this field */ struct _hdbc *dbc; /** query to execute */ char *query; @@ -361,7 +363,6 @@ struct _hstmt TDS_ODBC_ROW_STATUS row_status; /* do NOT free dynamic, free from socket or attach to connection */ TDSDYNAMIC *dyn; - struct _sql_errors errs; TDS_DESC *ard, *ird, *apd, *ipd; TDS_DESC *orig_ard, *orig_apd; SQLULEN sql_rowset_size; diff --git a/src/odbc/error.c b/src/odbc/error.c index 260e475..c9e0772 100644 --- a/src/odbc/error.c +++ b/src/odbc/error.c @@ -47,7 +47,7 @@ #include #endif -TDS_RCSID(var, "$Id: error.c,v 1.50 2008/03/12 14:26:07 freddy77 Exp $"); +TDS_RCSID(var, "$Id: error.c,v 1.51 2008/03/13 13:23:31 freddy77 Exp $"); static void odbc_errs_pop(struct _sql_errors *errs); static const char *odbc_get_msg(const char *sqlstate); @@ -503,7 +503,7 @@ _SQLGetDiagRec(SQLSMALLINT handleType, SQLHANDLE handle, SQLSMALLINT numRecord, SQLINTEGER FAR * pfNativeError, SQLCHAR * szErrorMsg, SQLSMALLINT cbErrorMsgMax, SQLSMALLINT FAR * pcbErrorMsg) { SQLRETURN result; - struct _sql_errors *errs = NULL; + struct _sql_errors *errs; const char *msg; char *p; @@ -518,31 +518,28 @@ _SQLGetDiagRec(SQLSMALLINT handleType, SQLHANDLE handle, SQLSMALLINT numRecord, if (numRecord <= 0 || cbErrorMsgMax < 0) return SQL_ERROR; - if (!handle || ((struct _hchk *) handle)->htype != handleType) + if (!handle || ((TDS_CHK *) handle)->htype != handleType) return SQL_INVALID_HANDLE; + errs = &((TDS_CHK *) handle)->errs; switch (handleType) { case SQL_HANDLE_STMT: odbc_ver = ((TDS_STMT *) handle)->dbc->env->attr.odbc_version; - errs = &((TDS_STMT *) handle)->errs; break; case SQL_HANDLE_DBC: odbc_ver = ((TDS_DBC *) handle)->env->attr.odbc_version; - errs = &((TDS_DBC *) handle)->errs; break; case SQL_HANDLE_ENV: odbc_ver = ((TDS_ENV *) handle)->attr.odbc_version; - errs = &((TDS_ENV *) handle)->errs; break; case SQL_HANDLE_DESC: parent = ((TDS_DESC *) handle)->parent; - if (((struct _hchk *) parent)->htype == SQL_HANDLE_DBC) + if (((TDS_CHK *) parent)->htype == SQL_HANDLE_DBC) odbc_ver = ((TDS_DBC *) parent)->env->attr.odbc_version; else odbc_ver = ((TDS_STMT *) parent)->dbc->env->attr.odbc_version; - errs = &((TDS_DESC *) handle)->errs; break; default: return SQL_INVALID_HANDLE; @@ -579,7 +576,6 @@ SQLError(SQLHENV henv, SQLHDBC hdbc, SQLHSTMT hstmt, SQLCHAR FAR * szSqlState, S SQLCHAR FAR * szErrorMsg, SQLSMALLINT cbErrorMsgMax, SQLSMALLINT FAR * pcbErrorMsg) { SQLRETURN result; - struct _sql_errors *errs = NULL; SQLSMALLINT type; SQLHANDLE handle; @@ -587,15 +583,12 @@ SQLError(SQLHENV henv, SQLHDBC hdbc, SQLHSTMT hstmt, SQLCHAR FAR * szSqlState, S henv, hdbc, hstmt, szSqlState, pfNativeError, szErrorMsg, cbErrorMsgMax, pcbErrorMsg); if (hstmt) { - errs = &((TDS_STMT *) hstmt)->errs; handle = hstmt; type = SQL_HANDLE_STMT; } else if (hdbc) { - errs = &((TDS_DBC *) hdbc)->errs; handle = hdbc; type = SQL_HANDLE_DBC; } else if (henv) { - errs = &((TDS_ENV *) henv)->errs; handle = henv; type = SQL_HANDLE_ENV; } else @@ -605,7 +598,7 @@ SQLError(SQLHENV henv, SQLHDBC hdbc, SQLHSTMT hstmt, SQLCHAR FAR * szSqlState, S if (result == SQL_SUCCESS) { /* remove first error */ - odbc_errs_pop(errs); + odbc_errs_pop(&((TDS_CHK *) handle)->errs); } return result; @@ -627,7 +620,7 @@ SQLGetDiagField(SQLSMALLINT handleType, SQLHANDLE handle, SQLSMALLINT numRecord, SQLSMALLINT cbBuffer, SQLSMALLINT FAR * pcbBuffer) { SQLRETURN result = SQL_SUCCESS; - struct _sql_errors *errs = NULL; + struct _sql_errors *errs; const char *msg; SQLINTEGER odbc_ver = SQL_OV_ODBC2; @@ -635,6 +628,7 @@ SQLGetDiagField(SQLSMALLINT handleType, SQLHANDLE handle, SQLSMALLINT numRecord, TDS_STMT *stmt = NULL; TDS_DBC *dbc = NULL; TDS_ENV *env = NULL; + SQLHANDLE parent; char tmp[16]; tdsdump_log(TDS_DBG_FUNC, "SQLGetDiagField(%d, %p, %d, %d, %p, %d, %p)\n", @@ -643,7 +637,7 @@ SQLGetDiagField(SQLSMALLINT handleType, SQLHANDLE handle, SQLSMALLINT numRecord, if (cbBuffer < 0) return SQL_ERROR; - if (!handle || ((struct _hchk *) handle)->htype != handleType) + if (!handle || ((TDS_CHK *) handle)->htype != handleType) return SQL_INVALID_HANDLE; switch (handleType) { @@ -651,23 +645,32 @@ SQLGetDiagField(SQLSMALLINT handleType, SQLHANDLE handle, SQLSMALLINT numRecord, stmt = ((TDS_STMT *) handle); dbc = stmt->dbc; env = dbc->env; - errs = &stmt->errs; break; case SQL_HANDLE_DBC: dbc = ((TDS_DBC *) handle); env = dbc->env; - errs = &dbc->errs; break; case SQL_HANDLE_ENV: env = ((TDS_ENV *) handle); - errs = &env->errs; + break; + + case SQL_HANDLE_DESC: + parent = ((TDS_DESC *) handle)->parent; + if (((TDS_CHK *) parent)->htype == SQL_HANDLE_DBC) { + dbc = (TDS_DBC *) parent; + } else { + stmt = (TDS_STMT *) parent; + dbc = stmt->dbc; + } + env = dbc->env; break; default: return SQL_INVALID_HANDLE; } + errs = &((TDS_CHK *) handle)->errs; odbc_ver = env->attr.odbc_version; /* header (numRecord ignored) */ diff --git a/src/odbc/odbc.c b/src/odbc/odbc.c index 6529b73..0938e37 100644 --- a/src/odbc/odbc.c +++ b/src/odbc/odbc.c @@ -60,7 +60,7 @@ #include #endif -TDS_RCSID(var, "$Id: odbc.c,v 1.477 2008/03/12 13:54:33 freddy77 Exp $"); +TDS_RCSID(var, "$Id: odbc.c,v 1.478 2008/03/13 13:23:31 freddy77 Exp $"); static SQLRETURN _SQLAllocConnect(SQLHENV henv, SQLHDBC FAR * phdbc); static SQLRETURN _SQLAllocEnv(SQLHENV FAR * phenv); @@ -5602,7 +5602,6 @@ _SQLGetInfo(TDS_DBC * dbc, SQLUSMALLINT fInfoType, SQLPOINTER rgbInfoValue, SQLS SIVAL = SQL_TC_ALL; break; case SQL_TXN_ISOLATION_OPTION: - /* TODO check SQLSetConnectAttr support */ UIVAL = SQL_TXN_READ_COMMITTED | SQL_TXN_READ_UNCOMMITTED | SQL_TXN_REPEATABLE_READ | SQL_TXN_SERIALIZABLE; break; case SQL_UNION: diff --git a/src/odbc/odbc_checks.c b/src/odbc/odbc_checks.c index a55e1a7..713bdcc 100644 --- a/src/odbc/odbc_checks.c +++ b/src/odbc/odbc_checks.c @@ -40,7 +40,7 @@ #include #endif -TDS_RCSID(var, "$Id: odbc_checks.c,v 1.19 2007/05/17 10:33:21 freddy77 Exp $"); +TDS_RCSID(var, "$Id: odbc_checks.c,v 1.20 2008/03/13 13:23:31 freddy77 Exp $"); #if ENABLE_EXTRA_CHECKS @@ -113,7 +113,7 @@ odbc_check_struct_extra(void *p) { const int invalid_htype = 0; - switch (((struct _hchk *) p)->htype) { + switch (((TDS_CHK *) p)->htype) { case SQL_HANDLE_ENV: odbc_check_env_extra((TDS_ENV *) p); break; commit 02c780a076896bb6b3a36c379d11b4fa3add8231 Author: freddy77 Date: Tue Mar 18 08:19:25 2008 +0000 update diff --git a/doc/tds.html b/doc/tds.html index a0bdf38..28ab6de 100644 --- a/doc/tds.html +++ b/doc/tds.html @@ -389,7 +389,7 @@ auth authentication data

- + @@ -416,10 +416,10 @@ auth authentication data - + - + @@ -431,13 +431,23 @@ auth authentication data - +
Second Release Candidate available for 0.82
+
+Version 0.82RC2 is now available from + +ftp.ibiblio.org. +
+
+
FreeTDS enters release process for Version 0.82
commit ba520b40b0b671c6a12e26d6368ea56a3e32f319 Author: jklowden Date: Thu Feb 28 23:27:14 2008 +0000 turn off iconv by default diff --git a/vms/configure.com b/vms/configure.com index 37b59b3..ca0d413 100644 --- a/vms/configure.com +++ b/vms/configure.com @@ -16,7 +16,7 @@ $! License along with this library; if not, write to the $! Free Software Foundation, Inc., 59 Temple Place - Suite 330, $! Boston, MA 02111-1307, USA. $! -$! $Id: configure.com,v 1.5 2005/12/29 10:24:34 freddy77 Exp $ +$! $Id: configure.com,v 1.6 2008/02/28 23:27:14 jklowden Exp $ $! $! CONFIGURE.COM -- run from top level source directory as @[.vms]configure $! @@ -38,7 +38,9 @@ $! The system-supplied iconv() is fine, but unless the internationalization $! kit has been installed, we may not have the conversions we need. Check $! for their presence and use the homegrown iconv() if necessary. $! -$ IF F$SEARCH("SYS$I18N_ICONV:UCS-2_ISO8859-1.ICONV") .NES. "" - +$ IF - + "FALSE" - ! native iconv() buggy, don't use for now + .AND. F$SEARCH("SYS$I18N_ICONV:UCS-2_ISO8859-1.ICONV") .NES. "" - .AND. F$SEARCH("SYS$I18N_ICONV:ISO8859-1_UCS-2.ICONV") .NES. "" - .AND. F$SEARCH("SYS$I18N_ICONV:UTF-8_ISO8859-1.ICONV") .NES. "" - .AND. F$SEARCH("SYS$I18N_ICONV:ISO8859-1_UTF-8.ICONV") .NES. "" commit a8b0c6b4ee8c579b2a76bceb742ad486b6d08747 Author: freddy77 Date: Fri Feb 29 10:54:53 2008 +0000 ported tests and SQL_ROWSET_SIZE fix diff --git a/ChangeLog b/ChangeLog index da12d08..e91b2b1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Feb 29 11:50:06 CET 2008 Frediano Ziglio + * src/odbc/odbc.c src/odbc/unittests/.cvsignore: + * src/odbc/unittests/Makefile.am src/odbc/unittests/rowset.c(added): + - ported tests and SQL_ROWSET_SIZE fix + Thu Feb 28 18:24:31 EST 2008 JK Lowden * doc/htdoc/news.html announced 0.82RC2 * vms/configure.com turn off iconv by default @@ -180,4 +185,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2493 2008/02/28 23:27:10 jklowden Exp $ +$Id: ChangeLog,v 1.2494 2008/02/29 10:54:53 freddy77 Exp $ diff --git a/src/odbc/odbc.c b/src/odbc/odbc.c index 9438336..51a0658 100644 --- a/src/odbc/odbc.c +++ b/src/odbc/odbc.c @@ -60,7 +60,7 @@ #include #endif -TDS_RCSID(var, "$Id: odbc.c,v 1.472 2008/02/15 11:06:39 freddy77 Exp $"); +TDS_RCSID(var, "$Id: odbc.c,v 1.473 2008/02/29 10:54:53 freddy77 Exp $"); static SQLRETURN _SQLAllocConnect(SQLHENV henv, SQLHDBC FAR * phdbc); static SQLRETURN _SQLAllocEnv(SQLHENV FAR * phenv); @@ -1472,8 +1472,7 @@ _SQLAllocStmt(SQLHDBC hdbc, SQLHSTMT FAR * phstmt) stmt->attr.simulate_cursor = SQL_SC_NON_UNIQUE; stmt->attr.use_bookmarks = SQL_UB_OFF; - /* is not the same of using APD sql_desc_bind_type */ - stmt->sql_rowset_size = SQL_BIND_BY_COLUMN; + stmt->sql_rowset_size = 1; stmt->row_count = TDS_NO_COUNT; stmt->row_status = NOT_IN_ROW; @@ -6189,6 +6188,10 @@ _SQLSetStmtAttr(SQLHSTMT hstmt, SQLINTEGER Attribute, SQLPOINTER ValuePtr, SQLIN stmt->attr.use_bookmarks = ui; break; case SQL_ROWSET_SIZE: /* although this is ODBC2 we must support this attribute */ + if (((TDS_INTPTR) ValuePtr) < 1) { + odbc_errs_add(&stmt->errs, "HY024", NULL); + ODBC_RETURN(stmt, SQL_ERROR); + } stmt->sql_rowset_size = ui; break; default: diff --git a/src/odbc/unittests/.cvsignore b/src/odbc/unittests/.cvsignore index fb6855d..4d90945 100644 --- a/src/odbc/unittests/.cvsignore +++ b/src/odbc/unittests/.cvsignore @@ -64,6 +64,7 @@ cursor5 attributes hidden blob1 +rowset cancel test64 wchar diff --git a/src/odbc/unittests/Makefile.am b/src/odbc/unittests/Makefile.am index f9e14f9..f6bb215 100644 --- a/src/odbc/unittests/Makefile.am +++ b/src/odbc/unittests/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am,v 1.72 2008/02/08 09:28:03 freddy77 Exp $ +# $Id: Makefile.am,v 1.73 2008/02/29 10:54:53 freddy77 Exp $ TESTS = \ t0001$(EXEEXT) t0002$(EXEEXT) t0003$(EXEEXT)\ t0004$(EXEEXT) connect$(EXEEXT) print$(EXEEXT)\ @@ -21,7 +21,7 @@ TESTS = \ connect2$(EXEEXT) timeout4$(EXEEXT) freeclose$(EXEEXT) \ cursor3$(EXEEXT) cursor4$(EXEEXT) cursor5$(EXEEXT) \ attributes$(EXEEXT) hidden$(EXEEXT) blob1$(EXEEXT) \ - cancel$(EXEEXT) wchar$(EXEEXT) + cancel$(EXEEXT) wchar$(EXEEXT) rowset$(EXEEXT) check_PROGRAMS = $(TESTS) @@ -80,6 +80,7 @@ cursor5_SOURCES = cursor5.c common.c common.h attributes_SOURCES = attributes.c common.c common.h hidden_SOURCES = hidden.c common.c common.h blob1_SOURCES = blob1.c common.c common.h +rowset_SOURCES = rowset.c common.c common.h cancel_SOURCES = cancel.c common.c common.h wchar_SOURCES = wchar.c common.c common.h diff --git a/src/odbc/unittests/rowset.c b/src/odbc/unittests/rowset.c new file mode 100644 index 0000000..93a0b2f --- /dev/null +++ b/src/odbc/unittests/rowset.c @@ -0,0 +1,108 @@ +#include "common.h" + +static char software_version[] = "$Id: rowset.c,v 1.2 2008/02/29 10:54:53 freddy77 Exp $"; +static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; + +static char odbc_err[256]; +static char odbc_sqlstate[6]; + +static void +ReadError(void) +{ + memset(odbc_err, 0, sizeof(odbc_err)); + memset(odbc_sqlstate, 0, sizeof(odbc_sqlstate)); + if (!SQL_SUCCEEDED(SQLGetDiagRec(SQL_HANDLE_STMT, Statement, 1, (SQLCHAR *) odbc_sqlstate, NULL, (SQLCHAR *) odbc_err, sizeof(odbc_err), NULL))) { + printf("SQLGetDiagRec should not fail\n"); + exit(1); + } + printf("Message: '%s' %s\n", odbc_sqlstate, odbc_err); +} + +static void +test_err(int n) +{ + SQLRETURN rc; + + rc = SQLSetStmtAttr(Statement, SQL_ROWSET_SIZE, (SQLPOINTER) int2ptr(n), 0); + if (rc != SQL_ERROR) { + fprintf(stderr, "SQLSetStmtAttr should fail\n"); + Disconnect(); + exit(1); + } + ReadError(); + if (strcmp(odbc_sqlstate, "HY024") != 0) { + fprintf(stderr, "Unexpected sql state returned\n"); + Disconnect(); + exit(1); + } +} + +int +main(int argc, char *argv[]) +{ + int i; + SQLLEN len; +#ifdef HAVE_SQLROWSETSIZE + SQLROWSETSIZE row_count; +#else + SQLULEN row_count; +#endif + SQLUSMALLINT statuses[10]; + char buf[32]; + SQLRETURN rc; + + use_odbc_version3 = 1; + Connect(); + + /* initial value should be 1 */ + CHK(SQLGetStmtAttr, (Statement, SQL_ROWSET_SIZE, &len, sizeof(len), NULL)); + if (len != 1) { + fprintf(stderr, "len should be 1\n"); + Disconnect(); + return 1; + } + + /* check invalid parameter values */ + test_err(-123); + test_err(-1); + test_err(0); + + /* set some correct values */ + CHK(SQLSetStmtAttr, (Statement, SQL_ROWSET_SIZE, (SQLPOINTER) int2ptr(2), 0)); + CHK(SQLSetStmtAttr, (Statement, SQL_ROWSET_SIZE, (SQLPOINTER) int2ptr(1), 0)); + + /* now check that SQLExtendedFetch works as expected */ + Command(Statement, "CREATE TABLE #rowset(n INTEGER, c VARCHAR(20))"); + for (i = 0; i < 10; ++i) { + char s[10]; + char sql[128]; + + memset(s, 'a' + i, 9); + s[9] = 0; + sprintf(sql, "INSERT INTO #rowset(n,c) VALUES(%d,'%s')", i+1, s); + Command(Statement, sql); + } + + ResetStatement(); + CHK(SQLSetStmtOption, (Statement, SQL_ATTR_CURSOR_TYPE, SQL_CURSOR_DYNAMIC)); + rc = CommandWithResult(Statement, "SELECT * FROM #rowset ORDER BY n"); + if (!SQL_SUCCEEDED(rc)) + ODBC_REPORT_ERROR("SQLExecDirect error"); + + CHK(SQLBindCol, (Statement, 2, SQL_C_CHAR, buf, sizeof(buf), &len)); + + row_count = 0xdeadbeef; + memset(statuses, 0x55, sizeof(statuses)); + CHK(SQLExtendedFetch, (Statement, SQL_FETCH_NEXT, 1, &row_count, statuses)); + + if (row_count != 1 || statuses[0] != SQL_ROW_SUCCESS || strcmp(buf, "aaaaaaaaa") != 0) { + fprintf(stderr, "Invalid result\n"); + Disconnect(); + return 1; + } + + Disconnect(); + + printf("Done.\n"); + return 0; +} commit 281d4a6963bfe2d187caaa4d1adde6e96c382285 Author: freddy77 Date: Wed Mar 5 11:01:15 2008 +0000 change some vc6 build options diff --git a/ChangeLog b/ChangeLog index e91b2b1..c274c53 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +Wed Mar 05 12:0:43 CET 2008 Frediano Ziglio + * win32/build_dsw.pl: change some build options + Fri Feb 29 11:50:06 CET 2008 Frediano Ziglio * src/odbc/odbc.c src/odbc/unittests/.cvsignore: * src/odbc/unittests/Makefile.am src/odbc/unittests/rowset.c(added): @@ -185,4 +188,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2494 2008/02/29 10:54:53 freddy77 Exp $ +$Id: ChangeLog,v 1.2495 2008/03/05 11:01:15 freddy77 Exp $ diff --git a/win32/build_dsw.pl b/win32/build_dsw.pl index a52e303..3a5dc9d 100644 --- a/win32/build_dsw.pl +++ b/win32/build_dsw.pl @@ -48,8 +48,8 @@ RSC=rc.exe # PROP Output_Dir "..\\Release" # PROP Intermediate_Dir "..\\Release" # PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\\"..\\" /D DBNTWIN32 /YX /FD /c +# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\\"..\\" /D DBNTWIN32 /YX /FD /c # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe @@ -71,8 +71,8 @@ LINK32=link.exe # PROP Output_Dir "..\\Debug" # PROP Intermediate_Dir "..\\Debug" # PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\\"..\\" /D DBNTWIN32 /YX /FD /GZ /c +# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D FREETDS_SRCDIR=\\"..\\" /D DBNTWIN32 /YX /FD /GZ /c # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe commit e1a31eedce73a87474310ac8cd3fe98bdaafff60 Author: freddy77 Date: Fri Mar 7 08:56:34 2008 +0000 updated protocol doc diff --git a/ChangeLog b/ChangeLog index c274c53..0e5937f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +Fri Mar 07 09:55:57 CET 2008 Frediano Ziglio + * doc/tds.html: updated + Wed Mar 05 12:0:43 CET 2008 Frediano Ziglio * win32/build_dsw.pl: change some build options @@ -188,4 +191,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2495 2008/03/05 11:01:15 freddy77 Exp $ +$Id: ChangeLog,v 1.2496 2008/03/07 08:56:34 freddy77 Exp $ diff --git a/doc/tds.html b/doc/tds.html index f1dc00e..a0bdf38 100644 --- a/doc/tds.html +++ b/doc/tds.html @@ -94,7 +94,8 @@ of what goes on.

The packet format

-All packets start with the following 8 byte header. +Every informations in TDS protocol (query, RPCs, responses and so on) is splitted in packets.

+

All packets start with the following 8 byte header.

  INT8       INT8          INT16      4 bytes
@@ -134,9 +135,11 @@ above header.

Note: A TDS packet that is longer than 512 bytes is split on the 512 byte boundary and the "more packets" bit is set. The full TDS packet is reassembled - from its component 512 byte packets with the 8-byte headers stripped out. (I - believe the 512 is the block_size in the login packet, so it could be set to a - different value. *mjs*)

+ from its component 512 byte packets with the 8-byte headers stripped out. + 512 is the block_size in the login packet, so it could be set to a + different values. + In Sybase you can configure a range of valid block sizes. + TDS7+ use a default of 4096 as block size.


commit c22ed544f1f569190b92587eb990ac69c875b2c0 Author: freddy77 Date: Fri Mar 7 10:57:54 2008 +0000 added transaction level support diff --git a/ChangeLog b/ChangeLog index 0e5937f..22bac52 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Fri Mar 07 11:57:00 CET 2008 Frediano Ziglio + * src/odbc/odbc.c src/odbc/unittests/.cvsignore: + * src/odbc/unittests/Makefile.am: + * src/odbc/unittests/transaction2.c(added): + - transaction level support + Fri Mar 07 09:55:57 CET 2008 Frediano Ziglio * doc/tds.html: updated @@ -191,4 +197,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2496 2008/03/07 08:56:34 freddy77 Exp $ +$Id: ChangeLog,v 1.2497 2008/03/07 10:57:54 freddy77 Exp $ diff --git a/src/odbc/odbc.c b/src/odbc/odbc.c index 51a0658..190efbc 100644 --- a/src/odbc/odbc.c +++ b/src/odbc/odbc.c @@ -60,7 +60,7 @@ #include #endif -TDS_RCSID(var, "$Id: odbc.c,v 1.473 2008/02/29 10:54:53 freddy77 Exp $"); +TDS_RCSID(var, "$Id: odbc.c,v 1.474 2008/03/07 10:57:54 freddy77 Exp $"); static SQLRETURN _SQLAllocConnect(SQLHENV henv, SQLHDBC FAR * phdbc); static SQLRETURN _SQLAllocEnv(SQLHENV FAR * phenv); @@ -270,6 +270,40 @@ change_database(TDS_DBC * dbc, char *database, int database_len) ODBC_RETURN_(dbc); } +static SQLRETURN +change_txn(TDS_DBC * dbc, SQLUINTEGER txn_isolation) +{ + char query[64]; + const char *level; + TDSSOCKET *tds = dbc->tds_socket; + + if (!tds) + ODBC_RETURN(dbc, SQL_ERROR); + + level = "READ COMMITTED"; + switch (txn_isolation) { + case SQL_TXN_READ_UNCOMMITTED: + level = "READ UNCOMMITTED"; + break; + case SQL_TXN_REPEATABLE_READ: + level = "REPEATABLE READ"; + break; + case SQL_TXN_SERIALIZABLE: + level = "SERIALIZABLE"; + break; + } + sprintf(query, "SET TRANSACTION ISOLATION LEVEL %s", level); + + if (tds->state == TDS_IDLE) + tds->query_timeout = dbc->default_query_timeout; + if (tds_submit_query(tds, query) != TDS_SUCCEED) + ODBC_RETURN(dbc, SQL_ERROR); + if (tds_process_simple_query(tds) != TDS_SUCCEED) + ODBC_RETURN(dbc, SQL_ERROR); + + ODBC_RETURN_(dbc); +} + static void odbc_env_change(TDSSOCKET * tds, int type, char *oldval, char *newval) { @@ -323,6 +357,10 @@ odbc_connect(TDS_DBC * dbc, TDSCONNECTION * connection) if (IS_TDS7_PLUS(dbc->tds_socket)) dbc->cursor_support = 1; + if (dbc->attr.txn_isolation != SQL_TXN_READ_COMMITTED) + if (change_txn(dbc, dbc->attr.txn_isolation) != SQL_SUCCESS) + ODBC_RETURN_(dbc); + /* this overwrite any error arrived (wanted behavior, Sybase return error for conversion errors) */ ODBC_RETURN(dbc, SQL_SUCCESS); } @@ -5890,7 +5928,10 @@ _SQLSetConnectAttr(SQLHDBC hdbc, SQLINTEGER Attribute, SQLPOINTER ValuePtr, SQLI break; #endif case SQL_ATTR_TXN_ISOLATION: - dbc->attr.txn_isolation = u_value; + if (u_value != dbc->attr.txn_isolation) { + if (change_txn(dbc, u_value) == SQL_SUCCESS) + dbc->attr.txn_isolation = u_value; + } ODBC_RETURN_(dbc); break; case SQL_ATTR_TRANSLATE_LIB: diff --git a/src/odbc/unittests/.cvsignore b/src/odbc/unittests/.cvsignore index 4d90945..b8adb7f 100644 --- a/src/odbc/unittests/.cvsignore +++ b/src/odbc/unittests/.cvsignore @@ -68,3 +68,4 @@ rowset cancel test64 wchar +transaction2 diff --git a/src/odbc/unittests/Makefile.am b/src/odbc/unittests/Makefile.am index f6bb215..6254689 100644 --- a/src/odbc/unittests/Makefile.am +++ b/src/odbc/unittests/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am,v 1.73 2008/02/29 10:54:53 freddy77 Exp $ +# $Id: Makefile.am,v 1.74 2008/03/07 10:57:54 freddy77 Exp $ TESTS = \ t0001$(EXEEXT) t0002$(EXEEXT) t0003$(EXEEXT)\ t0004$(EXEEXT) connect$(EXEEXT) print$(EXEEXT)\ @@ -21,7 +21,7 @@ TESTS = \ connect2$(EXEEXT) timeout4$(EXEEXT) freeclose$(EXEEXT) \ cursor3$(EXEEXT) cursor4$(EXEEXT) cursor5$(EXEEXT) \ attributes$(EXEEXT) hidden$(EXEEXT) blob1$(EXEEXT) \ - cancel$(EXEEXT) wchar$(EXEEXT) rowset$(EXEEXT) + cancel$(EXEEXT) wchar$(EXEEXT) rowset$(EXEEXT) transaction2$(EXEEXT) check_PROGRAMS = $(TESTS) @@ -83,6 +83,7 @@ blob1_SOURCES = blob1.c common.c common.h rowset_SOURCES = rowset.c common.c common.h cancel_SOURCES = cancel.c common.c common.h wchar_SOURCES = wchar.c common.c common.h +transaction2_SOURCES = transaction2.c common.c common.h AM_CPPFLAGS = -I$(top_srcdir)/include $(ODBC_INC) -DFREETDS_SRCDIR=\"$(srcdir)\" if MINGW32 diff --git a/src/odbc/unittests/transaction2.c b/src/odbc/unittests/transaction2.c new file mode 100644 index 0000000..c7a0fae --- /dev/null +++ b/src/odbc/unittests/transaction2.c @@ -0,0 +1,205 @@ +#include "common.h" +#include + +/* Test transaction types */ + +static char software_version[] = "$Id: transaction2.c,v 1.1 2008/03/07 10:57:54 freddy77 Exp $"; +static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; + +static void +AutoCommit(int onoff) +{ + CHK(SQLSetConnectAttr, (Connection, SQL_ATTR_AUTOCOMMIT, int2ptr(onoff), 0)); +} + +static void +EndTransaction(SQLSMALLINT type) +{ + CHK(SQLEndTran, (SQL_HANDLE_DBC, Connection, type)); +} + +#define SWAP(t,a,b) do { t xyz = a; a = b; b = xyz; } while(0) +#define SWAP_CONN() do { SWAP(HENV,env,Environment); SWAP(HDBC,dbc,Connection); SWAP(HSTMT,stmt,Statement);} while(0) + +static HENV env = SQL_NULL_HENV; +static HDBC dbc = SQL_NULL_HDBC; +static HSTMT stmt = SQL_NULL_HSTMT; + +static int +CheckDirtyRead(void) +{ + SQLRETURN ret; + + /* transaction 1 try to change a row but not commit */ + Command(Statement, "UPDATE test_transaction SET t = 'second' WHERE n = 1"); + + SWAP_CONN(); + + /* second transaction try to fetch uncommited row */ + ret = CommandWithResult(Statement, "SELECT * FROM test_transaction WHERE t = 'second' AND n = 1"); + if (ret == SQL_ERROR) { + EndTransaction(SQL_ROLLBACK); + SWAP_CONN(); + EndTransaction(SQL_ROLLBACK); + return 0; /* no dirty read */ + } + + CHK(SQLFetch, (Statement)); + ret = SQLFetch(Statement); + if (ret != SQL_NO_DATA) + ODBC_REPORT_ERROR("other rows ??"); + SQLMoreResults(Statement); + EndTransaction(SQL_ROLLBACK); + SWAP_CONN(); + EndTransaction(SQL_ROLLBACK); + return 1; +} + +static int +CheckNonrepeatableRead(void) +{ + SQLRETURN ret; + + /* transaction 2 read a row */ + SWAP_CONN(); + CHK(CommandWithResult, (Statement, "SELECT * FROM test_transaction WHERE t = 'initial' AND n = 1")); + SQLMoreResults(Statement); + + /* transaction 1 change a row and commit */ + SWAP_CONN(); + ret = CommandWithResult(Statement, "UPDATE test_transaction SET t = 'second' WHERE n = 1"); + if (ret == SQL_ERROR) { + EndTransaction(SQL_ROLLBACK); + SWAP_CONN(); + EndTransaction(SQL_ROLLBACK); + SWAP_CONN(); + return 0; /* no dirty read */ + } + EndTransaction(SQL_COMMIT); + + SWAP_CONN(); + + /* second transaction try to fetch commited row */ + Command(Statement, "SELECT * FROM test_transaction WHERE t = 'second' AND n = 1"); + + CHK(SQLFetch, (Statement)); + ret = SQLFetch(Statement); + if (ret != SQL_NO_DATA) + ODBC_REPORT_ERROR("other rows ??"); + SQLMoreResults(Statement); + EndTransaction(SQL_ROLLBACK); + SWAP_CONN(); + Command(Statement, "UPDATE test_transaction SET t = 'initial' WHERE n = 1"); + EndTransaction(SQL_COMMIT); + return 1; +} + +static int +CheckPhantom(void) +{ + SQLRETURN ret; + + /* transaction 2 read a row */ + SWAP_CONN(); + CHK(CommandWithResult, (Statement, "SELECT * FROM test_transaction WHERE t = 'initial'")); + SQLMoreResults(Statement); + + /* transaction 1 insert a row that match critera */ + SWAP_CONN(); + ret = CommandWithResult(Statement, "INSERT INTO test_transaction(n, t) VALUES(2, 'initial')"); + if (ret == SQL_ERROR) { + EndTransaction(SQL_ROLLBACK); + SWAP_CONN(); + EndTransaction(SQL_ROLLBACK); + SWAP_CONN(); + return 0; /* no dirty read */ + } + EndTransaction(SQL_COMMIT); + + SWAP_CONN(); + + /* second transaction try to fetch commited row */ + Command(Statement, "SELECT * FROM test_transaction WHERE t = 'initial'"); + + CHK(SQLFetch, (Statement)); + CHK(SQLFetch, (Statement)); + ret = SQLFetch(Statement); + if (ret != SQL_NO_DATA) + ODBC_REPORT_ERROR("other rows ??"); + SQLMoreResults(Statement); + EndTransaction(SQL_ROLLBACK); + SWAP_CONN(); + Command(Statement, "DELETE test_transaction WHERE n = 2"); + EndTransaction(SQL_COMMIT); + return 1; +} + +static void +Test(int txn, const char *expected) +{ + int dirty, repeatable, phantom; + char buf[128]; + + SWAP_CONN(); + CHK(SQLSetConnectAttr, (Connection, SQL_ATTR_TXN_ISOLATION, int2ptr(txn), 0)); + SWAP_CONN(); + + dirty = CheckDirtyRead(); + repeatable = CheckNonrepeatableRead(); + phantom = CheckPhantom(); + + sprintf(buf, "dirty %d non repeatable %d phantom %d", dirty, repeatable, phantom); + if (strcmp(buf, expected) != 0) { + fprintf(stderr, "detected wrong TXN\nexpected '%s' got '%s'\n", expected, buf); + exit(1); + } +} + +int +main(int argc, char *argv[]) +{ + Connect(); + + /* here we can't use temporary table cause we use two connection */ + Command(Statement, "IF OBJECT_ID('test_transaction') IS NOT NULL DROP TABLE test_transaction"); + Command(Statement, "CREATE TABLE test_transaction(n NUMERIC(18,0) PRIMARY KEY, t VARCHAR(30))"); + Command(Statement, "INSERT INTO test_transaction(n, t) VALUES(1, 'initial')"); + + CHK(SQLSetStmtAttr, (Statement, SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER) 2, 0)); + + /* TODO test returned error */ +#if 0 + /* SQL error S1009 -- Invalid argument value */ + CHK(SQLSetConnectAttr, (Connection, SQL_ATTR_TXN_ISOLATION, int2ptr(SQL_TXN_REPEATABLE_READ | SQL_TXN_READ_COMMITTED), 0)); +#endif + + AutoCommit(SQL_AUTOCOMMIT_OFF); + + /* save this connection and do another */ + SWAP_CONN(); + + Connect(); + + CHK(SQLSetStmtAttr, (Statement, SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER) 2, 0)); + AutoCommit(SQL_AUTOCOMMIT_OFF); + + SWAP_CONN(); + + Test(SQL_TXN_READ_UNCOMMITTED, "dirty 1 non repeatable 1 phantom 1"); + Test(SQL_TXN_READ_COMMITTED, "dirty 0 non repeatable 1 phantom 1"); + Test(SQL_TXN_REPEATABLE_READ, "dirty 0 non repeatable 0 phantom 1"); + Test(SQL_TXN_SERIALIZABLE, "dirty 0 non repeatable 0 phantom 0"); + + Disconnect(); + + SWAP_CONN(); + + EndTransaction(SQL_COMMIT); + + /* Sybase do not accept DROP TABLE during a transaction */ + AutoCommit(SQL_AUTOCOMMIT_ON); + Command(Statement, "DROP TABLE test_transaction"); + + Disconnect(); + return 0; +} commit 336e1d70c3f0bf03429a18400bf4889b3adeaef7 Author: freddy77 Date: Fri Mar 7 15:40:57 2008 +0000 improved transaction2 odbc test diff --git a/ChangeLog b/ChangeLog index 22bac52..5c9aed3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +Fri Mar 07 16:40:16 CET 2008 Frediano Ziglio + * src/odbc/unittests/transaction2.c: improved + Fri Mar 07 11:57:00 CET 2008 Frediano Ziglio * src/odbc/odbc.c src/odbc/unittests/.cvsignore: * src/odbc/unittests/Makefile.am: @@ -197,4 +200,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2497 2008/03/07 10:57:54 freddy77 Exp $ +$Id: ChangeLog,v 1.2498 2008/03/07 15:40:57 freddy77 Exp $ diff --git a/src/odbc/unittests/transaction2.c b/src/odbc/unittests/transaction2.c index c7a0fae..3842615 100644 --- a/src/odbc/unittests/transaction2.c +++ b/src/odbc/unittests/transaction2.c @@ -3,9 +3,26 @@ /* Test transaction types */ -static char software_version[] = "$Id: transaction2.c,v 1.1 2008/03/07 10:57:54 freddy77 Exp $"; +static char software_version[] = "$Id: transaction2.c,v 1.2 2008/03/07 15:40:57 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; +static char odbc_err[256]; +static char odbc_sqlstate[6]; + +static void +ReadError(void) +{ + memset(odbc_err, 0, sizeof(odbc_err)); + memset(odbc_sqlstate, 0, sizeof(odbc_sqlstate)); + if (!SQL_SUCCEEDED + (SQLGetDiagRec + (SQL_HANDLE_DBC, Connection, 1, (SQLCHAR *) odbc_sqlstate, NULL, (SQLCHAR *) odbc_err, sizeof(odbc_err), NULL))) { + printf("SQLGetDiagRec should not fail\n"); + exit(1); + } + printf("Message: '%s' %s\n", odbc_sqlstate, odbc_err); +} + static void AutoCommit(int onoff) { @@ -134,6 +151,36 @@ CheckPhantom(void) return 1; } +static int test_with_connect = 0; + +static void +ConnectWithTxn(int txn) +{ + int res; + char command[512]; + + CHK(SQLAllocEnv, (&Environment)); + CHK(SQLSetEnvAttr, (Environment, SQL_ATTR_ODBC_VERSION, (SQLPOINTER) (SQL_OV_ODBC3), SQL_IS_UINTEGER)); + + CHK(SQLAllocConnect, (Environment, &Connection)); + + CHK(SQLSetConnectAttr, (Connection, SQL_ATTR_TXN_ISOLATION, int2ptr(txn), 0)); + res = SQLConnect(Connection, (SQLCHAR *) SERVER, SQL_NTS, (SQLCHAR *) USER, SQL_NTS, (SQLCHAR *) PASSWORD, SQL_NTS); + if (!SQL_SUCCEEDED(res)) + ODBC_REPORT_ERROR("Unable to open data source\n"); + + CHK(SQLAllocStmt, (Connection, &Statement)); + + sprintf(command, "use %s", DATABASE); + if (!SQL_SUCCEEDED(SQLExecDirect(Statement, (SQLCHAR *) command, SQL_NTS))) + ODBC_REPORT_ERROR("Unable to execute statement\n"); + +#ifndef TDS_NO_DM + /* unixODBC seems to require it */ + SQLMoreResults(Statement); +#endif +} + static void Test(int txn, const char *expected) { @@ -141,7 +188,14 @@ Test(int txn, const char *expected) char buf[128]; SWAP_CONN(); - CHK(SQLSetConnectAttr, (Connection, SQL_ATTR_TXN_ISOLATION, int2ptr(txn), 0)); + if (test_with_connect) { + Disconnect(); + ConnectWithTxn(txn); + CHK(SQLSetStmtAttr, (Statement, SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER) 2, 0)); + AutoCommit(SQL_AUTOCOMMIT_OFF); + } else { + CHK(SQLSetConnectAttr, (Connection, SQL_ATTR_TXN_ISOLATION, int2ptr(txn), 0)); + } SWAP_CONN(); dirty = CheckDirtyRead(); @@ -158,22 +212,55 @@ Test(int txn, const char *expected) int main(int argc, char *argv[]) { + SQLRETURN ret; + + use_odbc_version3 = 1; Connect(); + /* Invalid argument value */ + ret = SQLSetConnectAttr(Connection, SQL_ATTR_TXN_ISOLATION, int2ptr(SQL_TXN_REPEATABLE_READ | SQL_TXN_READ_COMMITTED), 0); + ReadError(); + if (ret != SQL_ERROR || strcmp(odbc_sqlstate, "HY024") != 0) { + Disconnect(); + fprintf(stderr, "Unexpected success\n"); + return 1; + } + /* here we can't use temporary table cause we use two connection */ Command(Statement, "IF OBJECT_ID('test_transaction') IS NOT NULL DROP TABLE test_transaction"); Command(Statement, "CREATE TABLE test_transaction(n NUMERIC(18,0) PRIMARY KEY, t VARCHAR(30))"); - Command(Statement, "INSERT INTO test_transaction(n, t) VALUES(1, 'initial')"); CHK(SQLSetStmtAttr, (Statement, SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER) 2, 0)); - /* TODO test returned error */ -#if 0 - /* SQL error S1009 -- Invalid argument value */ - CHK(SQLSetConnectAttr, (Connection, SQL_ATTR_TXN_ISOLATION, int2ptr(SQL_TXN_REPEATABLE_READ | SQL_TXN_READ_COMMITTED), 0)); -#endif - AutoCommit(SQL_AUTOCOMMIT_OFF); + Command(Statement, "INSERT INTO test_transaction(n, t) VALUES(1, 'initial')"); + + /* test setting with active transaction "Operation invalid at this time" */ + ret = SQLSetConnectAttr(Connection, SQL_ATTR_TXN_ISOLATION, int2ptr(SQL_TXN_REPEATABLE_READ), 0); + ReadError(); + if (ret != SQL_ERROR || strcmp(odbc_sqlstate, "HY011") != 0) { + Disconnect(); + fprintf(stderr, "Unexpected success\n"); + return 1; + } + + EndTransaction(SQL_COMMIT); + + Command(Statement, "SELECT * FROM test_transaction"); + + /* test setting with pending data */ + ret = SQLSetConnectAttr(Connection, SQL_ATTR_TXN_ISOLATION, int2ptr(SQL_TXN_REPEATABLE_READ), 0); + ReadError(); + if (ret != SQL_ERROR || strcmp(odbc_sqlstate, "HY011") != 0) { + Disconnect(); + fprintf(stderr, "Unexpected success\n"); + return 1; + } + + SQLMoreResults(Statement); + + EndTransaction(SQL_COMMIT); + /* save this connection and do another */ SWAP_CONN(); @@ -190,6 +277,13 @@ main(int argc, char *argv[]) Test(SQL_TXN_REPEATABLE_READ, "dirty 0 non repeatable 0 phantom 1"); Test(SQL_TXN_SERIALIZABLE, "dirty 0 non repeatable 0 phantom 0"); + test_with_connect = 1; + + Test(SQL_TXN_READ_UNCOMMITTED, "dirty 1 non repeatable 1 phantom 1"); + Test(SQL_TXN_READ_COMMITTED, "dirty 0 non repeatable 1 phantom 1"); + Test(SQL_TXN_REPEATABLE_READ, "dirty 0 non repeatable 0 phantom 1"); + Test(SQL_TXN_SERIALIZABLE, "dirty 0 non repeatable 0 phantom 0"); + Disconnect(); SWAP_CONN(); commit c1b8c70982ac0f6b1942c1f0a5e569f4dea2ed0f Author: freddy77 Date: Tue Mar 11 08:36:41 2008 +0000 fix a problem with cvs and branches diff --git a/ChangeLog b/ChangeLog index 5c9aed3..f49e197 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +Tue Mar 11 09:36:11 CET 2008 Frediano Ziglio + * src/tds/encodings.pl: fix a problem with cvs and branches + Fri Mar 07 16:40:16 CET 2008 Frediano Ziglio * src/odbc/unittests/transaction2.c: improved @@ -200,4 +203,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2498 2008/03/07 15:40:57 freddy77 Exp $ +$Id: ChangeLog,v 1.2499 2008/03/11 08:36:41 freddy77 Exp $ diff --git a/src/tds/encodings.pl b/src/tds/encodings.pl index 2346c18..719482e 100755 --- a/src/tds/encodings.pl +++ b/src/tds/encodings.pl @@ -30,7 +30,7 @@ $filename = "${srcdir}sybase_character_sets.h"; open(OUT, ">$filename") or die qq($basename: could not open "$filename"\n); print OUT "/*\n"; print OUT " * This file produced from $0\n"; -print OUT ' * $Id: encodings.pl,v 1.10 2005/04/06 06:44:33 jklowden Exp $', "\n"; +print OUT ' * $Id: encodings.pl,v 1.11 2008/03/11 08:36:41 freddy77 Exp $', "\n"; print OUT " */\n"; # look up the canonical name @@ -64,7 +64,7 @@ while(){ # grep for similar names, as an aid to the to programmer. $name =~ s/[\-\_]+//g; - print STDERR "$Name: $name alternative_character_sets.h\n"; + print STDERR $Name.": $name alternative_character_sets.h\n"; } $comma = ','; } @@ -77,7 +77,7 @@ close(OUT); print "/*\n"; $date = localtime; print " * This file produced from $0 on $date\n"; -print ' * $Id: encodings.pl,v 1.10 2005/04/06 06:44:33 jklowden Exp $', "\n"; +print ' * $Id: encodings.pl,v 1.11 2008/03/11 08:36:41 freddy77 Exp $', "\n"; print " */\n"; %charsets = (); commit d40b619026bc96201e99ff093608c20dd3816867 Author: freddy77 Date: Tue Mar 11 08:42:30 2008 +0000 fix auto-commit off before connection diff --git a/ChangeLog b/ChangeLog index f49e197..127da9b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +Tue Mar 11 09:42:04 CET 2008 Frediano Ziglio + * src/odbc/odbc.c: fix auto-commit off before connection + Tue Mar 11 09:36:11 CET 2008 Frediano Ziglio * src/tds/encodings.pl: fix a problem with cvs and branches @@ -203,4 +206,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2499 2008/03/11 08:36:41 freddy77 Exp $ +$Id: ChangeLog,v 1.2500 2008/03/11 08:42:30 freddy77 Exp $ diff --git a/src/odbc/odbc.c b/src/odbc/odbc.c index 190efbc..57d078c 100644 --- a/src/odbc/odbc.c +++ b/src/odbc/odbc.c @@ -60,7 +60,7 @@ #include #endif -TDS_RCSID(var, "$Id: odbc.c,v 1.474 2008/03/07 10:57:54 freddy77 Exp $"); +TDS_RCSID(var, "$Id: odbc.c,v 1.475 2008/03/11 08:42:30 freddy77 Exp $"); static SQLRETURN _SQLAllocConnect(SQLHENV henv, SQLHDBC FAR * phdbc); static SQLRETURN _SQLAllocEnv(SQLHENV FAR * phenv); @@ -224,6 +224,9 @@ change_autocommit(TDS_DBC * dbc, int state) ODBC_RETURN(dbc, SQL_ERROR); } dbc->attr.autocommit = state; + } else { + /* if not connected we will change auto-commit after login */ + dbc->attr.autocommit = state; } ODBC_RETURN_(dbc); } @@ -358,7 +361,11 @@ odbc_connect(TDS_DBC * dbc, TDSCONNECTION * connection) dbc->cursor_support = 1; if (dbc->attr.txn_isolation != SQL_TXN_READ_COMMITTED) - if (change_txn(dbc, dbc->attr.txn_isolation) != SQL_SUCCESS) + if (!SQL_SUCCEEDED(change_txn(dbc, dbc->attr.txn_isolation))) + ODBC_RETURN_(dbc); + + if (dbc->attr.autocommit != SQL_AUTOCOMMIT_ON) + if (!SQL_SUCCEEDED(change_autocommit(dbc, dbc->attr.autocommit))) ODBC_RETURN_(dbc); /* this overwrite any error arrived (wanted behavior, Sybase return error for conversion errors) */ commit 265159a73de9867b225f5b6887466d299e1e7492 Author: freddy77 Date: Wed Mar 12 13:35:48 2008 +0000 improve auto-commit diff --git a/ChangeLog b/ChangeLog index 127da9b..7122046 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Wed Mar 12 14:34:21 CET 2008 Frediano Ziglio + * src/odbc/odbc.c: fix auto-commit set + * src/odbc/unittests/common.c src/odbc/unittests/common.h: + - make possible to override connection attributes + * src/odbc/unittests/transaction2.c: + - improve + Tue Mar 11 09:42:04 CET 2008 Frediano Ziglio * src/odbc/odbc.c: fix auto-commit off before connection @@ -206,4 +213,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2500 2008/03/11 08:42:30 freddy77 Exp $ +$Id: ChangeLog,v 1.2501 2008/03/12 13:35:48 freddy77 Exp $ diff --git a/src/odbc/odbc.c b/src/odbc/odbc.c index 57d078c..12682e8 100644 --- a/src/odbc/odbc.c +++ b/src/odbc/odbc.c @@ -60,7 +60,7 @@ #include #endif -TDS_RCSID(var, "$Id: odbc.c,v 1.475 2008/03/11 08:42:30 freddy77 Exp $"); +TDS_RCSID(var, "$Id: odbc.c,v 1.476 2008/03/12 13:35:49 freddy77 Exp $"); static SQLRETURN _SQLAllocConnect(SQLHENV henv, SQLHDBC FAR * phdbc); static SQLRETURN _SQLAllocEnv(SQLHENV FAR * phenv); @@ -280,11 +280,10 @@ change_txn(TDS_DBC * dbc, SQLUINTEGER txn_isolation) const char *level; TDSSOCKET *tds = dbc->tds_socket; - if (!tds) - ODBC_RETURN(dbc, SQL_ERROR); - - level = "READ COMMITTED"; switch (txn_isolation) { + case SQL_TXN_READ_COMMITTED: + level = "READ COMMITTED"; + break; case SQL_TXN_READ_UNCOMMITTED: level = "READ UNCOMMITTED"; break; @@ -294,17 +293,28 @@ change_txn(TDS_DBC * dbc, SQLUINTEGER txn_isolation) case SQL_TXN_SERIALIZABLE: level = "SERIALIZABLE"; break; + default: + odbc_errs_add(&dbc->errs, "HY024", NULL); + ODBC_RETURN(dbc, SQL_ERROR); } - sprintf(query, "SET TRANSACTION ISOLATION LEVEL %s", level); - if (tds->state == TDS_IDLE) - tds->query_timeout = dbc->default_query_timeout; + /* if not connected return success, will be set after connection */ + if (!tds) + return SQL_SUCCESS; + + if (tds->state != TDS_IDLE) { + odbc_errs_add(&dbc->errs, "HY011", NULL); + ODBC_RETURN(dbc, SQL_ERROR); + } + + tds->query_timeout = dbc->default_query_timeout; + sprintf(query, "SET TRANSACTION ISOLATION LEVEL %s", level); if (tds_submit_query(tds, query) != TDS_SUCCEED) ODBC_RETURN(dbc, SQL_ERROR); if (tds_process_simple_query(tds) != TDS_SUCCEED) ODBC_RETURN(dbc, SQL_ERROR); - ODBC_RETURN_(dbc); + return SQL_SUCCESS; } static void @@ -361,7 +371,7 @@ odbc_connect(TDS_DBC * dbc, TDSCONNECTION * connection) dbc->cursor_support = 1; if (dbc->attr.txn_isolation != SQL_TXN_READ_COMMITTED) - if (!SQL_SUCCEEDED(change_txn(dbc, dbc->attr.txn_isolation))) + if (change_txn(dbc, dbc->attr.txn_isolation) != SQL_SUCCESS) ODBC_RETURN_(dbc); if (dbc->attr.autocommit != SQL_AUTOCOMMIT_ON) diff --git a/src/odbc/unittests/common.c b/src/odbc/unittests/common.c index 78f58fe..f7b3283 100644 --- a/src/odbc/unittests/common.c +++ b/src/odbc/unittests/common.c @@ -12,13 +12,14 @@ #define TDS_SDIR_SEPARATOR "\\" #endif -static char software_version[] = "$Id: common.c,v 1.43 2008/01/29 14:30:48 freddy77 Exp $"; +static char software_version[] = "$Id: common.c,v 1.44 2008/03/12 13:35:49 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; HENV Environment; HDBC Connection; HSTMT Statement; int use_odbc_version3 = 0; +void (*odbc_set_conn_attr)(void) = NULL; char USER[512]; char SERVER[512]; @@ -193,17 +194,18 @@ Connect(void) printf("connection parameters:\nserver: '%s'\nuser: '%s'\npassword: '%s'\ndatabase: '%s'\n", SERVER, USER, "????" /* PASSWORD */ , DATABASE); + if (odbc_set_conn_attr) + (*odbc_set_conn_attr)(); + res = SQLConnect(Connection, (SQLCHAR *) SERVER, SQL_NTS, (SQLCHAR *) USER, SQL_NTS, (SQLCHAR *) PASSWORD, SQL_NTS); if (!SQL_SUCCEEDED(res)) { printf("Unable to open data source (ret=%d)\n", res); CheckReturn(); - exit(1); } if (SQLAllocStmt(Connection, &Statement) != SQL_SUCCESS) { printf("Unable to allocate statement\n"); CheckReturn(); - exit(1); } sprintf(command, "use %s", DATABASE); @@ -212,7 +214,6 @@ Connect(void) if (!SQL_SUCCEEDED(SQLExecDirect(Statement, (SQLCHAR *) command, SQL_NTS))) { printf("Unable to execute statement\n"); CheckReturn(); - exit(1); } #ifndef TDS_NO_DM @@ -311,8 +312,6 @@ CheckCols(int n, int line, const char * file) return; fprintf(stderr, "%s:%d: Unable to get column numbers\n", file, line); CheckReturn(); - Disconnect(); - exit(1); } if (cols != n) { @@ -334,8 +333,6 @@ CheckRows(int n, int line, const char * file) return; fprintf(stderr, "%s:%d: Unable to get row\n", file, line); CheckReturn(); - Disconnect(); - exit(1); } if (rows != n) { diff --git a/src/odbc/unittests/common.h b/src/odbc/unittests/common.h index b74e162..5e89ddf 100644 --- a/src/odbc/unittests/common.h +++ b/src/odbc/unittests/common.h @@ -21,7 +21,7 @@ #include #include -static char rcsid_common_h[] = "$Id: common.h,v 1.22 2008/01/29 14:30:48 freddy77 Exp $"; +static char rcsid_common_h[] = "$Id: common.h,v 1.23 2008/03/12 13:35:50 freddy77 Exp $"; static void *no_unused_common_h_warn[] = { rcsid_common_h, no_unused_common_h_warn }; #ifndef HAVE_SQLLEN @@ -37,6 +37,7 @@ extern HENV Environment; extern HDBC Connection; extern HSTMT Statement; extern int use_odbc_version3; +extern void (*odbc_set_conn_attr)(void); extern char USER[512]; extern char SERVER[512]; diff --git a/src/odbc/unittests/transaction2.c b/src/odbc/unittests/transaction2.c index 3842615..27353c4 100644 --- a/src/odbc/unittests/transaction2.c +++ b/src/odbc/unittests/transaction2.c @@ -3,7 +3,7 @@ /* Test transaction types */ -static char software_version[] = "$Id: transaction2.c,v 1.2 2008/03/07 15:40:57 freddy77 Exp $"; +static char software_version[] = "$Id: transaction2.c,v 1.3 2008/03/12 13:35:50 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static char odbc_err[256]; @@ -153,32 +153,22 @@ CheckPhantom(void) static int test_with_connect = 0; +static int global_txn; + static void -ConnectWithTxn(int txn) +my_attrs(void) { - int res; - char command[512]; - - CHK(SQLAllocEnv, (&Environment)); - CHK(SQLSetEnvAttr, (Environment, SQL_ATTR_ODBC_VERSION, (SQLPOINTER) (SQL_OV_ODBC3), SQL_IS_UINTEGER)); - - CHK(SQLAllocConnect, (Environment, &Connection)); - - CHK(SQLSetConnectAttr, (Connection, SQL_ATTR_TXN_ISOLATION, int2ptr(txn), 0)); - res = SQLConnect(Connection, (SQLCHAR *) SERVER, SQL_NTS, (SQLCHAR *) USER, SQL_NTS, (SQLCHAR *) PASSWORD, SQL_NTS); - if (!SQL_SUCCEEDED(res)) - ODBC_REPORT_ERROR("Unable to open data source\n"); - - CHK(SQLAllocStmt, (Connection, &Statement)); - - sprintf(command, "use %s", DATABASE); - if (!SQL_SUCCEEDED(SQLExecDirect(Statement, (SQLCHAR *) command, SQL_NTS))) - ODBC_REPORT_ERROR("Unable to execute statement\n"); + CHK(SQLSetConnectAttr, (Connection, SQL_ATTR_TXN_ISOLATION, int2ptr(global_txn), 0)); + AutoCommit(SQL_AUTOCOMMIT_OFF); +} -#ifndef TDS_NO_DM - /* unixODBC seems to require it */ - SQLMoreResults(Statement); -#endif +static void +ConnectWithTxn(int txn) +{ + global_txn = txn; + odbc_set_conn_attr = my_attrs; + Connect(); + odbc_set_conn_attr = NULL; } static void @@ -192,7 +182,6 @@ Test(int txn, const char *expected) Disconnect(); ConnectWithTxn(txn); CHK(SQLSetStmtAttr, (Statement, SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER) 2, 0)); - AutoCommit(SQL_AUTOCOMMIT_OFF); } else { CHK(SQLSetConnectAttr, (Connection, SQL_ATTR_TXN_ISOLATION, int2ptr(txn), 0)); } @@ -235,6 +224,7 @@ main(int argc, char *argv[]) AutoCommit(SQL_AUTOCOMMIT_OFF); Command(Statement, "INSERT INTO test_transaction(n, t) VALUES(1, 'initial')"); +#if ENABLE_DEVELOPING /* test setting with active transaction "Operation invalid at this time" */ ret = SQLSetConnectAttr(Connection, SQL_ATTR_TXN_ISOLATION, int2ptr(SQL_TXN_REPEATABLE_READ), 0); ReadError(); @@ -243,6 +233,7 @@ main(int argc, char *argv[]) fprintf(stderr, "Unexpected success\n"); return 1; } +#endif EndTransaction(SQL_COMMIT); commit ec8cc96a5acd3d0ab0743a190ca77d0d04bf5ed2 Author: freddy77 Date: Wed Mar 12 13:54:32 2008 +0000 handle SQL_TIMESTAMP like SQL_TYPE_TIMESTAMP diff --git a/ChangeLog b/ChangeLog index 7122046..b2ec0c6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +Wed Mar 12 14:53:50 CET 2008 Frediano Ziglio + * src/odbc/odbc.c: handle SQL_TIMESTAMP like SQL_TYPE_TIMESTAMP + Wed Mar 12 14:34:21 CET 2008 Frediano Ziglio * src/odbc/odbc.c: fix auto-commit set * src/odbc/unittests/common.c src/odbc/unittests/common.h: @@ -213,4 +216,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2501 2008/03/12 13:35:48 freddy77 Exp $ +$Id: ChangeLog,v 1.2502 2008/03/12 13:54:32 freddy77 Exp $ diff --git a/src/odbc/odbc.c b/src/odbc/odbc.c index 12682e8..6529b73 100644 --- a/src/odbc/odbc.c +++ b/src/odbc/odbc.c @@ -60,7 +60,7 @@ #include #endif -TDS_RCSID(var, "$Id: odbc.c,v 1.476 2008/03/12 13:35:49 freddy77 Exp $"); +TDS_RCSID(var, "$Id: odbc.c,v 1.477 2008/03/12 13:54:33 freddy77 Exp $"); static SQLRETURN _SQLAllocConnect(SQLHENV henv, SQLHDBC FAR * phdbc); static SQLRETURN _SQLAllocEnv(SQLHENV FAR * phenv); @@ -1954,13 +1954,14 @@ _SQLColAttribute(SQLHSTMT hstmt, SQLUSMALLINT icol, SQLUSMALLINT fDescType, SQLP *pfDesc = 15; break; } - if (drec->sql_desc_concise_type == SQL_TYPE_TIMESTAMP) { + if (drec->sql_desc_concise_type == SQL_TYPE_TIMESTAMP || drec->sql_desc_concise_type == SQL_TIMESTAMP) { *pfDesc = drec->sql_desc_precision ? 23 : 16; break; } case SQL_DESC_PRECISION: /* this section may be wrong */ if (drec->sql_desc_concise_type == SQL_NUMERIC || drec->sql_desc_concise_type == SQL_DECIMAL - || drec->sql_desc_concise_type == SQL_TYPE_TIMESTAMP) + || drec->sql_desc_concise_type == SQL_TYPE_TIMESTAMP + || drec->sql_desc_concise_type == SQL_TIMESTAMP) IOUT(SQLSMALLINT, drec->sql_desc_precision); else *pfDesc = drec->sql_desc_length; @@ -1969,7 +1970,9 @@ _SQLColAttribute(SQLHSTMT hstmt, SQLUSMALLINT icol, SQLUSMALLINT fDescType, SQLP case SQL_COLUMN_SCALE: case SQL_DESC_SCALE: /* this section may be wrong */ if (drec->sql_desc_concise_type == SQL_NUMERIC || drec->sql_desc_concise_type == SQL_DECIMAL - || drec->sql_desc_concise_type == SQL_TYPE_TIMESTAMP || drec->sql_desc_concise_type == SQL_FLOAT) + || drec->sql_desc_concise_type == SQL_TYPE_TIMESTAMP + || drec->sql_desc_concise_type == SQL_TIMESTAMP + || drec->sql_desc_concise_type == SQL_FLOAT) IOUT(SQLSMALLINT, drec->sql_desc_scale); else *pfDesc = 0; @@ -2403,7 +2406,9 @@ SQLGetDescField(SQLHDESC hdesc, SQLSMALLINT icol, SQLSMALLINT fDescType, SQLPOIN IOUT(SQLSMALLINT, drec->sql_desc_parameter_type); break; case SQL_DESC_PRECISION: - if (drec->sql_desc_concise_type == SQL_NUMERIC || drec->sql_desc_concise_type == SQL_DECIMAL || drec->sql_desc_concise_type == SQL_TIMESTAMP) + if (drec->sql_desc_concise_type == SQL_NUMERIC || drec->sql_desc_concise_type == SQL_DECIMAL + || drec->sql_desc_concise_type == SQL_TIMESTAMP + || drec->sql_desc_concise_type == SQL_TYPE_TIMESTAMP) IOUT(SQLSMALLINT, drec->sql_desc_precision); else /* TODO support date/time */ @@ -2416,7 +2421,9 @@ SQLGetDescField(SQLHDESC hdesc, SQLSMALLINT icol, SQLSMALLINT fDescType, SQLPOIN #endif case SQL_DESC_SCALE: if (drec->sql_desc_concise_type == SQL_NUMERIC || drec->sql_desc_concise_type == SQL_DECIMAL - || drec->sql_desc_concise_type == SQL_TYPE_TIMESTAMP || drec->sql_desc_concise_type == SQL_FLOAT) + || drec->sql_desc_concise_type == SQL_TYPE_TIMESTAMP + || drec->sql_desc_concise_type == SQL_TIMESTAMP + || drec->sql_desc_concise_type == SQL_FLOAT) IOUT(SQLSMALLINT, drec->sql_desc_scale); else *((SQLSMALLINT *) Value) = 0; @@ -2814,7 +2821,7 @@ odbc_populate_ird(TDS_STMT * stmt) return SQL_ERROR; /* TODO other types for date ?? SQL_TYPE_DATE, SQL_TYPE_TIME */ - if (drec->sql_desc_concise_type == SQL_TIMESTAMP) + if (drec->sql_desc_concise_type == SQL_TIMESTAMP || drec->sql_desc_concise_type == SQL_TYPE_TIMESTAMP) drec->sql_desc_length = sizeof("2000-01-01 12:00:00.0000")-1; else drec->sql_desc_length = col->column_size; commit fef64066a20e845bb7db85a5dd0dbb620d636cee Author: freddy77 Date: Wed Mar 12 14:26:07 2008 +0000 test proper handle type diff --git a/ChangeLog b/ChangeLog index b2ec0c6..0735575 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +Wed Mar 12 15:25:11 CET 2008 Frediano Ziglio + * src/odbc/error.c: check proper handle type + Wed Mar 12 14:53:50 CET 2008 Frediano Ziglio * src/odbc/odbc.c: handle SQL_TIMESTAMP like SQL_TYPE_TIMESTAMP @@ -216,4 +219,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2502 2008/03/12 13:54:32 freddy77 Exp $ +$Id: ChangeLog,v 1.2503 2008/03/12 14:26:07 freddy77 Exp $ diff --git a/src/odbc/error.c b/src/odbc/error.c index f06d7d0..260e475 100644 --- a/src/odbc/error.c +++ b/src/odbc/error.c @@ -47,7 +47,7 @@ #include #endif -TDS_RCSID(var, "$Id: error.c,v 1.49 2007/10/16 15:12:21 freddy77 Exp $"); +TDS_RCSID(var, "$Id: error.c,v 1.50 2008/03/12 14:26:07 freddy77 Exp $"); static void odbc_errs_pop(struct _sql_errors *errs); static const char *odbc_get_msg(const char *sqlstate); @@ -250,60 +250,64 @@ rank_errors(struct _sql_errors *errs) struct _sql_error swapbuf; char istrans; - if (errs->ranked == 0 && errs->num_errors > 1) { - /* Find the highest of all unranked errors until there are none left */ - for (settled = 0; settled < errs->num_errors; settled++) { - best = -1; - for (current = settled; current < errs->num_errors; current++) { - istrans = 0; - switch (errs->errs[current].native) { - case 1205: - case 1211: - case 2625: - case 3309: - case 7112: - case 266: - case 277: - case 611: - case 628: - case 3902: - case 3903: - case 3906: - case 3908: - case 6401: + /* already ranked or nothing to rank */ + if (errs->ranked != 0 || errs->num_errors <= 1) { + errs->ranked = 1; + return; + } + + /* Find the highest of all unranked errors until there are none left */ + for (settled = 0; settled < errs->num_errors; settled++) { + best = -1; + for (current = settled; current < errs->num_errors; current++) { + istrans = 0; + switch (errs->errs[current].native) { + case 1205: + case 1211: + case 2625: + case 3309: + case 7112: + case 266: + case 277: + case 611: + case 628: + case 3902: + case 3903: + case 3906: + case 3908: + case 6401: + istrans = 1; + break; + } + + if (istrans == 0) { + if (strcmp(errs->errs[current].state3,"25000") == 0) + istrans = 1; + else if (strcmp(errs->errs[current].state3,"S1012") == 0) + istrans = 1; + else if (strcmp(errs->errs[current].state3,"08007") == 0) istrans = 1; - break; - } - - if (istrans == 0) { - if (strcmp(errs->errs[current].state3,"25000") == 0) - istrans = 1; - else if (strcmp(errs->errs[current].state3,"S1012") == 0) - istrans = 1; - else if (strcmp(errs->errs[current].state3,"08007") == 0) - istrans = 1; - } - - /* Transaction errors are always best */ - if (istrans == 1 && errs->errs[current].msgstate >= 10) { - best = current; - break; - } - - if (best == -1) - best = current; - - /* Non-terminating comparisons only below this point */ - if (errs->errs[current].msgstate > errs->errs[best].msgstate) - best = current; } - /* swap settled position with best */ - if (best != settled) { - swapbuf = errs->errs[settled]; - errs->errs[settled] = errs->errs[best]; - errs->errs[best] = swapbuf; + /* Transaction errors are always best */ + if (istrans == 1 && errs->errs[current].msgstate >= 10) { + best = current; + break; } + + if (best == -1) + best = current; + + /* Non-terminating comparisons only below this point */ + if (errs->errs[current].msgstate > errs->errs[best].msgstate) + best = current; + } + + /* swap settled position with best */ + if (best != settled) { + swapbuf = errs->errs[settled]; + errs->errs[settled] = errs->errs[best]; + errs->errs[best] = swapbuf; } } errs->ranked = 1; @@ -506,6 +510,7 @@ _SQLGetDiagRec(SQLSMALLINT handleType, SQLHANDLE handle, SQLSMALLINT numRecord, static const char msgprefix[] = "[FreeTDS][SQL Server]"; SQLINTEGER odbc_ver = SQL_OV_ODBC2; + SQLHANDLE parent; tdsdump_log(TDS_DBG_FUNC, "_SQLGetDiagRec(%d, %p, %d, %p, %p, %p, %d, %p)\n", handleType, handle, numRecord, szSqlState, pfNativeError, szErrorMsg, cbErrorMsgMax, pcbErrorMsg); @@ -513,7 +518,7 @@ _SQLGetDiagRec(SQLSMALLINT handleType, SQLHANDLE handle, SQLSMALLINT numRecord, if (numRecord <= 0 || cbErrorMsgMax < 0) return SQL_ERROR; - if (!handle) + if (!handle || ((struct _hchk *) handle)->htype != handleType) return SQL_INVALID_HANDLE; switch (handleType) { @@ -531,7 +536,14 @@ _SQLGetDiagRec(SQLSMALLINT handleType, SQLHANDLE handle, SQLSMALLINT numRecord, odbc_ver = ((TDS_ENV *) handle)->attr.odbc_version; errs = &((TDS_ENV *) handle)->errs; break; - + case SQL_HANDLE_DESC: + parent = ((TDS_DESC *) handle)->parent; + if (((struct _hchk *) parent)->htype == SQL_HANDLE_DBC) + odbc_ver = ((TDS_DBC *) parent)->env->attr.odbc_version; + else + odbc_ver = ((TDS_STMT *) parent)->dbc->env->attr.odbc_version; + errs = &((TDS_DESC *) handle)->errs; + break; default: return SQL_INVALID_HANDLE; } @@ -589,8 +601,6 @@ SQLError(SQLHENV henv, SQLHDBC hdbc, SQLHSTMT hstmt, SQLCHAR FAR * szSqlState, S } else return SQL_INVALID_HANDLE; - rank_errors(errs); - result = _SQLGetDiagRec(type, handle, 1, szSqlState, pfNativeError, szErrorMsg, cbErrorMsgMax, pcbErrorMsg); if (result == SQL_SUCCESS) { @@ -633,7 +643,7 @@ SQLGetDiagField(SQLSMALLINT handleType, SQLHANDLE handle, SQLSMALLINT numRecord, if (cbBuffer < 0) return SQL_ERROR; - if (!handle) + if (!handle || ((struct _hchk *) handle)->htype != handleType) return SQL_INVALID_HANDLE; switch (handleType) { commit 29a5ac91b1b3aa94cfcf116f1f8f755767865ee5 Author: jklowden Date: Wed Mar 12 21:34:09 2008 +0000 Posted 0.82RC3 diff --git a/doc/htdoc/news.html b/doc/htdoc/news.html index b940620..d68c673 100644 --- a/doc/htdoc/news.html +++ b/doc/htdoc/news.html @@ -1,7 +1,7 @@ - + FreeTDS.org @@ -37,9 +37,23 @@ News  | 


+Version 0.82RC3 is now available from + +ftp.ibiblio.org. (12 March 2008) + +
+
+
Second Release Candidate available for 0.82
+
Version 0.82RC2 is now available from -ftp.ibiblio.org. +ftp.ibiblio.org. (28 February 2008)

0x6399SYBNTEXT7+yes4yes
0x67103SYBNVARCHAR7+yes2??0x67103SYBNVARCHAR7+yes1
0x68104SYBBITNyes10x7F127SYBINT8no0
0xA5165XSYBVARBINARY7+yes20xA5165XSYBVARBINARY7+yes2 *
0xA7167XSYBVARCHAR7+yes2yes0xA7167XSYBVARCHAR7+yes2 *yes
0xAD173XSYBBINARY7+yes20xE1225SYBLONGBINARY5yes4
0xE7231XSYBNVARCHAR7+yes2yes0xE7231XSYBNVARCHAR7+yes2 *yes
0xEF239XSYBNCHAR7+yes2yes

+

* Under TDS9+ these types allow size to be -1. These types represents varchar(max), varbinary(max) and nvarchar(max). +Data representation for these types change in this way: +

    +
  • size is 64 bit not 16 bit
  • +
  • if size is -1 meaning NULL
  • +
  • if size is -2 size is unknown
  • +
  • data is splitted in chunks where ever chunk start with a 32 bit size
  • +
  • a chunk with size <= 0 is the terminal chunk
  • +
+

Collate type - TDS8

commit 69922d6709c73175d82bc4535850ed11e3a9fa54 Author: freddy77 Date: Tue Mar 18 08:22:23 2008 +0000 consistent test diff --git a/src/odbc/unittests/transaction2.c b/src/odbc/unittests/transaction2.c index 27353c4..8c54082 100644 --- a/src/odbc/unittests/transaction2.c +++ b/src/odbc/unittests/transaction2.c @@ -3,7 +3,7 @@ /* Test transaction types */ -static char software_version[] = "$Id: transaction2.c,v 1.3 2008/03/12 13:35:50 freddy77 Exp $"; +static char software_version[] = "$Id: transaction2.c,v 1.4 2008/03/18 08:22:23 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static char odbc_err[256]; @@ -224,7 +224,7 @@ main(int argc, char *argv[]) AutoCommit(SQL_AUTOCOMMIT_OFF); Command(Statement, "INSERT INTO test_transaction(n, t) VALUES(1, 'initial')"); -#if ENABLE_DEVELOPING +#ifdef ENABLE_DEVELOPING /* test setting with active transaction "Operation invalid at this time" */ ret = SQLSetConnectAttr(Connection, SQL_ATTR_TXN_ISOLATION, int2ptr(SQL_TXN_REPEATABLE_READ), 0); ReadError(); commit caa5c9a05d262e85f96275bcebcddc27d148b877 Author: jklowden Date: Sun Mar 23 17:29:57 2008 +0000 applied ML patches from Johnny C. Lam for calout locations and gnutls test diff --git a/ChangeLog b/ChangeLog index cfa0bba..e822060 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Mar 23 13:14:05 EDT 2008 JK Lowden + * configure.ac doc/Makefile.am + - applied ML patches from Johnny C. Lam for calout locations + - and gnutls test + Thu Mar 13 14:22:28 CET 2008 Frediano Ziglio * include/tdsodbc.h src/odbc/error.c: - make errs offset constant in all odbc structures to make @@ -227,4 +232,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2504 2008/03/13 13:23:30 freddy77 Exp $ +$Id: ChangeLog,v 1.2505 2008/03/23 17:29:57 jklowden Exp $ diff --git a/configure.ac b/configure.ac index 26bf18f..8fed8b9 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. dnl ------------------------------------------------------------ -dnl $Id: configure.ac,v 1.34 2008/02/15 11:00:40 freddy77 Exp $ +dnl $Id: configure.ac,v 1.35 2008/03/23 17:29:57 jklowden Exp $ dnl If you're trying to create a new configure test, try dnl dnl http://autogen.sourceforge.net/conftest.html @@ -15,7 +15,7 @@ dnl ------------------------------------------------------------ AC_INIT(FreeTDS, 0.83.dev.esyscmd(echo -n $(date +"%Y%m%d"))) AC_CONFIG_SRCDIR(src/dblib/dblib.c) AC_PREREQ(2.53) -AC_REVISION($Revision: 1.34 $) +AC_REVISION($Revision: 1.35 $) AM_INIT_AUTOMAKE AC_CONFIG_HEADERS(include/config.h) @@ -621,7 +621,7 @@ AC_SUBST(ODBCNODMLIBAPP) AC_ARG_WITH(gnutls, AS_HELP_STRING([--with-gnutls], [build with TLS support])) -if test "$with_gnutls"; then +if test "$with_gnutls" = "yes"; then AC_DEFINE(HAVE_GNUTLS, 1, [Define to 1 if you have GNU tls.]) CPPFLAGS="$CPPFLAGS `libgnutls-config --cflags`" NETWORK_LIBS="$NETWORK_LIBS `libgnutls-config --libs`" diff --git a/doc/Makefile.am b/doc/Makefile.am index d416361..cec6568 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -2,7 +2,7 @@ # Converting DocBook to HTML (several small files) # http://www.freebsd.org/tutorials/docproj-primer/x3132.html#AEN3140 -# $Id: Makefile.am,v 1.62 2008/01/08 15:38:23 jklowden Exp $ +# $Id: Makefile.am,v 1.63 2008/03/23 17:29:57 jklowden Exp $ SHELL = /bin/sh TXT2MAN = $(srcdir)/txt2man @@ -55,7 +55,8 @@ man: $(man_MANS) installdirs: $(mkinstalldirs) $(TARGET_DOCDIR)/userguide \ $(TARGET_DOCDIR)/reference \ - $(TARGET_DOCDIR)/images 2>&1 + $(TARGET_DOCDIR)/images \ + $(TARGET_DOCDIR)/images/callouts 2>&1 MANOPTS = -I 'FreeTDS User Guide' -v 'FreeTDS Utilities' -t $(PRODUCT) -r $(VERSION) @@ -117,8 +118,8 @@ install-data-local: installdirs $(DOCDIR)/reference/index.html $(DOCDIR)/usergui if test -r $(DOCDIR)/reference ; then d=.; else d="$(srcdir)"; fi; \ find $$d/$(DOCDIR)/reference \( -type f -o -type l \) -exec \ $(INSTALL_DATA) {} $(TARGET_DOCDIR)/reference ';' - find $(srcdir)/images -name \*.gif -exec \ - $(INSTALL_DATA) {} $(TARGET_DOCDIR)/images ';' + cd $(srcdir) && find images -name \*.gif -exec \ + $(INSTALL_DATA) {} $(TARGET_DOCDIR)/{} ';' uninstall-local: rm -rf $(TARGET_DOCDIR) commit f64622af5a476514192cb713991cac89269b06e3 Author: jklowden Date: Sun Mar 23 17:42:36 2008 +0000 s/calout/callout/ diff --git a/ChangeLog b/ChangeLog index e822060..09d37bf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,6 @@ Sun Mar 23 13:14:05 EDT 2008 JK Lowden * configure.ac doc/Makefile.am - - applied ML patches from Johnny C. Lam for calout locations + - applied ML patches from Johnny C. Lam for callout locations - and gnutls test Thu Mar 13 14:22:28 CET 2008 Frediano Ziglio @@ -232,4 +232,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2505 2008/03/23 17:29:57 jklowden Exp $ +$Id: ChangeLog,v 1.2506 2008/03/23 17:42:36 jklowden Exp $ commit 11557109942abc5e139a6bb8be76498d70edcd32 Author: jklowden Date: Sun Mar 23 20:56:37 2008 +0000 clarified localization diff --git a/ChangeLog b/ChangeLog index 09d37bf..9ceb525 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +Sun Mar 23 16:55:08 EDT 2008 JK Lowden + * doc/userguide.sgml clarified localization + Sun Mar 23 13:14:05 EDT 2008 JK Lowden * configure.ac doc/Makefile.am - applied ML patches from Johnny C. Lam for callout locations @@ -232,4 +235,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2506 2008/03/23 17:42:36 jklowden Exp $ +$Id: ChangeLog,v 1.2507 2008/03/23 20:56:37 jklowden Exp $ diff --git a/doc/userguide.sgml b/doc/userguide.sgml index e8d4c79..647648e 100644 --- a/doc/userguide.sgml +++ b/doc/userguide.sgml @@ -5,8 +5,8 @@ ]> - $Date: 2008/01/10 22:57:39 $ - $Revision: 1.111 $ + $Date: 2008/03/23 20:56:38 $ + $Revision: 1.112 $ <productname>FreeTDS</productname> User Guide A Guide to Installing, Configuring, and Running FreeTDS @@ -56,9 +56,9 @@ This guide is here for you, and we hope that you will be here for it, that other The version you're reading is: -$Revision: 1.111 $ -$Date: 2008/01/10 22:57:39 $ -CVS control number $Id: userguide.sgml,v 1.111 2008/01/10 22:57:39 jklowden Exp $. +$Revision: 1.112 $ +$Date: 2008/03/23 20:56:38 $ +CVS control number $Id: userguide.sgml,v 1.112 2008/03/23 20:56:38 jklowden Exp $. can be found on the FreeTDS @@ -568,7 +568,7 @@ url="http://www.madgoat.com">www.madgoat.com). OS X® - As of this writing ($Date: 2008/01/10 22:57:39 $), the regular distribution compiles on OS X. Releases prior to 0.63 either did not compile or required patching. + As of this writing ($Date: 2008/03/23 20:56:38 $), the regular distribution compiles on OS X. Releases prior to 0.63 either did not compile or required patching. Alternative build procedure @@ -928,7 +928,7 @@ It bears mentioning here that prior versions of FreeTDS client charset any valid iconv character set - ISO-8859-1Valid for ISO 8859-1 character set. See TDS 7.0 for Nonwestern Languages for more information. + ISO-8859-1Valid for ISO 8859-1 character set. See Localization and TDS 7.0 for more information. Makes FreeTDS use iconv to convert to and from the specified character set from UCS-2 in TDS 7.0/8.0. As of 0.62 FreeTDS uses iconv to convert all character data, so there's no need to match the server's charset to insert any characters the server supports. @@ -1029,7 +1029,7 @@ As of 0.62 FreeTDS uses iconv to convert all character data, so there's no need
- For more about the wonder world of FreeTDSlogs, see Logging. + For more about the wonderful world of FreeTDS logs, see Logging.
Deprecated options</> @@ -1236,7 +1236,7 @@ When you're done, you should see something very like this: <para>If you specify <literal><replaceable>dataserver</replaceable>\<replaceable>instance</replaceable></literal> as dataserver during login, <productname>FreeTDS</productname> will attempt to connect to specified instance. - Only Microsoft SQL Server instances are supported. (This server feature was introduced with SQL Server 2000). + Only Microsoft SQL Server instances are supported. (This server feature was introduced with SQL Server 2000.) </para> <para>Note that other <filename>freetds.conf</> properties still apply. @@ -1249,8 +1249,8 @@ When you're done, you should see something very like this: <sect2 id="tsql"><title><application>tsql</application> - -The tsql utility is provided as part of FreeTDS expressly for troubleshooting. tsql is superficially similar to an isql, but uses libtds directly, bypassing the client libraries (e.g., db-lib). tsql can either use or bypass the configuration files, allowing you to see if it's your dataserver that's not responding, or your configuration files that are messed up. + The tsql utility is provided as part of FreeTDS expressly for troubleshooting. tsql is superficially similar to an isql, but uses libtds directly, bypassing the client libraries (e.g., db-lib). + tsql can either use or bypass the configuration files. By trying both options, you can usually determine if it's your dataserver that's not responding, or your configuration files that are messed up. Using freetds.conf: @@ -1263,18 +1263,6 @@ The tsql utility is provided as part of FreeTDS expressly for trou - Bypassing freetds.conf: - - - tsql - -H hostname - -p port - -U username - -Ppassword - -C - - - Failing to connect with tsql @@ -1300,6 +1288,20 @@ There was a problem connecting to the server + Bypassing freetds.conf: + + + tsql + -H hostname + -p port + -U username + -Ppassword + -C + + + Keep in mind that the TDS protocol version normally comes from freetds.conf. When using tsql this way, the library uses the compiled-in default (set by the configure script). If that's not what you want, override it using the TDSVER environment variable. + + Connect with <command>tsql</> using a hostname and port number @@ -1491,7 +1493,7 @@ The following table defines all possible ODBC connection attributes for the -Connection attributes that may appear in <filename>freetds.conf</> +
Connection attributes that may appear in <filename>odbc.ini</> @@ -1746,7 +1748,7 @@ This chapter details some advanced configurations that need expanded explanation Several version of Microsoft SQL server have a bug that affects big endian clients. This includes 7.0 GA and 7.0 SP1. Furthermore, TDS Protocol version 7.0 is natively little endian. SQL Server 2000 is also reported not to work from big endian clients without little endian emulation turned on. -If you are unfamiliar with the terms big endian and little endian, they are terms that come originally from Gulliver's Travels. What they refer to in computer science is the the order in which bytes are stored by a processor. Big endian machines such as Sparc and PowerPC store the most significant byte in the first memory location of a multi-byte integer. Little endian machines such as Intel and Alpha do it the other way around. So the 16-bit number 258 would be 0x0102 on big endian and 0x0201 on little endian machines. +The terms big endian and little endian come originally from Gulliver's Travels. In computer science they refer to the the integer byte-order for a processor. Big endian processors, such as Sparc and PowerPC store the most significant byte in the first memory location of a multi-byte integer. Little endian processors, such as Intel and Alpha do it the other way around. So the 16-bit number 258 would be 0x0102 on big endian and 0x0201 on little endian machines. In this example we want to force connections to a server named mssql to emulate a little endian client. We are using protocol version 4.2 here, version 7.0 and 8.0 will automatically emulate little endian mode regardless of the freetds.conf setting. @@ -1763,16 +1765,16 @@ In this example we want to force connections to a server named mssql - - <acronym>TDS</> 7.0 for Nonwestern Languages + + Localization and <acronym>TDS</> 7.0 -TDS 7.0 uses 2-byte Unicode (technically, UCS-2) to transfer character data between servers and clients. Included in character data are query text (i.e., SQL), metadata (table names and such), and bona fide data of datatypes nchar, nvarchar, and ntext. +TDS 7.0 uses 2-byte Unicode (technically, UCS-2) to transfer character data between servers and clients. Included in character data are query text (i.e., SQL), metadata (table names and such), and bona fide data of datatypes nchar, nvarchar, and ntext. (Background information on Unicode and how it affects FreeTDS can be found in the appendix.) -Since most Unix tools and languages do not support UCS-2, FreeTDS allows conversion by the client to other character sets using the iconv standard. Background information on Unicode and how it affects FreeTDS can be found in the appendix. If no iconv library is found, or if it is explicitly disabled, FreeTDS will use its built-in iconv substitute, and will be capable of converting between only ISO-8859-1 and UCS-2. +Because most Unix tools and environments do not support UCS-2, FreeTDS provides for conversion by the client to other character sets. The mechanism used is determined by the configure script, which looks for a iconv(3) function, an implementation of the iconv standard. If no iconv library is found, or if it is explicitly disabled, FreeTDS will use its built-in iconv substitute, and will be capable of converting among only ISO 8859-1, UTF-8, and UCS-2. -To learn what character set the client is using, FreeTDS examines the freetds.conf entry. If it finds nothing there, it assumes the client is using ISO-8859-1. That is generally a safe assumption for western languages such as English or French, but produces garbage for other languages. +To learn what character set the client wants, FreeTDS prefers the applicable freetds.conf client charset property. If that is not set, it parses the LANG environment variable. In either case, the found string is passed to iconv(3) (or its built-in replacment). The built-in replacement expects GNU iconv names: ISO-8859-1, US-ASCII, or UTF-8.. If neither is found, UCS-2 data are converted to ISO 8859-1. @@ -1801,10 +1803,9 @@ In this example a server named mssql will return data encoded If FreeTDS runs into a character it can not convert, its behavior varies according to the severity of the problem. On retrieving data from the server, FreeTDS substitutes an ASCII '?' in the character's place, and emits a warning message stating that some characters could not be converted. On sending data to the server, FreeTDS aborts the query and emits an error message. It is well to ensure that the data contained in the database is representable in the client's character set. -If you have a mix of character data that can not be contained in a single byte character set, you may wish to use UTF-8. UTF-8 is a variable length unicode encoding that is compatible with ASCII in the range 0 to 127. With UTF-8, you are guaranteed to never have an unconvertible character. +If you have a mix of character data that can not be contained in a single-byte character set, you may wish to use UTF-8. UTF-8 is a variable length unicode encoding that is compatible with ASCII in the range 0 to 127. With UTF-8, you are guaranteed to never have an unconvertible character. -FreeTDS is not fully compatible with multi-byte character sets such as UCS-2. You must use an ASCII-extension charset (e.g., UTF-8, ISO-8859-*)not EBCDIC or other weird charsets. Extreme care should be taken with testing applications using these encodings. Specifically, many applications do not expect the number of characters returned to exceed the column size (in bytes). On the other hand, support of UTF-8 and UCS-2 is a high priority for the developers. Patches and bug reports in this area are especially welcome. - +FreeTDS is not fully compatible with multi-byte character sets such as UCS-2. You must use an ASCII-extension charset (e.g., UTF-8, ISO-8859-*)not EBCDIC or other weird charsets. Great care should be taken testing applications using these encodings. Specifically, many applications do not expect the number of characters returned to exceed the column size (in bytes). In the following example, a server named mssql will return data encoded in the UTF-8 character set. @@ -3483,7 +3484,7 @@ But check! No point in trying to use a null pointer. - Typically it's more convenient to have db-lib convert the data into the desired for. The function that does that is dbind(). So: after fetching the metadata, and before fetching the data, we usually prepare the bound columns. + Typically it's more convenient to have db-lib convert the data into the desired form. The function that does that is dbind(). So: after fetching the metadata, and before fetching the data, we usually prepare the bound columns. Fetching Data commit 57b81538c6041f8b6534fbe6511a070739770115 Author: jklowden Date: Fri Apr 18 19:43:52 2008 +0000 added version lable diff --git a/doc/tds.html b/doc/tds.html index 28ab6de..b6ecd7a 100644 --- a/doc/tds.html +++ b/doc/tds.html @@ -439,7 +439,7 @@ auth authentication data

* Under TDS9+ these types allow size to be -1. These types represents varchar(max), varbinary(max) and nvarchar(max). -Data representation for these types change in this way: +Data representation for these types change in this way:

  • size is 64 bit not 16 bit
  • if size is -1 meaning NULL
  • @@ -447,7 +447,6 @@ Data representation for these types change in this way:
  • data is splitted in chunks where ever chunk start with a 32 bit size
  • a chunk with size <= 0 is the terminal chunk
-

Collate type - TDS8

@@ -1516,6 +1515,8 @@ The following people have contributed to this document:

(short list) +

Document Status

+

$Id: tds.html,v 1.37 2008/04/18 19:43:52 jklowden Exp $

Date: Wed Apr 23 21:35:45 2008 +0000 removed spurious 0xA0 from output diff --git a/ChangeLog b/ChangeLog index 9ceb525..33b692a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Wed Apr 23 17:25:58 EDT 2008 JK Lowden + * src/apps/bsqldb.c removed spurious 0xA0 from output + * src/odbc/odbc.c add error diagnostic to SQLGetData + * include/tds.h src/tds/log.c src/tds/login.c + * src/tds/token.c + - add tdsdump_col() + Sun Mar 23 16:55:08 EDT 2008 JK Lowden * doc/userguide.sgml clarified localization @@ -235,4 +242,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2507 2008/03/23 20:56:37 jklowden Exp $ +$Id: ChangeLog,v 1.2508 2008/04/23 21:35:45 jklowden Exp $ diff --git a/src/apps/bsqldb.c b/src/apps/bsqldb.c index aa87180..ba4f26b 100644 --- a/src/apps/bsqldb.c +++ b/src/apps/bsqldb.c @@ -45,7 +45,7 @@ #include #include "replacements.h" -static char software_version[] = "$Id: bsqldb.c,v 1.32 2007/12/06 19:00:24 freddy77 Exp $"; +static char software_version[] = "$Id: bsqldb.c,v 1.33 2008/04/23 21:35:45 jklowden Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; int err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr); @@ -869,7 +869,7 @@ msg_handler(DBPROCESS * dbproc, DBINT msgno, int msgstate, int severity, char *m fprintf(stderr, "%s\n", msgtext); if (severity > 10) { - fprintf(stderr, "%s: error: severity %d > 10, exiting\n", options.appname, severity); + fprintf(stderr, "%s: error: severity %d > 10, exiting\n", options.appname, severity); exit(severity); } commit f991c8282649826762b9dbd0c17215bcea1c373c Author: jklowden Date: Wed Apr 23 21:35:54 2008 +0000 add error diagnostic to SQLGetData diff --git a/src/odbc/odbc.c b/src/odbc/odbc.c index 0938e37..62f7222 100644 --- a/src/odbc/odbc.c +++ b/src/odbc/odbc.c @@ -60,7 +60,7 @@ #include #endif -TDS_RCSID(var, "$Id: odbc.c,v 1.478 2008/03/13 13:23:31 freddy77 Exp $"); +TDS_RCSID(var, "$Id: odbc.c,v 1.479 2008/04/23 21:35:54 jklowden Exp $"); static SQLRETURN _SQLAllocConnect(SQLHENV henv, SQLHDBC FAR * phdbc); static SQLRETURN _SQLAllocEnv(SQLHENV FAR * phenv); @@ -4637,7 +4637,10 @@ SQLGetData(SQLHSTMT hstmt, SQLUSMALLINT icol, SQLSMALLINT fCType, SQLPOINTER rgb } /* read data from TDS only if current statement */ - if ((stmt->cursor == NULL && stmt->dbc->current_statement != stmt) || stmt->row_status == PRE_NORMAL_ROW || stmt->row_status == NOT_IN_ROW) { + if ((stmt->cursor == NULL && stmt->dbc->current_statement != stmt) + || stmt->row_status == PRE_NORMAL_ROW + || stmt->row_status == NOT_IN_ROW) + { odbc_errs_add(&stmt->errs, "24000", NULL); ODBC_RETURN(stmt, SQL_ERROR); } @@ -4649,16 +4652,16 @@ SQLGetData(SQLHSTMT hstmt, SQLUSMALLINT icol, SQLSMALLINT fCType, SQLPOINTER rgb tds = stmt->dbc->tds_socket; context = stmt->dbc->env->tds_ctx; - resinfo = tds->current_results; - if (!resinfo) { + + if (!tds->current_results) { odbc_errs_add(&stmt->errs, "HY010", NULL); ODBC_RETURN(stmt, SQL_ERROR); } - if (icol <= 0 || icol > resinfo->num_cols) { + if (icol <= 0 || icol > tds->current_results->num_cols) { odbc_errs_add(&stmt->errs, "07009", "Column out of range"); ODBC_RETURN(stmt, SQL_ERROR); } - colinfo = resinfo->columns[icol - 1]; + colinfo = tds->current_results->columns[icol - 1]; if (colinfo->column_cur_size < 0) { *pcbValue = SQL_NULL_DATA; @@ -4700,22 +4703,23 @@ SQLGetData(SQLHSTMT hstmt, SQLUSMALLINT icol, SQLSMALLINT fCType, SQLPOINTER rgb } if (is_variable_type(colinfo->column_type) && (fCType == SQL_C_CHAR || fCType == SQL_C_BINARY)) { - /* calc how many bytes was readed */ - int readed = cbValueMax; + /* calculate how many bytes were read */ + int remaining = cbValueMax; /* FIXME test on destination char ??? */ - if (stmt->dbc->env->attr.output_nts != SQL_FALSE && fCType == SQL_C_CHAR && readed > 0) - --readed; - if (readed > *pcbValue) - readed = *pcbValue; - colinfo->column_text_sqlgetdatapos += readed; + if (stmt->dbc->env->attr.output_nts != SQL_FALSE && fCType == SQL_C_CHAR && remaining > 0) + --remaining; + if (remaining > *pcbValue) + remaining = *pcbValue; + colinfo->column_text_sqlgetdatapos += remaining; /* avoid infinite SQL_SUCCESS on empty strings */ if (colinfo->column_text_sqlgetdatapos == 0 && cbValueMax > 0) ++colinfo->column_text_sqlgetdatapos; - /* not all readed ?? */ - if (colinfo->column_text_sqlgetdatapos < colinfo->column_cur_size) - /* TODO add diagnostic */ + + if (colinfo->column_text_sqlgetdatapos < colinfo->column_cur_size) { /* not all read ?? */ + odbc_errs_add(&stmt->errs, "1004", "String data, right truncated"); ODBC_RETURN(stmt, SQL_SUCCESS_WITH_INFO); + } } else { colinfo->column_text_sqlgetdatapos = colinfo->column_size; } commit f0a6eca4f74069613ae324b645498827b96a7679 Author: jklowden Date: Wed Apr 23 21:36:01 2008 +0000 add tdsdump_col() diff --git a/include/tds.h b/include/tds.h index 1a5eafa..50d0282 100644 --- a/include/tds.h +++ b/include/tds.h @@ -20,7 +20,7 @@ #ifndef _tds_h_ #define _tds_h_ -/* $Id: tds.h,v 1.285 2008/01/18 13:37:12 freddy77 Exp $ */ +/* $Id: tds.h,v 1.286 2008/04/23 21:36:01 jklowden Exp $ */ #include #include @@ -1535,18 +1535,22 @@ void tds_set_parent(TDSSOCKET * tds, void *the_parent); void *tds_get_parent(TDSSOCKET * tds); int tds_swap_bytes(unsigned char *buf, int bytes); int tds_version(TDSSOCKET * tds_socket, char *pversion_string); +unsigned int tds_gettime_ms(void); + +/* log.c */ void tdsdump_off(void); void tdsdump_on(void); int tdsdump_open(const char *filename); void tdsdump_close(void); void tdsdump_dump_buf(const char* file, unsigned int level_line, const char *msg, const void *buf, int length); -void tdsdump_log(const char* file, unsigned int level_line, const char *fmt, ...) +void tdsdump_col(const TDSCOLUMN *col); +void tdsdump_log(const char* file, unsigned int level_line, const char *fmt, ...) + #if defined(__GNUC__) && __GNUC__ >= 2 __attribute__ ((__format__ (__printf__, 3, 4))) #endif ; extern int tds_debug_flags; -unsigned int tds_gettime_ms(void); /* net.c */ int tds_open_socket(TDSSOCKET * tds, const char *ip_addr, unsigned int port, int timeout); diff --git a/src/tds/log.c b/src/tds/log.c index 2de151f..4c9ee5d 100644 --- a/src/tds/log.c +++ b/src/tds/log.c @@ -66,7 +66,7 @@ #include #endif -TDS_RCSID(var, "$Id: log.c,v 1.4 2007/11/12 22:17:28 jklowden Exp $"); +TDS_RCSID(var, "$Id: log.c,v 1.5 2008/04/23 21:36:01 jklowden Exp $"); /* for now all messages go to the log */ int tds_debug_flags = TDS_DBGFLAG_ALLLVL | TDS_DBGFLAG_SOURCE; @@ -111,7 +111,7 @@ tdsdump_on(void) /** - * This creates and truncates a human readable dump file for the TDS + * Create and truncate a human readable dump file for the TDS * traffic. The name of the file is specified by the filename * parameter. If that is given as NULL or an empty string, * any existing log file will be closed. @@ -362,7 +362,7 @@ tdsdump_dump_buf(const char* file, unsigned int level_line, const char *msg, con /** - * This function write a message to the debug log. + * Write a message to the debug log. * \param file name of the log file * \param level_line kind of detail to be included * \param fmt printf-like format string @@ -415,3 +415,79 @@ tdsdump_log(const char* file, unsigned int level_line, const char *fmt, ...) TDS_MUTEX_UNLOCK(&g_dump_mutex); } /* tdsdump_log() */ +/** + * Write a column value to the debug log. + * \param file name of the log file + * \param col column to dump + */ +void +tdsdump_col(const TDSCOLUMN *col) +{ + const char* typename; + char* data; + TDS_SMALLINT type; + + assert(col); + assert(col->column_data); + + typename = tds_prtype(col->column_type); + type = col->column_type; + + switch(type) { + case SYBINTN: + switch(col->column_cur_size) { + case sizeof(TDS_INT): + type = SYBINT4; + break; + case sizeof(TDS_SMALLINT): + type = SYBINT2; + break; + case sizeof(TDS_TINYINT): + type = SYBINT1; + break; + } + break; + case SYBFLTN: + switch(col->column_cur_size) { + case sizeof(TDS_REAL): + type = SYBREAL; + break; + case sizeof(TDS_FLOAT): + type = SYBFLT8; + break; + } + break; + } + + switch(type) { + case SYBCHAR: + case SYBVARCHAR: + data = calloc(1, 1 + col->column_cur_size); + if( !data ) { + tdsdump_log(TDS_DBG_FUNC, "no memory to log data for type %s\n", typename); + return; + } + memcpy(data, col->column_data, col->column_cur_size); + tdsdump_log(TDS_DBG_FUNC, "type %s has value \"%s\"\n", typename, data); + free(data); + break; + case SYBINT1: + tdsdump_log(TDS_DBG_FUNC, "type %s has value %d\n", typename, (int)*(TDS_TINYINT*)col->column_data); + break; + case SYBINT2: + tdsdump_log(TDS_DBG_FUNC, "type %s has value %d\n", typename, (int)*(TDS_SMALLINT*)col->column_data); + break; + case SYBINT4: + tdsdump_log(TDS_DBG_FUNC, "type %s has value %d\n", typename, (int)*(TDS_INT*)col->column_data); + break; + case SYBREAL: + tdsdump_log(TDS_DBG_FUNC, "type %s has value %f\n", typename, (double)*(TDS_REAL*)col->column_data); + break; + case SYBFLT8: + tdsdump_log(TDS_DBG_FUNC, "type %s has value %d\n", typename, (double)*(TDS_FLOAT*)col->column_data); + break; + default: + tdsdump_log(TDS_DBG_FUNC, "cannot log data for type %s\n", typename); + break; + } +} diff --git a/src/tds/login.c b/src/tds/login.c index 1bcbd0c..58deec6 100644 --- a/src/tds/login.c +++ b/src/tds/login.c @@ -51,7 +51,7 @@ #include #endif -TDS_RCSID(var, "$Id: login.c,v 1.172 2007/12/31 10:06:50 freddy77 Exp $"); +TDS_RCSID(var, "$Id: login.c,v 1.173 2008/04/23 21:36:01 jklowden Exp $"); static int tds_send_login(TDSSOCKET * tds, TDSCONNECTION * connection); static int tds8_do_login(TDSSOCKET * tds, TDSCONNECTION * connection); @@ -533,6 +533,9 @@ tds_send_login(TDSSOCKET * tds, TDSCONNECTION * connection) int len; char blockstr[16]; + /* override lservname field for ASA servers */ + const char *lservname = getenv("ASA_DATABASE")? getenv("ASA_DATABASE") : tds_dstr_cstr(&connection->server_name); + if (strchr(tds_dstr_cstr(&connection->user_name), '\\') != NULL) { tdsdump_log(TDS_DBG_ERROR, "NT login not support using TDS 4.x or 5.0\n"); return TDS_FAIL; @@ -579,7 +582,7 @@ tds_send_login(TDSSOCKET * tds, TDSCONNECTION * connection) } tds_put_n(tds, magic3, 3); tds_put_login_string(tds, tds_dstr_cstr(&connection->app_name), TDS_MAX_LOGIN_STR_SZ); - tds_put_login_string(tds, tds_dstr_cstr(&connection->server_name), TDS_MAX_LOGIN_STR_SZ); + tds_put_login_string(tds, lservname, TDS_MAX_LOGIN_STR_SZ); if (IS_TDS42(tds)) { tds_put_login_string(tds, tds_dstr_cstr(&connection->password), 255); } else { diff --git a/src/tds/token.c b/src/tds/token.c index e6d5a6d..445c4b1 100644 --- a/src/tds/token.c +++ b/src/tds/token.c @@ -42,7 +42,7 @@ #include #endif -TDS_RCSID(var, "$Id: token.c,v 1.344 2008/01/13 20:01:45 freddy77 Exp $"); +TDS_RCSID(var, "$Id: token.c,v 1.345 2008/04/23 21:36:01 jklowden Exp $"); static int tds_process_msg(TDSSOCKET * tds, int marker); static int tds_process_compute_result(TDSSOCKET * tds); @@ -1223,6 +1223,7 @@ tds_process_param_result(TDSSOCKET * tds, TDSPARAMINFO ** pinfo) return TDS_FAIL; token = tds_get_data(tds, curparam); + tdsdump_col(curparam); /* * Real output parameters will either be unnamed or will have a valid @@ -1573,6 +1574,8 @@ tds_get_data_info(TDSSOCKET * tds, TDSCOLUMN * curcol, int is_param) CHECK_TDS_EXTRA(tds); CHECK_COLUMN_EXTRA(curcol); + tdsdump_log(TDS_DBG_INFO1, "tds_get_data_info(%p, %p, %d) %s", tds, curcol, is_param, is_param? "[for parameter]" : ""); + curcol->column_namelen = tds_get_string(tds, tds_get_byte(tds), curcol->column_name, sizeof(curcol->column_name) - 1); curcol->column_name[curcol->column_namelen] = '\0'; @@ -1585,11 +1588,52 @@ tds_get_data_info(TDSSOCKET * tds, TDSCOLUMN * curcol, int is_param) curcol->column_writeable = (curcol->column_flags & 0x10) > 1; curcol->column_nullable = (curcol->column_flags & 0x20) > 1; curcol->column_identity = (curcol->column_flags & 0x40) > 1; - } - /* TODO what's these bytes ?? */ - if (IS_TDS90(tds)) - tds_get_n(tds, NULL, 2); +#if 0 + /**************************************** + * NumParts=BYTE; (introduced in TDS 7.2) + * PartName=US_VARCHAR;(introduced in TDS 7.2) + * TableName=NumParts, {PartName}-; + * ColName= HYPERLINK \l "B_VARCHAR_Def" B_VARCHAR; + * ColumnData=UserType, Flags, [TableName], // ColName; + * NoMetaData='0xFF', '0xFF'; + */ + enum column_flag_bits_according_to_microsoft { + case_sensitive = 0x0001 + , nullable = 0x0002 + , updateable = 0x0004 + , might_be_updateable = 0x0008 + , identity = 0x0010 + , computed = 0x0020 + , us_reserved_odbc = 0x0040 | 0x0080 + , is_fixed_len_clr_type = 0x0100 + , is_hidden_browse_pk = 0x0200 + , is_browse_pk = 0x0400 + , might_be_nullable = 0x0800 + }; + /* TODO: implement members in TDSCOLUMN */ + if (IS_TDS90(tds)) { + curcol->is_computed = (curcol->column_flags & (1 << 4)) > 1; + curcol->us_reserved_odbc1 = (curcol->column_flags & (1 << 5)) > 1; + curcol->us_reserved_odbc2 = (curcol->column_flags & (1 << 6)) > 1; + curcol->is_fixed_len_clr_type = (curcol->column_flags & (1 << 7)) > 1; + } +#endif + } + if (IS_TDS90(tds)) { + tds_get_n(tds, NULL, 2); +#if 0 + /* TODO: implement members in TDSCOLUMN, values untested */ + curcol->us_reserved1 = (curcol->column_flags & 0x01); + curcol->us_reserved2 = (curcol->column_flags & 0x02); + curcol->us_reserved3 = (curcol->column_flags & 0x04); + curcol->us_reserved4 = (curcol->column_flags & 0x08); + curcol->is_hidden = (curcol->column_flags & 0x10); + curcol->is_key = (curcol->column_flags & 0x20); + curcol->is_nullable_unknown = (curcol->column_flags & 0x40); +#endif + } + curcol->column_usertype = tds_get_int(tds); tds_set_column_type(tds, curcol, tds_get_byte(tds)); commit 48d88d459db8323e2d69866ccd0862856e1d331e Author: jklowden Date: Thu Apr 24 15:59:29 2008 +0000 small clarifications diff --git a/ChangeLog b/ChangeLog index 33b692a..0357601 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +Thu Apr 24 11:57:24 EDT 2008 JK Lowden + * doc/htdoc/faq.html small clarifications + Wed Apr 23 17:25:58 EDT 2008 JK Lowden * src/apps/bsqldb.c removed spurious 0xA0 from output * src/odbc/odbc.c add error diagnostic to SQLGetData @@ -242,4 +245,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog truncated because of release * ChangeLog-0.82 added because of release -$Id: ChangeLog,v 1.2508 2008/04/23 21:35:45 jklowden Exp $ +$Id: ChangeLog,v 1.2509 2008/04/24 15:59:29 jklowden Exp $ diff --git a/doc/htdoc/faq.html b/doc/htdoc/faq.html index 76126b3..d49ac66 100644 --- a/doc/htdoc/faq.html +++ b/doc/htdoc/faq.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> - + -

-
  1. General Questions @@ -126,18 +122,12 @@
  2. -
  3. Problems Running - -
@@ -567,9 +571,7 @@ DBI::ODBC load for other systems. On the downside, it may be a little less robust than DBD::Sybase.

-

Are there any known issues?

- +

Are there any known issues?

  • ODBC can be confusing to set up. See the samples directory for example .ini files, and follow the User @@ -596,6 +598,20 @@ sometimes be misleading. In the latter case, it's often necessary to examine the log file to understand what went wrong.

    +

    What features are missing compared to the vendors' implementations?

    + +

    In no particular order:

    +
      +
    • MARS
    • +
    • db-lib browse API
    • +
    • Parameterized queries in ct-lib with TDS 7.0+ (i.e. Microsoft servers)
    • +
    • ct-lib money functions
    • +
    + +

    For specific functions, consult doc/api_status.txt in your distribution.

    + +

    Very few programs actually need the missing functionality. Parameterized ct-lib queries would benefit Perl DBD::Sybase users, but the functionality would require departing from Sybase's documented API. MARS comes up because there must be thousands of people whom Microsoft has convinced they need it, but the benefits are meager compared to the complexity.

    +

    Why does each connection support only one query at a time?

    @@ -635,13 +651,19 @@ That's not as bad as it sounds, and it certainly not unheard of to have 4 or more simultaneous connections supporting an application.
  • -
It's important to realize that the selection of rows and + + +

It's important to realize that the selection of rows and their accumulation into a container of some sort are two different functions. A TDS server issues its results a row at a time, which the client library dutifully makes available to the application on arrival. It's up to the application—or a higher-level library—to form a "rowset" of some kind if - desired. + desired.

+ +

But what about MARS® you ask? Doesn't that solve the problem? Well, no. MARS does make a TDS server more similar to other vendors' servers, and Microsoft benefits from one more just-like-the-others feature for its ODBC driver. But Microsoft claims a patent on MARS, the documentation is incomplete, and supporting it would introduce significant complexity.

+ +

MARS might get implemented one day; more surprising things have happened. But the technical advantages it provides to the programmer are over server-side cursors or simply using another connection are vanishingly small.

PHP note

If you use PHP, you will still run into this problem even if you create a new connection. The reason is that @@ -900,14 +922,19 @@ normally not the one you use to log in, or to test your script with on the command line.

- +

How do I debug my Oracle Heterogeneous Services error?

+ +

The message produced by the Oracle server is seldom detailed enough to understand what's wrong. + Really, the only way to debug these errors reliably is with a TDSDUMP log of the session. + The log will contain any error messages from the server and/or from the library. Often that's + all the information needed. If not, post the log to the mailing list.


Updates and comments FreeTDS FAQ Master
- $Id: faq.html,v 1.25 2009/02/11 02:41:58 jklowden Exp $ + $Id: faq.html,v 1.26 2010/12/31 04:12:07 jklowden Exp $

diff --git a/doc/tsql.txt b/doc/tsql.txt index 8536eec..62a147f 100644 --- a/doc/tsql.txt +++ b/doc/tsql.txt @@ -1,7 +1,7 @@ NAME tsql - utility to test FreeTDS connections and queries SYNOPSIS - tsql { -S servername [-I inside] | -H hostname -p port } + tsql { -S servername [-I interface] | -H hostname -p port } -U username [-P password] [-o options] tsql -C @@ -33,7 +33,7 @@ OPTIONS -S servername the Database Server to which to connect. - -I inside a freetds.conf or interfaces file describing servername + -I interface a freetds.conf or interfaces file describing servername -H hostname the DNS hostname of the server @@ -43,6 +43,8 @@ OPTIONS -P password database password. + -L list server "instances" (with -H) + -C prints some of the compile-time configuration parameters. -o options apply the options specified to every command. @@ -61,6 +63,12 @@ Typing "version" displays the TDS protocol version. Command batches may be separated with "go" or "GO". If "GO", the version string is reported before executing the batch. +After prompting for the password, tsql will attempt to connect to the remote +server. tsql displays a counter indicating the number of seconds that +it is attempting to connect. Typically, tsql should immediately respond +with a '1>' prompt. If you see the counter (1, 2, 3, ...), most likely tsql +is unable to connect to the indicated server. + If you can connect with "tsql -S servername", your basic FreeTDS installation is working. diff --git a/doc/userguide.sgml b/doc/userguide.sgml index 01a6d5b..2d9971d 100644 --- a/doc/userguide.sgml +++ b/doc/userguide.sgml @@ -9,8 +9,8 @@ ]> - $Date: 2010/09/16 07:44:33 $ - $Revision: 1.130 $ + $Date: 2010/12/31 04:12:07 $ + $Revision: 1.131 $ &freetds; User Guide A Guide to Installing, Configuring, and Running &freetds; @@ -62,9 +62,9 @@ This guide is here for you, and we hope that you will be here for it, that other The version you're reading is: -$Revision: 1.130 $ -$Date: 2010/09/16 07:44:33 $ -CVS control number $Id: userguide.sgml,v 1.130 2010/09/16 07:44:33 freddy77 Exp $. +$Revision: 1.131 $ +$Date: 2010/12/31 04:12:07 $ +CVS control number $Id: userguide.sgml,v 1.131 2010/12/31 04:12:07 jklowden Exp $. can be found on the &freetds; @@ -215,18 +215,16 @@ project on SourceForge. It is a fork of the Status - -The db-lib and ct-lib APIs have been usable for several years. They have been successfully substituted for Sybase's own libraries in a variety of venues, including Perl and PHP. That is not to say that these drivers are complete; they're not. But they faithfully implement a useful — and widely used — subset of their APIs. + The libraries are portable, mature, and stable. They're expected to compile readily and normally do not crash or corrupt data. There is a logging feature to aid in diagnosing problems. While they do not include every feature provided by the vendors' libaries, they do faithfully implement a useful — and widely used — subset of their APIs. - -In addition to the core db-lib API, &freetds; includes a full implementation of db-lib's bcp functions, as well as freebcp, a replacement for Sybase's bcp utility. + The db-lib and ct-lib APIs have been usable for several years. They have been successfully substituted for Sybase's own libraries in a variety of venues, including Perl and PHP. - -The ODBC driver should be fully ODBC 3.0 compliant. Any problems found in the currently implemented API subset are cheerfully addressed. + The ODBC driver should be fully ODBC 3.0 compliant. - -Basic API coverage information for all libraries may be found in this manual. It is maintained in doc/api_status.txt, included in the source distribution. + Basic API coverage information for all libraries may be found in this manual. It is maintained in doc/api_status.txt, included in the source distribution. + In addition to the core db-lib API, &freetds; includes a full implementation of db-lib's bcp functions, as well as freebcp, a replacement for Sybase's bcp utility. + How big is it? &freetds; has over 90,000 lines of C code, maintained by a handful of developers. Patches arrive irregularly, varying in size from one-liners to thousand-line monsters. Almost all are applied or used in some way. The mailing list has some 700 or so subscribers at this writing. Safe to say, &freetds;'s success so far lies somewhere between the Beetle and the Edsel. Who uses it? Oh, pretty much everyone. &freetds; users almost certainly number in the tens of thousands. It's used by large corporations, by the U.S. federal government (e.g. Database Access Library at the National Center for Biotechnology Information) and, judging by the mailing list, by many webservers running Apache and PHP. Microsoft recommends &freetds; to their customers who want access to Microsoft SQL Server from non-Win32 clients. So do we. @@ -237,10 +235,6 @@ Basic API coverage information for all libra You may be wondering how these libraries fit with Perl, PHP, TCL, Python, or other popular scripting languages. Most of these languages have bindings to Sybase that use either the db-lib or ct-lib API, for which &freetds; is intended as a drop-in replacement. For instance, Michael Peppler's DBD::Sybase works very well using &freetds; to access Sybase or Microsoft SQL Servers. PHP has options for sybase (db-lib) and sybase-ct (ct-lib) APIs. - -Not to be outdone, the folks at the O'Caml project have a binding for that language. You can read more about it on -Kenn Knowles's site; see also his ocamldbi driver. - Alternatives @@ -475,7 +469,7 @@ There are a few optional arguments to configure that may be importan Enable Microsoft behavior in the db-lib API where it diverges from Sybase's. (For instance, Microsoft uses different names for the members of its date structure.) Typically needed only for porting Win32 applications to Unix. - As of version 0.63, this option specifies just the default behavior. Programs can change the default at compile time by defining MSDBLIB or SYBDBLIB (for Microsoft or Sybase behavior, respectively) . + This option specifies default behavior. Programs can change the default at compile time by defining MSDBLIB or SYBDBLIB (for Microsoft or Sybase behavior, respectively). @@ -494,8 +488,7 @@ There are a few optional arguments to configure that may be importan - Enable SSPI support. SSPI is a Windows library that allow you to use your current logged account for - authentication. This allow you to login without entering a password again. + Enable SSPI support. SSPI is a Micrsoft library that allows you to use your current logged account for authentication. With this option enabled, FreeTDS supports "trusted logins" for Win32/64, just as Microsoft's own implmentations do. @@ -617,7 +610,7 @@ url="http://www.madgoat.com">www.madgoat.com). OS X® - As of this writing ($Date: 2010/09/16 07:44:33 $), the regular distribution compiles on OS X. Releases prior to 0.63 either did not compile or required patching. + As of this writing ($Date: 2010/12/31 04:12:07 $), the regular distribution compiles on OS X. Releases prior to 0.63 either did not compile or required patching. Alternative build procedure @@ -754,13 +747,16 @@ The TDS protocol version is probably something you'd rather not know 7.1 Include support for bigint (64 bit integers), variant and collation on all fields. Collation is not widely used. + + Microsoft SQL Server 2005 + 7.2 + Includes support for varchar(max), varbinary(max), xml datatypes and MARSMultiple Active Result Sets. &freetds; does not support MARS. . + - -Why downgrade your protocol? If you encounter a bug, reverting to 4.2 can help isolate it. If you're using low-bandwidth connections, 4.2 is faster than 7.0, because 7.0 transfers all character data in UCS-2 (Unicode, 2 bytes/character). -However TDS 4.2 has many limitations (see below). If you encounter problems, please report them to the mailing list. + For best results, use the highest version of hte protocol supported by your server. If you encounter problems, try a lower version. If that works, though, please report it to the mailing list! TDS 4.2 has limitations @@ -819,7 +815,7 @@ and 7.0. Version 7.0 is recommended for compatibility with SQL Server tools. Just as DNS defines hostnames for network addresses, &freetdsconf; uses a servername to define the properties of your server. In general, the servername is arbitrary and local; it's used only by your client programs to tell &freetds; which server to connect to. You can choose any name you like. - Sybase SQL Anywhere (a/k/a Sybase ASA), however, is fussy. You must use the database's name as your servername. Otherwise, the server will refuse your connection. + Sybase SQL Anywhere (a/k/a Sybase ASA), however, is fussy. Unless you use the ASA Database property, you must use the database's name as your servername. Otherwise, the server will refuse your connection. In particular, &freetds; needs to know: Primary Server Properties @@ -909,11 +905,11 @@ It bears mentioning here that prior versions of &freetds; were quite fussy about tds version + 4.2, 5.0, 7.0, 7.1, 7.2, auto --with-tdsver value (5.0 if unspecified) Overridden by TDSVER. - The TDS protocol version to use when connecting. - 4.2, 5.0, 7.0, 7.1, 7.2 + The TDS protocol version to use when connecting. auto tells &freetds; to use an autodetection (trial-and-error) algorithm to choose the protocol version. host @@ -961,16 +957,23 @@ It bears mentioning here that prior versions of &freetds; were quite fussy about The port number that the servername is listening to. Please note: - The "defaults" to the left are the server's default settings. &freetds; chooses its default port based on the TDS protocol version: 5000 for TDS 5.0, and 1433 for everything else. + The "defaults" to the left are the server's default settings. &freetds; chooses its default port based on the TDS protocol version: 5000 for TDS 5.0, and 1433 for everything else. Mutually exclusive with instance, below. Overridden by TDSPORT. - ASA database + instance + instance name + none + Name of Microsoft SQL Server instance to connect to. The port will be detected automatically. Mutually exclusive with port, above. Requires UDP connection to port 1434 on the server. + + + + ASA database valid database name servername [section] name - Specifies the name of the default database when connecting to an ASA server. A TDS 5.0 login packet has a field called lservname. For most TDS servers, lservname is a user-defined string with no inherent meaning. ASA servers, however, requires that lservname contain a valid database name, and sets that as the default database for the connection. FreeTDS normally fills lservname with the [section]text.. This entry instead sets the database name independently of the [section] name. + Specifies the name of the default database when connecting to an ASA server. A TDS 5.0 login packet has a field called lservname. For most TDS servers, lservname is a user-defined string with no inherent meaning. ASA servers, however, requires that lservname contain a valid database name, and sets that as the default database for the connection. FreeTDS normally fills lservname with the [section] text.. This entry instead sets the database name independently of the [section] name. @@ -1017,7 +1020,7 @@ It bears mentioning here that prior versions of &freetds; were quite fussy about any valid iconv character set ISO-8859-1Valid for ISO 8859-1 character set. See Localization and TDS 7.0 for more information. Makes &freetds; use iconv to convert to and from the specified character set from UCS-2 in TDS 7.0 or above. -As of 0.62 FreeTDS uses iconv to convert all character data, so there's no need to match the server's charset to insert any characters the server supports. +&freetds; uses iconv to convert all character data, so there's no need to match the server's charset to insert any characters the server supports. text size @@ -1026,12 +1029,6 @@ As of 0.62 FreeTDS uses iconv to convert all character data, so there's no need default value of TEXTSIZE, in bytes. For text and image datatypes, sets the maximum width of any returned column. Cf. set TEXTSIZE in the T-SQL documentation for your server. - instance - instance name - none - Name of Microsoft SQL Server instance to connect to. The port will be detected automatically. - - debug flags Any number even in hex or octal notation 0x4fff @@ -1126,7 +1123,7 @@ As of 0.62 FreeTDS uses iconv to convert all character data, so there's no need Deprecated options</> - <para>As of version 0.62 the following options are deprecated and supported only for backward compatibility.</para> + <para>The following options have long been deprecated.</para> <itemizedlist id="lst.freetds.conf.deprecated" spacing="compact"> <title>Deprecated &freetdsconf; settings @@ -1388,17 +1385,18 @@ Compile-time settings (established with the "configure" script): When servername cannot be converted to an address, up to two messages may result. Successful conversion (by any means) never produces an error message. -Failure to find or resolve <replaceable>servername</> +Failure to find <replaceable>servername</> in &freetdsconf; $ tsql -S nobox -U sa Password: locale is "C" locale charset is "646" -Msg 20012, Level 2, State -1, Server OpenClient, Line -1 -Server name not found in configuration files. -Msg 20013, Level 2, State -1, Server OpenClient, Line -1 -Unknown host machine name. +Password: +Error 20012 (severity 2): + Server name not found in configuration files. +Error 20013 (severity 2): + Unknown host machine name. There was a problem connecting to the server $ host nobox @@ -1408,10 +1406,10 @@ Host not found. -In the above case nobox was not found in &freetdsconf; and was is not a valid hostname according to DNS. +In the above case message 20012 indicates nobox was not found in &freetdsconf;. The library then treated nobox as a network hostname but found it also not to be valid per DNS, leading to message 20013. - If servername is found but refers to an invalid hostname, only message 20013 is returned. + If servername is found in the configuration files, but refers to an invalid hostname, only message 20013 is returned. Failure to resolve hostname for <replaceable>servername</> @@ -1421,17 +1419,19 @@ In the above case nobox was not found in &freetdsconf; and was is no locale is "C" locale charset is "646" -Msg 20013, Level 2, State -1, Server OpenClient, Line -1 -Unknown host machine name. +Error 20013 (severity 2): + Unknown host machine name. There was a problem connecting to the server Unfortunately, the host machine name (the right side of the host line in &freetdsconf;) isn't mentioned in the error message. Fortunately, this kind of setup problem is rarely encountered by users. + + Connecting to the Server If name lookup succeeds, &freetds; next attempts to connect to the server. To connect means to form at TCP connection by calling connect(2). A valid connection must exist before any information can be exchanged with the server. Specifically, we need a connection before we can log in. - A few things can go wrong at this point. The address returned by DNS may not be that of the machine hosting the server. The machine may be down. The server may not be running. The server may be running but not listening to the port &freetds; is attempting to connect to. In rare cases, both ends are correctly configured, but a firewall stands in the way. + A few things can go wrong at this point. The address returned by DNS may not be that of the machine hosting the server, or indeed of any machine! The machine may be down. The server may not be running. The server may be running but not listening to the port &freetds; is attempting to connect to. In rare cases, both ends are correctly configured, but a firewall stands in the way. If no server accepts the connection, no connection can be established. It's difficult to know why, and the message is consequently vague. @@ -1593,7 +1593,7 @@ The connection attributes are provided as a single argument, a string of concate But FreeTDS did not start out as an ODBC driver (remember db-lib and ct-lib), and has always had its own way to store server properties: &freetdsconf;. When Brian added the FreeTDS ODBC driver, he began by supporting the old SQLConnect, using odbc.ini to describe the DSN. That choice complied with the expectations of the Driver Managers, and minimized the amount of duplicated information in the configuration files. But it can be a little confusing, too, because odbc.ini in effect points to &freetdsconf;. We call this configuration ODBC-combined, because it supports all three FreeTDS libraries. -With version 0.60, the FreeTDS ODBC library started to see fuller implementation. The driver was made able to read the connection attributes directly from odbc.ini, rather than leaning on &freetdsconf;. For installations that don't need db-lib and ct-lib, this ODBC-only setup is simpler. +As progress on the the &freetds; ODBC library progressed, the driver was made able to read the connection attributes directly from odbc.ini, rather than leaning on &freetdsconf;. For installations that don't need db-lib and ct-lib, this ODBC-only setup is simpler. More recently, SQLDriverConnect was added to FreeTDS. As described above, this function allows the application to specify connection attributes with reference to either, or neither, configuration file. It's your choice. In making that choice, keep the following terms clear in your mind: @@ -2136,7 +2136,8 @@ Why this happens is anyone's guess. Here's one: it makes the datatype of the co Domain logins can be used only with TDS protocol versions 7.0 or above. As mentioned in the installation chapter, Microsoft SQL Server includes the ability to use domain logins instead of standard server logins. The advantage of doing this is that the passwords are encrypted on the wire using a challenge-response protocol. -&freetds; began supporting domain logins in version 0.60. + + Domain logins may or may not support single sign-on (connecting without prompting for a password) depending on how &freetds; was configured. For Windows hosts (both 32- and 64-bit), if SSPI is enabled, &freetds; will log in using so-called "trusted authentication". For Linux (and similar) hosts, enabling Kerberos provides similar functionality. If neither option is enabled, &freetds; can still log in using the domain account, but the user must re-enter the password, as described next. To use domain logins, use the 'DOMAIN\username' syntax for the username and use the domain password. commit 4d5c8725537f069f11c45b10e077dad4bd187ea8 Author: jklowden Date: Fri Dec 31 16:20:58 2010 +0000 updated per Frediano diff --git a/doc/htdoc/faq.html b/doc/htdoc/faq.html index bb1bb2b..bfa23bc 100644 --- a/doc/htdoc/faq.html +++ b/doc/htdoc/faq.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> - + General Questions -

What is FreeTDS?

- +

What is FreeTDS?

FreeTDS is a free implementation of the TDS (Tabular Data Stream) protocol that is used by Sybase and Microsoft for their - database products. It implements TDS 4.2, 5.0, 7.0 and - 8.0, and can communicate with any Sybase or Microsoft SQL - Server.

+ database products. It can communicate with any Sybase or Microsoft SQL + Server. It includes three client libraries: DB-Library, CT-Library, + and ODBC. All libraries use the same protocol and can communicate with + servers from both vendors.

-

FreeTDS comes with a low level library (the TDS layer) along - with a number of APIs (Application Programming Interfaces). The - APIs are DB-Lib, CT-Lib, and ODBC.

- -

Where do I get FreeTDS?

- +

Where do I get FreeTDS?

You can get the latest FreeTDS from @@ -197,8 +192,7 @@ to the list if you're looking for one and don't find one in the usual places.

-

Does FreeTDS support Microsoft servers?

-
+

Does FreeTDS support Microsoft servers?

Yes. Microsoft servers don't usually accept TDS 5.0 connections. Use one of versions 4.2, 7.0 or 8.0 of the protocol. @@ -219,8 +213,7 @@ "userguide/choosingtdsprotocol.htm">User Guide for details.

-

How can I get help (or support)?

- +

How can I get help (or support)?

After reading this FAQ and the User Guide, you might want to look at the mailing list -

Who is responsible for FreeTDS?

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Brian - BrunsStarted this crazy thing
Gregg - JensenMessage handlers and extra datatype support and some - sybperl stuff?
Arno - PedusaarDonated his TDS4.2 code to the cause
Mihai - IbanescuGNUified the packet
Craig - SpannringJDBC driver and CVS repository.
Mark - SchaalCleaned up message handling, bug fixes, ctlib - unittests
Kevin - LyonsVarious TDS bug fixes
Sam - TetherowVarious TDS bug fixes
Geoff - WinklessLost connection stuff
Ken - SeymourODBC Driver Fixes
Scott - GrayTDS 7.0 numeric support and bug fixes
Bob - KlineNTEXT support
Koscheev - Andreynegative money patch
Dennis - NicklausvxWorks port and fixes for dbdata() and SYBVARBINARY
Brandon M. - Reynoldsfix for arbitrarily large queries under dblib.
Steve - Langasekoff by one fixes and autoconf byte size thing.
Mark J. - Lilbackimplementation of dbstrlen and dbstrcpy
Thanks go to the folks at A2i, Inc. http://www.a2i.com for funding the - development of dblib host file bulk copy and writetext +

Who is responsible for FreeTDS?

+ +

Current contributors

+
+
Brian + Bruns
+
Started this crazy thing
+
James K. Lowden
+
Project maintainer since 2003
+
Frediano Ziglio
+
Wrote great swaths of the ODBC driver and keeps the TDS + library up to date with protocol changes. Also contributed + most of the current encryption logic.
+
+

For a more complete history, see AUTHORS in the distribution. + Thanks also go to the folks at A2i, Inc. http://www.a2i.com for funding the original + development of db-lib host file bulk copy and writetext support, and to Dave Poyourow there for helping with the debugging.

-

(These addresses have been mangled to defy "spamaton" programs - that mindlessly collect email addresses from the web. To send +

(To send email to anyone listed above, delete the "nospam." part of the address.)

-

Why LGPL license?

- +

Why LGPL license?

Brian Bruns started the project, and that's the choice he made. LGPL was chosen because if you want a commercial client, - you can buy them from Sybase, Microsoft or others. "I do believe + you can buy them from Sybase, Microsoft or others. “I do believe BSDish licenses are better in some cases, but not for something - like this," he said.

+ like this,” he said.


-

Documentation

- +

Documentation

What sort of documentation is available?

@@ -404,9 +278,9 @@ "reference/">Reference Manual is a beginning at an independent description of the client APIs and the TDS layer. - + -

What about a Programmer's Reference Manual?

+

What about a Programmer's Reference Manual?

The best information is available from the vendors. FreeTDS means to conform to the documented (and, in some cases, @@ -428,8 +302,7 @@ -

Is there any documentation on the TDS protocol?

- +

Is there any documentation on the TDS protocol?

There is preliminary documentation available. The most up to date version is in @@ -448,7 +321,6 @@

Implementation

-

What is this SYBASE environment variable?

Many programs look for the SYBASE environment variable in order to find the library's home. You will want to @@ -458,8 +330,7 @@ /usr/local/freetds/lib), then your SYBASE variable would be set to /usr/local/freetds.

-

How do I install the RPM?

- +

How do I install the RPM?

rpm -ivh freetds-0.52-1.i386.rpm (as root) will install the libraries.

@@ -468,11 +339,11 @@ install the headers and other stuff needed to build other stuff.


+ -

Programming: C++, Sybperl, SQSH, & PHP

- - +

Programming: C++, Sybperl, SQSH, & PHP

+

How do I compile Sybperl with FreeTDS?

How do I compile SQSH with FreeTDS?

How do I compile PHP 3 with FreeTDS?

@@ -488,9 +359,8 @@

An attempt to make a connection to a MS SQL server from PHP would fail, leaving a message in the Apache error log:

-        "connect: Network is unreachable
-         DB-Library: Login incorrect"
-
+ connect: Network is unreachable + DB-Library: Login incorrect

The problem turned out to be a very simple one to fix. In the php.ini file under the sybase section, there is a directive @@ -500,10 +370,10 @@

After uncommenting this and setting it to a reasonable value (ie. /usr/local/freetds/interfaces), things started working.

- + -

How should I choose among db-lib, ct-lib, - and ODBC

+

How should I choose among db-lib, ct-lib, + and ODBC?

FreeTDS offers three client libraries and one internal one (libtds). We generally encourage people to @@ -532,44 +402,14 @@ shared object of it if you want to. It's just not done "out of the box" by the distributed makefiles.

-

Which Perl library should I use?

- +

Which Perl library should I use?

There are four options for using TDS and Perl to connect to a - Sybase or MSSQL database, DBD::Sybase, DBD::ODBC, DBD::FreeTDS, - and Sybperl.

- -

From Mark Schaal:

- -

DBD::Sybase is the recommended option, and yes it does work - with MSSQL. You will need to install the perl DBI module and the - FreeTDS package, particularly the CTLib portion. Set your SYBASE - environment variable to /usr/local/freetds and install - DBD::Sybase. Don't worry too much if some of the tests fail. Do - worry if the module doesn't compile. Make sure you have the most - recent version of FreeTDS installed. You can check the mailing list - archives or ask the mailing list for help.

- -

DBD::FreeTDS does not depend on the FreeTDS libraries. It is - minimally functional but it is considered alpha software and is - not being actively developed.

- -

From Michael - Peppler:
- Sybperl is a thin wrapper around the Sybase C APIs. It's a lot - more mature than DBI/DBD::Sybase (I've been working on it for 9 - years :-) and it's maybe more natural to use for someone who - already knows the Sybase APIs (or MS's DBlibrary). It's a little - more powerful/flexible than DBI, though obviously less portable. - It's still actively maintained and developed (by yours truly)

- -

From Brian:
- DBD::ODBC is the newest option available. Its primary advantage - is not having to load another DBI driver if you already have - DBI::ODBC load for other systems. On the downside, it may be a - little less robust than DBD::Sybase.

+ Sybase or Microsoft database, DBD::Sybase, DBD::ODBC, + DBD::FreeTDS, + and Sybperl. As of 2010, DBD::Sybase and DBD::ODBC are your best choices. If + you need paramaterized queries on a Microsoft server, use DBD::ODBC

+

Are there any known issues?

    @@ -583,8 +423,6 @@
  • BCP does not support TDS 4.2. You must use a more modern protocol version.
  • -
  • Server-side cursors work only in ct-lib.
  • -
  • ODBC lacks a client-side cursor implementation.
  • DBD::Sybase dynamic SQL placeholders don't work, pending a client-side SQL parser. (The ODBC ones do.)
  • @@ -612,8 +450,7 @@

    Very few programs actually need the missing functionality. Parameterized ct-lib queries would benefit Perl DBD::Sybase users, but the functionality would require departing from Sybase's documented API. MARS comes up because there must be thousands of people whom Microsoft has convinced they need it, but the benefits are meager compared to the complexity.

    -

    Why does each connection support only one query at a time?

    - +

    Why does each connection support only one query at a time?

    If you are accustomed to programming with other database servers, you may be surprised when you first encounter this @@ -673,15 +510,13 @@ "http://lists.ibiblio.org/pipermail/freetds/2003q3/013915.html">this post by Daniel Fazekas in the mailing list archives. -

    Is FreeTDS thread safe?

    - +

    Is FreeTDS thread safe?

    Different threads may all use separate connections without interfering with each other. Threads may not share a DBPROCESS or CS_CONNECTION without controlling access via a mutex.

    -

    Are there plans to implement the OpenServer protocol/library?

    - +

    Are there plans to implement the OpenServer protocol/library?

    Not at this point, there is still much work to do on the client protocol. But, libtdssrv will do the trick for @@ -691,8 +526,7 @@

    Problems Running

    -

    Output Parameters

    - +

    Output Parameters

    I'm not getting my output parameters returned, but I seem to be doing everything right!

    @@ -700,8 +534,7 @@

    Microsoft SQL Server 7 with SP3, and later versions, quietly changed (which is to say, broke) how they respond to queries that execute stored procedures with output parameters. Earlier servers let you send a query like EXECUTE A @P OUTPUT and fetch the output parameter as a special result row (technique varying by library). Newer servers simply don't send back that data. To elicit output parameters from them, you have to use the RPC protocols such as the db-lib dbrpcparam.

    -

    What does this unknown marker message mean?

    - +

    What does this unknown marker message mean?

    Most of the time, it means you're not using the right protocol version. That can happen even if your ./configure @@ -713,9 +546,9 @@ needed the environment variable anyway, please post a message to the list and help us track it down.

    -

    What if I get a connection - refused message?

    - +

    + What if I get a + connection refused message?

    You want to make sure:

    @@ -810,10 +643,10 @@ -

    The Microsoft SQL Server is listening, my configuration and - environment are set up per question 6.1, but logins still - fail.

    - +

    The Microsoft SQL Server is listening, + my configuration and + environment are set up per question 6.1, but logins still + fail.

    Microsoft supports two security models in three permutations:

    @@ -850,10 +683,9 @@

    Do encrypted connections work?

    -

    Encrypted connections to Microsoft SQL Server 2008 using - FreeTDS 0.82 do not work. Avoid them. Patches welcome!

    +

    Yes. Sometimes it's tricky, though.

    -

    My text data are being truncated or are causing my +

    My text data are being truncated or are causing my client to break.

    The text data type is different from char @@ -871,13 +703,11 @@

     
     1> set textsize 10000
    -2> go
    -
    +2> go - See also the “text size” option in freetds.conf. + See also the text size option in freetds.conf. -

    My dates aren't formatted right!

    - +

    My dates aren't formatted right!

    Some dates turn out better than others.

    @@ -934,7 +764,7 @@ Updates and comments FreeTDS FAQ Master
    - $Id: faq.html,v 1.26 2010/12/31 04:12:07 jklowden Exp $ + $Id: faq.html,v 1.27 2010/12/31 16:20:58 jklowden Exp $

    commit 064e9b3d4c1d651d1ccf6018846620e8e4e38e24 Author: jklowden Date: Fri Dec 31 16:34:15 2010 +0000 updated per Frediano and corrected validation errors diff --git a/ChangeLog b/ChangeLog index d85b18d..6b7ceb5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Fri Dec 31 11:33:05 EST 2010 JK Lowden + * doc/api_status.txt doc/htdoc/faq.html + - updated per Frediano and corrected validation errors + Thu Dec 30 23:06:08 EST 2010 JK Lowden * doc/tsql.txt doc/userguide.sgml doc/htdoc/faq.html - updated to reflect current status @@ -3118,4 +3122,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog-0.82 added because of release $FreeTDS$ -$Id: ChangeLog,v 1.3185 2010/12/31 04:12:07 jklowden Exp $ +$Id: ChangeLog,v 1.3186 2010/12/31 16:34:15 jklowden Exp $ diff --git a/doc/api_status.txt b/doc/api_status.txt index f3584dd..d929148 100644 --- a/doc/api_status.txt +++ b/doc/api_status.txt @@ -1,7 +1,7 @@ #!/usr/pkg/bin/perl # API status document # -# $Id: api_status.txt,v 1.64 2010/09/14 14:40:43 jklowden Exp $s +# $Id: api_status.txt,v 1.65 2010/12/31 16:34:15 jklowden Exp $s # # This tab-delimited file is a database of the "readiness" of the various # APIs. Please feel free to modify it if you notice something is missing or @@ -269,6 +269,7 @@ dblib bcp n/a bcp_options partial dblib bcp bcp_readfmt (same) OK dblib bcp bcp_sendrow (same) OK dblib bcp BCP_SETL (same) OK +dblib bcp bcp_writefmt (same) dblib browse dbcolbrowse n/a never dblib browse dbcolsource n/a never dblib browse dbfreequal n/a never diff --git a/doc/htdoc/faq.html b/doc/htdoc/faq.html index bfa23bc..e0a403e 100644 --- a/doc/htdoc/faq.html +++ b/doc/htdoc/faq.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> - + -

    For a more complete history, see AUTHORS in the distribution. +

    For a more complete history, see AUTHORS in the distribution. Thanks also go to the folks at A2i, Inc. http://www.a2i.com for funding the original development of db-lib host file bulk copy and writetext support, and to Dave Poyourow there for helping with the - debugging. + debugging.

    (To send email to anyone listed above, delete the "nospam." part of the @@ -679,7 +679,7 @@ recognized by the presence of a backslash (\) character in the username. See the User Guide for - details.

    + details.

    Do encrypted connections work?

    @@ -764,7 +764,7 @@ Updates and comments FreeTDS FAQ Master
    - $Id: faq.html,v 1.27 2010/12/31 16:20:58 jklowden Exp $ + $Id: faq.html,v 1.28 2010/12/31 16:34:15 jklowden Exp $

    commit 0f0f3100c3ae4b8e84fb296e6ccb4cb9f13030c4 Author: jklowden Date: Mon Jan 3 20:27:53 2011 +0000 TDSPORT and TDSVER override even if no configuration file found diff --git a/ChangeLog b/ChangeLog index 6b7ceb5..4b637bc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Mon Jan 3 15:25:36 EST 2011 JK Lowden + * src/dblib/dblib.c + - TDSPORT and TDSVER override even if no configuration file found + Fri Dec 31 11:33:05 EST 2010 JK Lowden * doc/api_status.txt doc/htdoc/faq.html - updated per Frediano and corrected validation errors @@ -3122,4 +3126,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog-0.82 added because of release $FreeTDS$ -$Id: ChangeLog,v 1.3186 2010/12/31 16:34:15 jklowden Exp $ +$Id: ChangeLog,v 1.3187 2011/01/03 20:27:53 jklowden Exp $ diff --git a/src/dblib/dblib.c b/src/dblib/dblib.c index 4c0cedd..f92025f 100644 --- a/src/dblib/dblib.c +++ b/src/dblib/dblib.c @@ -75,7 +75,7 @@ #include #endif -TDS_RCSID(var, "$Id: dblib.c,v 1.375 2010/12/30 19:44:44 freddy77 Exp $"); +TDS_RCSID(var, "$Id: dblib.c,v 1.376 2011/01/03 20:27:54 jklowden Exp $"); static RETCODE _dbresults(DBPROCESS * dbproc); static int _db_get_server_type(int bindtype); @@ -1163,8 +1163,10 @@ tdsdbopen(LOGINREC * login, const char *server, int msdblib) tds_set_parent(dbproc->tds_socket, dbproc); + dbproc->tds_socket->env_chg_func = db_env_chg; dbproc->envchange_rcv = 0; + dbproc->dbcurdb[0] = '\0'; dbproc->servcharset[0] = '\0'; @@ -1174,6 +1176,7 @@ tdsdbopen(LOGINREC * login, const char *server, int msdblib) return NULL; } connection->option_flag2 &= ~0x02; /* we're not an ODBC driver */ + tds_fix_connection(connection); /* initialize from Environment variables */ dbproc->chkintr = NULL; dbproc->hndlintr = NULL; commit 4d2ecfe34220ccdc85093ca44afe910aa4192023 Author: freddy77 Date: Sat Jan 8 01:19:48 2011 +0000 fix unique inside variant diff --git a/ChangeLog b/ChangeLog index 4b637bc..974e493 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sat Jan 8 02:19:38 CET 2011 Frediano Ziglio + * src/odbc/unittests/data.c src/tds/token.c: + - fix unique inside variant + Mon Jan 3 15:25:36 EST 2011 JK Lowden * src/dblib/dblib.c - TDSPORT and TDSVER override even if no configuration file found @@ -3126,4 +3130,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog-0.82 added because of release $FreeTDS$ -$Id: ChangeLog,v 1.3187 2011/01/03 20:27:53 jklowden Exp $ +$Id: ChangeLog,v 1.3188 2011/01/08 01:19:48 freddy77 Exp $ diff --git a/src/odbc/unittests/data.c b/src/odbc/unittests/data.c index 9899722..c5889e5 100644 --- a/src/odbc/unittests/data.c +++ b/src/odbc/unittests/data.c @@ -13,7 +13,7 @@ * Also we have to check normal char and wide char */ -static char software_version[] = "$Id: data.c,v 1.36 2010/12/30 19:50:21 freddy77 Exp $"; +static char software_version[] = "$Id: data.c,v 1.37 2011/01/08 01:19:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static int result = 0; @@ -207,6 +207,7 @@ main(int argc, char *argv[]) /* for some reasons MS ODBC seems to convert -123.4 to -123.40000000000001 */ Test("SQL_VARIANT", "CAST('-123.5' AS FLOAT)", SQL_C_CHAR, "6 -123.5"); Test("SQL_VARIANT", "CAST('-123.4' AS NUMERIC(10,2))", SQL_C_CHAR, "7 -123.40"); + Test("SQL_VARIANT", "CAST('0DDF3B64-E692-11D1-AB06-00AA00BDD685' AS UNIQUEIDENTIFIER)", SQL_C_CHAR, "36 0DDF3B64-E692-11D1-AB06-00AA00BDD685"); } if (odbc_db_is_microsoft() && odbc_db_version_int() >= 0x09000000u) { diff --git a/src/tds/token.c b/src/tds/token.c index 9cddca9..6769888 100644 --- a/src/tds/token.c +++ b/src/tds/token.c @@ -1,6 +1,6 @@ /* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns - * Copyright (C) 2005-2010 Frediano Ziglio + * Copyright (C) 2005-2011 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -43,7 +43,7 @@ #include #endif -TDS_RCSID(var, "$Id: token.c,v 1.394 2010/12/28 14:37:10 freddy77 Exp $"); +TDS_RCSID(var, "$Id: token.c,v 1.395 2011/01/08 01:19:48 freddy77 Exp $"); #define USE_ICONV tds->use_iconv @@ -2118,7 +2118,7 @@ tds7_get_variant(TDSSOCKET * tds, TDSCOLUMN * curcol) tds_swap_numeric(num); return TDS_SUCCEED; } - varint = tds_get_varint_size(tds, type); + varint = (type == SYBUNIQUE) ? 0 : tds_get_varint_size(tds, type); if (varint != info_len) goto error_type; switch (varint) { commit 33b8299b83f87796d1d20805e21ce4bb5da5bcdd Author: freddy77 Date: Sat Jan 8 01:36:29 2011 +0000 small optimization for darwin os diff --git a/ChangeLog b/ChangeLog index 974e493..e3c0138 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +Sat Jan 8 02:36:23 CET 2011 Frediano Ziglio + * src/tds/net.c: small optimization for darwin os + Sat Jan 8 02:19:38 CET 2011 Frediano Ziglio * src/odbc/unittests/data.c src/tds/token.c: - fix unique inside variant @@ -3130,4 +3133,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog-0.82 added because of release $FreeTDS$ -$Id: ChangeLog,v 1.3188 2011/01/08 01:19:48 freddy77 Exp $ +$Id: ChangeLog,v 1.3189 2011/01/08 01:36:29 freddy77 Exp $ diff --git a/src/tds/net.c b/src/tds/net.c index 6940895..beaaee9 100644 --- a/src/tds/net.c +++ b/src/tds/net.c @@ -1,6 +1,6 @@ /* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Brian Bruns - * Copyright (C) 2004-2010 Ziglio Frediano + * Copyright (C) 2004-2011 Ziglio Frediano * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -107,7 +107,7 @@ #include #endif -TDS_RCSID(var, "$Id: net.c,v 1.109 2010/10/12 11:48:27 freddy77 Exp $"); +TDS_RCSID(var, "$Id: net.c,v 1.110 2011/01/08 01:36:29 freddy77 Exp $"); #define TDSSELREAD POLLIN #define TDSSELWRITE POLLOUT @@ -217,6 +217,15 @@ tds_open_socket(TDSSOCKET * tds, const char *ip_addr, unsigned int port, int tim setsockopt(tds->s, SOL_SOCKET, SO_KEEPALIVE, (const void *) &len, sizeof(len)); #endif +#if defined(__APPLE__) && defined(SO_NOSIGPIPE) + len = 1; + if (setsockopt(tds->s, SOL_SOCKET, SO_NOSIGPIPE, (const void *) &len, sizeof(len))) { + *p_oserr = sock_errno; + tds_close_socket(tds); + return TDSESOCK; + } +#endif + len = 1; #if defined(USE_NODELAY) || defined(USE_MSGMORE) setsockopt(tds->s, SOL_TCP, TCP_NODELAY, (const void *) &len, sizeof(len)); @@ -639,6 +648,8 @@ tds_goodwrite(TDSSOCKET * tds, const unsigned char *buffer, size_t len, unsigned /* In case the kernel does not support MSG_MORE, try again without it */ if (nput < 0 && errno == EINVAL && !last) nput = send(tds->s, p, remaining, MSG_NOSIGNAL); +#elif defined(__APPLE__) && defined(SO_NOSIGPIPE) + ssize_t nput = send(tds->s, p, remaining, 0); #else ssize_t nput = WRITESOCKET(tds->s, p, remaining); #endif @@ -709,7 +720,7 @@ tds_write_packet(TDSSOCKET * tds, unsigned char final) int sent; unsigned int left = 0; -#if !defined(_WIN32) && !defined(MSG_NOSIGNAL) && !defined(DOS32X) +#if !defined(_WIN32) && !defined(MSG_NOSIGNAL) && !defined(DOS32X) && (!defined(__APPLE__) || !defined(SO_NOSIGPIPE)) void (*oldsig) (int); #endif @@ -729,7 +740,7 @@ tds_write_packet(TDSSOCKET * tds, unsigned char final) tdsdump_dump_buf(TDS_DBG_NETWORK, "Sending packet", tds->out_buf, tds->out_pos); -#if !defined(_WIN32) && !defined(MSG_NOSIGNAL) && !defined(DOS32X) +#if !defined(_WIN32) && !defined(MSG_NOSIGNAL) && !defined(DOS32X) && (!defined(__APPLE__) || !defined(SO_NOSIGPIPE)) oldsig = signal(SIGPIPE, SIG_IGN); if (oldsig == SIG_ERR) { tdsdump_log(TDS_DBG_WARN, "TDS: Warning: Couldn't set SIGPIPE signal to be ignored\n"); @@ -747,7 +758,7 @@ tds_write_packet(TDSSOCKET * tds, unsigned char final) #endif sent = tds_goodwrite(tds, tds->out_buf, tds->out_pos, final); -#if !defined(_WIN32) && !defined(MSG_NOSIGNAL) && !defined(DOS32X) +#if !defined(_WIN32) && !defined(MSG_NOSIGNAL) && !defined(DOS32X) && (!defined(__APPLE__) || !defined(SO_NOSIGPIPE)) if (signal(SIGPIPE, oldsig) == SIG_ERR) { tdsdump_log(TDS_DBG_WARN, "TDS: Warning: Couldn't reset SIGPIPE signal to previous value\n"); } commit 9ebfecd7e59ab3d5a196b929e49231f64d936ca9 Author: freddy77 Date: Sun Jan 9 22:32:47 2011 +0000 prevent problems if version has no argument diff --git a/misc/freetds_autobuild b/misc/freetds_autobuild index 46ddc76..38f0a0f 100755 --- a/misc/freetds_autobuild +++ b/misc/freetds_autobuild @@ -105,6 +105,7 @@ do done set -e +trap 'echo Error at line $LINENO' ERR DOMAIN_UID= DOMAIN_PWD= @@ -119,8 +120,10 @@ cd $HOME/cpp/freetds/$FTDSDIR cd .. rm -rf $WORKDIR trap handle_exit EXIT -cp -rp $FTDSDIR $WORKDIR +test -h freetds rm -f freetds +test -d $FTDSDIR +cp -rp $FTDSDIR $WORKDIR ln -s $WORKDIR freetds cd $WORKDIR find . \( -name \*.bb -o -name \*.bbg -o -name \*.da -o -name \*.gc\* \) -exec rm -f {} \; commit dbeec2134623fe37d770a8f012128a167b43cba1 Author: freddy77 Date: Sun Jan 9 22:34:57 2011 +0000 add --help option diff --git a/ChangeLog b/ChangeLog index e3c0138..4331f6d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +Sun Jan 9 23:34:50 CET 2011 Frediano Ziglio + * misc/test-other.sh: add --help option + Sat Jan 8 02:36:23 CET 2011 Frediano Ziglio * src/tds/net.c: small optimization for darwin os @@ -3133,4 +3136,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog-0.82 added because of release $FreeTDS$ -$Id: ChangeLog,v 1.3189 2011/01/08 01:36:29 freddy77 Exp $ +$Id: ChangeLog,v 1.3190 2011/01/09 22:34:57 freddy77 Exp $ diff --git a/misc/test-other.sh b/misc/test-other.sh index 2fd0c6f..bdf6330 100755 --- a/misc/test-other.sh +++ b/misc/test-other.sh @@ -33,6 +33,16 @@ do do_perl=no do_php=yes ;; + --help) + echo "Usage: $0 [OPTION]..." + echo ' --help this help' + echo ' --verbose verbose output' + echo ' --no-perl do not execute Perl test' + echo ' --no-php do not execute PHP test' + echo ' --perl-only only Perl test' + echo ' --php-only only PHP test' + exit 0 + ;; *) echo 'Option not supported!' 1>&2 exit 1 commit 15b8dacd8d71bc0db1153bce7a6e89f1d0453fdb Author: freddy77 Date: Wed Jan 12 09:21:11 2011 +0000 support SQL_VARIANT passing parameters diff --git a/ChangeLog b/ChangeLog index 4331f6d..5c3e6ac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +Wed Jan 12 10:21:03 CET 2011 Frediano Ziglio + * src/tds/query.c: support SQL_VARIANT passing parameters + Sun Jan 9 23:34:50 CET 2011 Frediano Ziglio * misc/test-other.sh: add --help option @@ -3136,4 +3139,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog-0.82 added because of release $FreeTDS$ -$Id: ChangeLog,v 1.3190 2011/01/09 22:34:57 freddy77 Exp $ +$Id: ChangeLog,v 1.3191 2011/01/12 09:21:11 freddy77 Exp $ diff --git a/src/tds/query.c b/src/tds/query.c index ec1aa83..899bb09 100644 --- a/src/tds/query.c +++ b/src/tds/query.c @@ -1,6 +1,6 @@ /* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns - * Copyright (C) 2006, 2007, 2008, 2009, 2010 Frediano Ziglio + * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -46,7 +46,7 @@ #include -TDS_RCSID(var, "$Id: query.c,v 1.245 2010/11/26 08:41:26 freddy77 Exp $"); +TDS_RCSID(var, "$Id: query.c,v 1.246 2011/01/12 09:21:11 freddy77 Exp $"); static void tds_put_params(TDSSOCKET * tds, TDSPARAMINFO * info, int flags); static void tds7_put_query_params(TDSSOCKET * tds, const char *query, size_t query_len); @@ -716,6 +716,10 @@ tds_get_column_declaration(TDSSOCKET * tds, TDSCOLUMN * curcol, char *out) size /= 2u; } break; + case SYBVARIANT: + if (IS_TDS7_PLUS(tds)) + fmt = "SQL_VARIANT"; + break; /* nullable types should not occur here... */ case SYBFLTN: case SYBMONEYN: @@ -729,7 +733,6 @@ tds_get_column_declaration(TDSSOCKET * tds, TDSCOLUMN * curcol, char *out) case SYBUINT2: case SYBUINT4: case SYBUINT8: - case SYBVARIANT: default: tdsdump_log(TDS_DBG_ERROR, "Unknown type %d\n", tds_get_conversion_type(curcol->on_server.column_type, curcol->on_server.column_size)); break; commit 0daf07d452dc14401f29976411fff2935f8b0bf2 Author: freddy77 Date: Fri Jan 14 14:18:14 2011 +0000 minor dblib results changes diff --git a/ChangeLog b/ChangeLog index 5c3e6ac..2c6206e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +Fri Jan 14 15:15:21 CET 2011 Frediano Ziglio + * src/dblib/bcp.c src/dblib/dblib.c: minor dblib results changes + Wed Jan 12 10:21:03 CET 2011 Frediano Ziglio * src/tds/query.c: support SQL_VARIANT passing parameters @@ -3139,4 +3142,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog-0.82 added because of release $FreeTDS$ -$Id: ChangeLog,v 1.3191 2011/01/12 09:21:11 freddy77 Exp $ +$Id: ChangeLog,v 1.3192 2011/01/14 14:18:14 freddy77 Exp $ diff --git a/src/dblib/bcp.c b/src/dblib/bcp.c index 6c2dbaa..728e364 100644 --- a/src/dblib/bcp.c +++ b/src/dblib/bcp.c @@ -1,6 +1,6 @@ /* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns - * Copyright (C) 2010 Frediano Ziglio + * Copyright (C) 2010, 2011 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -62,7 +62,7 @@ #define MAX(a,b) ( (a) > (b) ? (a) : (b) ) #endif -TDS_RCSID(var, "$Id: bcp.c,v 1.195 2010/07/31 11:31:16 freddy77 Exp $"); +TDS_RCSID(var, "$Id: bcp.c,v 1.196 2011/01/14 14:18:15 freddy77 Exp $"); #ifdef HAVE_FSEEKO typedef off_t offset_type; @@ -2376,7 +2376,7 @@ _bcp_null_error(TDSBCPINFO *bcpinfo, int index, int offset) * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param bindcol * - * \return SUCCEED or FAIL. + * \return TDS_SUCCEED or TDS_FAIL. * \sa _bcp_add_fixed_columns, _bcp_add_variable_columns, _bcp_send_bcp_record */ static int @@ -2546,8 +2546,6 @@ rtrim(char *str, int len) * \brief * * \param dbproc contains all information needed by db-lib to manage communications with the server. - * - * \return SUCCEED or FAIL. */ static void _bcp_free_columns(DBPROCESS * dbproc) @@ -2574,7 +2572,6 @@ _bcp_free_columns(DBPROCESS * dbproc) * * \param dbproc contains all information needed by db-lib to manage communications with the server. * - * \return SUCCEED or FAIL. * \sa bcp_done(), bcp_exec(), bcp_init() */ static void @@ -2598,7 +2595,5 @@ _bcp_free_storage(DBPROCESS * dbproc) dbproc->bcpinfo->bindinfo = NULL; TDS_ZERO_FREE(dbproc->bcpinfo); } - - return; } diff --git a/src/dblib/dblib.c b/src/dblib/dblib.c index f92025f..240b304 100644 --- a/src/dblib/dblib.c +++ b/src/dblib/dblib.c @@ -1,6 +1,6 @@ /* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns - * Copyright (C) 2006-2010 Frediano Ziglio + * Copyright (C) 2006-2011 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -75,7 +75,7 @@ #include #endif -TDS_RCSID(var, "$Id: dblib.c,v 1.376 2011/01/03 20:27:54 jklowden Exp $"); +TDS_RCSID(var, "$Id: dblib.c,v 1.377 2011/01/14 14:18:15 freddy77 Exp $"); static RETCODE _dbresults(DBPROCESS * dbproc); static int _db_get_server_type(int bindtype); @@ -4044,7 +4044,7 @@ dbcmdrow(DBPROCESS * dbproc) tds = dbproc->tds_socket; if (tds->res_info) return SUCCEED; - return TDS_FAIL; + return FAIL; } /** @@ -4095,7 +4095,7 @@ dbadlen(DBPROCESS * dbproc, int computeid, int column) colinfo = dbacolptr(dbproc, computeid, column, 0); if (!colinfo) - return FAIL; + return -1; len = colinfo->column_cur_size < 0? 0 : colinfo->column_cur_size; @@ -4125,7 +4125,7 @@ dbalttype(DBPROCESS * dbproc, int computeid, int column) colinfo = dbacolptr(dbproc, computeid, column, 0); if (!colinfo) - return FAIL; + return -1; switch (colinfo->column_type) { case SYBVARCHAR: @@ -5740,7 +5740,6 @@ dbsetuserdata(DBPROCESS * dbproc, BYTE * ptr) CHECK_PARAMETER(dbproc, SYBENULL, ); dbproc->user_data = ptr; - return; } /** @@ -7105,7 +7104,7 @@ dbstrbuild(DBPROCESS * dbproc, char *charbuf, int bufsize, char *text, char *for rc = tds_vstrbuild(charbuf, bufsize, &resultlen, text, TDS_NULLTERM, formats, TDS_NULLTERM, ap); charbuf[resultlen] = '\0'; va_end(ap); - return rc; + return rc == TDS_SUCCEED ? SUCCEED : FAIL; } static char * commit a2c523f6ab36056f46d0436ef3d3ca3d35747e7f Author: freddy77 Date: Mon Jan 17 22:05:37 2011 +0000 silly format improve diff --git a/src/odbc/unittests/data.c b/src/odbc/unittests/data.c index c5889e5..2f26163 100644 --- a/src/odbc/unittests/data.c +++ b/src/odbc/unittests/data.c @@ -13,7 +13,7 @@ * Also we have to check normal char and wide char */ -static char software_version[] = "$Id: data.c,v 1.37 2011/01/08 01:19:48 freddy77 Exp $"; +static char software_version[] = "$Id: data.c,v 1.38 2011/01/17 22:05:37 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static int result = 0; @@ -96,7 +96,7 @@ Test(const char *type, const char *value_to_convert, SQLSMALLINT out_c_type, con } if (strcmp(sbuf, expected) != 0) { - fprintf(stderr, "Wrong result\n Got: %s\n Expected: %s\n", sbuf, expected); + fprintf(stderr, "Wrong result\n Got: %s\n Expected: %s\n", sbuf, expected); result = 1; } } commit c4cc0e315a3849befcec5c5e8d874703903ae13e Author: freddy77 Date: Mon Jan 17 22:27:40 2011 +0000 unify metadata read from server diff --git a/ChangeLog b/ChangeLog index 2c6206e..ca49421 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Mon Jan 17 23:27:25 CET 2011 Frediano Ziglio + * include/tds.h src/tds/data.c src/tds/token.c: + - unify metadata read from server + Fri Jan 14 15:15:21 CET 2011 Frediano Ziglio * src/dblib/bcp.c src/dblib/dblib.c: minor dblib results changes @@ -3142,4 +3146,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog-0.82 added because of release $FreeTDS$ -$Id: ChangeLog,v 1.3192 2011/01/14 14:18:14 freddy77 Exp $ +$Id: ChangeLog,v 1.3193 2011/01/17 22:27:40 freddy77 Exp $ diff --git a/include/tds.h b/include/tds.h index 4d32887..3955b48 100644 --- a/include/tds.h +++ b/include/tds.h @@ -1,6 +1,6 @@ /* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns - * Copyright (C) 2010 Frediano Ziglio + * Copyright (C) 2010, 2011 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -21,7 +21,7 @@ #ifndef _tds_h_ #define _tds_h_ -/* $Id: tds.h,v 1.348 2010/12/30 18:54:08 freddy77 Exp $ */ +/* $Id: tds.h,v 1.349 2011/01/17 22:27:40 freddy77 Exp $ */ #include #include @@ -1520,6 +1520,7 @@ int tds_process_tokens(TDSSOCKET * tds, /*@out@*/ TDS_INT * result_type, /*@out@ /* data.c */ void tds_set_param_type(TDSSOCKET * tds, TDSCOLUMN * curcol, TDS_SERVER_TYPE type); void tds_set_column_type(TDSSOCKET * tds, TDSCOLUMN * curcol, int type); +TDS_INT tds_data_get_info(TDSSOCKET *tds, TDSCOLUMN *col); /* tds_convert.c */ diff --git a/src/tds/data.c b/src/tds/data.c index fdd4034..c06a21e 100644 --- a/src/tds/data.c +++ b/src/tds/data.c @@ -1,5 +1,5 @@ /* FreeTDS - Library of routines accessing Sybase and Microsoft databases - * Copyright (C) 2003-2010 Frediano Ziglio + * Copyright (C) 2003-2011 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -35,7 +35,7 @@ #include #endif -TDS_RCSID(var, "$Id: data.c,v 1.27 2010/11/26 08:41:26 freddy77 Exp $"); +TDS_RCSID(var, "$Id: data.c,v 1.28 2011/01/17 22:27:41 freddy77 Exp $"); /** * Set type of column initializing all dependency @@ -183,4 +183,77 @@ tds_get_cardinal_type(int datatype, int usertype) return datatype; } +TDS_INT +tds_data_get_info(TDSSOCKET *tds, TDSCOLUMN *col) +{ + switch (col->column_varint_size) { + case 8: + col->column_size = 0x7ffffffflu; + break; + case 5: + case 4: + col->column_size = tds_get_int(tds); + break; + case 2: + /* assure > 0 */ + col->column_size = tds_get_smallint(tds); + /* under TDS9 this means ?var???(MAX) */ + if (col->column_size < 0 && IS_TDS72_PLUS(tds)) { + col->column_size = 0x3ffffffflu; + col->column_varint_size = 8; + } + break; + case 1: + col->column_size = tds_get_byte(tds); + break; + case 0: + col->column_size = tds_get_size_by_type(col->column_type); + break; + } + + /* numeric and decimal have extra info */ + if (is_numeric_type(col->column_type)) { + col->column_prec = tds_get_byte(tds); /* precision */ + col->column_scale = tds_get_byte(tds); /* scale */ + /* FIXME check prec/scale, don't let server crash us */ + } + + if (IS_TDS71_PLUS(tds) && is_collate_type(col->on_server.column_type)) { + /* based on true type as sent by server */ + /* + * first 2 bytes are windows code (such as 0x409 for english) + * other 2 bytes ??? + * last bytes is id in syscharsets + */ + tds_get_n(tds, col->column_collation, 5); + col->char_conv = + tds_iconv_from_collate(tds, col->column_collation); + } + + /* Only read table_name for blob columns (eg. not for SYBLONGBINARY) */ + if (is_blob_type(col->on_server.column_type)) { + /* discard this additional byte */ + if (IS_TDS72_PLUS(tds)) { + unsigned char num_parts = tds_get_byte(tds); + /* TODO do not discard first ones */ + for (; num_parts; --num_parts) { + col->table_namelen = + tds_get_string(tds, tds_get_smallint(tds), col->table_name, sizeof(col->table_name) - 1); + } + } else { + col->table_namelen = + tds_get_string(tds, tds_get_smallint(tds), col->table_name, sizeof(col->table_name) - 1); + } + } else if (IS_TDS72_PLUS(tds) && col->on_server.column_type == SYBMSXML) { + unsigned char has_schema = tds_get_byte(tds); + if (has_schema) { + /* discard schema informations */ + tds_get_string(tds, tds_get_byte(tds), NULL, 0); /* dbname */ + tds_get_string(tds, tds_get_byte(tds), NULL, 0); /* schema owner */ + tds_get_string(tds, tds_get_smallint(tds), NULL, 0); /* schema collection */ + } + } + return TDS_SUCCEED; +} + #include "types.h" diff --git a/src/tds/token.c b/src/tds/token.c index 6769888..254f84f 100644 --- a/src/tds/token.c +++ b/src/tds/token.c @@ -43,7 +43,7 @@ #include #endif -TDS_RCSID(var, "$Id: token.c,v 1.395 2011/01/08 01:19:48 freddy77 Exp $"); +TDS_RCSID(var, "$Id: token.c,v 1.396 2011/01/17 22:27:41 freddy77 Exp $"); #define USE_ICONV tds->use_iconv @@ -1404,19 +1404,8 @@ tds_process_compute_result(TDSSOCKET * tds) tds_set_column_type(tds, curcol, tds_get_byte(tds)); - switch (curcol->column_varint_size) { - case 4: - curcol->column_size = tds_get_int(tds); - break; - case 2: - curcol->column_size = tds_get_smallint(tds); - break; - case 1: - curcol->column_size = tds_get_byte(tds); - break; - case 0: - break; - } + tds_data_get_info(tds, curcol); + tdsdump_log(TDS_DBG_INFO1, "processing result. column_size %d\n", curcol->column_size); /* Adjust column size according to client's encoding */ @@ -1474,76 +1463,14 @@ tds7_get_data_info(TDSSOCKET * tds, TDSCOLUMN * curcol) curcol->column_timestamp = (curcol->column_type == SYBBINARY && curcol->column_usertype == TDS_UT_TIMESTAMP); - switch (curcol->column_varint_size) { - case 8: - curcol->column_size = 0x7ffffffflu; - break; - case 4: - curcol->column_size = tds_get_int(tds); - break; - case 2: - curcol->column_size = tds_get_smallint(tds); - /* under TDS7.2 this means ?var???(MAX) */ - if (curcol->column_size < 0 && IS_TDS72_PLUS(tds)) { - curcol->column_size = 0x3ffffffflu; - curcol->column_varint_size = 8; - } - break; - case 1: - curcol->column_size = tds_get_byte(tds); - break; - case 0: - break; - } + tds_data_get_info(tds, curcol); /* Adjust column size according to client's encoding */ curcol->on_server.column_size = curcol->column_size; - /* numeric and decimal have extra info */ - if (is_numeric_type(curcol->column_type)) { - curcol->column_prec = tds_get_byte(tds); /* precision */ - curcol->column_scale = tds_get_byte(tds); /* scale */ - /* FIXME check prec/scale, don't let server crash us */ - } - - if (IS_TDS71_PLUS(tds) && is_collate_type(curcol->on_server.column_type)) { - /* based on true type as sent by server */ - /* - * first 2 bytes are windows code (such as 0x409 for english) - * other 2 bytes ??? - * last bytes is id in syscharsets - */ - tds_get_n(tds, curcol->column_collation, 5); - curcol->char_conv = - tds_iconv_from_collate(tds, curcol->column_collation); - } - /* NOTE adjustements must be done after curcol->char_conv initialization */ adjust_character_column_size(tds, curcol); - if (is_blob_type(curcol->column_type)) { - /* discard this additional byte */ - if (IS_TDS72_PLUS(tds)) { - unsigned char num_parts = tds_get_byte(tds); - /* TODO do not discard first ones */ - for (; num_parts; --num_parts) { - curcol->table_namelen = - tds_get_string(tds, tds_get_smallint(tds), curcol->table_name, sizeof(curcol->table_name) - 1); - } - } else { - curcol->table_namelen = - tds_get_string(tds, tds_get_smallint(tds), curcol->table_name, sizeof(curcol->table_name) - 1); - } - } else if (IS_TDS72_PLUS(tds) && curcol->column_type == SYBMSXML) { - unsigned char has_schema = tds_get_byte(tds); - if (has_schema) { - /* discard schema informations */ - tds_get_string(tds, tds_get_byte(tds), NULL, 0); /* dbname */ - tds_get_string(tds, tds_get_byte(tds), NULL, 0); /* schema owner */ - tds_get_string(tds, tds_get_smallint(tds), NULL, 0); /* schema collection */ - } - } - /* * under 7.0 lengths are number of characters not * number of bytes...tds_get_string handles this @@ -1722,45 +1649,10 @@ tds_get_data_info(TDSSOCKET * tds, TDSCOLUMN * curcol, int is_param) tdsdump_log(TDS_DBG_INFO1, "processing result. type = %d(%s), varint_size %d\n", curcol->column_type, tds_prtype(curcol->column_type), curcol->column_varint_size); - switch (curcol->column_varint_size) { - case 4: - curcol->column_size = tds_get_int(tds); - /* Only read table_name for blob columns (eg. not for SYBLONGBINARY) */ - if (is_blob_type (curcol->column_type)) { - curcol->table_namelen = - tds_get_string(tds, tds_get_smallint(tds), curcol->table_name, sizeof(curcol->table_name) - 1); - } - break; - case 2: - /* assure > 0 */ - curcol->column_size = tds_get_smallint(tds); - /* under TDS9 this means ?var???(MAX) */ - if (curcol->column_size < 0 && IS_TDS72_PLUS(tds)) { - curcol->column_size = 0x3ffffffflu; - curcol->column_varint_size = 8; - } - break; - case 1: - curcol->column_size = tds_get_byte(tds); - break; - case 0: - break; - } - tdsdump_log(TDS_DBG_INFO1, "processing result. column_size %d\n", curcol->column_size); - /* numeric and decimal have extra info */ - if (is_numeric_type(curcol->column_type)) { - curcol->column_prec = tds_get_byte(tds); /* precision */ - curcol->column_scale = tds_get_byte(tds); /* scale */ - /* FIXME check prec/scale, don't let server crash us */ - } + tds_data_get_info(tds, curcol); - /* read sql collation info */ - if (IS_TDS71_PLUS(tds) && is_collate_type(curcol->on_server.column_type)) { - tds_get_n(tds, curcol->column_collation, 5); - curcol->char_conv = - tds_iconv_from_collate(tds, curcol->column_collation); - } + tdsdump_log(TDS_DBG_INFO1, "processing result. column_size %d\n", curcol->column_size); /* Adjust column size according to client's encoding */ curcol->on_server.column_size = curcol->column_size; @@ -1925,37 +1817,7 @@ tds5_process_result(TDSSOCKET * tds) tds_set_column_type(tds, curcol, tds_get_byte(tds)); - switch (curcol->column_varint_size) { - case 4: - if (curcol->column_type == SYBTEXT || curcol->column_type == SYBIMAGE) { - curcol->column_size = tds_get_int(tds); - - /* save name */ - curcol->table_namelen = - tds_get_string(tds, tds_get_smallint(tds), curcol->table_name, sizeof(curcol->table_name) - 1); - } else - tdsdump_log(TDS_DBG_INFO1, "UNHANDLED TYPE %x\n", curcol->column_type); - break; - case 5: - curcol->column_size = tds_get_int(tds); - break; - case 2: - curcol->column_size = tds_get_smallint(tds); - break; - case 1: - curcol->column_size = tds_get_byte(tds); - break; - case 0: - curcol->column_size = tds_get_size_by_type(curcol->column_type); - break; - } - - /* numeric and decimal have extra info */ - if (is_numeric_type(curcol->column_type)) { - curcol->column_prec = tds_get_byte(tds); /* precision */ - curcol->column_scale = tds_get_byte(tds); /* scale */ - /* FIXME check prec/scale, don't let server crash us */ - } + tds_data_get_info(tds, curcol); /* Adjust column size according to client's encoding */ curcol->on_server.column_size = curcol->column_size; @@ -3023,37 +2885,7 @@ tds5_process_dyn_result2(TDSSOCKET * tds) /* column type */ tds_set_column_type(tds, curcol, tds_get_byte(tds)); - /* column size */ - switch (curcol->column_varint_size) { - case 5: - curcol->column_size = tds_get_int(tds); - break; - case 4: - if (curcol->column_type == SYBTEXT || curcol->column_type == SYBIMAGE) { - curcol->column_size = tds_get_int(tds); - /* read table name */ - curcol->table_namelen = - tds_get_string(tds, tds_get_smallint(tds), curcol->table_name, - sizeof(curcol->table_name) - 1); - } else - tdsdump_log(TDS_DBG_INFO1, "UNHANDLED TYPE %x\n", curcol->column_type); - break; - case 2: - curcol->column_size = tds_get_smallint(tds); - break; - case 1: - curcol->column_size = tds_get_byte(tds); - break; - case 0: - break; - } - - /* numeric and decimal have extra info */ - if (is_numeric_type(curcol->column_type)) { - curcol->column_prec = tds_get_byte(tds); /* precision */ - curcol->column_scale = tds_get_byte(tds); /* scale */ - /* FIXME check prec/scale, don't let server crash us */ - } + tds_data_get_info(tds, curcol); /* Adjust column size according to client's encoding */ curcol->on_server.column_size = curcol->column_size; commit a854961e226e1c292e1a22c6ebfb309324591106 Author: jklowden Date: Sat Jan 22 20:11:27 2011 +0000 tds_canonical_charset_name cannot return NULL diff --git a/ChangeLog b/ChangeLog index ca49421..b90e1c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +Sat Jan 22 15:04:21 EST 2011 JK Lowden + * src/tds/iconv.c tds_canonical_charset_name cannot return NULL + Mon Jan 17 23:27:25 CET 2011 Frediano Ziglio * include/tds.h src/tds/data.c src/tds/token.c: - unify metadata read from server @@ -3146,4 +3149,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog-0.82 added because of release $FreeTDS$ -$Id: ChangeLog,v 1.3193 2011/01/17 22:27:40 freddy77 Exp $ +$Id: ChangeLog,v 1.3194 2011/01/22 20:11:27 jklowden Exp $ diff --git a/src/tds/iconv.c b/src/tds/iconv.c index 98d1479..773958f 100644 --- a/src/tds/iconv.c +++ b/src/tds/iconv.c @@ -42,7 +42,7 @@ #include #endif -TDS_RCSID(var, "$Id: iconv.c,v 1.147 2010/11/26 19:46:55 freddy77 Exp $"); +TDS_RCSID(var, "$Id: iconv.c,v 1.148 2011/01/22 20:11:28 jklowden Exp $"); #define CHARSIZE(charset) ( ((charset)->min_bytes_per_char == (charset)->max_bytes_per_char )? \ (charset)->min_bytes_per_char : 0 ) @@ -1173,7 +1173,7 @@ tds_canonical_charset_name(const char *charset_name) if (res >= 0) return canonic_charsets[res].name; - return NULL; + return charset_name; /* hope for the best */ } /** commit 7e6172f05370929a94a1f61eb437b7bddb318f3e Author: jklowden Date: Tue Jan 25 06:18:53 2011 +0000 remove use and reference to sqlfront.h. diff --git a/ChangeLog b/ChangeLog index b90e1c3..b261a2f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Tue Jan 25 00:52:04 EST 2011 JK Lowden + * doc/userguide.sgml include/sybdb.h + - remove use and reference to sqlfront.h. + Sat Jan 22 15:04:21 EST 2011 JK Lowden * src/tds/iconv.c tds_canonical_charset_name cannot return NULL @@ -3149,4 +3153,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog-0.82 added because of release $FreeTDS$ -$Id: ChangeLog,v 1.3194 2011/01/22 20:11:27 jklowden Exp $ +$Id: ChangeLog,v 1.3195 2011/01/25 06:18:53 jklowden Exp $ diff --git a/doc/userguide.sgml b/doc/userguide.sgml index 2d9971d..641ef39 100644 --- a/doc/userguide.sgml +++ b/doc/userguide.sgml @@ -9,8 +9,8 @@ ]> - $Date: 2010/12/31 04:12:07 $ - $Revision: 1.131 $ + $Date: 2011/01/25 06:18:53 $ + $Revision: 1.132 $ &freetds; User Guide A Guide to Installing, Configuring, and Running &freetds; @@ -62,9 +62,9 @@ This guide is here for you, and we hope that you will be here for it, that other The version you're reading is: -$Revision: 1.131 $ -$Date: 2010/12/31 04:12:07 $ -CVS control number $Id: userguide.sgml,v 1.131 2010/12/31 04:12:07 jklowden Exp $. +$Revision: 1.132 $ +$Date: 2011/01/25 06:18:53 $ +CVS control number $Id: userguide.sgml,v 1.132 2011/01/25 06:18:53 jklowden Exp $. can be found on the &freetds; @@ -610,7 +610,7 @@ url="http://www.madgoat.com">www.madgoat.com). OS X® - As of this writing ($Date: 2010/12/31 04:12:07 $), the regular distribution compiles on OS X. Releases prior to 0.63 either did not compile or required patching. + As of this writing ($Date: 2011/01/25 06:18:53 $), the regular distribution compiles on OS X. Releases prior to 0.63 either did not compile or required patching. Alternative build procedure @@ -3538,7 +3538,7 @@ the extent to which it is implemented. The Status field may be: #include ]]> -#include <sqlfront.h> /* sqlfront.h always comes first */ +#include <sybfront.h> /* sybfront.h always comes first */ #include <sybdb.h> /* sybdb.h is the only other file you need */ int err_handler(DBPROCESS*, int, int, int, char*, char*); diff --git a/include/sybdb.h b/include/sybdb.h index 6c6ab2b..24901d5 100644 --- a/include/sybdb.h +++ b/include/sybdb.h @@ -42,7 +42,7 @@ extern "C" #define TDS_STATIC_CAST(type, a) ((type)(a)) #endif -static const char rcsid_sybdb_h[] = "$Id: sybdb.h,v 1.97 2010/12/30 14:53:12 freddy77 Exp $"; +static const char rcsid_sybdb_h[] = "$Id: sybdb.h,v 1.98 2011/01/25 06:18:53 jklowden Exp $"; static const void *const no_unused_sybdb_h_warn[] = { rcsid_sybdb_h, no_unused_sybdb_h_warn }; #ifdef FALSE @@ -173,8 +173,12 @@ enum #define SYBDATETIME SYBDATETIME SYBBIT = 50, /* 0x32 */ #define SYBBIT SYBBIT + SYBBITN = 104, /* 0x68 */ +#define SYBBITN SYBBITN SYBTEXT = 35, /* 0x23 */ #define SYBTEXT SYBTEXT + SYBNTEXT = 99, /* 0x63 */ +#define SYBNTEXT SYBNTEXT SYBIMAGE = 34, /* 0x22 */ #define SYBIMAGE SYBIMAGE SYBMONEY4 = 122, /* 0x7A */ @@ -199,8 +203,10 @@ enum #define SYBFLTN SYBFLTN SYBMONEYN = 110, /* 0x6E */ #define SYBMONEYN SYBMONEYN - SYBDATETIMN = 111 /* 0x6F */ + SYBDATETIMN = 111, /* 0x6F */ #define SYBDATETIMN SYBDATETIMN + SYBNVARCHAR = 103 /* 0x67 */ +#define SYBNVARCHAR SYBNVARCHAR }; #define SYBAOPCNT 0x4b commit fc5e01130d78de81dd9cfb98102a8ee0af2e7593 Author: freddy77 Date: Fri Feb 11 13:54:43 2011 +0000 improve iconv replacement unsigned/signed declaration diff --git a/ChangeLog b/ChangeLog index b261a2f..9a5b5ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Fri Feb 11 14:54:17 CET 2011 Frediano Ziglio + * src/replacements/iconv.c: + - improve iconv replacement unsigned/signed declaration + Tue Jan 25 00:52:04 EST 2011 JK Lowden * doc/userguide.sgml include/sybdb.h - remove use and reference to sqlfront.h. @@ -3153,4 +3157,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog-0.82 added because of release $FreeTDS$ -$Id: ChangeLog,v 1.3195 2011/01/25 06:18:53 jklowden Exp $ +$Id: ChangeLog,v 1.3196 2011/02/11 13:54:43 freddy77 Exp $ diff --git a/src/replacements/iconv.c b/src/replacements/iconv.c index 8d6a1f7..fb017eb 100644 --- a/src/replacements/iconv.c +++ b/src/replacements/iconv.c @@ -1,5 +1,6 @@ /* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2003, 2004 James K. Lowden, based on original work by Brian Bruns + * Copyright (C) 2011 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -49,7 +50,7 @@ #include #endif -TDS_RCSID(var, "$Id: iconv.c,v 1.20 2010/09/27 07:25:24 freddy77 Exp $"); +TDS_RCSID(var, "$Id: iconv.c,v 1.21 2011/02/11 13:54:43 freddy77 Exp $"); /** * \addtogroup conv @@ -87,10 +88,10 @@ static const unsigned char utf8_masks[7] = { }; static int -get_utf8(const unsigned char *p, int len, ICONV_CHAR *out) +get_utf8(const unsigned char *p, size_t len, ICONV_CHAR *out) { ICONV_CHAR uc; - int l; + size_t l; l = utf8_lengths[p[0]]; if (TDS_UNLIKELY(l == 0)) @@ -107,10 +108,10 @@ get_utf8(const unsigned char *p, int len, ICONV_CHAR *out) } static int -put_utf8(unsigned char *buf, int buf_len, ICONV_CHAR c) +put_utf8(unsigned char *buf, size_t buf_len, ICONV_CHAR c) { #define MASK(n) ((0xffffffffu << (n)) & 0xffffffffu) - int o_len; + size_t o_len; unsigned mask; if ((c & MASK(7)) == 0) { @@ -155,7 +156,7 @@ put_utf8(unsigned char *buf, int buf_len, ICONV_CHAR c) } static int -get_ucs4le(const unsigned char *p, int len, ICONV_CHAR *out) +get_ucs4le(const unsigned char *p, size_t len, ICONV_CHAR *out) { if (len < 4) return -EINVAL; @@ -164,7 +165,7 @@ get_ucs4le(const unsigned char *p, int len, ICONV_CHAR *out) } static int -put_ucs4le(unsigned char *buf, int buf_len, ICONV_CHAR c) +put_ucs4le(unsigned char *buf, size_t buf_len, ICONV_CHAR c) { if (buf_len < 4) return -E2BIG; @@ -173,7 +174,7 @@ put_ucs4le(unsigned char *buf, int buf_len, ICONV_CHAR c) } static int -get_ucs4be(const unsigned char *p, int len, ICONV_CHAR *out) +get_ucs4be(const unsigned char *p, size_t len, ICONV_CHAR *out) { if (len < 4) return -EINVAL; @@ -182,7 +183,7 @@ get_ucs4be(const unsigned char *p, int len, ICONV_CHAR *out) } static int -put_ucs4be(unsigned char *buf, int buf_len, ICONV_CHAR c) +put_ucs4be(unsigned char *buf, size_t buf_len, ICONV_CHAR c) { if (buf_len < 4) return -E2BIG; @@ -191,7 +192,7 @@ put_ucs4be(unsigned char *buf, int buf_len, ICONV_CHAR c) } static int -get_utf16le(const unsigned char *p, int len, ICONV_CHAR *out) +get_utf16le(const unsigned char *p, size_t len, ICONV_CHAR *out) { ICONV_CHAR c, c2; @@ -212,7 +213,7 @@ get_utf16le(const unsigned char *p, int len, ICONV_CHAR *out) } static int -put_utf16le(unsigned char *buf, int buf_len, ICONV_CHAR c) +put_utf16le(unsigned char *buf, size_t buf_len, ICONV_CHAR c) { if (c >= 0x110000u) return -EILSEQ; @@ -231,7 +232,7 @@ put_utf16le(unsigned char *buf, int buf_len, ICONV_CHAR c) } static int -get_utf16be(const unsigned char *p, int len, ICONV_CHAR *out) +get_utf16be(const unsigned char *p, size_t len, ICONV_CHAR *out) { ICONV_CHAR c, c2; @@ -252,7 +253,7 @@ get_utf16be(const unsigned char *p, int len, ICONV_CHAR *out) } static int -put_utf16be(unsigned char *buf, int buf_len, ICONV_CHAR c) +put_utf16be(unsigned char *buf, size_t buf_len, ICONV_CHAR c) { if (c >= 0x110000u) return -EILSEQ; @@ -271,7 +272,7 @@ put_utf16be(unsigned char *buf, int buf_len, ICONV_CHAR c) } static int -get_iso1(const unsigned char *p, int len, ICONV_CHAR *out) +get_iso1(const unsigned char *p, size_t len, ICONV_CHAR *out) { if (len < 1) return -EINVAL; @@ -280,7 +281,7 @@ get_iso1(const unsigned char *p, int len, ICONV_CHAR *out) } static int -put_iso1(unsigned char *buf, int buf_len, ICONV_CHAR c) +put_iso1(unsigned char *buf, size_t buf_len, ICONV_CHAR c) { if (c >= 0x100u) return -EILSEQ; @@ -291,7 +292,7 @@ put_iso1(unsigned char *buf, int buf_len, ICONV_CHAR c) } static int -get_ascii(const unsigned char *p, int len, ICONV_CHAR *out) +get_ascii(const unsigned char *p, size_t len, ICONV_CHAR *out) { if (len < 1) return -EINVAL; @@ -302,7 +303,7 @@ get_ascii(const unsigned char *p, int len, ICONV_CHAR *out) } static int -put_ascii(unsigned char *buf, int buf_len, ICONV_CHAR c) +put_ascii(unsigned char *buf, size_t buf_len, ICONV_CHAR c) { if (c >= 0x80u) return -EILSEQ; @@ -313,19 +314,19 @@ put_ascii(unsigned char *buf, int buf_len, ICONV_CHAR c) } static int -get_err(const unsigned char *p, int len, ICONV_CHAR *out) +get_err(const unsigned char *p, size_t len, ICONV_CHAR *out) { return -EILSEQ; } static int -put_err(unsigned char *buf, int buf_len, ICONV_CHAR c) +put_err(unsigned char *buf, size_t buf_len, ICONV_CHAR c) { return -EILSEQ; } -typedef int (*iconv_get_t)(const unsigned char *p, int len, ICONV_CHAR *out); -typedef int (*iconv_put_t)(unsigned char *buf, int buf_len, ICONV_CHAR c); +typedef int (*iconv_get_t)(const unsigned char *p, size_t len, ICONV_CHAR *out); +typedef int (*iconv_put_t)(unsigned char *buf, size_t buf_len, ICONV_CHAR c); static const iconv_get_t iconv_gets[8] = { get_iso1, get_ascii, get_utf16le, get_utf16be, get_ucs4le, get_ucs4be, get_utf8, get_err commit 8a95ff50cdd242434bc0428280f4992cc69fa773 Author: jklowden Date: Sun Feb 13 01:54:37 2011 +0000 Add linker appendix diff --git a/ChangeLog b/ChangeLog index 9a5b5ce..e0dacf2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +Sat Feb 12 20:53:19 EST 2011 JK Lowden + * doc/userguide.sgml Add linker appendix + Fri Feb 11 14:54:17 CET 2011 Frediano Ziglio * src/replacements/iconv.c: - improve iconv replacement unsigned/signed declaration @@ -3157,4 +3160,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog-0.82 added because of release $FreeTDS$ -$Id: ChangeLog,v 1.3196 2011/02/11 13:54:43 freddy77 Exp $ +$Id: ChangeLog,v 1.3197 2011/02/13 01:54:37 jklowden Exp $ diff --git a/doc/userguide.sgml b/doc/userguide.sgml index 641ef39..6316797 100644 --- a/doc/userguide.sgml +++ b/doc/userguide.sgml @@ -2,240 +2,217 @@ + FreeTDS"> + DB-Library'> + CT-Library'> + ODBC'> freetds.conf"> ]> - - $Date: 2011/01/25 06:18:53 $ - $Revision: 1.132 $ - &freetds; User Guide - A Guide to Installing, Configuring, and Running &freetds; - - Brian - Bruns + + $Date: 2011/02/13 01:54:38 $ + $Revision: 1.133 $ + &freetds; User Guide + A Guide to Installing, Configuring, and Running &freetds; + + Brian + Bruns - - James - K. - Lowden + + James + K. + Lowden - - 2001 - 2002 - 2003 - 2004 - 2005 - 2006 - 2007 - 2008 - 2009 - 2010 - Brian Bruns and James K. Lowden + + 2001 + 2002 + 2003 + 2004 + 2005 + 2006 + 2007 + 2008 + 2009 + 2010 + 2011 + Brian Bruns and James K. Lowden - - Permission is granted to copy, distribute and/or modify this document - under the terms of the GNU Free Documentation License, Version 1.1 - or any later version published by the Free Software Foundation; - with no Invariant Sections, with no - Front-Cover Texts, and with no Back-Cover Texts. - A copy of the license is included in the section entitled GNU - Free Documentation License. + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.1 + or any later version published by the Free Software Foundation; + with no Invariant Sections, with no + Front-Cover Texts, and with no Back-Cover Texts. + A copy of the license is included in the section entitled GNU + Free Documentation License. - + - - About this User Guide - -This User Guide describes &freetds; &version;. It is the product of (lots of) happy collaborative effort. Although Brian's name and mine are at the top of it, behind it are many others, who contributed thoughtful suggestions, bamboozled questions, stellar prose, and terse instructions. I don't mention this for the usual reasons (the enumeration of which I leave to you) but rather to emphasize that the purpose of our effort is to help you and those who come after you to have the easiest and most enjoyable time with &freetds;. - - -It is surprisingly hard, after a while, to remember how it can be for someone newly approaching a project to use it. What seems as obvious as a fog horn to an old hand may be much more like the fog itself to the newcomer. That can make installing and setting up new software a puzzling or frustrating experience. You may have heard, It's easy if you know how. Indeed it is, and that's our purpose here: to make it easy, by letting you know how. - - -This guide is here for you, and we hope that you will be here for it, that others might benefit from your experience or inexperience. The most recent version - -The version you're reading is: - - -$Revision: 1.132 $ -$Date: 2011/01/25 06:18:53 $ -CVS control number $Id: userguide.sgml,v 1.132 2011/01/25 06:18:53 jklowden Exp $. - + +About this User Guide + +This User Guide describes &freetds; &version;. It is the product of (lots of) happy collaborative effort. Although Brian's name and mine are at the top of it, behind it are many others, who contributed thoughtful suggestions, bamboozled questions, stellar prose, and terse instructions. I don't mention this for the usual reasons (the enumeration of which I leave to you) but rather to emphasize that the purpose of our effort is to help you and those who come after you to have the easiest and most enjoyable time with &freetds;. + +It is surprisingly hard, after a while, to remember how it can be for someone newly approaching a project to use it. What seems as obvious as a fog horn to an old hand may be much more like the fog itself to the newcomer. That can make installing and setting up new software a puzzling or frustrating experience. You may have heard, It's easy if you know how. Indeed it is, and that's our purpose here: to make it easy, by letting you know how. + +This guide is here for you, and we hope that you will be here for it, that others might benefit from your experience or inexperience. The most recent version + +The version you're reading is: + + $Revision: 1.133 $ + $Date: 2011/02/13 01:54:38 $ + CVS control number $Id: userguide.sgml,v 1.133 2011/02/13 01:54:38 jklowden Exp $. + -can be found on the &freetds; -web site, where you will also find the most up to date FAQ, as well as links to the anonymous and browseable CVS tree. If you find something wrong, unclear, badly put, misleading, or incorrigible, I hope you will let us know. Post your musings or rants to the mailing list (see Helping). Patches to doc/userguide.sgml are especially welcome, of course. By taking the time let us know what you think, perhaps the path to enlightenment will be made a little smoother for the fellow behind you. - - -A few technical notes. This guide is written in SGML DocBook format, specifications for which are found in the DocBook book. It was converted to HTML with OpenJade. -The SGML text is distributed with the rest of the source code, and may be edited with your favorite or least favorite text editor. - - -Enough. Let's begin. - - - --jkl - + can be found on the &freetds; + web site, where you will also find the most up to date FAQ, as well as links to the anonymous and browseable CVS tree. If you find something wrong, unclear, badly put, misleading, or incorrigible, I hope you will let us know. Post your musings or rants to the mailing list (see Helping). Patches to doc/userguide.sgml are especially welcome, of course. By taking the time let us know what you think, perhaps the path to enlightenment will be made a little smoother for the fellow behind you. + +A few technical notes. This guide is written in SGML DocBook format, specifications for which are found in the DocBook book. It was converted to HTML with OpenJade. + The SGML text is distributed with the rest of the source code, and may be edited with your favorite or least favorite text editor. + +Enough. Let's begin. + +--jkl - - What is &freetds;? - - -&freetds; is an open source (or free software if you prefer) programming library, a re-implementation of the Tabular Data Stream protocol. It can be used in place of Sybase's db-lib or ct-lib libraries. It also includes an ODBC library. It allows many open source applications such as Perl and PHP (or your own C or C++ program) to connect to Sybase or Microsoft SQL Server. - - -&freetds; is distributed in source code form, and is expected to compile on just about any operating system. That means every form of Unix® and Unix-like™ system (including notable variants such as Interix® and QNX®), as well as Win32®, VMS®, and OS X®. If it doesn't compile on your system — and you're not using MS-DOS® — it's probably considered a bug. - - - Background: The <acronym>TDS</> Protocol - and related <acronym>API</>s +<chapter id="what"> + <title>What is &freetds;? + + +&freetds; is re-implementation of C libraries originally implmented by Sybase and Microsoft SQL Server. It includes drop-in replacements for + + + Sybase's DB-Library or CT-Library + Microsoft's DB-Library (which differs in small details from Sybase's) + an ODBC library similar that provided by the vendors + + +The TDS part of the name comes from name of the protocol used to communicate with such servers: the Tabular Data Stream. + +&freetds; allows many open source applications such as Perl and PHP (or your own C or C++ program) to connect to Sybase or Microsoft SQL Server. + +&freetds; is distributed in source code form, and is expected to compile on just about any operating system. That means every form of Unix® and Unix-like™ system (including notable variants such as Interix® and QNX®), as well as Win32®, VMS®, and OS X®. If it doesn't compile on your system — and you're not using MS-DOS® — it's probably considered a bug. + + + Background: The <acronym>TDS</> Protocol + and related <acronym>API</>s - -TDS is a protocol, a set of rules describing how to transmit data between two computers. Like any protocol, it defines the types of messages that can be sent, and the order in which they may be sent. Protocols describe the bits on the wire, how data flow. - - -In reading this manual, it may be helpful to keep in mind that a protocol is not an API, although the two are related. The server recognizes and speaks a protocol; anything that can send it the correct combination of bytes in the right order can communicate with it. But programmers aren't generally in the business of sending bytes; that's the job of a library. Over the years, there have been a few libraries — each with its own API — that do the work of moving SQL through a TDS pipe. ODBC, db-lib, and ct-lib have very different APIs, but they're all one to the server, because on the wire they speak TDS. - - -The TDS protocol was designed and developed by Sybase Inc. for their Sybase SQL Server relational database engine in 1984. The problem Sybase faced then still exists: There was no commonly accepted application-level protocol to transfer data between a database server and its client. To encourage the use of their product, Sybase came up with a flexible pair of products called netlib and db-lib. - - -netlib's job was to ferry data between the two computers. To do that, it had to deal with the underlying network protocol. Remember, in those days TCP/IP was not the ubiquitous thing it is today. Besides TCP/IP, netlib ran on DECnet, IPX/SPX, NetBEUI and the like. - - -db-lib provided an API to the client program, and communicated with the server via netlib. What db-lib sent to the server took the form of a stream of bytes, a structured stream of bytes meant for tables of data, a Tabular Data Stream. - - -In 1990 Sybase entered into a technology sharing agreement with Microsoft which resulted in Microsoft marketing its own SQL Server. Microsoft kept the db-lib API and added ODBC. (Microsoft has since added other APIs, too.) -At about the same time, Sybase introduced a more powerful successor to db-lib, called ct-lib, and called the pair OpenClient. - - +TDS is a protocol, a set of rules describing how to transmit data between two computers. Like any protocol, it defines the types of messages that can be sent, and the order in which they may be sent. Protocols describe the bits on the wire, how data flow. -ct-lib, db-lib, and ODBC are APIs that — however different their programming style may be — all use netlib to communicate to the server. The language they use is TDS. - - -The TDS protocol comes in several flavors, most of which have never -been openly documented. If anything, it's probably considered to be something like a trade secret, or at least proprietary technology. The exception is TDS 5.0, used exclusively by Sybase, for which documentation is available from Sybase. - +In reading this manual, it may be helpful to keep in mind that a protocol is not an API, although the two are related. The server recognizes and speaks a protocol; anything that can send it the correct combination of bytes in the right order can communicate with it. But programmers aren't generally in the business of sending bytes; that's the job of a library. Over the years, there have been a few libraries — each with its own API — that do the work of moving SQL through a TDS pipe. ODBC, &dblib;, and &ctlib; have very different APIs, but they're all one to the server, because on the wire they speak TDS. + +The TDS protocol was designed and developed by Sybase Inc. for their Sybase SQL Server relational database engine in 1984. The problem Sybase faced then still exists: There was no commonly accepted application-level protocol to transfer data between a database server and its client. To encourage the use of their product, Sybase came up with DB-Library. + +DB-Library provided an API to the client program, and communicated with the server. What it sent to the server took the form of a stream of bytes meant for tables of data, a Tabular Data Stream. + +In 1990 Sybase entered into a technology sharing agreement with Microsoft which resulted in Microsoft marketing its own SQL Server. Microsoft kept the DB-Library API and added ODBC. (Microsoft has since added other APIs, too. It no longer supports its own DB-Library implementation.) At about the same time, Sybase introduced a more powerful successor to DB-Library, called CT-Library, and called the pair OpenClient. + +CT-Library, DB-Library, and ODBC are APIs that — however different their programming style may be — all communicate with the server in the same way. The language they use is TDS. + +The TDS protocol comes in several flavors, most of which have never been openly documented. If anything, it's probably considered to be something like a trade secret, or at least proprietary technology. The exception is TDS 5.0, used exclusively by Sybase, for which documentation is available from Sybase. + + + History of <acronym>TDS</> Versions - - History of <acronym>TDS</> Versions - - -At first, there was One Version of TDS common to both vendors but, in keeping with the broad history of private ventures, they soon diverged. Each vendor has subsequently brought out different versions, and neither supports the other's flavor. That is to say, each vendor's client libraries use the latest version of TDS offered by that vendor. You can't reliably use Microsoft's libraries to connect to Sybase, or Sybase's libraries to connect to Microsoft. In some cases you'll get a connection, but pretty soon you'll bump into some incompatibility. - - - Versions of the <acronym>TDS</> protocol +At first, there was One Version of TDS common to both vendors but, in keeping with the broad history of private ventures, they soon diverged. Each vendor has subsequently brought out different versions, and neither supports the other's flavor. That is to say, each vendor's client libraries use the latest version of TDS offered by that vendor. You can't reliably use Microsoft's libraries to connect to Sybase, or Sybase's libraries to connect to Microsoft. In some cases you'll get a connection, but pretty soon you'll bump into some incompatibility. + + Versions of the <acronym>TDS</> protocol + TDS 4.2 - Sybase and Microsoft - - -The version in use at the time of the Sybase/Microsoft split. - - + Sybase and Microsoft + +The version in use at the time of the Sybase/Microsoft split. + + TDS 5.0 - Sybase - - -Introduced for Sybase. Because TDS 5.0 includes negotiated capabilities through which protocol features can be expanded, we are unlikely to see a new TDS version from Sybase. - - + Sybase + +Introduced for Sybase. Because TDS 5.0 includes negotiated capabilities through which protocol features can be expanded, we are unlikely to see a new TDS version from Sybase. + + TDS 7.0 - Microsoft - - -Introduced for SQL Server 7.0. Includes support for the extended datatypes in SQL Server 7.0 (such as char/varchar fields of more than 255 characters). It also includes support for Unicode. - - + Microsoft + +Introduced for SQL Server 7.0. Includes support for the extended datatypes in SQL Server 7.0 (such as char/varchar fields of more than 255 characters). It also includes support for Unicode. + + TDS 7.1 - Microsoft - - -Introduced for SQL Server 2000. Includes support for big integer (64-bit int) and variant datatypes. - - + Microsoft + +Introduced for SQL Server 2000. Includes support for big integer (64-bit int) and variant datatypes. + + TDS 7.2 - Microsoft - - -Introduced for SQL Server 2005. Includes support for varchar(max), varbinary(max), xml datatypes and MARS. - - + Microsoft + +Introduced for SQL Server 2005. Includes support for varchar(max), varbinary(max), xml datatypes and MARS. + + - + + + History of &freetds; - History of &freetds; - -&freetds; was and is developed by observation and experimentation, which is to say, by trial and error. - - -In early 1997, the only option for connecting to a Sybase server from Linux or other free systems was an aging Sybase-released version of OpenClient. Unfortunately it had a few problems. The original release was a.out-based, although Greg Thain did a great service in converting the library to ELF. Secondly, it included only the newer ct-lib API. The older db-lib API was missing. - - -Brian Bruns, a Sybase DBA and originator of the &freetds; project, had some db-lib programs he wanted to run under Linux, and thus began the &freetds; project. The original work focused on db-lib and version 5.0 of the protocol, but quickly expanded to include a ct-lib compatible layer and TDS version 4.2. Later support for ODBC and TDS 7.0 and 7.1 was added. Craig Spannring wrote a Java JDBC driver which became FreeTDS/JDBC. - - -As the project matured, it gained new participants. Frediano Ziglio greatly expanded the ODBC driver, and continues to improve both it and the underlying TDS library. Bill Thompson wrote most of the present BCP system and added cursors to our ct-lib. Your humble author joined the project to add documentation, and wound up as the project's maintainer. Such are the rewards for doing a good deed. - - -There have been many other contributions. Please see the AUTHORS in the distribution for a (we hope) complete list. - +&freetds; was and is developed by observation and experimentation, which is to say, by trial and error. + +In early 1997, the only option for connecting to a Sybase server from Linux or other free systems was an aging Sybase-released version of OpenClient. Unfortunately it had a few problems. The original release was a.out-based, although Greg Thain did a great service in converting the library to ELF. Secondly, it included only the newer &ctlib; API. The older &dblib; API was missing. + +Brian Bruns, a Sybase DBA and originator of the &freetds; project, had some &dblib; programs he wanted to run under Linux, and thus began the &freetds; project. The original work focused on &dblib; and version 5.0 of the protocol, but quickly expanded to include a &ctlib; compatible layer and TDS version 4.2. Later support for ODBC and TDS 7.0 and 7.1 was added. Craig Spannring wrote a Java JDBC driver which became FreeTDS/JDBC. + +As the project matured, it gained new participants. Frediano Ziglio greatly expanded the ODBC driver, and continues to improve both it and the underlying TDS library. Bill Thompson wrote most of the present BCP system and added cursors to our &ctlib;. Your humble author joined the project to add documentation, and wound up as the project's maintainer. Such are the rewards for doing a good deed. + +There have been many other contributions. Please see the AUTHORS in the distribution for a (we hope) complete list. - - Current Projects, Language Bindings, and Alternatives - + + Current Projects, Language Bindings, and Alternatives + Current Projects - -&freetds; consists of two projects. The &freetds; C libraries and &freetds;/ JDBC. - + +&freetds; consists of two projects. The &freetds; C libraries and &freetds;/ JDBC. - -The &freetds; C libraries support three separate APIs: db-lib, ct-lib, and ODBC. Underlying these three is libtds, which handles the low-level details of the TDS protocol, such as sending, receiving, and datatype conversion. This document and the FreeTDS website are dedicated to these libraries. - - -If Java is your game, we refer you to the -jTDS -project on SourceForge. It is a fork of the -FreeTDS/JDBC project, by Craig Spannring, and is a free, native 100% Java implementation of a Type 4 JDBC driver. - - - + The &freetds; C libraries support three separate APIs: &dblib;, &ctlib;, and ODBC. Underlying these three is libtds, which handles the low-level details of the TDS protocol, such as sending, receiving, and datatype conversion. This document and the FreeTDS website are dedicated to these libraries. + + If Java is your game, we refer you to the + jTDS + project on SourceForge. It is a fork of the + FreeTDS/JDBC project, by Craig Spannring, and is a free, native 100% Java implementation of a Type 4 JDBC driver. + + + Status - The libraries are portable, mature, and stable. They're expected to compile readily and normally do not crash or corrupt data. There is a logging feature to aid in diagnosing problems. While they do not include every feature provided by the vendors' libaries, they do faithfully implement a useful — and widely used — subset of their APIs. - - The db-lib and ct-lib APIs have been usable for several years. They have been successfully substituted for Sybase's own libraries in a variety of venues, including Perl and PHP. - - The ODBC driver should be fully ODBC 3.0 compliant. - - Basic API coverage information for all libraries may be found in this manual. It is maintained in doc/api_status.txt, included in the source distribution. - - In addition to the core db-lib API, &freetds; includes a full implementation of db-lib's bcp functions, as well as freebcp, a replacement for Sybase's bcp utility. - - How big is it? &freetds; has over 90,000 lines of C code, maintained by a handful of developers. Patches arrive irregularly, varying in size from one-liners to thousand-line monsters. Almost all are applied or used in some way. The mailing list has some 700 or so subscribers at this writing. Safe to say, &freetds;'s success so far lies somewhere between the Beetle and the Edsel. - - Who uses it? Oh, pretty much everyone. &freetds; users almost certainly number in the tens of thousands. It's used by large corporations, by the U.S. federal government (e.g. Database Access Library at the National Center for Biotechnology Information) and, judging by the mailing list, by many webservers running Apache and PHP. Microsoft recommends &freetds; to their customers who want access to Microsoft SQL Server from non-Win32 clients. So do we. - - + +The libraries are portable, mature, and stable. They're expected to compile readily and normally do not crash or corrupt data. There is a logging feature to aid in diagnosing problems. While they do not include every feature provided by the vendors' libaries, they do faithfully implement a useful — and widely used — subset of their APIs. + +The &dblib; and &ctlib; APIs have been usable for several years. They have been successfully substituted for Sybase's own libraries in a variety of venues, including Perl and PHP. + +The ODBC driver should be fully ODBC 3.0 compliant. + +Basic API coverage information for all libraries may be found in this manual. It is maintained in doc/api_status.txt, included in the source distribution. + +In addition to the core &dblib; API, &freetds; includes a full implementation of &dblib;'s bcp functions, as well as freebcp, a replacement for Sybase's bcp utility. + +How big is it? &freetds; has over 90,000 lines of C code, maintained by a handful of developers. Patches arrive irregularly, varying in size from one-liners to thousand-line monsters. Almost all are applied or used in some way. The mailing list has some 700 or so subscribers at this writing. Safe to say, &freetds;'s success so far lies somewhere between the Beetle and the Edsel. + +Who uses it? Oh, pretty much everyone. &freetds; users almost certainly number in the tens of thousands. It's used by large corporations, by the U.S. federal government (e.g. Database Access Library at the National Center for Biotechnology Information) and, judging by the mailing list, by many webservers running Apache and PHP. Microsoft recommends &freetds; to their customers who want access to Microsoft SQL Server from non-Win32 clients. So do we. + Languages besides C and Java - -You may be wondering how these libraries fit with Perl, PHP, TCL, Python, or other popular scripting languages. Most of these languages have bindings to Sybase that use either the db-lib or ct-lib API, for which &freetds; is intended as a drop-in replacement. For instance, Michael Peppler's DBD::Sybase works very well using &freetds; to access Sybase or Microsoft SQL Servers. PHP has options for sybase (db-lib) and sybase-ct (ct-lib) APIs. - - + +You may be wondering how these libraries fit with Perl, PHP, TCL, Python, or other popular scripting languages. Most of these languages have bindings to Sybase that use either the &dblib; or &ctlib; API, for which &freetds; is intended as a drop-in replacement. For instance, Michael Peppler's DBD::Sybase works very well using &freetds; to access Sybase or Microsoft SQL Servers. PHP has options for sybase (&dblib;) and sybase-ct (&ctlib;) APIs. + Alternatives @@ -243,4721 +220,4947 @@ You may be wondering how these libraries fit with Perl, PHP, TCL, Python, or oth Sybase OpenClient - In the time since &freetds; was started, Sybase (as well as most major DBMS vendors) has released its database for the Intel GNU/Linux platform. The good: it is a solid product and supports TDS 4.2 and TDS 5.0. The bad: it doesn't support TDS 7.0 or Linux/*BSD on non-Intel platforms. The ugly: Microsoft broke date handling for big endian Sybase clients. - Depending on platform, it may cost something. - - + +In the time since &freetds; was started, Sybase (as well as most major DBMS vendors) has released its database for the Intel GNU/Linux platform. The good: it is a solid product and supports TDS 4.2 and TDS 5.0. The bad: it doesn't support TDS 7.0 or Linux/*BSD on non-Intel platforms. The ugly: Microsoft broke date handling for big endian Sybase clients. + +Depending on platform, it may cost something. + + ODBC bridge products - They use the ODBC driver on the NT box where your SQL Server runs so you'll never have trouble with new protocols and the like. On the downside, they can be costly and may be inefficient. We know of EasySoft ODBC-ODBC Bridge from EasySoft, Universal Data Access Driver from OpenLink Software, SequeLink from Merant, and -ODBC Router from August Software Corporation. - - - + They use the ODBC driver on the NT box where your SQL Server runs so you'll never have trouble with new protocols and the like. On the downside, they can be costly and may be inefficient. We know of EasySoft ODBC-ODBC Bridge from EasySoft, Universal Data Access Driver from OpenLink Software, SequeLink from Merant, and + ODBC Router from August Software Corporation. + + Inline ODBC driver Based on libtds, this is a native ODBC driver for i386 *nix. It is free in price, but comes only as a binary at the present time. - - + + DBD::Proxy We have no direct experience with this Perl-only option. It has the same caveats as an ODBC bridge except it's free. - - - - + + + + - - - - Build &freetds; - - -If you build it they will come. - - - - The <acronym>GNU</> World - -&freetds; uses GNU Automake, Autoconf, and libtool to increase portability. - - -For many people, the preceding sentence says it all (good or bad). If you're familiar with the GNU system, you can probably just download the tarball and get away with scanning the README impatiently and then following your instincts. Because everyone is a beginner once and no one is an expert at everything, we'll try to explain things in plain English where possible, and to define our terms as we go along. - - -If the following nevertheless reads like gibberish, you might very well want to use something prepackaged (see Alternatives). If it reads like a vaguely intelligible alien script that might yield to intensive research, we've included links to some of the usual suspects at the end of this chapter. If it reads like a bad explanation of something you could explain better, please send us your version! - - - - What to build: Packages, Tarballs, and the <productname>CVS</productname> repository - -The latest &freetds; package is always available from - - iBiblio -and its mirrors. - - -Code changes by the developers are immediately available in the CVS repository. If you've run into a problem, you may want to check out from CVS to see if it's fixed there. - - -No password is needed to obtain the current CVS copy of FreeTDS; you need only have a CVS client installed on your machine. Then: - -$ cvs -d:pserver:anonymous@freetds.cvs.sourceforge.net:/cvsroot/freetds login -$ cvs -z3 -d:pserver:anonymous@freetds.cvs.sourceforge.net:/cvsroot/freetds checkout -P freetds -Password: -$ make install - - - -For those behind firewalls or otherwise unable to access CVS, nightly snapshots of CVS are rolled up into tarballs for your convenience. They can be downloaded from - ibiblio.org. Tarballs are generated around 3am EST (GMT-5). - - -In general, the CVS HEAD revision (the basis of the current nightly snapshot) works better and has more functionality than the release version. Bugs sometimes persist in the release version but are usually fixed in short order (once identified) in CVS HEAD. - - -As with any project of this sort, if you want to use the CVS HEAD revision, it's a good idea to join the mailing list. - - - - How to build: Configure and make - -If you've built other GNU projects, building &freetds; is a fairly straightforward process. We have a terse and verbose description. - - -&freetds; is known to build with GNU and BSD make. If you encounter a large number of build errors, and your operating system's make is not GNU make (as is the case on most non-GNU/Linux systems), you may wish to install GNU make from ftp.gnu.org. - - For Experts - -$ ./configure --prefix=/usr/local/freetds -$ make -$ su root -Password: -$ make install - + - -Building from CVS is described in the file INSTALL.CVS. - + + Build &freetds; + - - For Everyone Else - (&freetds; for Dummies?) - - -The GNU development system can generate code for a wide variety of hardware architectures and operating systems, virtually all of which can run FreeTDS in consequence. The work of building and installing the FreeTDS libraries begins with the command configure, which generates the Makefile that governs how the code is compiled, linked, and installed. Once you've configured the project, make will manage the rest of the build. - - ODBC Preparation - If you intend to build the FreeTDS ODBC driver — and want to use a Driver Manager (DM), as most people do — install the Driver Manager before configuring FreeTDS. configure will detect the the DM and use its header (.h) files for ODBC constants and such. If your DM is installed in an unusual directory, you may have to provide the directory name as a parameter to configure. - - FreeTDS doesn't require a DM. You can build the ODBC driver without one, as long as you have the requisite header files: sql.h, sqlext.h and sqltypes.h. These can be taken from either the iODBC or UnixODBC distributions. Put them wherever you like (e.g., /usr/local/include). Because FreeTDS won't detect your (missing) DM, it won't automatically build the ODBC driver, so you'll have to tell configure what to do and where to look. Cf. - - -The simplest form of running configure is: - - $ ./configure - -and sometimes that's enough. configure accepts some command-line arguments, too, and you may need to provide some, depending on what your environment looks like. - - -There are a few optional arguments to configure that may be important to you. For a complete list, see configure --help. - - <command>configure</> options - Directories and TDS version - - - install architecture-independent files in PREFIX. When you run make install, libraries will be placed in PREFIX/lib, executables in PREFIX/bin, and so on. - - The default is /usr/local if this argument is not passed to configure. - - +If you build it they will come. + + + The <acronym>GNU</> World - - - read-only single-machine data in DIR - - The default is PREFIX/etc (PREFIX being the value of , above) if this argument is not passed to configure. - - +&freetds; uses GNU Automake, Autoconf, and libtool to increase portability. - - - Specifies the location of the iconv library to use. configure will search for libiconv in the usual places; use if it's unsuccessful (assuming you want to use iconv, of course). Overridden by , below. - - - - - If you're building the ODBC driver and not using a Driver Manager, use this option to indicate the location of the .h files. configure will not cause the ODBC driver to be built unless this option is used or a DM is detected/specified. - - - - - Specifies the default TDS version. (There are a couple of ways to set the TDS version at run-time. This parameter takes effect if no run-time settings are provided.) Acceptable values of VER are 4.2, 4.6, 5.0, 7.0, 7.1 and 7.2. - The default is 5.0 if this argument is not passed to configure. - - - - - ODBC Driver Managers - - - - Specify directory of iODBC or unixODBC support, and use it as the Driver Manager. - As of version 0.62, the ODBC Driver Manager is detected by configure, so use this parameter only if yours is installed in a nonstandard path. - (Requires iODBC or unixODBC to have already been installed.) - - - - - Things you can turn off - - - Do not attempt to detect ODBC, and do not build the ODBC driver. In case you don't care about ODBC. - - - - - - Do not attempt to build applications like tsql. - - - - - - Do not attempt to build server stuff. - - - - - - Do not attempt to build pool stuff. - - - - - - By default, configure will search your system for an iconv library for use with Microsoft servers (because TDS 7.0 employs Unicode). This switch prevents that search. If no iconv library is used, &freetds; relies on its built-in iconv emulation, which is capable of converting ISO-8859-1 to UCS-2, sufficient for many applications. - - - - - Force &freetds; not to use threadsafe versions of functions such as gethostbyname_r() where available. Rely instead on the older and non-threadsafe ones such as gethostbyname(). configure tests some of these functions. If the tests are successful, &freetds; will use threadsafe functions throughout. - Threadsafe operation has been tested on Linux, FreeBSD, and HP-UX. It should work on Solaris, Tru64, and (reportedly) IRIX. Not expected to work on non-unixy systems. It is a good idea to enable threadsafe operation if you configure Apache with multi-threading support. - - - - - Debug-mode compiles are enabled by default, and will remain so at least until version 1.0. You can speed things up ever so slightly by disabling it. - - - - - Things you can turn on - - - Enable Microsoft behavior in the db-lib API where it diverges from Sybase's. (For instance, Microsoft uses different names for the members of its date structure.) Typically needed only for porting Win32 applications to Unix. - This option specifies default behavior. Programs can change the default at compile time by defining MSDBLIB or SYBDBLIB (for Microsoft or Sybase behavior, respectively). - - +For many people, the preceding sentence says it all (good or bad). If you're familiar with the GNU system, you can probably just download the tarball and get away with scanning the README impatiently and then following your instincts. Because everyone is a beginner once and no one is an expert at everything, we'll try to explain things in plain English where possible, and to define our terms as we go along. - - - Enable close compatibility with Sybase's ABI, at the expense of other features. Currently, this enables the generation of a dbopen() entry point in db-lib, which may clash with the DBM function with the same name. Absolutely not required for use with other free software. - - +If the following nevertheless reads like gibberish, you might very well want to use something prepackaged (see Alternatives). If it reads like a vaguely intelligible alien script that might yield to intensive research, we've included links to some of the usual suspects at the end of this chapter. If it reads like a bad explanation of something you could explain better, please send us your version! + + + What to build: Packages, Tarballs, and the <productname>CVS</productname> repository - - - Enable Kerberos support. With Kerberos you can connect to server using your stored Kerberos ticket. - This require you to configure Kerberos support on your machine. - - +The latest &freetds; package is always available from + + iBiblio + and its mirrors. - - - Enable SSPI support. SSPI is a Micrsoft library that allows you to use your current logged account for authentication. With this option enabled, FreeTDS supports "trusted logins" for Win32/64, just as Microsoft's own implmentations do. - - +Code changes by the developers are immediately available in the CVS repository. If you've run into a problem, you may want to check out from CVS to see if it's fixed there. - - - Intended for debugging purposes, enables certain internal consistency checks against problems like memory corruption and buffer exhaustion. - - +No password is needed to obtain the current CVS copy of FreeTDS; you need only have a CVS client installed on your machine. Then: + + $ cvs -d:pserver:anonymous@freetds.cvs.sourceforge.net:/cvsroot/freetds login + $ cvs -z3 -d:pserver:anonymous@freetds.cvs.sourceforge.net:/cvsroot/freetds checkout -P freetds + Password: + $ make install - - - Enable some code still in development. Should be used only by a developer or a brave user :) - - +For those behind firewalls or otherwise unable to access CVS, nightly snapshots of CVS are rolled up into tarballs for your convenience. They can be downloaded from + ibiblio.org. Tarballs are generated around 3am EST (GMT-5). - - SSL support - - - Enable SSL using GnuTLS. Use version 1.2.3 or newer. - - +In general, the CVS HEAD revision (the basis of the current nightly snapshot) works better and has more functionality than the release version. Bugs sometimes persist in the release version but are usually fixed in short order (once identified) in CVS HEAD. + As with any project of this sort, if you want to use the CVS HEAD revision, it's a good idea to join the mailing list. + + + + How to build: Configure and make - - - Enable SSL using OpenSSL. Unlike &freetds;, OpenSSL does not use the LGPL. Please read the OpenSSL license before distributing binaries compiled with this option. - - +If you've built other GNU projects, building &freetds; is a fairly straightforward process. We have a terse and verbose description. + &freetds; is known to build with GNU and BSD make. If you encounter a large number of build errors, and your operating system's make is not GNU make (as is the case on most non-GNU/Linux systems), you may wish to install GNU make from ftp.gnu.org. + + For Experts + + $ ./configure --prefix=/usr/local/freetds + $ make + $ su root + Password: + $ make install + - - - <command>Make</> - -Now you're ready to build. Follow these easy steps. - - - Download the tarball and unpack it. - Alternatively, get the latest build from CVS - - -CVS users will need the GNU autotools: Autoconf, Automake, and libtool. - - -. - - Change to the freetds directory. - - run ./configure with any options you need. - - make; make install; make clean - - - -You normally need to be root to make install, unless you used the - -With any luck, you've built and installed the &freetds; libraries. - - - - - - OS-specific Issues - - If you've recently built and installed &freetds; and noticed steps peculiar to your OS, we'll happily include your comments here. +Building from CVS is described in the file INSTALL.CVS. - One thing that can be said, if it's not too obvious: check with your vendor or favorite download site. &freetds; is routinely rolled up into OS install packages. We know of packages for Debian, Red Hat, FreeBSD, and NetBSD. The installation through the package management systems in these environments may well reduce your work to simply make install. - - - The &freetds; ODBC driver compiles under + + For Everyone Else + (&freetds; for Dummies?) - - VC++. Project files are included in the win32 directory. See also Makefile.win32. +The GNU development system can generate code for a wide variety of hardware architectures and operating systems, virtually all of which can run FreeTDS in consequence. The work of building and installing the FreeTDS libraries begins with the command configure, which generates the Makefile that governs how the code is compiled, linked, and installed. Once you've configured the project, make will manage the rest of the build. + ODBC Preparation - Dev-C++ - MingW +If you intend to build the FreeTDS ODBC driver — and want to use a Driver Manager (DM), as most people do — install the Driver Manager before configuring FreeTDS. configure will detect the the DM and use its header (.h) files for ODBC constants and such. If your DM is installed in an unusual directory, you may have to provide the directory name as a parameter to configure. + - gcc under cygwin. +FreeTDS doesn't require a DM. You can build the ODBC driver without one, as long as you have the requisite header files: sql.h, sqlext.h and sqltypes.h. These can be taken from either the iODBC or UnixODBC distributions. Put them wherever you like (e.g., /usr/local/include). Because FreeTDS won't detect your (missing) DM, it won't automatically build the ODBC driver, so you'll have to tell configure what to do and where to look. Cf. + - The Borland Builder 6.0 compiler is also reported to work, but requires some tweaking of the #include statements. We would apply any patches that make this work cleanly. +The simplest form of running configure is: + + $ ./configure + and sometimes that's enough. configure accepts some command-line arguments, too, and you may need to provide some, depending on what your environment looks like. + +There are a few optional arguments to configure that may be important to you. For a complete list, see configure --help. + + <command>configure</> options + + Directories and TDS version + + + install architecture-independent files in PREFIX. When you run make install, libraries will be placed in PREFIX/lib, executables in PREFIX/bin, and so on. + +The default is /usr/local if this argument is not passed to configure. + + + + + + read-only single-machine data in DIR + +The default is PREFIX/etc (PREFIX being the value of , above) if this argument is not passed to configure. + + + + + + Specifies the location of the iconv library to use. configure will search for libiconv in the usual places; use if it's unsuccessful (assuming you want to use iconv, of course). Overridden by , below. + + + + + Specifies the default TDS version. (There are a couple of ways to set the TDS version at run-time. This parameter takes effect if no run-time settings are provided.) Acceptable values of VER are 4.2, 4.6, 5.0, 7.0, 7.1 and 7.2. + +The default is 5.0 if this argument is not passed to configure. + + + + + ODBC Driver Managers + + + + Specify directory of iODBC or unixODBC support, and use it as the Driver Manager. + As of version 0.62, the ODBC Driver Manager is detected by configure, so use this parameter only if yours is installed in a nonstandard path. + (Requires iODBC or unixODBC to have already been installed.) + + + + + If you're building the ODBC driver and not using a Driver Manager, use this option to indicate the location of the .h files. configure will not cause the ODBC driver to be built unless this option is used or a DM is detected/specified. + + + + + Things you can turn off + + + Do not attempt to detect ODBC, and do not build the ODBC driver. In case you don't care about ODBC. + + + + + Do not attempt to build applications like tsql. + + + + + Do not attempt to build server stuff. + + + + + Do not attempt to build pool stuff. + + + + + By default, configure will search your system for an iconv library for use with Microsoft servers (because TDS 7.0 employs Unicode). This switch prevents that search. If no iconv library is used, &freetds; relies on its built-in iconv emulation, which is capable of converting ISO-8859-1 to UCS-2, sufficient for many applications. + + + + + Force &freetds; not to use threadsafe versions of functions such as gethostbyname_r() where available. Rely instead on the older and non-threadsafe ones such as gethostbyname(). configure tests some of these functions. If the tests are successful, &freetds; will use threadsafe functions throughout. + +Threadsafe operation has been tested on Linux, FreeBSD, and HP-UX. It should work on Solaris, Tru64, and (reportedly) IRIX. Not expected to work on non-unixy systems. It is a good idea to enable threadsafe operation if you configure Apache with multi-threading support. + + + + + Debug-mode compiles are enabled by default, and will remain so at least until version 1.0. You can speed things up ever so slightly by disabling it. + + + + + Things you can turn on + + + Enable Microsoft behavior in the &dblib; API where it diverges from Sybase's. (For instance, Microsoft uses different names for the members of its date structure.) Typically needed only for porting Win32 applications to Unix. + +This option specifies default behavior. Programs can change the default at compile time by defining MSDBLIB or SYBDBLIB (for Microsoft or Sybase behavior, respectively). + + + + + + Enable close compatibility with Sybase's ABI, at the expense of other features. Currently, this enables the generation of a dbopen() entry point in &dblib;, which may clash with the DBM function with the same name. Absolutely not required for use with other free software. + + + + + + Enable Kerberos support. With Kerberos you can connect to server using your stored Kerberos ticket. + This require you to configure Kerberos support on your machine. + + + + + + Enable SSPI support. SSPI is a Micrsoft library that allows you to use your current logged account for authentication. With this option enabled, FreeTDS supports "trusted logins" for Win32/64, just as Microsoft's own implmentations do. + + + + + + Intended for debugging purposes, enables certain internal consistency checks against problems like memory corruption and buffer exhaustion. + + + + + + Enable some code still in development. Should be used only by a developer or a brave user :) + + + + + SSL support + + + Enable SSL using GnuTLS. Use version 1.2.3 or newer. + + + + + + Enable SSL using OpenSSL. Unlike &freetds;, OpenSSL does not use the LGPL. Please read the OpenSSL license before distributing binaries compiled with this option. + + + + + + <command>Make</> - - +Now you're ready to build. Follow these easy steps. + + Download the tarball and unpack it. + +Alternatively, get the latest build from CVS + + +CVS users will need the GNU autotools: Autoconf, Automake, and libtool. + + . + + Change to the freetds directory. + + run ./configure with any options you need. + + make; make install; make clean + + + +You normally need to be root to make install, unless you used the + +With any luck, you've built and installed the &freetds; libraries. + + + + + OS-specific Issues + - From the Department of Double Emulation: &freetds; builds as a .dll under WINE and as a .a under Interix. See the mailing list archives (second half of 2003) for details. - - VMS® - &freetds; will probably build and run on most versions of OpenVMS Alpha 7.0 and later with DEC/Compaq C 6.0 or later. Other prerequisites: +If you've recently built and installed &freetds; and noticed steps peculiar to your OS, we'll happily include your comments here. + - - gunzip - vmstar - MMS or MMK - - - - Build Instructions - - Decompress and unpack the source archive using gunzip and vmstar. If -you are untarring on an ODS-5 disk, you should use the /ODS2 or -o -option to create universally VMS-friendly filenames; otherwise the build will fail to locate some files. +One thing that can be said, if it's not too obvious: check with your vendor or favorite download site. &freetds; is routinely rolled up into OS install packages. We know of packages for Debian, Red Hat, FreeBSD, and NetBSD. The installation through the package management systems in these environments may well reduce your work to simply make install. + - Set default to the top-level source directory and run the configuration -script: + Win32 and Win64 + +Building for Windows using Microsoft's compiler is supported via the NMakefile included in the distribution. Set up the command-line build environment per Microsoft's instructions, and run e.g. - $ @[.vms]configure - + $ nmake -fNmakefile -nologo apps PLATFORM=win32 CONFIGURATION=debug - This creates a descrip.mms in the top-level source -directory which you may execute by simply running MMS (if you have the Module Management System that -is part of DECset) or MMK (a freeware MMS alternative available from www.madgoat.com). +Perhaps you're shaking your head at such an old school approach. Over the years, Microsoft's proprietary project-configuration files have proved difficult to support. Every version is different, and there are a great many versions in use in the wild at any one time. As the project changes, it becomes impossible to maintain these kinds of files. - Further information can be found in the in the source distribution. - + Other ways to build under Windows® + + + + Visual Studio. Project files are included in the win32 directory. See above note for why these might be out of date. + + Dev-C++ + MingW + + gcc under cygwin. + + The Borland Builder 6.0 compiler is also reported to work, but requires some tweaking of the #include statements. We would apply any patches that make this work cleanly. + + +From the Department of Double Emulation: &freetds; builds as a .dll under WINE and as a .a under Interix. See the mailing list archives (second half of 2003) for details. + + + VMS® - - - OS X® - As of this writing ($Date: 2011/01/25 06:18:53 $), the regular distribution compiles on OS X. Releases prior to 0.63 either did not compile or required patching. - - - Alternative build procedure - On 11 March 2004, Dmitri Fedortchenko offered the following approach, using a local libtool. It is included here as a source of clues, in case you encounter trouble. - - - Installing with libtool 1.5.2 - Install the latest libtool from GNU into /usr/local, so as not to interfere with the Apple-original. - Make sure /usr/local/bin is in your PATH and /usr/local/lib is in your LIBRARY_PATH. - Go to the &freetds; source directory and generate the Makefiles - - $ ./configure --disable-libiconv --disable-odbc - - - Overwrite FreeTDS's libtool with a symbolic link to your (better) one - - If you run configure again, you'll need to perform this step -again, because libtool will have been regenerated in its fossilized state. - $ ln -sf /usr/local/bin/libtool - - - - To check that you've done everything correctly up to this -point, - - $ ./libtool --version - - libtool should report version 1.5.2 (or whatever version you downloaded, and not 1.4). - And finally, of course - - $ make && make install - - +&freetds; will probably build and run on most versions of OpenVMS Alpha 7.0 and later with DEC/Compaq C 6.0 or later. Other prerequisites: + + + gunzip + vmstar + MMS or MMK + + + Build Instructions + - - - +Decompress and unpack the source archive using gunzip and vmstar. If + you are untarring on an ODS-5 disk, you should use the /ODS2 or -o + option to create universally VMS-friendly filenames; otherwise the build will fail to locate some files. + - AIX® - -AIX® can induce linker indigestion. libtool doesn't always understand that a .a file -can be a shared library. One solution is to build only static libraries with the - -Another problem seems to be that the linker isn't asked to pull in all the requisite libraries. Cf. this helpful -mailing list message. - - +Set default to the top-level source directory and run the configuration + script: + + + $ @[.vms]configure + - GNU/Linux distributions that use RPMs - -You may find it convenient to make an RPM from the source distribution, in which case you'll be glad to -know it is easily done: + This creates a descrip.mms in the top-level source + directory which you may execute by simply running MMS (if you have the Module Management System that + is part of DECset) or MMK (a freeware MMS alternative available from www.madgoat.com). + - - $ rpmbuild -ta freetds-0.63RC9.tar.gz - +Further information can be found in the in the source distribution. + + + + OS X® - - +As of this writing ($Date: 2011/02/13 01:54:38 $), the regular distribution compiles on OS X. Releases prior to 0.63 either did not compile or required patching. + + + + Alternative build procedure +On 11 March 2004, Dmitri Fedortchenko offered the following approach, using a local libtool. It is included here as a source of clues, in case you encounter trouble. + + + Installing with libtool 1.5.2 + Install the latest libtool from GNU into /usr/local, so as not to interfere with the Apple-original. + Make sure /usr/local/bin is in your PATH and /usr/local/lib is in your LIBRARY_PATH. + Go to the &freetds; source directory and generate the Makefiles + + $ ./configure --disable-libiconv --disable-odbc + + Overwrite FreeTDS's libtool with a symbolic link to your (better) one + + If you run configure again, you'll need to perform this step + again, because libtool will have been regenerated in its fossilized state. + $ ln -sf /usr/local/bin/libtool + + To check that you've done everything correctly up to this + point, + + $ ./libtool --version + libtool should report version 1.5.2 (or whatever version you downloaded, and not 1.4). + And finally, of course + + $ make && make install + + + + +]]> + + + AIX® + +AIX® can induce linker indigestion. libtool doesn't always understand that a .a file + can be a shared library. One solution is to build only static libraries with the + +Another problem seems to be that the linker isn't asked to pull in all the requisite libraries. Cf. this helpful + mailing list message. + + + GNU/Linux distributions that use RPMs +You may find it convenient to make an RPM from the source distribution, in which case you'll be glad to + know it is easily done: + + + $ rpmbuild -ta freetds-0.63RC9.tar.gz + + - + - - - Install &freetds; - - -If you install it they will stay? - - - - -Confusing terminology - -Configuring and installing -don't have absolute, context-free definitions. In some circles, we install a product and then configure it. In the GNU world, we configure the package (generate the Makefiles), then we make install the package. To install the package is to copy the binaries to their appropriate run-time directories, copy the documentation to the doc directory, and maybe let the package manager know what's happened. That's generally considered part of the build process, covered in the last chapter. - - -For lack of a better term, this chapter describes installing the product. Put more specifically, once we're done with the package manager, we still have to tell &freetds; about your database servers, and we still have to tell your client programs about &freetds;. - - - + + + Install &freetds; + + +If you install it they will stay? + + + + Confusing terminology + +Configuring and installing + don't have absolute, context-free definitions. In some circles, we install a product and then configure it. In the GNU world, we configure the package (generate the Makefiles), then we make install the package. In the case of a library package such as &freetds; To install the package is to copy the files the application developer will use to their canonical locations: header files to include, libraries to the lib, documentation and man pages share. Install targets were specified during the build process as arguments to configure, covered in the last chapter. + +For lack of a better term, this chapter describes installing the product. Put more specifically, once we're done with the package manager, we still have to tell &freetds; about your database servers, and we still have to tell your client programs about &freetds;. + + The local environment - -After &freetds; has been built and installed, it still doesn't know where your servers are or what particular version of Sybase or Microsoft software each one is using. - - -The purpose of this section is to explain how to describe your servernames to &freetds;. &freetds; looks up your server's attributes in &freetdsconf;. Some of the attributes can be overridden by environment variables. - - -One of the more important (and arcane) settings is the TDS protocol version, described next. - + +After &freetds; has been built and installed, it still doesn't know where your servers are or what particular version of Sybase or Microsoft software each one is using. + +The purpose of this section is to explain how to describe your servernames to &freetds;. &freetds; looks up your server's attributes in &freetdsconf;. Some of the attributes can be overridden by environment variables. + +One of the more important (and arcane) settings is the TDS protocol version, described next. - - Choosing a <acronym>TDS</> protocol version - -The TDS protocol version is probably something you'd rather not know even existed, much less something you'd have to choose. But there's not that much to it, really. Unless you run into an incompatibility, you're best off running with the highest protocol version supported by your server. That's what the vendors' own products do, which is why when you read the Sybase or Microsoft documentation you find no mention of TDS versions. - -Versions of the <acronym>TDS</> Protocol, by Product - - - Product - TDS Version - Comment - - - - - Sybase before System 10, Microsoft SQL Server 6.x - 4.2 - Still works with all products, subject to its limitations. - - - Sybase System 10 and above - 5.0 - Still the most current protocol used by Sybase. - - - Sybase System SQL Anywhere - 5.0 only - Originally Watcom SQL Server, a completely separate codebase. Our best information is that SQL Anywhere first supported TDS in version 5.5.03 using the OpenServer Gateway (OSG), and native TDS 5.0 support arrived with version 6.0. - - - Microsoft SQL Server 7.0 - 7.0 - Includes support for the extended datatypes in SQL Server 7.0 (such as char/varchar fields of more than 255 characters), and support for Unicode. - - - Microsoft SQL Server 2000 - 7.1 - Include support for bigint (64 bit integers), variant and collation on all fields. Collation is not widely used. - - - Microsoft SQL Server 2005 - 7.2 - Includes support for varchar(max), varbinary(max), xml datatypes and MARSMultiple Active Result Sets. &freetds; does not support MARS. . - - - -
    -
    - For best results, use the highest version of hte protocol supported by your server. If you encounter problems, try a lower version. If that works, though, please report it to the mailing list! - - - TDS 4.2 has limitations - ASCII only, of course. - - RPC is not supported. - - BCP is not supported. - - varchar fields are limited to 255 characters. If your table defines longer fields, they'll be truncated. - + + Choosing a <acronym>TDS</> protocol version + +The TDS protocol version is probably something you'd rather not know even existed, much less something you'd have to choose. But there's not that much to it, really. Unless you run into an incompatibility, you're best off running with the highest protocol version supported by your server. That's what the vendors' own products do, which is why when you read the Sybase or Microsoft documentation you find no mention of TDS versions. + + Versions of the <acronym>TDS</> Protocol, by Product + + + Product + TDS Version + Comment + + + + + Sybase before System 10, Microsoft SQL Server 6.x + 4.2 + Still works with all products, subject to its limitations. + + + Sybase System 10 and above + 5.0 + Still the most current protocol used by Sybase. + + + Sybase System SQL Anywhere + 5.0 only + Originally Watcom SQL Server, a completely separate codebase. Our best information is that SQL Anywhere first supported TDS in version 5.5.03 using the OpenServer Gateway (OSG), and native TDS 5.0 support arrived with version 6.0. + + + Microsoft SQL Server 7.0 + 7.0 + Includes support for the extended datatypes in SQL Server 7.0 (such as char/varchar fields of more than 255 characters), and support for Unicode. + + + Microsoft SQL Server 2000 + 7.1 + Include support for bigint (64 bit integers), variant and collation on all fields. Collation is not widely used. + + + Microsoft SQL Server 2005 + 7.2 + Includes support for varchar(max), varbinary(max), xml datatypes and MARSMultiple Active Result Sets. &freetds; does not support MARS.. + + + +
    + +For best results, use the highest version of hte protocol supported by your server. If you encounter problems, try a lower version. If that works, though, please report it to the mailing list! + +TDS 4.2 has limitations + ASCII only, of course. + + RPC is not supported. + + BCP is not supported. + + varchar fields are limited to 255 characters. If your table defines longer fields, they'll be truncated. + dynamic queries (also called prepared statements) are not supported. - - - - - The protocol version may also affect how database servers interpret -commands. For example, Microsoft SQL Server 2000 is known to behave differently with versions 4.2 -and 7.0. Version 7.0 is recommended for compatibility with SQL Server tools. - - - +
    + + + + The protocol version may also affect how database servers interpret + commands. For example, Microsoft SQL Server 2000 is known to behave differently with versions 4.2 + and 7.0. Version 7.0 is recommended for compatibility with SQL Server tools. +
    - <replaceable>servername</> Lookup - - &freetds; converts the servername to an IP address by following the steps below, stopping when it succeeds. + <replaceable>servername</> Lookup + + +&freetds; converts the servername to an IP address by following the steps below, stopping when it succeeds. Name lookup sequence - <footnote><para>This description applies to db-lib and ct-lib. ODBC lookup is different. </para></footnote> - - Find servername in &freetdsconf;. If a section with that name exists, use the hostname, port, and TDS version specified therein. - Attempt to convert servername to an IP address with inet_addr(3). - Request name-lookup from the operating system via gethostbyname(3) or similar. - + This description applies to &dblib; and &ctlib;. ODBC lookup is different. + + Find servername in &freetdsconf;. If a section with that name exists, use the hostname, port, and TDS version specified therein. + Attempt to convert servername to an IP address with inet_addr(3). + Request name-lookup from the operating system via gethostbyname(3) or similar. + - If the TDS version and port are not read from &freetdsconf;, they are derived from the compiled-in defaults and overridden by applicable environment variables. - - - As you can see, if most of your servers use the same TDS version and answer to the default port, then you don't need to list them all in &freetdsconf;. You can simply compile in the right defaults — or set the TDSPORT and TDSVER environment variables — and rely on DNS for name resolution. - - + If the TDS version and port are not read from &freetdsconf;, they are derived from the compiled-in defaults and overridden by applicable environment variables. + - - The &freetdsconf; file +As you can see, if most of your servers use the same TDS version and answer to the default port, then you don't need to list them all in &freetdsconf;. You can simply compile in the right defaults — or set the TDSPORT and TDSVER environment variables — and rely on DNS for name resolution. + + + + The &freetdsconf; file What it does - -Just as DNS defines hostnames for network addresses, &freetdsconf; uses a servername to define the properties of your server. - In general, the servername is arbitrary and local; it's used only by your client programs to tell &freetds; which server to connect to. You can choose any name you like. - Sybase SQL Anywhere (a/k/a Sybase ASA), however, is fussy. Unless you use the ASA Database property, you must use the database's name as your servername. Otherwise, the server will refuse your connection. - -In particular, &freetds; needs to know: - Primary Server Properties - Hostname or IP address of the server - - Port number or Instance name (not both) - - TDS protocol version - - - - - - - &freetds; also supports an older configuration file format, known as the interfaces file. Use &freetdsconf; unless interfaces is needed for your situation. It is easier to read, and it is where all the new options are being added. &freetds; looks for &freetdsconf; first, falling back on interfaces only if &freetdsconf; is not found. - - -Should you need it, more information about interfaces can be found in the Appendix. - - +Just as DNS defines hostnames for network addresses, &freetdsconf; uses a servername to define the properties of your server. + +In general, the servername is arbitrary and local; it's used only by your client programs to tell &freetds; which server to connect to. You can choose any name you like. + +Sybase SQL Anywhere (a/k/a Sybase ASA), however, is fussy. Unless you use the ASA Database property, you must use the database's name as your servername. Otherwise, the server will refuse your connection. + + In particular, &freetds; needs to know: + Primary Server Properties + Hostname or IP address of the server + + Port number or Instance name (not both) + + TDS protocol version + + + + + &freetds; also supports an older configuration file format, known as the interfaces file. Use &freetdsconf; unless interfaces is needed for your situation. It is easier to read, and it is where all the new options are being added. &freetds; looks for &freetdsconf; first, falling back on interfaces only if &freetdsconf; is not found. + +Should you need it, more information about interfaces can be found in the Appendix. + + Where it goes - -The default location of &freetdsconf; is determined by the --sysconfdir option of configure. If you don't specify anything, configure's default sysconfdir is /usr/local/etc. tsql -C reports the sysconfdir to let you confirm it. - - -In addition, &freetds; will look for a file .freetds.conf in the user's home directory (${HOME}/.freetds.conf). - - -The actual name and location of &freetdsconf; may be specified by the environment variable FREETDS (or FREETDSCONF, same effect). See Environment Variables, below. - - -&freetds; reads the user's ${HOME}/.freetds.conf before resorting to the system-wide sysconfdir/&freetdsconf;. The file used is the first one that is readable and contains a section for the server. - - + +The default location of &freetdsconf; is determined by the --sysconfdir option of configure. If you don't specify anything, configure's default sysconfdir is /usr/local/etc. tsql -C reports the sysconfdir to let you confirm it. + +In addition, &freetds; will look for a file .freetds.conf in the user's home directory (${HOME}/.freetds.conf). + +The actual name and location of &freetdsconf; may be specified by the environment variable FREETDS (or FREETDSCONF, same effect). See Environment Variables, below. + +&freetds; reads the user's ${HOME}/.freetds.conf before resorting to the system-wide sysconfdir/&freetdsconf;. The file used is the first one that is readable and contains a section for the server. + What it looks like - The following information is also provided in the &freetdsconf; manual page, cf. man freetds.conf. - -The &freetdsconf; file format is similar to that of Samba's modified win.ini. It -is composed of two types of sections: one [global] section, and a [servername] section for each servername. Settings in the [global] section affect all servernames, but can be overridden in a [servername] section. For example - - -A &freetdsconf; file example - -[global] - tds version = 4.2 -[myserver] - host = ntbox.mydomain.com - port = 1433 + The following information is also provided in the &freetdsconf; manual page, cf. man freetds.conf. + +The &freetdsconf; file format is similar to that of Samba's modified win.ini. It + is composed of two types of sections: one [global] section, and a [servername] section for each servername. Settings in the [global] section affect all servernames, but can be overridden in a [servername] section. For example + + A &freetdsconf; file example + + [global] + tds version = 4.2 + + [myserver] + host = ntbox.mydomain.com + port = 1433 + + [myserver2] + host = unixbox.mydomain.com + port = 4000 + tds version = 5.0 + + [myserver3] + host = instancebox.mydomain.com + instance = foo + tds version = 7.1 + + + +In this example, the default TDS version for all servernames is set to 4.2. It is then overridden for myserver2 (a Sybase server) which uses 5.0, and myserver3 (a MSSQL 2000 server) which uses 7.1. + +Usually, it is sufficient to state just the server's hostname and TDS protocol version. Everything else can be inferred, unless your setup (or your server's) strays from the defaults. + Some people seem to feel safer using the IP address for the server, rather than its name. We don't recommend you do that. Use the name, and benefit from the inherent advantages. That's why DNS was invented in the first place, you know. + +It bears mentioning here that prior versions of &freetds; were quite fussy about domain logins, forcing users to make explicit per-server entries in &freetdsconf;. That is no longer the case. If the username has the form DOMAIN\username, &freetds; will automatically use a domain login. + + &freetdsconf; settings + + + + Name + Possible Values + Default + Meaning + + + + + tds version + 4.2, 5.0, 7.0, 7.1, 7.2, auto + --with-tdsver value (5.0 if unspecified) + Overridden by TDSVER. + The TDS protocol version to use when connecting. auto tells &freetds; to use an autodetection (trial-and-error) algorithm to choose the protocol version. + + + host + host name or IP address + none + The host that the servername is running on. + + + port + any valid port + + + + + + + Product + Version + Default Port + + + + + + Sybase SQL Server + prior to System 10 + 1433 + + + Sybase SQL Server + 10 and up + 5000 + + + Sybase SQL Anywhere + 7 + 2638 + + + Microsoft SQL Server + all + 1433 + + + + The port number that the servername is listening to. + Please note: + The "defaults" to the left are the server's default settings. &freetds; chooses its default port based on the TDS protocol version: 5000 for TDS 5.0, and 1433 for everything else. Mutually exclusive with instance, below. + Overridden by TDSPORT. + + + + instance + instance name + none + Name of Microsoft SQL Server instance to connect to. The port will be detected automatically. Mutually exclusive with port, above. Requires UDP connection to port 1434 on the server. + + + + ASA database + valid database name + servername [section] name + Specifies the name of the default database when connecting to an ASA server. A TDS 5.0 login packet has a field called lservname. For most TDS servers, lservname is a user-defined string with no inherent meaning. ASA servers, however, requires that lservname contain a valid database name, and sets that as the default database for the connection. FreeTDS normally fills lservname with the [section] text.. This entry instead sets the database name independently of the [section] name. + + + + initial block size + multiple of 512 + 512 + Specifies the maximum size of a protocol block. Don't mess with unless you know what you are doing. + + + + dump file + any valid file name + none + Overridden by TDSDUMP. + + Specifies the location of a tds dump file and turns on logging + + + dump file append + yes/no + no + Appends dump file instead of overwriting it. Useful for debugging when many processes are active. + + + timeout + 0- + none + Sets period to wait for response of query before timing out. + + + connect timeout + 0- + none + Sets period to wait for response from connect before timing out. + + + emulate little endian + yes/no + no + Forces big endian machines (Sparc, PPC, PARISC) to act as little endian to communicate with MS Servers. Set automatically for TDS 7.0 or above on big endian hosts + + + client charset + any valid iconv character set + ISO-8859-1Valid for ISO 8859-1 character set. See Localization and TDS 7.0 for more information. + Makes &freetds; use iconv to convert to and from the specified character set from UCS-2 in TDS 7.0 or above. + &freetds; uses iconv to convert all character data, so there's no need to match the server's charset to insert any characters the server supports. + + + text size + 0 to 4,294,967,295 + 4,294,967,295 + default value of TEXTSIZE, in bytes. For text and image datatypes, sets the maximum width of any returned column. Cf. set TEXTSIZE in the T-SQL documentation for your server. + + + debug flags + Any number even in hex or octal notation + 0x4fff + Sets granularity of logging. A bitmask. See table below for specification. + + + encryption + off/request/required + off + Specify if encryption is desidered. Supported for Microsoft servers. off disables encryption (only if needed); request means use if available; required means create and allow encrypted connections only. + + + enable gssapi delegation + on/off + off + Enable delegation flag using Kerberos. + + + +
    + Overrides</> -[myserver2] - host = unixbox.mydomain.com - port = 4000 - tds version = 5.0 +<para>Many settings in &freetdsconf; can be overridden by <link linkend="envvar">environment variables</link>.</para> -[myserver3] - host = instancebox.mydomain.com - instance = foo - tds version = 7.1 -</programlisting> -</example> - <para> -In this example, the default <acronym>TDS</> version for all servernames is set to <literal>4.2</>. It is then overridden for <literal>myserver2</literal> (a Sybase server) which uses <literal>5.0</literal>, and <literal>myserver3</literal> (a MSSQL 2000 server) which uses <literal>7.1</literal>. - </para> - <para> -Usually, it is sufficient to state just the server's hostname and TDS protocol version. Everything else can be inferred, unless your setup (or your server's) strays from the defaults. - <tip><para>Some people seem to feel safer using the IP address for the server, rather than its name. We don't recommend you do that. Use the name, and benefit from the inherent advantages. That's why DNS was invented in the first place, you know. </para></tip> - </para> - <para> -It bears mentioning here that prior versions of &freetds; were quite fussy about domain logins, forcing users to make explicit per-server entries in &freetdsconf;. That is no longer the case. If the username has the form <parameter>DOMAIN\username</>, &freetds; will automatically use a domain login. - </para> -<table id="tab.freetds.conf"> -<title>&freetdsconf; settings - - - - Name - Possible Values - Default - Meaning - - - - - tds version - 4.2, 5.0, 7.0, 7.1, 7.2, auto - --with-tdsver value (5.0 if unspecified) - Overridden by TDSVER. - - The TDS protocol version to use when connecting. auto tells &freetds; to use an autodetection (trial-and-error) algorithm to choose the protocol version. - - - host - host name or IP address - none - The host that the servername is running on. - - - port - any valid port - - - - - - - Product - Version - Default Port - - - - - - Sybase SQL Server - prior to System 10 - 1433 - - - Sybase SQL Server - 10 and up - 5000 - - - Sybase SQL Anywhere - 7 - 2638 - - - Microsoft SQL Server - all - 1433 - - - - The port number that the servername is listening to. - Please note: - The "defaults" to the left are the server's default settings. &freetds; chooses its default port based on the TDS protocol version: 5000 for TDS 5.0, and 1433 for everything else. Mutually exclusive with instance, below. - Overridden by TDSPORT. - - - - - instance - instance name - none - Name of Microsoft SQL Server instance to connect to. The port will be detected automatically. Mutually exclusive with port, above. Requires UDP connection to port 1434 on the server. - - - - ASA database - valid database name - servername [section] name - Specifies the name of the default database when connecting to an ASA server. A TDS 5.0 login packet has a field called lservname. For most TDS servers, lservname is a user-defined string with no inherent meaning. ASA servers, however, requires that lservname contain a valid database name, and sets that as the default database for the connection. FreeTDS normally fills lservname with the [section] text.. This entry instead sets the database name independently of the [section] name. - - - - initial block size - multiple of 512 - 512 - Specifies the maximum size of a protocol block. Don't mess with unless you know what you are doing. - - - - dump file - any valid file name - none - Overridden by TDSDUMP. - - Specifies the location of a tds dump file and turns on logging - - - dump file append - yes/no - no - Appends dump file instead of overwriting it. Useful for debugging when many processes are active. - - - timeout - 0- - none - Sets period to wait for response of query before timing out. - - - connect timeout - 0- - none - Sets period to wait for response from connect before timing out. - - - emulate little endian - yes/no - no - Forces big endian machines (Sparc, PPC, PARISC) to act as little endian to communicate with MS Servers. Set automatically for TDS 7.0 or above on big endian hosts - - - client charset - any valid iconv character set - ISO-8859-1Valid for ISO 8859-1 character set. See Localization and TDS 7.0 for more information. - Makes &freetds; use iconv to convert to and from the specified character set from UCS-2 in TDS 7.0 or above. -&freetds; uses iconv to convert all character data, so there's no need to match the server's charset to insert any characters the server supports. - - - text size - 0 to 4,294,967,295 - 4,294,967,295 - default value of TEXTSIZE, in bytes. For text and image datatypes, sets the maximum width of any returned column. Cf. set TEXTSIZE in the T-SQL documentation for your server. - - - debug flags - Any number even in hex or octal notation - 0x4fff - Sets granularity of logging. A bitmask. See table below for specification. - - - encryption - off/request/required - off - Specify if encryption is desidered. Supported for Microsoft servers. off disables encryption (only if needed); request means use if available; required means create and allow encrypted connections only. - - - enable gssapi delegation - on/off - off - Enable delegation flag using Kerberos. - - - - - Overrides</> - <para>Many settings in &freetdsconf; can be overridden by <link linkend="envvar">environment variables</link>. - </para> - <para>The servername can also be decorated adding the port or instance name using <link linkend="PortOverride">port override syntax</link>. - </para> - </sect3> +<para>The servername can also be decorated adding the port or instance name using <link linkend="PortOverride">port override syntax</link>.</para> + </sect3> <sect3> <title>Controlling log details</> - <abstract><para>The logging capability has helped solve innumerable cases, some trivial and some very low-level bugs. Sometimes a developer needs very detailed information about one function, whereas someone else may interested only in whether or not a particular function is called, or even want to see only the SQL that was transmitted to the server. </para> </abstract> - -<para>The log's granularity can be controlled with the <literal>debug flags</> entry. The default value (<literal>4FFF</> hex) gives a level of detail that is useful for resolving problems via the mailing list. </para> - -<table id="tab.freetds.conf.debugflags"> -<title>Valid bitmask values for <literal>debug flags</> entry in &freetdsconf; - - - - Value - Meaning - - - - - - 0x80 - function trace and info - - - 0x40 - information level 2 - - - 0x20 - information level 1 - - - 0x10 - network - - - 0x08 - warning - - - 0x04 - error - - - 0x02 - severe error - - - 0x1000 - show pid - - - 0x2000 - show time - - - 0x4000 - show source level info (source file and line) - - - 0x8000 - thread id (not implemented) - - - - - - For more about the wonderful world of &freetds; logs, see Logging. - - - Deprecated options</> - <para>The following options have long been deprecated.</para> - -<itemizedlist id="lst.freetds.conf.deprecated" spacing="compact"> - <title>Deprecated &freetdsconf; settings - try server login - try domain login - nt domain - cross domain login - debug level - - + The logging capability has helped solve innumerable cases, some trivial and some very low-level bugs. Sometimes a developer needs very detailed information about one function, whereas someone else may interested only in whether or not a particular function is called, or even want to see only the SQL that was transmitted to the server. + -
    -
    +The log's granularity can be controlled with the debug flags entry. The default value (4FFF hex) gives a level of detail that is useful for resolving problems via the mailing list. + + + Valid bitmask values for <literal>debug flags</> entry in &freetdsconf; + + + + Value + Meaning + + + + + + 0x80 + function trace and info + + + 0x40 + information level 2 + + + 0x20 + information level 1 + + + 0x10 + network + + + 0x08 + warning + + + 0x04 + error + + + 0x02 + severe error + + + 0x1000 + show pid + + + 0x2000 + show time + + + 0x4000 + show source level info (source file and line) + + + 0x8000 + thread id (not implemented) + + + +
    + - - The <filename>locales.conf</filename> file +For more about the wonderful world of &freetds; logs, see Logging. + + + Deprecated options</> + +<para>The following options have long been deprecated.</para> + + <itemizedlist id="lst.freetds.conf.deprecated" spacing="compact"> + <title>Deprecated &freetdsconf; settings + try server login + try domain login + nt domain + cross domain login + debug level + + + + + + + + The <filename>locales.conf</filename> file What it does - -For an English-speaking American, not much. &freetds; originated in the United States, and uses U.S. conventions if no locales.conf is present. The locales.conf provided with the installation also reflects these conventions. - - - locales.conf will probably be dropped from FreeTDS one day. Its only real purpose now is to control the format of date strings. The Right Way™ to deduce the appropriate default date format is from the application's locale settings, while allowing an override in &freetdsconf;. That's the direction we're headed. - If your purpose is to affect the client charset description, use &freetdsconf; instead. - - -Information on locales and locale strings is easily (even too easily!) found on the Internet, or see man locale for your system. &freetds; will examine its environment for a LOCALE string. If it finds one, it will look it up in locales.conf to find your preferred settings. If it fails to find one, it will use its defaults. - - + +For an English-speaking American, not much. &freetds; originated in the United States, and uses U.S. conventions if no locales.conf is present. The locales.conf provided with the installation also reflects these conventions. + + +locales.conf will probably be dropped from FreeTDS one day. Its only real purpose now is to control the format of date strings. The Right Way™ to deduce the appropriate default date format is from the application's locale settings, while allowing an override in &freetdsconf;. That's the direction we're headed. + +If your purpose is to affect the client charset description, use &freetdsconf; instead. + + +Information on locales and locale strings is easily (even too easily!) found on the Internet, or see man locale for your system. &freetds; will examine its environment for a LOCALE string. If it finds one, it will look it up in locales.conf to find your preferred settings. If it fails to find one, it will use its defaults. + Where it goes - - Like &freetdsconf;, the location of locales.conf is determined by the value of - + +Like &freetdsconf;, the location of locales.conf is determined by the value of + What it looks like - -The format of locales.conf is similar to that of &freetdsconf;. There is a [default] section, and a section for each locale. - -locales.conf controls three settings - - - date format - - This entry will be passed (almost) literally to strftime(3) to convert dates to strings. - For the most part, see you system documentation for strftime(3) (man 3 strftime). You will see there though that strftime(3) has no provision for milliseconds. The locales.conf format string uses %z for milliseconds. If your system's strftime(3) does employ %z for its own use, it will not be given that chance by &freetds;. &freetds; will consume the %z for its milliseconds needs, and will not pass it on to strftime(3). - - - - language - - The language that will be used for error/status messages from the server. A SQL Server client can specify a language for such messages at login time. &freetds; issues a few messages of its own. Messages from the server are called messages; those from the client library (i.e., from &freetds;) are called error messages. &freetds;-issued messages are not affected by locales.conf. - - - - - charset - - Indicates to the server what character set should be used for communicating with the client. - - - - - + +The format of locales.conf is similar to that of &freetdsconf;. There is a [default] section, and a section for each locale. + + locales.conf controls three settings + + + date format + + +This entry will be passed (almost) literally to strftime(3) to convert dates to strings. + +For the most part, see you system documentation for strftime(3) (man 3 strftime). You will see there though that strftime(3) has no provision for milliseconds. The locales.conf format string uses %z for milliseconds. If your system's strftime(3) does employ %z for its own use, it will not be given that chance by &freetds;. &freetds; will consume the %z for its milliseconds needs, and will not pass it on to strftime(3). + + + + language + + +The language that will be used for error/status messages from the server. A SQL Server client can specify a language for such messages at login time. &freetds; issues a few messages of its own. Messages from the server are called messages; those from the client library (i.e., from &freetds;) are called error messages. &freetds;-issued messages are not affected by locales.conf. + + + + charset + + +Indicates to the server what character set should be used for communicating with the client. + + + + + + + Environment variables + + What they're for +You can use environment variables to + + Override some of the settings in &freetds;'s configuration file. + Advertise the location of the &freetds; libraries to programs that want them. + Control how logging is done. + + + This section covers the first two items. For information about environment variables that control logging, see Logging +In a typical system, no environment variables need be used. They're sometimes handy for testing, for instance setting TDSVER to check if a connection problem is due to using the wrong protocol version. And they have other uses, described below. But they're just knobs, so don't feel you have to turn every one, unless you're the sort that likes turning knobs. + + + Environment Variables + + FREETDS + +may be used to specify the name and location of the &freetdsconf; file. In prior versions of &freetds; this variable was known as FREETDSCONF. + + + + TDSVER + - - Environment variables - - What they're for - -You can use environment variables to - - Override some of the settings in &freetds;'s configuration file. - Advertise the location of the &freetds; libraries to programs that want them. - Control how logging is done. - +governs the version of the TDS protocol used to connect to your server. For a given server, &freetds; inspects four sources in the following order to determine which TDS protocol version to use, using the first one it finds. + + The value specified in TDSVER + + A &freetdsconf; file entry (see below) + + The interfaces file entry (see below) + + The + + + + + TDSPORT + -This section covers the first two items. For information about environment variables that control logging, see Logging - - -In a typical system, no environment variables need be used. They're sometimes handy for testing, for instance setting TDSVER to check if a connection problem is due to using the wrong protocol version. And they have other uses, described below. But they're just knobs, so don't feel you have to turn every one, unless you're the sort that likes turning knobs. - +specifies a TCP port number at which the servername is listening. It overrides the default port (1433 for TDS 4.2/7.0/7.1/7.2, 4000 for TDS 5.0) as well as any port specified in the &freetdsconf; file. + + + + SYBASE + - - Environment Variables - - FREETDS - - may be used to specify the name and location of the &freetdsconf; file. In prior versions of &freetds; this variable was known as FREETDSCONF. - - - - TDSVER - - governs the version of the TDS protocol used to connect to your server. For a given server, &freetds; inspects four sources in the following order to determine which TDS protocol version to use, using the first one it finds. - - The value specified in TDSVER - - A &freetdsconf; file entry (see below) - - The interfaces file entry (see below) - - The - - - - - TDSPORT - - specifies a TCP port number at which the servername is listening. It overrides the default port (1433 for TDS 4.2/7.0/7.1/7.2, 4000 for TDS 5.0) as well as any port specified in the &freetdsconf; file. - - - - SYBASE - - points to the &freetds; run-time directory. Use of this variable originated with Sybase (the company), and many programs still rely on SYBASE to discover the location of the SYBASE libraries. - - The primary use of SYBASE is to advertise the location of the &freetds; libraries. A secondary use is to point to the location of the interfaces file (if used, see the Appendix), which some programs examine directly. +points to the &freetds; run-time directory. Use of this variable originated with Sybase (the company), and many programs still rely on SYBASE to discover the location of the SYBASE libraries. + - - - - TDSQUERY - DSQUERY - - provides a server name to connect to if none is specified by the application. DSQUERY is the historical Sybase name for this variable. - - - - - TDSHOST - - overrides the host specified in the &freetdsconf;. - - - - +The primary use of SYBASE is to advertise the location of the &freetds; libraries. A secondary use is to point to the location of the interfaces file (if used, see the Appendix), which some programs examine directly. + + + + + TDSQUERY + DSQUERY + + +provides a server name to connect to if none is specified by the application. DSQUERY is the historical Sybase name for this variable. + + + + TDSHOST + + +overrides the host specified in the &freetdsconf;. + + + + - - + + Setting environment variables - -Of course, each shell is a little different. In the Bourne shell and variants such as ksh and bash, to set -SYBASE and TDSVER do: +Of course, each shell is a little different. In the Bourne shell and variants such as ksh and bash, to set + SYBASE and TDSVER do: + -$ export SYBASE=/usr/local/freetds # (or your favorite directory) -$ export TDSVER=4.2 - - - -In csh: + $ export SYBASE=/usr/local/freetds # (or your favorite directory) + $ export TDSVER=4.2 +In csh: + -$ setenv SYBASE /usr/local/freetds -$ setenv TDSVER 4.2 - - - - - Checking your work - -When you're done, you should see something very like this: + $ setenv SYBASE /usr/local/freetds + $ setenv TDSVER 4.2 + + + Checking your work +When you're done, you should see something very like this: + -$ ls $SYBASE -etc include interfaces lib - - - + $ ls $SYBASE + etc include interfaces lib + - - Port override syntax + + Port override syntax + - The port to which to connect can be overridden using a &freetds; extended syntax. - +The port to which to connect can be overridden using a &freetds; extended syntax. + - A port may be appended to the servername in the form servername:port. &freetds; will attempt to connect to specified port. Please note port must be a number; a service name is not supported. - +A port may be appended to the servername in the form servername:port. &freetds; will attempt to connect to specified port. Please note port must be a number; a service name is not supported. + - If you specify servername\instance +If you specify servername\instance as servername during login, &freetds; will attempt to connect to specified instance. - Only Microsoft SQL Server instances are supported. (This server feature was introduced with SQL Server 2000.) - + Only Microsoft SQL Server instances are supported. (This server feature was introduced with SQL Server 2000.) + - Note that other &freetdsconf; properties still apply. - - For the technically curious: each SQL Server instance appears on the network as a server listening at a port. The old way — and it still works — is to designate each instance in &freetdsconf; as a separate server. The new named instance notation, if we can call it that, instead uses the server to discover the port. The library sends a UDP packet containing the instance name to the server at a well known port, port 1434. The server responds with a port number. &freetds; then uses that number to connect in the usual way. - +Note that other &freetdsconf; properties still apply. + + For the technically curious: each SQL Server instance appears on the network as a server listening at a port. The old way — and it still works — is to designate each instance in &freetdsconf; as a separate server. The new named instance notation, if we can call it that, instead uses the server to discover the port. The library sends a UDP packet containing the instance name to the server at a well known port, port 1434. The server responds with a port number. &freetds; then uses that number to connect in the usual way. + + + Confirm the installation - Confirm the installation - - We want to make sure that when your application requests a connection to your server, it actually works. In detail, we want to know: - - &freetds; can find and read &freetdsconf; - servername exists in &freetdsconf; - a host property exists for servername - host can be resolved to a network address - the server is listening to the port or named instance - the user can log in to the server - + +We want to make sure that when your application requests a connection to your server, it actually works. In detail, we want to know: + + &freetds; can find and read &freetdsconf; + servername exists in &freetdsconf; + a host property exists for servername + host can be resolved to a network address + the server is listening to the port or named instance + the user can log in to the server + + + Each of the above can be confirmed independently with tsql. Once you're sure you can connect and log in, you can run the unit tests to see if the software works as promised. + + <application>tsql</application> - - Each of the above can be confirmed independently with tsql. Once you're sure you can connect and log in, you can run the unit tests to see if the software works as promised. - - - <application>tsql</application> - The tsql utility is provided as part of FreeTDS expressly for troubleshooting. tsql is superficially similar to an isql, but uses libtds directly, bypassing the client libraries (e.g., db-lib). It can also report where it looks for &freetdsconf; and other compile-time settings (with tsql -C). - - -Show compile-time settings with <command>tsql</> +The tsql utility is provided as part of FreeTDS expressly for troubleshooting. tsql is superficially similar to an isql, but uses libtds directly, bypassing the client libraries (e.g., &dblib;). It can also report where it looks for &freetdsconf; and other compile-time settings (with tsql -C). + + Show compile-time settings with <command>tsql</> -$ tsql -C -Password: - -locale is "C" -locale charset is "646" -Compile-time settings (established with the "configure" script): - Version: freetds &version; - freetds.conf directory: /usr/local/etc - MS db-lib source compatibility: no - Sybase binary compatibility: no - Thread safety: yes - iconv library: no - TDS version: 7.0 - iODBC: no - unixodbc: no - - - - - For details on the use of tsql, consult its man page. + $ tsql -C + Password: + + locale is "C" + locale charset is "646" + Compile-time settings (established with the "configure" script): + Version: freetds &version; + freetds.conf directory: /usr/local/etc + MS db-lib source compatibility: no + Sybase binary compatibility: no + Thread safety: yes + iconv library: no + TDS version: 7.0 + iODBC: no + unixodbc: no + + + - <replaceable>servername</> Lookup - If all goes well, the first time you fire up tsql it connects and you can issue your first query. More often, though, the result is less joyous. Listed below for your troubleshooting pleasure are a variety of servername lookup failures and their corresponding messages. - When servername cannot be converted to an address, up to two messages may result. Successful conversion (by any means) never produces an error message. +For details on the use of tsql, consult its man page. - -Failure to find <replaceable>servername</> in &freetdsconf; + <replaceable>servername</> Lookup + +If all goes well, the first time you fire up tsql it connects and you can issue your first query. More often, though, the result is less joyous. Listed below for your troubleshooting pleasure are a variety of servername lookup failures and their corresponding messages. + +When servername cannot be converted to an address, up to two messages may result. Successful conversion (by any means) never produces an error message. + + + Failure to find <replaceable>servername</> in &freetdsconf; -$ tsql -S nobox -U sa -Password: - -locale is "C" -locale charset is "646" -Password: -Error 20012 (severity 2): + $ tsql -S nobox -U sa + Password: + + locale is "C" + locale charset is "646" + Password: + Error 20012 (severity 2): Server name not found in configuration files. -Error 20013 (severity 2): + Error 20013 (severity 2): Unknown host machine name. -There was a problem connecting to the server - -$ host nobox - -Host not found. - - - + There was a problem connecting to the server + + $ host nobox + + Host not found. + + + + In the above case message 20012 indicates nobox was not found in &freetdsconf;. The library then treated nobox as a network hostname but found it also not to be valid per DNS, leading to message 20013. + -In the above case message 20012 indicates nobox was not found in &freetdsconf;. The library then treated nobox as a network hostname but found it also not to be valid per DNS, leading to message 20013. - +If servername is found in the configuration files, but refers to an invalid hostname, only message 20013 is returned. + + + Failure to resolve hostname for <replaceable>servername</> + + $ tsql -S nonesuch -U sa + Password: + + locale is "C" + locale charset is "646" + Error 20013 (severity 2): + Unknown host machine name. + There was a problem connecting to the server + + + Unfortunately, the host machine name (the right side of the host line in &freetdsconf;) isn't mentioned in the error message. Fortunately, this kind of setup problem is rarely encountered by users. + + Connecting to the Server - If servername is found in the configuration files, but refers to an invalid hostname, only message 20013 is returned. +If name lookup succeeds, &freetds; next attempts to connect to the server. To connect means to form at TCP connection by calling connect(2). A valid connection must exist before any information can be exchanged with the server. Specifically, we need a connection before we can log in. - -Failure to resolve hostname for <replaceable>servername</> - -$ tsql -S nonesuch -U sa -Password: - -locale is "C" -locale charset is "646" -Error 20013 (severity 2): - Unknown host machine name. -There was a problem connecting to the server - - - - Unfortunately, the host machine name (the right side of the host line in &freetdsconf;) isn't mentioned in the error message. Fortunately, this kind of setup problem is rarely encountered by users. - - - Connecting to the Server - If name lookup succeeds, &freetds; next attempts to connect to the server. To connect means to form at TCP connection by calling connect(2). A valid connection must exist before any information can be exchanged with the server. Specifically, we need a connection before we can log in. - - A few things can go wrong at this point. The address returned by DNS may not be that of the machine hosting the server, or indeed of any machine! The machine may be down. The server may not be running. The server may be running but not listening to the port &freetds; is attempting to connect to. In rare cases, both ends are correctly configured, but a firewall stands in the way. - - If no server accepts the connection, no connection can be established. It's difficult to know why, and the message is consequently vague. +A few things can go wrong at this point. The address returned by DNS may not be that of the machine hosting the server, or indeed of any machine! The machine may be down. The server may not be running. The server may be running but not listening to the port &freetds; is attempting to connect to. In rare cases, both ends are correctly configured, but a firewall stands in the way. - -Failing to connect with tsql +If no server accepts the connection, no connection can be established. It's difficult to know why, and the message is consequently vague. + + + Failing to connect with tsql -$ tsql -S emforester -U sa #only connect? -Password: - -Msg 20009, Level 9, State -1, Server OpenClient, Line -1 -Unable to connect: Adaptive Server is unavailable or does not exist -There was a problem connecting to the server - - - - If you get message 20009, remember you haven't connected to the machine. It's a configuration or network issue, not a protocol failure. Verify the server is up, has the name and IP address &freetds; is using, and is listening to the configured port. - - Named instances provide another way for connections to fail. You can verify the instance name and the port the server is using with tsql -L. + $ tsql -S emforester -U sa #only connect? + Password: + + Msg 20009, Level 9, State -1, Server OpenClient, Line -1 + Unable to connect: Adaptive Server is unavailable or does not exist + There was a problem connecting to the server + + + If you get message 20009, remember you haven't connected to the machine. It's a configuration or network issue, not a protocol failure. Verify the server is up, has the name and IP address &freetds; is using, and is listening to the configured port. + +Named instances provide another way for connections to fail. You can verify the instance name and the port the server is using with tsql -L. + + + Getting instance information with tsql + + $ tsql -LH servername + + locale is "C" + locale charset is "646" + ServerName TITAN + InstanceName MSSQLSERVER + IsClustered No + Version 8.00.194 + tcp 1433 + np \\TITAN\pipe\sql\query + + + servername could be configured to use instance MSSQLSERVER or port 1433. - -Getting instance information with tsql + +After a valid connection is formed, &freetds; sends a login packet. The TDS protocol provides no way to interrogate the server for its TDS version. If you specify the wrong one, you'll get an error. + + + Using the wrong protocol for the server -$ tsql -LH servername - -locale is "C" -locale charset is "646" - ServerName TITAN - InstanceName MSSQLSERVER - IsClustered No - Version 8.00.194 - tcp 1433 - np \\TITAN\pipe\sql\query - - - - servername could be configured to use instance MSSQLSERVER or port 1433. - + $ tsql -S servername + Password: + + Msg 20017, Level 9, State -1, Server OpenClient, Line -1 + Unexpected EOF from the server + Msg 20002, Level 9, State -1, Server OpenClient, Line -1 + Adaptive Server connection failed + There was a problem connecting to the server + + + + Unexpected EOF from the server seems to be a fairly common message when the wrong TDS version is used. Note that there's no complaint about the login. + - After a valid connection is formed, &freetds; sends a login packet. The TDS protocol provides no way to interrogate the server for its TDS version. If you specify the wrong one, you'll get an error. +If the right TDS version is used, the server will accept the login packet and examine its contents to authenticate the user. If there's a problem, the server will say so. This is the first time we're receiving a message from the server. If you'd like to help the project and want to so something fairly easy but still useful, modify tsql to distinguish clearly between errors returned by the library, and those returned by the server. Errors should be marked error and don't return state or a line number, but can contain an error code (and message) from the operating system. + + + Login failure + + $ tsql -S servername -U notme + Password: + + Msg 18456, Level 14, State 1, Server [servername], Line 0 + Login failed for user 'notme'. + Msg 20002, Level 9, State -1, Server OpenClient, Line -1 + Adaptive Server connection failed + There was a problem connecting to the server + + - -Using the wrong protocol for the server + Bypassing &freetdsconf;: + + + tsql + -H hostname + -p port + -U username + -Ppassword + -C + + + Keep in mind that the TDS protocol version normally comes from &freetdsconf;. When using tsql this way, the library uses the compiled-in default (set by the configure script). If that's not what you want, override it using the TDSVER environment variable. + + + Connect with <command>tsql</> using a hostname and port number -$ tsql -S servername -Password: - -Msg 20017, Level 9, State -1, Server OpenClient, Line -1 -Unexpected EOF from the server -Msg 20002, Level 9, State -1, Server OpenClient, Line -1 -Adaptive Server connection failed -There was a problem connecting to the server - - - + $ TDSVER=7.0 tsql -H hillary -p 4100 -U sa + Password: + + 1> + + + - Unexpected EOF from the server seems to be a fairly common message when the wrong TDS version is used. Note that there's no complaint about the login. - - - If the right TDS version is used, the server will accept the login packet and examine its contents to authenticate the user. If there's a problem, the server will say so. This is the first time we're receiving a message from the server. If you'd like to help the project and want to so something fairly easy but still useful, modify tsql to distinguish clearly between errors returned by the library, and those returned by the server. Errors should be marked error and don't return state or a line number, but can contain an error code (and message) from the operating system. - +For details on tsql, see the its man page. + + + <application>Unit Tests</application> - -Login failure +The source code directory of each &freetds; library includes a unittests directory. + -$ tsql -S servername -U notme -Password: - -Msg 18456, Level 14, State 1, Server [servername], Line 0 -Login failed for user 'notme'. -Msg 20002, Level 9, State -1, Server OpenClient, Line -1 -Adaptive Server connection failed -There was a problem connecting to the server - - - - + $ ls -d -1 src/*/unittests + + src/ctlib/unittests + src/dblib/unittests + src/odbc/unittests + src/tds/unittests + + + The unit tests rely on the PWD file in root of the FreeTDS source tree. + PWD holds a username, password, servername, and database to be used for the unit tests. We try to make sure to leave nothing behind: any data and objects created are either temporary or removed at the end of the test. The tests should all work, subject to disclaimers in the directory's README. - Bypassing &freetdsconf;: - - - tsql - -H hostname - -p port - -U username - -Ppassword - -C - - - Keep in mind that the TDS protocol version normally comes from &freetdsconf;. When using tsql this way, the library uses the compiled-in default (set by the configure script). If that's not what you want, override it using the TDSVER environment variable. - +To invoke the tests, edit the PWD file and issue the command make check. In order to execute all tests successfully, you must indicate a working, available servername in PWD. + Some tests require permission to create stored procedures on server. - -Connect with <command>tsql</> using a hostname and port number - -$ TDSVER=7.0 tsql -H hillary -p 4100 -U sa -Password: - -1> - - - +To complete successfully, the ODBC tests require some additional setup. In your PWD file, add a SRV entry specifying the DSN entry for your odbc.ini. The ODBC tests all build their own odbc.ini and try to redirect the Driver Manager to it, however this functionality is very DM dependent and may well fail unless you have either iODBC or unixODBC. + + + The PWD provided by &freetds; includes usernames and passwords that probably don't exist on your server. + + + + +
    + + Preparing ODBC + Background and Terminology +To connect to a database server, a library such as &freetds; needs some information about the connection. By server, which IP address and port is do you mean? Which user is requesting the connection, and what authentication does he offer? Every database library needs a way to capture and convey that information. +ODBC was conceived as a general interface definition, not tied to any particular database or access library. For that reason, ODBC also needs to know which driver to use with a given server. - -For details on tsql, see the its man page. - - - - <application>Unit Tests</application> - -The source code directory of each &freetds; library includes a unittests directory. +The original ODBC solution to this conundrum employed the odbc.ini file. odbc.ini stored information about a server, known generically as a Data Source Name (DSN). ODBC applications connected to the server by calling the function SQLConnect(DSN, UID, PWD), where DSN is the Data Source Name entry in odbc.ini, UID is the username, and PWD the password. Any and all information about the DSN was kept in odbc.ini. And all was right with the world. - -$ ls -d -1 src/*/unittests - -src/ctlib/unittests -src/dblib/unittests -src/odbc/unittests -src/tds/unittests - - +The ODBC 3.0 specification introduced a new function: SQLDriverConnect. + The connection attributes are provided as a single argument, a string of concatenated name-value pairs. SQLDriverConnect subsumed the functionality of SQLConnect, in that the name-value pair string allowed the caller to pass — in addition the the original DSN, UID, and PWD — any other parameters the driver could accept. Moreover, the application can specify which driver to use. In effect, it became possible to specify the entire set of DSN properties as parameters to SQLDriverConnect, obviating the need for odbc.ini. This led to the use of the so-called DSN-less configuration, a setup with no odbc.ini. -The unit tests rely on the PWD file in root of the FreeTDS source tree. -PWD holds a username, password, servername, and database to be used for the unit tests. We try to make sure to leave nothing behind: any data and objects created are either temporary or removed at the end of the test. The tests should all work, subject to disclaimers in the directory's README. - -To invoke the tests, edit the PWD file and issue the command make check. In order to execute all tests successfully, you must indicate a working, available servername in PWD. -Some tests require permission to create stored procedures on server. - - -To complete successfully, the ODBC tests require some additional setup. In your PWD file, add a SRV entry specifying the DSN entry for your odbc.ini. The ODBC tests all build their own odbc.ini and try to redirect the Driver Manager to it, however this functionality is very DM dependent and may well fail unless you have either iODBC or unixODBC. - - - -The PWD provided by &freetds; includes usernames and passwords that probably don't exist on your server. - - - - +But FreeTDS did not start out as an ODBC driver (remember &dblib; and &ctlib;), and has always had its own way to store server properties: &freetdsconf;. When Brian added the &freetds; ODBC driver, he began by supporting the old SQLConnect, using odbc.ini to describe the DSN. That choice complied with the expectations of the Driver Managers, and minimized the amount of duplicated information in the configuration files. But it can be a little confusing, too, because odbc.ini in effect points to &freetdsconf;. We call this configuration ODBC-combined, because it supports all three FreeTDS libraries. + +As progress on the the &freetds; ODBC library progressed, the driver was made able to read the connection attributes directly from odbc.ini, rather than leaning on &freetdsconf;. For installations that don't need &dblib; and &ctlib;, this ODBC-only setup is simpler. + +More recently, SQLDriverConnect was added to &freetds;. As described above, this function allows the application to specify connection attributes with reference to either, or neither, configuration file. It's your choice. In making that choice, keep the following terms clear in your mind: - - - Preparing ODBC - Background and Terminology - -To connect to a database, a library such as FreeTDS needs some information about the connection. Which server, and by server, which IP address and port is do you mean? Which user is requesting the connection, and what authentication does he offer? Every database library needs a way to capture and convey that information. - - -ODBC was conceived as a general interface definition, not tied to any particular database or access library. For that reason, ODBC also needs to know which driver to use with a given server. - - -The original ODBC solution to this conundrum employed the odbc.ini file. odbc.ini stored information about a server, known generically as a Data Source Name (DSN). ODBC applications connected to the server by calling the function SQLConnect(DSN, UID, PWD), where DSN is the Data Source Name entry in odbc.ini, UID is the username, and PWD the password. Any and all information about the DSN was kept in odbc.ini. And all was right with the world. - - -The ODBC 3.0 specification introduced a new function: SQLDriverConnect. -The connection attributes are provided as a single argument, a string of concatenated name-value pairs. SQLDriverConnect subsumed the functionality of SQLConnect, in that the name-value pair string allowed the caller to pass — in addition the the original DSN, UID, and PWD — any other parameters the driver could accept. Moreover, the application can specify which driver to use. In effect, it became possible to specify the entire set of DSN properties as parameters to SQLDriverConnect, obviating the need for odbc.ini. This led to the use of the so-called DSN-less configuration, a setup with no odbc.ini. - - -But FreeTDS did not start out as an ODBC driver (remember db-lib and ct-lib), and has always had its own way to store server properties: &freetdsconf;. When Brian added the FreeTDS ODBC driver, he began by supporting the old SQLConnect, using odbc.ini to describe the DSN. That choice complied with the expectations of the Driver Managers, and minimized the amount of duplicated information in the configuration files. But it can be a little confusing, too, because odbc.ini in effect points to &freetdsconf;. We call this configuration ODBC-combined, because it supports all three FreeTDS libraries. - - -As progress on the the &freetds; ODBC library progressed, the driver was made able to read the connection attributes directly from odbc.ini, rather than leaning on &freetdsconf;. For installations that don't need db-lib and ct-lib, this ODBC-only setup is simpler. - -More recently, SQLDriverConnect was added to FreeTDS. As described above, this function allows the application to specify connection attributes with reference to either, or neither, configuration file. It's your choice. In making that choice, keep the following terms clear in your mind: - + Important &freetds; ODBC terms + + SERVERNAME + -Important <productname>FreeTDS</> ODBC terms - - SERVERNAME - - specifies the [servername] entry in &freetdsconf;. - - - - SERVER - - specifies the real server i.e., the TCP/IP name of the machine hosting the database server. - - - - DSN - Driver - - In your connection string, you can decide to use a DSN entry in odbc.ini using the DSN attribute, or to specify the driver you want with the Driver attribute. - - - +specifies the [servername] entry in &freetdsconf;. + + + + SERVER + - -In sum, &freetds; supports three ODBC three choices: - +specifies the real server i.e., the TCP/IP name of the machine hosting the database server. + + + + DSN + Driver + +In your connection string, you can decide to use a DSN entry in odbc.ini using the DSN attribute, or to specify the driver you want with the Driver attribute. + + + + -ODBC configuration choices - - DSN-less - - No connection information is specified in odbc.ini. Advantageous if you're using more of FreeTDS than just the ODBC driver. - - - - ODBC-only - - All connection information -is specified in odbc.ini, without the need for &freetdsconf;. This is the traditional ODBC setup. - - - - ODBC-combined - - Connection information maintained in &freetdsconf;. odbc.ini contains DSN entries that refer to servernames in &freetdsconf;. - - - +In sum, &freetds; supports three ODBC three choices: + + ODBC configuration choices + + DSN-less + + +No connection information is specified in odbc.ini. Advantageous if you're using more of &freetds; than just the ODBC driver. + + + + ODBC-only + + +All connection information + is specified in odbc.ini, without the need for &freetdsconf;. This is the traditional ODBC setup. + + + + ODBC-combined + + +Connection information maintained in &freetdsconf;. odbc.ini contains DSN entries that refer to servernames in &freetdsconf;. + + + +Library or Driver? +What's a library and what's a driver? Technically, they're the same thing: bodies of subroutines whose names are exported to a linker (static or runtime). By convention, a library is used directly by an application, whose programmer will require documentation and header files. A driver, by contrast, is defined by a binary API and is used in some kind of framework, hence printer driver and video driver. + +An ODBC driver is a hybrid. For the most part, an application relies on a driver manager to define manifest constants, and links to the DM's library. But because the ODBC specification leaves behavior up to the driver, the application is forced to include the driver's header files, too, to exploit driver-specific functions. - Connection attributes - -The following table defines all possible ODBC connection attributes for the FreeTDS ODBC driver. Which ones you'll need depends on how you set yourself up. They may appear in your connection string, or in odbc.ini. - - -Connection attributes used only in connection strings - - - - Name - Possible Values - Default - Meaning - - - - - DSN - A valid DSN entry - none - The DSN to which FreeTDS should connect. FreeTDS will search odbc.ini for entry. It lets you specify a connection as for SQLConnect, but using SQLDriverConnect. Do not use Servername and DSN together. - - - UID - Any valid username - none - The username to be used when connecting. To use domain authentication, specify the domain using the format domain\username. - - - PWD - Any - empty - The password to be used when connecting. - - - WSID - Any - Computer name - The name of the local computer, sent to server. Can be specified only for a DSN-less connection. - - - -
    - -Connection attributes that may appear in <filename>odbc.ini</> - - - - Name - Possible Values - Default - Meaning - - - - - Servername - A valid &freetdsconf; server section - none - A &freetdsconf; servername, not a hostname as known to DNS. If you want to use ODBC-only configuration, use Server instead. - - - Server - A server name or (ip) address - none - Hostname of a server. Used in an ODBC-only configuration. To specify a Microsoft SQL Server instance, use the form server\instance. - - - Port - Any TCP port - Depends on the TDS version specified with configure - The TCP port where the servername is listening. - - - TDS_Version - Any valid protocol version - Depends on the TDS version specified with configure - TDS protocol version to use (e.g., 5.0, 7.0). - - - ClientCharset - A name recognized by the iconv library linked to FreeTDS. - This correspond to client charset in &freetdsconf;. - ISO8859-1 - Character set (encoding) used by the client. - - - APP - Free form text, up to 30 characters. - none - Application name. Identifies the connecting application to the server. - - - LANGUAGE - Any - us_english - (Human) language the server should use for error messages. - - - Address - Any - none - IP address of the servername. Useful if you want to specify a server by address, rather than by name. The format is ip,port or simply ip in standard dotted-decimal notation. - - - Database - Any - none - Specify which database you want to access. If the database does not exist or the user lacks permission to access it, the connection will fail. - - - TextSize - Any - DB dependent - Maximum size returned from server for blobs. - - - PacketSize - Any - DB dependent - Size of packets to server. Some users saw some performance gain by increasing this value. Normally you shouldn't set it. - - - Trusted_Connection - Yes/No - No - Use your current account instead of UID/PWD attributes. - This option require SSPI or Kerberos. This superceed UID/PWD attributes. - - - -
    -
    + + Connection attributes + +The following table defines all possible ODBC connection attributes for the FreeTDS ODBC driver. Which ones you'll need depends on how you set yourself up. They may appear in your connection string, or in odbc.ini. + + +Connection attributes used only in connection strings + + + + Name + Possible Values + Default + Meaning + + + + + DSN + A valid DSN entry + none + The DSN to which FreeTDS should connect. FreeTDS will search odbc.ini for entry. It lets you specify a connection as for SQLConnect, but using SQLDriverConnect. Do not use Servername and DSN together. + + + UID + Any valid username + none + The username to be used when connecting. To use domain authentication, specify the domain using the format domain\username. + + + PWD + Any + empty + The password to be used when connecting. + + + WSID + Any + Computer name + The name of the local computer, sent to server. Can be specified only for a DSN-less connection. + + + +
    + + Connection attributes that may appear in <filename>odbc.ini</> + + + + Name + Possible Values + Default + Meaning + + + + + Servername + A valid &freetdsconf; server section + none + A &freetdsconf; servername, not a hostname as known to DNS. If you want to use ODBC-only configuration, use Server instead. + + + Server + A server name or (ip) address + none + Hostname of a server. Used in an ODBC-only configuration. To specify a Microsoft SQL Server instance, use the form server\instance. + + + Port + Any TCP port + Depends on the TDS version specified with configure + The TCP port where the servername is listening. + + + TDS_Version + Any valid protocol version + Depends on the TDS version specified with configure + TDS protocol version to use (e.g., 5.0, 7.0). + + + ClientCharset + A name recognized by the iconv library linked to FreeTDS. + This correspond to client charset in &freetdsconf;. + ISO 8859-1 + Character set (encoding) used by the client. + + + APP + Free form text, up to 30 characters. + none + Application name. Identifies the connecting application to the server. + + + LANGUAGE + Any + us_english + (Human) language the server should use for error messages. + + + Address + Any + none + IP address of the servername. Useful if you want to specify a server by address, rather than by name. The format is ip,port or simply ip in standard dotted-decimal notation. + + + Database + Any + none + Specify which database you want to access. If the database does not exist or the user lacks permission to access it, the connection will fail. + + + TextSize + Any + DB dependent + Maximum size returned from server for blobs. + + + PacketSize + Any + DB dependent + Size of packets to server. Some users saw some performance gain by increasing this value. Normally you shouldn't set it. + + + Trusted_Connection + Yes/No + No + Use your current account instead of UID/PWD attributes. + This option require SSPI or Kerberos. This superceed UID/PWD attributes. + + + +
    - DSN-less configuration - -In a DSN-less configuration, the odbc.ini file is not consulted for server connection properties. To connect to a servername, your application may refer to a servername entry in &freetdsconf;, or explicitly specify the servername's hostname (bypassing &freetdsconf;). - -Sample files for a DSN-less configuration -The odbcinst.ini is quite brief: -

    - + DSN-less configuration + +In a DSN-less configuration, the odbc.ini file is not consulted for server connection properties. To connect to a servername, your application may refer to a servername entry in &freetdsconf;, or explicitly specify the servername's hostname (bypassing &freetdsconf;). + + + Sample files for a DSN-less configuration + +The odbcinst.ini is quite brief: + ; ; odbcinst.ini ; [FreeTDS] Driver = /usr/local/freetds/lib/libtdsodbc.so -
    + The &freetdsconf; might look something like: -
    - + ; ; freetds.conf ; [JDBC] - host = jdbc.sybase.com - port = 4444 - tds version = 5.0 + host = jdbc.sybase.com + port = 4444 + tds version = 5.0 -
    - - -Connecting with a DSN-less configuration + + + + Connecting with a DSN-less configuration -/* - * application call - */ -const char servername[] = "JDBC"; refers to the [JDBC] entry in &freetdsconf;. -sprintf(tmp, "DRIVER=FreeTDSrefers to the [FreeTDS] entry in odbcinst.ini.;SERVERNAME=%s;UID=%s;PWD=%s;DATABASE=%s;", + /* + * application call + */ + const char servername[] = "JDBC"; refers to the [JDBC] entry in &freetdsconf;. + sprintf(tmp, "DRIVER=FreeTDSrefers to the [FreeTDS] entry in odbcinst.ini.;SERVERNAME=%s;UID=%s;PWD=%s;DATABASE=%s;", servername, username, password, dbname); -res = SQLDriverConnect(Connection, NULL, (SQLCHAR *) tmp, SQL_NTS, - (SQLCHAR *) tmp, sizeof(tmp), &len, SQL_DRIVER_NOPROMPT); -if (!SQL_SUCCEEDED(res)) { + res = SQLDriverConnect(Connection, NULL, (SQLCHAR *) tmp, SQL_NTS, + (SQLCHAR *) tmp, sizeof(tmp), &len, SQL_DRIVER_NOPROMPT); + if (!SQL_SUCCEEDED(res)) { printf("Unable to open data source (ret=%d)\n", res); exit(1); -} - - - -You can even establish a connection without reference to either odbc.ini or freetd.conf. - -Connecting with a DSN-less configuration that does not use &freetdsconf; + } + + + + You can even establish a connection without reference to either odbc.ini or freetd.conf. + + + Connecting with a DSN-less configuration that does not use &freetdsconf; -/* - * application call - */ -const char servername[] = "jdbc.sybase.com"; refers to the real server name. -sprintf(tmp, "DRIVER=FreeTDSrefers to the [FreeTDS] entry in odbcinst.ini.;SERVER=%s;UID=%s;PWD=%s;DATABASE=%s;TDS_Version=5.0;Port=4444;", + /* + * application call + */ + const char servername[] = "jdbc.sybase.com"; refers to the real server name. + sprintf(tmp, "DRIVER=FreeTDSrefers to the [FreeTDS] entry in odbcinst.ini.;SERVER=%s;UID=%s;PWD=%s;DATABASE=%s;TDS_Version=5.0;Port=4444;", servername, username, password, dbname); -res = SQLDriverConnect(Connection, NULL, (SQLCHAR *) tmp, SQL_NTS, - (SQLCHAR *) tmp, sizeof(tmp), &len, SQL_DRIVER_NOPROMPT); -if (!SQL_SUCCEEDED(res)) { + res = SQLDriverConnect(Connection, NULL, (SQLCHAR *) tmp, SQL_NTS, + (SQLCHAR *) tmp, sizeof(tmp), &len, SQL_DRIVER_NOPROMPT); + if (!SQL_SUCCEEDED(res)) { printf("Unable to open data source (ret=%d)\n", res); exit(1); -} - - - - + } + + - ODBC-only configuration - -An ODBC-only configuration relies solely on odbc.ini for server properties. Other &freetds; drivers don't know about odbc.ini. - -Sample ODBC-only <filename>odbc.ini</filename> file + + + ODBC-only configuration + +An ODBC-only configuration relies solely on odbc.ini for server properties. Other &freetds; libraries don't know about odbc.ini. + + + Sample ODBC-only <filename>odbc.ini</filename> file -[ODBC Data Sources]Several DSNs might be listed here. In this example, we have only one, JDBC. It matches the [JDBC] entry later in the file. - JDBC = Sybase JDBC Server - -[JDBC] -Driver = /usr/local/freetds/lib/libtdsodbc.so -Description = Sybase JDBC Server -Trace = No -Server = jdbc.sybase.com -Database = pubs2 -Port = 4444 -TDS_Version = 5.0 - -[Default] -Driver = /usr/local/freetds/lib/libtdsodbc.so - - - + [ODBC Data Sources]Several DSNs might be listed here. In this example, we have only one, JDBC. It matches the [JDBC] entry later in the file. + JDBC = Sybase JDBC Server + + [JDBC] + Driver = /usr/local/freetds/lib/libtdsodbc.so + Description = Sybase JDBC Server + Trace = No + Server = jdbc.sybase.com + Database = pubs2 + Port = 4444 + TDS_Version = 5.0 + + [Default] + Driver = /usr/local/freetds/lib/libtdsodbc.so + + + + ODBC-combined configuration - ODBC-combined configuration - -Like the DSN-less configuration, ODBC-combined keeps server properties in &freetdsconf;. The difference is that your applications can refer to the server by its DSN. To make that possible, the DSN entry in odbc.ini refers to the servername entry in &freetdsconf;. +Like the DSN-less configuration, ODBC-combined keeps server properties in &freetdsconf;. The difference is that your applications can refer to the server by its DSN. To make that possible, the DSN entry in odbc.ini refers to the servername entry in &freetdsconf;. -Sample ODBC-combined <filename>odbc.ini</filename> file + + Sample ODBC-combined <filename>odbc.ini</filename> file -[ODBC Data Sources]Several DSNs might be listed here. In this example, we have only one, JDBCdsn. It matches the [JDBCdsn] entry later in the file. - JDBCdsn = Sybase JDBC Server - -[JDBCdsn] -Driver = /usr/local/freetds/lib/libtdsodbc.so -Description = Sybase JDBC Server -Trace = No -Servername = JDBCRefers to the [JDBC] entry in &freetdsconf;. -Database = pubs2 - -[Default] -Driver = /usr/local/freetds/lib/libtdsodbc.so - - -Sample ODBC-combined &freetdsconf; file + [ODBC Data Sources]Several DSNs might be listed here. In this example, we have only one, JDBCdsn. It matches the [JDBCdsn] entry later in the file. + JDBCdsn = Sybase JDBC Server + + [JDBCdsn] + Driver = /usr/local/freetds/lib/libtdsodbc.so + Description = Sybase JDBC Server + Trace = No + Servername = JDBCRefers to the [JDBC] entry in &freetdsconf;. + Database = pubs2 + + [Default] + Driver = /usr/local/freetds/lib/libtdsodbc.so + + + + Sample ODBC-combined &freetdsconf; file -; -; freetds.conf -; -[JDBC] - host = jdbc.sybase.com - port = 4444 - tds version = 5.0 - - - - -With this arrangement, an application can connect to the server in two ways, via its DSN (JDBCdsn), or its servername (JDBC). - + ; + ; freetds.conf + ; + [JDBC] + host = jdbc.sybase.com + port = 4444 + tds version = 5.0 + + + +With this arrangement, an application can connect to the server in two ways, via its DSN (JDBCdsn), or its servername (JDBC). + + + Troubleshooting ODBC connections - Troubleshooting ODBC connections + +Supposing everything compiles and installs without trouble, how do you know if your ODBC setup works? Or, if you know it doesn't, what then? + +First, try to connect with tsql. If you're intending to use &freetdsconf;, exercise it with + tsql -S servername. If not, use + TDSVER=7.0 tsql -H hostname -p port + +If tsql works and isql doesn't, you've isolated the problem to the ODBC setup. &freetds; might have some interoperability problems, but mere connection to the database isn't one of them! If tsql + doesn't work, turn on logging with TDSDUMP. The log will tell you what TCP/IP name (and address) FreeTDS is attempting to connect to, and what version of the TDS protocol it's using. - -Supposing everything compiles and installs without trouble, how do you know if your ODBC setup works? Or, if you know it doesn't, what then? - - -First, try to connect with tsql. If you're intending to use &freetdsconf;, exercise it with - tsql -S servername. If not, use - TDSVER=7.0 tsql -H hostname -p port - - -If tsql works and isql doesn't, you've isolated the problem to the ODBC setup. &freetds; might have some interoperability problems, but mere connection to the database isn't one of them! If tsql -doesn't work, turn on logging with TDSDUMP. The log will tell you what TCP/IP name (and address) FreeTDS is attempting to connect to, and what version of the TDS protocol it's using. - - - With iODBC - - iODBC comes with a sample command line query program called odbctest that is located in the iodbc/samples directory. Using this program you can get a listing of DSNs, connect, and issue queries. It is often useful to compile a program such as this directly against the &freetds; driver instead of using a driver manager. This makes it simpler to debug if something goes wrong. To do so, simply compile and install the ODBC driver with iODBC as normal When compiling directly to &freetds; you still need the Driver Manager's header files., then compile and link the program directly: + With iODBC - - Compile <filename>odbctest</> without a driver manager. + iODBC comes with a sample command line query program called odbctest that is located in the iodbc/samples directory. Using this program you can get a listing of DSNs, connect, and issue queries. It is often useful to compile a program such as this directly against the &freetds; driver instead of using a driver manager. This makes it simpler to debug if something goes wrong. To do so, simply compile and install the ODBC driver with iODBC as normal When compiling directly to &freetds; you still need the Driver Manager's header files., then compile and link the program directly: + + + Compile <filename>odbctest</> without a driver manager. -$ make odbctest.o -$ gcc -g -o odbctest odbctest.o /usr/local/freetds/lib/libtdsodbc.a - - - -The - + $ make odbctest.o + $ gcc -g -o odbctest odbctest.o /usr/local/freetds/lib/libtdsodbc.a + + + The + With unixODBC - - -Try isql -v dsn username password, and have a look at the log. See if the right address and TDS version are being used. Adjust to taste. - - Use <command>osql</> + - -The osql utility is a Bourne shell script that checks your ODBC configuration. If it approves, it invokes the unixODBC isql utility. Cf. man osql for details on its use. +Try isql -v dsn username password, and have a look at the log. See if the right address and TDS version are being used. Adjust to taste. + Use <command>osql</> + - - Use <command>osql</> to test the ODBC setup. +The osql utility is a Bourne shell script that checks your ODBC configuration. If it approves, it invokes the unixODBC isql utility. Cf. man osql for details on its use. + + + Use <command>osql</> to test the ODBC setup. -$ make odbctest.o - -$ osql -S machine -U mr_ed -P hayseed -looking for odbc.ini and odbcinst.ini in /usr/local/etc - reading "/usr/home/mr_ed/.odbc.ini" -[machine] found in "/usr/home/mr_ed/.odbc.ini" -found this section: - [machine] - Database = testdb - Servername = machine - Trace = Yes - TraceFile = /tmp/unixodbc.trace - -looking for driver for DSN [machine] -no driver mentioned for [machine] in .odbc.ini -looking for driver for DSN [default] -driver "FreeTDS" found for [default] in .odbc.ini -found driver named "FreeTDS" -FreeTDS is not a readable file -looking for entry named [FreeTDS] in /usr/local/etc/odbcinst.ini -driver "/usr/local/lib/libtdsodbc.so" found for [FreeTDS] in odbcinst.ini -/usr/local/lib/libtdsodbc.so is a readable file -Using ODBC-Combined strategy -FreeTDS servername is "machine" (from /usr/home/mr_ed/.odbc.ini) -looking for [machine] in /usr/home/mr_ed/.freetds.conf -"/usr/home/mr_ed/.freetds.conf" is a readable file -found this section: - [machine] - host = machine.example.com - port = 2500 - tds version = 7.1 - -machine.example.com has address 10.82.32.177 - - DSN: machine - Driver: /usr/local/lib/libtdsodbc.so - Server's hostname: machine.example.com - Address: 10.82.32.177 - -Attempting connection as mr_ed ... -+ exec isql machine mr_ed hayseed -v -+---------------------------------------+ -| Connected! | -| | -| sql-statement | -| help [tablename] | -| quit | -| | -+---------------------------------------+ -SQL> - - - - + $ make odbctest.o + + $ osql -S machine -U mr_ed -P hayseed + looking for odbc.ini and odbcinst.ini in /usr/local/etc + reading "/usr/home/mr_ed/.odbc.ini" + [machine] found in "/usr/home/mr_ed/.odbc.ini" + found this section: + [machine] + Database = testdb + Servername = machine + Trace = Yes + TraceFile = /tmp/unixodbc.trace + + looking for driver for DSN [machine] + no driver mentioned for [machine] in .odbc.ini + looking for driver for DSN [default] + driver "FreeTDS" found for [default] in .odbc.ini + found driver named "FreeTDS" + FreeTDS is not a readable file + looking for entry named [FreeTDS] in /usr/local/etc/odbcinst.ini + driver "/usr/local/lib/libtdsodbc.so" found for [FreeTDS] in odbcinst.ini + /usr/local/lib/libtdsodbc.so is a readable file + Using ODBC-Combined strategy + FreeTDS servername is "machine" (from /usr/home/mr_ed/.odbc.ini) + looking for [machine] in /usr/home/mr_ed/.freetds.conf + "/usr/home/mr_ed/.freetds.conf" is a readable file + found this section: + [machine] + host = machine.example.com + port = 2500 + tds version = 7.1 - - - + machine.example.com has address 10.82.32.177 + + DSN: machine + Driver: /usr/local/lib/libtdsodbc.so + Server's hostname: machine.example.com + Address: 10.82.32.177 + + Attempting connection as mr_ed ... + + exec isql machine mr_ed hayseed -v + +---------------------------------------+ + | Connected! | + | | + | sql-statement | + | help [tablename] | + | quit | + | | + +---------------------------------------+ + SQL> + + + + + - + - - Advanced Configurations - -This chapter details some advanced configurations that need expanded explanation. - - - Big Endian Clients with Buggy <productname>SQL Server</productname>s - -Several version of Microsoft SQL server have a bug that affects big endian clients. This includes 7.0 GA and 7.0 SP1. Furthermore, TDS Protocol version 7.0 is natively little endian. SQL Server 2000 is also reported not to work from big endian clients without little endian emulation turned on. - -The terms big endian and little endian come originally from Gulliver's Travels. In computer science they refer to the the integer byte-order for a processor. Big endian processors, such as Sparc and PowerPC store the most significant byte in the first memory location of a multi-byte integer. Little endian processors, such as Intel and Alpha do it the other way around. So the 16-bit number 258 would be 0x0102 on big endian and 0x0201 on little endian machines. + + Advanced Configurations - -In this example we want to force connections to a server named mssql to emulate a little endian client. We are using protocol version 4.2 here, version 7.0 or above will automatically emulate little endian mode regardless of the &freetdsconf; setting. -You shouldn't use this option, set another protocol version instead (7.0, 7.1 or 7.2). - - -Emulate Little Endian &freetdsconf; setting +This chapter details some advanced configurations that need expanded explanation. + + Big Endian Clients with Buggy <productname>SQL Server</productname>s + +Several version of Microsoft SQL server have a bug that affects big endian clients. This includes 7.0 GA and 7.0 SP1. Furthermore, TDS Protocol version 7.0 is natively little endian. SQL Server 2000 is also reported not to work from big endian clients without little endian emulation turned on. + The terms big endian and little endian come originally from Gulliver's Travels. In computer science they refer to the the integer byte-order for a processor. Big endian processors, such as Sparc and PowerPC store the most significant byte in the first memory location of a multi-byte integer. Little endian processors, such as Intel and Alpha do it the other way around. So the 16-bit number 258 would be 0x0102 on big endian and 0x0201 on little endian machines. + + +In this example we want to force connections to a server named mssql to emulate a little endian client. We are using protocol version 4.2 here, version 7.0 or above will automatically emulate little endian mode regardless of the &freetdsconf; setting. + You shouldn't use this option, set another protocol version instead (7.0, 7.1 or 7.2). + + Emulate Little Endian &freetdsconf; setting -[mssql] + [mssql] host = ntbox.mydomain.com port = 1433 tds version = 4.2 emulate little endian = yes - - + + - - Localization and <acronym>TDS</> 7.0 - -TDS 7.0 uses 2-byte Unicode (technically, UCS-2) to transfer character data between servers and clients. Included in character data are query text (i.e., SQL), metadata (table names and such), and bona fide data of datatypes nchar, nvarchar, and ntext. (Background information on Unicode and how it affects &freetds; can be found in the appendix.) - - -Because most Unix tools and environments do not support UCS-2, &freetds; provides for conversion by the client to other character sets. The mechanism used is determined by the configure script, which looks for a iconv(3) function, an implementation of the iconv standard. If no iconv library is found, or if it is explicitly disabled, &freetds; will use its built-in iconv substitute, and will be capable of converting among only ISO 8859-1, UTF-8, and UCS-2. - - -To learn what character set the client wants, &freetds; prefers the applicable &freetdsconf; client charset property. If that is not set, it parses the LANG environment variable. In either case, the found string is passed to iconv(3) (or its built-in replacment). The built-in replacement expects GNU iconv names: ISO-8859-1, US-ASCII, or UTF-8.. If neither is found, UCS-2 data are converted to ISO 8859-1. - + + Localization and <acronym>TDS</> 7.0 - -To list all supported iconv character sets try iconv(1). GNU's does: - +TDS 7.0 uses 2-byte Unicode (technically, UCS-2) to transfer character data between servers and clients. Included in character data are query text (i.e., SQL), metadata (table names and such), and bona fide data of datatypes nchar, nvarchar, and ntext. (Background information on Unicode and how it affects &freetds; can be found in the appendix.) + +Because most Unix tools and environments do not support UCS-2, &freetds; provides for conversion by the client to other character sets. The mechanism used is determined by the configure script, which looks for a iconv(3) function, an implementation of the iconv standard. If no iconv library is found, or if it is explicitly disabled, &freetds; will use its built-in iconv substitute, and will be capable of converting among only ISO 8859-1, UTF-8, and UCS-2. + +To learn what character set the client wants, &freetds; prefers the applicable &freetdsconf; client charset property. If that is not set, it parses the LANG environment variable. In either case, the found string is passed to iconv(3) (or its built-in replacment). The built-in replacement expects GNU iconv names: ISO-8859-1, US-ASCII, or UTF-8.. If neither is found, UCS-2 data are converted to ISO 8859-1. + + +To list all supported iconv character sets try iconv(1). GNU's does: -$ iconv --list - - -For other systems, consult your documentation (most likely man iconv will give you some hints). - - -In this example a server named mssql will return data encoded in the GREEK character set. - - -Configuring for GREEK &freetdsconf; setting + $ iconv --list + +For other systems, consult your documentation (most likely man iconv will give you some hints). + +In this example a server named mssql will return data encoded in the GREEK character set. + + Configuring for GREEK &freetdsconf; setting -[mssql] + [mssql] host = ntbox.mydomain.com port = 1433 tds version = 7.0 client charset = GREEK - - - -If &freetds; runs into a character it can not convert, its behavior varies according to the severity of the problem. On retrieving data from the server, &freetds; substitutes an ASCII '?' in the character's place, and emits a warning message stating that some characters could not be converted. On sending data to the server, &freetds; aborts the query and emits an error message. It is well to ensure that the data contained in the database is representable in the client's character set. + + + +If &freetds; runs into a character it can not convert, its behavior varies according to the severity of the problem. On retrieving data from the server, &freetds; substitutes an ASCII '?' in the character's place, and emits a warning message stating that some characters could not be converted. On sending data to the server, &freetds; aborts the query and emits an error message. It is well to ensure that the data contained in the database is representable in the client's character set. + - -If you have a mix of character data that can not be contained in a single-byte character set, you may wish to use UTF-8. UTF-8 is a variable length unicode encoding that is compatible with ASCII in the range 0 to 127. With UTF-8, you are guaranteed to never have an unconvertible character. +If you have a mix of character data that can not be contained in a single-byte character set, you may wish to use UTF-8. UTF-8 is a variable length unicode encoding that is compatible with ASCII in the range 0 to 127. With UTF-8, you are guaranteed to never have an unconvertible character. + + &freetds; is not fully compatible with multi-byte character sets such as UCS-2. You must use an ASCII-extension charset (e.g., UTF-8, ISO-8859-*)not EBCDIC or other weird charsets. Great care should be taken testing applications using these encodings. Specifically, many applications do not expect the number of characters returned to exceed the column size (in bytes). -&freetds; is not fully compatible with multi-byte character sets such as UCS-2. You must use an ASCII-extension charset (e.g., UTF-8, ISO-8859-*)not EBCDIC or other weird charsets. Great care should be taken testing applications using these encodings. Specifically, many applications do not expect the number of characters returned to exceed the column size (in bytes). - -In the following example, a server named mssql will return data encoded in the UTF-8 character set. - - -Configuring for <acronym>UTF-8</> &freetdsconf; setting +In the following example, a server named mssql will return data encoded in the UTF-8 character set. + + Configuring for <acronym>UTF-8</> &freetdsconf; setting -[mssql] + [mssql] host = ntbox.mydomain.com port = 1433 tds version = 7.0 client charset = UTF-8 - - - -It is also worth clarifying that TDS 7.0 and above do not accept any specified character set during login, as 4.2 does. A TDS 7.0 login packet uses UCS-2. - + + + +It is also worth clarifying that TDS 7.0 and above do not accept any specified character set during login, as 4.2 does. A TDS 7.0 login packet uses UCS-2. Microsoft Server Note - -String literals in SQL must be prefixed with 'N' unless the enclosed string can be represented in the server's single-byte character set, irrespective of the column's datatype. For example, in the SQL statement +String literals in SQL must be prefixed with 'N' unless the enclosed string can be represented in the server's single-byte character set, irrespective of the column's datatype. For example, in the SQL statement + -INSERT INTO tablename (greeting) VALUES ('Hallå') - + INSERT INTO tablename (greeting) VALUES ('Hallå') + + the string is subject to somewhat surprising treatment by the server. -the string is subject to somewhat surprising treatment by the server. - - -When the server parses the SQL, it extracts the data values for insertion (or update, or comparison, etc.) Unprefixed strings are converted to the single-byte character set of the server/database.The precise rules are unknown to the author. Inserted data are then of course stored in the column. In the case of UCS-2 columns — nchar, nvarchar, and ntext — the value stored is that which results from a second conversion: from the single-byte form to the UCS-2 form. - - -The only safe way to enclose strings in SQL text is with an 'N' prefix: +When the server parses the SQL, it extracts the data values for insertion (or update, or comparison, etc.) Unprefixed strings are converted to the single-byte character set of the server/database.The precise rules are unknown to the author. Inserted data are then of course stored in the column. In the case of UCS-2 columns — nchar, nvarchar, and ntext — the value stored is that which results from a second conversion: from the single-byte form to the UCS-2 form. +The only safe way to enclose strings in SQL text is with an 'N' prefix: + -INSERT INTO tablename (greeting) VALUES (N'Hallå') - + INSERT INTO tablename (greeting) VALUES (N'Hallå') + Commentary - - Commentary - -What's surprising about this? Versions 7.0 and later of the TDS protocol use UCS-2 to send SQL text. No matter how your local client is configured — with UCS-2 or ISO 8859-1 or anything else — it's converted to UCS-2 before it's sent to the server. And obviously arrives at the server as UCS-2. If the column into which it's being inserted is also UCS-2, there's no need of any conversion, much less two, and certainly no need to lose infomation. - - -Why this happens is anyone's guess. Here's one: it makes the datatype of the column unimportant. Regardless of whether you use char/varchar/text or nchar/nvarchar/ntext or a mixture of the two, the arriving SQL (if naïvely written) will store exactly the same characters. - - +What's surprising about this? Versions 7.0 and later of the TDS protocol use UCS-2 to send SQL text. No matter how your local client is configured — with UCS-2 or ISO 8859-1 or anything else — it's converted to UCS-2 before it's sent to the server. And obviously arrives at the server as UCS-2. If the column into which it's being inserted is also UCS-2, there's no need of any conversion, much less two, and certainly no need to lose infomation. + +Why this happens is anyone's guess. Here's one: it makes the datatype of the column unimportant. Regardless of whether you use char/varchar/text or nchar/nvarchar/ntext or a mixture of the two, the arriving SQL (if naïvely written) will store exactly the same characters. + - - Domain Logins -Domain logins can be used only with TDS protocol versions 7.0 or above. - -As mentioned in the installation chapter, Microsoft SQL Server includes the ability to use domain logins instead of standard server logins. The advantage of doing this is that the passwords are encrypted on the wire using a challenge-response protocol. - - Domain logins may or may not support single sign-on (connecting without prompting for a password) depending on how &freetds; was configured. For Windows hosts (both 32- and 64-bit), if SSPI is enabled, &freetds; will log in using so-called "trusted authentication". For Linux (and similar) hosts, enabling Kerberos provides similar functionality. If neither option is enabled, &freetds; can still log in using the domain account, but the user must re-enter the password, as described next. - - -To use domain logins, use the 'DOMAIN\username' syntax for the username and use the domain password. - -Logging in with a domain login - -$ tsql -S camelot -U 'NOTTINGHAM\lancelot' -P roundtable -locale is "C" -locale charset is "646" -Msg 5703, Level 0, State 1, Server CPRO200, Line 0 -Changed language setting to middle_english. -1> - - + + Domain Logins + Domain logins can be used only with TDS protocol versions 7.0 or above. - -When &freetds; sees the \ character, it automatically chooses a domain login. - -The term domain in this context is a Microsoft term. It refers to what's sometimes called an NT domain. It's unrelated to the DNS domain. DNS domains are used for name resolution. NT domains are used for authentication. Authentication is done by the domain controller, often the Primary Domain Controller (PDC). - -The SQL Server machine may belong to an NT domain. &freetds; provides an encrypted password — a domain password, known to the domain controller — that the server will ask the domain controller to verify. +As mentioned in the installation chapter, Microsoft SQL Server includes the ability to use domain logins instead of standard server logins. The advantage of doing this is that the passwords are encrypted on the wire using a challenge-response protocol. +Domain logins may or may not support single sign-on (connecting without prompting for a password) depending on how &freetds; was configured. For Windows hosts (both 32- and 64-bit), if SSPI is enabled, &freetds; will log in using so-called "trusted authentication". For Linux (and similar) hosts, enabling Kerberos provides similar functionality. If neither option is enabled, &freetds; can still log in using the domain account, but the user must re-enter the password, as described next. + +To use domain logins, use the 'DOMAIN\username' syntax for the username and use the domain password. + Logging in with a domain login + + $ tsql -S camelot -U 'NOTTINGHAM\lancelot' -P roundtable + locale is "C" + locale charset is "646" + Msg 5703, Level 0, State 1, Server CPRO200, Line 0 + Changed language setting to middle_english. + 1> + + + +When &freetds; sees the \ character, it automatically chooses a domain login. + The term domain in this context is a Microsoft term. It refers to what's sometimes called an NT domain. It's unrelated to the DNS domain. DNS domains are used for name resolution. NT domains are used for authentication. Authentication is done by the domain controller, often the Primary Domain Controller (PDC). +The SQL Server machine may belong to an NT domain. &freetds; provides an encrypted password — a domain password, known to the domain controller — that the server will ask the domain controller to verify. + Implementation details - -Support for domain logins in &freetds; is limited to the TCP/IP network protocol stack. &freetds; does not currently implement support for Named Pipe-based SQL connections — that is, connections transported over the DCE/RPC interface, which uses TCP port 139, 445, or 135 on Win32 machines depending on the type of encapsulation used for DCE/RPC itself. Supporting this would require a fairly extensive DCE/RPC library for Unix. Samba has one that is licensed under the GPL and therefore not usable by LGPL-licensed projects such as &freetds; . - - -For a technical description of the protocol used for domain logins, see -http://davenport.sourceforge.net/ntlm.html - - +Support for domain logins in &freetds; is limited to the TCP/IP network protocol stack. &freetds; does not currently implement support for Named Pipe-based SQL connections — that is, connections transported over the DCE/RPC interface, which uses TCP port 139, 445, or 135 on Win32 machines depending on the type of encapsulation used for DCE/RPC itself. Supporting this would require a fairly extensive DCE/RPC library for Unix. Samba has one that is licensed under the GPL and therefore not usable by LGPL-licensed projects such as &freetds; . + + +For a technical description of the protocol used for domain logins, see + http://davenport.sourceforge.net/ntlm.html + - - Kerberos support - In order to take advantage of Kerberos you have to set up your machine with keytab from your Active Directory. - To configure your stuff you could use samba or configure directly Kerberos (/etc/krb5.conf). - - By default Unix do not initialize Kerberos ticket with your login account. You have to use kinit to initialize ticket. - You could also configure Kerberos in PAM in order to initialize Kerberos ticket at login time. - + + Kerberos Support +Perhaps surprisingly, Kerberos can be used to authenticate to Microsoft SQL Servers. This affords single-signon (or, at most, double-signon) capability in non-Windows environment. The reason this works is that much of Active Directory is based on Kerberos. + +To take advantage of Kerberos you have to set up your machine with keytab from your Active Directory. + To configure your stuff you could use Samba or configure Kerberos directly (/etc/krb5.conf). configure includes options to define the location of your Kerberos installation (cf. ). + +By default UNIX does not initialize a Kerberos ticket with your login account. You have to use kinit to initialize a ticket. + You could also configure Kerberos in PAM in order to initialize Kerberos ticket at login time. + + + Threading in unixODBC - - Threading on unixODBC - unixODBC use strong thread locking policy. This cause big locks using default configurations for &freetds; which lead to performance issues using multi-thread applications (every single operation get serialized). In order to avoid this problem you have to set up threading model on odbcinst.ini (this configuration is supported only in this file). -Sample <filename>odbcinst.ini</> for threading model +unixODBC uses a strong thread-locking policy that causes big locks with the default configuration for &freetds;. Performance of multi-threaded applications can be affected because every operation is serialized. To avoid this problem, choose a threading model in odbcinst.ini. + + Sample <filename>odbcinst.ini</> for threading model -[FreeTDS] + [FreeTDS] Driver = /usr/local/freetds/lib/libtdsodbc.so Threading = 1 - - -Sample <filename>odbc.ini</> for threading model + + + + Sample <filename>odbc.ini</> for threading model -[Server1] + [Server1] Driver = FreeTDS Server = myServer1 Port = 1433 TDS_Version = 7.2 - - -You can use also a connection string like DRIVER=FreeTDS;SERVER=myServer1;PORT=1433;TDS_Version=7.2;. - + + + You can use also a connection string e.g. DRIVER=FreeTDS;SERVER=myServer1;PORT=1433;TDS_Version=7.2;. + + + Appending Dump Files +When running &freetds; with applications such as Apache/PHP it is often difficult to get a usable log file. Since each of the many httpd children opens the file at the beginning of its connection and closes it on connection close, they tend to stomp all over each other. In append mode, the log file is opened for append each time it is written to and then immediately closed. If you are experiencing problems when running under Apache (or similar application) use append mode to generate useful logs. + + Turning on Dump File Append mode in &freetdsconf; + + [mssql] + host = ntbox.mydomain.com + port = 1433 + tds version = 7.0 + dump file = /tmp/freetds.log + dump file append = yes + + - - Appending Dump Files - -When running &freetds; with applications such as Apache/PHP it is often difficult to get a usable log file. Since each of the many httpd children opens the file at the beginning of its connection and closes it on connection close, they tend to stomp all over each other. In append mode, the log file is opened for append each time it is written to and then immediately closed. If you are experiencing problems when running under Apache (or similar application) use append mode to generate useful logs. - - -Turning on Dump File Append mode in &freetdsconf; - -[mssql] - host = ntbox.mydomain.com - port = 1433 - tds version = 7.0 - dump file = /tmp/freetds.log - dump file append = yes - - - -In this example, the /tmp/freetds.log file will contain log entries for all processes using the Microsoft SQL Server server, identified by pid. - - -Because there will be one log file being opened and closed more or less continuously, there is going to be a negative impact on performance. Also, be advised that the log file will grow quite large. +In this example, the /tmp/freetds.log file will contain log entries for all processes using the Microsoft SQL Server server, identified by pid. + Because there will be one log file being opened and closed more or less continuously, there is going to be a negative impact on performance. Also, be advised that the log file will grow quite large. - -As an alternative to &freetds; logging, you might also consider using tcpdump or ethereal to log network packets. While not as useful as a TDS log, it can also help to identify problems. - - +As an alternative to &freetds; logging, you might also consider using tcpdump or wireshark to log network packets. While not as useful as a TDS log, it can also help to identify problems. + - + TDS Connection Pooling - -&freetds; 0.52 was the first to include a TDS Connection Pooling server. It lives in the src/pool directory. - - -The &freetds; connection pool is a server process, it acts just like a SQL Server. You can use any program to attach to it that you could use to attach to a real SQL Server. The pool in turn connects to the SQL Server and database you specify, and attempts to share these connections. See the README in the pool directory for a more detailed description of its inner workings. - - -To configure the pooling server, first make sure &freetds; has a working entry for the real SQL Server by connecting to it with SQSH or another program. - - -The &freetds; connection pool currently only supports TDS version 4.2. This restriction applies to both the client-to-pool and pool-to-server connections! + +&freetds; 0.52 was the first to include a TDS Connection Pooling server. It lives in the src/pool directory. + +The &freetds; connection pool is a server process, it acts just like a SQL Server. You can use any program to attach to it that you could use to attach to a real SQL Server. The pool in turn connects to the SQL Server and database you specify, and attempts to share these connections. See the README in the pool directory for a more detailed description of its inner workings. + +To configure the pooling server, first make sure &freetds; has a working entry for the real SQL Server by connecting to it with SQSH or another program. + The &freetds; connection pool currently only supports TDS version 4.2. This restriction applies to both the client-to-pool and pool-to-server connections! - -After FreeTDS has been installed, you will find an executable named tdspool in the /usr/local/bin directory (or whatever directory was specified with the configure - -Next, edit the pool.conf file in the &freetds;'s etc directory. The pool.conf file is formatted like the &freetdsconf; with a section name in brackets and options for each section in key/value pairs. - - -Just like the &freetdsconf; file there are two types of sections, a [global] section whose options affect all pools, and a section with the name of the pool for pool-specific options. The following options are supported and may appear in either section. - - - - -pool.conf settings - - - - Name - Possible Values - Default - Meaning - - - - - user - Any valid user - none - The username used to connect to the servername. - - - password - Any - none - The password of the user at the servername. - - - server - Any TDS 4.2 entry in the freetds.conf file - none - The alias from the freetds.conf file representing the servername that will be connected to. - - - database - Any valid database - User's default database - The database on the servername to use. - - - port - Any TCP port - none - Port on which tdspool will listen. - - - min pool conn - 1 or more - none - Minimum number of open connections to maintain to the servername. - - - max pool conn - 1 or more - none - Maximum number of open connections to open against the servername. - - - max member age - 0 (no limit) or a number of seconds - 0 - Maximum age of idle members before connection is closed. - - - -
    -
    - - -Now, let's put this into practice. - -pool.conf + +After FreeTDS has been installed, you will find an executable named tdspool in the /usr/local/bin directory (or whatever directory was specified with the configure + +Next, edit the pool.conf file in the &freetds;'s etc directory. The pool.conf file is formatted like the &freetdsconf; with a section name in brackets and options for each section in key/value pairs. + +Just like the &freetdsconf; file there are two types of sections, a [global] section whose options affect all pools, and a section with the name of the pool for pool-specific options. The following options are supported and may appear in either section. + + + pool.conf settings + + + + Name + Possible Values + Default + Meaning + + + + + user + Any valid user + none + The username used to connect to the servername. + + + password + Any + none + The password of the user at the servername. + + + server + Any TDS 4.2 entry in the freetds.conf file + none + The alias from the freetds.conf file representing the servername that will be connected to. + + + database + Any valid database + User's default database + The database on the servername to use. + + + port + Any TCP port + none + Port on which tdspool will listen. + + + min pool conn + 1 or more + none + Minimum number of open connections to maintain to the servername. + + + max pool conn + 1 or more + none + Maximum number of open connections to open against the servername. + + + max member age + 0 (no limit) or a number of seconds + 0 + Maximum age of idle members before connection is closed. + + + +
    + + +Now, let's put this into practice. + + pool.conf -[global] + [global] min pool conn = 5 max pool conn = 10 max member age = 120 - -[mypool] + + [mypool] user = webuser password = secret database = ebiz server = fooserv max pool conn = 7 port = 5000 - - -The [global] section defines that we will open 5 connections against the server initially, and will increase up to 10 as demand requires. These connections will be closed after being idle for 2 minutes (120 seconds), but only until there are 5 remaining open. - - -The [mypool] section defines a pool named mypool that will listen on port 5000. It will login to a SQL Server named fooserv using the user webuser and the ever so clever password of secret. Once logged in, the connections will use the database ebiz instead of webuser's default database. Also, since this SQL Server has a limited number of CALs (Client Access Licenses), we are restricting the maximum number of connections to 7, which overrides the global setting of 10. - - -Now you can run tdspool with the name of the pool you are serving. + +
    + The [global] section defines that we will open 5 connections against the server initially, and will increase up to 10 as demand requires. These connections will be closed after being idle for 2 minutes (120 seconds), but only until there are 5 remaining open.
    + +The [mypool] section defines a pool named mypool that will listen on port 5000. It will login to a SQL Server named fooserv using the user webuser and the ever so clever password of secret. Once logged in, the connections will use the database ebiz instead of webuser's default database. Also, since this SQL Server has a limited number of CALs (Client Access Licenses), we are restricting the maximum number of connections to 7, which overrides the global setting of 10. + +Now you can run tdspool with the name of the pool you are serving. -$ tdspool mypool - - - -Before your clients connect to the pool, you must edit your &freetdsconf; to include the host and port of the pooling server, and point your clients at it. - + $ tdspool mypool
    + +Before your clients connect to the pool, you must edit your &freetdsconf; to include the host and port of the pooling server, and point your clients at it.
    - - - stunnel HOWTO - - Contributed by Bradley Bell. - - -To set up FreeTDS over stunnel between a Linux webserver and a W2k SQL server: - - - - Get unencrypted freetds working - - Install openssl and stunnel on the Linux box: - stunnel.org - - - Download the stunnel binary and openssl dll's for Windows. - - - Generate stunnel.pem (complete with Diffie-Hellman parameters) for - placement on the W2k box. See instructions in the stunnel FAQ. - - - Start stunnel on the W2k box: - - $ stunnel.exe -d 61666 -r localhost:1433 - - - 61666 is just an arbitrary port number. - - - Start stunnel on the Linux box: - - - $ stunnel -c -d 1433 -r win2kserver:61666 - - where win2kserver is the hostname or IP address of the W2k box. - + + + stunnel HOWTO + +Contributed by Bradley Bell. + +To set up FreeTDS over stunnel between a Linux webserver and a W2k SQL server: + + + +Get unencrypted freetds working + + +Install openssl and stunnel on the Linux box: + stunnel.org + - Set up FreeTDS to use the tunnel. If this is your unencrypted entry in - &freetdsconf;: - - -Unencrypted entry in &freetdsconf; + +Download the stunnel binary and openssl dll's for Windows. + + + +Generate stunnel.pem (complete with Diffie-Hellman parameters) for + placement on the W2k box. See instructions in the stunnel FAQ. + + + +Start stunnel on the W2k box: + + $ stunnel.exe -d 61666 -r localhost:1433 + + +61666 is just an arbitrary port number. + + + +Start stunnel on the Linux box: + + $ stunnel -c -d 1433 -r win2kserver:61666 + +where win2kserver is the hostname or IP address of the W2k box. + + + +Set up FreeTDS to use the tunnel. If this is your unencrypted entry in + &freetdsconf;: + + Unencrypted entry in &freetdsconf; - [win2kserver] - host = win2kserver - port = 1433 - - - the encrypted equivalent uses: - - -Encrypted entry in &freetdsconf; + [win2kserver] + host = win2kserver + port = 1433 + + + + the encrypted equivalent uses: + + Encrypted entry in &freetdsconf; - [win2kserver] - host = localhost + [win2kserver] + host = localhost port = 1433 - - + + - +
    - - - Use &freetds; - &freetds; includes several utilities. Some are testing tools, some demonstration projects, some intended for day-to-day use. All have man pages. + + + Use &freetds; + &freetds; includes several utilities. Some are testing tools, some demonstration projects, some intended for day-to-day use. All have man pages. + + &freetds; Utilities</> - <sect1 id="utilities"><title>&freetds; Utilities</> - <variablelist><title>(listed alphabetically) - - bsqldb - - A non-interactive equivalent of the isql utility programs distributed by Sybase and Microsoft. Like them, bsqldb uses the command go on a line by itself as a separator between batches. The last batch need not be followed by go. + + bsqldb + - bsqldb makes use of the db-lib API. Intended for production use. - - - - bsqlodbc - - A non-interactive equivalent of the isql utility programs distributed by Sybase and Microsoft. Like them, bsqlodbc uses the command go on a line by itself as a separator between batches. The last batch need not be followed by go. It uses the ODBC API. + A non-interactive equivalent of the isql utility programs distributed by Sybase and Microsoft. Like them, bsqldb uses the command go on a line by itself as a separator between batches. The last batch need not be followed by go. + + +bsqldb makes use of the db-lib API. Intended for production use. + + + + bsqlodbc + - bsqlodbc is a demonstration project, but can also aid in isolating problems. ODBC applications typically have many layers, and it can be difficult to know if a problem arises in a layer, or in the interface between layers. By executing a query in bsqlodbc, you can see if the functionality of the ODBC driver works when used as the folks who wrote the driver thought it would be used. - - +A non-interactive equivalent of the isql utility programs distributed by Sybase and Microsoft. Like them, bsqlodbc uses the command go on a line by itself as a separator between batches. The last batch need not be followed by go. It uses the ODBC API. + +bsqlodbc is a demonstration project, but can also aid in isolating problems. ODBC applications typically have many layers, and it can be difficult to know if a problem arises in a layer, or in the interface between layers. By executing a query in bsqlodbc, you can see if the functionality of the ODBC driver works when used as the folks who wrote the driver thought it would be used. + + + + + datacopy + +A tool for migrating data between Sybase ASE and SQL Server or vice versa. + - - datacopy - - A tool for migrating data between Sybase ASE and SQL Server or vice versa. +datacopy will move table data from one server to another without the need for intermediate files. datacopy is much faster and more efficient than is freebcp out/in. - datacopy will move table data from one server to another without the need for intermediate files. datacopy is much faster and more efficient than is freebcp out/in. datacopy makes use of the db-lib bcp API. - - - - - defncopy - - Replaces a similar program of the same name distributed by Sybase. - - defncopy reads the text of a stored procedure or view, and writes a script suitable for recreating the procedure or view. For tables, it reads the output of sp_help and constructs a CREATE TABLE statement, complete with CREATE INDEX, too. - - - - - fisql - - A complete replacement of the isql utility programs distributed by Sybase and Microsoft. Like them, fisql uses the command go on a line by itself as a separator between batches. - - - - - freebcp - - Replicates the functionality of the bcp utility programs distributed by Sybase and Microsoft. - freebcp makes use of the db-lib bcp API. - The manual pages or online help for Sybase or SQL Server can be referenced for more detailed information on bcp functionality. - - - - - osql - - A Bourne shell script that checks and reports on your configuration. - - - - - tsql - - A diagnostic tool that uses uses the lowest level FreeTDS library, libtds, as a way to isolate potential bugs in the protocol implementation. - tsql is not a replacement for a complete isql. - - - - - + + + + + defncopy + + +Replaces a similar program of the same name distributed by Sybase. + + +defncopy reads the text of a stored procedure or view, and writes a script suitable for recreating the procedure or view. For tables, it reads the output of sp_help and constructs a CREATE TABLE statement, complete with CREATE INDEX, too. + + + + + fisql + + +A complete replacement of the isql utility programs distributed by Sybase and Microsoft. Like them, fisql uses the command go on a line by itself as a separator between batches. + + + + + freebcp + + +Replicates the functionality of the bcp utility programs distributed by Sybase and Microsoft. +freebcp makes use of the db-lib bcp API. + +The manual pages or online help for Sybase or SQL Server can be referenced for more detailed information on bcp functionality. + + + + + osql + + +A Bourne shell script that checks and reports on your configuration. + + + + + tsql + +A diagnostic tool that uses uses the lowest level FreeTDS library, libtds, as a way to isolate potential bugs in the protocol implementation. +tsql is not a replacement for a complete isql. + + + +
    + + + + How to get what works with it working - - - How to get what works with it working - -The following programs are known to work to some extent with &freetds;. Here you will find any special instructions for getting them compiled or running. - - - <application>SQSH</application> - -SQSH is a command line based query tool written by Scott Gray to replace the isql utility that ships with Sybase ASE. It makes a great diagnostic tool for &freetds; as well. If you are having trouble, install SQSH (it's easy) and try getting that to work before more complicated arrangements. +The following programs are known to work to some extent with &freetds;. Here you will find any special instructions for getting them compiled or running. + + <application>SQSH</application> - That advice is so good, it bears repeating. If you are having trouble, grab SQSH and get that to work. Not only will it help isolate the problem, it will give you a very capable tool. +SQSH is a command line based query tool written by Scott Gray to replace the isql utility that ships with Sybase ASE. It makes a great diagnostic tool for &freetds; as well. If you are having trouble, install SQSH (it's easy) and try getting that to work before more complicated arrangements. + + SQSH is an excellent tool. Because it uses &ctlib;, it works with &freetds;, but potentially — and with significant effort — it could be ported to ODBC and thus made useful for other server environments. Just a thought…. + - +SQSH 2.1 includes direct support for &freetds;, so these instructions may not be necessary, but are still included just in case. - -SQSH 2.1 includes direct support for &freetds;, so these instructions may not be necessary, but are still included just in case. - - -After running configure in SQSH's directory (make sure you set the Sybase environment variable first), look for the Sybase_LIBS definition in the Makefile. Change the line to match this example. - -The <application>SQSH</application> Makefile +After running configure in SQSH's directory (make sure you set the Sybase environment variable first), look for the Sybase_LIBS definition in the Makefile. Change the line to match this example. + + The <application>SQSH</application> Makefile -# -# The following set of CT-LIB libraries were determined automatically -# by 'configure'. For most systems configure looks up the required -# libraries by looking at the name of the OS (although this doesn't -# mean it got them right), however if the line below ends with the -# word "Guess", then 'configure' didn't have an entry for your operating -# system and it took a best guess to figure out which libraries you -# need. In either case, there may be problems, so look this line over -# and if it doesn't work, compare it to the libraries located in -# $SYBASE/samples/ct-library. -# -# The listings below show suggested libraries for Operating Systems -# that frequently fail to be recognized by 'configure': -# -# SCO: -lblk -lct -lcs -lcomn -ltcl -ltli -lnsl_s -lintl -m -lsocket -# Dynix: -lblk -lct -lcs -lcomn -ltcl -ltli -lnsl -lintl -lm -lseq -# -SYBASE_LIBS = -lct -ldl -lm - - -At this point you can also enable readline support if you didn't specify it in the configure arguments. - - -After that just type make and you are off and running. - + # + # The following set of CT-LIB libraries were determined automatically + # by 'configure'. For most systems configure looks up the required + # libraries by looking at the name of the OS (although this doesn't + # mean it got them right), however if the line below ends with the + # word "Guess", then 'configure' didn't have an entry for your operating + # system and it took a best guess to figure out which libraries you + # need. In either case, there may be problems, so look this line over + # and if it doesn't work, compare it to the libraries located in + # $SYBASE/samples/ct-library. + # + # The listings below show suggested libraries for Operating Systems + # that frequently fail to be recognized by 'configure': + # + # SCO: -lblk -lct -lcs -lcomn -ltcl -ltli -lnsl_s -lintl -m -lsocket + # Dynix: -lblk -lct -lcs -lcomn -ltcl -ltli -lnsl -lintl -lm -lseq + # + SYBASE_LIBS = -lct -ldl -lm + + + At this point you can also enable readline support if you didn't specify it in the configure arguments. + +After that just type make and you are off and running. + + + Perl - - Perl - There are a few ways to use Perl to connect to a SQL Server using &freetds;. - +There are a few ways to use Perl to connect to a SQL Server using &freetds;. + DBD::Sybase - The recommended choice is DBD::Sybase from Michael Peppler. Despite the name it works for any Sybase or Microsoft SQL Server. DBD::Sybase uses the ct-lib API and works well. - - + +The recommended choice is DBD::Sybase from Michael Peppler. Despite the name it works for any Sybase or Microsoft SQL Server. DBD::Sybase uses the &ctlib; API and works well. + + DBD::ODBC - -You may also use DBD::ODBC with the &freetds; ODBC driver. You may find this attractive if you're familiar with DBD::ODBC. - - + +You may also use DBD::ODBC with the &freetds; ODBC driver. You may find this attractive if you're familiar with DBD::ODBC. + Sybperl - -Finally, you can use Sybperl. Scripts written against Sybperl will not run against other databases the way DBI scripts will. However, it will be familiar ground for those who know db-lib. - - + +Finally, you can use Sybperl. Scripts written against Sybperl will not run against other databases the way DBI scripts will. However, it will be familiar ground for those who know &dblib;. + Building and using the Perl modules - - - - Building <systemitem class="library">DBD::Sybase</systemitem> - -$ cd DBD-Sybase-0.91 -$ export SYBASE=/usr/local/freetds -$ perl Makefile.PL -$ make -$ su root -Password: -$ make install - - -There will be some output about missing libraries after perl Makefile.PL. These are normal. - - -The following example will attach to Sybase's public JDBC server and run a simple query (it can be found in samples/test.pl): + + Building <systemitem class="library">DBD::Sybase</systemitem> + + $ cd DBD-Sybase-0.91 + $ export SYBASE=/usr/local/freetds + $ perl Makefile.PL + $ make + $ su root + Password: + $ make install + + + There will be some output about missing libraries after perl Makefile.PL. These are normal. -Connect to a server with <systemitem class="library">DBD::Sybase</systemitem> +The following example will attach to Sybase's public JDBC server and run a simple query (it can be found in samples/test.pl): + + Connect to a server with <systemitem class="library">DBD::Sybase</systemitem> -#!/usr/local/bin/perl -# -use DBI; - -my $dbh = DBI->connect("dbi:Sybase:server=JDBC", 'guest', 'sybase', {PrintError => 0}); - -die "Unable for connect to server $DBI::errstr" - unless $dbh; - -my $rc; -my $sth; + #!/usr/local/bin/perl + # + use DBI; + + my $dbh = DBI->connect("dbi:Sybase:server=JDBC", 'guest', 'sybase', {PrintError => 0}); + + die "Unable for connect to server $DBI::errstr" + unless $dbh; + + my $rc; + my $sth; + + $sth = $dbh->prepare("select \@\@servername"); + if($sth->execute) { + while(@dat = $sth->fetchrow) { + print "@dat\n"; + } + } + + -$sth = $dbh->prepare("select \@\@servername"); -if($sth->execute) { - while(@dat = $sth->fetchrow) { - print "@dat\n"; - } -} - - - - - - Building <systemitem class="library">DBD::ODBC</systemitem> + + Building <systemitem class="library">DBD::ODBC</systemitem> -$ cd DBD-ODBC-0.28 -$ export SYBASE=/usr/local/freetds -$ export ODBCHOME=/usr/local -$ export DBI_DSN=dbi:ODBC:JDBC -$ export DBI_USER=guest -$ export DBI_PASS=sybase -$ perl Makefile.PL -$ make -$ su root -Password: -$ make install - - -We used the public JDBC server logins for our configuration here. You'll want to replace these with ones suitable to your environment. - - -Connect to a server with <systemitem class="library">DBD::ODBC</systemitem> + $ cd DBD-ODBC-0.28 + $ export SYBASE=/usr/local/freetds + $ export ODBCHOME=/usr/local + $ export DBI_DSN=dbi:ODBC:JDBC + $ export DBI_USER=guest + $ export DBI_PASS=sybase + $ perl Makefile.PL + $ make + $ su root + Password: + $ make install + + We used the public JDBC server logins for our configuration here. You'll want to replace these with ones suitable to your environment. + + + Connect to a server with <systemitem class="library">DBD::ODBC</systemitem> -#!/usr/local/bin/perl -# -use DBI; + #!/usr/local/bin/perl + # + use DBI; + + my $dbh = DBI->connect("dbi:ODBC:JDBC", 'guest', 'sybase', {PrintError => 0}); + + die "Unable for connect to server $DBI::errstr" + unless $dbh; + + my $rc; + my $sth; + + $sth = $dbh->prepare("select \@\@servername"); + if($sth->execute) { + while(@dat = $sth->fetchrow) { + print "@dat\n"; + } + } + + + You'll note this is the same program as for DBD::Sybase with the exception of the connect statement, welcome to the magic of DBI! + + + + + PHP -my $dbh = DBI->connect("dbi:ODBC:JDBC", 'guest', 'sybase', {PrintError => 0}); +There are three options for building PHP with support for &freetds; corresponding to the three APIs that &freetds; supports: &dblib;, &ctlib;, and ODBC. + All these examples build the CGI version. Consult PHP's documentation for building the Apache module and including other extensions. + + &dblib; -die "Unable for connect to server $DBI::errstr" - unless $dbh; +PHP can be configured with &dblib; access for a "Sybase" server (which also works with Microsoft servers), or with the mssql extension, intended exclusively for Microsoft servers. -my $rc; -my $sth; +PHP and &dblib; for <quote>Sybase</> -$sth = $dbh->prepare("select \@\@servername"); -if($sth->execute) { - while(@dat = $sth->fetchrow) { - print "@dat\n"; - } -} - - -You'll note this is the same program as for DBD::Sybase with the exception of the connect statement, welcome to the magic of DBI! - - - - - - PHP - -There are three options for building PHP with support for &freetds; corresponding to the three APIs that &freetds; supports: db-lib, ct-lib, and ODBC. -All these examples build the CGI version. Consult PHP's documentation for building the Apache module and including other extensions. - - - <systemitem class="library">db-lib</systemitem> - -PHP can be configured with db-lib access for a "Sybase" server (which also works with Microsoft servers), or with the mssql extension, intended exclusively for Microsoft servers. - - -PHP and <systemitem class="library">db-lib</systemitem> for <quote>Sybase</> - First build &freetds; normally. +First build &freetds; normally. -$ ./configure --prefix=/usr/local/freetds -$ make -$ su root -Password: -$ make install - - Then build PHP with support for Sybase + $ ./configure --prefix=/usr/local/freetds + $ make + $ su root + Password: + $ make install + +Then build PHP with support for Sybase -$ cd php -$ ./configure --with-sybase=/usr/local/freetds -$ make -$ su root -Password: -$ make install - - And that's it! - - - + $ cd php + $ ./configure --with-sybase=/usr/local/freetds + $ make + $ su root + Password: + $ make install + +And that's it! + + - <systemitem class="library">ct-lib</systemitem> - -Option 2 is to use the ct-lib API. Again here, we run into minor difficulties at build time. Applications linking with Sybase's OpenClient have to link in a handful of libraries and these libraries vary slightly from platform to platform. When creating &freetds; it was decided that there would be only one library: libct. This saves a great deal of library naming conflicts that Sybase ran into (e.g. libtcl is used both by Sybase and the language TCL), however some applications like PHP assume that all the Sybase libraries will be present. So, some hand editing of the Makefile is necessary to remove these extra libs. Build &freetds; just as you would for db-lib in - with db-lib, above. Then configure PHP with ct-lib. - -$ cd php -$ ./configure --with-sybase-ct=/usr/local/freetds - -Now edit the Zend/Makefile looking for the libZend_la_LDFLAGS line and remove -lsybtcl -lintl -lcomn and -lcs, leaving the -lct. Then proceed to make and install PHP. + &ctlib; + +Option 2 is to use the &ctlib; API. Again here, we run into minor difficulties at build time. Applications linking with Sybase's OpenClient have to link in a handful of libraries and these libraries vary slightly from platform to platform. When creating &freetds; it was decided that there would be only one library: libct. This saves a great deal of library naming conflicts that Sybase ran into (e.g. libtcl is used both by Sybase and the language TCL), however some applications like PHP assume that all the Sybase libraries will be present. So, some hand editing of the Makefile is necessary to remove these extra libs. Build &freetds; just as you would for &dblib; in + with &dblib;, above. Then configure PHP with &ctlib;. + + $ cd php + $ ./configure --with-sybase-ct=/usr/local/freetds + Now edit the Zend/Makefile looking for the libZend_la_LDFLAGS line and remove -lsybtcl -lintl -lcomn and -lcs, leaving the -lct. Then proceed to make and install PHP. -$ make -$ su root -Password: -$ make install - -We hope an upcoming version of PHP will automatically detect the presence of &freetds; and include only the -lct library. - - - - <systemitem class="library">ODBC</systemitem> - -The third and newest option is to use the &freetds; ODBC driver with PHP. First build the iODBC or unixODBC driver manager and &freetds; as detailed in this guide. Then build PHP with support for ODBC. + $ make + $ su root + Password: + $ make install + We hope an upcoming version of PHP will automatically detect the presence of &freetds; and include only the -lct library. + + + <systemitem class="library">ODBC</systemitem> + +The third and newest option is to use the &freetds; ODBC driver with PHP. First build the iODBC or unixODBC driver manager and &freetds; as detailed in . Then build PHP with support for ODBC. -$ cd php -$ ./configure --with-iodbc=/usr/local -$ make -$ su root -Password: -$ make install - -Now everything should run. There is a sample PHP script in the &freetds; samples directory called odbctest.php. - - - - - SybSQL - -SybSQL is a Qt-based GUI interface to Sybase databases that uses the db-lib API. - - -SybSQL has a fairly basic build process that simply uses a Makefile. In order for SybSQL to find Qt and &freetds; you need to define QTDIR and SYBASE environment variables. If you have Qt installed, you may have QTDIR defined already. To verify, type echo $QTDIR at the shell prompt. This example uses my own installation path of qt-2.3.1 (from RedHat 7.2), YMMV. + $ cd php + $ ./configure --with-iodbc=/usr/local + $ make + $ su root + Password: + $ make install + Now everything should run. There is a sample PHP script in the &freetds; samples directory called odbctest.php. + + + + SybSQL + +SybSQL is a Qt-based GUI interface to Sybase databases that uses the &dblib; API. + +SybSQL has a fairly basic build process that simply uses a Makefile. In order for SybSQL to find Qt and &freetds; you need to define QTDIR and SYBASE environment variables. If you have Qt installed, you may have QTDIR defined already. To verify, type echo $QTDIR at the shell prompt. This example uses my own installation path of qt-2.3.1 (from RedHat 7.2), YMMV. -$ export QTDIR=/usr/lib/qt-2.3.1 -$ export SYBASE=/usr/local -$ make - -When finished you'll have an executable named sybsql that you can run. - - -One caveat to the way in which SybSQL and &freetds; interact is that SybSQL expects to be running under OpenClient, and makes the assumption that a valid $SYBASE/interfaces file exists. Since &freetds; has deprecated use of the interfaces file in favor of the &freetdsconf; config file, you may have to create a interfaces file just to satisfy SybSQL. - - -By defining SYBASE to the parent directory of the interfaces file, you may put it wherever you like; it does not have to be in /usr/local. When using &freetdsconf;, &freetds; does not rely on the SYBASE variable for finding its own components, so it is safe to point it elsewhere. - + $ export QTDIR=/usr/lib/qt-2.3.1 + $ export SYBASE=/usr/local + $ make + When finished you'll have an executable named sybsql that you can run. + +One caveat to the way in which SybSQL and &freetds; interact is that SybSQL expects to be running under OpenClient, and makes the assumption that a valid $SYBASE/interfaces file exists. Since &freetds; has deprecated use of the interfaces file in favor of the &freetdsconf; config file, you may have to create a interfaces file just to satisfy SybSQL. + +By defining SYBASE to the parent directory of the interfaces file, you may put it wherever you like; it does not have to be in /usr/local. When using &freetdsconf;, &freetds; does not rely on the SYBASE variable for finding its own components, so it is safe to point it elsewhere. - - Python - -Your humble author is not enlightened enough to use Python, and the information contained in this section is a little rough. Please contact the list for more assistance or (better yet) to improve these instructions. - - -Install distutils if you haven't already. - -$ tar xvfz distutils-latest.tgz -$ cd distutils -$ python setup.py install - - - -You can obtain the Python Sybase module here. This example uses version 0.34, the most current at the time of this writing, please adjust accordingly if using a different version. + + Python + Your humble author is not enlightened enough to use Python, and the information contained in this section is a little rough. Please contact the list for more assistance or (better yet) to improve these instructions. + + +Install distutils if you haven't already. -$ tar xvfz sybase-0.34.tgz -$ cd sybase-0.34 -$ export SYBASE=/usr/local/freetds -$ export CFLAGS="-DHAVE_FREETDS" -$ export LD_LIBRARY_PATH=/usr/local/freetds/lib:${LD_LIBRARY_PATH} -$ python setup.py install - -Edit the example.py and fix the bottom stuff, FreeTDS lacks the 110 -symbols for version use 100 + $ tar xvfz distutils-latest.tgz + $ cd distutils + $ python setup.py install + +You can obtain the Python Sybase module here. This example uses version 0.34, the most current at the time of this writing, please adjust accordingly if using a different version. + + $ tar xvfz sybase-0.34.tgz + $ cd sybase-0.34 + $ export SYBASE=/usr/local/freetds + $ export CFLAGS="-DHAVE_FREETDS" + $ export LD_LIBRARY_PATH=/usr/local/freetds/lib:${LD_LIBRARY_PATH} + $ python setup.py install + Edit the example.py and fix the bottom stuff, FreeTDS lacks the 110 + symbols for version use 100 -$ python example.py - - - + $ python example.py + + + + Qt - - Qt - Qt has two driver to access SQL Server databases: QTDS and QODBC. - At the time of writing (January 2010) QTDS has a performance problem cause it does not reuse connection but do a connection for every query so use QODBC. - - There are however some problems with wide character support on Qt. Qt assume sizeof(SQLWCHAR) == 2 however using some DM (like iODBC using Linux which is the default setting on Ubuntu) which could lead to wrong characters conversion. - +Qt has two drivers to access SQL Server databases: QTDS and QODBC. + At the time of writing (January 2010) QTDS has a performance problem because rather than maintaining a connection, it instead re-connects for every query. So use QODBC. + +There are however some problems with wide character support on Qt because Qt assumes sizeof(SQLWCHAR) == 2. On some DMs, though — including iODBC, the default on Ubuntu — sizeof(SQLWCHAR) == 4, which could lead to invalid character conversion. + + + ODBC on Unix - - ODBC on Unix - ODBC have many issues under Unix mainly due to lack of specifications. - - - ODBC and 64-bit - On first specifications ODBC was only 32-bit. Converting it to 64-bit there was not good specification which leads to wrong declarations and problems. For instance some SQLINTEGER are used for pointer offsets specification but SQLINTEGER was 32-bit while pointer offsets must be 64-bit. Also row numbers and other stuffs are now 64-bit. - - If you use unixODBC I would recommend at least version 2.2.14. Former versions have issues if used on 64-bit environments. +ODBC have many issues under Unix mainly due to lack of specifications. + + ODBC and 64-bit + +ODBC was originally specified as 32-bitIn fact, the earliest versions were 16-bit.. Its evolution to 64-bit took place in the absence of a good specification which led to conflicting declarations and associated problems. For instance, some parameters are defined as SQLINTEGER but are used for pointer offsets. But SQLINTEGER was (and remains) 32-bit, while pointer offsets must be 64-bit. Also row numbers and some other formerly 32-bity quantities are now 64-bit. + +If you use unixODBC Frediano would recommend at least version 2.2.14. Earlier versions have issues if used on 64-bit environments. - - sizeof(SQLWCHAR) - Under Windows you have sizeof(wchar_t) == sizeof(SQLWCHAR) == 2 but on many Unix systems you have sizeof(wchar_t) == 4. The problem is that some DM decided to keep sizeof(SQLWCHAR) == 2 (like unixODBC) while in other DM sizeof(SQLWCHAR) == sizeof(wchar_t) == 4 (like iODBC). This leads to ABI imcompatibility between applications and drivers. If you compile &freetds; ODBC driver using iODBC on such systems (like Linux) do not use the driver using unixODBC and viceversa. - - You can compile &freetds; with both includes and rename the library to use two ABI (for instance having a libtdsiodbc.so and a libtdsuodbc.so). - - As the time of writing Ubuntu compiled Qt using iODBC but mostly packages use unixODBC. If you plan to use Qt using &freetds; ODBC driver you should have a iODBC compatible driver. Also QODBC Qt driver have problems with iODBC and SQLWCHAR (see Qt). Due to these problems I would suggest to not use this configuration (Qt database) on Ubuntu. - + + sizeof(SQLWCHAR) + +Under Windows sizeof(wchar_t) == sizeof(SQLWCHAR) == 2 but on many Unix systems you have sizeof(wchar_t) == 4. And some DMs decided to keep sizeof(SQLWCHAR) == 2 (including unixODBC) while in other DM sizeof(SQLWCHAR) == sizeof(wchar_t) == 4 (namely iODBC). This leads to incompatibile ABIs between applications and drivers. If you compile the &freetds; ODBC driver using iODBC take care to ensure all drivers are compiled with the same header files. + +Alternatively, compile &freetds; with both includes and rename the library to use two ABIs (for instance having a libtdsiodbc.so and a libtdsuodbc.so). + +As of the time of writing Ubuntu compiled Qt using iODBC but most packages use unixODBC. If you plan to use Qt with the &freetds; ODBC driver, you should have an iODBC-compatible driver. Also be aware that the QODBC Qt driver has problems with iODBC and SQLWCHAR (see Qt). Due to these problems Frediano suggests not to use this configuration (Qt database) on Ubuntu at this time. - - Default charset - Is not possible to specify charset under ODBC and there was not so clear specifications. For this reason by default many DM converting from multi-byte to wide characters assume ISO8859-1 charset. For this reason even &freetds; driver assume ISO8859-1 by default. Also some DM have problems converting multi-byte encodings (like UTF-8) assuming a byte get converted to a single wide character (and viceversa). This can create problems if you use multi-byte encoding for &freetds; driver. - + + Default charset + +Character encoding is yet another trap. ODBC makes no provision for specifying client character encoding. By default many DM converting from multi-byte to wide characters assume the client uses ISO 8859-1. Even the &freetds; driver assumes ISO 8859-1 by default. Also some DM have problems converting multi-byte encodings (like UTF-8), by assuming a byte can be converted to a single wide character (and vice versa). That creates problems if you use multi-byte encoding for &freetds; driver. - - + - - - Troubleshooting - -Jason Mewes (Mall Rats) + + + Troubleshooting + + Jason Mewes (Mall Rats) + He's like motherf**king McGuiver, no he's better than McGuiver! - - - Known Issues - - <type>Text</type> Fields - -Questions sometimes arise over large varchar types (anything larger than varchar(255)) that became available with Microsoft SQL Server 7.0. When accessing long varchars with TDS protocol version 4.2 or 5.0, these fields will be truncated to 255 characters, due to limitations inherent in the protocol definition. Your best bet in that case is to convert them to text types. - - -In Microsoft SQL Server 7.0 and later, varchar types can hold up to 8000 bytes (8000 ASCII characters or 4000 Unicode characters). To move these large varchars through TDS 4.2, convert them with either a CONVERT as in, - -SELECT mycol = convert(mycol, text) FROM mytable -or with the newer SQL92 CAST syntax e.g., - -SELECT CAST(mycol as TEXT) FROM mytable - - -A related problem is that some people have reported problems with text field using TDS version 7.0. One known workaround is to convert long strings to varchar(8000) in your query text with CAST( variable_name as varchar(8000) ) as variable_name. Text datatype handling is fixed in &freetds; 0.60, except for bcp operations. - - -There is also a bug (Lions and tigers and bugs! Oh, my!) in Microsoft's implementation of text fields. Disregardless [sic] of their documentation, you must explicitly set the value of TEXTSIZE, else the text fields will be represented to have a maximum size of 4 gigabytes or so. The usual manifestation is some sort of spurious out of memory error or segment fault. To avoid this, set TEXTSIZE to some reasonable value before querying any TEXT fields. For example, in isql: + + + Known Issues + + <type>Text</type> Fields + +Questions sometimes arise over large varchar types (anything larger than varchar(255)) that became available with Microsoft SQL Server 7.0. When accessing long varchars with TDS protocol version 4.2 or 5.0, these fields will be truncated to 255 characters, due to limitations inherent in the protocol definition. Your best bet in that case is to convert them to text types. + +In Microsoft SQL Server 7.0 and later, varchar types can hold up to 8000 bytes (8000 ASCII characters or 4000 Unicode characters). To move these large varchars through TDS 4.2, convert them with either a CONVERT as in, + + SELECT mycol = convert(mycol, text) FROM mytable + or with the newer SQL92 CAST syntax e.g., -1>set TEXTSIZE 10000 -2>go - + SELECT CAST(mycol as TEXT) FROM mytable -Another way to handle control the default TEXTSIZE is to use the setting in &freetdsconf;. - +A related problem is that some people have reported problems with text field using TDS version 7.0. One known workaround is to convert long strings to varchar(8000) in your query text with CAST( variable_name as varchar(8000) ) as variable_name. Text datatype handling is fixed in &freetds; 0.60, except for bcp operations. + +There is also a bug (Lions and tigers and bugs! Oh, my!) in Microsoft's implementation of text fields. Disregardless [sic] of their documentation, you must explicitly set the value of TEXTSIZE, else the text fields will be represented to have a maximum size of 4 gigabytes or so. The usual manifestation is some sort of spurious out of memory error or segment fault. To avoid this, set TEXTSIZE to some reasonable value before querying any TEXT fields. For example, in isql: + + 1>set TEXTSIZE 10000 + 2>go + + Another way to handle control the default TEXTSIZE is to use the setting in &freetdsconf;. - Endianism - -If either your server or your client is a big endian system, pay careful attention to all references to endianism anywhere near &freetds;. See the section on Little Endian Emulation for details. - - - - <type>Datetime</type> and <type>Money</type> - -Big endian clients may experience difficulty with Microsoft servers. Some versions of SQL Server 7 did not handle these types on these machines correctly, according to the protocol. According to - http://support.microsoft.com/support/kb/articles/Q254/1/23.ASP on the Microsoft support site, it's fixed as of service pack 3. Unfortunately, there's no direct way for &freetds; to know whether or not a service pack has been installed, and how/whether to support the buggy version is an outstanding issue. Your best bet is to apply their patch. - The Knowledge Base article states The Sybase CT-Lib client is the only known big-endian client that can connect to SQL Server. Depends on who's doing the knowing, of course. - + Endianism + +If either your server or your client is a big endian system, pay careful attention to all references to endianism anywhere near &freetds;. See the section on Little Endian Emulation for details. - - Microsoft's <quote>Integrated Security</quote> - -&freetds; may be unable to connect to the server. The error message that appears will be "Login failed for user 'example'. Reason: Not associated with a trusted SQL Server connection". To solve this, turn on SQL Server authentication: - + + <type>Datetime</type> and <type>Money</type> + +Big endian clients may experience difficulty with Microsoft servers. Some versions of SQL Server 7 did not handle these types on these machines correctly, according to the protocol. According to + http://support.microsoft.com/support/kb/articles/Q254/1/23.ASP on the Microsoft support site, it's fixed as of service pack 3. Unfortunately, there's no direct way for &freetds; to know whether or not a service pack has been installed, and how/whether to support the buggy version is an outstanding issue. Your best bet is to apply their patch. + The Knowledge Base article states The Sybase CT-Lib client is the only known big-endian client that can connect to SQL Server. Depends on who's doing the knowing, of course. + + + Microsoft's <quote>Integrated Security</quote> + +&freetds; may be unable to connect to the server. The error message that appears will be "Login failed for user 'example'. Reason: Not associated with a trusted SQL Server connection". To solve this, turn on SQL Server authentication: - -Open the SQL Server Enterprise Manager, - - -Select the server, - - -Right mouse click and choose Properties. A properties window will appear. - - -Choose the Security tab. The security properties will be displayed. - - -Change the Authentication field to SQL Server and Windows, - - -Apply the changes and try again. - - - -These instructions apply to Microsoft SQL Server 7 and SQL Server 2000. - + Open the SQL Server Enterprise Manager, + + Select the server, + + Right mouse click and choose Properties. A properties window will appear. + + Choose the Security tab. The security properties will be displayed. + + Change the Authentication field to SQL Server and Windows, + + Apply the changes and try again. + + + +These instructions apply to Microsoft SQL Server 7 and SQL Server 2000. <productname>SQL Server</productname>'s Security Model - -Microsoft supports two security models in three permutations: - - Windows NT Authentication Mode. The operating system performs authentication; users will not have explicit SQL Server accounts. - - Standard Mode. SQL Server authenticates connections itself without consulting the operating system. Users of course need SQL Server accounts to log in. - - Mixed Mode Combines the above two. - - -For normal operation, you need either Standard or Mixed mode. - - -Windows NT Authentication, often called integrated security, -relies on Microsoft's domain login. In it, a user's network security attributes are established at network login time. When connecting to the database server, SQL -Server uses the facilities of the host operating system (Windows NT or similar) to determine the authenticated network username. -SQL Server then permits or denies login access based on that network -username alone, without requiring a separate login name and password. - - -The &freetds; supports integrated security mode. If you have SQL Server running in integrated (domain) mode along with a Windows PDC, and wish to try it, see Domain Logins in the Advanced Configurations chapter. If you have Active Directory you can also use Kerberos, see Kerberos support. +Microsoft supports two security models in three permutations: + + + Windows NT Authentication Mode. The operating system performs authentication; users will not have explicit SQL Server accounts. + + Standard Mode. SQL Server authenticates connections itself without consulting the operating system. Users of course need SQL Server accounts to log in. + + Mixed Mode Combines the above two. + + + For normal operation, you need either Standard or Mixed mode. + +Windows NT Authentication, often called integrated security, + relies on Microsoft's domain login. In it, a user's network security attributes are established at network login time. When connecting to the database server, SQL + Server uses the facilities of the host operating system (Windows NT or similar) to determine the authenticated network username. + SQL Server then permits or denies login access based on that network + username alone, without requiring a separate login name and password. + The &freetds; supports integrated security mode. If you have SQL Server running in integrated (domain) mode along with a Windows PDC, and wish to try it, see Domain Logins in the Advanced Configurations chapter. If you have Active Directory you can also use Kerberos, see Kerberos support. - -&freetds; supports the traditional database -security model, which Microsoft terms SQL Server -Authentication but is frequently known as standard -security. Username+Password pairs have to be passed to the -server explicitly. - - -Mixed Mode allows users to connect using either authentication -method. Users who connect through a Windows NT account can make use -of trusted connections in either Windows NT Authentication Mode or -Mixed Mode. After successful connection to SQL -Server, the security mechanism is the same for both -modes. - - + +&freetds; supports the traditional database + security model, which Microsoft terms SQL Server + Authentication but is frequently known as standard + security. Username+Password pairs have to be passed to the + server explicitly. + +Mixed Mode allows users to connect using either authentication + method. Users who connect through a Windows NT account can make use + of trusted connections in either Windows NT Authentication Mode or + Mixed Mode. After successful connection to SQL + Server, the security mechanism is the same for both + modes. + - - Is the server there? - - Start with <command>ping</> - -First ping the host to make sure you can talk to the machine the server resides on. - - - Finding the server's host + + Is the server there? + + Start with <command>ping</> + +First ping the host to make sure you can talk to the machine the server resides on. + + + Finding the server's host -$ ping -c1 myhost - -PING myhost (127.0.0.1) from 127.0.0.1 : 56(84) bytes of data. -64 bytes from myhost (127.0.0.1): icmp_seq=0 ttl=255 time=250 usec - - - -A successful ping shows that your network isn't preventing you from reaching the machine hosting the server. - - - - Test with <command>telnet</> - -Attempt to telnet to the port, to verify that the servername is listening. - - Finding the server + $ ping -c1 myhost + + PING myhost (127.0.0.1) from 127.0.0.1 : 56(84) bytes of data. + 64 bytes from myhost (127.0.0.1): icmp_seq=0 ttl=255 time=250 usec + + + A successful ping shows that your network isn't preventing you from reaching the machine hosting the server. + + + Test with <command>telnet</> + +Attempt to telnet to the port, to verify that the servername is listening. + + Finding the server -$ telnet myhost 1433 - -Trying 127.0.0.1... -Connected to myhost. -Escape character is '^]'. - - - -If you get output as above, the servername is listening. If you get a 'Connection Refused' message, you're talking to the wrong host, wrong port, or the servername is down. + $ telnet myhost 1433 + + Trying 127.0.0.1... + Connected to myhost. + Escape character is '^]'. + + + If you get output as above, the servername is listening. If you get a 'Connection Refused' message, you're talking to the wrong host, wrong port, or the servername is down. To exit telnet: When connected, telnet's command mode may be entered by - typing the telnet escape character (initially Ctrl-], as above). Once in command mode, telnet may be exited with the command quit. - - - - - Test with <command>tsql</> - -tsql can be run in two ways, one which uses &freetdsconf; and one which connects directly using the host and port. First attempt a connection using host and port. - - Connecting to the server, bypassing &freetdsconf; + typing the telnet escape character (initially Ctrl-], as above). Once in command mode, telnet may be exited with the command quit. + + + + Test with <command>tsql</> + +tsql can be run in two ways, one which uses &freetdsconf; and one which connects directly using the host and port. First attempt a connection using host and port. + + Connecting to the server, bypassing &freetdsconf; -$ cd src/apps -$ TDSVER=7.0 ./tsql -H myhost -p 1433 -U user - - -If you receive a message of 'Login Failed.' then your connectivity is OK, but you have a authentication issue. - - -If you receive a message like + $ cd src/apps + $ TDSVER=7.0 ./tsql -H myhost -p 1433 -U user + + If you receive a message of 'Login Failed.' then your connectivity is OK, but you have a authentication issue. + +If you receive a message like - - Msg. No.: 18450 Severity: 14 State: 1 Login failed- User: loginid Reason: Not defined as a valid user of a trusted SQL Server connection - - -SQL Server is accepting only domain logins. This applies only to Microsoft SQL Server and you'll need to have your DBA verify that server logins are allowed, or use a domain login. + + Msg. No.: 18450 Severity: 14 State: 1 Login failed- User: loginid Reason: Not defined as a valid user of a trusted SQL Server connection + + SQL Server is accepting only domain logins. This applies only to Microsoft SQL Server and you'll need to have your DBA verify that server logins are allowed, or use a domain login. + +Finally, if you received a prompt, then try tsql using the servername. + + Connecting to the server using &freetdsconf; + + $ ./tsql -S myserver -U user + + If this fails, FreeTDS is either not finding your &freetdsconf; file, finding the wrong one, or there is an error in the file. + + + + Logging + +&freetds; has quite extensive logging capabilities. These are often invaluable in setting up new configurations, when it's hard to be sure precisely what configuration information is being used, and what communication is (not) working. Often such questions can be quickly resolved by turning on logging and examining the logs. + Environment Variables that Control Logging + + + TDSDUMP + - - -Finally, if you received a prompt, then try tsql using the servername. - - Connecting to the server using &freetdsconf; +Log files can be turned on using the TDSDUMP environment variable. For instance, setting the location of a dumpfile -$ ./tsql -S myserver -U user - - -If this fails, FreeTDS is either not finding your &freetdsconf; file, finding the wrong one, or there is an error in the file. - - - - - Logging - -&freetds; has quite extensive logging capabilities. These are often invaluable in setting up new configurations, when it's hard to be sure precisely what configuration information is being used, and what communication is (not) working. Often such questions can be quickly resolved by turning on logging and examining the logs. - - Environment Variables that Control Logging - + $ export TDSDUMP=/tmp/freetds.log + Will generate a log file named freetds.log in the /tmp directory. + The filenames stdout and stderr are also supported. They can be handy if you want to intersperse the log output with your application's output, or if your application opens more than one connection. (The logfile is otherwise normally truncatated each time the library connects to the server.) + + - TDSDUMP - - Log files can be turned on using the TDSDUMP environment variable. For instance, setting the location of a dumpfile + TDSDUMPCONFIG + + +Set TDSDUMPCONFIG to a file to + write information to on how the configuration information is being + obtained, e.g. from environment variables, a &freetdsconf; file, or interfaces file. Sometimes it's unclear what source of information &freetds; is using to connect to a given servername. This variable can make that bright and clear. + + + + + + What if you were running Apache/PHP? Apache has many children. + Setting the TDSDUMP (and/or TDSDUMPCONFIG) variable to a null string will cause &freetds; to open a log under every PID. -$ export TDSDUMP=/tmp/freetds.log - -Will generate a log file named freetds.log in the /tmp directory. - The filenames stdout and stderr are also supported. They can be handy if you want to intersperse the log output with your application's output, or if your application opens more than one connection. (The logfile is otherwise normally truncatated each time the library connects to the server.) - - - - - TDSDUMPCONFIG - - Set TDSDUMPCONFIG to a file to -write information to on how the configuration information is being -obtained, e.g. from environment variables, a &freetdsconf; file, or interfaces file. Sometimes it's unclear what source of information &freetds; is using to connect to a given servername. This variable can make that bright and clear. - - - - + $ export TDSDUMP="" + The log files will be named /tmp/freetds.log.9999, where 9999 is the pid number of the process generating the log. + - -What if you were running Apache/PHP? Apache has many children. -Setting the TDSDUMP (and/or TDSDUMPCONFIG) variable to a null string will cause &freetds; to open a log under every PID. - -$ export TDSDUMP="" - -The log files will be named /tmp/freetds.log.9999, where 9999 is the pid number of the process generating the log. - - -A couple of important notes about using the logs with &freetds;. First, -the logs tend to grow large, so trim or archive them often. Secondly, -&freetds; will record certain network packets to the log, this -includes login packets which can contain clear text or clear text -equivalent passwords. So, if this is a concern (most likely -is) make sure that the files are not world readable, and avoid posting -them to mailing lists. - - -Once in a while, someone writes to the mailing list, asking why &freetds; is so slow. It sometimes turns out that logging was left turned on. Don't you be the next victim! &freetds; logs are meant for development and debugging, not as a system monitoring tool. - - - - +A couple of important notes about using the logs with &freetds;. First, + the logs tend to grow large, so trim or archive them often. Secondly, + &freetds; will record certain network packets to the log, this + includes login packets which can contain clear text or clear text + equivalent passwords. So, if this is a concern (most likely + is) make sure that the files are not world readable, and avoid posting + them to mailing lists. + +Once in a while, someone writes to the mailing list, asking why &freetds; is so slow. It sometimes turns out that logging was left turned on. Don't you be the next victim! &freetds; logs are meant for development and debugging, not as a system monitoring tool. + + + &freetdsconf; variables that Control Logging - - See Valid bitmask values for debug flags entry in &freetdsconf; - - The logfile is normally truncated each time &freetds; connects to the server. - - + +See Valid bitmask values for debug flags entry in &freetdsconf; + +The logfile is normally truncated each time &freetds; connects to the server. + - - Logging in ODBC land - (Tree-huggers need not worry) - -Many ODBC Driver Managers have their own support for logging. How logging is controlled, however, varies widely by implementation. The ODBC log is often very helpful because it provides a log of all calls made directly by the application. - - - - unixODBC - - unixODBC supports logging via some entries in odbcinst.ini. For example: + + Logging in ODBC land + (Tree-huggers need not worry) + +Many ODBC Driver Managers have their own support for logging. How logging is controlled, however, varies widely by implementation. The ODBC log is often very helpful because it provides a log of all calls made directly by the application. + + + unixODBC + + +unixODBC supports logging via some entries in odbcinst.ini. For example: -[ODBC] -Trace = Yes -TraceFile = /tmp/sql.log -ForceTrace = Yes - -Will generate a log file named sql.log in the /tmp directory. - - - + [ODBC] + Trace = Yes + TraceFile = /tmp/sql.log + ForceTrace = Yes + Will generate a log file named sql.log in the /tmp directory. + + - - + +
    + + + "Page contains no data" + +Web browsers display this error when the underlying script didn't return any information. The error could be in any of several places, of which &freetds; is one. To isolate the cause, turn on enough logs to see the query, and execute the query through SQSH. If that works, the problem lies further up the chain. If it doesn't, take a look at the known issues section. + +&freetds; under PHP executing within an Apache process may abort with a segmentation fault. The evidence of this is the words "Segmentation Fault" or "Bus Error" in the Apache error log, and a "Page contains no data" warning displayed by the web browser. The unexpected termination of the process causes the connection to the client to be closed before any buffered data is sent. + +To diagnose this sort of problem, follow this procedure; + + Compile PHP as a CGI binary. - - "Page contains no data" - -Web browsers display this error when the underlying script didn't return any information. The error could be in any of several places, of which &freetds; is one. To isolate the cause, turn on enough logs to see the query, and execute the query through SQSH. If that works, the problem lies further up the chain. If it doesn't, take a look at the known issues section. - - -&freetds; under PHP executing within an Apache process may abort with a segmentation fault. The evidence of this is the words "Segmentation Fault" or "Bus Error" in the Apache error log, and a "Page contains no data" warning displayed by the web browser. The unexpected termination of the process causes the connection to the client to be closed before any buffered data is sent. - - -To diagnose this sort of problem, follow this procedure; - - -Compile PHP as a CGI binary. This should have been a side-effect of your build of PHP, look for an -executable called php in the PHP build tree. If you are using a -packaged binary, look for a php-cgi package. - + executable called php in the PHP build tree. If you are using a + packaged binary, look for a php-cgi package. + + + Make a reproducer. -Make a reproducer. Make a PHP script that reliably reproduces the segmentation -fault via the web server, but with no arguments. This is so that you -can execute it using the PHP binary, thus excluding the web -server as the cause of the problem. - - -Reproduce on command line. + fault via the web server, but with no arguments. This is so that you + can execute it using the PHP binary, thus excluding the web + server as the cause of the problem. + + + Reproduce on command line. + Reproduce the segmentation fault using PHP on the command line, by -activating PHP with the script as first argument. For example; - + activating PHP with the script as first argument. For example; + -% php file.php -Segmentation fault -% - + % php file.php + Segmentation fault + % + If this doesn't reproduce the segmentation fault, then there is -something about the environment that differs, so look for the -differences and resolve them. Check environment variables, -assumptions made by the script, the UID you are executing under, and -the current working directory. - - - -Reproduce using GDB. + something about the environment that differs, so look for the + differences and resolve them. Check environment variables, + assumptions made by the script, the UID you are executing under, and + the current working directory. + + + + Reproduce using GDB. + Now reproduce the segmentation fault using the debugger, GDB. -Instead of aborting to the command line, GDB will stop executing the -PHP program at the point of failure. Use the bt -command to determine the details and context. This is called a -backtrace. - + Instead of aborting to the command line, GDB will stop executing the + PHP program at the point of failure. Use the bt + command to determine the details and context. This is called a + backtrace. + -% gdb php -gdb> run file.php -gdb> bt - - - -Analyze the backtrace. + % gdb php + gdb> run file.php + gdb> bt + + + Analyze the backtrace. + Read the backtrace to determine what the cause of the problem -is. Examine each line, assigning responsibility by component; some -code is PHP, some is &freetds;, and some may be glibc. You will need -the source code for each component, and software engineering debugging -skills. + is. Examine each line, assigning responsibility by component; some + code is PHP, some is &freetds;, and some may be glibc. You will need + the source code for each component, and software engineering debugging + skills. + If you cannot determine the cause yourself, send the backtrace -to the mailing list, along with the -PHP script. It helps to make the script as small as possible, but -still fail. It also helps to report the version numbers of PHP, and -&freetds;. + to the mailing list, along with the + PHP script. It helps to make the script as small as possible, but + still fail. It also helps to report the version numbers of PHP, and + &freetds;. + + + + + + + Slow connection or data retrieval - - +&freetds; is not slow. We know this because we've tested it. It's measurably slower than the vendors' products for some operations, but it's not noticeably slower and it's certainly no laggard. If your experience is different, if you're waiting 30 seconds for simple operations or minutes instead of seconds for for query results, something is up with your setup. There are two likely culprits. + + + + +Logging. If everything seems a bit sluggish, check to make sure logging is turned off. TDSDUMP should not be defined, and there should be no dump file mentioned in &freetdsconf;. You can double-check by setting TDSDUMPCONFIG temporarily, which will log only the startup process. + + + +DNS. If connecting to the server takes 30 seconds or 1 minute, you could do worse than to check your resolv.conf. Use host or nslookup to confirm that &freetds; can actually resolve the name/address you provided in &freetdsconf;. Give particular attention to reverse DNS lookups, if you were forced (or thought you were forced) to identify the server by number, instead of by name, as Vint intended. You can defeat &freetds;'s automatic reverse-DNS lookup feature by inserting + + #define NOREVERSELOOKUPS + + in src/tds/config.c, rebuilding, and reinstalling. + Reverse lookup code has been removed as of version 0.62 due to wrong implementation. + + +Packet size. Check packet size setting on &freetdsconf; (see initial block size). Default value (no configuration) is usually fine. The slowness is due to multiple packet to use. + Under GNU/Linux system we use an optimization to reduce network traffic so you shouldn't see much difference using this system. + + + - - Slow connection or data retrieval - -&freetds; is not slow. We know this because we've tested it. It's measurably slower than the vendors' products for some operations, but it's not noticeably slower and it's certainly no laggard. If your experience is different, if you're waiting 30 seconds for simple operations or minutes instead of seconds for for query results, something is up with your setup. There are two likely culprits. - + + + Getting Help + + Beatles - - - Logging. If everything seems a bit sluggish, check to make sure logging is turned off. TDSDUMP should not be defined, and there should be no dump file mentioned in &freetdsconf;. You can double-check by setting TDSDUMPCONFIG temporarily, which will log only the startup process. - - - DNS. If connecting to the server takes 30 seconds or 1 minute, you could do worse than to check your resolv.conf. Use host or nslookup to confirm that &freetds; can actually resolve the name/address you provided in &freetdsconf;. Give particular attention to reverse DNS lookups, if you were forced (or thought you were forced) to identify the server by number, instead of by name, as Vint intended. You can defeat &freetds;'s automatic reverse-DNS lookup feature by inserting - - #define NOREVERSELOOKUPS - -in src/tds/config.c, rebuilding, and reinstalling. - Reverse lookup code has been removed as of version 0.62 due to wrong implementation. - - - - Packet size. Check packet size setting on &freetdsconf; (see initial block size). Default value (no configuration) is usually fine. The slowness is due to multiple packet to use. - Under GNU/Linux system we use an optimization to reduce network traffic so you shouldn't see much difference using this system. - - + + Help me if you can, I'm feeling down + And I do appreciate you being 'round. + Help me get my feet back on the ground, + Won't you please, please help me? + + +In the battle against frustration and wasted motion, this manual is our first defense. Our documentation is intended to make it possible for a knowledgeable user to, well, use &freetds; without further assistance. We strive to include all known features and behaviors here, so you can work quickly and anonymously, and go home before 5:00. Would that it were always thus. + + + Reconfirm the installation + +For initial setup and login problems, review . Distinguish between network and server issues, between finding the server and logging into it. The TDSDUMPCONFIG log will show how the servername is being looked up, what address & port is being used, what TDS version is being used. The TDSDUMP log will show quite clearly whether or not the server accepted the connection, and whether or not the login succeeded. + +Remember compiled-in defaults can be displayed with tsql: + +$ tsql -C + +Compile-time settings (established with the "configure" script) + Version: freetds v0.83.dev.20110124 + freetds.conf directory: /usr/local/etc + MS db-lib source compatibility: no + Sybase binary compatibility: no + Thread safety: yes + iconv library: no + TDS version: 7.0 + iODBC: no + unixodbc: no + SSPI "trusted" logins: no + Keberos: no + + +For &odbc; setup issues, the osql script is intended to confirm the configuration files are all sane. If it fails to report a problem, please post a message describing the problem to the mailing list. Thanks. - - - Getting Help - -Beatles - - Help me if you can, I'm feeling down - And I do appreciate you being 'round. - Help me get my feet back on the ground, - Won't you please, please help me? - - - In the battle against frustration and wasted motion, this manual is our first defense. Our documentation is intended to make it possible for a knowledgeable user to, well, use &freetds; without further assistance. We strive to include all known features and behaviors here, so you can work quickly and anonymously, and go home before 5:00. Would that it were always thus. - - - Isolate the cause - -Successful problem isolation will yield earliest resolution. You (believe it or not) have more information about your environment than anyone else does, and have the greatest motivation to solve your problem. The resources at your disposal will be much more useful if the problem is specific. (Sorry if this is obvious. If it is, you might be surprised how often it's not.) - - -If you can demonstrate the problem with tsql or sqsh, you can expect a quick answer to your question, possibly even a fairly quick fix. (It has happened several times in the last few years that bug reports to small problems were fixed the same day. On a few occasions, new functions were added in a few days. Making &freetds; useful and bugless is the goal of the project, after all.) - - -&freetds; being what it is, problems frequently arise amidst complex environments. It can be hard for both you and the list participants — who are your allies and best resource — to determine what's going wrong. If you can submit a script that they can use to try to reproduce your results, you have a much better chance of happy resolution. - - -On the plus side, the list includes people with a variety of backgrounds, who frequently answer questions that aren't really about &freetds; per se. Clear questions have sometimes even led to submitting patches to other projects. - + + + Isolate the cause + +Successful problem isolation will yield earliest resolution. You (believe it or not) have more information about your environment than anyone else does, and have the greatest motivation to solve your problem. The resources at your disposal will be much more useful if the problem is specific. (Sorry if this is obvious. If it is, you might be surprised how often it's not.) + +If you can demonstrate the problem with tsql or sqsh, you can expect a quick answer to your question, possibly even a fairly quick fix. (It has happened several times in the last few years that bug reports to small problems were fixed the same day. On a few occasions, new functions were added in a few days. Making &freetds; useful and bugless is the goal of the project, after all.) + +&freetds; being what it is, problems frequently arise amidst complex environments. It can be hard for both you and the list participants — who are your allies and best resource — to determine what's going wrong. If you can submit a script that they can use to try to reproduce your results, you have a much better chance of happy resolution. + +On the plus side, the list includes people with a variety of backgrounds, who frequently answer questions that aren't really about &freetds; per se. Clear questions have sometimes even led to submitting patches to other projects. Try a different client</> - <para>&freetds; comes with its own utilities that use the various libraries. It's a good idea to run your query through one of them — the one that uses the same API you're using — to see if it produces the same behavior you're seeing. That helps eliminate your application (and the rest of the calling hierarchy) as a source of the problem. </para> - </sect2> + +<para>&freetds; comes with its own utilities that use the various libraries. It's a good idea to run your query through one of them — the one that uses the same API you're using — to see if it produces the same behavior you're seeing. That helps eliminate your application (and the rest of the calling hierarchy) as a source of the problem.</para> + </sect2> + + <sect2 id="help.permissions"> + <title>Check permissions + +If your query works in tsql but not with Apache, make sure the account running Apache can find and read freetds.conf. + - The Mailing List - -3 Henry VI, I, ii, approximately - - In them I trust; for they are [hackers] - Witty, courteous, liberal, full of spirit. - - + The Mailing List + + 3 Henry VI, I, ii, approximately - + + In them I trust; for they are [hackers] + Witty, courteous, liberal, full of spirit. + + + The Archive - The &freetds; mailing list archive is a good place to start. It is searchable. It should be considered the most up to date (and least edited) source of information. - - New developments between releases tend not to be announced on the website. The website is updated only intermittently, when we post a new release or &freetds; is somehow in the news, say. If you found a bug or need a feature, you may find it was announced/discussed/fixed by perusing the archive. - - + +The &freetds; mailing list archive is a good place to start. It is searchable. It should be considered the most up to date (and least edited) source of information. + +New developments between releases tend not to be announced on the website. The website is updated only intermittently, when we post a new release or &freetds; is somehow in the news, say. If you found a bug or need a feature, you may find it was announced/discussed/fixed by perusing the archive. + - Ask the list - -Many of the original authors and anyone maintaining or extending the code reads the list. The traffic tends to be bursty. It usually focuses on build problems and troubleshooting. Again, the more specific your question, the sooner you'll get a useful reply (if it comes). - - - - Please, do not email the authors directly. You may well be ignored because they're they type that gets a ton of mail. Anyone willing to address your question reads the list, and you don't want to offend anyone willing to help you by going about it the wrong way. - - + Ask the list + +Many of the original authors and anyone maintaining or extending the code reads the list. The traffic tends to be bursty. It usually focuses on build problems and troubleshooting. Again, the more specific your question, the sooner you'll get a useful reply (if it comes). + + +Please, do not email the authors directly. You may well be ignored because they're they type that gets a ton of mail. Anyone willing to address your question reads the list, and you don't want to offend anyone willing to help you by going about it the wrong way. + - - What to include when asking for help + + What to include when asking for help Waddya got? - It's important to convey your setup and configuration. - - SQL Server version - &freetds; version (or snapshot date, if not a release) - which client library you are using - what language or Perl module, as appropriate, you're using - your client OS and hardware architecture - - - + +It's important to convey your setup and configuration. + + SQL Server version + &freetds; version (or snapshot date, if not a release) + which client library you are using + what language or Perl module, as appropriate, you're using + your client OS and hardware architecture + + Attach a logfile + + +If you're puzzled by some interaction with the server (often the case), it's a very good idea to set TDSDUMP and attach the log to your message. Messages are currently limited to 75 KB attachments, and the logs are quite detailed, so make your query as short as possible. If necessary, trim the log; gzip is also your friend here. It's always a good idea to post it on a website where people can fetch it if they're so inclined. + +Log files are especially important if you're not programming at the C level. Sometimes there are problems — an impedance mismatch, to coin a phrase — between &freetds; and the calling framework/language. But if you write to the list and say Why does my PHP foo() returns an empty string?, please keep in mind that your question might as well be in Urdu to someone familiar with the C library. Without knowing which C function was called, and with what data, it's impossible to even begin to try to answer the question. + +Think about it this way: If you attach a log no one reads, you wasted some bandwidth. If you don't attach one and someone asks you for it, you wasted a day. Like that. + - If you're puzzled by some interaction with the server (often the case), it's a very good idea to set TDSDUMP and attach the log to your message. Messages are currently limited to 75 KB attachments, and the logs are quite detailed, so make your query as short as possible. If necessary, trim the log; gzip is also your friend here. It's always a good idea to post it on a website where people can fetch it if they're so inclined. - - Think about it this way: If you attach a log no one reads, you wasted some bandwidth. If you don't attach one and someone asks you for it, you wasted a day. Like that. - - - Help the Help - - If you've found an error, weakness, misbehavior, discrepancy, call-it-what-you-will in one of the published APIs, it's very helpful if you write a unit test for it, and tell us what the Microsoft or Sybase behavior is. Those problems get fixed. Oftentimes, right away. Everyone who's sent us a unit test has gotten their feature in the next release. If you don't, you'll at least get an explanation. - - -Moving down, Perl or PHP code provided it creates all the tables it needs and populates them will generally result in a quick fix. A stand-alone query that will run in SQSH also works well. Here again, it helps to attach a log. - If you provide an SQL query in your question to the list, provide a table definition, too. Problems are often related to specific datatypes, so a table definition is an absolute must. You can run sp_help table to generate one. - - -It is very helpful if you can show an example of the problem using sqsh or an appropriate utility. Using those programs limits the scope of question to &freetds; itself. - -If the problem is a segmentation fault or bus error, that's bad. Please obtain a -backtrace and include it in your mail. See the "Page contains no data" section for how to -do this. + Show your work + +Great questions make the problem crystal clear to a tired developer after supper. + +Show what you did, and show what happened. Throughout this User Guide, you've seen examples of screenshots; in each case the first line was the command entered, followed by the machine's response. By showing verbatim what you did and saw, you give someone who knows what to do a chance to look over your shoulder. Across the Internet! How cool is that? + +Whether you're having a problem with your own application or with something at a higher level, you're well advised to try to reproduce it using one of the &freetds; utilities, preferably one that used the same client library you're using. If, say, bsqldb works and your program doesn't, that's a clue. By the same token, if bsqldb exhibits problems, too, chances are you found a bug. Or — how to say it? — a missing feature. It's always good to know about those. - + - - - Helping - -Bertrand Russell - - The time you enjoy wasting is not wasted time. - - - -&freetds; is a cooperative, volunteer effort. Flame wars on the list are unknown and the signal to noise ratio is pretty high for its venue. Many people have contributed patches, and few have been turned away. - - - Pick a weak spot and fix it. - + + + Helping + + Bertrand Russell - +The time you enjoy wasting is not wasted time. + + +&freetds; is a cooperative, volunteer effort. Flame wars on the list are unknown and the signal to noise ratio is pretty high for its venue. Many people have contributed patches, and few have been turned away. + + Pick a weak spot and fix it. + + - We don't have enough non-English speakers to test our character set conversion features. Anyone willing to participate in that way would be most welcome. + +We don't have enough non-English speakers to test our character set conversion features. Anyone willing to participate in that way would be most welcome. - Canonical examples of using the each library would be very helpful to newcomers. + +Canonical examples of using the each library would be very helpful to newcomers. - An isql Perl and PHP would all make debugging and testing easier for everyone. + +An isql Perl and PHP would all make debugging and testing easier for everyone. - - + - Send a patch - -Good patches are nearly always applied in short order. Patches uploaded to SourceForge trigger automatic notification to the &freetds; mailing list. - - + Send a patch + +Good patches are nearly always applied in short order. Patches uploaded to SourceForge trigger automatic notification to the &freetds; mailing list. + - Correct this User Guide - -Any corrections or suggestions, be they typographical, grammatical, structural, factual, or mineral are most welcome. Please send it to &freetds; FAQ Master, or post a message to the list. - - -The User Guide is maintained in SGML DocBook format; the file in your distibution is doc/userguide.sgml. It is a flat ASCII file that you can edit with any text editor. You don't have to know SGML to correct or add to the User Guide, however. Just open it up, find the place you're interested in, and type away. Do a diff -u old_version your_version and post your patch to the SourceForge site. Any errors or lackings in your markup will be graciously emended by yours truly. - - + Correct this User Guide + +Any corrections or suggestions, be they typographical, grammatical, structural, factual, or mineral are most welcome. Please send it to &freetds; FAQ Master, or post a message to the list. + +The User Guide is maintained in SGML DocBook format; the file in your distibution is doc/userguide.sgml. It is a flat ASCII file that you can edit with any text editor. You don't have to know SGML to correct or add to the User Guide, however. Just open it up, find the place you're interested in, and type away. Do a diff -u old_version your_version and post your patch to the SourceForge site. Any errors or lackings in your markup will be graciously emended by yours truly. + - Document an <acronym>API</> - -We have just begun an independent reference manual to &freetds;; the main API documents are the work of the server vendors. We're using Doxygen, which extracts documentation directly from comments in the source code, and we're maybe 25% done. - - -The TDS protocol is partly documented, as are the APIs to libtds and db-lib, but much remains. - - + Document an <acronym>API</> + +We have just begun an independent reference manual to &freetds;; the main API documents are the work of the server vendors. We're using Doxygen, which extracts documentation directly from comments in the source code, and we're maybe 25% done. + +The TDS protocol is partly documented, as are the APIs to libtds and db-lib, but much remains. + - Be the Webmaster - -The FAQ and in particular the news don't get updated often enough. If that's your thing, drop a line to your friendly project maintainer, James K. Lowden. - - - - - Advocacy - -Out of ten people you know, it's a fair bet 10 never heard of &freetds; and nine don't understand the problem it solves. Lots of places have begun to use Microsoft SQL Servers in all sorts of ways, and if you adhere to the Microsoft line, there's only one way to connect to them: from a Microsoft OS. - - -What can &freetds; do that can't be done any other way? Glad you asked. &freetds; can - - - Connect to every version of either vendor's server, using the same binaries. - Provide a ct-lib interface to Microsoft SQL Server. This feature alone allows DBD::Sybase and sqsh, among others, to connect to Microsoft's product. - Provide a bcp-capable interface and command-line utility on unix-like operating systems for Microsoft SQL Server. - Run on many more operating systems than either vendor's libraries do. - Get fixed, instead of telling you to get stuffed. - Amuse and inform. Also frustrate and infuriate, but we don't put that under Advocacy. - - If more people knew, fewer would be stuck. - - - - - - Programming - - - - TDS protocol reference - -Can be found on www.freetds.org - - - API Reference Manual - -The reference manual is installed as part of FreeTDS. It can be regenerated at any time using Doxygen with cd doc; make doc. - - -The reference manual is a work in progress: only the db-lib library is completely documented, and quite minimally at that. Should you find it inadequate, you may be interested to learn it's not hard to add to, technically. Doxygen generates a manual from encoded comments in the source code. Its markup syntax is not hard to learn. You can read more about it at the Doxygen website. - - -Basic API coverage information for the db-lib, ct-lib, and ODBC client libraries is maintained in doc/api_status.txt, included in the source distribution. For your convenience and enjoyment, we include that file in the following sections. In each table, we note for the function - Sybase and Microsoft sometimes use slightly different names for the same function. It is the intention of the -the extent to which it is implemented. The Status field may be: - - - db-lib API function status domain - - (blank) - - Function is not implemented. - - - - stub - - Function is implemented as a stub. Some such functions return SUCCEED even though they have no effect, to satisfy upper layers. - - - - Partial - - Function is partly implemented. We haven't dealt with every possible option, for instance. - - - - OK - - Function is implemented. Completely, we claim. - - - - - + Be the Webmaster - - db-lib API Implementation Summary - Microsoft's version of db-lib is - online. - Sybase's is both - online - and can be - downloaded - as a PDF file. - - Links such as these are quite perishable. Should you find them broken, please check the FreeTDS User Guide posted on our website. If it's out of date, please let us know, so we can correct it. Thanks. - &dblibapisgml; +The FAQ and in particular the news don't get updated often enough. If that's your thing, drop a line to your friendly project maintainer, James K. Lowden. + - - ct-lib API Implementation Summary - Sybase ct-lib documentation can be found - online - and in PDF form. Links such as these are quite perishable. Should you find them broken, please check the FreeTDS User Guide posted on our website. If it's out of date, please let us know, so we can correct it. Thanks. - &ctlibapisgml; - - - - ODBC API Implementation Summary - Microsoft's ODBC documentation is - online. - - The functions are linked to the reference page on Microsoft's website. Links such as these are quite perishable. Should you find them broken, please check the FreeTDS User Guide posted on our website. If it's out of date, please let us know, so we can correct it. Thanks. - &odbcapisgml; + + Light another's taper + +Every question you answer on the mailing list will save someone time and, if done well, will actually improve your own knowledge. The project's developers will often answer technical questions that require substantial understanding of the code or suggest a possible bug. Setup issues, though, connecting and logging in to the server, getting Apache going, are questions many experienced users can and do answer, thereby fostering the community on which the project depends. + +Your experience may well be more closely aligned with the question posed than that of anyone else reading the list that day. You may use that framework or language or OS, or have that particular server. No one, no matter how expert in the code, has used every configuration, version, OS, compiler, etc. Whether you simply confirm there's a problem in some particular arrangement, or say, dunno, works for me, you're adding information. + - - - DB-Library for the Tenderfoot - Mark Twain - Few things are harder to put up with than the annoyance of a good example. - - Below is a complete sample working db-lib program, presented as a series of examples. - Features of sample code - Processes command-line options to select the server, database, username, and password - Remaining arguments on the command line comprise the SQL query to execute - Installs error and message handlers - Illustrates correct row-processing - Illustrates correct error detection and handling - - Other sample code may be found in the distribution, in the cleverly named samples directory. A complete program, heavily commented for your perusal, is apps/bsqldb.c. - - What's the big deal with errors? - Correct handling of errors is extremely important in database applications because they involve two systems most others don't: the network and the database server. Both can give rise to errors that, if not detected and reported when they occur, let the application proceed blithely on until something truly mysterious happens. In the worst case, in the absence of a properly reported error, the application may seem to have updated the data, when in fact it did not. - Every db-lib application uses the network, making it subject to network failures. Database programs also almost always have very high data integrity requirements. It is necessary to know the row was absolutely, positively committed, once and only once, without error or exception. Without taking great care to trap and handle all error conditions, no statement about the program's reliability can be made with confidence. - - - How to Get and Build the sample code - Run doc/grep_sample_code to extract the C code from the User Guide SGML source. - Compile - Link - - Files Required to Build the Sample Code - sybfront.h - sybdb.h - libsybdb.a or libsybdb.so - - Your library's extension may vary according to your operating system. - - The source code may be built with commands similar to these. The precise options and paths depend on your particular system. The commands below work with the GNU compiler and linker on an ELF system with dynamic linking, common on Linux and BSD systems. -Building the Sample Code - - $ ../doc/grep_sample_code ../doc/userguide.sgml > sample.c - $ cc -I /usr/local/include -Wl,-L/usr/local/lib -Wl,-R/usr/local/lib sample.c -lsybdb -o sample - - - where /usr/local/include and /usr/local/lib are respectively the locations of your header files and libraries. - - - We now proceed to the code proper. - + + Ambitious ideas - Header files - We need two header files to use db-lib. We need a few others to deal with I/O in C, as you know. Also declare the error and message handler functions, more about which later. +If you want to get your hands really dirty, here are some big ideas to contemplate. + + + <literal>libtds2</literal> - - Sample Code: <symbol>db-lib</> header files - - -#include -#include -#include -#include -#include -#include -]]> +After many years developing &freetds;, we've learned quite a bit about the protocol and how to write database libraries. Unfortunately, though, one of the things holding us back — and, obviously hampering the project — is the underlying utility library. -#include <sybfront.h> /* sybfront.h always comes first */ -#include <sybdb.h> /* sybdb.h is the only other file you need */ +This wouldn't be a from-scratch effort; most of the code is already written. What's needed is a more uniform API that better reflects the TDS protocol, and that does not attempt character set conversions immediately on receipt of the data. + -int err_handler(DBPROCESS*, int, int, int, char*, char*); -int msg_handler(DBPROCESS*, DBINT, int, int, char*, char*, char*, int); - - + + <literal>libstddb</literal> + +This would be a new client library modelled after stdio, a project to demonstrate what database programming should be like. - - Prolog - Nothing special here. Collect the command line parameters. We do this with the standard getopts(3) function. Cf. man 3 getopts for details. - - - Sample Code: <symbol>db-lib</> prolog - -extern char *optarg; -extern int optind; - -const static char syntax[] = - "syntax: example -S server -D db -U user -P passwd\n"; - -struct { - char *appname, *servername, *dbname, *username, *password; -} options = {0,0,0,0,0}; -int -main(int argc, char *argv[]) -{ - int i, ch; - LOGINREC *login; - DBPROCESS *dbproc; - RETCODE erc; - - options.appname = basename(argv[0]); - - while ((ch = getopt(argc, argv, "U:P:S:D:")) != -1) { - switch (ch) { - case 'S': - options.servername = strdup(optarg); - break; - case 'D': - options.dbname = strdup(optarg); - break; - case 'U': - options.username = strdup(optarg); - break; - case 'P': - options.password = strdup(optarg); - break; - case '?': - default: - fprintf(stderr, syntax); - exit(1); - } - } + + Server code - argc -= optind; - argv += optind; - - if (! (options.servername - && options.username && options.password)) { - fprintf(stderr, syntax); - exit(1); - } - - Prolog Notes - - LOGINREC is a structure that describes the client. It's passed to the server at connect time. - - DBPROCESS is a structure that describes the connection. It is returned by dbopen(). - - RETCODE is the most common return code type for db-lib functions. - - +&freetds; includes a little stub of a server, but it could be much more useful. One idea would be to make it a front-end to SQLite, thereby creating for the first time a TDS client & server pair composed entirely of free software. - Initialize - Initialize the library. Create and populate a LOGINREC record. - - - Sample Code: <symbol>db-lib</> Initialize - + - - if (dbinit() == FAIL) { - fprintf(stderr, "%s:%d: dbinit() failed\n", - options.appname, __LINE__); - exit(1); - } - - - dberrhandle(err_handler); - dbmsghandle(msg_handler); + + Advocacy - - if ((login = dblogin()) == NULL) { - fprintf(stderr, "%s:%d: unable to allocate login structure\n", - options.appname, __LINE__); - exit(1); - } +Out of ten people you know, it's a fair bet 10 never heard of &freetds; and nine don't understand the problem it solves. Lots of places have begun to use Microsoft SQL Servers in all sorts of ways, and if you adhere to the Microsoft line, there's only one way to connect to them: from a Microsoft OS. - - DBSETLUSER(login, options.username); - DBSETLPWD(login, options.password); +What can &freetds; do that can't be done any other way? Glad you asked. &freetds; can + + Connect to every version of either vendor's server, using the same binaries. + Provide a &ctlib; interface to Microsoft SQL Server. This feature alone allows DBD::Sybase and sqsh, among others, to connect to Microsoft's product. + Provide a bcp-capable interface and command-line utility on unix-like operating systems for Microsoft SQL Server. + Run on many more operating systems than either vendor's libraries do. + Get fixed, instead of telling you to get stuffed. + Amuse and inform. Also frustrate and infuriate, but we don't put that under Advocacy. + + +If more people knew, fewer would be stuck. + + + + + Programming + + + + TDS protocol reference + +Can be found on www.freetds.org + + API Reference Manual + +The reference manual is installed as part of FreeTDS. It can be regenerated at any time using Doxygen with cd doc; make doc. + +The reference manual is a work in progress: only the db-lib library is completely documented, and quite minimally at that. Should you find it inadequate, you may be interested to learn it's not hard to add to, technically. Doxygen generates a manual from encoded comments in the source code. Its markup syntax is not hard to learn. You can read more about it at the Doxygen website. + +Basic API coverage information for the db-lib, ct-lib, and ODBC client libraries is maintained in doc/api_status.txt, included in the source distribution. For your convenience and enjoyment, we include that file in the following sections. In each table, we note for the function + Sybase and Microsoft sometimes use slightly different names for the same function. It is the intention of the + the extent to which it is implemented. The Status field may be: + + + db-lib API function status domain + + (blank) + + +Function is not implemented. + + + + stub + + +Function is implemented as a stub. Some such functions return SUCCEED even though they have no effect, to satisfy upper layers. + + + + Partial + + +Function is partly implemented. We haven't dealt with every possible option, for instance. + + + + OK + + +Function is implemented. Completely, we claim. + + + + + + db-lib API Implementation Summary + +Microsoft's version of db-lib is + online. + Sybase's is both + online + and can be + downloaded + as a PDF file. + + Links such as these are quite perishable. Should you find them broken, please check the FreeTDS User Guide posted on our website. If it's out of date, please let us know, so we can correct it. Thanks. + &dblibapisgml; + + + ct-lib API Implementation Summary + +Sybase ct-lib documentation can be found + online + and in PDF form. Links such as these are quite perishable. Should you find them broken, please check the FreeTDS User Guide posted on our website. If it's out of date, please let us know, so we can correct it. Thanks. + &ctlibapisgml; + - - Initialization Notes - - Always make dbinit() the first db-lib call. - - Install the error- and mesage-handlers right away. They're explained in more detail later. - - dblogin() almost never fails. -But check! No point in trying to use a null pointer. - - The LOGIN record isn't directly accessible. It's populated via macros like these. There are other fields, but these two are essential. Look for SETLsomething in the documentation. - - + + ODBC API Implementation Summary + +Microsoft's ODBC documentation is + online. + + +The functions are linked to the reference page on Microsoft's website. Links such as these are quite perishable. Should you find them broken, please check the FreeTDS User Guide posted on our website. If it's out of date, please let us know, so we can correct it. Thanks. + &odbcapisgml; + + + + DB-Library for the Tenderfoot + Mark Twain + +Few things are harder to put up with than the annoyance of a good example. + + Below is a complete sample working db-lib program, presented as a series of examples. + Features of sample code + Processes command-line options to select the server, database, username, and password + Remaining arguments on the command line comprise the SQL query to execute + Installs error and message handlers + Illustrates correct row-processing + Illustrates correct error detection and handling + + Other sample code may be found in the distribution, in the cleverly named samples directory. A complete program, heavily commented for your perusal, is apps/bsqldb.c. + + +What's the big deal with errors? + +Correct handling of errors is extremely important in database applications because they involve two systems most others don't: the network and the database server. Both can give rise to errors that, if not detected and reported when they occur, let the application proceed blithely on until something truly mysterious happens. In the worst case, in the absence of a properly reported error, the application may seem to have updated the data, when in fact it did not. + +Every db-lib application uses the network, making it subject to network failures. Database programs also almost always have very high data integrity requirements. It is necessary to know the row was absolutely, positively committed, once and only once, without error or exception. Without taking great care to trap and handle all error conditions, no statement about the program's reliability can be made with confidence. + + +How to Get and Build the sample code + Run doc/grep_sample_code to extract the C code from the User Guide SGML source. + Compile + Link + + + Files Required to Build the Sample Code + sybfront.h + sybdb.h + libsybdb.a or libsybdb.so + + Your library's extension may vary according to your operating system. + + +The source code may be built with commands similar to these. The precise options and paths depend on your particular system. The commands below work with the GNU compiler and linker on an ELF system with dynamic linking, common on Linux and BSD systems. + Building the Sample Code + + $ ../doc/grep_sample_code ../doc/userguide.sgml > sample.c + $ cc -I /usr/local/include -Wl,-L/usr/local/lib -Wl,-R/usr/local/lib sample.c -lsybdb -o sample + + where /usr/local/include and /usr/local/lib are respectively the locations of your header files and libraries. + + +We now proceed to the code proper. + + Header files + We need two header files to use db-lib. We need a few others to deal with I/O in C, as you know. Also declare the error and message handler functions, more about which later. + + + + Sample Code: <symbol>db-lib</> header files + + +#include +#include +#include +#include +#include +#include + ]]> + +#include <sybfront.h> /* sybfront.h always comes first */ +#include <sybdb.h> /* sybdb.h is the only other file you need */ + +int err_handler(DBPROCESS*, int, int, int, char*, char*); +int msg_handler(DBPROCESS*, DBINT, int, int, char*, char*, char*, int); + + + Prolog + Nothing special here. Collect the command line parameters. We do this with the standard getopts(3) function. Cf. man 3 getopts for details. + - Connect to the server - dbopen() forms a connection with the server. We pass our LOGINREC pointer (which describes the client end), and the name of the server. Then, optionally, we change to our favored database. If that step is skipped, the user lands in his default database. - - - Sample Code: <symbol>db-lib</> Connect to the server - - if ((dbproc = dbopen(login, options.servername)) == NULL) { - fprintf(stderr, "%s:%d: unable to connect to %s as %s\n", - options.appname, __LINE__, - options.servername, options.username); - exit(1); + + Sample Code: <symbol>db-lib</> prolog + + extern char *optarg; + extern int optind; + + const static char syntax[] = + "syntax: example -S server -D db -U user -P passwd\n"; + + struct { + char *appname, *servername, *dbname, *username, *password; + } options = {0,0,0,0,0}; + + int + main(int argc, char *argv[]) + { + int i, ch; + LOGINREC *login; + DBPROCESS *dbproc; + RETCODE erc; + + options.appname = basename(argv[0]); + + while ((ch = getopt(argc, argv, "U:P:S:D:")) != -1) { + switch (ch) { + case 'S': + options.servername = strdup(optarg); + break; + case 'D': + options.dbname = strdup(optarg); + break; + case 'U': + options.username = strdup(optarg); + break; + case 'P': + options.password = strdup(optarg); + break; + case '?': + default: + fprintf(stderr, syntax); + exit(1); + } + } + + argc -= optind; + argv += optind; + + if (! (options.servername + && options.username && options.password)) { + fprintf(stderr, syntax); + exit(1); } + + Prolog Notes + - if (options.dbname && (erc = dbuse(dbproc, options.dbname)) == FAIL) { - fprintf(stderr, "%s:%d: unable to use to database %s\n", - options.appname, __LINE__, options.dbname); - exit(1); +LOGINREC is a structure that describes the client. It's passed to the server at connect time. + + +DBPROCESS is a structure that describes the connection. It is returned by dbopen(). + + +RETCODE is the most common return code type for db-lib functions. + + + + Initialize + Initialize the library. Create and populate a LOGINREC record. + + + + Sample Code: <symbol>db-lib</> Initialize + + + + if (dbinit() == FAIL) { + fprintf(stderr, "%s:%d: dbinit() failed\n", + options.appname, __LINE__); + exit(1); + } + + + dberrhandle(err_handler); + dbmsghandle(msg_handler); + + + if ((login = dblogin()) == NULL) { + fprintf(stderr, "%s:%d: unable to allocate login structure\n", + options.appname, __LINE__); + exit(1); } + + + DBSETLUSER(login, options.username); + DBSETLPWD(login, options.password); + + + Initialization Notes + +Always make dbinit() the first db-lib call. + - - +Install the error- and mesage-handlers right away. They're explained in more detail later. + + +dblogin() almost never fails. + But check! No point in trying to use a null pointer. + + +The LOGIN record isn't directly accessible. It's populated via macros like these. There are other fields, but these two are essential. Look for SETLsomething in the documentation. + + + Connect to the server + dbopen() forms a connection with the server. We pass our LOGINREC pointer (which describes the client end), and the name of the server. Then, optionally, we change to our favored database. If that step is skipped, the user lands in his default database. + - Send a query + + Sample Code: <symbol>db-lib</> Connect to the server + + if ((dbproc = dbopen(login, options.servername)) == NULL) { + fprintf(stderr, "%s:%d: unable to connect to %s as %s\n", + options.appname, __LINE__, + options.servername, options.username); + exit(1); + } + + if (options.dbname && (erc = dbuse(dbproc, options.dbname)) == FAIL) { + fprintf(stderr, "%s:%d: unable to use to database %s\n", + options.appname, __LINE__, options.dbname); + exit(1); + } + + + + + Send a query db-lib maintains a command buffer to hold the SQL to be sent to the server. Two functions — dbcmd() and dbfcmd() — build up the query from strings of text. The command buffer is reset after the query is sent to the server. - We left the SQL on the command line. We fetch it now and send it to the server. - - - Sample Code: <symbol>db-lib</> Send a query - - for (i=0; i < argc; i++) { - assert(argv[i]); - printf("%s ", argv[i]); - if ((erc = dbfcmd(dbproc, "%s ", argv[i])) == FAIL) { - fprintf(stderr, "%s:%d: dbcmd() failed\n", options.appname, __LINE__); - exit(1); +We left the SQL on the command line. We fetch it now and send it to the server. + - } + + Sample Code: <symbol>db-lib</> Send a query + + for (i=0; i < argc; i++) { + assert(argv[i]); + printf("%s ", argv[i]); + if ((erc = dbfcmd(dbproc, "%s ", argv[i])) == FAIL) { + fprintf(stderr, "%s:%d: dbcmd() failed\n", options.appname, __LINE__); + exit(1); + + } } printf("\n"); - + if ((erc = dbsqlexec(dbproc)) == FAIL) { - fprintf(stderr, "%s:%d: dbsqlexec() failed\n", options.appname, __LINE__); - exit(1); - + fprintf(stderr, "%s:%d: dbsqlexec() failed\n", options.appname, __LINE__); + exit(1); + } - - Initialization Notes - Failure at this juncture is rare. The library is merely allocating memory to hold the SQL. - dbsqlexec() waits for the server to execute the query. Depending on the complexity of the query, that may take a while. - - dbsqlexec() will fail if something is grossly wrong with the query, e.g. incorrect syntax or a reference to nonexistent table. It's only the first of a few places where an error can crop up in processing the query, though. Just because dbsqlexec() succeeded doesn't mean you're in the clear. - + + Initialization Notes + Failure at this juncture is rare. The library is merely allocating memory to hold the SQL. + dbsqlexec() waits for the server to execute the query. Depending on the complexity of the query, that may take a while. + + dbsqlexec() will fail if something is grossly wrong with the query, e.g. incorrect syntax or a reference to nonexistent table. It's only the first of a few places where an error can crop up in processing the query, though. Just because dbsqlexec() succeeded doesn't mean you're in the clear. - - Fetch Results - A query may produce zero, one, or more results. Broadly, that entails providing buffers to db-lib to fill, and iterating over the results a row (and column) at a time. - + + Fetch Results + A query may produce zero, one, or more results. Broadly, that entails providing buffers to db-lib to fill, and iterating over the results a row (and column) at a time. + Kinds of Results - Results is a special term: it means more than rows or no rows. To process the results means to gather the data returned by the server into the application's variables. - Kinds of Results - - - - - - - - - - Type - Metadata - Regular Rows - Compute Rows - Return Status - Example SQL - - - - None - None - None - None - None - Any INSERT, UPDATE, or DELETE statement - - Empty - 1 set - None - 0 or more - None - SELECT name FROM systypes WHERE 0 = 1 - - Simple - 1 set - 0 or more - None - None - SELECT name FROM sysobjects - - Complex - 2 or more - 0 or more - 1 or more - None - SELECT name FROM sysobjects COMPUTE COUNT(name) - - Stored Procedure - 0 or more - 0 or more - 0 or more - 1 or more - EXEC sp_help sysobjects - - - -
    + +Results is a special term: it means more than rows or no rows. To process the results means to gather the data returned by the server into the application's variables. + Kinds of Results + + + + + + + + + + Type + Metadata + Regular Rows + Compute Rows + Return Status + Example SQL + + + + None + None + None + None + None + Any INSERT, UPDATE, or DELETE statement + + Empty + 1 set + None + 0 or more + None + SELECT name FROM systypes WHERE 0 = 1 + + Simple + 1 set + 0 or more + None + None + SELECT name FROM sysobjects + + Complex + 2 or more + 0 or more + 1 or more + None + SELECT name FROM sysobjects COMPUTE COUNT(name) + + Stored Procedure + 0 or more + 0 or more + 0 or more + 1 or more + EXEC sp_help sysobjects + + + +
    - As the above table shows, results can comprise ordinary rows and compute rows (resulting from a COMPUTE clause). Stored procedures may of course contain multiple SQL statements, some of which may be SELECT statements and might include COMPUTE clauses. In addition, they generate a return status (with a RETURN statement or else automatically) and perhaps OUTPUT parameters. + +As the above table shows, results can comprise ordinary rows and compute rows (resulting from a COMPUTE clause). Stored procedures may of course contain multiple SQL statements, some of which may be SELECT statements and might include COMPUTE clauses. In addition, they generate a return status (with a RETURN statement or else automatically) and perhaps OUTPUT parameters. Data and Metadata - Observe that a row is set of columns, and each column has attributes such as type and size. The column attributes of a row are collectively known as metadata. The server always returns metadata before any data (even for a a SELECT statement that produced no rows). - - Result-fetching functions - - - - - - - - Function - Fetches - Returns - Comment - - - - dbresults() - metadata - SUCCEED, FAIL or, NO_MORE_RESULTS. - SUCCEED indicates just that: the query executed successfully (whew!). There may be metadata (and perhaps data) and/or stored procedure outputs available. - - nextrow() - data - REG_ROW, - compute_id, - NO_MORE_ROWS, - BUF_FULL, - or FAIL. - - Places fetched data into bound columns, if any. - - - -
    - Binding +Observe that a row is set of columns, and each column has attributes such as type and size. The column attributes of a row are collectively known as metadata. The server always returns metadata before any data (even for a a SELECT statement that produced no rows). + - Each time dbresults() returns SUCCEED, there is something to retrieve. db-lib has different functions to deal with the different kinds of results. The functions are of two kinds: those that convert the data into a form desired by the application, known as binding, and those that return the data in native form. + Result-fetching functions + + + + + + + + Function + Fetches + Returns + Comment + + + + dbresults() + metadata + SUCCEED, FAIL or, NO_MORE_RESULTS. + SUCCEED indicates just that: the query executed successfully (whew!). There may be metadata (and perhaps data) and/or stored procedure outputs available. + + nextrow() + data + REG_ROW, + compute_id, + NO_MORE_ROWS, + BUF_FULL, + or FAIL. + + Places fetched data into bound columns, if any. + + + +
    - To understand binding, it may be easiest to examine two primitive functions, dbdata() and dbconvert(). dbdata() returns a pointer to the column's data. The data to which it points are in native form, 4 bytes for an INT, 8 bytes for a DATETIME and so on. dbconvert() converts between datatypes; you can hand it an integer and get back a character array (or a C double. You might think of dbconvert() as atoi(3) on steroids). dbbind() combines these two functions. The application indicates in what form it would like to use each column, and the library converts them on the fly as each row is read. + Binding - To bind a column is to provide a buffer to db-lib to fill and indicate which datatype the buffer is meant to hold. This is the sort of thing C++'s type system does so much better + +Each time dbresults() returns SUCCEED, there is something to retrieve. db-lib has different functions to deal with the different kinds of results. The functions are of two kinds: those that convert the data into a form desired by the application, known as binding, and those that return the data in native form. + + +To understand binding, it may be easiest to examine two primitive functions, dbdata() and dbconvert(). dbdata() returns a pointer to the column's data. The data to which it points are in native form, 4 bytes for an INT, 8 bytes for a DATETIME and so on. dbconvert() converts between datatypes; you can hand it an integer and get back a character array (or a C double. You might think of dbconvert() as atoi(3) on steroids). dbbind() combines these two functions. The application indicates in what form it would like to use each column, and the library converts them on the fly as each row is read. - It may be well to pause here to observe the three ways a datatype is described in a db-lib program. - <function>db-lib</> Datatype Descriptors - - Sever Datatype - - Describes the data as an abstract type, not representing any particular kind of storage. SYBREAL, for example, doesn't imply any particular arrangement of bits; it just means a floating-point datatype corresponding to the T-SQL REAL type on the server. These all begin with SYB, e.g. SYBINT4. - - - - Program Variable Datatype - - Defines a C variable in a machine-independent way. Because a C defines its int type according the CPU architecture, it may have 2, 4, 8, or some other number of bytes. A DBINT on the other hand, is guaranteed to be 4 bytes and, as such, assuredly will hold any value returned by the server from a T-SQL INT column. These all begin with DB, e.g. DBREAL. - - - - Bind Type - - Prescribes a conversion operation. Indicates to dbbind() the Program Variable Datatype defined by the target buffer. Sybase and Microsoft call this the vartype. These all end with BIND, e.g. STRINGBIND. - - - - +To bind a column is to provide a buffer to db-lib to fill and indicate which datatype the buffer is meant to hold. This is the sort of thing C++'s type system does so much better - Typically it's more convenient to have db-lib convert the data into the desired form. The function that does that is dbind(). So: after fetching the metadata, and before fetching the data, we usually prepare the bound columns. +It may be well to pause here to observe the three ways a datatype is described in a db-lib program. + <function>db-lib</> Datatype Descriptors + + Sever Datatype + + +Describes the data as an abstract type, not representing any particular kind of storage. SYBREAL, for example, doesn't imply any particular arrangement of bits; it just means a floating-point datatype corresponding to the T-SQL REAL type on the server. These all begin with SYB, e.g. SYBINT4. + + + + Program Variable Datatype + + +Defines a C variable in a machine-independent way. Because a C defines its int type according the CPU architecture, it may have 2, 4, 8, or some other number of bytes. A DBINT on the other hand, is guaranteed to be 4 bytes and, as such, assuredly will hold any value returned by the server from a T-SQL INT column. These all begin with DB, e.g. DBREAL. + + + + Bind Type + + +Prescribes a conversion operation. Indicates to dbbind() the Program Variable Datatype defined by the target buffer. Sybase and Microsoft call this the vartype. These all end with BIND, e.g. STRINGBIND. + + + + + +Typically it's more convenient to have db-lib convert the data into the desired form. The function that does that is dbind(). So: after fetching the metadata, and before fetching the data, we usually prepare the bound columns. + Fetching Data - Data-fetching functions - - - - - - - - - Type - Regular rows - Compute rows - Return status - OUTPUT parameters - - - - Meta - dbnumcols() - dbnumcompute(), - dbnumalts(), - dbaltop(), - dbbylist() - dbhasretstatus() - dbnumrets() - - Binding - dbbind(), dbnullbind() - dbaltbind(), - dbanullbind() - dbretstatus() - none - - Native - dbdatlen(), dbdata() - dbadlen(), - dbalttype(), - dbaltutype(), - dbaltlen(), - dbadata() - none - dbretdata(), - dbretlen(), - dbretname(), - dbrettype() - - - -
    + + Data-fetching functions + + + + + + + + + Type + Regular rows + Compute rows + Return status + OUTPUT parameters + + + + Meta + dbnumcols() + dbnumcompute(), + dbnumalts(), + dbaltop(), + dbbylist() + dbhasretstatus() + dbnumrets() + + Binding + dbbind(), dbnullbind() + dbaltbind(), + dbanullbind() + dbretstatus() + none + + Native + dbdatlen(), dbdata() + dbadlen(), + dbalttype(), + dbaltutype(), + dbaltlen(), + dbadata() + none + dbretdata(), + dbretlen(), + dbretname(), + dbrettype() + + + +
    - The paradigm may now perhaps be clear: Query, fetch results, bind columns, fetch regular rows, fetch compute rows, fetch stored procedure outputs. Repeat as necessary. + +The paradigm may now perhaps be clear: Query, fetch results, bind columns, fetch regular rows, fetch compute rows, fetch stored procedure outputs. Repeat as necessary. - Putting it all together - - - - - - - Step - Function - Once Per - Many Times Per - - - - Query - dbsqlexec() - Query - Program - - Fetch metadata - dbresults() - SQL statement - Query - - Prepare variables - dbbind() - Column - Statement - - Fetch regular data - dbnextrow() - Row - Statement - - Fetch compute data - dbnextrow() - Compute column - Statement - - Fetch output parameters - dbretdata() - output parameter - Stored procedure - - Fetch return status - dbretstatus() - Stored procedure - Program - - - -
    - - Fetch All Rows! - db-lib doesn't insist every column — or even any column — be bound or otherwise retrieved into the application's variables. There is, however, one absolutely crucial, inflexible, unalterable requirement: the application must process all rows produced by the query. Before the DBPROCESS can be used for another query, the application must either fetch all rows, or cancel the results and receive an acknowledgement from the server. Cancelling is beyond the scope of this document, so for now fetch all rows. - - Now, at last, some sample code that fetches data. In the interest of simplicity, we don't bind anything except regular rows. - - - Sample Code: <symbol>db-lib</> Fetch Results - - while ((erc = dbresults(dbproc)) != NO_MORE_RESULTS) { - struct COL - { - char *name; - char *buffer; - int type, size, status; - } *columns, *pcol; - int ncols; - int row_code; - - if (erc == FAIL) { - fprintf(stderr, "%s:%d: dbresults failed\n", - options.appname, __LINE__); - exit(1); - } - - ncols = dbnumcols(dbproc); - - if ((columns = calloc(ncols, sizeof(struct COL))) == NULL) { - perror(NULL); - exit(1); - } - - /* - * Read metadata and bind. - */ - for (pcol = columns; pcol - columns < ncols; pcol++) { - int c = pcol - columns + 1; + + Putting it all together + + + + + + + Step + Function + Once Per + Many Times Per + + + + Query + dbsqlexec() + Query + Program + + Fetch metadata + dbresults() + SQL statement + Query + + Prepare variables + dbbind() + Column + Statement + + Fetch regular data + dbnextrow() + Row + Statement + + Fetch compute data + dbnextrow() + Compute column + Statement + + Fetch output parameters + dbretdata() + output parameter + Stored procedure + + Fetch return status + dbretstatus() + Stored procedure + Program + + + +
    - pcol->name = dbcolname(dbproc, c); - pcol->type = dbcoltype(dbproc, c); - pcol->size = dbcollen(dbproc, c); + +Fetch All Rows! + db-lib doesn't insist every column — or even any column — be bound or otherwise retrieved into the application's variables. There is, however, one absolutely crucial, inflexible, unalterable requirement: the application must process all rows produced by the query. Before the DBPROCESS can be used for another query, the application must either fetch all rows, or cancel the results and receive an acknowledgement from the server. Cancelling is beyond the scope of this document, so for now fetch all rows. + + +Now, at last, some sample code that fetches data. In the interest of simplicity, we don't bind anything except regular rows. - if (SYBCHAR != pcol->type) { - pcol->size = dbwillconvert(pcol->type, SYBCHAR); - } - - printf("%*s ", pcol->size, pcol->name); - - if ((pcol->buffer = calloc(1, pcol->size + 1)) == NULL){ - perror(NULL); - exit(1); - } - - erc = dbbind(dbproc, c, NTBSTRINGBIND, - pcol->size+1, (BYTE*)pcol->buffer); - if (erc == FAIL) { - fprintf(stderr, "%s:%d: dbbind(%d) failed\n", - options.appname, __LINE__, c); - exit(1); - } + + + Sample Code: <symbol>db-lib</> Fetch Results + + while ((erc = dbresults(dbproc)) != NO_MORE_RESULTS) { + struct COL + { + char *name; + char *buffer; + int type, size, status; + } *columns, *pcol; + int ncols; + int row_code; + + if (erc == FAIL) { + fprintf(stderr, "%s:%d: dbresults failed\n", + options.appname, __LINE__); + exit(1); + } + + ncols = dbnumcols(dbproc); + + if ((columns = calloc(ncols, sizeof(struct COL))) == NULL) { + perror(NULL); + exit(1); + } + + /* + * Read metadata and bind. + */ + for (pcol = columns; pcol - columns < ncols; pcol++) { + int c = pcol - columns + 1; + + pcol->name = dbcolname(dbproc, c); + pcol->type = dbcoltype(dbproc, c); + pcol->size = dbcollen(dbproc, c); + + if (SYBCHAR != pcol->type) { + pcol->size = dbwillconvert(pcol->type, SYBCHAR); + } + + printf("%*s ", pcol->size, pcol->name); + + if ((pcol->buffer = calloc(1, pcol->size + 1)) == NULL){ + perror(NULL); + exit(1); + } + + erc = dbbind(dbproc, c, NTBSTRINGBIND, + pcol->size+1, (BYTE*)pcol->buffer); + if (erc == FAIL) { + fprintf(stderr, "%s:%d: dbbind(%d) failed\n", + options.appname, __LINE__, c); + exit(1); + } status);]]> - if (erc == FAIL) { - fprintf(stderr, "%s:%d: dbnullbind(%d) failed\n", - options.appname, __LINE__, c); - exit(1); - } - } - printf("\n"); - - /* - * Print the data to stdout. - */ - while ((row_code = dbnextrow(dbproc)) != NO_MORE_ROWS){ - switch (row_code) { - case REG_ROW: - for (pcol=columns; pcol - columns < ncols; pcol++) { - char *buffer = pcol->status == -1? - "NULL" : pcol->buffer; - printf("%*s ", pcol->size, buffer); - } - printf("\n"); - break; - - case BUF_FULL: - assert(row_code != BUF_FULL); - break; - - case FAIL: - fprintf(stderr, "%s:%d: dbresults failed\n", - options.appname, __LINE__); - exit(1); - break; - - default: - printf("Data for computeid %d ignored\n", row_code); - } - - - } - - /* free metadata and data buffers */ - for (pcol=columns; pcol - columns < ncols; pcol++) { - free(pcol->buffer); - } - free(columns); - - /* - * Get row count, if available. - */ - if (DBCOUNT(dbproc) > -1) - fprintf(stderr, "%d rows affected\n", DBCOUNT(dbproc)); - - /* - * Check return status - */ - if (dbhasretstat(dbproc) == TRUE) { - printf("Procedure returned %d\n", dbretstatus(dbproc)); - } + erc = dbnullbind(dbproc, c, &pcol->status);]]> + if (erc == FAIL) { + fprintf(stderr, "%s:%d: dbnullbind(%d) failed\n", + options.appname, __LINE__, c); + exit(1); } - + } + printf("\n"); + + /* + * Print the data to stdout. + */ + while ((row_code = dbnextrow(dbproc)) != NO_MORE_ROWS){ + switch (row_code) { + case REG_ROW: + for (pcol=columns; pcol - columns < ncols; pcol++) { + char *buffer = pcol->status == -1? + "NULL" : pcol->buffer; + printf("%*s ", pcol->size, buffer); + } + printf("\n"); + break; + + case BUF_FULL: + assert(row_code != BUF_FULL); + break; + + case FAIL: + fprintf(stderr, "%s:%d: dbresults failed\n", + options.appname, __LINE__); + exit(1); + break; + + default: + printf("Data for computeid %d ignored\n", row_code); + } + + } + + /* free metadata and data buffers */ + for (pcol=columns; pcol - columns < ncols; pcol++) { + free(pcol->buffer); + } + free(columns); + + /* + * Get row count, if available. + */ + if (DBCOUNT(dbproc) > -1) + fprintf(stderr, "%d rows affected\n", DBCOUNT(dbproc)); + + /* + * Check return status + */ + if (dbhasretstat(dbproc) == TRUE) { + printf("Procedure returned %d\n", dbretstatus(dbproc)); + } + } + dbclose(dbproc); dbexit(); exit(0); -} - - Data-fetching Notes - As soon as dbresults() reports SUCCESS, the row's metadata are available. - db-lib columns start with 1. - dbcollen() returns the sizeof the native data (e.g. 4 bytes for a T-SQL INT). We'll use dbbind() to convert everything to strings. If the column is [VAR]CHAR, we want the column's defined size, otherwise we want its maximum size when represented as a string, which FreeTDS's dbwillconvert() returns (for fixed-length datatypes). For IMAGE data, we need to multiply by 2, because dbbind() will convert each byte to a hexadecimal pair. The example program will report an error with IMAGE data. - NTBSTRINGBIND null-terminates the character array for us. NTB might perhaps stand for null terminating byte. - A zero-length string is not a NULL! dbnullbind() arranges for the passed buffer to be set to -1 whenever that column is NULL for a particular row. - Each time dbnextrow() returns REG_ROW, it has filled the bound buffers with the converted values for the row. - Computed rows are left as an exercise to the reader. - - + } +
    + Data-fetching Notes + As soon as dbresults() reports SUCCESS, the row's metadata are available. + db-lib columns start with 1. + dbcollen() returns the sizeof the native data (e.g. 4 bytes for a T-SQL INT). We'll use dbbind() to convert everything to strings. If the column is [VAR]CHAR, we want the column's defined size, otherwise we want its maximum size when represented as a string, which FreeTDS's dbwillconvert() returns (for fixed-length datatypes). For IMAGE data, we need to multiply by 2, because dbbind() will convert each byte to a hexadecimal pair. The example program will report an error with IMAGE data. + NTBSTRINGBIND null-terminates the character array for us. NTB might perhaps stand for null terminating byte. + A zero-length string is not a NULL! dbnullbind() arranges for the passed buffer to be set to -1 whenever that column is NULL for a particular row. + Each time dbnextrow() returns REG_ROW, it has filled the bound buffers with the converted values for the row. + Computed rows are left as an exercise to the reader. +
    - - Messages and Errors - Errors may originate on the server or in the library itself. The former are known as messages (because they are: they arrive as messages from the server); the latter are termed errors. Their handling is a little intimidating. It requires writing and installing a callback function (whose parameters are predefined by db-lib), and thinking about how to handle different types of errors. - + + Messages and Errors + Errors may originate on the server or in the library itself. The former are known as messages (because they are: they arrive as messages from the server); the latter are termed errors. Their handling is a little intimidating. It requires writing and installing a callback function (whose parameters are predefined by db-lib), and thinking about how to handle different types of errors. + Kinds of Errors Messages - Messages arise because the server has something to say. Just one more way in which databases differ from files.. They usually describe some problem encountered executing the SQL. Perhaps the SQL refers to a nonexistent object or attempted to violate a constraint. But they can also be benign, indicating for instance merely that the default database has changed. - - + +Messages arise because the server has something to say. Just one more way in which databases differ from files.. They usually describe some problem encountered executing the SQL. Perhaps the SQL refers to a nonexistent object or attempted to violate a constraint. But they can also be benign, indicating for instance merely that the default database has changed. + + Errors - Errors arise either because the application has misused db-lib in some way — say, passed a NULL DBPROCESS pointer or tried to issue a query while results were pending — or because some trouble cropped up in communicating with the server (couldn't find it, say, or didn't hear back from it). - - - - Why these two require distinct handling is lost in the mists of time. But it does help to keep them distinct in your mind, especially while reading the documentation. + +Errors arise either because the application has misused db-lib in some way — say, passed a NULL DBPROCESS pointer or tried to issue a query while results were pending — or because some trouble cropped up in communicating with the server (couldn't find it, say, or didn't hear back from it). + + + + +Why these two require distinct handling is lost in the mists of time. But it does help to keep them distinct in your mind, especially while reading the documentation. - To have db-lib use your handler, pass its name to the appropriate dberrhandle() or dbmsghandle() function immediately after calling dbinit(). + +To have db-lib use your handler, pass its name to the appropriate dberrhandle() or dbmsghandle() function immediately after calling dbinit(). - - Sample Code: <symbol>db-lib</> Error and Message handlers - -int -msg_handler(DBPROCESS *dbproc, DBINT msgno, int msgstate, int severity, - char *msgtext, char *srvname, char *procname, int line) -{ + + + Sample Code: <symbol>db-lib</> Error and Message handlers + + int + msg_handler(DBPROCESS *dbproc, DBINT msgno, int msgstate, int severity, + char *msgtext, char *srvname, char *procname, int line) + { enum {changed_database = 5701, changed_language = 5703 }; - if (msgno == changed_database || msgno == changed_language) - return 0; - + if (msgno == changed_database || msgno == changed_language) + return 0; + if (msgno > 0) { - fprintf(stderr, "Msg %ld, Level %d, State %d\n", - (long) msgno, severity, msgstate); - - if (strlen(srvname) > 0) - fprintf(stderr, "Server '%s', ", srvname); - if (strlen(procname) > 0) - fprintf(stderr, "Procedure '%s', ", procname); - if (line > 0) - fprintf(stderr, "Line %d", line); - - fprintf(stderr, "\n\t"); + fprintf(stderr, "Msg %ld, Level %d, State %d\n", + (long) msgno, severity, msgstate); + + if (strlen(srvname) > 0) + fprintf(stderr, "Server '%s', ", srvname); + if (strlen(procname) > 0) + fprintf(stderr, "Procedure '%s', ", procname); + if (line > 0) + fprintf(stderr, "Line %d", line); + + fprintf(stderr, "\n\t"); } fprintf(stderr, "%s\n", msgtext); if (severity > 10) { - fprintf(stderr, "%s: error: severity %d > 10, exiting\n", - options.appname, severity); - exit(severity); + fprintf(stderr, "%s: error: severity %d > 10, exiting\n", + options.appname, severity); + exit(severity); } - + return 0; -} - -int -err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, - char *dberrstr, char *oserrstr) -{ + } + + int + err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, + char *dberrstr, char *oserrstr) + { if (dberr) { - fprintf(stderr, "%s: Msg %d, Level %d\n", - options.appname, dberr, severity); - fprintf(stderr, "%s\n\n", dberrstr); + fprintf(stderr, "%s: Msg %d, Level %d\n", + options.appname, dberr, severity); + fprintf(stderr, "%s\n\n", dberrstr); } - + else { - fprintf(stderr, "%s: DB-LIBRARY error:\n\t", options.appname); - fprintf(stderr, "%s\n", dberrstr); + fprintf(stderr, "%s: DB-LIBRARY error:\n\t", options.appname); + fprintf(stderr, "%s\n", dberrstr); } - + return INT_CANCEL; -} - - Handlers are always called before the function that engendered them returns control to the application. - Error Handling Notes - When first writing a handler, pay careful attention to the precise type of each parameter. Only by carefully matching them will you convince a modern C compiler that the address of your function is of the type accepted by dbmsghandle(). Back in K&R days, that wasn't such a problem. But there were other problems, some much worse. - Some messages don't convey much, as though the server gets lonely sometimes. You're not obliged to print every one. - Severities are defined in the server documentation, and can be set by the T-SQL RAISERROR statement. - Message handlers always and only ever return zero. - When first writing the handler, pay careful attention to the precise type of each parameter. Only by carefully matching them will you convince a modern C compiler that the address of your function is of the type accepted by dberrhandle(). If that advice sounds familiar, it's because it bears repeating. - Some messages are so severe they provoke db-lib into calling the error handler, too! If you have both installed — and of course you do, right? — then you can skip those lacking an error number. - While INT_CANCEL is the most common return code, it's not the only one. For one thing, the error handler's return code can control how long db-lib keeps retrying timeout errors. See the documentation for details. - - - - No matter what the error handler says or does, it can't remedy the error. It's still an error and usually the best that can happen is that the function will return FAIL. The exception is timeout conditions, when the handler can stave off failure by requesting retries. + } + + Handlers are always called before the function that engendered them returns control to the application. + Error Handling Notes + When first writing a handler, pay careful attention to the precise type of each parameter. Only by carefully matching them will you convince a modern C compiler that the address of your function is of the type accepted by dbmsghandle(). Back in K&R days, that wasn't such a problem. But there were other problems, some much worse. + Some messages don't convey much, as though the server gets lonely sometimes. You're not obliged to print every one. + Severities are defined in the server documentation, and can be set by the T-SQL RAISERROR statement. + Message handlers always and only ever return zero. + When first writing the handler, pay careful attention to the precise type of each parameter. Only by carefully matching them will you convince a modern C compiler that the address of your function is of the type accepted by dberrhandle(). If that advice sounds familiar, it's because it bears repeating. + Some messages are so severe they provoke db-lib into calling the error handler, too! If you have both installed — and of course you do, right? — then you can skip those lacking an error number. + While INT_CANCEL is the most common return code, it's not the only one. For one thing, the error handler's return code can control how long db-lib keeps retrying timeout errors. See the documentation for details. + - You may be asking yourself, OK, fine, I can print the error message. But what if I want to communicate something back to line in my program where the error occurred? How to do that? First of all, remember the calling function — that's your application — will learn of an error from the return code. If it needs more detail, though, there are two ways to pass it. + +No matter what the error handler says or does, it can't remedy the error. It's still an error and usually the best that can happen is that the function will return FAIL. The exception is timeout conditions, when the handler can stave off failure by requesting retries. - - Set a global variable. - Use setuserdata() and - getuserdata(). - + +You may be asking yourself, OK, fine, I can print the error message. But what if I want to communicate something back to line in my program where the error occurred? How to do that? First of all, remember the calling function — that's your application — will learn of an error from the return code. If it needs more detail, though, there are two ways to pass it. + + + Set a global variable. + Use setuserdata() and + getuserdata(). + + + If your application is written in C++, you may be tempted to use throw(). Don't! Your handler is a C function and, more important, it's an extension of db-lib. You can put a throw() in your handler and it will compile. But when it executes, it's going to rip through db-lib's stack. Your application will be unuseable at that point, if it doesn't cause a segment fault. - If your application is written in C++, you may be tempted to use throw(). Don't! Your handler is a C function and, more important, it's an extension of db-lib. You can put a throw() in your handler and it will compile. But when it executes, it's going to rip through db-lib's stack. Your application will be unuseable at that point, if it doesn't cause a segment fault. - - - - Last Remarks - We've reached the end of our db-lib tour. The almost 300 lines of C above constitute program with these features: + + Last Remarks + +We've reached the end of our db-lib tour. The almost 300 lines of C above constitute program with these features: Sample Code features</> - <listitem><para>Accepts command-line parameters and SQL. </para></listitem> - <listitem><para>Checks for errors and server messages. </para></listitem> - <listitem><para>Processes any number of results.. </para></listitem> - <listitem><para>Prints results in columns of suitable widths. </para></listitem> - </itemizedlist> + <listitem><para>Accepts command-line parameters and SQL.</para></listitem> + <listitem><para>Checks for errors and server messages.</para></listitem> + <listitem><para>Processes any number of results..</para></listitem> + <listitem><para>Prints results in columns of suitable widths.</para></listitem> + </itemizedlist> There are things it doesn't do, in the name of simplicity. <itemizedlist><title> Sample Code nonfeatures</> - <listitem><para>No BCP (bulk copy) mode </para></listitem> - <listitem><para>No RPC (remote procedure call) mode, preventing it from retrieving output parameters. </para></listitem> - </itemizedlist> - Your humble author hopes you found it worthwhile. Happy Hacking. - </para> + <listitem><para>No BCP (bulk copy) mode</para></listitem> + <listitem><para>No RPC (remote procedure call) mode, preventing it from retrieving output parameters.</para></listitem> + </itemizedlist> + Your humble author hopes you found it worthwhile. Happy Hacking.</para> </sect2> - - - + </sect1> </chapter> - <!-- ////////////////// CHAPTER /////////////////////// --> - <chapter id="acknowledgments"> - <title>Acknowledgments - - Codesmyths - Many people, too many to mention, have contributed patches and located bugs. The primary names are: - - - -Brian Bruns (brian@bruns.org) -Started this crazy thing - -Mihai Ibanescu (misa@dntis.ro) -GNUified the packet - -Gregg Jensen (greggj@savvis.com) -Message handlers and extra datatype support and some sybperl stuff - -James K. Lowden (jklowden@schemamania.org) -Wrote most of the documentation. Helped out here and there. - -Steve Murphree (smurph@smcomp.com) -Added more ODBC functionality. - -Arno Pedusaar (psaar@fenar.ee) -Donated his TDS4.2 code to the cause - -Mark Schaal (mark@champ.tstonramp.com) -Cleaned up message handling, more datatype support, bug fixes - -Craig Spannring (cts@internetcds.com) -Wrote the JDBC and DBI drivers - -Bill Thompson (thompbil@exchange.uk.ml.com) -Completer of the db-lib bcp API and author of freebcp. - -Frediano Ziglio (freddy77@gmail.com) -Extended the ODBC library, and added many, many fixes and enhancements to libtds. + + + Acknowledgments + + Codesmyths + +Many people, too many to mention, have contributed patches and located bugs. The primary names are: + + + Brian Bruns (brian@bruns.org) + Started this crazy thing + + Mihai Ibanescu (misa@dntis.ro) + GNUified the packet + + Gregg Jensen (greggj@savvis.com) + Message handlers and extra datatype support and some sybperl stuff + + James K. Lowden (jklowden@schemamania.org) + Wrote most of the documentation. Helped out here and there. + + Steve Murphree (smurph@smcomp.com) + Added more ODBC functionality. + + Arno Pedusaar (psaar@fenar.ee) + Donated his TDS4.2 code to the cause + + Mark Schaal (mark@champ.tstonramp.com) + Cleaned up message handling, more datatype support, bug fixes + + Craig Spannring (cts@internetcds.com) + Wrote the JDBC and DBI drivers + + Bill Thompson (thompbil@exchange.uk.ml.com) + Completer of the &dblib; bcp API and author of freebcp. + + Frediano Ziglio (freddy77@gmail.com) + Extended the ODBC library, and added many, many fixes and enhancements to libtds. - - - - - Contributors - This user guide owes at least 100 words each to the following people. - - - Brian Bruns - James Cameron - Allen Grace - James K. Lowden - Bill Thompson - Frediano Ziglio - - - + + + + Contributors + +This user guide owes at least 100 words each to the following people. + + Brian Bruns + James Cameron + Allen Grace + James K. Lowden + Bill Thompson + Frediano Ziglio + + + + + + + + + On Linkers + &freetds; is a library, obviously, its functions invoked by an application. How the application finds the library can be mysterious. In the interest of making &freetds; easier to use, this appendix discusses how it all works. + This appendix focusses on using &freetds; in your application. It isn't intended to help in building &freetds;, although the background information it provides might be useful. + + +
    + What is a C function? + +A C function is a named bit of code. + +A C compiler recognizes function names in source code by parsing the C language. When it encounters a function name, it looks for a definition for the function — i.e. actual code implementing it — in the current file. If it finds one, it creates machine instructions to push any parameters on the stack, jump to the named address, and clear the stack after the functions returns. If it doesn't find one, it shrugsYou have to watch carefully. Modern compilers shrug quickly. and adds that name to the list of names to be resolved later. We'll get to what that means in a minute. + +The compiler's job ends where the linker's begins. + Compiler's job + Convert source code into object code + Put in jumps to defined functions + Create a list of defined functions, and their addresses + Create a list of undefined ones + + +The nm utility displays function names. Here are the ones defined by bsqldb.c (in bsqsldb.o): + +$ nm bsqldb.o | grep -wi t +0000000000000000 T err_handler +0000000000000270 T get_login +00000000000001d0 t get_printable_size +0000000000000940 T main +00000000000000a0 T msg_handler +00000000000007d0 t next_query +00000000000006c0 t set_format_string +0000000000000080 t usage + +GNU nm marks with a lower-case letter functions that are locally defined, not intended to be used outside the file. The C programmer marked those functions static. Note how closely the source code corresponds to the object code: + +$ grep ^static src/bsqldb.c +static int next_query(DBPROCESS *dbproc); +static void print_results(DBPROCESS *dbproc); +static int get_printable_size(int type, int size); +static void usage(const char invoked_as[]); +static int set_format_string(struct METADATA * meta, const char separator[]); + + +(Order doesn't matter. It's a set, not a list.) + + +Here are some functions used, but not defined, by bsqldb.o: + +$ nm bsqldb.o | grep -w U | head + U __assert_fail + U __ctype_b_loc + U __errno_location + U __strdup + U __xpg_basename + U asprintf + U calloc + U dbaltbind + U dbaltcolid + U dbaltlen + +Two things to note. First, the functions defined by bsqldb.o have addresses, and those that don't, don't. Second, only the name identifies the function. It's been that way since about 1978, and it's one reason C libraries are so useful: to find a function, the tool need only resolve the name, i.e. convert the name into an address. The caller (the programmer, really) has to know the function's inputs and semantics (how it behaves), but the tool's job is bone simple. Which turns out to be quite handy. + + + +
    - +
    + What is a C library? +A C library is a set of named functions, for example dbinit() or SQLConnect(). Or, for that matter, fopen(3)The Unix convention is to put in parentheses behind the name the section of the manual in which the function is documented. &freetds; functions don't get numbers because they're not in the manual. Yet. . + +Libraries come in two flavors: static and dynamic. + +
    + Static libraries +Static libraries (also known as archives) have been around as long as C itself. Like a .zip file, they're just a bag of object files — containing functions, of course — with a table of contents in front giving the address of each nameOr, depending on how you look at it, the name of each address.. Static libraries are created from object files using a librarian utility of some kind. One such programs is ar, for archive. + +Static libraries are part of the build environment. Functions in static libraries are joined to a program's main module by a static linker at build time to produce an executable program. The executable incorporates the libraries' object code into its own body, making it completely self-sufficient. +
    + +
    + Dynamic libraries + +Dynamic libraries are the new kid on the block, as these things go, arriving on the Unix scene circa 1985. Like a static library, a dynamic library is a collection of functions with a table of contents. They are referenced at build time to give the executatble information about how they will eventually be used, but they aren't used until run time. + +Dynamic libraries are part of the run-time environment. When a program is run, the run-time linker finds the dynamic libraries needed by the program, finds the addresses of the required functions, and assembles a runable image in memory. Missing libraries and/or missing functions — or the wrong versions of them — can lead to head-scratching and other amusing behavior. + +In Windows® dynamic libraries are called dynamic link libraries (DLLs). In Unix they're normally called shared objects. But they're roughly the same thing. + + + What about <literal>.h</literal> files? + +C header files include functional prototypes, declarations (not definitions) of functions. Functional prototypes describe to the compiler each function's parameters, allowing the compiler to confirm that the function is being called correctly. + +Most of the functions declared in header files are implemented in libraries. However, there's no mechanical or automatic relationship between the functional prototypes in the header files and the implementation of those same functions in a library. The .h file is maintained by hand, by the programmer, and is used to generate a library. The header file and associated library are distributed and installed together (one hopes), but correct installation and subsequent use by the compiler & linker require human beings to keep track of the pair. Failure to do so leads to interesting development and even run-time problems, especially with libraries whose functions' parameters frequently change from version to version. + +For example, imagine a function f(int g) defined in library libf.so and declared in f.h. In a later version of libf.so, the function's parameter is changed to use a pointer, f(int *p), and f.h is likewise updated. Possible errors that cannot be prevented by the linker include: + + + An old program could use the new library. Probably the integer it passes will be interpreted as an out-of-bounds address, resulting in a segmentation violation. - The <filename>interfaces</filename> File - The interfaces file is retained for compatibility with Sybase environments. It is recommended that new users use the freetds.conf format instead. - - Where it came from - -Under Sybase OpenClient there is a file called interfaces that defines servers available to the software. &freetds; inherited this file structure with minor alterations. The interfaces remains supported for backward compatibility, and for those running in a mixed &freetds;/Sybase environment. - - -The interfaces is not read by &freetds; unless it does not find &freetdsconf;. Note also that make install will install a skeleton &freetdsconf;, which you'll have to remove if you want to use interfaces instead. + A new program could use the old library, passing an address that the library interprets as an integer. Hillarity ensues. + + Existing source code could be compiled using the old header file but linked to the new library. If you've never done that, give it time. + + +These errors are possible because C functions are identified to the linker by name only. On the upside, that makes the tools simple and easy to implement and, by the same token, simplifies the use of C libraries by other languages. The downside is that the work of ensuring that the right libraries are used becomes an administrative task instead of a technical one. + +
    +
    +
    + Checking if a Library Provides a Function + +A linker, any linker, knits together object files (some of which may be in libraries) such that every function needed by the program has a definition. If the linker fails to locate a definition for even one function, it will fail and the program will not run. + +Returning to bsqldb.o, we can use nm to see which functions are unresolved, and determine whether or not a particular library contains them. We'll ignore the first symbols start with an underscore, marking them per the C standard as being provided by the implementationWhy and how leading underscores enter into this discussion is just one more example of arcane historical practices one needs to know to master the subject. For our purposes, though, it's enough to know that implementation-provided functions like these — functions provided by the C standard library — often have an underscored prepended. , and focus on the last five in this abbreviated list. + + + Some unresolved functions in <filename>bsqldb.o</filename> + + asprintf + basename + + Normally provided by the standard C library, but if not by &freetds;'s replacements library: +$ nm /usr/lib/libc.a | grep -w T | grep -E 'asprintf|basename' + +0000000000000000 T _basename +0000000000000000 T _asprintf + - - - Where it goes - -Anywhere. The SYBASE environment variable must contain the location of interfaces; that is how &freetds; will find it. + + + + calloc + + Provided by the standard C library: +$ nm /usr/lib/libc.a | grep -w T | grep calloc +0000000000004240 T calloc + - - - What it does - -The interfaces file aliases a servername to the hostname and port number of the servername's machine. When &freetds; receives a request to connect to a database server, it looks up the servername in interfaces. There, it finds the machine name (or address) and port number to connect to, that is, the port where the database server is listening. + + + + dbaltbind + dbaltcolid + + Provided by &dblib;: +$ nm libsybdb.a | grep -Ew 'dbaltbind|dbaltcolid' +0000000000007140 T dbaltbind +0000000000003590 T dbaltcolid + + + + - How's that again? - -The interfaces file sometimes trips people up. It seems innocuous enough, but it's also a pretty good example of it's easy if you know how. Keep in mind: - +Although these examples refer to static libraries, nm works just as well with dynamic libraries, too. + - - The servername is the name of the database server. When a database client specifies the name of the server to connect to, it's the servername that is used. - - The host name is the name of the host (machine) where the database server is running. It has an IP address, and in almost any environment, you can ping the machine name to see if you've got it right. After it uses the servername to look up the host name, &freetds; will do the same thing ping does to get the IP address of the machine to connect to. - - Finally, the port number is frequently overlooked. From the network's point of view, knowing the IP address without the port number is a little like knowing the address of an apartment building without knowing the apartment number. In both cases, it will be hard to find what you came for. Make sure you know the port number, and that it's correctly entered in the interfaces file. - - - - +There are other tools besides nm. Windows®, for instance, has dumpbin, and the GNU bintools include objdump. +
    - - What it looks like - -The format of the interfaces file is borrowed directly from that used by Sybase on Unix platforms (Windows has a different format). Additionally, we have overloaded one of the fields to add the ability to set the protocol version. An example interfaces file looks like this. - - - -An <filename>interfaces</filename> file example - -myserver - query tcp 4.2 127.0.0.1 4000 - master tcp ether 127.0.0.1 4000 - +
    + How Dost Thy Linker Link? + +Now at last we come to how the linker performs its magic. Once again the discussion divides between static and dynamic linking. + +
    + Static Linker + +Static linking happens at build time. Object files are collected together; a distinct list of all function names is created, and the linker is tasked with finding a definition for each one. + +Different linkers have different command-line options to support OS-specific features. This document isn't intended to teach how to use any particular linker. Our task here is to understand the principles involved, so that you can apply them to your particular situation. + +The static linker needs three kinds of information: +Static linker inputs + Object modules to be linked, including libraries + Locations of libraries + Search order + + +
    + Knitting together the object modules +The static linker merges your object files into one executable. Your project's object files may refer freely (usually) to each other's functions, and the linker will match them up. It will catenate them together, compute every funtion's offset from the start of the executable, and replace every function reference with the actual address needed for the executable it's constructing. For library functions, definitions are copied from the library and appended to the output file (executable). The placeholder addresses left by the compiler are similarly replaced by offsets. +
    + +
    + Specifying libraries + +An application programmer using &freetds; will need to mention the name fo the &freetds; library being used. Failure to do so will provoke the dread undefined reference linker error: + +Missing library name +$ gcc -o bsqldb bsqldb.o +bsqldb.o: In function `get_login': +../../../src/apps/bsqldb.c:816: undefined reference to `dblogin' +../../../src/apps/bsqldb.c:823: undefined reference to `dbsetlname' +../../../src/apps/bsqldb.c:874: undefined reference to `dbsetlname' +../../../src/apps/bsqldb.c:884: undefined reference to `dbsetlname' +../../../src/apps/bsqldb.c:889: undefined reference to `dbsetlname' +… + - - -The entry starts with the servername beginning in the first column (no -whitespace preceding it). Following the servername are one or more services lines which must be indented with whitespace. &freetds; uses only the query line, although others may be present to retain compatibility with Sybase. + +
    - - -The fields in the services lines are as follows. - -Services Line - - - - Name - Example - Meaning - - - - - service - query - The only supported service - - - transport - tcp - The transport protocol to use. Only tcp is supported by &freetds;. - - - physical - 4.2 - Historically this field referred the physical/datalink layer, however it appears to simply a comment field. Therefore, &freetds; optionally uses it to specify the protocol version to connect with. - - - hostname/IP - 127.0.0.1 - The hostname or IP address where the SQL Server resides. - - - port - 4000 - The TCP port where the SQL Server is listening. - - - -
    -
    - -In the example above, the hostname was entered as an IP address. It needn't be; it could just as well be a name. &freetds; can use a name rather than an address; it will just let the network (specifically, the resolver get the address. - +
    + Finding libraries + +Specifying the library is necessary but may be insufficient. The linker may need to be told where to look for the library. This is often the case for the application programmer using &freetds; because the &freetds; libraries may be installed in a location not on the linker's default search path. Linkers are usually pretty blunt about missing libraries: + +Library not found +$ gcc -o bsqldb bsqldb.o -l sybdb +ld: cannot find -lsybdb + + + + +Order matters. Linkers tend to be fussy about library search order, some more than others. It's good practice to tell the linker to search project libraries first, third-party libraries (e.g. iconv or kerberos) next, and finally system libraries. + +
    +
    + +
    + Dynamic Linker +The dynamic linker — also known as the runtime linker — is, like the rest of dynamic linking, more complicated than its static counterpart. Whereas it's impossible even to generate an executable with missing static function references, an executable that uses dynamic libraries depends on the runtime environment to have its references satisfied. + +When a dynamically linked application is launched, the OS invokes the runtime linker to resolve any undefined references. Much as the static linker does, the runtime linker consults a list of dynamic libraries along its configured search path. The names of the libraries to search for are embedded in the executable. Sometimes, not always, the search path is found in the executable too. Usually any embedded path can be overridden. + +
    + Information in the executable + +Exactly what information is in the executable and how to display it depends on the format of the executable. Different OSes use different formats and most Unix derivatives actually support at least two. The most commonly encountered format for the &freetds; programmer is the ELF format. In the interest of your time and mine, that's the one we'll examine here. + +The GNU bintool utility readelf displays the information in the executable that is input to the runtime linker: + +$ readelf -d src/apps/.libs/bsqldb +Dynamic section at offset 0x6028 contains 20 entries: + Tag Type Name/Value + 0x0000000000000001 (NEEDED) Shared library: [libsybdb.so.5] + 0x0000000000000001 (NEEDED) Shared library: [libpthread.so.0] + 0x0000000000000001 (NEEDED) Shared library: [libc.so.12] + 0x000000000000000f (RPATH) Library rpath: [/usr/pkg/lib:/usr/local/lib] +… + + + +What is this telling us? First, the bsqldb executable uses three shared libraries, namely sybdb for &dblib;, pthread for POSIX threads, and c, the C standard library. The runtime linker is going to have to find those somewhere, and it's going to use only those libraries to resolve unresolved references in the executable. + +Second, readelf displays the RPATH. The runtime linker searches for the required dynamic libraries in the directories listed in the RPATH, if extant. + +The RPATH is placed in the executable by the static linker. It can be thought of as a hint from the application builder to the system administrator. If an executable is built with an appropriate RPATH, the runtine linker will have all the information it needs to find the required libraries. +
    + +
    + Information outside the executable + +Runtime linkers differ. The advice and observations that follow apply in many situations, but not all. The best way to know how yours works is to consult your system's documentation. RTFM! + +The NetBSD and GNU linkers both (as of this writing on machines used by the author) honor a configuration file and environment variables. They also have compiled-in default search locations. At a minimum, the default is /usr/lib. Sometimes a configuration file extends this to /usr/local/lib. + +The primary environment variable is LD_LIBRARY_PATH. On some systems this overrides the RPATH in the executable. In others it doesn't. Where ineffective, specific libraries (not their paths) can be forceably used with LD_PRELOAD. +
    + +
    + Displaying what the Runtime linker will do + +The ldd(1) shows which dynamic libraries an executable requires and where, if at all, they'll be found: + +$ ldd $(command -v bsqldb) +/usr/local/bin/bsqldb: + -lc.12 => /usr/lib/libc.so.12 + -lpthread.0 => /usr/lib/libpthread.so.0 + -lsybdb.5 => /usr/local/lib/libsybdb.so.5 + + +Important to understand: ldd is not figuring out this information by itself. All it does is report the results of its interrogation of the runtime linker. As the configuration of the runtime linker is changed, so changes the output of ldd. +
    + +
    + Advice for the lazy + +To avoid tinkering with your runtime linker, embed an RPATH in your executable commensurate with its intended runtime environment. If ldd doesn't show the libraries you want, or some are not found, use readelf to see which libraries are used and the RPATH. Relink with a better RPATH if needed. + +When testing with new libraries, use LD_PRELOAD to override the default, taking care that the semantics haven't changed. + +
    + +
    +
    +
    + +The <filename>interfaces</filename> File + The interfaces file is retained for compatibility with Sybase environments. It is recommended that new users use the freetds.conf format instead. + + Where it came from + +Under Sybase OpenClient there is a file called interfaces that defines servers available to the software. &freetds; inherited this file structure with minor alterations. The interfaces remains supported for backward compatibility, and for those running in a mixed &freetds;/Sybase environment. + +The interfaces is not read by &freetds; unless it does not find &freetdsconf;. Note also that make install will install a skeleton &freetdsconf;, which you'll have to remove if you want to use interfaces instead. + + + Where it goes + +Anywhere. The SYBASE environment variable must contain the location of interfaces; that is how &freetds; will find it. + + + What it does + +The interfaces file aliases a servername to the hostname and port number of the servername's machine. When &freetds; receives a request to connect to a database server, it looks up the servername in interfaces. There, it finds the machine name (or address) and port number to connect to, that is, the port where the database server is listening. + + How's that again? + +The interfaces file sometimes trips people up. It seems innocuous enough, but it's also a pretty good example of it's easy if you know how. Keep in mind: + + + The servername is the name of the database server. When a database client specifies the name of the server to connect to, it's the servername that is used. + + The host name is the name of the host (machine) where the database server is running. It has an IP address, and in almost any environment, you can ping the machine name to see if you've got it right. After it uses the servername to look up the host name, &freetds; will do the same thing ping does to get the IP address of the machine to connect to. + + Finally, the port number is frequently overlooked. From the network's point of view, knowing the IP address without the port number is a little like knowing the address of an apartment building without knowing the apartment number. In both cases, it will be hard to find what you came for. Make sure you know the port number, and that it's correctly entered in the interfaces file. + + + + + + + What it looks like + +The format of the interfaces file is borrowed directly from that used by Sybase on Unix platforms (Windows has a different format). Additionally, we have overloaded one of the fields to add the ability to set the protocol version. An example interfaces file looks like this. + + + An <filename>interfaces</filename> file example + + myserver + query tcp 4.2 127.0.0.1 4000 + master tcp ether 127.0.0.1 4000 + + + +The entry starts with the servername beginning in the first column (no + whitespace preceding it). Following the servername are one or more services lines which must be indented with whitespace. &freetds; uses only the query line, although others may be present to retain compatibility with Sybase. + +The fields in the services lines are as follows. + + Services Line + + + + Name + Example + Meaning + + + + + service + query + The only supported service + + + transport + tcp + The transport protocol to use. Only tcp is supported by &freetds;. + + + physical + 4.2 + Historically this field referred the physical/datalink layer, however it appears to simply a comment field. Therefore, &freetds; optionally uses it to specify the protocol version to connect with. + + + hostname/IP + 127.0.0.1 + The hostname or IP address where the SQL Server resides. + + + port + 4000 + The TCP port where the SQL Server is listening. + + + +
    + +In the example above, the hostname was entered as an IP address. It needn't be; it could just as well be a name. &freetds; can use a name rather than an address; it will just let the network (specifically, the resolver get the address.
    - About Unicode, UCS-2, and UTF-8 - -For better or worse, &freetds; brings the otherwise innocent programmer into contact with the arcane business of how data are stored and transported. &freetds; is a data communications library that of course connects to databases, which are charged with storing information in a way that is neutral to all architectures and languages. On the surface, that might not seem very complex, even worth discussing. Under the surface, things are not so simple. - -
    <acronym>ASCII</>: What everyone knows - -The world we are all familiar with, programmingwise, is ASCII. Our email (mostly), our text files, our web pages (mostly), all use ASCII to represent English (or English-like) text. Perhaps because ASCII czyborra.com is offline at the time of this writing (December 2003). It contained good information, so it's still included here, in case it comes back to life. was standardized back in 1972 by the ISO, it seems like the natural way to store information. But let's look under the hood a little bit, and examine our assumptions. - - -Our so-called text files are nothing special, nothing but a little agreement we enter into with our operating system. The only reason we can read them with cat or vi is that the operating system and its tools are in on the agreement. A file is only a stream of bytes, after all, no more text than an executable. The only thing distinguishing a text file from any other, is our understanding to treat it like one. We agree that the number 65 will represent the letter A, 66, B, and so on, 127 values in all. See man ascii for further details. - - -The important thing to understand is that the designation of 65 for A and so on is a choice. It's an encoding standard, made necessary by the old simple fact that computers store numbers, not letters. ASCII is so ubiquitous these days that it's hard sometimes to remember there was a time when it was but one of a set of competing encoding standards. Others you probably have heard of include EBCDIC and the Baudot systems, but they are by no means the only historical alternatives, nor the only modern ones. - +About Unicode, UCS-2, and UTF-8 + +For better or worse, &freetds; brings the otherwise innocent programmer into contact with the arcane business of how data are stored and transported. &freetds; is a data communications library that of course connects to databases, which are charged with storing information in a way that is neutral to all architectures and languages. On the surface, that might not seem very complex, even worth discussing. Under the surface, things are not so simple. +
    <acronym>ASCII</>: What everyone knows + +The world we are all familiar with, programmingwise, is ASCII. Our email (mostly), our text files, our web pages (mostly), all use ASCII to represent English (or English-like) text. Perhaps because ASCII czyborra.com is offline at the time of this writing (December 2003). It contained good information, so it's still included here, in case it comes back to life. was standardized back in 1972 by the ISO, it seems like the natural way to store information. But let's look under the hood a little bit, and examine our assumptions. + +Our so-called text files are nothing special, nothing but a little agreement we enter into with our operating system. The only reason we can read them with cat or vi is that the operating system and its tools are in on the agreement. A file is only a stream of bytes, after all, no more text than an executable. The only thing distinguishing a text file from any other, is our understanding to treat it like one. We agree that the number 65 will represent the letter A, 66, B, and so on, 127 values in all. See man ascii for further details. + +The important thing to understand is that the designation of 65 for A and so on is a choice. It's an encoding standard, made necessary by the old simple fact that computers store numbers, not letters. ASCII is so ubiquitous these days that it's hard sometimes to remember there was a time when it was but one of a set of competing encoding standards. Others you probably have heard of include EBCDIC and the Baudot systems, but they are by no means the only historical alternatives, nor the only modern ones.
    The <acronym>ASCII</> Compact - -UNIX® and unix-like systems bought into ASCII big time. Program code, filenames, string constants (and variables), configuration files, everything but everything is encoded in ASCII. Practically every utility, command, and library assumes the text data will be ASCII. At the dawn of the 21st century, there is widespread recognition that ASCII will no longer suffice, but the art of upgrading all the computers and computer programmers is, well, an unfinished work. - -
    + +UNIX® and unix-like systems bought into ASCII big time. Program code, filenames, string constants (and variables), configuration files, everything but everything is encoded in ASCII. Practically every utility, command, and library assumes the text data will be ASCII. At the dawn of the 21st century, there is widespread recognition that ASCII will no longer suffice, but the art of upgrading all the computers and computer programmers is, well, an unfinished work. +
    -
    ISO 8859: What everyone would like to forget - -ASCII won, it would seem, but the race goes not to the swift. ASCII has many limitations, the most egregious of which is, it's not much good for anything besides English. It encodes all the letters and punctuation (almost) of the English alphabet, but is useless for German, Russian, and Greek, to say nothing of Chinese. - - -ASCII assigns one byte to every character, but deals with only 7 of the 8 available bits, the range 0-127 (with the high bit always zero). Demand for computers that could display and print languages besides English — even English with em dashes and cent (¢) signs — arrived soon enough, with the Marketing Department way out in front of the propeller heads. The predictable result was an array of 8-bit ASCII encoding standards for a wide variety of alphabets. Eventually, they were standardized (or at least enumerated and documented) by the ISO. These are what our friendly database vendors are referring to when they talk about character sets. More information on this subject can be found at webreference.com. - - - -The upshot is, there is no uniform standard, no agreement on the meaning of a byte, particularly if that byte's value is greater than 127. Let's say your client machine sends HELLO and your database stores it as 72 69 76 76 79. When another client retrieves that value, it will convert it into human-readable form by applying an encoding standard. If everything's tightly wrapped, it will use the very same encoding that your database used (and the same one you had in mind when you sent it), and that client will also see HELLO. If things are not so tightly wrapped but that client is fortunate enough to be using a similar standard to what you were using, say, ISO 8859-1, he'll still see HELLO. Most languages based on the Roman alphabet can be represented by ISO 8859-1, and are thus interchangeable. Beyond that, things get quickly messy. Greek clients, for one, are not so lucky: there are three ISO 8859 standards for Greek, all mutually incompatible. +
    ISO 8859: What everyone would like to forget -For more information, see ISO 8859 Alphabet Soup. Roman Czyborra's site is very informative; take your time there if you don't want your head to spin. - - -Database servers need to know what encoding standard to employ, too. It's not obvious at first, but notions like uppercase and lowercase, trailing blanks, and collation rules all depend on what letter is meant by what number. (Collation even depends on what culture is interpreting the letters.) - +ASCII won, it would seem, but the race goes not to the swift. ASCII has many limitations, the most egregious of which is, it's not much good for anything besides English. It encodes all the letters and punctuation (almost) of the English alphabet, but is useless for German, Russian, and Greek, to say nothing of Chinese. + +ASCII assigns one byte to every character, but deals with only 7 of the 8 available bits, the range 0-127 (with the high bit always zero). Demand for computers that could display and print languages besides English — even English with em dashes and cent (¢) signs — arrived soon enough, with the Marketing Department way out in front of the propeller heads. The predictable result was an array of 8-bit ASCII encoding standards for a wide variety of alphabets. Eventually, they were standardized (or at least enumerated and documented) by the ISO. These are what our friendly database vendors are referring to when they talk about character sets. More information on this subject can be found at webreference.com. + +The upshot is, there is no uniform standard, no agreement on the meaning of a byte, particularly if that byte's value is greater than 127. Let's say your client machine sends HELLO and your database stores it as 72 69 76 76 79. When another client retrieves that value, it will convert it into human-readable form by applying an encoding standard. If everything's tightly wrapped, it will use the very same encoding that your database used (and the same one you had in mind when you sent it), and that client will also see HELLO. If things are not so tightly wrapped but that client is fortunate enough to be using a similar standard to what you were using, say, ISO 8859-1, he'll still see HELLO. Most languages based on the Roman alphabet can be represented by ISO 8859-1, and are thus interchangeable. Beyond that, things get quickly messy. Greek clients, for one, are not so lucky: there are three ISO 8859 standards for Greek, all mutually incompatible. + + For more information, see ISO 8859 Alphabet Soup. Roman Czyborra's site is very informative; take your time there if you don't want your head to spin. + +Database servers need to know what encoding standard to employ, too. It's not obvious at first, but notions like uppercase and lowercase, trailing blanks, and collation rules all depend on what letter is meant by what number. (Collation even depends on what culture is interpreting the letters.)
    -
    Unicode: East meets West - -ASCII and its 8-bit cousins are on the way out, and with them the assumption that a character can be represented by a single byte. The new kid on the block is Unicode, similar to but not precisely the same as ISO 10646. Unicode (despite its name) is a set of standards. The most widely implemented is the 16-bit form, called UCS-2. As you might guess, UCS-2 uses two bytes per character, allowing it to encode most characters of most languages. Because most is far from all, there are nascent 32-bit forms, too, but they are neither complete nor in common use. - - -In the same sense that 7-bit ASCII was extended to 8 bits, Unicode extends the most prevalent 8-bit ASCII, ISO 8859-1, to 16 and 32 bits. The first 256 values remain in Unicode as in ISO 8859-1: 65 is still A, except instead of being 8 bits (0x40), it's 16 bits (0x0040). Unlike the 8-bit extensions, Unicode has a unique 1:1 map of numbers to characters, so no language context or character set name is needed to decode a Unicode string. - - -UCS-2 is the system employed by Microsoft NT-based systems. Microsoft database servers store UCS-2 strings in nchar and nvarchar datatypes. Microsoft also designed version 7.0 (and up) of the TDS protocol around UCS-2: all metadata (table names and such) are encoded according to UCS-2 on the wire. - +
    Unicode: East meets West + +ASCII and its 8-bit cousins are on the way out, and with them the assumption that a character can be represented by a single byte. The new kid on the block is Unicode, similar to but not precisely the same as ISO 10646. Unicode (despite its name) is a set of standards. The most widely implemented is the 16-bit form, called UCS-2. As you might guess, UCS-2 uses two bytes per character, allowing it to encode most characters of most languages. Because most is far from all, there are nascent 32-bit forms, too, but they are neither complete nor in common use. + +In the same sense that 7-bit ASCII was extended to 8 bits, Unicode extends the most prevalent 8-bit ASCII, ISO 8859-1, to 16 and 32 bits. The first 256 values remain in Unicode as in ISO 8859-1: 65 is still A, except instead of being 8 bits (0x40), it's 16 bits (0x0040). Unlike the 8-bit extensions, Unicode has a unique 1:1 map of numbers to characters, so no language context or character set name is needed to decode a Unicode string. + +UCS-2 is the system employed by Microsoft NT-based systems. Microsoft database servers store UCS-2 strings in nchar and nvarchar datatypes. Microsoft also designed version 7.0 (and up) of the TDS protocol around UCS-2: all metadata (table names and such) are encoded according to UCS-2 on the wire.
    -
    Unicode's Pluses and Minuses - -You will read from time to time that Unicode is not perfect. Surprise, surprise: it's true. From a linguistic point of view, Unicode is incomplete; in particular, UCS-2 is demonstrably too small (!) to hold all the forms of Chinese ideographs used over the centuries. (It is, however, quite useful and widely employed in representing modern Chinese.) Of more common concern to programmers are Unicode's technical problems, or rather, Unix's technical shortcomings vis-a-vis any encoding more complex than ISO 8859-x. - - -The basic problem, from a programmer's perspective, is the ancient agreement Unix entered into 30 years ago, the ASCII Compact, alluded to earlier. Assumptions about ASCII are littered throughout Unix-like systems, beginning with C's convention of representing strings as arrays of characters ending in a zero. Returning to our HELLO example earlier, C will store HELLO as 72 69 76 76 79 0, in very nice ASCII. Many many parts of the operating system and its associated tools and applications will recognize that as a 5-letter word because it's terminated by a null (zero). In UCS-2 Unicode, though, that same HELLO uses 2 bytes for every character and becomes 72 0 69 0 76 0 76 0 79 0 0 0. Practically the whole OS will think that's a 1-letter word, H. Not a good thing. - - -Even if every OS were magically rid of all ASCII assumptions and C strings, there would still be the problem of Endianism. Technical explanations on the subject are not hard to find. The long and short of it is, given a 16-bit integer (2 bytes), different hardware architectures will store the value differently. Asked to store our friend A, (0x41), for instance, a Sparc processor will put the least significant byte at the higher address (00 41) whereas an Intel processor will put it in the lower address (41 00). Put aside the questions of left, right, and wrong; architectures are a fact of life. Endianism shows up wherever integers are stored and retrieved in heterogeneous environments. - - -The Unicode folks knew about Endianism, of course, and had to address it. A Unicode bytestream is supposed to begin with a byte-order mark. Needless to say, perhaps, many don't. - +
    Unicode's Pluses and Minuses + +You will read from time to time that Unicode is not perfect. Surprise, surprise: it's true. From a linguistic point of view, Unicode is incomplete; in particular, UCS-2 is demonstrably too small (!) to hold all the forms of Chinese ideographs used over the centuries. (It is, however, quite useful and widely employed in representing modern Chinese.) Of more common concern to programmers are Unicode's technical problems, or rather, Unix's technical shortcomings vis-a-vis any encoding more complex than ISO 8859-x. + +The basic problem, from a programmer's perspective, is the ancient agreement Unix entered into 30 years ago, the ASCII Compact, alluded to earlier. Assumptions about ASCII are littered throughout Unix-like systems, beginning with C's convention of representing strings as arrays of characters ending in a zero. Returning to our HELLO example earlier, C will store HELLO as 72 69 76 76 79 0, in very nice ASCII. Many many parts of the operating system and its associated tools and applications will recognize that as a 5-letter word because it's terminated by a null (zero). In UCS-2 Unicode, though, that same HELLO uses 2 bytes for every character and becomes 72 0 69 0 76 0 76 0 79 0 0 0. Practically the whole OS will think that's a 1-letter word, H. Not a good thing. + +Even if every OS were magically rid of all ASCII assumptions and C strings, there would still be the problem of Endianism. Technical explanations on the subject are not hard to find. The long and short of it is, given a 16-bit integer (2 bytes), different hardware architectures will store the value differently. Asked to store our friend A, (0x41), for instance, a Sparc processor will put the least significant byte at the higher address (00 41) whereas an Intel processor will put it in the lower address (41 00). Put aside the questions of left, right, and wrong; architectures are a fact of life. Endianism shows up wherever integers are stored and retrieved in heterogeneous environments. + +The Unicode folks knew about Endianism, of course, and had to address it. A Unicode bytestream is supposed to begin with a byte-order mark. Needless to say, perhaps, many don't.
    -
    Unicode Transformation Format: UTF-8 - -The presence of nulls embedded in character data and of byte order issues make straight Unicode i.e., UCS-2 or UCS-4 hard to work with in a heterogeneous environment. Too many opportunities arise for the data to be truncated or misinterpreted, and too many systems would fail even to transmit such data. In short, when 16-bit data are thrust into a multi-architecture 8-bit world, it frequently bodes ill for the data. - - -To answer that problem, to make Unicode transmissible and unambiguous to most machines, several transformation formats were adopted. Their goals were generally similar: to create a generally recognized format that would unambiguously and safely convey Unicode information between machines and across the Internet. To do that, they sought to remove nulls and endianism from the data stream. The most popular one — practically the only one used — is known as UTF-8. - - -UTF-8 found wide acceptance for many reasons. UTF-8 represents any Unicode character as a combination of 1-4 bytes. The number of bytes required depends on the integer value of the Unicode character, and only one byte is used to represent the old ASCII range (0-127). UTF-8 does not use zero to represent any part of any character (except for the ASCII NUL). In consequence, UTF-8 is efficient with respect to space, has no endianism issues, and embeds no nulls. UTF-8 strings can be treated as plain old ASCII strings. These properties make UTF-8 data relatively easy for systems accustomed to processing ASCII data. - - -Here's a small example showing the difference between UCS-2 and UTF-8. +
    Unicode Transformation Format: UTF-8 + +The presence of nulls embedded in character data and of byte order issues make straight Unicode i.e., UCS-2 or UCS-4 hard to work with in a heterogeneous environment. Too many opportunities arise for the data to be truncated or misinterpreted, and too many systems would fail even to transmit such data. In short, when 16-bit data are thrust into a multi-architecture 8-bit world, it frequently bodes ill for the data. + +To answer that problem, to make Unicode transmissible and unambiguous to most machines, several transformation formats were adopted. Their goals were generally similar: to create a generally recognized format that would unambiguously and safely convey Unicode information between machines and across the Internet. To do that, they sought to remove nulls and endianism from the data stream. The most popular one — practically the only one used — is known as UTF-8. + +UTF-8 found wide acceptance for many reasons. UTF-8 represents any Unicode character as a combination of 1-4 bytes. The number of bytes required depends on the integer value of the Unicode character, and only one byte is used to represent the old ASCII range (0-127). UTF-8 does not use zero to represent any part of any character (except for the ASCII NUL). In consequence, UTF-8 is efficient with respect to space, has no endianism issues, and embeds no nulls. UTF-8 strings can be treated as plain old ASCII strings. These properties make UTF-8 data relatively easy for systems accustomed to processing ASCII data. + +Here's a small example showing the difference between UCS-2 and UTF-8. -<quote>HELLO</quote> in UCS-2 and UTF-8 + <quote>HELLO</quote> in UCS-2 and UTF-8 -$ echo HELLO | iconv -f ascii -t UCS-2 | hexdump -C -00000000 00 48 00 45 00 4c 00 4c 00 4f 00 0a |.H.E.L.L.O..| -0000000c -$ echo HELLO | iconv -f ascii -t utf-8 | hexdump -C -00000000 48 45 4c 4c 4f 0a |HELLO.| -00000006 -$ echo HELLO | hexdump -C -00000000 48 45 4c 4c 4f 0a |HELLO.| -00000006 - - -It is the similarity of the last two outputs that makes UTF-8 so attractive. It behaves like ASCII when ASCII's all that's needed. But it lacks ASCII's limitations. - -While UTF-8 solves many technical problems, it doesn't magically transform every ASCII-assuming system into a Unicode system. For example, to display Unicode data correctly — even Unicode data in UTF-8 format — the system still needs a suitable font. And it must distinguish the buffer size (and byte count) from the character count. - + $ echo HELLO | iconv -f ascii -t UCS-2 | hexdump -C + 00000000 00 48 00 45 00 4c 00 4c 00 4f 00 0a |.H.E.L.L.O..| + 0000000c + $ echo HELLO | iconv -f ascii -t utf-8 | hexdump -C + 00000000 48 45 4c 4c 4f 0a |HELLO.| + 00000006 + $ echo HELLO | hexdump -C + 00000000 48 45 4c 4c 4f 0a |HELLO.| + 00000006 + + It is the similarity of the last two outputs that makes UTF-8 so attractive. It behaves like ASCII when ASCII's all that's needed. But it lacks ASCII's limitations. + +While UTF-8 solves many technical problems, it doesn't magically transform every ASCII-assuming system into a Unicode system. For example, to display Unicode data correctly — even Unicode data in UTF-8 format — the system still needs a suitable font. And it must distinguish the buffer size (and byte count) from the character count.
    -
    Unicode and FreeTDS - -Microsoft servers using TDS 7.0 and above (anything since SQL Server 6.5) transmit their data in UCS-2 format (16-bit integers). Because most applications linked to &freetds; are not prepared to deal with UCS-2 data, &freetds; can convert the data to something more acceptable, including ASCII. To do so, it employs an iconv library. &freetds; determines the server's encoding from the TDS protocol and information reported by the server (generally per connection, but in the case of TDS 7.1, per result set column). It discovers the client's encoding in &freetdsconf;. &freetds; will happily convert and convey your data in any single-byte format that iconv can provide. In practice, this normally means some form of ISO 8859-x or UTF-8. - - -At some future time, &freetds; aims to support Unicode and other multi-byte character sets. It does not do so at the current time. - - -Sybase servers, by the way, adhere to a server makes right policy: they transmit their data in whatever character set the client requested at login time. The list of available character sets is fairly short, but includes UTF-8. While FreeTDS could convert Sybase data streams as easily as it does Microsoft data streams, to our knowledge no one is doing so. The Sybase server can perform the conversion itself, making FreeTDS's capability in this regard largely redundant and irrelevant. - -
    For further information - - UTF-8 and Unicode FAQ for Unix/Linux, by Markus Kuhn. As the man says, very comprehensive. - ASCII: American Standard Code for Information Infiltration, by Tom Jennings. Everything you ever wanted know about ASCII, but didn't know whom to ask. - A Brief History of Character Codes, by Steven J. Searle. Includes useful references. - Unicode Home Page. - - - - +
    Unicode and FreeTDS + +Microsoft servers using TDS 7.0 and above (anything since SQL Server 6.5) transmit their data in UCS-2 format (16-bit integers). Because most applications linked to &freetds; are not prepared to deal with UCS-2 data, &freetds; can convert the data to something more acceptable, including ASCII. To do so, it employs an iconv library. &freetds; determines the server's encoding from the TDS protocol and information reported by the server (generally per connection, but in the case of TDS 7.1, per result set column). It discovers the client's encoding in &freetdsconf;. &freetds; will happily convert and convey your data in any single-byte format that iconv can provide. In practice, this normally means some form of ISO 8859-x or UTF-8. + +At some future time, &freetds; aims to support Unicode and other multi-byte character sets. It does not do so at the current time. + +Sybase servers, by the way, adhere to a server makes right policy: they transmit their data in whatever character set the client requested at login time. The list of available character sets is fairly short, but includes UTF-8. While FreeTDS could convert Sybase data streams as easily as it does Microsoft data streams, to our knowledge no one is doing so. The Sybase server can perform the conversion itself, making FreeTDS's capability in this regard largely redundant and irrelevant. +
    For further information + + UTF-8 and Unicode FAQ for Unix/Linux, by Markus Kuhn. As the man says, very comprehensive. + ASCII: American Standard Code for Information Infiltration, by Tom Jennings. Everything you ever wanted know about ASCII, but didn't know whom to ask. + A Brief History of Character Codes, by Steven J. Searle. Includes useful references. + Unicode Home Page. + + +
    -GNU Free Documentation License + GNU Free Documentation License + + + +Version 1.1, March 2000 + + + + + PREAMBLE + + +The purpose of this License is to make a manual, textbook, + or other written document "free" in the sense of freedom: to + assure everyone the effective freedom to copy and redistribute it, + with or without modifying it, either commercially or + noncommercially. Secondarily, this License preserves for the + author and publisher a way to get credit for their work, while not + being considered responsible for modifications made by + others. + - If you have no Invariant Sections, write "with no Invariant - Sections" instead of saying which ones are invariant. If you have - no Front-Cover Texts, write "no Front-Cover Texts" instead of - "Front-Cover Texts being LIST"; likewise for Back-Cover - Texts. +This License is a kind of "copyleft", which means that + derivative works of the document must themselves be free in the + same sense. It complements the GNU General Public License, which + is a copyleft license designed for free software. + - If your document contains nontrivial examples of program - code, we recommend releasing these examples in parallel under your - choice of free software license, such as the GNU General Public - License, to permit their use in free software. - +We have designed this License in order to use it for manuals + for free software, because free software needs free documentation: + a free program should come with manuals providing the same + freedoms that the software does. But this License is not limited + to software manuals; it can be used for any textual work, + regardless of subject matter or whether it is published as a + printed book. We recommend this License principally for works + whose purpose is instruction or reference. + + + + APPLICABILITY AND DEFINITIONS + - +This License applies to any manual or other work that + contains a notice placed by the copyright holder saying it can be + distributed under the terms of this License. The "Document", + below, refers to any such manual or work. Any member of the + public is a licensee, and is addressed as "you". + + +A "Modified Version" of the Document means any work + containing the Document or a portion of it, either copied + verbatim, or with modifications and/or translated into another + language. + + +A "Secondary Section" is a named appendix or a front-matter + section of the Document that deals exclusively with the + relationship of the publishers or authors of the Document to the + Document's overall subject (or to related matters) and contains + nothing that could fall directly within that overall subject. + (For example, if the Document is in part a textbook of + mathematics, a Secondary Section may not explain any mathematics.) + The relationship could be a matter of historical connection with + the subject or with related matters, or of legal, commercial, + philosophical, ethical or political position regarding + them. + + +The "Invariant Sections" are certain Secondary Sections + whose titles are designated, as being those of Invariant Sections, + in the notice that says that the Document is released under this + License. + + +The "Cover Texts" are certain short passages of text that + are listed, as Front-Cover Texts or Back-Cover Texts, in the + notice that says that the Document is released under this + License. + + +A "Transparent" copy of the Document means a + machine-readable copy, represented in a format whose specification + is available to the general public, whose contents can be viewed + and edited directly and straightforwardly with generic text + editors or (for images composed of pixels) generic paint programs + or (for drawings) some widely available drawing editor, and that + is suitable for input to text formatters or for automatic + translation to a variety of formats suitable for input to text + formatters. A copy made in an otherwise Transparent file format + whose markup has been designed to thwart or discourage subsequent + modification by readers is not Transparent. A copy that is not + "Transparent" is called "Opaque". + + +Examples of suitable formats for Transparent copies include + plain ASCII without markup, Texinfo input format, LaTeX input + format, SGML or XML using a publicly available DTD, and + standard-conforming simple HTML designed for human modification. + Opaque formats include PostScript, PDF, proprietary formats that + can be read and edited only by proprietary word processors, SGML + or XML for which the DTD and/or processing tools are not generally + available, and the machine-generated HTML produced by some word + processors for output purposes only. + + +The "Title Page" means, for a printed book, the title page + itself, plus such following pages as are needed to hold, legibly, + the material this License requires to appear in the title page. + For works in formats which do not have any title page as such, + "Title Page" means the text near the most prominent appearance of + the work's title, preceding the beginning of the body of the + text. + + + + VERBATIM COPYING + + +You may copy and distribute the Document in any medium, + either commercially or noncommercially, provided that this + License, the copyright notices, and the license notice saying this + License applies to the Document are reproduced in all copies, and + that you add no other conditions whatsoever to those of this + License. You may not use technical measures to obstruct or + control the reading or further copying of the copies you make or + distribute. However, you may accept compensation in exchange for + copies. If you distribute a large enough number of copies you + must also follow the conditions in section 3. + + +You may also lend copies, under the same conditions stated + above, and you may publicly display copies. + + + + COPYING IN QUANTITY + + +If you publish printed copies of the Document numbering more + than 100, and the Document's license notice requires Cover Texts, + you must enclose the copies in covers that carry, clearly and + legibly, all these Cover Texts: Front-Cover Texts on the front + cover, and Back-Cover Texts on the back cover. Both covers must + also clearly and legibly identify you as the publisher of these + copies. The front cover must present the full title with all + words of the title equally prominent and visible. You may add + other material on the covers in addition. Copying with changes + limited to the covers, as long as they preserve the title of the + Document and satisfy these conditions, can be treated as verbatim + copying in other respects. + + +If the required texts for either cover are too voluminous to + fit legibly, you should put the first ones listed (as many as fit + reasonably) on the actual cover, and continue the rest onto + adjacent pages. + + +If you publish or distribute Opaque copies of the Document + numbering more than 100, you must either include a + machine-readable Transparent copy along with each Opaque copy, or + state in or with each Opaque copy a publicly-accessible + computer-network location containing a complete Transparent copy + of the Document, free of added material, which the general + network-using public has access to download anonymously at no + charge using public-standard network protocols. If you use the + latter option, you must take reasonably prudent steps, when you + begin distribution of Opaque copies in quantity, to ensure that + this Transparent copy will remain thus accessible at the stated + location until at least one year after the last time you + distribute an Opaque copy (directly or through your agents or + retailers) of that edition to the public. + + +It is requested, but not required, that you contact the + authors of the Document well before redistributing any large + number of copies, to give them a chance to provide you with an + updated version of the Document. + + + + MODIFICATIONS + + +You may copy and distribute a Modified Version of the + Document under the conditions of sections 2 and 3 above, provided + that you release the Modified Version under precisely this + License, with the Modified Version filling the role of the + Document, thus licensing distribution and modification of the + Modified Version to whoever possesses a copy of it. In addition, + you must do these things in the Modified Version: + + + Use in the Title Page + (and on the covers, if any) a title distinct from that of the + Document, and from those of previous versions (which should, if + there were any, be listed in the History section of the + Document). You may use the same title as a previous version if + the original publisher of that version gives permission. + + + List on the Title Page, + as authors, one or more persons or entities responsible for + authorship of the modifications in the Modified Version, + together with at least five of the principal authors of the + Document (all of its principal authors, if it has less than + five). + + + State on the Title page + the name of the publisher of the Modified Version, as the + publisher. + + + Preserve all the + copyright notices of the Document. + + + Add an appropriate + copyright notice for your modifications adjacent to the other + copyright notices. + + + Include, immediately + after the copyright notices, a license notice giving the public + permission to use the Modified Version under the terms of this + License, in the form shown in the Addendum below. + + + Preserve in that license + notice the full lists of Invariant Sections and required Cover + Texts given in the Document's license notice. + + + Include an unaltered + copy of this License. + + + Preserve the section + entitled "History", and its title, and add to it an item stating + at least the title, year, new authors, and publisher of the + Modified Version as given on the Title Page. If there is no + section entitled "History" in the Document, create one stating + the title, year, authors, and publisher of the Document as given + on its Title Page, then add an item describing the Modified + Version as stated in the previous sentence. + + + Preserve the network + location, if any, given in the Document for public access to a + Transparent copy of the Document, and likewise the network + locations given in the Document for previous versions it was + based on. These may be placed in the "History" section. You + may omit a network location for a work that was published at + least four years before the Document itself, or if the original + publisher of the version it refers to gives permission. + + + In any section entitled + "Acknowledgements" or "Dedications", preserve the section's + title, and preserve in the section all the substance and tone of + each of the contributor acknowledgements and/or dedications + given therein. + + + Preserve all the + Invariant Sections of the Document, unaltered in their text and + in their titles. Section numbers or the equivalent are not + considered part of the section titles. + + + Delete any section + entitled "Endorsements". Such a section may not be included in + the Modified Version. + + + Do not retitle any + existing section as "Endorsements" or to conflict in title with + any Invariant Section. + + + + +If the Modified Version includes new front-matter sections + or appendices that qualify as Secondary Sections and contain no + material copied from the Document, you may at your option + designate some or all of these sections as invariant. To do this, + add their titles to the list of Invariant Sections in the Modified + Version's license notice. These titles must be distinct from any + other section titles. + + +You may add a section entitled "Endorsements", provided it + contains nothing but endorsements of your Modified Version by + various parties--for example, statements of peer review or that + the text has been approved by an organization as the authoritative + definition of a standard. + + +You may add a passage of up to five words as a Front-Cover + Text, and a passage of up to 25 words as a Back-Cover Text, to the + end of the list of Cover Texts in the Modified Version. Only one + passage of Front-Cover Text and one of Back-Cover Text may be + added by (or through arrangements made by) any one entity. If the + Document already includes a cover text for the same cover, + previously added by you or by arrangement made by the same entity + you are acting on behalf of, you may not add another; but you may + replace the old one, on explicit permission from the previous + publisher that added the old one. + + +The author(s) and publisher(s) of the Document do not by + this License give permission to use their names for publicity for + or to assert or imply endorsement of any Modified Version. + + + + COMBINING DOCUMENTS + + +You may combine the Document with other documents released + under this License, under the terms defined in section 4 above for + modified versions, provided that you include in the combination + all of the Invariant Sections of all of the original documents, + unmodified, and list them all as Invariant Sections of your + combined work in its license notice. + + +The combined work need only contain one copy of this + License, and multiple identical Invariant Sections may be replaced + with a single copy. If there are multiple Invariant Sections with + the same name but different contents, make the title of each such + section unique by adding at the end of it, in parentheses, the + name of the original author or publisher of that section if known, + or else a unique number. Make the same adjustment to the section + titles in the list of Invariant Sections in the license notice of + the combined work. + + +In the combination, you must combine any sections entitled + "History" in the various original documents, forming one section + entitled "History"; likewise combine any sections entitled + "Acknowledgements", and any sections entitled "Dedications". You + must delete all sections entitled "Endorsements." + + + + COLLECTIONS OF DOCUMENTS + + +You may make a collection consisting of the Document and + other documents released under this License, and replace the + individual copies of this License in the various documents with a + single copy that is included in the collection, provided that you + follow the rules of this License for verbatim copying of each of + the documents in all other respects. + + +You may extract a single document from such a collection, + and distribute it individually under this License, provided you + insert a copy of this License into the extracted document, and + follow this License in all other respects regarding verbatim + copying of that document. + + + + AGGREGATION WITH INDEPENDENT WORKS + + +A compilation of the Document or its derivatives with other + separate and independent documents or works, in or on a volume of + a storage or distribution medium, does not as a whole count as a + Modified Version of the Document, provided no compilation + copyright is claimed for the compilation. Such a compilation is + called an "aggregate", and this License does not apply to the + other self-contained works thus compiled with the Document, on + account of their being thus compiled, if they are not themselves + derivative works of the Document. + + +If the Cover Text requirement of section 3 is applicable to + these copies of the Document, then if the Document is less than + one quarter of the entire aggregate, the Document's Cover Texts + may be placed on covers that surround only the Document within the + aggregate. Otherwise they must appear on covers around the whole + aggregate. + + + + TRANSLATION + + +Translation is considered a kind of modification, so you may + distribute translations of the Document under the terms of section + 4. Replacing Invariant Sections with translations requires + special permission from their copyright holders, but you may + include translations of some or all Invariant Sections in addition + to the original versions of these Invariant Sections. You may + include a translation of this License provided that you also + include the original English version of this License. In case of + a disagreement between the translation and the original English + version of this License, the original English version will + prevail. + + + + TERMINATION + + +You may not copy, modify, sublicense, or distribute the + Document except as expressly provided for under this License. Any + other attempt to copy, modify, sublicense or distribute the + Document is void, and will automatically terminate your rights + under this License. However, parties who have received copies, or + rights, from you under this License will not have their licenses + terminated so long as such parties remain in full + compliance. + + + + FUTURE REVISIONS OF THIS LICENSE + + +The Free Software Foundation may publish new, revised + versions of the GNU Free Documentation License from time to time. + Such new versions will be similar in spirit to the present + version, but may differ in detail to address new problems or + concerns. See http://www.gnu.org/copyleft/. + + +Each version of the License is given a distinguishing + version number. If the Document specifies that a particular + numbered version of this License "or any later version" applies to + it, you have the option of following the terms and conditions + either of that specified version or of any later version that has + been published (not as a draft) by the Free Software Foundation. + If the Document does not specify a version number of this License, + you may choose any version ever published (not as a draft) by the + Free Software Foundation. + + + + How to use this License for your documents + + +To use this License in a document you have written, include + a copy of the License in the document and put the following + copyright and license notices just after the title page: + + + + +If you have no Invariant Sections, write "with no Invariant + Sections" instead of saying which ones are invariant. If you have + no Front-Cover Texts, write "no Front-Cover Texts" instead of + "Front-Cover Texts being LIST"; likewise for Back-Cover + Texts. + + +If your document contains nontrivial examples of program + code, we recommend releasing these examples in parallel under your + choice of free software license, such as the GNU General Public + License, to permit their use in free software. + + + @@ -4092,7 +4118,7 @@ int msg_handler(DBPROCESS*, DBINT, int, int, char*, char*, char*, int); Some messages don't convey much, as though the server gets lonely sometimes. You're not obliged to print every one. Severities are defined in the server documentation, and can be set by the T-SQL RAISERROR statement. Message handlers always and only ever return zero. - When first writing the handler, pay careful attention to the precise type of each parameter. Only by carefully matching them will you convince a modern C compiler that the address of your function is of the type accepted by dberrhandle(). If that advice sounds familiar, it's because it bears repeating. + When first writing the handler, pay careful attention to the precise type of each parameter. Only by carefully matching them will you convince a modern C compiler that the address of your function is of the type accepted by dberrhandle(). If that advice sounds familiar, it's because it bears repeating. Some messages are so severe they provoke db-lib into calling the error handler, too! If you have both installed — and of course you do, right? — then you can skip those lacking an error number. While INT_CANCEL is the most common return code, it's not the only one. For one thing, the error handler's return code can control how long db-lib keeps retrying timeout errors. See the documentation for details. @@ -4196,13 +4222,13 @@ int msg_handler(DBPROCESS*, DBINT, int, int, char*, char*, char*, int); - + On Linkers &freetds; is a library, obviously, its functions invoked by an application. How the application finds the library can be mysterious. In the interest of making &freetds; easier to use, this appendix discusses how it all works. This appendix focusses on using &freetds; in your application. It isn't intended to help in building &freetds;, although the background information it provides might be useful. -
    +
    What is a C function? A C function is a named bit of code. @@ -4214,7 +4240,7 @@ int msg_handler(DBPROCESS*, DBINT, int, int, char*, char*, char*, int); Convert source code into object code Put in jumps to defined functions Create a list of defined functions, and their addresses - Create a list of undefined ones + Create a list of undefined functions The nm utility displays function names. Here are the ones defined by bsqldb.c (in bsqsldb.o): @@ -4256,7 +4282,7 @@ static int set_format_string(struct METADATA * meta, const char separator[]); U dbaltcolid U dbaltlen -Two things to note. First, the functions defined by bsqldb.o have addresses, and those that don't, don't. Second, only the name identifies the function. It's been that way since about 1978, and it's one reason C libraries are so useful: to find a function, the tool need only resolve the name, i.e. convert the name into an address. The caller (the programmer, really) has to know the function's inputs and semantics (how it behaves), but the tool's job is bone simple. Which turns out to be quite handy. +Two things to note. First, the functions defined by bsqldb.o have addresses, and undefined functions don't. Second, only the name identifies the function. It's been that way since about 1978, and it's one reason C libraries are so useful: to find a function, the tool need only resolve the name, i.e. convert the name into an address. The caller (the programmer, really) has to know the function's inputs and semantics (how it behaves), but the tool's job is bone simple. Which turns out to be quite handy.
    -
    +
    What is a C library? A C library is a set of named functions, for example dbinit() or SQLConnect(). Or, for that matter, fopen(3)The Unix convention is to put in parentheses behind the name the section of the manual in which the function is documented. &freetds; functions don't get numbers because they're not in the manual. Yet. . Libraries come in two flavors: static and dynamic. -
    +
    Static libraries Static libraries (also known as archives) have been around as long as C itself. Like a .zip file, they're just a bag of object files — containing functions, of course — with a table of contents in front giving the address of each nameOr, depending on how you look at it, the name of each address.. Static libraries are created from object files using a librarian utility of some kind. One such programs is ar, for archive. Static libraries are part of the build environment. Functions in static libraries are joined to a program's main module by a static linker at build time to produce an executable program. The executable incorporates the libraries' object code into its own body, making it completely self-sufficient.
    -
    +
    Dynamic libraries Dynamic libraries are the new kid on the block, as these things go, arriving on the Unix scene circa 1985. Like a static library, a dynamic library is a collection of functions with a table of contents. They are referenced at build time to give the executatble information about how they will eventually be used, but they aren't used until run time. @@ -4293,7 +4319,7 @@ It has an address — a location — in the text C header files include functional prototypes, declarations (not definitions) of functions. Functional prototypes describe to the compiler each function's parameters, allowing the compiler to confirm that the function is being called correctly. -Most of the functions declared in header files are implemented in libraries. However, there's no mechanical or automatic relationship between the functional prototypes in the header files and the implementation of those same functions in a library. The .h file is maintained by hand, by the programmer, and is used to generate a library. The header file and associated library are distributed and installed together (one hopes), but correct installation and subsequent use by the compiler & linker require human beings to keep track of the pair. Failure to do so leads to interesting development and even run-time problems, especially with libraries whose functions' parameters frequently change from version to version. +Most of the functions declared in header files are implemented in libraries. However, there's no mechanical or automatic relationship between the functional prototypes in the header files and their implementation in a library. The .h file is maintained by hand, by the programmer, and is used to generate a library. The header file and associated library are distributed and installed together (one hopes), but correct installation and subsequent use by the compiler & linker require human beings to keep track of the pair. Failure to do so leads to interesting development and even run-time problems, especially with libraries whose functions' parameters change from version to version. For example, imagine a function f(int g) defined in library libf.so and declared in f.h. In a later version of libf.so, the function's parameter is changed to use a pointer, f(int *p), and f.h is likewise updated. Possible errors that cannot be prevented by the linker include: @@ -4314,7 +4340,7 @@ These errors are possible because C functions are identified to the linker A linker, any linker, knits together object files (some of which may be in libraries) such that every function needed by the program has a definition. If the linker fails to locate a definition for even one function, it will fail and the program will not run. -Returning to bsqldb.o, we can use nm to see which functions are unresolved, and determine whether or not a particular library contains them. We'll ignore the first symbols start with an underscore, marking them per the C standard as being provided by the implementationWhy and how leading underscores enter into this discussion is just one more example of arcane historical practices one needs to know to master the subject. For our purposes, though, it's enough to know that implementation-provided functions like these — functions provided by the C standard library — often have an underscored prepended. , and focus on the last five in this abbreviated list. +Returning to bsqldb.o, we can use nm to see which functions are unresolved, and determine whether or not a particular library contains them. We'll ignore the symbols that start with an underscore, marking them per the C standard as being provided by the implementationWhy and how leading underscores enter into this discussion is just one more example of arcane historical practices one needs to know to master the subject. For our purposes, though, it's enough to know that implementation-provided functions like these — functions provided by the C standard library — often have an underscored prepended. , and focus on the last five in this abbreviated list. Some unresolved functions in <filename>bsqldb.o</filename> @@ -4382,7 +4408,7 @@ Although these examples refer to static libraries, nm works j
    Knitting together the object modules -The static linker merges your object files into one executable. Your project's object files may refer freely (usually) to each other's functions, and the linker will match them up. It will catenate them together, compute every funtion's offset from the start of the executable, and replace every function reference with the actual address needed for the executable it's constructing. For library functions, definitions are copied from the library and appended to the output file (executable). The placeholder addresses left by the compiler are similarly replaced by offsets. +The static linker merges your object files into one executable. Your project's object files may refer freely (usually) to each other's functions, and the linker will match them up. It will catenate them together, compute every function's offset from the start of the executable, and replace every function reference with the actual address needed for the executable it's constructing. For library functions, definitions are copied from the library and appended to the output file (executable). The placeholder addresses left by the compiler are similarly replaced by offsets.
    @@ -4474,7 +4500,15 @@ Although these examples refer to static libraries, nm works j -lsybdb.5 => /usr/local/lib/libsybdb.so.5 -Important to understand: ldd is not figuring out this information by itself. All it does is report the results of its interrogation of the runtime linker. As the configuration of the runtime linker is changed, so changes the output of ldd. +Important to understand: ldd is not figuring out this information by itself. It just reports the results of its interrogation of the runtime linker. As the configuration of the runtime linker is changed, so changes the output of ldd. +
    + +
    + A Word about Windows® +WIndows executables use the older COFF format, which has no provision for an RPATH. The runtime linker searches the PATH instead, after some built-in locations that usually include the current working directory. Neither ldd nor any similar utility is included in the basic product. + +It has been said that Unix is for programmers and Windows is for users, and perhaps that roughtly describes the intention. But the Unix features listed above — RPATH and ldd — as well as a canonical filesystem hierarchy and dynamic library versioning, all promote a better user experience. Because of them, the problem of DLL conflicts in Windows hardly exists in Unix. Yet they are neither new nor secrect nor patented nor complicated; Microsoft could have adopted years ago (as Apple finally did). We therefore know that the 20-year old phenomemon known as “DLL hell” is not inevitable, but a choice signifying nothing so much as Microsoft's indifference to its customers. +
    @@ -4488,6 +4522,14 @@ Important to understand: ldd is not figu
    +
    + Keep in Mind +The compiler's job ends on the last line of each source code file. A header file describes a function for the compiler, not the linker. + +The linker, static or runtime, uses only the function's name to resolve references. Function parameters and semantics are invisible to it. + +The programmer and, to a lesser degree, the sysadmin direct the choice of which library to link to an executable. A missing function will prevent execution. A wrong function will promote wrong execution. Don't do that. +
    The <filename>interfaces</filename> File commit b429812727bcb4cc5837d94e8c975386685bf6d2 Author: jklowden Date: Sun Mar 13 21:32:39 2011 +0000 doc/userguide.sgml updated for upcoming release diff --git a/ChangeLog b/ChangeLog index ef42e9c..d330b3f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Sun Mar 13 14:40:55 EDT 2011 JK Lowden + * doc/bsqldb.txt doc/freebcp.txt doc/tsql.txt + - doc/userguide.sgml + - updated for upcoming release + * src/apps/bsqldb.c support numeric/decimal + * src/apps/freebcp.c allow no username for trusted logins + Sat Mar 12 07:52:15 EST 2011 JK Lowden * doc/userguide.sgml fine tune linker appendix @@ -3173,4 +3180,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog-0.82 added because of release $FreeTDS$ -$Id: ChangeLog,v 1.3200 2011/03/12 12:54:00 jklowden Exp $ +$Id: ChangeLog,v 1.3201 2011/03/13 21:32:39 jklowden Exp $ diff --git a/doc/bsqldb.txt b/doc/bsqldb.txt index bfac1d0..36c72c4 100644 --- a/doc/bsqldb.txt +++ b/doc/bsqldb.txt @@ -1,10 +1,10 @@ NAME - bsqldb - batch SQL script processor using db-lib + bsqldb - batch SQL script processor using DB-Library SYNOPSIS - bsqldb [-U username] [-P password] [-S server] [-D database] - [-i input_file] [-o output_file] [-e error_file] - [-t field_term] [-qv] + bsqldb [-U username] [-P password] [-S servername] [-D database] + [-i input_file] [-o output_file] [-e error_file] [-H hostname] + [-t field_term] [-hqv] DESCRIPTION bsqldb is a utility program distributed with FreeTDS. @@ -14,15 +14,16 @@ DESCRIPTION the command "go" on a line by itself as a separator between batches. The last batch need not be followed by "go". - bsqldb makes use of the db-lib API provided by FreeTDS. This + bsqldb makes use of the DB-Library API provided by FreeTDS. This API is of course also available to application developers. OPTIONS - -U username Database server login name. - + -U username Database server login name. If username is not provided, a domain + login is attempted for TDS 7+ connections. + -P password Database server password. - -S server Database server to which to connect. + -S servername Database server to which to connect. -D database Database to use. @@ -38,21 +39,24 @@ OPTIONS -h Print column headers with the data to the same file. - -H Override hostname sent to server. + -H hostname Override name of client sent to server. -q Do not print column metadata, return status, or rowcount. Overrides -h. - -v Verbose mode, for more information about the db-lib interaction. + -v Verbose mode, for more information about the DB-Libraryrary interaction. This also reports the result set metadata, including and return code. All verbose data are written to standard error (or -e), so as not to interfere with the data stream. +ENVIRONMENT + DSQUERY default servername + NOTES bsqldb is a filter; it reads from standard input, writes to standard output, and writes errors to standard error. The -i, -o, and -e options override these, of course. - The source code for bsqldb is intended as a model for db-lib users. db-lib + The source code for bsqldb is intended as a model for DB-Library users. DB-Library has a rich set of functions, and it can be hard sometimes to understand how to use them, particularly the first time. If you are using it in this way and find something unclear, you are encouraged to email the author your diff --git a/doc/freebcp.txt b/doc/freebcp.txt index 6a841e7..df2a421 100644 --- a/doc/freebcp.txt +++ b/doc/freebcp.txt @@ -48,7 +48,7 @@ TABLES AND FILES OPTIONS -c The host data file is (or will be) in "character" format, i.e., a text file. Encoding is determined by the - client charset attribute in freetds.conf. + client charset attribute in freetds.conf. -n The host data file is in "native" format. This is a format that freebcp will be able to process, @@ -86,7 +86,8 @@ OPTIONS -S servername The name of the Database Server to which to connect. - -U username A database login name. + -U username A database login name. If username is not provided, a domain + login is attempted for TDS 7+ connections. -P password A database password. @@ -119,6 +120,9 @@ OPTIONS -v -V Print the version information and exit. +ENVIRONMENT + DSQUERY default servername + NOTES When connecting to a Sybase database server, it is required that the TDS 5.0 protocol be used. When connecting to a Microsoft SQL Server diff --git a/doc/tsql.txt b/doc/tsql.txt index 62a147f..d410bed 100644 --- a/doc/tsql.txt +++ b/doc/tsql.txt @@ -39,7 +39,8 @@ OPTIONS -p port the port at which SQL Server is listening - -U username database login name. + -U username database login name. If username is not provided, a domain + login is attempted for TDS 7+ connections. -P password database password. commit d5ceb93411a37a34dd8522da40904dd1417e928f Author: jklowden Date: Sun Mar 13 21:32:46 2011 +0000 support numeric/decimal diff --git a/src/apps/bsqldb.c b/src/apps/bsqldb.c index 0360abd..09fbea9 100644 --- a/src/apps/bsqldb.c +++ b/src/apps/bsqldb.c @@ -53,7 +53,7 @@ #include #include "replacements.h" -static char software_version[] = "$Id: bsqldb.c,v 1.48 2011/02/17 15:55:28 jklowden Exp $"; +static char software_version[] = "$Id: bsqldb.c,v 1.49 2011/03/13 21:32:46 jklowden Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #ifdef _WIN32 @@ -661,6 +661,7 @@ static int get_printable_size(int type, int size) /* adapted from src/dblib/dblib.c */ { switch (type) { + case SYBBITN: case SYBBIT: return 1; case SYBINTN: @@ -680,11 +681,15 @@ get_printable_size(int type, int size) /* adapted from src/dblib/dblib.c */ return 6; case SYBINT4: return 11; + case SYBDECIMAL: + case SYBNUMERIC: case SYBINT8: return 21; case SYBVARCHAR: case SYBCHAR: return size; + case SYBNVARCHAR: + return size/2; case SYBFLT8: return 11; /* FIX ME -- we do not track precision */ case SYBREAL: @@ -698,15 +703,13 @@ get_printable_size(int type, int size) /* adapted from src/dblib/dblib.c */ case SYBDATETIMN: return 26; /* FIX ME */ #if 0 /* not exported by sybdb.h */ - case SYBBITN: case SYBLONGBINARY: case SYBLONGCHAR: - case SYBNTEXT: - case SYBNVARCHAR: #endif case SYBBINARY: case SYBIMAGE: case SYBTEXT: + case SYBNTEXT: case SYBVARBINARY: return INT_MAX; } @@ -819,6 +822,8 @@ get_login(int argc, char *argv[], OPTIONS *options) DBSETLAPP(login, options->appname); + options->servername = getenv("DSQUERY"); + while ((ch = getopt(argc, argv, "U:P:S:dD:i:o:e:t:H:hqv")) != -1) { switch (ch) { case 'U': commit e9d3a01514d871b42eade62ac783243f76677b1a Author: jklowden Date: Sun Mar 13 21:32:49 2011 +0000 allow no username for trusted logins diff --git a/src/apps/freebcp.c b/src/apps/freebcp.c index f67ad36..b2e6ee0 100644 --- a/src/apps/freebcp.c +++ b/src/apps/freebcp.c @@ -54,7 +54,7 @@ #include #include "freebcp.h" -static char software_version[] = "$Id: freebcp.c,v 1.58 2010/12/17 04:31:36 berryc Exp $"; +static char software_version[] = "$Id: freebcp.c,v 1.59 2011/03/13 21:32:49 jklowden Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; void pusage(void); @@ -324,21 +324,27 @@ process_parameters(int argc, char **argv, BCPPARAMDATA *pdata) /* * Check for required/disallowed option combinations + * If no username is provided, rely on domain login. */ - /* these must be specified */ - if (!pdata->Uflag || !pdata->Pflag || !pdata->Sflag) { - fprintf(stderr, "All 3 options -U, -P, -S must be supplied.\n"); - return (FALSE); + /* Server */ + if (!pdata->Sflag) { + if ((pdata->server = getenv("DSQUERY")) != NULL) { + pdata->server = strdup(pdata->server); /* can be freed */ + pdata->Sflag++; + } else { + fprintf(stderr, "-S must be supplied.\n"); + return (FALSE); + } } - /* only one of these can be specified */ + /* Only one of these can be specified */ if (pdata->cflag + pdata->nflag + pdata->fflag != 1) { fprintf(stderr, "Exactly one of options -c, -n, -f must be supplied.\n"); return (FALSE); } - /* character mode file: Fill in some default values*/ + /* Character mode file: fill in default values */ if (pdata->cflag) { if (!pdata->tflag || !pdata->fieldterm) { /* field terminator not specified */ @@ -407,14 +413,17 @@ login_to_database(BCPPARAMDATA * pdata, DBPROCESS ** pdbproc) if (!login) return FALSE; - DBSETLUSER(login, pdata->user); - DBSETLPWD(login, pdata->pass); + if (pdata->user) + DBSETLUSER(login, pdata->user); + if (pdata->pass) { + DBSETLPWD(login, pdata->pass); + memset(pdata->pass, 0, strlen(pdata->pass)); + } + DBSETLAPP(login, "FreeBCP"); if (pdata->charset) DBSETLCHARSET(login, pdata->charset); - /* if packet size specified, set in login record */ - if (pdata->Aflag && pdata->packetsize > 0) { DBSETLPACKET(login, pdata->packetsize); } commit 76772b234cde83105f6f897f1370bee35edec619 Author: jklowden Date: Tue Mar 22 00:23:23 2011 +0000 updated for upcoming release diff --git a/ChangeLog b/ChangeLog index d330b3f..ac8e369 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +Mon Mar 21 20:21:51 EDT 2011 JK Lowden + * doc/userguide.sgml updated for upcoming release + Sun Mar 13 14:40:55 EDT 2011 JK Lowden * doc/bsqldb.txt doc/freebcp.txt doc/tsql.txt - doc/userguide.sgml @@ -3180,4 +3183,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog-0.82 added because of release $FreeTDS$ -$Id: ChangeLog,v 1.3201 2011/03/13 21:32:39 jklowden Exp $ +$Id: ChangeLog,v 1.3202 2011/03/22 00:23:23 jklowden Exp $ diff --git a/doc/userguide.sgml b/doc/userguide.sgml index ac19ae9..80f95bc 100644 --- a/doc/userguide.sgml +++ b/doc/userguide.sgml @@ -13,8 +13,8 @@ ]> - $Date: 2011/03/12 12:54:01 $ - $Revision: 1.134 $ + $Date: 2011/03/22 00:23:24 $ + $Revision: 1.135 $ &freetds; User Guide A Guide to Installing, Configuring, and Running &freetds; @@ -63,9 +63,9 @@ The version you're reading is: - $Revision: 1.134 $ - $Date: 2011/03/12 12:54:01 $ - CVS control number $Id: userguide.sgml,v 1.134 2011/03/12 12:54:01 jklowden Exp $. + $Revision: 1.135 $ + $Date: 2011/03/22 00:23:24 $ + CVS control number $Id: userguide.sgml,v 1.135 2011/03/22 00:23:24 jklowden Exp $. can be found on the &freetds; @@ -83,17 +83,18 @@ What is &freetds;? -&freetds; is re-implementation of C libraries originally implmented by Sybase and Microsoft SQL Server. It includes drop-in replacements for +&freetds; is re-implementation of C libraries originally marketed by Sybase and Microsoft SQL Server. It allows many open source applications such as Perl and PHP (or your own C or C++ program) to connect to Sybase or Microsoft SQL Server. + +&freetds; provides drop-in replacements for - Sybase's DB-Library or CT-Library - Microsoft's DB-Library (which differs in small details from Sybase's) - an ODBC library similar that provided by the vendors + Sybase's &dblib; and &ctlib; + Microsoft's &dblib; (which differs in small details from Sybase's) + the &odbc; drivers from both vendors + interactive SQL and BCP utilities -The TDS part of the name comes from name of the protocol used to communicate with such servers: the Tabular Data Stream. - -&freetds; allows many open source applications such as Perl and PHP (or your own C or C++ program) to connect to Sybase or Microsoft SQL Server. +The TDS part of the name comes from name of the protocol used to communicate with such servers: the Tabular Data Stream. &freetds; is distributed in source code form, and is expected to compile on just about any operating system. That means every form of Unix® and Unix-like™ system (including notable variants such as Interix® and QNX®), as well as Win32®, VMS®, and OS X®. If it doesn't compile on your system — and you're not using MS-DOS® — it's probably considered a bug. @@ -104,17 +105,17 @@ The TDS part of the name comes from name of the protocol used to TDS is a protocol, a set of rules describing how to transmit data between two computers. Like any protocol, it defines the types of messages that can be sent, and the order in which they may be sent. Protocols describe the bits on the wire, how data flow. -In reading this manual, it may be helpful to keep in mind that a protocol is not an API, although the two are related. The server recognizes and speaks a protocol; anything that can send it the correct combination of bytes in the right order can communicate with it. But programmers aren't generally in the business of sending bytes; that's the job of a library. Over the years, there have been a few libraries — each with its own API — that do the work of moving SQL through a TDS pipe. ODBC, &dblib;, and &ctlib; have very different APIs, but they're all one to the server, because on the wire they speak TDS. +In reading this manual, it may be helpful to keep in mind that a protocol is not an API, although the two are related. The server recognizes and speaks a protocol; anything that can send it the correct combination of bytes in the right order can communicate with it. But programmers aren't generally in the business of sending bytes; that's the job of a library. Over the years, there have been a few libraries — each with its own API — that do the work of moving SQL through a TDS pipe. &odbc;, &dblib;, and &ctlib; have very different APIs, but they're all one to the server, because on the wire they speak TDS. -The TDS protocol was designed and developed by Sybase Inc. for their Sybase SQL Server relational database engine in 1984. The problem Sybase faced then still exists: There was no commonly accepted application-level protocol to transfer data between a database server and its client. To encourage the use of their product, Sybase came up with DB-Library. +The TDS protocol was designed and developed by Sybase Inc. for their Sybase SQL Server relational database engine in 1984. The problem Sybase faced then still exists: There was no commonly accepted application-level protocol to transfer data between a database server and its client. To encourage the use of their product, Sybase came up with &dblib;. -DB-Library provided an API to the client program, and communicated with the server. What it sent to the server took the form of a stream of bytes meant for tables of data, a Tabular Data Stream. +&dblib; provided an API to the client program, and communicated with the server. What it sent to the server took the form of a stream of bytes meant for tables of data, a Tabular Data Stream. -In 1990 Sybase entered into a technology sharing agreement with Microsoft which resulted in Microsoft marketing its own SQL Server. Microsoft kept the DB-Library API and added ODBC. (Microsoft has since added other APIs, too. It no longer supports its own DB-Library implementation.) At about the same time, Sybase introduced a more powerful successor to DB-Library, called CT-Library, and called the pair OpenClient. +In 1990 Sybase entered into a technology sharing agreement with Microsoft which resulted in Microsoft marketing its own SQL Server. Microsoft kept the &dblib; API and added &odbc;. (Microsoft has since added other APIs, too. It no longer supports its own &dblib; implementation.) At about the same time, Sybase introduced a more powerful successor to &dblib;, called &ctlib;, and called the pair OpenClient. -CT-Library, DB-Library, and ODBC are APIs that — however different their programming style may be — all communicate with the server in the same way. The language they use is TDS. +&ctlib;, &dblib;, and &odbc; are APIs that — however different their programming style may be — all communicate with the server in the same way. The language they use is TDS. -The TDS protocol comes in several flavors, most of which have never been openly documented. If anything, it's probably considered to be something like a trade secret, or at least proprietary technology. The exception is TDS 5.0, used exclusively by Sybase, for which documentation is available from Sybase. +The TDS protocol comes in several flavors, most of which were not openly documented. If anything, it was considered to be something like a trade secret, or at least proprietary technology. The exception is TDS 5.0, used exclusively by Sybase, for which documentation is available from Sybase. @@ -132,46 +133,43 @@ The TDS part of the name comes from name of the protocol used to The version in use at the time of the Sybase/Microsoft split. - TDS 5.0 - Sybase - - -Introduced for Sybase. Because TDS 5.0 includes negotiated capabilities through which protocol features can be expanded, we are unlikely to see a new TDS version from Sybase. - + + TDS 5.0 Sybase + Introduced for Sybase. Because TDS 5.0 includes negotiated capabilities through which protocol features can be expanded, we are unlikely to see a new TDS version from Sybase. + - TDS 7.0 - Microsoft - - -Introduced for SQL Server 7.0. Includes support for the extended datatypes in SQL Server 7.0 (such as char/varchar fields of more than 255 characters). It also includes support for Unicode. - + + TDS 7.0 Microsoft + Introduced for SQL Server 7.0. Includes support for the extended datatypes in SQL Server 7.0 (such as char/varchar fields of more than 255 characters). It also includes support for Unicode. + - TDS 7.1 - Microsoft - - -Introduced for SQL Server 2000. Includes support for big integer (64-bit int) and variant datatypes. - + + TDS 7.1 Microsoft + was 8.0 + Earlier &freetds; documentation referred to versions 7, 8 and 9. Microsoft subsequently published a protocol specification document denoting 7.1 and 7.2, and one finds scattered references using that scheme elsewhere, too. For that reason, &freetds; switched to Microsoft's nomenclature. + + Introduced for SQL Server 2000. Includes support for big integer (64-bit int) and variant datatypes. + - TDS 7.2 - Microsoft - + + TDS 7.2 Microsoft + was 9.0 + Introduced for SQL Server 2005. Includes support for varchar(max), varbinary(max), xml datatypes and MARS. + -Introduced for SQL Server 2005. Includes support for varchar(max), varbinary(max), xml datatypes and MARS. - - - History of &freetds; + + History of &freetds; &freetds; was and is developed by observation and experimentation, which is to say, by trial and error. In early 1997, the only option for connecting to a Sybase server from Linux or other free systems was an aging Sybase-released version of OpenClient. Unfortunately it had a few problems. The original release was a.out-based, although Greg Thain did a great service in converting the library to ELF. Secondly, it included only the newer &ctlib; API. The older &dblib; API was missing. -Brian Bruns, a Sybase DBA and originator of the &freetds; project, had some &dblib; programs he wanted to run under Linux, and thus began the &freetds; project. The original work focused on &dblib; and version 5.0 of the protocol, but quickly expanded to include a &ctlib; compatible layer and TDS version 4.2. Later support for ODBC and TDS 7.0 and 7.1 was added. Craig Spannring wrote a Java JDBC driver which became FreeTDS/JDBC. +Brian Bruns, a Sybase DBA and originator of the &freetds; project, had some &dblib; programs he wanted to run under Linux, and thus began the &freetds; project. The original work focused on &dblib; and version 5.0 of the protocol, but quickly expanded to include a &ctlib; compatible layer and TDS version 4.2. Later support for &odbc; and TDS 7.0 and 7.1 was added. Craig Spannring wrote a Java JDBC driver which became FreeTDS/JDBC. -As the project matured, it gained new participants. Frediano Ziglio greatly expanded the ODBC driver, and continues to improve both it and the underlying TDS library. Bill Thompson wrote most of the present BCP system and added cursors to our &ctlib;. Your humble author joined the project to add documentation, and wound up as the project's maintainer. Such are the rewards for doing a good deed. +As the project matured, it gained new participants. Frediano Ziglio greatly expanded the &odbc; driver, and continues to improve both it and the underlying TDS library. Bill Thompson wrote most of the present BCP system and added cursors to our &ctlib;. Your humble author joined the project to add documentation, and in 2002 became its maintainer. Such are the rewards for doing a good deed. There have been many other contributions. Please see the AUTHORS in the distribution for a (we hope) complete list. @@ -182,7 +180,7 @@ The TDS part of the name comes from name of the protocol used to &freetds; consists of two projects. The &freetds; C libraries and &freetds;/ JDBC. - The &freetds; C libraries support three separate APIs: &dblib;, &ctlib;, and ODBC. Underlying these three is libtds, which handles the low-level details of the TDS protocol, such as sending, receiving, and datatype conversion. This document and the FreeTDS website are dedicated to these libraries. + The &freetds; C libraries support three separate APIs: &dblib;, &ctlib;, and &odbc;. Underlying these three is libtds, which handles the low-level details of the TDS protocol, such as sending, receiving, and datatype conversion. This document and the FreeTDS website are dedicated to these libraries. If Java is your game, we refer you to the jTDS @@ -194,7 +192,7 @@ The TDS part of the name comes from name of the protocol used to Status -The libraries are portable, mature, and stable. They're expected to compile readily and normally do not crash or corrupt data. There is a logging feature to aid in diagnosing problems. While they do not include every feature provided by the vendors' libaries, they do faithfully implement a useful — and widely used — subset of their APIs. +The libraries are portable, mature, and stable. They're expected to compile readily and normally do not crash or corrupt data. Extensive logging aids in diagnosing problems. While they do not include every feature provided by the vendors' libraries, they do faithfully implement a useful — and widely used — subset of their APIs. The &dblib; and &ctlib; APIs have been usable for several years. They have been successfully substituted for Sybase's own libraries in a variety of venues, including Perl and PHP. @@ -202,11 +200,13 @@ The TDS part of the name comes from name of the protocol used to Basic API coverage information for all libraries may be found in this manual. It is maintained in doc/api_status.txt, included in the source distribution. +For Microsoft servers, &freetds; now offers the best &dblib; for any OS on the planet (including Windows!) thanks not only to the hard work of its contributors, but also to Microsoft'sMicrosoft ceased enhancing &dblib; in 2001, advising customers to avoid using &dblib;. For Microsoft's unmaintained product, that's good advice. But if the &dblib; specification meets your needs, &freetds; permits you to keep using it with little loss (and some gain) of functionality. strategy. It is the only Win64 implementation of &dblib;, and the only Win32 implementation to support modern versions of the protocol. (SQL Server 2008 still accepts the TDS 4.2 connections that Microsoft's old library uses, but rejects BCP uploads with a spurious permission-denied message.) + In addition to the core &dblib; API, &freetds; includes a full implementation of &dblib;'s bcp functions, as well as freebcp, a replacement for Sybase's bcp utility. -How big is it? &freetds; has over 90,000 lines of C code, maintained by a handful of developers. Patches arrive irregularly, varying in size from one-liners to thousand-line monsters. Almost all are applied or used in some way. The mailing list has some 700 or so subscribers at this writing. Safe to say, &freetds;'s success so far lies somewhere between the Beetle and the Edsel. +How big is it? &freetds; has over 100,000 lines of C code, maintained by a handful of developers. Patches arrive irregularly, varying in size from one-liners to thousand-line monsters. Almost all are applied or used in some way. The mailing list has some 700 or so subscribers at this writing. Safe to say, &freetds;'s success so far lies somewhere between the Beetle and the Edsel. -Who uses it? Oh, pretty much everyone. &freetds; users almost certainly number in the tens of thousands. It's used by large corporations, by the U.S. federal government (e.g. Database Access Library at the National Center for Biotechnology Information) and, judging by the mailing list, by many webservers running Apache and PHP. Microsoft recommends &freetds; to their customers who want access to Microsoft SQL Server from non-Win32 clients. So do we. +Who uses it? Oh, pretty much everyone. &freetds; users number in the tens of thousands. It's used by large corporations, by the U.S. federal government (e.g. Database Access Library at the National Center for Biotechnology Information) and, judging by the mailing list, by many webservers running Apache and PHP. Sybase recommends &freetds; for their EAServer product. Microsoft recommends &freetds; to their customers who want access to Microsoft SQL Server from non-Win32 clients. So do we. Languages besides C and Java @@ -227,19 +227,19 @@ The TDS part of the name comes from name of the protocol used to - ODBC bridge products - They use the ODBC driver on the NT box where your SQL Server runs so you'll never have trouble with new protocols and the like. On the downside, they can be costly and may be inefficient. We know of EasySoft ODBC-ODBC Bridge from EasySoft, Universal Data Access Driver from OpenLink Software, SequeLink from Merant, and - ODBC Router from August Software Corporation. + &odbc; bridge products + They use the &odbc; driver on the NT box where your SQL Server runs so you'll never have trouble with new protocols and the like. On the downside, they can be costly and may be inefficient. We know of EasySoft ODBC-ODBC Bridge from EasySoft, Universal Data Access Driver from OpenLink Software, SequeLink from Merant, and + &odbc; Router from August Software Corporation. - Inline ODBC driver - Based on libtds, this is a native ODBC driver for i386 *nix. It is free in price, but comes only as a binary at the present time. + Inline &odbc; driver + Based on libtds, this is a native &odbc; driver for i386 *nix. It is free in price, but comes only as a binary at the present time. DBD::Proxy - We have no direct experience with this Perl-only option. It has the same caveats as an ODBC bridge except it's free. + We have no direct experience with this Perl-only option. It has the same caveats as an &odbc; bridge except it's free. @@ -257,7 +257,14 @@ The TDS part of the name comes from name of the protocol used to The <acronym>GNU</> World -&freetds; uses GNU Automake, Autoconf, and libtool to increase portability. +&freetds; uses GNU Autoconf, Automake, and libtool + + Versions used for this release + autoconf (GNU Autoconf) 2.65 + automake (GNU automake) 1.11.1 + ltmain.sh (GNU libtool) 2.2.6b + + to increase portability. For many people, the preceding sentence says it all (good or bad). If you're familiar with the GNU system, you can probably just download the tarball and get away with scanning the README impatiently and then following your instincts. Because everyone is a beginner once and no one is an expert at everything, we'll try to explain things in plain English where possible, and to define our terms as we go along. @@ -278,7 +285,7 @@ The TDS part of the name comes from name of the protocol used to $ cvs -d:pserver:anonymous@freetds.cvs.sourceforge.net:/cvsroot/freetds login $ cvs -z3 -d:pserver:anonymous@freetds.cvs.sourceforge.net:/cvsroot/freetds checkout -P freetds Password: - $ make install + $ For those behind firewalls or otherwise unable to access CVS, nightly snapshots of CVS are rolled up into tarballs for your convenience. They can be downloaded from ibiblio.org. Tarballs are generated around 3am EST (GMT-5). @@ -295,14 +302,14 @@ The TDS part of the name comes from name of the protocol used to For Experts - $ ./configure --prefix=/usr/local/freetds + $ ./configure --prefix=/usr/local $ make $ su root Password: $ make install -Building from CVS is described in the file INSTALL.CVS. +Building from CVS is described in the file INSTALL.CVS. For Everyone Else @@ -321,9 +328,9 @@ The TDS part of the name comes from name of the protocol used to The simplest form of running configure is: $ ./configure - and sometimes that's enough. configure accepts some command-line arguments, too, and you may need to provide some, depending on what your environment looks like. + and sometimes that's enough. configure accepts command-line arguments, too, and you may need to provide some, depending on what your environment looks like. -There are a few optional arguments to configure that may be important to you. For a complete list, see configure --help. +There are a few optional arguments to configure that may be important to you. For a complete list, see configure --help. <command>configure</> options @@ -428,7 +435,7 @@ The TDS part of the name comes from name of the protocol used to Things you can turn on - Enable Microsoft behavior in the &dblib; API where it diverges from Sybase's. (For instance, Microsoft uses different names for the members of its date structure.) Typically needed only for porting Win32 applications to Unix. + Enable Microsoft behavior in the &dblib; API where it diverges from Sybase's. Use this option if you are replacing Microsoft's libraries with &freetds; This option specifies default behavior. Programs can change the default at compile time by defining MSDBLIB or SYBDBLIB (for Microsoft or Sybase behavior, respectively). @@ -548,9 +555,11 @@ and, sure enough, asprintf.c earlier includes win Which shouldn't be defined unless inttypes.h exists on your system. -Let's review: config.h defines a bunch of preprocessor definitions that (try to) describe your build environment to the compiler. In this example, it got one wrong, causing the compiler to look for a file that isn't present, creating the error. The solution is not to change the &freetds; source code, but merely to comment out line 92 in config.h. +Let's review: config.h has preprocessor definitions that (try to) describe the build environment to the compiler. In this example, it got one wrong, causing the compiler to look for a file that isn't present, creating the error. The solution is not to change the &freetds; source code, but merely to comment out line 92 in config.h. -Perhaps you're shaking your head at such an old school approach. Over the years, Microsoft's proprietary project-configuration files have proved difficult to support. Every version is different, and there are a great many versions in use in the wild at any one time. As the project changes, it becomes impossible to maintain these kinds of files. +Perhaps you're shaking your head at such an old school approach. Over the years, Microsoft's proprietary project-configuration files have proved difficult to support. Every version is different, and there are a great many versions in use in the wild at any one time. As the project changes, it becomes impossible to maintain these kinds of files. + + For Windows applications that use &freetds; the hard-won wisdom is just use the NMakefile, please, thanks! If you like a visual environment and visual debugging, no problem: Microsoft's tools support Makefile projects. The author has direct knowledge of developers for whom that arrangement works quite well. Other ways to build under Windows® @@ -607,7 +616,7 @@ Which shouldn't be defined unless inttypes.h exists on your OS X® -As of this writing ($Date: 2011/03/12 12:54:01 $), the regular distribution compiles on OS X. Releases prior to 0.63 either did not compile or required patching. +As of this writing ($Date: 2011/03/22 00:23:24 $), the regular distribution compiles on OS X. @@ -740,21 +749,17 @@ Which shouldn't be defined unless inttypes.h exists on your -For best results, use the highest version of hte protocol supported by your server. If you encounter problems, try a lower version. If that works, though, please report it to the mailing list! +For best results, use the highest version of the protocol supported by your server. If you encounter problems, try a lower version. If that works, though, please report it to the mailing list! + Want to help? Try out the auto-protocol feature. &freetds; has experimental support for iteratively trying protocol connections until it finds one the server accepts. This is suitable when query responses are non-trivial (because the tiny delay in connecting is thus insignificant). Try setting your TDS version to 0 and report your results. -TDS 4.2 has limitations - ASCII only, of course. - - RPC is not supported. - - BCP is not supported. - - varchar fields are limited to 255 characters. If your table defines longer fields, they'll be truncated. - - dynamic queries (also called prepared statements) are not supported. - - - + + TDS 4.2 has limitations + ASCII only, of course. + RPC is not supported. + BCP is not supported. + varchar fields are limited to 255 characters. If your table defines longer fields, they'll be truncated. + dynamic queries (also called prepared statements) are not supported. + The protocol version may also affect how database servers interpret commands. For example, Microsoft SQL Server 2000 is known to behave differently with versions 4.2 @@ -1690,8 +1695,7 @@ Which shouldn't be defined unless inttypes.h exists on your ClientCharset - A name recognized by the iconv library linked to FreeTDS. - This correspond to client charset in &freetdsconf;. + A name recognized by the iconv library linked to FreeTDS. Corresponds to client charset in &freetdsconf;. ISO 8859-1 Character set (encoding) used by the client. @@ -1722,21 +1726,20 @@ Which shouldn't be defined unless inttypes.h exists on your TextSize Any - DB dependent + Server-dependent Maximum size returned from server for blobs. PacketSize Any - DB dependent + Server-dependent Size of packets to server. Some users saw some performance gain by increasing this value. Normally you shouldn't set it. Trusted_Connection Yes/No No - Use your current account instead of UID/PWD attributes. - This option require SSPI or Kerberos. This superceed UID/PWD attributes. + Use your current account instead of UID/PWD attributes. This option require SSPI or Kerberos and supersedes any UID/PWD attributes passed from the application. @@ -1885,9 +1888,11 @@ Which shouldn't be defined unless inttypes.h exists on your If tsql works and isql doesn't, you've isolated the problem to the ODBC setup. &freetds; might have some interoperability problems, but mere connection to the database isn't one of them! If tsql doesn't work, turn on logging with TDSDUMP. The log will tell you what TCP/IP name (and address) FreeTDS is attempting to connect to, and what version of the TDS protocol it's using. - With iODBC + + With iODBC - iODBC comes with a sample command line query program called odbctest that is located in the iodbc/samples directory. Using this program you can get a listing of DSNs, connect, and issue queries. It is often useful to compile a program such as this directly against the &freetds; driver instead of using a driver manager. This makes it simpler to debug if something goes wrong. To do so, simply compile and install the ODBC driver with iODBC as normal When compiling directly to &freetds; you still need the Driver Manager's header files., then compile and link the program directly: + iODBC comes with a sample command line query program called odbctest, located in the iodbc/samples directory. Using this program you can get a listing of DSNs, connect, and issue queries. + For debugging purposes, you may wish to link a program such as odbctest directly to &freetds; instead of to the driver manager. Why? Once the program is started in the debugger, the driver entry points become viable breakpoints. Because the DM loads the driver dynamically with dlopen(3), no driver addresses even exist until the runtime linker loads it. To do so, compile and install the &odbc; driver with iODBC as normal When linking directly to &freetds; you still need the Driver Manager's header files., then compile and link the program: Compile <filename>odbctest</> without a driver manager. @@ -1896,7 +1901,7 @@ Which shouldn't be defined unless inttypes.h exists on your $ gcc -g -o odbctest odbctest.o /usr/local/freetds/lib/libtdsodbc.a - The + Now you can run gdb or another debugger and set breakpoints on functions in the library without the driver manager getting in the way. With unixODBC @@ -1961,8 +1966,10 @@ Which shouldn't be defined unless inttypes.h exists on your | | +---------------------------------------+ SQL> - - + + +The reader is here advised that the isql that comes with many versions of unixODBC will truncate text and surprise in other ways without warning. If it behaves strangely, try &freetds;'s bsqlodbc before you decide you've found a &freetds; bug. + @@ -2067,11 +2074,16 @@ Which shouldn't be defined unless inttypes.h exists on your Domain Logins Domain logins can be used only with TDS protocol versions 7.0 or above. -As mentioned in the installation chapter, Microsoft SQL Server includes the ability to use domain logins instead of standard server logins. The advantage of doing this is that the passwords are encrypted on the wire using a challenge-response protocol. +As mentioned in the installation chapter, Microsoft SQL Server includes the ability to use domain + The term domain in this context is a Microsoft term. It refers to what's sometimes called an NT domain. It's unrelated to the DNS domain. DNS domains are used for name resolution. NT domains are used for authentication. Authentication is done by the domain controller, often the Primary Domain Controller (PDC). + The SQL Server machine may belong to an NT domain. &freetds; provides an encrypted password — a domain password, known to the domain controller — that the server will ask the domain controller to verify. +logins instead of standard server logins. Passwords are encrypted on the wire using a challenge-response protocol. &freetds; plays nice with such logins. + +&freetds; supports single sign-on (connecting without prompting for a username & password) or not, depending on how it was configured. For Windows hosts (both 32- and 64-bit), if SSPI is enabled, &freetds; will log in using so-called trusted authentication. For non-Windows hosts, enabling Kerberos provides similar functionality. -Domain logins may or may not support single sign-on (connecting without prompting for a password) depending on how &freetds; was configured. For Windows hosts (both 32- and 64-bit), if SSPI is enabled, &freetds; will log in using so-called "trusted authentication". For Linux (and similar) hosts, enabling Kerberos provides similar functionality. If neither option is enabled, &freetds; can still log in using the domain account, but the user must re-enter the password, as described next. +When neither option is enabled, &freetds; can still log in using the domain account, but the user must supply the username & password. -To use domain logins, use the 'DOMAIN\username' syntax for the username and use the domain password. +To use domain logins without SSPI or Kerberos, use the 'DOMAIN\username' syntax for the username and use the domain password. Logging in with a domain login $ tsql -S camelot -U 'NOTTINGHAM\lancelot' -P roundtable @@ -2082,10 +2094,7 @@ Which shouldn't be defined unless inttypes.h exists on your 1> - When &freetds; sees the \ character, it automatically chooses a domain login. - The term domain in this context is a Microsoft term. It refers to what's sometimes called an NT domain. It's unrelated to the DNS domain. DNS domains are used for name resolution. NT domains are used for authentication. Authentication is done by the domain controller, often the Primary Domain Controller (PDC). -The SQL Server machine may belong to an NT domain. &freetds; provides an encrypted password — a domain password, known to the domain controller — that the server will ask the domain controller to verify. Implementation details @@ -2099,13 +2108,15 @@ Which shouldn't be defined unless inttypes.h exists on your Kerberos Support -Perhaps surprisingly, Kerberos can be used to authenticate to Microsoft SQL Servers. This affords single-signon (or, at most, double-signon) capability in non-Windows environment. The reason this works is that much of Active Directory is based on Kerberos. +Perhaps surprisingly, + It works because much of Active Directory is based on Kerberos. From each according to his ability; to each according to his needs. +Kerberos can be used to authenticate to Microsoft SQL Servers. This affords single-signon (or, at most, double-signon) capability in non-Windows environment. -To take advantage of Kerberos you have to set up your machine with keytab from your Active Directory. - To configure your stuff you could use Samba or configure Kerberos directly (/etc/krb5.conf). configure includes options to define the location of your Kerberos installation (cf. ). +To take advantage of Kerberos you have to set up your machine with keytab + No, the author does not really know what he's talking about. +from your Active Directory. You could use Samba or configure Kerberos directly (/etc/krb5.conf). configure includes options to define the location of your Kerberos installation (cf. ). -By default UNIX does not initialize a Kerberos ticket with your login account. You have to use kinit to initialize a ticket. - You could also configure Kerberos in PAM in order to initialize Kerberos ticket at login time. +By default UNIX does not initialize a Kerberos ticket with your login account. You must use kinit to initialize a ticket. You could also configure Kerberos in PAM to initialize a Kerberos ticket at login time. @@ -2159,19 +2170,20 @@ Which shouldn't be defined unless inttypes.h exists on your TDS Connection Pooling -&freetds; 0.52 was the first to include a TDS Connection Pooling server. It lives in the src/pool directory. +The Connection Pooling server swims in the src/pool directory. -The &freetds; connection pool is a server process, it acts just like a SQL Server. You can use any program to attach to it that you could use to attach to a real SQL Server. The pool in turn connects to the SQL Server and database you specify, and attempts to share these connections. See the README in the pool directory for a more detailed description of its inner workings. +The &freetds; connection pool is a server process; it emulates a SQL Server. Any program that can attach to a real SQL Server may instead elect to attach to the pool server. The pool in turn connects to the SQL Server and database you specify, and attempts to share these connections. See the src/pool/README for a more detailed description of its inner workings. -To configure the pooling server, first make sure &freetds; has a working entry for the real SQL Server by connecting to it with SQSH or another program. - The &freetds; connection pool currently only supports TDS version 4.2. This restriction applies to both the client-to-pool and pool-to-server connections! +To configure the pool server, first make sure &freetds; has a working entry for the real SQL Server by connecting to it with SQSH or another program. + +The &freetds; connection pool currently only supports TDS version 4.2. This restriction applies to both the client-to-pool and pool-to-server connections! After FreeTDS has been installed, you will find an executable named tdspool in the /usr/local/bin directory (or whatever directory was specified with the configure -Next, edit the pool.conf file in the &freetds;'s etc directory. The pool.conf file is formatted like the &freetdsconf; with a section name in brackets and options for each section in key/value pairs. +Edit pool.conf in the &freetds;'s etc directory. The pool.conf file is formatted like &freetdsconf;, with a section name in brackets and options for each section in key/value pairs. -Just like the &freetdsconf; file there are two types of sections, a [global] section whose options affect all pools, and a section with the name of the pool for pool-specific options. The following options are supported and may appear in either section. +Just as in &freetdsconf; there are two types of sections, a [global] section whose options affect all pools, and a section with the name of the pool for pool-specific options. The following options are supported and may appear in either section. pool.conf settings @@ -2260,7 +2272,7 @@ Which shouldn't be defined unless inttypes.h exists on your The [mypool] section defines a pool named mypool that will listen on port 5000. It will login to a SQL Server named fooserv using the user webuser and the ever so clever password of secret. Once logged in, the connections will use the database ebiz instead of webuser's default database. Also, since this SQL Server has a limited number of CALs (Client Access Licenses), we are restricting the maximum number of connections to 7, which overrides the global setting of 10. -Now you can run tdspool with the name of the pool you are serving. +Run tdspool with the name of the pool you are serving. $ tdspool mypool @@ -2349,17 +2361,17 @@ Which shouldn't be defined unless inttypes.h exists on your A non-interactive equivalent of the isql utility programs distributed by Sybase and Microsoft. Like them, bsqldb uses the command go on a line by itself as a separator between batches. The last batch need not be followed by go. -bsqldb makes use of the db-lib API. Intended for production use. +bsqldb makes use of the &dblib; API. Intended for production use. bsqlodbc -A non-interactive equivalent of the isql utility programs distributed by Sybase and Microsoft. Like them, bsqlodbc uses the command go on a line by itself as a separator between batches. The last batch need not be followed by go. It uses the ODBC API. +A non-interactive equivalent of the isql utility programs distributed by Sybase and Microsoft. Like them, bsqlodbc uses the command go on a line by itself as a separator between batches. The last batch need not be followed by go. It uses the &odbc; API. -bsqlodbc is a demonstration project, but can also aid in isolating problems. ODBC applications typically have many layers, and it can be difficult to know if a problem arises in a layer, or in the interface between layers. By executing a query in bsqlodbc, you can see if the functionality of the ODBC driver works when used as the folks who wrote the driver thought it would be used. +bsqlodbc is a demonstration project, but can also aid in isolating problems. &odbc; applications typically have many layers, and it can be difficult to know if a problem arises in a layer, or in the interface between layers. By executing a query in bsqlodbc, you can see if the functionality of the &odbc; driver works when used as the folks who wrote the driver thought it would be used. @@ -2372,7 +2384,7 @@ Which shouldn't be defined unless inttypes.h exists on your datacopy will move table data from one server to another without the need for intermediate files. datacopy is much faster and more efficient than is freebcp out/in. -datacopy makes use of the db-lib bcp API. +datacopy makes use of the &dblib; bcp API. @@ -2401,7 +2413,7 @@ Which shouldn't be defined unless inttypes.h exists on your Replicates the functionality of the bcp utility programs distributed by Sybase and Microsoft. -freebcp makes use of the db-lib bcp API. +freebcp makes use of the &dblib; bcp API. The manual pages or online help for Sybase or SQL Server can be referenced for more detailed information on bcp functionality. @@ -2419,7 +2431,7 @@ Which shouldn't be defined unless inttypes.h exists on your tsql -A diagnostic tool that uses uses the lowest level FreeTDS library, libtds, as a way to isolate potential bugs in the protocol implementation. +A diagnostic tool that uses uses the lowest level &freetds; library, libtds, as a way to isolate potential bugs in the protocol implementation. tsql is not a replacement for a complete isql. @@ -2484,7 +2496,7 @@ Which shouldn't be defined unless inttypes.h exists on your DBD::ODBC -You may also use DBD::ODBC with the &freetds; ODBC driver. You may find this attractive if you're familiar with DBD::ODBC. +You may also use DBD::ODBC with the &freetds; &odbc; driver. You may find this attractive if you're familiar with DBD::ODBC. Sybperl @@ -2578,7 +2590,7 @@ Which shouldn't be defined unless inttypes.h exists on your PHP -There are three options for building PHP with support for &freetds; corresponding to the three APIs that &freetds; supports: &dblib;, &ctlib;, and ODBC. +There are three options for building PHP with support for &freetds; corresponding to the three APIs that &freetds; supports: &dblib;, &ctlib;, and &odbc;. All these examples build the CGI version. Consult PHP's documentation for building the Apache module and including other extensions. &dblib; @@ -2624,9 +2636,9 @@ Which shouldn't be defined unless inttypes.h exists on your We hope an upcoming version of PHP will automatically detect the presence of &freetds; and include only the -lct library. - <systemitem class="library">ODBC</systemitem> + &odbc; -The third and newest option is to use the &freetds; ODBC driver with PHP. First build the iODBC or unixODBC driver manager and &freetds; as detailed in . Then build PHP with support for ODBC. +The third and newest option is to use the &freetds; &odbc; driver with PHP. First build the iODBC or unixODBC driver manager and &freetds; as detailed in . Then build PHP with support for ODBC. $ cd php $ ./configure --with-iodbc=/usr/local @@ -2690,24 +2702,24 @@ Which shouldn't be defined unless inttypes.h exists on your ODBC on Unix -ODBC have many issues under Unix mainly due to lack of specifications. - +&odbc; has some issues on Unix, mainly due to lack of clean specifications. + ODBC and 64-bit -ODBC was originally specified as 32-bitIn fact, the earliest versions were 16-bit.. Its evolution to 64-bit took place in the absence of a good specification which led to conflicting declarations and associated problems. For instance, some parameters are defined as SQLINTEGER but are used for pointer offsets. But SQLINTEGER was (and remains) 32-bit, while pointer offsets must be 64-bit. Also row numbers and some other formerly 32-bity quantities are now 64-bit. +ODBC was originally specified as 32-bitIn fact, the earliest versions were 16-bit.. Its evolution to 64-bit took place in the absence of a good specification which led to conflicting declarations and associated problems. For instance, some parameters are defined as SQLINTEGER but are used for pointer offsets. But SQLINTEGER was (and remains) 32-bit, while pointer offsets must be 64-bit. Also row numbers and some other formerly 32-bit quantities are now 64-bit. If you use unixODBC Frediano would recommend at least version 2.2.14. Earlier versions have issues if used on 64-bit environments. - + sizeof(SQLWCHAR) -Under Windows sizeof(wchar_t) == sizeof(SQLWCHAR) == 2 but on many Unix systems you have sizeof(wchar_t) == 4. And some DMs decided to keep sizeof(SQLWCHAR) == 2 (including unixODBC) while in other DM sizeof(SQLWCHAR) == sizeof(wchar_t) == 4 (namely iODBC). This leads to incompatibile ABIs between applications and drivers. If you compile the &freetds; ODBC driver using iODBC take care to ensure all drivers are compiled with the same header files. +Under Windows sizeof(wchar_t) == sizeof(SQLWCHAR) == 2 but on many Unix systems you have sizeof(wchar_t) == 4. And some DMs decided to keep sizeof(SQLWCHAR) == 2 (including unixODBC) while in other DM sizeof(SQLWCHAR) == sizeof(wchar_t) == 4 (namely iODBC). This leads to incompatible ABIs between applications and drivers. If you compile the &freetds; ODBC driver using iODBC take care to ensure all drivers are compiled with the same header files. Alternatively, compile &freetds; with both includes and rename the library to use two ABIs (for instance having a libtdsiodbc.so and a libtdsuodbc.so). -As of the time of writing Ubuntu compiled Qt using iODBC but most packages use unixODBC. If you plan to use Qt with the &freetds; ODBC driver, you should have an iODBC-compatible driver. Also be aware that the QODBC Qt driver has problems with iODBC and SQLWCHAR (see Qt). Due to these problems Frediano suggests not to use this configuration (Qt database) on Ubuntu at this time. +At the time of writing Ubuntu compiled Qt using iODBC but most packages use unixODBC. If you plan to use Qt with the &freetds; &odbc; driver, you should have an iODBC-compatible driver. Also be aware that the QODBC Qt driver has problems with iODBC and SQLWCHAR (see Qt). Due to these problems Frediano suggests not using this configuration (Qt database) on Ubuntu at this time. - + Default charset Character encoding is yet another trap. ODBC makes no provision for specifying client character encoding. By default many DM converting from multi-byte to wide characters assume the client uses ISO 8859-1. Even the &freetds; driver assumes ISO 8859-1 by default. Also some DM have problems converting multi-byte encodings (like UTF-8), by assuming a byte can be converted to a single wide character (and vice versa). That creates problems if you use multi-byte encoding for &freetds; driver. @@ -2725,6 +2737,26 @@ Which shouldn't be defined unless inttypes.h exists on your Known Issues + + + Porting Issues + + + Date Structures and Offsets + +Microsoft and Sybase use different &dblib; date structures and conventions. Notably months can by [0,11] or [1,12]. Pay careful attention to the results of dbdatecrack(). + + + + Floating Point + +Precision may surprise you if you pay attention. Microsoft's &dblib; promotes single-precision to double in dbbind() by appending zeros; C promotes it to the nearest double. &freetds; relies on the C compiler. + +Math libraries vary, too. If porting an application whose output uses functions such at log(3), expect differences in different implementations. Perfectly consistent results between OSes will require the use of a single math library. + + + + <type>Text</type> Fields @@ -2746,8 +2778,9 @@ Which shouldn't be defined unless inttypes.h exists on your Another way to handle control the default TEXTSIZE is to use the setting in &freetdsconf;. - - Endianism + + + Endianism If either your server or your client is a big endian system, pay careful attention to all references to endianism anywhere near &freetds;. See the section on Little Endian Emulation for details. @@ -2761,7 +2794,7 @@ Which shouldn't be defined unless inttypes.h exists on your Microsoft's <quote>Integrated Security</quote> -&freetds; may be unable to connect to the server. The error message that appears will be "Login failed for user 'example'. Reason: Not associated with a trusted SQL Server connection". To solve this, turn on SQL Server authentication: +&freetds; may be unable to connect to the server. The error message will be "Login failed for user 'example'. Reason: Not associated with a trusted SQL Server connection". To solve this, turn on SQL Server authentication: Open the SQL Server Enterprise Manager, @@ -2778,46 +2811,16 @@ Which shouldn't be defined unless inttypes.h exists on your These instructions apply to Microsoft SQL Server 7 and SQL Server 2000. - - <productname>SQL Server</productname>'s Security Model -Microsoft supports two security models in three permutations: - - - Windows NT Authentication Mode. The operating system performs authentication; users will not have explicit SQL Server accounts. - - Standard Mode. SQL Server authenticates connections itself without consulting the operating system. Users of course need SQL Server accounts to log in. - - Mixed Mode Combines the above two. - - - For normal operation, you need either Standard or Mixed mode. - -Windows NT Authentication, often called integrated security, - relies on Microsoft's domain login. In it, a user's network security attributes are established at network login time. When connecting to the database server, SQL - Server uses the facilities of the host operating system (Windows NT or similar) to determine the authenticated network username. - SQL Server then permits or denies login access based on that network - username alone, without requiring a separate login name and password. - The &freetds; supports integrated security mode. If you have SQL Server running in integrated (domain) mode along with a Windows PDC, and wish to try it, see Domain Logins in the Advanced Configurations chapter. If you have Active Directory you can also use Kerberos, see Kerberos support. +&freetds; supports integrated security mode, too. If you have SQL Server running in integrated (domain) mode along with a Windows PDC, and wish to try it, see Domain Logins in the Advanced Configurations chapter. If you have Active Directory you can also use Kerberos, see Kerberos support. -&freetds; supports the traditional database - security model, which Microsoft terms SQL Server - Authentication but is frequently known as standard - security. Username+Password pairs have to be passed to the - server explicitly. - -Mixed Mode allows users to connect using either authentication - method. Users who connect through a Windows NT account can make use - of trusted connections in either Windows NT Authentication Mode or - Mixed Mode. After successful connection to SQL - Server, the security mechanism is the same for both - modes. - + Is the server there? + Start with <command>ping</> @@ -2829,13 +2832,13 @@ Which shouldn't be defined unless inttypes.h exists on your $ ping -c1 myhost PING myhost (127.0.0.1) from 127.0.0.1 : 56(84) bytes of data. - 64 bytes from myhost (127.0.0.1): icmp_seq=0 ttl=255 time=250 usec - + 64 bytes from myhost (127.0.0.1): icmp_seq=0 ttl=255 time=250 usec A successful ping shows that your network isn't preventing you from reaching the machine hosting the server. + - Test with <command>telnet</> + Test with <command>telnet</> Attempt to telnet to the port, to verify that the servername is listening. @@ -2845,16 +2848,15 @@ Which shouldn't be defined unless inttypes.h exists on your Trying 127.0.0.1... Connected to myhost. - Escape character is '^]'. - + Escape character is '^]'. - If you get output as above, the servername is listening. If you get a 'Connection Refused' message, you're talking to the wrong host, wrong port, or the servername is down. - To exit telnet: When connected, telnet's command mode may be entered by - typing the telnet escape character (initially Ctrl-], as above). Once in command mode, telnet may be exited with the command quit. +If you get output as above, the servername is listening. If you get a 'Connection Refused' message, you're talking to the wrong host, wrong port, or the servername is down. + To exit telnet: When connected, telnet's command mode may be entered by typing the telnet escape character (initially Ctrl-], as above). Once in command mode, telnet may be exited with the command quit. + - Test with <command>tsql</> + Test with <command>tsql</> tsql can be run in two ways, one which uses &freetdsconf; and one which connects directly using the host and port. First attempt a connection using host and port. @@ -2867,9 +2869,9 @@ Which shouldn't be defined unless inttypes.h exists on your If you receive a message like - - Msg. No.: 18450 Severity: 14 State: 1 Login failed- User: loginid Reason: Not defined as a valid user of a trusted SQL Server connection - + Msg. No.: 18450 Severity: 14 State: 1 Login failed- User: loginid + Reason: Not defined as a valid user of a trusted SQL Server connection + SQL Server is accepting only domain logins. This applies only to Microsoft SQL Server and you'll need to have your DBA verify that server logins are allowed, or use a domain login. Finally, if you received a prompt, then try tsql using the servername. @@ -2881,8 +2883,9 @@ Which shouldn't be defined unless inttypes.h exists on your If this fails, FreeTDS is either not finding your &freetdsconf; file, finding the wrong one, or there is an error in the file. + - Logging + Logging &freetds; has quite extensive logging capabilities. These are often invaluable in setting up new configurations, when it's hard to be sure precisely what configuration information is being used, and what communication is (not) working. Often such questions can be quickly resolved by turning on logging and examining the logs. Environment Variables that Control Logging @@ -2895,7 +2898,7 @@ Which shouldn't be defined unless inttypes.h exists on your $ export TDSDUMP=/tmp/freetds.log Will generate a log file named freetds.log in the /tmp directory. - The filenames stdout and stderr are also supported. They can be handy if you want to intersperse the log output with your application's output, or if your application opens more than one connection. (The logfile is otherwise normally truncatated each time the library connects to the server.) + The filenames stdout and stderr are also supported. They can be handy if you want to intersperse the log output with your application's output, or if your application opens more than one connection. (The logfile is otherwise normally truncated each time the library connects to the server.) @@ -3054,13 +3057,14 @@ Which shouldn't be defined unless inttypes.h exists on your #define NOREVERSELOOKUPS - in src/tds/config.c, rebuilding, and reinstalling. - Reverse lookup code has been removed as of version 0.62 due to wrong implementation. + +in src/tds/config.c, rebuilding, and reinstalling. + + Reverse lookup code has been removed as of version 0.62 because it was poorly implemented. -Packet size. Check packet size setting on &freetdsconf; (see initial block size). Default value (no configuration) is usually fine. The slowness is due to multiple packet to use. - Under GNU/Linux system we use an optimization to reduce network traffic so you shouldn't see much difference using this system. +Packet size. The default packet size setting in &freetdsconf; (see initial block size) is usually fine. Slowness can potentially be due to multiple packet to use. Under GNU/Linux system we use an optimization to reduce network traffic; you shouldn't see much difference using this system. @@ -3101,8 +3105,7 @@ Compile-time settings (established with the "configure" script) iODBC: no unixodbc: no SSPI "trusted" logins: no - Keberos: no - + Keberos: no For &odbc; setup issues, the osql script is intended to confirm the configuration files are all sane. If it fails to report a problem, please post a message describing the problem to the mailing list. Thanks. @@ -3236,7 +3239,7 @@ For &odbc; setup issues, the osql script is intended to confi We have just begun an independent reference manual to &freetds;; the main API documents are the work of the server vendors. We're using Doxygen, which extracts documentation directly from comments in the source code, and we're maybe 25% done. -The TDS protocol is partly documented, as are the APIs to libtds and db-lib, but much remains. +The TDS protocol is partly documented, as are the APIs to libtds and &dblib;, but much remains. Be the Webmaster @@ -3289,7 +3292,8 @@ For &odbc; setup issues, the osql script is intended to confi What can &freetds; do that can't be done any other way? Glad you asked. &freetds; can Connect to every version of either vendor's server, using the same binaries. - Provide a &ctlib; interface to Microsoft SQL Server. This feature alone allows DBD::Sybase and sqsh, among others, to connect to Microsoft's product. + Provide a &ctlib; for Microsoft SQL Server. This feature alone allows DBD::Sybase and sqsh, among others, to connect to Microsoft's product. + Provide a modern &dblib; for Microsoft SQL Server: Win32/64, and TDS 7+. Provide a bcp-capable interface and command-line utility on unix-like operating systems for Microsoft SQL Server. Run on many more operating systems than either vendor's libraries do. Get fixed, instead of telling you to get stuffed. @@ -3313,7 +3317,7 @@ For &odbc; setup issues, the osql script is intended to confi The reference manual is installed as part of FreeTDS. It can be regenerated at any time using Doxygen with cd doc; make doc. -The reference manual is a work in progress: only the db-lib library is completely documented, and quite minimally at that. Should you find it inadequate, you may be interested to learn it's not hard to add to, technically. Doxygen generates a manual from encoded comments in the source code. Its markup syntax is not hard to learn. You can read more about it at the Doxygen website. +The reference manual is a work in progress: only &dblib; is completely documented, and quite minimally at that. Should you find it inadequate, you may be interested to learn it's not hard to add to, technically. Doxygen generates a manual from encoded comments in the source code. Its markup syntax is not hard to learn. You can read more about it at the Doxygen website. Basic API coverage information for the db-lib, ct-lib, and ODBC client libraries is maintained in doc/api_status.txt, included in the source distribution. For your convenience and enjoyment, we include that file in the following sections. In each table, we note for the function Sybase and Microsoft sometimes use slightly different names for the same function. It is the intention of the - db-lib API Implementation Summary + &dblib; API Implementation Summary -Microsoft's version of db-lib is +Microsoft's version of &dblib; is online. Sybase's is both online @@ -3394,7 +3398,7 @@ For &odbc; setup issues, the osql script is intended to confi Few things are harder to put up with than the annoyance of a good example. - Below is a complete sample working db-lib program, presented as a series of examples. + Below is a complete sample working &dblib; program, presented as a series of examples. Features of sample code Processes command-line options to select the server, database, username, and password Remaining arguments on the command line comprise the SQL query to execute @@ -3409,7 +3413,7 @@ For &odbc; setup issues, the osql script is intended to confi Correct handling of errors is extremely important in database applications because they involve two systems most others don't: the network and the database server. Both can give rise to errors that, if not detected and reported when they occur, let the application proceed blithely on until something truly mysterious happens. In the worst case, in the absence of a properly reported error, the application may seem to have updated the data, when in fact it did not. -Every db-lib application uses the network, making it subject to network failures. Database programs also almost always have very high data integrity requirements. It is necessary to know the row was absolutely, positively committed, once and only once, without error or exception. Without taking great care to trap and handle all error conditions, no statement about the program's reliability can be made with confidence. +Every &dblib; application uses the network, making it subject to network failures. Database programs also almost always have very high data integrity requirements. It is necessary to know the row was absolutely, positively committed, once and only once, without error or exception. Without taking great care to trap and handle all error conditions, no statement about the program's reliability can be made with confidence. How to Get and Build the sample code @@ -3438,11 +3442,11 @@ For &odbc; setup issues, the osql script is intended to confi We now proceed to the code proper. Header files - We need two header files to use db-lib. We need a few others to deal with I/O in C, as you know. Also declare the error and message handler functions, more about which later. + We need two header files to use &dblib;. We need a few others to deal with I/O in C, as you know. Also declare the error and message handler functions, more about which later. - Sample Code: <symbol>db-lib</> header files + Sample Code: &dblib; header files @@ -3467,7 +3471,7 @@ int msg_handler(DBPROCESS*, DBINT, int, int, char*, char*, char*, int); - Sample Code: <symbol>db-lib</> prolog + Sample Code: &dblib; prolog extern char *optarg; extern int optind; @@ -3528,7 +3532,7 @@ int msg_handler(DBPROCESS*, DBINT, int, int, char*, char*, char*, int); DBPROCESS is a structure that describes the connection. It is returned by dbopen(). -RETCODE is the most common return code type for db-lib functions. +RETCODE is the most common return code type for &dblib; functions. @@ -3537,7 +3541,7 @@ int msg_handler(DBPROCESS*, DBINT, int, int, char*, char*, char*, int); - Sample Code: <symbol>db-lib</> Initialize + Sample Code: &dblib; Initialize @@ -3585,7 +3589,7 @@ int msg_handler(DBPROCESS*, DBINT, int, int, char*, char*, char*, int); - Sample Code: <symbol>db-lib</> Connect to the server + Sample Code: &dblib; Connect to the server if ((dbproc = dbopen(login, options.servername)) == NULL) { fprintf(stderr, "%s:%d: unable to connect to %s as %s\n", @@ -3604,13 +3608,13 @@ int msg_handler(DBPROCESS*, DBINT, int, int, char*, char*, char*, int); Send a query - db-lib maintains a command buffer to hold the SQL to be sent to the server. Two functions — dbcmd() and dbfcmd() — build up the query from strings of text. The command buffer is reset after the query is sent to the server. + &dblib; maintains a command buffer to hold the SQL to be sent to the server. Two functions — dbcmd() and dbfcmd() — build up the query from strings of text. The command buffer is reset after the query is sent to the server. We left the SQL on the command line. We fetch it now and send it to the server. - Sample Code: <symbol>db-lib</> Send a query + Sample Code: &dblib; Send a query for (i=0; i < argc; i++) { assert(argv[i]); @@ -3637,7 +3641,7 @@ int msg_handler(DBPROCESS*, DBINT, int, int, char*, char*, char*, int); Fetch Results - A query may produce zero, one, or more results. Broadly, that entails providing buffers to db-lib to fill, and iterating over the results a row (and column) at a time. + A query may produce zero, one, or more results. Broadly, that entails providing buffers to &dblib; to fill, and iterating over the results a row (and column) at a time. Kinds of Results @@ -3747,16 +3751,16 @@ int msg_handler(DBPROCESS*, DBINT, int, int, char*, char*, char*, int); Binding -Each time dbresults() returns SUCCEED, there is something to retrieve. db-lib has different functions to deal with the different kinds of results. The functions are of two kinds: those that convert the data into a form desired by the application, known as binding, and those that return the data in native form. +Each time dbresults() returns SUCCEED, there is something to retrieve. &dblib; has different functions to deal with the different kinds of results. The functions are of two kinds: those that convert the data into a form desired by the application, known as binding, and those that return the data in native form. To understand binding, it may be easiest to examine two primitive functions, dbdata() and dbconvert(). dbdata() returns a pointer to the column's data. The data to which it points are in native form, 4 bytes for an INT, 8 bytes for a DATETIME and so on. dbconvert() converts between datatypes; you can hand it an integer and get back a character array (or a C double. You might think of dbconvert() as atoi(3) on steroids). dbbind() combines these two functions. The application indicates in what form it would like to use each column, and the library converts them on the fly as each row is read. -To bind a column is to provide a buffer to db-lib to fill and indicate which datatype the buffer is meant to hold. This is the sort of thing C++'s type system does so much better +To bind a column is to provide a buffer to &dblib; to fill and indicate which datatype the buffer is meant to hold. This is the sort of thing C++'s type system does so much better -It may be well to pause here to observe the three ways a datatype is described in a db-lib program. +It may be well to pause here to observe the three ways a datatype is described in a &dblib; program. <function>db-lib</> Datatype Descriptors Sever Datatype @@ -3782,7 +3786,7 @@ int msg_handler(DBPROCESS*, DBINT, int, int, char*, char*, char*, int); -Typically it's more convenient to have db-lib convert the data into the desired form. The function that does that is dbind(). So: after fetching the metadata, and before fetching the data, we usually prepare the bound columns. +Typically it's more convenient to have &dblib; convert the data into the desired form. The function that does that is dbind(). So: after fetching the metadata, and before fetching the data, we usually prepare the bound columns. Fetching Data @@ -3896,14 +3900,14 @@ int msg_handler(DBPROCESS*, DBINT, int, int, char*, char*, char*, int); Fetch All Rows! - db-lib doesn't insist every column — or even any column — be bound or otherwise retrieved into the application's variables. There is, however, one absolutely crucial, inflexible, unalterable requirement: the application must process all rows produced by the query. Before the DBPROCESS can be used for another query, the application must either fetch all rows, or cancel the results and receive an acknowledgement from the server. Cancelling is beyond the scope of this document, so for now fetch all rows. + &dblib; doesn't insist every column — or even any column — be bound or otherwise retrieved into the application's variables. There is, however, one absolutely crucial, inflexible, unalterable requirement: the application must process all rows produced by the query. Before the DBPROCESS can be used for another query, the application must either fetch all rows, or cancel the results and receive an acknowledgement from the server. Cancelling is beyond the scope of this document, so for now fetch all rows. Now, at last, some sample code that fetches data. In the interest of simplicity, we don't bind anything except regular rows. - Sample Code: <symbol>db-lib</> Fetch Results + Sample Code: &dblib; Fetch Results while ((erc = dbresults(dbproc)) != NO_MORE_RESULTS) { struct COL @@ -4023,7 +4027,7 @@ int msg_handler(DBPROCESS*, DBINT, int, int, char*, char*, char*, int); Data-fetching Notes As soon as dbresults() reports SUCCESS, the row's metadata are available. - db-lib columns start with 1. + &dblib; columns start with 1. dbcollen() returns the sizeof the native data (e.g. 4 bytes for a T-SQL INT). We'll use dbbind() to convert everything to strings. If the column is [VAR]CHAR, we want the column's defined size, otherwise we want its maximum size when represented as a string, which FreeTDS's dbwillconvert() returns (for fixed-length datatypes). For IMAGE data, we need to multiply by 2, because dbbind() will convert each byte to a hexadecimal pair. The example program will report an error with IMAGE data. NTBSTRINGBIND null-terminates the character array for us. NTB might perhaps stand for null terminating byte. A zero-length string is not a NULL! dbnullbind() arranges for the passed buffer to be set to -1 whenever that column is NULL for a particular row. @@ -4033,7 +4037,7 @@ int msg_handler(DBPROCESS*, DBINT, int, int, char*, char*, char*, int); Messages and Errors - Errors may originate on the server or in the library itself. The former are known as messages (because they are: they arrive as messages from the server); the latter are termed errors. Their handling is a little intimidating. It requires writing and installing a callback function (whose parameters are predefined by db-lib), and thinking about how to handle different types of errors. + Errors may originate on the server or in the library itself. The former are known as messages (because they are: they arrive as messages from the server); the latter are termed errors. Their handling is a little intimidating. It requires writing and installing a callback function (whose parameters are predefined by &dblib;), and thinking about how to handle different types of errors. Kinds of Errors @@ -4047,7 +4051,7 @@ int msg_handler(DBPROCESS*, DBINT, int, int, char*, char*, char*, int); Errors -Errors arise either because the application has misused db-lib in some way — say, passed a NULL DBPROCESS pointer or tried to issue a query while results were pending — or because some trouble cropped up in communicating with the server (couldn't find it, say, or didn't hear back from it). +Errors arise either because the application has misused &dblib; in some way — say, passed a NULL DBPROCESS pointer or tried to issue a query while results were pending — or because some trouble cropped up in communicating with the server (couldn't find it, say, or didn't hear back from it). @@ -4055,11 +4059,11 @@ int msg_handler(DBPROCESS*, DBINT, int, int, char*, char*, char*, int); Why these two require distinct handling is lost in the mists of time. But it does help to keep them distinct in your mind, especially while reading the documentation. -To have db-lib use your handler, pass its name to the appropriate dberrhandle() or dbmsghandle() function immediately after calling dbinit(). +To have &dblib; use your handler, pass its name to the appropriate dberrhandle() or dbmsghandle() function immediately after calling dbinit(). - Sample Code: <symbol>db-lib</> Error and Message handlers + Sample Code: &dblib; Error and Message handlers int msg_handler(DBPROCESS *dbproc, DBINT msgno, int msgstate, int severity, @@ -4119,8 +4123,8 @@ int msg_handler(DBPROCESS*, DBINT, int, int, char*, char*, char*, int); Severities are defined in the server documentation, and can be set by the T-SQL RAISERROR statement. Message handlers always and only ever return zero. When first writing the handler, pay careful attention to the precise type of each parameter. Only by carefully matching them will you convince a modern C compiler that the address of your function is of the type accepted by dberrhandle(). If that advice sounds familiar, it's because it bears repeating. - Some messages are so severe they provoke db-lib into calling the error handler, too! If you have both installed — and of course you do, right? — then you can skip those lacking an error number. - While INT_CANCEL is the most common return code, it's not the only one. For one thing, the error handler's return code can control how long db-lib keeps retrying timeout errors. See the documentation for details. + Some messages are so severe they provoke &dblib; into calling the error handler, too! If you have both installed — and of course you do, right? — then you can skip those lacking an error number. + While INT_CANCEL is the most common return code, it's not the only one. For one thing, the error handler's return code can control how long &dblib; keeps retrying timeout errors. See the documentation for details. @@ -4135,13 +4139,13 @@ int msg_handler(DBPROCESS*, DBINT, int, int, char*, char*, char*, int); getuserdata(). - If your application is written in C++, you may be tempted to use throw(). Don't! Your handler is a C function and, more important, it's an extension of db-lib. You can put a throw() in your handler and it will compile. But when it executes, it's going to rip through db-lib's stack. Your application will be unuseable at that point, if it doesn't cause a segment fault. + If your application is written in C++, you may be tempted to use throw(). Don't! Your handler is a C function and, more important, it's an extension of &dblib;. You can put a throw() in your handler and it will compile. But when it executes, it's going to rip through &dblib;'s stack. Your application will be unuseable at that point, if it doesn't cause a segment fault. Last Remarks -We've reached the end of our db-lib tour. The almost 300 lines of C above constitute program with these features: +We've reached the end of our &dblib; tour. The almost 300 lines of C above constitute program with these features: Sample Code features</> <listitem><para>Accepts command-line parameters and SQL.</para></listitem> <listitem><para>Checks for errors and server messages.</para></listitem> @@ -4529,6 +4533,7 @@ Important to understand: <command>ldd</command> is <emphasis>not</emphasis> figu <para>The linker, static or runtime, uses only the function's name to resolve references. Function parameters and semantics are invisible to it. </para> <para>The programmer and, to a lesser degree, the sysadmin direct the choice of which library to link to an executable. A missing function will prevent execution. A wrong function will promote wrong execution. Don't do that. </para> + </section> </Appendix> commit 89d5fb43106ee5fb41168ea5839f76a96e313142 Author: jklowden <jklowden> Date: Tue Mar 22 00:41:31 2011 +0000 updated for upcoming release diff --git a/doc/userguide.sgml b/doc/userguide.sgml index 80f95bc..6eb480a 100644 --- a/doc/userguide.sgml +++ b/doc/userguide.sgml @@ -8,13 +8,13 @@ <!ENTITY dblib '<systemitem class="library">DB-Library</systemitem>'> <!ENTITY ctlib '<systemitem class="library">CT-Library</systemitem>'> <!ENTITY odbc '<systemitem class="library">ODBC</systemitem>'> - <!ENTITY version "0.92"> <!-- echo '0.84 + 0.5 * (1.0 - 0.84)' --> + <!ENTITY version "0.91"> <!-- echo $(( (100 - 82)/2 + 82))--> <!ENTITY freetdsconf "<filename>freetds.conf</filename>"> ]> <book> <bookinfo> - <date>$Date: 2011/03/22 00:23:24 $</date> - <releaseinfo>$Revision: 1.135 $</releaseinfo> + <date>$Date: 2011/03/22 00:41:31 $</date> + <releaseinfo>$Revision: 1.136 $</releaseinfo> <title>&freetds; User Guide A Guide to Installing, Configuring, and Running &freetds; @@ -63,9 +63,9 @@ The version you're reading is: - $Revision: 1.135 $ - $Date: 2011/03/22 00:23:24 $ - CVS control number $Id: userguide.sgml,v 1.135 2011/03/22 00:23:24 jklowden Exp $. + $Revision: 1.136 $ + $Date: 2011/03/22 00:41:31 $ + CVS control number $Id: userguide.sgml,v 1.136 2011/03/22 00:41:31 jklowden Exp $. can be found on the &freetds; @@ -616,7 +616,7 @@ Which shouldn't be defined unless inttypes.h exists on your OS X® -As of this writing ($Date: 2011/03/22 00:23:24 $), the regular distribution compiles on OS X. +As of this writing ($Date: 2011/03/22 00:41:31 $), the regular distribution compiles on OS X. commit ef6aecb2f6ebec3e23546e34fb02168b91eb8e32 Author: jklowden Date: Tue Mar 22 13:11:14 2011 +0000 updated for upcoming release diff --git a/doc/userguide.sgml b/doc/userguide.sgml index 6eb480a..b154ca1 100644 --- a/doc/userguide.sgml +++ b/doc/userguide.sgml @@ -13,8 +13,8 @@ ]> - $Date: 2011/03/22 00:41:31 $ - $Revision: 1.136 $ + $Date: 2011/03/22 13:11:14 $ + $Revision: 1.137 $ &freetds; User Guide A Guide to Installing, Configuring, and Running &freetds; @@ -63,9 +63,9 @@ The version you're reading is: - $Revision: 1.136 $ - $Date: 2011/03/22 00:41:31 $ - CVS control number $Id: userguide.sgml,v 1.136 2011/03/22 00:41:31 jklowden Exp $. + $Revision: 1.137 $ + $Date: 2011/03/22 13:11:14 $ + CVS control number $Id: userguide.sgml,v 1.137 2011/03/22 13:11:14 jklowden Exp $. can be found on the &freetds; @@ -616,7 +616,7 @@ Which shouldn't be defined unless inttypes.h exists on your OS X® -As of this writing ($Date: 2011/03/22 00:41:31 $), the regular distribution compiles on OS X. +As of this writing ($Date: 2011/03/22 13:11:14 $), the regular distribution compiles on OS X. @@ -745,6 +745,10 @@ Which shouldn't be defined unless inttypes.h exists on your 7.2 Includes support for varchar(max), varbinary(max), xml datatypes and MARSMultiple Active Result Sets. &freetds; does not support MARS.. + + Microsoft SQL Server 2008 + 7.2 (unchanged) +
    commit dfab441387bc2cac0d51f37a836ac1e0d9a7360c Author: jklowden Date: Tue Mar 22 16:00:44 2011 +0000 updated for upcoming release diff --git a/doc/userguide.sgml b/doc/userguide.sgml index b154ca1..de05057 100644 --- a/doc/userguide.sgml +++ b/doc/userguide.sgml @@ -13,8 +13,8 @@ ]> - $Date: 2011/03/22 13:11:14 $ - $Revision: 1.137 $ + $Date: 2011/03/22 16:00:44 $ + $Revision: 1.138 $ &freetds; User Guide A Guide to Installing, Configuring, and Running &freetds; @@ -63,9 +63,9 @@ The version you're reading is: - $Revision: 1.137 $ - $Date: 2011/03/22 13:11:14 $ - CVS control number $Id: userguide.sgml,v 1.137 2011/03/22 13:11:14 jklowden Exp $. + $Revision: 1.138 $ + $Date: 2011/03/22 16:00:44 $ + CVS control number $Id: userguide.sgml,v 1.138 2011/03/22 16:00:44 jklowden Exp $. can be found on the &freetds; @@ -328,7 +328,7 @@ The TDS part of the name comes from name of the protocol used to The simplest form of running configure is: $ ./configure - and sometimes that's enough. configure accepts command-line arguments, too, and you may need to provide some, depending on what your environment looks like. + and sometimes that's enough. configure accepts command-line arguments, too, and you may need to provide some, depending on your environment.
    There are a few optional arguments to configure that may be important to you. For a complete list, see configure --help. @@ -449,14 +449,13 @@ The TDS part of the name comes from name of the protocol used to - Enable Kerberos support. With Kerberos you can connect to server using your stored Kerberos ticket. - This require you to configure Kerberos support on your machine. + Enable Kerberos support. With Kerberos you can connect to server using your stored Kerberos ticket. Obviously requires Kerberos be configured on the machine. - Enable SSPI support. SSPI is a Micrsoft library that allows you to use your current logged account for authentication. With this option enabled, FreeTDS supports "trusted logins" for Win32/64, just as Microsoft's own implmentations do. + Enable SSPI support. SSPI is a Micrsoft library that allows you to use your current logged-in account for authentication. With this option enabled, FreeTDS supports "trusted logins" for Win32/64, just as Microsoft's own implementations do. @@ -512,6 +511,17 @@ The TDS part of the name comes from name of the protocol used to You normally need to be root to make install, unless you used the With any luck, you've built and installed the &freetds; libraries. + + + Two bits of advice, if you like to keep things tidy and keep track of what you did. + + Create a file to hold your configure options called, say, .build_options. + + Create a build directory for the binaries, and invoke ../configure $(cat ../.build_options). + + This approach lets you remove the binaries at any time and rebuild from scratch using the same options + +
    @@ -616,7 +626,7 @@ Which shouldn't be defined unless inttypes.h exists on your OS X® -As of this writing ($Date: 2011/03/22 13:11:14 $), the regular distribution compiles on OS X. +As of this writing ($Date: 2011/03/22 16:00:44 $), the regular distribution compiles on OS X. commit d796ef604f8988874b91b8e6719663a38d9b1f05 Author: jklowden Date: Tue Mar 22 16:03:44 2011 +0000 updated for upcoming release diff --git a/doc/userguide.sgml b/doc/userguide.sgml index de05057..de9133f 100644 --- a/doc/userguide.sgml +++ b/doc/userguide.sgml @@ -13,8 +13,8 @@ ]> - $Date: 2011/03/22 16:00:44 $ - $Revision: 1.138 $ + $Date: 2011/03/22 16:03:44 $ + $Revision: 1.139 $ &freetds; User Guide A Guide to Installing, Configuring, and Running &freetds; @@ -63,9 +63,9 @@ The version you're reading is: - $Revision: 1.138 $ - $Date: 2011/03/22 16:00:44 $ - CVS control number $Id: userguide.sgml,v 1.138 2011/03/22 16:00:44 jklowden Exp $. + $Revision: 1.139 $ + $Date: 2011/03/22 16:03:44 $ + CVS control number $Id: userguide.sgml,v 1.139 2011/03/22 16:03:44 jklowden Exp $. can be found on the &freetds; @@ -519,7 +519,7 @@ The TDS part of the name comes from name of the protocol used to Create a build directory for the binaries, and invoke ../configure $(cat ../.build_options). - This approach lets you remove the binaries at any time and rebuild from scratch using the same options + This approach lets you remove the binaries at any time and rebuild from scratch using the same options. @@ -626,7 +626,7 @@ Which shouldn't be defined unless inttypes.h exists on your OS X® -As of this writing ($Date: 2011/03/22 16:00:44 $), the regular distribution compiles on OS X. +As of this writing ($Date: 2011/03/22 16:03:44 $), the regular distribution compiles on OS X. commit 820de48076d626c32f80503a756cc5c1fd93da0e Author: jklowden Date: Tue Mar 22 17:54:04 2011 +0000 neater output diff --git a/ChangeLog b/ChangeLog index ac8e369..7efbb19 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Mar 22 13:51:32 EDT 2011 JK Lowden + * autogen.sh neater output + * src/apps/tsql.c spell Kerberos correctly + * src/dblib/bcp.c initialize bcp_terminator + Mon Mar 21 20:21:51 EDT 2011 JK Lowden * doc/userguide.sgml updated for upcoming release @@ -3183,4 +3188,4 @@ Wed Jan 9 19:54:43 EST 2008 JK Lowden * ChangeLog-0.82 added because of release $FreeTDS$ -$Id: ChangeLog,v 1.3202 2011/03/22 00:23:23 jklowden Exp $ +$Id: ChangeLog,v 1.3203 2011/03/22 17:54:04 jklowden Exp $ diff --git a/autogen.sh b/autogen.sh index 13f0052..8111ee3 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,7 +1,7 @@ #!/bin/sh # Run this to generate all the initial makefiles, etc. -# $Id: autogen.sh,v 1.9 2006/10/21 12:23:07 freddy77 Exp $ +# $Id: autogen.sh,v 1.10 2011/03/22 17:54:04 jklowden Exp $ # From automake.info: # @@ -34,7 +34,9 @@ PKG_NAME="FreeTDS." #conf_flags="--enable-maintainer-mode --enable-compile-warnings" #--enable-iso-c if test x$NOCONFIGURE = x; then - echo Running $srcdir/configure $conf_flags "$@" ... + echo Running $srcdir/configure $conf_flags "$@" '...' \ + | tr ' ' \\n \ + | sed 's/^-/ &/' $srcdir/configure $conf_flags "$@" \ && echo Now type \`make\' to compile $PKG_NAME else commit 596ea4c77e9652eb16082f26da68ef333ec4a252 Author: jklowden Date: Tue Mar 22 17:54:09 2011 +0000 spell Kerberos correctly diff --git a/src/apps/tsql.c b/src/apps/tsql.c index 43c9029..c2e9ee6 100644 --- a/src/apps/tsql.c +++ b/src/apps/tsql.c @@ -87,7 +87,7 @@ #include "tdsconvert.h" #include "replacements.h" -TDS_RCSID(var, "$Id: tsql.c,v 1.139 2010/12/21 16:55:24 jklowden Exp $"); +TDS_RCSID(var, "$Id: tsql.c,v 1.140 2011/03/22 17:54:09 jklowden Exp $"); #define TDS_ISSPACE(c) isspace((unsigned char) (c)) @@ -459,7 +459,7 @@ populate_login(TDSLOGIN * login, int argc, char **argv) "iODBC", settings->iodbc ? "yes" : "no", "unixodbc", settings->unixodbc ? "yes" : "no", "SSPI \"trusted\" logins", have_sspi, - "Keberos", enable_krb5); + "Kerberos", enable_krb5); exit(0); break; default: commit 8b182a2cf698b9be27c6ad8cd37bc6b2b4934a4e Author: jklowden Date: Tue Mar 22 17:54:13 2011 +0000 initialize bcp_terminator diff --git a/src/dblib/bcp.c b/src/dblib/bcp.c index 728e364..1fb35d9 100644 --- a/src/dblib/bcp.c +++ b/src/dblib/bcp.c @@ -62,7 +62,7 @@ #define MAX(a,b) ( (a) > (b) ? (a) : (b) ) #endif -TDS_RCSID(var, "$Id: bcp.c,v 1.196 2011/01/14 14:18:15 freddy77 Exp $"); +TDS_RCSID(var, "$Id: bcp.c,v 1.197 2011/03/22 17:54:13 jklowden Exp $"); #ifdef HAVE_FSEEKO typedef off_t offset_type; @@ -2352,6 +2352,9 @@ bcp_bind(DBPROCESS * dbproc, BYTE * varaddr, int prefixlen, DBINT varlen, colinfo->column_varaddr = (char *)varaddr; colinfo->column_bindtype = vartype; colinfo->column_bindlen = varlen; + + TDS_ZERO_FREE(colinfo->bcp_terminator); + colinfo->bcp_term_len = 0; if((colinfo->bcp_terminator = malloc(termlen)) == NULL) { dbperror(dbproc, SYBEMEM, errno); return FAIL;