~ubuntu-branches/debian/sid/unixodbc/sid

« back to all changes in this revision

Viewing changes to DriverManager/SQLConnect.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2004-10-15 03:07:52 UTC
  • mfrom: (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20041015030752-dzw4vhxlgycz3woj
Tags: 2.2.4-11
Brown paper bag me: conflicts do not write themselves just because
you add a line to the changelog.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 *
28
28
 **********************************************************************
29
29
 *
30
 
 * $Id: SQLConnect.c,v 1.4 2001/12/19 15:55:53 lurcher Exp $
 
30
 * $Id: SQLConnect.c,v 1.20 2002/12/20 11:36:46 lurcher Exp $
31
31
 *
32
32
 * $Log: SQLConnect.c,v $
 
33
 * Revision 1.20  2002/12/20 11:36:46  lurcher
 
34
 *
 
35
 * Update DMEnvAttr code to allow setting in the odbcinst.ini entry
 
36
 *
 
37
 * Revision 1.19  2002/12/05 17:44:30  lurcher
 
38
 *
 
39
 * Display unknown return values in return logging
 
40
 *
 
41
 * Revision 1.18  2002/11/19 18:52:27  lurcher
 
42
 *
 
43
 * Alter the cursor lib to not require linking to the driver manager.
 
44
 *
 
45
 * Revision 1.17  2002/11/13 15:59:20  lurcher
 
46
 *
 
47
 * More VMS changes
 
48
 *
 
49
 * Revision 1.16  2002/08/27 08:49:02  lurcher
 
50
 *
 
51
 * New version number and fix for cursor lib loading
 
52
 *
 
53
 * Revision 1.15  2002/08/23 09:42:37  lurcher
 
54
 *
 
55
 * Fix some build warnings with casts, and a AIX linker mod, to include
 
56
 * deplib's on the link line, but not the libtool generated ones
 
57
 *
 
58
 * Revision 1.14  2002/08/12 13:17:52  lurcher
 
59
 *
 
60
 * Replicate the way the MS DM handles loading of driver libs, and allocating
 
61
 * handles in the driver. usage counting in the driver means that dlopen is
 
62
 * only called for the first use, and dlclose for the last. AllocHandle for
 
63
 * the driver environment is only called for the first time per driver
 
64
 * per application environment.
 
65
 *
 
66
 * Revision 1.13  2002/07/25 09:30:26  lurcher
 
67
 *
 
68
 * Additional unicode and iconv changes
 
69
 *
 
70
 * Revision 1.12  2002/07/24 08:49:51  lurcher
 
71
 *
 
72
 * Alter UNICODE support to use iconv for UNICODE-ANSI conversion
 
73
 *
 
74
 * Revision 1.11  2002/07/12 09:01:37  lurcher
 
75
 *
 
76
 * Fix problem, with SAPDB where if the connection specifies ODBC 2, the
 
77
 * don't make use of the ODBC 3 method of SQLGetFunctions
 
78
 *
 
79
 * Revision 1.10  2002/07/04 17:27:56  lurcher
 
80
 *
 
81
 * Small bug fixes
 
82
 *
 
83
 * Revision 1.8  2002/05/24 12:42:49  lurcher
 
84
 *
 
85
 * Alter NEWS and ChangeLog to match their correct usage
 
86
 * Additional UNICODE tweeks
 
87
 *
 
88
 * Revision 1.7  2002/03/26 09:35:46  lurcher
 
89
 *
 
90
 * Extend naming of cursor lib to work on non linux platforms
 
91
 * (it expected a .so)
 
92
 *
 
93
 * Revision 1.6  2002/02/21 18:44:09  lurcher
 
94
 *
 
95
 * Fix bug on 32 bit platforms without long long support
 
96
 * Add option to set environment variables from the ini file
 
97
 *
 
98
 * Revision 1.5  2002/01/21 18:00:51  lurcher
 
99
 *
 
100
 * Assorted fixed and changes, mainly UNICODE/bug fixes
 
101
 *
33
102
 * Revision 1.4  2001/12/19 15:55:53  lurcher
34
103
 *
35
104
 * Add option to disable calling of SQLGetFunctions in driver
347
416
 
348
417
#include "drivermanager.h"
349
418
 
350
 
static char const rcsid[]= "$RCSfile: SQLConnect.c,v $ $Revision: 1.4 $";
 
419
static char const rcsid[]= "$RCSfile: SQLConnect.c,v $ $Revision: 1.20 $";
351
420
 
352
 
#define CURSOR_LIB      "libodbccr.so"
 
421
#define CURSOR_LIB      "libodbccr"
 
422
#define CURSOR_LIB_VER  ".1"
353
423
 
354
424
/*
355
425
 * structure to contain the loaded lib entry points
514
584
}
515
585
 
516
586
/*
 
587
 * implement reference counting for driver libs
 
588
 */
 
589
 
 
590
struct lib_count
 
591
{
 
592
    char                *lib_name;
 
593
    int                 count;
 
594
    void                *handle;
 
595
    struct lib_count    *next;
 
596
};
 
597
 
 
598
/*
 
599
 * I hate statics, but there is little option here, there can be multiple envs
 
600
 * so I can't save it in them
 
601
 */
 
602
 
 
603
static struct lib_count *lib_list = NULL;
 
604
 
 
605
static void *odbc_dlopen( char *libname )
 
606
{
 
607
    void *hand;
 
608
    struct lib_count *list;
 
609
 
 
610
    mutex_lib_entry();
 
611
 
 
612
    /*
 
613
     * have we already got it ?
 
614
     */
 
615
 
 
616
    list = lib_list;
 
617
    while( list )
 
618
    {
 
619
        if ( strcmp( list -> lib_name, libname ) == 0 )
 
620
        {
 
621
            break;
 
622
        }
 
623
 
 
624
        list = list -> next;
 
625
    }
 
626
 
 
627
    if ( list )
 
628
    {
 
629
        list -> count ++;
 
630
        hand = list -> handle;
 
631
    }
 
632
    else
 
633
    {
 
634
        hand = lt_dlopen( libname );
 
635
 
 
636
        if ( hand )
 
637
        {
 
638
            list = malloc( sizeof( struct lib_count ));
 
639
            list -> next = lib_list;
 
640
            lib_list = list;
 
641
            list -> count = 1;
 
642
            list -> lib_name = strdup( libname );
 
643
            list -> handle = hand;
 
644
        }
 
645
    }
 
646
 
 
647
    mutex_lib_exit();
 
648
 
 
649
    return hand;
 
650
}
 
651
 
 
652
static odbc_dlclose( void *handle )
 
653
{
 
654
    struct lib_count *list, *prev;
 
655
 
 
656
    mutex_lib_entry();
 
657
 
 
658
    /*
 
659
     * look for list entry
 
660
     */
 
661
 
 
662
    list = lib_list;
 
663
    prev = NULL;
 
664
    while( list )
 
665
    {
 
666
        if ( list -> handle == handle )
 
667
        {
 
668
            break;
 
669
        }
 
670
 
 
671
        prev = list;
 
672
        list = list -> next;
 
673
    }
 
674
 
 
675
    /*
 
676
     * it should always be found, but you never know...
 
677
     */
 
678
 
 
679
    if ( list )
 
680
    {
 
681
        list -> count --;
 
682
 
 
683
        if ( list -> count < 1 )
 
684
        {
 
685
            free( list -> lib_name );
 
686
            lt_dlclose( list -> handle );
 
687
            if ( prev )
 
688
            {
 
689
                prev -> next = list -> next;
 
690
            }
 
691
            else
 
692
            {
 
693
                lib_list = list -> next;
 
694
            }
 
695
            free( list );
 
696
        }
 
697
    }
 
698
    else
 
699
    {
 
700
        lt_dlclose( handle );
 
701
    }
 
702
 
 
703
    mutex_lib_exit();
 
704
}
 
705
 
 
706
/*
517
707
 * open the library, extract the names, and do setup
518
708
 * before the actual connect.
519
709
 */
520
710
 
521
 
int __connect_part_one( DMHDBC connection, char *driver_lib, char *driver_name )
 
711
int __connect_part_one( DMHDBC connection, char *driver_lib, char *driver_name, int *warnings )
522
712
{
523
713
    int i;
524
714
    int ret;
529
719
    char disable_gf[ 50 ];
530
720
    char fake_string[ 50 ];
531
721
    int fake_unicode;
 
722
    struct env_lib_struct *env_lib_list, *env_lib_prev;
532
723
 
533
724
    /*
534
725
     * check to see if we want to alter the default threading level
535
726
     * before opening the lib
536
727
     */
537
728
 
 
729
    *warnings = FALSE;
 
730
 
538
731
    SQLGetPrivateProfileString( driver_name, "Threading", "3",
539
732
                                threading_string, sizeof( threading_string ), 
540
733
                "ODBCINST.INI" );
612
805
 
613
806
    fake_unicode = atoi( fake_string );
614
807
 
 
808
#ifdef HAVE_ICONV
 
809
    SQLGetPrivateProfileString( driver_name, "IconvEncoding", DEFAULT_ICONV_ENCODING,
 
810
                                connection->unicode_string, sizeof( connection->unicode_string ), 
 
811
                "ODBCINST.INI" );
 
812
#endif
 
813
 
 
814
    /*
 
815
     * initialize unicode
 
816
     */
 
817
 
 
818
    if ( !unicode_setup( connection ))
 
819
    {
 
820
        char txt[ 256 ];
 
821
 
 
822
        sprintf( txt, "Can't initiatate unicode conversion" );
 
823
 
 
824
        dm_log_write( __FILE__,
 
825
                __LINE__,
 
826
                LOG_INFO,
 
827
                LOG_INFO,
 
828
                txt );
 
829
 
 
830
        __post_internal_error( &connection -> error,
 
831
                ERROR_IM003, txt,
 
832
                connection -> environment -> requested_version );
 
833
 
 
834
        *warnings = TRUE;
 
835
    }
 
836
 
615
837
    /*
616
838
     * initialize libtool
617
839
     */
627
849
    connection -> functions = NULL;
628
850
    connection -> dl_handle = NULL;
629
851
 
630
 
    if ( !(connection -> dl_handle = lt_dlopen( driver_lib )))
 
852
    if ( !(connection -> dl_handle = odbc_dlopen( driver_lib )))
631
853
    {
632
854
        char txt[ 256 ];
633
855
 
641
863
                txt );
642
864
 
643
865
        __post_internal_error( &connection -> error,
644
 
                ERROR_IM003, txt,
 
866
                ERROR_01000, txt,
645
867
                connection -> environment -> requested_version );
 
868
 
646
869
        return 0;
647
870
    }
648
871
 
763
986
    }
764
987
 
765
988
    /*
766
 
     * allocate a env handle
 
989
     * check if this is the first time this driver has been loaded under this
 
990
     * lib, if not then reuse the env, else get the env from the driver
767
991
     */
768
992
 
769
 
    if ( CHECK_SQLALLOCHANDLE( connection ))
 
993
    mutex_lib_entry();
 
994
 
 
995
    env_lib_list = connection -> environment -> env_lib_list;
 
996
    env_lib_prev = NULL;
 
997
 
 
998
    while( env_lib_list )
770
999
    {
771
 
        ret = SQLALLOCHANDLE( connection,
772
 
                SQL_HANDLE_ENV,
773
 
                SQL_NULL_HENV,
774
 
                &connection -> driver_env,
775
 
                connection );
 
1000
        if ( strcmp( driver_lib, env_lib_list -> lib_name ) == 0 )
 
1001
        {
 
1002
            break;
 
1003
        }
 
1004
        env_lib_prev = env_lib_list;
 
1005
        env_lib_list = env_lib_list -> next;
776
1006
    }
777
 
    else if ( CHECK_SQLALLOCENV( connection ))
 
1007
 
 
1008
    if ( env_lib_list )
778
1009
    {
779
 
        ret = SQLALLOCENV( connection,
780
 
                &connection -> driver_env );
 
1010
        env_lib_list -> count ++;
 
1011
        connection -> driver_env = env_lib_list -> env_handle;
 
1012
        connection -> env_list_ent = env_lib_list;
 
1013
 
 
1014
        mutex_lib_exit();
781
1015
    }
782
1016
    else
783
1017
    {
784
 
        dm_log_write( __FILE__,
785
 
                __LINE__,
786
 
                LOG_INFO,
787
 
                LOG_INFO,
788
 
                "Error: IM004" );
789
 
 
790
 
        __post_internal_error( &connection -> error,
791
 
                ERROR_IM004, NULL,
792
 
                connection -> environment -> requested_version );
793
 
        return 0;
794
 
    }
795
 
 
796
 
    if ( ret )
797
 
    {
798
 
        dm_log_write( __FILE__,
799
 
                __LINE__,
800
 
                LOG_INFO,
801
 
                LOG_INFO,
802
 
                "Error: IM004" );
803
 
 
804
 
        __post_internal_error( &connection -> error,
805
 
                ERROR_IM004, NULL,
806
 
                connection -> environment -> requested_version );
807
 
        return 0;
808
 
    }
809
 
 
810
 
    /*
811
 
     * if it looks like a 3.x driver, try setting the interface type
812
 
     * to 3.x
813
 
     */
814
 
    if ( CHECK_SQLSETENVATTR( connection ))
815
 
    {
816
 
        ret = SQLSETENVATTR( connection,
817
 
                connection -> driver_env,
818
 
                SQL_ATTR_ODBC_VERSION,
819
 
                connection -> environment -> requested_version,
820
 
                0 );
 
1018
        env_lib_list = calloc( 1, sizeof( struct env_lib_struct ));
 
1019
 
 
1020
        env_lib_list -> count = 1;
 
1021
        env_lib_list -> next = connection -> environment -> env_lib_list;
 
1022
        env_lib_list -> lib_name = strdup( driver_lib );
 
1023
        connection -> env_list_ent = env_lib_list;
 
1024
 
 
1025
        connection -> environment -> env_lib_list = env_lib_list;
 
1026
 
 
1027
        mutex_lib_exit();
 
1028
 
 
1029
        __set_local_attributes( connection, SQL_HANDLE_ENV );
821
1030
 
822
1031
        /*
823
 
         * if it don't set then assume a 2.x driver
 
1032
         * allocate a env handle
824
1033
         */
825
1034
 
 
1035
        if ( CHECK_SQLALLOCHANDLE( connection ))
 
1036
        {
 
1037
            ret = SQLALLOCHANDLE( connection,
 
1038
                    SQL_HANDLE_ENV,
 
1039
                    SQL_NULL_HENV,
 
1040
                    &connection -> driver_env,
 
1041
                    connection );
 
1042
        }
 
1043
        else if ( CHECK_SQLALLOCENV( connection ))
 
1044
        {
 
1045
            ret = SQLALLOCENV( connection,
 
1046
                    &connection -> driver_env );
 
1047
        }
 
1048
        else
 
1049
        {
 
1050
            dm_log_write( __FILE__,
 
1051
                    __LINE__,
 
1052
                    LOG_INFO,
 
1053
                    LOG_INFO,
 
1054
                    "Error: IM004" );
 
1055
 
 
1056
            __post_internal_error( &connection -> error,
 
1057
                    ERROR_IM004, NULL,
 
1058
                    connection -> environment -> requested_version );
 
1059
 
 
1060
            if ( env_lib_list -> count == 1 )
 
1061
            {
 
1062
                mutex_lib_entry();
 
1063
 
 
1064
                if ( env_lib_prev )
 
1065
                {
 
1066
                    env_lib_prev -> next = env_lib_list -> next;
 
1067
                }
 
1068
                else
 
1069
                {
 
1070
                    connection -> environment -> env_lib_list = env_lib_list -> next;
 
1071
                }
 
1072
 
 
1073
                free( env_lib_list -> lib_name );
 
1074
                free( env_lib_list );
 
1075
 
 
1076
                mutex_lib_exit();
 
1077
            }
 
1078
            else
 
1079
            {
 
1080
                mutex_lib_entry();
 
1081
 
 
1082
                env_lib_list -> count --;
 
1083
 
 
1084
                mutex_lib_exit();
 
1085
            }
 
1086
            
 
1087
            return 0;
 
1088
        }
 
1089
 
 
1090
        env_lib_list -> env_handle = connection -> driver_env;
 
1091
 
826
1092
        if ( ret )
827
1093
        {
828
 
            connection -> driver_version = SQL_OV_ODBC2;
 
1094
            dm_log_write( __FILE__,
 
1095
                    __LINE__,
 
1096
                    LOG_INFO,
 
1097
                    LOG_INFO,
 
1098
                    "Error: IM004" );
 
1099
 
 
1100
            __post_internal_error( &connection -> error,
 
1101
                    ERROR_IM004, NULL,
 
1102
                    connection -> environment -> requested_version );
 
1103
 
 
1104
            if ( env_lib_list -> count == 1 )
 
1105
            {
 
1106
                mutex_lib_entry();
 
1107
 
 
1108
                if ( env_lib_prev )
 
1109
                {
 
1110
                    env_lib_prev -> next = env_lib_list -> next;
 
1111
                }
 
1112
                else
 
1113
                {
 
1114
                    connection -> environment -> env_lib_list = env_lib_list -> next;
 
1115
                }
 
1116
 
 
1117
                free( env_lib_list -> lib_name );
 
1118
                free( env_lib_list );
 
1119
 
 
1120
                mutex_lib_exit();
 
1121
            }
 
1122
            else
 
1123
            {
 
1124
                mutex_lib_entry();
 
1125
 
 
1126
                env_lib_list -> count --;
 
1127
 
 
1128
                mutex_lib_exit();
 
1129
            }
 
1130
 
 
1131
            return 0;
829
1132
        }
830
 
        else
 
1133
 
 
1134
        /*
 
1135
         * if it looks like a 3.x driver, try setting the interface type
 
1136
         * to 3.x
 
1137
         */
 
1138
        if ( CHECK_SQLSETENVATTR( connection ))
831
1139
        {
832
 
            if ( CHECK_SQLGETENVATTR( connection ))
833
 
            {
834
 
                SQLINTEGER actual_version;
835
 
 
836
 
                ret = SQLGETENVATTR( connection,
 
1140
            ret = SQLSETENVATTR( connection,
837
1141
                    connection -> driver_env,
838
1142
                    SQL_ATTR_ODBC_VERSION,
839
 
                    &actual_version,
840
 
                    0,
841
 
                    NULL );
842
 
 
843
 
                if ( !ret )
 
1143
                    connection -> environment -> requested_version,
 
1144
                    0 );
 
1145
 
 
1146
            /*
 
1147
             * if it don't set then assume a 2.x driver
 
1148
             */
 
1149
 
 
1150
            if ( ret )
 
1151
            {
 
1152
                connection -> driver_version = SQL_OV_ODBC2;
 
1153
            }
 
1154
            else
 
1155
            {
 
1156
                if ( CHECK_SQLGETENVATTR( connection ))
844
1157
                {
845
 
                    connection -> driver_version = actual_version;
 
1158
                    SQLINTEGER actual_version;
 
1159
 
 
1160
                    ret = SQLGETENVATTR( connection,
 
1161
                        connection -> driver_env,
 
1162
                        SQL_ATTR_ODBC_VERSION,
 
1163
                        &actual_version,
 
1164
                        0,
 
1165
                        NULL );
 
1166
 
 
1167
                    if ( !ret )
 
1168
                    {
 
1169
                        connection -> driver_version = actual_version;
 
1170
                    }
 
1171
                    else
 
1172
                    {
 
1173
                        connection -> driver_version =
 
1174
                            connection -> environment -> requested_version;
 
1175
                    }
846
1176
                }
847
1177
                else
848
1178
                {
850
1180
                        connection -> environment -> requested_version;
851
1181
                }
852
1182
            }
853
 
            else
854
 
            {
855
 
                connection -> driver_version =
856
 
                    connection -> environment -> requested_version;
857
 
            }
858
 
        }
859
 
    }
860
 
    else
861
 
    {
862
 
        connection -> driver_version = SQL_OV_ODBC2;
863
 
    }
864
 
 
865
 
    /*
866
 
     * set any env attributes
867
 
     */
868
 
 
869
 
    __set_attributes( connection, SQL_HANDLE_ENV );
 
1183
        }
 
1184
        else
 
1185
        {
 
1186
            connection -> driver_version = SQL_OV_ODBC2;
 
1187
        }
 
1188
 
 
1189
        /*
 
1190
         * set any env attributes
 
1191
         */
 
1192
        __set_attributes( connection, SQL_HANDLE_ENV );
 
1193
    }
870
1194
 
871
1195
    /*
872
1196
     * allocate a connection handle
873
1197
     */
 
1198
 
874
1199
    if ( connection -> driver_version == SQL_OV_ODBC3 )
875
1200
    {
876
1201
        if ( CHECK_SQLALLOCHANDLE( connection ))
1080
1405
        SQLUSMALLINT supported_funcs[ SQL_API_ODBC3_ALL_FUNCTIONS_SIZE ];
1081
1406
 
1082
1407
        /*
1083
 
         * try using fast version
 
1408
         * try using fast version, but only if the driver is set to ODBC 3, 
 
1409
         * some drivers (SAPDB) fail to return the correct values in this situation
1084
1410
         */
1085
1411
 
1086
 
        if ( CHECK_SQLALLOCHANDLE( connection ))
 
1412
        if ( CHECK_SQLALLOCHANDLE( connection ) && connection -> driver_version == SQL_OV_ODBC3 )
1087
1413
        {
1088
1414
            ret = SQLGETFUNCTIONS( connection,
1089
1415
                connection -> driver_dbc,
1209
1535
    {
1210
1536
        connection -> functions[ DM_SQLALLOCSTMT ].can_supply = 1;
1211
1537
    }
1212
 
 
1213
1538
    if ( !connection -> functions[ DM_SQLFREEENV ].func &&
1214
1539
            connection -> functions[ DM_SQLFREEHANDLE ].func )
1215
1540
    {
1218
1543
    if ( !connection -> functions[ DM_SQLFREECONNECT ].func &&
1219
1544
            connection -> functions[ DM_SQLFREEHANDLE ].func )
1220
1545
    {
1221
 
        connection -> functions[ DM_SQLALLOCCONNECT ].can_supply = 1;
 
1546
        connection -> functions[ DM_SQLFREECONNECT ].can_supply = 1;
1222
1547
    }
1223
1548
    if ( !connection -> functions[ DM_SQLGETDIAGREC ].func &&
1224
1549
            connection -> functions[ DM_SQLERROR ].func )
1501
1826
 
1502
1827
    if ( use_cursor )
1503
1828
    {
1504
 
        int (*cl_connect)(void*);
1505
 
 
1506
 
        if ( !(connection -> cl_handle = lt_dlopen( CURSOR_LIB )))
 
1829
        char name[ 128 ];
 
1830
        int (*cl_connect)(void*, struct driver_helper_funcs*);
 
1831
        struct driver_helper_funcs dh;
 
1832
 
 
1833
        sprintf( name, "%s%s%s", CURSOR_LIB, SHLIBEXT, CURSOR_LIB_VER );
 
1834
 
 
1835
        if ( !(connection -> cl_handle = odbc_dlopen( name )))
1507
1836
        {
1508
 
            char txt[ 256 ];
1509
 
 
1510
 
            sprintf( txt, "Can't open cursor lib '%s' : %s", 
1511
 
                CURSOR_LIB, lt_dlerror());
1512
 
 
1513
 
            dm_log_write( __FILE__,
1514
 
                    __LINE__,
1515
 
                    LOG_INFO,
1516
 
                    LOG_INFO,
1517
 
                    txt  );
1518
 
 
1519
 
            __post_internal_error( &connection -> error,
1520
 
                    ERROR_01000, txt,
1521
 
                    connection -> environment -> requested_version );
1522
 
 
1523
 
            return 0;
 
1837
            /*
 
1838
             * try again
 
1839
             */
 
1840
 
 
1841
#ifdef __VMS
 
1842
            sprintf( name, "%s:%s%s%s", SYSTEM_LIB_PATH, CURSOR_LIB, SHLIBEXT, CURSOR_LIB_VER );
 
1843
#else
 
1844
            sprintf( name, "%s/%s%s%s", SYSTEM_LIB_PATH, CURSOR_LIB, SHLIBEXT, CURSOR_LIB_VER );
 
1845
#endif
 
1846
            if ( !(connection -> cl_handle = odbc_dlopen( name )))
 
1847
            {
 
1848
                char txt[ 256 ];
 
1849
 
 
1850
                sprintf( txt, "Can't open cursor lib '%s' : %s", 
 
1851
                    CURSOR_LIB, lt_dlerror());
 
1852
 
 
1853
                dm_log_write( __FILE__,
 
1854
                        __LINE__,
 
1855
                        LOG_INFO,
 
1856
                        LOG_INFO,
 
1857
                        txt  );
 
1858
 
 
1859
                __post_internal_error( &connection -> error,
 
1860
                        ERROR_01000, txt,
 
1861
                        connection -> environment -> requested_version );
 
1862
 
 
1863
                return 0;
 
1864
            }
1524
1865
        }
1525
1866
 
1526
 
        if ( !( cl_connect = (int(*)(void*))lt_dlsym( connection -> cl_handle,
 
1867
        if ( !( cl_connect = (int(*)(void*, struct driver_helper_funcs* ))lt_dlsym( connection -> cl_handle,
1527
1868
                        "CLConnect" )))
1528
1869
        {
1529
1870
            dm_log_write( __FILE__,
1536
1877
                    ERROR_01000, "Unable to load cursor library",
1537
1878
                    connection -> environment -> requested_version );
1538
1879
 
1539
 
            lt_dlclose( connection -> cl_handle );
 
1880
            odbc_dlclose( connection -> cl_handle );
1540
1881
            connection -> cl_handle = NULL;
1541
1882
 
1542
1883
            return 0;
1543
1884
        }
1544
 
        if ( cl_connect( connection ) != SQL_SUCCESS )
 
1885
 
 
1886
        /*
 
1887
         * setup helper functions
 
1888
         */
 
1889
 
 
1890
        dh.__post_internal_error_ex = __post_internal_error_ex;
 
1891
        dh.__post_internal_error = __post_internal_error;
 
1892
        dh.dm_log_write = dm_log_write;
 
1893
 
 
1894
        if ( cl_connect( connection, &dh ) != SQL_SUCCESS )
1545
1895
        {
1546
 
            lt_dlclose( connection -> cl_handle );
 
1896
            odbc_dlclose( connection -> cl_handle );
1547
1897
            connection -> cl_handle = NULL;
1548
1898
            return 0;
1549
1899
        }
1563
1913
void __disconnect_part_one( DMHDBC connection )
1564
1914
{
1565
1915
    int ret;
 
1916
    struct env_lib_struct *env_lib_list, *env_lib_prev;
1566
1917
 
1567
1918
    /*
1568
1919
     * try a version 3 disconnect first on the connection
1602
1953
    connection -> driver_dbc = (SQLHANDLE)NULL;
1603
1954
 
1604
1955
    /*
1605
 
     * now disconnect the environment
 
1956
     * now disconnect the environment, if its the last usage on the connection
1606
1957
     */
1607
1958
 
1608
1959
    if ( connection -> driver_env )
1609
1960
    {
1610
 
        if ( connection -> driver_version == SQL_OV_ODBC3 )
1611
 
        {
1612
 
            if ( CHECK_SQLFREEHANDLE( connection ))
1613
 
            {
1614
 
                ret = SQLFREEHANDLE( connection,
1615
 
                        SQL_HANDLE_ENV,
 
1961
        env_lib_prev = env_lib_list = NULL;
 
1962
 
 
1963
        if ( connection -> env_list_ent )
 
1964
        {
 
1965
            env_lib_list = connection -> environment -> env_lib_list;
 
1966
            while( env_lib_list )
 
1967
            {
 
1968
                if ( env_lib_list == connection -> env_list_ent )
 
1969
                {
 
1970
                    break;
 
1971
                }
 
1972
                env_lib_prev = env_lib_list;
 
1973
                env_lib_list = env_lib_list -> next;
 
1974
            }
 
1975
        }
 
1976
 
 
1977
        if ( env_lib_list && env_lib_list -> count > 1 )
 
1978
        {
 
1979
            mutex_lib_entry();
 
1980
            env_lib_list -> count --;
 
1981
            mutex_lib_exit();
 
1982
        }
 
1983
        else
 
1984
        {
 
1985
            if ( connection -> driver_version == SQL_OV_ODBC3 )
 
1986
            {
 
1987
                if ( CHECK_SQLFREEHANDLE( connection ))
 
1988
                {
 
1989
                    ret = SQLFREEHANDLE( connection,
 
1990
                            SQL_HANDLE_ENV,
 
1991
                            connection -> driver_env );
 
1992
 
 
1993
                    if ( !ret )
 
1994
                        connection -> driver_env = (SQLHANDLE)NULL;
 
1995
                }
 
1996
            }
 
1997
 
 
1998
            /*
 
1999
             * is it still open ?
 
2000
             */
 
2001
 
 
2002
            if ( CHECK_SQLFREEENV( connection ))
 
2003
            {
 
2004
                SQLFREEENV( connection,
1616
2005
                        connection -> driver_env );
1617
 
 
1618
 
                if ( !ret )
1619
 
                    connection -> driver_env = (SQLHANDLE)NULL;
1620
 
            }
1621
 
        }
1622
 
 
1623
 
        /*
1624
 
         * is it still open ?
1625
 
         */
1626
 
 
1627
 
        if ( CHECK_SQLFREEENV( connection ))
1628
 
        {
1629
 
            SQLFREEENV( connection,
1630
 
                    connection -> driver_env );
1631
 
        }
1632
 
        else
1633
 
        {
 
2006
            }
 
2007
            else
 
2008
            {
 
2009
                /*
 
2010
                 * not a lot we can do here
 
2011
                 */
 
2012
            }
 
2013
 
1634
2014
            /*
1635
 
             * not a lot we can do here
 
2015
             * remove the entry
1636
2016
             */
 
2017
 
 
2018
            mutex_lib_entry();
 
2019
 
 
2020
            if ( env_lib_prev )
 
2021
            {
 
2022
                env_lib_prev -> next = env_lib_list -> next;
 
2023
            }
 
2024
            else
 
2025
            {
 
2026
                connection -> environment -> env_lib_list = env_lib_list -> next;
 
2027
            }
 
2028
 
 
2029
            free( env_lib_list -> lib_name );
 
2030
            free( env_lib_list );
 
2031
 
 
2032
            mutex_lib_exit();
1637
2033
        }
1638
2034
    }
 
2035
 
1639
2036
    connection -> driver_env = (SQLHANDLE)NULL;
1640
2037
 
1641
2038
    /*
1644
2041
 
1645
2042
    if ( connection -> cl_handle )
1646
2043
    {
1647
 
        lt_dlclose( connection -> cl_handle );
 
2044
        odbc_dlclose( connection -> cl_handle );
1648
2045
        connection -> cl_handle = NULL;
1649
2046
    }
1650
2047
 
1661
2058
                connection -> fini_func.func();
1662
2059
            }
1663
2060
 
1664
 
            lt_dlclose( connection -> dl_handle );
 
2061
            odbc_dlclose( connection -> dl_handle );
1665
2062
        }
1666
2063
        connection -> dl_handle = NULL;
1667
2064
    }
1687
2084
}
1688
2085
 
1689
2086
/*
 
2087
 * normal disconnect
 
2088
 */
 
2089
 
 
2090
void __disconnect_part_three( DMHDBC connection )
 
2091
{
 
2092
    struct env_lib_struct *env_lib_list, *env_lib_prev;
 
2093
 
 
2094
    if ( connection -> driver_version == SQL_OV_ODBC3 )
 
2095
    {
 
2096
        if ( CHECK_SQLFREEHANDLE( connection ))
 
2097
        {
 
2098
            SQLFREEHANDLE( connection,
 
2099
                    SQL_HANDLE_DBC,
 
2100
                    connection -> driver_dbc );
 
2101
        }
 
2102
        else if ( CHECK_SQLFREECONNECT( connection ))
 
2103
        {
 
2104
            SQLFREECONNECT( connection,
 
2105
                    connection -> driver_dbc );
 
2106
        }
 
2107
    }
 
2108
    else
 
2109
    {
 
2110
        if ( CHECK_SQLFREECONNECT( connection ))
 
2111
        {
 
2112
            SQLFREECONNECT( connection,
 
2113
                    connection -> driver_dbc );
 
2114
        }
 
2115
        else if ( CHECK_SQLFREEHANDLE( connection ))
 
2116
        {
 
2117
            SQLFREEHANDLE( connection,
 
2118
                    SQL_HANDLE_DBC,
 
2119
                    connection -> driver_dbc );
 
2120
        }
 
2121
    }
 
2122
 
 
2123
    connection -> driver_dbc = (SQLHANDLE)NULL;
 
2124
 
 
2125
    /*
 
2126
     * now disconnect the environment, if its the last usage on the connection
 
2127
     */
 
2128
 
 
2129
    env_lib_prev = env_lib_list = NULL;
 
2130
 
 
2131
    if ( connection -> env_list_ent )
 
2132
    {
 
2133
        env_lib_list = connection -> environment -> env_lib_list;
 
2134
        while( env_lib_list )
 
2135
        {
 
2136
            if ( env_lib_list == connection -> env_list_ent )
 
2137
            {
 
2138
                break;
 
2139
            }
 
2140
            env_lib_prev = env_lib_list;
 
2141
            env_lib_list = env_lib_list -> next;
 
2142
        }
 
2143
    }
 
2144
 
 
2145
    if ( env_lib_list && env_lib_list -> count > 1 )
 
2146
    {
 
2147
        mutex_lib_entry();
 
2148
        env_lib_list -> count --;
 
2149
        mutex_lib_exit();
 
2150
    }
 
2151
    else
 
2152
    {
 
2153
        if ( connection -> driver_version == SQL_OV_ODBC3 )
 
2154
        {
 
2155
            if ( CHECK_SQLFREEHANDLE( connection ))
 
2156
            {
 
2157
                SQLFREEHANDLE( connection,
 
2158
                        SQL_HANDLE_ENV,
 
2159
                        connection -> driver_env );
 
2160
            }
 
2161
            else if ( CHECK_SQLFREEENV( connection ))
 
2162
            {
 
2163
                SQLFREEENV( connection,
 
2164
                        connection -> driver_env );
 
2165
            }
 
2166
        }
 
2167
        else
 
2168
        {
 
2169
            if ( CHECK_SQLFREEENV( connection ))
 
2170
            {
 
2171
                SQLFREEENV( connection,
 
2172
                        connection -> driver_env );
 
2173
            }
 
2174
            else if ( CHECK_SQLFREEHANDLE( connection ))
 
2175
            {
 
2176
                SQLFREEHANDLE( connection,
 
2177
                        SQL_HANDLE_ENV,
 
2178
                        connection -> driver_env );
 
2179
            }
 
2180
        }
 
2181
 
 
2182
        /*
 
2183
         * remove the entry
 
2184
         */
 
2185
 
 
2186
        mutex_lib_entry();
 
2187
 
 
2188
        if ( env_lib_prev )
 
2189
        {
 
2190
            env_lib_prev -> next = env_lib_list -> next;
 
2191
        }
 
2192
        else
 
2193
        {
 
2194
            connection -> environment -> env_lib_list = env_lib_list -> next;
 
2195
        }
 
2196
 
 
2197
        free( env_lib_list -> lib_name );
 
2198
        free( env_lib_list );
 
2199
 
 
2200
        mutex_lib_exit();
 
2201
    }
 
2202
 
 
2203
    connection -> driver_env = (SQLHANDLE)NULL;
 
2204
 
 
2205
    /*
 
2206
     * unload the lib
 
2207
     */
 
2208
 
 
2209
    if ( connection -> cl_handle )
 
2210
    {
 
2211
        odbc_dlclose( connection -> cl_handle );
 
2212
        connection -> cl_handle = NULL;
 
2213
    }
 
2214
 
 
2215
    if ( connection -> dl_handle )
 
2216
    {
 
2217
        /*
 
2218
         * this is safe, because the dlopen function will reuse the handle if we 
 
2219
         * open the same lib again
 
2220
         */
 
2221
        if ( !connection -> dont_dlclose )
 
2222
        {
 
2223
            if ( connection -> fini_func.func )
 
2224
            {
 
2225
                connection -> fini_func.func();
 
2226
            }
 
2227
 
 
2228
            odbc_dlclose( connection -> dl_handle );
 
2229
        }
 
2230
        connection -> dl_handle = NULL;
 
2231
    }
 
2232
 
 
2233
    /*
 
2234
     * shutdown unicode
 
2235
     */
 
2236
 
 
2237
    unicode_shutdown( connection );
 
2238
 
 
2239
    /*
 
2240
     * free some memory
 
2241
     */
 
2242
 
 
2243
    if ( connection -> functions )
 
2244
    {
 
2245
        free( connection -> functions );
 
2246
        connection -> functions = NULL;
 
2247
    }
 
2248
    connection -> state = STATE_C2;
 
2249
 
 
2250
    /*
 
2251
     * now clean up any statements that are left about
 
2252
     */
 
2253
 
 
2254
    __clean_stmt_from_dbc( connection );
 
2255
    __clean_desc_from_dbc( connection );
 
2256
}
 
2257
 
 
2258
/*
1690
2259
 * interface for SQLGetFunctions
1691
2260
 */
1692
2261
 
1848
2417
 
1849
2418
        if ( ptr -> connection.cl_handle )
1850
2419
        {
1851
 
            lt_dlclose( ptr -> connection.cl_handle );
 
2420
            odbc_dlclose( ptr -> connection.cl_handle );
1852
2421
            ptr -> connection.cl_handle = NULL;
1853
2422
        }
1854
2423
 
1869
2438
                    ptr -> connection.fini_func.func();
1870
2439
                }
1871
2440
 
1872
 
                lt_dlclose( ptr -> connection.dl_handle );
 
2441
                odbc_dlclose( ptr -> connection.dl_handle );
1873
2442
            }
1874
2443
            ptr -> connection.dl_handle = NULL;
1875
2444
        }
2304
2873
    mutex_pool_exit();
2305
2874
}
2306
2875
 
2307
 
void __handle_attr_extensions( DMHDBC connection, char *dsn )
 
2876
void __handle_attr_extensions( DMHDBC connection, char *dsn, char *driver_name )
2308
2877
{
2309
2878
    char txt[ 1024 ];
2310
2879
 
2311
 
    SQLGetPrivateProfileString( dsn, "DMEnvAttr", "",
2312
 
                                txt, sizeof( txt ), 
2313
 
                "ODBC.INI" );
2314
 
 
2315
 
    if ( strlen( txt ))
2316
 
    {
2317
 
        __parse_attribute_string( &connection -> env_attribute,
2318
 
            txt, strlen( txt ));
2319
 
    }
2320
 
 
2321
 
    SQLGetPrivateProfileString( dsn, "DMConnAttr", "",
2322
 
                                txt, sizeof( txt ), 
2323
 
                "ODBC.INI" );
2324
 
 
2325
 
    if ( strlen( txt ))
2326
 
    {
2327
 
        __parse_attribute_string( &connection -> dbc_attribute,
2328
 
            txt, strlen( txt ));
2329
 
    }
2330
 
 
2331
 
    SQLGetPrivateProfileString( dsn, "DMStmtAttr", "",
2332
 
                                txt, sizeof( txt ), 
2333
 
                "ODBC.INI" );
2334
 
 
2335
 
    if ( strlen( txt ))
2336
 
    {
2337
 
        __parse_attribute_string( &connection -> stmt_attribute,
2338
 
            txt, strlen( txt ));
 
2880
    if ( dsn && strlen( dsn ))
 
2881
    {
 
2882
        SQLGetPrivateProfileString( dsn, "DMEnvAttr", "",
 
2883
                    txt, sizeof( txt ), 
 
2884
                    "ODBC.INI" );
 
2885
 
 
2886
        if ( strlen( txt ))
 
2887
        {
 
2888
            __parse_attribute_string( &connection -> env_attribute,
 
2889
                txt, strlen( txt ));
 
2890
        }
 
2891
 
 
2892
        SQLGetPrivateProfileString( dsn, "DMConnAttr", "",
 
2893
                    txt, sizeof( txt ), 
 
2894
                    "ODBC.INI" );
 
2895
 
 
2896
        if ( strlen( txt ))
 
2897
        {
 
2898
            __parse_attribute_string( &connection -> dbc_attribute,
 
2899
                txt, strlen( txt ));
 
2900
        }
 
2901
 
 
2902
        SQLGetPrivateProfileString( dsn, "DMStmtAttr", "",
 
2903
                    txt, sizeof( txt ), 
 
2904
                    "ODBC.INI" );
 
2905
 
 
2906
        if ( strlen( txt ))
 
2907
        {
 
2908
            __parse_attribute_string( &connection -> stmt_attribute,
 
2909
                txt, strlen( txt ));
 
2910
        }
 
2911
    }
 
2912
 
 
2913
    if ( driver_name && strlen( driver_name ))
 
2914
    {
 
2915
        SQLGetPrivateProfileString( driver_name, "DMEnvAttr", "",
 
2916
                          txt, sizeof( txt ), 
 
2917
                          "ODBCINST.INI" );
 
2918
     
 
2919
        if ( strlen( txt ))
 
2920
        {
 
2921
            __parse_attribute_string( &connection -> env_attribute,
 
2922
                         txt, strlen( txt ));
 
2923
        }
2339
2924
    }
2340
2925
}
2341
2926
 
2353
2938
    char lib_name[ INI_MAX_PROPERTY_VALUE + 1 ];
2354
2939
    char driver_name[ INI_MAX_PROPERTY_VALUE + 1 ];
2355
2940
    SQLCHAR s1[ 100 + LOG_MESSAGE_LEN ], s2[ 100 + LOG_MESSAGE_LEN ], s3[ 100 + LOG_MESSAGE_LEN ];
 
2941
    int warnings;
2356
2942
 
2357
2943
    /*
2358
2944
     * check connection
2518
3104
        {
2519
3105
            sprintf( connection -> msg,
2520
3106
                    "\n\t\tExit:[%s]",
2521
 
                        __get_return_status( ret_from_connect ));
 
3107
                        __get_return_status( ret_from_connect, s1 ));
2522
3108
 
2523
3109
            dm_log_write( __FILE__,
2524
3110
                        __LINE__,
2622
3208
     * do we have any Environment, Connection, or Statement attributes set in the ini ?
2623
3209
     */
2624
3210
 
2625
 
    __handle_attr_extensions( connection, dsn );
 
3211
    __handle_attr_extensions( connection, dsn, driver_name );
2626
3212
 
2627
3213
    /*
2628
3214
     * if necessary change the threading level
2629
3215
     */
2630
3216
 
2631
 
    if ( !__connect_part_one( connection, lib_name, driver_name ))
 
3217
    if ( !__connect_part_one( connection, lib_name, driver_name, &warnings ))
2632
3218
    {
2633
3219
        thread_release( SQL_HANDLE_DBC, connection );
2634
3220
        return function_return( connection, SQL_ERROR );
2655
3241
 
2656
3242
    if ( CHECK_SQLCONNECT( connection ))
2657
3243
    {
 
3244
        /*
 
3245
        if ( CHECK_SQLSETCONNECTATTR( connection ))
 
3246
        {
 
3247
            int lret;
 
3248
                
 
3249
            lret = SQLSETCONNECTATTR( connection,
 
3250
                    connection -> driver_dbc,
 
3251
                    SQL_ATTR_ANSI_APP,
 
3252
                    SQL_AA_TRUE,
 
3253
                    0 );
 
3254
        }
 
3255
        */
 
3256
 
2658
3257
        ret_from_connect = SQLCONNECT( connection,
2659
3258
                connection -> driver_dbc,
2660
3259
                dsn, SQL_NTS,
2694
3293
                        __post_internal_error_ex( &connection -> error,
2695
3294
                                sqlstate,
2696
3295
                                native_error,
2697
 
                                message_text );
 
3296
                                message_text,
 
3297
                                SUBCLASS_ODBC, SUBCLASS_ODBC );
2698
3298
 
2699
3299
                        sprintf( connection -> msg, "\t\tDIAG [%s] %s",
2700
3300
                                sqlstate, message_text );
2726
3326
                        __post_internal_error_ex( &connection -> error,
2727
3327
                                sqlstate,
2728
3328
                                native_error,
2729
 
                                message_text );
 
3329
                                message_text,
 
3330
                                SUBCLASS_ODBC, SUBCLASS_ODBC );
2730
3331
 
2731
3332
                        sprintf( connection -> msg, "\t\tDIAG [%s] %s",
2732
3333
                            sqlstate, message_text );
2750
3351
 
2751
3352
            sprintf( connection -> msg,
2752
3353
                    "\n\t\tExit:[%s]",
2753
 
                        __get_return_status( ret_from_connect ));
 
3354
                        __get_return_status( ret_from_connect, s1 ));
2754
3355
 
2755
3356
            dm_log_write( __FILE__,
2756
3357
                    __LINE__,
2767
3368
    {
2768
3369
        SQLWCHAR * uc_dsn, *uc_user, *uc_auth;
2769
3370
 
2770
 
        uc_dsn = ansi_to_unicode((SQLCHAR*) dsn, SQL_NTS );
2771
 
        uc_user = ansi_to_unicode( user_name, name_length2 );
2772
 
        uc_auth = ansi_to_unicode( authentication, name_length3 );
 
3371
        uc_dsn = ansi_to_unicode_alloc((SQLCHAR*) dsn, SQL_NTS, connection );
 
3372
        uc_user = ansi_to_unicode_alloc( user_name, name_length2, connection );
 
3373
        uc_auth = ansi_to_unicode_alloc( authentication, name_length3, connection );
 
3374
 
 
3375
        if ( CHECK_SQLSETCONNECTATTR( connection ))
 
3376
        {
 
3377
            int lret;
 
3378
                
 
3379
            lret = SQLSETCONNECTATTR( connection,
 
3380
                    connection -> driver_dbc,
 
3381
                    SQL_ATTR_ANSI_APP,
 
3382
                    SQL_AA_FALSE,
 
3383
                    0 );
 
3384
        }
2773
3385
 
2774
3386
        ret_from_connect = SQLCONNECTW( connection,
2775
3387
                connection -> driver_dbc,
2794
3406
 
2795
3407
            /*
2796
3408
             * get the errors from the driver before
2797
 
             * loseing the connection 
 
3409
             * looseing the connection 
2798
3410
             */
2799
3411
 
2800
3412
            if ( CHECK_SQLERRORW( connection ))
2814
3426
 
2815
3427
                    if ( SQL_SUCCEEDED( ret ))
2816
3428
                    {
 
3429
                        SQLCHAR *as1, *as2; 
 
3430
 
2817
3431
                        __post_internal_error_ex_w( &connection -> error,
2818
3432
                                sqlstate,
2819
3433
                                native_error,
2820
 
                                message_text );
 
3434
                                message_text,
 
3435
                                SUBCLASS_ODBC, SUBCLASS_ODBC );
2821
3436
 
2822
 
                        unicode_to_ansi( sqlstate, SQL_NTS );
2823
 
                        unicode_to_ansi( message_text, SQL_NTS );
 
3437
                        as1 = (SQLCHAR *) unicode_to_ansi_alloc( sqlstate, SQL_NTS, connection );
 
3438
                        as2 = (SQLCHAR *) unicode_to_ansi_alloc( message_text, SQL_NTS, connection );
2824
3439
 
2825
3440
                        sprintf( connection -> msg, "\t\tDIAG [%s] %s",
2826
 
                                sqlstate, message_text );
 
3441
                                as1, as2 );
 
3442
 
 
3443
                        if ( as1 ) free( as1 );
 
3444
                        if ( as2 ) free( as2 );
2827
3445
 
2828
3446
                        dm_log_write_diag( connection -> msg );
2829
3447
                    }
2836
3454
 
2837
3455
                do
2838
3456
                {
 
3457
 
2839
3458
                    ret = SQLGETDIAGRECW( connection,
2840
3459
                            SQL_HANDLE_DBC,
2841
3460
                            connection -> driver_dbc,
2848
3467
 
2849
3468
                    if ( SQL_SUCCEEDED( ret ))
2850
3469
                    {
 
3470
                        SQLCHAR *as1, *as2; 
 
3471
 
2851
3472
                        __post_internal_error_ex_w( &connection -> error,
2852
3473
                                sqlstate,
2853
3474
                                native_error,
2854
 
                                message_text );
 
3475
                                message_text,
 
3476
                                SUBCLASS_ODBC, SUBCLASS_ODBC );
2855
3477
 
2856
 
                        unicode_to_ansi( sqlstate, SQL_NTS );
2857
 
                        unicode_to_ansi( message_text, SQL_NTS );
 
3478
                        as1 = (SQLCHAR *) unicode_to_ansi_alloc( sqlstate, SQL_NTS, connection );
 
3479
                        as2 = (SQLCHAR *) unicode_to_ansi_alloc( message_text, SQL_NTS, connection );
2858
3480
 
2859
3481
                        sprintf( connection -> msg, "\t\tDIAG [%s] %s",
2860
 
                                sqlstate, message_text );
 
3482
                                as1, as2 );
 
3483
 
 
3484
                        if ( as1 ) free( as1 );
 
3485
                        if ( as2 ) free( as2 );
2861
3486
 
2862
3487
                        dm_log_write_diag( connection -> msg );
2863
3488
                    }
2878
3503
 
2879
3504
            sprintf( connection -> msg,
2880
3505
                    "\n\t\tExit:[%s]",
2881
 
                        __get_return_status( ret_from_connect ));
 
3506
                        __get_return_status( ret_from_connect, s1 ));
2882
3507
 
2883
3508
            dm_log_write( __FILE__,
2884
3509
                    __LINE__,
2933
3558
    {
2934
3559
        sprintf( connection -> msg,
2935
3560
                "\n\t\tExit:[%s]",
2936
 
                    __get_return_status( ret_from_connect ));
 
3561
                    __get_return_status( ret_from_connect, s1 ));
2937
3562
 
2938
3563
        dm_log_write( __FILE__,
2939
3564
                __LINE__,
2944
3569
 
2945
3570
    thread_release( SQL_HANDLE_DBC, connection );
2946
3571
 
 
3572
    if ( warnings && ret_from_connect == SQL_SUCCESS )
 
3573
    {
 
3574
        ret_from_connect = SQL_SUCCESS_WITH_INFO;
 
3575
    }
 
3576
 
2947
3577
    return function_return( connection, ret_from_connect );
2948
3578
}