Transactions, y_inline and both
#1

Usually I act like a smartass, but today is my dumb day! I'm staring at the sources but I'm all out of coffee and can't make anything out of it

1. IIRC inline functions are inserted directly into code. Now, when I do something like

pawn Код:
CallStuff() {
    inline DealWithIt() {
        new
            rows,
            cols;
   
        cache_get_data(rows, cols, dbhandle);
        printf("We got something Mike! %d %d", rows, cols);
    }
   
    mysql_tquery(dbhandle, "SELECT 2+2 AS hamster FROM dual", using inline DealWithIt, "");
}
Is this still a threaded query, or does it require the callback to be... a callback?

2. Is it possible to use transactions via blueg plugin (I've got r31)?

Exhibit 1:

pawn Код:
CallStuff() {
    mysql_tquery(dbhandle, "START TRANSACTION", "", "");
    mysql_tquery(dbhandle, "SELECT 'Do something meaningful' AS hamster FROM dual", "", "");
    mysql_tquery(dbhandle, "SELECT 'Or not' AS hamster FROM dual", "", "");
    mysql_tquery(dbhandle, "COMMIT", "", "");
}
Exhibit 2 - chained:

pawn Код:
CallStuff() {
    inline S1() {
        inline S2() {
            inline S3() {
                inline S4() {
                    printf("Dealt with it!");
                }
                mysql_tquery(dbhandle, "COMMIT", using inline S4, "");
            }
            mysql_tquery(dbhandle, "SELECT 'Or not' AS hamster FROM dual", using inline S3, "");
        }
        mysql_tquery(dbhandle, "SELECT 'Do something meaningful' AS hamster FROM dual", using inline S2, "");
    }
    mysql_tquery(dbhandle, "START TRANSACTION", using inline S1, "");
}
Would any of those work?

I don't quite grasp concept of threaded queries (except that each query is separate, and in case there are multiple cpu threads available, they'll be used or something like that), so sorry for my ignorance.

@update:
Awesome, transactions work as planned! (exhibit 1 code used). Question 1 still stands
Reply
#2

R31 supports inline functions, but you'll have to use mysql_tquery_inline instead of mysql_tquery.
Reply
#3

Awesome, thanks guys. Oh, do you think that transaction used like that can create race condition vulnerability?
Reply
#4

I wouldn't use transactions anyway until R33 is released, because that multi-threading stuff could mix other queries into that transaction. But as long as you commit every started transaction it shouldn't be any problem.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)