/ GetTableShare: allocates and open a table share. */ /
| 80 | /* GetTableShare: allocates and open a table share. */ |
| 81 | /************************************************************************/ |
| 82 | TABLE_SHARE *GetTableShare(PGLOBAL g, THD *thd, const char *db, |
| 83 | const char *name, bool& mysql) |
| 84 | { |
| 85 | char key[256]; |
| 86 | uint k; |
| 87 | TABLE_SHARE *s; |
| 88 | |
| 89 | k = snprintf(key, sizeof(key), "%s", db) + 1; |
| 90 | k += snprintf(key + k, sizeof(key) - k, "%s", name); |
| 91 | key[++k] = 0; |
| 92 | |
| 93 | if (!(s = alloc_table_share(db, name, key, ++k))) { |
| 94 | strcpy(g->Message, "Error allocating share"); |
| 95 | return NULL; |
| 96 | } // endif s |
| 97 | |
| 98 | if (!open_table_def(thd, s, GTS_TABLE | GTS_VIEW)) { |
| 99 | if (!s->is_view) { |
| 100 | if (stricmp(plugin_name(s->db_plugin)->str, "connect")) |
| 101 | mysql = true; |
| 102 | else |
| 103 | mysql = false; |
| 104 | |
| 105 | } else |
| 106 | mysql = true; |
| 107 | |
| 108 | } else { |
| 109 | if (thd->is_error()) |
| 110 | thd->clear_error(); // Avoid stopping info commands |
| 111 | |
| 112 | snprintf(g->Message, sizeof(g->Message), "Error %d opening share", s->error); |
| 113 | free_table_share(s); |
| 114 | return NULL; |
| 115 | } // endif open_table_def |
| 116 | |
| 117 | return s; |
| 118 | } // end of GetTableShare |
| 119 | |
| 120 | /************************************************************************/ |
| 121 | /* TabColumns: constructs the result blocks containing all the columns */ |
no test coverage detected