Skip to content

Commit

Permalink
Small fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Cole committed Jul 21, 2023
1 parent 0285a38 commit 68e9d51
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 12 deletions.
2 changes: 1 addition & 1 deletion YSI_Coding/y_inline/y_inline_impl.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1620,7 +1620,7 @@ stock Callback_Release(const input[E_CALLBACK_DATA])
static stock Callback_Claim_(func[E_INLINE_CALL])
{
KillTimer(func[E_INLINE_CALL_TIMER]);
func[E_INLINE_CALL_TIMER] = YSI_SetTimerEx__("Inline_MaybeConst_", 0, false, YSI_gscSpecifier_i, AMX_Ref(func[E_INDIRECTION_ALWAYS_NULL]));
func[E_INLINE_CALL_TIMER] = YSI_SetTimerEx__("Inline_MaybeConst_", 0, false, YSI_gscSpecifier_i, AMX_Ref(func[E_INLINE_CALL:E_INDIRECTION_ALWAYS_NULL]));
}

/*-------------------------------------------------------------------------*//**
Expand Down
9 changes: 6 additions & 3 deletions YSI_Core/y_utils/y_utils_files.inc
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,13 @@ stock GetYSIScriptfilesDir(E_YSI_DIR:dir)
strcat(test, __COMPILER_PACK".gitkeep");
if ((file = fopen(test, io_write)))
{
// Found `YSI/dir/`.
StrCpy(YSI_gsDefaultDirs[dir], path[18]),
fclose(file);
}
if (fexist(test))
{
// Found `YSI/dir/`.
StrCpy(YSI_gsDefaultDirs[dir], path[18]);
}
else
{
#if defined fcreatedir
Expand All @@ -424,7 +427,7 @@ stock GetYSIScriptfilesDir(E_YSI_DIR:dir)
// Found nothing.
YSI_gsDefaultDirs[dir][0] = '\0';
}
//#endif
#endif
}
}
}
Expand Down
103 changes: 95 additions & 8 deletions YSI_Extra/y_inline_mysql.inc
Original file line number Diff line number Diff line change
Expand Up @@ -194,26 +194,113 @@ stock ORM_SaveInline(ORM:id, Func:cb<>)
#define MySQL_Connect mysql_connect
#define MySQL_Close mysql_close
#define MySQL_Log mysql_log
#define Cache_NumRows cache_num_rows
#define Cache_GetValueInt cache_get_value_int

public OnQueryError(errorid, const error[], const callback[], const query[], MySQL:handle)
{
printf("ERROR: %d, %d (%s)", _:handle, errorid, error);
printf(" %s, %s", callback, query);
}

@test(.group = "y_inline_mysql") MySQL_PQueryInline()
FINAL__ MySQL:YSI_gsSQL = MySQL_Connect("127.0.0.1", "root", "root", "y_inline_mysql");

@test(.group = "y_inline_mysql") MySQL_PQueryInline0()
{
MySQL_Log(ERROR | WARNING | INFO | DEBUG);
ASSERT_NZ(YSI_gsSQL);
if (YSI_gsSQL)
{
inline CreateResult()
{
printf("MySQL CREATE A: %d", Cache_NumRows());
}
for (new i = 0; i != 100; ++i)
{
inline const InsertResult()
{
inline SelectResult()
{
new
n = Cache_NumRows(),
v;
if (n)
{
printf("MySQL SELECT A: %d", Cache_NumRows());
do
{
--n;
Cache_GetValueInt(n, "ARow", v);
printf(" - %d: %d", n, v);
}
while (n);
}
else
{
printf("MySQL SELECT A: 0");
}
}
printf("MySQL INSERT A: %d", Cache_NumRows());
MySQL_PQueryInline(YSI_gsSQL, using inline SelectResult, "SELECT * FROM table1;");
}
MySQL_TQueryInline(YSI_gsSQL, using inline CreateResult, "CREATE TABLE IF NOT EXISTS table1 ( ARow int );");
MySQL_TQueryInline(YSI_gsSQL, using inline InsertResult, "INSERT INTO table1 VALUES (7);");
}
//MySQL_Close(YSI_gsSQL);
}
}

@test(.group = "y_inline_mysql") MySQL_PQueryInline1()
{
MySQL_Log(ERROR | WARNING | INFO | DEBUG);
ASSERT_NZ(YSI_gsSQL);
if (YSI_gsSQL)
{
inline const CreateResult()
{
printf("MySQL CREATE B: %d", Cache_NumRows());
}
for (new i = 0; i != 100; ++i)
{
MySQL_TQueryInline(YSI_gsSQL, using inline CreateResult, "CREATE TABLE IF NOT EXISTS table1 ( ARow int );");
}
//MySQL_Close(YSI_gsSQL);
}
}

@test(.group = "y_inline_mysql") MySQL_PQueryInline2()
{
MySQL_Log(ERROR | WARNING | INFO | DEBUG);
ASSERT_NZ(YSI_gsSQL);
if (YSI_gsSQL)
{
for (new i = 0; i != 100; ++i)
{
inline InsertResult()
{
printf("MySQL INSERT B: %d", Cache_NumRows());
}
MySQL_TQueryInline(YSI_gsSQL, using inline InsertResult, "INSERT INTO table1 VALUES (7);");
}
//MySQL_Close(YSI_gsSQL);
}
}

@test(.group = "y_inline_mysql") MySQL_PQueryInline3()
{
MySQL_Log(ERROR | WARNING | INFO | DEBUG);
new MySQL:sql = MySQL_Connect("127.0.0.1", "root", "", "y_inline_mysql");
ASSERT_NE(sql, MYSQL_INVALID_HANDLE);
if (sql)
ASSERT_NZ(YSI_gsSQL);
if (YSI_gsSQL)
{
inline const MySQLResult()
for (new i = 0; i != 100; ++i)
{

inline const SelectResult()
{
printf("MySQL SELECT B: %d", Cache_NumRows());
}
MySQL_PQueryInline(YSI_gsSQL, using inline SelectResult, "SELECT * FROM table1;");
}
MySQL_PQueryInline(sql, using inline MySQLResult, "CREATE TABLE IF NOT EXIST table1 ( Row int );");
MySQL_Close(sql);
//MySQL_Close(YSI_gsSQL);
}
}

0 comments on commit 68e9d51

Please sign in to comment.