(ctx context.Context, line string)
| 343 | } |
| 344 | |
| 345 | func (c *InteractiveClient) executor(ctx context.Context, line string) { |
| 346 | // take an execution lock, so that errors and warnings don't show up while |
| 347 | // we are underway |
| 348 | c.executionLock.Lock() |
| 349 | defer c.executionLock.Unlock() |
| 350 | |
| 351 | // set afterClose to restart - is we are exiting the metaquery will set this to AfterPromptCloseExit |
| 352 | c.afterClose = AfterPromptCloseRestart |
| 353 | |
| 354 | line = strings.TrimSpace(line) |
| 355 | |
| 356 | resolvedQuery := c.getQuery(ctx, line) |
| 357 | if resolvedQuery == nil { |
| 358 | // we failed to resolve a query, or are in the middle of a multi-line entry |
| 359 | // restart the prompt, DO NOT clear the interactive buffer |
| 360 | c.restartInteractiveSession() |
| 361 | return |
| 362 | } |
| 363 | |
| 364 | // we successfully retrieved a query |
| 365 | |
| 366 | // create a context for the execution of the query |
| 367 | queryCtx := c.createQueryContext(ctx) |
| 368 | |
| 369 | if resolvedQuery.IsMetaQuery { |
| 370 | c.hidePrompt = true |
| 371 | c.interactivePrompt.Render() |
| 372 | |
| 373 | if err := c.executeMetaquery(queryCtx, resolvedQuery.ExecuteSQL); err != nil { |
| 374 | error_helpers.ShowError(ctx, err) |
| 375 | } |
| 376 | c.hidePrompt = false |
| 377 | |
| 378 | // cancel the context |
| 379 | c.cancelActiveQueryIfAny() |
| 380 | } else { |
| 381 | statushooks.Show(ctx) |
| 382 | defer statushooks.Done(ctx) |
| 383 | statushooks.SetStatus(ctx, "Executing query…") |
| 384 | // otherwise execute query |
| 385 | c.executeQuery(ctx, queryCtx, resolvedQuery) |
| 386 | } |
| 387 | |
| 388 | // restart the prompt |
| 389 | c.restartInteractiveSession() |
| 390 | } |
| 391 | |
| 392 | func (c *InteractiveClient) executeQuery(ctx context.Context, queryCtx context.Context, resolvedQuery *modconfig.ResolvedQuery) { |
| 393 | // if there is a custom search path, wait until the first connection of each plugin has loaded |
no test coverage detected