The SQL parser defines the unary function crc32() that computes the CRC-32 of a string using the ISO 3309 polynomial that is being used by zlib and many others.
Often, CRC is computed in pieces. To faciliate this, we introduce an optional second parameter: crc32('MariaDB') is equal to crc32(crc32('Maria','DB')).
InnoDB files use a different polynomial, which is used by the special instructions that the Intel Nehalem microarchitecture introduced in SSE4.2. This is commonly called CRC-32C.
It would be very convenient to introduce an SQL function crc32c() that would compute CRC-32C checksums. Then we could could define simple SQL function that would generate a logically empty InnoDB redo log corresponding to a particular checkpoint LSN. Starting with MDEV-14425 and MDEV-27199, InnoDB would refuse normal startup if the redo log file was deleted.
Attachments
Issue Links
causes
MCOL-49662-argument CRC32 call upon Columnstore table returns a wrong value
Closed
MDEV-274822-argument CRC32 and CRC32C don't work in virtual column expressions
Later, I will try to create an SQL version of the above Perl using appropriate constructs:
SELECT …unhex(hex(crc32c(…)))… INTO DUMPFILE 'ib_logfile0';
Marko Mäkelä
added a comment - Later, I will try to create an SQL version of the above Perl using appropriate constructs:
SELECT …unhex(hex(crc32c(…)))… INTO DUMPFILE 'ib_logfile0' ;
Here is the SQL to create a logically empty log file in the MDEV-14425 format corresponding to the 64-bit log sequence number specified in the first line:
set @lsn=x'000000000000c96b';
set @header=concat('Phys',x'00000000',@lsn,repeat(x'00',492));
set @header=concat(@header,unhex(hex(crc32c(@header))),repeat(x'00',3584));
set @checkpoint=concat(@lsn,@lsn,repeat(x'00',44));
set @checkpoint=concat(@checkpoint,unhex(hex(crc32c(@checkpoint))),
repeat(x'00',8128));
set @payload=concat(x'fa0000',@lsn);
set @payload=concat(@payload,x'01',unhex(hex(crc32c(@payload))));
select concat(@header,@checkpoint,@payload) into dumpfile 'ib_logfile0';
Marko Mäkelä
added a comment - Here is the SQL to create a logically empty log file in the MDEV-14425 format corresponding to the 64-bit log sequence number specified in the first line:
set @lsn=x '000000000000c96b' ;
set @header=concat( 'Phys' ,x '00000000' ,@lsn,repeat(x '00' ,492));
set @header=concat(@header,unhex(hex(crc32c(@header))),repeat(x '00' ,3584));
set @ checkpoint =concat(@lsn,@lsn,repeat(x '00' ,44));
set @ checkpoint =concat(@ checkpoint ,unhex(hex(crc32c(@ checkpoint ))),
repeat(x '00' ,8128));
set @payload=concat(x 'fa0000' ,@lsn);
set @payload=concat(@payload,x '01' ,unhex(hex(crc32c(@payload))));
select concat(@header,@ checkpoint ,@payload) into dumpfile 'ib_logfile0' ;
serg, based on your review feedback I reversed the arguments of the 2-ary functions. When a previous checksum is specified, it must be the first and not the second argument:
This would return the same value 809606978 three times.
Marko Mäkelä
added a comment - serg , based on your review feedback I reversed the arguments of the 2-ary functions. When a previous checksum is specified, it must be the first and not the second argument:
SELECT CRC32C( 'MariaDB' ),CRC32C(CRC32C( 'Maria' ), 'DB' ),CRC32C(0, 'MariaDB' );
This would return the same value 809606978 three times.
These are minor omissions, but maybe it makes sense to add queries for them, for completeness.
3141/3142 and 3170/3171 seem obvious, something like
--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
select crc32(1,'foo','bar');
--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
select crc32c(1,'foo','bar');
should do it. For the other two errors, I can't see at the first glance how to get there, but I suppose whoever wrote it would know right away.
I have no objections against merging the new variations of functions into 10.8 main and releasing with 10.8.1. The above note about MTR tests is not a mandatory requirement.
It concerns the functions themselves, the way they appear to work as built-in functions. How InnoDB uses them to create its log is out of the scope of this task.
The functions don't work with Columnstore (MCOL-4966 to track), but anyway Columnstore doesn't support everything that the server does, so I don't see it as a blocker. Also the functions lack proper parameter validation, but as a legacy issue concerning other existing functions (MDEV-27480), it cannot block the feature either.
Elena Stepanova
added a comment - - edited According to GCOV, there are a few missing lines in the coverage:
line numbers as of preview-10.8-MDEV-27265-misc 6e615c62b
===File sql/item_create.cc:
3141 : + my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
3142 : + return nullptr;
3150 : + my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name->str);
3151 : + return nullptr;
3170 : + my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
3171 : + return nullptr;
3179 : + my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name->str);
3180 : + return nullptr;
These are minor omissions, but maybe it makes sense to add queries for them, for completeness.
3141/3142 and 3170/3171 seem obvious, something like
--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
select crc32(1, 'foo' , 'bar' );
--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
select crc32c(1, 'foo' , 'bar' );
should do it. For the other two errors, I can't see at the first glance how to get there, but I suppose whoever wrote it would know right away.
I have no objections against merging the new variations of functions into 10.8 main and releasing with 10.8.1. The above note about MTR tests is not a mandatory requirement.
It concerns the functions themselves, the way they appear to work as built-in functions. How InnoDB uses them to create its log is out of the scope of this task.
The functions don't work with Columnstore ( MCOL-4966 to track), but anyway Columnstore doesn't support everything that the server does, so I don't see it as a blocker. Also the functions lack proper parameter validation, but as a legacy issue concerning other existing functions ( MDEV-27480 ), it cannot block the feature either.
I will replace those redundant error checks with assertions and include test cases to exercise this.
Marko Mäkelä
added a comment - The handling for the error ER_WRONG_PARAMETERS_TO_NATIVE_FCT is redundant and unreachable:
--error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select crc32c( '' as empty);
#0 my_error (nr=1583, MyFlags=0) at /mariadb/10.8/mysys/my_error.c:109
#1 0x00005635f0b30506 in Create_native_func::create_func (
this=0x5635f1ceb478 <Create_func_crc32c::s_singleton>, thd=0x7f8b34000d48,
name=0x7f8b4a75e6d0, item_list=0x7f8b34016f20)
at /mariadb/10.8/sql/item_create.cc:2653
#2 0x00005635f0a321e0 in MYSQLparse (thd=thd@entry=0x7f8b34000d48)
at /mariadb/10.8/sql/sql_yacc.yy:10441
Item*
Create_native_func::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list)
{
if (unlikely(has_named_parameters(item_list)))
{
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
}
return create_native(thd, name, item_list);
}
I will replace those redundant error checks with assertions and include test cases to exercise this.
People
Marko Mäkelä
Marko Mäkelä
Votes:
0Vote for this issue
Watchers:
5Start watching this issue
Dates
Created:
Updated:
Resolved:
Git Integration
Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.
{"report":{"fcp":739.8000001907349,"ttfb":173,"pageVisibility":"visible","entityId":105847,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"535d4d43-12a6-4d65-9ab2-103d2084c801","navigationType":0,"readyForUser":848.5,"redirectCount":0,"resourceLoadedEnd":512.8000001907349,"resourceLoadedStart":181.30000019073486,"resourceTiming":[{"duration":19.59999990463257,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":181.30000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":181.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":200.90000009536743,"responseStart":0,"secureConnectionStart":0},{"duration":19.899999856948853,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":181.60000014305115,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":181.60000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":201.5,"responseStart":0,"secureConnectionStart":0},{"duration":177.29999995231628,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":181.70000004768372,"connectEnd":204.20000004768372,"connectStart":204.20000004768372,"domainLookupEnd":204.20000004768372,"domainLookupStart":204.20000004768372,"fetchStart":181.70000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":205.10000014305115,"responseEnd":359,"responseStart":220.5,"secureConnectionStart":204.20000004768372},{"duration":297.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/099b33461394b8015fc36c0a4b96e19f-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":181.80000019073486,"connectEnd":181.80000019073486,"connectStart":181.80000019073486,"domainLookupEnd":181.80000019073486,"domainLookupStart":181.80000019073486,"fetchStart":181.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":205.60000014305115,"responseEnd":479.30000019073486,"responseStart":224.40000009536743,"secureConnectionStart":181.80000019073486},{"duration":40.90000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/94c15bff32baef80f4096a08aceae8bc-CDN/lu2bu7/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":181.90000009536743,"connectEnd":181.90000009536743,"connectStart":181.90000009536743,"domainLookupEnd":181.90000009536743,"domainLookupStart":181.90000009536743,"fetchStart":181.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":206.10000014305115,"responseEnd":222.80000019073486,"responseStart":219.10000014305115,"secureConnectionStart":181.90000009536743},{"duration":43.799999952316284,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":182.10000014305115,"connectEnd":182.10000014305115,"connectStart":182.10000014305115,"domainLookupEnd":182.10000014305115,"domainLookupStart":182.10000014305115,"fetchStart":182.10000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":206.30000019073486,"responseEnd":225.90000009536743,"responseStart":223.20000004768372,"secureConnectionStart":182.10000014305115},{"duration":44.200000047683716,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":182.10000014305115,"connectEnd":182.10000014305115,"connectStart":182.10000014305115,"domainLookupEnd":182.10000014305115,"domainLookupStart":182.10000014305115,"fetchStart":182.10000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":207.30000019073486,"responseEnd":226.30000019073486,"responseStart":223.80000019073486,"secureConnectionStart":182.10000014305115},{"duration":24.100000143051147,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bu7/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":182.20000004768372,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":182.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":206.30000019073486,"responseStart":0,"secureConnectionStart":0},{"duration":45.59999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":182.30000019073486,"connectEnd":182.30000019073486,"connectStart":182.30000019073486,"domainLookupEnd":182.30000019073486,"domainLookupStart":182.30000019073486,"fetchStart":182.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":209.10000014305115,"responseEnd":227.90000009536743,"responseStart":226.40000009536743,"secureConnectionStart":182.30000019073486},{"duration":25.90000009536743,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bu7/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":182.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":182.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":208.40000009536743,"responseStart":0,"secureConnectionStart":0},{"duration":51.60000014305115,"initiatorType":"script","name":"https://jira.mariadb.org/s/3339d87fa2538a859872f2df449bf8d0-CDN/lu2bu7/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":182.5,"connectEnd":182.5,"connectStart":182.5,"domainLookupEnd":182.5,"domainLookupStart":182.5,"fetchStart":182.5,"redirectEnd":0,"redirectStart":0,"requestStart":210,"responseEnd":234.10000014305115,"responseStart":229.20000004768372,"secureConnectionStart":182.5},{"duration":321.10000014305115,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":190.70000004768372,"connectEnd":190.70000004768372,"connectStart":190.70000004768372,"domainLookupEnd":190.70000004768372,"domainLookupStart":190.70000004768372,"fetchStart":190.70000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":228.40000009536743,"responseEnd":511.80000019073486,"responseStart":503,"secureConnectionStart":190.70000004768372},{"duration":318.60000014305115,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":194.20000004768372,"connectEnd":194.20000004768372,"connectStart":194.20000004768372,"domainLookupEnd":194.20000004768372,"domainLookupStart":194.20000004768372,"fetchStart":194.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":237.5,"responseEnd":512.8000001907349,"responseStart":506,"secureConnectionStart":194.20000004768372},{"duration":54.5,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":503.7000000476837,"connectEnd":503.7000000476837,"connectStart":503.7000000476837,"domainLookupEnd":503.7000000476837,"domainLookupStart":503.7000000476837,"fetchStart":503.7000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":523.5,"responseEnd":558.2000000476837,"responseStart":557.4000000953674,"secureConnectionStart":503.7000000476837},{"duration":192.59999990463257,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":733.1000001430511,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":733.1000001430511,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":925.7000000476837,"responseStart":0,"secureConnectionStart":0},{"duration":221.20000004768372,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":739.9000000953674,"connectEnd":739.9000000953674,"connectStart":739.9000000953674,"domainLookupEnd":739.9000000953674,"domainLookupStart":739.9000000953674,"fetchStart":739.9000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":928.8000001907349,"responseEnd":961.1000001430511,"responseStart":959.8000001907349,"secureConnectionStart":739.9000000953674}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":35,"responseStart":173,"responseEnd":193,"domLoading":176,"domInteractive":925,"domContentLoadedEventStart":925,"domContentLoadedEventEnd":972,"domComplete":1451,"loadEventStart":1451,"loadEventEnd":1451,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":883.9000000953674},{"name":"bigPipe.sidebar-id.end","time":884.6000001430511},{"name":"bigPipe.activity-panel-pipe-id.start","time":884.8000001907349},{"name":"bigPipe.activity-panel-pipe-id.end","time":888.6000001430511},{"name":"activityTabFullyLoaded","time":989}],"measures":[],"correlationId":"8913f808488aff","effectiveType":"4g","downlink":9,"rtt":0,"serverDuration":89,"dbReadsTimeInMs":16,"dbConnsTimeInMs":23,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
Later, I will try to create an SQL version of the above Perl using appropriate constructs: