19 #include <drizzled/charset.h>
20 #include <drizzled/error.h>
21 #include <drizzled/function/str/strfunc.h>
22 #include <drizzled/internal/my_sys.h>
23 #include <drizzled/item/func.h>
24 #include <drizzled/message/schema.h>
25 #include <drizzled/plugin/function.h>
26 #include <drizzled/plugin/storage_engine.h>
32 #include <google/protobuf/io/zero_copy_stream.h>
33 #include <google/protobuf/io/zero_copy_stream_impl.h>
34 #include <google/protobuf/text_format.h>
37 using namespace drizzled;
38 using namespace google;
45 void fix_length_and_dec()
48 args[0]->collation.set(get_charset_by_csname(args[0]->collation.collation->csname, MY_CS_BINSORT), DERIVATION_COERCIBLE);
51 const char *func_name()
const
53 return "show_schema_proto";
56 bool check_argument_count(
int n)
65 assert(fixed ==
true);
67 String *db_sptr= args[0]->val_str(str);
78 message::schema::shared_ptr proto= plugin::StorageEngine::getSchemaDefinition(schema_identifier);
81 my_error(ER_BAD_DB_ERROR, schema_identifier);
86 protobuf::TextFormat::PrintToString(*proto, &proto_as_text);
88 str->alloc(proto_as_text.length());
89 str->length(proto_as_text.length());
91 strncpy(str->ptr(),proto_as_text.c_str(), proto_as_text.length());
96 plugin::Create_function<ShowSchemaProtoFunction> *show_schema_proto_func= NULL;
100 show_schema_proto_func=
new plugin::Create_function<ShowSchemaProtoFunction>(
"show_schema_proto");
101 context.add(show_schema_proto_func);
105 DRIZZLE_DECLARE_PLUGIN
111 N_(
"Shows text representation of schema definition proto"),
117 DRIZZLE_DECLARE_PLUGIN_END;