MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:Sergei Golubchik Date:June 21 2009 2:07pm
Subject:Re: Custom storage engine: supporting key constraints
View as plain text  
Hi, Slava!

On Jun 12, Slava Akhmechet wrote:
> After some digging I realized that supporting key constraints is a
> responsibility of the storage engine. MySQL defines a lot of
> flags/error modes for this, so I want to clear up my understanding
> before I implement this.
> 
> First, there are errors HA_ERR_FOUND_DUPP_KEY,
> HA_ERR_FOUND_DUPP_UNIQUE. From what I understand write_row/update_row

Only HA_ERR_FOUND_DUPP_KEY, you can ignore HA_ERR_FOUND_DUPP_UNIQUE.

> should return these errors if and only if there is a duplicate key or
> a duplicate unique column (respectively), *and* the relevant key has a
> flag HA_NOSAME. Is this correct? Do all keys that must not have
> duplicates have HA_NOSAME flag set?

Yes.

Note that there could be a unique constraint over muptiple columns
(multi-segment key), and some of these columns may allow NULL values.

> Also, how should UNIQUEs be handled? If there is no index on the
> column, write_row would have to scan all the rows to make sure there
> are no duplicates, which seems far too high level for the storage
> engine API. Am I missing something here?

UNIQUE means UNIQUE INDEX, in MySQL there can be no unique constraints
over non-indexed columns.

Regards / Mit vielen Grüßen,
Sergei

-- 
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /   Sergei Golubchik <serg@stripped>
 / /|_/ / // /\ \/ /_/ / /__  Principal Software Engineer/Server Architect
/_/  /_/\_, /___/\___\_\___/  Sun Microsystems GmbH, HRB München 161028
       <___/                  Sonnenallee 1, 85551 Kirchheim-Heimstetten
Geschäftsführer: Thomas Schroeder, Wolfgang Engels, Wolf Frenkel
Vorsitzender des Aufsichtsrates: Martin Häring
Thread
Custom storage engine: supporting key constraintsSlava Akhmechet13 Jun
  • Re: Custom storage engine: supporting key constraintsStewart Smith13 Jun
  • Re: Custom storage engine: supporting key constraintsSergei Golubchik21 Jun