Each row of data in oracle database has a unique identifier(or rowid), which is usually used to access the data inside the oracle. Rowid requires 10 bytes of storage space and uses 18 characters to display. This value indicates the physical location of the row in the oracle database. You can use rowid in a query to indicate that the value is included in the query result.
It takes 10 bytes or 80 binary bits to save the rowid. The 80 binary bits are:
The data object number indicates the number of the database object to which this row belongs. Each data object is uniquely assigned a number when the database is created, and this number is unique. The data object number occupies approximately 32 bits.
Corresponding to the file number, indicating the number of the file where the row is located, and each file label in the table space is unique. The position occupied by the file number is 10 bits.
The block number indicates the position of the block of the file where the line is changed. The block number requires 22 bits.
The row number indicates the specific position of the row in the row directory. The row number requires 16 bits.
This adds up to 80 bits.
Oracle's physical extension ROWID has 18 bits, and each bit is coded with 64 bits, which are represented by 64 characters A~Z, a~z, 0~9, +, /. A means 0, B means 1,...Z means 25, a means 26,...z means 51, 0 means 52,..., 9 means 61, + means 62, and / means 63.
select rowid,empno from scott.emp;
ROWID EMPNO
------------------ ----------
AAAR3sAAEAAAACXAAA 7369
AAAR3sAAEAAAACXAAB 7499
AAAR3sAAEAAAACXAAC 7521
AAAR3sAAEAAAACXAAD 7566
Through the dbms_rowid package, you can directly get the information contained in the specific rowid:
SQL> select dbms_rowid.rowid_object(rowid) object_id,dbms_rowid.rowid_relative_fno(rowid) file_id,dbms_rowid.rowid_block_number(rowid) block_id,dbms_rowid.rowid_row_number(rowid) row_number from emp;
Some key information for implement, please check it and give some suggestion:
Like oracle, we use 10 bytes to represent ROWID. The difference is that 4 bytes space id corresponds to oracle object id, 4 bytes page id corresponds to block no, and 2 bytes row no corresponds to row no. Because there is only one file in the mariadb tablespace, we think that the file no in the oracle rowid can only be 1 in mariadb
When allocating memory to the record in the sturct TABLE structure, allocate 18 more bytes to store the ROWID
Add rowid field (or virtual column) in struct TABLE_SHARE to identify rowid column
In the row_sel_store_mysql_rec function, if there is a rowid in the select list, the actual value of the rowid is generated according to the first description rule and returned to the server layer together with other fields
woqutech.com
added a comment - Some key information for implement, please check it and give some suggestion:
Like oracle, we use 10 bytes to represent ROWID. The difference is that 4 bytes space id corresponds to oracle object id, 4 bytes page id corresponds to block no, and 2 bytes row no corresponds to row no. Because there is only one file in the mariadb tablespace, we think that the file no in the oracle rowid can only be 1 in mariadb
When allocating memory to the record in the sturct TABLE structure, allocate 18 more bytes to store the ROWID
Add rowid field (or virtual column) in struct TABLE_SHARE to identify rowid column
In the row_sel_store_mysql_rec function, if there is a rowid in the select list, the actual value of the rowid is generated according to the first description rule and returned to the server layer together with other fields
How is ROWID used in the applications you are looking at?
Is it not enough that the ROWID is unique for the table or has it to be unique over all tables?
Why not just return the primary key that InnoDB always creates?
(For other storage engines we would have an option to force a hidden primary key when tables are created. See MDEV-21181 Automatic invisible primary key)
Michael Widenius
added a comment - - edited How is ROWID used in the applications you are looking at?
Is it not enough that the ROWID is unique for the table or has it to be unique over all tables?
Why not just return the primary key that InnoDB always creates?
(For other storage engines we would have an option to force a hidden primary key when tables are created. See MDEV-21181 Automatic invisible primary key)
```
CREATE TABLE "CIM"."TASKLIST" ("ID" VARCHAR2(42) NOT NULL ENABLE, "STATIONLINE" VARCHAR2(4000) ... "BELONGCITY" VARCHAR2(42)) ;
ALTER TABLE "CIM"."TASKLIST" ADD PRIMARY KEY ("ID") USING INDEX ENABLE;
```
and the select and delete is
```
select null from TASKLIST where rowid = : plsqldev_rowid for update nowait;
DELETE FROM TASKLIST WHERE ROWID = : PLSQLDEV_ROWID;
```
In this case,
we can not use _rowid feature
user has the primary key id( is a VARCHAR2(42)), so InnoDB will not create a hidden primary key. we can not use hidden primary key for ROWID.
map a VARCHAR2(42) to 10 byte ROWID may have the same ROWID for two different row .
woqutech.com
added a comment - - edited The table definition on oracle is
```
CREATE TABLE "CIM"."TASKLIST" ("ID" VARCHAR2(42) NOT NULL ENABLE, "STATIONLINE" VARCHAR2(4000) ... "BELONGCITY" VARCHAR2(42)) ;
ALTER TABLE "CIM"."TASKLIST" ADD PRIMARY KEY ("ID") USING INDEX ENABLE;
```
and the select and delete is
```
select null from TASKLIST where rowid = : plsqldev_rowid for update nowait;
DELETE FROM TASKLIST WHERE ROWID = : PLSQLDEV_ROWID;
```
In this case,
we can not use _rowid feature
user has the primary key id( is a VARCHAR2(42)), so InnoDB will not create a hidden primary key. we can not use hidden primary key for ROWID.
map a VARCHAR2(42) to 10 byte ROWID may have the same ROWID for two different row .
People
Unassigned
woqutech.com
Votes:
0Vote for this issue
Watchers:
3Start watching this issue
Dates
Created:
Updated:
Git Integration
Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.
{"report":{"fcp":1021.5,"ttfb":246.2999997138977,"pageVisibility":"visible","entityId":95613,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"8422baa5-5389-4f4c-b567-657b5fad1b32","navigationType":0,"readyForUser":1094.6999998092651,"redirectCount":0,"resourceLoadedEnd":1130.5999999046326,"resourceLoadedStart":252.19999980926514,"resourceTiming":[{"duration":265.59999990463257,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":252.19999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":252.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":517.7999997138977,"responseStart":0,"secureConnectionStart":0},{"duration":265.59999990463257,"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":252.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":252.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":518.0999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":275.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":252.59999990463257,"connectEnd":252.59999990463257,"connectStart":252.59999990463257,"domainLookupEnd":252.59999990463257,"domainLookupStart":252.59999990463257,"fetchStart":252.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":252.59999990463257,"responseEnd":528.0999999046326,"responseStart":528.0999999046326,"secureConnectionStart":252.59999990463257},{"duration":338.30000019073486,"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":252.7999997138977,"connectEnd":252.7999997138977,"connectStart":252.7999997138977,"domainLookupEnd":252.7999997138977,"domainLookupStart":252.7999997138977,"fetchStart":252.7999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":252.7999997138977,"responseEnd":591.0999999046326,"responseStart":591.0999999046326,"secureConnectionStart":252.7999997138977},{"duration":341.69999980926514,"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":253,"connectEnd":253,"connectStart":253,"domainLookupEnd":253,"domainLookupStart":253,"fetchStart":253,"redirectEnd":0,"redirectStart":0,"requestStart":253,"responseEnd":594.6999998092651,"responseStart":594.6999998092651,"secureConnectionStart":253},{"duration":341.90000009536743,"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":253.2999997138977,"connectEnd":253.2999997138977,"connectStart":253.2999997138977,"domainLookupEnd":253.2999997138977,"domainLookupStart":253.2999997138977,"fetchStart":253.2999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":253.2999997138977,"responseEnd":595.1999998092651,"responseStart":595.1999998092651,"secureConnectionStart":253.2999997138977},{"duration":342.19999980926514,"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":253.40000009536743,"connectEnd":253.40000009536743,"connectStart":253.40000009536743,"domainLookupEnd":253.40000009536743,"domainLookupStart":253.40000009536743,"fetchStart":253.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":253.40000009536743,"responseEnd":595.5999999046326,"responseStart":595.5999999046326,"secureConnectionStart":253.40000009536743},{"duration":423.80000019073486,"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":253.59999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":253.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":677.4000000953674,"responseStart":0,"secureConnectionStart":0},{"duration":343.09999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":253.69999980926514,"connectEnd":253.69999980926514,"connectStart":253.69999980926514,"domainLookupEnd":253.69999980926514,"domainLookupStart":253.69999980926514,"fetchStart":253.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":253.69999980926514,"responseEnd":596.7999997138977,"responseStart":596.7999997138977,"secureConnectionStart":253.69999980926514},{"duration":423.59999990463257,"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":253.90000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":253.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":677.5,"responseStart":0,"secureConnectionStart":0},{"duration":343.40000009536743,"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":254.09999990463257,"connectEnd":254.09999990463257,"connectStart":254.09999990463257,"domainLookupEnd":254.09999990463257,"domainLookupStart":254.09999990463257,"fetchStart":254.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":254.09999990463257,"responseEnd":597.5,"responseStart":597.5,"secureConnectionStart":254.09999990463257},{"duration":875.1999998092651,"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":254.90000009536743,"connectEnd":254.90000009536743,"connectStart":254.90000009536743,"domainLookupEnd":254.90000009536743,"domainLookupStart":254.90000009536743,"fetchStart":254.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":254.90000009536743,"responseEnd":1130.0999999046326,"responseStart":1130.0999999046326,"secureConnectionStart":254.90000009536743},{"duration":875.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":255,"connectEnd":255,"connectStart":255,"domainLookupEnd":255,"domainLookupStart":255,"fetchStart":255,"redirectEnd":0,"redirectStart":0,"requestStart":255,"responseEnd":1130.5999999046326,"responseStart":1130.5999999046326,"secureConnectionStart":255},{"duration":427,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":699.6999998092651,"connectEnd":699.6999998092651,"connectStart":699.6999998092651,"domainLookupEnd":699.6999998092651,"domainLookupStart":699.6999998092651,"fetchStart":699.6999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":699.6999998092651,"responseEnd":1126.6999998092651,"responseStart":1126.6999998092651,"secureConnectionStart":699.6999998092651},{"duration":188.7999997138977,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1014.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1014.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1203.2999997138977,"responseStart":0,"secureConnectionStart":0}],"fetchStart":1,"domainLookupStart":1,"domainLookupEnd":1,"connectStart":1,"connectEnd":1,"requestStart":86,"responseStart":247,"responseEnd":248,"domLoading":250,"domInteractive":1246,"domContentLoadedEventStart":1246,"domContentLoadedEventEnd":1301,"domComplete":1797,"loadEventStart":1797,"loadEventEnd":1798,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1209.1999998092651},{"name":"bigPipe.sidebar-id.end","time":1210.0999999046326},{"name":"bigPipe.activity-panel-pipe-id.start","time":1210.2999997138977},{"name":"bigPipe.activity-panel-pipe-id.end","time":1213.7999997138977},{"name":"activityTabFullyLoaded","time":1312.6999998092651}],"measures":[],"correlationId":"3a1085bf995d1","effectiveType":"4g","downlink":9.9,"rtt":0,"serverDuration":100,"dbReadsTimeInMs":10,"dbConnsTimeInMs":18,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
Some key information for implement, please check it and give some suggestion: