~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field.cc

  • Committer: Monty Taylor
  • Date: 2011-02-12 21:49:59 UTC
  • mto: (2165.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 2166.
  • Revision ID: mordred@inaugust.com-20110212214959-bve8sh4hu761y48m
Updated the windows build to be able to build from the command line and not to show warnings on strncpy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 * @file This file implements the Field class and API
24
24
 */
25
25
 
26
 
#include <config.h>
 
26
#include "config.h"
27
27
#include <cstdio>
28
28
#include <errno.h>
29
29
#include <float.h>
30
 
#include <drizzled/sql_select.h>
31
 
#include <drizzled/error.h>
32
 
#include <drizzled/field/str.h>
33
 
#include <drizzled/field/num.h>
34
 
#include <drizzled/field/blob.h>
35
 
#include <drizzled/field/boolean.h>
36
 
#include <drizzled/field/enum.h>
37
 
#include <drizzled/field/null.h>
38
 
#include <drizzled/field/date.h>
39
 
#include <drizzled/field/decimal.h>
40
 
#include <drizzled/field/real.h>
41
 
#include <drizzled/field/double.h>
42
 
#include <drizzled/field/int32.h>
43
 
#include <drizzled/field/int64.h>
44
 
#include <drizzled/field/num.h>
45
 
#include <drizzled/field/time.h>
46
 
#include <drizzled/field/epoch.h>
47
 
#include <drizzled/field/datetime.h>
48
 
#include <drizzled/field/microtime.h>
49
 
#include <drizzled/field/varstring.h>
50
 
#include <drizzled/field/uuid.h>
51
 
#include <drizzled/time_functions.h>
52
 
#include <drizzled/internal/m_string.h>
53
 
#include <drizzled/table.h>
54
 
#include <drizzled/util/test.h>
55
 
#include <drizzled/session.h>
56
 
#include <drizzled/current_session.h>
57
 
#include <drizzled/display.h>
58
 
#include <drizzled/typelib.h>
 
30
#include "drizzled/sql_select.h"
 
31
#include "drizzled/error.h"
 
32
#include "drizzled/field/str.h"
 
33
#include "drizzled/field/num.h"
 
34
#include "drizzled/field/blob.h"
 
35
#include "drizzled/field/boolean.h"
 
36
#include "drizzled/field/enum.h"
 
37
#include "drizzled/field/null.h"
 
38
#include "drizzled/field/date.h"
 
39
#include "drizzled/field/decimal.h"
 
40
#include "drizzled/field/real.h"
 
41
#include "drizzled/field/double.h"
 
42
#include "drizzled/field/int32.h"
 
43
#include "drizzled/field/int64.h"
 
44
#include "drizzled/field/num.h"
 
45
#include "drizzled/field/time.h"
 
46
#include "drizzled/field/epoch.h"
 
47
#include "drizzled/field/datetime.h"
 
48
#include "drizzled/field/microtime.h"
 
49
#include "drizzled/field/varstring.h"
 
50
#include "drizzled/field/uuid.h"
 
51
#include "drizzled/time_functions.h"
 
52
#include "drizzled/internal/m_string.h"
 
53
 
 
54
#include "drizzled/display.h"
59
55
 
60
56
namespace drizzled
61
57
{
746
742
  return 0;
747
743
}
748
744
 
749
 
bool Field::is_null(ptrdiff_t row_offset) const
 
745
bool Field::is_null(ptrdiff_t row_offset)
750
746
{
751
747
  return null_ptr ?
752
748
    (null_ptr[row_offset] & null_bit ? true : false) :
753
749
    table->null_row;
754
750
}
755
751
 
756
 
bool Field::is_real_null(ptrdiff_t row_offset) const
 
752
bool Field::is_real_null(ptrdiff_t row_offset)
757
753
{
758
754
  return null_ptr ? (null_ptr[row_offset] & null_bit ? true : false) : false;
759
755
}
760
756
 
761
 
bool Field::is_null_in_record(const unsigned char *record) const
 
757
bool Field::is_null_in_record(const unsigned char *record)
762
758
{
763
759
  if (! null_ptr)
764
760
    return false;
765
761
  return test(record[(uint32_t) (null_ptr -table->getInsertRecord())] & null_bit);
766
762
}
767
763
 
768
 
bool Field::is_null_in_record_with_offset(ptrdiff_t with_offset) const
 
764
bool Field::is_null_in_record_with_offset(ptrdiff_t with_offset)
769
765
{
770
766
  if (! null_ptr)
771
767
    return false;
784
780
    null_ptr[row_offset]&= (unsigned char) ~null_bit;
785
781
}
786
782
 
787
 
bool Field::maybe_null(void) const
 
783
bool Field::maybe_null(void)
788
784
{
789
785
  return null_ptr != 0 || table->maybe_null;
790
786
}
791
787
 
792
 
bool Field::real_maybe_null(void) const
 
788
bool Field::real_maybe_null(void)
793
789
{
794
790
  return null_ptr != 0;
795
791
}
851
847
{
852
848
}
853
849
 
854
 
void Field::hash(uint32_t *nr, uint32_t *nr2) const
 
850
void Field::hash(uint32_t *nr, uint32_t *nr2)
855
851
{
856
852
  if (is_null())
857
853
  {
943
939
  return(result);
944
940
}
945
941
 
946
 
type::Decimal *Field::val_decimal(type::Decimal *) const
 
942
type::Decimal *Field::val_decimal(type::Decimal *)
947
943
{
948
944
  /* This never have to be called */
949
945
  assert(0);
1012
1008
  return copy->length+ store_length;
1013
1009
}
1014
1010
 
1015
 
bool Field::get_date(type::Time &ltime, uint32_t fuzzydate) const
 
1011
bool Field::get_date(type::Time &ltime, uint32_t fuzzydate)
1016
1012
{
1017
1013
  char buff[type::Time::MAX_STRING_LENGTH];
1018
1014
  String tmp(buff,sizeof(buff),&my_charset_bin),*res;
1019
1015
 
1020
1016
  assert(getTable() and getTable()->getSession());
1021
1017
 
1022
 
  if (not (res= val_str_internal(&tmp)) or
 
1018
  if (not (res=val_str_internal(&tmp)) or
1023
1019
      str_to_datetime_with_warn(getTable()->getSession(),
1024
1020
                                res->ptr(), res->length(),
1025
1021
                                &ltime, fuzzydate) <= type::DRIZZLE_TIMESTAMP_ERROR)
1030
1026
  return false;
1031
1027
}
1032
1028
 
1033
 
bool Field::get_time(type::Time &ltime) const
 
1029
bool Field::get_time(type::Time &ltime)
1034
1030
{
1035
1031
  char buff[type::Time::MAX_STRING_LENGTH];
1036
1032
  String tmp(buff,sizeof(buff),&my_charset_bin),*res;
1253
1249
  }
1254
1250
}
1255
1251
 
1256
 
bool Field::isReadSet() const 
 
1252
bool Field::isReadSet() 
1257
1253
1258
1254
  return table->isReadSet(field_index); 
1259
1255
}