| 79 | */ |
| 80 | |
| 81 | int ha_sequence::open(const char *name, int mode, uint flags) |
| 82 | { |
| 83 | int error; |
| 84 | DBUG_ENTER("ha_sequence::open"); |
| 85 | DBUG_ASSERT(table->s == table_share && file); |
| 86 | |
| 87 | file->table= table; |
| 88 | file->option_struct= option_struct; |
| 89 | if (likely(!(error= file->open(name, mode, flags)))) |
| 90 | { |
| 91 | /* |
| 92 | Allocate ref in table's mem_root. We can't use table's ref |
| 93 | as it's allocated by ha_ caller that allocates this. |
| 94 | */ |
| 95 | ref_length= file->ref_length; |
| 96 | if (!(ref= (uchar*) alloc_root(&table->mem_root,ALIGN_SIZE(ref_length)*2))) |
| 97 | { |
| 98 | file->ha_close(); |
| 99 | error=HA_ERR_OUT_OF_MEM; |
| 100 | DBUG_RETURN(error); |
| 101 | } |
| 102 | file->ref= ref; |
| 103 | file->dup_ref= dup_ref= ref+ALIGN_SIZE(file->ref_length); |
| 104 | |
| 105 | /* |
| 106 | ha_open() sets the following for us. We have to set this for the |
| 107 | underlying handler |
| 108 | */ |
| 109 | file->cached_table_flags= (file->table_flags() | HA_REUSES_FILE_NAMES); |
| 110 | |
| 111 | file->reset_statistics(); |
| 112 | internal_tmp_table= file->internal_tmp_table= |
| 113 | MY_TEST(flags & HA_OPEN_INTERNAL_TABLE); |
| 114 | reset_statistics(); |
| 115 | |
| 116 | /* |
| 117 | Don't try to read the initial row if the call is part of CREATE, REPAIR |
| 118 | or FLUSH |
| 119 | */ |
| 120 | if (!(flags & (HA_OPEN_FOR_CREATE | HA_OPEN_FOR_REPAIR | |
| 121 | HA_OPEN_FOR_FLUSH))) |
| 122 | { |
| 123 | if (unlikely((error= table->s->sequence->read_initial_values(table)))) |
| 124 | file->ha_close(); |
| 125 | } |
| 126 | else if (!table->s->tmp_table) |
| 127 | table->internal_set_needs_reopen(true); |
| 128 | |
| 129 | /* |
| 130 | The following is needed to fix comparison of rows in |
| 131 | ha_update_first_row() for InnoDB |
| 132 | */ |
| 133 | if (!error) |
| 134 | memcpy(table->record[1], table->s->default_values, table->s->reclength); |
| 135 | } |
| 136 | DBUG_RETURN(error); |
| 137 | } |
| 138 |
nothing calls this directly
no test coverage detected