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>
28 #include <drizzled/identifier.h>
29 #include <drizzled/session.h>
30 #include <drizzled/catalog/instance.h>
36 #include <google/protobuf/io/zero_copy_stream.h>
37 #include <google/protobuf/io/zero_copy_stream_impl.h>
38 #include <google/protobuf/text_format.h>
49 void fix_length_and_dec()
52 args[0]->collation.set(get_charset_by_csname(args[0]->collation.collation->csname, MY_CS_BINSORT), DERIVATION_COERCIBLE);
55 const char *func_name()
const
57 return "show_schema_proto";
69 assert(fixed ==
true);
71 String *db_sptr= args[0]->val_str(str);
83 message::schema::shared_ptr proto= plugin::StorageEngine::getSchemaDefinition(schema_identifier);
86 my_error(ER_BAD_DB_ERROR, schema_identifier);
91 protobuf::TextFormat::PrintToString(*proto, &proto_as_text);
93 str->alloc(proto_as_text.length());
94 str->length(proto_as_text.length());
96 strncpy(str->ptr(),proto_as_text.c_str(), proto_as_text.length());
101 plugin::Create_function<ShowSchemaProtoFunction> *show_schema_proto_func= NULL;
105 show_schema_proto_func=
new plugin::Create_function<ShowSchemaProtoFunction>(
"show_schema_proto");
106 context.add(show_schema_proto_func);
110 DRIZZLE_DECLARE_PLUGIN
116 N_(
"Shows text representation of schema definition proto"),
122 DRIZZLE_DECLARE_PLUGIN_END;
String * val_str(String *)
TODO: Rename this file - func.h is stupid.
bool check_argument_count(int n)