cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject [02/15] cassandra git commit: COPY FROM fails when importing blob
Date Tue, 29 Mar 2016 16:58:18 GMT
COPY FROM fails when importing blob

patch by Stefania Alborghetti; reviewed by Paulo Motta for CASSANDRA-11375


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/5a45aa62
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/5a45aa62
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/5a45aa62

Branch: refs/heads/cassandra-2.2
Commit: 5a45aa62dd57f59753396c5d5541dbf3a0a1b220
Parents: 8b8a3f5
Author: Stefania Alborghetti <stefania.alborghetti@datastax.com>
Authored: Fri Mar 18 16:46:37 2016 +0800
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Tue Mar 29 17:56:33 2016 +0100

----------------------------------------------------------------------
 CHANGES.txt                |  1 +
 pylib/cqlshlib/copyutil.py | 16 ++++++++++------
 2 files changed, 11 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/5a45aa62/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 7794d4f..65d094f 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.1.14
+ * COPY FROM fails when importing blob (CASSANDRA-11375)
  * Backport CASSANDRA-10679 (CASSANDRA-9598)
  * Don't do defragmentation if reading from repaired sstables (CASSANDRA-10342)
  * Fix streaming_socket_timeout_in_ms not enforced (CASSANDRA-11286)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/5a45aa62/pylib/cqlshlib/copyutil.py
----------------------------------------------------------------------
diff --git a/pylib/cqlshlib/copyutil.py b/pylib/cqlshlib/copyutil.py
index ba2a47b..28e08b1 100644
--- a/pylib/cqlshlib/copyutil.py
+++ b/pylib/cqlshlib/copyutil.py
@@ -1176,7 +1176,7 @@ class FeedingProcess(mp.Process):
                     if rows:
                         sent += self.send_chunk(ch, rows)
                 except Exception, exc:
-                    self.outmsg.send(ImportTaskError(exc.__class__.__name__, exc.message))
+                    self.outmsg.send(ImportTaskError(exc.__class__.__name__, str(exc)))
 
                 if reader.exhausted:
                     break
@@ -1679,7 +1679,11 @@ class ImportConversion(object):
             return converters.get(t.typename, convert_unknown)(unprotect(v), ct=t)
 
         def convert_blob(v, **_):
-            return bytearray.fromhex(v[2:])
+            try:
+                return bytearray.fromhex(v[2:])
+            except TypeError:
+                # Work-around for Python 2.6 bug
+                return bytearray.fromhex(unicode(v[2:]))
 
         def convert_text(v, **_):
             return v
@@ -1869,7 +1873,7 @@ class ImportConversion(object):
         try:
             return [conv(val) for conv, val in zip(converters, row)]
         except Exception, e:
-            raise ParseError(e.message)
+            raise ParseError(str(e))
 
     def get_null_primary_key_message(self, idx):
         message = "Cannot insert null value for primary key column '%s'." % (self.columns[idx],)
@@ -2183,7 +2187,7 @@ class ImportProcess(ChildProcess):
             try:
                 return conv.convert_row(r)
             except Exception, err:
-                errors[err.message].append(r)
+                errors[str(err)].append(r)
                 return None
 
         converted_rows = filter(None, [convert_row(r) for r in rows])
@@ -2248,7 +2252,7 @@ class ImportProcess(ChildProcess):
                 pk = get_row_partition_key_values(row)
                 rows_by_ring_pos[get_ring_pos(ring, pk_to_token_value(pk))].append(row)
             except Exception, e:
-                errors[e.message].append(row)
+                errors[str(e)].append(row)
 
         if errors:
             for msg, rows in errors.iteritems():
@@ -2286,7 +2290,7 @@ class ImportProcess(ChildProcess):
     def report_error(self, err, chunk, rows=None, attempts=1, final=True):
         if self.debug:
             traceback.print_exc(err)
-        self.outmsg.send(ImportTaskError(err.__class__.__name__, err.message, rows, attempts,
final))
+        self.outmsg.send(ImportTaskError(err.__class__.__name__, str(err), rows, attempts,
final))
         if final:
             self.update_chunk(rows, chunk)
 


Mime
View raw message