Jump to content
  • 0

Issue with query_sql: SELECT id fails, but SELECT COUNT(*) works on the same table


Gabsu

Question


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  2
  • Reputation:   0
  • Joined:  11/15/18
  • Last Seen:  

Hey everyone, I don't know if here is the right place to ask for help about this problem, sorry if it's wrong.

I have an issue with the custom script Compendium and the `query_sql` function.

The Problem:

Inside the script (in the `OnActivate` event called by an item), the `query_sql` function fails when trying to execute a query like `SELECT id FROM compendium WHERE account_id = ...`. The function returns `Success flag: 0`, returning failure in query execution.

The strangest part is that, in the same script and on the same `compendium` table, queries like `SELECT COUNT(*) FROM compendium` work perfectly (return `Success flag: 1`).

Environment:

*   rAthena is up-to-date
*   MySQL: 8.0.41
*   Operating System: Windows
*   `compendium` Table: Created with `INT UNSIGNED` for `id` and `account_id`, `ENGINE=MyISAM` (script default).

Steps Already Taken:

1.  Script Syntax: We checked and corrected multiple syntax errors in the script (`Compendium1.1.c`) and `item_db_usable.yml`. The script now loads without errors in the console.
2.  SQL Connection: Confirmed the SQL connection is working, as `query_sql("SELECT COUNT(*) FROM login")` returns success.
3.  Permissions: Verified and confirmed that the MySQL user (`ragnarok`) has `SELECT`, `INSERT`, `UPDATE` permissions on the `ragnarok` database and the `compendium` table.
4.  Query Syntax: Tried various variations of the `SELECT id FROM compendium WHERE account_id = ...` query (with/without quotes around `account_id`, with/without backticks on names), all fail with `Success flag: 0`.
5.  Test without WHERE: The query `SELECT id FROM compendium LIMIT 1` (without the `WHERE` clause) also fails with `Success flag: 0`.
6.  Table Recreation: Tried `DROP TABLE compendium;` and let the script recreate it via `CREATE TABLE IF NOT EXISTS...` in `OnInit`. The problem persisted.
7.  Logs: Checked the MySQL error logs, and there are no errors recorded at the time the `SELECT id` query fails.

It seems the issue is not with the script syntax, permissions, or basic connection, but with something specific preventing the `query_sql` function from reading column data (like `id`) from the `compendium` table in this environment, even though it can count rows.

Has anyone seen something similar or have any suggestions on what might be causing this specific failure in reading column data via `query_sql`?

Thanks for the help!

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  222
  • Reputation:   95
  • Joined:  06/02/12
  • Last Seen:  

Hey. I can't reproduce this error, it's working fine here. If you made any changes to the script, could you share it? What is the message displayed in the map-server console?

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  2
  • Reputation:   0
  • Joined:  11/15/18
  • Last Seen:  

8 hours ago, Racaae said:

Hey. I can't reproduce this error, it's working fine here. If you made any changes to the script, could you share it? What is the message displayed in the map-server console?

 
Hey Racaae, thank you for your answer! Gonna start with a sorry here, I was being dumb lol.
 
I started from 0 and ran some tests, fixed one or two syntax errors, and, because I made the item to call the event usable, the emulator deleted the item before the script could check if the item existed and it wouldn't work, my previous problem was just me overthinking and messing with everything lol, but thanks for trying to help!
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...