Skip to content

Add a pager for windows #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 10, 2020
Merged

Add a pager for windows #33

merged 3 commits into from
Apr 10, 2020

Conversation

ecordell
Copy link
Contributor

@ecordell ecordell commented Apr 9, 2020

Getting this up for a quick sanity check while I work to verify these changes.

Background:
I'm using sqlittle in another project that needs to run on mac/linux/windows, didn't realize there was an os restriction until I'd gotten pretty far.

From reading go/internal and sqlite3, this seems like this will probably work - but I hit a snag testing, because wine has not implemented filelocks, and I primarily use linux/mac.

Also - I copied the naming conventions from pager_unix.go, any objections if I update to be more in line with typical golang style?

db/pager_unix.go Outdated
@@ -106,7 +108,7 @@ func (f *filePager) CheckReservedLock() (bool, error) {
lock := &unix.Flock_t{
Type: unix.F_WRLCK,
Whence: seek_set,
Start: sqlite_shared_first,
Start: sqlite_reserved_byte,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looked like an unintentional typo from my reading of sqlite3.c, I can remove the change if I misunderstood.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, must have been a copy from another Flock. Nice find!

@alicebob
Copy link
Owner

Thanks for the PR! It looks good on a quick read, I'll read it properly in a bit.

any objections if I update to be more in line with typical golang style?

I'm not sure what you refer to, but if it's the _s: feel free :) (just make it a separate commit, please)

constants are shared between os lock implementations, so move them
out of os-specific files

also camelcases them
@ecordell
Copy link
Contributor Author

Thanks @alicebob -

I was able to simplify this a lot once I discovered golang.org/x/sys/windows. I also spun up a windows 10 vm to verify that this branch can open sqlite files and read them on windows.

I'm not sure what you refer to, but if it's the _s: feel free :) (just make it a separate commit, please)

yep, that's all I meant! added that in an extra commit on top.

@ecordell
Copy link
Contributor Author

aside: It looks to me like there is a race condition for already locked and already unlocked logic for both unix and windows pagers if used across multiple goroutines. The file-level locking should mean that that nothing bad happens to the database itself, but it could mean that library users hit unexpected failures.

// around problems caused by indexing and/or anti-virus software on
// Windows systems.
// If you are using this code as a model for alternative VFSes, do not
// copy this retry logic. It is a hack intended for Windows only.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice comment.

@alicebob alicebob merged commit 528efd8 into alicebob:master Apr 10, 2020
@alicebob
Copy link
Owner

Thanks for the PR! I just merged it and called it v1.4.0. If you have an idea how to solve the race, that would be great, otherwise I'll have a look later.

If you run into more problems please don't hesitate to open an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants