Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add meta result attribute when calling a stored procedure #296

Open
TataFalat opened this issue Oct 14, 2024 · 3 comments
Open

add meta result attribute when calling a stored procedure #296

TataFalat opened this issue Oct 14, 2024 · 3 comments

Comments

@TataFalat
Copy link

Dear developers,
I am considering moving from mysql to mariadb in my node.js BE implementation.
I would really appreciate adding meta result attribute when calling a stored procedure.
My BE implementation uses stored procedures to retrieve data and it relies on metadata info.
I suppose it is possible to add it the same way you add it to SELECT queries.
Thank you in advance, Jan.

@rusher
Copy link
Collaborator

rusher commented Oct 14, 2024

stored procedure result have metadata as well.

example for CREATE PROCEDURE stmtSimple (IN p1 INT, IN p2 INT) begin SELECT p1 + p2 t; end

const rows = await shareConn.query('call stmtSimple(?,?)', [2, 2]);
    console.log(rows);
    // logged:
    // [
    //   [ { t: 4n } ],
    //   OkPacket { affectedRows: 0, insertId: 0n, warningStatus: 0 }
    // ]
    console.log(rows[0].meta);
    // logged:
    //   [
    //     ColumnDef {
    //     collation: Collation {
    //     index: 63,
    //     name: 'BINARY',
    //     charset: 'binary',
    //     maxLength: 1
    //   },
    //     columnLength: 12,
    //     columnType: 8,
    //     flags: 128,
    //     scale: 0,
    //     type: 'BIGINT'
    // }
    // ]
    //   [
    //     ColumnDef {
    //     collation: Collation {
    //     index: 63,
    //     name: 'BINARY',
    //     charset: 'binary',
    //     maxLength: 1
    //   },
    //     columnLength: 12,
    //     columnType: 8,
    //     flags: 128,
    //     scale: 0,
    //     type: 'BIGINT'
    // }

Could you tell what you expect ?

@rusher
Copy link
Collaborator

rusher commented Oct 14, 2024

ah, maybe this is because the difference compared to a SELECT command is that stored procedure will return 2 results. (there is always an additional OkPacket when executing a stored procedure). If you want to compare to a SELECT, you'll have to use only the first result.

@TataFalat
Copy link
Author

TataFalat commented Oct 15, 2024 via email

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

No branches or pull requests

2 participants