Skip Headers

Oracle9i Data Cartridge Developer's Guide
Release 2 (9.2)

Part Number A96595-01
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback

Go to previous page Go to next page

17
Reference: Extensible Indexing Interface

This chapter describes Java language ODCI (Oracle Data Cartridge Interface) Extensible Indexing Interfaces. For more complete details on Java functionality, refer to the Oracle9i Supplied Java Packages Reference.

The following interfaces are described:


Extensible Indexing -- System Defined Interface Routines


Caution:

These routines are invoked by Oracle at the appropriate times based on SQL statements executed by the end user. The user should not try to invoke these routines directly as this may result in corruption of index data.



ODCIGetInterfaces

Syntax

ODCIGetInterfaces(ifclist OUT ODCIObjectList) RETURN NUMBER

Purpose

The ODCIGetInterfaces function is invoked when an INDEXTYPE is created by a CREATE INDEXTYPE... statement or is altered.

Table 17-1 ODCIGetInterfaces Arguments
Argument Meaning
ifclist

Contains information about the interfaces it supports

Returns

Usage Notes

This function should be implemented as a static type method.

This function must return 'SYS.ODCIINDEX2' in the ODCIObjectList if the indextype uses the second version of the ODCIIndex interface, that is, the version described in this book.

In existing code that uses the previous, Oracle8i version of the ODCIIndex interface, this function was required to return 'SYS.ODCIINDEX1' to specify the Oracle8i version of the interface. That code will still work. To continue to use the Oracle8i interface, continue to have this function return 'SYS.ODCIINDEX1', and do not implement Oracle9i versions of any of the routines.


ODCIIndexAlter

Syntax

ODCIIndexAlter(ia ODCIIndexInfo, parms IN OUT VARCHAR2, alter_option NUMBER, env ODCIEnv) RETURN NUMBER

Purpose

This method is invoked when a domain index or a domain index partition is altered using an ALTER INDEX or an ALTER INDEX PARTITION statement.

Table 17-2 ODCIIndexAlter Arguments
Argument Meaning
ia

Contains information about the index and the indexed column

parms (IN)

Parameter string

if ALTER INDEX PARAMETERS or ALTER INDEX REBUILD contains the user specified parameter string

if ALTER INDEX RENAME contains the new name of the domain index

parms (OUT)

Parameter string

is valid only if ALTER INDEX PARAMETERS or ALTER INDEX REBUILD. Contains the resultant string to be stored in system catalogs

alter_option

Specifies one of the following options:

  • AlterIndexNone if ALTER INDEX [PARTITION] PARAMETERS
  • AlterIndexRename if ALTER INDEX RENAME [PARTITION]
  • AlterIndexRebuild if ALTER INDEX REBUILD [PARTITION] [PARALLEL (DEGREE deg)] [PARAMETERS]
  • AlterIndexUpdBlockRefs if ALTER INDEX [schema.]index UPDATE BLOCK REFERENCES
env

The environment handle passed to the routine

Returns

ODCIConst.Success on success, or ODCIConst.Error on error, or ODCIConst.Warning.

Usage Notes


ODCIIndexClose

Syntax

ODCIIndexClose(self IN <impltype>, env ODCIEnv) RETURN NUMBER

Purpose

This method is invoked to end the processing of an operator.

Table 17-3 ODCIIndexClose Arguments
Argument Meaning
self(IN)

Is the value of the context returned by the previous invocation of ODCIIndexFetch

env

The environment handle passed to the routine

Returns

Usage Notes


ODCIIndexCreate

Syntax

ODCIIndexCreate(ia ODCIIndexInfo, parms VARCHAR2, env ODCIEnv) RETURN NUMBER

Purpose

The ODCIIndexCreate method is invoked when a domain index is created by a CREATE INDEX...INDEXTYPE IS...PARAMETERS... statement issued by the user. The domain index that is created can be a non-partitioned index or a local partitioned domain index.

Table 17-4 ODCIIndexCreate Arguments
Argument Meaning
ia

Contains information about the indexed column

parms

Is the PARAMETERS string passed in uninterpreted by Oracle. The maximum size of the parameter string is 1000 characters.

env

The environment handle passed to the routine

Returns

Usage Notes


ODCIIndexDelete

Syntax

ODCIIndexDelete(ia ODCIIndexInfo, rid VARCHAR2, oldval <icoltype>, env ODCIEnv) RETURN NUMBER

Purpose

This procedure is invoked when a row is deleted from a table that has a domain index defined on one of its columns.

Table 17-5 ODCIIndexDelete Arguments
Argument Meaning
ia

Contains information about the index and the indexed column

rid

The row identifier of the deleted row

oldval

The value of the indexed column in the deleted row. The datatype is the same as that of the indexed column.

env

The environment handle passed to the routine

Returns

ODCIConst.Success on success, or ODCIConst.Error on error

Usage Notes


ODCIIndexDrop

Syntax

ODCIIndexDrop(ia ODCIIndexInfo, env ODCIEnv) RETURN NUMBER

Purpose

The ODCIIndexDrop procedure is invoked when a domain index is dropped explicitly using a DROP INDEX statement, or implicitly through a DROP TABLE, or DROP USER statement.

Table 17-6 ODCIIndexDrop Arguments
Argument Meaning
ia

Contains information about the indexed column

env

The environment handle passed to the routine

Returns

ODCIConst.Success on success, or ODCIConst.Error on error, or ODCIConst.Warning.

While dropping a local domain index, the first N+1 calls can return ODCIConst.ErrContinue too.

Usage Notes


ODCIIndexExchangePartition

Syntax

ODCIIndexExchangePartition( ia ODCIIndexInfo, ia1 ODCIIndexInfo, env ODCIEnv) RETURN NUMBER

Purpose

This method is invoked when an ALTER TABLE EXCHANGE PARTITION...INCLUDING INDEXES is issued on a partitioned table on which a local domain index is defined.

Table 17-7 ODCIIndexExchangePartition Arguments
Argument Meaning

ia

Contains information about the partition to exchange

ia1

Contains information about the non-local, unpartitioned domain index to exchange

env

The environment handle passed to the routine

Returns

ODCIConst.Success on success, or ODCIConst.Error on error, or ODCIConst.Warning.

Usage Notes

The function should be implemented as a static type method.

This method should handle both converting a partition of a domain index into a non-partitioned domain index table and converting a non-partitioned index to a partition of a partitioned domain index.


ODCIIndexFetch

Syntax

ODCIIndexFetch(self IN [OUT] <impltype>, nrows IN NUMBER, rids OUT ODCIRidList, env ODCIEnv) RETURN NUMBER

Purpose

This procedure is invoked repeatedly to retrieve the rows satisfying the operator predicate.

Table 17-8 ODCIIndexFetch Arguments
Argument Meaning
self(IN)

Is the value of the context returned by the previous call (to ODCIIndexFetch or to ODCIIndexStart if this is the first time fetch is being called for this operator instance

self(OUT)

The context that is passed to the next query-time call.Note that this parameter does not have to be defined as OUT if the value is not modified in this routine.

nrows

Is the maximum number of result rows that can be returned to Oracle in this call

rids

Is the array of row identifiers for the result rows being returned by this call

env

The environment handle passed to the routine

Returns

ODCIConst.Success on success, or ODCIConst.Error on error

Usage Notes


ODCIIndexGetMetadata

Syntax

ODCIIndexGetMetadata(ia IN ODCIIndexInfo, version IN VARCHAR2, new_block OUT PLS_INTEGER) RETURN VARCHAR2;

Purpose

This routine is called repeatedly to return a series of strings of PL/SQL code that comprise the non-dictionary metadata associated with the index in ia. The routine can pass whatever information is required at import time--for example, policy, version, preferences, and so on. This method is optional unless implementation-specific metadata is required.

Table 17-9 ODCIIndexGetMetadata Arguments
Argument Description
ia

Specifies the index on which export is currently working.

version

Version of export making the call in the form 08.01.03.00.00.

new_block

Non-zero (TRUE): Returned string starts a new PL/SQL block. Export will terminate the current block (if any) with END; and open a new block with BEGIN before writing strings to the dump file. The routine is called again.

0 (FALSE): Returned string continues current block. Export writes only the returned string to the dump file then calls the routine again.

Developers of domain index implementation types in 8.1.3 must implement ODCIIndexGetMetadata even if only to indicate that no PL/SQL metadata exists or that the index is not participating in fast rebuild.

Returns

Usage Notes

This function should be implemented as a static type method.

The routine will be called repeatedly until the return string length is 0. If an index has no metadata to be exported using PL/SQL, it should return an empty string upon first call.

This routine can be used to build one or more blocks of anonymous PL/SQL code for execution by import.Each block returned will be invoked independently by import. That is, if a block fails for any reason at import time, subsequent blocks will still be invoked. Therefore any dependent code should be incorporated within a single block. The size of an individual block of PL/SQL code is limited only by the size of import's read buffer controlled by its BUFFER parameter.

The execution of these PL/SQL blocks at import time will be considered part of the associated domain index's creation. Therefore, their execution will be dependent upon the successful import of the index's underlying base table and user's setting of import's INDEXES=Y/N parameter, as is the creation of the index.

The routine should not pass back the BEGIN/END strings that open and close the individual blocks of PL/SQL code; export will add these to mark the individual units of execution.

The parameter version is the version number of the currently executing export client. Since export and import can be used to downgrade a database to the previous functional point release, it also represents the minimum server version you can expect to find at import time; it may be higher, but never lower.

The cartridge developer can use this information to determine what version of information should be written to the dump file. For example, assume the current server version is 08.02.00.00.00, but the export version handed in is 08.01.04.00.00. If a cartridge's metadata changed formats between 8.1 and 8.2, it would know to write the data to the dump file in 8.1 format anticipating an import into an 8.1.4 system. Server versions starting at 8.2 and higher will have to know how to convert 8.1 format metadata.

Some points to be aware of:

  1. The data contained within the strings handed back to export must be completely platform-independent. That is, they should contain no binary information that may reflect the endian nature of the export platform, which may be different from the import platform. Binary information may be passed as hex strings and converted through RAWTOHEX and HEXTORAW.
  2. The strings are translated from the export server to export client character set and are written to the dump file as such. At import time, they are translated from export client character set to import client character set, then from import client char set to import server character set when handed over the UPI interface.
  3. Specifying a specific target schema in the execution of any of the PL/SQL blocks should be avoided as it will most likely cause an error if you exercise import's FROMUSER -> TOUSER schema replication feature. For example, a procedure prototype such as:
    PROCEDURE AQ_CREATE ( schema IN VARCHAR2, que_name IN VARCHAR2) ...
    

    Should be avoided since this will fail if you have remapped schema A to schema B on import. You can assume at import time that you are already connected to the target schema.

  4. Export dump files from a particular version must be importable into all future versions. This means that all PL/SQL routines invoked within the anonymous PL/SQL blocks written to the dump file must be supported for all time. You may wish to encode some version information to assist with detecting when conversion may be required.
  5. Export will be operating in a read-only transaction if its parameter CONSISTENT=Y. In this case, no writes are allowed from the export session. Therefore, this method must not write any database state.
  6. You can attempt to import the same dump file multiple times, especially when using import's IGNORE=Y parameter. Therefore, this method must produce PL/SQL code that is idempotent, or at least deterministic when executed multiple times.
  7. Case on database object names must be preserved; that is, objects named 'Foo' and 'FOO' are distinct objects. Database object names should be enclosed within double quotes ("") to preserve case.

Error Handling

Any unrecoverable error should raise an exception allowing it to propagate back to get_domain_index_metadata and thence back to export. This will cause export to terminate the creation of the current index's DDL in the dump file and to move on to the next index.

At import time, failure of the execution of any metadata PL/SQL block will cause the associated index to not be created under the assumption that the metadata creation is an integral part of the index creation.


ODCIIndexInsert

Syntax

ODCIIndexInsert(ia ODCIIndexInfo, rid VARCHAR2, newval <icoltype>, env ODCIEnv) RETURN NUMBER

Purpose

This method is invoked when a new row is inserted into a table that has a domain index defined on one of its columns.

Table 17-10 ODCIIndexInsert Arguments  
Argument Meaning
ia

Contains information about the index and the indexed column

rid

The row identifier of the new row in the table

newval

The value of the indexed column in the inserted row.

env

The environment handle passed to the routine

Returns

ODCIConst.Success on success, or ODCIConst.Error on error

Usage Notes

This function should be implemented as a static type method.

This method should insert index data corresponding to the new row into the appropriate tables/files storing index data.

If ODCIIndexInsert is invoked at the partition level, then the index partition name is filled in in the ODCIIndexInfo argument.


ODCIIndexMergePartition

Syntax

ODCIIndexMergePartition(ia ODCIIndexInfo, part_name1 ODCIPartInfo, part_name2 ODCIPartInfo, parms VARCHAR2, env ODCIEnv) RETURN NUMBER

Purpose

This method is invoked when a ALTER TABLE MERGE PARTITION is issued on range partitioned table on which a local domain index is defined.

Table 17-11 ODCIIndexMergePartition Arguments
Argument Meaning

ia

Contains index and table partition name for one of the partitions to be merged

part_name1

Contains index and table partition name for the second partition to be merged

part_name2

Holds index and table partition name for the merged partition

parms

Contains the parameter string for the resultant merged partition--essentially the default parameter string associated with the index

env

The environment handle passed to the routine

Returns

ODCIConst.Success on success, or ODCIConst.Error on error, or ODCIConst.Warning.

Usage Notes


ODCIIndexSplitPartition

Syntax

ODCIIndexSplitPartition(ia ODCIIndexInfo, part_name1 ODCIPartInfo, part_name2 ODCIPartInfo, parms VARCHAR2, env ODCIEnv) RETURN NUMBER

Purpose

This method is invoked when an ALTER TABLE SPLIT PARTITION is invoked on a partitioned table on which a local domain index is defined.

Table 17-12 ODCIIndexSplitPartition Arguments
Argument Meaning

ia

Contains the information about the partition to be split

part_name1

Holds the index and table partition names for one of the new partitions

part_name2

Holds the index and table partition names for the other new partition

parms

Contains the parameter string for the new partitions-- essentially the parameter string associated with the index partition that is being split

env

The environment handle passed to the routine

Returns

ODCIConst.Success on success, or ODCIConst.Error on error, or ODCIConst.Warning.

Usage Notes

The function should be implemented as a static type method.

Cartridge writers need to drop the metadata corresponding to the partition that is split and create metadata for the two partitions that are created as a result of the split. The index data corresponding to these partitions need not be computed since the indexes are marked UNUSABLE. When the user issues ALTER INDEX REBUILD PARTITION to make the indexes usable, the indexes can be built.

The old table and the old index partition's dictionary entries are deleted before the call to ODCIIndexSplitPartition, so the cartridge code for this routine should not rely on the existence of this data in the views.


ODCIIndexStart

Syntax

ODCIIndexStart(sctx IN OUT <impltype>, ia ODCIIndexInfo, pi ODCIPredInfo, qi ODCIQueryInfo, strt <opbndtype>, stop <opbndtype>, <valargs>, env ODCIEnv) RETURN NUMBER

Purpose

This procedure is invoked to start the evaluation of an operator on an indexed column.

Table 17-13 ODCIIndexStart Arguments  
Argument Meaning
sctx(IN)

The value of the scan context returned by some previous related query-time call (such as the corresponding ancillary operator, if invoked before the primary operator); NULL otherwise

sctx(OUT)

The context that is passed to the next query-time call; the next query-time call will be to ODCIIndexFetch

ia

Contains information about the index and the indexed column

pi

Contains information about the operator predicate

qi

Contains query information (hints plus list of ancillary operators referenced)

strt

The start value of the bounds on the operator return value. The datatype is the same as that of the operator's return value

stop

The stop value of the bounds on the operator return value. The datatype is the same as that of the operator's return value.

valargs

The value arguments of the operator invocation. The number and datatypes of these arguments are the same as those of the value arguments to the operator.

env

The environment handle passed to the routine

Returns

ODCIConst.Success on success, or ODCIConst.Error on error

Usage Notes


ODCIIndexTruncate

Syntax

ODCIIndexTruncate(ia ODCIIndexInfo, env ODCIEnv) RETURN NUMBER

Purpose

The ODCIIndexTruncate procedure is invoked when a TRUNCATE statement is issued against a table that has a domain index defined on one of its columns.

Table 17-14 ODCIIndexTruncate Arguments
Argument Meaning
ia

Contains information about the indexed column

env

The environment handle passed to the routine

Returns

ODCIConst.Success on success, or ODCIConst.Error on error, or ODCIConst.Warning.

While truncating a local domain index, the first N+1 calls can return ODCIConst.ErrContinue too.

Usage Notes


ODCIIndexUpdate

Syntax

ODCIIndexUpdate( ia ODCIIndexInfo, rid VARCHAR2, oldval <icoltype>, newval <icoltype>, env ODCIEnv)RETURN NUMBER

Purpose

This method is invoked when a row is updated in a table that has a domain index defined on one of its columns.

Table 17-15 ODCIIndexUpdate Arguments
Argument Meaning
ia

Contains information about the index and the indexed column

rid

The row identifier of the updated row

oldval

The value of the indexed column before the update. The datatype is the same as that of the indexed column.

newval

The value of the indexed column after the update. The datatype is the same as that of the indexed column.

env

The environment handle passed to the routine

Returns

ODCIConst.Success on success, or ODCIConst.Error on error

Usage Notes


Go to previous page Go to next page
Oracle
Copyright © 1996, 2002 Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback