Because MariaDB does not accept a constant virtual column (other DBMS's do) I was obliged to write the noconst UDF as:
/***********************************************************************/
|
/* Returns its argument saying it is not a constant. */
|
/***********************************************************************/
|
my_bool noconst_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
{
|
if (args->arg_count != 1 || args->arg_type[0] != STRING_RESULT) {
|
strcpy(message, "noconst unique argument must be a string");
|
return true;
|
} // endif arg
|
|
initid->const_item = false; // The trick!
|
return false;
|
} // end of noconst_init
|
|
char *noconst(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
unsigned long *res_length, char *, char *)
|
{
|
return args->args[0];
|
} // end of noconst
|
Now, creating the table t1, inserting one line to it and displaying it does work:
MariaDB [test]> create table t1 (
|
-> n int key not null auto_increment,
|
-> msg char(20) as (noconst('Hello World')) virtual);
|
Query OK, 0 rows affected (0.06 sec)
|
|
MariaDB [test]> insert into t1() values();
|
Query OK, 1 row affected (0.01 sec)
|
|
MariaDB [test]> select * from t1;
|
+---+-------------+
|
| n | msg |
|
+---+-------------+
|
| 1 | Hello World |
|
+---+-------------+
|
1 row in set (0.00 sec)
|
However, later on when stopping the server a crash occurs in the function:
void udf_handler::cleanup()
|
{
|
if (!not_original)
|
{
|
if (initialized)
|
{
|
if (u_d->func_deinit != NULL)
|
{
|
Udf_func_deinit deinit= u_d->func_deinit;
|
(*deinit)(&initid);
|
}
|
free_udf(u_d);
|
initialized= FALSE;
|
}
|
if (buffers) // Because of bug in ecc
|
delete [] buffers;
|
buffers= 0;
|
}
|
}
|
See the attach udf_crash.log.
The same kind of crash occurs with different other UDF's.
{"report":{"fcp":1096.5,"ttfb":407,"pageVisibility":"visible","entityId":52729,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"7d753241-cc71-4377-ba67-f038832d39ef","navigationType":0,"readyForUser":1213.1999998092651,"redirectCount":0,"resourceLoadedEnd":1259,"resourceLoadedStart":412.69999980926514,"resourceTiming":[{"duration":102.30000019073486,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":412.69999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":412.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":515,"responseStart":0,"secureConnectionStart":0},{"duration":103.19999980926514,"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":413,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":413,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":516.1999998092651,"responseStart":0,"secureConnectionStart":0},{"duration":170.80000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":413.19999980926514,"connectEnd":413.19999980926514,"connectStart":413.19999980926514,"domainLookupEnd":413.19999980926514,"domainLookupStart":413.19999980926514,"fetchStart":413.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":413.19999980926514,"responseEnd":584,"responseStart":584,"secureConnectionStart":413.19999980926514},{"duration":339.2000002861023,"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":413.3999996185303,"connectEnd":413.3999996185303,"connectStart":413.3999996185303,"domainLookupEnd":413.3999996185303,"domainLookupStart":413.3999996185303,"fetchStart":413.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":413.3999996185303,"responseEnd":752.5999999046326,"responseStart":752.5999999046326,"secureConnectionStart":413.3999996185303},{"duration":344.19999980926514,"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":413.5,"connectEnd":413.5,"connectStart":413.5,"domainLookupEnd":413.5,"domainLookupStart":413.5,"fetchStart":413.5,"redirectEnd":0,"redirectStart":0,"requestStart":413.5,"responseEnd":757.6999998092651,"responseStart":757.6999998092651,"secureConnectionStart":413.5},{"duration":344.5,"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":413.69999980926514,"connectEnd":413.69999980926514,"connectStart":413.69999980926514,"domainLookupEnd":413.69999980926514,"domainLookupStart":413.69999980926514,"fetchStart":413.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":413.69999980926514,"responseEnd":758.1999998092651,"responseStart":758.1999998092651,"secureConnectionStart":413.69999980926514},{"duration":344.6000003814697,"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":413.8999996185303,"connectEnd":413.8999996185303,"connectStart":413.8999996185303,"domainLookupEnd":413.8999996185303,"domainLookupStart":413.8999996185303,"fetchStart":413.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":413.8999996185303,"responseEnd":758.5,"responseStart":758.5,"secureConnectionStart":413.8999996185303},{"duration":345.09999990463257,"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":414,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":414,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":759.0999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":344.69999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":414.19999980926514,"connectEnd":414.19999980926514,"connectStart":414.19999980926514,"domainLookupEnd":414.19999980926514,"domainLookupStart":414.19999980926514,"fetchStart":414.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":414.19999980926514,"responseEnd":758.8999996185303,"responseStart":758.8999996185303,"secureConnectionStart":414.19999980926514},{"duration":345.7000002861023,"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":414.3999996185303,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":414.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":760.0999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":345.19999980926514,"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":414.5,"connectEnd":414.5,"connectStart":414.5,"domainLookupEnd":414.5,"domainLookupStart":414.5,"fetchStart":414.5,"redirectEnd":0,"redirectStart":0,"requestStart":414.5,"responseEnd":759.6999998092651,"responseStart":759.6999998092651,"secureConnectionStart":414.5},{"duration":666.5999999046326,"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":420.5,"connectEnd":420.5,"connectStart":420.5,"domainLookupEnd":420.5,"domainLookupStart":420.5,"fetchStart":420.5,"redirectEnd":0,"redirectStart":0,"requestStart":420.5,"responseEnd":1087.0999999046326,"responseStart":1087.0999999046326,"secureConnectionStart":420.5},{"duration":770.5999999046326,"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":420.59999990463257,"connectEnd":420.59999990463257,"connectStart":420.59999990463257,"domainLookupEnd":420.59999990463257,"domainLookupStart":420.59999990463257,"fetchStart":420.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":420.59999990463257,"responseEnd":1191.1999998092651,"responseStart":1191.1999998092651,"secureConnectionStart":420.59999990463257},{"duration":341.40000009536743,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":742.5999999046326,"connectEnd":742.5999999046326,"connectStart":742.5999999046326,"domainLookupEnd":742.5999999046326,"domainLookupStart":742.5999999046326,"fetchStart":742.5999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":742.5999999046326,"responseEnd":1084,"responseStart":1084,"secureConnectionStart":742.5999999046326},{"duration":215.80000019073486,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1089.3999996185303,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1089.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1305.1999998092651,"responseStart":0,"secureConnectionStart":0},{"duration":146.90000009536743,"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":1112.0999999046326,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1112.0999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1259,"responseStart":0,"secureConnectionStart":0},{"duration":89.5,"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":1113.5999999046326,"connectEnd":1113.5999999046326,"connectStart":1113.5999999046326,"domainLookupEnd":1113.5999999046326,"domainLookupStart":1113.5999999046326,"fetchStart":1113.5999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":1113.5999999046326,"responseEnd":1203.0999999046326,"responseStart":1203.0999999046326,"secureConnectionStart":1113.5999999046326},{"duration":95.19999980926514,"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":1114,"connectEnd":1114,"connectStart":1114,"domainLookupEnd":1114,"domainLookupStart":1114,"fetchStart":1114,"redirectEnd":0,"redirectStart":0,"requestStart":1114,"responseEnd":1209.1999998092651,"responseStart":1209.1999998092651,"secureConnectionStart":1114}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":237,"responseStart":407,"responseEnd":415,"domLoading":411,"domInteractive":1369,"domContentLoadedEventStart":1369,"domContentLoadedEventEnd":1433,"domComplete":1894,"loadEventStart":1894,"loadEventEnd":1894,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1319.5999999046326},{"name":"bigPipe.sidebar-id.end","time":1321.8999996185303},{"name":"bigPipe.activity-panel-pipe-id.start","time":1322.0999999046326},{"name":"bigPipe.activity-panel-pipe-id.end","time":1325.3999996185303},{"name":"activityTabFullyLoaded","time":1455.6999998092651}],"measures":[],"correlationId":"77be4a34e8a686","effectiveType":"4g","downlink":9.8,"rtt":0,"serverDuration":104,"dbReadsTimeInMs":11,"dbConnsTimeInMs":19,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
That's a surprise it works at all, documentation says UDFs are not allowed for virtual columns.
bertrandop,
Could you please attach the whole c file with your UDF function? It will be faster than me creating missing parts.