MCPcopy Create free account
hub / github.com/MariaDB/server / mysql_ha_read

Function mysql_ha_read

sql/sql_handler.cc:768–1024  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

766*/
767
768bool mysql_ha_read(THD *thd, TABLE_LIST *tables,
769 enum enum_ha_read_modes mode, const char *keyname,
770 List<Item> *key_expr,
771 enum ha_rkey_function ha_rkey_mode, Item *cond,
772 ha_rows select_limit_cnt, ha_rows offset_limit_cnt)
773{
774 SQL_HANDLER *handler;
775 TABLE *table;
776 Protocol *protocol= thd->protocol;
777 char buff[MAX_FIELD_WIDTH];
778 String buffer(buff, sizeof(buff), system_charset_info);
779 int error, keyno;
780 uint num_rows;
781 uchar *UNINIT_VAR(key);
782 MDL_deadlock_and_lock_abort_error_handler sql_handler_lock_error;
783 DBUG_ENTER("mysql_ha_read");
784 DBUG_PRINT("enter",("'%s'.'%s' as '%s'",
785 tables->db.str, tables->table_name.str, tables->alias.str));
786
787 if (thd->locked_tables_mode)
788 {
789 my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0));
790 DBUG_RETURN(TRUE);
791 }
792
793retry:
794 if (!(handler= mysql_ha_find_handler(thd, &tables->alias)))
795 goto err0;
796
797 if (thd->transaction->xid_state.check_has_uncommitted_xa())
798 goto err0;
799
800 table= handler->table;
801 tables->table= table; // This is used by fix_fields
802 table->pos_in_table_list= tables;
803
804 if (handler->lock->table_count > 0)
805 {
806 int lock_error;
807
808 THR_LOCK_DATA **pos,**end;
809 for (pos= handler->lock->locks,
810 end= handler->lock->locks + handler->lock->lock_count;
811 pos < end;
812 pos++)
813 {
814 pos[0]->type= pos[0]->org_type;
815 }
816
817 /* save open_tables state */
818 TABLE* backup_open_tables= thd->open_tables;
819 /* Always a one-element list, see mysql_ha_open(). */
820 DBUG_ASSERT(table->next == NULL || table->s->tmp_table);
821 /*
822 mysql_lock_tables() needs thd->open_tables to be set correctly to
823 be able to handle aborts properly.
824 */
825 thd->set_open_tables(table);

Callers 1

sql_parse.ccFile · 0.85

Calls 15

my_errorFunction · 0.85
mysql_ha_find_handlerFunction · 0.85
mysql_lock_tablesFunction · 0.85
trans_rollback_stmtFunction · 0.85
mysql_ha_close_tableFunction · 0.85
key_copyFunction · 0.85
trans_commit_stmtFunction · 0.85
mysql_unlock_tablesFunction · 0.85
my_eofFunction · 0.85
set_open_tablesMethod · 0.80

Tested by

no test coverage detected