fix bug:GPSQL-3051 and add a test case to reproduce it