Skip to content

Commit

Permalink
Added support for starting up a database using a parameter file (PFIL…
Browse files Browse the repository at this point in the history
…E), as

requested (#295).
  • Loading branch information
anthony-tuininga committed Dec 4, 2019
1 parent 6b73d22 commit 809ead0
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
10 changes: 8 additions & 2 deletions doc/src/api_manual/connection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -514,12 +514,18 @@ Connection Object
This method is an extension to the DB API definition.


.. method:: Connection.startup(force=False, restrict=False)
.. method:: Connection.startup(force=False, restrict=False, pfile=None)

Startup the database. This is equivalent to the SQL\*Plus command "startup
nomount". The connection must be connected as :data:`~cx_Oracle.SYSDBA` or
:data:`~cx_Oracle.SYSOPER` with the :data:`~cx_Oracle.PRELIM_AUTH` option
specified for this to work. An example is shown below:
specified for this to work.

The pfile parameter, if specified, is expected to be a string identifying
the location of the parameter file (PFILE) which will be used instead of
the stored parameter file (SPFILE).

An example is shown below:

::

Expand Down
3 changes: 3 additions & 0 deletions doc/src/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Version 8.0 (TBD)
-----------------

#) Dropped support for Python 2.7.
#) Added support for starting up a database using a parameter file (PFILE),
as requested
(`issue 295 <https://github.com/oracle/python-cx_Oracle/issues/295>`__).


Version 7.3 (December 2019)
Expand Down
2 changes: 1 addition & 1 deletion odpi
25 changes: 18 additions & 7 deletions src/cxoConnection.c
Original file line number Diff line number Diff line change
Expand Up @@ -1707,15 +1707,16 @@ static PyObject *cxoConnection_shutdown(cxoConnection *conn, PyObject* args,
static PyObject *cxoConnection_startup(cxoConnection *conn, PyObject* args,
PyObject* keywordArgs)
{
static char *keywordList[] = { "force", "restrict", NULL };
PyObject *forceObj, *restrictObj;
static char *keywordList[] = { "force", "restrict", "pfile", NULL };
PyObject *forceObj, *restrictObj, *pfileObj;
cxoBuffer pfileBuffer;
dpiStartupMode mode;
int temp;

// parse arguments
forceObj = restrictObj = NULL;
if (!PyArg_ParseTupleAndKeywords(args, keywordArgs, "|OO", keywordList,
&forceObj, &restrictObj))
forceObj = restrictObj = pfileObj = NULL;
if (!PyArg_ParseTupleAndKeywords(args, keywordArgs, "|OOO", keywordList,
&forceObj, &restrictObj, &pfileObj))
return NULL;

// set the flags to use during startup
Expand All @@ -1729,12 +1730,22 @@ static PyObject *cxoConnection_startup(cxoConnection *conn, PyObject* args,
if (temp)
mode |= DPI_MODE_STARTUP_RESTRICT;

// check the pfile parameter
if (cxoBuffer_fromObject(&pfileBuffer, pfileObj,
conn->encodingInfo.encoding) < 0)
return NULL;

// make sure we are actually connected
if (cxoConnection_isConnected(conn) < 0)
if (cxoConnection_isConnected(conn) < 0) {
cxoBuffer_clear(&pfileBuffer);
return NULL;
}

// perform the work
if (dpiConn_startupDatabase(conn->handle, mode) < 0)
temp = dpiConn_startupDatabaseWithPfile(conn->handle, pfileBuffer.ptr,
pfileBuffer.size, mode);
cxoBuffer_clear(&pfileBuffer);
if (temp < 0)
return cxoError_raiseAndReturnNull();

Py_RETURN_NONE;
Expand Down

0 comments on commit 809ead0

Please sign in to comment.