I'm doing some test to get 100% working with FreeTDS (sql server odbc
driver for *nix) and DBD::ODBC.

Using 1.09 I get some fails (see out1.txt)

Analyzing log (unixODBC and FreeTDS one) it appear that binding is wrong
for input/output parameters. You bind a string composed by one zero
character ("\0"), not a NULL. I did this change:

diff -r -U10 DBD-ODBC-1.09orig/dbdimp.c DBD-ODBC-1.09/dbdimp.c
--- DBD-ODBC-1.09orig/dbdimp.c  2004-03-06 18:53:58.000000000 +0100
+++ DBD-ODBC-1.09/dbdimp.c      2004-04-15 21:24:10.000000000 +0200
@@ -2617,20 +2634,21 @@
       cbColDef = 1;
       if (phs->is_inout) {
         if (!phs->sv_buf) {
            croak("panic: DBD::ODBC binding undef with bad buffer!!!!");
         }
         phs->sv_buf[0] = '\0'; /* just in case, we *know* we called
SvGROW above */
         rgbValue = phs->sv_buf;
         /* patch for binding undef inout params on sql server */
         ibScale = 1;
         phs->cbValue = 1;
+        phs->cbValue = SQL_NULL_DATA;
       } else {
         rgbValue = NULL;
         phs->cbValue = SQL_NULL_DATA;
       }
    }
    else {
       rgbValue = phs->sv_buf;
       phs->cbValue = (UDWORD) value_len;
       /* not undef, may be a blank string or something */
       if (phs->cbValue == 0)

however I get a infinite loop (see out2.txt). From unixODBC log it seems
that DBD::ODBC calls in a loop SQLMoreResults, SQLMoreResults returns
SQL_NO_DATA however DBD::ODBC doesn't reset moreResults.

I improved the patch (attached) however I don't understand why I get
infinite loop with FreeTDS and not with MS ODBC...
Why you pass a null character instead of a NULL? From comment it's a
workaround for sql server however it can break other drivers, a best way
for sql server if to use only output parameter (not input/output) cause
with sql server you use always deferred bind.
I did also some changes to t/07bind.t however I don't know if these
change are so right...

freddy77
[EMAIL PROTECTED] DBD-ODBC-1.09]$ perl Makefile.PL
Useless use of private variable in void context at Makefile.PL line 430.

Configuring DBD::ODBC ...

>>>     Remember to actually *READ* the README file!
        And re-read it if you have any problems.

Using DBI 1.37 installed in 
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi/auto/DBI
Using ODBC in /usr
Use of uninitialized value in substitution (s///) at Makefile.PL line 154.

Umm, this looks like a unixodbc type of driver manager.
We expect to find the sql.h, sqlext.h and (which were
supplied with unixODBC) in $ODBCHOME/include directory alongside
the /usr/lib/libodbc.a /usr/lib/libodbc.so library. in $ODBCHOME/lib

Use of uninitialized value in pattern match (m//) at Makefile.PL line 271.
Warning: LD_LIBRARY_PATH doesn't include /usr

Checking if your kit is complete...
Looks good
Injecting selected odbc driver into cc command
Injecting selected odbc driver into cc command
Using DBI 1.37 installed in 
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi/auto/DBI
Writing Makefile for DBD::ODBC

The DBD::ODBC tests will use these values for the database connection:
    DBI_DSN=dbi:ODBC:OPDN106            e.g. dbi:ODBC:demo
    DBI_USER=test
    DBI_PASS=test


[EMAIL PROTECTED] DBD-ODBC-1.09]$ make
cp Changes blib/lib/DBD/ODBC/Changes.pm
cp ODBC.pm blib/lib/DBD/ODBC.pm
/usr/bin/perl -p -e "s/~DRIVER~/ODBC/g" < 
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi/auto/DBI/Driver.xst > ODBC.xsi
/usr/bin/perl /usr/lib/perl5/5.8.3/ExtUtils/xsubpp  -typemap 
/usr/lib/perl5/5.8.3/ExtUtils/typemap  ODBC.xs > ODBC.xsc && mv ODBC.xsc ODBC.c
Warning: duplicate function definition 'data_sources' detected in ODBC.xs, line 202
gcc -c -I/usr/include  -I. 
-I/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi/auto/DBI -D_REENTRANT 
-D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBUGGING -fno-strict-aliasing 
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm 
-O2 -g -pipe -march=i386 -mcpu=i686   -DVERSION=\"1.09\" -DXS_VERSION=\"1.09\" -fPIC 
"-I/usr/lib/perl5/5.8.3/i386-linux-thread-multi/CORE"  -I/usr/include ODBC.c
gcc -c -I/usr/include  -I. 
-I/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi/auto/DBI -D_REENTRANT 
-D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBUGGING -fno-strict-aliasing 
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm 
-O2 -g -pipe -march=i386 -mcpu=i686   -DVERSION=\"1.09\" -DXS_VERSION=\"1.09\" -fPIC 
"-I/usr/lib/perl5/5.8.3/i386-linux-thread-multi/CORE"  -I/usr/include dbdimp.c
Running Mkbootstrap for DBD::ODBC ()
chmod 644 ODBC.bs
rm -f blib/arch/auto/DBD/ODBC/ODBC.so
LD_RUN_PATH="/usr/lib" gcc  -shared -L/usr/local/lib ODBC.o dbdimp.o  -o 
blib/arch/auto/DBD/ODBC/ODBC.so   -L/usr/lib -lodbc
chmod 755 blib/arch/auto/DBD/ODBC/ODBC.so
cp ODBC.bs blib/arch/auto/DBD/ODBC/ODBC.bs
chmod 644 blib/arch/auto/DBD/ODBC/ODBC.bs
Manifying blib/man3/DBD::ODBC.3pm


[EMAIL PROTECTED] DBD-ODBC-1.09]$ make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 
'blib/lib', 'blib/arch')" t/*.t
t/01base.........ok
t/02simple.......ok
t/03dbatt........ok
t/05meth.........ok
t/07bind.........ok
t/08bind2........skipped
        all skipped: SQLDescribeParam not supported using Microsoft SQL Server
t/09multi........ok
t/20SqlServer....ok 3/28DBD::ODBC::st execute failed: (DBD: st_execute/SQLExecute 
err=-1) at t/20SqlServer.t line 214.
t/20SqlServer....dubious
        Test returned status 255 (wstat 65280, 0xff00)
Scalar found where operator expected at (eval 152) line 1, near "'int'  $__val"
        (Missing operator before   $__val?)
DIED. FAILED tests 4-28
        Failed 25/28 tests, 10.71% okay
t/30Oracle.......skipped
        all skipped: Oracle tests not supported using Microsoft SQL Server
Failed Test     Stat Wstat Total Fail  Failed  List of Failed
-------------------------------------------------------------------------------
t/20SqlServer.t  255 65280    28   50 178.57%  4-28
2 tests skipped.
Failed 1/9 test scripts, 88.89% okay. 25/93 subtests failed, 73.12% okay.
make: *** [test_dynamic] Error 255


[EMAIL PROTECTED] DBD-ODBC-1.09]$ make test TEST_VERBOSE=1
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(1, 
'blib/lib', 'blib/arch')" t/*.t
t/01base.........1..5
ok 1
ok 2
ok 3
ok 4
ok 5
ok
t/02simple.......1..21
ok 1
 Test 2: connecting to the database
ok 2
 Test 3: create test table
Using fields: COL_A smallint NOT NULL PRIMARY KEY , COL_B varchar(8000), COL_C text, 
COL_D datetime
ok 3
 Test 4: check existance of test table
(unknown owner).PERL_DBD_TEST
ok 4
 Test 5: insert test data
ok 5
 Test 6: select test data
1|foo|foo varchar|
2|bar|bar varchar|
3|bletch|bletch varchar|
4|80char|THIS IS A STRING LONGER THAN 80 CHARS.  THIS SHOULD BE CHECKED FOR TRUNCATION 
AND COMPARED WITH ITSELF.|
5|gt250char|THIS IS A STRING LONGER THAN 80 CHARS.  THIS SHOULD BE CHECKED FOR 
TRUNCATION AND COMPARED WITH ITSELF.  THIS IS A STRING LONGER THAN 80 CHARS.  THIS 
SHOULD BE CHECKED FOR TRUNCATION AND COMPARED WITH ITSELF.  THIS IS A STRING LONGER 
THAN 80 CHARS.  THIS SHOULD BE CHECKED FOR TRUNCATION AND COMPARED WITH ITSELF.  THIS 
IS A STRING LONGER THAN 80 CHARS.  THIS SHOULD BE CHECKED FOR TRUNCATION AND COMPARED 
WITH ITSELF.|
retrieved 103 byte string OK
retrieved 418 byte string OK
ok 6
 Tests 7,8: test LongTruncOk
ok 7
ok 8
 Test 9: test ColAttributes
Column count is: 4
1: COL_A = 5 5 yes
2: COL_B = 12 12 yes
3: COL_C = -1 -1 yes
4: COL_D = 93 93 yes

ok 9
 Test 10: test $DBI::err
ok 10
 Test 11: test date or timestamp values
1998-05-14 00:00:00.000
ok 11
 Test 12: test group by queries
1, 1
2, 1
3, 1
4, 1
5, 1
ok 12
 Test 13: test data_sources
Data sources:
        DBI:ODBC:oldTEST
        DBI:ODBC:ONEIRIDEi_dsnless
        DBI:ODBC:ONEIRIDE
        DBI:ODBC:Default
        DBI:ODBC:OPDN014
        DBI:ODBC:OPDN106
        DBI:ODBC:JDBC
        DBI:ODBC:test

ok 13
 Test 14: test ping method
ok 14
 Test 15: test storing of DBH parameter
ok 15
Attrib not true (1)
 Test 16: test connecting twice to the same db.
ok 16
 Test 17: test get_info
 connected to Microsoft SQL Server
ok 17
 Test 18: test automatically finish when execute run again
ok 18
 Test 19: test connection success when DBI DSN is invalid
Test Ok if Errstr not undef: [unixODBC][FreeTDS][SQL Server]Unable to connect to data 
source (SQL-08001)(DBD: db_login/SQLConnect err=-1)
ok 19
 Test 20: test connection success when DBI DSN has DSN=
ok 20
 Test 21: test connection success when DBI DSN has DSN= and uid and pwd are set
ok 21
ok
t/03dbatt........1..19
ok 1
ok 2
Transactions supported: -65534
ok 3
ok 4
Transactions supported: -65534
ok 5
ok 6
ok 7
ok 8
ok 9
ok 10
ok 11
ok 12
ok 13
ok 14
ok 15
ok 16
ok 17
ok 18
ok 19
ok
t/05meth.........1..6
ok 1
ok 2
ok 3
ok 4
ok 5
ok 6
calling finish
resetting attributes
disconnecting
disconnected
ok
t/07bind.........1..10
ok 1
 Test 2: connecting to the database
ok 2
 Test 3: create test table
Using fields: COL_A smallint NOT NULL PRIMARY KEY , COL_B varchar(8000), COL_C text, 
COL_D datetime
ok 3
 Test 4: insert test data
Binding the value: 1 type = 5
TYPE FOUND = 93
Binding the value: 2 type = 5
TYPE FOUND = 93
Binding the value: 3 type = 5
TYPE FOUND = 93
Binding the value: 4 type = 5
TYPE FOUND = 93
Binding the value: 5 type = 5
TYPE FOUND = 93
Binding the value: 6 type = 5
TYPE FOUND = 93
ok 4
 Test 5: select test data
ok 5
 Test 6: insert long test data
Binding the value: 10 type = 5
TYPE FOUND = 93
Binding the value: 11 type = 5
TYPE FOUND = 93
Binding the value: 12 type = 5
TYPE FOUND = 93
ok 6
 Test 7: check long test data
ok 7
 Test 8: update long test data
ok 8
 Test 9: check long test data
ok 9
param 1: 1
param 2: test
ok 10
ok
t/08bind2........1..0 # Skipped: SQLDescribeParam not supported using Microsoft SQL 
Server
skipped
        all skipped: SQLDescribeParam not supported using Microsoft SQL Server
t/09multi........1..4
ok 1
ok 2
ok 3
ok 4
ok
t/20SqlServer....1..28
Inserting:  0,  string length 13
Inserting:  1, 2001-01-01 01:01:01.110 string length 12
Inserting:  2, 2002-02-02 02:02:02.123 string length 114
Inserting:  3, 2003-03-03 03:03:03.333 string length 251
Inserting:  4, 2004-04-04 04:04:04.443 string length 282
Inserting:  5, 2005-05-05 05:05:05.557 string length 131
Retrieving: 0,  string length 13
Retrieving: 1, 2001-01-01 01:01:01.110 string length 12
Retrieving: 2, 2002-02-02 02:02:02.123 string length 114
Retrieving: 3, 2003-03-03 03:03:03.333 string length 251
Retrieving: 4, 2004-04-04 04:04:04.443 string length 282
Retrieving: 5, 2005-05-05 05:05:05.557 string length 131
ok 1
ok 2
1
2
3
ok 3
CREATE PROCEDURE PERL_DBD_PROC1 (@i int, @result int OUTPUT) AS BEGIN     SET @result 
= @i+1;END
DBD::ODBC::st execute failed: (DBD: st_execute/SQLExecute err=-1) at t/20SqlServer.t 
line 214.
dubious
        Test returned status 255 (wstat 65280, 0xff00)
Scalar found where operator expected at (eval 152) line 1, near "'int'  $__val"
        (Missing operator before   $__val?)
DIED. FAILED tests 4-28
        Failed 25/28 tests, 10.71% okay
t/30Oracle.......1..0 # Skipped: Oracle tests not supported using Microsoft SQL Server
skipped
        all skipped: Oracle tests not supported using Microsoft SQL Server
Failed Test     Stat Wstat Total Fail  Failed  List of Failed
-------------------------------------------------------------------------------
t/20SqlServer.t  255 65280    28   50 178.57%  4-28
2 tests skipped.
Failed 1/9 test scripts, 88.89% okay. 25/93 subtests failed, 73.12% okay.
make: *** [test_dynamic] Error 255

[EMAIL PROTECTED] DBD-ODBC-1.09]$ PERL_DL_NONLAZY=1 /usr/bin/perl 
"-MExtUtils::Command::MM" "-e" "test_harness(1, 'blib/lib', 'blib/arch')" 
t/20SqlServer.t
t/20SqlServer....1..28
Inserting:  0,  string length 13
Inserting:  1, 2001-01-01 01:01:01.110 string length 12
Inserting:  2, 2002-02-02 02:02:02.123 string length 114
Inserting:  3, 2003-03-03 03:03:03.333 string length 251
Inserting:  4, 2004-04-04 04:04:04.443 string length 282
Inserting:  5, 2005-05-05 05:05:05.557 string length 131
Retrieving: 0,  string length 13
Retrieving: 1, 2001-01-01 01:01:01.110 string length 12
Retrieving: 2, 2002-02-02 02:02:02.123 string length 114
Retrieving: 3, 2003-03-03 03:03:03.333 string length 251
Retrieving: 4, 2004-04-04 04:04:04.443 string length 282
Retrieving: 5, 2005-05-05 05:05:05.557 string length 131
ok 1
ok 2
1
2
3
ok 3
CREATE PROCEDURE PERL_DBD_PROC1 (@i int, @result int OUTPUT) AS BEGIN     SET @result 
= @i+1;END
ok 4
ok 5
2002-07-12 05:08:37.350
ok 6
ok 7
ok 8
ok 9
ok 10
ok 11
ok 12
ok 13
ok 14
ok 15
ok 16
ok 17
ok 18
ok 19
outputData $VAR1 = {
          'some_data' => 1
        };

out of for loop
ok 20
ok 21
ok 22
outputData $VAR1 = {
          'parameter1' => 2222,
          'some_more_data' => 3
        };

out of for loop
out of for loop
out of for loop
out of for loop
out of for loop
out of for loop
out of for loop
... interrupted ...

Attachment: dbd.diff.gz
Description: dbd.diff.gz

Reply via email to