@@ -162,62 +162,26 @@ impl Arguments for PgArguments {
162162 self . buffer . count
163163 }
164164
165- fn merge ( & mut self , mut arguments : Self ) {
166- // Merge `Arguments.types`
167- {
168- self . types . append ( & mut arguments. types ) ;
165+ fn merge ( & mut self , arguments : Self ) {
166+ let buf_offset = self . buffer . len ( ) ;
167+ let count_offset = self . buffer . count ;
168+
169+ self . types . extend ( arguments. types ) ;
170+ self . buffer . count += arguments. buffer . count ;
171+ self . buffer . buffer . extend ( arguments. buffer . buffer ) ;
172+
173+ for mut patch in arguments. buffer . patches {
174+ patch. buf_offset += buf_offset;
175+ patch. arg_index += count_offset;
176+ self . buffer . patches . push ( patch) ;
169177 }
170- // Merge `Arguments.Buffer`
171- {
172- // Merge `buffer`
173- self . buffer . buffer . append ( & mut arguments. buffer . buffer ) ;
174178
175- // Merge `patches`
176- self . buffer . patches . append ( & mut arguments. buffer . patches ) ;
177-
178- // Merge `type_holes`
179- self . buffer . type_holes . append ( & mut arguments. buffer . type_holes ) ;
180-
181- // Increment number of arguments
182- self . buffer . count += arguments. buffer . count ;
179+ for ( offset, kind) in arguments. buffer . type_holes {
180+ self . buffer . type_holes . push ( ( offset + buf_offset, kind) ) ;
183181 }
184-
185- // drop(arguments);
186- }
187-
188- fn position < ' t , T > ( & mut self , position : u32 , value : T ) -> Result < ( ) , BoxDynError >
189- where
190- T : Encode < ' t , Self :: Database > + Type < Self :: Database >
191- {
192- todo ! ( )
193182 }
194183}
195184
196-
197- // #[derive(Default, Debug, Clone)]
198- // pub struct PgArgumentBuffer {
199- // buffer: Vec<u8>,
200-
201- // // Number of arguments
202- // count: usize,
203-
204- // // Whenever an `Encode` impl needs to defer some work until after we resolve parameter types
205- // // it can use `patch`.
206- // //
207- // // This currently is only setup to be useful if there is a *fixed-size* slot that needs to be
208- // // tweaked from the input type. However, that's the only use case we currently have.
209- // patches: Vec<Patch>,
210-
211- // // Whenever an `Encode` impl encounters a `PgTypeInfo` object that does not have an OID
212- // // It pushes a "hole" that must be patched later.
213- // //
214- // // The hole is a `usize` offset into the buffer with the type name that should be resolved
215- // // This is done for Records and Arrays as the OID is needed well before we are in an async
216- // // function and can just ask postgres.
217- // //
218- // type_holes: Vec<(usize, HoleKind)>, // Vec<{ offset, type_name }>
219- // }
220-
221185impl PgArgumentBuffer {
222186 pub ( crate ) fn encode < ' q , T > ( & mut self , value : T ) -> Result < ( ) , BoxDynError >
223187 where
0 commit comments