-
-
Notifications
You must be signed in to change notification settings - Fork 464
Closed
Labels
Buggeneral bugs; can be anythinggeneral bugs; can be anything
Description
Help us help you
- I have checked that my issue doesn't exist yet.
- I have tried my absolute best to reduce the problem-space and have provided the absolute smallest test-case possible.
- I can always reproduce the issue with the provided description below.
Environment
- Operating System version: Windows 10 64-bit
- Game/AppID (with version if applicable): TF2/Any
- Current SourceMod version: 1.10
- Current SourceMod snapshot: 6528
- Current Metamod: Source snapshot: 1.11.0-dev+1145
Description
You can call FetchInt, etc. without calling FetchRow for SQLite query callbacks, which goes against the documentation and expected behaviour.
Problematic Code (or Steps to Reproduce)
#include <sourcemod>
#pragma semicolon 1
#pragma newdecls required
public Plugin myinfo = {
name = "",
author = "",
description = "",
version = "0.0.0",
url = ""
};
public void OnPluginStart()
{
char err[256];
Database db = SQL_Connect("testdb", false, err, sizeof(err));
if (db == null)
SetFailState("Couldn't connect: %s", err);
SQL_FastQuery(db, "CREATE TABLE IF NOT EXISTS testdb (field1 INTEGER, field2 INTEGER);");
char driver[16];
db.Driver.GetIdentifier(driver, sizeof(driver));
if (StrEqual(driver, "mysql"))
{
SQL_FastQuery(db, "INSERT INTO testdb (field1, field2) VALUES (123, 456) ON DUPLICATE KEY UPDATE field1 = 123, field2 = 456;");
SQL_FastQuery(db, "INSERT INTO testdb (field1, field2) VALUES (123, 789) ON DUPLICATE KEY UPDATE field1 = 123, field2 = 789;");
}
else // SQLite
{
SQL_FastQuery(db, "REPLACE INTO testdb (field1, field2) VALUES (123, 456);");
SQL_FastQuery(db, "REPLACE INTO testdb (field1, field2) VALUES (123, 789);");
}
db.Query(Callback, "SELECT * FROM testdb WHERE field1 = 123");
}
public void Callback(Database db, DBResultSet results, const char[] error, any data)
{
int val1 = SQL_FetchInt(results, 0); // Line 43
int val2 = SQL_FetchInt(results, 1);
PrintToServer("Query Results: %i %i", val1, val2);
SQL_FetchRow(results);
val1 = SQL_FetchInt(results, 0);
val2 = SQL_FetchInt(results, 1);
PrintToServer("Query Results after FetchRow: %i %i", val1, val2);
SQL_FetchRow(results);
val1 = SQL_FetchInt(results, 0);
val2 = SQL_FetchInt(results, 1);
PrintToServer("Query Results after 2nd FetchRow: %i %i", val1, val2);
}Logs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Buggeneral bugs; can be anythinggeneral bugs; can be anything

