~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: lbieber
  • Date: 2010-10-02 19:48:35 UTC
  • mfrom: (1730.6.19 drizzle-make-lcov)
  • Revision ID: lbieber@orisndriz08-20101002194835-q5zd9qc4lvx1xnfo
Merge Hartmut - clean up lex, now require flex to build, also "make lcov" improvements

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(getDataHomeCatalog());
 
2033
                n.append("/");
 
2034
                n.append(database_name);
 
2035
                n.append("/");
 
2036
                n.append(tab_file_name);
 
2037
                ident = new TableIdentifier(database_name, tab_name, n);
2042
2038
        }
2043
2039
        
2044
2040
        share = new TableShare(message::Table::STANDARD);
2114
2110
 
2115
2111
        xt_spinlock_free(self, &mi->mi_dirty_lock);
2116
2112
        XT_INDEX_FREE_LOCK(self, mi);
2117
 
#ifndef DRIZZLED
2118
2113
        myxt_bitmap_free(self, &mi->mi_col_map);
2119
 
#endif
2120
2114
        if (mi->mi_free_list)
2121
2115
                xt_free(self, mi->mi_free_list);
2122
2116
 
2146
2140
        uint                                    options = 0;
2147
2141
        u_int                                   key_length = 0;
2148
2142
        xtBool                                  partial_field;
2149
 
    MX_BITMAP               mi_col_map;
2150
2143
 
2151
2144
        enter_();
2152
2145
 
2161
2154
        ind->mi_fix_key = TRUE;
2162
2155
        ind->mi_select_total = 0;
2163
2156
        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
2157
        myxt_bitmap_init(self, &ind->mi_col_map, GET_TABLE_SHARE(table_arg)->fields);
2171
 
#endif
2172
2158
        
2173
2159
        ind->mi_seg_count = (uint) index->key_parts;
2174
2160
        key_part_end = index->key_part + index->key_parts;
2202
2188
                        }
2203
2189
                }
2204
2190
 
2205
 
                seg->col_idx = field->position();
 
2191
                seg->col_idx = field->field_index;
2206
2192
                seg->is_recs_in_range = 1;
2207
2193
                seg->is_selectivity = 1;
2208
2194
                seg->type = (int) type;
2315
2301
 
2316
2302
                /* NOTE: do not set if the field is only partially in the index!!! */
2317
2303
                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
 
2304
                        MX_BIT_FAST_TEST_AND_SET(&ind->mi_col_map, field->field_index);
2323
2305
        }
2324
2306
 
2325
2307
        if (key_length > XT_INDEX_MAX_KEY_SIZE)
2442
2424
                for (key_part = index->key_part; key_part != key_part_end; key_part++) {
2443
2425
                        curr_field = key_part->field;
2444
2426
 
2445
 
                        if ((u_int) curr_field->position()+1 > dic->dic_ind_cols_req)
2446
 
                                dic->dic_ind_cols_req = curr_field->position()+1;
 
2427
                        if ((u_int) curr_field->field_index+1 > dic->dic_ind_cols_req)
 
2428
                                dic->dic_ind_cols_req = curr_field->field_index+1;
2447
2429
                }
2448
2430
        }
2449
2431
 
2480
2462
                                else
2481
2463
                                        max_ave_row_size = 200;
2482
2464
                                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;
 
2465
                                if ((u_int) curr_field->field_index+1 > dic->dic_blob_cols_req)
 
2466
                                        dic->dic_blob_cols_req = curr_field->field_index+1;
2485
2467
                                dic->dic_blob_count++;
2486
2468
                                xt_realloc(self, (void **) &dic->dic_blob_cols, sizeof(Field *) * dic->dic_blob_count);
2487
2469
                                dic->dic_blob_cols[dic->dic_blob_count-1] = curr_field;
2955
2937
xtPublic void myxt_static_convert_identifier(XTThreadPtr XT_UNUSED(self), MX_CONST_CHARSET_INFO *cs, char *from, char *to, size_t to_len)
2956
2938
{
2957
2939
#ifdef DRIZZLED
2958
 
        ((void)cs);
 
2940
        ((void *)cs);
2959
2941
         xt_strcpy(to_len, to, from);
2960
2942
#else
2961
2943
        uint errors;
2977
2959
{
2978
2960
#ifdef DRIZZLED
2979
2961
        char *to = xt_dup_string(self, from);
2980
 
        ((void)cs);
 
2962
        ((void *)cs);
2981
2963
#else
2982
2964
        uint    errors;
2983
2965
        u_int   len;
3064
3046
                THD *thd = current_thd;
3065
3047
 
3066
3048
                if (thd)
3067
 
                        return (MX_CHARSET_INFO *)thd->charset();
 
3049
                        return (MX_CHARSET_INFO *)thd_charset(thd);
3068
3050
        }
3069
3051
        return (MX_CHARSET_INFO *)&my_charset_utf8_general_ci;
3070
3052
}
3178
3160
{
3179
3161
        Session *session = (Session *) s;
3180
3162
 
 
3163
        session->lockForDelete();
3181
3164
        delete session;
3182
3165
 
3183
3166
        if (end_threads)
3184
 
          drizzled::internal::my_thread_end();
 
3167
                drizzled::internal::my_thread_end();
3185
3168
}
3186
3169
#else
3187
3170
xtPublic void myxt_destroy_thread(void *thread, xtBool end_threads)
3363
3346
 
3364
3347
static void myxt_bitmap_init(XTThreadPtr self, MX_BITMAP *map, u_int n_bits)
3365
3348
{
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
3349
        my_bitmap_map   *buf;
3373
3350
    uint                        size_in_bytes = (((n_bits) + 31) / 32) * 4;
 
3351
 
3374
3352
        buf = (my_bitmap_map *) xt_malloc(self, size_in_bytes);
 
3353
 
 
3354
#ifdef DRIZZLED
 
3355
        map->init(buf, n_bits);
 
3356
#else
3375
3357
        map->bitmap= buf;
3376
3358
        map->n_bits= n_bits;
3377
3359
        create_last_word_mask(map);
3382
3364
static void myxt_bitmap_free(XTThreadPtr self, MX_BITMAP *map)
3383
3365
{
3384
3366
#ifdef DRIZZLED
3385
 
    (void) self;
3386
 
    if (map->empty())
3387
 
        map->clear();
3388
 
    delete map;
 
3367
        my_bitmap_map *buf = map->getBitmap();
 
3368
        if (buf)
 
3369
                xt_free(self, buf);
 
3370
        map->setBitmap(NULL);
3389
3371
#else
3390
3372
        if (map->bitmap) {
3391
3373
                xt_free(self, map->bitmap);