MCPcopy Create free account
hub / github.com/erans/pgsqlite / execute_ddl

Method execute_ddl

src/query/executor.rs:1828–2217  ·  view source on GitHub ↗
(
        framed: &mut Framed<T, crate::protocol::PostgresCodec>,
        db: &Arc<DbHandler>,
        session: &Arc<SessionState>,
        query: &str,
        _query_router: Option<&Arc<QueryRouter>

Source from the content-addressed store, hash-verified

1826 }
1827
1828 async fn execute_ddl<T>(
1829 framed: &mut Framed<T, crate::protocol::PostgresCodec>,
1830 db: &Arc<DbHandler>,
1831 session: &Arc<SessionState>,
1832 query: &str,
1833 _query_router: Option<&Arc<QueryRouter>>,
1834 ) -> Result<(), PgSqliteError>
1835 where
1836 T: tokio::io::AsyncRead + tokio::io::AsyncWrite + Unpin + Send,
1837 {
1838 use crate::translator::CreateTableTranslator;
1839 use crate::query::{QueryTypeDetector, QueryType};
1840 use crate::ddl::EnumDdlHandler;
1841 use tracing::info;
1842
1843 // Check if this is a CREATE DATABASE statement
1844 if matches!(QueryTypeDetector::detect_query_type(query), QueryType::Create) &&
1845 query.trim_start()[6..].trim_start().to_uppercase().starts_with("DATABASE") {
1846 info!("CREATE DATABASE command received - SQLite doesn't have database concept, succeeding with no-op");
1847
1848 // Send command complete
1849 framed.send(BackendMessage::CommandComplete {
1850 tag: "CREATE DATABASE".to_string()
1851 }).await
1852 .map_err(PgSqliteError::Io)?;
1853
1854 return Ok(());
1855 }
1856
1857 // Check if this is a DROP DATABASE statement
1858 if matches!(QueryTypeDetector::detect_query_type(query), QueryType::Drop) &&
1859 query.trim_start()[4..].trim_start().to_uppercase().starts_with("DATABASE") {
1860 info!("DROP DATABASE command received - SQLite doesn't have database concept, succeeding with no-op");
1861
1862 // Send command complete
1863 framed.send(BackendMessage::CommandComplete {
1864 tag: "DROP DATABASE".to_string()
1865 }).await
1866 .map_err(PgSqliteError::Io)?;
1867
1868 return Ok(());
1869 }
1870
1871 // Check if this is a CREATE USER/ROLE statement
1872 if matches!(QueryTypeDetector::detect_query_type(query), QueryType::Create) {
1873 let after_create = query.trim_start()[6..].trim_start().to_uppercase();
1874 if after_create.starts_with("USER") || after_create.starts_with("ROLE") {
1875 info!("CREATE USER/ROLE command received - SQLite doesn't have user management, succeeding with no-op");
1876
1877 let tag = if after_create.starts_with("USER") { "CREATE USER" } else { "CREATE ROLE" };
1878 framed.send(BackendMessage::CommandComplete {
1879 tag: tag.to_string()
1880 }).await
1881 .map_err(PgSqliteError::Io)?;
1882
1883 return Ok(());
1884 }
1885 }

Callers

nothing calls this directly

Calls 11

getMethod · 0.45
is_emptyMethod · 0.45
lenMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected