[OpenSER-Devel] [ openser-Patches-1665077 ] insert on duplicate key
update function for db, mysql
SourceForge.net
noreply at sourceforge.net
Wed Jul 18 18:29:10 CEST 2007
Patches item #1665077, was opened at 2007-02-21 10:16
Message generated for change (Comment added) made by henningw
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=743022&aid=1665077&group_id=139143
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
>Status: Closed
Resolution: None
Priority: 5
Private: No
Submitted By: Henning Westerholt (henningw)
Assigned to: Nobody/Anonymous (nobody)
Summary: insert on duplicate key update function for db, mysql
Initial Comment:
Hello,
The current replace function replaces a row in the db, if it exists. Prior to the insertion the old row is deleted.
For some situations a function that uses the INSERT, ON DUPLICATE KEY UPDATE call, thus preserving old data that is not overwritten, is very convenient. We're using this function a lot in our modules.
This attached patch implements suchs a function, so called "insert_update". It adds the some code to the db interface, and the mysql module.
I know this syntax is a MySQL extension that is not present in PostgreSQL. But it is of course possible to implemented a similar feature with some SQL statements there.
Regards,
Henning
----------------------------------------------------------------------
>Comment By: Henning Westerholt (henningw)
Date: 2007-07-18 16:29
Message:
Logged In: YES
user_id=337916
Originator: YES
updated version in svn trunk
----------------------------------------------------------------------
Comment By: Henning Westerholt (henningw)
Date: 2007-04-18 08:59
Message:
Logged In: YES
user_id=337916
Originator: YES
Hi Daniel,
any update on this?
Henning
----------------------------------------------------------------------
Comment By: Henning Westerholt (henningw)
Date: 2007-04-16 11:15
Message:
Logged In: YES
user_id=337916
Originator: YES
Hi Daniel,
thanks for the reply. Yes, there is a difference.
REPLACE either inserts, or deletes and inserts.
UPDATE ON DUPLICATE KEY.. either either inserts or updates, thus
presevering old data.
This is very helpful if you want to preserve data fields that are not
changed, e.g. in usrloc or logging scenarios.
----------------------------------------------------------------------
Comment By: Daniel-Constantin Mierla (miconda)
Date: 2007-04-16 11:08
Message:
Logged In: YES
user_id=1246013
Originator: NO
I think mysql has a REPLACE function. Is there any difference against
"INSERT, ON DUPLICATE KEY
UPDATE"?
----------------------------------------------------------------------
Comment By: Henning Westerholt (henningw)
Date: 2007-04-16 10:35
Message:
Logged In: YES
user_id=337916
Originator: YES
I rework the patch for svn trunk after the last_inserted_id addition.
This applies now cleanly to the repository again.
In my opionion this is a useful contribution to openser, any comments on
this?
Best regards,
Henning
File Added: db-mysql-insert-update-function-trunk.patch
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=743022&aid=1665077&group_id=139143
More information about the Devel
mailing list