19 #include "SqliteSymbian.h" //sqlite3SymbianLastOsError() |
19 #include "SqliteSymbian.h" //sqlite3SymbianLastOsError() |
20 #include "sqlite3.h" |
20 #include "sqlite3.h" |
21 #include "SqlSrvStatement.h" |
21 #include "SqlSrvStatement.h" |
22 #include "SqlBufIterator.h" //TSqlBufRIterator |
22 #include "SqlBufIterator.h" //TSqlBufRIterator |
23 #include "SqlSrvResourceProfiler.h" |
23 #include "SqlSrvResourceProfiler.h" |
24 #include "UTraceSql.h" |
24 #include "OstTraceDefinitions.h" |
|
25 #ifdef OST_TRACE_COMPILER_IN_USE |
|
26 #include "SqlSrvStatementTraces.h" |
|
27 #endif |
|
28 #include "SqlTraceDef.h" |
|
29 |
25 ////////////////////////////////////////////////////////////////////////////////////////////////////// |
30 ////////////////////////////////////////////////////////////////////////////////////////////////////// |
26 ///////////////////////////// local const data //////////////////////////////////////////// |
31 ///////////////////////////// local const data //////////////////////////////////////////// |
27 ////////////////////////////////////////////////////////////////////////////////////////////////////// |
32 ////////////////////////////////////////////////////////////////////////////////////////////////////// |
28 |
33 |
29 //This is the name prefix which will be given to the nameless parameters. |
34 //This is the name prefix which will be given to the nameless parameters. |
135 |
140 |
136 @panic SqlDb 4 In _DEBUG mode if aSqlStmt is not zero-terminated string. |
141 @panic SqlDb 4 In _DEBUG mode if aSqlStmt is not zero-terminated string. |
137 */ |
142 */ |
138 CSqlSrvStatement* CSqlSrvStatement::NewLC(sqlite3* aDbHandle, const TDesC16& aSqlStmt, TInt& aColumnCount, TInt& aParamCount) |
143 CSqlSrvStatement* CSqlSrvStatement::NewLC(sqlite3* aDbHandle, const TDesC16& aSqlStmt, TInt& aColumnCount, TInt& aParamCount) |
139 { |
144 { |
140 __SQLASSERT(aSqlStmt.Length() > 0 ? (TInt)aSqlStmt[aSqlStmt.Length() - 1] == 0 : ETrue, ESqlPanicBadArgument); |
145 __SQLTRACE_INTERNALSEXPR(TPtrC sqlprnptr(aSqlStmt.Left(aSqlStmt.Length() - 1))); |
|
146 SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, CSQLSRVSTATEMENT_NEWLC_ENTRY, "Entry;0;CSqlSrvStatement::NewLC-16;aDbHandle=0x%X;aSqlStmt=%S", (TUint)aDbHandle, __SQLPRNSTR(sqlprnptr))); |
|
147 __ASSERT_DEBUG(aSqlStmt.Length() > 0 ? (TInt)aSqlStmt[aSqlStmt.Length() - 1] == 0 : ETrue, __SQLPANIC2(ESqlPanicBadArgument)); |
141 |
148 |
142 CSqlSrvStatement* self = new (ELeave) CSqlSrvStatement; |
149 CSqlSrvStatement* self = new (ELeave) CSqlSrvStatement; |
143 CleanupStack::PushL(self); |
150 CleanupStack::PushL(self); |
144 self->ConstructL(aDbHandle, aSqlStmt); |
151 self->ConstructL(aDbHandle, aSqlStmt); |
145 SYMBIAN_TRACE_SQL_EVENTS_ONLY(UTF::Printf(UTF::TTraceContext(UTF::EInternals), KSrvStmtCreated, self)); |
|
146 aColumnCount = self->iColumnCount; |
152 aColumnCount = self->iColumnCount; |
147 aParamCount = self->iParamCount; |
153 aParamCount = self->iParamCount; |
|
154 SQL_TRACE_INTERNALS(OstTraceExt4(TRACE_INTERNALS, CSQLSRVSTATEMENT_NEWLC_EXIT, "Exit;0x%X;CSqlSrvStatement::NewLC-16;iStmtHandle=0x%X;aColumnCount=%d;aParamCount=%d", (TUint)self, (TUint)self->iStmtHandle, aColumnCount, aParamCount)); |
148 return self; |
155 return self; |
149 } |
156 } |
150 |
157 |
151 /** |
158 /** |
152 Creates a new CSqlSrvStatement instance. |
159 Creates a new CSqlSrvStatement instance. |
167 |
174 |
168 @panic SqlDb 4 In _DEBUG mode if aSqlStmt is not zero-terminated string. |
175 @panic SqlDb 4 In _DEBUG mode if aSqlStmt is not zero-terminated string. |
169 */ |
176 */ |
170 CSqlSrvStatement* CSqlSrvStatement::NewLC(sqlite3* aDbHandle, const TDesC8& aSqlStmt, TInt& aColumnCount, TInt& aParamCount) |
177 CSqlSrvStatement* CSqlSrvStatement::NewLC(sqlite3* aDbHandle, const TDesC8& aSqlStmt, TInt& aColumnCount, TInt& aParamCount) |
171 { |
178 { |
172 __SQLASSERT(aSqlStmt.Length() > 0 ? (TInt)aSqlStmt[aSqlStmt.Length() - 1] == 0 : ETrue, ESqlPanicBadArgument); |
179 __SQLTRACE_INTERNALSEXPR(TPtrC8 sqlprnptr(aSqlStmt.Left(aSqlStmt.Length() - 1))); |
|
180 __SQLTRACE_INTERNALSVAR(TBuf<100> des16prnbuf); |
|
181 SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, CSQLSRVSTATEMENT_NEWLC_ENTRY2, "Entry;0;CSqlSrvStatement::NewLC-8;aDbHandle=0x%X;aSqlStmt=%s", (TUint)aDbHandle, __SQLPRNSTR8(sqlprnptr, des16prnbuf))); |
|
182 __ASSERT_DEBUG(aSqlStmt.Length() > 0 ? (TInt)aSqlStmt[aSqlStmt.Length() - 1] == 0 : ETrue, __SQLPANIC2(ESqlPanicBadArgument)); |
173 |
183 |
174 CSqlSrvStatement* self = new (ELeave) CSqlSrvStatement; |
184 CSqlSrvStatement* self = new (ELeave) CSqlSrvStatement; |
175 CleanupStack::PushL(self); |
185 CleanupStack::PushL(self); |
176 self->ConstructL(aDbHandle, aSqlStmt); |
186 self->ConstructL(aDbHandle, aSqlStmt); |
177 SYMBIAN_TRACE_SQL_EVENTS_ONLY(UTF::Printf(UTF::TTraceContext(UTF::EInternals), KSrvStmtCreated, self)); |
|
178 aColumnCount = self->iColumnCount; |
187 aColumnCount = self->iColumnCount; |
179 aParamCount = self->iParamCount; |
188 aParamCount = self->iParamCount; |
|
189 SQL_TRACE_INTERNALS(OstTraceExt4(TRACE_INTERNALS, CSQLSRVSTATEMENT_NEWLC_EXIT2, "Exit;0x%X;CSqlSrvStatement::NewLC-8;iStmtHandle=0x%X;aColumnCount=%d;aParamCount=%d", (TUint)self, (TUint)self->iStmtHandle, aColumnCount, aParamCount)); |
180 return self; |
190 return self; |
181 } |
191 } |
182 |
192 |
183 /** |
193 /** |
184 Destroys the allocated by CSqlSrvStatement instance memory and other resources. |
194 Destroys the allocated by CSqlSrvStatement instance memory and other resources. |
185 */ |
195 */ |
186 CSqlSrvStatement::~CSqlSrvStatement() |
196 CSqlSrvStatement::~CSqlSrvStatement() |
187 { |
197 { |
|
198 SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, CSQLSRVSTATEMENT_CSQLSRVSTATEMENT2_ENTRY, "Entry;0x%X;CSqlSrvStatement::~CSqlSrvStatement;iStmtHandle=0x%X", (TUint)this, (TUint)iStmtHandle)); |
188 DestroyParamBufArray(); |
199 DestroyParamBufArray(); |
189 iBufFlat.Close(); |
200 iBufFlat.Close(); |
190 if(iStmtHandle) |
201 if(iStmtHandle) |
191 { |
202 { |
192 #ifdef SYMBIAN_TRACE_SQL_EVENTS |
203 #ifdef SYMBIAN_USE_SQLITE_VERSION_3_6_4 |
193 TInt scanCount = sqlite3_stmt_status(iStmtHandle, SQLITE_STMTSTATUS_FULLSCAN_STEP, ETrue); |
204 __SQLTRACE_INTERNALSEXPR(TInt scanCount = sqlite3_stmt_status(iStmtHandle, SQLITE_STMTSTATUS_FULLSCAN_STEP, ETrue)); |
194 TInt sortCount = sqlite3_stmt_status(iStmtHandle, SQLITE_STMTSTATUS_SORT, ETrue); |
205 __SQLTRACE_INTERNALSEXPR(TInt sortCount = sqlite3_stmt_status(iStmtHandle, SQLITE_STMTSTATUS_SORT, ETrue)); |
195 SYMBIAN_TRACE_SQL_EVENTS_ONLY(UTF::Printf(UTF::TTraceContext(UTF::EInternals), KSrvStmtStatus, this, scanCount, sortCount)); |
206 SQL_TRACE_INTERNALS(OstTraceExt3(TRACE_INTERNALS, CSQLSRVSTATEMENT_CSQLSRVSTATEMENT2, "0x%X;CSqlSrvStatement::~CSqlSrvStatement;scan count=%d;sort count=%d", (TUint)this, scanCount, sortCount)); |
196 #endif |
207 #endif |
197 (void)sqlite3_finalize(iStmtHandle); |
208 (void)sqlite3_finalize(iStmtHandle); |
198 } |
209 } |
|
210 SQL_TRACE_INTERNALS(OstTrace1(TRACE_INTERNALS, CSQLSRVSTATEMENT_CSQLSRVSTATEMENT2_EXIT, "Exit;0x%X;CSqlSrvStatement::~CSqlSrvStatement", (TUint)this)); |
199 } |
211 } |
200 |
212 |
201 /** |
213 /** |
202 Sets SQL statement parameter values. |
214 Sets SQL statement parameter values. |
203 |
215 |
391 } |
403 } |
392 else |
404 else |
393 {//sqlite3_column_bytes16() already allocated the needed memory if a UTF8->UTF16 conversion |
405 {//sqlite3_column_bytes16() already allocated the needed memory if a UTF8->UTF16 conversion |
394 //had to be performed. The sqlite3_column_text16() on the next line is guaranteed to succeed. |
406 //had to be performed. The sqlite3_column_text16() on the next line is guaranteed to succeed. |
395 const TUint16* text = reinterpret_cast <const TUint16*> (sqlite3_column_text16(iStmtHandle, colIdx)); |
407 const TUint16* text = reinterpret_cast <const TUint16*> (sqlite3_column_text16(iStmtHandle, colIdx)); |
396 __SQLASSERT(text != NULL, ESqlPanicInternalError); |
408 __ASSERT_DEBUG(text != NULL, __SQLPANIC(ESqlPanicInternalError)); |
397 __SQLLEAVE_IF_ERROR(it.SetText(TPtrC16(text, charLength))); |
409 __SQLLEAVE_IF_ERROR(it.SetText(TPtrC16(text, charLength))); |
398 } |
410 } |
399 } |
411 } |
400 break; |
412 break; |
401 case SQLITE_BLOB: |
413 case SQLITE_BLOB: |
435 |
447 |
436 @panic SqlDb 2 In _DEBUG mode. Invalid (not created) CSqlSrvStatement object. |
448 @panic SqlDb 2 In _DEBUG mode. Invalid (not created) CSqlSrvStatement object. |
437 */ |
449 */ |
438 TInt CSqlSrvStatement::ColumnSource(TInt aColumnIndex, TPtrC8& aColumnSource) const |
450 TInt CSqlSrvStatement::ColumnSource(TInt aColumnIndex, TPtrC8& aColumnSource) const |
439 { |
451 { |
440 __SQLASSERT(iStmtHandle != NULL, ESqlPanicInvalidObj); |
452 __ASSERT_DEBUG(iStmtHandle != NULL, __SQLPANIC(ESqlPanicInvalidObj)); |
441 TInt colType = sqlite3_column_type(iStmtHandle, aColumnIndex); |
453 TInt colType = sqlite3_column_type(iStmtHandle, aColumnIndex); |
442 if(colType == SQLITE_TEXT) |
454 if(colType == SQLITE_TEXT) |
443 {//Since the first called function after the Next() operation is always CSqlSrvStatement::ColumnValuesL(), then |
455 {//Since the first called function after the Next() operation is always CSqlSrvStatement::ColumnValuesL(), then |
444 //sqlite3_column_bytes16() (called from ColumnValuesL()) already allocated the needed memory if a UTF8->UTF16 |
456 //sqlite3_column_bytes16() (called from ColumnValuesL()) already allocated the needed memory if a UTF8->UTF16 |
445 //conversion had to be performed. The sqlite3_column_text16() on the next line is guaranteed to succeed. |
457 //conversion had to be performed. The sqlite3_column_text16() on the next line is guaranteed to succeed. |
446 const void* text = sqlite3_column_text16(iStmtHandle, aColumnIndex); |
458 const void* text = sqlite3_column_text16(iStmtHandle, aColumnIndex); |
447 __SQLASSERT(text != NULL, ESqlPanicInternalError); |
459 __ASSERT_DEBUG(text != NULL, __SQLPANIC2(ESqlPanicInternalError)); |
448 TInt length = sqlite3_column_bytes16(iStmtHandle, aColumnIndex); |
460 TInt length = sqlite3_column_bytes16(iStmtHandle, aColumnIndex); |
449 aColumnSource.Set(reinterpret_cast <const TUint8*> (text), length); |
461 aColumnSource.Set(reinterpret_cast <const TUint8*> (text), length); |
450 } |
462 } |
451 else if(colType == SQLITE_BLOB) |
463 else if(colType == SQLITE_BLOB) |
452 { |
464 { |
453 const void* data = sqlite3_column_blob(iStmtHandle, aColumnIndex); |
465 const void* data = sqlite3_column_blob(iStmtHandle, aColumnIndex); |
466 |
478 |
467 @panic SqlDb 4 In _DEBUG mode. aDbHandle is NULL. |
479 @panic SqlDb 4 In _DEBUG mode. aDbHandle is NULL. |
468 */ |
480 */ |
469 void CSqlSrvStatement::DoCommonConstructL() |
481 void CSqlSrvStatement::DoCommonConstructL() |
470 { |
482 { |
471 __SQLASSERT(iStmtHandle != NULL, ESqlPanicInvalidObj); |
483 __ASSERT_DEBUG(iStmtHandle != NULL, __SQLPANIC(ESqlPanicInvalidObj)); |
472 iColumnCount = sqlite3_column_count(iStmtHandle); |
484 iColumnCount = sqlite3_column_count(iStmtHandle); |
473 iParamCount = sqlite3_bind_parameter_count(iStmtHandle); |
485 iParamCount = sqlite3_bind_parameter_count(iStmtHandle); |
474 __SQLLEAVE_IF_ERROR(iBufFlat.SetCount(Max(iColumnCount, iParamCount))); |
486 __SQLLEAVE_IF_ERROR(iBufFlat.SetCount(Max(iColumnCount, iParamCount))); |
475 } |
487 } |
476 |
488 |
505 @panic SqlDb 4 In _DEBUG mode. No parameter buffer has been created yet for this parameter. |
517 @panic SqlDb 4 In _DEBUG mode. No parameter buffer has been created yet for this parameter. |
506 @panic SqlDb 4 In _DEBUG mode. Parameter index out of bounds. |
518 @panic SqlDb 4 In _DEBUG mode. Parameter index out of bounds. |
507 */ |
519 */ |
508 void CSqlSrvStatement::BindParamBufL(TInt aParamIndex) |
520 void CSqlSrvStatement::BindParamBufL(TInt aParamIndex) |
509 { |
521 { |
510 __SQLASSERT(iStmtHandle != NULL, ESqlPanicInvalidObj); |
522 __ASSERT_DEBUG(iStmtHandle != NULL, __SQLPANIC(ESqlPanicInvalidObj)); |
511 __SQLASSERT(aParamIndex >= 0 && aParamIndex < sqlite3_bind_parameter_count(iStmtHandle), ESqlPanicBadArgument); |
523 __ASSERT_DEBUG(aParamIndex >= 0 && aParamIndex < sqlite3_bind_parameter_count(iStmtHandle), __SQLPANIC(ESqlPanicBadArgument)); |
512 __SQLASSERT(aParamIndex < iParamBufArray.Count(), ESqlPanicBadArgument); |
524 __ASSERT_DEBUG(aParamIndex < iParamBufArray.Count(), __SQLPANIC(ESqlPanicBadArgument)); |
513 __SQLASSERT(iParamBufArray[aParamIndex] != NULL, ESqlPanicBadArgument); |
525 __ASSERT_DEBUG(iParamBufArray[aParamIndex] != NULL, __SQLPANIC(ESqlPanicBadArgument)); |
514 (void)sqlite3SymbianLastOsError();//clear last OS error |
526 (void)sqlite3SymbianLastOsError();//clear last OS error |
515 //Bind the parameter value. |
527 //Bind the parameter value. |
516 //SQLITE_STATIC is used as an argument, because the text/blob data will be kept and can be used by the next bind call |
528 //SQLITE_STATIC is used as an argument, because the text/blob data will be kept and can be used by the next bind call |
517 HSqlSrvStmtParamBuf& paramBuf = *iParamBufArray[aParamIndex]; |
529 HSqlSrvStmtParamBuf& paramBuf = *iParamBufArray[aParamIndex]; |
518 const TPtrC8 paramData(paramBuf.Data()); |
530 const TPtrC8 paramData(paramBuf.Data()); |
544 @panic SqlDb 2 In _DEBUG mode. Invalid (not created) CSqlSrvStatement object. |
556 @panic SqlDb 2 In _DEBUG mode. Invalid (not created) CSqlSrvStatement object. |
545 @panic SqlDb 4 In _DEBUG mode. Invalid aColIdx value. |
557 @panic SqlDb 4 In _DEBUG mode. Invalid aColIdx value. |
546 */ |
558 */ |
547 TInt CSqlSrvStatement::ColumnInt(TInt aColIdx) const |
559 TInt CSqlSrvStatement::ColumnInt(TInt aColIdx) const |
548 { |
560 { |
549 __SQLASSERT(iStmtHandle != NULL, ESqlPanicInvalidObj); |
561 __ASSERT_DEBUG(iStmtHandle != NULL, __SQLPANIC(ESqlPanicInvalidObj)); |
550 __SQLASSERT((TUint)aColIdx < iColumnCount, ESqlPanicBadArgument); |
562 __ASSERT_DEBUG((TUint)aColIdx < iColumnCount, __SQLPANIC(ESqlPanicBadArgument)); |
551 TInt colType = sqlite3_column_type(iStmtHandle, aColIdx); |
563 TInt colType = sqlite3_column_type(iStmtHandle, aColIdx); |
552 switch(colType) |
564 switch(colType) |
553 { |
565 { |
554 case SQLITE_FLOAT: |
566 case SQLITE_FLOAT: |
555 { |
567 { |
584 @panic SqlDb 2 In _DEBUG mode. Invalid (not created) CSqlSrvStatement object. |
596 @panic SqlDb 2 In _DEBUG mode. Invalid (not created) CSqlSrvStatement object. |
585 @panic SqlDb 4 In _DEBUG mode. Invalid aColIdx value. |
597 @panic SqlDb 4 In _DEBUG mode. Invalid aColIdx value. |
586 */ |
598 */ |
587 TInt64 CSqlSrvStatement::ColumnInt64(TInt aColIdx) const |
599 TInt64 CSqlSrvStatement::ColumnInt64(TInt aColIdx) const |
588 { |
600 { |
589 __SQLASSERT(iStmtHandle != NULL, ESqlPanicInvalidObj); |
601 __ASSERT_DEBUG(iStmtHandle != NULL, __SQLPANIC(ESqlPanicInvalidObj)); |
590 __SQLASSERT((TUint)aColIdx < iColumnCount, ESqlPanicBadArgument); |
602 __ASSERT_DEBUG((TUint)aColIdx < iColumnCount, __SQLPANIC(ESqlPanicBadArgument)); |
591 TInt colType = sqlite3_column_type(iStmtHandle, aColIdx); |
603 TInt colType = sqlite3_column_type(iStmtHandle, aColIdx); |
592 switch(colType) |
604 switch(colType) |
593 { |
605 { |
594 case SQLITE_FLOAT: |
606 case SQLITE_FLOAT: |
595 { |
607 { |
621 @panic SqlDb 2 In _DEBUG mode. Invalid (not created) CSqlSrvStatement object. |
633 @panic SqlDb 2 In _DEBUG mode. Invalid (not created) CSqlSrvStatement object. |
622 @panic SqlDb 4 In _DEBUG mode. Invalid aColIdx value. |
634 @panic SqlDb 4 In _DEBUG mode. Invalid aColIdx value. |
623 */ |
635 */ |
624 TReal CSqlSrvStatement::ColumnReal(TInt aColIdx) const |
636 TReal CSqlSrvStatement::ColumnReal(TInt aColIdx) const |
625 { |
637 { |
626 __SQLASSERT(iStmtHandle != NULL, ESqlPanicInvalidObj); |
638 __ASSERT_DEBUG(iStmtHandle != NULL, __SQLPANIC(ESqlPanicInvalidObj)); |
627 __SQLASSERT((TUint)aColIdx < iColumnCount, ESqlPanicBadArgument); |
639 __ASSERT_DEBUG((TUint)aColIdx < iColumnCount, __SQLPANIC(ESqlPanicBadArgument)); |
628 TInt colType = sqlite3_column_type(iStmtHandle, aColIdx); |
640 TInt colType = sqlite3_column_type(iStmtHandle, aColIdx); |
629 switch(colType) |
641 switch(colType) |
630 { |
642 { |
631 case SQLITE_INTEGER: |
643 case SQLITE_INTEGER: |
632 { |
644 { |
655 @panic SqlDb 2 In _DEBUG mode. Invalid (not created) CSqlSrvStatement object. |
667 @panic SqlDb 2 In _DEBUG mode. Invalid (not created) CSqlSrvStatement object. |
656 @panic SqlDb 4 In _DEBUG mode. Invalid aColIdx value. |
668 @panic SqlDb 4 In _DEBUG mode. Invalid aColIdx value. |
657 */ |
669 */ |
658 TPtrC CSqlSrvStatement::ColumnTextL(TInt aColIdx) const |
670 TPtrC CSqlSrvStatement::ColumnTextL(TInt aColIdx) const |
659 { |
671 { |
660 __SQLASSERT(iStmtHandle != NULL, ESqlPanicInvalidObj); |
672 __ASSERT_DEBUG(iStmtHandle != NULL, __SQLPANIC(ESqlPanicInvalidObj)); |
661 __SQLASSERT((TUint)aColIdx < iColumnCount, ESqlPanicBadArgument); |
673 __ASSERT_DEBUG((TUint)aColIdx < iColumnCount, __SQLPANIC(ESqlPanicBadArgument)); |
662 TPtrC res; |
674 TPtrC res; |
663 TInt colType = sqlite3_column_type(iStmtHandle, aColIdx); |
675 TInt colType = sqlite3_column_type(iStmtHandle, aColIdx); |
664 if(colType == SQLITE_TEXT) |
676 if(colType == SQLITE_TEXT) |
665 { |
677 { |
666 TInt charLength = (TUint)sqlite3_column_bytes16(iStmtHandle, aColIdx) / sizeof(TUint16); |
678 TInt charLength = (TUint)sqlite3_column_bytes16(iStmtHandle, aColIdx) / sizeof(TUint16); |
671 __SQLLEAVE(KErrNoMemory); |
683 __SQLLEAVE(KErrNoMemory); |
672 } |
684 } |
673 //sqlite3_column_bytes16() already allocated the needed memory if a UTF8->UTF16 conversion |
685 //sqlite3_column_bytes16() already allocated the needed memory if a UTF8->UTF16 conversion |
674 //had to be performed. The sqlite3_column_text16() on the next line is guaranteed to succeed. |
686 //had to be performed. The sqlite3_column_text16() on the next line is guaranteed to succeed. |
675 const TUint16* text = reinterpret_cast <const TUint16*> (sqlite3_column_text16(iStmtHandle, aColIdx)); |
687 const TUint16* text = reinterpret_cast <const TUint16*> (sqlite3_column_text16(iStmtHandle, aColIdx)); |
676 __SQLASSERT(text != NULL, ESqlPanicInternalError); |
688 __ASSERT_DEBUG(text != NULL, __SQLPANIC(ESqlPanicInternalError)); |
677 res.Set(text, charLength); |
689 res.Set(text, charLength); |
678 } |
690 } |
679 return res; |
691 return res; |
680 } |
692 } |
681 |
693 |
682 /** |
694 /** |
690 @panic SqlDb 2 In _DEBUG mode. Invalid (not created) CSqlSrvStatement object. |
702 @panic SqlDb 2 In _DEBUG mode. Invalid (not created) CSqlSrvStatement object. |
691 @panic SqlDb 4 In _DEBUG mode. Invalid aColIdx value. |
703 @panic SqlDb 4 In _DEBUG mode. Invalid aColIdx value. |
692 */ |
704 */ |
693 TPtrC8 CSqlSrvStatement::ColumnBinary(TInt aColIdx) const |
705 TPtrC8 CSqlSrvStatement::ColumnBinary(TInt aColIdx) const |
694 { |
706 { |
695 __SQLASSERT(iStmtHandle != NULL, ESqlPanicInvalidObj); |
707 __ASSERT_DEBUG(iStmtHandle != NULL, __SQLPANIC(ESqlPanicInvalidObj)); |
696 __SQLASSERT((TUint)aColIdx < iColumnCount, ESqlPanicBadArgument); |
708 __ASSERT_DEBUG((TUint)aColIdx < iColumnCount, __SQLPANIC(ESqlPanicBadArgument)); |
697 TPtrC8 res; |
709 TPtrC8 res; |
698 TInt colType = sqlite3_column_type(iStmtHandle, aColIdx); |
710 TInt colType = sqlite3_column_type(iStmtHandle, aColIdx); |
699 if(colType == SQLITE_BLOB) |
711 if(colType == SQLITE_BLOB) |
700 { |
712 { |
701 TInt byteLength = sqlite3_column_bytes(iStmtHandle, aColIdx); |
713 TInt byteLength = sqlite3_column_bytes(iStmtHandle, aColIdx); |
759 @leave KErrNoMemory, an out of memory condition has occurred; |
771 @leave KErrNoMemory, an out of memory condition has occurred; |
760 */ |
772 */ |
761 HSqlSrvStmtParamBuf* CSqlSrvStatement::GetParamBufL(TInt aParamIndex, HSqlSrvStmtParamBuf::TDataType aDataType, |
773 HSqlSrvStmtParamBuf* CSqlSrvStatement::GetParamBufL(TInt aParamIndex, HSqlSrvStmtParamBuf::TDataType aDataType, |
762 HSqlSrvStmtParamBuf::TBufType aBufType) |
774 HSqlSrvStmtParamBuf::TBufType aBufType) |
763 { |
775 { |
764 __SQLASSERT(aParamIndex >= 0 && aParamIndex < sqlite3_bind_parameter_count(iStmtHandle), ESqlPanicBadArgument); |
776 __ASSERT_DEBUG(aParamIndex >= 0 && aParamIndex < sqlite3_bind_parameter_count(iStmtHandle), __SQLPANIC(ESqlPanicBadArgument)); |
765 ExtendParamBufArrayL(aParamIndex); |
777 ExtendParamBufArrayL(aParamIndex); |
766 HSqlSrvStmtParamBuf*& paramBuf = iParamBufArray[aParamIndex]; |
778 HSqlSrvStmtParamBuf*& paramBuf = iParamBufArray[aParamIndex]; |
767 if(paramBuf) |
779 if(paramBuf) |
768 {//Reset and reuse the existing buffer |
780 {//Reset and reuse the existing buffer |
769 __SQLASSERT(paramBuf->ParamIndex() == aParamIndex, ESqlPanicInternalError); |
781 __ASSERT_DEBUG(paramBuf->ParamIndex() == aParamIndex, __SQLPANIC(ESqlPanicInternalError)); |
770 paramBuf->Reset(aDataType, aBufType); |
782 paramBuf->Reset(aDataType, aBufType); |
771 } |
783 } |
772 else |
784 else |
773 { |
785 { |
774 paramBuf = HSqlSrvStmtParamBuf::NewL(*this, aParamIndex, aDataType, aBufType); |
786 paramBuf = HSqlSrvStmtParamBuf::NewL(*this, aParamIndex, aDataType, aBufType); |
787 @panic SqlDb 2 In _DEBUG mode. Invalid (not created) CSqlSrvStatement object. |
799 @panic SqlDb 2 In _DEBUG mode. Invalid (not created) CSqlSrvStatement object. |
788 @panic SqlDb 4 In _DEBUG mode. Parameter index out of bounds. |
800 @panic SqlDb 4 In _DEBUG mode. Parameter index out of bounds. |
789 */ |
801 */ |
790 void CSqlSrvStatement::ExtendParamBufArrayL(TInt aParamIndex) |
802 void CSqlSrvStatement::ExtendParamBufArrayL(TInt aParamIndex) |
791 { |
803 { |
792 __SQLASSERT(iStmtHandle != NULL, ESqlPanicInvalidObj); |
804 __ASSERT_DEBUG(iStmtHandle != NULL, __SQLPANIC(ESqlPanicInvalidObj)); |
793 __SQLASSERT(aParamIndex >= 0 && aParamIndex < sqlite3_bind_parameter_count(iStmtHandle), ESqlPanicBadArgument); |
805 __ASSERT_DEBUG(aParamIndex >= 0 && aParamIndex < sqlite3_bind_parameter_count(iStmtHandle), __SQLPANIC(ESqlPanicBadArgument)); |
794 TInt ext = aParamIndex - iParamBufArray.Count() + 1; |
806 TInt ext = aParamIndex - iParamBufArray.Count() + 1; |
795 while(ext-- > 0) |
807 while(ext-- > 0) |
796 { |
808 { |
797 __SQLLEAVE_IF_ERROR(iParamBufArray.Append(NULL)); |
809 __SQLLEAVE_IF_ERROR(iParamBufArray.Append(NULL)); |
798 } |
810 } |
813 @panic SqlDb 2 In _DEBUG mode. Invalid (not created) CSqlSrvStatement object. |
825 @panic SqlDb 2 In _DEBUG mode. Invalid (not created) CSqlSrvStatement object. |
814 @panic SqlDb 4 In _DEBUG mode. Parameter index out of bounds. |
826 @panic SqlDb 4 In _DEBUG mode. Parameter index out of bounds. |
815 */ |
827 */ |
816 TPtrC8 CSqlSrvStatement::CopyAndStoreParamL(TInt aParamIndex, HSqlSrvStmtParamBuf::TDataType aDataType, const TDesC8& aParamValue) |
828 TPtrC8 CSqlSrvStatement::CopyAndStoreParamL(TInt aParamIndex, HSqlSrvStmtParamBuf::TDataType aDataType, const TDesC8& aParamValue) |
817 { |
829 { |
818 __SQLASSERT(iStmtHandle != NULL, ESqlPanicInvalidObj); |
830 __ASSERT_DEBUG(iStmtHandle != NULL, __SQLPANIC(ESqlPanicInvalidObj)); |
819 __SQLASSERT(aParamIndex >= 0 && aParamIndex < sqlite3_bind_parameter_count(iStmtHandle), ESqlPanicBadArgument); |
831 __ASSERT_DEBUG(aParamIndex >= 0 && aParamIndex < sqlite3_bind_parameter_count(iStmtHandle), __SQLPANIC(ESqlPanicBadArgument)); |
820 HSqlSrvStmtParamBuf* paramBuf = GetParamBufL(aParamIndex, aDataType, HSqlSrvStmtParamBuf::EBufSimpleBind); |
832 HSqlSrvStmtParamBuf* paramBuf = GetParamBufL(aParamIndex, aDataType, HSqlSrvStmtParamBuf::EBufSimpleBind); |
821 return paramBuf->SetDataL(aParamValue); |
833 return paramBuf->SetDataL(aParamValue); |
822 } |
834 } |