~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_table.cc

  • Committer: Brian Aker
  • Date: 2008-08-14 20:59:41 UTC
  • Revision ID: brian@tangent.org-20080814205941-rdqc6mqguf50mvoq
Remove SET

Show diffs side-by-side

added added

removed removed

Lines of Context:
805
805
                                     sql_field->charset, &dup_val_count))
806
806
      return(1);
807
807
    break;
808
 
  case DRIZZLE_TYPE_SET:
809
 
    sql_field->pack_flag=pack_length_to_packflag(sql_field->pack_length) |
810
 
      FIELDFLAG_BITFIELD;
811
 
    if (sql_field->charset->state & MY_CS_BINSORT)
812
 
      sql_field->pack_flag|=FIELDFLAG_BINARY;
813
 
    sql_field->unireg_check=Field::BIT_FIELD;
814
 
    if (check_duplicates_in_interval("SET",sql_field->field_name,
815
 
                                 sql_field->interval,
816
 
                                     sql_field->charset, &dup_val_count))
817
 
      return(1);
818
 
    /* Check that count of unique members is not more then 64 */
819
 
    if (sql_field->interval->count -  dup_val_count > sizeof(int64_t)*8)
820
 
    {
821
 
       my_error(ER_TOO_BIG_SET, MYF(0), sql_field->field_name);
822
 
       return(1);
823
 
    }
824
 
    break;
825
808
  case DRIZZLE_TYPE_NEWDATE:  // Rest of string types
826
809
  case DRIZZLE_TYPE_TIME:
827
810
  case DRIZZLE_TYPE_DATETIME:
958
941
    */
959
942
    if (sql_field->def && 
960
943
        save_cs != sql_field->def->collation.collation &&
961
 
        (sql_field->sql_type == DRIZZLE_TYPE_SET ||
962
 
         sql_field->sql_type == DRIZZLE_TYPE_ENUM))
 
944
        (sql_field->sql_type == DRIZZLE_TYPE_ENUM))
963
945
    {
964
946
      /*
965
947
        Starting from 5.1 we work here with a copy of Create_field
981
963
      }
982
964
    }
983
965
 
984
 
    if (sql_field->sql_type == DRIZZLE_TYPE_SET ||
985
 
        sql_field->sql_type == DRIZZLE_TYPE_ENUM)
 
966
    if (sql_field->sql_type == DRIZZLE_TYPE_ENUM)
986
967
    {
987
968
      uint32_t dummy;
988
969
      const CHARSET_INFO * const cs= sql_field->charset;
1027
1008
                                       interval->type_lengths[i]);
1028
1009
          interval->type_lengths[i]= lengthsp;
1029
1010
          ((uchar *)interval->type_names[i])[lengthsp]= '\0';
1030
 
          if (sql_field->sql_type == DRIZZLE_TYPE_SET)
1031
 
          {
1032
 
            if (cs->coll->instr(cs, interval->type_names[i], 
1033
 
                                interval->type_lengths[i], 
1034
 
                                comma_buf, comma_length, NULL, 0))
1035
 
            {
1036
 
              my_error(ER_ILLEGAL_VALUE_FOR_TYPE, MYF(0), "set", tmp->ptr());
1037
 
              return(true);
1038
 
            }
1039
 
          }
1040
1011
        }
1041
1012
        sql_field->interval_list.empty(); // Don't need interval_list anymore
1042
1013
      }
1043
1014
 
1044
 
      if (sql_field->sql_type == DRIZZLE_TYPE_SET)
1045
 
      {
1046
 
        uint32_t field_length;
1047
 
        if (sql_field->def != NULL)
1048
 
        {
1049
 
          char *not_used;
1050
 
          uint not_used2;
1051
 
          bool not_found= 0;
1052
 
          String str, *def= sql_field->def->val_str(&str);
1053
 
          if (def == NULL) /* SQL "NULL" maps to NULL */
1054
 
          {
1055
 
            if ((sql_field->flags & NOT_NULL_FLAG) != 0)
1056
 
            {
1057
 
              my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->field_name);
1058
 
              return(true);
1059
 
            }
1060
 
 
1061
 
            /* else, NULL is an allowed value */
1062
 
            (void) find_set(interval, NULL, 0,
1063
 
                            cs, &not_used, &not_used2, &not_found);
1064
 
          }
1065
 
          else /* not NULL */
1066
 
          {
1067
 
            (void) find_set(interval, def->ptr(), def->length(),
1068
 
                            cs, &not_used, &not_used2, &not_found);
1069
 
          }
1070
 
 
1071
 
          if (not_found)
1072
 
          {
1073
 
            my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->field_name);
1074
 
            return(true);
1075
 
          }
1076
 
        }
1077
 
        calculate_interval_lengths(cs, interval, &dummy, &field_length);
1078
 
        sql_field->length= field_length + (interval->count - 1);
1079
 
      }
1080
 
      else  /* DRIZZLE_TYPE_ENUM */
 
1015
      /* DRIZZLE_TYPE_ENUM */
1081
1016
      {
1082
1017
        uint32_t field_length;
1083
1018
        assert(sql_field->sql_type == DRIZZLE_TYPE_ENUM);
1723
1658
 
1724
1659
void sp_prepare_create_field(THD *thd, Create_field *sql_field)
1725
1660
{
1726
 
  if (sql_field->sql_type == DRIZZLE_TYPE_SET ||
1727
 
      sql_field->sql_type == DRIZZLE_TYPE_ENUM)
 
1661
  if (sql_field->sql_type == DRIZZLE_TYPE_ENUM)
1728
1662
  {
1729
1663
    uint32_t field_length, dummy;
1730
 
    if (sql_field->sql_type == DRIZZLE_TYPE_SET)
1731
 
    {
1732
 
      calculate_interval_lengths(sql_field->charset,
1733
 
                                 sql_field->interval, &dummy, 
1734
 
                                 &field_length);
1735
 
      sql_field->length= field_length + 
1736
 
                         (sql_field->interval->count - 1);
1737
 
    }
1738
 
    else /* DRIZZLE_TYPE_ENUM */
 
1664
    /* DRIZZLE_TYPE_ENUM */
1739
1665
    {
1740
1666
      calculate_interval_lengths(sql_field->charset,
1741
1667
                                 sql_field->interval,