| 128 | */ |
| 129 | |
| 130 | bool check_duplicate_names(THD *thd, List<Item> &item_list, bool gen_unique_view_name) |
| 131 | { |
| 132 | Item *item; |
| 133 | List_iterator_fast<Item> it(item_list); |
| 134 | List_iterator_fast<Item> itc(item_list); |
| 135 | DBUG_ENTER("check_duplicate_names"); |
| 136 | |
| 137 | while ((item= it++)) |
| 138 | { |
| 139 | Item *check; |
| 140 | /* treat underlying fields like set by user names */ |
| 141 | if (item->real_item()->type() == Item::FIELD_ITEM) |
| 142 | item->base_flags|= item_base_t::IS_EXPLICIT_NAME; |
| 143 | itc.rewind(); |
| 144 | while ((check= itc++) && check != item) |
| 145 | { |
| 146 | if (item->name.streq(check->name)) |
| 147 | { |
| 148 | if (!gen_unique_view_name) |
| 149 | goto err; |
| 150 | if (!item->is_explicit_name()) |
| 151 | make_unique_view_field_name(thd, item, item_list, item); |
| 152 | else if (!check->is_explicit_name()) |
| 153 | make_unique_view_field_name(thd, check, item_list, item); |
| 154 | else |
| 155 | goto err; |
| 156 | } |
| 157 | } |
| 158 | } |
| 159 | DBUG_RETURN(FALSE); |
| 160 | |
| 161 | err: |
| 162 | my_error(ER_DUP_FIELDNAME, MYF(0), item->name.str); |
| 163 | DBUG_RETURN(TRUE); |
| 164 | } |
| 165 | |
| 166 | |
| 167 | /** |
no test coverage detected