inline void Descriptor::insert_column_link(size_t col_ndx, DataType type, StringData name, Table& target, LinkType link_type) { typedef _impl::TableFriend tf; if (REALM_UNLIKELY(!is_attached() || !target.is_attached())) throw LogicError(LogicError::detached_accessor); if (REALM_UNLIKELY(col_ndx > get_column_count())) throw LogicError(LogicError::column_index_out_of_range); if (REALM_UNLIKELY(!tf::is_link_type(ColumnType(type)))) throw LogicError(LogicError::illegal_type); if (REALM_UNLIKELY(!is_root())) throw LogicError(LogicError::wrong_kind_of_descriptor); // Both origin and target must be group-level tables, and in the same group. Group* origin_group = tf::get_parent_group(*get_root_table()); Group* target_group = tf::get_parent_group(target); if (!origin_group || !target_group) throw LogicError(LogicError::wrong_kind_of_table); if (origin_group != target_group) throw LogicError(LogicError::group_mismatch); LinkTargetInfo link(&target); tf::insert_column(*this, col_ndx, type, name, link); // Throws adj_insert_column(col_ndx); tf::set_link_type(*get_root_table(), col_ndx, link_type); // Throws }
int CSQLiteQuery::ColumnValue(int iCol, LPTSTR pszValue, DWORD dwLength, BOOL& bIsNull) { int nRtVal = ERROR_SUCCESS; const unsigned char *lpszValueA; if( SQLITE_NULL == ColumnType(iCol) ) { bIsNull = TRUE; } else { lpszValueA = sqlite3_column_text(m_pStmt, iCol); if( NULL == lpszValueA ) { nRtVal = -ERROR_FUNCTION_FAILED; } else { #ifdef _UNICODE MultiByteToWideChar( CP_ACP, 0, (LPCSTR)lpszValueA, -1, pszValue, dwLength ); #else StringCchCopy(pszValue, dwLength, lpszValueA); #endif bIsNull = FALSE; } } return nRtVal; }
inline bool Spec::get_first_column_type_from_ref(ref_type top_ref, Allocator& alloc, ColumnType& type) noexcept { const char* top_header = alloc.translate(top_ref); ref_type types_ref = to_ref(Array::get(top_header, 0)); const char* types_header = alloc.translate(types_ref); if (Array::get_size_from_header(types_header) == 0) return false; type = ColumnType(Array::get(types_header, 0)); return true; }
void ZipIntKeyIndex::load(PathRef path) { auto fpath = path + ".zint"; m_mmapBase = (byte_t*)mmap_load(fpath.string(), &m_mmapSize); auto h = (const Header*)m_mmapBase; m_isUnique = h->isUnique ? true : false; m_keyType = ColumnType(h->keyType); m_minKey = h->minKey; size_t indexBits = terark_bsr_u64(h->rows - 1) + 1; m_keys .risk_set_data((byte*)(h+1) , h->rows, h->keyBits); m_index.risk_set_data((byte*)(h+1) + m_keys.mem_size(), h->rows, indexBits); }
inline void Spec::set_column_type(size_t column_ndx, ColumnType type) { REALM_ASSERT(column_ndx < get_column_count()); // At this point we only support upgrading to string enum REALM_ASSERT(ColumnType(m_types.get(column_ndx)) == col_type_String); REALM_ASSERT(type == col_type_StringEnum); m_types.set(column_ndx, type); // Throws update_has_strong_link_columns(); }
inline void Descriptor::set_link_type(size_t col_ndx, LinkType link_type) { typedef _impl::TableFriend tf; if (REALM_UNLIKELY(!is_attached())) throw LogicError(LogicError::detached_accessor); if (REALM_UNLIKELY(col_ndx >= get_column_count())) throw LogicError(LogicError::column_index_out_of_range); if (REALM_UNLIKELY(!tf::is_link_type(ColumnType(get_column_type(col_ndx))))) throw LogicError(LogicError::illegal_type); tf::set_link_type(*get_root_table(), col_ndx, link_type); // Throws }
int CSQLiteQuery::ColumnValue(int iCol, INT64& nValue, BOOL& bIsNull) { if( SQLITE_NULL == ColumnType(iCol) ) { bIsNull = TRUE; } else { nValue = sqlite3_column_int64(m_pStmt, iCol); bIsNull = FALSE; } return ERROR_SUCCESS; }
inline void Descriptor::insert_column(size_t col_ndx, DataType type, StringData name, DescriptorRef* subdesc, bool nullable) { typedef _impl::TableFriend tf; if (REALM_UNLIKELY(!is_attached())) throw LogicError(LogicError::detached_accessor); if (REALM_UNLIKELY(col_ndx > get_column_count())) throw LogicError(LogicError::column_index_out_of_range); if (REALM_UNLIKELY(tf::is_link_type(ColumnType(type)))) throw LogicError(LogicError::illegal_type); LinkTargetInfo invalid_link; tf::insert_column(*this, col_ndx, type, name, invalid_link, nullable); // Throws adj_insert_column(col_ndx); if (subdesc && type == type_Table) *subdesc = get_subdescriptor(col_ndx); }
ECode CStmt::Column( /* [in] */ Int32 col, /* [out] */ IInterface** obj) { VALIDATE_NOT_NULL(obj); Int32 type = 0; ColumnType(col,&type); switch (type) { case SQLITE_INTEGER: { Int64 value = 0; ColumnLong(col,&value); *obj = (IInterface *)&value; // android-changed: performance } break; case SQLITE_FLOAT: { Double value = 0.0; ColumnDouble(col,&value); *obj = (IInterface *)&value; } break; case SQLITE_BLOB: { AutoPtr<ArrayOf<Byte> > value; ColumnBytes(col,(ArrayOf<unsigned char>**)&value); *obj = (IInterface *)&value; } break; case SQLITE3_TEXT: { String value; ColumnString(col,&value); *obj = (IInterface *)&value; } break; } REFCOUNT_ADD(*obj); return NOERROR; }
bool c4_HandlerSeq::IsNested(int index_)const { return ColumnType(index_) == 'V'; }
ColumnType Column::getType(void) const throw () { return ColumnType(sqlite3_column_type(m_Statement.statement.get(), m_index)); }
inline ColumnType Spec::get_column_type(size_t ndx) const noexcept { REALM_ASSERT(ndx < get_column_count()); return ColumnType(m_types.get(ndx)); }
Database::Query::ColumnType Database::Query::getType(int column) { return _stmt ? ColumnType(sqlite3_column_type(_stmt, column)) : TYPE_NULL; }