void Blob::getData(tntdb::Blob& blob) const { log_debug("OCILobGetLength"); ub4 len; sword ret = OCILobGetLength(conn->getSvcCtxHandle(), conn->getErrorHandle(), lob, &len); conn->checkError(ret, "OCILobGetLength"); log_debug("len=" << len); log_debug("OCILobOpen"); ret = OCILobOpen(conn->getSvcCtxHandle(), conn->getErrorHandle(), lob, OCI_LOB_READONLY); conn->checkError(ret, "OCILobOpen"); char* buffer = blob.reserve(len, true); memset(buffer, '\0', len); ub4 amt = len; log_debug("OCILobRead"); ret = OCILobRead(conn->getSvcCtxHandle(), conn->getErrorHandle(), lob, &amt, 1, buffer, len, 0, 0, 0, SQLCS_IMPLICIT); conn->checkError(ret, "OCILobRead"); log_debug("OCILobClose"); ret = OCILobClose(conn->getSvcCtxHandle(), conn->getErrorHandle(), lob); conn->checkError(ret, "OCILobClose"); }
// После фетча - перекодируем date и выкачиваем blob.s int ora_fetch(database *db) { t_ora *o = db->h; int i; db_col *c; //printf("Here fetch!"); getch(); if (!o) return ora_error(db); //printf("Try real fetch!, OCI_NO_DATA=%d",OCI_NO_DATA); getch(); if (++o->rownum>1) i = OCIStmtFetch( o->stmt, o->errhp, (ub4) 1, (ub4) OCI_FETCH_NEXT, (ub4) OCI_DEFAULT); else i=db->err_code; // Первый фетч делает сам Оракл... //printf("Returns code=%d... Try real fetch!",i); getch(); db->err_code = 0; // Clear last error code... if (i == OCI_NO_DATA ) { ora_error(db); db->err_code = 0; return 0; } if (!ora_ok(i)) return ora_error(db); debugf(" ..ora10 start fetch ...\n"); for(i = db->out.count-1, c = db->out.cols;i>=0; i--, c++) { c->null=(((short)c->null)!=0); // Перекодировка флажков is_null.. //if(!c->null) if(c->type==dbDate) { unsigned char *D=(void*)c->dbvalue; if (c->null) *(double*)c->value=0; else *(double*)c->value=dt_encode((D[0]-100)*100+(D[1]-100), D[2],D[3],D[4]-1,D[5]-1,D[6]-1); } else if (c->type==dbBlob) // Вытягиваем блобу... { db_blob_handle *b=(void*)c->value; // Это указатель на "вытащенный блоб", его нужно установить на... int cnt_read = 0, offset = 0, blob_length = 0; debugf(" ..ora10 download blob to handle=%d\n",b); if (c->null) { b->len=0; continue;} if (OCI_SUCCESS!=OCILobGetLength (o->svchp,o->errhp,o->blob_read, &blob_length)) return ora_error(db); // - Сюда сливаются БЛОБЫ от SELCETA -- db->out.blob,&db->out.bsize,&db->out.blen if (blob_length +1 >= db->out.bsize) { int sz = blob_length+1024; // Новая длина void *p; // Еще место нужно... Realloc... debugf(" ..ora10 blob size=%d\n",sz); db->out.bsize = sz; p = realloc(db->out.blob,db->out.bsize); // Думаем что памяти достаточно if (!p) { sprintf(db->error,"vdb - no memory"); db->err_code = -2; return 0; } db->out.blob = p ; } debugf(" .. ora Ok - begin read\n"); if (OCI_SUCCESS!=OCILobRead(o->svchp,o->errhp,o->blob_read, // Интересно, такое бывает? &cnt_read, 1, db->out.blob, db->out.bsize, 0, 0 csid_csfrm)) return ora_error(db); debugf(" .. ora ReadDone, no error cnt_read=%d\n",cnt_read); db->out.blen = cnt_read+1; // Zero termanited на всякий случай... // Корректируем указатель, т.к. блоб мог реаллокнуться.. debugf(" .. ora Setb->data\n"); b->data = db->out.blob; // Все заточено под один БЛОБ b->len = cnt_read; b->data[b->len] = 0; // Терминирование нулем - вещь полезная... debugf(" ora OK flashed to bh=%d- do it again\n",b); } } debugf(" ..ora - FetchDone OK\n"); return 1; }
/* ** Push a value on top of the stack. */ static int pushvalue (lua_State *L, cur_data *cur, int i) { /* column index ranges from 1 to numcols */ /* C array index ranges from 0 to numcols-1 */ column_data *col = &(cur->cols[i-1]); if (col->null) { /* Oracle NULL => Lua nil */ lua_pushnil (L); return 1; } switch (col->type) { case SQLT_NUM: case SQLT_INT: case SQLT_FLT: lua_pushnumber (L, col->val.d); break; case SQLT_CHR: case SQLT_STR: case SQLT_VCS: case SQLT_AFC: case SQLT_AVC: lua_pushstring (L, (char *)(col->val.s)); break; case SQLT_CLOB: { ub4 lob_len; conn_data *conn; env_data *env; lua_rawgeti (L, LUA_REGISTRYINDEX, cur->conn); conn = lua_touserdata (L, -1); lua_rawgeti (L, LUA_REGISTRYINDEX, conn->env); env = lua_touserdata (L, -1); lua_pop (L, 2); ASSERT (L, OCILobGetLength (conn->svchp, cur->errhp, (OCILobLocator *)col->val.s, &lob_len), cur->errhp); if (lob_len > 0) { char *lob_buffer=malloc(lob_len); ub4 amount = lob_len; ASSERT(L, OCILobRead(conn->svchp, cur->errhp, (OCILobLocator *) col->val.s, &amount, (ub4) 1, (dvoid *) lob_buffer, (ub4) lob_len, (dvoid *)0, (sb4 (*) (dvoid *, CONST dvoid *, ub4, ub1)) 0, (ub2) 0, (ub1) SQLCS_IMPLICIT), cur->errhp); lua_pushlstring (L, lob_buffer, amount); free(lob_buffer); } else { lua_pushstring (L, ""); } break; } default: luaL_error (L, LUASQL_PREFIX"unexpected error"); } return 1; }
char* OWStatement::ReadCLob( OCILobLocator* phLocator ) { ub4 nSize = 0; ub4 nAmont = 0; char* pszBuffer = NULL; if( CheckError( OCILobGetLength ( poConnection->hSvcCtx, hError, phLocator, (ub4*) &nSize ), hError ) ) { return NULL; } nSize *= this->poConnection->nCharSize; pszBuffer = (char*) VSIMalloc( sizeof(char*) * nSize ); if( pszBuffer == NULL) { return NULL; } if( CheckError( OCILobRead( poConnection->hSvcCtx, hError, phLocator, (ub4*) &nAmont, (ub4) 1, (dvoid*) pszBuffer, (ub4) nSize, (dvoid*) NULL, NULL, (ub2) 0, (ub1) SQLCS_IMPLICIT ), hError ) ) { CPLFree( pszBuffer ); return NULL; } pszBuffer[nAmont] = '\0'; return pszBuffer; }
static size_t oci_blob_read(php_stream *stream, char *buf, size_t count) { struct oci_lob_self *self = (struct oci_lob_self*)stream->abstract; ub4 amt; sword r; amt = count; r = OCILobRead(self->S->H->svc, self->S->err, self->lob, &amt, self->offset, buf, count, NULL, NULL, 0, SQLCS_IMPLICIT); if (r != OCI_SUCCESS && r != OCI_NEED_DATA) { return (size_t)-1; } self->offset += amt; if (amt < count) { stream->eof = 1; } return amt; }
unsigned long OWStatement::ReadBlob( OCILobLocator* phLocator, void* pBuffer, int nSize ) { ub4 nAmont = (ub4) 0; if( CheckError( OCILobRead( poConnection->hSvcCtx, hError, phLocator, (ub4*) &nAmont, (ub4) 1, (dvoid*) pBuffer, (ub4) nSize, (dvoid *) 0, (OCICallbackLobRead) 0, (ub2) 0, (ub1) SQLCS_IMPLICIT), hError ) ) { return 0; } return nAmont; }
DB_ROW zbx_db_fetch(DB_RESULT result) { #if defined(HAVE_IBM_DB2) int i; #elif defined(HAVE_ORACLE) int i; sword rc; static char errbuf[512]; sb4 errcode; #endif if (NULL == result) return NULL; #if defined(HAVE_IBM_DB2) if (SUCCEED != zbx_ibm_db2_success(SQLFetch(result->hstmt))) /* e.g., SQL_NO_DATA_FOUND */ return NULL; for (i = 0; i < result->ncolumn; i++) { result->values[i] = (SQL_NULL_DATA == result->values_len[i] ? NULL : result->values_cli[i]); } return result->values; #elif defined(HAVE_MYSQL) return mysql_fetch_row(result); #elif defined(HAVE_ORACLE) if (OCI_NO_DATA == (rc = OCIStmtFetch2(result->stmthp, oracle.errhp, 1, OCI_FETCH_NEXT, 0, OCI_DEFAULT))) return NULL; for (i = 0; i < result->ncolumn; i++) { if (NULL != result->clobs[i]) { ub4 alloc, amount, amt = 0; ub1 csfrm; rc = OCILobGetLength(oracle.svchp, oracle.errhp, result->clobs[i], &amount); if (OCI_SUCCESS != rc) break; rc = OCILobCharSetForm(oracle.envhp, oracle.errhp, result->clobs[i], &csfrm); if (OCI_SUCCESS != rc) break; if (result->values_alloc[i] < (alloc = amount * 4 + 1)) { result->values_alloc[i] = alloc; result->values[i] = zbx_realloc(result->values[i], result->values_alloc[i]); } amt = amount; rc = OCILobRead(oracle.svchp, oracle.errhp, result->clobs[i], &amt, (ub4)1, (dvoid *)result->values[i], (ub4)(result->values_alloc[i] - 1), (dvoid *)NULL, (OCICallbackLobRead)NULL, (ub2)0, csfrm); if (OCI_SUCCESS != rc) zabbix_errlog(ERR_Z3006, rc, zbx_oci_error(rc)); result->values[i][amt] = '\0'; } } if (OCI_SUCCESS == rc) return result->values; if (OCI_SUCCESS != (rc = OCIErrorGet((dvoid *)oracle.errhp, (ub4)1, (text *)NULL, &errcode, (text *)errbuf, (ub4)sizeof(errbuf), OCI_HTYPE_ERROR))) { zabbix_errlog(ERR_Z3006, rc, zbx_oci_error(rc)); return NULL; } switch (errcode) { case 3113: /* ORA-03113: end-of-file on communication channel */ case 3114: /* ORA-03114: not connected to ORACLE */ zabbix_errlog(ERR_Z3006, errcode, errbuf); return NULL; } return result->values; #elif defined(HAVE_POSTGRESQL) /* free old data */ if (NULL != result->values) zbx_free(result->values); /* EOF */ if (result->cursor == result->row_num) return NULL; /* init result */ result->fld_num = PQnfields(result->pg_result); if (result->fld_num > 0) { int i; result->values = zbx_malloc(result->values, sizeof(char *) * result->fld_num); for (i = 0; i < result->fld_num; i++) { if (PQgetisnull(result->pg_result, result->cursor, i)) { result->values[i] = NULL; } else { result->values[i] = PQgetvalue(result->pg_result, result->cursor, i); if (PQftype(result->pg_result, i) == ZBX_PG_BYTEAOID) /* binary data type BYTEAOID */ zbx_pg_unescape_bytea((u_char *)result->values[i]); } } } result->cursor++; return result->values; #elif defined(HAVE_SQLITE3) /* EOF */ if (result->curow >= result->nrow) return NULL; if (NULL == result->data) return NULL; result->curow++; /* NOTE: first row == header row */ return &(result->data[result->curow * result->ncolumn]); #endif }
// Перекодировка is_null, in bind vars, закачка блобов и потом ora_exec int ora_exec(database *db) { t_ora *o = db->h; db_col *c; int i; if (!o) return ora_error(db); //if (!o->execnum) // { // o->execnum = 1; if (!ora_check_bind(db)) return 0; // Если первый раз - подвязать переменные... // } debugf(" ..ora - check bind ok!\n"); o->execnum++; // Номер запуска exec... for(i=0,c=db->in.cols;i<db->in.count;i++,c++) if ((c->dbflag & 2)==0) { // Все ин-параметры if(c->type==dbDate) // Перекодируем дату { unsigned char *D=(void*)c->dbvalue; double uval = *(double*)c->value; int Year,Month,Day,Hour,Min,Sec; if (!uval) c->null=ORA_NULL; else { c->null=0; dt_decode(uval,&Year,&Month,&Day,&Hour,&Min,&Sec); D[0]=100+Year/100; D[1]=Year%100+100; D[2]=Month; D[3]=Day; D[4]=Hour+1; D[5]=Min+1; D[6]=Sec+1; } //printf("ORA uval=%lf\n",uval); getch(); } else if (c->type == dbBlob && (!(c->dbflag & 2))) { // Закачиваем блобы... db_blob_handle *b = (void*) c->value; // Странно, но я храню блоб тута... int cnt_write = 0, offset = 0, code; cnt_write = b->len; // Сколько записывать... code = OCILobTrim(o->svchp, o->errhp, o->blob,0); //printf("2LobTrimmed data=%d len=%d olob=%d code=%d!\n",b->data,b->len,o->blob,code); c->null = ORA_NULL; if (b->data && b->len>0) { c->null = 0; if ( !ora_ok(db->err_code = OCILobWrite(o->svchp, o->errhp, o->blob, &cnt_write, 1, (dvoid *) b->data, (ub4) b->len, OCI_ONE_PIECE, 0, 0 csid_csfrm) )) { debugf("F**k! cant write blob err_code=%d ND=%d!\n",db->err_code,OCI_NEED_DATA); //if (db->err_code!=-2) // ZU? return ora_error(db); } debugf("vora- ok write %d bytes of lob\n",b->len); } } } debugf(" ..ora - begin OCIStmtExecute stmt=%p!\n",o->stmt); db->err_code = OCIStmtExecute(o->svchp, o->stmt, o->errhp, (ub4) 1, (ub4) 0, (CONST OCISnapshot *) NULL, (OCISnapshot *) NULL,OCI_DEFAULT); debugf("ORARES on exec = %d\n",db->err_code); if (db->err_code == OCI_NO_DATA) return 1; // ExecOK, данные не сфетчились... if (!ora_ok(db->err_code)) return ora_error(db); // А это уже ошибка... debugf("ORA - decode out\n"); //return 1; // Далее - идет обратная декодировка. Пока не отлаживаем for(i = 0, c = db->in.cols;i<db->in.count; i++, c++) if (c->dbflag & 2) { // Смотрим на аут-параметры int is_null; debugf("----ORA --- chek OUT HERE=%s\n",c->name); //printf("NULL=%d on %s\n",*(short*)c->null,c->name); //is_null = c->null && ((*(short*)(c->null)) ); //if (c->null) *(int*)(c->null) = is_null; //printf("Check in var=%s is_null = %d val=%d\n",c->name,is_null,*(int*)c->value); //if (is_null) continue; if ( c->type==dbDate) { unsigned char *D=(void*)c->dbvalue; if (c->null) *(double*)c->value=0; else *(double*)c->value=dt_encode((D[0]-100)*100+(D[1]-100), D[2],D[3],D[4]-1,D[5]-1,D[6]-1); } else if (c->type==dbBlob) { // Вытягиваем блобу... db_blob_handle *b=(void*)c->value; // Это указатель на "вытащенный блоб", его нужно установить на... int cnt_read = 0, offset = 0, blob_length = 0; debugf("ORA --- chek out blob null==%d\n",c->null); if (c->null) {b->len=0; continue;} /// OCILobLock ??? //db->err_code = OCILobOpen ( o->svchp, o->errhp, o->blob_read, OCI_LOB_READONLY ); //printf("Lob opened error = %d\n", db->err_code); //if (db->out.size<1) { // db->out.data = realloc(db->out.data,1); // db->out.size = 1; // } //OCILobRead(o->svchp,o->errhp,o->blob_read, // Интересно, такое бывает? //&cnt_read, 1, db->out.blob, 1 , 0, 0); // Just for FUN ... // printf("Read = %d bytes\n", cnt_read ); if (!ora_ok(db->err_code=OCILobGetLength (o->svchp,o->errhp,o->blob_read, &blob_length))) { debugf("Fail get blob length code=%d result=%d!\n",db->err_code,blob_length); blob_length = 100* 1024 ; // return 1; // ZUZUKA ora_error(db); } //printf("Getting out blob len = %d..\n",blob_length); // - Сюда сливаются БЛОБЫ от SELCETA -- db->out.blob,&db->out.bsize,&db->out.blen if (blob_length +1 >= db->out.bsize) { // Еще место нужно... Realloc... db->out.bsize = blob_length+1024; // Новая длина db->out.blob = realloc(db->out.blob,db->out.bsize); // Думаем что памяти достаточно } if (!ora_ok(db->err_code=OCILobRead(o->svchp,o->errhp,o->blob_read, // Интересно, такое бывает? &cnt_read, 1, db->out.blob, db->out.bsize, 0, 0 csid_csfrm))) { //printf("Fail read blob err=%d!\n"); return ora_error(db); } //OCILobTrim(o->svchp, o->errhp, o->blob_read,0); db->out.blen = cnt_read+1; // Zero termanited на всякий случай... //printf("Read blob len = %d bh=%d\n",cnt_read,b); // Корректируем указатель, т.к. блоб мог реаллокнуться.. b->data = db->out.blob; // Все заточено под один БЛОБ b->len = cnt_read; b->data[b->len] = 0; // Терминирование нулем - вещь полезная... } } return 1; }
int main(int argc, char *argv[]) { ub1 *LobReadBuf=NULL; ub4 *KeysValueBuf=NULL; OCIStmt *stmtsellochp = 0; OCIBind *bndv1 = 0; OCIDefine *defv1 = 0; OCILobLocator *lobloc=0; static text *stmt_sellocstr = (text *)"SELECT DOCUMENT FROM FOO WHERE PKEY = :MYPKEY"; int i, j, q; /* loop variables */ sword orc; /* Return value */ ub4 LobSize = 0; /* Size of Lob to be selected */ ub4 Iter=1; /* How many times to repeat before exiting */ ub4 NumRows=0; /* Num of Rows to select in each iteration */ ub4 trace_flag=0; /* 0 is default, means no sql_trace */ int UserNum=1; /* used in multiuser tests */ ub4 KeyStartValue=0; /* primary key generator, derived from USERKEYRANGE * UserNum */ ub4 KeyMaxValue=0; /* derived from StartValue + NumRows*Iter */ sb8 KeyValue=0; /* random number between StartValue and MaxValue */ int LobType; /* to check Lobtype = BASICFILE or SECUREFILE */ int ReqTime; /* argument to GetDbTime function ReqTime=1 elasped, ReqTime=0 cpu time */ ub4 StartTimeTot; ub4 StartTime; ub4 StartCpu; ub4 EndTimeTot; ub4 EndTime; ub4 EndCpu; ub4 ElapsedTimeTot; ub4 ElapsedTime; ub4 ElapsedCpu; ub4 AvgElapsed; ub4 AvgCpu; float AvgRate; if (argc <= 5) { printf("Usage: %s <uid> <pwd> <LobSize(bytes)> <NumRows> <Iteration> <UserNum> trace_flag(1|0>\n\r", argv[0]); exit(-1); } /* process command line args */ LobSize=atoi(argv[3]); NumRows=atoi(argv[4]); Iter=atoi(argv[5]); if (argc > 6 ) UserNum=atoi(argv[6]); /* Used in multiuser run, to make unique pkeys */ if (argc > 7 ) trace_flag=atoi(argv[7]); /* Allocate OCI handles */ if (AllocateHandles(0)) { printf("AllocateHandles failed \n"); exit(-1); } /* Login using argv[1] and argv[2] */ if ( (ConnectToDb(argv[1], argv[2])) != OCI_SUCCESS ) { printf("ConnectToDb failed \n"); CheckErr(errhp, orc); exit(-1); } srand48(LobSize); printf("Using LobSize=%d bytes, NumRows=%d, calculated total memorysize=%d bytes\r\n", LobSize, NumRows, LobSize*NumRows); if((LobSize==0)||(NumRows<1)) { printf("Parameter error\r\n"); exit(-1); } /* Memory allocation section */ if ( (LobReadBuf=(ub1 *)malloc(LobSize)) == NULL ) { printf("Error allocating memory for LobReadBuf\r\n"); exit(-1); } /* Initialize allocated memory and setup Read buffer as 0000000 */ memset(LobReadBuf,0,LobSize); /* setup Lob read buffer as 0 */ KeyStartValue=UserNum*USERKEYRANGE; /* Value is set as per UserNum */ KeyMaxValue = KeyStartValue + (NumRows*Iter); /* SQL_TRACE section */ if (trace_flag == 1) { printf("Begin tracing...\n"); TurnOnSqlTrace(); } printf("Trying to Select %d Rows with Lob size of %d Bytes)\r\n", NumRows, LobSize); printf("Selecting data.....please wait\r\n"); /* allocate a statement handle for SELECT OF LOB LOCATOR and prepare it */ CheckErr(errhp, OCIHandleAlloc(envhp, (dvoid **) &stmtsellochp, OCI_HTYPE_STMT, (size_t) 0, (dvoid **) 0)); CheckErr(errhp, OCIStmtPrepare(stmtsellochp, errhp, (CONST text *) stmt_sellocstr, strlen((char *) stmt_sellocstr), OCI_NTV_SYNTAX, OCI_DEFAULT)); /* Allocate Lob Locator descriptor */ CheckErr(errhp, OCIDescriptorAlloc(envhp, (dvoid **)&lobloc, (ub4) OCI_DTYPE_LOB, (size_t) 0, (dvoid **) 0)) ; CheckErr(errhp, OCIBindByName(stmtsellochp, (OCIBind **) &bndv1, errhp, (text *)":MYPKEY", (sb4) 7, &KeyValue, (sb4) sizeof(ub4), SQLT_INT, (dvoid *) 0, (ub2 *) 0, (ub2 *) 0, (ub4) 0, (ub4 *) 0, OCI_DEFAULT)); CheckErr(errhp, OCIDefineByPos (stmtsellochp, (OCIDefine **) &defv1, errhp, 1, &lobloc, 0 , SQLT_BLOB, (dvoid *)0, (ub2 *)0, (ub2 *)0, OCI_DEFAULT)); /* Allocate and Prepare statement to get cpu and elapsed time using dbms_utility */ PrepareDbTime(); for (q = 0 ; q < Iter ; q ++ ) { StartTime = GetDbTime(1); if ( q == 1) { /* Discard q=0 as warm up */ StartTimeTot = StartTime; StartCpu = GetDbTime(0); } for (i=0; i < NumRows; i++) { KeyValue=(lrand48 () % (KeyMaxValue-KeyStartValue)) + KeyStartValue ; CheckErr(errhp, OCIStmtExecute(svchp, stmtsellochp, errhp, (ub4) 1, (ub4) 0, (CONST OCISnapshot *) 0, (OCISnapshot *) 0, OCI_DEFAULT)); /* CheckErr(errhp, OCILobGetLength(svchp, errhp, lobloc, &LobReadLen)); printf ("Length of the lob to read %d \n", LobReadLen); */ /* Got the Locator, now start Reading data using it */ CheckErr(errhp, OCILobRead(svchp, errhp, lobloc, &LobSize, 1, &LobReadBuf[0], (ub4) LobSize, (dvoid *)0, NULL, (ub2) 0, (ub1) SQLCS_IMPLICIT)); } EndTime = GetDbTime(1); ElapsedTime = (EndTime - StartTime)*10 ; printf("Elapsed time for Iter %d Select (%d rows) in msecs: %ld\n", q+1, NumRows, ElapsedTime); } /* end of Iteration 'for' loop */ EndTimeTot = EndTime; ElapsedTimeTot = (EndTimeTot-StartTimeTot)*10; EndCpu = GetDbTime(0); /* cpu time is centisecond, x10 to report in msec, not accurate, doing it for consistency */ ElapsedCpu = (EndCpu - StartCpu) * 10; printf ("--------------------------------------------------------------------------- \n"); printf("Total Elapsed time for select (%d rows) in msecs (excluding Iter 1) : %ld\n", (NumRows*(Iter-1)), ElapsedTimeTot); if (Iter > 1) { AvgElapsed=ElapsedTimeTot/(Iter-1); AvgCpu=ElapsedCpu/(Iter-1); printf("Avg Elapsed time for a Iteration (%d rows) in msecs (excluding Iter 1) : %ld\n", NumRows, AvgElapsed ); printf("Avg CPU time for a Iteration (%d rows) in msecs (excluding Iter 1) : %ld\n", NumRows, AvgCpu ); /* x1000 to report in seconds from mseconds */ AvgRate=((float)LobSize*(float)NumRows*1000)/((float)AvgElapsed*1024*1024); printf("Avg Read Rate for (%d rows) (excluding Iter 1) : %0.2f (Mb/sec)\n", NumRows, AvgRate); } LobType=CheckLobType(); if (LobType == 1) printf ("SECUREFILE Lob Read Test Finished (Using OCILobRead API)\n"); else printf ("BASICFILE Lob Read Test Finished (Using OCILobRead API)\n"); printf("Selected LobSize=%d bytes, NumRows=%d, Iter=%d \r\n", LobSize, NumRows, Iter ); printf ("--------------------------------------------------------------------------- \n"); return(0); } /* end of Main */
sword status; if (var->lobVar->isFile) { Py_BEGIN_ALLOW_THREADS status = OCILobFileOpen(var->lobVar->connection->handle, var->lobVar->environment->errorHandle, var->lobVar->data[var->pos], OCI_FILE_READONLY); Py_END_ALLOW_THREADS if (Environment_CheckForError(var->lobVar->environment, status, "ExternalLobVar_FileOpen()") < 0) return -1; } Py_BEGIN_ALLOW_THREADS status = OCILobRead(var->lobVar->connection->handle, var->lobVar->environment->errorHandle, var->lobVar->data[var->pos], length, offset, buffer, bufferSize, NULL, NULL, 0, var->lobVar->type->charsetForm); Py_END_ALLOW_THREADS if (Environment_CheckForError(var->lobVar->environment, status, "ExternalLobVar_LobRead()") < 0) { OCILobFileClose(var->lobVar->connection->handle, var->lobVar->environment->errorHandle, var->lobVar->data[var->pos]); return -1; } if (var->lobVar->isFile) { Py_BEGIN_ALLOW_THREADS status = OCILobFileClose(var->lobVar->connection->handle, var->lobVar->environment->errorHandle, var->lobVar->data[var->pos]);