1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 // |
7 // |
8 // Initial Contributors: |
8 // Initial Contributors: |
9 // Nokia Corporation - initial contribution. |
9 // Nokia Corporation - initial contribution. |
10 // |
10 // |
11 // Contributors: |
11 // Contributors: |
|
12 // NTT DOCOMO, INC - Fix for Bug 1915 "SQL server panics when using long column type strings" |
12 // |
13 // |
13 // Description: |
14 // Description: |
14 // |
15 // |
15 |
16 |
16 #include <s32mem.h> |
17 #include <s32mem.h> |
129 } |
130 } |
130 return err; |
131 return err; |
131 } |
132 } |
132 |
133 |
133 /** |
134 /** |
134 Sends a command to the server for retrieving a string with ";" separated declared types of columns |
135 Sends a command to the server for retrieving the declared types of columns |
135 The caller is responsible for deleting the result buffer. |
|
136 |
|
137 @param aColumnCount The number of the columns which the statement has. |
|
138 @return A pointer to a heap based HBufC object, containing the column names, separated with ";". |
|
139 |
136 |
140 Usage of the IPC call arguments: |
137 Usage of the IPC call arguments: |
141 Arg 0: [out] Input buffer max length |
138 Arg 0: [out] buffer length in bytes |
142 Arg 1: [in/out] Data buffer, will be filled with the declared types of columns, separated with ";" |
139 Arg 1: [in/out] buffer |
143 */ |
140 */ |
144 HBufC* RSqlStatementSession::GetDeclColumnTypesL(TInt aColumnCount) |
141 TInt RSqlStatementSession::GetDeclColumnTypes(RSqlBufFlat& aDeclColumnTypeBuf) |
145 { |
142 { |
146 //The longest DBMS data type, represented as text, is "LONG VARBINARY" - 14 characters. |
143 aDeclColumnTypeBuf.Reset(); |
147 //So we can safely assume that 20 characters buffer space per DBMS column type is enough. |
144 TPtr8& ptr = aDeclColumnTypeBuf.BufPtr(); |
148 const TInt KLongestDbmsTypeLength = 20; |
145 TInt err = DbSession().SendReceive(::MakeMsgCode(ESqlSrvStmtDeclColumnTypes, ESqlSrvStatementHandle, iHandle), TIpcArgs(ptr.MaxLength(), &ptr)); |
149 HBufC* colTypeBuf = HBufC::NewLC(aColumnCount * KLongestDbmsTypeLength); |
146 if(err > KSqlClientBufOverflowCode) |
150 TPtr ptr = colTypeBuf->Des(); |
147 { |
151 TInt err = DbSession().SendReceive(::MakeMsgCode(ESqlSrvStmtDeclColumnTypes, ESqlSrvStatementHandle, iHandle), TIpcArgs(ptr.MaxLength(), &ptr)); |
148 err = Retry(aDeclColumnTypeBuf, err - KSqlClientBufOverflowCode, ESqlDeclColumnTypesBuf); |
152 __SQLLEAVE_IF_ERROR(err); |
149 } |
153 CleanupStack::Pop(colTypeBuf); |
150 return err; |
154 return colTypeBuf; |
|
155 } |
151 } |