feat(postgres): list user-defined types with details and DDL for PG-family databases
This commit is contained in:
1 parent
0c6c1fada2
commit
154c460657
59 files changed
+6538
-150
No files matched your search
@@ -1127,6 +1127,7 @@ pub enum AgentMethod {
|
||||
CompletionAssistantSearchV1,
|
||||
GetObjectSource,
|
||||
GetColumns,
|
||||
GetCustomTypeDetails,
|
||||
ListIndexes,
|
||||
ListForeignKeys,
|
||||
ListTriggers,
|
||||
@@ -1208,6 +1209,7 @@ impl AgentMethod {
|
||||
Self::GetObjectSource => "get_object_source",
|
||||
Self::GetTableDdl => "get_table_ddl",
|
||||
Self::GetColumns => "get_columns",
|
||||
Self::GetCustomTypeDetails => "get_type_details",
|
||||
Self::ListIndexes => "list_indexes",
|
||||
Self::ListForeignKeys => "list_foreign_keys",
|
||||
Self::ListTriggers => "list_triggers",
|
||||
@@ -2060,6 +2062,21 @@ impl AgentDriverClient {
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn get_custom_type_details<T: DeserializeOwned + Send + 'static>(
|
||||
&mut self,
|
||||
database: &str,
|
||||
schema: &str,
|
||||
name: &str,
|
||||
timeout_duration: Option<Duration>,
|
||||
) -> Result<T, String> {
|
||||
self.call_method_with_timeout(
|
||||
AgentMethod::GetCustomTypeDetails,
|
||||
agent_type_details_params(database, schema, name),
|
||||
timeout_duration,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn get_table_comment<T: DeserializeOwned + Send + 'static>(
|
||||
&mut self,
|
||||
database: &str,
|
||||
@@ -2756,6 +2773,10 @@ pub fn agent_object_source_params<K: Serialize>(database: &str, schema: &str, na
|
||||
serde_json::json!({ "database": database, "schema": schema, "name": name, "object_type": object_type })
|
||||
}
|
||||
|
||||
pub fn agent_type_details_params(database: &str, schema: &str, name: &str) -> Value {
|
||||
serde_json::json!({ "database": database, "schema": schema, "name": name })
|
||||
}
|
||||
|
||||
pub fn agent_close_query_session_params(session_id: &str) -> Value {
|
||||
serde_json::json!({ "sessionId": session_id })
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ pub async fn list_tables_filtered(
|
||||
}
|
||||
|
||||
pub async fn list_objects(pool: &Pool, schema: &str) -> Result<Vec<ObjectInfo>, String> {
|
||||
let mut objects = db::postgres::list_objects(pool, schema).await?;
|
||||
let mut objects = db::postgres::list_objects(pool, schema, true, true, false).await?;
|
||||
let names = objects.iter().map(|object| object.name.clone()).collect::<Vec<_>>();
|
||||
let external_names = external_table_names(pool, schema, &names).await.unwrap_or_else(|error| {
|
||||
log::debug!("[cloudberry][list_objects:external-table-fallback] error={error}");
|
||||
|
||||
@@ -42,6 +42,8 @@ pub async fn list_objects(pool: &MySqlPool, database: &str) -> Result<Vec<Object
|
||||
schema: Some(database.to_string()),
|
||||
valid: None,
|
||||
signature: None,
|
||||
custom_type_kind: None,
|
||||
has_members: None,
|
||||
comment: table.comment,
|
||||
created_at: None,
|
||||
updated_at: None,
|
||||
@@ -105,6 +107,8 @@ fn plugin_object(
|
||||
schema: Some(database.to_string()),
|
||||
valid: None,
|
||||
signature: None,
|
||||
custom_type_kind: None,
|
||||
has_members: None,
|
||||
comment: if comment_parts.is_empty() { None } else { Some(comment_parts.join(", ")) },
|
||||
created_at: None,
|
||||
updated_at: None,
|
||||
|
||||
@@ -2952,6 +2952,8 @@ fn row_to_object(row: &mysql_async::Row, database: &str) -> ObjectInfo {
|
||||
schema: Some(database.to_string()),
|
||||
valid: None,
|
||||
signature: None,
|
||||
custom_type_kind: None,
|
||||
has_members: None,
|
||||
comment: get_opt_str(row, "object_comment")
|
||||
.map(|s| fix_potential_double_encoding(&s))
|
||||
.filter(|s| !s.is_empty()),
|
||||
@@ -3226,6 +3228,8 @@ fn table_infos_to_objects(
|
||||
schema: Some(database.to_string()),
|
||||
valid: None,
|
||||
signature: None,
|
||||
custom_type_kind: None,
|
||||
has_members: None,
|
||||
comment: table.comment,
|
||||
created_at: meta.and_then(|meta| meta.created_at.clone()),
|
||||
updated_at: meta.and_then(|meta| meta.updated_at.clone()),
|
||||
@@ -5491,6 +5495,8 @@ mod tests {
|
||||
schema: Some("app".to_string()),
|
||||
valid: None,
|
||||
signature: None,
|
||||
custom_type_kind: None,
|
||||
has_members: None,
|
||||
comment: None,
|
||||
created_at: None,
|
||||
updated_at: None,
|
||||
|
||||
@@ -126,6 +126,8 @@ pub async fn list_objects(pool: &mysql_async::Pool, schema: &str) -> Result<Vec<
|
||||
.or_else(|| (!schema.trim().is_empty()).then(|| schema.to_string())),
|
||||
valid: None,
|
||||
signature: None,
|
||||
custom_type_kind: None,
|
||||
has_members: None,
|
||||
comment: None,
|
||||
created_at: None,
|
||||
updated_at: None,
|
||||
|
||||
+1537
-51
File diff suppressed because it is too large.
Load diff
@@ -14,6 +14,8 @@ pub async fn list_objects(pool: &Pool, schema: &str) -> Result<Vec<ObjectInfo>,
|
||||
schema: None,
|
||||
valid: None,
|
||||
signature: None,
|
||||
custom_type_kind: None,
|
||||
has_members: None,
|
||||
comment: t.comment.clone(),
|
||||
created_at: None,
|
||||
updated_at: None,
|
||||
|
||||
@@ -2319,6 +2319,8 @@ pub async fn list_objects(client: &mut SqlServerClient, schema: &str) -> Result<
|
||||
schema: Some(schema.to_string()),
|
||||
valid: None,
|
||||
signature: None,
|
||||
custom_type_kind: None,
|
||||
has_members: None,
|
||||
comment: row.get::<&str, _>(4).filter(|s: &&str| !s.is_empty()).map(|s: &str| s.to_string()),
|
||||
created_at: row.get::<chrono::NaiveDateTime, _>(2).map(|value| value.to_string()),
|
||||
updated_at: row.get::<chrono::NaiveDateTime, _>(3).map(|value| value.to_string()),
|
||||
|
||||
Reference in new issue
Block a user