@@ -109,18 +109,18 @@ func (ss *SingleSelectAcquire) GetTail() primitivegraph.PrimitiveNode {
109109 return ss .root
110110}
111111
112- type eliderPayload struct {
113- currentTcc internaldto.TxnControlCounters
114- tableName string
115- reqEncoding string
116- }
112+ // type eliderPayload struct {
113+ // currentTcc internaldto.TxnControlCounters
114+ // tableName string
115+ // reqEncoding string
116+ // }
117117
118118type standardMethodElider struct {
119119 elisionFunc func (... any ) bool
120120}
121121
122122func (sme * standardMethodElider ) IsElide (argz ... any ) bool {
123- return sme .elisionFunc (argz )
123+ return sme .elisionFunc (argz ... )
124124}
125125
126126func newStandardMethodElider (elisionFunc func (... any ) bool ) methodElider {
@@ -135,7 +135,7 @@ func (ss *SingleSelectAcquire) elideActionIfPossible(
135135 tableName string ,
136136 reqEncoding string ,
137137) methodElider {
138- elisionFunc := func (argz ... any ) bool {
138+ elisionFunc := func (_ ... any ) bool {
139139 olderTcc , isMatch := ss .handlerCtx .GetNamespaceCollection ().GetAnalyticsCacheTableNamespaceConfigurator ().Match (
140140 tableName ,
141141 reqEncoding ,
@@ -174,21 +174,47 @@ type methodElider interface {
174174 IsElide (... any ) bool
175175}
176176
177- func (ss * SingleSelectAcquire ) actionHTTP (
178- elider methodElider ,
179- ) error {
180- return nil
177+ // func (ss *SingleSelectAcquire) actionHTTP(
178+ // _ methodElider,
179+ // ) error {
180+ // return nil
181+ // }
182+
183+ type actionInsertResult struct {
184+ err error
185+ isHousekeepingDone bool
186+ }
187+
188+ type ActionInsertResult interface {
189+ GetError () (error , bool )
190+ IsHousekeepingDone () bool
191+ }
192+
193+ //nolint:revive // no idea why this is a thing
194+ func (air * actionInsertResult ) GetError () (error , bool ) {
195+ return air .err , air .err != nil
181196}
182197
183- //nolint:nestif,funlen // acceptable for now
198+ func (air * actionInsertResult ) IsHousekeepingDone () bool {
199+ return air .isHousekeepingDone
200+ }
201+
202+ func newActionInsertResult (isHousekeepingDone bool , err error ) ActionInsertResult {
203+ return & actionInsertResult {
204+ err : err ,
205+ isHousekeepingDone : isHousekeepingDone ,
206+ }
207+ }
208+
209+ //nolint:nestif,funlen,gocognit // acceptable for now
184210func (ss * SingleSelectAcquire ) actionInsertPreparation (
185211 target interface {},
186212 resErr error ,
187213 housekeepingDone bool ,
188214 tableName string ,
189215 paramsUsed map [string ]interface {},
190216 reqEncoding string ,
191- ) error {
217+ ) ActionInsertResult {
192218 var items interface {}
193219 var ok bool
194220 logging .GetLogger ().Infoln (fmt .Sprintf ("SingleSelectAcquire.Execute() target = %v" , target ))
@@ -221,19 +247,19 @@ func (ss *SingleSelectAcquire) actionInsertPreparation(
221247 items = pl
222248 ok = true
223249 case nil :
224- return nil
250+ return newActionInsertResult ( housekeepingDone , nil )
225251 }
226252 keys := make (map [string ]map [string ]interface {})
227253
228254 //nolint:nestif // TODO: fix
229255 if ok {
230256 iArr , iErr := castItemsArray (items )
231257 if iErr != nil {
232- return iErr
258+ return newActionInsertResult ( housekeepingDone , iErr )
233259 }
234260 streamErr := ss .stream .Write (iArr )
235261 if streamErr != nil {
236- return streamErr
262+ return newActionInsertResult ( housekeepingDone , streamErr )
237263 }
238264 if ok && len (iArr ) > 0 {
239265 if ! housekeepingDone && ss .insertPreparedStatementCtx != nil {
@@ -244,7 +270,7 @@ func (ss *SingleSelectAcquire) actionInsertPreparation(
244270 ss .insertionContainer .SetTableTxnCounters (tableName , tcc )
245271 housekeepingDone = true
246272 if execErr != nil {
247- return execErr
273+ return newActionInsertResult ( housekeepingDone , execErr )
248274 }
249275 }
250276
@@ -279,21 +305,22 @@ func (ss *SingleSelectAcquire) actionInsertPreparation(
279305 ),
280306 )
281307 if rErr != nil {
282- return fmt .Errorf (
308+ expandedErr := fmt .Errorf (
283309 "sql insert error: '%w' from query: %s" ,
284310 rErr ,
285311 ss .insertPreparedStatementCtx .GetQuery (),
286312 )
313+ return newActionInsertResult (housekeepingDone , expandedErr )
287314 }
288315 keys [strconv .Itoa (i )] = item
289316 }
290317 }
291318 }
292319 }
293- return nil
320+ return newActionInsertResult ( housekeepingDone , nil )
294321}
295322
296- //nolint:funlen,gocognit,gocyclo,cyclop,nestif, revive // TODO: investigate
323+ //nolint:funlen,gocognit,gocyclo,cyclop,revive // TODO: investigate
297324func (ss * SingleSelectAcquire ) Build () error {
298325 prov , err := ss .tableMeta .GetProvider ()
299326 if err != nil {
@@ -404,15 +431,17 @@ func (ss *SingleSelectAcquire) Build() error {
404431 ss .handlerCtx .LogHTTPResponseMap (res .GetProcessedBody ())
405432 logging .GetLogger ().Infoln (fmt .Sprintf ("SingleSelectAcquire.Execute() response = %v" , res ))
406433
407- insertPrepErr := ss .actionInsertPreparation (
434+ insertPrepResult := ss .actionInsertPreparation (
408435 res .GetProcessedBody (),
409436 resErr ,
410437 housekeepingDone ,
411438 tableName ,
412439 paramsUsed ,
413440 reqEncoding ,
414441 )
415- if insertPrepErr != nil {
442+ housekeepingDone = insertPrepResult .IsHousekeepingDone ()
443+ insertPrepErr , hasInsertPrepErr := insertPrepResult .GetError ()
444+ if hasInsertPrepErr {
416445 return internaldto .NewErroneousExecutorOutput (insertPrepErr )
417446 }
418447
0 commit comments