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

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