File tree Expand file tree Collapse file tree 3 files changed +32
-6
lines changed
Expand file tree Collapse file tree 3 files changed +32
-6
lines changed Original file line number Diff line number Diff line change @@ -234,16 +234,14 @@ func (v *connection) sendMessage(msg msgs.FrontEndMsg) error {
234234 if result == nil {
235235 if len (msgBytes ) > 0 {
236236 _ , result = v .conn .Write (msgBytes )
237-
238- if result == nil {
239- connectionLogger .Debug ("-> " + msg .String ())
240- }
241237 }
242238 }
243239 }
244240
245241 if result != nil {
246242 connectionLogger .Error ("-> FAILED SENDING " + msg .String ()+ ": %v" , result .Error ())
243+ } else {
244+ connectionLogger .Debug ("-> " + msg .String ())
247245 }
248246
249247 return result
@@ -473,6 +471,10 @@ func (v *connection) authSendSHA512Password(extraAuthData []byte) error {
473471 return v .sendMessage (msg )
474472}
475473
474+ func (v * connection ) sync () error {
475+ return v .sendMessage (& msgs.FESyncMsg {})
476+ }
477+
476478func (v * connection ) lockSessionMutex () {
477479 v .sessMutex .Lock ()
478480}
Original file line number Diff line number Diff line change @@ -677,6 +677,29 @@ func TestSTDINCopyWithStream(t *testing.T) {
677677 assertNoNext (t , rows )
678678}
679679
680+ func TestHangAfterError (t * testing.T ) {
681+ connDB := openConnection (t )
682+ defer closeConnection (t , connDB )
683+
684+ rows , err := connDB .QueryContext (ctx , "SELECT 1" )
685+ defer rows .Close ()
686+
687+ assertNoErr (t , err )
688+ assertNext (t , rows )
689+ assertNoNext (t , rows )
690+
691+ rows , err = connDB .QueryContext (ctx , "SELECT 1+'abcd'" )
692+
693+ assertErr (t , err , "Invalid" )
694+
695+ rows , err = connDB .QueryContext (ctx , "SELECT 2" )
696+ defer rows .Close ()
697+
698+ assertNoErr (t , err )
699+ assertNext (t , rows )
700+ assertNoNext (t , rows )
701+ }
702+
680703var verticaUserName = flag .String ("user" , "dbadmin" , "the user name to connect to Vertica" )
681704var verticaPassword = flag .String ("password" , os .Getenv ("VERTICA_TEST_PASSWORD" ), "Vertica password for this user" )
682705var verticaHostPort = flag .String ("locator" , "localhost:5433" , "Vertica's host and port" )
Original file line number Diff line number Diff line change @@ -88,8 +88,8 @@ func (s *stmt) Close() error {
8888 if s .parseState == parseStateParsed {
8989 closeMsg := & msgs.FECloseMsg {TargetType : msgs .CmdTargetTypeStatement , TargetName : s .preparedName }
9090
91- s .conn .lockSessionMutex ()
92- defer s .conn .unlockSessionMutex ()
91+ // s.conn.lockSessionMutex()
92+ // defer s.conn.unlockSessionMutex()
9393
9494 if err := s .conn .sendMessage (closeMsg ); err != nil {
9595 return err
@@ -354,6 +354,7 @@ func (s *stmt) prepareAndDescribe() error {
354354
355355 switch msg := bMsg .(type ) {
356356 case * msgs.BEErrorMsg :
357+ s .conn .sync ()
357358 return msg .ToErrorType ()
358359 case * msgs.BEParseCompleteMsg :
359360 s .parseState = parseStateParsed
You can’t perform that action at this time.
0 commit comments