Skip to content

Commit 6e0a3f5

Browse files
committed
Edited compiler script for Unix, added experimental field 'rewind' for 'mysql_fetch_row(s)' script function so no more RAM required.
1 parent aff3507 commit 6e0a3f5

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
mysql.config
2-
mysql.creator
2+
mysql.creator*
33
mysql.files
44
mysql.includes

bin/unix/cod4x_mysql.so

3.92 MB
Binary file not shown.

build_unix.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
#!/bin/sh
12
cd bin/unix
2-
#!/bin/bash
33
LIBNAME='cod4x_mysql.so'
44

55
echo Compiling...

script_functions.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ void Scr_MySQL_Fetch_Row_f()
361361
Plugin_Scr_MakeArray();
362362

363363
int i;
364+
mysql_field_seek(g_mysql_res[handle], 0);
364365
for(i = 0; i < col_count; ++i)
365366
{
366367
/* A little help here? I don't actually understand data representation
@@ -400,26 +401,25 @@ void Scr_MySQL_Fetch_Rows_f()
400401
Scr_MySQL_CheckCall(handle);
401402

402403
unsigned int col_count = mysql_num_fields(g_mysql_res[handle]);
403-
int row = mysql_num_rows(g_mysql_res[handle]);
404404

405405
// do this no matter what.
406406
Plugin_Scr_MakeArray();
407407

408-
if(row != 0)
408+
if(mysql_num_rows(g_mysql_res[handle]) != 0) /* Rows are exist */
409409
{
410410
int i = 0;
411411

412412
//int keyArrayIndex[col_count]; // NO, NO and... NO
413413
//char* keyArray[col_count]; // When you do that, in this world one T-Max cries somewhere!
414414
// First answer: http://stackoverflow.com/questions/5377411/non-const-declaration-of-array
415415

416-
int* keyArrayIndex = calloc(col_count, sizeof(int));
416+
/*int* keyArrayIndex = calloc(col_count, sizeof(int));
417417
MYSQL_FIELD* field;
418418
while((field = mysql_fetch_field(g_mysql_res[handle])) != NULL)
419419
{
420420
keyArrayIndex[i] = Plugin_Scr_AllocString(field->name);
421421
++i;
422-
}
422+
}*/
423423

424424
MYSQL_ROW rows;
425425
/*if( row == 1 ) // only one row? custom handling to only return a single dimensional array.
@@ -435,13 +435,18 @@ void Scr_MySQL_Fetch_Rows_f()
435435
while((rows = mysql_fetch_row(g_mysql_res[handle])) != NULL)
436436
{
437437
Plugin_Scr_MakeArray();
438-
for (i = 0; i < col_count; ++i) {
438+
439+
mysql_field_seek(g_mysql_res[handle], 0);
440+
for (i = 0; i < col_count; ++i)
441+
{
439442
Plugin_Scr_AddString(rows[i]);
440-
Plugin_Scr_AddArrayKey(keyArrayIndex[i]);
443+
444+
MYSQL_FIELD* field = mysql_fetch_field(g_mysql_res[handle]);
445+
Plugin_Scr_AddArrayKey(Plugin_Scr_AllocString(field->name));
441446
}
442447
Plugin_Scr_AddArray();
443448
}
444449
//}
445-
free(keyArrayIndex);
450+
//free(keyArrayIndex);
446451
}
447452
}

0 commit comments

Comments
 (0)