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

SELECT query on standard database with geopoly virtual table fails #235

Open
captn3m0 opened this issue Dec 18, 2023 · 8 comments
Open

SELECT query on standard database with geopoly virtual table fails #235

captn3m0 opened this issue Dec 18, 2023 · 8 comments

Comments

@captn3m0
Copy link

Database: https://dbhub.io/captn3m0/bbmp-2023.db

The database is public, and uses the GEOPOLY extension. The table was created using CREATE VIRTUAL TABLE wards USING geopoly(No,Name).

Query: SELECT No FROM wards LIMIT 0,10

Running the query as a Visualization fails:

error executing query at 2:48:52 PM: SQL that modifies a database can only be used on Live databases

Running it over the API (/v1/query) results in the same response:

{
	"error": "SQL that modifies a database can only be used on Live databases"
}
@justinclift
Copy link
Member

Interesting. I'll do some experimentation with that database on my local development setup, and figure out what's going wrong.

Hopefully it won't be too hard to fix. 😄

@justinclift
Copy link
Member

justinclift commented Dec 18, 2023

Debugging this now, it looks like that query is (somehow) causing a bunch of INSERT, UPDATE, and DELETE statements to run. Debugging output from our SQLite Authorizer function (while running in my local dev desktop):

2023/12/18 15:16:19 SQLite Authorizer function - action 'Insert', table 'wards_node', function ''
2023/12/18 15:16:19 SQLite Authorizer function - action 'Delete', table 'wards_node', function ''
2023/12/18 15:16:19 SQLite Authorizer function - action 'Insert', table 'wards_rowid', function ''
2023/12/18 15:16:19 SQLite Authorizer function - action 'Update', table 'wards_rowid', function 'nodeno'
2023/12/18 15:16:19 SQLite Authorizer function - action 'Delete', table 'wards_rowid', function ''
2023/12/18 15:16:19 SQLite Authorizer function - action 'Insert', table 'wards_parent', function ''
2023/12/18 15:16:19 SQLite Authorizer function - action 'Delete', table 'wards_parent', function ''
2023/12/18 15:16:19 SQLite Authorizer function - action 'Update', table 'wards_rowid', function 'a0'
2023/12/18 15:16:19 SQLite Authorizer function - action 'Update', table 'wards_rowid', function 'a1'
2023/12/18 15:16:19 SQLite Authorizer function - action 'Update', table 'wards_rowid', function 'a2'
2023/12/18 15:16:19 SQLite Authorizer function - action 'Update', table 'wards_rowid', function 'a3'
2023/12/18 15:16:19 SQLite Authorizer function - action 'Update', table 'wards_rowid', function 'a4'
2023/12/18 15:16:19 SQLite Authorizer function - action 'Update', table 'wards_rowid', function 'a5'
2023/12/18 15:16:19 SQLite Authorizer function - action 'Update', table 'wards_rowid', function 'a6'
2023/12/18 15:16:19 Error when running query by 'default' for database (default/bbmp-2023.db): 'no such column: No (SELECT No FROM wards LIMIT 0,10;) (SQL logic error)'

Naturally, INSERT/UPDATE/DELETE aren't super great in what's supposed to be a read only database.

I'm not (yet) sure how that SELECT is turning into a bunch of statements that modify the database. Will probably need to check out the Geopoly stuff next, as that'll probably clue me in.

Will spend some more time on this today, and hopefully figure things out. It might be as simple as just needing to add the geopoly extension to the server or something, which hopefully will change things to not try altering the database (for read only databases).

Will find out... 😄

@justinclift
Copy link
Member

Oh hang on, we already compile SQLite with the geopoly extension (sorry, I forgot that). So it's not going to be completely that simple.

@justinclift
Copy link
Member

Attacking this problem from a different direction... the query seems to execute as expected when the database is uploaded as a live database though.

Maybe go with that approach instead? 😄

@captn3m0
Copy link
Author

captn3m0 commented Dec 18, 2023 via email

@justinclift
Copy link
Member

justinclift commented Dec 18, 2023

Yep, they do support the query end point. With that time it got stuck, how long ago was that?

We were having backend problems with RabbitMQ a while ago, which completely wedged everything when it occurred. We replaced RabbitMQ (about a week ago), so if that's what you hit then you're probably ok to use Query calls again. 😄

@justinclift
Copy link
Member

Oh, why the avoidance of the Execute end point btw? Was that also getting stuck when you used it?

@justinclift
Copy link
Member

@captn3m0 When you have a chance to try this stuff again, let me know if you come across any of the end points not working as expected.

And I just realised that when you said "remember being stuck" that you were probably meaning "conceptually" rather than server problems. Heh. 😉

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

2 participants