~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to plugin/show_schema_proto/show_schema_proto.cc

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-06-19 10:46:49 UTC
  • mfrom: (1.1.6)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20120619104649-e2l0ggd4oz3um0f4
Tags: upstream-7.1.36-stable
ImportĀ upstreamĀ versionĀ 7.1.36-stable

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
class ShowSchemaProtoFunction : public Item_str_func
41
41
{
42
42
public:
43
 
  ShowSchemaProtoFunction() : Item_str_func() {}
44
43
  String *val_str(String*);
45
44
 
46
45
  void fix_length_and_dec()
47
46
  {
48
47
    max_length= 16384; /* Guesswork? */
49
 
    args[0]->collation.set(
50
 
      get_charset_by_csname(args[0]->collation.collation->csname,
51
 
                            MY_CS_BINSORT), DERIVATION_COERCIBLE);
 
48
    args[0]->collation.set(get_charset_by_csname(args[0]->collation.collation->csname, MY_CS_BINSORT), DERIVATION_COERCIBLE);
52
49
  }
53
50
 
54
51
  const char *func_name() const
69
66
 
70
67
  String *db_sptr= args[0]->val_str(str);
71
68
 
72
 
  if (db_sptr == NULL)
 
69
  if (not db_sptr)
73
70
  {
74
71
    null_value= true;
75
72
    return NULL;
77
74
 
78
75
  null_value= false;
79
76
 
80
 
  const char* db= db_sptr->c_ptr_safe();
81
 
 
82
 
  string proto_as_text("");
83
 
  message::schema::shared_ptr proto;
84
 
 
85
 
 
86
 
  identifier::Schema schema_identifier(db);
87
 
  if (not (proto= plugin::StorageEngine::getSchemaDefinition(schema_identifier)))
 
77
  identifier::Schema schema_identifier(*db_sptr);
 
78
  message::schema::shared_ptr proto= plugin::StorageEngine::getSchemaDefinition(schema_identifier);
 
79
  if (not proto)
88
80
  {
89
81
    my_error(ER_BAD_DB_ERROR, schema_identifier);
90
82
    return NULL;
91
83
  }
92
84
 
 
85
  string proto_as_text;
93
86
  protobuf::TextFormat::PrintToString(*proto, &proto_as_text);
94
87
 
95
 
  if (str->alloc(proto_as_text.length()))
96
 
  {
97
 
    null_value= true;
98
 
    return NULL;
99
 
  }
100
 
 
 
88
  str->alloc(proto_as_text.length());
101
89
  str->length(proto_as_text.length());
102
90
 
103
91
  strncpy(str->ptr(),proto_as_text.c_str(), proto_as_text.length());
120
108
  "show_schema_proto",
121
109
  "1.0",
122
110
  "Stewart Smith",
123
 
  "Shows text representation of schema definition proto",
 
111
  N_("Shows text representation of schema definition proto"),
124
112
  PLUGIN_LICENSE_GPL,
125
 
  initialize, /* Plugin Init */
126
 
  NULL,   /* depends */
127
 
  NULL    /* config options */
 
113
  initialize,
 
114
  NULL,
 
115
  NULL
128
116
}
129
117
DRIZZLE_DECLARE_PLUGIN_END;