draft-ietf-imapext-condstore-01.txt   draft-ietf-imapext-condstore-02.txt 
Internet Draft: IMAP Extension for Conditional STORE A. Melnikov Internet Draft: IMAP Extension for Conditional STORE A. Melnikov
Document: draft-ietf-imapext-condstore-01.txt S. Hole Document: draft-ietf-imapext-condstore-02.txt S. Hole
Expires: October 2003 ACI WorldWide/MessagingDirect Expires: December 2003 ACI WorldWide/MessagingDirect
April 2003 June 2003
IMAP Extension for Conditional STORE operation IMAP Extension for Conditional STORE operation
Status of this Memo Status of this Memo
This document is an Internet-Draft and is in full conformance with This document is an Internet-Draft and is in full conformance with
all provisions of Section 10 of RFC2026. Internet-Drafts are all provisions of Section 10 of RFC2026. Internet-Drafts are
working documents of the Internet Engineering Task Force (IETF), its working documents of the Internet Engineering Task Force (IETF), its
areas, and its working groups. Note that other groups may also areas, and its working groups. Note that other groups may also
distribute working documents as Internet-Drafts. distribute working documents as Internet-Drafts.
skipping to change at line 30 skipping to change at line 30
The list of current Internet-Drafts can be accessed at The list of current Internet-Drafts can be accessed at
http://www.ietf.org/ietf/1id-abstracts.txt. The list of Internet- http://www.ietf.org/ietf/1id-abstracts.txt. The list of Internet-
Draft Shadow Directories can be accessed at Draft Shadow Directories can be accessed at
http://www.ietf.org/shadow.html. http://www.ietf.org/shadow.html.
Copyright Notice Copyright Notice
Copyright (C) The Internet Society 2001-2003. All Rights Reserved. Copyright (C) The Internet Society 2001-2003. All Rights Reserved.
0.1. Open issues Please see the Full Copyright section near the end of this document
for more information.
1). Should conditional STORE be atomic accross message set (i.e. either
all messages in message set weren't changed since and conditional
STORE succeeds or operation fails for all messages)?
This can be difficult to implement for some servers.
Is a server allowed to reply NO to a conditional STORE operation that
contains more than one message? Do we need a special response code
for this (probably yes).
0.2. Change History
Changes from draft-ietf-imapext-condstore-00
1. Dropped "/message" prefix in entry names as per decision in San Francisco.
2. Fixed ABNF for SEARCH and SORT untagged responses.
3. Changed "private" to "priv" to be consistent with ANNOTATE.
4. MODIFIED response code is now returned in OK response, not NO.
5. Added NOMODSEQ response code.
Changes from draft-melnikov-imap-condstore-09:
1. Some text clarifications based on suggestions by Harrie Hazewinkel
2. Added paragraph about mailbox locking and DOS when conditional STORE
operation is performed on a large mailbox.
3. Fixed syntax of <entry-name> to match the ANNOTATE extention.
4. Added sentence that a system flag MUST always be considered existent,
when UNCHANGEDSINCE 0 is used. Is this a good idea?
5. Clarified client behavior upon receipt of MODIFIED response code.
6. Updated ABNF to clarify where 0 is allowed as mod-sequence and where
it is not.
7. Got rid of MODSEQ response code and return this data in the untagged
SEARCH/SORT responses.
8. Updated RFC number for the IMAP4rev1 document.
Changes from -08 to -09:
1. Added an extended example about reporting regular (non-conditional) flag
changes to other sessions.
2. Simplified FETCH MODSEQ syntax by removing per-metadata requests and
responses.
Changes from -07 to -08:
1. Added note saying the change to UIDVALIDITY also invalidates HIGHESTMODSEQ.
2. Fixed several bugs in ABNF for STATUS and STORE commands.
Changes from -06 to -07:
1. Added clarification that when a server does command reordering, the second
completed operation gets the higher mod sequence.
2. Renamed annotation type specifier "both" to "all" as per suggestion
from Minneapolis meeting.
3. Removed PERFLAGMODSEQ capability, as it doesn't buy anything: a client
has to work with both types of servers (i.e. servers that support per
message per flag modseqs and servers that support only per message
modseqs) anyway.
4. Per flag mod-sequences are optional for a server to return. Updated syntax.
5. Allow MODSEQ response code only as a result of SEARCH/SORT as suggested
by John Myers. MODSEQ response code is not allowed after FETCH or STORE.
Changes from -05 to -06:
1. Replaced "/message/flags/system" with "/message/flags" to
match ANNOTATE draft.
2. Extended FETCH/SEARCH/SORT syntax to allow for specifying
whether an operation should be performed on a shared or a private
annotation (or both).
3. Corrected some examples.
Changes from -04 to -05:
1. Added support for SORT extension.
2. Multiple language/spelling fixes by Randall Gellens.
Changes from -03 to -04:
1. Added text saying that MODSEQ fetch data items cause server
to include MODSEQ data response in all subsuquent unsolicited FETCH
responses.
2. Added "authors address" section.
Changes from -02 to -03:
1. Changed MODTIME untagged response to MODTIME response code.
2. Added MODTIME response code to the tagged OK response for SEARCH.
Updated examples accordingly.
3. Changed rule for sending untagged FETCH response as a result of
STORE when .SILENT prefix is used. If .SILENT prefix is used,
server doesn't have to send untagged FETCH response, because
MODTIME response code already contains modtime.
4. Renamed MODTIME to MODSEQ to make sure there is no confusion
between mod-sequence and ACAP modtime.
5. Minor ABNF changes.
6. Minor language corrections.
Changes from -01 to -02:
1. Added MODTIME data item to STATUS command.
2. Added OK untagged response to SELECT/EXAMINE.
3. Clarified that MODIFIED response code contains list of UIDs for
conditional UID STORE and message set for STORE.
4. Added per-message modtime.
5. Added PERFLAGMODTIME capability.
6. Fixed several bugs in examples.
7. Added more comments to ABNF.
Changes from -00 to -01:
1. Refreshed the list of Open Issues.
2. Changed "attr-name" to "entry-name", because modtime applies to
entry, not attribute.
3. Added MODTIME untagged response.
4. Cleaned up ABNF.
5. Added "Acknowledgments" section.
6. Fixed some spelling mistakes.
Table of Contents
1 Abstract .................................................. X
2 Conventions Used in This Document ......................... X
3 Introduction and Overview ................................. X
4 IMAP Protocol Changes ..................................... X
4.1 New OK untagged responses for SELECT and EXAMINE ......... X
4.1.1 HIGHESTMODSEQ response code ............................ X
4.1.2 NOMODSEQ response code ................................. X
4.2 STORE and UID STORE Commands ............................. X
4.3 MODSEQ message data item in FETCH Command ................ X
4.4 MODSEQ search criterion in SEARCH ........................ X
4.5 MODSEQ Sort Criterion .................................... X
4.6 Modified SEARCH and SORT untagged responses .............. X
4.7 HIGHESTMODSEQ status data items .......................... X
5 Formal Syntax ............................................. X
6 Security Considerations ................................... X
7 References ................................................ X
7.1 Normative References ..................................... X
7.2 Informative References ................................... X
8 Acknowledgments ........................................... X
9 Author's Addresses ........................................ X
10 Full Copyright Statement ................................. X
1. Abstract Abstract
Often, multiple IMAP clients need to coordinate changes to a common Often, multiple IMAP clients need to coordinate changes to a common
IMAP mailbox. Examples include different clients for the same user, IMAP mailbox. Examples include different clients for the same user,
and multiple users accessing shared mailboxes. These clients and multiple users accessing shared mailboxes. These clients
need a mechanism to synchronize state changes for messages within the need a mechanism to synchronize state changes for messages within the
mailbox. They must be able to guarantee that only one client can change mailbox. They must be able to guarantee that only one client can change
message state (e.g., message flags or annotations) at any time. An message state (e.g., message flags or annotations) at any time. An
example of such an application is use of an IMAP mailbox as a message example of such an application is use of an IMAP mailbox as a message
queue with multiple dequeueing clients. queue with multiple dequeueing clients.
The Conditional Store facility provides a protected update mechanism for The Conditional Store facility provides a protected update mechanism for
message state information that can detect and resolve conflicts between message state information that can detect and resolve conflicts between
multiple writing mail clients. multiple writing mail clients.
2. Conventions Used in This Document Table of Contents
1 Conventions Used in This Document ......................... X
2 Introduction and Overview ................................. X
3 IMAP Protocol Changes ..................................... X
3.1 New OK untagged responses for SELECT and EXAMINE ......... X
3.1.1 HIGHESTMODSEQ response code ............................ X
3.1.2 NOMODSEQ response code ................................. X
3.2 STORE and UID STORE Commands ............................. X
3.3 MODSEQ message data item in FETCH Command ................ X
3.4 MODSEQ search criterion in SEARCH ........................ X
3.5 MODSEQ Sort Criterion .................................... X
3.6 Modified SEARCH and SORT untagged responses .............. X
3.7 HIGHESTMODSEQ status data items .......................... X
3.8 CONDSTORE parameter to SELECT and EXAMINE ................ X
4 Formal Syntax ............................................. X
5 Security Considerations ................................... X
6 References ................................................ X
6.1 Normative References ..................................... X
6.2 Informative References ................................... X
7 IANA Considerations ....................................... X
8 Acknowledgments ........................................... X
9 Author's Addresses ........................................ X
10 Intellectual Property Rights .............................. X
11 Full Copyright Statement .................................. X
1. Conventions Used in This Document
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in RFC 2119 [KEYWORDS]. document are to be interpreted as described in RFC 2119 [KEYWORDS].
In examples, lines beginning with "S:" are sent by the IMAP server, and In examples, lines beginning with "S:" are sent by the IMAP server, and
lines beginning with "C:" are sent by the client. Line breaks may appear lines beginning with "C:" are sent by the client. Line breaks may appear
in example commands solely for editorial clarity; when present in in example commands solely for editorial clarity; when present in
the actual message they are represented by "CRLF". the actual message they are represented by "CRLF".
skipping to change at line 203 skipping to change at line 101
Some IMAP mailboxes are private, accessible only to the owning user. Some IMAP mailboxes are private, accessible only to the owning user.
Other mailboxes are not, either because the owner has set an ACL Other mailboxes are not, either because the owner has set an ACL
[ACL] which permits access by other users, or because it is a [ACL] which permits access by other users, or because it is a
shared mailbox. Let's call a metadata item "shared" for the mailbox shared mailbox. Let's call a metadata item "shared" for the mailbox
if any changes to the metadata items are persistent and visible to all if any changes to the metadata items are persistent and visible to all
other users accessing the mailbox. Otherwise the metadata item is called other users accessing the mailbox. Otherwise the metadata item is called
"private". Note, that private metadata items are still visible to all "private". Note, that private metadata items are still visible to all
sessions accessing the mailbox as the same user. Also note, that different sessions accessing the mailbox as the same user. Also note, that different
mailboxes may have different metadata items as shared. mailboxes may have different metadata items as shared.
3. Introduction and Overview See the next section for the definition of a "CONDSTORE-aware client"
and a "CONDSTORE enabling command".
2. Introduction and Overview
The Conditional STORE extension is present in any IMAP4 implementation The Conditional STORE extension is present in any IMAP4 implementation
which returns "CONDSTORE" as one of the supported capabilities in the which returns "CONDSTORE" as one of the supported capabilities in the
CAPABILITY command response. CAPABILITY command response.
Every IMAP message has an associated positive unsigned 64-bit value called a Every IMAP message has an associated positive unsigned 64-bit value called a
modification sequence (mod-sequence). This is an opaque value updated by modification sequence (mod-sequence). This is an opaque value updated by
the server whenever a metadata item is modified. The value is intended to the server whenever a metadata item is modified. The value is intended to
be used only for comparisons within a server. However, the server MUST be used only for comparisons within a server. However, the server MUST
guarantee that each STORE command performed on the same mailbox, including guarantee that each STORE command performed on the same mailbox, including
skipping to change at line 245 skipping to change at line 146
the appended message. the appended message.
When an annotation is added, modified or removed the corresponding message When an annotation is added, modified or removed the corresponding message
mod-sequence MUST be updated. mod-sequence MUST be updated.
The server MAY store separate (per message) modification sequence values for The server MAY store separate (per message) modification sequence values for
different metadata items. If the server does so, per message mod-sequence is different metadata items. If the server does so, per message mod-sequence is
the highest mod-sequence of all metadata items for the specified message. the highest mod-sequence of all metadata items for the specified message.
The server that supports this extention is not required to be able to store The server that supports this extention is not required to be able to store
mod-sequences for every available mailbox. Section 4.1.2 describes how mod-sequences for every available mailbox. Section 3.1.2 describes how
the server may act if a particular mailbox doesn't support the persistent the server may act if a particular mailbox doesn't support the persistent
storage of mod-sequences. storage of mod-sequences.
This extension makes the following changes to the IMAP4 protocol: This extension makes the following changes to the IMAP4 protocol:
a) extends the syntax of the STORE command to allow STORE a) extends the syntax of the STORE command to allow STORE
modifiers modifiers
b) adds the MODIFIED response code which should be used with b) adds the MODIFIED response code which should be used with
an OK response to the STORE command an OK response to the STORE command
c) adds a new MODSEQ message data item for use with the FETCH command c) adds a new MODSEQ message data item for use with the FETCH command
d) adds a new MODSEQ search criterion d) adds a new MODSEQ search criterion
e) extends syntax of untagged SEARCH and SORT responses to include e) extends the syntax of untagged SEARCH responses to include mod-sequence
mod-sequence.
f) adds a new OK untagged responses for the SELECT and EXAMINE commands f) adds new OK untagged responses for the SELECT and EXAMINE commands
g) adds the HIGHESTMODSEQ status data item to the STATUS command g) defines an additional parameter to SELECT/EXAMINE commands
h) adds a new MODSEQ sort criterion h) adds the HIGHESTMODSEQ status data item to the STATUS command
A client supporting CONDSTORE extension indicates its willingness to receive
mod-sequence updates in all untagged FETCH responses by issuing a SELECT or
EXAMINE command with the CONDSTORE parameter, or a FETCH, SEARCH, or SORT
(if it also supports SORT=MODSEQ extension, see below) command that includes
the MODSEQ message data item, or a STORE command with the UNCHANGEDSINCE modifier.
The server will include mod-sequence data in all FETCH responses, whether they
were caused by a regular STORE, STORE with UNCHANGEDSINCE modifier, or an external
agent, until the connection is closed.
This document uses the term "CONSTORE-aware client" to refer to a client
that announces its willingness to receive mod-sequence updates as described
above. The term "CONDSTORE enabling command" will refer any of the commands
listed above.
This document also defines a new SORT extension with a capability name
"SORT=MODSEQ". This extension is upwards compatible with the SORT extension
defined in [SORT]. Server implementations that support both the CONDSTORE and
SORT extensions SHOULD also support the SORT=MODSEQ extension. The
SORT=MODSEQ extension makes the following additions to the SORT extension:
a) extends syntax of untagged SORT responses to include mod-sequence
(see section 3.6)
b) adds a new MODSEQ sort criterion (see sections 3.4 and 3.5)
The rest of this document describes the protocol changes more rigorously. The rest of this document describes the protocol changes more rigorously.
4. IMAP Protocol Changes 3. IMAP Protocol Changes
4.1. New OK untagged responses for SELECT and EXAMINE 3.1. New OK untagged responses for SELECT and EXAMINE
This document adds two new response codes HIGHESTMODSEQ and NOMODSEQ. This document adds two new response codes HIGHESTMODSEQ and NOMODSEQ.
One of those response codes MUST be returned in the OK untagged One of those response codes MUST be returned in the OK untagged
response for a successful SELECT and EXAMINE commands. response for a successful SELECT and EXAMINE commands.
When opening a mailbox the server must check if the mailbox supports When opening a mailbox the server must check if the mailbox supports
the persistent storage of mod-sequences. If the mailbox supports the persistent storage of mod-sequences. If the mailbox supports
the persistent storage of mod-sequences and mailbox open operation succeeds, the persistent storage of mod-sequences and mailbox open operation succeeds,
the server MUST send the OK untagged response including HIGHESTMODSEQ the server MUST send the OK untagged response including HIGHESTMODSEQ
response code. If the persistent storage for the mailbox is not supported, response code. If the persistent storage for the mailbox is not supported,
the server MUST send the OK untagged response including NOMODSEQ response the server MUST send the OK untagged response including NOMODSEQ response
code instead. code instead.
4.1.1. HIGHESTMODSEQ response code 3.1.1. HIGHESTMODSEQ response code
This document adds a new response code that is returned in the OK This document adds a new response code that is returned in the OK
untagged response for the SELECT and EXAMINE commands. A server untagged response for the SELECT and EXAMINE commands. A server
supporting the persistent storage of mod-sequences for the mailbox MUST supporting the persistent storage of mod-sequences for the mailbox MUST
send the OK untagged response including HIGHESTMODSEQ response code with send the OK untagged response including HIGHESTMODSEQ response code with
every successful SELECT or EXAMINE command: every successful SELECT or EXAMINE command:
OK [HIGHESTMODSEQ <mod-sequence-value>] OK [HIGHESTMODSEQ <mod-sequence-value>]
Where <mod-sequence-value> is the highest mod-sequence value of all Where <mod-sequence-value> is the highest mod-sequence value of all
skipping to change at line 311 skipping to change at line 236
mailbox. mailbox.
A disconnected client can use the value of HIGHESTMODSEQ to check if A disconnected client can use the value of HIGHESTMODSEQ to check if
it has to refetch flags and/or annotations from the server. If the it has to refetch flags and/or annotations from the server. If the
UIDVALIDITY value has changed for the selected mailbox, the client UIDVALIDITY value has changed for the selected mailbox, the client
MUST delete the cached value of HIGHESTMODSEQ. If UIDVALIDITY for MUST delete the cached value of HIGHESTMODSEQ. If UIDVALIDITY for
the mailbox is the same and if the HIGHESTMODSEQ value stored in the mailbox is the same and if the HIGHESTMODSEQ value stored in
the client's cache is less than the value returned by the server, the client's cache is less than the value returned by the server,
then some metadata items on the server have changed since the last then some metadata items on the server have changed since the last
synchronization, and the client needs to update its cache. The client synchronization, and the client needs to update its cache. The client
MAY use SEARCH MODSEQ as described in section 4.4 to find out exactly MAY use SEARCH MODSEQ as described in section 3.4 to find out exactly
which metadata items have changed. which metadata items have changed.
Example: C: A142 SELECT INBOX Example: C: A142 SELECT INBOX
S: * 172 EXISTS S: * 172 EXISTS
S: * 1 RECENT S: * 1 RECENT
S: * OK [UNSEEN 12] Message 12 is first unseen S: * OK [UNSEEN 12] Message 12 is first unseen
S: * OK [UIDVALIDITY 3857529045] UIDs valid S: * OK [UIDVALIDITY 3857529045] UIDs valid
S: * OK [UIDNEXT 4392] Predicted next UID S: * OK [UIDNEXT 4392] Predicted next UID
S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
S: * OK [PERMANENTFLAGS (\Deleted \Seen \*)] Limited S: * OK [PERMANENTFLAGS (\Deleted \Seen \*)] Limited
S: * OK [HIGHESTMODSEQ 20010715194045007] S: * OK [HIGHESTMODSEQ 20010715194045007]
S: A142 OK [READ-WRITE] SELECT completed S: A142 OK [READ-WRITE] SELECT completed
4.1.2 NOMODSEQ response code 3.1.2 NOMODSEQ response code
A server that doesn't support the persistent storage of mod-sequences for A server that doesn't support the persistent storage of mod-sequences for
the mailbox MUST send the OK untagged response including NOMODSEQ response the mailbox MUST send the OK untagged response including NOMODSEQ response
code with every successful SELECT or EXAMINE command. code with every successful SELECT or EXAMINE command.
Example: C: A142 SELECT INBOX Example: C: A142 SELECT INBOX
S: * 172 EXISTS S: * 172 EXISTS
S: * 1 RECENT S: * 1 RECENT
S: * OK [UNSEEN 12] Message 12 is first unseen S: * OK [UNSEEN 12] Message 12 is first unseen
S: * OK [UIDVALIDITY 3857529045] UIDs valid S: * OK [UIDVALIDITY 3857529045] UIDs valid
S: * OK [UIDNEXT 4392] Predicted next UID S: * OK [UIDNEXT 4392] Predicted next UID
S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
S: * OK [PERMANENTFLAGS (\Deleted \Seen \*)] Limited S: * OK [PERMANENTFLAGS (\Deleted \Seen \*)] Limited
S: * OK [NOMODSEQ] Sorry, this mailbox format doesn't support modsequences S: * OK [NOMODSEQ] Sorry, this mailbox format doesn't support modsequences
S: A142 OK [READ-WRITE] SELECT completed S: A142 OK [READ-WRITE] SELECT completed
4.2. STORE and UID STORE Commands 3.2. STORE and UID STORE Commands
Arguments: message set Arguments: message set
OPTIONAL store modifiers OPTIONAL store modifiers
message data item name message data item name
value for message data item value for message data item
Responses: untagged responses: FETCH Responses: untagged responses: FETCH
Result: OK - store completed Result: OK - store completed
NO - store error: can't store that data NO - store error: can't store that data
BAD - command unknown or arguments invalid BAD - command unknown or arguments invalid
This document extends the syntax of the STORE and UID STORE This document extends the syntax of the STORE and UID STORE
commands (see section 6.4.6 of [IMAP4]) to include an optional STORE commands (see section 6.4.6 of [IMAP4]) to include an optional STORE
modifier. The document defines the following modifier: modifier. The document defines the following modifier:
UNCHANGEDSINCE UNCHANGEDSINCE
If the mod-sequence of any metadata item specified in the STORE For each message specified in the message set the server performs
operation for any message in the message set is greater than the the following. If the mod-sequence of any metadata item of the
specified unchangedsince value, then the command MUST NOT change message is equal or less than the specified UNCHANGEDSINCE value,
any flags. Instead, the server replies with the OK tagged response that then the requested operation (as described by the
includes a MODIFIED response code. The MODIFIED response code includes message data item) is performed. If the operation is successful
the message set (for STORE) or set of UIDs (for UID STORE) the server MUST update the mod-sequence attribute of the message.
of all messages that failed the UNCHANGESINCE test. An untagged FETCH response MUST be sent (even if the .SILENT suffix
is specified) and the response MUST include the MODSEQ message data
item. This is required to update the client's cache with the correct
mod-sequence values. See section 3.3 for more details.
However, if the mod-sequence of any metadata item of the
message is greater than the specified UNCHANGEDSINCE value, than
the requested operation MUST NOT be performed. In this case,
the mod-sequence attribute of the message is not updated, and the
message number (or unique identifier in the case of the UID STORE
command) is added to the list of messages that failed the UNCHANGESINCE test.
When the server finished performing the operation on all the messages
in the message set, it checks for a non-empty list of messages that
failed the UNCHANGESINCE test. If this list is non-empty, the server MUST
return in the tagged response a MODIFIED response code. The MODIFIED
response code includes the message set (for STORE) or set of UIDs
(for UID STORE) of all messages that failed the UNCHANGESINCE test.
Example: Example:
C: a101 STORE 7,5,9 (UNCHANGEDSINCE 20000320162338) All messages pass the UNCHANGESINCE test.
C: a103 UID STORE 6,4,8 (UNCHANGEDSINCE 200012121230045)
+FLAGS.SILENT (\Deleted) +FLAGS.SILENT (\Deleted)
S: a101 OK [MODIFIED 7,9] Conditional STORE failed S: * 1 FETCH (UID 4 MODSEQ (200012121231000))
S: * 2 FETCH (UID 6 MODSEQ (200012101230852))
S: * 4 FETCH (UID 8 MODSEQ (200012121130956))
S: a103 OK Conditional Store completed
Example:
C: a104 STORE * (UNCHANGEDSINCE 200012121230045) +FLAGS.SILENT
(\Deleted $Processed)
S: * 50 FETCH (MODSEQ (200012111230045))
S: a104 OK Store (conditional) completed
Example:
In spite of the failure of the conditional STORE operation In spite of the failure of the conditional STORE operation
for message 7, the server continues to process the conditional for message 7, the server continues to process the conditional
STORE in order to find all messages which fail the test. STORE in order to find all messages which fail the test.
C: a105 STORE 7,5,9 (UNCHANGEDSINCE 20000320162338)
+FLAGS.SILENT (\Deleted)
S: * 5 FETCH (MODSEQ (20000320162350))
S: a105 OK [MODIFIED 7,9] Conditional STORE failed
Example:
Same as above, but the server follows SHOULD recommendation
in section 6.4.6 of [IMAP4].
C: a105 STORE 7,5,9 (UNCHANGEDSINCE 20000320162338)
+FLAGS.SILENT (\Deleted)
S: * 7 FETCH (MODSEQ (20000320162342) FLAGS (\Seen \Deleted))
S: * 5 FETCH (MODSEQ (20000320162350))
S: * 9 FETCH (MODSEQ (20000320162349) FLAGS (\Answered))
S: a105 OK [MODIFIED 7,9] Conditional STORE failed
Use of UNCHANGEDSINCE with a modification sequence of 0 Use of UNCHANGEDSINCE with a modification sequence of 0
always fails if the metadata item exists. A system flag always fails if the metadata item exists. A system flag
MUST always be considered existent, whether it was set or not. MUST always be considered existent, whether it was set or not.
Example: Example:
C: a102 STORE 12 (UNCHANGEDSINCE 0) C: a102 STORE 12 (UNCHANGEDSINCE 0)
+FLAGS.SILENT ($MDNSent) +FLAGS.SILENT ($MDNSent)
S: a102 OK [MODIFIED 12] Conditional STORE failed S: a102 OK [MODIFIED 12] Conditional STORE failed
Note: A client trying to atomically change the state of a particular Note: A client trying to make an atomic change to the state of a particular
flag (or a set of flags) should be prepared to deal with the case metadata item (or a set of metadata items) should be prepared
when the server returns MODIFIED response code if the state to deal with the case when the server returns MODIFIED response code
of the flag being watched hasn't changed (but the state of some if the state of the metadata item being watched hasn't changed (but
other flag has). This is necessary, because some servers don't store the state of some other metadata item has). This is necessary, because
separate mod-sequences for different flags or annotations. However, some servers don't store separate mod-sequences for different metadata
server implementations are discouraged from doing that, as it is items. However, a server implementation SHOULD avoid generating
possible not to return spurious errors even when storing a single spurious MODIFIED responses for +FLAGS/-FLAGS STORE operations,
mod-sequence per message. even when the server stores a single mod-sequence per message.
Upon the receipt of MODIFIED response code the client SHOULD try to Upon the receipt of MODIFIED response code the client SHOULD try to
figure out if the required flags have indeed changed. If they haven't figure out if the required metadata items have indeed changed. If they
the client SHOULD retry the command. haven't the client SHOULD retry the command.
Example: Example:
C: a106 STORE 100:150 (UNCHANGEDSINCE 200212030000000) C: a106 STORE 100:150 (UNCHANGEDSINCE 200212030000000)
+FLAGS.SILENT ($Processed) +FLAGS.SILENT ($Processed)
S: * 100 FETCH (MODSEQ (200303181230852))
S: * 102 FETCH (MODSEQ (200303181230852))
...
S: * 150 FETCH (MODSEQ (200303181230852))
S: a106 OK [MODIFIED 101] Conditional STORE failed S: a106 OK [MODIFIED 101] Conditional STORE failed
the flag $Processed was set on the message 101 ... the flag $Processed was set on the message 101 ...
C: a107 NOOP C: a107 NOOP
S: * 101 FETCH (MODSEQ (200303011130956) FLAGS ($Processed)) S: * 101 FETCH (MODSEQ (200303011130956) FLAGS ($Processed))
S: a107 OK S: a107 OK
... so the client retries the operation for the rest of the messages
C: a108 STORE 100,102:150 (UNCHANGEDSINCE 200303011130956)
+FLAGS.SILENT ($Processed)
S: * 100 FETCH (MODSEQ (200303181230852))
S: * 102 FETCH (MODSEQ (200303181230852))
...
S: a108 OK Conditional Store completed
Or the flag hasn't changed ... Or the flag hasn't changed ...
C: b107 NOOP C: b107 NOOP
S: * 101 FETCH (MODSEQ (200303011130956) FLAGS (\Deleted \Answered)) S: * 101 FETCH (MODSEQ (200303011130956) FLAGS (\Deleted \Answered))
S: b107 OK S: b107 OK
... and the client retries the operation for all messages ... and the client retries the operation for the message 100
with the updated UNCHANGEDSINCE value
C: b108 STORE 100:150 (UNCHANGEDSINCE 200212030000000) C: b108 STORE 100 (UNCHANGEDSINCE 200303011130956)
+FLAGS.SILENT ($Processed) +FLAGS.SILENT ($Processed)
S: * 100 FETCH (MODSEQ (200303181230852)) S: * 100 FETCH (MODSEQ (200303181230852))
S: * 101 FETCH (MODSEQ (200303181230852))
S: * 102 FETCH (MODSEQ (200303181230852))
...
S: b108 OK Conditional Store completed S: b108 OK Conditional Store completed
If the operation is successful the server MUST update the
mod-sequence attribute for every message that was changed.
Untagged FETCH responses MUST be sent (even if .SILENT is
specified) and each response MUST include MODSEQ message data
item if its mod-sequence has changed. This is required to
update clients cache with the correct mod-sequence values.
See section 4.3 for more details.
Example: Example:
C: a103 UID STORE 6,4,8 (UNCHANGEDSINCE 200012121230045) The following example is based on the example from the section 4.2.3 of
+FLAGS.SILENT (\Deleted) [RFC-2180] and demonstrates that the MODIFIED response code may be also
S: * 1 FETCH (UID 4 MODSEQ (200012121231000)) returned in the tagged NO response.
S: * 2 FETCH (UID 6 MODSEQ (200012101230852))
S: * 4 FETCH (UID 8 MODSEQ (200012121130956))
S: a103 OK Conditional Store completed
Example: Client tries to conditionally STORE flags on a mixture of expunged
and non-expunged messages, one message fails the UNCHANGEDSINCE test.
C: a104 STORE * (UNCHANGEDSINCE 200012121230045) +FLAGS.SILENT C: B001 STORE 1:7 (UNCHANGEDSINCE 20000320172338) +FLAGS (\SEEN)
(\Deleted $Processed) S: * 1 FETCH FLAGS (MODSEQ (20000320172342) \SEEN)
S: * 50 FETCH (MODSEQ (200012111230045)) S: * 3 FETCH FLAGS (MODSEQ (20000320172342) \SEEN)
S: a104 OK Store (conditional) completed S: B001 NO [MODIFIED 2] Some of the messages no longer exist.
C: B002 NOOP
S: * 4 EXPUNGE
S: * 4 EXPUNGE
S: * 4 EXPUNGE
S: * 4 EXPUNGE
S: * 2 FETCH (MODSEQ (20000320172340) FLAGS (\Deleted \Answered))
S: B002 OK NOOP Completed.
By receiving FETCH responses for messages 1 and 3, and EXPUNGE
responses that indicate that messages 4:7 have been expunged,
the client retries the operation only for the message 2. The
updated UNCHANGEDSINCE value is used.
C: b003 STORE 2 (UNCHANGEDSINCE 20000320172340) +FLAGS (\Seen)
S: * 2 FETCH (MODSEQ (20000320180050))
S: b003 OK Conditional Store completed
Note: If a message is specified multiple times in the message Note: If a message is specified multiple times in the message
set, and the server doesn't internally eliminate duplicates from set, and the server doesn't internally eliminate duplicates from
the message set, it MUST NOT fail the conditional STORE the message set, it MUST NOT fail the conditional STORE
operation for the second (or subsequent) occurrence of the message operation for the second (or subsequent) occurrence of the message
if the operation completed successfully for the first occurrence. if the operation completed successfully for the first occurrence.
For example, if the client specifies: For example, if the client specifies:
a105 STORE 7,3:9 (UNCHANGEDSINCE 200012121230045) a105 STORE 7,3:9 (UNCHANGEDSINCE 200012121230045)
+FLAGS.SILENT (\Deleted) +FLAGS.SILENT (\Deleted)
the server must not fail the operation for message 7 as part of the server must not fail the operation for message 7 as part of
processing "3:9" if it succeeded when message 7 was processed processing "3:9" if it succeeded when message 7 was processed
the first time. the first time.
4.3. MODSEQ message data item in FETCH Command Once the client specified the UNCHANGEDSINCE modifier in a STORE command,
the server MUST include the MODSEQ fetch response data items in all
subsequent unsolicited FETCH responses.
This document also changes the behaviour of the server when it has performed
a STORE or UID STORE command and the UNCHANGEDSINCE modifier is not specified.
If the operation is successful for a message, the server MUST update
the mod-sequence attribute of the message. The server is REQUIRED to
include the mod-sequence value whenever it decides to send the
unsolicited FETCH response to all CONDSTORE-aware clients that have opened
the mailbox containing the message.
3.3. MODSEQ message data item in FETCH Command
This extension adds a MODSEQ message data item to the FETCH command. This extension adds a MODSEQ message data item to the FETCH command.
The MODSEQ message data item allows clients to retrieve mod-sequence The MODSEQ message data item allows clients to retrieve mod-sequence
values for a range of messages in the currently selected mailbox. values for a range of messages in the currently selected mailbox.
Once the client specified the MODSEQ message data item in a FETCH request, Once the client specified the MODSEQ message data item in a FETCH request,
the server MUST include the MODSEQ fetch response data items in all the server MUST include the MODSEQ fetch response data items in all
subsequent unsolicited FETCH responses. subsequent unsolicited FETCH responses.
Syntax: MODSEQ Syntax: MODSEQ
The MODSEQ message data item causes the server to return MODSEQ fetch The MODSEQ message data item causes the server to return MODSEQ fetch
response data items. response data items.
Syntax: MODSEQ ( <permsg-modsequence> ) Syntax: MODSEQ ( <permsg-modsequence> )
MODSEQ response data items contain per-message mod-sequences. MODSEQ response data items contain per-message mod-sequences.
The MODSEQ response data item is returned if the client issued FETCH with The MODSEQ response data item is returned if the client issued FETCH with
MODSEQ message data item. It also allows the server to notify the client MODSEQ message data item. It also allows the server to notify the client
about mod-sequence changes caused by conditional STOREs (section 4.2) and/or about mod-sequence changes caused by conditional STOREs (section 3.2) and/or
changes caused by external sources. changes caused by external sources.
Example: Example:
C: a FETCH 1:3 (MODSEQ) C: a FETCH 1:3 (MODSEQ)
S: * 1 FETCH (MODSEQ (20000624140003)) S: * 1 FETCH (MODSEQ (20000624140003))
S: * 2 FETCH (MODSEQ (20000624140007)) S: * 2 FETCH (MODSEQ (20000624140007))
S: * 3 FETCH (MODSEQ (20000624140005)) S: * 3 FETCH (MODSEQ (20000624140005))
S: a OK Fetch complete S: a OK Fetch complete
skipping to change at line 579 skipping to change at line 564
C: C360 NOOP C: C360 NOOP
S: * 7 FETCH (FLAGS (\Deleted) MODSEQ (200012121245160)) S: * 7 FETCH (FLAGS (\Deleted) MODSEQ (200012121245160))
S: C360 OK Noop completed S: C360 OK Noop completed
... and only changes to shared flags are reported in session 3. ... and only changes to shared flags are reported in session 3.
C: D390 NOOP C: D390 NOOP
S: * 7 FETCH (FLAGS (\Deleted) MODSEQ (200012121245160)) S: * 7 FETCH (FLAGS (\Deleted) MODSEQ (200012121245160))
S: D390 OK Noop completed S: D390 OK Noop completed
4.4. MODSEQ search criterion in SEARCH 3.4. MODSEQ search criterion in SEARCH
The MODSEQ criterion for the SEARCH command allows a client to search The MODSEQ criterion for the SEARCH command allows a client to search
for the metadata items that were modified since a specified moment. for the metadata items that were modified since a specified moment.
Syntax: MODSEQ [<entry-name> <entry-type-req>] <mod-sequence-valzer> Syntax: MODSEQ [<entry-name> <entry-type-req>] <mod-sequence-valzer>
Messages that have modification values which are equal to or Messages that have modification values which are equal to or
greater than <mod-sequence-valzer>. This allows a client, greater than <mod-sequence-valzer>. This allows a client,
for example, to find out which messages contain metadata items for example, to find out which messages contain metadata items
that have changed since the last time it updated its disconnected that have changed since the last time it updated its disconnected
cache. The client may also specify <entry-name> (name of metadata cache. The client may also specify <entry-name> (name of metadata
item) and <entry-type-req> (type of metadata item) before item) and <entry-type-req> (type of metadata item) before
<mod-sequence-valzer>. <entry-type-req> can be one of "shared", <mod-sequence-valzer>. <entry-type-req> can be one of "shared",
"priv" (private) or "all". The latter means that the server should use "priv" (private) or "all". The latter means that the server should use
the biggest value among "priv" and "shared" mod-sequences for the the biggest value among "priv" and "shared" mod-sequences for the
metadata item. If the server doesn't store internally separate metadata item. If the server doesn't store internally separate
mod-sequences for different flags and annotations, it MUST ignore mod-sequences for different metadata items, it MUST ignore
<entry-name> and <entry-type-req>. Otherwise the server should <entry-name> and <entry-type-req>. Otherwise the server should
use them to narrow down the search. use them to narrow down the search.
For a flag <flagname> the corresponding <entry-name> has a form For a flag <flagname> the corresponding <entry-name> has a form
"/flags/<flagname>" as defined in [ANNOTATE]. Note, that "/flags/<flagname>" as defined in [ANNOTATE]. Note, that
the leading "\" character that denotes a system flag has to be the leading "\" character that denotes a system flag has to be
escaped as per Section 4.3 of [IMAP4], as the <entry-name> uses escaped as per Section 4.3 of [IMAP4], as the <entry-name> uses
syntax for quoted strings. syntax for quoted strings.
If client specifies a MODSEQ criterion in a SEARCH command and If client specifies a MODSEQ criterion in a SEARCH command and
the server returns a non-empty SEARCH result, the server MUST also the server returns a non-empty SEARCH result, the server MUST also
return a MODSEQ response code in the tagged OK response. The MODSEQ append (to the end of the untagged SEARCH response) the highest
response code covers all messages returned in the untagged SEARCH results. mod-sequence for all messages being returned. See also section 3.6.
See also section 4.6.
Example: Example:
C: a SEARCH MODSEQ "/flags/draft" all 20010320162338 C: a SEARCH MODSEQ "/flags/\\draft" all 20010320162338
ANNOTATION "/comment" "value" "IMAP4" ANNOTATION "/comment" "value" "IMAP4"
S: * SEARCH 2 5 6 7 11 12 18 19 20 23 (MODSEQ 20010917162500) S: * SEARCH 2 5 6 7 11 12 18 19 20 23 (MODSEQ 20010917162500)
S: a OK Search complete S: a OK Search complete
In the above example, the message numbers of any messages In the above example, the message numbers of any messages
containing the string "IMAP4" in the "value" attribute of the containing the string "IMAP4" in the "value" attribute of the
"/comment" entry and having a mod-sequence equal to or "/comment" entry and having a mod-sequence equal to or
greater than 20010320162338 for the "\Draft" flag are returned in greater than 20010320162338 for the "\Draft" flag are returned in
the search results. the search results.
Example: Example:
C: a SEARCH OR NOT MODSEQ 20010320162338 LARGER 50000 C: a SEARCH OR NOT MODSEQ 20010320162338 LARGER 50000
S: * SEARCH S: * SEARCH
S: a OK Search complete, nothing found S: a OK Search complete, nothing found
4.5. MODSEQ Sort Criterion 3.5. MODSEQ Sort Criterion
If a server implementing CONDSTORE also implements the SORT If a server implementing CONDSTORE also implements the SORT
extension as defined by [SORT], it MUST also support sorting on extension as defined by [SORT], it SHOULD implement the
per-message mod-sequence. SORT=MODSEQ extension that allows for sorting on per-message
mod-sequence. SORT=MODSEQ extension adds MODSEQ sort criterion
Syntax: MODSEQ that allows to sort the matching messages based on their mod-sequence.
If client specifies a MODSEQ search (as per section 4.4) or sort If client specifies a MODSEQ search (as per section 3.4) or sort
criterion in the SORT command and the server returns a non-empty criterion in the SORT command and the server returns a non-empty
SORT result, the server MUST also return a MODSEQ response SORT result, the server MUST also append (to the end of the untagged
code in the tagged OK response which covers all messages returned SORT response) the highest mod-sequence for all messages being returned.
in untagged SORT responses. See also section 4.6. See also section 3.6.
Example (MODSEQ search criterion):
Example:
C: A282 SORT (SUBJECT MODSEQ) UTF-8 SINCE 1-Feb-2001 C: A282 SORT (SUBJECT MODSEQ) UTF-8 SINCE 1-Feb-2001
S: * SORT 2 81 83 84 82 882 (MODSEQ 117) S: * SORT 2 81 83 84 82 882 (MODSEQ 117)
S: A282 OK SORT completed S: A282 OK SORT completed
Example: Example (MODSEQ sort criterion):
C: A283 SORT (SUBJECT REVERSE DATE) UTF-8 MODSEQ 21 C: A283 SORT (SUBJECT REVERSE DATE) UTF-8 MODSEQ 21
S: * SORT 6 3 4 5 2 (MODSEQ 125) S: * SORT 6 3 4 5 2 (MODSEQ 125)
S: A283 OK SORT completed S: A283 OK SORT completed
Example: Example (MODSEQ search criterion and MODSEQ SORT criterion,
but no messages matching the search criteria):
C: A284 SORT (MODSEQ) KOI8-R OR NOT MODSEQ 20010320162338 C: A284 SORT (MODSEQ) KOI8-R OR NOT MODSEQ 20010320162338
SUBJECT "Privet" SUBJECT "Privet"
S: * SORT S: * SORT
S: A284 OK Sort complete, nothing found S: A284 OK Sort complete, nothing found
4.6. Modified SEARCH and SORT untagged responses 3.6. Modified SEARCH and SORT untagged responses
Data: zero or more numbers Data: zero or more numbers
mod-sequence value (omitted if no match) mod-sequence value (omitted if no match)
This document extends syntax of the untagged SEARCH and SORT responses This document extends syntax of the untagged SEARCH and SORT responses
to include mod-sequence for all messages being returned. to include mod-sequence for all messages being returned.
If a client specifies a MODSEQ criterion in a SEARCH (or UID SEARCH) If a client specifies a MODSEQ criterion in a SEARCH (or UID SEARCH)
command and the server returns a non-empty SEARCH result, the server command and the server returns a non-empty SEARCH result, the server
MUST also append (to the end of the untagged SEARCH response) the MUST also append (to the end of the untagged SEARCH response) the
highest mod-sequence for all messages being returned. highest mod-sequence for all messages being returned. See section
3.4 for examples.
If client specifies a MODSEQ search or sort criterion in a SORT If client specifies a MODSEQ search or sort criterion in a SORT
(or UID SORT) command and the server returns a non-empty SORT result, (or UID SORT) command and the server returns a non-empty SORT result,
the server MUST also append (to the end of the untagged SORT response) the server MUST also append (to the end of the untagged SORT response)
the highest mod-sequence for all messages being returned. the highest mod-sequence for all messages being returned. See section
3.5 for examples.
4.7. HIGHESTMODSEQ status data items 3.7. HIGHESTMODSEQ status data items
This document defines a new status data item: This document defines a new status data item:
HIGHESTMODSEQ HIGHESTMODSEQ
The highest mod-sequence value all messages The highest mod-sequence value all messages
in the mailbox. This is the same value that is returned by the server in the mailbox. This is the same value that is returned by the server
in the HIGHESTMODSEQ response code in OK untagged response in the HIGHESTMODSEQ response code in OK untagged response
(see section 4.1.1). (see section 3.1.1).
Example: C: A042 STATUS blurdybloop (UIDNEXT MESSAGES HIGHESTMODSEQ) Example: C: A042 STATUS blurdybloop (UIDNEXT MESSAGES HIGHESTMODSEQ)
S: * STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292 S: * STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292
HIGHESTMODSEQ 200201011231777) HIGHESTMODSEQ 200201011231777)
S: A042 OK STATUS completed S: A042 OK STATUS completed
5. Formal Syntax 3.8. CONDSTORE parameter to SELECT and EXAMINE
The CONDSTORE extension defines a single optional select parameter
"CONDSTORE", which tells the server that it MUST include the MODSEQ
fetch response data items in all subsequent unsolicited FETCH responses.
The CONDSTORE parameter to SELECT/EXAMINE helps to avoid a race condition
that might arise when a metadata item(s) is(are) modified in another session
after the server has sent the HIGHESTMODSEQ response code and before the
client was able to issue a CONDSTORE enabling command.
Example: C: A142 SELECT INBOX (CONDSTORE)
S: * 172 EXISTS
S: * 1 RECENT
S: * OK [UNSEEN 12] Message 12 is first unseen
S: * OK [UIDVALIDITY 3857529045] UIDs valid
S: * OK [UIDNEXT 4392] Predicted next UID
S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
S: * OK [PERMANENTFLAGS (\Deleted \Seen \*)] Limited
S: * OK [HIGHESTMODSEQ 20010715194045007]
S: A142 OK [READ-WRITE] SELECT completed, CONDSTORE is now enabled
4. Formal Syntax
The following syntax specification uses the Augmented Backus-Naur The following syntax specification uses the Augmented Backus-Naur
Form (ABNF) notation as specified in [ABNF]. Form (ABNF) notation as specified in [ABNF].
Non-terminals referenced but not defined below are as defined by Non-terminals referenced but not defined below are as defined by
[IMAP4]. [IMAP4].
Except as noted otherwise, all alphabetic characters are case- Except as noted otherwise, all alphabetic characters are case-
insensitive. The use of upper or lower case characters to define token insensitive. The use of upper or lower case characters to define token
strings is for editorial clarity only. Implementations MUST accept strings is for editorial clarity only. Implementations MUST accept
these strings in a case-insensitive fashion. these strings in a case-insensitive fashion.
capability =/ "CONDSTORE" capability =/ "CONDSTORE" / "SORT=MODSEQ"
status = "STATUS" SP mailbox SP status = "STATUS" SP mailbox SP
"(" status-att-req *(SP status-att-req) ")" "(" status-att-req *(SP status-att-req) ")"
;; redefine STATUS command syntax defined in [IMAP4] ;; redefine STATUS command syntax defined in [IMAP4]
status-att-req = status-att / "HIGHESTMODSEQ" status-att-req = status-att / "HIGHESTMODSEQ"
status-rsp-info = status-att SP number / status-rsp-info = status-att SP number /
"HIGHESTMODSEQ" SP mod-sequence-value "HIGHESTMODSEQ" SP mod-sequence-value
skipping to change at line 733 skipping to change at line 745
fetch-att =/ fetch-mod-sequence fetch-att =/ fetch-mod-sequence
;; modifies original IMAP4 fetch-att ;; modifies original IMAP4 fetch-att
fetch-mod-sequence = "MODSEQ" fetch-mod-sequence = "MODSEQ"
fetch-mod-resp = "MODSEQ" SP "(" permsg-modsequence ")" fetch-mod-resp = "MODSEQ" SP "(" permsg-modsequence ")"
search-key =/ search-modsequence search-key =/ search-modsequence
;; modifies original IMAP4 search-key ;; modifies original IMAP4 search-key
;;
;; This change applies to all command referencing this
;; non-terminal, in particular SEARCH and SORT.
search-modsequence = "MODSEQ" [search-modseq-ext] SP mod-sequence-valzer search-modsequence = "MODSEQ" [search-modseq-ext] SP mod-sequence-valzer
search-modseq-ext = SP entry-name SP entry-type-req search-modseq-ext = SP entry-name SP entry-type-req
resp-text-code =/ "HIGHESTMODSEQ" SP mod-sequence-value / resp-text-code =/ "HIGHESTMODSEQ" SP mod-sequence-value /
"NOMODSEQ" / "NOMODSEQ" /
"MODIFIED" SP set "MODIFIED" SP set
entry-name = '"' "/flags/" attr-flag '"' entry-name = entry-name-flag / entry-annotate-name
;; The server MUST understand entry-name-flag.
;; If the server also supports [ANNOTATE], it MUST
;; also support entry-annotate-name.
entry-flag-name = '"' "/flags/" attr-flag '"'
;; each system or user defined flag <flag> ;; each system or user defined flag <flag>
;; is mapped to "/flags/<flag>". ;; is mapped to "/flags/<flag>".
;; ;;
;; <entry-name> follows the escape rules used ;; <entry-flag-name> follows the escape rules used
;; by "quoted" string as described in Section ;; by "quoted" string as described in Section
;; 4.3 of [IMAP4], e.g. for the flag \Seen ;; 4.3 of [IMAP4], e.g. for the flag \Seen
;; the corresponding <entry-name> is ;; the corresponding <entry-name> is
;; "/flags/\\seen", and for the flag ;; "/flags/\\seen", and for the flag
;; $MDNSent, the corresponding <entry-name> ;; $MDNSent, the corresponding <entry-name>
;; is "/flags/$mdnsent". ;; is "/flags/$mdnsent".
entry-annotate-name = entry
;; <entry> is defined in [ANNOTATE]
entry-type-resp = "priv" | "shared" entry-type-resp = "priv" | "shared"
;; metadata item type ;; metadata item type
entry-type-req = entry-type-resp | "all" entry-type-req = entry-type-resp | "all"
;; perform SEARCH operation on private ;; perform SEARCH operation on private
;; metadata item, shared metadata item or both ;; metadata item, shared metadata item or both
permsg-modsequence = mod-sequence-value permsg-modsequence = mod-sequence-value
;; per message mod-sequence ;; per message mod-sequence
mod-sequence-value = 1*DIGIT mod-sequence-value = 1*DIGIT
;; Positive unsigned 64-bit integer (mod-sequence) ;; Positive unsigned 64-bit integer (mod-sequence)
;; (1 <= n < 18,446,744,073,709,551,615) ;; (1 <= n < 18,446,744,073,709,551,615)
mod-sequence-valzer = "0" | mod-sequence-value mod-sequence-valzer = "0" | mod-sequence-value
search_sort_mod_seq = "(" "MODSEQ" SP mod-sequence-value ")" search_sort_mod_seq = "(" "MODSEQ" SP mod-sequence-value ")"
sort-key =/ "MODSEQ" sort-key =/ "MODSEQ"
condstore-param = "CONDSTORE"
;; defines the select parameter used with
;; CONDSTORE extension
;;Borrowed from IMAP4rev1 and modified accordingly: ;;Borrowed from IMAP4rev1 and modified accordingly:
mailbox-data =/ "STATUS" SP mailbox SP "(" mailbox-data =/ "STATUS" SP mailbox SP "("
[status-rsp-info *(SP status-rsp-info)] ")" / [status-rsp-info *(SP status-rsp-info)] ")" /
"SEARCH" [1*(SP nz-number) SP search_sort_mod_seq] / "SEARCH" [1*(SP nz-number) SP search_sort_mod_seq] /
"SORT" [1*(SP nz-number) SP search_sort_mod_seq] "SORT" [1*(SP nz-number) SP search_sort_mod_seq]
attr-flag = "\\Answered" / "\\Flagged" / "\\Deleted" / attr-flag = "\\Answered" / "\\Flagged" / "\\Deleted" /
"\\Seen" / "\\Draft" / attr-flag-keyword / "\\Seen" / "\\Draft" / attr-flag-keyword /
attr-flag-extension attr-flag-extension
;; Does not include "\Recent" ;; Does not include "\\Recent"
attr-flag-extension = "\\" atom attr-flag-extension = "\\" atom
;; Future expansion. Client implementations ;; Future expansion. Client implementations
;; MUST accept flag-extension flags. Server ;; MUST accept flag-extension flags. Server
;; implementations MUST NOT generate ;; implementations MUST NOT generate
;; flag-extension flags except as defined by ;; flag-extension flags except as defined by
;; future standard or standards-track ;; future standard or standards-track
;; revisions of this specification. ;; revisions of [IMAP4].
attr-flag-keyword = atom attr-flag-keyword = atom
6. Security Considerations 5. Security Considerations
As a conditional STORE operation must be atomic for a message set,
an implementation may choose to use some kind of message or even
mailbox level locking for the duration of the conditional STORE
operation. Such implementation may suffer from a Deny of Service
Attack when conditional STORE is executed on a large mailbox.
Other IMAP4 security issues can be found in Security Considerations It is believed that the Conditional STORE extension doesn't raise
section of [IMAP4]. any new security concerns that are not already discussed in [IMAP4].
7. References 6. References
7.1. Normative References 6.1. Normative References
[KEYWORDS] Bradner, "Key words for use in RFCs to Indicate [KEYWORDS] Bradner, "Key words for use in RFCs to Indicate
Requirement Levels", RFC 2119, Harvard University, March 1997. Requirement Levels", RFC 2119, Harvard University, March 1997.
[ABNF] Crocker, Overell, "Augmented BNF for Syntax Specifications: [ABNF] Crocker, Overell, "Augmented BNF for Syntax Specifications:
ABNF", RFC 2234, Internet Mail Consortium, Demon Internet Ltd, ABNF", RFC 2234, Internet Mail Consortium, Demon Internet Ltd,
November 1997. November 1997.
[IMAP4] Crispin, M., "Internet Message Access Protocol - Version [IMAP4] Crispin, M., "Internet Message Access Protocol - Version
4rev1", RFC 3501, University of Washington, March 2003. 4rev1", RFC 3501, University of Washington, March 2003.
[ANNOTATE] Gellens, R., Daboo, C., "IMAP ANNOTATE Extension", [ANNOTATE] Gellens, R., Daboo, C., "IMAP ANNOTATE Extension",
work in progress. work in progress.
<http://www.ietf.org/internet-drafts/draft-ietf-imapext-annotate-xx.txt> <http://www.ietf.org/internet-drafts/draft-ietf-imapext-annotate-xx.txt>
[SORT] Crispin, M., "Internet Message Access Protocol -- SORT [SORT] Crispin, M., Murchison, K., "Internet Message Access Protocol --
Extension", work in progress. SORT AND THREAD EXTENSIONS", work in progress.
<http://www.ietf.org/internet-drafts/draft-crispin-imapext-sort-xx.txt> <http://www.ietf.org/internet-drafts/draft-ietf-imapext-sort-xx.txt>
7.2. Informative References 6.2. Informative References
[ACAP] Newman, Myers, "ACAP -- Application Configuration Access [ACAP] Newman, Myers, "ACAP -- Application Configuration Access
Protocol", RFC 2244, Innosoft, Netscape, November 1997. Protocol", RFC 2244, Innosoft, Netscape, November 1997.
<ftp://ftp.isi.edu/in-notes/rfc2244.txt> <ftp://ftp.isi.edu/in-notes/rfc2244.txt>
[ACL] Myers, "IMAP4 ACL extension", RFC 2086, Carnegie Mellon, [ACL] Myers, "IMAP4 ACL extension", RFC 2086, Carnegie Mellon,
January 1997. January 1997.
<ftp://ftp.isi.edu/in-notes/rfc2086.txt> <ftp://ftp.isi.edu/in-notes/rfc2086.txt>
[NTP] Mills, D, "Network Time Protocol (Version 3) Specification, [NTP] Mills, D, "Network Time Protocol (Version 3) Specification,
Implementation and Analysis", RFC 1305, March 1992. Implementation and Analysis", RFC 1305, March 1992.
<ftp://ftp.isi.edu/in-notes/rfc1305.txt> <ftp://ftp.isi.edu/in-notes/rfc1305.txt>
[RFC-2180] Gahrns, M., "IMAP4 Multi-Accessed Mailbox Practice",
RFC 2180, July 1997.
<ftp://ftp.isi.edu/in-notes/rfc2180.txt>
7. IANA Considerations
IMAP4 capabilities are registered by publishing a standards track or
IESG approved experimental RFC. The registry is currently located
at:
http://www.iana.org/assignments/imap4-capabilities
This document consitutes registration of the CONDSTORE and SORT=MODSEQ
IMAP capabilities.
8. Acknowledgments 8. Acknowledgments
Some text was borrowed from "IMAP ANNOTATE Extension" by Randall Gellens Some text was borrowed from "IMAP ANNOTATE Extension" by Randall Gellens
and Cyrus Daboo, and "ACAP -- Application Configuration Access Protocol" and Cyrus Daboo, and "ACAP -- Application Configuration Access Protocol"
by Chris Newman and John Myers. by Chris Newman and John Myers.
Many thanks to Randall Gellens for his comments on how CONDSTORE should Many thanks to Randall Gellens for his comments on how CONDSTORE should
interact with ANNOTATE extension and for thorough review of the document. interact with ANNOTATE extension and for thorough review of the document.
Authors also acknowledge the feedback provided by Cyrus Daboo, Larry Authors also acknowledge the feedback provided by Cyrus Daboo, Larry
Greenfield, Chris Newman, Harrie Hazewinkel, Arnt Gulbrandsen Timo Greenfield, Chris Newman, Harrie Hazewinkel, Arnt Gulbrandsen, Timo
Sirainen and Mark Crispin. Sirainen and Mark Crispin.
9. Author's Addresses 9. Author's Addresses
Alexey Melnikov Alexey Melnikov
mailto: mel@messagingdirect.com mailto: mel@isode.com
ACI WorldWide/MessagingDirect Isode Limited
59 Clarendon Road, Watford, Hertfordshire,
WD17 1FQ, United Kingdom
Steve Hole Steve Hole
mailto: Steve.Hole@messagingdirect.com mailto: Steve.Hole@messagingdirect.com
ACI WorldWide/MessagingDirect ACI WorldWide/MessagingDirect
#900, 10117 Jasper Avenue, #900, 10117 Jasper Avenue,
Edmonton, Alberta, T5J 1W8, CANADA Edmonton, Alberta, T5J 1W8, CANADA
10. Full Copyright Statement 10. Intellectual Property Rights
The IETF takes no position regarding the validity or scope of any
intellectual property or other rights that might be claimed to pertain
to the implementation or use of the technology described in this
document or the extent to which any license under such rights might or
might not be available; neither does it represent that it has made any
effort to identify any such rights. Information on the IETF's
procedures with respect to rights in standards-track and
standards-related documentation can be found in BCP-11. Copies of
claims of rights made available for publication and any assurances of
licenses to be made available, or the result of an attempt made to
obtain a general license or permission for the use of such proprietary
rights by implementors or users of this specification can be obtained
from the IETF Secretariat.
The IETF invites any interested party to bring to its attention any
copyrights, patents or patent applications, or other proprietary
rights which may cover technology that may be required to practice
this standard. Please address the information to the IETF Executive
Director.
11. Full Copyright Statement
Copyright (C) The Internet Society 2001-2003. All Rights Reserved. Copyright (C) The Internet Society 2001-2003. All Rights Reserved.
This document and translations of it may be copied and furnished to This document and translations of it may be copied and furnished to
others, and derivative works that comment on or otherwise explain it others, and derivative works that comment on or otherwise explain it
or assist in its implementation may be prepared, copied, published or assist in its implementation may be prepared, copied, published
and distributed, in whole or in part, without restriction of any and distributed, in whole or in part, without restriction of any
kind, provided that the above copyright notice and this paragraph kind, provided that the above copyright notice and this paragraph
are included on all such copies and derivative works. However, this are included on all such copies and derivative works. However, this
document itself may not be modified in any way, such as by removing document itself may not be modified in any way, such as by removing
skipping to change at line 904 skipping to change at line 960
"AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
Acknowledgement Acknowledgement
Funding for the RFC Editor function is currently provided by the Funding for the RFC Editor function is currently provided by the
Internet Society. Internet Society.
Appendix A. Open Issues and Change History
Note that this appendix will be removed before publication.
0.1. Change History
Changes from draft-ietf-imapext-condstore-01
1. Fixed missing \\ in one example.
2. Added explanatory comment that search-key modifications apply at
least to SEARCH and SORT command.
3. Don't require from a conditional store operation to be atomic accross
message set, updated text and examples.
4. Added SORT=MODSEQ extension and reworked text in the Introduction section.
5. Added Conditional STORE example based on suggestions from RFC 2180.
6. Removed the paragraph about DOS attack from the Security considerations
section, as it doesn't apply anymore.
7. Updated entry-name ABNF.
8. Added an optional CONDSTORE parameter to SELECT/EXAMINE.
Changes from draft-ietf-imapext-condstore-00
1. Dropped "/message" prefix in entry names as per decision in San Francisco.
2. Fixed ABNF for SEARCH and SORT untagged responses.
3. Changed "private" to "priv" to be consistent with ANNOTATE.
4. MODIFIED response code is now returned in OK response, not NO.
5. Added NOMODSEQ response code.
Changes from draft-melnikov-imap-condstore-09:
1. Some text clarifications based on suggestions by Harrie Hazewinkel
2. Added paragraph about mailbox locking and DOS when conditional STORE
operation is performed on a large mailbox.
3. Fixed syntax of <entry-name> to match the ANNOTATE extention.
4. Added sentence that a system flag MUST always be considered existent,
when UNCHANGEDSINCE 0 is used. Is this a good idea?
5. Clarified client behavior upon receipt of MODIFIED response code.
6. Updated ABNF to clarify where 0 is allowed as mod-sequence and where
it is not.
7. Got rid of MODSEQ response code and return this data in the untagged
SEARCH/SORT responses.
8. Updated RFC number for the IMAP4rev1 document.
Changes from -08 to -09:
1. Added an extended example about reporting regular (non-conditional) flag
changes to other sessions.
2. Simplified FETCH MODSEQ syntax by removing per-metadata requests and
responses.
Changes from -07 to -08:
1. Added note saying the change to UIDVALIDITY also invalidates HIGHESTMODSEQ.
2. Fixed several bugs in ABNF for STATUS and STORE commands.
Changes from -06 to -07:
1. Added clarification that when a server does command reordering, the second
completed operation gets the higher mod sequence.
2. Renamed annotation type specifier "both" to "all" as per suggestion
from Minneapolis meeting.
3. Removed PERFLAGMODSEQ capability, as it doesn't buy anything: a client
has to work with both types of servers (i.e. servers that support per
message per flag modseqs and servers that support only per message
modseqs) anyway.
4. Per flag mod-sequences are optional for a server to return. Updated syntax.
5. Allow MODSEQ response code only as a result of SEARCH/SORT as suggested
by John Myers. MODSEQ response code is not allowed after FETCH or STORE.
Changes from -05 to -06:
1. Replaced "/message/flags/system" with "/message/flags" to
match ANNOTATE draft.
2. Extended FETCH/SEARCH/SORT syntax to allow for specifying
whether an operation should be performed on a shared or a private
annotation (or both).
3. Corrected some examples.
Changes from -04 to -05:
1. Added support for SORT extension.
2. Multiple language/spelling fixes by Randall Gellens.
Changes from -03 to -04:
1. Added text saying that MODSEQ fetch data items cause server
to include MODSEQ data response in all subsuquent unsolicited FETCH
responses.
2. Added "authors address" section.
Changes from -02 to -03:
1. Changed MODTIME untagged response to MODTIME response code.
2. Added MODTIME response code to the tagged OK response for SEARCH.
Updated examples accordingly.
3. Changed rule for sending untagged FETCH response as a result of
STORE when .SILENT prefix is used. If .SILENT prefix is used,
server doesn't have to send untagged FETCH response, because
MODTIME response code already contains modtime.
4. Renamed MODTIME to MODSEQ to make sure there is no confusion
between mod-sequence and ACAP modtime.
5. Minor ABNF changes.
6. Minor language corrections.
Changes from -01 to -02:
1. Added MODTIME data item to STATUS command.
2. Added OK untagged response to SELECT/EXAMINE.
3. Clarified that MODIFIED response code contains list of UIDs for
conditional UID STORE and message set for STORE.
4. Added per-message modtime.
5. Added PERFLAGMODTIME capability.
6. Fixed several bugs in examples.
7. Added more comments to ABNF.
Changes from -00 to -01:
1. Refreshed the list of Open Issues.
2. Changed "attr-name" to "entry-name", because modtime applies to
entry, not attribute.
3. Added MODTIME untagged response.
4. Cleaned up ABNF.
5. Added "Acknowledgments" section.
6. Fixed some spelling mistakes.
 End of changes. 

This html diff was produced by rfcdiff 1.23, available from http://www.levkowetz.com/ietf/tools/rfcdiff/