~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/cast/boolean.cc

  • Committer: Andrew Hutchings
  • Date: 2011-02-02 12:51:57 UTC
  • mto: (2157.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 2158.
  • Revision ID: andrew@linuxjedi.co.uk-20110202125157-r6thh7ox4g9l90ec
Make transaction_message_threshold a read-only global variable instead of a per-session variable
Make replication_dictionary column lengths use transation_message_threshold

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#include <config.h>
 
21
#include "config.h"
22
22
 
23
 
#include <drizzled/error.h>
24
 
#include <drizzled/function/cast/boolean.h>
25
 
#include <drizzled/lex_string.h>
26
 
#include <drizzled/type/boolean.h>
 
23
#include "drizzled/function/cast/boolean.h"
 
24
#include "drizzled/error.h"
27
25
 
28
26
namespace drizzled {
29
27
namespace function {
47
45
      if (not (res= args[0]->val_str(&_res)))
48
46
      { 
49
47
        null_value= true; 
 
48
 
50
49
        break;
51
50
      }
52
51
      null_value= false; 
53
52
 
54
 
      bool result;
55
 
      if (not type::convert(result, *res))
56
 
      {
57
 
        my_error(ER_INVALID_CAST_TO_BOOLEAN, MYF(0), res->c_ptr());
58
 
      }
59
 
 
60
 
      return evaluate(result, value);
 
53
      if (res->length() == 1)
 
54
      {
 
55
        switch (res->c_ptr()[0])
 
56
        {
 
57
        case 'y': case 'Y':
 
58
        case 't': case 'T': // PG compatibility
 
59
          return evaluate(true, value);
 
60
 
 
61
        case 'n': case 'N':
 
62
        case 'f': case 'F': // PG compatibility
 
63
          return evaluate(false, value);
 
64
 
 
65
        default:
 
66
          break;
 
67
        }
 
68
      }
 
69
      else if ((res->length() == 5) and (strcasecmp(res->c_ptr(), "FALSE") == 0))
 
70
      {
 
71
        return evaluate(false, value);
 
72
      }
 
73
      if ((res->length() == 4) and (strcasecmp(res->c_ptr(), "TRUE") == 0))
 
74
      {
 
75
        return evaluate(true, value);
 
76
      }
 
77
      else if ((res->length() == 5) and (strcasecmp(res->c_ptr(), "FALSE") == 0))
 
78
      {
 
79
        return evaluate(false, value);
 
80
      }
 
81
      else if ((res->length() == 3) and (strcasecmp(res->c_ptr(), "YES") == 0))
 
82
      {
 
83
        return evaluate(true, value);
 
84
      }
 
85
      else if ((res->length() == 2) and (strcasecmp(res->c_ptr(), "NO") == 0))
 
86
      {
 
87
        return evaluate(false, value);
 
88
      }
 
89
 
 
90
      my_error(ER_INVALID_CAST_TO_BOOLEAN, MYF(0), res->c_ptr());
 
91
      return evaluate(false, value);
61
92
    }
62
93
 
63
94
  case REAL_RESULT: