Class: MysqlBlobStreaming
- Inherits:
-
Object
- Object
- MysqlBlobStreaming
- Defined in:
- ext/mysql_blob_streaming/mysql_blob_streaming.c
Class Method Summary collapse
-
.stream(*args) ⇒ Object
MysqlBlobStreaming.stream(mysql2_client, query, buffer_length, &block).
Class Method Details
.stream(*args) ⇒ Object
MysqlBlobStreaming.stream(mysql2_client, query, buffer_length, &block)
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'ext/mysql_blob_streaming/mysql_blob_streaming.c', line 142
static VALUE stmt_fetch_and_write(int argc, VALUE *argv, VALUE self)
{
VALUE rb_mysql2_client;
VALUE rb_query;
VALUE rb_buffer_length;
VALUE rb_block;
rb_scan_args(argc, argv, "3&", &rb_mysql2_client, &rb_query, &rb_buffer_length, &rb_block);
int buffer_length = FIX2INT(rb_buffer_length);
if (buffer_length == 0) {
return 0;
}
if (buffer_length < 0) {
rb_raise(rb_eRuntimeError, "buffer size must be integer >= 0");
}
char *query = RSTRING_PTR(rb_query);
MYSQL *conn = mysql_connection(rb_mysql2_client);
MYSQL_STMT *stmt = prepare_and_execute_stmt_with_query(conn, query);
MYSQL_BIND *bind = build_result_bind(stmt, buffer_length);
int total_blob_length = determine_blob_length(stmt, bind);
loop_store_buffer(stmt, bind, total_blob_length, rb_block, self);
mysql_stmt_close(stmt);
free_result_bind(bind);
return Qnil;
}
|