Skip to main content

Catalog

Struct Catalog 

Source
pub struct Catalog { /* private fields */ }
Expand description

The objects of one cluster, with the OID counter.

Implementations§

Source§

impl Catalog

Source

pub fn create_aggregate( &mut self, function: Function, aggregate: Aggregate, refs: &[ObjRef], ) -> Result<u32>

AggregateCreate: the row of pg_proc of the aggregate, which gets the next OID, and its row of pg_aggregate. The function depends on its schema and on the objects in refs, which are its types, its support functions and its sort operator.

§Errors

42723 when the schema has a function with the name and the argument types.

Source

pub fn replace_aggregate( &mut self, oid: u32, function: Function, aggregate: Aggregate, refs: &[ObjRef], ) -> Result<()>

AggregateCreate with replace for the aggregate oid that exists: its function and its row of pg_aggregate get the new facts, and its dependencies are new.

§Errors

An internal error when no function has the OID.

Source

pub fn aggregates(&self) -> impl Iterator<Item = &Aggregate>

The aggregates, in the order of the OIDs of their functions.

Source

pub fn aggregate(&self, function: u32) -> Option<&Aggregate>

The row of pg_aggregate of the function with the OID.

Source§

impl Catalog

Source

pub fn rename_type(&mut self, oid: u32, name: &str) -> Result<()>

RenameTypeInternal: the new name of a type that is not a composite type. The array type gets the name that makeArrayTypeName gives it. When the name is the name of an array type that PostgreSQL made, that array type gets a new name first, as moveArrayTypeName gives it.

§Errors

42710 when the schema has another type with the name, and an internal error for a type that the catalog does not have.

Source

pub fn set_type_namespace(&mut self, oid: u32, namespace: u32) -> Result<()>

AlterTypeNamespaceInternal: moves the type and its array type to the schema. A composite type moves with its relation, and a domain moves with its constraints. changeDependencyFor changes the dependency of the type on the schema. The caller checks the names in the new schema.

§Errors

An internal error for a type that the catalog does not have.

Source

pub fn set_type_owner(&mut self, oid: u32, owner: u32) -> Result<()>

AlterTypeOwnerInternal: the new owner of a type that is not a composite type, of its array type, and of the multirange type of a range type with its array type.

§Errors

An internal error for a type that the catalog does not have.

Source§

impl Catalog

Source

pub fn default_acls(&self) -> impl Iterator<Item = &DefaultAcl>

The default privileges, in the order of their OIDs.

Source

pub fn default_acl(&self, oid: u32) -> Option<&DefaultAcl>

The default privileges with the OID.

Source

pub fn find_default_acl( &self, role: u32, namespace: u32, objtype: u8, ) -> Option<&DefaultAcl>

get_default_acl_internal: the entry of the role, the schema and the kind of objects, or None.

Source

pub fn set_default_acl( &mut self, role: u32, namespace: u32, objtype: u8, acl: Option<Vec<String>>, )

SetDefaultACL: sets the ACL of the entry of the role, the schema and the kind of objects. A new entry gets the next OID and, for a schema, an automatic dependency on the schema. None removes the entry.

Source§

impl Catalog

Source

pub fn deletions(&self, objects: &[ObjRef]) -> Result<Vec<Target>, Refusal>

performMultipleDeletions up to the report: the objects that a removal of objects takes away, in the order of the removal. An object comes after the objects that depend on it.

§Errors

A Refusal for a pinned object, and for a part of an object that objects does not have.

Source

pub fn remove(&mut self, targets: &[Target]) -> Result<()>

deleteObjectsInList: removes the targets in order, each with its rows of pg_depend and its comments, as deleteOneObject does. After an error the caller discards the catalog.

§Errors

An internal error for an object of a class that the catalog cannot remove.

Source

pub fn view_of_rule(&self, rule: u32) -> Option<&Relation>

The view of a _RETURN rule.

Source§

impl Catalog

Source

pub fn add_enum_label( &mut self, ty: u32, label: String, neighbor: Option<(usize, bool)>, ) -> Result<()>

AddEnumLabel: adds the label at the end, or before or after the label at the place neighbor of the sort order. The new label gets the middle of the sort orders of its neighbors. When the precision of float4 gives no middle, RenumberEnumType gives the labels the sort orders 1, 2, 3 and so on, and the search starts again. The new label takes the next OID, but an even OID that does not sort correctly against the even OIDs of the other labels is skipped, so that the label gets the odd OID after it. The caller checks the name.

§Errors

An internal error for a type that is not an enum type of the catalog.

Source

pub fn rename_enum_label( &mut self, ty: u32, at: usize, name: String, ) -> Result<()>

RenameEnumLabel: the label at the place at of the sort order gets the new name. The caller checks the names.

§Errors

An internal error for a type that is not an enum type of the catalog.

Source

pub fn label_is_uncommitted(&self, label: u32) -> bool

EnumUncommitted: true for a label that ALTER TYPE ... ADD VALUE of the open transaction gave to an enum type that an earlier transaction made.

Source

pub fn has_uncommitted_enums(&self) -> bool

True when the open transaction made an enum type or gave a label to one, so that the commit has a change for Catalog::commit_enums.

Source

pub fn commit_enums(&mut self)

AtEOXact_Enum: after the commit, each enum type and each label is one of an earlier transaction.

Source§

impl Catalog

Source

pub fn create_opfamily(&mut self, new: OpFamily) -> u32

CreateOpFamily: a new operator family, which gets the next OID. It depends on its access method and its schema.

Source

pub fn create_opclass(&mut self, new: OpClass) -> u32

The row of pg_opclass of DefineOpClass, which gets the next OID. The caller adds the members and then runs Catalog::opclass_depends, in the order of DefineOpClass.

Source

pub fn opclass_depends(&mut self, oid: u32)

The dependencies of DefineOpClass for the class: on its schema, its family, its type and its storage type.

Source

pub fn add_amop(&mut self, new: AmOp, link: &MemberLink) -> u32

The part of storeOperators for one operator: the row of pg_amop, which gets the next OID, and its dependencies.

Source

pub fn add_amproc(&mut self, new: AmProc, link: &MemberLink) -> u32

The part of storeProcedures for one function: the row of pg_amproc, which gets the next OID, and its dependencies.

Source

pub fn alter_opfamily(&mut self, oid: u32, change: impl FnOnce(&mut OpFamily))

Changes the row of the operator family.

Source

pub fn alter_opclass(&mut self, oid: u32, change: impl FnOnce(&mut OpClass))

Changes the row of the operator class.

Source

pub fn set_opcf_namespace(&mut self, family: bool, oid: u32, namespace: u32)

AlterObjectNamespace_internal for an operator family, or for an operator class when family is false: the move to the schema, with changeDependencyFor for the dependency on the schema.

Source

pub fn opfamilies(&self) -> impl Iterator<Item = &OpFamily>

The operator families, in the order of their OIDs.

Source

pub fn opfamily(&self, oid: u32) -> Option<&OpFamily>

The operator family with the OID.

Source

pub fn opclasses(&self) -> impl Iterator<Item = &OpClass>

The operator classes, in the order of their OIDs.

Source

pub fn opclass(&self, oid: u32) -> Option<&OpClass>

The operator class with the OID.

Source

pub fn amops(&self) -> impl Iterator<Item = &AmOp>

The rows of pg_amop, in the order of their OIDs.

Source

pub fn amop(&self, oid: u32) -> Option<&AmOp>

The row of pg_amop with the OID.

Source

pub fn amprocs(&self) -> impl Iterator<Item = &AmProc>

The rows of pg_amproc, in the order of their OIDs.

Source

pub fn amproc(&self, oid: u32) -> Option<&AmProc>

The row of pg_amproc with the OID.

Source§

impl Catalog

Source

pub fn operators(&self) -> impl Iterator<Item = &Operator>

The operators of the catalog, in the order of their OIDs.

Source

pub fn operator(&self, oid: u32) -> Option<&Operator>

The operator with the OID.

Source

pub fn operator_by_name( &self, namespace: u32, name: &str, left: u32, right: u32, ) -> Option<&Operator>

OperatorGet: the operator of the schema with the name and the input types.

Source

pub fn create_operator(&mut self, new: Operator) -> u32

OperatorCreate and OperatorShellMake for a new operator, which gets the next OID, with the dependencies of makeOperatorDependencies.

Source

pub fn replace_operator(&mut self, oid: u32, new: Operator) -> Result<()>

OperatorCreate for a shell operator that exists: the operator gets the new facts and keeps its OID, and its dependencies are made again.

§Errors

An internal error when no operator has the OID.

Source

pub fn alter_operator( &mut self, oid: u32, change: impl FnOnce(&mut Operator), ) -> Result<()>

Changes the row of the operator, as OperatorUpd and AlterOperator change it.

§Errors

An internal error when no operator has the OID.

Source§

impl Catalog

Source

pub fn set_relation_owner( &mut self, oid: u32, owner: u32, old: &str, new: &str, ) -> Result<()>

The change of ATExecChangeOwner for one relation: relowner, relacl, and the owner of the row type and of its array type, as AlterTypeOwnerInternal changes them. old and new are the names of the two roles, for the items of the ACL.

Source

pub fn set_schema_owner( &mut self, oid: u32, owner: u32, old: &str, new: &str, ) -> Result<()>

The change of AlterSchemaOwner_internal: nspowner and nspacl. old and new are the names of the two roles, for the items of the ACL.

Source

pub fn set_object_owner( &mut self, object: ObjRef, owner: u32, old: &str, new: &str, ) -> Result<()>

The change of AlterObjectOwner_internal for a function, a collation, a language, an extension, an operator, an operator class, an operator family, a statistics object, a text search dictionary and a text search configuration, and of AlterTypeOwnerInternal for the ACL of a type. The owner column changes, and the ACL that GRANT gave gets aclnewowner. The caller changes the owner of a type with Catalog::set_type_owner first. old and new are the names of the two roles, for the items of the ACL.

§Errors

An internal error for an object that the catalog does not have.

Source§

impl Catalog

Source

pub fn alter_sequence( &mut self, oid: u32, info: SequenceInfo, rewrite: Option<SequenceData>, ) -> Result<()>

The update of pg_sequence in AlterSequence. With rewrite, the sequence gets a new file with this row, as RelationSetNewRelfilenumber and fill_seq_with_data make it. The new file takes an OID, as GetNewRelFileNumber does.

Source

pub fn root_identity_sequence(&self, table: u32, column: i16) -> Option<u32>

getIdentitySequence: the sequence of an identity column. A partition has no sequence of its own, so its column uses the sequence of the column with the same name in the topmost partitioned table.

Source

pub fn identity_sequence(&self, table: u32, column: i16) -> Option<u32>

The sequence that an identity column owns, which has an internal dependency on the column. The column of a partition owns no sequence.

Source

pub fn owned_sequences(&self, table: u32) -> Vec<u32>

getOwnedSequences: the sequences that a column of the table owns, by an automatic dependency of OWNED BY or SERIAL or by the internal dependency of an identity column, in the order of the columns.

Source

pub fn set_owned_by( &mut self, sequence: u32, column: Option<(u32, i16)>, kind: DepKind, )

process_owned_by: the sequence loses its dependencies of kind on relations, and then gets one on the column when column is given.

Source§

impl Catalog

Source

pub fn moved_relations(&self, oid: u32) -> Vec<u32>

The relations that move with a relation to a new schema, as AlterTableNamespaceInternal moves them: the relation, then its indexes, then the sequences that its columns own.

Source

pub fn sequence_owner(&self, sequence: u32) -> Option<u32>

sequenceIsOwned: the table whose column owns the sequence, by an automatic or an internal dependency.

Source

pub fn set_relation_namespace(&mut self, oid: u32, namespace: u32) -> Result<()>

AlterTableNamespaceInternal: moves the relations of Catalog::moved_relations to the schema, with the row type and the array type of each one and the constraints of the table. changeDependencyFor changes the dependency on the schema of each relation that is not an index or a composite type, as the type of a composite type has the dependency. The caller checks the names in the new schema.

§Errors

An internal error for a relation that the catalog does not have.

Source§

impl Catalog

Source

pub fn create_stat_ext(&mut self, new: StatExt, refs: &[ObjRef]) -> Result<u32>

CreateStatistics: a new statistics object, which gets the next OID. It depends on each key column, or on the table when there is no key column, on the objects refs that the expressions refer to, and on its schema.

§Errors

23505 when the schema has a statistics object with the name.

Source

pub fn stat_exts(&self) -> impl Iterator<Item = &StatExt>

The statistics objects, in the order of their OIDs.

Source

pub fn stat_ext(&self, oid: u32) -> Option<&StatExt>

The statistics object with the OID.

Source

pub fn stat_ext_by_name(&self, namespace: u32, name: &str) -> Option<&StatExt>

The statistics object with the name in the schema.

Source

pub fn alter_stat_ext(&mut self, oid: u32, change: impl FnOnce(&mut StatExt))

Changes the row of the statistics object.

Source

pub fn set_stat_ext_namespace(&mut self, oid: u32, namespace: u32)

AlterObjectNamespace_internal for a statistics object: the move to the schema, with changeDependencyFor for the dependency on the schema.

Source§

impl Catalog

Source

pub fn create_ts_template(&mut self, new: TsTemplate) -> Result<u32>

DefineTSTemplate: a new template, which gets the next OID. It depends on its schema, its lexize function and its init function.

§Errors

23505 when the schema has a template with the name.

Source

pub fn create_ts_parser(&mut self, new: TsParser) -> Result<u32>

DefineTSParser: a new parser, which gets the next OID. It depends on its schema and its functions.

§Errors

23505 when the schema has a parser with the name.

Source

pub fn create_ts_dictionary(&mut self, new: TsDictionary) -> Result<u32>

DefineTSDictionary: a new dictionary, which gets the next OID. It depends on its schema and on its template.

§Errors

23505 when the schema has a dictionary with the name.

Source

pub fn create_ts_config( &mut self, new: TsConfig, copy: &[TsMapping], ) -> Result<u32>

DefineTSConfiguration: a new configuration, which gets the next OID, with a copy of the rows of pg_ts_config_map of copy.

§Errors

23505 when the schema has a configuration with the name.

Source

pub fn add_ts_mapping( &mut self, config: u32, tokens: &[i32], dicts: &[u32], replace: bool, )

The ADD MAPPING and ALTER MAPPING parts of MakeConfigurationMapping. With replace, the rows of the token types go first. Then each token type gets the dictionaries in order.

Source

pub fn replace_ts_dictionary( &mut self, config: u32, tokens: &[i32], old: u32, new: u32, )

The ALTER MAPPING REPLACE part of MakeConfigurationMapping: each row of the token types, or of all token types when tokens is empty, that has the dictionary old gets the dictionary new.

Source

pub fn drop_ts_mapping(&mut self, config: u32, token: i32) -> bool

DropConfigurationMapping for one token type: false when the configuration has no row for it.

Source

pub fn update_ts_config_depends(&mut self, config: u32)

Updates the dependencies of a configuration after Catalog::drop_ts_mapping.

Source

pub fn ts_templates(&self) -> impl Iterator<Item = &TsTemplate>

The templates, in the order of their OIDs.

Source

pub fn ts_template(&self, oid: u32) -> Option<&TsTemplate>

The template with the OID.

Source

pub fn ts_template_by_name( &self, namespace: u32, name: &str, ) -> Option<&TsTemplate>

The template with the name in the schema.

Source

pub fn ts_parsers(&self) -> impl Iterator<Item = &TsParser>

The parsers, in the order of their OIDs.

Source

pub fn ts_parser(&self, oid: u32) -> Option<&TsParser>

The parser with the OID.

Source

pub fn ts_parser_by_name(&self, namespace: u32, name: &str) -> Option<&TsParser>

The parser with the name in the schema.

Source

pub fn ts_dictionaries(&self) -> impl Iterator<Item = &TsDictionary>

The dictionaries, in the order of their OIDs.

Source

pub fn ts_dictionary(&self, oid: u32) -> Option<&TsDictionary>

The dictionary with the OID.

Source

pub fn ts_dictionary_by_name( &self, namespace: u32, name: &str, ) -> Option<&TsDictionary>

The dictionary with the name in the schema.

Source

pub fn ts_configs(&self) -> impl Iterator<Item = &TsConfig>

The configurations, in the order of their OIDs.

Source

pub fn ts_config(&self, oid: u32) -> Option<&TsConfig>

The configuration with the OID.

Source

pub fn ts_config_by_name(&self, namespace: u32, name: &str) -> Option<&TsConfig>

The configuration with the name in the schema.

Source

pub fn ts_mappings(&self) -> &[TsMapping]

The rows of pg_ts_config_map, in the order that they were made.

Source§

impl Catalog

Source

pub fn new() -> Catalog

An empty catalog. The first object gets the OID 16384.

Source

pub fn next_oid(&self) -> u32

The OID that the next object gets.

Source

pub fn advance_oid(&mut self, oid: u32)

Moves the OID counter forward to oid. PostgreSQL does not give an OID again after a rollback, so a session gives the counter of a rolled back copy to the copy that it keeps.

Source

pub fn set_next_oid(&mut self, oid: u32)

Sets the OID counter. Only initdb gives the OIDs below 16384, so only the catalog of a new cluster sets the counter back.

Source

pub fn skip_oids(&mut self, count: u32)

Uses count OIDs that PostgreSQL uses and rupg does not, such as the OID of a table that a check refuses after the OID was given.

Source

pub fn take_oid(&mut self) -> u32

GetNewObjectId for an object that the catalog does not keep, such as a role: the next OID of the counter.

Source

pub fn schemas(&self) -> impl Iterator<Item = &Schema>

The user schemas.

Source

pub fn schema(&self, oid: u32) -> Option<&Schema>

The schema with the OID.

Source

pub fn builtin_dropped(&self, object: ObjRef) -> bool

True when DROP removed the object of initdb. A lookup of the built-in objects must not find it.

Source

pub fn schema_dropped(&self, oid: u32) -> bool

True when DROP removed the schema of initdb with the OID.

Source

pub fn any_builtin_dropped(&self) -> bool

True when DROP removed an object of initdb.

Source

pub fn schema_by_name(&self, name: &str) -> Option<&Schema>

The user schema with the name.

Source

pub fn is_temp_schema(&self, oid: u32) -> bool

isAnyTempNamespace: true for a temporary schema pg_temp_N or its TOAST schema pg_toast_temp_N of any session. A user cannot make a schema with the prefix pg_, so the name tells.

Source

pub fn relations(&self) -> impl Iterator<Item = &Relation>

The relations.

Source

pub fn relation(&self, oid: u32) -> Option<&Relation>

The relation with the OID.

Source

pub fn relation_by_name(&self, namespace: u32, name: &str) -> Option<&Relation>

The relation with the name in the schema.

Source

pub fn types(&self) -> impl Iterator<Item = &Type>

The row types and array types.

Source

pub fn type_by_oid(&self, oid: u32) -> Option<&Type>

The type with the OID.

Source

pub fn type_by_name(&self, namespace: u32, name: &str) -> Option<&Type>

The type with the name in the schema.

Source

pub fn defaults(&self) -> impl Iterator<Item = &AttrDefault>

The column defaults.

Source

pub fn default_of(&self, relation: u32, column: i16) -> Option<&AttrDefault>

The default of a column.

Source

pub fn constraints(&self) -> impl Iterator<Item = &Constraint>

The constraints.

Source

pub fn constraint(&self, oid: u32) -> Option<&Constraint>

The constraint with the OID.

Source

pub fn constraints_of(&self, relation: u32) -> impl Iterator<Item = &Constraint>

The constraints of a relation, in the order of their OIDs.

Source

pub fn triggers(&self) -> impl Iterator<Item = &Trigger>

The triggers in the order of their OIDs.

Source

pub fn trigger(&self, oid: u32) -> Option<&Trigger>

The trigger with the OID.

Source

pub fn triggers_of(&self, relation: u32) -> Vec<&Trigger>

The triggers of a relation in the order of their names, as the index pg_trigger_tgrelid_tgname_index gives them.

Source

pub fn trigger_by_name(&self, relation: u32, name: &str) -> Option<&Trigger>

The trigger of the relation with the name.

Source

pub fn create_trigger( &mut self, new: NewTrigger, replace: bool, qual: &[ObjRef], ) -> Result<u32>

CreateTriggerFiringOn: a new trigger, or with replace new facts for the trigger of the relation with the same name. A replaced trigger keeps its OID and tgenabled, and gets new dependencies. The trigger depends on its function, then on its relation, then on each column of UPDATE OF, then on the objects that the condition of WHEN reads. A clone in a partition then has the partition dependencies on the trigger of the parent table and on its relation. The relation gets relhastriggers. The result is the OID of the trigger.

A constraint trigger first gets its constraint of the kind t, with the name of the trigger, as CreateConstraintEntry makes it. The trigger then depends on the table of FROM, and the constraint depends on the trigger, so that DROP TRIGGER drops the constraint.

§Errors

42710 when the relation has a trigger with the name and replace is false, or when that trigger is internal, or when it is a clone and the new trigger is not. 23505 when the relation has a constraint with the name of a new constraint trigger.

Source

pub fn rename_trigger(&mut self, oid: u32, name: &str) -> Result<()>

renametrig_internal: a new name for a trigger.

§Errors

42710 when the relation of the trigger has a trigger with the new name.

Source

pub fn clear_trigger_parent(&mut self, oid: u32)

The part of DropClonedTriggersFromPartition that removes the partition dependencies of a clone, so that the clone can go.

Source

pub fn set_trigger_enabled(&mut self, oid: u32, enabled: u8)

EnableDisableTrigger: sets tgenabled of a trigger.

Source

pub fn rules(&self) -> impl Iterator<Item = &Rule>

The rules in the order of their OIDs.

Source

pub fn rule(&self, oid: u32) -> Option<&Rule>

The rule with the OID.

Source

pub fn rule_by_name(&self, relation: u32, name: &str) -> Option<&Rule>

The rule of a relation with the name.

Source

pub fn collations(&self) -> impl Iterator<Item = &Collation>

The collations in the order of their OIDs.

Source

pub fn collation(&self, oid: u32) -> Option<&Collation>

The collation with the OID.

Source

pub fn collation_by_name( &self, namespace: u32, name: &str, ) -> Option<&Collation>

The collation with the name in a schema, as lookup_collation finds it: a collation of the encoding of the database first, then a collation of any encoding.

Source

pub fn constraints_of_domain( &self, domain: u32, ) -> impl Iterator<Item = &Constraint>

The check constraints of a domain.

Source

pub fn functions(&self) -> impl Iterator<Item = &Function>

The functions in the order of their OIDs.

Source

pub fn function(&self, oid: u32) -> Option<&Function>

The function with the OID.

Source

pub fn casts(&self) -> impl Iterator<Item = &Cast>

The casts, in the order of their OIDs.

Source

pub fn depends(&self) -> &[Depend]

The rows of pg_depend for user objects, in the order that PostgreSQL inserts them.

Source

pub fn descriptions(&self) -> impl Iterator<Item = (ObjRef, &str)>

The rows of pg_description for user objects: each object with its comment, in the order of the objects.

Source

pub fn description(&self, object: ObjRef) -> Option<&str>

The comment of an object, or None.

Source

pub fn set_description(&mut self, object: ObjRef, text: Option<String>)

CreateComments: sets the comment of an object, or drops it for None.

Source

pub fn object_acls(&self) -> impl Iterator<Item = (ObjRef, &[String])>

The ACLs that Catalog::set_object_acl gave.

Source

pub fn object_acl(&self, object: ObjRef) -> Option<&[String]>

The ACL that GRANT or REVOKE gave to an object, or None when the object keeps the ACL that it was made with. The ACL of a column is empty when it is null.

Source

pub fn set_object_acl(&mut self, object: ObjRef, acl: Option<Vec<String>>)

Sets the ACL of an object, or drops the ACL for None.

Source

pub fn choose_relation_name( &self, name1: &str, name2: Option<&str>, label: &str, namespace: u32, constraint: bool, ) -> String

ChooseRelationName: make_object_name(name1, name2, label), with a number after the label when a relation in the schema has the name, or a constraint in the schema has it and constraint is true.

Source

pub fn choose_constraint_name( &self, name1: &str, name2: Option<&str>, label: &str, namespace: u32, ) -> String

ChooseConstraintName: as Catalog::choose_relation_name, but only the constraints of the schema count.

Source

pub fn rename_relation(&mut self, oid: u32, name: &str) -> Result<()>

RenameRelationInternal: the new name of a relation. The row type and the array type get new names, as RenameTypeInternal gives them, and the constraint of an index gets the name of the index, as RenameConstraintById gives it.

§Errors

42P07 when the schema has a relation with the name, 42710 when the name is the name of a type or of a constraint of the table, and an internal error for a relation that the catalog does not have.

Source

pub fn rename_column( &mut self, relation: u32, number: i16, name: &str, ) -> Result<()>

renameatt_internal: the new name of a column. The caller checks the name.

§Errors

An internal error for a column that the catalog does not have.

Source

pub fn rename_constraint(&mut self, oid: u32, name: &str) -> Result<()>

RenameConstraintById: the new name of a constraint. The index of a primary key or a unique constraint keeps its name: the caller renames the index, which renames the constraint.

§Errors

42710 when the table has a constraint with the name, and an internal error for a constraint that the catalog does not have.

Source

pub fn rename_schema(&mut self, oid: u32, name: &str) -> Result<()>

RenameSchema: the new name of a schema. The caller checks the name.

§Errors

An internal error for a schema that the catalog does not have.

Source

pub fn create_schema(&mut self, name: &str, owner: u32) -> Result<u32>

CREATE SCHEMA. The caller checks the names of the built-in schemas and the pg_ prefix.

Source

pub fn add_column(&mut self, table: u32, column: Column) -> Result<i16>

ATExecAddColumn for the catalog: the column goes at the end of the columns of the table, and it depends on its type and its collation, as add_column_datatype_dependency and add_column_collation_dependency record them. The result is the number of the new column.

§Errors

54011 for a table that has the most columns already, and an internal error for a relation that is not in the catalog.

Source

pub fn alter_column_type( &mut self, table: u32, number: i16, new: &Column, ) -> Result<()>

ATExecAlterColumnType for the catalog: the column gets its new type, type modifier, collation and number of array dimensions, and its dependencies on the old type and collation give way to dependencies on the new ones.

§Errors

An internal error for a column that is not in the catalog.

Source

pub fn set_index_column( &mut self, index: u32, column: usize, class: u32, collation: u32, from: &Column, ) -> Result<()>

The column column of an index, from 0, after a change of the type of the column from of the table, as the index that ATPostAlterTypeCleanup makes again has it: the type of the table column, the collation collation, and for a key column the operator class class.

§Errors

An internal error for an index or a column that is not in the catalog.

Source

pub fn set_foreign_operators( &mut self, constraint: u32, pf_eq: Vec<u32>, pp_eq: Vec<u32>, ff_eq: Vec<u32>, ) -> Result<()>

The equality operators of a foreign key, conpfeqop, conppeqop and conffeqop, after a change of the type of a key column, as the foreign key that ATPostAlterTypeCleanup makes again has them.

§Errors

An internal error for a constraint that is not a foreign key of the catalog.

Source

pub fn create_table(&mut self, new: NewRelation) -> Result<u32>

heap_create_with_catalog for an ordinary table: the table gets an OID, then its array type, then its row type.

Source

pub fn create_partitioned_table(&mut self, new: NewRelation) -> Result<u32>

heap_create_with_catalog for a partitioned table. Catalog::set_partition_key then gives the key.

Source

pub fn set_partition_key(&mut self, table: u32, key: PartitionKey) -> Result<()>

StorePartitionKey: the row of pg_partitioned_table. The table depends on the operator class and the collation of each key column.

Source

pub fn attach_partition( &mut self, table: u32, parent: u32, bound: PartitionBound, ) -> Result<()>

StorePartitionBound and StoreCatalogInheritance1 for a partition: the bound, the row of pg_inherits, and the dependency of the partition on its parent. The dependency is automatic, so DROP TABLE of the parent drops the partition too.

Source

pub fn set_inherits(&mut self, table: u32, parents: Vec<u32>) -> Result<()>

StoreCatalogInheritance: the rows of pg_inherits of a new table of INHERITS, in the order of its parents, and the normal dependency of the table on each parent. So DROP TABLE of a parent needs CASCADE.

Source

pub fn add_inherit(&mut self, table: u32, parent: u32) -> Result<()>

StoreCatalogInheritance1 of ALTER TABLE ... INHERIT: the table gets the parent after its other parents, with the next inhseqno, and the normal dependency on the parent.

Source

pub fn set_of_type(&mut self, table: u32, ty: u32) -> Result<()>

The new reloftype of the table, or 0 for NOT OF, as ATExecAddOf and ATExecDropOf set it. The table loses its dependency on the old type and gets a normal dependency on the new type, as heap_create_with_catalog records it for a new typed table.

Source

pub fn remove_inherit(&mut self, table: u32, parent: u32) -> Result<()>

The part of RemoveInheritance of ALTER TABLE ... NO INHERIT: the table loses the row of pg_inherits of the parent and its dependency on the parent. The next INHERIT takes the number after the highest number that is left.

Source

pub fn children(&self, parent: u32) -> Vec<&Relation>

find_inheritance_children: the partitions of a table and the tables that inherit from it, in the order of their OIDs.

Source

pub fn all_inheritors(&self, table: u32) -> Vec<u32>

find_all_inheritors with no table itself: the children of the table, then the children of each of them in the same order, and so on. A table that inherits from two of them comes once.

Source

pub fn partitions(&self, parent: u32) -> Vec<&Relation>

The partitions of a partitioned table, in the order of their OIDs.

Source

pub fn set_index_parent(&mut self, index: u32, parent: u32) -> Result<()>

IndexSetParentIndex: the index becomes a partition of the index parent of the parent table, with the partition dependencies on parent and on its table.

Source

pub fn set_constraint_parent( &mut self, constraint: u32, parent: u32, ) -> Result<()>

ConstraintSetParentConstraint: the constraint of a partition comes from the constraint parent of the parent table, with the partition dependencies on parent and on the table of the constraint.

Source

pub fn set_index_valid(&mut self, index: u32, valid: bool) -> Result<()>

Sets indisvalid of an index.

Source

pub fn set_index_ready(&mut self, index: u32, ready: bool) -> Result<()>

Sets indisready of an index.

Source

pub fn set_constraint_inherited( &mut self, constraint: u32, local: bool, inhcount: i16, ) -> Result<()>

Sets conislocal and coninhcount of a constraint that a parent table gives.

Source

pub fn set_constraint_deferrability( &mut self, constraint: u32, deferrable: bool, deferred: bool, ) -> Result<()>

AlterConstrUpdateConstraintEntry and AlterConstrTriggerDeferrability: sets condeferrable and condeferred of a foreign key, and tgdeferrable and tginitdeferred of its triggers that check the rows and of its triggers of NO ACTION. The other triggers of the actions always fire at once.

Source

pub fn set_constraint_no_inherit( &mut self, constraint: u32, no_inherit: bool, ) -> Result<()>

Sets connoinherit of a constraint.

Source

pub fn set_constraint_enforced( &mut self, constraint: u32, enforced: bool, ) -> Result<()>

Sets conenforced of a check constraint or a foreign key, and convalidated to the same value, as ATExecAlterCheckConstrEnforceability and ATExecAlterFKConstrEnforceability do.

Source

pub fn set_constraint_validated( &mut self, constraint: u32, validated: bool, ) -> Result<()>

Sets convalidated of a constraint.

Source

pub fn set_column_inherited( &mut self, table: u32, number: i16, local: bool, inhcount: i16, ) -> Result<()>

Sets attislocal and attinhcount of the column number of a table.

Source

pub fn detach_partition(&mut self, table: u32) -> Result<()>

The part of RemoveInheritance and DetachPartitionFinalize for the partition table: it loses its bound, its row of pg_inherits and its dependency on its parent.

Source

pub fn clear_index_parent(&mut self, index: u32) -> Result<()>

IndexSetParentIndex with no parent: the index is no longer a partition of an index, and it loses its partition dependencies.

Source

pub fn clear_constraint_parent(&mut self, constraint: u32) -> Result<()>

ConstraintSetParentConstraint with no parent: the constraint is local again, with no parent constraint and no partition dependencies.

Source

pub fn create_composite_type(&mut self, new: NewRelation) -> Result<u32>

DefineCompositeType: the relation of a composite type, with its row type and the array type, as a table gets them. The result is the OID of the row type.

Source

pub fn create_view( &mut self, new: NewRelation, text: String, path: Vec<u32>, refs: &[ObjRef], ) -> Result<u32>

DefineView: the view gets its OID, its array type and its row type as a table does, then its _RETURN rule. The rule is part of the view, and it depends on the objects that the query reads.

Source

pub fn make_matview( &mut self, oid: u32, text: String, path: Vec<u32>, refs: &[ObjRef], populated: bool, ) -> Result<()>

StoreViewQuery for CREATE MATERIALIZED VIEW: the new table oid of create_ctas_internal becomes a materialized view, and it gets its _RETURN rule as a view does. populated is false for WITH NO DATA.

Source

pub fn set_populated(&mut self, oid: u32, populated: bool) -> Result<()>

SetMatViewPopulatedState: the new relispopulated of the materialized view oid.

Source

pub fn replace_view( &mut self, oid: u32, columns: Vec<Column>, text: String, path: Vec<u32>, refs: &[ObjRef], ) -> Result<()>

CREATE OR REPLACE VIEW of a view that exists. The columns after the old columns are new, and the rule gets the new query and new dependencies. The caller checks that the old columns did not change.

Source

pub fn set_view_text( &mut self, oid: u32, text: String, path: Vec<u32>, ) -> Result<()>

A new text of the view oid with the same query, which ALTER ... RENAME gives when the view reads an object that gets a new name. The rule keeps its dependencies.

Source

pub fn create_rule( &mut self, new: NewRule, replace: bool, actions: &[ObjRef], qual: &[ObjRef], ) -> Result<u32>

InsertRule: a new rule, or with replace new facts for the rule of the relation with the same name. A replaced rule keeps its OID and ev_enabled, and gets new dependencies. The rule depends on its relation, then on the objects that the actions read, then on the objects that the condition reads. The result is the OID of the rule.

§Errors

42710 when the relation has a rule with the name and replace is false.

Source

pub fn create_collation( &mut self, collation: Collation, comment: Option<&str>, ) -> Option<u32>

CollationCreate with if_not_exists and quiet: adds a collation and gives its OID, or gives None and adds nothing when the schema has a collation with the name for the same encoding. A collation for any encoding also conflicts with a collation for the encoding of the database, and a collation for one encoding conflicts with a collation for any encoding. The OID in collation is not used, and comment is the description of the new collation.

Source

pub fn set_options(&mut self, oid: u32, options: Vec<String>) -> Result<()>

Sets reloptions of a relation.

Source

pub fn set_clustered(&mut self, table: u32, index: Option<u32>)

mark_index_clustered: sets indisclustered on the index and clears it on each other index of the table. None clears it on all of them.

Source

pub fn set_replica_identity( &mut self, table: u32, code: u8, index: Option<u32>, ) -> Result<()>

relation_mark_replica_identity: sets relreplident of the table, and sets indisreplident on the index and clears it on each other index of the table.

Source

pub fn set_schema_acl( &mut self, oid: u32, acl: Option<Vec<String>>, ) -> Result<()>

Sets nspacl of a schema.

Source

pub fn create_domain(&mut self, new: NewDomain, refs: &[ObjRef]) -> Result<u32>

DefineDomain: the domain gets the OID after the OID of its array type, as AssignTypeArrayOid takes the first one. refs are the objects that the default refers to. The caller checks the base type, and adds the check constraints with Catalog::add_domain_check after this.

Source

pub fn create_enum(&mut self, new: NewEnum) -> Result<u32>

DefineEnum: the enum type, its labels and its array type. The array type gets the first OID, then the type, then each label gets the next even OID, as EnumValuesCreate gives the labels even OIDs in their sort order. The type depends on its schema. The return value is the OID of the type.

§Errors

42710 when the schema has a type with the name that is not an array type of another type.

Source

pub fn create_range(&mut self, new: NewRange) -> Result<u32>

DefineRange: the range type, its multirange type, their array types, the constructors and the cast from the range type to the multirange type. The array type of the range type gets the first OID, then the multirange type, its array type and the range type. The constructors and the cast come after the types. The return value is the OID of the range type.

§Errors

42710 when the schema has a type with the name of the range type or of the multirange type that is not an array type of another type.

Source

pub fn create_function(&mut self, new: Function, refs: &[ObjRef]) -> Result<u32>

ProcedureCreate: a new function, which gets the next OID. It depends on its schema and on the objects in refs, which are the objects that its body refers to.

§Errors

42723 when the schema has a function with the same name and the same argument types.

Source

pub fn replace_function( &mut self, oid: u32, new: Function, refs: &[ObjRef], ) -> Result<()>

ProcedureCreate with replace for the function oid that exists: the function gets the new facts and keeps its OID and its owner. Its old dependencies go, and it depends on its schema and on the objects in refs, as a new function does.

§Errors

An internal error when no function has the OID.

Source

pub fn alter_function( &mut self, oid: u32, change: impl FnOnce(&mut Function), ) -> Result<()>

AlterFunction, and AlterObjectRename_internal, AlterObjectNamespace_internal and AlterObjectOwner_internal for a function: change gives the new row of the function. changeDependencyFor changes the dependency of the function on its schema when the schema changes.

§Errors

An internal error for a function that the catalog does not have.

Source

pub fn create_extension(&mut self, new: Extension) -> Result<u32>

CreateExtensionInternal: a new extension, which gets the next OID.

§Errors

42710 when an extension has the name.

Source

pub fn add_to_extension(&mut self, object: ObjRef, extension: u32)

recordDependencyOnCurrentExtension: makes an object a member of an extension, as a statement of the script of the extension does.

Source

pub fn create_language(&mut self, new: Language) -> Result<u32>

create_proc_lang: a new procedural language, which gets the next OID. It depends on its handlers.

§Errors

42710 when a language has the name.

Source

pub fn languages(&self) -> impl Iterator<Item = &Language>

The procedural languages, in the order of their OIDs.

Source

pub fn extensions(&self) -> impl Iterator<Item = &Extension>

The extensions, in the order of their OIDs.

Source

pub fn add_domain_check( &mut self, domain: u32, name: Option<&str>, expr: String, refs: &[ObjRef], ) -> Result<u32>

domainAddCheckConstraint: a check constraint of a domain. Without a name, the name is domain_check. refs are the objects that the expression refers to.

Source

pub fn add_domain_not_null( &mut self, domain: u32, name: Option<&str>, ) -> Result<u32>

domainAddNotNullConstraint: the not-null constraint of a domain, which also sets typnotnull. Without a name, the name is domain_not_null.

Source

pub fn set_new_file(&mut self, oid: u32) -> Result<()>

RelationSetNewRelfilenumber: the relation gets a new file, with a new OID, as REINDEX gives a new file to each index that it builds again.

Source

pub fn set_acl(&mut self, oid: u32, acl: Option<Vec<String>>) -> Result<()>

Sets relacl of a relation.

Source

pub fn create_sequence( &mut self, new: NewRelation, info: SequenceInfo, ) -> Result<u32>

DefineSequence. A sequence has no row type, and each column of a sequence is not null.

Source

pub fn set_sequence_owner(&mut self, sequence: u32, table: u32, column: i16)

OWNED BY: the sequence goes with the column of the table.

Source

pub fn set_unlogged(&mut self, oid: u32, unlogged: bool) -> Result<()>

ATExecSetRelOptions of SET LOGGED and SET UNLOGGED: the persistence of the relation changes. For a table, its indexes, its TOAST table with the index of the TOAST table, and the sequences that it owns change with it.

§Errors

The relation does not exist.

Source

pub fn change_stored_exprs( &mut self, change: &mut dyn FnMut(&str, bool) -> Result<Option<String>>, ) -> Result<()>

Changes the expressions that the catalog keeps in the form of the analyzer: the defaults of the columns and of the domains, the expressions of the check constraints, and the expressions and the predicates of the indexes. change gets the form, and true for the list of the expressions of an index. It gives the new form, or None for no change.

§Errors

The errors of change.

Source

pub fn add_default( &mut self, relation: u32, column: i16, expr: String, refs: &[ObjRef], ) -> Result<u32>

StoreAttrDefault: the default of a column. refs are the objects that the expression refers to.

Source

pub fn set_identity( &mut self, relation: u32, column: i16, identity: u8, ) -> Result<()>

The attidentity of a column: a, d, or 0 for a column that is not an identity column.

Source

pub fn set_stat_target( &mut self, relation: u32, column: i16, target: Option<i16>, ) -> Result<()>

ATExecSetStatistics: attstattarget of a column, or None for the default.

Source

pub fn set_storage( &mut self, relation: u32, column: i16, storage: u8, ) -> Result<()>

ATExecSetStorage and SetIndexStorageProperties: attstorage of a column and of each index column that is the column.

Source

pub fn set_compression( &mut self, relation: u32, column: i16, compression: u8, ) -> Result<()>

ATExecSetCompression and SetIndexStorageProperties: attcompression of a column and of each index column that is the column.

Source

pub fn set_column_generated( &mut self, relation: u32, column: i16, generated: u8, ) -> Result<()>

attgenerated of a column, which ATExecDropExpression sets to 0.

§Errors

An internal error for a column that is not in the catalog.

Source

pub fn set_column_options( &mut self, relation: u32, column: i16, options: Vec<String>, ) -> Result<()>

ATExecSetOptions: attoptions of a column.

Source

pub fn remove_default(&mut self, relation: u32, column: i16)

RemoveAttrDefault: removes the default of a column with its rows of pg_depend. A column with no default is not an error.

Source

pub fn add_check( &mut self, relation: u32, name: Option<&str>, expr: String, keys: Vec<i16>, refs: &[ObjRef], no_inherit: bool, ) -> Result<u32>

StoreRelCheck: a check constraint. keys are the columns that the expression refers to, in the order of their first use, and refs are the objects that the expression refers to.

Without a name, the name is table_column_check when the expression refers to one column, else table_check.

Source

pub fn add_not_null( &mut self, relation: u32, name: Option<&str>, column: i16, no_inherit: bool, ) -> Result<u32>

StoreRelNotNull: the not-null constraint of a column. Without a name, the name is table_column_not_null.

Source

pub fn create_index(&mut self, new: NewIndex) -> Result<(u32, Option<u32>)>

index_create, and index_constraint_create for the index of a primary key or a unique constraint. The result is the OID of the index and the OID of the constraint.

Without a name, the name is table_pkey for a primary key, table_columns_key for a unique constraint, else table_columns_idx.

Source

pub fn add_foreign_key(&mut self, new: NewForeignKey) -> Result<u32>

ATAddForeignKeyConstraint: a foreign key with its four triggers. Without a name, the name is table_columns_fkey.

Source

pub fn add_fk_constraint( &mut self, new: NewForeignKey, parent: u32, side: FkSide, ) -> Result<u32>

addFkConstraint: the row of pg_constraint of a foreign key, with no triggers. A constraint of the statement has no parent. A clone of the constraint parent serves one side: a clone for a partition of the referenced table depends on parent as a part of it, and a clone for a partition of the referencing table is a partition of parent. A clone keeps the name of parent, unless the table has a constraint with that name, and then the name gets _1, _2 and so on. The constraint is NO INHERIT unless its table is partitioned.

Source

pub fn add_fk_action_triggers( &mut self, constraint: u32, parents: Option<(u32, u32)>, ) -> Result<(u32, u32)>

createForeignKeyActionTriggers: the triggers of the actions of a foreign key on its referenced table, for a delete and for an update, in this order. Only NO ACTION can wait to the end of the transaction. The triggers of a clone are the clones of parents, the triggers of its parent constraint.

Source

pub fn add_fk_check_triggers( &mut self, constraint: u32, parents: Option<(u32, u32)>, ) -> Result<(u32, u32)>

createForeignKeyCheckTriggers: the checks of a foreign key on its referencing table, for an insert and for an update, in this order. The triggers of a clone are the clones of parents, the triggers of its parent constraint.

Source

pub fn set_trigger_parent(&mut self, trigger: u32, parent: u32)

TriggerSetParentTrigger: the trigger becomes a clone of the trigger parent, with the partition dependencies on parent and on its table.

Source

pub fn drop_depends_of(&mut self, object: ObjRef)

deleteDependencyRecordsFor: the object loses all its rows of pg_depend, so that it can go alone.

Source

pub fn attach_index_constraint( &mut self, index: u32, kind: ConKind, deferrable: bool, deferred: bool, ) -> Result<u32>

index_constraint_create for ALTER TABLE ... ADD CONSTRAINT ... USING INDEX: the existing index index gets the primary key or the unique constraint kind, with the name of the index. The index loses its automatic dependencies on the columns of the table, because it depends on the constraint now. A primary key sets indisprimary, and a deferrable constraint clears indimmediate.

§Errors

42710 when the table has a constraint with the name of the index, and an internal error for an index that the catalog does not have.

Source

pub fn create_toast(&mut self, table: u32) -> Result<u32>

create_toast_table: the TOAST table of a table and its index, in the schema pg_toast, or in pg_toast_temp_N for a table of the temporary schema pg_temp_N. The TOAST table gets an OID, then its index. They have no row type.

Trait Implementations§

Source§

impl Clone for Catalog

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Catalog

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Catalog

Source§

fn default() -> Catalog

Returns the “default value” for a type. Read more
Source§

impl Eq for Catalog

Source§

impl PartialEq for Catalog

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Catalog

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.