~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field.cc

  • Committer: Brian Aker
  • Date: 2010-05-14 14:34:40 UTC
  • mfrom: (1530.1.3 staging)
  • Revision ID: brian@gaz-20100514143440-p7yyn7y6yxpqumf1
Rollup merge for typelib/tableshare cleanup.

Show diffs side-by-side

added added

removed removed

Lines of Context:
918
918
  return 0;                                     // This shouldn't happen
919
919
}
920
920
 
921
 
Field *TableShare::make_field(memory::Root *root,
922
 
                              unsigned char *ptr,
923
 
                              uint32_t field_length,
924
 
                              bool is_nullable,
925
 
                              unsigned char *null_pos,
926
 
                              unsigned char null_bit,
927
 
                              uint8_t decimals,
928
 
                              enum_field_types field_type,
929
 
                              const CHARSET_INFO * field_charset,
930
 
                              Field::utype unireg_check,
931
 
                              TYPELIB *interval,
932
 
                              const char *field_name)
933
 
{
934
 
  TableShare *share= this;
935
 
  assert(root);
936
 
 
937
 
  if (! is_nullable)
938
 
  {
939
 
    null_pos=0;
940
 
    null_bit=0;
941
 
  }
942
 
  else
943
 
  {
944
 
    null_bit= ((unsigned char) 1) << null_bit;
945
 
  }
946
 
 
947
 
  switch (field_type) 
948
 
  {
949
 
  case DRIZZLE_TYPE_DATE:
950
 
  case DRIZZLE_TYPE_DATETIME:
951
 
  case DRIZZLE_TYPE_TIMESTAMP:
952
 
    field_charset= &my_charset_bin;
953
 
  default: break;
954
 
  }
955
 
 
956
 
  if (field_type == DRIZZLE_TYPE_VARCHAR ||
957
 
      field_type == DRIZZLE_TYPE_BLOB ||
958
 
      field_type == DRIZZLE_TYPE_ENUM)
959
 
  {
960
 
    if (field_type == DRIZZLE_TYPE_VARCHAR)
961
 
      return new (root) Field_varstring(ptr,field_length,
962
 
                                  HA_VARCHAR_PACKLENGTH(field_length),
963
 
                                  null_pos,null_bit,
964
 
                                  field_name,
965
 
                                  share,
966
 
                                  field_charset);
967
 
 
968
 
    if (field_type == DRIZZLE_TYPE_BLOB)
969
 
    {
970
 
      return new (root) Field_blob(ptr,
971
 
                                   null_pos,
972
 
                                   null_bit,
973
 
                                   field_name,
974
 
                                   share,
975
 
                                   calc_pack_length(DRIZZLE_TYPE_LONG, 0),
976
 
                                   field_charset);
977
 
    }
978
 
 
979
 
    if (interval)
980
 
    {
981
 
      return new (root) Field_enum(ptr,
982
 
                                   field_length,
983
 
                                   null_pos,
984
 
                                   null_bit,
985
 
                                   field_name,
986
 
                                   get_enum_pack_length(interval->count),
987
 
                                   interval,
988
 
                                   field_charset);
989
 
    }
990
 
  }
991
 
 
992
 
  switch (field_type)
993
 
  {
994
 
  case DRIZZLE_TYPE_DECIMAL:
995
 
    return new (root) Field_decimal(ptr,
996
 
                                    field_length,
997
 
                                    null_pos,
998
 
                                    null_bit,
999
 
                                    unireg_check,
1000
 
                                    field_name,
1001
 
                                    decimals,
1002
 
                                    false,
1003
 
                                    false /* is_unsigned */);
1004
 
  case DRIZZLE_TYPE_DOUBLE:
1005
 
    return new (root) Field_double(ptr,
1006
 
                                   field_length,
1007
 
                                   null_pos,
1008
 
                                   null_bit,
1009
 
                                   unireg_check,
1010
 
                                   field_name,
1011
 
                                   decimals,
1012
 
                                   false,
1013
 
                                   false /* is_unsigned */);
1014
 
  case DRIZZLE_TYPE_LONG:
1015
 
    return new (root) Field_long(ptr,
1016
 
                                 field_length,
1017
 
                                 null_pos,
1018
 
                                 null_bit,
1019
 
                                 unireg_check,
1020
 
                                 field_name,
1021
 
                                 false,
1022
 
                                 false /* is_unsigned */);
1023
 
  case DRIZZLE_TYPE_LONGLONG:
1024
 
    return new (root) Field_int64_t(ptr,
1025
 
                                    field_length,
1026
 
                                    null_pos,
1027
 
                                    null_bit,
1028
 
                                    unireg_check,
1029
 
                                    field_name,
1030
 
                                    false,
1031
 
                                    false /* is_unsigned */);
1032
 
  case DRIZZLE_TYPE_TIMESTAMP:
1033
 
    return new (root) Field_timestamp(ptr,
1034
 
                                      field_length,
1035
 
                                      null_pos,
1036
 
                                      null_bit,
1037
 
                                      unireg_check,
1038
 
                                      field_name,
1039
 
                                      share,
1040
 
                                      field_charset);
1041
 
  case DRIZZLE_TYPE_DATE:
1042
 
    return new (root) Field_date(ptr,
1043
 
                                 null_pos,
1044
 
                                 null_bit,
1045
 
                                 field_name,
1046
 
                                 field_charset);
1047
 
  case DRIZZLE_TYPE_DATETIME:
1048
 
    return new (root) Field_datetime(ptr,
1049
 
                                     null_pos,
1050
 
                                     null_bit,
1051
 
                                     field_name,
1052
 
                                     field_charset);
1053
 
  case DRIZZLE_TYPE_NULL:
1054
 
    return new (root) Field_null(ptr,
1055
 
                                 field_length,
1056
 
                                 field_name,
1057
 
                                 field_charset);
1058
 
  default: // Impossible (Wrong version)
1059
 
    break;
1060
 
  }
1061
 
  return 0;
1062
 
}
1063
 
 
1064
921
/*****************************************************************************
1065
922
 Warning handling
1066
923
*****************************************************************************/