Skip to content

Commit a00e0b8

Browse files
committed
first go at implementing some handler functions
1 parent 9db333e commit a00e0b8

File tree

1 file changed

+45
-12
lines changed

1 file changed

+45
-12
lines changed

storage/example/ha_example.cc

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -449,14 +449,42 @@ int ha_example::close(void)
449449

450450
int ha_example::write_row(uchar *buf)
451451
{
452-
DBUG_ENTER("ha_example::write_row");
453-
/*
454-
Example of a successful write_row. We don't store the data
455-
anywhere; they are thrown away. A real implementation will
456-
probably need to do something with 'buf'. We report a success
457-
here, to pretend that the insert was successful.
458-
*/
459-
DBUG_RETURN(0);
452+
DBUG_ENTER("ha_example::write_row");
453+
454+
if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT) {
455+
table->timestamp_field->set_time();
456+
}
457+
458+
if (table->next_number_field && buf == table->record[0]) {
459+
int error;
460+
461+
if ((error = update_auto_increment())) {
462+
return error;
463+
}
464+
}
465+
466+
my_bitmap_map *old_map = dbug_tmp_use_all_columns(table, table->read_set);
467+
my_ptrdiff_t offset = (my_ptrdiff_t) (buf - table->record[0]);
468+
469+
for (uint i = 0; i < table->s->fields; i++) {
470+
Field *field = table->field[i];
471+
field->move_field_offset(offset);
472+
473+
uint index = field->field_index;
474+
475+
char tmp_buf[1024];
476+
String tmp(tmp_buf, sizeof(tmp_buf), &my_charset_bin);
477+
String *val = field->val_str(&tmp, &tmp);
478+
479+
DBUG_PRINT("ha_example", ("at index '%d'", index));
480+
DBUG_PRINT("ha_example", ("table name is '%s'", field->table_name[0]));
481+
DBUG_PRINT("ha_example", ("name is '%s'", field->field_name));
482+
DBUG_PRINT("ha_example", ("value is '%s'", val->c_ptr()));
483+
}
484+
485+
dbug_tmp_restore_column_map(table->read_set, old_map);
486+
487+
DBUG_RETURN(0);
460488
}
461489

462490

@@ -628,6 +656,7 @@ int ha_example::index_last(uchar *buf)
628656
int ha_example::rnd_init(bool scan)
629657
{
630658
DBUG_ENTER("ha_example::rnd_init");
659+
631660
DBUG_RETURN(HA_ERR_WRONG_COMMAND);
632661
}
633662

@@ -991,10 +1020,14 @@ int ha_example::create(const char *name, TABLE *table_arg,
9911020
HA_CREATE_INFO *create_info)
9921021
{
9931022
DBUG_ENTER("ha_example::create");
994-
/*
995-
This is not implemented but we want someone to be able to see that it
996-
works.
997-
*/
1023+
1024+
String file_name;
1025+
file_name.append("foo");
1026+
file_name.append("bar");
1027+
file_name.append("baz");
1028+
1029+
DBUG_PRINT("ha_example", ("filename is '%s'", file_name.c_ptr()));
1030+
9981031
DBUG_RETURN(0);
9991032
}
10001033

0 commit comments

Comments
 (0)