--- mysql.c.in.orig 2006-05-31 14:33:38.000000000 +0200 +++ mysql.c.in 2006-05-31 14:24:51.000000000 +0200 @@ -1010,19 +1010,15 @@ return ary; } -/* fetch_hash2 (internal) */ -static VALUE fetch_hash2(VALUE obj, VALUE with_table) +/* fetch field names */ +static VALUE fetch_field_names(VALUE obj, VALUE with_table) { MYSQL_RES* res = GetMysqlRes(obj); unsigned int n = mysql_num_fields(res); - MYSQL_ROW row = mysql_fetch_row(res); - unsigned long* lengths = mysql_fetch_lengths(res); MYSQL_FIELD* fields = mysql_fetch_fields(res); unsigned int i; - VALUE hash; - if (row == NULL) - return Qnil; - hash = rb_hash_new(); + VALUE ary; + ary = rb_ary_new2(n); for (i=0; iptr[strlen(fields[i].table)] = '.'; strcpy(RSTRING(col)->ptr+strlen(fields[i].table)+1, fields[i].name); } + rb_ary_store(ary, i, col); + } + return ary; +} + +/* fetch_hash2 (internal) */ +static VALUE fetch_hash2(VALUE obj, VALUE field_names) +{ + MYSQL_RES* res = GetMysqlRes(obj); + MYSQL_ROW row = mysql_fetch_row(res); + unsigned long* lengths = mysql_fetch_lengths(res); + unsigned int n = RARRAY(field_names)->len; + unsigned int i; + VALUE hash; + if (row == NULL) + return Qnil; + hash = rb_hash_new(); + for (i=0; i