I have been looking around in the documentation, but could not find an explanation of what the "int2vector" type really is. It is found in some system tables like pg_trigger, but that's all a documentation search returns...
It seems to be vaguely similar to int2array, but has a different OID (INT2VECTOROID is 22, INT2ARRAYOID is 1005).
I have found ways to generate int2array in SQL (for instance with SELECT cast('{1,2}' as int2[])
), but not int2vector.
The question applies to int4vector & int4array as well, and the uses case is when interfacing with libpq in binary format.
CodePudding user response:
int2vector
is an obsolete data type for arrays of smallint
from the time before PostgreSQL had array data types. Today you would use smallint[]
.
You shouldn't use int2vector
in your table definitions, as it is not documented. On the other hand, it is unlikely to get removed, since the catalog tables make use of that data type for historical reasons. There is no advantage to be had by using int2vector
.