Bug 452317 - FeedConverter.js: QueryInterface should throw NS_ERROR_NO_INTERFACE...
[wine-gecko.git] / toolkit / components / places / src / nsPlacesTriggers.h
blob76fe1a81a47bcea2b119cb8eeb23ea64eaf237b4
1 /* vim: sw=2 ts=2 sts=2 expandtab
2 * ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is Places code.
17 * The Initial Developer of the Original Code is
18 * Mozilla Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 2008
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Shawn Wilsher <me@shawnwilsher.com> (Original Author)
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #ifndef __nsPlacesTriggers_h__
40 #define __nsPlacesTriggers_h__
42 /**
43 * Trigger increments the visit count by one for each inserted visit that isn't
44 * an invalid transition, embedded transition, or a download transition.
46 #define CREATE_VISIT_COUNT_INSERT_TRIGGER NS_LITERAL_CSTRING( \
47 "CREATE TRIGGER moz_historyvisits_afterinsert_v1_trigger " \
48 "AFTER INSERT ON moz_historyvisits FOR EACH ROW " \
49 "WHEN NEW.visit_type NOT IN (0, 4, 7) " /* invalid, EMBED, DOWNLOAD */ \
50 "BEGIN " \
51 "UPDATE moz_places " \
52 "SET visit_count = visit_count + 1 " \
53 "WHERE moz_places.id = NEW.place_id; " \
54 "END" \
57 /**
58 * Trigger decrements the visit count by one for each removed visit that isn't
59 * an invalid transition, embeded transition, or a download transition. To be
60 * safe, we ensure that the visit count will not fall below zero.
62 #define CREATE_VISIT_COUNT_DELETE_TRIGGER NS_LITERAL_CSTRING( \
63 "CREATE TRIGGER moz_historyvisits_afterdelete_v1_trigger " \
64 "AFTER DELETE ON moz_historyvisits FOR EACH ROW " \
65 "WHEN OLD.visit_type NOT IN (0, 4, 7) " /* invalid, EMBED, DOWNLOAD */ \
66 "BEGIN " \
67 "UPDATE moz_places " \
68 "SET visit_count = visit_count - 1 " \
69 "WHERE moz_places.id = OLD.place_id " \
70 "AND visit_count > 0; " \
71 "END" \
74 /**
75 * Trigger checks to ensure that at least one bookmark is still using a keyword
76 * when any bookmark is deleted. If there are no more bookmarks using it, the
77 * keyword is deleted.
79 #define CREATE_KEYWORD_VALIDITY_TRIGGER NS_LITERAL_CSTRING( \
80 "CREATE TRIGGER moz_bookmarks_beforedelete_v1_trigger " \
81 "BEFORE DELETE ON moz_bookmarks FOR EACH ROW " \
82 "WHEN OLD.keyword_id NOT NULL " \
83 "BEGIN " \
84 "DELETE FROM moz_keywords " \
85 "WHERE id = OLD.keyword_id " \
86 "AND NOT EXISTS ( " \
87 "SELECT id " \
88 "FROM moz_bookmarks " \
89 "WHERE keyword_id = OLD.keyword_id " \
90 "AND id <> OLD.id " \
91 "LIMIT 1 " \
92 ");" \
93 "END" \
96 #endif // __nsPlacesTriggers_h__