Skip to content

Commit

Permalink
Added support for fetching SYS.XMLTYPE by modifying the type informat…
Browse files Browse the repository at this point in the history
…ion to

return (LONG) VARCHAR2 when SYS.XMLTYPE is detected
(oracle/python-cx_Oracle#14).
  • Loading branch information
anthony-tuininga committed Dec 3, 2018
1 parent 61f68d7 commit d51e9c4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/dpiImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,7 @@ void dpiObject__free(dpiObject *obj, dpiError *error);
int dpiObjectType__allocate(dpiConn *conn, void *param,
uint32_t nameAttribute, dpiObjectType **objType, dpiError *error);
void dpiObjectType__free(dpiObjectType *objType, dpiError *error);
int dpiObjectType__isXmlType(dpiObjectType *objType);


//-----------------------------------------------------------------------------
Expand Down
19 changes: 19 additions & 0 deletions src/dpiObjectType.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,25 @@ static int dpiObjectType__init(dpiObjectType *objType, void *param,
}


//-----------------------------------------------------------------------------
// dpiObjectType__isXmlType() [INTERNAL]
// Returns a boolean indicating if the object type in question refers to the
// type SYS.XMLTYPE.
//-----------------------------------------------------------------------------
int dpiObjectType__isXmlType(dpiObjectType *objType)
{
static const char *schema = "SYS", *name = "XMLTYPE";
size_t schemaLength, nameLength;

schemaLength = strlen(schema);
nameLength = strlen(name);
return (objType->schemaLength == schemaLength &&
strncmp(objType->schema, schema, schemaLength) == 0 &&
objType->nameLength == nameLength &&
strncmp(objType->name, name, nameLength) == 0);
}


//-----------------------------------------------------------------------------
// dpiObjectType_addRef() [PUBLIC]
// Add a reference to the object type.
Expand Down
7 changes: 7 additions & 0 deletions src/dpiOracleType.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,13 @@ int dpiOracleType__populateTypeInfo(dpiConn *conn, void *handle,
if (dpiObjectType__allocate(conn, handle, DPI_OCI_ATTR_TYPE_NAME,
&info->objectType, error) < 0)
return DPI_FAILURE;
if (dpiObjectType__isXmlType(info->objectType)) {
dpiObjectType__free(info->objectType, error);
info->objectType = NULL;
info->ociTypeCode = DPI_SQLT_CHR;
info->oracleTypeNum = DPI_ORACLE_TYPE_LONG_VARCHAR;
info->defaultNativeTypeNum = DPI_NATIVE_TYPE_BYTES;
}
}

return DPI_SUCCESS;
Expand Down

0 comments on commit d51e9c4

Please sign in to comment.