From 1f9c29411ed6da0cbd322b0f3a7ea957a976ff28 Mon Sep 17 00:00:00 2001 From: Priec Date: Thu, 30 Apr 2026 11:48:03 +0200 Subject: [PATCH] multiple requests to the structure of a tables at once(batching) --- .gitignore | 1 + client | 2 +- common/proto/table_structure.proto | 39 ++++++----- common/src/proto/descriptor.bin | Bin 57729 -> 58132 bytes common/src/proto/komp_ac.table_structure.rs | 68 +++++++++++--------- server | 2 +- 6 files changed, 63 insertions(+), 49 deletions(-) diff --git a/.gitignore b/.gitignore index 3c838ef..6ad69b4 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ steel_decimal/tests/property_tests.proptest-regressions .direnv/ canvas/*.toml .aider* +.codex diff --git a/client b/client index 6a32d8c..8138995 160000 --- a/client +++ b/client @@ -1 +1 @@ -Subproject commit 6a32d8cb3a27860d9600bc2006b4a480b8b22be9 +Subproject commit 8138995272f49e19810a3d0df9fbea6032fe5744 diff --git a/common/proto/table_structure.proto b/common/proto/table_structure.proto index 3c559d9..6cf493e 100644 --- a/common/proto/table_structure.proto +++ b/common/proto/table_structure.proto @@ -4,40 +4,45 @@ package komp_ac.table_structure; import "common.proto"; -// Introspects the physical PostgreSQL table for a given logical table -// (defined in table_definitions) and returns its column structure. +// Introspects the physical PostgreSQL tables for one or more logical tables +// (defined in table_definitions) and returns their column structures. // The server validates that: // - The profile (schema) exists in `schemas` -// - The table is defined for that profile in `table_definitions` -// It then queries information_schema for the physical table and returns -// normalized column metadata. If the physical table is missing despite -// a definition, the response may contain an empty `columns` list. +// - Every table is defined for that profile in `table_definitions` +// It then queries information_schema for the physical tables and returns +// normalized column metadata. service TableStructureService { // Return the physical column list (name, normalized data_type, - // nullability, primary key flag) for a table in a profile. + // nullability, primary key flag) for one or more tables in a profile. // // Behavior: // - NOT_FOUND if profile doesn't exist in `schemas` - // - NOT_FOUND if table not defined for that profile in `table_definitions` + // - NOT_FOUND if any table is not defined for that profile in `table_definitions` // - Queries information_schema.columns ordered by ordinal position // - Normalizes data_type text (details under TableColumn.data_type) - // - Returns an empty list if the table is validated but has no visible - // columns in information_schema (e.g., physical table missing) - rpc GetTableStructure(GetTableStructureRequest) returns (TableStructureResponse); + // - Returns an error if any validated table has no visible columns in + // information_schema (e.g., physical table missing) + rpc GetTableStructure(GetTableStructureRequest) returns (GetTableStructureResponse); } -// Request identifying the profile (schema) and table to inspect. +// Request identifying the profile (schema) and tables to inspect. message GetTableStructureRequest { // Required. Profile (PostgreSQL schema) name. Must exist in `schemas`. string profile_name = 1; - // Required. Table name within the profile. Must exist in `table_definitions` - // for the given profile. The physical table is then introspected via - // information_schema. - string table_name = 2; + // Required. Table names within the profile. Each must exist in + // `table_definitions` for the given profile. The physical tables are then + // introspected via information_schema. + repeated string table_names = 2; } -// Response with the ordered list of columns (by ordinal position). +// Batched response keyed by table name. +message GetTableStructureResponse { + // Per-table physical column lists keyed by requested table name. + map table_structures = 1; +} + +// Response with the ordered list of columns (by ordinal position) for one table. message TableStructureResponse { // Columns of the physical table, including system columns (id, deleted, // created_at), user-defined columns, and any foreign-key columns such as diff --git a/common/src/proto/descriptor.bin b/common/src/proto/descriptor.bin index 740da507a9c8100644f455c05f65a5ee9b9eb650..4a88a03d656c60cc3ff9ad6109d98b08b9723403 100644 GIT binary patch delta 1351 zcmZ8gO=uKJ6z;0-jFXxTiJeT+(Uq&w49 zJvv5og*`0`3)UWXVGn{V>_NfBqu@pG;9Ud{9@d*DJ$Mv-)zdw3cMd)ERlV^ z&NKbD=lY|=b>oj+BrEGYD=YPJbWv{AkDcE|GQwG@u}hw_!MKH~KHga&(bf-YXXGbL zatll>tDw^&2&*CtScUOT-{Z^-NKcE-lOt{+(8x?L$RVDSI`93q6}tbw3VhxZL9@~w zvD>=b=A`d`f%4Y}R`)#VXgIZyL4gRwTi*hPl6n}AzuayXgbN> z)5^Z|!6GTsK-vj;mM?Vwq7$6bOruN7A^S6y5BMbIbj=T_?=cF08-BoO&A;MSof?g5 z8or>8Vz>Rss}a?c<}O2e9| zTllPfSN;`N&99TiNxB;sdmOLX%1K>LJzvP5#kBmpA!mXBN^{q!3IIFYRY$PZICR}n zv9#fG7j7ypkyFsk(_#w1*bNj_Knkdr@BrzLM|w~?!s49eK~UE(kfeXJy*CeZkMImoE+rTfxCf= zfEX8s$d76R9~!O$jrQFpabjesRBhA&D6=y;Q)QS#34#(w=`c9}?IY6|(sC}HCVnIQ*As>bP=lHfj!0I96 z+m{zhDf@t(QuIAhZGb>}V(*~@L8TLikB|#cDK?FQHjV64@_zI9czb#y+v2(~kPGQN z`B!<5Rb55-srlv@EWw;&Yz`nuSIFL^eq%01PkR?c|o5n$SLbA{4UcrnJ95aYr44@itA9{4MKvu)YadwK8oHE*9CsgJ*^?Vy#$}D$iQ_CLFs9$^^8#1MsihNtaHd zG^lGzU=A{3;p~Y@Nid*m9RWizeyQ+Lj2Ud*sW6jm@Tz6Ag0sQ1W`POG4#XReaN)A7 zQ}Bv5bDL@~?=7pVc?+I<0@|yiF!5<%IcuHUTyV#ZGm*Dg1xJqUTC8Z+ zkjxe)x0z`(t5^~>wpOQi*I0qO;wr^Y4F(il?FjYL7aG-q0TR&FKC)sw)z||I^V&Xb zDPMDaw~_#g)x}n`VfAxCnjMP7FAmWq6d}5nz(4oh&b&@=DG}_@}*mwAcCMYg7#&0BD-0*vcGc)OGM3{qEtl9w${&xGr4#8 IeSazQAH`7F%>V!Z diff --git a/common/src/proto/komp_ac.table_structure.rs b/common/src/proto/komp_ac.table_structure.rs index 1e48052..b460079 100644 --- a/common/src/proto/komp_ac.table_structure.rs +++ b/common/src/proto/komp_ac.table_structure.rs @@ -1,17 +1,27 @@ // This file is @generated by prost-build. -/// Request identifying the profile (schema) and table to inspect. +/// Request identifying the profile (schema) and tables to inspect. #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetTableStructureRequest { /// Required. Profile (PostgreSQL schema) name. Must exist in `schemas`. #[prost(string, tag = "1")] pub profile_name: ::prost::alloc::string::String, - /// Required. Table name within the profile. Must exist in `table_definitions` - /// for the given profile. The physical table is then introspected via - /// information_schema. - #[prost(string, tag = "2")] - pub table_name: ::prost::alloc::string::String, + /// Required. Table names within the profile. Each must exist in + /// `table_definitions` for the given profile. The physical tables are then + /// introspected via information_schema. + #[prost(string, repeated, tag = "2")] + pub table_names: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, } -/// Response with the ordered list of columns (by ordinal position). +/// Batched response keyed by table name. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetTableStructureResponse { + /// Per-table physical column lists keyed by requested table name. + #[prost(map = "string, message", tag = "1")] + pub table_structures: ::std::collections::HashMap< + ::prost::alloc::string::String, + TableStructureResponse, + >, +} +/// Response with the ordered list of columns (by ordinal position) for one table. #[derive(Clone, PartialEq, ::prost::Message)] pub struct TableStructureResponse { /// Columns of the physical table, including system columns (id, deleted, @@ -55,14 +65,13 @@ pub mod table_structure_service_client { )] use tonic::codegen::*; use tonic::codegen::http::Uri; - /// Introspects the physical PostgreSQL table for a given logical table - /// (defined in table_definitions) and returns its column structure. + /// Introspects the physical PostgreSQL tables for one or more logical tables + /// (defined in table_definitions) and returns their column structures. /// The server validates that: /// - The profile (schema) exists in `schemas` - /// - The table is defined for that profile in `table_definitions` - /// It then queries information_schema for the physical table and returns - /// normalized column metadata. If the physical table is missing despite - /// a definition, the response may contain an empty `columns` list. + /// - Every table is defined for that profile in `table_definitions` + /// It then queries information_schema for the physical tables and returns + /// normalized column metadata. #[derive(Debug, Clone)] pub struct TableStructureServiceClient { inner: tonic::client::Grpc, @@ -144,20 +153,20 @@ pub mod table_structure_service_client { self } /// Return the physical column list (name, normalized data_type, - /// nullability, primary key flag) for a table in a profile. + /// nullability, primary key flag) for one or more tables in a profile. /// /// Behavior: /// - NOT_FOUND if profile doesn't exist in `schemas` - /// - NOT_FOUND if table not defined for that profile in `table_definitions` + /// - NOT_FOUND if any table is not defined for that profile in `table_definitions` /// - Queries information_schema.columns ordered by ordinal position /// - Normalizes data_type text (details under TableColumn.data_type) - /// - Returns an empty list if the table is validated but has no visible - /// columns in information_schema (e.g., physical table missing) + /// - Returns an error if any validated table has no visible columns in + /// information_schema (e.g., physical table missing) pub async fn get_table_structure( &mut self, request: impl tonic::IntoRequest, ) -> std::result::Result< - tonic::Response, + tonic::Response, tonic::Status, > { self.inner @@ -198,31 +207,30 @@ pub mod table_structure_service_server { #[async_trait] pub trait TableStructureService: std::marker::Send + std::marker::Sync + 'static { /// Return the physical column list (name, normalized data_type, - /// nullability, primary key flag) for a table in a profile. + /// nullability, primary key flag) for one or more tables in a profile. /// /// Behavior: /// - NOT_FOUND if profile doesn't exist in `schemas` - /// - NOT_FOUND if table not defined for that profile in `table_definitions` + /// - NOT_FOUND if any table is not defined for that profile in `table_definitions` /// - Queries information_schema.columns ordered by ordinal position /// - Normalizes data_type text (details under TableColumn.data_type) - /// - Returns an empty list if the table is validated but has no visible - /// columns in information_schema (e.g., physical table missing) + /// - Returns an error if any validated table has no visible columns in + /// information_schema (e.g., physical table missing) async fn get_table_structure( &self, request: tonic::Request, ) -> std::result::Result< - tonic::Response, + tonic::Response, tonic::Status, >; } - /// Introspects the physical PostgreSQL table for a given logical table - /// (defined in table_definitions) and returns its column structure. + /// Introspects the physical PostgreSQL tables for one or more logical tables + /// (defined in table_definitions) and returns their column structures. /// The server validates that: /// - The profile (schema) exists in `schemas` - /// - The table is defined for that profile in `table_definitions` - /// It then queries information_schema for the physical table and returns - /// normalized column metadata. If the physical table is missing despite - /// a definition, the response may contain an empty `columns` list. + /// - Every table is defined for that profile in `table_definitions` + /// It then queries information_schema for the physical tables and returns + /// normalized column metadata. #[derive(Debug)] pub struct TableStructureServiceServer { inner: Arc, @@ -307,7 +315,7 @@ pub mod table_structure_service_server { T: TableStructureService, > tonic::server::UnaryService for GetTableStructureSvc { - type Response = super::TableStructureResponse; + type Response = super::GetTableStructureResponse; type Future = BoxFuture< tonic::Response, tonic::Status, diff --git a/server b/server index 82df1de..51f3eca 160000 --- a/server +++ b/server @@ -1 +1 @@ -Subproject commit 82df1dea822ddf18fd3724b2d1cc413fd7fd0bde +Subproject commit 51f3eca615b59e9e12bc172f8c8646c75b6da55a