diff --git a/go/vt/vtgate/engine/fake_vcursor_test.go b/go/vt/vtgate/engine/fake_vcursor_test.go index f9cedd74bfc..ae1c9e918a7 100644 --- a/go/vt/vtgate/engine/fake_vcursor_test.go +++ b/go/vt/vtgate/engine/fake_vcursor_test.go @@ -275,10 +275,6 @@ func (t *noopVCursor) SetAutocommit(context.Context, bool) error { panic("implement me") } -func (t *noopVCursor) SetSessionForeignKeyChecks(ctx context.Context, foreignKeyChecks bool) error { - panic("implement me") -} - func (t *noopVCursor) SetClientFoundRows(context.Context, bool) error { panic("implement me") } @@ -747,10 +743,6 @@ func (f *loggingVCursor) SetAutocommit(context.Context, bool) error { panic("implement me") } -func (f *loggingVCursor) SetSessionForeignKeyChecks(ctx context.Context, foreignKeyChecks bool) error { - panic("implement me") -} - func (f *loggingVCursor) SetClientFoundRows(context.Context, bool) error { panic("implement me") } diff --git a/go/vt/vtgate/engine/primitive.go b/go/vt/vtgate/engine/primitive.go index 833f4cc3b45..c69423ee3fb 100644 --- a/go/vt/vtgate/engine/primitive.go +++ b/go/vt/vtgate/engine/primitive.go @@ -154,7 +154,6 @@ type ( SetAutocommit(ctx context.Context, autocommit bool) error SetClientFoundRows(context.Context, bool) error - SetSessionForeignKeyChecks(ctx context.Context, autocommit bool) error SetSkipQueryPlanCache(context.Context, bool) error SetSQLSelectLimit(int64) error SetTransactionMode(vtgatepb.TransactionMode) diff --git a/go/vt/vtgate/safe_session.go b/go/vt/vtgate/safe_session.go index 34645d87bf3..2adb5b665a5 100644 --- a/go/vt/vtgate/safe_session.go +++ b/go/vt/vtgate/safe_session.go @@ -573,25 +573,23 @@ func (session *SafeSession) TimeZone() *time.Location { } // ForeignKeyChecks returns the foreign_key_checks stored in system_variables map in the session. -func (session *SafeSession) ForeignKeyChecks() (*bool, *string) { +func (session *SafeSession) ForeignKeyChecks() *bool { session.mu.Lock() fkVal, ok := session.SystemVariables[sysvars.ForeignKeyChecks] session.mu.Unlock() if !ok { - return nil, nil + return nil } switch strings.ToLower(fkVal) { case "off", "0": - fkCheckStr := "0" fkCheckBool := false - return &fkCheckBool, &fkCheckStr + return &fkCheckBool case "on", "1": - fkCheckStr := "1" fkCheckBool := true - return &fkCheckBool, &fkCheckStr + return &fkCheckBool } - return nil, nil + return nil } // SetOptions sets the options diff --git a/go/vt/vtgate/vcursor_impl.go b/go/vt/vtgate/vcursor_impl.go index d69ffcffe0d..616b1ce8846 100644 --- a/go/vt/vtgate/vcursor_impl.go +++ b/go/vt/vtgate/vcursor_impl.go @@ -43,7 +43,6 @@ import ( vtrpcpb "vitess.io/vitess/go/vt/proto/vtrpc" "vitess.io/vitess/go/vt/sqlparser" "vitess.io/vitess/go/vt/srvtopo" - "vitess.io/vitess/go/vt/sysvars" "vitess.io/vitess/go/vt/topo" topoprotopb "vitess.io/vitess/go/vt/topo/topoproto" "vitess.io/vitess/go/vt/topotools" @@ -832,16 +831,6 @@ func (vc *vcursorImpl) SetAutocommit(ctx context.Context, autocommit bool) error return nil } -// SetSessionForeignKeyChecks implements the SessionActions interface -func (vc *vcursorImpl) SetSessionForeignKeyChecks(ctx context.Context, foreignKeyChecks bool) error { - if foreignKeyChecks { - vc.safeSession.SetSystemVariable(sysvars.ForeignKeyChecks, "1") - } else { - vc.safeSession.SetSystemVariable(sysvars.ForeignKeyChecks, "0") - } - return nil -} - // SetQueryTimeout implements the SessionActions interface func (vc *vcursorImpl) SetQueryTimeout(maxExecutionTime int64) { vc.safeSession.QueryTimeout = maxExecutionTime @@ -1365,7 +1354,7 @@ func (vc *vcursorImpl) UpdateForeignKeyChecksState(fkStateFromQuery *bool) { return } // If the query doesn't have anything, then we consult the session state. - vc.fkChecksState, _ = vc.safeSession.ForeignKeyChecks() + vc.fkChecksState = vc.safeSession.ForeignKeyChecks() } // GetForeignKeyChecksState gets the stored foreign key checks state in the vcursor.