PGAdmin3 隐藏对象类型

PGAdmin3 hidden object types

我已经在网络和 PGSQL 文档中搜索了关于什么对我来说是隐藏数据类型的信息,但没有找到任何信息。我正在处理一个现有数据库,该数据库具有 return 类型的函数,前面带有双下划线 (__some_type)。在 PGAdmin3 中,您可以选择在树视图中显示类型,在那里我看到了一些可识别的类型,这些类型在各种功能中使用,而没有,但我在任何地方都看不到这些其他类型。我了解到,通过 PyCharm 完整版,我可以连接到 PostgreSQL 数据库并查看我提到的所有类型。以及在带有“\dT”的控制台中,但不是在 PGAdmin 本身中。

Question: What is the deal with types that are preceded with one or two underscores? (__some_type).

跟进:我确实发现了一个未经验证的来源描述了一个限制用户创建以下划线开头的类型的约定,但尚未从 PG 来源证实这一点。

这是link:https://momjian.us/main/writings/pgsql/aw_pgsql_book/node223.html

而我提到的那条线一直到 "NOTES" 下方的底部:

Type names cannot begin with the underscore character ("_") and can only be 31 characters long. This is because Postgres silently creates an array type for each base type with a name consisting of the base type's name prepended with an underscore.

继续搜索结果: 我找到了我所说内容的参考资料,但它没有详细说明此类类型的行为,或者如果用户违反此 'restriction'.

会发生什么

来自 6.3 文档的 PG 源代码:

As discussed earlier, Postgres fully supports arrays of base types. Additionally, Postgres supports arrays of user-defined types as well. When you define a type, Postgres automatically provides support for arrays of that type. For historical reasons, the array type has the same name as the user-defined type with the underscore character _ prepended. Composite types do not need any function defined on them, since the system already understands what they look like inside.

6.4 Docs on Create Type:

Restrictions

Type names cannot begin with the underscore character ("_") and can only be 15 characters long. This is because Postgres silently creates an array type for each base type with a name consisting of the base type's name prepended with an underscore.

类型名称中对下划线的限制不再适用。根据文档判断,它被丢弃在 8.2 and 8.3.

之间

这些类型没有出现在 pgAdmin3 中这一事实看起来像是一个错误。从 source 可以看出,它会过滤掉任何带有前导下划线的类型。它试图抑制自动生成的数组类型,但查询早于 8.3 版(当时这仍然是一种可靠的方法),并且从未更新为使用新的 pg_type.typarray 列。

不确定 pgAdmin4 中是否存在此问题。如果您想坚持使用 pgAdmin3,BigSQL 仍在维护 fork,因此如果您想看到此修复,它们可能是您最好的选择。