~vkolesnikov/pbxt/pbxt-1.0-17.06.2011

« back to all changes in this revision

Viewing changes to src/myxt_xt.cc

  • Committer: Paul McCullagh
  • Date: 2009-07-30 15:43:08 UTC
  • mfrom: (663.3.2 rc2_PBMS)
  • Revision ID: paul.mccullagh@primebase.org-20090730154308-smf9l4vcpcqa0b1q
Merged changes for PBMS version 0.5.09

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
#include "myxt_xt.h"
53
53
#include "strutil_xt.h"
54
54
#include "database_xt.h"
55
 
#ifdef XT_STREAMING
56
 
#include "streaming_xt.h"
57
 
#endif
58
55
#include "cache_xt.h"
59
56
#include "datalog_xt.h"
60
57
 
2950
2947
        return &my_charset_utf8_general_ci;
2951
2948
}
2952
2949
 
2953
 
#ifdef XT_STREAMING
2954
 
xtPublic xtBool myxt_use_blobs(XTOpenTablePtr ot, void **ret_pbms_table, xtWord1 *rec_buf)
2955
 
{
2956
 
        void    *pbms_table;
2957
 
        XTTable *tab = ot->ot_table;
2958
 
        u_int   idx = 0;
2959
 
        Field   *field;
2960
 
        char    *blob_ref;
2961
 
        xtWord4 len;
2962
 
        char    in_url[PBMS_BLOB_URL_SIZE];
2963
 
        char    *out_url;
2964
 
 
2965
 
        if (!xt_pbms_open_table(&pbms_table, tab->tab_name->ps_path))
2966
 
                return FAILED;
2967
 
 
2968
 
        for (idx=0; idx<tab->tab_dic.dic_blob_count; idx++) {
2969
 
                field = tab->tab_dic.dic_blob_cols[idx];
2970
 
                if ((blob_ref = mx_get_length_and_data(field, (char *) rec_buf, &len)) && len) {
2971
 
                        xt_strncpy(PBMS_BLOB_URL_SIZE, in_url, blob_ref, len);
2972
 
 
2973
 
                        if (!xt_pbms_use_blob(pbms_table, &out_url, in_url, field->field_index)) {
2974
 
                                xt_pbms_close_table(pbms_table);
2975
 
                                return FAILED;
2976
 
                        }
2977
 
 
2978
 
                        if (out_url) {
2979
 
                                len = strlen(out_url);
2980
 
                                mx_set_length_and_data(field, (char *) rec_buf, len, out_url);
2981
 
                        }
2982
 
                }
2983
 
        }
2984
 
        *ret_pbms_table = pbms_table;
2985
 
        return OK;
2986
 
}
2987
 
 
2988
 
xtPublic void myxt_unuse_blobs(XTOpenTablePtr XT_UNUSED(ot), void *pbms_table)
2989
 
{
2990
 
        xt_pbms_close_table(pbms_table);
2991
 
}
2992
 
 
2993
 
xtPublic xtBool myxt_retain_blobs(XTOpenTablePtr XT_UNUSED(ot), void *pbms_table, xtRecordID rec_id)
2994
 
{
2995
 
        xtBool                          ok;
2996
 
        PBMSEngineRefRec        eng_ref;
2997
 
 
2998
 
        memset(&eng_ref, 0, sizeof(PBMSEngineRefRec));
2999
 
        XT_SET_DISK_8(eng_ref.er_data, rec_id);
3000
 
        ok = xt_pbms_retain_blobs(pbms_table, &eng_ref);
3001
 
        xt_pbms_close_table(pbms_table);
3002
 
        return ok;
3003
 
}
3004
 
 
3005
 
xtPublic void myxt_release_blobs(XTOpenTablePtr ot, xtWord1 *rec_buf, xtRecordID rec_id)
3006
 
{
3007
 
        void                            *pbms_table;
3008
 
        XTTable                         *tab = ot->ot_table;
3009
 
        u_int                           idx = 0;
3010
 
        Field                           *field;
3011
 
        char                            *blob_ref;
3012
 
        xtWord4                         len;
3013
 
        char                            in_url[PBMS_BLOB_URL_SIZE];
3014
 
        PBMSEngineRefRec        eng_ref;
3015
 
 
3016
 
        memset(&eng_ref, 0, sizeof(PBMSEngineRefRec));
3017
 
        XT_SET_DISK_8(eng_ref.er_data, rec_id);
3018
 
 
3019
 
        if (!xt_pbms_open_table(&pbms_table, tab->tab_name->ps_path))
3020
 
                return;
3021
 
 
3022
 
        for (idx=0; idx<tab->tab_dic.dic_blob_count; idx++) {
3023
 
                field = tab->tab_dic.dic_blob_cols[idx];
3024
 
                if ((blob_ref = mx_get_length_and_data(field, (char *) rec_buf, &len)) && len) {
3025
 
                        xt_strncpy(PBMS_BLOB_URL_SIZE, in_url, blob_ref, len);
3026
 
 
3027
 
                        xt_pbms_release_blob(pbms_table, in_url, field->field_index, &eng_ref);
3028
 
                }
3029
 
        }
3030
 
 
3031
 
        xt_pbms_close_table(pbms_table);
3032
 
}
3033
 
#endif // XT_STREAMING
3034
 
 
3035
2950
xtPublic void *myxt_create_thread()
3036
2951
{
3037
2952
#ifdef DRIZZLED