系统目录表coltype
列中的值syscolumns
主要在 Informix ESQL/C 标头中定义sqltypes.h
。这个头在整个 Informix 服务器代码中使用。
coltype
列中的值是低位中的 8 位(无符号)整数和高位中的各种标志值的混合。特别是,当使用NOT NULL
限定符定义列时,该0x100
位被设置 — 对应于“add 256”。还有其他一些您不太可能看到的标志位。
另一个答案中显示的值 4118(十进制)对应于 hex 0x1016
;的16
(又名22十进制)对应于SQLROW
,和0x1000
(4096十进制)位对应于#define SQLNAMED 0x1000 /* Named row type vs row type */
。该类型是(如另一个答案中所述)“命名行类型”。
考虑一个表:
CREATE TABLE bool_check
(
b1 BOOLEAN NOT NULL,
b2 BOOLEAN
);
Run Code Online (Sandbox Code Playgroud)
sqltype
列中的值syscolumns
是:
b1
= 297 = 256 + 41b2
= 41这些对应于SQLUDTFIXED
(类型 41)。该类型SQLBOOL
被标记为“由 FE [前端] 使用,......在 BE [后端,意味着数据库服务器] 中不是真正的主要类型”。该collength
是1
两个。
标题的相关部分包括:
SQL 类型:
#define SQLCHAR 0
#define SQLSMINT 1
#define SQLINT 2
#define SQLFLOAT 3
#define SQLSMFLOAT 4
#define SQLDECIMAL 5
#define SQLSERIAL 6
#define SQLDATE 7
#define SQLMONEY 8
#define SQLNULL 9
#define SQLDTIME 10
#define SQLBYTES 11
#define SQLTEXT 12
#define SQLVCHAR 13
#define SQLINTERVAL 14
#define SQLNCHAR 15
#define SQLNVCHAR 16
#define SQLINT8 17
#define SQLSERIAL8 18
#define SQLSET 19
#define SQLMULTISET 20
#define SQLLIST 21
#define SQLROW 22
#define SQLCOLLECTION 23
#define SQLROWREF 24
/*
* Note: SQLXXX values from 25 through 39 are reserved to avoid collision
* with reserved PTXXX values in that same range. See p_types_t.h
*
* REFSER8: create tab with ref: referenced serial 8 rsam counter
* this is essentially a SERIAL8, but is an additional rsam counter
* this type only lives in the system catalogs and when read from
* disk is converted to SQLSERIAL8 with CD_REFSER8 set in ddcol_t
* ddc_flags we must distinguish from SERIAL8 to allow both
* counters in one tab
*
* SQLSTREAM: Is a synonym for SQLUDTFIXED used by CDR (Enterprise
* Replication) code
*/
#define SQLUDTVAR 40
#define SQLUDTFIXED 41
#define SQLSTREAM SQLUDTFIXED
#define SQLREFSER8 42
/* These types are used by FE, they are not real major types in BE */
#define SQLLVARCHAR 43
#define SQLSENDRECV 44
#define SQLBOOL 45
#define SQLIMPEXP 46
#define SQLIMPEXPBIN 47
/* This type is used by the UDR code to track default parameters,
it is not a real major type in BE */
#define SQLUDRDEFAULT 48
#define SQLUNKNOWN 51
#define SQLBIGINT 52
#define SQLBIGSERIAL 53
#define SQLMAXTYPES 54
#define SQLLABEL SQLINT
Run Code Online (Sandbox Code Playgroud)
标志:
#define SQLNONULL 0x0100 /* disallow nulls */
/* a bit to show that the value is from a host variable */
#define SQLHOST 0x0200 /* Value is from host var. */
#define SQLNETFLT 0x0400 /* float-to-decimal for networked backend */
#define SQLDISTINCT 0x0800 /* distinct bit */
#define SQLNAMED 0x1000 /* Named row type vs row type */
#define SQLDLVARCHAR 0x2000 /* Distinct of lvarchar */
#define SQLDBOOLEAN 0x4000 /* Distinct of boolean */
#define SQLCLIENTCOLL 0x8000 /* Collection is processed on client */
/* we are overloading SQLDBOOLEAN for use with row types */
#define SQLVARROWTYPE 0x4000 /* varlen row type */
Run Code Online (Sandbox Code Playgroud)
还有“C-ISAM 类型”,编号为 100 到 125,名称为 aCCHARTYPE
和CDECIMALTYPE
。他们在这里不是直接关注的问题。头文件中有 524 行(至少在我查看的版本中)。其中,74 行是空白,315 行包含代码,其余行是纯注释行。AFAIK,这种SQLREFSER8
类型是死产的;它不存在于该文件之外。
类型BLOB NOT NULL
和CLOB NOT NULL
在两个编码coltype
为297(41 + 256 -同一个BOOLEAN NOT NULL
),或SQLUDTFIXED
与collength
72(而不是1
对BOOLEAN NOT NULL
)。固定长度数据是一个描述符,提供有关BLOB
orCLOB
值实际存储位置的所有详细信息。