Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 24 additions & 30 deletions src/base/object_representation_sr.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ static void or_install_btids_prefix_length (DB_SEQ * prefix_seq, OR_INDEX * inde
static int or_install_btids_filter_pred (DB_SEQ * pred_seq, OR_INDEX * index);
static void or_install_btids_class (OR_CLASSREP * rep, BTID * id, DB_SEQ * constraint_seq, int seq_size,
BTREE_TYPE type, const char *cons_name);
static int or_install_btids_attribute (OR_CLASSREP * rep, int att_id, BTID * id);
static int or_install_btids_attribute (OR_CLASSREP * rep, int att_id, BTID * id, BTREE_TYPE type);
static void or_install_btids_constraint (OR_CLASSREP * rep, DB_SEQ * constraint_seq, BTREE_TYPE type,
const char *cons_name);
static void or_install_btids_function_info (DB_SEQ * fi_seq, OR_INDEX * index);
Expand Down Expand Up @@ -179,6 +179,7 @@ orc_diskrep_from_record (THREAD_ENTRY * thread_p, RECDES * record)
OR_ATTRIBUTE *or_att;
int i, j, k, n_attributes, n_btstats;
BTREE_STATS *bt_statsp;
int bt_stat_index;

DISK_REPR *rep = NULL;
OR_CLASSREP *or_rep = NULL;
Expand Down Expand Up @@ -284,15 +285,8 @@ orc_diskrep_from_record (THREAD_ENTRY * thread_p, RECDES * record)

/* initialize B+tree statistics information */

n_btstats = att->n_btstats = or_att->n_btids;

// TODO (CUBVEC): vector
if (or_att->type == DB_TYPE_VECTOR)
{
att->n_btstats = 0;
continue;
}

/* Vector indexes are not included in B+tree statistics */
n_btstats = att->n_btstats = or_att->n_btids - or_att->n_vector_indexes;
if (n_btstats > 0)
{
att->bt_stats = (BTREE_STATS *) malloc (sizeof (BTREE_STATS) * n_btstats);
Expand All @@ -303,9 +297,15 @@ orc_diskrep_from_record (THREAD_ENTRY * thread_p, RECDES * record)
}
memset (att->bt_stats, 0, sizeof (BTREE_STATS) * n_btstats);

for (j = 0, bt_statsp = att->bt_stats; j < n_btstats; j++, bt_statsp++)
bt_stat_index = 0;
for (j = 0; j < or_att->n_btids; j++)
{
bt_statsp->btid = or_att->btids[j];
if (or_att->btids[j].type == VECTOR_INDEX)
{
continue;
}
bt_statsp = att->bt_stats + bt_stat_index++;
bt_statsp->btid = or_att->btids[j].btid;

bt_statsp->leafs = 0;
bt_statsp->pages = 0;
Expand Down Expand Up @@ -403,6 +403,7 @@ orc_diskrep_from_record (THREAD_ENTRY * thread_p, RECDES * record)
{
bt_statsp->pkeys[k] = 0;
}
assert (bt_stat_index == n_btstats);
} /* for (j = 0, ...) */
}
else
Expand Down Expand Up @@ -2129,7 +2130,7 @@ or_install_btids_class (OR_CLASSREP * rep, BTID * id, DB_SEQ * constraint_seq, i
* id(in): B-tree ID
*/
static int
or_install_btids_attribute (OR_CLASSREP * rep, int att_id, BTID * id)
or_install_btids_attribute (OR_CLASSREP * rep, int att_id, BTID * id, BTREE_TYPE type)
{
int i;
OR_ATTRIBUTE *att;
Expand Down Expand Up @@ -2167,27 +2168,32 @@ or_install_btids_attribute (OR_CLASSREP * rep, int att_id, BTID * id)
{
/* allocate a bigger array and copy over our local pack */
size = ptr->n_btids + OR_ATT_BTID_PREALLOC;
ptr->btids = (BTID *) malloc (sizeof (BTID) * size);
ptr->btids = (OR_ATTRIBUTE_INDEX *) malloc (sizeof (OR_ATTRIBUTE_INDEX) * size);
if (ptr->btids != NULL)
{
memcpy (ptr->btids, ptr->btid_pack, (sizeof (BTID) * ptr->n_btids));
memcpy (ptr->btids, ptr->btid_pack, (sizeof (OR_ATTRIBUTE_INDEX) * ptr->n_btids));
}
ptr->max_btids = size;
}
else
{
/* we already have an externally allocated array, make it bigger */
size = ptr->n_btids + OR_ATT_BTID_PREALLOC;
ptr->btids = (BTID *) realloc (ptr->btids, size * sizeof (BTID));
ptr->btids = (OR_ATTRIBUTE_INDEX *) realloc (ptr->btids, size * sizeof (OR_ATTRIBUTE_INDEX));
ptr->max_btids = size;
}
}
}

if (ptr->btids)
{
ptr->btids[ptr->n_btids] = *id;
ptr->btids[ptr->n_btids].btid = *id;
ptr->btids[ptr->n_btids].type = type;
ptr->n_btids += 1;
if (type == VECTOR_INDEX)
{
ptr->n_vector_indexes += 1;
}
}
else
{
Expand Down Expand Up @@ -2277,19 +2283,7 @@ or_install_btids_constraint (OR_CLASSREP * rep, DB_SEQ * constraint_seq, BTREE_T
}
}

/* CUBVEC-TODO: When updating catalog after creating an index on table,
* we fetch the class representation (classrep) and get index information
* through or_get_classrep().
*
* The logic that updates catalog index metadata (orc_diskrep_from_record)
* assumes all indexes are B+Tree indexes. To avoid running this path
* for vector indexes, we temporarily skip including vector indexes
* in the classrep so they are not written into the catalog.
*/
if (true) // type != VECTOR_INDEX
{
(void) or_install_btids_attribute (rep, att_id, &id);
}
(void) or_install_btids_attribute (rep, att_id, &id, type);
}

/*
Expand Down
12 changes: 10 additions & 2 deletions src/base/object_representation_sr.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ struct or_auto_increment
};
// *INDENT-ON*

typedef struct or_attribute_index OR_ATTRIBUTE_INDEX;
struct or_attribute_index
{
BTID btid; /* B-tree ID for index or constraint */
BTREE_TYPE type; /* index type */
};

typedef struct or_attribute OR_ATTRIBUTE;
struct or_attribute
{
Expand All @@ -101,15 +108,16 @@ struct or_attribute
DB_DEFAULT_EXPR_TYPE on_update_expr; /* on update default expr type */
OR_DEFAULT_VALUE default_value; /* default value */
OR_DEFAULT_VALUE current_default_value; /* default value */
BTID *btids; /* B-tree ID's for indexes and constraints */
OR_ATTRIBUTE_INDEX *btids; /* B-tree ID's for indexes and constraints */
TP_DOMAIN *domain; /* full domain of this attribute */

int n_btids; /* Number of ID's in the btids array */
int n_vector_indexes; /* Number of vector indexes */
BTID index; /* btree id if indexed */

/* local array of btid's to use if possible */
int max_btids; /* Size of the btids array */
BTID btid_pack[OR_ATT_BTID_PREALLOC];
OR_ATTRIBUTE_INDEX btid_pack[OR_ATT_BTID_PREALLOC];

unsigned is_fixed:1; /* non-zero if this is a fixed width attribute */
unsigned is_autoincrement:1; /* non-zero if att is auto increment att */
Expand Down
5 changes: 5 additions & 0 deletions src/optimizer/query_planner.c
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,11 @@ qo_top_plan_new (QO_PLAN * plan)
return plan;
}

if (qo_is_viscan (plan))
{
return plan;
}

all_distinct = tree->info.query.all_distinct;
group_by = tree->info.query.q.select.group_by;
order_by = tree->info.query.order_by;
Expand Down
3 changes: 1 addition & 2 deletions src/query/query_executor.c
Original file line number Diff line number Diff line change
Expand Up @@ -24288,8 +24288,7 @@ qexec_execute_build_columns (THREAD_ENTRY * thread_p, XASL_NODE * xasl, XASL_STA
search_index_type = true;
for (j = 0; j < attrepr->n_btids && search_index_type; j++)
{
btid = attrepr->btids + j;

btid = &attrepr->btids[j].btid;
for (k = 0; k < rep->n_indexes; k++)
{
index = rep->indexes + k;
Expand Down
10 changes: 6 additions & 4 deletions src/storage/heap_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -2812,15 +2812,15 @@ heap_classrepr_dump (THREAD_ENTRY * thread_p, FILE * fp, const OID * class_oid,
/* find index_name */
for (j = 0; j < repr->n_indexes; ++j)
{
if (BTID_IS_EQUAL (&(repr->indexes[j].btid), &(attrepr->btids[k])))
if (BTID_IS_EQUAL (&(repr->indexes[j].btid), &(attrepr->btids[k].btid)))
{
index_name = repr->indexes[j].btname;
break;
}
}

fprintf (fp, " BTID: VFID %d|%d, Root_PGID %d, %s\n", (int) attrepr->btids[k].vfid.volid,
attrepr->btids[k].vfid.fileid, attrepr->btids[k].root_pageid,
fprintf (fp, " BTID: VFID %d|%d, Root_PGID %d, %s\n", (int) attrepr->btids[k].btid.vfid.volid,
attrepr->btids[k].btid.vfid.fileid, attrepr->btids[k].btid.root_pageid,
(index_name == NULL) ? "unknown" : index_name);
}
}
Expand Down Expand Up @@ -7041,7 +7041,7 @@ heap_scancache_start_modify (THREAD_ENTRY * thread_p, HEAP_SCANCACHE * scan_cach
for (i = 0; i < scan_cache->num_btids; i++)
{
// TODO (CUBVEC): refactor this code
if (!BTID_IS_VECTOR_INDEX (&classrepr->indexes[i].btid))
if (classrepr->indexes[i].type != VECTOR_INDEX)
{
scan_cache->m_index_stats->add_empty (classrepr->indexes[i].btid);
}
Expand Down Expand Up @@ -12958,6 +12958,8 @@ heap_attrvalue_get_index (int value_index, ATTR_ID * attrid, int *n_btids, BTID
{
value = &idx_attrinfo->values[value_index];
*n_btids = value->last_attrepr->n_btids;
// TODO (CUBVEC) : OR_ATTRIBUTE structure has been changed due to CUBVEC-142 issue.
// Currently, btids contains index type, we need to collect BTID from array.
*btids = value->last_attrepr->btids;
*attrid = value->attrid;
return &value->dbvalue;
Expand Down
5 changes: 5 additions & 0 deletions src/storage/storage_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,11 @@ struct lorecdes
(((b1)->vfid.fileid == (b2)->vfid.fileid) && \
((b1)->vfid.volid == (b2)->vfid.volid))

/* TODO (CUBVEC) : This function is used to check if the index is a vector index.
* Since all vector indexes are now stored in disk storage,
* we cannot check if the index is a vector index by checking the volume ID.
* We need to check the index type by lookup page header of the index page.
*/
#define BTID_IS_VECTOR_INDEX(btid) ((btid)->vfid.volid == NULL_VOLID)

// TODO (CUBVEC): the following should be removed after CUBVEC-135 is resolved.
Expand Down
9 changes: 3 additions & 6 deletions src/transaction/locator_sr.c
Original file line number Diff line number Diff line change
Expand Up @@ -7906,8 +7906,7 @@ locator_add_or_remove_index_internal (THREAD_ENTRY * thread_p, RECDES * recdes,
assert (scan_cache->m_index_stats != NULL);

// TODO (CUBVEC): refactor this code
//if (!BTID_IS_VECTOR_INDEX (&index->btid))
if (!BTID_IS_VECTOR_INDEX_DUMMY (index->btname))
if (index->type != VECTOR_INDEX)
{
unique_stat_info = &scan_cache->m_index_stats->get_stats_of (index->btid);
}
Expand Down Expand Up @@ -7938,8 +7937,7 @@ locator_add_or_remove_index_internal (THREAD_ENTRY * thread_p, RECDES * recdes,
#if defined(ENABLE_SYSTEMTAP)
CUBRID_IDX_INSERT_START (classname, index->btname);
#endif /* ENABLE_SYSTEMTAP */
//if (BTID_IS_VECTOR_INDEX (&index->btid))
if (BTID_IS_VECTOR_INDEX_DUMMY (index->btname))
if (index->type == VECTOR_INDEX)
{
const DB_VECTOR_FLOAT *vf = db_get_vector_float (key_dbvalue);

Expand Down Expand Up @@ -8548,8 +8546,7 @@ locator_update_index (THREAD_ENTRY * thread_p, RECDES * new_recdes, RECDES * old
{
assert (scan_cache->m_index_stats != NULL);
// TODO (CUBVEC): refactor this code
//if (!BTID_IS_VECTOR_INDEX (&index->btid))
if (!BTID_IS_VECTOR_INDEX_DUMMY (index->btname))
if (index->type != VECTOR_INDEX)
{
unique_stat_info = &scan_cache->m_index_stats->get_stats_of (index->btid);
}
Expand Down