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

Fix for issue #450 #451

Merged
merged 1 commit into from
Nov 3, 2022
Merged

Conversation

shirwadkarsonia
Copy link
Contributor

Fixed issue #450. Error was being caused by the error message "Error creating $tablename table in $sqlitedb : $message" in src/generic/genxml.tcl. The variable $tablename does not exist inside the function "SQLiteUpdateKeyValue" and hence was throwing an exception. Changed to variable name to $table.

@sm-shaw
Copy link
Contributor

sm-shaw commented Nov 3, 2022

Can reproduce and confirm PR resolves issue #450. This issue occurs when the SQLite db files have already been created however write access is then revoked to make them read-only.
If we are unable to create the SQLite db files on startup the following error is given. (With /tmp/SQLITEDBS given as the storage directory in generic.xml config)

$ ./hammerdbcli 
HammerDB CLI v4.6
Copyright (C) 2003-2022 Steve Shaw
Type "help" for a list of commands
Access /tmp/SQLITEDBS exception. Use temp directory.
Access /tmp/SQLITEDBS exception. Use temp directory.
Access /tmp/SQLITEDBS exception. Use temp directory.
Access /tmp/SQLITEDBS exception. Use temp directory.
Access /tmp/SQLITEDBS exception. Use temp directory.
Access /tmp/SQLITEDBS exception. Use temp directory.
Access /tmp/SQLITEDBS exception. Use temp directory.
Access /tmp/SQLITEDBS exception. Use temp directory.

If we then allow access, startup but then change the directory to read only:

$ chmod 400 *
$ ls -ltr
total 188
-r-------- 1 steve steve 57344 Nov  3 14:28 generic.db
-r-------- 1 steve steve 28672 Nov  3 14:28 database.db
-r-------- 1 steve steve 16384 Nov  3 14:28 oracle.db
-r-------- 1 steve steve 16384 Nov  3 14:28 mssqlserver.db
-r-------- 1 steve steve 16384 Nov  3 14:28 db2.db
-r-------- 1 steve steve 16384 Nov  3 14:28 mysql.db
-r-------- 1 steve steve 16384 Nov  3 14:28 postgresql.db
-r-------- 1 steve steve 16384 Nov  3 14:28 mariadb.db

When running any command that tries to write to the files we get the error in #450

hammerdb>dbset db maria
Database set to MariaDB
can't read "tablename": no such variable
    while executing
"puts "Error creating $tablename table in $sqlitedb : $message""
    invoked from within
"if [catch {hdb eval $sqlcmd} message ] {
                puts "Error creating $tablename table in $sqlitedb : $message"
                return
       ..."
    invoked from within
"if [catch {sqlite3 hdb $sqlitedb} message ] {
        puts "Error initializing SQLite database : $message"
        return
    } else {
        catch {..."
    (procedure "SQLiteUpdateKeyValue" line 4)
    invoked from within
"SQLiteUpdateKeyValue "generic" "benchmark" "rdbms" $rdbms"
    (procedure "dbset" line 30)
    invoked from within
"dbset db maria"

With the change in the PR we get the correct error message as follows telling us the .db file is readonly.

hammerdb>dbset db maria
Database set to MariaDB
Error creating benchmark table in /tmp/SQLITEDBS/generic.db : attempt to write a readonly database

The PR is fine to accept - many thanks @shirwadkarsonia

Copy link
Contributor

@sm-shaw sm-shaw left a comment

Choose a reason for hiding this comment

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

Fix resolves #450 and was reproduced as per general comment to assist other reviewers.

@abondvt89
Copy link
Contributor

Merging after reviews and approval of the three members of the code maintenance team.

@abondvt89 abondvt89 merged commit 22bdf97 into TPC-Council:master Nov 3, 2022
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.

v4.5 Can’t read variable $tablename error when fails to create sqlite tables
4 participants