Type:
Bug
Priority:
Minor
Resolution:
Unresolved
Affects Version/s:
N/A
I'm setting it to Minor as I don't think it would be anyone's loss if a foreign key on a vector column couldn't be created, but it seems to be rejected on a wrong reason, maybe it could/should be improved.
bb-11.6-MDEV-32887-vector 764592a4da2a1b490471732fbefe2ce745ce1f32
MariaDB [test]> create or replace table t (a vector(1) not null , key (a)) engine=InnoDB;
Query OK, 0 rows affected (0.094 sec)
MariaDB [test]> create table t2 (b vector(1) not null , vector(b), foreign key (b) references t(a)) engine=InnoDB;
ERROR 1005 (HY000): Can 't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
MariaDB [test]> show warnings;
+---------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Level | Code | Message |
+---------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Warning | 150 | Create table `test`.`t2` with foreign key (b) constraint failed. There is no index in the referenced table where the referenced columns appear as the first columns. |
| Error | 1005 | Can' t create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed" ) |
| Warning | 1215 | Cannot add foreign key constraint for `t2` |
+ ---------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
3 rows in set (0.000 sec)
So, it claims that table t does not have a key on the vector column a , but of course it does.
It appears that the presence of vector index prevents it from automatically creating a normal key on the column b , because this works (the same without vector key):
MariaDB [test]> create or replace table t2 (b vector(1) not null , foreign key (b) references t(a)) engine=InnoDB;
Query OK, 0 rows affected (0.078 sec)
MariaDB [test]> show create table t2\G
*************************** 1. row ***************************
Table : t2
Create Table : CREATE TABLE `t2` (
`b` vector(1) NOT NULL ,
KEY `b` (`b`),
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t` (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE =utf8mb4_uca1400_ai_ci
1 row in set (0.001 sec)
and this works too (the same with vector key and explicit key on column b):
MariaDB [test]> create or replace table t2 (b vector(1) not null , vector(b), key (b), foreign key (b) references t(a)) engine=InnoDB;
Query OK, 0 rows affected (0.167 sec)
MariaDB [test]> show create table t2\G
*************************** 1. row ***************************
Table : t2
Create Table : CREATE TABLE `t2` (
`b` vector(1) NOT NULL ,
KEY `b_2` (`b`),
VECTOR KEY `b` (`b`),
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t` (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE =utf8mb4_uca1400_ai_ci
It doesn't compare directly with spatial, because a normal key on a spatial column is converted into a prefix key and then the FK is rejected on the reason "There is only prefix index in the referenced table".
is caused by
MDEV-34939
vector search in 11.7
Closed
{"report":{"fcp":956.7999999523163,"ttfb":128,"pageVisibility":"visible","entityId":131194,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"92b2a7a0-2aa2-4706-881b-f6fa84b56988","navigationType":0,"readyForUser":1024.7999999523163,"redirectCount":0,"resourceLoadedEnd":1360.4000000953674,"resourceLoadedStart":133.20000004768372,"resourceTiming":[{"duration":392.7000000476837,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":133.20000004768372,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":133.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":525.9000000953674,"responseStart":0,"secureConnectionStart":0},{"duration":392.5,"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":133.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":133.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":526,"responseStart":0,"secureConnectionStart":0},{"duration":401.19999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":133.60000014305115,"connectEnd":133.60000014305115,"connectStart":133.60000014305115,"domainLookupEnd":133.60000014305115,"domainLookupStart":133.60000014305115,"fetchStart":133.60000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":133.60000014305115,"responseEnd":534.7999999523163,"responseStart":534.7999999523163,"secureConnectionStart":133.60000014305115},{"duration":425.90000009536743,"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":133.70000004768372,"connectEnd":133.70000004768372,"connectStart":133.70000004768372,"domainLookupEnd":133.70000004768372,"domainLookupStart":133.70000004768372,"fetchStart":133.70000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":133.70000004768372,"responseEnd":559.6000001430511,"responseStart":559.6000001430511,"secureConnectionStart":133.70000004768372},{"duration":429.2999999523163,"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":133.90000009536743,"connectEnd":133.90000009536743,"connectStart":133.90000009536743,"domainLookupEnd":133.90000009536743,"domainLookupStart":133.90000009536743,"fetchStart":133.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":133.90000009536743,"responseEnd":563.2000000476837,"responseStart":563.2000000476837,"secureConnectionStart":133.90000009536743},{"duration":429.7000000476837,"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":133.90000009536743,"connectEnd":133.90000009536743,"connectStart":133.90000009536743,"domainLookupEnd":133.90000009536743,"domainLookupStart":133.90000009536743,"fetchStart":133.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":133.90000009536743,"responseEnd":563.6000001430511,"responseStart":563.6000001430511,"secureConnectionStart":133.90000009536743},{"duration":430.2999999523163,"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":134,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":134,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":564.2999999523163,"responseStart":0,"secureConnectionStart":0},{"duration":429.90000009536743,"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":134,"connectEnd":134,"connectStart":134,"domainLookupEnd":134,"domainLookupStart":134,"fetchStart":134,"redirectEnd":0,"redirectStart":0,"requestStart":134,"responseEnd":563.9000000953674,"responseStart":563.9000000953674,"secureConnectionStart":134},{"duration":430.09999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":134.20000004768372,"connectEnd":134.20000004768372,"connectStart":134.20000004768372,"domainLookupEnd":134.20000004768372,"domainLookupStart":134.20000004768372,"fetchStart":134.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":134.20000004768372,"responseEnd":564.2999999523163,"responseStart":564.2999999523163,"secureConnectionStart":134.20000004768372},{"duration":430.40000009536743,"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":134.29999995231628,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":134.29999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":564.7000000476837,"responseStart":0,"secureConnectionStart":0},{"duration":430.2999999523163,"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":134.5,"connectEnd":134.5,"connectStart":134.5,"domainLookupEnd":134.5,"domainLookupStart":134.5,"fetchStart":134.5,"redirectEnd":0,"redirectStart":0,"requestStart":134.5,"responseEnd":564.7999999523163,"responseStart":564.7999999523163,"secureConnectionStart":134.5},{"duration":685.5999999046326,"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":135.20000004768372,"connectEnd":135.20000004768372,"connectStart":135.20000004768372,"domainLookupEnd":135.20000004768372,"domainLookupStart":135.20000004768372,"fetchStart":135.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":135.20000004768372,"responseEnd":820.7999999523163,"responseStart":820.7999999523163,"secureConnectionStart":135.20000004768372},{"duration":1225.1000001430511,"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":135.29999995231628,"connectEnd":135.29999995231628,"connectStart":135.29999995231628,"domainLookupEnd":135.29999995231628,"domainLookupStart":135.29999995231628,"fetchStart":135.29999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":135.29999995231628,"responseEnd":1360.4000000953674,"responseStart":1360.4000000953674,"secureConnectionStart":135.29999995231628},{"duration":536.5999999046326,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":764.7000000476837,"connectEnd":764.7000000476837,"connectStart":764.7000000476837,"domainLookupEnd":764.7000000476837,"domainLookupStart":764.7000000476837,"fetchStart":764.7000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":764.7000000476837,"responseEnd":1301.2999999523163,"responseStart":1301.2999999523163,"secureConnectionStart":764.7000000476837}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":2,"responseStart":128,"responseEnd":131,"domLoading":130,"domInteractive":1379,"domContentLoadedEventStart":1379,"domContentLoadedEventEnd":1413,"domComplete":2200,"loadEventStart":2200,"loadEventEnd":2201,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1362.1000001430511},{"name":"bigPipe.sidebar-id.end","time":1362.7999999523163},{"name":"bigPipe.activity-panel-pipe-id.start","time":1362.9000000953674},{"name":"bigPipe.activity-panel-pipe-id.end","time":1365.2000000476837},{"name":"activityTabFullyLoaded","time":1416.9000000953674}],"measures":[],"correlationId":"452f8babfecff5","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":66,"dbReadsTimeInMs":10,"dbConnsTimeInMs":16,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}