Movatterモバイル変換


[0]ホーム

URL:



Facebook
Postgres Pro
Facebook
Downloads
8.19. Object Identifier Types
Prev UpChapter 8. Data TypesHome Next

8.19. Object Identifier Types

Object identifiers (OIDs) are used internally byPostgreSQL as primary keys for various system tables. Typeoid represents an object identifier. There are also several alias types foroid:regproc,regprocedure,regoper,regoperator,regclass,regtype,regrole,regnamespace,regconfig, andregdictionary.Table 8.26 shows an overview.

Theoid type is currently implemented as an unsigned four-byte integer. Therefore, it is not large enough to provide database-wide uniqueness in large databases, or even in large individual tables.

Theoid type itself has few operations beyond comparison. It can be cast to integer, however, and then manipulated using the standard integer operators. (Beware of possible signed-versus-unsigned confusion if you do this.)

The OID alias types have no operations of their own except for specialized input and output routines. These routines are able to accept and display symbolic names for system objects, rather than the raw numeric value that typeoid would use. The alias types allow simplified lookup of OID values for objects. For example, to examine thepg_attribute rows related to a tablemytable, one could write:

SELECT * FROM pg_attribute WHERE attrelid = 'mytable'::regclass;

rather than:

SELECT * FROM pg_attribute  WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'mytable');

While that doesn't look all that bad by itself, it's still oversimplified. A far more complicated sub-select would be needed to select the right OID if there are multiple tables namedmytable in different schemas. Theregclass input converter handles the table lookup according to the schema path setting, and so it does theright thing automatically. Similarly, casting a table's OID toregclass is handy for symbolic display of a numeric OID.

Table 8.26. Object Identifier Types

NameReferencesDescriptionValue Example
oidanynumeric object identifier564182
regprocpg_procfunction namesum
regprocedurepg_procfunction with argument typessum(int4)
regoperpg_operatoroperator name+
regoperatorpg_operatoroperator with argument types*(integer,integer) or-(NONE,integer)
regclasspg_classrelation namepg_type
regtypepg_typedata type nameinteger
regrolepg_authidrole namesmithee
regnamespacepg_namespacenamespace namepg_catalog
regconfigpg_ts_configtext search configurationenglish
regdictionarypg_ts_dicttext search dictionarysimple

All of the OID alias types for objects grouped by namespace accept schema-qualified names, and will display schema-qualified names on output if the object would not be found in the current search path without being qualified. Theregproc andregoper alias types will only accept input names that are unique (not overloaded), so they are of limited use; for most usesregprocedure orregoperator are more appropriate. Forregoperator, unary operators are identified by writingNONE for the unused operand.

An additional property of most of the OID alias types is the creation of dependencies. If a constant of one of these types appears in a stored expression (such as a column default expression or view), it creates a dependency on the referenced object. For example, if a column has a default expressionnextval('my_seq'::regclass),PostgreSQL understands that the default expression depends on the sequencemy_seq; the system will not let the sequence be dropped without first removing the default expression.regrole is the only exception for the property. Constants of this type are not allowed in such expressions.

Note

The OID alias types do not completely follow transaction isolation rules. The planner also treats them as simple constants, which may result in sub-optimal planning.

Another identifier type used by the system isxid, or transaction (abbreviatedxact) identifier. This is the data type of the system columnsxmin andxmax. Transaction identifiers are 32-bit quantities.

A third identifier type used by the system iscid, or command identifier. This is the data type of the system columnscmin andcmax. Command identifiers are also 32-bit quantities.

A final identifier type used by the system istid, or tuple identifier (row identifier). This is the data type of the system columnctid. A tuple ID is a pair (block number, tuple index within block) that identifies the physical location of the row within its table.

(The system columns are further explained inSection 5.5.)


Prev Up Next
8.18. Domain Types Home 8.20. pg_lsn Type
epubpdf
Go to PostgreSQL 12
By continuing to browse this website, you agree to the use of cookies. Go toPrivacy Policy.

[8]ページ先頭

©2009-2025 Movatter.jp