ruby-mysql-ext 2.9.9 → 2.9.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,6 +9,7 @@ static VALUE cMysql;
9
9
  static VALUE cPacket;
10
10
  static VALUE cMysqlTime;
11
11
  static VALUE cProtocol;
12
+ static VALUE cRawRecord;
12
13
  static VALUE cStmtRawRecord;
13
14
  static VALUE cExecutePacket;
14
15
  static VALUE cCharset;
@@ -477,6 +478,33 @@ static VALUE _protocol_value2net(VALUE obj, VALUE netval, VALUE types)
477
478
  return Qnil;
478
479
  }
479
480
 
481
+ VALUE raw_record_to_a(VALUE obj)
482
+ {
483
+ VALUE packet;
484
+ VALUE ary;
485
+ packet_data_t *data;
486
+ int nfields;
487
+ int i;
488
+ VALUE str;
489
+ VALUE encoding;
490
+
491
+ Data_Get_Struct(rb_iv_get(obj, "@packet"), packet_data_t, data);
492
+ nfields = FIX2INT(rb_iv_get(obj, "@nfields"));
493
+ ary = rb_ary_new2(nfields);
494
+ encoding = rb_iv_get(obj, "@encoding");
495
+ for (i = 0; i < nfields; i++) {
496
+ str = _packet_lcs(data);
497
+ #ifdef HAVE_RUBY_ENCODING_H
498
+ if (str != Qnil) {
499
+ str = rb_funcall(str, rb_intern("force_encoding"), 1, encoding);
500
+ str = rb_funcall(str, rb_intern("encode"), 0);
501
+ }
502
+ #endif
503
+ rb_ary_push(ary, str);
504
+ }
505
+ return ary;
506
+ }
507
+
480
508
  VALUE stmt_raw_record_parse_record_packet(VALUE obj)
481
509
  {
482
510
  VALUE packet;
@@ -571,6 +599,7 @@ void Init_ext(void)
571
599
  cPacket = rb_const_get(cMysql, rb_intern("Packet"));
572
600
  cMysqlTime = rb_define_class_under(cMysql, "Time", rb_cObject);
573
601
  cProtocol = rb_const_get(cMysql, rb_intern("Protocol"));
602
+ cRawRecord = rb_const_get(cMysql, rb_intern("RawRecord"));
574
603
  cStmtRawRecord = rb_const_get(cMysql, rb_intern("StmtRawRecord"));
575
604
  cExecutePacket = rb_const_get(cProtocol, rb_intern("ExecutePacket"));
576
605
  cCharset = rb_const_get(cMysql, rb_intern("Charset"));
@@ -590,6 +619,8 @@ void Init_ext(void)
590
619
  rb_define_method(cPacket, "eof?", packet_eofQ, 0);
591
620
  rb_define_method(cPacket, "to_s", packet_to_s, 0);
592
621
 
622
+ rb_define_method(cRawRecord, "to_a", raw_record_to_a, 0);
623
+
593
624
  rb_define_method(cStmtRawRecord, "parse_record_packet", stmt_raw_record_parse_record_packet, 0);
594
625
  rb_define_alias(cStmtRawRecord, "to_a", "parse_record_packet");
595
626
 
@@ -20,7 +20,7 @@ class Mysql
20
20
  rescue LoadError
21
21
  end
22
22
 
23
- VERSION = 20909 # Version number of this library
23
+ VERSION = 20910 # Version number of this library
24
24
  MYSQL_UNIX_PORT = "/tmp/mysql.sock" # UNIX domain socket filename
25
25
  MYSQL_TCP_PORT = 3306 # TCP socket port number
26
26
 
@@ -11,7 +11,7 @@ class Mysql
11
11
 
12
12
  # convert String to LengthCodedString
13
13
  def self.lcs(str)
14
- str = Charset.to_binary str
14
+ str = Charset.to_binary str.dup
15
15
  lcb(str.length)+str
16
16
  end
17
17
 
@@ -13,7 +13,7 @@ MYSQL_SOCKET = ENV['MYSQL_SOCKET']
13
13
 
14
14
  describe 'Mysql::VERSION' do
15
15
  it 'returns client version' do
16
- Mysql::VERSION.should == 20909
16
+ Mysql::VERSION.should == 20910
17
17
  end
18
18
  end
19
19
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-mysql-ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.9
4
+ version: 2.9.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-17 00:00:00.000000000 Z
12
+ date: 2012-07-12 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: This is MySQL connector with C extension.
15
15
  email: tommy@tmtm.org