| 792 | */ |
| 793 | |
| 794 | bool Create_json_table::add_json_table_fields(THD *thd, TABLE *table, |
| 795 | Table_function_json_table *jt) |
| 796 | { |
| 797 | TABLE_SHARE *share= table->s; |
| 798 | Json_table_column *jc; |
| 799 | uint fieldnr= 0; |
| 800 | MEM_ROOT *mem_root_save= thd->mem_root; |
| 801 | List_iterator_fast<Json_table_column> jc_i(jt->m_columns); |
| 802 | Column_derived_attributes da(&my_charset_utf8mb4_general_ci); |
| 803 | DBUG_ENTER("add_json_table_fields"); |
| 804 | |
| 805 | thd->mem_root= &table->mem_root; |
| 806 | current_counter= other; |
| 807 | |
| 808 | while ((jc= jc_i++)) |
| 809 | { |
| 810 | Create_field *sql_f= jc->m_field; |
| 811 | List_iterator_fast<Json_table_column> it2(jt->m_columns); |
| 812 | Json_table_column *jc2; |
| 813 | /* |
| 814 | Initialize length from its original value (number of characters), |
| 815 | which was set in the parser. This is necessary if we're |
| 816 | executing a prepared statement for the second time. |
| 817 | */ |
| 818 | sql_f->length= sql_f->char_length; |
| 819 | |
| 820 | if (sql_f->prepare_stage1(thd, thd->mem_root, |
| 821 | COLUMN_DEFINITION_TABLE_FIELD, |
| 822 | &da)) |
| 823 | goto err_exit; |
| 824 | |
| 825 | while ((jc2= it2++) != jc) |
| 826 | { |
| 827 | if (sql_f->field_name.streq(jc2->m_field->field_name)) |
| 828 | { |
| 829 | my_error(ER_DUP_FIELDNAME, MYF(0), sql_f->field_name.str); |
| 830 | goto err_exit; |
| 831 | } |
| 832 | } |
| 833 | it2.rewind(); |
| 834 | } |
| 835 | |
| 836 | jc_i.rewind(); |
| 837 | |
| 838 | while ((jc= jc_i++)) |
| 839 | { |
| 840 | Create_field *sql_f= jc->m_field; |
| 841 | Record_addr addr(!(sql_f->flags & NOT_NULL_FLAG)); |
| 842 | Bit_addr bit(addr.null()); |
| 843 | uint uneven_delta; |
| 844 | |
| 845 | sql_f->prepare_stage2(table->file, table->file->ha_table_flags()); |
| 846 | |
| 847 | if (!sql_f->charset) |
| 848 | sql_f->charset= &my_charset_utf8mb4_bin; |
| 849 | |
| 850 | Field *f= sql_f->type_handler()->make_table_field_from_def(share, |
| 851 | thd->mem_root, &sql_f->field_name, addr, bit, sql_f, sql_f->flags); |
no test coverage detected