summaryrefslogtreecommitdiff
path: root/wizards
diff options
context:
space:
mode:
authorJean-Pierre Ledure <jp@ledure.be>2017-01-13 15:24:08 +0100
committerJean-Pierre Ledure <jp@ledure.be>2017-01-13 15:28:06 +0100
commit3107a5d0e9ff7a3ccaac536606a733767886d438 (patch)
treeedbdfa22784200c2763d5986f5dd839dc21621e2 /wizards
parent15cee52b62c760e1cb212d34d9279c5eee5ecb6d (diff)
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
Diffstat (limited to 'wizards')
-rw-r--r--wizards/source/access2base/DoCmd.xba8
-rw-r--r--wizards/source/access2base/Field.xba8
-rw-r--r--wizards/source/access2base/Recordset.xba1
-rw-r--r--wizards/source/access2base/Utils.xba2
4 files changed, 15 insertions, 4 deletions
diff --git a/wizards/source/access2base/DoCmd.xba b/wizards/source/access2base/DoCmd.xba
index 9b6500c30897..b52cbbdccde9 100644
--- a/wizards/source/access2base/DoCmd.xba
+++ b/wizards/source/access2base/DoCmd.xba
@@ -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
diff --git a/wizards/source/access2base/Field.xba b/wizards/source/access2base/Field.xba
index 35d5bc6bddb8..5a7fcc4cd870 100644
--- a/wizards/source/access2base/Field.xba
+++ b/wizards/source/access2base/Field.xba
@@ -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
diff --git a/wizards/source/access2base/Recordset.xba b/wizards/source/access2base/Recordset.xba
index d04f2e6bf382..0bc968fd4c8e 100644
--- a/wizards/source/access2base/Recordset.xba
+++ b/wizards/source/access2base/Recordset.xba
@@ -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
diff --git a/wizards/source/access2base/Utils.xba b/wizards/source/access2base/Utils.xba
index 7367e4e63e59..3b71d0adb92d 100644
--- a/wizards/source/access2base/Utils.xba
+++ b/wizards/source/access2base/Utils.xba
@@ -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)