Permalink
Browse files

Merge pull request #229 from dermoth/mysql_varbinary_fix

Fix MySQL VARBINARY column creation
  • Loading branch information...
dermoth committed Aug 31, 2017
2 parents 3e3a1ee + 5d58665 commit 77beefef1391beec72e952484b98227cee570676
Showing with 15 additions and 4 deletions.
  1. +3 −4 Abe/DataStore.py
  2. +12 −0 Abe/SqlAbstraction.py
View
@@ -95,10 +95,9 @@
PUBKEY_ID_NETWORK_FEE = NULL_PUBKEY_ID
# Size of the script and pubkey columns in bytes.
MAX_SCRIPT = 1000000
MAX_PUBKEY = 65
NO_CLOB = 'BUG_NO_CLOB'
MAX_SCRIPT = SqlAbstraction.MAX_SCRIPT
MAX_PUBKEY = SqlAbstraction.MAX_PUBKEY
NO_CLOB = SqlAbstraction.NO_CLOB
# XXX This belongs in another module.
class InvalidBlock(Exception):
View
@@ -19,6 +19,8 @@
import re
import logging
MAX_SCRIPT = 1000000
MAX_PUBKEY = 65
NO_CLOB = 'BUG_NO_CLOB'
STMT_RE = re.compile(r"([^']+)((?:'[^']*')?)")
@@ -197,6 +199,9 @@ def ret(x):
pass
elif val == 'mysql':
transform_stmt = sql._transform_concat(transform_stmt)
# Also squeeze in MySQL VARBINARY length fix
# Some MySQL version do not auto-convert to BLOB
transform_stmt = sql._transform_varbinary(transform_stmt)
transform_stmt = sql._append_table_epilogue(transform_stmt)
@@ -430,6 +435,13 @@ def ret(stmt):
return fn(concat_re.sub(repl, stmt))
return ret
def _transform_varbinary(sql, fn):
varbinary_re = re.compile(r"VARBINARY\(" + str(MAX_SCRIPT) + "\)")
def ret(stmt):
# Suitable for prefix+length up to 16,777,215 (2^24 - 1)
return fn(varbinary_re.sub("MEDIUMBLOB", stmt))
return ret
def _append_table_epilogue(sql, fn):
epilogue = sql.config.get('create_table_epilogue', "")
if epilogue == "":

0 comments on commit 77beefe

Please sign in to comment.