Data types in the UDR interface. More...
#include <sqludr.h>
Inherits tmudr::TMUDRSerializableObject.
Data types in the UDR interface.
Describes an SQL data type and the corresponding C/C++ type, used for scalar parameters, columns of input rows and columns of result rows.
Start and end fields of interval columns
SQL data types
More detailed type information, but not as detailed as the actual type
TypeInfo::TypeInfo | ( | const TypeInfo & | type | ) |
Copy constructor
TypeInfo::TypeInfo | ( | SQLTypeCode | sqlType = UNDEFINED_SQL_TYPE , |
|
int | length = 0 , |
|||
bool | nullable = false , |
|||
int | scale = 0 , |
|||
SQLCharsetCode | charset = CHARSET_UTF8 , |
|||
SQLIntervalCode | intervalCode = UNDEFINED_INTERVAL_CODE , |
|||
int | precision = 0 , |
|||
SQLCollationCode | collation = SYSTEM_COLLATION | |||
) |
Default constructor, with optional arguments
Construct a TypeInfo object from an SQL type, with several optional arguments (including the SQL type). This is mostly used to create formal parameters or output columns in the compiler interface, if a more complex data type is required that is not covered by the TupleInfo::addXXXColumn() methods.
sqlType | SQL type enum to construct the type from. | |
length | Length of CHAR/VARCHAR types, not needed for other types. Note that the length for UTF-8 types is in bytes, not characters, so this is equivalent to [VAR]CHAR ( length BYTES ) CHARACTER SET UTF8 | |
nullable | Determines the NULL / NOT NULL attribute of the type Default: false (that means NOT NULL) | |
scale | Scale for numeric type, fraction precision for fractional seconds, not needed for other types. | |
charset | Character set enum for CHAR/VARCHAR types, not needed for other types. | |
intervalCode | Interval code enum for intervals, not needed otherwise. | |
precision | Precision for numeric types and leading precision for interval data types. | |
collation | Collation enum for CHAR/VARCHAR types, not needed for other types. Note that only one type of collation is currently supported. |
UDRException |
int TypeInfo::getByteLength | ( | ) | const |
Get the length of a value of the type.
Getting the length is useful for CHAR/VARCHAR data types but probably not as useful for other types that may have an internal representation unknown to a UDR writer. This returns the length in bytes, not in characters.
TypeInfo::SQLCharsetCode TypeInfo::getCharset | ( | ) | const |
Get the character set of the data type.
TypeInfo::SQLCollationCode TypeInfo::getCollation | ( | ) | const |
Get the collation for char/varchar data types.
Note that, currently, only one collation is supported. This default collation is a binary collation, except that trailing blanks are ignored.
TypeInfo::SQLIntervalCode TypeInfo::getIntervalCode | ( | ) | const |
Get the interval code for start/end fields.
bool TypeInfo::getIsNullable | ( | ) | const |
Get whether the type is nullable.
int TypeInfo::getMaxCharLength | ( | ) | const |
Get the maximum number of characters that can be stored in this type.
This method should be used only for character types that have a fixed-width encoding. For variable-length encoding, like UTF-8, the method returns the highest possible number of characters (assuming single byte characters in the case of UTF-8). Right now, UTF-8 data types all have byte semantics, meaning there is no limit for the number of characters stored in a type, it is only limited by the number of bytes. The method returns 0 for numeric types. It returns the length of the string representation for types that are represented by a string, like datetime types.
UDRException |
int TypeInfo::getPrecision | ( | ) | const |
Get the precision (max. number of significant digits).
The precision is the maximum number of digits before the decimal point a value can have. For interval types, this is the "leading precision". For example, an INTEGER value can range from -2,147,483,648 to 2,147,483,647. It's precision is 10, since the longest number has 10 digits. Note that not all 10 digit numbers can be represented in an integer. This is called binary precision. NUMERIC and DECIMAL types have decimal precision, meaning that a NUMERIC(10,0) type can represent values from -9,999,999,999 to +9,999,999,999.
int TypeInfo::getScale | ( | ) | const |
Get the scale of the data type.
For integer, largeint, etc. types the scale is 0, since these are integer data types. For NUMERIC and DECIMAL types, a scale can be specified. Timestamp and some interval data types have a "fraction precision" value, which is the number of digits allowed after the decimal point for seconds. This fraction precision is returned as the scale, since can be considered the scale of the seconds part. For other data types like CHAR, the scale value is meaningless.
TypeInfo::SQLTypeCode TypeInfo::getSQLType | ( | ) | const |
Get the SQL type.
TypeInfo::SQLTypeClassCode TypeInfo::getSQLTypeClass | ( | ) | const |
Get the SQL type class.
Determine whether this is a numeric character, datetime or interval type.
TypeInfo::SQLTypeSubClassCode TypeInfo::getSQLTypeSubClass | ( | ) | const |
Get the SQL type subclass.
This goes to one more level of detail beyond the type class, like exact/approximate numeric, char/varchar, etc.
void TypeInfo::setNullable | ( | bool | nullable | ) |
Set the nullable attribute of a type
Use this method to set types created locally in the UDF to be nullable or not nullable.
nullable | true to set the type to nullable, false to give the type the NOT NULL attibute. |