[TYPO3-dev] Raising Mysql requirements to 4.1?

ries van Twisk typo3 at rvt.dds.nl
Mon Oct 1 16:18:09 CEST 2007


On Oct 1, 2007, at 8:54 AM, Martin Kutschker wrote:

> ries van Twisk schrieb:
>> Hey Dmitry,
>>
>> and others..
>>
>> what if we extension t3lib_db with tree additional functions
>>
>> 1) $GLOBAL['TYPO3_DB'] -> beginTransactionBlock();
>> 2) $GLOBAL['TYPO3_DB'] -> endTransactionBlock();
>> 3) $GLOBAL['TYPO3_DB'] -> abortTransactionBlock();
>>
>> And your below function could look like:
>>
>>> if (get_resource_type($GLOBALS['TYPO3_DB']->link) == 'mysql link') {
>>>     $query =
>>> $GLOBALS['TYPO3_DB']->INSERTquery('tx_realurl_urlencodecache',
>>> $insertFields);
>>>     $query .= ' ON DUPLICATE KEY UPDATE tstamp=' .
>>> $insertFields['tstamp'];
>>>     $GLOBALS['TYPO3_DB']->sql_query($query);
>>> }
>>> else {
>>         $GLOBAL['TYPO3_DB'] -> beginTransactionBlock();
>>>     $GLOBALS['TYPO3_DB']->exec_DELETEquery 
>>> ('tx_realurl_urlencodecache',
>>> 'url_hash='.intval($hash));
>>>     $GLOBALS['TYPO3_DB']->exec_INSERTquery 
>>> ('tx_realurl_urlencodecache',
>>> $insertFields);
>>            $GLOBAL['TYPO3_DB'] -> endTransactionBlock();
>>> }
>>
>>
>> By doing it like that we can start supporting other RDBM's much  
>> better.
>> For the native MySQL ISAM driver the tree functions above simply  
>> don't
>> do anything, with InnoDB we can also use transaction blocks.  
>> (Actually MyISAM ignores
>> transaction blocks anyways).
>
> If you care to check for the table type on Mysql you can replace it  
> (in
> this case!) with a TABLE LOCK. But the problem is that you cannot  
> abort it,
> so it's not a general solution.
>
> Intersting is also that the Mysql version does an UPDATE but we have
> DELETE/UPDATE pair on other DBs. Shouldn't that be a SELECT/UPDATE/ 
> INSERT
> triple?
I am not sure what you mean actually..
In the above case Dmitry just tries to insert or update a record.

But I think ypou mean this that the above could be written a bit  
faster if the link was not MySQL  if that is what you mean.
For example if the record exists, we just update it's timestamp like  
in the MySQL
version. Rather then deleting and inserting the same record which is  
I think
much more expensive.

so then we get, which makes the whole system more transaction correct..

$record=select record
if (record) {
	update record with new timestamp
} else {
	insert new record
}

>
> Masi
> _______________________________________________


In some other cases like the cache_pages,
we might want to put that in a transaction block and
we cannot really update rather then delete/insert (can we??)

Ries












More information about the TYPO3-dev mailing list