misc: truncate schema_temp to 63 characters (#43165)
This commit is contained in:
parent
44d11e2b02
commit
d9409b15bd
|
@ -20,6 +20,17 @@ psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
|
|||
psycopg2.extensions.register_type(psycopg2.extensions.UNICODEARRAY)
|
||||
|
||||
|
||||
def truncate_pg_identifier(identifier, hash_length=6, force_hash=False):
|
||||
if len(identifier) < 64 and not force_hash:
|
||||
return identifier
|
||||
else:
|
||||
# insert hash in the middle, to keep some readability
|
||||
return (
|
||||
identifier[:(63 - hash_length) // 2]
|
||||
+ hashlib.md5(identifier.encode('utf-8')).hexdigest()[:hash_length]
|
||||
+ identifier[-(63 - hash_length) // 2:])
|
||||
|
||||
|
||||
def quote(name):
|
||||
return '"%s"' % name
|
||||
|
||||
|
@ -79,7 +90,7 @@ class WcsOlapFeeder(object):
|
|||
self.ctx = Context()
|
||||
self.ctx.push({
|
||||
'schema': self.schema,
|
||||
'schema_temp': self.schema + '_temp',
|
||||
'schema_temp': truncate_pg_identifier(schema + '_temp'),
|
||||
'role_table': 'role',
|
||||
'channel_table': 'channel',
|
||||
'category_table': 'category',
|
||||
|
|
Loading…
Reference in New Issue