~mysql/myodbc/3.51

« back to all changes in this revision

Viewing changes to util/MYODBCUtilReadConnectStr.c

  • Committer: lawrin
  • Date: 2012-02-01 21:57:31 UTC
  • Revision ID: lawrenty.novitsky@oracle.com-20120201215731-05247vniwixy2yd9
Patch for the Bug#13647492. Driver does not understand individual names of options under which they are saved by the setup lib.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 
1
/* Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
2
2
 
3
3
   The MySQL Connector/ODBC is licensed under the terms of the GPLv2
4
4
   <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
20
20
   with this program; if not, write to the Free Software Foundation, Inc.,
21
21
   51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA */
22
22
 
 
23
#include "installer.h"
23
24
#include "MYODBCUtil.h"
24
25
 
 
26
 
 
27
static const char* OPTION_NAMES[]= { "FOUND_ROWS",        /*FLAG_FOUND_ROWS*/
 
28
                                     "BIG_PACKETS",       /*FLAG_BIG_PACKETS*/
 
29
                                     "NO_PROMPT",         /*FLAG_NO_PROMPT*/
 
30
                                                                                                                               "DYNAMIC_CURSOR",    /*FLAG_DYNAMIC_CURSOR*/
 
31
                                                                                                                               "NO_SCHEMA",         /*FLAG_NO_SCHEMA*/
 
32
                                                                                                                               "NO_DEFAULT_CURSOR",
 
33
                                                                                                                               "NO_LOCALE",
 
34
                                                                                                                               "PAD_SPACE",
 
35
                                                                                                                               "FULL_COLUMN_NAMES",
 
36
                                                                                                                               "COMPRESSED_PROTO",
 
37
                                                                                                                               "IGNORE_SPACE",
 
38
                                                                                                                               "NO_BIGINT",
 
39
                                                                                                                               "NO_CATALOG",
 
40
                                                                                                                               "USE_MYCNF",
 
41
                                                                                                                               "SAFE",
 
42
                                                                                                                               "NO_TRANSACTIONS",
 
43
                                                                                                                               "LOG_QUERY",
 
44
                                                                                                                               "NO_CACHE",
 
45
                                                                                                                               "FORWARD_CURSOR",
 
46
                                                                                                                               "AUTO_RECONNECT",
 
47
                                                                                                                               "AUTO_IS_NULL",
 
48
                                                                                                                               "ZERO_DATE_TO_MIN",
 
49
                                                                                                                               "MIN_DATE_TO_ZERO",
 
50
                                                                                                                               "MULTI_STATEMENTS",
 
51
                                                                                                                               "COLUMN_SIZE_S32",
 
52
                                                                                                                               "NO_BINARY_RESULT",
 
53
                                     "NO_I_S"               /*FLAG_NO_INFORMATION_SCHEMA*/
 
54
                                    };
 
55
 
 
56
static const ulong OPTION_FLAGS[]= { FLAG_FOUND_ROWS,
 
57
                                     FLAG_BIG_PACKETS,
 
58
                                     FLAG_NO_PROMPT,
 
59
                                     FLAG_DYNAMIC_CURSOR,
 
60
                                     FLAG_NO_SCHEMA,
 
61
                                     FLAG_NO_DEFAULT_CURSOR,
 
62
                                     FLAG_NO_LOCALE,
 
63
                                     FLAG_PAD_SPACE,
 
64
                                     FLAG_FULL_COLUMN_NAMES,
 
65
                                     FLAG_COMPRESSED_PROTO,
 
66
                                     FLAG_IGNORE_SPACE,
 
67
                                     FLAG_NO_BIGINT,
 
68
                                                                                                                               FLAG_NO_CATALOG,
 
69
                                     FLAG_USE_MYCNF,
 
70
                                                                                                                               FLAG_SAFE,
 
71
                                                                                                                               FLAG_NO_TRANSACTIONS,
 
72
                                                                                                                               FLAG_LOG_QUERY,
 
73
                                                                                                                               FLAG_NO_CACHE,
 
74
                                                                                                                               FLAG_FORWARD_CURSOR,
 
75
                                                                                                                               FLAG_AUTO_RECONNECT,
 
76
                                                                                                                               FLAG_AUTO_IS_NULL,
 
77
                                                                                                                               FLAG_ZERO_DATE_TO_MIN,
 
78
                                                                                                                               FLAG_MIN_DATE_TO_ZERO,
 
79
                                                                                                                               FLAG_MULTI_STATEMENTS,
 
80
                                                                                                                               FLAG_COLUMN_SIZE_S32,
 
81
                                                                                                                               FLAG_NO_BINARY_RESULT,
 
82
                                     FLAG_NO_INFORMATION_SCHEMA
 
83
 
 
84
};
 
85
 
 
86
ulong NamedAttributeToFlag(const char* name)
 
87
{
 
88
  int i;
 
89
 
 
90
  for (i= 0; i < sizeof(OPTION_NAMES)/sizeof(char*);++i)
 
91
  {
 
92
    if (strcasecmp( name, OPTION_NAMES[i] ) == 0)
 
93
    {
 
94
      return OPTION_FLAGS[i];
 
95
    }
 
96
  }
 
97
 
 
98
  return 0;
 
99
}
 
100
 
 
101
 
25
102
/*!
26
103
    \internal
27
104
    \brief      Parse a string of "name=value" pairs.
35
112
*/  
36
113
BOOL MYODBCUtilReadConnectStr( MYODBCUTIL_DATASOURCE *pDataSource, LPCSTR pszStr )
37
114
{
38
 
    MYODBCUTIL_ATTR_PARSE_STATE nState         = MYODBCUTIL_ATTR_PARSE_STATE_NAME_START;
39
 
    char *                  pAnchorChar    = (char *)pszStr;
40
 
    char *                  pScanChar      = (char *)pszStr;
41
 
    char *                  pszName        = 0;     
 
115
    MYODBCUTIL_ATTR_PARSE_STATE nState      = MYODBCUTIL_ATTR_PARSE_STATE_NAME_START;
 
116
    char *                      pAnchorChar = (char *)pszStr;
 
117
    char *                      pScanChar   = (char *)pszStr;
 
118
    char *                      pszName     = 0; 
 
119
 
 
120
    ulong nOption= 0, nPositives=0, nNegatives= 0, flag= 0;
42
121
 
43
122
    /* short circuit if we have not been given stuff to parse */
44
123
    if ( !pszStr || !(*pszStr) )
132
211
                        else if ( strcasecmp( pszName, "OPTION" ) == 0 )
133
212
                        {    
134
213
                            if ( !pDataSource->pszOPTION )
 
214
                            {
135
215
                                pDataSource->pszOPTION = (char *)_global_strndup( pAnchorChar, pScanChar - pAnchorChar );
 
216
                                nOption= strtoul(pDataSource->pszOPTION, NULL, 10);
 
217
                            }
136
218
                        }
137
219
                        else if( strcasecmp( pszName, "INTERACTIVE" ) == 0 )
138
220
                        {
237
319
                        {
238
320
                          pDataSource->bSaveFileDSN = TRUE;
239
321
                        }
 
322
                        else if ((flag= NamedAttributeToFlag(pszName)) != 0)
 
323
                        {
 
324
                          /* Check if we did not have that option yet */
 
325
                          if ((flag & (nPositives | nNegatives)) == 0)
 
326
                          {
 
327
                            if (atol(pAnchorChar) != 0)
 
328
                            {
 
329
                              nPositives |= flag;
 
330
                            }
 
331
                            else
 
332
                            {
 
333
                              nNegatives |= flag;
 
334
                            }
 
335
                          }
 
336
                        }
240
337
                        else
241
338
                        {
242
339
                            /* What the ? */
264
361
        if ( pScanChar[0] == '\0' )
265
362
            break;
266
363
 
267
 
        pScanChar++;
 
364
        ++pScanChar;
268
365
 
269
366
    } /* while scan */
270
367
 
 
368
    if ((nNegatives|nPositives) != 0)
 
369
    {
 
370
      char tmp[24];
 
371
 
 
372
      nOption= nOption & ~nNegatives;
 
373
      nOption= nOption | nPositives;
 
374
 
 
375
      sprintf(tmp, "%lu", nOption);
 
376
 
 
377
      if (pDataSource->pszOPTION != NULL)
 
378
      {
 
379
        _global_free(pDataSource->pszOPTION);
 
380
      }
 
381
 
 
382
      pDataSource->pszOPTION= (char *)_global_strdup(tmp);
 
383
    }
 
384
 
271
385
    if ( pszName )
272
386
    {
273
387
        _global_free( pszName );