Internally handle MySQL's native column types in an enumeration, not as constants. See mysql.h.pp in the MySQL server code.

This commit is contained in:
Ansgar Becker
2015-11-19 19:54:59 +00:00
parent a2dfca0f00
commit c890cf5172
3 changed files with 44 additions and 72 deletions

View File

@ -165,39 +165,6 @@ const
CLIENT_SSL_VERIFY_SERVER_CERT = 67108864; CLIENT_SSL_VERIFY_SERVER_CERT = 67108864;
CLIENT_REMEMBER_OPTIONS = 134217728; CLIENT_REMEMBER_OPTIONS = 134217728;
// Enum Field Types
FIELD_TYPE_DECIMAL = 0;
FIELD_TYPE_TINY = 1;
FIELD_TYPE_SHORT = 2;
FIELD_TYPE_LONG = 3;
FIELD_TYPE_FLOAT = 4;
FIELD_TYPE_DOUBLE = 5;
FIELD_TYPE_NULL = 6;
FIELD_TYPE_TIMESTAMP = 7;
FIELD_TYPE_LONGLONG = 8;
FIELD_TYPE_INT24 = 9;
FIELD_TYPE_DATE = 10;
FIELD_TYPE_TIME = 11;
FIELD_TYPE_DATETIME = 12;
FIELD_TYPE_YEAR = 13;
FIELD_TYPE_NEWDATE = 14;
FIELD_TYPE_VARCHAR = 15;
FIELD_TYPE_BIT = 16;
FIELD_TYPE_TIMESTAMP2 = 17;
FIELD_TYPE_DATETIME2 = 18;
FIELD_TYPE_TIME2 = 19;
FIELD_TYPE_JSON = 245;
FIELD_TYPE_NEWDECIMAL = 246;
FIELD_TYPE_ENUM = 247;
FIELD_TYPE_SET = 248;
FIELD_TYPE_TINY_BLOB = 249;
FIELD_TYPE_MEDIUM_BLOB = 250;
FIELD_TYPE_LONG_BLOB = 251;
FIELD_TYPE_BLOB = 252;
FIELD_TYPE_VAR_STRING = 253;
FIELD_TYPE_STRING = 254;
FIELD_TYPE_GEOMETRY = 255;
COLLATION_BINARY = 63; COLLATION_BINARY = 63;
// Equivalent to COLLATION_BINARY, this is what a new driver returns when connected to a pre-4.1 server. // Equivalent to COLLATION_BINARY, this is what a new driver returns when connected to a pre-4.1 server.
COLLATION_NONE = 0; COLLATION_NONE = 0;

View File

@ -5364,7 +5364,7 @@ begin
end else if (Field.flags and SET_FLAG) = SET_FLAG then begin end else if (Field.flags and SET_FLAG) = SET_FLAG then begin
if FConnection.Datatypes[j].Index = dtSet then if FConnection.Datatypes[j].Index = dtSet then
FColumnTypes[i] := FConnection.Datatypes[j]; FColumnTypes[i] := FConnection.Datatypes[j];
end else if Field._type = FConnection.Datatypes[j].NativeType then begin end else if Field._type = Cardinal(FConnection.Datatypes[j].NativeType) then begin
// Text and Blob types share the same constants (see FIELD_TYPEs) // Text and Blob types share the same constants (see FIELD_TYPEs)
// Some function results return binary collation up to the latest versions. Work around // Some function results return binary collation up to the latest versions. Work around
// that by checking if this field is a real table field // that by checking if this field is a real table field

View File

@ -195,10 +195,15 @@ type
// MySQL data type categorization // MySQL data type categorization
TDBDatatypeCategoryIndex = (dtcInteger, dtcReal, dtcText, dtcBinary, dtcTemporal, dtcSpatial, dtcOther); TDBDatatypeCategoryIndex = (dtcInteger, dtcReal, dtcText, dtcBinary, dtcTemporal, dtcSpatial, dtcOther);
// MySQL native column type constants. See include/mysql.h.pp in the server code
TMySQLType = (mytDecimal, mytTiny, mytShort, mytLong, mytFloat, mytDouble, mytNull, mytTimestamp,
mytLonglong, mytInt24, mytDate, mytTime, mytDatetime, mytYear, mytNewdate, mytVarchar,
mytBit, mytTimestamp2, mytDatetime2, mytTime2, mytJson=245, mytNewdecimal, mytEnum, mytSet, mytTinyblob,
mytMediumblob, mytLongblob, mytBlob, mytVarstring, mytString, mytGeometry);
// MySQL data type structure // MySQL data type structure
TDBDatatype = record TDBDatatype = record
Index: TDBDatatypeIndex; Index: TDBDatatypeIndex;
NativeType: Cardinal; // See field types NativeType: TMySQLType; // See above
NativeTypes: String; // Same as above, but for multiple postgresql oid's NativeTypes: String; // Same as above, but for multiple postgresql oid's
Name: String; Name: String;
Names: String; Names: String;
@ -280,7 +285,7 @@ var
( (
( (
Index: dtTinyint; Index: dtTinyint;
NativeType: FIELD_TYPE_TINY; NativeType: mytTiny;
Name: 'TINYINT'; Name: 'TINYINT';
Description: 'TINYINT[(M)] [UNSIGNED] [ZEROFILL]' + CRLF + Description: 'TINYINT[(M)] [UNSIGNED] [ZEROFILL]' + CRLF +
'A very small integer. The signed range is -128 to 127. ' + 'A very small integer. The signed range is -128 to 127. ' +
@ -294,7 +299,7 @@ var
), ),
( (
Index: dtSmallint; Index: dtSmallint;
NativeType: FIELD_TYPE_SHORT; NativeType: mytShort;
Name: 'SMALLINT'; Name: 'SMALLINT';
Description: 'SMALLINT[(M)] [UNSIGNED] [ZEROFILL]' + CRLF + Description: 'SMALLINT[(M)] [UNSIGNED] [ZEROFILL]' + CRLF +
'A small integer. The signed range is -32768 to 32767. ' + 'A small integer. The signed range is -32768 to 32767. ' +
@ -308,7 +313,7 @@ var
), ),
( (
Index: dtMediumint; Index: dtMediumint;
NativeType: FIELD_TYPE_INT24; NativeType: mytInt24;
Name: 'MEDIUMINT'; Name: 'MEDIUMINT';
Description: 'MEDIUMINT[(M)] [UNSIGNED] [ZEROFILL]' + CRLF + Description: 'MEDIUMINT[(M)] [UNSIGNED] [ZEROFILL]' + CRLF +
'A medium-sized integer. The signed range is -8388608 to 8388607. ' + 'A medium-sized integer. The signed range is -8388608 to 8388607. ' +
@ -322,7 +327,7 @@ var
), ),
( (
Index: dtInt; Index: dtInt;
NativeType: FIELD_TYPE_LONG; NativeType: mytLong;
Name: 'INT'; Name: 'INT';
Description: 'INT[(M)] [UNSIGNED] [ZEROFILL]' + CRLF + Description: 'INT[(M)] [UNSIGNED] [ZEROFILL]' + CRLF +
'A normal-size integer. The signed range is -2147483648 to 2147483647. ' + 'A normal-size integer. The signed range is -2147483648 to 2147483647. ' +
@ -336,7 +341,7 @@ var
), ),
( (
Index: dtBigint; Index: dtBigint;
NativeType: FIELD_TYPE_LONGLONG; NativeType: mytLonglong;
Name: 'BIGINT'; Name: 'BIGINT';
Description: 'BIGINT[(M)] [UNSIGNED] [ZEROFILL]' + CRLF + Description: 'BIGINT[(M)] [UNSIGNED] [ZEROFILL]' + CRLF +
'A large integer. The signed range is -9223372036854775808 to ' + 'A large integer. The signed range is -9223372036854775808 to ' +
@ -350,7 +355,7 @@ var
), ),
( (
Index: dtFloat; Index: dtFloat;
NativeType: FIELD_TYPE_FLOAT; NativeType: mytFloat;
Name: 'FLOAT'; Name: 'FLOAT';
Description: 'FLOAT[(M,D)] [UNSIGNED] [ZEROFILL]' + CRLF + Description: 'FLOAT[(M,D)] [UNSIGNED] [ZEROFILL]' + CRLF +
'A small (single-precision) floating-point number. Allowable values are '+ 'A small (single-precision) floating-point number. Allowable values are '+
@ -367,7 +372,7 @@ var
), ),
( (
Index: dtDouble; Index: dtDouble;
NativeType: FIELD_TYPE_DOUBLE; NativeType: mytDouble;
Name: 'DOUBLE'; Name: 'DOUBLE';
Description: 'DOUBLE[(M,D)] [UNSIGNED] [ZEROFILL]' + CRLF + Description: 'DOUBLE[(M,D)] [UNSIGNED] [ZEROFILL]' + CRLF +
'A normal-size (double-precision) floating-point number. Allowable ' + 'A normal-size (double-precision) floating-point number. Allowable ' +
@ -384,7 +389,7 @@ var
), ),
( (
Index: dtDecimal; Index: dtDecimal;
NativeType: FIELD_TYPE_NEWDECIMAL; NativeType: mytNewdecimal;
Name: 'DECIMAL'; Name: 'DECIMAL';
Description: 'DECIMAL[(M[,D])] [UNSIGNED] [ZEROFILL]' + CRLF + Description: 'DECIMAL[(M[,D])] [UNSIGNED] [ZEROFILL]' + CRLF +
'A packed "exact" fixed-point number. M is the total number of digits ' + 'A packed "exact" fixed-point number. M is the total number of digits ' +
@ -404,7 +409,7 @@ var
), ),
( (
Index: dtDate; Index: dtDate;
NativeType: FIELD_TYPE_DATE; NativeType: mytDate;
Name: 'DATE'; Name: 'DATE';
Description: 'DATE' + CRLF + Description: 'DATE' + CRLF +
'A date. The supported range is ''1000-01-01'' to ''9999-12-31''. MySQL ' + 'A date. The supported range is ''1000-01-01'' to ''9999-12-31''. MySQL ' +
@ -420,7 +425,7 @@ var
), ),
( (
Index: dtTime; Index: dtTime;
NativeType: FIELD_TYPE_TIME; NativeType: mytTime;
Name: 'TIME'; Name: 'TIME';
Description: 'TIME' + CRLF + Description: 'TIME' + CRLF +
'A time. The range is ''-838:59:59'' to ''838:59:59''. MySQL displays TIME ' + 'A time. The range is ''-838:59:59'' to ''838:59:59''. MySQL displays TIME ' +
@ -436,7 +441,7 @@ var
), ),
( (
Index: dtYear; Index: dtYear;
NativeType: FIELD_TYPE_YEAR; NativeType: mytYear;
Name: 'YEAR'; Name: 'YEAR';
Description: 'YEAR[(2|4)]' + CRLF + Description: 'YEAR[(2|4)]' + CRLF +
'A year in two-digit or four-digit format. The default is four-digit ' + 'A year in two-digit or four-digit format. The default is four-digit ' +
@ -455,7 +460,7 @@ var
), ),
( (
Index: dtDatetime; Index: dtDatetime;
NativeType: FIELD_TYPE_DATETIME; NativeType: mytDatetime;
Name: 'DATETIME'; Name: 'DATETIME';
Description: 'DATETIME' + CRLF + Description: 'DATETIME' + CRLF +
'A date and time combination. The supported range is ''1000-01-01 ' + 'A date and time combination. The supported range is ''1000-01-01 ' +
@ -472,7 +477,7 @@ var
), ),
( (
Index: dtTimestamp; Index: dtTimestamp;
NativeType: FIELD_TYPE_TIMESTAMP; NativeType: mytTimestamp;
Name: 'TIMESTAMP'; Name: 'TIMESTAMP';
Description: 'TIMESTAMP' + CRLF + Description: 'TIMESTAMP' + CRLF +
'A timestamp. The range is ''1970-01-01 00:00:01'' UTC to ''2038-01-09 ' + 'A timestamp. The range is ''1970-01-01 00:00:01'' UTC to ''2038-01-09 ' +
@ -491,7 +496,7 @@ var
), ),
( (
Index: dtChar; Index: dtChar;
NativeType: FIELD_TYPE_STRING; NativeType: mytString;
Name: 'CHAR'; Name: 'CHAR';
Description: 'CHAR[(M)]' + CRLF + Description: 'CHAR[(M)]' + CRLF +
'A fixed-length string that is always right-padded with spaces to the ' + 'A fixed-length string that is always right-padded with spaces to the ' +
@ -509,7 +514,7 @@ var
), ),
( (
Index: dtVarchar; Index: dtVarchar;
NativeType: FIELD_TYPE_VAR_STRING; NativeType: mytVarstring;
Name: 'VARCHAR'; Name: 'VARCHAR';
Description: 'VARCHAR(M)' + CRLF + Description: 'VARCHAR(M)' + CRLF +
'A variable-length string. M represents the maximum column length in ' + 'A variable-length string. M represents the maximum column length in ' +
@ -531,7 +536,7 @@ var
), ),
( (
Index: dtTinytext; Index: dtTinytext;
NativeType: FIELD_TYPE_TINY_BLOB; NativeType: mytTinyblob;
Name: 'TINYTEXT'; Name: 'TINYTEXT';
Description: 'TINYTEXT' + CRLF + Description: 'TINYTEXT' + CRLF +
'A TEXT column with a maximum length of 255 (28 - 1) characters. The ' + 'A TEXT column with a maximum length of 255 (28 - 1) characters. The ' +
@ -547,7 +552,7 @@ var
), ),
( (
Index: dtText; Index: dtText;
NativeType: FIELD_TYPE_BLOB; NativeType: mytBlob;
Name: 'TEXT'; Name: 'TEXT';
Description: 'TEXT[(M)]' + CRLF + Description: 'TEXT[(M)]' + CRLF +
'A TEXT column with a maximum length of 65,535 (216 - 1) characters. The ' + 'A TEXT column with a maximum length of 65,535 (216 - 1) characters. The ' +
@ -566,7 +571,7 @@ var
), ),
( (
Index: dtMediumtext; Index: dtMediumtext;
NativeType: FIELD_TYPE_MEDIUM_BLOB; NativeType: mytMediumblob;
Name: 'MEDIUMTEXT'; Name: 'MEDIUMTEXT';
Description: 'MEDIUMTEXT' + CRLF + Description: 'MEDIUMTEXT' + CRLF +
'A TEXT column with a maximum length of 16,777,215 (224 - 1) characters. ' + 'A TEXT column with a maximum length of 16,777,215 (224 - 1) characters. ' +
@ -582,7 +587,7 @@ var
), ),
( (
Index: dtLongtext; Index: dtLongtext;
NativeType: FIELD_TYPE_LONG_BLOB; NativeType: mytLongblob;
Name: 'LONGTEXT'; Name: 'LONGTEXT';
Description: 'LONGTEXT' + CRLF + Description: 'LONGTEXT' + CRLF +
'A TEXT column with a maximum length of 4,294,967,295 or 4GB (232 - 1) ' + 'A TEXT column with a maximum length of 4,294,967,295 or 4GB (232 - 1) ' +
@ -601,7 +606,7 @@ var
), ),
( (
Index: dtJson; Index: dtJson;
NativeType: FIELD_TYPE_JSON; NativeType: mytJson;
Name: 'JSON'; Name: 'JSON';
Description: 'JSON' + CRLF + Description: 'JSON' + CRLF +
'Documents stored in JSON columns are converted to an internal format that '+ 'Documents stored in JSON columns are converted to an internal format that '+
@ -619,7 +624,7 @@ var
), ),
( (
Index: dtBinary; Index: dtBinary;
NativeType: FIELD_TYPE_STRING; NativeType: mytString;
Name: 'BINARY'; Name: 'BINARY';
Description: 'BINARY(M)' + CRLF + Description: 'BINARY(M)' + CRLF +
'The BINARY type is similar to the CHAR type, but stores binary byte ' + 'The BINARY type is similar to the CHAR type, but stores binary byte ' +
@ -635,7 +640,7 @@ var
), ),
( (
Index: dtVarbinary; Index: dtVarbinary;
NativeType: FIELD_TYPE_VAR_STRING; NativeType: mytVarstring;
Name: 'VARBINARY'; Name: 'VARBINARY';
Description: 'VARBINARY(M)' + CRLF + Description: 'VARBINARY(M)' + CRLF +
'The VARBINARY type is similar to the VARCHAR type, but stores binary ' + 'The VARBINARY type is similar to the VARCHAR type, but stores binary ' +
@ -651,7 +656,7 @@ var
), ),
( (
Index: dtTinyblob; Index: dtTinyblob;
NativeType: FIELD_TYPE_TINY_BLOB; NativeType: mytTinyblob;
Name: 'TINYBLOB'; Name: 'TINYBLOB';
Description: 'TINYBLOB' + CRLF + Description: 'TINYBLOB' + CRLF +
'A BLOB column with a maximum length of 255 (28 - 1) bytes. Each ' + 'A BLOB column with a maximum length of 255 (28 - 1) bytes. Each ' +
@ -666,7 +671,7 @@ var
), ),
( (
Index: dtBlob; Index: dtBlob;
NativeType: FIELD_TYPE_BLOB; NativeType: mytBlob;
Name: 'BLOB'; Name: 'BLOB';
Description: 'BLOB[(M)]' + CRLF + Description: 'BLOB[(M)]' + CRLF +
'A BLOB column with a maximum length of 65,535 (216 - 1) bytes. Each ' + 'A BLOB column with a maximum length of 65,535 (216 - 1) bytes. Each ' +
@ -684,7 +689,7 @@ var
), ),
( (
Index: dtMediumblob; Index: dtMediumblob;
NativeType: FIELD_TYPE_MEDIUM_BLOB; NativeType: mytMediumblob;
Name: 'MEDIUMBLOB'; Name: 'MEDIUMBLOB';
Description: 'MEDIUMBLOB' + CRLF + Description: 'MEDIUMBLOB' + CRLF +
'A BLOB column with a maximum length of 16,777,215 (224 - 1) bytes. Each ' + 'A BLOB column with a maximum length of 16,777,215 (224 - 1) bytes. Each ' +
@ -699,7 +704,7 @@ var
), ),
( (
Index: dtLongblob; Index: dtLongblob;
NativeType: FIELD_TYPE_LONG_BLOB; NativeType: mytLongblob;
Name: 'LONGBLOB'; Name: 'LONGBLOB';
Description: 'LONGBLOB' + CRLF + Description: 'LONGBLOB' + CRLF +
'A BLOB column with a maximum length of 4,294,967,295 or 4GB (232 - 1) ' + 'A BLOB column with a maximum length of 4,294,967,295 or 4GB (232 - 1) ' +
@ -716,7 +721,7 @@ var
), ),
( (
Index: dtEnum; Index: dtEnum;
NativeType: FIELD_TYPE_ENUM; NativeType: mytEnum;
Name: 'ENUM'; Name: 'ENUM';
Description: 'ENUM(''value1'',''value2'',...)' + CRLF + Description: 'ENUM(''value1'',''value2'',...)' + CRLF +
'An enumeration. A string object that can have only one value, chosen ' + 'An enumeration. A string object that can have only one value, chosen ' +
@ -733,7 +738,7 @@ var
), ),
( (
Index: dtSet; Index: dtSet;
NativeType: FIELD_TYPE_SET; NativeType: mytSet;
Name: 'SET'; Name: 'SET';
Description: 'SET(''value1'',''value2'',...)' + CRLF + Description: 'SET(''value1'',''value2'',...)' + CRLF +
'A set. A string object that can have zero or more values, each of which ' + 'A set. A string object that can have zero or more values, each of which ' +
@ -750,7 +755,7 @@ var
), ),
( (
Index: dtBit; Index: dtBit;
NativeType: FIELD_TYPE_BIT; NativeType: mytBit;
Name: 'BIT'; Name: 'BIT';
Description: 'BIT[(M)]' + CRLF + Description: 'BIT[(M)]' + CRLF +
'A bit-field type. M indicates the number of bits per value, from 1 to ' + 'A bit-field type. M indicates the number of bits per value, from 1 to ' +
@ -764,7 +769,7 @@ var
), ),
( (
Index: dtPoint; Index: dtPoint;
NativeType: FIELD_TYPE_GEOMETRY; NativeType: mytGeometry;
Name: 'POINT'; Name: 'POINT';
Description: 'POINT(x,y)' + CRLF + Description: 'POINT(x,y)' + CRLF +
'Constructs a WKB Point using its coordinates.'; 'Constructs a WKB Point using its coordinates.';
@ -777,7 +782,7 @@ var
), ),
( (
Index: dtLinestring; Index: dtLinestring;
NativeType: FIELD_TYPE_GEOMETRY; NativeType: mytGeometry;
Name: 'LINESTRING'; Name: 'LINESTRING';
Description: 'LINESTRING(pt1,pt2,...)' + CRLF + Description: 'LINESTRING(pt1,pt2,...)' + CRLF +
'Constructs a WKB LineString value from a number of WKB Point arguments. ' + 'Constructs a WKB LineString value from a number of WKB Point arguments. ' +
@ -792,7 +797,7 @@ var
), ),
( (
Index: dtPolygon; Index: dtPolygon;
NativeType: FIELD_TYPE_GEOMETRY; NativeType: mytGeometry;
Name: 'POLYGON'; Name: 'POLYGON';
Description: 'POLYGON(ls1,ls2,...)' + CRLF + Description: 'POLYGON(ls1,ls2,...)' + CRLF +
'Constructs a WKB Polygon value from a number of WKB LineString ' + 'Constructs a WKB Polygon value from a number of WKB LineString ' +
@ -807,7 +812,7 @@ var
), ),
( (
Index: dtGeometry; Index: dtGeometry;
NativeType: FIELD_TYPE_GEOMETRY; NativeType: mytGeometry;
Name: 'GEOMETRY'; Name: 'GEOMETRY';
Description: ''; Description: '';
HasLength: False; HasLength: False;
@ -819,7 +824,7 @@ var
), ),
( (
Index: dtMultipoint; Index: dtMultipoint;
NativeType: FIELD_TYPE_GEOMETRY; NativeType: mytGeometry;
Name: 'MULTIPOINT'; Name: 'MULTIPOINT';
Description: 'MULTIPOINT(pt1,pt2,...)' + CRLF + Description: 'MULTIPOINT(pt1,pt2,...)' + CRLF +
'Constructs a WKB MultiPoint value using WKB Point arguments. If any ' + 'Constructs a WKB MultiPoint value using WKB Point arguments. If any ' +
@ -833,7 +838,7 @@ var
), ),
( (
Index: dtMultilinestring; Index: dtMultilinestring;
NativeType: FIELD_TYPE_GEOMETRY; NativeType: mytGeometry;
Name: 'MULTILINESTRING'; Name: 'MULTILINESTRING';
Description: 'MULTILINESTRING(ls1,ls2,...)' + CRLF + Description: 'MULTILINESTRING(ls1,ls2,...)' + CRLF +
'Constructs a WKB MultiLineString value using WKB LineString arguments. ' + 'Constructs a WKB MultiLineString value using WKB LineString arguments. ' +
@ -847,7 +852,7 @@ var
), ),
( (
Index: dtMultipolygon; Index: dtMultipolygon;
NativeType: FIELD_TYPE_GEOMETRY; NativeType: mytGeometry;
Name: 'MULTIPOLYGON'; Name: 'MULTIPOLYGON';
Description: 'MULTIPOLYGON(poly1,poly2,...)' + CRLF + Description: 'MULTIPOLYGON(poly1,poly2,...)' + CRLF +
'Constructs a WKB MultiPolygon value from a set of WKB Polygon ' + 'Constructs a WKB MultiPolygon value from a set of WKB Polygon ' +
@ -862,7 +867,7 @@ var
), ),
( (
Index: dtGeometrycollection; Index: dtGeometrycollection;
NativeType: FIELD_TYPE_GEOMETRY; NativeType: mytGeometry;
Name: 'GEOMETRYCOLLECTION'; Name: 'GEOMETRYCOLLECTION';
Description: 'GEOMETRYCOLLECTION(g1,g2,...)' + CRLF + Description: 'GEOMETRYCOLLECTION(g1,g2,...)' + CRLF +
'Constructs a WKB GeometryCollection. If any argument is not a ' + 'Constructs a WKB GeometryCollection. If any argument is not a ' +