设为首页 收藏本站
查看: 433|回复: 0

[经验分享] Oracle 10g dbms_rowid 包源码

[复制链接]

尚未签到

发表于 2016-7-27 09:54:04 | 显示全部楼层 |阅读模式
  

  前几天Roger 的blog 更新了一篇文章,是DBMS_ROWID包的定义部分,Oracle 的包的都是用wrap 进行加密的。itpub上有人研究了unwrap,也公布了一些代码,可以实现unwrap。


关于wrap和unwrap,参考我的blog:
Oracle wrap 和 unwrap( 加密与解密) 说明
http://blog.csdn.net/tianlesoftware/article/details/6698535


rowid在DB 维护中用的也是比较多。 了解ROWID 的相关函数,有助于工作。
Oracle Rowid 介绍
http://blog.csdn.net/tianlesoftware/article/details/5020718

Roger贴的那部分没有只有代码,没有注释,所以这里用Toad 把注释部分也拉出来了。贴一下。也可以直接用SQL 查看:
SQL>select text from dba_source where name='DBMS_ROWID';
  
  /* Formatted on2011/8/18 11:26:49 (QP5 v5.163.1008.3004) */
  CREATE OR REPLACE PACKAGE SYS.DBMS_ROWID
  IS
  ------------
  -- OVERVIEW
  --
  -- This package provides procedures to createROWIDs and to interpret
  -- their contents
  
  -- SECURITY
  --
  -- The execution privilege is granted to PUBLIC.Procedures in this
  -- package run under the caller security.
  
  
  ----------------------------
  
  ----------------------------
  
  -- ROWID TYPES:
  --
  -- RESTRICTED - Restricted ROWID
  --
  -- EXTENDED- Extended ROWID
  --
  rowid_type_restricted CONSTANT INTEGER := 0;
  rowid_type_extended CONSTANT INTEGER := 1;
  
  -- ROWID VERIFICATION RESULTS:
  --
  -- VALID- Valid ROWID
  --
  -- INVALID - Invalid ROWID
  --
  rowid_is_valid CONSTANT INTEGER := 0;
  rowid_is_invalid CONSTANT INTEGER := 1;
  
  -- OBJECT TYPES:
  --
  -- UNDEFINED - Object Number not defined (forrestricted ROWIDs)
  --
  rowid_object_undefined CONSTANT INTEGER := 0;
  
  -- ROWID CONVERSION TYPES:
  --
  -- INTERNAL - convert to/from column of ROWIDtype
  --
  -- EXTERNAL - convert to/from string format
  --
  rowid_convert_internal CONSTANT INTEGER := 0;
  rowid_convert_external CONSTANT INTEGER := 1;
  
  -- EXCEPTIONS:
  --
  --ROWID_INVALID - invalid rowid format
  --
  --ROWID_BAD_BLOCK - block is beyond end of file
  --
  ROWID_INVALID EXCEPTION;
  PRAGMA EXCEPTION_INIT (ROWID_INVALID, -1410);
  ROWID_BAD_BLOCK EXCEPTION;
  PRAGMA EXCEPTION_INIT (ROWID_BAD_BLOCK, -28516);
  
  -- PROCEDURES AND FUNCTIONS:
  --
  
  --
  --ROWID_CREATE constructs a ROWID from its constituents:
  --
  --rowid_type - type (restricted/extended)
  --object_number - data object number (rowid_object_undefined for restricted)
  --relative_fno - relative file number
  --block_number - block number in this file
  --file_number - file number in this block
  --
  FUNCTION rowid_create (rowid_type IN NUMBER,
  object_number IN NUMBER,
  relative_fno IN NUMBER,
  block_number IN NUMBER,
  ROW_NUMBER IN NUMBER)
  RETURN ROWID;
  
  PRAGMA RESTRICT_REFERENCES (rowid_create, WNDS, RNDS, WNPS, RNPS);
  
  --
  --ROWID_INFO breaks ROWID into its components and returns them:
  --
  --rowid_in - ROWID to be interpreted
  --rowid_type - type (restricted/extended)
  --object_number - data object number (rowid_object_undefined for restricted)
  --relative_fno - relative file number
  --block_number - block number in this file
  -- file_number - file number in this block
  --ts_type_in - type of tablespace which this row belongs to
  -- 'BIGFILE' indicates BigfileTablespace
  -- 'SMALLFILE' indicates Smallfile(traditional pre-10i) TS.
  -- NOTE: These two are the onlyallowed values for this param
  --
  PROCEDURE rowid_info (rowid_in IN ROWID,
  rowid_type OUT NUMBER,
  object_number OUT NUMBER,
  relative_fno OUT NUMBER,
  block_number OUT NUMBER,
  ROW_NUMBER OUT NUMBER,
  ts_type_in IN VARCHAR2 DEFAULT 'SMALLFILE');
  
  PRAGMA RESTRICT_REFERENCES (rowid_info, WNDS, RNDS, WNPS, RNPS);
  
  --
  --ROWID_TYPE returns the type of a ROWID (restricted/extended_nopart,..)
  --
  --row_id - ROWID to be interpreted
  --
  FUNCTION rowid_type (row_idIN ROWID)
  RETURN NUMBER;
  
  PRAGMA RESTRICT_REFERENCES (rowid_type, WNDS, RNDS, WNPS, RNPS);
  
  --
  --ROWID_OBJECT extracts the data object number from a ROWID.
  --ROWID_OBJECT_UNDEFINED is returned for restricted rowids.
  --
  --row_id - ROWID to be interpreted
  --
  FUNCTION rowid_object (row_idIN ROWID)
  RETURN NUMBER;
  
  PRAGMA RESTRICT_REFERENCES (rowid_object, WNDS, RNDS, WNPS, RNPS);
  
  --
  --ROWID_RELATIVE_FNO extracts the relative file number from a ROWID.
  --
  --row_id - ROWID to be interpreted
  --ts_type_in - type of tablespace which this row belongs to
  --
  FUNCTION rowid_relative_fno (row_id IN ROWID,
  ts_type_in IN VARCHAR2 DEFAULT 'SMALLFILE')
  RETURN NUMBER;
  
  PRAGMA RESTRICT_REFERENCES (rowid_relative_fno, WNDS, RNDS, WNPS, RNPS);
  
  --
  --ROWID_BLOCK_NUMBER extracts the block number from a ROWID.
  --
  --row_id - ROWID to be interpreted
  --ts_type_in - type of tablespace which this row belongs to
  --
  --
  FUNCTION rowid_block_number (row_id IN ROWID,
  ts_type_in IN VARCHAR2 DEFAULT 'SMALLFILE')
  RETURN NUMBER;
  
  PRAGMA RESTRICT_REFERENCES (rowid_block_number, WNDS, RNDS, WNPS, RNPS);
  
  --
  --ROWID_ROW_NUMBER extracts the row number from a ROWID.
  --
  --row_id - ROWID to be interpreted
  --
  FUNCTION rowid_row_number (row_id IN ROWID)
  RETURN NUMBER;
  
  PRAGMA RESTRICT_REFERENCES (rowid_row_number, WNDS, RNDS, WNPS, RNPS);
  
  --
  --ROWID_TO_ABSOLUTE_FNO extracts the relative file number from a ROWID,
  --which addresses a row in a given table
  --
  --row_id - ROWID to be interpreted
  --
  --schema_name - name of the schema which contains the table
  --
  --object_name - table name
  --
  FUNCTION rowid_to_absolute_fno (row_id IN ROWID,
  schema_name IN VARCHAR2,
  object_name IN VARCHAR2)
  RETURN NUMBER;
  
  PRAGMA RESTRICT_REFERENCES (rowid_to_absolute_fno, WNDS, WNPS, RNPS);
  
  --
  --ROWID_TO_EXTENDED translates the restricted ROWID which addresses
  -- arow in a given table to the extended format. Later, it may be removed
  --from this package into a different place
  --
  --old_rowid - ROWID to be converted
  --
  --schema_name - name of the schema which contains the table (OPTIONAL)
  --
  --object_name - table name (OPTIONAL)
  --
  --conversion_type - rowid_convert_internal/external_convert_external
  -- (whether old_rowid wasstored in a column of ROWID
  -- type, or the characterstring)
  --
  FUNCTION rowid_to_extended (old_rowid IN ROWID,
  schema_name IN VARCHAR2,
  object_name IN VARCHAR2,
  conversion_type IN INTEGER)
  RETURN ROWID;
  
  PRAGMA RESTRICT_REFERENCES (rowid_to_extended, WNDS, WNPS, RNPS);
  
  --
  --ROWID_TO_RESTRICTED translates the extnded ROWID into a restricted format
  --
  --old_rowid - ROWID to be converted
  --
  --conversion_type - internal/external (IN)
  --
  --conversion_type - rowid_convert_internal/external_convert_external
  -- (whetherreturned rowid will be stored in a column of
  -- ROWID type, or thecharacter string)
  --
  FUNCTION rowid_to_restricted (old_rowid IN ROWID,
  conversion_type IN INTEGER)
  RETURN ROWID;
  
  PRAGMA RESTRICT_REFERENCES (rowid_to_restricted, WNDS, RNDS, WNPS, RNPS);
  
  --
  --ROWID_VERIFY verifies the ROWID. It returns rowid_valid or rowid_invalid
  --value depending on whether a given ROWID is valid or not.
  --
  --rowid_in - ROWID to be verified
  --
  --schema_name - name of the schema which contains the table
  --
  --object_name - table name
  --
  --conversion_type - rowid_convert_internal/external_convert_external
  -- (whether old_rowid wasstored in a column of ROWID
  -- type, or the characterstring)
  --
  FUNCTION rowid_verify (rowid_in IN ROWID,
  schema_name IN VARCHAR2,
  object_name IN VARCHAR2,
  conversion_type IN INTEGER)
  RETURN NUMBER;
  
  PRAGMA RESTRICT_REFERENCES (rowid_verify, WNDS, WNPS, RNPS);
  END;
  /
  
  
  
  
  
  
  -------------------------------------------------------------------------------------------------------
  Blog: http://blog.csdn.net/tianlesoftware
  Weibo: http://weibo.com/tianlesoftware
  Email: dvd.dba@gmail.com
  DBA1 群:62697716(满); DBA2 群:62697977(满)DBA3 群:62697850(满)
  DBA 超级群:63306533(满); DBA4 群: 83829929(满)DBA5群: 142216823(满)
  DBA6 群:158654907(满) 聊天 群:40132017(满) 聊天2群:69087192(满)
  --加群需要在备注说明Oracle表空间和数据文件的关系,否则拒绝申请

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-250062-1-1.html 上篇帖子: Oracle RBA(Redo Byte Address) 说明 下篇帖子: oracle 解决匹配的几种方法
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表