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

Error in exporting library to bibtex #51

Closed
gapost opened this issue Jan 7, 2021 · 4 comments
Closed

Error in exporting library to bibtex #51

gapost opened this issue Jan 7, 2021 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@gapost
Copy link

gapost commented Jan 7, 2021

Hi,

I want to export my library to a bibtex file. I go to library view, press "export" and select "bibtex" and "download file" and I get the following error:

Database error: SQLSTATE[HY000]: General error: 1 too many SQL variables.

My library has currently 1211 items and my configuration: I,Librarian 5.7.1, PHP 7.3.25, SQLite 3.29.0

@mkucej
Copy link
Owner

mkucej commented Jan 14, 2021

Thank you for your report. This message might be caused by a limit of 999 variables in SQLite. I will need to see the full error message to track the cause, because I can't reproduce this with even much higher number of items.

@mkucej mkucej self-assigned this Jan 14, 2021
@mkucej mkucej added the bug Something isn't working label Jan 14, 2021
@gapost
Copy link
Author

gapost commented Jan 15, 2021

Hi, thank you for your reply.

Where can I find the full error message?

@mkucej
Copy link
Owner

mkucej commented Jan 15, 2021

Background

https://www.sqlite.org/limits.html

To prevent excessive memory allocations, the maximum value of a host parameter number is SQLITE_MAX_VARIABLE_NUMBER, which defaults to 999 for SQLite versions prior to 3.32.0 (2020-05-22) or 32766 for SQLite versions after 3.32.0.

Bug went unnoticed, because the Ubuntu compiled Sqlite3 overrides the default SQLITE_MAX_VARIABLE_NUMBER to 250,000.

Bugged code

The issue is caused by

\LibrarianApp\ItemsModel::itemData()
// Item placeholder.
$item_placeholders = array_fill(0, count($item_ids), '?');
$item_placeholder  = join(',', $item_placeholders);

When the number of $item_ids exceeds SQLITE_MAX_VARIABLE_NUMBER, script throws error: SQLSTATE[HY000]: General error: 1 too many SQL variables.

Similar issue can be found in:

\LibrarianApp\TagsModel::_getItemTags()
// List of recommended tags.
$columns = str_word_count($abstract, 1);
$placeholder_arr = array_fill(0, count($columns), '?');
$placeholders = join(',', $placeholder_arr);

@mkucej mkucej closed this as completed in b20159b Jan 21, 2021
@gapost
Copy link
Author

gapost commented Jan 24, 2021

Hi there,
thank you very much for your quick response to debug this issue!
George

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants