ha_innobase::general_fetch

/***********************************************************************//**
Reads the next or previous row from a cursor, which must have previously been
positioned using index_read.
@return    0, HA_ERR_END_OF_FILE, or error number */
UNIV_INTERN
int
ha_innobase::general_fetch(
/*=======================*/
    uchar*    buf,        /*!< in/out: buffer for next row in MySQL
                format */
    uint    direction,    /*!< in: ROW_SEL_NEXT or ROW_SEL_PREV */
    uint    match_mode)    /*!< in: 0, ROW_SEL_EXACT, or
                ROW_SEL_EXACT_PREFIX */
{
    ulint        ret;
    int        error    = 0;

    DBUG_ENTER("general_fetch");

    ut_a(prebuilt->trx == thd_to_trx(user_thd));

    innodb_srv_conc_enter_innodb(prebuilt->trx);

    ret = row_search_for_mysql((byte*)buf, 0, prebuilt, match_mode, direction);

    innodb_srv_conc_exit_innodb(prebuilt->trx);

    switch (ret) {
    case DB_SUCCESS:
        error = 0;
        table->status = 0;
        break;
    case DB_RECORD_NOT_FOUND:
        error = HA_ERR_END_OF_FILE;
        table->status = STATUS_NOT_FOUND;
        break;
    case DB_END_OF_INDEX:
        error = HA_ERR_END_OF_FILE;
        table->status = STATUS_NOT_FOUND;
        break;
    default:
        error = convert_error_code_to_mysql(
            (int) ret, prebuilt->table->flags, user_thd);
        table->status = STATUS_NOT_FOUND;
        break;
    }

    DBUG_RETURN(error);
}
时间: 2024-08-11 09:53:42

ha_innobase::general_fetch的相关文章

class ha_innobase: public handler

/** The class defining a handle to an Innodb table */ class ha_innobase: public handler { row_prebuilt_t* prebuilt; /*!< prebuilt struct in InnoDB, used to save CPU time with prebuilt data structures*/ THD* user_thd; /*!< the thread handle of the us

ha_innobase::rnd_next

/*****************************************************************//** Reads the next row in a table scan (also used to read the FIRST row in a table scan). @return 0, HA_ERR_END_OF_FILE, or error number */ UNIV_INTERN int ha_innobase::rnd_next( /*==

ha_innobase::open

http://mysql.taobao.org/monthly/2015/08/07/ /*****************************************************************//** Creates and opens a handle to a table which already exists in an InnoDB database. @return 1 if error, 0 if success */ UNIV_INTERN int h

select 数据

http://blog.csdn.net/wudongxu/article/details/6683846 ha_innobase::open ib_table = dict_table_get(norm_name, TRUE, ignore_err); prebuilt = row_create_prebuilt(ib_table, table->s->reclength); ha_innobase::rnd_next if(第一次查找) index_first(buf); else gen

select count(*) 底层究竟做了什么?

阅读本文大概需要 6.6 分钟. SELECT COUNT( * ) FROM t是个再常见不过的 SQL 需求了.在 MySQL 的使用规范中,我们一般使用事务引擎 InnoDB 作为(一般业务)表的存储引擎,在此前提下,COUNT( * )操作的时间复杂度为 O(N),其中 N 为表的行数. 而 MyISAM 表中可以快速取到表的行数.这些实践经验的背后是怎样的机制,以及为什么需要/可以是这样,就是此文想要探讨的. 先来看一下概况: MySQL COUNT( * ) 在 2 种存储引擎中的部

MySQL 外键异常分析

外键约束异常现象 如下测例中,没有违反引用约束的插入失败. create database `a-b`; use `a-b`; SET FOREIGN_KEY_CHECKS=0; create table t1(c1 int primary key, c2 int) engine=innodb; create table t2(c1 int primary key, c2 int) engine=innodb; alter table t2 add foreign key(c2) referen

怎么跳出MySQL的10个大坑

淘宝自从2010开始规模使用MySQL,替换了之前商品.交易.用户等原基于IOE方案的核心数据库,目前已部署数千台规模.同时和Oracle, Percona, Mariadb等上游厂商有良好合作,共向上游提交20多个Patch.目前淘宝核心系统研发部数据库组,根据淘宝的业务需求,改进数据库和提升性能,提供高性能.可扩展的.稳定可靠的数据库(存储)解决方案. 目前有以下几个方向:单机,提升单机数据库的性能,增加我们所需特性:集群,提供性能扩展,可靠性,可能涉及分布式事务处理:IO存储体系,跟踪IO

MYSQL INNODB主键使用varchar和int有什么区别?

本文和大家分享的主要是MYSQL 数据库主键使用varchar和int的区别,一起来看看吧,希望对大家学习mysql有所帮助. 我现在总结的3个问题: 1.tablespace中空间浪费 当然我们知道使用varchar可能会导致辅助索引比较大,因为用到varchar可能存储的字符较多,同时 在行头也存在一个可变字段字符区域(1-2)字节 而辅助索引叶子结点毕竟都存储了主键值,这样至少会多varchar数据字节数量+1(或者2) 字节- 4(int)字节空间. 如果辅助索引比较多空间浪费是可想而知

MySQL数据库InnoDB存储引擎多版本控制(MVCC)实现原理分析

文/何登成 导读:   来自网易研究院的MySQL内核技术研究人何登成,把MySQL数据库InnoDB存储引擎的多版本控制(简称:MVCC)实现原理,做了深入的研究与详细的文字图表分析,方便大家理解InnoDB存储引擎实现的多版本控制技术(简称:MVCC). 基本知识 假设对于多版本控制(MVCC)的基础知识,有所了解.MySQL数据库InnoDB存储引擎为了实现多版本的一致性读,采用的是基于回滚段的协议. 行结构 MySQL数据库InnoDB存储引擎表数据的组织方式为主键聚簇索引.由于采用索引