ruby-odbc 0.99995 → 0.99996

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c7479d33fa9c59ff9ddceda117a54eff5b755a40
4
- data.tar.gz: ffe877023d88272ddb59da531bf1fda03cdf6c35
3
+ metadata.gz: 7504ee7d8bcf0055aa40cdb22f44a7bf697f3494
4
+ data.tar.gz: 10f13522e517035268aaee2af4964911e06068d2
5
5
  SHA512:
6
- metadata.gz: 95b9dd91fe942297cd879cfc83c82af7fe9a2aeaabcff01a65a9870b89886e8a7d729f8a2119241d46363282081bfeb9d8c0a21daf8836b619807deea947d0e8
7
- data.tar.gz: 328aa7cff9af2f30af215560abc65d947879468299e31e449d7c919cb146a84effde0f88e9816fd7633230c70ecded79417db8dae00d1cb882f76b114f2d6040
6
+ metadata.gz: b7d6a796455a8bd4e9cdb8dfff99b30424a4cc15a4346a95bdedb7975dcdc48e729090ae7d1c34f589c29d705c8f8b8c1ba153234373f9cf0f75707043922002
7
+ data.tar.gz: 3478edc7204561c5b930e203b0879bf93d3d19a15b653750e4395a2b22c9c0ec2de49b37f9b8d45659760acaf0a9584cc91ddcccfb27f441f2334d0523f791b1
data/ChangeLog CHANGED
@@ -1,6 +1,12 @@
1
1
  ODBC binding for Ruby
2
2
  ---------------------
3
3
 
4
+ Wed Mar 25 2015 version 0.99996 released
5
+
6
+ * when built for Ruby >= 2.0 release GVL for potentially
7
+ long running ODBC API functions, thanks Matt Conover
8
+ for initial implementation
9
+
4
10
  Wed Mar 13 2013 version 0.99995 released
5
11
 
6
12
  * added ODBC::Database.use_sql_column_name= flag to switch
data/README CHANGED
@@ -1,6 +1,6 @@
1
- # $Id: README,v 1.42 2013/03/13 19:24:03 chw Exp chw $
1
+ # $Id: README,v 1.43 2015/03/25 10:54:58 chw Exp chw $
2
2
 
3
- ruby-odbc-0.99995
3
+ ruby-odbc-0.99996
4
4
 
5
5
  This is an ODBC binding for Ruby. So far it has been tested with
6
6
 
@@ -78,6 +78,40 @@ rescue
78
78
  puts "WARNING: the option -DHAVE_TYPE_SQLULEN"
79
79
  end
80
80
  $have_odbcinst_h = have_header("odbcinst.h")
81
+ begin
82
+ if PLATFORM !~ /(mingw|cygwin)/ then
83
+ header = "sqltypes.h"
84
+ else
85
+ header = ["windows.h", "sqltypes.h"]
86
+ end
87
+ if defined? have_type
88
+ have_type("SQLROWOFFSET", header)
89
+ else
90
+ throw
91
+ end
92
+ rescue
93
+ puts "WARNING: please check sqltypes.h for SQLROWOFFSET manually,"
94
+ puts "WARNING: if defined, modify CFLAGS in Makefile to contain"
95
+ puts "WARNING: the option -DHAVE_TYPE_SQLROWOFFSET"
96
+ end
97
+ $have_odbcinst_h = have_header("odbcinst.h")
98
+ begin
99
+ if PLATFORM !~ /(mingw|cygwin)/ then
100
+ header = "sqltypes.h"
101
+ else
102
+ header = ["windows.h", "sqltypes.h"]
103
+ end
104
+ if defined? have_type
105
+ have_type("SQLROWSETSIZE", header)
106
+ else
107
+ throw
108
+ end
109
+ rescue
110
+ puts "WARNING: please check sqltypes.h for SQLROWSETSIZE manually,"
111
+ puts "WARNING: if defined, modify CFLAGS in Makefile to contain"
112
+ puts "WARNING: the option -DHAVE_TYPE_SQLROWSETSIZE"
113
+ end
114
+ $have_odbcinst_h = have_header("odbcinst.h")
81
115
 
82
116
  if PLATFORM =~ /mswin32/ then
83
117
  if !have_library_ex("odbc32", "SQLAllocConnect", "sql.h") ||
data/ext/odbc.c CHANGED
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * ODBC-Ruby binding
3
- * Copyright (c) 2001-2013 Christian Werner <chw@ch-werner.de>
3
+ * Copyright (c) 2001-2015 Christian Werner <chw@ch-werner.de>
4
4
  * Portions copyright (c) 2004 Ryszard Niewisiewicz <micz@fibernet.pl>
5
5
  * Portions copyright (c) 2006 Carl Blakeley <cblakeley@openlinksw.co.uk>
6
6
  *
@@ -8,7 +8,7 @@
8
8
  * and redistribution of this file and for a
9
9
  * DISCLAIMER OF ALL WARRANTIES.
10
10
  *
11
- * $Id: odbc.c,v 1.75 2013/03/13 19:31:13 chw Exp chw $
11
+ * $Id: odbc.c,v 1.76 2015/03/25 10:55:52 chw Exp chw $
12
12
  */
13
13
 
14
14
  #undef ODBCVER
@@ -49,16 +49,26 @@ typedef SQLCHAR SQLTCHAR;
49
49
  #endif
50
50
 
51
51
  #ifndef HAVE_TYPE_SQLLEN
52
- #define SQLLEN SQLINTEGER
52
+ #define SQLLEN SQLINTEGER
53
53
  #endif
54
54
  #ifndef HAVE_TYPE_SQLULEN
55
55
  #define SQLULEN SQLUINTEGER
56
56
  #endif
57
+ #ifndef HAVE_TYPE_SQLROWOFFSET
58
+ #define SQLROWOFFSET SQLLEN
59
+ #endif
60
+ #ifndef HAVE_TYPE_SQLROWSETSIZE
61
+ #define SQLROWSETSIZE SQLULEN
62
+ #endif
57
63
 
58
64
  #if (RUBY_VERSION_MAJOR <= 1) && (RUBY_VERSION_MINOR < 9)
59
65
  #define TIME_USE_USEC 1
60
66
  #endif
61
67
 
68
+ #ifdef HAVE_RUBY_THREAD_H
69
+ #include "ruby/thread.h"
70
+ #endif
71
+
62
72
  /*
63
73
  * Conditionally undefine aliases of ODBC installer UNICODE functions.
64
74
  */
@@ -163,7 +173,7 @@ typedef struct dbc {
163
173
  VALUE self;
164
174
  VALUE env;
165
175
  struct env *envp;
166
- LINK stmts;
176
+ LINK stmts;
167
177
  SQLHDBC hdbc;
168
178
  VALUE rbtime;
169
179
  VALUE gmtime;
@@ -355,7 +365,911 @@ static const char *colnamebuf[] = {
355
365
  /*
356
366
  *----------------------------------------------------------------------
357
367
  *
358
- * UNICODE converters et.al.
368
+ * Wrappers for long running SQL APIs with GVL released.
369
+ *
370
+ *----------------------------------------------------------------------
371
+ */
372
+
373
+ #ifdef RUBY_CALL_WO_GVL_FLAG_SKIP_CHECK_INTS_
374
+
375
+ static void
376
+ empty_ubf(void *args)
377
+ {
378
+ }
379
+
380
+ struct S_SQLCONNECT {
381
+ SQLHDBC hdbc;
382
+ SQLTCHAR *dsn;
383
+ SQLSMALLINT dsn_len;
384
+ SQLTCHAR *usr;
385
+ SQLSMALLINT usr_len;
386
+ SQLTCHAR *pwd;
387
+ SQLSMALLINT pwd_len;
388
+ };
389
+
390
+ static void *
391
+ F_SQLCONNECT(void *args)
392
+ {
393
+ size_t ret;
394
+ struct S_SQLCONNECT *argp = (struct S_SQLCONNECT *) args;
395
+
396
+ ret = SQLConnect(argp->hdbc, argp->dsn, argp->dsn_len,
397
+ argp->usr, argp->usr_len, argp->pwd, argp->pwd_len);
398
+ return (void *) ret;
399
+ }
400
+
401
+ static inline SQLRETURN
402
+ SQLCONNECT(SQLHDBC hdbc, SQLTCHAR *dsn, SQLSMALLINT dsn_len, SQLTCHAR *usr,
403
+ SQLSMALLINT usr_len, SQLTCHAR *pwd, SQLSMALLINT pwd_len)
404
+ {
405
+ size_t ret;
406
+ struct S_SQLCONNECT arg;
407
+
408
+ arg.hdbc = hdbc;
409
+ arg.dsn = dsn;
410
+ arg.dsn_len = dsn_len;
411
+ arg.usr = usr;
412
+ arg.usr_len = usr_len;
413
+ arg.pwd = pwd;
414
+ arg.pwd_len = pwd_len;
415
+ ret = (size_t) rb_thread_call_without_gvl(F_SQLCONNECT, &arg,
416
+ empty_ubf, &arg);
417
+ return ret;
418
+ }
419
+
420
+ struct S_SQLDRIVERCONNECT {
421
+ SQLHDBC hdbc;
422
+ SQLHWND hwnd;
423
+ SQLTCHAR *connin;
424
+ SQLSMALLINT connin_len;
425
+ SQLTCHAR *connout;
426
+ SQLSMALLINT connout_max;
427
+ SQLSMALLINT *connout_len;
428
+ SQLUSMALLINT compl;
429
+ };
430
+
431
+ static void *
432
+ F_SQLDRIVERCONNECT(void *args)
433
+ {
434
+ size_t ret;
435
+ struct S_SQLDRIVERCONNECT *argp = (struct S_SQLDRIVERCONNECT *) args;
436
+
437
+ ret = SQLDriverConnect(argp->hdbc, argp->hwnd, argp->connin,
438
+ argp->connin_len, argp->connout, argp->connout_max,
439
+ argp->connout_len, argp->compl);
440
+ return (void *) ret;
441
+ }
442
+
443
+ static inline SQLRETURN
444
+ SQLDRIVERCONNECT(SQLHDBC hdbc, SQLHWND hwnd, SQLTCHAR *connin,
445
+ SQLSMALLINT connin_len, SQLTCHAR *connout,
446
+ SQLSMALLINT connout_max, SQLSMALLINT *connout_len,
447
+ SQLUSMALLINT compl)
448
+ {
449
+ size_t ret;
450
+ struct S_SQLDRIVERCONNECT arg;
451
+
452
+ arg.hdbc = hdbc;
453
+ arg.hwnd = hwnd;
454
+ arg.connin = connin;
455
+ arg.connin_len = connin_len;
456
+ arg.connout = connout;
457
+ arg.connout_max = connout_max;
458
+ arg.connout_len = connout_len;
459
+ arg.compl = compl;
460
+ ret = (size_t) rb_thread_call_without_gvl(F_SQLDRIVERCONNECT, &arg,
461
+ empty_ubf, &arg);
462
+ return ret;
463
+ }
464
+
465
+ struct S_SQLDISCONNECT {
466
+ SQLHSTMT hstmt;
467
+ };
468
+
469
+ static void *
470
+ F_SQLDISCONNECT(void *args)
471
+ {
472
+ size_t ret;
473
+ struct S_SQLDISCONNECT *argp = (struct S_SQLDISCONNECT *) args;
474
+
475
+ ret = SQLDisconnect(argp->hstmt);
476
+ return (void *) ret;
477
+ }
478
+
479
+ static inline SQLRETURN
480
+ SQLDISCONNECT(SQLHSTMT hstmt)
481
+ {
482
+ size_t ret;
483
+ struct S_SQLDISCONNECT arg;
484
+
485
+ arg.hstmt = hstmt;
486
+ ret = (size_t) rb_thread_call_without_gvl(F_SQLDISCONNECT, &arg,
487
+ empty_ubf, &arg);
488
+ return ret;
489
+ }
490
+
491
+ struct S_SQLTABLES {
492
+ SQLHSTMT hdbc;
493
+ SQLTCHAR *cat;
494
+ SQLSMALLINT cat_len;
495
+ SQLTCHAR *sch;
496
+ SQLSMALLINT sch_len;
497
+ SQLTCHAR *tbl;
498
+ SQLSMALLINT tbl_len;
499
+ SQLTCHAR *typ;
500
+ SQLSMALLINT typ_len;
501
+ };
502
+
503
+ static void *
504
+ F_SQLTABLES(void *args)
505
+ {
506
+ size_t ret;
507
+ struct S_SQLTABLES *argp = (struct S_SQLTABLES *) args;
508
+
509
+ ret = SQLTables(argp->hdbc, argp->cat, argp->cat_len,
510
+ argp->sch, argp->sch_len, argp->tbl,
511
+ argp->tbl_len, argp->typ, argp->typ_len);
512
+ return (void *) ret;
513
+ }
514
+
515
+ static inline SQLRETURN
516
+ SQLTABLES(SQLHDBC hdbc, SQLTCHAR *cat, SQLSMALLINT cat_len,
517
+ SQLTCHAR *sch, SQLSMALLINT sch_len, SQLTCHAR *tbl,
518
+ SQLSMALLINT tbl_len, SQLTCHAR *typ, SQLSMALLINT typ_len)
519
+ {
520
+ size_t ret;
521
+ struct S_SQLTABLES arg;
522
+
523
+ arg.hdbc = hdbc;
524
+ arg.cat = cat;
525
+ arg.cat_len = cat_len;
526
+ arg.sch = sch;
527
+ arg.sch_len = sch_len;
528
+ arg.tbl = tbl;
529
+ arg.tbl_len = tbl_len;
530
+ arg.typ = typ;
531
+ arg.typ_len = typ_len;
532
+ ret = (size_t) rb_thread_call_without_gvl(F_SQLTABLES, &arg,
533
+ empty_ubf, &arg);
534
+ return ret;
535
+ }
536
+
537
+ struct S_SQLCOLUMNS {
538
+ SQLHSTMT hdbc;
539
+ SQLTCHAR *cat;
540
+ SQLSMALLINT cat_len;
541
+ SQLTCHAR *sch;
542
+ SQLSMALLINT sch_len;
543
+ SQLTCHAR *tbl;
544
+ SQLSMALLINT tbl_len;
545
+ SQLTCHAR *col;
546
+ SQLSMALLINT col_len;
547
+ };
548
+
549
+ static void *
550
+ F_SQLCOLUMNS(void *args)
551
+ {
552
+ size_t ret;
553
+ struct S_SQLCOLUMNS *argp = (struct S_SQLCOLUMNS *) args;
554
+
555
+ ret = SQLColumns(argp->hdbc, argp->cat, argp->cat_len,
556
+ argp->sch, argp->sch_len, argp->tbl,
557
+ argp->tbl_len, argp->col, argp->col_len);
558
+ return (void *) ret;
559
+ }
560
+
561
+ static inline SQLRETURN
562
+ SQLCOLUMNS(SQLHDBC hdbc, SQLTCHAR *cat, SQLSMALLINT cat_len,
563
+ SQLTCHAR *sch, SQLSMALLINT sch_len, SQLTCHAR *tbl,
564
+ SQLSMALLINT tbl_len, SQLTCHAR *col, SQLSMALLINT col_len)
565
+ {
566
+ size_t ret;
567
+ struct S_SQLCOLUMNS arg;
568
+
569
+ arg.hdbc = hdbc;
570
+ arg.cat = cat;
571
+ arg.cat_len = cat_len;
572
+ arg.sch = sch;
573
+ arg.sch_len = sch_len;
574
+ arg.tbl = tbl;
575
+ arg.tbl_len = tbl_len;
576
+ arg.col = col;
577
+ arg.col_len = col_len;
578
+ ret = (size_t) rb_thread_call_without_gvl(F_SQLCOLUMNS, &arg,
579
+ empty_ubf, &arg);
580
+ return ret;
581
+ }
582
+
583
+ struct S_SQLPRIMARYKEYS {
584
+ SQLHSTMT hdbc;
585
+ SQLTCHAR *cat;
586
+ SQLSMALLINT cat_len;
587
+ SQLTCHAR *sch;
588
+ SQLSMALLINT sch_len;
589
+ SQLTCHAR *tbl;
590
+ SQLSMALLINT tbl_len;
591
+ };
592
+
593
+ static void *
594
+ F_SQLPRIMARYKEYS(void *args)
595
+ {
596
+ size_t ret;
597
+ struct S_SQLPRIMARYKEYS *argp = (struct S_SQLPRIMARYKEYS *) args;
598
+
599
+ ret = SQLPrimaryKeys(argp->hdbc, argp->cat, argp->cat_len,
600
+ argp->sch, argp->sch_len, argp->tbl, argp->tbl_len);
601
+ return (void *) ret;
602
+ }
603
+
604
+ static inline SQLRETURN
605
+ SQLPRIMARYKEYS(SQLHDBC hdbc, SQLTCHAR *cat, SQLSMALLINT cat_len,
606
+ SQLTCHAR *sch, SQLSMALLINT sch_len, SQLTCHAR *tbl,
607
+ SQLSMALLINT tbl_len)
608
+ {
609
+ size_t ret;
610
+ struct S_SQLPRIMARYKEYS arg;
611
+
612
+ arg.hdbc = hdbc;
613
+ arg.cat = cat;
614
+ arg.cat_len = cat_len;
615
+ arg.sch = sch;
616
+ arg.sch_len = sch_len;
617
+ arg.tbl = tbl;
618
+ arg.tbl_len = tbl_len;
619
+ ret = (size_t) rb_thread_call_without_gvl(F_SQLPRIMARYKEYS, &arg,
620
+ empty_ubf, &arg);
621
+ return ret;
622
+ }
623
+
624
+ struct S_SQLFOREIGNKEYS {
625
+ SQLHSTMT hdbc;
626
+ SQLTCHAR *pkcat;
627
+ SQLSMALLINT pkcat_len;
628
+ SQLTCHAR *pksch;
629
+ SQLSMALLINT pksch_len;
630
+ SQLTCHAR *pktbl;
631
+ SQLSMALLINT pktbl_len;
632
+ SQLTCHAR *fkcat;
633
+ SQLSMALLINT fkcat_len;
634
+ SQLTCHAR *fksch;
635
+ SQLSMALLINT fksch_len;
636
+ SQLTCHAR *fktbl;
637
+ SQLSMALLINT fktbl_len;
638
+ };
639
+
640
+ static void *
641
+ F_SQLFOREIGNKEYS(void *args)
642
+ {
643
+ size_t ret;
644
+ struct S_SQLFOREIGNKEYS *argp = (struct S_SQLFOREIGNKEYS *) args;
645
+
646
+ ret = SQLForeignKeys(argp->hdbc, argp->pkcat, argp->pkcat_len,
647
+ argp->pksch, argp->pksch_len,
648
+ argp->pktbl, argp->pktbl_len,
649
+ argp->fkcat, argp->fkcat_len,
650
+ argp->fksch, argp->fksch_len,
651
+ argp->fktbl, argp->fktbl_len);
652
+ return (void *) ret;
653
+ }
654
+
655
+ static inline SQLRETURN
656
+ SQLFOREIGNKEYS(SQLHDBC hdbc, SQLTCHAR *pkcat, SQLSMALLINT pkcat_len,
657
+ SQLTCHAR *pksch, SQLSMALLINT pksch_len, SQLTCHAR *pktbl,
658
+ SQLSMALLINT pktbl_len, SQLTCHAR *fkcat, SQLSMALLINT fkcat_len,
659
+ SQLTCHAR *fksch, SQLSMALLINT fksch_len, SQLTCHAR *fktbl,
660
+ SQLSMALLINT fktbl_len)
661
+ {
662
+ size_t ret;
663
+ struct S_SQLFOREIGNKEYS arg;
664
+
665
+ arg.hdbc = hdbc;
666
+ arg.pkcat = pkcat;
667
+ arg.pkcat_len = pkcat_len;
668
+ arg.pksch = pksch;
669
+ arg.pksch_len = pksch_len;
670
+ arg.pktbl = pktbl;
671
+ arg.pktbl_len = pktbl_len;
672
+ arg.fkcat = fkcat;
673
+ arg.fkcat_len = fkcat_len;
674
+ arg.fksch = fksch;
675
+ arg.fksch_len = fksch_len;
676
+ arg.fktbl = fktbl;
677
+ arg.fktbl_len = fktbl_len;
678
+ ret = (size_t) rb_thread_call_without_gvl(F_SQLFOREIGNKEYS, &arg,
679
+ empty_ubf, &arg);
680
+ return ret;
681
+ }
682
+
683
+ struct S_SQLPROCEDURES {
684
+ SQLHSTMT hdbc;
685
+ SQLTCHAR *cat;
686
+ SQLSMALLINT cat_len;
687
+ SQLTCHAR *sch;
688
+ SQLSMALLINT sch_len;
689
+ SQLTCHAR *prc;
690
+ SQLSMALLINT prc_len;
691
+ };
692
+
693
+ static void *
694
+ F_SQLPROCEDURES(void *args)
695
+ {
696
+ size_t ret;
697
+ struct S_SQLPROCEDURES *argp = (struct S_SQLPROCEDURES *) args;
698
+
699
+ ret = SQLProcedures(argp->hdbc, argp->cat, argp->cat_len,
700
+ argp->sch, argp->sch_len, argp->prc, argp->prc_len);
701
+ return (void *) ret;
702
+ }
703
+
704
+ static inline SQLRETURN
705
+ SQLPROCEDURES(SQLHDBC hdbc, SQLTCHAR *cat, SQLSMALLINT cat_len,
706
+ SQLTCHAR *sch, SQLSMALLINT sch_len, SQLTCHAR *prc,
707
+ SQLSMALLINT prc_len)
708
+ {
709
+ size_t ret;
710
+ struct S_SQLPROCEDURES arg;
711
+
712
+ arg.hdbc = hdbc;
713
+ arg.cat = cat;
714
+ arg.cat_len = cat_len;
715
+ arg.sch = sch;
716
+ arg.sch_len = sch_len;
717
+ arg.prc = prc;
718
+ arg.prc_len = prc_len;
719
+ ret = (size_t) rb_thread_call_without_gvl(F_SQLPROCEDURES, &arg,
720
+ empty_ubf, &arg);
721
+ return ret;
722
+ }
723
+
724
+ struct S_SQLPROCEDURECOLUMNS {
725
+ SQLHSTMT hdbc;
726
+ SQLTCHAR *cat;
727
+ SQLSMALLINT cat_len;
728
+ SQLTCHAR *sch;
729
+ SQLSMALLINT sch_len;
730
+ SQLTCHAR *prc;
731
+ SQLSMALLINT prc_len;
732
+ SQLTCHAR *col;
733
+ SQLSMALLINT col_len;
734
+ };
735
+
736
+ static void *
737
+ F_SQLPROCEDURECOLUMNS(void *args)
738
+ {
739
+ size_t ret;
740
+ struct S_SQLPROCEDURECOLUMNS *argp = (struct S_SQLPROCEDURECOLUMNS *) args;
741
+
742
+ ret = SQLProcedureColumns(argp->hdbc, argp->cat, argp->cat_len,
743
+ argp->sch, argp->sch_len, argp->prc,
744
+ argp->prc_len, argp->col, argp->col_len);
745
+ return (void *) ret;
746
+ }
747
+
748
+ static inline SQLRETURN
749
+ SQLPROCEDURECOLUMNS(SQLHDBC hdbc, SQLTCHAR *cat, SQLSMALLINT cat_len,
750
+ SQLTCHAR *sch, SQLSMALLINT sch_len, SQLTCHAR *prc,
751
+ SQLSMALLINT prc_len, SQLTCHAR *col, SQLSMALLINT col_len)
752
+ {
753
+ size_t ret;
754
+ struct S_SQLPROCEDURECOLUMNS arg;
755
+
756
+ arg.hdbc = hdbc;
757
+ arg.cat = cat;
758
+ arg.cat_len = cat_len;
759
+ arg.sch = sch;
760
+ arg.sch_len = sch_len;
761
+ arg.prc = prc;
762
+ arg.prc_len = prc_len;
763
+ arg.col = col;
764
+ arg.col_len = col_len;
765
+ ret = (size_t) rb_thread_call_without_gvl(F_SQLPROCEDURECOLUMNS, &arg,
766
+ empty_ubf, &arg);
767
+ return ret;
768
+ }
769
+
770
+ struct S_SQLTABLEPRIVILEGES {
771
+ SQLHSTMT hdbc;
772
+ SQLTCHAR *cat;
773
+ SQLSMALLINT cat_len;
774
+ SQLTCHAR *sch;
775
+ SQLSMALLINT sch_len;
776
+ SQLTCHAR *tbl;
777
+ SQLSMALLINT tbl_len;
778
+ };
779
+
780
+ static void *
781
+ F_SQLTABLEPRIVILEGES(void *args)
782
+ {
783
+ size_t ret;
784
+ struct S_SQLTABLEPRIVILEGES *argp = (struct S_SQLTABLEPRIVILEGES *) args;
785
+
786
+ ret = SQLTablePrivileges(argp->hdbc, argp->cat, argp->cat_len,
787
+ argp->sch, argp->sch_len, argp->tbl,
788
+ argp->tbl_len);
789
+ return (void *) ret;
790
+ }
791
+
792
+ static inline SQLRETURN
793
+ SQLTABLEPRIVILEGES(SQLHDBC hdbc, SQLTCHAR *cat, SQLSMALLINT cat_len,
794
+ SQLTCHAR *sch, SQLSMALLINT sch_len, SQLTCHAR *tbl,
795
+ SQLSMALLINT tbl_len)
796
+ {
797
+ size_t ret;
798
+ struct S_SQLTABLEPRIVILEGES arg;
799
+
800
+ arg.hdbc = hdbc;
801
+ arg.cat = cat;
802
+ arg.cat_len = cat_len;
803
+ arg.sch = sch;
804
+ arg.sch_len = sch_len;
805
+ arg.tbl = tbl;
806
+ arg.tbl_len = tbl_len;
807
+ ret = (size_t) rb_thread_call_without_gvl(F_SQLTABLEPRIVILEGES, &arg,
808
+ empty_ubf, &arg);
809
+ return ret;
810
+ }
811
+
812
+ struct S_SQLSTATISTICS {
813
+ SQLHSTMT hdbc;
814
+ SQLTCHAR *cat;
815
+ SQLSMALLINT cat_len;
816
+ SQLTCHAR *sch;
817
+ SQLSMALLINT sch_len;
818
+ SQLTCHAR *tbl;
819
+ SQLSMALLINT tbl_len;
820
+ SQLUSMALLINT uniq;
821
+ SQLUSMALLINT resv;
822
+ };
823
+
824
+ static void *
825
+ F_SQLSTATISTICS(void *args)
826
+ {
827
+ size_t ret;
828
+ struct S_SQLSTATISTICS *argp = (struct S_SQLSTATISTICS *) args;
829
+
830
+ ret = SQLStatistics(argp->hdbc, argp->cat, argp->cat_len,
831
+ argp->sch, argp->sch_len, argp->tbl,
832
+ argp->tbl_len, argp->uniq, argp->resv);
833
+ return (void *) ret;
834
+ }
835
+
836
+ static inline SQLRETURN
837
+ SQLSTATISTICS(SQLHDBC hdbc, SQLTCHAR *cat, SQLSMALLINT cat_len,
838
+ SQLTCHAR *sch, SQLSMALLINT sch_len, SQLTCHAR *tbl,
839
+ SQLSMALLINT tbl_len, SQLUSMALLINT uniq, SQLUSMALLINT resv)
840
+ {
841
+ size_t ret;
842
+ struct S_SQLSTATISTICS arg;
843
+
844
+ arg.hdbc = hdbc;
845
+ arg.cat = cat;
846
+ arg.cat_len = cat_len;
847
+ arg.sch = sch;
848
+ arg.sch_len = sch_len;
849
+ arg.tbl = tbl;
850
+ arg.tbl_len = tbl_len;
851
+ arg.uniq = uniq;
852
+ arg.resv = resv;
853
+ ret = (size_t) rb_thread_call_without_gvl(F_SQLSTATISTICS, &arg,
854
+ empty_ubf, &arg);
855
+ return ret;
856
+ }
857
+
858
+ struct S_SQLSPECIALCOLUMNS {
859
+ SQLHSTMT hdbc;
860
+ SQLUSMALLINT idtyp;
861
+ SQLTCHAR *cat;
862
+ SQLSMALLINT cat_len;
863
+ SQLTCHAR *sch;
864
+ SQLSMALLINT sch_len;
865
+ SQLTCHAR *tbl;
866
+ SQLSMALLINT tbl_len;
867
+ SQLUSMALLINT scope;
868
+ SQLUSMALLINT nulbl;
869
+ };
870
+
871
+ static void *
872
+ F_SQLSPECIALCOLUMNS(void *args)
873
+ {
874
+ size_t ret;
875
+ struct S_SQLSPECIALCOLUMNS *argp = (struct S_SQLSPECIALCOLUMNS *) args;
876
+
877
+ ret = SQLSpecialColumns(argp->hdbc, argp->idtyp, argp->cat, argp->cat_len,
878
+ argp->sch, argp->sch_len, argp->tbl,
879
+ argp->tbl_len, argp->scope, argp->nulbl);
880
+ return (void *) ret;
881
+ }
882
+
883
+ static inline SQLRETURN
884
+ SQLSPECIALCOLUMNS(SQLHDBC hdbc, SQLUSMALLINT idtyp, SQLTCHAR *cat,
885
+ SQLSMALLINT cat_len, SQLTCHAR *sch, SQLSMALLINT sch_len,
886
+ SQLTCHAR *tbl, SQLSMALLINT tbl_len,
887
+ SQLUSMALLINT scope, SQLUSMALLINT nulbl)
888
+ {
889
+ size_t ret;
890
+ struct S_SQLSPECIALCOLUMNS arg;
891
+
892
+ arg.hdbc = hdbc;
893
+ arg.idtyp = idtyp;
894
+ arg.cat = cat;
895
+ arg.cat_len = cat_len;
896
+ arg.sch = sch;
897
+ arg.sch_len = sch_len;
898
+ arg.tbl = tbl;
899
+ arg.tbl_len = tbl_len;
900
+ arg.scope = scope;
901
+ arg.nulbl = nulbl;
902
+ ret = (size_t) rb_thread_call_without_gvl(F_SQLSPECIALCOLUMNS, &arg,
903
+ empty_ubf, &arg);
904
+ return ret;
905
+ }
906
+
907
+ struct S_SQLGETTYPEINFO {
908
+ SQLHSTMT hdbc;
909
+ SQLSMALLINT type;
910
+ };
911
+
912
+ static void *
913
+ F_SQLGETTYPEINFO(void *args)
914
+ {
915
+ size_t ret;
916
+ struct S_SQLGETTYPEINFO *argp = (struct S_SQLGETTYPEINFO *) args;
917
+
918
+ ret = SQLGetTypeInfo(argp->hdbc, argp->type);
919
+ return (void *) ret;
920
+ }
921
+
922
+ static inline SQLRETURN
923
+ SQLGETTYPEINFO(SQLHDBC hdbc, SQLSMALLINT type)
924
+ {
925
+ size_t ret;
926
+ struct S_SQLGETTYPEINFO arg;
927
+
928
+ arg.hdbc = hdbc;
929
+ arg.type = type;
930
+ ret = (size_t) rb_thread_call_without_gvl(F_SQLGETTYPEINFO, &arg,
931
+ empty_ubf, &arg);
932
+ return ret;
933
+ }
934
+
935
+ #if (ODBCVER >= 0x0300)
936
+
937
+ struct S_SQLENDTRAN {
938
+ SQLSMALLINT htype;
939
+ SQLHANDLE handle;
940
+ SQLSMALLINT op;
941
+ };
942
+
943
+ static void *
944
+ F_SQLENDTRAN(void *args)
945
+ {
946
+ size_t ret;
947
+ struct S_SQLENDTRAN *argp = (struct S_SQLENDTRAN *) args;
948
+
949
+ ret = SQLEndTran(argp->htype, argp->handle, argp->op);
950
+ return (void *) ret;
951
+ }
952
+
953
+ static inline SQLRETURN
954
+ SQLENDTRAN(SQLUSMALLINT htype, SQLHANDLE handle, SQLUSMALLINT op)
955
+ {
956
+ size_t ret;
957
+ struct S_SQLENDTRAN arg;
958
+
959
+ arg.htype = htype;
960
+ arg.handle = handle;
961
+ arg.op = op;
962
+ ret = (size_t) rb_thread_call_without_gvl(F_SQLENDTRAN, &arg,
963
+ empty_ubf, &arg);
964
+ return ret;
965
+ }
966
+
967
+ #else
968
+
969
+ struct S_SQLTRANSACT {
970
+ SQLHENV henv;
971
+ SQLHDBC hdbc;
972
+ SQLSMALLINT op;
973
+ };
974
+
975
+ static void *
976
+ F_SQLTRANSACT(void *args)
977
+ {
978
+ size_t ret;
979
+ struct S_SQLTRANSACT *argp = (struct S_SQLTRANSACT *) args;
980
+
981
+ ret = SQLTransact(argp->henv, argp->hdbc, argp->op);
982
+ return (void *) ret;
983
+ }
984
+
985
+ static inline SQLRETURN
986
+ SQLTRANSACT(SQLHENV henv, SQLHDBC hdbc, SQLUSMALLINT op)
987
+ {
988
+ size_t ret;
989
+ struct S_SQLTRANSACT arg;
990
+
991
+ arg.henv = henv;
992
+ arg.hdbc = hdbc;
993
+ arg.op = op;
994
+ ret = (size_t) rb_thread_call_without_gvl(F_SQLTRANCACT, &arg,
995
+ empty_ubf, &arg);
996
+ return ret;
997
+ }
998
+
999
+ #endif
1000
+
1001
+ struct S_SQLEXECDIRECT {
1002
+ SQLHSTMT hstmt;
1003
+ SQLTCHAR *sql;
1004
+ SQLINTEGER len;
1005
+ };
1006
+
1007
+ static void *
1008
+ F_SQLEXECDIRECT(void *args)
1009
+ {
1010
+ size_t ret;
1011
+ struct S_SQLEXECDIRECT *argp = (struct S_SQLEXECDIRECT *) args;
1012
+
1013
+ ret = SQLExecDirect(argp->hstmt, argp->sql, argp->len);
1014
+ return (void *) ret;
1015
+ }
1016
+
1017
+ static void
1018
+ F_SQLEXECDIRECT_UBF(void *args)
1019
+ {
1020
+ struct S_SQLEXECDIRECT *argp = (struct S_SQLEXECDIRECT *) args;
1021
+
1022
+ SQLCancel(argp->hstmt);
1023
+ }
1024
+
1025
+ static inline SQLRETURN
1026
+ SQLEXECDIRECT(SQLHSTMT hstmt, SQLTCHAR *sql, SQLINTEGER len)
1027
+ {
1028
+ size_t ret;
1029
+ struct S_SQLEXECDIRECT arg;
1030
+
1031
+ arg.hstmt = hstmt;
1032
+ arg.sql = sql;
1033
+ arg.len = len;
1034
+ ret = (size_t) rb_thread_call_without_gvl(F_SQLEXECDIRECT, &arg,
1035
+ F_SQLEXECDIRECT_UBF, &arg);
1036
+ return ret;
1037
+ }
1038
+
1039
+ struct S_SQLEXECUTE {
1040
+ SQLHSTMT hstmt;
1041
+ };
1042
+
1043
+ static void *
1044
+ F_SQLEXECUTE(void *args)
1045
+ {
1046
+ size_t ret;
1047
+ struct S_SQLEXECUTE *argp = (struct S_SQLEXECUTE *) args;
1048
+
1049
+ ret = SQLExecute(argp->hstmt);
1050
+ return (void *) ret;
1051
+ }
1052
+
1053
+ static void
1054
+ F_SQLEXECUTE_UBF(void *args)
1055
+ {
1056
+ struct S_SQLEXECUTE *argp = (struct S_SQLEXECUTE *) args;
1057
+
1058
+ SQLCancel(argp->hstmt);
1059
+ }
1060
+
1061
+ static inline SQLRETURN
1062
+ SQLEXECUTE(SQLHSTMT hstmt)
1063
+ {
1064
+ size_t ret;
1065
+ struct S_SQLEXECUTE arg;
1066
+
1067
+ arg.hstmt = hstmt;
1068
+ ret = (size_t) rb_thread_call_without_gvl(F_SQLEXECUTE, &arg,
1069
+ F_SQLEXECUTE_UBF, &arg);
1070
+ return ret;
1071
+ }
1072
+
1073
+ struct S_SQLPREPARE {
1074
+ SQLHSTMT hstmt;
1075
+ SQLTCHAR *sql;
1076
+ SQLINTEGER len;
1077
+ };
1078
+
1079
+ static void *
1080
+ F_SQLPREPARE(void *args)
1081
+ {
1082
+ size_t ret;
1083
+ struct S_SQLPREPARE *argp = (struct S_SQLPREPARE *) args;
1084
+
1085
+ ret = SQLPrepare(argp->hstmt, argp->sql, argp->len);
1086
+ return (void *) ret;
1087
+ }
1088
+
1089
+ static void
1090
+ F_SQLPREPARE_UBF(void *args)
1091
+ {
1092
+ struct S_SQLPREPARE *argp = (struct S_SQLPREPARE *) args;
1093
+
1094
+ SQLCancel(argp->hstmt);
1095
+ }
1096
+
1097
+ static inline SQLRETURN
1098
+ SQLPREPARE(SQLHSTMT hstmt, SQLTCHAR *sql, SQLINTEGER len)
1099
+ {
1100
+ size_t ret;
1101
+ struct S_SQLPREPARE arg;
1102
+
1103
+ arg.hstmt = hstmt;
1104
+ arg.sql = sql;
1105
+ arg.len = len;
1106
+ ret = (size_t) rb_thread_call_without_gvl(F_SQLPREPARE, &arg,
1107
+ F_SQLPREPARE_UBF, &arg);
1108
+ return ret;
1109
+ }
1110
+
1111
+ struct S_SQLMORERESULTS {
1112
+ SQLHSTMT hstmt;
1113
+ };
1114
+
1115
+ static void *
1116
+ F_SQLMORERESULTS(void *args)
1117
+ {
1118
+ size_t ret;
1119
+ struct S_SQLMORERESULTS *argp = (struct S_SQLMORERESULTS *) args;
1120
+
1121
+ ret = SQLMoreResults(argp->hstmt);
1122
+ return (void *) ret;
1123
+ }
1124
+
1125
+ static inline SQLRETURN
1126
+ SQLMORERESULTS(SQLHSTMT hstmt)
1127
+ {
1128
+ size_t ret;
1129
+ struct S_SQLMORERESULTS arg;
1130
+
1131
+ arg.hstmt = hstmt;
1132
+ ret = (size_t) rb_thread_call_without_gvl(F_SQLMORERESULTS, &arg,
1133
+ empty_ubf, &arg);
1134
+ return ret;
1135
+ }
1136
+
1137
+ struct S_SQLFETCH {
1138
+ SQLHSTMT hstmt;
1139
+ };
1140
+
1141
+ static void *
1142
+ F_SQLFETCH(void *args)
1143
+ {
1144
+ size_t ret;
1145
+ struct S_SQLFETCH *argp = (struct S_SQLFETCH *) args;
1146
+
1147
+ ret = SQLFetch(argp->hstmt);
1148
+ return (void *) ret;
1149
+ }
1150
+
1151
+ static inline SQLRETURN
1152
+ SQLFETCH(SQLHSTMT hstmt)
1153
+ {
1154
+ size_t ret;
1155
+ struct S_SQLFETCH arg;
1156
+
1157
+ arg.hstmt = hstmt;
1158
+ ret = (size_t) rb_thread_call_without_gvl(F_SQLFETCH, &arg,
1159
+ empty_ubf, &arg);
1160
+ return ret;
1161
+ }
1162
+
1163
+ #if (ODBCVER >= 0x0300)
1164
+
1165
+ struct S_SQLFETCHSCROLL {
1166
+ SQLHSTMT hstmt;
1167
+ SQLSMALLINT dir;
1168
+ SQLROWOFFSET offs;
1169
+ };
1170
+
1171
+ static void *
1172
+ F_SQLFETCHSCROLL(void *args)
1173
+ {
1174
+ size_t ret;
1175
+ struct S_SQLFETCHSCROLL *argp = (struct S_SQLFETCHSCROLL *) args;
1176
+
1177
+ ret = SQLFetchScroll(argp->hstmt, argp->dir, argp->offs);
1178
+ return (void *) ret;
1179
+ }
1180
+
1181
+ static inline SQLRETURN
1182
+ SQLFETCHSCROLL(SQLHSTMT hstmt, SQLSMALLINT dir, SQLROWOFFSET offs)
1183
+ {
1184
+ size_t ret;
1185
+ struct S_SQLFETCHSCROLL arg;
1186
+
1187
+ arg.hstmt = hstmt;
1188
+ arg.dir = dir;
1189
+ arg.offs = offs;
1190
+ ret = (size_t) rb_thread_call_without_gvl(F_SQLFETCHSCROLL, &arg,
1191
+ empty_ubf, &arg);
1192
+ return ret;
1193
+ }
1194
+
1195
+ #else
1196
+
1197
+ struct S_SQLEXTENDEDFETCH {
1198
+ SQLHSTMT hstmt;
1199
+ SQLUSMALLINT type;
1200
+ SQLROWOFFSET row;
1201
+ SQLROWSETSIZE *rowp;
1202
+ SQLUSMALLINT *status
1203
+ };
1204
+
1205
+ static void *
1206
+ F_SQLEXTENDEDFETCH(void *args)
1207
+ {
1208
+ size_t ret;
1209
+ struct S_SQLEXTENDEDFETCH *argp = (struct S_SQLEXTENDEDFETCH *) args;
1210
+
1211
+ ret = SQLExtendedFetch(argp->hstmt, argp->type, argp->row, argp->rowp,
1212
+ argp->status);
1213
+ return (void *) ret;
1214
+ }
1215
+
1216
+ static inline SQLRETURN
1217
+ SQLEXTENDEDFETCH(SQLHSTMT hstmt, SQLUSMALLINT type, SQLROWOFFSET row,
1218
+ SQLROWSETSIZE *rowp, SQLUSMALLINT *status)
1219
+ {
1220
+ size_t ret;
1221
+ struct S_SQLEXTENDEDFETCH arg;
1222
+
1223
+ arg.hstmt = hstmt;
1224
+ arg.type = type;
1225
+ arg.row = row;
1226
+ arg.rowp = rowp;
1227
+ arg.status = status;
1228
+ ret = (size_t) rb_thread_call_without_gvl(F_SQLEXTENDEDFETCH, &arg,
1229
+ empty_ubf, &arg);
1230
+ return ret;
1231
+ }
1232
+
1233
+ #endif
1234
+
1235
+ #else
1236
+
1237
+ #define SQLCONNECT SQLConnect
1238
+ #define SQLDRIVERCONNECT SQLDriverConnect
1239
+ #define SQLDISCONNECT SQLDisconnect
1240
+ #define SQLTABLES SQLTables
1241
+ #define SQLCOLUMNS SQLColumns
1242
+ #define SQLPRIMARYKEYS SQLPrimaryKeys
1243
+ #define SQLFOREGINKEYS SQLForeignKeys
1244
+ #define SQLPROCEDURES SQLProcedures
1245
+ #define SQLPROCEDURECOLUMNS SQLProcedureColumns
1246
+ #define SQLTABLEPRIVILEGES SQLTablePrivileges
1247
+ #define SQLSTATISTICS SQLStatistics
1248
+ #define SQLSPECIALCOLUMNS SQLSpecialColumns
1249
+ #define SQLGETTYPEINFO SQLGetTypeInfo
1250
+ #if (ODBCVER >= 0x0300)
1251
+ #define SQLENDTRAN SQLEndTran
1252
+ #else
1253
+ #define SQLTRANSACT SQLTransact
1254
+ #endif
1255
+ #define SQLEXECDIRECT SQLExecDirect
1256
+ #define SQLEXECUTE SQLExecute
1257
+ #define SQLPREPARE SQLPrepare
1258
+ #define SQLMORERESULTS SQLMoreResults
1259
+ #define SQLFETCH SQLFetch
1260
+ #if (ODBCVER >= 0x0300)
1261
+ #define SQLFETCHSCROLL SQLFetchScroll
1262
+ #else
1263
+ #define SQLEXTENDEDFETCH SQLExtendedFetch
1264
+ #endif
1265
+
1266
+ #endif
1267
+
1268
+
1269
+ /*
1270
+ *----------------------------------------------------------------------
1271
+ *
1272
+ * UNICODE converters et.al.
359
1273
  *
360
1274
  *----------------------------------------------------------------------
361
1275
  */
@@ -390,7 +1304,7 @@ uc_strchr(SQLWCHAR *str, SQLWCHAR c)
390
1304
 
391
1305
  static int
392
1306
  mkutf(char *dest, SQLWCHAR *src, int len)
393
- {
1307
+ {
394
1308
  int i;
395
1309
  char *cp = dest;
396
1310
 
@@ -629,7 +1543,7 @@ uc_free(SQLWCHAR *str)
629
1543
  /*
630
1544
  *----------------------------------------------------------------------
631
1545
  *
632
- * Things for ODBC::DSN
1546
+ * Things for ODBC::DSN
633
1547
  *
634
1548
  *----------------------------------------------------------------------
635
1549
  */
@@ -656,7 +1570,7 @@ dsn_init(VALUE self)
656
1570
  /*
657
1571
  *----------------------------------------------------------------------
658
1572
  *
659
- * Things for ODBC::Driver
1573
+ * Things for ODBC::Driver
660
1574
  *
661
1575
  *----------------------------------------------------------------------
662
1576
  */
@@ -683,7 +1597,7 @@ drv_init(VALUE self)
683
1597
  /*
684
1598
  *----------------------------------------------------------------------
685
1599
  *
686
- * Cleanup routines and GC mark/free callbacks.
1600
+ * Cleanup routines and GC mark/free callbacks.
687
1601
  *
688
1602
  *----------------------------------------------------------------------
689
1603
  */
@@ -745,7 +1659,7 @@ list_first(LINK *head)
745
1659
  static int
746
1660
  list_empty(LINK *head)
747
1661
  {
748
- return head->succ == NULL;
1662
+ return head->succ == NULL;
749
1663
  }
750
1664
 
751
1665
  static void
@@ -799,7 +1713,7 @@ free_dbc(DBC *p)
799
1713
  tracemsg(2, fprintf(stderr, "ObjFree: DBC %p\n", p););
800
1714
  if (p->hdbc != SQL_NULL_HDBC) {
801
1715
  callsql(SQL_NULL_HENV, p->hdbc, SQL_NULL_HSTMT,
802
- SQLDisconnect(p->hdbc), "SQLDisconnect");
1716
+ SQLDISCONNECT(p->hdbc), "SQLDisconnect");
803
1717
  callsql(SQL_NULL_HENV, p->hdbc, SQL_NULL_HSTMT,
804
1718
  SQLFreeConnect(p->hdbc), "SQLFreeConnect");
805
1719
  p->hdbc = SQL_NULL_HDBC;
@@ -932,7 +1846,7 @@ mark_stmt(STMT *q)
932
1846
  /*
933
1847
  *----------------------------------------------------------------------
934
1848
  *
935
- * Set internal error (or warning) message.
1849
+ * Set internal error (or warning) message.
936
1850
  *
937
1851
  *----------------------------------------------------------------------
938
1852
  */
@@ -955,7 +1869,7 @@ set_err(const char *msg, int warn)
955
1869
  /*
956
1870
  *----------------------------------------------------------------------
957
1871
  *
958
- * Functions to retrieve last SQL error or warning.
1872
+ * Functions to retrieve last SQL error or warning.
959
1873
  *
960
1874
  *----------------------------------------------------------------------
961
1875
  */
@@ -1286,7 +2200,7 @@ succeeded_nodata(SQLHENV henv, SQLHDBC hdbc, SQLHSTMT hstmt, SQLRETURN ret,
1286
2200
  /*
1287
2201
  *----------------------------------------------------------------------
1288
2202
  *
1289
- * Return ENV from VALUE.
2203
+ * Return ENV from VALUE.
1290
2204
  *
1291
2205
  *----------------------------------------------------------------------
1292
2206
  */
@@ -1327,7 +2241,7 @@ get_env(VALUE self)
1327
2241
  /*
1328
2242
  *----------------------------------------------------------------------
1329
2243
  *
1330
- * Return DBC from VALUE.
2244
+ * Return DBC from VALUE.
1331
2245
  *
1332
2246
  *----------------------------------------------------------------------
1333
2247
  */
@@ -1353,7 +2267,7 @@ get_dbc(VALUE self)
1353
2267
  /*
1354
2268
  *----------------------------------------------------------------------
1355
2269
  *
1356
- * Raise ODBC error from Ruby.
2270
+ * Raise ODBC error from Ruby.
1357
2271
  *
1358
2272
  *----------------------------------------------------------------------
1359
2273
  */
@@ -1384,7 +2298,7 @@ dbc_raise(VALUE self, VALUE msg)
1384
2298
  /*
1385
2299
  *----------------------------------------------------------------------
1386
2300
  *
1387
- * Obtain an ENV.
2301
+ * Obtain an ENV.
1388
2302
  *
1389
2303
  *----------------------------------------------------------------------
1390
2304
  */
@@ -1422,7 +2336,7 @@ env_new(VALUE self)
1422
2336
  /*
1423
2337
  *----------------------------------------------------------------------
1424
2338
  *
1425
- * Obtain array of known DSNs.
2339
+ * Obtain array of known DSNs.
1426
2340
  *
1427
2341
  *----------------------------------------------------------------------
1428
2342
  */
@@ -1477,7 +2391,7 @@ dbc_dsns(VALUE self)
1477
2391
  /*
1478
2392
  *----------------------------------------------------------------------
1479
2393
  *
1480
- * Obtain array of known drivers.
2394
+ * Obtain array of known drivers.
1481
2395
  *
1482
2396
  *----------------------------------------------------------------------
1483
2397
  */
@@ -1553,7 +2467,7 @@ dbc_drivers(VALUE self)
1553
2467
  /*
1554
2468
  *----------------------------------------------------------------------
1555
2469
  *
1556
- * Management methods.
2470
+ * Management methods.
1557
2471
  *
1558
2472
  *----------------------------------------------------------------------
1559
2473
  */
@@ -1872,7 +2786,7 @@ dbc_rfdsn(int argc, VALUE *argv, VALUE self)
1872
2786
  /*
1873
2787
  *----------------------------------------------------------------------
1874
2788
  *
1875
- * Return last ODBC error or warning.
2789
+ * Return last ODBC error or warning.
1876
2790
  *
1877
2791
  *----------------------------------------------------------------------
1878
2792
  */
@@ -1900,7 +2814,7 @@ dbc_clrerror(VALUE self)
1900
2814
  /*
1901
2815
  *----------------------------------------------------------------------
1902
2816
  *
1903
- * Connection instance initializer.
2817
+ * Connection instance initializer.
1904
2818
  *
1905
2819
  *----------------------------------------------------------------------
1906
2820
  */
@@ -1972,7 +2886,7 @@ dbc_new(int argc, VALUE *argv, VALUE self)
1972
2886
  /*
1973
2887
  *----------------------------------------------------------------------
1974
2888
  *
1975
- * Connect to data source.
2889
+ * Connect to data source.
1976
2890
  *
1977
2891
  *----------------------------------------------------------------------
1978
2892
  */
@@ -2062,7 +2976,7 @@ dbc_connect(int argc, VALUE *argv, VALUE self)
2062
2976
  rb_raise(Cerror, "%s", msg);
2063
2977
  }
2064
2978
  if (!succeeded(SQL_NULL_HENV, dbc, SQL_NULL_HSTMT,
2065
- SQLConnect(dbc, (SQLTCHAR *) sdsn, SQL_NTS,
2979
+ SQLCONNECT(dbc, (SQLTCHAR *) sdsn, SQL_NTS,
2066
2980
  (SQLTCHAR *) suser,
2067
2981
  (SQLSMALLINT) (suser ? SQL_NTS : 0),
2068
2982
  (SQLTCHAR *) spasswd,
@@ -2146,7 +3060,7 @@ dbc_drvconnect(VALUE self, VALUE drv)
2146
3060
  rb_raise(Cerror, "%s", msg);
2147
3061
  }
2148
3062
  if (!succeeded(e->henv, dbc, SQL_NULL_HSTMT,
2149
- SQLDriverConnect(dbc, NULL, (SQLTCHAR *) sdrv, SQL_NTS,
3063
+ SQLDRIVERCONNECT(dbc, NULL, (SQLTCHAR *) sdrv, SQL_NTS,
2150
3064
  NULL, 0, NULL, SQL_DRIVER_NOPROMPT),
2151
3065
  &msg, "SQLDriverConnect")) {
2152
3066
  #ifdef UNICODE
@@ -2214,7 +3128,7 @@ dbc_use_scn(int argc, VALUE *argv, VALUE self)
2214
3128
  /*
2215
3129
  *----------------------------------------------------------------------
2216
3130
  *
2217
- * Drop all active statements from data source.
3131
+ * Drop all active statements from data source.
2218
3132
  *
2219
3133
  *----------------------------------------------------------------------
2220
3134
  */
@@ -2238,7 +3152,7 @@ dbc_dropall(VALUE self)
2238
3152
  /*
2239
3153
  *----------------------------------------------------------------------
2240
3154
  *
2241
- * Disconnect from data source.
3155
+ * Disconnect from data source.
2242
3156
  *
2243
3157
  *----------------------------------------------------------------------
2244
3158
  */
@@ -2259,7 +3173,7 @@ dbc_disconnect(int argc, VALUE *argv, VALUE self)
2259
3173
  }
2260
3174
  if (list_empty(&p->stmts)) {
2261
3175
  callsql(SQL_NULL_HENV, p->hdbc, SQL_NULL_HSTMT,
2262
- SQLDisconnect(p->hdbc), "SQLDisconnect");
3176
+ SQLDISCONNECT(p->hdbc), "SQLDisconnect");
2263
3177
  if (!succeeded(SQL_NULL_HENV, p->hdbc, SQL_NULL_HSTMT,
2264
3178
  SQLFreeConnect(p->hdbc), &msg, "SQLFreeConnect")) {
2265
3179
  rb_raise(Cerror, "%s", msg);
@@ -2275,11 +3189,21 @@ dbc_disconnect(int argc, VALUE *argv, VALUE self)
2275
3189
  /*
2276
3190
  *----------------------------------------------------------------------
2277
3191
  *
2278
- * Database meta data via SQLGetInfo()
3192
+ * Database meta data via SQLGetInfo()
2279
3193
  *
2280
3194
  *----------------------------------------------------------------------
2281
3195
  */
2282
3196
 
3197
+ #ifndef SQL_DTC_TRANSITION_COST
3198
+ #define SQL_DTC_TRANSITION_COST 1750
3199
+ #endif
3200
+ #ifndef SQL_DTC_ENLIST_EXPENSIZE
3201
+ #define SQL_DTC_ENLIST_EXPENDSIZE 1
3202
+ #endif
3203
+ #ifndef SQL_DTC_UNENLIST_EXPENSIZE
3204
+ #define SQL_DTC_UNENLIST_EXPENDSIZE 2
3205
+ #endif
3206
+
2283
3207
  #define GI_CONST_SINT(x) { #x, x, SQL_C_SHORT }
2284
3208
  #define GI_CONST_INT(x) { #x, x, SQL_C_LONG }
2285
3209
  #define GI_CONST_BITS(x) { #x, x, SQL_C_LONG }
@@ -3189,7 +4113,7 @@ dbc_getinfo(int argc, VALUE *argv, VALUE self)
3189
4113
  /*
3190
4114
  *----------------------------------------------------------------------
3191
4115
  *
3192
- * Fill column type array for statement.
4116
+ * Fill column type array for statement.
3193
4117
  *
3194
4118
  *----------------------------------------------------------------------
3195
4119
  */
@@ -3340,7 +4264,7 @@ make_coltypes(SQLHSTMT hstmt, int ncols, char **msgp)
3340
4264
  /*
3341
4265
  *----------------------------------------------------------------------
3342
4266
  *
3343
- * Fill parameter info array for statement.
4267
+ * Fill parameter info array for statement.
3344
4268
  *
3345
4269
  *----------------------------------------------------------------------
3346
4270
  */
@@ -3420,7 +4344,7 @@ retain_paraminfo_override(STMT *q, int nump, PARAMINFO *paraminfo)
3420
4344
  /*
3421
4345
  *----------------------------------------------------------------------
3422
4346
  *
3423
- * Wrap SQLHSTMT into struct/VALUE.
4347
+ * Wrap SQLHSTMT into struct/VALUE.
3424
4348
  *
3425
4349
  *----------------------------------------------------------------------
3426
4350
  */
@@ -3465,7 +4389,7 @@ wrap_stmt(VALUE dbc, DBC *p, SQLHSTMT hstmt, STMT **qp)
3465
4389
  /*
3466
4390
  *----------------------------------------------------------------------
3467
4391
  *
3468
- * Create statement with result.
4392
+ * Create statement with result.
3469
4393
  *
3470
4394
  *----------------------------------------------------------------------
3471
4395
  */
@@ -3575,7 +4499,7 @@ upcase_if(char *string, int upc)
3575
4499
  /*
3576
4500
  *----------------------------------------------------------------------
3577
4501
  *
3578
- * Constructor: make column from statement.
4502
+ * Constructor: make column from statement.
3579
4503
  *
3580
4504
  *----------------------------------------------------------------------
3581
4505
  */
@@ -3747,7 +4671,7 @@ make_column(SQLHSTMT hstmt, int i, int upc, int use_scn)
3747
4671
  /*
3748
4672
  *----------------------------------------------------------------------
3749
4673
  *
3750
- * Constructor: make parameter from statement.
4674
+ * Constructor: make parameter from statement.
3751
4675
  *
3752
4676
  *----------------------------------------------------------------------
3753
4677
  */
@@ -3787,7 +4711,7 @@ make_param(STMT *q, int i)
3787
4711
  /*
3788
4712
  *----------------------------------------------------------------------
3789
4713
  *
3790
- * Query tables/columns/keys/indexes/types of data source.
4714
+ * Query tables/columns/keys/indexes/types of data source.
3791
4715
  *
3792
4716
  *----------------------------------------------------------------------
3793
4717
  */
@@ -3900,7 +4824,7 @@ dbc_info(int argc, VALUE *argv, VALUE self, int mode)
3900
4824
  switch (mode) {
3901
4825
  case INFO_TABLES:
3902
4826
  if (!succeeded(SQL_NULL_HENV, SQL_NULL_HDBC, hstmt,
3903
- SQLTables(hstmt, NULL, 0, NULL, 0,
4827
+ SQLTABLES(hstmt, NULL, 0, NULL, 0,
3904
4828
  swhich, (swhich == NULL) ? 0 : SQL_NTS,
3905
4829
  NULL, 0),
3906
4830
  &msg, "SQLTables")) {
@@ -3909,7 +4833,7 @@ dbc_info(int argc, VALUE *argv, VALUE self, int mode)
3909
4833
  break;
3910
4834
  case INFO_COLUMNS:
3911
4835
  if (!succeeded(SQL_NULL_HENV, SQL_NULL_HDBC, hstmt,
3912
- SQLColumns(hstmt, NULL, 0, NULL, 0,
4836
+ SQLCOLUMNS(hstmt, NULL, 0, NULL, 0,
3913
4837
  swhich, (swhich == NULL) ? 0 : SQL_NTS,
3914
4838
  swhich2, (swhich2 == NULL) ? 0 : SQL_NTS),
3915
4839
  &msg, "SQLColumns")) {
@@ -3918,7 +4842,7 @@ dbc_info(int argc, VALUE *argv, VALUE self, int mode)
3918
4842
  break;
3919
4843
  case INFO_PRIMKEYS:
3920
4844
  if (!succeeded(SQL_NULL_HENV, SQL_NULL_HDBC, hstmt,
3921
- SQLPrimaryKeys(hstmt, NULL, 0, NULL, 0,
4845
+ SQLPRIMARYKEYS(hstmt, NULL, 0, NULL, 0,
3922
4846
  swhich, (swhich == NULL) ? 0 : SQL_NTS),
3923
4847
  &msg, "SQLPrimaryKeys")) {
3924
4848
  goto error;
@@ -3926,7 +4850,7 @@ dbc_info(int argc, VALUE *argv, VALUE self, int mode)
3926
4850
  break;
3927
4851
  case INFO_INDEXES:
3928
4852
  if (!succeeded(SQL_NULL_HENV, SQL_NULL_HDBC, hstmt,
3929
- SQLStatistics(hstmt, NULL, 0, NULL, 0,
4853
+ SQLSTATISTICS(hstmt, NULL, 0, NULL, 0,
3930
4854
  swhich, (swhich == NULL) ? 0 : SQL_NTS,
3931
4855
  (SQLUSMALLINT) (RTEST(which2) ?
3932
4856
  SQL_INDEX_UNIQUE : SQL_INDEX_ALL),
@@ -3937,14 +4861,14 @@ dbc_info(int argc, VALUE *argv, VALUE self, int mode)
3937
4861
  break;
3938
4862
  case INFO_TYPES:
3939
4863
  if (!succeeded(SQL_NULL_HENV, SQL_NULL_HDBC, hstmt,
3940
- SQLGetTypeInfo(hstmt, (SQLSMALLINT) itype),
4864
+ SQLGETTYPEINFO(hstmt, (SQLSMALLINT) itype),
3941
4865
  &msg, "SQLGetTypeInfo")) {
3942
4866
  goto error;
3943
4867
  }
3944
4868
  break;
3945
4869
  case INFO_FORKEYS:
3946
4870
  if (!succeeded(SQL_NULL_HENV, SQL_NULL_HDBC, hstmt,
3947
- SQLForeignKeys(hstmt, NULL, 0, NULL, 0,
4871
+ SQLFOREIGNKEYS(hstmt, NULL, 0, NULL, 0,
3948
4872
  swhich, (swhich == NULL) ? 0 : SQL_NTS,
3949
4873
  NULL, 0, NULL, 0,
3950
4874
  swhich2, (swhich2 == NULL) ? 0 : SQL_NTS),
@@ -3954,7 +4878,7 @@ dbc_info(int argc, VALUE *argv, VALUE self, int mode)
3954
4878
  break;
3955
4879
  case INFO_TPRIV:
3956
4880
  if (!succeeded(SQL_NULL_HENV, SQL_NULL_HDBC, hstmt,
3957
- SQLTablePrivileges(hstmt, NULL, 0, NULL, 0, swhich,
4881
+ SQLTABLEPRIVILEGES(hstmt, NULL, 0, NULL, 0, swhich,
3958
4882
  (swhich == NULL) ? 0 : SQL_NTS),
3959
4883
  &msg, "SQLTablePrivileges")) {
3960
4884
  goto error;
@@ -3962,7 +4886,7 @@ dbc_info(int argc, VALUE *argv, VALUE self, int mode)
3962
4886
  break;
3963
4887
  case INFO_PROCS:
3964
4888
  if (!succeeded(SQL_NULL_HENV, SQL_NULL_HDBC, hstmt,
3965
- SQLProcedures(hstmt, NULL, 0, NULL, 0,
4889
+ SQLPROCEDURES(hstmt, NULL, 0, NULL, 0,
3966
4890
  swhich, (swhich == NULL) ? 0 : SQL_NTS),
3967
4891
  &msg, "SQLProcedures")) {
3968
4892
  goto error;
@@ -3970,7 +4894,7 @@ dbc_info(int argc, VALUE *argv, VALUE self, int mode)
3970
4894
  break;
3971
4895
  case INFO_PROCCOLS:
3972
4896
  if (!succeeded(SQL_NULL_HENV, SQL_NULL_HDBC, hstmt,
3973
- SQLProcedureColumns(hstmt, NULL, 0, NULL, 0,
4897
+ SQLPROCEDURECOLUMNS(hstmt, NULL, 0, NULL, 0,
3974
4898
  swhich,
3975
4899
  (swhich == NULL) ? 0 : SQL_NTS,
3976
4900
  swhich2,
@@ -3981,7 +4905,7 @@ dbc_info(int argc, VALUE *argv, VALUE self, int mode)
3981
4905
  break;
3982
4906
  case INFO_SPECCOLS:
3983
4907
  if (!succeeded(SQL_NULL_HENV, SQL_NULL_HDBC, hstmt,
3984
- SQLSpecialColumns(hstmt, (SQLUSMALLINT) iid,
4908
+ SQLSPECIALCOLUMNS(hstmt, (SQLUSMALLINT) iid,
3985
4909
  NULL, 0, NULL, 0,
3986
4910
  swhich,
3987
4911
  (swhich == NULL) ? 0 : SQL_NTS,
@@ -4071,7 +4995,7 @@ dbc_speccols(int argc, VALUE *argv, VALUE self)
4071
4995
  /*
4072
4996
  *----------------------------------------------------------------------
4073
4997
  *
4074
- * Transaction stuff.
4998
+ * Transaction stuff.
4075
4999
  *
4076
5000
  *----------------------------------------------------------------------
4077
5001
  */
@@ -4081,6 +5005,7 @@ dbc_trans(VALUE self, int what)
4081
5005
  {
4082
5006
  ENV *e;
4083
5007
  SQLHDBC dbc = SQL_NULL_HDBC;
5008
+ SQLRETURN ret;
4084
5009
  char *msg;
4085
5010
 
4086
5011
  e = get_env(self);
@@ -4090,16 +5015,18 @@ dbc_trans(VALUE self, int what)
4090
5015
  d = get_dbc(self);
4091
5016
  dbc = d->hdbc;
4092
5017
  }
4093
- if (!succeeded(e->henv, dbc, SQL_NULL_HSTMT,
4094
5018
  #if (ODBCVER >= 0x0300)
4095
- SQLEndTran((SQLSMALLINT)
4096
- ((dbc == SQL_NULL_HDBC) ? SQL_HANDLE_ENV :
4097
- SQL_HANDLE_DBC),
4098
- (dbc == SQL_NULL_HDBC) ? e->henv : dbc,
4099
- (SQLSMALLINT) what),
5019
+ ret = SQLENDTRAN((SQLSMALLINT)
5020
+ ((dbc == SQL_NULL_HDBC) ? SQL_HANDLE_ENV : SQL_HANDLE_DBC),
5021
+ (dbc == SQL_NULL_HDBC) ? e->henv : dbc,
5022
+ (SQLSMALLINT) what);
5023
+ #else
5024
+ ret = SQLTRANSACT(e->henv, dbc, (SQLUSMALLINT) what);
5025
+ #endif
5026
+ if (!succeeded(e->henv, dbc, SQL_NULL_HSTMT, ret,
5027
+ #if (ODBCVER >= 0x0300)
4100
5028
  &msg, "SQLEndTran"
4101
5029
  #else
4102
- SQLTransact(e->henv, dbc, (SQLUSMALLINT) what),
4103
5030
  &msg, "SQLTransact"
4104
5031
  #endif
4105
5032
  )) {
@@ -4166,7 +5093,7 @@ dbc_transaction(VALUE self)
4166
5093
  /*
4167
5094
  *----------------------------------------------------------------------
4168
5095
  *
4169
- * Environment attribute handling.
5096
+ * Environment attribute handling.
4170
5097
  *
4171
5098
  *----------------------------------------------------------------------
4172
5099
  */
@@ -4247,17 +5174,17 @@ env_odbcver(int argc, VALUE *argv, VALUE self)
4247
5174
  /*
4248
5175
  *----------------------------------------------------------------------
4249
5176
  *
4250
- * Connection/statement option handling.
5177
+ * Connection/statement option handling.
4251
5178
  *
4252
- * Note:
4253
- * ODBC 2 allows statement options to be set using SQLSetConnectOption,
4254
- * establishing the statement option as a default for any hstmts
4255
- * later allocated for that hdbc. This feature was deprecated in
4256
- * ODBC 3.x and may not work with ODBC 3.x drivers.
5179
+ * Note:
5180
+ * ODBC 2 allows statement options to be set using SQLSetConnectOption,
5181
+ * establishing the statement option as a default for any hstmts
5182
+ * later allocated for that hdbc. This feature was deprecated in
5183
+ * ODBC 3.x and may not work with ODBC 3.x drivers.
4257
5184
  *
4258
- * Although the Database class includes attribute accessors for
4259
- * statement-level options, a safer alternative, if using an ODBC 3
4260
- * driver, is to set the option directly on the Statement instance.
5185
+ * Although the Database class includes attribute accessors for
5186
+ * statement-level options, a safer alternative, if using an ODBC 3
5187
+ * driver, is to set the option directly on the Statement instance.
4261
5188
  *
4262
5189
  *----------------------------------------------------------------------
4263
5190
  */
@@ -4385,8 +5312,8 @@ do_option(int argc, VALUE *argv, VALUE self, int isstmt, int op)
4385
5312
  if (val == Qnil) {
4386
5313
  return v ? Qtrue : Qfalse;
4387
5314
  }
4388
- v = (TYPE(val) == T_FIXNUM) ?
4389
- (FIX2INT(val) ? SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF) :
5315
+ v = (TYPE(val) == T_FIXNUM) ?
5316
+ (FIX2INT(val) ? SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF) :
4390
5317
  (RTEST(val) ? SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF);
4391
5318
  break;
4392
5319
 
@@ -4394,8 +5321,8 @@ do_option(int argc, VALUE *argv, VALUE self, int isstmt, int op)
4394
5321
  if (val == Qnil) {
4395
5322
  return v ? Qtrue : Qfalse;
4396
5323
  }
4397
- v = (TYPE(val) == T_FIXNUM) ?
4398
- (FIX2INT(val) ? SQL_NOSCAN_ON : SQL_NOSCAN_OFF) :
5324
+ v = (TYPE(val) == T_FIXNUM) ?
5325
+ (FIX2INT(val) ? SQL_NOSCAN_ON : SQL_NOSCAN_OFF) :
4399
5326
  (RTEST(val) ? SQL_NOSCAN_ON : SQL_NOSCAN_OFF);
4400
5327
  break;
4401
5328
 
@@ -4424,7 +5351,7 @@ do_option(int argc, VALUE *argv, VALUE self, int isstmt, int op)
4424
5351
  rb_raise(Cerror, "%s", msg);
4425
5352
  }
4426
5353
  } else {
4427
- if (!succeeded(SQL_NULL_HENV, SQL_NULL_HDBC, q->hstmt,
5354
+ if (!succeeded(SQL_NULL_HENV, SQL_NULL_HDBC, q->hstmt,
4428
5355
  SQLSetStmtOption(q->hstmt, (SQLUSMALLINT) op,
4429
5356
  (SQLUINTEGER) v),
4430
5357
  &msg, "SQLSetStmtOption(%d)", op)) {
@@ -4539,7 +5466,7 @@ stmt_getsetoption(int argc, VALUE *argv, VALUE self)
4539
5466
  /*
4540
5467
  *----------------------------------------------------------------------
4541
5468
  *
4542
- * Scan literal date/time/timestamp to TIMESTAMP_STRUCT.
5469
+ * Scan literal date/time/timestamp to TIMESTAMP_STRUCT.
4543
5470
  *
4544
5471
  *----------------------------------------------------------------------
4545
5472
  */
@@ -4573,7 +5500,7 @@ scan_dtts(VALUE str, int do_d, int do_t, TIMESTAMP_STRUCT *ts)
4573
5500
  ts->day = dd;
4574
5501
  return 1;
4575
5502
  }
4576
- if (do_t &&
5503
+ if (do_t &&
4577
5504
  (sscanf(cstr, "{t '%d:%d:%d' %c", &hh, &mmm, &ss, &c) == 4) &&
4578
5505
  (c == '}')) {
4579
5506
  ts->hour = yy;
@@ -4617,7 +5544,7 @@ next:
4617
5544
  /*
4618
5545
  *----------------------------------------------------------------------
4619
5546
  *
4620
- * Date methods.
5547
+ * Date methods.
4621
5548
  *
4622
5549
  *----------------------------------------------------------------------
4623
5550
  */
@@ -4638,7 +5565,7 @@ date_new(int argc, VALUE *argv, VALUE self)
4638
5565
  {
4639
5566
  DATE_STRUCT *date;
4640
5567
  VALUE obj = Data_Make_Struct(self, DATE_STRUCT, 0, xfree, date);
4641
-
5568
+
4642
5569
  rb_obj_call_init(obj, argc, argv);
4643
5570
  return obj;
4644
5571
  }
@@ -4852,7 +5779,7 @@ date_cmp(VALUE self, VALUE date)
4852
5779
  /*
4853
5780
  *----------------------------------------------------------------------
4854
5781
  *
4855
- * Time methods.
5782
+ * Time methods.
4856
5783
  *
4857
5784
  *----------------------------------------------------------------------
4858
5785
  */
@@ -4873,7 +5800,7 @@ time_new(int argc, VALUE *argv, VALUE self)
4873
5800
  {
4874
5801
  TIME_STRUCT *time;
4875
5802
  VALUE obj = Data_Make_Struct(self, TIME_STRUCT, 0, xfree, time);
4876
-
5803
+
4877
5804
  rb_obj_call_init(obj, argc, argv);
4878
5805
  return obj;
4879
5806
  }
@@ -4887,7 +5814,7 @@ time_load1(VALUE self, VALUE str, int load)
4887
5814
  if (scan_dtts(str, 0, 1, &tss)) {
4888
5815
  TIME_STRUCT *time;
4889
5816
  VALUE obj;
4890
-
5817
+
4891
5818
  if (load) {
4892
5819
  obj = Data_Make_Struct(self, TIME_STRUCT, 0, xfree, time);
4893
5820
  } else {
@@ -5080,7 +6007,7 @@ time_cmp(VALUE self, VALUE time)
5080
6007
  /*
5081
6008
  *----------------------------------------------------------------------
5082
6009
  *
5083
- * TimeStamp methods.
6010
+ * TimeStamp methods.
5084
6011
  *
5085
6012
  *----------------------------------------------------------------------
5086
6013
  */
@@ -5423,7 +6350,7 @@ timestamp_cmp(VALUE self, VALUE timestamp)
5423
6350
  /*
5424
6351
  *----------------------------------------------------------------------
5425
6352
  *
5426
- * Statement methods.
6353
+ * Statement methods.
5427
6354
  *
5428
6355
  *----------------------------------------------------------------------
5429
6356
  */
@@ -5481,7 +6408,7 @@ check_ncols(STMT *q)
5481
6408
  (q->coltypes == NULL)) {
5482
6409
  COLTYPE *coltypes = NULL;
5483
6410
  SQLSMALLINT cols = 0;
5484
-
6411
+
5485
6412
  if (succeeded(SQL_NULL_HENV, SQL_NULL_HDBC, q->hstmt,
5486
6413
  SQLNumResultCols(q->hstmt, &cols), NULL,
5487
6414
  "SQLNumResultCols")
@@ -5985,7 +6912,7 @@ do_fetch(STMT *q, int mode)
5985
6912
  }
5986
6913
  if (q->dbcp != NULL && q->dbcp->use_sql_column_name == Qtrue) {
5987
6914
  use_scn = 1;
5988
- }
6915
+ }
5989
6916
  switch (mode & DOFETCH_MODES) {
5990
6917
  case DOFETCH_HASH:
5991
6918
  case DOFETCH_HASH2:
@@ -6460,7 +7387,7 @@ stmt_fetch1(VALUE self, int bang)
6460
7387
  const char *msg;
6461
7388
  char *err;
6462
7389
  #if (ODBCVER < 0x0300)
6463
- SQLUINTEGER nRows;
7390
+ SQLROWSETSIZE nRows;
6464
7391
  SQLUSMALLINT rowStat[1];
6465
7392
  #endif
6466
7393
 
@@ -6473,10 +7400,10 @@ stmt_fetch1(VALUE self, int bang)
6473
7400
  }
6474
7401
  #if (ODBCVER < 0x0300)
6475
7402
  msg = "SQLExtendedFetch(SQL_FETCH_NEXT)";
6476
- ret = SQLExtendedFetch(q->hstmt, SQL_FETCH_NEXT, 0, &nRows, rowStat);
7403
+ ret = SQLEXTENDEDFETCH(q->hstmt, SQL_FETCH_NEXT, 0, &nRows, rowStat);
6477
7404
  #else
6478
7405
  msg = "SQLFetchScroll(SQL_FETCH_NEXT)";
6479
- ret = SQLFetchScroll(q->hstmt, SQL_FETCH_NEXT, 0);
7406
+ ret = SQLFETCHSCROLL(q->hstmt, SQL_FETCH_NEXT, 0);
6480
7407
  #endif
6481
7408
  if (ret == SQL_NO_DATA) {
6482
7409
  (void) tracesql(SQL_NULL_HENV, SQL_NULL_HDBC, q->hstmt, ret, msg);
@@ -6492,7 +7419,7 @@ usef:
6492
7419
  /* Fallback to SQLFetch() when others not implemented */
6493
7420
  msg = "SQLFetch";
6494
7421
  q->usef = 1;
6495
- ret = SQLFetch(q->hstmt);
7422
+ ret = SQLFETCH(q->hstmt);
6496
7423
  if (ret == SQL_NO_DATA) {
6497
7424
  (void) tracesql(SQL_NULL_HENV, SQL_NULL_HDBC, q->hstmt, ret, msg);
6498
7425
  return Qnil;
@@ -6532,7 +7459,7 @@ stmt_fetch_first1(VALUE self, int bang, int nopos)
6532
7459
  const char *msg;
6533
7460
  char *err;
6534
7461
  #if (ODBCVER < 0x0300)
6535
- SQLUINTEGER nRows;
7462
+ SQLROWSETSIZE nRows;
6536
7463
  SQLUSMALLINT rowStat[1];
6537
7464
  #endif
6538
7465
 
@@ -6545,10 +7472,10 @@ stmt_fetch_first1(VALUE self, int bang, int nopos)
6545
7472
  }
6546
7473
  #if (ODBCVER < 0x0300)
6547
7474
  msg = "SQLExtendedFetch(SQL_FETCH_FIRST)";
6548
- ret = SQLExtendedFetch(q->hstmt, SQL_FETCH_FIRST, 0, &nRows, rowStat);
7475
+ ret = SQLEXTENDEDFETCH(q->hstmt, SQL_FETCH_FIRST, 0, &nRows, rowStat);
6549
7476
  #else
6550
7477
  msg = "SQLFetchScroll(SQL_FETCH_FIRST)";
6551
- ret = SQLFetchScroll(q->hstmt, SQL_FETCH_FIRST, 0);
7478
+ ret = SQLFETCHSCROLL(q->hstmt, SQL_FETCH_FIRST, 0);
6552
7479
  #endif
6553
7480
  if (ret == SQL_NO_DATA) {
6554
7481
  (void) tracesql(SQL_NULL_HENV, SQL_NULL_HDBC, q->hstmt, ret, msg);
@@ -6583,7 +7510,7 @@ stmt_fetch_scroll1(int argc, VALUE *argv, VALUE self, int bang)
6583
7510
  int idir, ioffs = 1;
6584
7511
  char msg[128], *err;
6585
7512
  #if (ODBCVER < 0x0300)
6586
- SQLUINTEGER nRows;
7513
+ SQLROWSETSIZE nRows;
6587
7514
  SQLUSMALLINT rowStat[1];
6588
7515
  #endif
6589
7516
 
@@ -6598,11 +7525,11 @@ stmt_fetch_scroll1(int argc, VALUE *argv, VALUE self, int bang)
6598
7525
  }
6599
7526
  #if (ODBCVER < 0x0300)
6600
7527
  sprintf(msg, "SQLExtendedFetch(%d)", idir);
6601
- ret = SQLExtendedFetch(q->hstmt, (SQLSMALLINT) idir, (SQLINTEGER) ioffs,
7528
+ ret = SQLEXTENDEDFETCH(q->hstmt, (SQLSMALLINT) idir, (SQLROWOFFSET) ioffs,
6602
7529
  &nRows, rowStat);
6603
7530
  #else
6604
7531
  sprintf(msg, "SQLFetchScroll(%d)", idir);
6605
- ret = SQLFetchScroll(q->hstmt, (SQLSMALLINT) idir, (SQLINTEGER) ioffs);
7532
+ ret = SQLFETCHSCROLL(q->hstmt, (SQLSMALLINT) idir, (SQLROWOFFSET) ioffs);
6606
7533
  #endif
6607
7534
  if (ret == SQL_NO_DATA) {
6608
7535
  (void) tracesql(SQL_NULL_HENV, SQL_NULL_HDBC, q->hstmt, ret, msg);
@@ -6703,7 +7630,7 @@ stmt_fetch_hash1(int argc, VALUE *argv, VALUE self, int bang)
6703
7630
  const char *msg;
6704
7631
  char *err;
6705
7632
  #if (ODBCVER < 0x0300)
6706
- SQLUINTEGER nRows;
7633
+ SQLROWSETSIZE nRows;
6707
7634
  SQLUSMALLINT rowStat[1];
6708
7635
  #endif
6709
7636
 
@@ -6716,10 +7643,10 @@ stmt_fetch_hash1(int argc, VALUE *argv, VALUE self, int bang)
6716
7643
  }
6717
7644
  #if (ODBCVER < 0x0300)
6718
7645
  msg = "SQLExtendedFetch(SQL_FETCH_NEXT)";
6719
- ret = SQLExtendedFetch(q->hstmt, SQL_FETCH_NEXT, 0, &nRows, rowStat);
7646
+ ret = SQLEXTENDEDFETCH(q->hstmt, SQL_FETCH_NEXT, 0, &nRows, rowStat);
6720
7647
  #else
6721
7648
  msg = "SQLFetchScroll(SQL_FETCH_NEXT)";
6722
- ret = SQLFetchScroll(q->hstmt, SQL_FETCH_NEXT, 0);
7649
+ ret = SQLFETCHSCROLL(q->hstmt, SQL_FETCH_NEXT, 0);
6723
7650
  #endif
6724
7651
  if (ret == SQL_NO_DATA) {
6725
7652
  (void) tracesql(SQL_NULL_HENV, SQL_NULL_HDBC, q->hstmt, ret, msg);
@@ -6735,7 +7662,7 @@ usef:
6735
7662
  /* Fallback to SQLFetch() when others not implemented */
6736
7663
  msg = "SQLFetch";
6737
7664
  q->usef = 1;
6738
- ret = SQLFetch(q->hstmt);
7665
+ ret = SQLFETCH(q->hstmt);
6739
7666
  if (ret == SQL_NO_DATA) {
6740
7667
  (void) tracesql(SQL_NULL_HENV, SQL_NULL_HDBC, q->hstmt, ret, msg);
6741
7668
  return Qnil;
@@ -6776,7 +7703,7 @@ stmt_fetch_first_hash1(int argc, VALUE *argv, VALUE self, int bang, int nopos)
6776
7703
  const char *msg;
6777
7704
  char *err;
6778
7705
  #if (ODBCVER < 0x0300)
6779
- SQLUINTEGER nRows;
7706
+ SQLROWSETSIZE nRows;
6780
7707
  SQLUSMALLINT rowStat[1];
6781
7708
  #endif
6782
7709
 
@@ -6789,10 +7716,10 @@ stmt_fetch_first_hash1(int argc, VALUE *argv, VALUE self, int bang, int nopos)
6789
7716
  }
6790
7717
  #if (ODBCVER < 0x0300)
6791
7718
  msg = "SQLExtendedFetch(SQL_FETCH_FIRST)";
6792
- ret = SQLExtendedFetch(q->hstmt, SQL_FETCH_FIRST, 0, &nRows, rowStat);
7719
+ ret = SQLEXTENDEDFETCH(q->hstmt, SQL_FETCH_FIRST, 0, &nRows, rowStat);
6793
7720
  #else
6794
7721
  msg = "SQLFetchScroll(SQL_FETCH_FIRST)";
6795
- ret = SQLFetchScroll(q->hstmt, SQL_FETCH_FIRST, 0);
7722
+ ret = SQLFETCHSCROLL(q->hstmt, SQL_FETCH_FIRST, 0);
6796
7723
  #endif
6797
7724
  if (ret == SQL_NO_DATA) {
6798
7725
  (void) tracesql(SQL_NULL_HENV, SQL_NULL_HDBC, q->hstmt, ret, msg);
@@ -6818,19 +7745,19 @@ stmt_each(VALUE self)
6818
7745
  VALUE row, res = Qnil;
6819
7746
  STMT *q;
6820
7747
  #if (ODBCVER < 0x0300)
6821
- SQLUINTEGER nRows;
7748
+ SQLROWSETSIZE nRows;
6822
7749
  SQLUSMALLINT rowStat[1];
6823
7750
  #endif
6824
7751
 
6825
7752
  Data_Get_Struct(self, STMT, q);
6826
7753
  #if (ODBCVER < 0x0300)
6827
7754
  switch (callsql(SQL_NULL_HENV, SQL_NULL_HDBC, q->hstmt,
6828
- SQLExtendedFetch(q->hstmt, SQL_FETCH_FIRST, 0, &nRows,
7755
+ SQLEXTENDEDFETCH(q->hstmt, SQL_FETCH_FIRST, 0, &nRows,
6829
7756
  rowStat),
6830
7757
  "SQLExtendedFetch(SQL_FETCH_FIRST)"))
6831
7758
  #else
6832
7759
  switch (callsql(SQL_NULL_HENV, SQL_NULL_HDBC, q->hstmt,
6833
- SQLFetchScroll(q->hstmt, SQL_FETCH_FIRST, 0),
7760
+ SQLFETCHSCROLL(q->hstmt, SQL_FETCH_FIRST, 0),
6834
7761
  "SQLFetchScroll(SQL_FETCH_FIRST)"))
6835
7762
  #endif
6836
7763
  {
@@ -6868,7 +7795,7 @@ stmt_each_hash(int argc, VALUE *argv, VALUE self)
6868
7795
  STMT *q;
6869
7796
  int mode = stmt_hash_mode(argc, argv, self);
6870
7797
  #if (ODBCVER < 0x0300)
6871
- SQLUINTEGER nRows;
7798
+ SQLROWSETSIZE nRows;
6872
7799
  SQLUSMALLINT rowStat[1];
6873
7800
  #endif
6874
7801
 
@@ -6884,12 +7811,12 @@ stmt_each_hash(int argc, VALUE *argv, VALUE self)
6884
7811
  Data_Get_Struct(self, STMT, q);
6885
7812
  #if (ODBCVER < 0x0300)
6886
7813
  switch (callsql(SQL_NULL_HENV, SQL_NULL_HDBC, q->hstmt,
6887
- SQLExtendedFetch(q->hstmt, SQL_FETCH_FIRST, 0, &nRows,
7814
+ SQLEXTENDEDFETCH(q->hstmt, SQL_FETCH_FIRST, 0, &nRows,
6888
7815
  rowStat),
6889
7816
  "SQLExtendedFetch(SQL_FETCH_FIRST)"))
6890
7817
  #else
6891
7818
  switch (callsql(SQL_NULL_HENV, SQL_NULL_HDBC, q->hstmt,
6892
- SQLFetchScroll(q->hstmt, SQL_FETCH_FIRST, 0),
7819
+ SQLFETCHSCROLL(q->hstmt, SQL_FETCH_FIRST, 0),
6893
7820
  "SQLFetchScroll(SQL_FETCH_FIRST)"))
6894
7821
  #endif
6895
7822
  {
@@ -6955,6 +7882,7 @@ stmt_prep_int(int argc, VALUE *argv, VALUE self, int mode)
6955
7882
  STMT *q = NULL;
6956
7883
  VALUE sql, dbc, stmt;
6957
7884
  SQLHSTMT hstmt;
7885
+ SQLRETURN ret;
6958
7886
  #ifdef UNICODE
6959
7887
  SQLWCHAR *ssql = NULL;
6960
7888
  #else
@@ -7004,10 +7932,8 @@ stmt_prep_int(int argc, VALUE *argv, VALUE self, int mode)
7004
7932
  ssql = (SQLCHAR *) csql;
7005
7933
  #endif
7006
7934
  if ((mode & MAKERES_EXECD)) {
7007
- SQLRETURN ret;
7008
-
7009
- if (!succeeded_nodata(SQL_NULL_HENV, SQL_NULL_HDBC, hstmt,
7010
- (ret = SQLExecDirect(hstmt, ssql, SQL_NTS)),
7935
+ ret = SQLEXECDIRECT(hstmt, ssql, SQL_NTS);
7936
+ if (!succeeded_nodata(SQL_NULL_HENV, SQL_NULL_HDBC, hstmt, ret,
7011
7937
  &msg, "SQLExecDirect('%s')", csql)) {
7012
7938
  goto sqlerr;
7013
7939
  }
@@ -7020,22 +7946,24 @@ stmt_prep_int(int argc, VALUE *argv, VALUE self, int mode)
7020
7946
  }
7021
7947
  hstmt = SQL_NULL_HSTMT;
7022
7948
  }
7023
- } else if (!succeeded(SQL_NULL_HENV, SQL_NULL_HDBC, hstmt,
7024
- SQLPrepare(hstmt, ssql, SQL_NTS),
7949
+ } else {
7950
+ ret = SQLPREPARE(hstmt, ssql, SQL_NTS);
7951
+ if (!succeeded(SQL_NULL_HENV, SQL_NULL_HDBC, hstmt, ret,
7025
7952
  &msg, "SQLPrepare('%s')", csql)) {
7026
7953
  sqlerr:
7027
7954
  #ifdef UNICODE
7028
- uc_free(ssql);
7955
+ uc_free(ssql);
7029
7956
  #endif
7030
- callsql(SQL_NULL_HENV, SQL_NULL_HDBC, hstmt,
7031
- SQLFreeStmt(hstmt, SQL_DROP), "SQLFreeStmt(SQL_DROP)");
7032
- if (q != NULL) {
7033
- q->hstmt = SQL_NULL_HSTMT;
7034
- unlink_stmt(q);
7957
+ callsql(SQL_NULL_HENV, SQL_NULL_HDBC, hstmt,
7958
+ SQLFreeStmt(hstmt, SQL_DROP), "SQLFreeStmt(SQL_DROP)");
7959
+ if (q != NULL) {
7960
+ q->hstmt = SQL_NULL_HSTMT;
7961
+ unlink_stmt(q);
7962
+ }
7963
+ rb_raise(Cerror, "%s", msg);
7964
+ } else {
7965
+ mode |= MAKERES_PREPARE;
7035
7966
  }
7036
- rb_raise(Cerror, "%s", msg);
7037
- } else {
7038
- mode |= MAKERES_PREPARE;
7039
7967
  }
7040
7968
  #ifdef UNICODE
7041
7969
  uc_free(ssql);
@@ -7452,8 +8380,8 @@ stmt_exec_int(int argc, VALUE *argv, VALUE self, int mode)
7452
8380
  goto error;
7453
8381
  }
7454
8382
  }
7455
- if (!succeeded_nodata(SQL_NULL_HENV, SQL_NULL_HDBC, q->hstmt,
7456
- (ret = SQLExecute(q->hstmt)),
8383
+ ret = SQLEXECUTE(q->hstmt);
8384
+ if (!succeeded_nodata(SQL_NULL_HENV, SQL_NULL_HDBC, q->hstmt, ret,
7457
8385
  &msg, "SQLExecute")) {
7458
8386
  error:
7459
8387
  #ifdef UNICODE
@@ -7512,7 +8440,7 @@ static VALUE
7512
8440
  stmt_do(int argc, VALUE *argv, VALUE self)
7513
8441
  {
7514
8442
  VALUE stmt;
7515
-
8443
+
7516
8444
  if (argc < 1) {
7517
8445
  rb_raise(rb_eArgError, "wrong # of arguments");
7518
8446
  }
@@ -7557,7 +8485,7 @@ stmt_ignorecase(int argc, VALUE *argv, VALUE self)
7557
8485
  /*
7558
8486
  *----------------------------------------------------------------------
7559
8487
  *
7560
- * Create statement without implicit SQL prepare or execute.
8488
+ * Create statement without implicit SQL prepare or execute.
7561
8489
  *
7562
8490
  *----------------------------------------------------------------------
7563
8491
  */
@@ -7580,7 +8508,7 @@ stmt_new(VALUE self)
7580
8508
  /*
7581
8509
  *----------------------------------------------------------------------
7582
8510
  *
7583
- * Procedures with statements.
8511
+ * Procedures with statements.
7584
8512
  *
7585
8513
  *----------------------------------------------------------------------
7586
8514
  */
@@ -7671,7 +8599,7 @@ stmt_procwrap(int argc, VALUE *argv, VALUE self)
7671
8599
  /*
7672
8600
  *----------------------------------------------------------------------
7673
8601
  *
7674
- * Module functions.
8602
+ * Module functions.
7675
8603
  *
7676
8604
  *----------------------------------------------------------------------
7677
8605
  */
@@ -7854,7 +8782,7 @@ mod_trace(int argc, VALUE *argv, VALUE self)
7854
8782
  /*
7855
8783
  *----------------------------------------------------------------------
7856
8784
  *
7857
- * Table of constants and intern'ed string mappings.
8785
+ * Table of constants and intern'ed string mappings.
7858
8786
  *
7859
8787
  *----------------------------------------------------------------------
7860
8788
  */
@@ -7990,10 +8918,26 @@ static struct {
7990
8918
  O_CONST2(SQL_OV_ODBC3, 3),
7991
8919
  #endif
7992
8920
  #ifdef SQL_ATTR_CONNECTION_POOLING
8921
+ #ifdef SQL_CP_OFF
7993
8922
  O_CONST(SQL_CP_OFF),
8923
+ #else
8924
+ O_CONST2(SQL_CP_OFF, 0),
8925
+ #endif
8926
+ #ifdef SQL_CP_ONE_PER_DRIVER
7994
8927
  O_CONST(SQL_CP_ONE_PER_DRIVER),
8928
+ #else
8929
+ O_CONST2(SQL_CP_ONE_PER_DRIVER, 1),
8930
+ #endif
8931
+ #ifdef SQL_CP_ONE_PER_HENV
7995
8932
  O_CONST(SQL_CP_ONE_PER_HENV),
8933
+ #else
8934
+ O_CONST2(SQL_CP_ONE_PER_HENV, 2),
8935
+ #endif
8936
+ #ifdef SQL_CP_DEFAULT
7996
8937
  O_CONST(SQL_CP_DEFAULT),
8938
+ #else
8939
+ O_CONST2(SQL_CP_DEFAULT, 0),
8940
+ #endif
7997
8941
  #else
7998
8942
  O_CONST2(SQL_CP_OFF, 0),
7999
8943
  O_CONST2(SQL_CP_ONE_PER_DRIVER, 0),
@@ -8107,7 +9051,7 @@ static struct {
8107
9051
  /*
8108
9052
  *----------------------------------------------------------------------
8109
9053
  *
8110
- * Module initializer.
9054
+ * Module initializer.
8111
9055
  *
8112
9056
  *----------------------------------------------------------------------
8113
9057
  */
@@ -8128,7 +9072,7 @@ Init_odbc()
8128
9072
  rb_cDate = rb_eval_string("Date");
8129
9073
 
8130
9074
  if (rb_const_defined(rb_cObject, modid)) {
8131
- v = rb_const_get(rb_cObject, modid);
9075
+ v = rb_const_get(rb_cObject, modid);
8132
9076
  if (TYPE(v) != T_MODULE) {
8133
9077
  rb_raise(rb_eTypeError, "%s already defined", modname);
8134
9078
  }
@@ -8470,3 +9414,12 @@ Init_odbc()
8470
9414
  }
8471
9415
  #endif
8472
9416
  }
9417
+
9418
+ /*
9419
+ * Local Variables:
9420
+ * mode: c
9421
+ * c-basic-offset: 4
9422
+ * fill-column: 78
9423
+ * tab-width: 8
9424
+ * End:
9425
+ */