Skip to content

fix: use Database.Format for SQL escaping instead of manual EscapeString - #8

Merged
Rushaway merged 1 commit into
masterfrom
fix/sql-format-escaping
Aug 27, 2026
Merged

fix: use Database.Format for SQL escaping instead of manual EscapeString#8
Rushaway merged 1 commit into
masterfrom
fix/sql-format-escaping

Conversation

@Rushaway

Copy link
Copy Markdown
Member

Summary

  • In player_manager.sp, the queries were already built with h_db.Format, which already escaped %s arguments; remove the now-redundant EscapeString(...) call into a separate buffer beforehand and pass the raw player name straight to Format.
  • Bump SHOP_VERSION (3.0E9 -> 3.0E10).

Why

Database.Format escapes string arguments on its own, so pre-escaping into a buffer before calling it does nothing useful and adds an extra driver touchpoint. The public EscapeString/DB_EscapeString API used by other Shop_* plugins is untouched.

Test plan

  • Compile plugin and confirm no errors
  • Connect with a Steam name containing quotes and confirm player row insert/update still works

h_db.Format was already used to build these queries, so the preceding
EscapeString call into a separate buffer was redundant; pass the raw
value straight to Format instead, which escapes %s arguments directly.
Copilot AI lite review requested due to automatic review settings August 24, 2026 20:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Rushaway
Rushaway merged commit 5904879 into master Aug 27, 2026
7 checks passed
Rushaway added a commit that referenced this pull request Aug 27, 2026
DB_EscapeString was removed in e8d909c since PR #8 moved all query
building to Database.Format. The EscapeString() wrapper in shop.sp
was its only caller and has no callers of its own, so drop it too.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Rushaway added a commit that referenced this pull request Aug 27, 2026
…hs (#9)

* fix(db): remove blocking SQL calls from connect/upgrade/fastquery paths

DB_TryConnect() used a synchronous SQLite_UseDatabase()/SQL_ConnectCustom()
fallback when no "shop" entry existed in databases.cfg, blocking the game
thread on every (re)connect attempt in that configuration. Database.Connect()
already falls back to an implicit local SQLite database for an unknown
config name, so a single async call now covers both cases.

DB_FastQuery() used SQL_LockDatabase()/SQL_FastQuery(), and the legacy
v1->v2 schema upgrade (DB_UgradeState_1) issued a nested, fully
synchronous SQL_Query() per item category while iterating the old
`items` table. Both now go through Database.Query(); the per-category
upgrade fetches are dispatched together and joined with a pending
counter before the migration continues.

Bumped plugin version to 3.0E10.

* fix: declare g_iPendingCategoryFetches before first use

SourcePawn requires globals to be declared before use in the same file;
it was declared after DB_UgradeState_1(), which referenced it first,
causing "undefined symbol" at compile time.

* Remove DB_EscapeString function

Removed the DB_EscapeString function that escapes strings for database queries.

* fix: remove EscapeString wrapper for deleted DB_EscapeString

DB_EscapeString was removed in e8d909c since PR #8 moved all query
building to Database.Format. The EscapeString() wrapper in shop.sp
was its only caller and has no callers of its own, so drop it too.
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.

2 participants