[ODBC-251] Error when updating blob field Created: 2019-05-20  Updated: 2019-08-01

Status: Open
Project: MariaDB Connector/ODBC
Component/s: None
Affects Version/s: 3.1.1
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Luis A S C Junior Assignee: Lawrin Novitsky
Resolution: Unresolved Votes: 0
Labels: regression
Environment:

ODBC 3.1.1 with MariaDB 10.3.15 under Windows Server 2008


Attachments: Text File SQL-create-table.txt     JPEG File image.jpg     File test.asp    

 Description   

I use a function to update a BLOB field working for more then teen years with MyODBC 3.51.12, now i have try with MariaODBC 3.1.1, but a error has show.

I have using Windows Server 2008 32 bits (IIS 7.0) with Classic ASP and MariaODBC Connector 3.1.1.

The MariaDB version is 10.3.15 64 bits running in other server, into Windows 10 64 bits.

In have installed the MyODBC versions 3.51.12, 5.1.13, 5.2.7 and 5.3.6.
With version 3.51.12 working fine, with 5.1.13, 5.2.7 or 5.3.6 all returning this error:

=====================================
Microsoft OLE DB Provider for ODBC Drivers erro '80004005'
[MySQL][ODBC 5.3(w) Driver][mysqld-5.6.34-log]Build WHERE -> insert_fields() failed.
=====================================

With MariaODBC 3.1.1, this is a error:

==========================
Microsoft OLE DB Provider for ODBC Drivers erro '80004005'
[ma-3.1.1][10.3.15-MariaDB]Can't build index for update/delete
==========================

How to repeat:

  • Install a MariaODBC 3.1.1 in Windows.
  • Create a test table:

CREATE TABLE `testtable` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`file` MEDIUMBLOB NULL,
PRIMARY KEY (`id`)
)
COLLATE='latin1_swedish_ci'
ENGINE=MyISAM;

  • Create a ASP file (test.asp) with:

========================
BEGIN TEST.ASP

<%
wstring="DRIVER=

{MariaDB ODBC 3.1 Driver}

;SERVER=127.0.0.1;PORT=3306;DATABASE=test;UID=testuser;PWD=testpass;OPTION=16427"
Set connec=server.createobject("adodb.connection")
connec.Open wstring

sql="delete from testtable where id=1"
set xx=connec.execute(sql)
set xx=nothing

sql="insert into testtable (id,file) values (1,'')"
set xx=connec.execute(sql)
set xx=nothing

Const adOpenStatic = 3
Const adLockOptimistic = 3

Set Rs = Server.CreateObject("ADODB.Recordset")
Set Rs.ActiveConnection = connec

Rs.CursorType = adOpenStatic
Rs.LockType = adLockOptimistic

xsource="select file from testtable where id=1"
Rs.Source = xsource
Rs.Open

Const adTypeBinary = 1

Dim BinaryStream
Set BinaryStream = CreateObject("ADODB.Stream")

BinaryStream.Type = adTypeBinary

BinaryStream.Open

BinaryStream.LoadFromFile "image.jpg"

ReadBinaryFile = BinaryStream.Read

RS("file").AppendChunk ReadBinaryFile
RS.Update

set ReadBinaryFile=nothing

BinaryStream.close
set BinaryStream=nothing

connec.close
set connec=nothing
%>

END TEST.ASP
==============================

Save any small image file in same folder of test.asp with name image.jpg and execute the test.asp in browser for run the application.

The error occurs in line:
RS.Update



 Comments   
Comment by Lawrin Novitsky [ 2019-06-03 ]

Thank you for your report.

This can be a duplicate of the ODBC-102. But there mysql's connector reportedly works. And in your case only some its old version works.

Would it be possible to provide ODBC trace for your issue?

Comment by Lawrin Novitsky [ 2019-06-13 ]

The workaround would be to add id field to the field list in the 'select' statement

Comment by Lawrin Novitsky [ 2019-06-19 ]

I am actually not sure if we should fix this.
We cannot be sure, that we update the correct row. Or that we update only that row, and not any other.
In your case WHERE clause unambiguously determines the row. But that is not always granted.
And we will have to compare in the composed WHERE clause mediumblob field with its the current value in connector's result buffer.
Let aside, that separating WHERE clause from the query is not that trivial task for a connector.
At the end we will have bad and bugs prone solution, while there is good workaround without all these drawbacks.

Generated at Thu Feb 08 03:27:20 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.