ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Oracle 10g dbms_rowid 包源码

Oracle 10g dbms_rowid 包源码

原创 Linux操作系统 作者:vcdog 时间:2011-08-27 05:31:07 0 删除 编辑


前几天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表空间和数据文件的关系,否则拒绝申请

作者:tianlesoftware 发表于2011-8-18 12:13:21 原文链接
阅读:245 评论:0 查看评论


Link URL: http://blog.csdn.net/tianlesoftware/article/details/6697761

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7589639/viewspace-705933/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2011-08-21

  • 博文量
    28
  • 访问量
    33034