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":1657.9000005722046,"ttfb":688,"pageVisibility":"visible","entityId":105847,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"a6ab1ee6-b3d9-4b5f-861b-596e4a478fd2","navigationType":0,"readyForUser":1735,"redirectCount":0,"resourceLoadedEnd":1788.9000005722046,"resourceLoadedStart":693.9000005722046,"resourceTiming":[{"duration":430.19999980926514,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":693.9000005722046,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":693.9000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1124.1000003814697,"responseStart":0,"secureConnectionStart":0},{"duration":430.3999996185303,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/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&whisper-enabled=true","startTime":694.1000003814697,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":694.1000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1124.5,"responseStart":0,"secureConnectionStart":0},{"duration":486.3999996185303,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":694.4000005722046,"connectEnd":694.4000005722046,"connectStart":694.4000005722046,"domainLookupEnd":694.4000005722046,"domainLookupStart":694.4000005722046,"fetchStart":694.4000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":694.4000005722046,"responseEnd":1180.8000001907349,"responseStart":1180.8000001907349,"secureConnectionStart":694.4000005722046},{"duration":576.8999996185303,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/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&whisper-enabled=true","startTime":694.6000003814697,"connectEnd":694.6000003814697,"connectStart":694.6000003814697,"domainLookupEnd":694.6000003814697,"domainLookupStart":694.6000003814697,"fetchStart":694.6000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":694.6000003814697,"responseEnd":1271.5,"responseStart":1271.5,"secureConnectionStart":694.6000003814697},{"duration":581,"initiatorType":"script","name":"https://jira.mariadb.org/s/a9324d6758d385eb45c462685ad88f1d-CDN/lu2cib/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":694.8000001907349,"connectEnd":694.8000001907349,"connectStart":694.8000001907349,"domainLookupEnd":694.8000001907349,"domainLookupStart":694.8000001907349,"fetchStart":694.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":694.8000001907349,"responseEnd":1275.8000001907349,"responseStart":1275.8000001907349,"secureConnectionStart":694.8000001907349},{"duration":581.3000001907349,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":695,"connectEnd":695,"connectStart":695,"domainLookupEnd":695,"domainLookupStart":695,"fetchStart":695,"redirectEnd":0,"redirectStart":0,"requestStart":695,"responseEnd":1276.3000001907349,"responseStart":1276.3000001907349,"secureConnectionStart":695},{"duration":581.6999998092651,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":695.2000007629395,"connectEnd":695.2000007629395,"connectStart":695.2000007629395,"domainLookupEnd":695.2000007629395,"domainLookupStart":695.2000007629395,"fetchStart":695.2000007629395,"redirectEnd":0,"redirectStart":0,"requestStart":695.2000007629395,"responseEnd":1276.9000005722046,"responseStart":1276.9000005722046,"secureConnectionStart":695.2000007629395},{"duration":630.3000001907349,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2cib/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":695.4000005722046,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":695.4000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1325.7000007629395,"responseStart":0,"secureConnectionStart":0},{"duration":581.9000005722046,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":695.5,"connectEnd":695.5,"connectStart":695.5,"domainLookupEnd":695.5,"domainLookupStart":695.5,"fetchStart":695.5,"redirectEnd":0,"redirectStart":0,"requestStart":695.5,"responseEnd":1277.4000005722046,"responseStart":1277.4000005722046,"secureConnectionStart":695.5},{"duration":630.0999994277954,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2cib/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":695.7000007629395,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":695.7000007629395,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1325.8000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":582.1999998092651,"initiatorType":"script","name":"https://jira.mariadb.org/s/5d5e8fe91fbc506585e83ea3b62ccc4b-CDN/lu2cib/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":695.8000001907349,"connectEnd":695.8000001907349,"connectStart":695.8000001907349,"domainLookupEnd":695.8000001907349,"domainLookupStart":695.8000001907349,"fetchStart":695.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":695.8000001907349,"responseEnd":1278,"responseStart":1278,"secureConnectionStart":695.8000001907349},{"duration":713,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":697.2000007629395,"connectEnd":697.2000007629395,"connectStart":697.2000007629395,"domainLookupEnd":697.2000007629395,"domainLookupStart":697.2000007629395,"fetchStart":697.2000007629395,"redirectEnd":0,"redirectStart":0,"requestStart":697.2000007629395,"responseEnd":1410.2000007629395,"responseStart":1410.2000007629395,"secureConnectionStart":697.2000007629395},{"duration":999.7999992370605,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":702.2000007629395,"connectEnd":702.2000007629395,"connectStart":702.2000007629395,"domainLookupEnd":702.2000007629395,"domainLookupStart":702.2000007629395,"fetchStart":702.2000007629395,"redirectEnd":0,"redirectStart":0,"requestStart":702.2000007629395,"responseEnd":1702,"responseStart":1701.9000005722046,"secureConnectionStart":702.2000007629395},{"duration":88.20000076293945,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1354.5,"connectEnd":1354.5,"connectStart":1354.5,"domainLookupEnd":1354.5,"domainLookupStart":1354.5,"fetchStart":1354.5,"redirectEnd":0,"redirectStart":0,"requestStart":1354.5,"responseEnd":1442.7000007629395,"responseStart":1442.7000007629395,"secureConnectionStart":1354.5},{"duration":157.4000005722046,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2cib/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/css/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":1606.3000001907349,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1606.3000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1763.7000007629395,"responseStart":0,"secureConnectionStart":0},{"duration":157.29999923706055,"initiatorType":"link","name":"https://jira.mariadb.org/s/50bc9be5bfead1a25e72c1a9338c94f6-CDN/lu2cib/820016/12ta74/e108c7645258ccb43280ed3404e3e949/_/download/contextbatch/css/com.atlassian.jira.plugins.jira-development-integration-plugin:0,-_super,-jira.view.issue,-jira.global,-jira.general,-jira.browse.project,-project.issue.navigator,-atl.general/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":1606.7000007629395,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1606.7000007629395,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1764,"responseStart":0,"secureConnectionStart":0},{"duration":174.10000038146973,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/e65b778d185daf5aee24936755b43da6/_/download/contextbatch/js/browser-metrics-plugin.contrib,-_super,-project.issue.navigator,-jira.view.issue,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":1607.6000003814697,"connectEnd":1607.6000003814697,"connectStart":1607.6000003814697,"domainLookupEnd":1607.6000003814697,"domainLookupStart":1607.6000003814697,"fetchStart":1607.6000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":1607.6000003814697,"responseEnd":1781.7000007629395,"responseStart":1781.7000007629395,"secureConnectionStart":1607.6000003814697},{"duration":179.60000038146973,"initiatorType":"script","name":"https://jira.mariadb.org/s/097ae97cb8fbec7d6ea4bbb1f26955b9-CDN/lu2cib/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/js/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true&whisper-enabled=true","startTime":1608,"connectEnd":1608,"connectStart":1608,"domainLookupEnd":1608,"domainLookupStart":1608,"fetchStart":1608,"redirectEnd":0,"redirectStart":0,"requestStart":1608,"responseEnd":1787.6000003814697,"responseStart":1787.6000003814697,"secureConnectionStart":1608},{"duration":180.60000038146973,"initiatorType":"script","name":"https://jira.mariadb.org/s/e0bf5781d46ea69fb123572974cf39de-CDN/lu2cib/820016/12ta74/e108c7645258ccb43280ed3404e3e949/_/download/contextbatch/js/com.atlassian.jira.plugins.jira-development-integration-plugin:0,-_super,-jira.view.issue,-jira.global,-jira.general,-jira.browse.project,-project.issue.navigator,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true&whisper-enabled=true","startTime":1608.3000001907349,"connectEnd":1608.3000001907349,"connectStart":1608.3000001907349,"domainLookupEnd":1608.3000001907349,"domainLookupStart":1608.3000001907349,"fetchStart":1608.3000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":1608.3000001907349,"responseEnd":1788.9000005722046,"responseStart":1788.9000005722046,"secureConnectionStart":1608.3000001907349},{"duration":176,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1648.6000003814697,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1648.6000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1824.6000003814697,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":512,"responseStart":688,"responseEnd":699,"domLoading":692,"domInteractive":1859,"domContentLoadedEventStart":1859,"domContentLoadedEventEnd":1915,"domComplete":2118,"loadEventStart":2118,"loadEventEnd":2118,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1826.7000007629395},{"name":"bigPipe.sidebar-id.end","time":1827.8000001907349},{"name":"bigPipe.activity-panel-pipe-id.start","time":1827.9000005722046},{"name":"bigPipe.activity-panel-pipe-id.end","time":1832.3000001907349},{"name":"activityTabFullyLoaded","time":1936.7000007629395}],"measures":[],"correlationId":"9b226a384e20fd","effectiveType":"4g","downlink":9.9,"rtt":0,"serverDuration":118,"dbReadsTimeInMs":16,"dbConnsTimeInMs":26,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
Later, I will try to create an SQL version of the above Perl using appropriate constructs: