Skip to content
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

\i command, bufio.Scanner: token too long #290

Open
katmfoo opened this issue Aug 3, 2021 · 5 comments
Open

\i command, bufio.Scanner: token too long #290

katmfoo opened this issue Aug 3, 2021 · 5 comments

Comments

@katmfoo
Copy link

katmfoo commented Aug 3, 2021

When attempting to import a large sql file (mine was over 2 GB), I would eventually get the following error:

bufio.Scanner: token too long

@nineinchnick
Copy link
Member

We might try to use bufio.Reader.ReadLine() instead of a Scanner in

s := bufio.NewScanner(f)
but huge lines might cause issues in other places.

Until we address this, I'd recommend using tools dedicated to a particular DB for loading a large amount of data, as usql might not have the best performance for this.

@kenshaw
Copy link
Member

kenshaw commented Aug 3, 2021

I'd like to echo @nineinchnick -- perhaps one day usql will be ready to deal with bulk-loading data into any database, unfortunately it isn't ready for that yet. I'm quite familiar with this specific hack I wrote. I'l try to push out a fix, but as above, for bulk-loading data, I'd suggest relying on the database's native client.

kenshaw added a commit that referenced this issue Aug 3, 2021
Overhaul of \i and \ir file reading, changing to bufio.Reader.ReadLine
in place of the previous bufio.Scanner. Related to #290.
@kenshaw
Copy link
Member

kenshaw commented Aug 3, 2021

@pricheal + @nineinchnick I just pushed a commit changing to bufio.Reader.ReadLine. I don't have a multi-gigabyte file to test with, but I'll try to generate one later. My guess is if the original SQL script involved was trying to import a multi-gigabyte entry into a single row, this is going to cause the same problem. Either way, the new implementation is likely better. All of my superficial tests/checks are passing using this changed implementation, but requires more scrutiny.

jgryko5 pushed a commit to jgryko5/usql that referenced this issue Aug 24, 2021
Overhaul of \i and \ir file reading, changing to bufio.Reader.ReadLine
in place of the previous bufio.Scanner. Related to xo#290.
@kenshaw
Copy link
Member

kenshaw commented Aug 31, 2021

@pricheal were you able to test this change?

@katmfoo
Copy link
Author

katmfoo commented Aug 31, 2021

@pricheal were you able to test this change?

If I remember correctly I tested it and experienced the same 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

No branches or pull requests

3 participants