~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Andrew Hutchings
  • Date: 2010-09-26 08:33:47 UTC
  • mto: (1795.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 1796.
  • Revision ID: andrew@linuxjedi.co.uk-20100926083347-fzsc9e7w0j4u7bj1
Disable boost:po allow_guessing which was making some wrong assumptions

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2005 PrimeBase Technologies GmbH
 
1
/* Copyright (c) 2005 PrimeBase Technologies GmbH
2
2
 *
3
3
 * PrimeBase XT
4
4
 *
14
14
 *
15
15
 * You should have received a copy of the GNU General Public License
16
16
 * along with this program; if not, write to the Free Software
17
 
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
18
 *
19
19
 * 2006-05-16   Paul McCullagh
20
20
 *
44
44
#include <drizzled/charset_info.h>
45
45
#include <plugin/myisam/my_handler.h>
46
46
#include <plugin/myisam/myisampack.h>
47
 
#include <boost/filesystem.hpp>
48
47
//extern "C" struct charset_info_st *session_charset(Session *session);
49
48
extern pthread_key_t THR_Session;
50
49
 
51
 
namespace fs=boost::filesystem;
52
50
using namespace drizzled;
53
51
#else
54
52
#include "mysql_priv.h"
663
661
                        memcpy(&data, ((char *) from)+packlength, sizeof(char*));
664
662
                        
665
663
                        //*len = ((Field_blob *) field)->get_length((byte *) from);
666
 
                        *len = ((Field_blob *) field)->get_length((byte *) from, GET_TABLE_SHARE(table)->db_low_byte_first);
 
664
                        *len = ((Field_blob *) field)->get_length((byte *) from, packlength, GET_TABLE_SHARE(table)->db_low_byte_first);
667
665
                        return data;
668
666
                }
669
667
#ifndef DRIZZLED
724
722
                case DRIZZLE_TYPE_TIMESTAMP:
725
723
                case DRIZZLE_TYPE_LONGLONG:
726
724
                case DRIZZLE_TYPE_DATETIME:
727
 
                case DRIZZLE_TYPE_TIME:
728
725
                case DRIZZLE_TYPE_DATE:
729
726
                case DRIZZLE_TYPE_DECIMAL:
730
727
                case DRIZZLE_TYPE_ENUM:
731
 
                case DRIZZLE_TYPE_UUID:
732
728
#endif
733
729
                        break;
734
730
        }
774
770
                        */
775
771
                        xtWord4 packlength = ((Field_blob *) field)->pack_length_no_ptr();
776
772
 
777
 
                        ((Field_blob *) field)->store_length((byte *) from, len, GET_TABLE_SHARE(table)->db_low_byte_first);
 
773
                        ((Field_blob *) field)->store_length((byte *) from, packlength, len, GET_TABLE_SHARE(table)->db_low_byte_first);
778
774
                        memcpy_fixed(((char *) from)+packlength, &data, sizeof(char*));
779
775
 
780
776
                        if (data)
839
835
                case DRIZZLE_TYPE_TIMESTAMP:
840
836
                case DRIZZLE_TYPE_LONGLONG:
841
837
                case DRIZZLE_TYPE_DATETIME:
842
 
                case DRIZZLE_TYPE_TIME:
843
838
                case DRIZZLE_TYPE_DATE:
844
839
                case DRIZZLE_TYPE_DECIMAL:
845
840
                case DRIZZLE_TYPE_ENUM:
846
 
                case DRIZZLE_TYPE_UUID:
847
841
#endif
848
842
                        break;
849
843
        }
1845
1839
                xt_lock_mutex(self, &tab->tab_dic_field_lock);
1846
1840
                pushr_(xt_unlock_mutex, &tab->tab_dic_field_lock);
1847
1841
                field->ptr = (byte *) buffer + field->offset(table->getDefaultValues());
1848
 
                field->val_str_internal(&val);
 
1842
                field->val_str(&val);
1849
1843
                field->ptr = save;                                      // Restore org row pointer
1850
1844
                freer_(); // xt_unlock_mutex(&tab->tab_dic_field_lock)
1851
1845
                xt_strcpy(len, value, val.c_ptr());
2035
2029
                        message::Table::STANDARD);
2036
2030
        }
2037
2031
        else {
2038
 
          fs::path n(getDataHomeCatalog());
2039
 
          n /= database_name;
2040
 
          n /= tab_file_name;
2041
 
                ident = new TableIdentifier(database_name, tab_name, n.file_string());
 
2032
                std::string n;
 
2033
                n.append(data_home);
 
2034
                n.append("/");
 
2035
                n.append(database_name);
 
2036
                n.append("/");
 
2037
                n.append(tab_file_name);
 
2038
                ident = new TableIdentifier(database_name, tab_name, n);
2042
2039
        }
2043
2040
        
2044
2041
        share = new TableShare(message::Table::STANDARD);
2114
2111
 
2115
2112
        xt_spinlock_free(self, &mi->mi_dirty_lock);
2116
2113
        XT_INDEX_FREE_LOCK(self, mi);
2117
 
#ifndef DRIZZLED
2118
2114
        myxt_bitmap_free(self, &mi->mi_col_map);
2119
 
#endif
2120
2115
        if (mi->mi_free_list)
2121
2116
                xt_free(self, mi->mi_free_list);
2122
2117
 
2146
2141
        uint                                    options = 0;
2147
2142
        u_int                                   key_length = 0;
2148
2143
        xtBool                                  partial_field;
2149
 
    MX_BITMAP               mi_col_map;
2150
2144
 
2151
2145
        enter_();
2152
2146
 
2161
2155
        ind->mi_fix_key = TRUE;
2162
2156
        ind->mi_select_total = 0;
2163
2157
        ind->mi_subset_of = 0;
2164
 
#ifdef DRIZZLED
2165
 
    mi_col_map.resize(GET_TABLE_SHARE(table_arg)->fields);      
2166
 
    mi_col_map.reset();
2167
 
    ind->mi_col_map= mi_col_map.to_ulong();
2168
 
    ind->mi_col_map_size= GET_TABLE_SHARE(table_arg)->fields;
2169
 
#else
2170
2158
        myxt_bitmap_init(self, &ind->mi_col_map, GET_TABLE_SHARE(table_arg)->fields);
2171
 
#endif
2172
2159
        
2173
2160
        ind->mi_seg_count = (uint) index->key_parts;
2174
2161
        key_part_end = index->key_part + index->key_parts;
2202
2189
                        }
2203
2190
                }
2204
2191
 
2205
 
                seg->col_idx = field->position();
 
2192
                seg->col_idx = field->field_index;
2206
2193
                seg->is_recs_in_range = 1;
2207
2194
                seg->is_selectivity = 1;
2208
2195
                seg->type = (int) type;
2315
2302
 
2316
2303
                /* NOTE: do not set if the field is only partially in the index!!! */
2317
2304
                if (!partial_field)
2318
 
#ifdef DRIZZLED
2319
 
                        MX_BIT_FAST_TEST_AND_SET(&mi_col_map, field->position());
2320
 
#else
2321
 
                        MX_BIT_FAST_TEST_AND_SET(&ind->mi_col_map, field->position());
2322
 
#endif
 
2305
                        MX_BIT_FAST_TEST_AND_SET(&ind->mi_col_map, field->field_index);
2323
2306
        }
2324
2307
 
2325
2308
        if (key_length > XT_INDEX_MAX_KEY_SIZE)
2442
2425
                for (key_part = index->key_part; key_part != key_part_end; key_part++) {
2443
2426
                        curr_field = key_part->field;
2444
2427
 
2445
 
                        if ((u_int) curr_field->position()+1 > dic->dic_ind_cols_req)
2446
 
                                dic->dic_ind_cols_req = curr_field->position()+1;
 
2428
                        if ((u_int) curr_field->field_index+1 > dic->dic_ind_cols_req)
 
2429
                                dic->dic_ind_cols_req = curr_field->field_index+1;
2447
2430
                }
2448
2431
        }
2449
2432
 
2480
2463
                                else
2481
2464
                                        max_ave_row_size = 200;
2482
2465
                                large_blob_field_count++;
2483
 
                                if ((u_int) curr_field->position()+1 > dic->dic_blob_cols_req)
2484
 
                                        dic->dic_blob_cols_req = curr_field->position()+1;
 
2466
                                if ((u_int) curr_field->field_index+1 > dic->dic_blob_cols_req)
 
2467
                                        dic->dic_blob_cols_req = curr_field->field_index+1;
2485
2468
                                dic->dic_blob_count++;
2486
2469
                                xt_realloc(self, (void **) &dic->dic_blob_cols, sizeof(Field *) * dic->dic_blob_count);
2487
2470
                                dic->dic_blob_cols[dic->dic_blob_count-1] = curr_field;
2955
2938
xtPublic void myxt_static_convert_identifier(XTThreadPtr XT_UNUSED(self), MX_CONST_CHARSET_INFO *cs, char *from, char *to, size_t to_len)
2956
2939
{
2957
2940
#ifdef DRIZZLED
2958
 
        ((void)cs);
 
2941
        ((void *)cs);
2959
2942
         xt_strcpy(to_len, to, from);
2960
2943
#else
2961
2944
        uint errors;
2977
2960
{
2978
2961
#ifdef DRIZZLED
2979
2962
        char *to = xt_dup_string(self, from);
2980
 
        ((void)cs);
 
2963
        ((void *)cs);
2981
2964
#else
2982
2965
        uint    errors;
2983
2966
        u_int   len;
3064
3047
                THD *thd = current_thd;
3065
3048
 
3066
3049
                if (thd)
3067
 
                        return (MX_CHARSET_INFO *)thd->charset();
 
3050
                        return (MX_CHARSET_INFO *)thd_charset(thd);
3068
3051
        }
3069
3052
        return (MX_CHARSET_INFO *)&my_charset_utf8_general_ci;
3070
3053
}
3178
3161
{
3179
3162
        Session *session = (Session *) s;
3180
3163
 
 
3164
        session->lockForDelete();
3181
3165
        delete session;
3182
3166
 
3183
3167
        if (end_threads)
3184
 
          drizzled::internal::my_thread_end();
 
3168
                drizzled::internal::my_thread_end();
3185
3169
}
3186
3170
#else
3187
3171
xtPublic void myxt_destroy_thread(void *thread, xtBool end_threads)
3363
3347
 
3364
3348
static void myxt_bitmap_init(XTThreadPtr self, MX_BITMAP *map, u_int n_bits)
3365
3349
{
3366
 
#ifdef DRIZZLED
3367
 
    (void) self;
3368
 
    map= new boost::dynamic_bitset<>(n_bits);
3369
 
    map->resize(n_bits);
3370
 
    map->reset();
3371
 
#else
3372
3350
        my_bitmap_map   *buf;
3373
3351
    uint                        size_in_bytes = (((n_bits) + 31) / 32) * 4;
 
3352
 
3374
3353
        buf = (my_bitmap_map *) xt_malloc(self, size_in_bytes);
 
3354
 
 
3355
#ifdef DRIZZLED
 
3356
        map->init(buf, n_bits);
 
3357
#else
3375
3358
        map->bitmap= buf;
3376
3359
        map->n_bits= n_bits;
3377
3360
        create_last_word_mask(map);
3382
3365
static void myxt_bitmap_free(XTThreadPtr self, MX_BITMAP *map)
3383
3366
{
3384
3367
#ifdef DRIZZLED
3385
 
    (void) self;
3386
 
    if (map->empty())
3387
 
        map->clear();
3388
 
    delete map;
 
3368
        my_bitmap_map *buf = map->getBitmap();
 
3369
        if (buf)
 
3370
                xt_free(self, buf);
 
3371
        map->setBitmap(NULL);
3389
3372
#else
3390
3373
        if (map->bitmap) {
3391
3374
                xt_free(self, map->bitmap);