~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/pbxt/src/myxt_xt.cc

  • Committer: Monty Taylor
  • Date: 2010-07-06 00:44:32 UTC
  • mfrom: (1643.1.13 build)
  • Revision ID: mordred@inaugust.com-20100706004432-843uftc92rc2497l
Merged in PBMS, translation updates, a few build fixes and a few bug fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 */
26
26
 
27
27
#include "xt_config.h"
 
28
#include "xt_defs.h"
28
29
 
29
30
#ifdef DRIZZLED
30
31
#include <drizzled/plugin.h>
608
609
{
609
610
#ifdef DRIZZLED
610
611
        if (field->null_ptr)
611
 
                record[(uint) (field->null_ptr - (uchar *) table->default_values)] &= (uchar) ~field->null_bit;
 
612
                record[(uint) (field->null_ptr - (uchar *) table->getDefaultValues())] &= (uchar) ~field->null_bit;
612
613
#else
613
614
        ASSERT(table == field->table);
614
615
        if (field->null_ptr)
620
621
{
621
622
        if (field->null_ptr) {
622
623
#ifdef DRIZZLED
623
 
                if (record[(uint) (field->null_ptr - (uchar *) table->default_values)] & (uchar) field->null_bit)
 
624
                if (record[(uint) (field->null_ptr - (uchar *) table->getDefaultValues())] & (uchar) field->null_bit)
624
625
                        return TRUE;
625
626
#else
626
627
                ASSERT(table == field->table);
641
642
        char *from;
642
643
        
643
644
#ifdef DRIZZLED
644
 
        from = dest + field->offset(table->default_values);
 
645
        from = dest + field->offset(table->getDefaultValues());
645
646
#else
646
647
        ASSERT(table == field->table);
647
648
        from = dest + field->offset(table->record[0]);
764
765
        char *from;
765
766
        
766
767
#ifdef DRIZZLED
767
 
        from = dest + field->offset(table->default_values);
 
768
        from = dest + field->offset(table->getDefaultValues());
768
769
#else
769
770
        ASSERT(table == field->table);
770
771
        from = dest + field->offset(table->record[0]);
890
891
                Field *field = GET_TABLE_FIELDS(table)[col_idx];
891
892
                byte  *field_save = field->ptr;
892
893
 
893
 
                field->ptr = GET_TABLE_SHARE(table)->default_values + keyseg->start;
 
894
                field->ptr = GET_TABLE_SHARE(table)->getDefaultValues() + keyseg->start;
894
895
                memcpy(record + keyseg->start, field->ptr, field->pack_length());
895
896
                record[keyseg->null_pos] &= ~keyseg->null_bit;
896
 
                record[keyseg->null_pos] |= GET_TABLE_SHARE(table)->default_values[keyseg->null_pos] & keyseg->null_bit;
 
897
                record[keyseg->null_pos] |= GET_TABLE_SHARE(table)->getDefaultValues()[keyseg->null_pos] & keyseg->null_bit;
897
898
 
898
899
                field->ptr = field_save;
899
900
        }
1584
1585
        xtWord4                 item_size;
1585
1586
        xtWord4                 row_size = 0;
1586
1587
 
1587
 
        for (Field **field=GET_TABLE_FIELDS(table); *field ; field++) {
 
1588
        for (Field* const *field=GET_TABLE_FIELDS(table); *field ; field++) {
1588
1589
                if ((*field)->is_null_in_record((const uchar *) rec_buff)) {
1589
1590
                        sdata = NULL;
1590
1591
                        dlen = 0;
1621
1622
        xtWord4                 dlen;
1622
1623
        xtWord4                 item_size;
1623
1624
 
1624
 
        for (Field **field=GET_TABLE_FIELDS(table); *field; field++) {
 
1625
        for (Field * const* field=GET_TABLE_FIELDS(table); *field; field++) {
1625
1626
                if (mx_is_null_in_record(table, *field, rec_buff)) {
1626
1627
                        sdata = NULL;
1627
1628
                        dlen = 0;
1762
1763
         * is a nullable column with a non-NULL value".
1763
1764
         */
1764
1765
        memset(dest_buff, 0xFF, GET_TABLE_SHARE(table)->null_bytes);
1765
 
        for (Field **field=GET_TABLE_FIELDS(table); *field && (!col_cnt || i<col_cnt); field++, i++) {
 
1766
        for (Field * const *field=GET_TABLE_FIELDS(table); *field && (!col_cnt || i<col_cnt); field++, i++) {
1766
1767
                curr_field = *field;
1767
1768
                is_null = FALSE;
1768
1769
                switch (*source_buf) {
1813
1814
        STRUCT_TABLE    *table = ot->ot_table->tab_dic.dic_my_table;
1814
1815
        u_int                   i=0;
1815
1816
 
1816
 
        for (Field **field=GET_TABLE_FIELDS(table); *field; field++, i++) {
 
1817
        for (Field * const *field=GET_TABLE_FIELDS(table); *field; field++, i++) {
1817
1818
                if (!my_strcasecmp(system_charset_info, (*field)->field_name, col_name)) {
1818
1819
                        *col_idx = i;
1819
1820
                        return OK;
1855
1856
                xt_lock_mutex(self, &tab->tab_dic_field_lock);
1856
1857
                pushr_(xt_unlock_mutex, &tab->tab_dic_field_lock);
1857
1858
#ifdef DRIZZLED
1858
 
                field->ptr = (byte *) buffer + field->offset(table->default_values);
 
1859
                field->ptr = (byte *) buffer + field->offset(table->getDefaultValues());
1859
1860
#else
1860
1861
                field->ptr = (byte *) buffer + field->offset(field->table->record[0]);
1861
1862
#endif
1887
1888
        xt_lock_mutex(self, &tab->tab_dic_field_lock);
1888
1889
        pushr_(xt_unlock_mutex, &tab->tab_dic_field_lock);
1889
1890
#ifdef DRIZZLED
1890
 
        field->ptr = (byte *) buffer + field->offset(table->default_values);
 
1891
        field->ptr = (byte *) buffer + field->offset(table->getDefaultValues());
1891
1892
#else
1892
1893
        field->ptr = (byte *) buffer + field->offset(field->table->record[0]);
1893
1894
#endif
2035
2036
                return NULL;
2036
2037
 
2037
2038
        tab_file_name = xt_last_name_of_path(tab_path->ps_path);
2038
 
        tab_name_len = filename_to_tablename(tab_file_name, tab_name, XT_IDENTIFIER_NAME_SIZE);
 
2039
        tab_name_len = TableIdentifier::filename_to_tablename(tab_file_name, tab_name, XT_IDENTIFIER_NAME_SIZE);
2039
2040
 
2040
2041
        xt_2nd_last_name_of_path(XT_IDENTIFIER_NAME_SIZE, database_name, tab_path->ps_path);
2041
2042
 
2063
2064
                ident = new TableIdentifier(database_name, tab_name, n);
2064
2065
        }
2065
2066
        
2066
 
        share = new TableShare();
2067
 
        share->init();
 
2067
        share = new TableShare(message::Table::STANDARD);
2068
2068
        if ((error = share->open_table_def(*thd, *ident))) {
2069
2069
          xt_throw_sulxterr(XT_CONTEXT, XT_ERR_LOADING_MYSQL_DIC, tab_path->ps_path, (u_long) error);
2070
2070
          delete ident;
2161
2161
#ifdef DRIZZLED
2162
2162
        char            tab_name[XT_IDENTIFIER_NAME_SIZE];
2163
2163
 
2164
 
        uint32_t tab_name_len = filename_to_tablename(name, tab_name, XT_IDENTIFIER_NAME_SIZE); 
 
2164
        uint32_t tab_name_len = TableIdentifier::filename_to_tablename(name, tab_name, XT_IDENTIFIER_NAME_SIZE);        
2165
2165
        
2166
2166
        TableIdentifier *ident = NULL;
2167
2167
        if (table_type == XT_TABLE_TYPE_TEMPORARY) {
2418
2418
                        seg->flag |= HA_NULL_PART;
2419
2419
                        seg->null_bit = field->null_bit;
2420
2420
#ifdef DRIZZLED
2421
 
                        seg->null_pos = (uint) (field->null_ptr - (uchar*) table_arg->default_values);
 
2421
                        seg->null_pos = (uint) (field->null_ptr - (uchar*) table_arg->getDefaultValues());
2422
2422
#else
2423
2423
                        seg->null_pos = (uint) (field->null_ptr - (uchar*) table_arg->record[0]);
2424
2424
#endif
2624
2624
        u_int   dic_rec_size;
2625
2625
        xtBool  dic_rec_fixed;
2626
2626
        Field   *curr_field;
2627
 
        Field   **field;
 
2627
        Field * const *field;
2628
2628
 
2629
2629
        /* How many columns are required for all indexes. */
2630
2630
        KeyInfo                         *index;
2637
2637
 
2638
2638
        dic->dic_ind_cols_req = 0;
2639
2639
        for (uint i=0; i<GET_TABLE_SHARE(my_tab)->keys; i++) {
2640
 
                index = &my_tab->key_info[i];
 
2640
                index = &my_tab->getKeyInfo(i);
2641
2641
 
2642
2642
                key_part_end = index->key_part + index->key_parts;
2643
2643
                for (key_part = index->key_part; key_part != key_part_end; key_part++) {
2762
2762
 
2763
2763
        if (dic->dic_def_ave_row_size) {
2764
2764
                /* The average row size has been set: */
2765
 
                dic_rec_size = offsetof(XTTabRecFix, rf_data) + GET_TABLE_SHARE(my_tab)->reclength;
 
2765
                dic_rec_size = offsetof(XTTabRecFix, rf_data) + GET_TABLE_SHARE(my_tab)->getRecordLength();
2766
2766
 
2767
2767
                /* The conditions for a fixed record are: */
2768
 
                if (dic->dic_def_ave_row_size >= (xtWord8) GET_TABLE_SHARE(my_tab)->reclength &&
 
2768
                if (dic->dic_def_ave_row_size >= (xtWord8) GET_TABLE_SHARE(my_tab)->getRecordLength() &&
2769
2769
                        dic_rec_size <= XT_TAB_MAX_FIX_REC_LENGTH &&
2770
2770
                        !blob_field_count) {
2771
2771
                        dic_rec_fixed = TRUE;
2791
2791
                 * we handle these rows as fixed size rows.
2792
2792
                 * Fixed size rows use the internal MySQL format.
2793
2793
                 */
2794
 
                dic_rec_size = offsetof(XTTabRecFix, rf_data) + GET_TABLE_SHARE(my_tab)->reclength;
 
2794
                dic_rec_size = offsetof(XTTabRecFix, rf_data) + GET_TABLE_SHARE(my_tab)->getRecordLength();
2795
2795
                /* Fixed length records must be less than 16K in size,
2796
2796
                 * have an average size which is very close (20%) to the maximum size or
2797
2797
                 * be less than a minimum size,
2862
2862
                 * index columns!
2863
2863
                 */              
2864
2864
                if (field_count == dic->dic_ind_cols_req)
2865
 
                        dic->dic_ind_rec_len = GET_TABLE_SHARE(my_tab)->reclength;
 
2865
                        dic->dic_ind_rec_len = GET_TABLE_SHARE(my_tab)->getRecordLength();
2866
2866
                else {
2867
2867
                        field=GET_TABLE_FIELDS(my_tab);
2868
2868
                        
2869
2869
                        curr_field = field[dic->dic_ind_cols_req];
2870
2870
#ifdef DRIZZLED
2871
 
                        dic->dic_ind_rec_len = curr_field->offset(my_tab->default_values);
 
2871
                        dic->dic_ind_rec_len = curr_field->offset(my_tab->getDefaultValues());
2872
2872
#else
2873
2873
                        dic->dic_ind_rec_len = curr_field->offset(my_tab->record[0]);
2874
2874
#endif
2886
2886
        if (!dic_rec_fixed) {
2887
2887
                xtWord8 max_rec_size = offsetof(XTTabRecExt, re_data);
2888
2888
 
2889
 
                for (Field **f=GET_TABLE_FIELDS(my_tab); (curr_field = *f); f++) {
 
2889
                for (Field * const *f=GET_TABLE_FIELDS(my_tab); (curr_field = *f); f++) {
2890
2890
                        max_data_size = curr_field->key_length();
2891
2891
                        enum_field_types tno = curr_field->type();
2892
2892
                        if (tno == MYSQL_TYPE_BLOB)
2908
2908
 
2909
2909
        dic->dic_key_count = GET_TABLE_SHARE(my_tab)->keys;
2910
2910
        dic->dic_mysql_buf_size = GET_TABLE_SHARE(my_tab)->rec_buff_length;
2911
 
        dic->dic_mysql_rec_size = GET_TABLE_SHARE(my_tab)->reclength;
 
2911
        dic->dic_mysql_rec_size = GET_TABLE_SHARE(my_tab)->getRecordLength();
2912
2912
}
2913
2913
 
2914
2914
static u_int my_get_best_superset(XTThreadPtr XT_UNUSED(self), XTDictionaryPtr dic, XTIndexPtr ind)
2951
2951
        myxt_setup_dictionary(self, dic);
2952
2952
        dic->dic_keys = (XTIndexPtr *) xt_calloc(self, sizeof(XTIndexPtr) * GET_TABLE_SHARE(my_tab)->keys);
2953
2953
        for (uint i=0; i<GET_TABLE_SHARE(my_tab)->keys; i++)
2954
 
                dic->dic_keys[i] = my_create_index(self, my_tab, i, &my_tab->key_info[i]);
 
2954
                dic->dic_keys[i] = my_create_index(self, my_tab, i, &my_tab->getKeyInfo(i));
2955
2955
 
2956
2956
        /* Check if any key is a subset of another: */
2957
2957
        for (u_int i=0; i<dic->dic_key_count; i++)
3134
3134
        dd_tab->init(self);
3135
3135
        pushr_(my_free_dd_table, dd_tab);
3136
3136
 
3137
 
        for (Field **field=GET_TABLE_FIELDS(my_tab); (curr_field = *field); field++) {
 
3137
        for (Field * const *field=GET_TABLE_FIELDS(my_tab); (curr_field = *field); field++) {
3138
3138
                col = XTDDColumnFactory::createFromMySQLField(self, my_tab, curr_field);
3139
3139
                dd_tab->dt_cols.append(self, col);
3140
3140
        }
3145
3145
                dd_tab->dt_indexes.append(self, ind);
3146
3146
                ind->co_table = dd_tab;
3147
3147
                ind->in_index = i;
3148
 
                ha_create_dd_index(self, ind, &my_tab->key_info[i]);
 
3148
                ha_create_dd_index(self, ind, &my_tab->getKeyInfo(i));
3149
3149
        }
3150
3150
 
3151
3151
        popr_(); // my_free_dd_table(dd_tab)
3237
3237
 
3238
3238
xtPublic void myxt_static_convert_file_name(char *from, char *to, size_t to_len)
3239
3239
{
3240
 
        filename_to_tablename(from, to, to_len);
 
3240
  TableIdentifier::filename_to_tablename(from, to, to_len);
3241
3241
}
3242
3242
 
3243
3243
xtPublic int myxt_strcasecmp(char * a, char *b)