Skip to content

Commit 662ff94

Browse files
committed
fix(cubesql): Don't show meta OLAP queries in query history
1 parent a9140a1 commit 662ff94

File tree

2 files changed

+228
-127
lines changed

2 files changed

+228
-127
lines changed

rust/cubesql/cubesql/src/sql/postgres/extended.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,21 @@ pub enum PreparedStatement {
5858
description: Option<protocol::RowDescription>,
5959
span_id: Option<Arc<SpanId>>,
6060
},
61+
Error {
62+
/// Prepared statement can be declared from SQL or protocol (Parser)
63+
from_sql: bool,
64+
sql: String,
65+
created: DateTime<Utc>,
66+
span_id: Option<Arc<SpanId>>,
67+
},
6168
}
6269

6370
impl PreparedStatement {
6471
pub fn get_created(&self) -> &DateTime<Utc> {
6572
match self {
6673
PreparedStatement::Empty { created, .. } => created,
6774
PreparedStatement::Query { created, .. } => created,
75+
PreparedStatement::Error { created, .. } => created,
6876
}
6977
}
7078

@@ -73,20 +81,23 @@ impl PreparedStatement {
7381
match self {
7482
PreparedStatement::Empty { .. } => "".to_string(),
7583
PreparedStatement::Query { query, .. } => query.to_string(),
84+
PreparedStatement::Error { sql, .. } => sql.clone(),
7685
}
7786
}
7887

7988
pub fn get_from_sql(&self) -> bool {
8089
match self {
8190
PreparedStatement::Empty { from_sql, .. } => from_sql.clone(),
8291
PreparedStatement::Query { from_sql, .. } => from_sql.clone(),
92+
PreparedStatement::Error { from_sql, .. } => from_sql.clone(),
8393
}
8494
}
8595

8696
pub fn get_parameters(&self) -> Option<&Vec<PgTypeId>> {
8797
match self {
8898
PreparedStatement::Empty { .. } => None,
8999
PreparedStatement::Query { parameters, .. } => Some(&parameters.parameters),
100+
PreparedStatement::Error { .. } => None,
90101
}
91102
}
92103

@@ -103,13 +114,18 @@ impl PreparedStatement {
103114

104115
Ok(statement)
105116
}
117+
PreparedStatement::Error { .. } => Err(CubeError::internal(
118+
"It's not possible to bind errored prepared statements (it's a bug)".to_string(),
119+
)
120+
.into()),
106121
}
107122
}
108123

109124
pub fn span_id(&self) -> Option<Arc<SpanId>> {
110125
match self {
111126
PreparedStatement::Empty { span_id, .. } => span_id.clone(),
112127
PreparedStatement::Query { span_id, .. } => span_id.clone(),
128+
PreparedStatement::Error { span_id, .. } => span_id.clone(),
113129
}
114130
}
115131
}

0 commit comments

Comments
 (0)