Skip to content

Commit 0ad44c9

Browse files
committed
Added support for 5.5 in information_schema.columns table parsing
In 5.5, there is no DATETIME_PRECISION field in the information_schema.columns table.
1 parent 0eeaa98 commit 0ad44c9

File tree

1 file changed

+29
-31
lines changed

1 file changed

+29
-31
lines changed

tableparser/tableparser.go

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -211,37 +211,35 @@ func (t *Table) parse() error {
211211
}
212212

213213
func makeScanRecipients(f *Field, allowNull *string, cols []string) []interface{} {
214-
fields := []interface{}{
215-
&f.TableCatalog,
216-
&f.TableSchema,
217-
&f.TableName,
218-
&f.ColumnName,
219-
&f.OrdinalPosition,
220-
&f.ColumnDefault,
221-
&allowNull,
222-
&f.DataType,
223-
&f.CharacterMaximumLength,
224-
&f.CharacterOctetLength,
225-
&f.NumericPrecision,
226-
&f.NumericScale,
227-
&f.DatetimePrecision,
228-
&f.CharacterSetName,
229-
&f.CollationName,
230-
&f.ColumnType,
231-
&f.ColumnKey,
232-
&f.Extra,
233-
&f.Privileges,
234-
&f.ColumnComment,
235-
}
236-
237-
if len(cols) > 20 && cols[20] == "GENERATION_EXPRESSION" { // MySQL 5.7+ "GENERATION_EXPRESSION" field
238-
fields = append(fields, &f.GenerationExpression)
239-
}
240-
if len(cols) > 21 && cols[21] == "SRS_ID" { // MySQL 8.0+ "SRS ID" field
241-
fields = append(fields, &f.SrsID)
242-
}
243-
244-
return fields
214+
fields := []interface{}{
215+
&f.TableCatalog,
216+
&f.TableSchema,
217+
&f.TableName,
218+
&f.ColumnName,
219+
&f.OrdinalPosition,
220+
&f.ColumnDefault,
221+
&allowNull,
222+
&f.DataType,
223+
&f.CharacterMaximumLength,
224+
&f.CharacterOctetLength,
225+
&f.NumericPrecision,
226+
&f.NumericScale,
227+
}
228+
229+
if len(cols) > 19 { // MySQL 5.5 does not have "DATETIME_PRECISION" field
230+
fields = append(fields, &f.DatetimePrecision)
231+
}
232+
233+
fields = append(fields, &f.CharacterSetName, &f.CollationName, &f.ColumnType, &f.ColumnKey, &f.Extra, &f.Privileges, &f.ColumnComment)
234+
235+
if len(cols) > 20 && cols[20] == "GENERATION_EXPRESSION" { // MySQL 5.7+ "GENERATION_EXPRESSION" field
236+
fields = append(fields, &f.GenerationExpression)
237+
}
238+
if len(cols) > 21 && cols[21] == "SRS_ID" { // MySQL 8.0+ "SRS ID" field
239+
fields = append(fields, &f.SrsID)
240+
}
241+
242+
return fields
245243
}
246244

247245
// FieldNames returns an string array with the table's field names

0 commit comments

Comments
 (0)