Bug #48514 unable to update mysql table via odbc when new and old field values are the same
Submitted: 3 Nov 2009 19:05 Modified: 3 Nov 2009 21:27
Reporter: Brian Gold Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / ODBC Severity:S3 (Non-critical)
Version:Connector 5.1.6 x64, server: 5.0.51a-15 OS:Windows (Server 2003)
Assigned to: CPU Architecture:Any
Tags: linked server, MSSQL, ODBC

[3 Nov 2009 19:05] Brian Gold
Description:
While connected to mysql via ODBC, if you attempt to issue an UPDATE command, setting a field to the same value that it already using, you get the following error:

The OLE DB provider "MSDASQL" for linked server "test_linked_server" could not UPDATE table "[test_table]...[test_field]". The rowset was using optimistic concurrency and the value of a column has been changed after the containing row was last fetched or resynchronized.
OLE DB provider "MSDASQL" for linked server "test_linked_server" returned message "Row cannot be located for updating. Some values may have been changed since it was last read.".

How to repeat:
I have reproduced this on a separate server with the following settings:

MySql Version: 5.0.51a
MySQL ODBC 5.1 Driver  Version: 05.01.0006 w/ the following flags:
Flags 1:
  Allow big result sets
  Use compression
 
Flags 2:
  Don't cache results of forward-only cursors
  
Flags 3:
  Read options from my.cnf
  Allow multiple statements

-------------------------
my.cnf contents
-------------------------
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
# 
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
[client]
port		= 6603
socket		= /var/run/mysqld/mysqld.sock

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket		= /var/run/mysqld/mysqld.sock
nice		= 0

[mysqld]
#
# * Basic Settings
#
user		= mysql
pid-file	= /var/run/mysqld/mysqld.pid
socket		= /var/run/mysqld/mysqld.sock
port		= 6603
basedir		= /usr
datadir		= /data/mysql_data
tmpdir		= /tmp
language	= /usr/share/mysql/english
#skip-external-locking
#
# Instead of skip-networking you can listen only on
# localhost which is more compatible and is not less secure.
#bind-address		= 127.0.0.1
#skip-networking
#
# * Fine Tuning
#
key_buffer		= 16M
max_allowed_packet	= 16M
thread_stack=128
thread_cache_size	= 8
#max_connections        = 100
#  Changed from 8 to 1024.
table_cache            = 1024
#thread_concurrency     = 10
#
# * Query Cache Configuration
#
query_cache_limit       = 1M
# query_cache_size changed from 16M
query_cache_size        = 300M
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
#log		= /var/log/mysql/mysql.log
#
# Error logging goes to syslog. This is a Debian improvement :)
#
# Here you can see queries with especially long duration
log_slow_queries	= /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
#       other settings you may need to change.
#server-id		= 1
#log_bin			= /var/log/mysql/mysql-bin.log
#log-slave-updates
#log-bin-index		= /var/log/mysql/mysql-bin.index
#log-error		= /var/log/mysql/error.log
#relay-log 		= /var/log/mysql/relay.log
#relay-log-info-file 	= /var/log/mysql/relay-log.info
#relay-log-index		= /var/log/mysql/relay-log.index
#master-host		= [master ip address]
#master-user		= slave_user
#master-password		= [place password here]
#replicate-do-db=dash
#replicate-do-db=mysql
#replicate-do-db=annieselke
#replicate-do-db=customer
#replicate-do-db=doctrine
#replicate-do-db=dsr
#replicate-do-db=dsr_dev
#replicate-do-db=graffiti
#replicate-do-db=mediawiki
#replicate-do-db=pch
#replicate-do-db=pinetar
#replicate-do-db=pinetask
#replicate-do-db=pinetask-live
#replicate-do-db=test
#replicate-do-db=webstats
#replicate-do-db=weta
#replicate-do-db=tracgraffiti
#replicate-do-db=tracpch
#replicate-do-db=tracannie
#replicate-do-db=tracdash
#replicate-do-db=tracdsr
#replicate-do-db=tracmailer
#replicate-do-db=tracpinetar
#replicate-do-db=tracresq
#replicate-do-db=tracreports
#replicate-do-db=tracdoc
#replicate-do-db=tracprojects
#replicate-do-db=tracmot
#replicate-do-db=tracmarketng
#expire_logs_days	= 10
#max_binlog_size         = 100M
#binlog_do_db		= include_database_name
#binlog_ignore_db	= include_database_name
#
# * BerkeleyDB
#
# Using BerkeleyDB is now discouraged as its support will cease in 5.1.12.
skip-bdb
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
# You might want to disable InnoDB to shrink the mysqld process by circa 100MB.
#skip-innodb
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem

#The bigger you set this the less disk I/O is needed to access data in tables. On a dedicated database server you may set this parameter up to 80% of the machine physical memory size. Do not set it too large, though, because competition of the physical memory may cause paging in the operating system.
# Changed from 200M
innodb_buffer_pool_size=300M

#Allow connections via named pipes (Windows NT+ only). Note: you can specify a pipe name on the advanced network page, if required.
#enable-named-pipe

#Set the default character set.
default-character-set=cp1250
#Set the default collation.
default-collation=cp1250_general_ci

[mysqldump]
quick
quote-names
max_allowed_packet	= 16M

[mysql]
#no-auto-rehash	# faster start of mysql but no tab completition

[isamchk]
key_buffer		= 16M

#
# * NDB Cluster
#
# See /usr/share/doc/mysql-server-*/README.Debian for more information.
#
# The following configuration is read by the NDB Data Nodes (ndbd processes)
# not from the NDB Management Nodes (ndb_mgmd processes).
#
# [MYSQL_CLUSTER]
# ndb-connectstring=127.0.0.1

#
# * IMPORTANT: Additional settings that can override those from this file!
#
!includedir /etc/mysql/conf.d/

# Setting added by Brett on 8.13.08 for, hopefully, optimization
innodb_flush_log_at_trx_commit=2

--------------------------
Connect to the odbc via any method. In the example below I used Microsoft SQL Server 2005 via linked server. The same works with Microsoft Access and presumably via any other ODBC based query.

Issue the following command:
update test_linked_server...test_table
set test_field = 'foo' where test_field = 'foo'
update mysql_dsr_dev...container
set status = 'received' where id = 130
[3 Nov 2009 19:10] Brian Gold
Updated synopsis to be a bit clearer
[3 Nov 2009 21:27] MySQL Verification Team
Thank you for the bug report. Duplicate of bug: http://bugs.mysql.com/bug.php?id=46406.
[4 Nov 2009 8:10] Tonci Grgin
Brian, please use suggestion in Bug#46406 ([29 Jul 9:04] Tonci Grgin) and see if it helps.