118
118
return (*str != '\0');
122
bool drizzled_show_create(Session *session, TableList *table_list, bool is_if_not_exists)
125
String buffer(buff, sizeof(buff), system_charset_info);
127
/* Only one table for now, but VIEW can involve several tables */
128
if (session->openTables(table_list))
130
if (session->is_error())
134
Clear all messages with 'error' level status and
135
issue a warning with 'warning' level status in
136
case of invalid view and last error is ER_VIEW_INVALID
138
drizzle_reset_errors(session, true);
139
session->clear_error();
144
if (store_create_info(table_list, &buffer, is_if_not_exists))
147
List<Item> field_list;
149
field_list.push_back(new Item_empty_string("Table",NAME_CHAR_LEN));
150
// 1024 is for not to confuse old clients
151
field_list.push_back(new Item_empty_string("Create Table",
152
max(buffer.length(),(uint32_t)1024)));
155
if (session->client->sendFields(&field_list))
158
session->client->store(table_list->table->getAlias());
161
session->client->store(buffer.ptr(), buffer.length());
163
if (session->client->flush())
171
Get a CREATE statement for a given database.
173
The database is identified by its name, passed as @c dbname parameter.
174
The name should be encoded using the system character set (UTF8 currently).
176
Resulting statement is stored in the string pointed by @c buffer. The string
177
is emptied first and its character set is set to the system character set.
179
If is_if_not_exists is set, then
180
the resulting CREATE statement contains "IF NOT EXISTS" clause. Other flags
181
in @c create_options are ignored.
183
@param session The current thread instance.
184
@param dbname The name of the database.
185
@param buffer A String instance where the statement is stored.
186
@param create_info If not NULL, the options member influences the resulting
189
@returns true if errors are detected, false otherwise.
192
static bool store_db_create_info(SchemaIdentifier &schema_identifier, string &buffer, bool if_not_exists)
194
message::Schema schema;
196
bool found= plugin::StorageEngine::getSchemaDefinition(schema_identifier, schema);
200
buffer.append("CREATE DATABASE ");
203
buffer.append("IF NOT EXISTS ");
206
buffer.append(schema.name());
209
if (schema.has_collation())
211
buffer.append(" COLLATE = ");
212
buffer.append(schema.collation());
218
bool mysqld_show_create_db(Session &session, SchemaIdentifier &schema_identifier, bool if_not_exists)
220
message::Schema schema_message;
223
if (not plugin::StorageEngine::getSchemaDefinition(schema_identifier, schema_message))
226
This assumes that the only reason for which store_db_create_info()
227
can fail is incorrect database name (which is the case now).
229
my_error(ER_BAD_DB_ERROR, MYF(0), schema_identifier.getSQLPath().c_str());
233
if (not store_db_create_info(schema_identifier, buffer, if_not_exists))
236
This assumes that the only reason for which store_db_create_info()
237
can fail is incorrect database name (which is the case now).
239
my_error(ER_BAD_DB_ERROR, MYF(0), schema_identifier.getSQLPath().c_str());
243
List<Item> field_list;
244
field_list.push_back(new Item_empty_string("Database",NAME_CHAR_LEN));
245
field_list.push_back(new Item_empty_string("Create Database",1024));
247
if (session.client->sendFields(&field_list))
250
session.client->store(schema_message.name());
251
session.client->store(buffer);
253
if (session.client->flush())
122
262
Get the quote character for displaying an identifier.
287
#define LIST_PROCESS_HOST_LEN 64
290
Build a CREATE TABLE statement for a table.
294
table_list A list containing one table to write statement
296
packet Pointer to a string where statement will be
300
Currently always return 0, but might return error code in the
307
int store_create_info(TableList *table_list, String *packet, bool is_if_not_exists)
309
Table *table= table_list->table;
311
table->restoreRecordAsDefault(); // Get empty record
315
enum drizzled::message::TransformSqlError transform_err;
317
(void)is_if_not_exists;
319
transform_err= message::transformTableDefinitionToSql(*(table->getShare()->getTableProto()),
324
packet->append(create_sql.c_str(), create_sql.length(), default_charset_info);
329
/****************************************************************************
330
Return info about all processes
331
returns for each thread: thread id, user, host, db, command, info
332
****************************************************************************/
347
thread_info(uint64_t thread_id_arg,
348
time_t start_time_arg,
349
uint32_t command_arg,
350
const string &user_arg,
351
const string &host_arg,
352
const string &db_arg,
353
const string &proc_info_arg,
354
const string &state_info_arg,
355
const string &query_arg)
356
: thread_id(thread_id_arg), start_time(start_time_arg), command(command_arg),
357
user(user_arg), host(host_arg), db(db_arg), proc_info(proc_info_arg),
358
state_info(state_info_arg), query(query_arg)
146
362
} /* namespace drizzled */