ExecutorTestingKnobs is part of the context used to control parts of the system during testing.
| 785 | // ExecutorTestingKnobs is part of the context used to control parts of the |
| 786 | // system during testing. |
| 787 | type ExecutorTestingKnobs struct { |
| 788 | // StatementFilter can be used to trap execution of SQL statements and |
| 789 | // optionally change their results. The filter function is invoked after each |
| 790 | // statement has been executed. |
| 791 | StatementFilter StatementFilter |
| 792 | |
| 793 | // BeforePrepare can be used to trap execution of SQL statement preparation. |
| 794 | // If a nil error is returned, planning continues as usual. |
| 795 | BeforePrepare func(ctx context.Context, stmt string, txn *kv.Txn) error |
| 796 | |
| 797 | // BeforeExecute is called by the Executor before plan execution. It is useful |
| 798 | // for synchronizing statement execution. |
| 799 | BeforeExecute func(ctx context.Context, stmt string) |
| 800 | |
| 801 | // AfterExecute is like StatementFilter, but it runs in the same goroutine of the |
| 802 | // statement. |
| 803 | AfterExecute func(ctx context.Context, stmt string, err error) |
| 804 | |
| 805 | // AfterExecCmd is called after successful execution of any command. |
| 806 | AfterExecCmd func(ctx context.Context, cmd Command, buf *StmtBuf) |
| 807 | |
| 808 | // DisableAutoCommit, if set, disables the auto-commit functionality of some |
| 809 | // SQL statements. That functionality allows some statements to commit |
| 810 | // directly when they're executed in an implicit SQL txn, without waiting for |
| 811 | // the Executor to commit the implicit txn. |
| 812 | // This has to be set in tests that need to abort such statements using a |
| 813 | // StatementFilter; otherwise, the statement commits immediately after |
| 814 | // execution so there'll be nothing left to abort by the time the filter runs. |
| 815 | DisableAutoCommit bool |
| 816 | |
| 817 | // BeforeAutoCommit is called when the Executor is about to commit the KV |
| 818 | // transaction after running a statement in an implicit transaction, allowing |
| 819 | // tests to inject errors into that commit. |
| 820 | // If an error is returned, that error will be considered the result of |
| 821 | // txn.Commit(), and the txn.Commit() call will not actually be |
| 822 | // made. If no error is returned, txn.Commit() is called normally. |
| 823 | // |
| 824 | // Note that this is not called if the SQL statement representing the implicit |
| 825 | // transaction has committed the KV txn itself (e.g. if it used the 1-PC |
| 826 | // optimization). This is only called when the Executor is the one doing the |
| 827 | // committing. |
| 828 | BeforeAutoCommit func(ctx context.Context, stmt string) error |
| 829 | |
| 830 | // DisableTempObjectsCleanupOnSessionExit disables cleaning up temporary schemas |
| 831 | // and tables when a session is closed. |
| 832 | DisableTempObjectsCleanupOnSessionExit bool |
| 833 | // TempObjectsCleanupCh replaces the time.Ticker.C channel used for scheduling |
| 834 | // a cleanup on every temp object in the cluster. If this is set, the job |
| 835 | // will now trigger when items come into this channel. |
| 836 | TempObjectsCleanupCh chan time.Time |
| 837 | // OnTempObjectsCleanupDone will trigger when the temporary objects cleanup |
| 838 | // job is done. |
| 839 | OnTempObjectsCleanupDone func() |
| 840 | |
| 841 | // WithStatementTrace is called after the statement is executed in |
| 842 | // execStmtInOpenState. |
| 843 | WithStatementTrace func(span opentracing.Span, stmt string) |
| 844 |
nothing calls this directly
no outgoing calls
no test coverage detected