| 650 | } |
| 651 | |
| 652 | void |
| 653 | dbcontext::cmd_insert_internal(dbcallback_i& cb, const prep_stmt& pst, |
| 654 | const string_ref *fvals, size_t fvalslen) |
| 655 | { |
| 656 | if (!for_write_flag) { |
| 657 | return cb.dbcb_resp_short(2, "readonly"); |
| 658 | } |
| 659 | lock_tables_if(); |
| 660 | if (lock == 0) { |
| 661 | return cb.dbcb_resp_short(1, "lock_tables"); |
| 662 | } |
| 663 | if (pst.get_table_id() >= table_vec.size()) { |
| 664 | return cb.dbcb_resp_short(2, "tblnum"); |
| 665 | } |
| 666 | TABLE *const table = table_vec[pst.get_table_id()].table; |
| 667 | handler *const hnd = table->file; |
| 668 | uchar *const buf = table->record[0]; |
| 669 | empty_record(table); |
| 670 | memset(buf, 0, table->s->null_bytes); /* clear null flags */ |
| 671 | const prep_stmt::fields_type& rf = pst.get_ret_fields(); |
| 672 | const size_t n = std::min(rf.size(), fvalslen); |
| 673 | for (size_t i = 0; i < n; ++i) { |
| 674 | uint32_t fn = rf[i]; |
| 675 | Field *const fld = table->field[fn]; |
| 676 | if (fvals[i].begin() == 0) { |
| 677 | fld->set_null(); |
| 678 | } else { |
| 679 | fld->store(fvals[i].begin(), fvals[i].size(), &my_charset_bin); |
| 680 | } |
| 681 | } |
| 682 | table->next_number_field = table->found_next_number_field; |
| 683 | /* FIXME: test */ |
| 684 | const int r = hnd->ha_write_row(buf); |
| 685 | const ulonglong insert_id = table->file->insert_id_for_cur_row; |
| 686 | table->next_number_field = 0; |
| 687 | table_vec[pst.get_table_id()].modified = true; |
| 688 | if (r == 0 && table->found_next_number_field != 0) { |
| 689 | return cb.dbcb_resp_short_num64(0, insert_id); |
| 690 | } |
| 691 | if (r != 0) { |
| 692 | return cb.dbcb_resp_short_num(1, r); |
| 693 | } |
| 694 | return cb.dbcb_resp_short(0, ""); |
| 695 | } |
| 696 | |
| 697 | void |
| 698 | dbcontext::cmd_sql_internal(dbcallback_i& cb, const prep_stmt& pst, |
nothing calls this directly
no test coverage detected