Kaydet (Commit) 3107a5d0 authored tarafından Jean-Pierre Ledure's avatar Jean-Pierre Ledure

Access2Base - Review size limits of VARCHAR fields

- Basic has no practical limit anymore for string variables
- LONGVARCHAR fields can vary a lot in size across RDBMS's (f.i. Sqlite < 64K)
This forces an overflow check when setting a field value and no check when getting it

Change-Id: I4c9629f63164fbbdb84497e7002fa3186d7c63b7
üst 15cee52b
......@@ -340,7 +340,7 @@ Const cstProgressMeterLimit = 100
Utils._updateResultSetColumnValue(iRDBMS, oOutput.RowSet, i + 1, vField)
ElseIf oDatabase._BinaryStream Then
&apos; Typically for SQLite where binary fields are limited
If lInputSize &gt; vOutputField.Column.Precision Then
If lInputSize &gt; vOutputField._Precision Then
TraceError(TRACEWARNING, ERRPRECISION, Utils._CalledSub(), 0, 1, Array(vOutputField._Name, lInputRecs + 1))
Utils._updateResultSetColumnValue(iRDBMS, oOutput.RowSet, i + 1, Null)
Else
......@@ -352,6 +352,12 @@ Const cstProgressMeterLimit = 100
End If
Else
vField = Utils._getResultSetColumnValue(.RowSet, i + 1)
If VarType(vField) = vbString Then
If Len(vField) &gt; vOutputField._Precision Then
TraceError(TRACEWARNING, ERRPRECISION, Utils._CalledSub(), 0, 1, Array(vOutputField._Name, lInputRecs + 1))
End If
End If
&apos; Update is done anyway, if too long, with truncation
Utils._updateResultSetColumnValue(iRDBMS, oOutput.RowSet, i + 1, vField)
End If
Next i
......
......@@ -16,6 +16,7 @@ REM ----------------------------------------------------------------------------
Private _Type As String &apos; Must be FIELD
Private _Name As String
Private _Precision As Long
Private _ParentName As String
Private _ParentType As String
Private _ParentDatabase As Object
......@@ -400,7 +401,6 @@ Dim cstThisSub As String
Dim bCond1 As Boolean, bCond2 As Boolean, vValue As Variant, oValue As Object, sValue As String
Dim oSize As Object, lSize As Long, bNullable As Boolean, bNull As Boolean
Const cstMaxTextLength = 65535
Const cstMaxBinlength = 2 * 65535
_PropertyGet = EMPTY
......@@ -551,7 +551,6 @@ Const cstMaxBinlength = 2 * 65535
If Not bNull Then
lSize = CLng(oValue.getLength())
oValue.closeInput()
If lSize &gt; cstMaxTextLength Then Goto Trace_Length
vValue = Column.getString() &apos; vbString
Else
oValue.closeInput()
......@@ -686,6 +685,7 @@ Dim oParent As Object
End If
Case .CHAR, .VARCHAR, .LONGVARCHAR, .CLOB
If Not Utils._CheckArgument(pvValue, iArgNr, vbString, , False) Then Goto Trace_Error_Value
If Len(pvValue) &gt; _Precision Then Goto Trace_Error_Length
Column.updateString(pvValue) &apos; vbString
Case .DATE
If Not Utils._CheckArgument(pvValue, iArgNr, vbDate, , False) Then Goto Trace_Error_Value
......@@ -756,6 +756,10 @@ Trace_Error_Updatable:
TraceError(TRACEFATAL, ERRNOTUPDATABLE, Utils._CalledSub(), 0, 1)
_PropertySet = False
Goto Exit_Function
Trace_Error_Length:
TraceError(TRACEFATAL, ERROVERFLOW, Utils._CalledSub(), 0, , Array(lSize, &quot;AppendChunk&quot;))
_PropertySet = False
Goto Exit_Function
Error_Function:
TraceError(TRACEABORT, Err, cstThisSub, Erl)
_PropertySet = False
......
......@@ -545,6 +545,7 @@ Dim i As Integer, oFields As Object, iIndex As Integer
Set oObject = New Field
oObject._Name = sObjectName
Set oObject.Column = oFields.getByName(sObjectName)
If Utils._hasUNOProperty(oObject.Column, &quot;Precision&quot;) Then oObject._Precision = oObject.Column.Precision
oObject._ParentName = _Name
oObject._ParentType = _Type
Set oObject._ParentDatabase = _ParentDatabase
......
......@@ -1166,7 +1166,7 @@ Const cstMaxBinlength = 2 * 65535
Case .DECIMAL, .NUMERIC : poResultSet.updateDouble(piColIndex, pvValue)
Case .TINYINT : poResultSet.updateShort(piColIndex, pvValue)
Case .CHAR, .VARCHAR, .LONGVARCHAR, .CLOB
If piRDBMS = DBMS_SQLITE And InStr(sValueTypeName, &quot;BINARY&quot;) &gt;0 Then &apos; Sqlite exception ... !
If piRDBMS = DBMS_SQLITE And InStr(sValueTypeName, &quot;BINARY&quot;) &gt; 0 Then &apos; Sqlite exception ... !
poResultSet.updateBytes(piColIndex, pvValue)
Else
poResultSet.updateString(piColIndex, pvValue)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment