英文:
What is the significance of '0x6000' in the OID of composite_type column type in PostgreSQL?
问题
I'm analyzing packet in PostgreSQL.
在分析 PostgreSQL 数据包。
In Result packet, table OID usually above '0x6000' (ex, 0x6026)
在结果数据包中,表的 OID 通常在 '0x6000' 以上(例如,0x6026)。
In the other hand, in column OID of known types(int, varchar, byte, etc..) are usually under 0x6000.
另一方面,在已知类型(int、varchar、byte 等)的列 OID 通常在 0x6000 以下。
but type OID of composite_type (user-defined column type) represents over 0x6000 (ex, 0x6024)
但是复合类型(用户定义的列类型)的类型 OID 表示在 0x6000 以上(例如,0x6024)。
I guess '0x6000' will be boundary between user-defined column and system-defined (known)
我猜想 '0x6000' 可能是用户定义列和系统定义列之间的边界。
What means of '0x6000'? is composite_type start value? or '0x6024' is OID of composite_type?
'0x6000' 的含义是什么?是复合类型的起始值吗?还是 '0x6024' 是复合类型的 OID?
In PostgreSQL JDBC, varchar is 1043(0x413), int is 21(0x15), but there are no information of composite_type.
在 PostgreSQL JDBC 中,varchar 是 1043(0x413),int 是 21(0x15),但没有关于复合类型的信息。
英文:
I'm analyzing packet in PostgreSQL.
in Result packet, table OID usually above '0x6000' (ex, 0x6026)
In the other hand, in column OID of known types(int, varchar, byte, etc..) are usually under 0x6000.
but typd OID of composite_type (user-defined column type) represents over 0x6000 (ex, 0x6024)
I guess '0x6000' will be boundary between user-defined column and system-defined(known)
What means of '0x6000'? is composite_type start value? or '0x6024' is OID of composite_type?
In PostgreSQL JDBC, varchar is 1043(0x413), int is 21(0x15), but there are no information of composite_type.
答案1
得分: 2
在PostgreSQL中,低于10000的OID是为特定对象固定且硬编码的。低于12000的OID是系统对象,不能被删除(public
模式和数据库除外)。低于16384的OID是系统对象。OID生成器为用户对象分配更高的数字。详见该主题的文档。
英文:
Low Object IDs (OIDs) have a special meaning in PostgreSQL, but the boundaries are different from what you think. 0x6000 has no special meaning in PostgreSQL.
This is best explained by quoting the relevant parts of src/include/access/transam.h
:
/* ----------
* Object ID (OID) zero is InvalidOid.
*
* OIDs 1-9999 are reserved for manual assignment (see .dat files in
* src/include/catalog/). Of these, 8000-9999 are reserved for
* development purposes (such as in-progress patches and forks);
* they should not appear in released versions.
*
* OIDs 10000-11999 are reserved for assignment by genbki.pl, for use
* when the .dat files in src/include/catalog/ do not specify an OID
* for a catalog entry that requires one. Note that genbki.pl assigns
* these OIDs independently in each catalog, so they're not guaranteed
* to be globally unique. Furthermore, the bootstrap backend and
* initdb's post-bootstrap processing can also assign OIDs in this range.
* The normal OID-generation logic takes care of any OID conflicts that
* might arise from that.
*
* OIDs 12000-16383 are reserved for unpinned objects created by initdb's
* post-bootstrap processing. initdb forces the OID generator up to
* 12000 as soon as it's made the pinned objects it's responsible for.
*
* OIDs beginning at 16384 are assigned from the OID generator
* during normal multiuser operation. (We force the generator up to
* 16384 as soon as we are in normal operation.)
*
* The choices of 8000, 10000 and 12000 are completely arbitrary, and can be
* moved if we run low on OIDs in any category. Changing the macros below,
* and updating relevant documentation (see bki.sgml and RELEASE_CHANGES),
* should be sufficient to do this. Moving the 16384 boundary between
* initdb-assigned OIDs and user-defined objects would be substantially
* more painful, however, since some user-defined OIDs will appear in
* on-disk data; such a change would probably break pg_upgrade.
*
* NOTE: if the OID generator wraps around, we skip over OIDs 0-16383
* and resume with 16384. This minimizes the odds of OID conflict, by not
* reassigning OIDs that might have been assigned during initdb. Critically,
* it also ensures that no user-created object will be considered pinned.
* ----------
*/
#define FirstGenbkiObjectId 10000
#define FirstUnpinnedObjectId 12000
#define FirstNormalObjectId 16384
So:
-
OIDs under 10000 are fixed and hard-coded for certain objects
-
OIDs under 12000 are system objects that cannot be dropped (with the exception of the
public
schema and databases) -
OIDs under 16384 are system objects
-
the OID generator assigns higher numbers to user objects
See also the documentation on the topic.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论