@@ -54,13 +54,20 @@ func GetRelationType(ctx *sql.Context, schema string, relation string) (Relation
5454 if ! ok {
5555 return RelationType_DoesNotExist , errors .Errorf ("GetRelationType cannot find the database" )
5656 }
57+
58+ // Verify relation against temporary tables created this session
59+ dbName := ctx .GetCurrentDatabase ()
60+ if _ , ok := session .GetTemporaryTable (ctx , dbName , relation ); ok {
61+ return RelationType_Table , nil
62+ }
63+
5764 return GetRelationTypeFromRoot (ctx , schema , relation , state .WorkingRoot ().(* RootValue ))
5865}
5966
6067// GetRelationTypeFromRoot performs the same function as GetRelationType, except that it uses the given root rather than
6168// the working session's root.
6269func GetRelationTypeFromRoot (ctx * sql.Context , schema string , relation string , root * RootValue ) (RelationType , error ) {
63- // Check regular and temporary tables first
70+ // Check tables first
6471 ok , err := root .HasTable (ctx , doltdb.TableName {Schema : schema , Name : relation })
6572 if err != nil {
6673 return RelationType_DoesNotExist , err
@@ -69,12 +76,6 @@ func GetRelationTypeFromRoot(ctx *sql.Context, schema string, relation string, r
6976 return RelationType_Table , nil
7077 }
7178
72- doltSession := dsess .DSessFromSess (ctx .Session )
73- dbName := ctx .GetCurrentDatabase ()
74- if _ , ok := doltSession .GetTemporaryTable (ctx , dbName , relation ); ok {
75- return RelationType_Table , nil
76- }
77-
7879 // Check sequences next
7980 collection , err := sequences .LoadSequences (ctx , root )
8081 if err != nil {
0 commit comments