Skip to content

As of reach dependent on view commit history #4011

@n8layman

Description

@n8layman

We observed a strange problem where a view we had established to union three long running tables suddenly started always referring to HEAD when using as of. After some exploration we found out that this occurs when a view is dropped and then added back in. It appears that a newly created view can't use as of to reach further back into the commit history than it's own creation commit.

I also wonder if this is a more general issue with as of. For example, we've been dropping tables then immediately re-adding them back in without an intervening commit in order to handle changes to the schema. This was a cool trick but can dolt's as of handle that? Or will it stop at the last time a table was added?

reprex:

dolt sql -q "create table test (pk int, c1 int, primary key(pk))" 
dolt sql -q "insert into test values (1,2), (2,4), (3,6)"
dolt commit -am "create test table and add values"
dolt sql -q "select * from test" 

dolt sql -q "create view test_view as select * from test where c1 < 3"
dolt sql -q "select * from test_view" 

dolt sql -q "insert into test values (4,1), (5,3), (6,5)"
dolt commit -am "add some more values"

dolt sql -q "select * from test" 
dolt sql -q "select * from test_view as of 'HEAD'"
dolt sql -q "select * from test_view as of 'HEAD^'"

dolt sql -q "alter table test add column c2 int"
dolt commit -am "Added column c2"
dolt sql -q "select * from test_view as of 'HEAD'"
dolt sql -q "select * from test_view as of 'HEAD^'"
dolt sql -q "select * from test_view as of 'HEAD~2'"

dolt sql -q "drop view test_view"
dolt commit -am "drop test_view"

dolt sql -q "create view test_view as select * from test where c1 < 3"
dolt commit -am "re-add test_view"
dolt sql -q "select * from test_view as of 'HEAD'"
dolt sql -q "select * from test_view as of 'HEAD^'"
dolt sql -q "select * from test_view as of 'HEAD~2'" 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions