Back to index

php5  5.3.10
Classes | Defines | Functions | Variables
php_pdo_oci_int.h File Reference
#include <oci.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  pdo_oci_error_info
struct  pdo_oci_db_handle
struct  pdo_oci_column
struct  pdo_oci_stmt
struct  pdo_oci_bound_param

Defines

#define oci_init_error(w)   _oci_error(H->err, dbh, NULL, w, H->last_err, TRUE, __FILE__, __LINE__ TSRMLS_CC)
#define oci_drv_error(w)   _oci_error(H->err, dbh, NULL, w, H->last_err, FALSE, __FILE__, __LINE__ TSRMLS_CC)
#define oci_stmt_error(w)   _oci_error(S->err, stmt->dbh, stmt, w, S->last_err, FALSE, __FILE__, __LINE__ TSRMLS_CC)
#define PDO_OCI_PREFETCH_DEFAULT   100
#define PDO_OCI_PREFETCH_ROWSIZE   1024

Functions

ub4 _oci_error (OCIError *err, pdo_dbh_t *dbh, pdo_stmt_t *stmt, char *what, sword status, int isinit, const char *file, int line TSRMLS_DC)

Variables

const ub4 PDO_OCI_INIT_MODE
pdo_driver_t pdo_oci_driver
OCIEnv * pdo_oci_Env

Class Documentation

struct pdo_oci_error_info

Definition at line 23 of file php_pdo_oci_int.h.

Class Members
sb4 errcode
char * errmsg
const char * file
int line
struct pdo_oci_db_handle

Definition at line 31 of file php_pdo_oci_int.h.

Collaboration diagram for pdo_oci_db_handle:
Class Members
unsigned _reserved:31
unsigned attached:1
ub2 charset
pdo_oci_error_info einfo
OCIEnv * env
OCIError * err
sword last_err
OCIServer * server
OCISession * session
OCISvcCtx * svc
struct pdo_oci_column

Definition at line 47 of file php_pdo_oci_int.h.

Class Members
char * data
ub4 datalen
OCIDefine * def
ub2 dtype
ub2 fetched_len
sb2 indicator
ub2 retcode
struct pdo_oci_stmt

Definition at line 60 of file php_pdo_oci_int.h.

Collaboration diagram for pdo_oci_stmt:
Class Members
pdo_oci_column * cols
pdo_oci_error_info einfo
OCIError * err
ub4 exec_type
pdo_oci_db_handle * H
unsigned int have_blobs:1
sword last_err
OCIStmt * stmt
ub2 stmt_type
struct pdo_oci_bound_param

Definition at line 72 of file php_pdo_oci_int.h.

Class Members
ub4 actual_len
OCIBind * bind
sb2 indicator
sb2 oci_type
ub2 retcode
dvoid * thing
unsigned used_for_output

Define Documentation

#define oci_drv_error (   w)    _oci_error(H->err, dbh, NULL, w, H->last_err, FALSE, __FILE__, __LINE__ TSRMLS_CC)

Definition at line 91 of file php_pdo_oci_int.h.

#define oci_init_error (   w)    _oci_error(H->err, dbh, NULL, w, H->last_err, TRUE, __FILE__, __LINE__ TSRMLS_CC)

Definition at line 90 of file php_pdo_oci_int.h.

#define oci_stmt_error (   w)    _oci_error(S->err, stmt->dbh, stmt, w, S->last_err, FALSE, __FILE__, __LINE__ TSRMLS_CC)

Definition at line 92 of file php_pdo_oci_int.h.

#define PDO_OCI_PREFETCH_DEFAULT   100

Definition at line 97 of file php_pdo_oci_int.h.

#define PDO_OCI_PREFETCH_ROWSIZE   1024

Definition at line 100 of file php_pdo_oci_int.h.


Function Documentation

ub4 _oci_error ( OCIError *  err,
pdo_dbh_t *  dbh,
pdo_stmt_t *  stmt,
char *  what,
sword  status,
int  isinit,
const char *  file,
int line  TSRMLS_DC 
)

Definition at line 60 of file oci_driver.c.

{
       text errbuf[1024] = "<<Unknown>>";
       char tmp_buf[2048];
       pdo_oci_db_handle *H = (pdo_oci_db_handle *)dbh->driver_data;
       pdo_oci_error_info *einfo;
       pdo_oci_stmt *S = NULL;
       pdo_error_type *pdo_err = &dbh->error_code;

       if (stmt) {
              S = (pdo_oci_stmt*)stmt->driver_data;
              einfo = &S->einfo;
              pdo_err = &stmt->error_code;
       }
       else {
              einfo = &H->einfo;
       }

       if (einfo->errmsg) {
              pefree(einfo->errmsg, dbh->is_persistent);
       }

       einfo->errmsg = NULL;
       einfo->errcode = 0;
       einfo->file = file;
       einfo->line = line;

       if (isinit) { /* Initialization error */
              strcpy(*pdo_err, "HY000");
              slprintf(tmp_buf, sizeof(tmp_buf), "%s (%s:%d)", what, file, line);
              einfo->errmsg = pestrdup(tmp_buf, dbh->is_persistent);
       }
       else {
              switch (status) {
                     case OCI_SUCCESS:
                            strcpy(*pdo_err, "00000");
                            break;
                     case OCI_ERROR:
                            OCIErrorGet(err, (ub4)1, NULL, &einfo->errcode, errbuf, (ub4)sizeof(errbuf), OCI_HTYPE_ERROR);
                            slprintf(tmp_buf, sizeof(tmp_buf), "%s: %s (%s:%d)", what, errbuf, file, line);
                            einfo->errmsg = pestrdup(tmp_buf, dbh->is_persistent);
                            break;
                     case OCI_SUCCESS_WITH_INFO:
                            OCIErrorGet(err, (ub4)1, NULL, &einfo->errcode, errbuf, (ub4)sizeof(errbuf), OCI_HTYPE_ERROR);
                            slprintf(tmp_buf, sizeof(tmp_buf), "%s: OCI_SUCCESS_WITH_INFO: %s (%s:%d)", what, errbuf, file, line);
                            einfo->errmsg = pestrdup(tmp_buf, dbh->is_persistent);
                            break;
                     case OCI_NEED_DATA:
                            slprintf(tmp_buf, sizeof(tmp_buf), "%s: OCI_NEED_DATA (%s:%d)", what, file, line);
                            einfo->errmsg = pestrdup(tmp_buf, dbh->is_persistent);
                            break;
                     case OCI_NO_DATA:
                            slprintf(tmp_buf, sizeof(tmp_buf), "%s: OCI_NO_DATA (%s:%d)", what, file, line);
                            einfo->errmsg = pestrdup(tmp_buf, dbh->is_persistent);
                            break;
                     case OCI_INVALID_HANDLE:
                            slprintf(tmp_buf, sizeof(tmp_buf), "%s: OCI_INVALID_HANDLE (%s:%d)", what, file, line);
                            einfo->errmsg = pestrdup(tmp_buf, dbh->is_persistent);
                            break;
                     case OCI_STILL_EXECUTING:
                            slprintf(tmp_buf, sizeof(tmp_buf), "%s: OCI_STILL_EXECUTING (%s:%d)", what, file, line);
                            einfo->errmsg = pestrdup(tmp_buf, dbh->is_persistent);
                            break;
                     case OCI_CONTINUE:
                            slprintf(tmp_buf, sizeof(tmp_buf), "%s: OCI_CONTINUE (%s:%d)", what, file, line);
                            einfo->errmsg = pestrdup(tmp_buf, dbh->is_persistent);
                            break;
              }

              if (einfo->errcode) {
                     switch (einfo->errcode) {
                            case 1013:    /* user requested cancel of current operation */
                                   zend_bailout();
                                   break;

#if 0
                            case 955:     /* ORA-00955: name is already used by an existing object */
                                   *pdo_err = PDO_ERR_ALREADY_EXISTS;
                                   break;
#endif

                            case 12154:   /* ORA-12154: TNS:could not resolve service name */
                                   strcpy(*pdo_err, "42S02");
                                   break;
                            
                            case   22:    /* ORA-00022: invalid session id */
                            case   378:
                            case   602:
                            case   603:
                            case   604:
                            case   609:
                            case  1012:   /* ORA-01012: */
                            case  1033:
                            case  1041:
                            case  1043:
                            case  1089:
                            case  1090:
                            case  1092:
                            case  3113:   /* ORA-03133: end of file on communication channel */
                            case  3114:
                            case  3122:
                            case  3135:
                            case 12153:
                            case 27146:
                            case 28511:
                                   /* consider the connection closed */
                                   dbh->is_closed = 1;
                                   H->attached = 0;
                                   strcpy(*pdo_err, "01002"); /* FIXME */
                                   break;

                            default:
                                   strcpy(*pdo_err, "HY000");
                     }
              }

              if (stmt) {
                     /* always propogate the error code back up to the dbh,
                      * so that we can catch the error information when execute
                      * is called via query.  See Bug #33707 */
                     if (H->einfo.errmsg) {
                            pefree(H->einfo.errmsg, dbh->is_persistent);
                     }
                     H->einfo = *einfo;
                     H->einfo.errmsg = einfo->errmsg ? pestrdup(einfo->errmsg, dbh->is_persistent) : NULL;
                     strcpy(dbh->error_code, stmt->error_code);
              }
       }

       /* little mini hack so that we can use this code from the dbh ctor */
       if (!dbh->methods) {
              zend_throw_exception_ex(php_pdo_get_exception(), einfo->errcode TSRMLS_CC, "SQLSTATE[%s]: %s", *pdo_err, einfo->errmsg);
       }

       return einfo->errcode;
}

Here is the call graph for this function:


Variable Documentation

Definition at line 714 of file oci_driver.c.

OCIEnv* pdo_oci_Env

Definition at line 87 of file pdo_oci.c.

const ub4 PDO_OCI_INIT_MODE

Definition at line 71 of file pdo_oci.c.