Feature Request: data_seek support #130

Open
kyledrake opened this Issue Mar 2, 2011 · 5 comments

3 participants

@kyledrake

Check out this code: https://github.com/oldmoe/mysqlplus/blob/master/ext/mysql.c#L1363

This is really useful for picking out random results on -huge- queries, and helps to get around the RAND() slowdown problems. You could implement a result[rand(result.count)] and not have to pull down an entire pile of records into ruby.

I'm working on a piece of code to allow people to utilize this easily using mysqlplus.. but I'd love to be able to do it in mysql2 instead :-)

@kyledrake

This reference changed: https://github.com/oldmoe/mysqlplus/blob/master/ext/mysql.c#L1390

Basically, it's the data_seek(offset) function. It's very useful! Would be really nice to be able to use it.

@sodabrew sodabrew was assigned Nov 25, 2012
@sodabrew
Collaborator

This function: http://dev.mysql.com/doc/refman/5.0/en/mysql-data-seek.html

Sounds good to me. I'll look at adding this after 0.3.12 (or closing with a reason it cannot be done).

@sodabrew
Collaborator

I had a thought about this: what if we implement it as an operator overload on array access (the [] operator) on the result set? Then you could do this:

result = connection.query("BIG QUERY")
thing = result[1234]
@sodabrew sodabrew added a commit to sodabrew/mysql2 that referenced this issue Dec 30, 2012
@sodabrew sodabrew Feature request #130: add element reference operator #[] to Mysql2::R…
…esult using mysql_data_seek.
3f2ed50
@sodabrew sodabrew added a commit to sodabrew/mysql2 that referenced this issue Jul 10, 2013
@sodabrew sodabrew Feature request #130: add element reference operator #[] to Mysql2::R…
…esult using mysql_data_seek.
384c306
@sodabrew sodabrew added a commit to sodabrew/mysql2 that referenced this issue Jul 10, 2013
@sodabrew sodabrew Feature request #130: add element reference operator #[] to Mysql2::R…
…esult using mysql_data_seek.
c8558a4
@sodabrew sodabrew added a commit to sodabrew/mysql2 that referenced this issue Jul 16, 2013
@sodabrew sodabrew Feature request #130: add element reference operator #[] to Mysql2::R…
…esult using mysql_data_seek.
0ed17f8
@simi

@sodabrew will be this merged?

@sodabrew
Collaborator

Not until we open a merge window for the next major release.

@sodabrew sodabrew added a commit to sodabrew/mysql2 that referenced this issue Feb 26, 2015
@sodabrew sodabrew Feature request #130: add element reference operator #[] to Mysql2::R…
…esult using mysql_data_seek.
34a958f
@sodabrew sodabrew added a commit to sodabrew/mysql2 that referenced this issue Jun 11, 2015
@sodabrew sodabrew Feature request #130: add element reference operator #[] to Mysql2::R…
…esult using mysql_data_seek.
b7d5d6c
@sodabrew sodabrew added a commit to sodabrew/mysql2 that referenced this issue Jun 12, 2015
@sodabrew sodabrew Feature request #130: add element reference operator #[] to Mysql2::R…
…esult using mysql_data_seek.
887ac01
@sodabrew sodabrew modified the milestone: 0.4.0, 0.5.0 Aug 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment