Changed default max length of VARCHAR from 4096 to 255 with a new variable to configure it

This commit is contained in:
2020-10-15 11:05:49 +01:00
parent dea358d146
commit 572cb38e0f
2 changed files with 18 additions and 5 deletions

View File

@@ -147,6 +147,9 @@ struct column_data_t *initEmptyColumn(e_column_type type, int nullable, const ch
col->type = type;
col->type_bytes = columnTypeToByteSize(col->type);
if (col->type == TYPE_STRING) {
col->max_len = 255;
}
col->n_values = 0;
@@ -462,11 +465,18 @@ void escapeColumnName_sb(str_builder *sb,
strbld_char(sb,'`');
strbld_char(sb,'.');
}
if (col_len == 0) {
col_len = strlen(col);
}
if (col_len == 1 && col[0] == '*') {
strbld_char(sb, '*');
} else {
strbld_char(sb,'`');
if (col != 0) {
strbld_str(sb, col, col_len);
}
strbld_char(sb,'`');
}
}
char *escapeColumnNameAs(char **str, size_t *len, const char *tbl, size_t tbl_len,
@@ -551,7 +561,9 @@ void columnCreateStr_sb(str_builder *sb, struct column_data_t *col)
strbld_str(sb, "DOUBLE", 6);
break;
case TYPE_STRING:
strbld_str(sb, "VARCHAR(4096)", 13);
strbld_str(sb, "VARCHAR(", 8);
db_value_sb(sb, TYPE_UINT32, 1, col->max_len);
strbld_char(sb, ')');
break;
case TYPE_BLOB:
strbld_str(sb, "MEDIUMBLOB", 10);

View File

@@ -37,6 +37,7 @@ struct column_data_t {
enum e_column_type_t type;
size_t type_bytes;
size_t max_len;
size_t n_values;