New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix mysql table name too long while archiving a segment #15276
Conversation
fix error > WP DB Error: Identifier name 'wp_foooobarrrrrr_matomo_logtmpsegment07171d02820b83eab14316299645c2e9' is too long SQL: CREATE TEMPORARY TABLE wp_foooobarrrrrr_matomo_logtmpsegment07171d02820b83eab14316299645c2e9 (idvisit BIGINT(10) UNSIGNED NOT NULL)
core/DataAccess/LogAggregator.php
Outdated
@@ -195,7 +195,8 @@ public function setQueryOriginHint($nameOfOrigiin) | |||
private function getSegmentTmpTableName() | |||
{ | |||
$bind = $this->getGeneralQueryBindParams(); | |||
return self::LOG_TABLE_SEGMENT_TEMPORARY_PREFIX . md5(json_encode($bind) . $this->segment->getString()); | |||
$tableName = self::LOG_TABLE_SEGMENT_TEMPORARY_PREFIX . md5(json_encode($bind) . $this->segment->getString()); | |||
return Common::mb_substr($tableName, 0, 64); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make 64 a constant? We could also shorten self::LOG_TABLE_SEGMENT_TEMPORARY_PREFIX
since the table names are about 5 characters too long it seems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed something, is that what you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, was also wondering if shortening self::LOG_TABLE_SEGMENT_TEMPORARY_PREFIX
was an option since wp_foooobarrrrrr_matomo_logtmpsegment07171d02820b83eab14316299645c2e9
was 69 characters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@diosmosis now I understand what you mean. I guess it's not really needed I would say as the next one might again have an even longer prefix etc. Even if the table name is truncated by 16 characters it would still not be an issue since a temporary table only exists for one session and is not visible to any other mysql session... and after an archive the table is being deleted so it's unlikely there will two tables having the same name... we could shorten it though to logtmpseg
if that helps and still clear what it is about?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it's not really needed. Will merge.
…5276) * Fix mysql table name too long while archiving a segment fix error > WP DB Error: Identifier name 'wp_foooobarrrrrr_matomo_logtmpsegment07171d02820b83eab14316299645c2e9' is too long SQL: CREATE TEMPORARY TABLE wp_foooobarrrrrr_matomo_logtmpsegment07171d02820b83eab14316299645c2e9 (idvisit BIGINT(10) UNSIGNED NOT NULL) * add constant
…5276) * Fix mysql table name too long while archiving a segment fix error > WP DB Error: Identifier name 'wp_foooobarrrrrr_matomo_logtmpsegment07171d02820b83eab14316299645c2e9' is too long SQL: CREATE TEMPORARY TABLE wp_foooobarrrrrr_matomo_logtmpsegment07171d02820b83eab14316299645c2e9 (idvisit BIGINT(10) UNSIGNED NOT NULL) * add constant
fix error