feat(pg,kingbase): partition table operations and detail queries
This commit is contained in:
1 parent
882bd130ab
commit
1000aa07b6
62 files changed
+6180
-133
No files matched your search
@@ -715,6 +715,100 @@ pub struct SubpartitionInfo {
|
||||
pub partition_key: String,
|
||||
}
|
||||
|
||||
/// PostgreSQL declarative partitioning strategy (`pg_partitioned_table.partstrat`:
|
||||
/// `r` = range, `l` = list, `h` = hash).
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum PgPartitionKind {
|
||||
Range,
|
||||
List,
|
||||
Hash,
|
||||
}
|
||||
|
||||
/// Structured form of a partition's `pg_get_expr(relpartbound)` definition.
|
||||
///
|
||||
/// Values are kept as SQL literal text (`'2024-01-01'`, `1`, `MINVALUE`,
|
||||
/// `MAXVALUE`, `'a'`) so the UI can round-trip exactly what PostgreSQL
|
||||
/// reported without re-typing or re-quoting them client-side.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase", tag = "kind")]
|
||||
pub enum PgPartitionBound {
|
||||
Range { from: Vec<String>, to: Vec<String> },
|
||||
List { values: Vec<String> },
|
||||
Hash { modulus: i32, remainder: i32 },
|
||||
Default,
|
||||
}
|
||||
|
||||
/// One relation in a PostgreSQL partition hierarchy, as returned by
|
||||
/// `get_table_partitioning_core`. `children` is nested to the same depth as
|
||||
/// the catalog's partition tree (PG supports multi-level partitioning).
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct PgPartitionNode {
|
||||
pub schema: String,
|
||||
pub name: String,
|
||||
/// Set only when this node is itself a partitioned parent.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub strategy: Option<PgPartitionKind>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub key_definition: Option<String>,
|
||||
/// This node's own partition bound (set for every non-root node).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub bound: Option<PgPartitionBound>,
|
||||
/// Raw `pg_get_expr(relpartbound)` text; retained as a display fallback
|
||||
/// when `bound` could not be parsed.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub bound_definition: Option<String>,
|
||||
#[serde(default)]
|
||||
pub is_leaf: bool,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub row_estimate: Option<i64>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub total_bytes: Option<i64>,
|
||||
#[serde(default)]
|
||||
pub children: Vec<PgPartitionNode>,
|
||||
}
|
||||
|
||||
/// Structured partitioning view of one PostgreSQL relation, used by the table
|
||||
/// structure editor's "Partitions" tab. Works for the partitioned parent
|
||||
/// (`is_partitioned`), for a member partition (`is_partition`), and reports
|
||||
/// the whole subtree rooted at the requested relation either way.
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct PgTablePartitioning {
|
||||
pub is_partitioned: bool,
|
||||
pub is_partition: bool,
|
||||
/// Display form `"schema.table"` of the owning parent, when this relation
|
||||
/// is itself a partition.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub parent: Option<String>,
|
||||
/// Parent parts, kept separate so a dotted identifier cannot be mis-split.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub parent_schema: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub parent_table: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub own_bound: Option<PgPartitionBound>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub strategy: Option<PgPartitionKind>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub key_definition: Option<String>,
|
||||
#[serde(default)]
|
||||
pub key_columns: Vec<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub key_expression: Option<String>,
|
||||
/// Name of the default partition, when the parent has one.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub default_partition: Option<String>,
|
||||
/// Descendant partitions (the root itself is not included).
|
||||
#[serde(default)]
|
||||
pub partitions: Vec<PgPartitionNode>,
|
||||
/// Server version (`current_setting('server_version_num')`), used by the UI
|
||||
/// to gate `DETACH PARTITION CONCURRENTLY` (PostgreSQL 14+).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub server_version_num: Option<i32>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct FunctionInfo {
|
||||
|
||||
Reference in new issue
Block a user