38
void new_index_to_table(
40
, const std::string name
41
, uint16_t num_index_parts
42
, uint32_t field_indexes[]
43
, uint32_t compare_lengths[]
40
void new_index_to_table( drizzle::Table *table,
41
const std::string name,
42
uint16_t num_index_parts,
43
uint32_t field_indexes[],
44
uint32_t compare_lengths[],
47
48
using namespace drizzle;
58
59
index->set_is_primary(is_primary);
59
60
index->set_is_unique(is_unique);
61
while (x < num_index_parts) {
62
while (x < num_index_parts)
63
64
index_part= index->add_index_part();
65
66
field= index_part->mutable_field();
145
146
field_constraints= field->mutable_constraints();
146
147
field_constraints->set_is_nullable(true);
148
149
numeric_field_options= field->mutable_numeric_options();
149
150
numeric_field_options->set_precision(8);
150
151
numeric_field_options->set_scale(3);
154
uint32_t fields_in_index[1]= {6};
155
uint32_t compare_lengths_in_index[1]= {0};
156
bool is_unique= true;
157
bool is_primary= false;
158
/* Add a single-column index on important_number field */
161
, "idx_important_decimal"
164
, compare_lengths_in_index
155
uint32_t fields_in_index[1]= {6};
156
uint32_t compare_lengths_in_index[1]= {0};
157
bool is_unique= true;
158
bool is_primary= false;
159
/* Add a single-column index on important_number field */
160
new_index_to_table(table, "idx_important_decimal", 1, fields_in_index, compare_lengths_in_index, is_primary, is_unique);
171
/* Add a double-column index on first two varchar fields */
172
uint32_t fields_in_index[2]= {0,1};
173
uint32_t compare_lengths_in_index[2]= {20,35};
174
bool is_unique= true;
175
bool is_primary= true;
181
, compare_lengths_in_index
164
/* Add a double-column index on first two varchar fields */
165
uint32_t fields_in_index[2]= {0,1};
166
uint32_t compare_lengths_in_index[2]= {20,35};
167
bool is_unique= true;
168
bool is_primary= true;
169
new_index_to_table(table, "idx_varchar1_2", 2, fields_in_index, compare_lengths_in_index, is_primary, is_unique);
187
172
/* Do engine-specific stuff */
193
int main(int argc, char* argv[])
178
int main(int argc, char* argv[])
195
180
GOOGLE_PROTOBUF_VERIFY_VERSION;
198
184
cerr << "Usage: " << argv[0] << " SCHEMA" << endl;
204
190
fill_table(&table, "example_table");
206
192
fstream output(argv[1], ios::out | ios::trunc | ios::binary);
207
if (!table.SerializeToOstream(&output))
193
if (!table.SerializeToOstream(&output))
209
195
cerr << "Failed to write schema." << endl;