~statik/ubuntu/maverick/erlang/erlang-merge-testing

« back to all changes in this revision

Viewing changes to lib/mnesia/doc/src/mnesia.xml

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2009-05-01 10:14:38 UTC
  • mfrom: (3.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090501101438-6qlr6rsdxgyzrg2z
Tags: 1:13.b-dfsg-2
* Cleaned up patches: removed unneeded patch which helped to support
  different SCTP library versions, made sure that changes for m68k
  architecture applied only when building on this architecture.
* Removed duplicated information from binary packages descriptions.
* Don't require libsctp-dev build-dependency on solaris-i386 architecture
  which allows to build Erlang on Nexenta (thanks to Tim Spriggs for
  the suggestion).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="latin1" ?>
 
2
<!DOCTYPE erlref SYSTEM "erlref.dtd">
 
3
 
 
4
<erlref>
 
5
  <header>
 
6
    <copyright>
 
7
      <year>1996</year><year>2009</year>
 
8
      <holder>Ericsson AB. All Rights Reserved.</holder>
 
9
    </copyright>
 
10
    <legalnotice>
 
11
      The contents of this file are subject to the Erlang Public License,
 
12
      Version 1.1, (the "License"); you may not use this file except in
 
13
      compliance with the License. You should have received a copy of the
 
14
      Erlang Public License along with this software. If not, it can be
 
15
      retrieved online at http://www.erlang.org/.
 
16
    
 
17
      Software distributed under the License is distributed on an "AS IS"
 
18
      basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
 
19
      the License for the specific language governing rights and limitations
 
20
      under the License.
 
21
    
 
22
    </legalnotice>
 
23
 
 
24
    <title>mnesia</title>
 
25
    <prepared>Claes Wikstr&ouml;m and H&aring;kan Mattsson</prepared>
 
26
    <responsible></responsible>
 
27
    <docno></docno>
 
28
    <approved></approved>
 
29
    <checked></checked>
 
30
    <date></date>
 
31
    <rev></rev>
 
32
    <file></file>
 
33
  </header>
 
34
  <module>mnesia</module>
 
35
  <modulesummary>A Distributed Telecommunications DBMS </modulesummary>
 
36
  <description>
 
37
    <p><c>Mnesia</c> is a distributed DataBase Management System (DBMS),
 
38
      appropriate for telecommunications applications and other Erlang
 
39
      applications which require continuous operation and  exhibit soft
 
40
      real-time properties.
 
41
      </p>
 
42
    <p>Listed below are some of the most important and attractive capabilities, Mnesia provides:
 
43
      </p>
 
44
    <list type="bulleted">
 
45
      <item>
 
46
        <p>A relational/object hybrid data model which is
 
47
          suitable for telecommunications applications.
 
48
          </p>
 
49
      </item>
 
50
      <item>
 
51
        <p>A specifically designed  DBMS query language, QLC (as an add-on library). 
 
52
          </p>
 
53
      </item>
 
54
      <item>
 
55
        <p>Persistence. Tables may be coherently kept on disc as
 
56
          well as in main memory.
 
57
          </p>
 
58
      </item>
 
59
      <item>
 
60
        <p>Replication. Tables may be replicated at several nodes.
 
61
          </p>
 
62
      </item>
 
63
      <item>
 
64
        <p>Atomic transactions. A series of table manipulation
 
65
          operations can be grouped into a single atomic
 
66
          transaction.
 
67
          </p>
 
68
      </item>
 
69
      <item>
 
70
        <p>Location transparency. Programs can be written without
 
71
          knowledge of the actual location of data.
 
72
          </p>
 
73
      </item>
 
74
      <item>
 
75
        <p>Extremely fast real time data searches.
 
76
          </p>
 
77
      </item>
 
78
      <item>
 
79
        <p>Schema manipulation routines. It is possible to
 
80
          reconfigure the DBMS at runtime without stopping the
 
81
          system.
 
82
          </p>
 
83
      </item>
 
84
    </list>
 
85
    <p>This Reference Manual describes the Mnesia API. This includes
 
86
      functions used to define and manipulate Mnesia tables.
 
87
      </p>
 
88
    <p>All functions documented in these pages can be used in any
 
89
      combination with queries using the list comprehension notation. The
 
90
      query notation is described in the QLC's man page.
 
91
      </p>
 
92
    <p>Data in Mnesia is organized as a set of tables.  Each table
 
93
      has a name which must be an atom. Each table is made up of
 
94
      Erlang records.  The user is responsible for the record
 
95
      definitions.  Each table also has a set of properties. Below
 
96
      are some of the properties that are associated with each
 
97
      table:
 
98
      </p>
 
99
    <list type="bulleted">
 
100
      <item>
 
101
        <p><c>type</c>. Each table can either have 'set',
 
102
          'ordered_set' or 'bag' semantics. Note: currently 'ordered_set' 
 
103
          is not supported for 'disc_only_copies'. If a table is of type
 
104
          'set' it means that each key leads to either one or zero
 
105
          records.           <br></br>
 
106
If a new item is inserted with the same key as
 
107
          an existing record, the old record is overwritten. On the
 
108
          other hand, if a table is of type 'bag', each key can map to
 
109
          several records. However, all records in type bag tables are
 
110
          unique, only the keys may be duplicated.
 
111
          </p>
 
112
      </item>
 
113
      <item>
 
114
        <p><c>record_name</c>. All records stored in a table must
 
115
          have the same name. You may say that the records must be
 
116
          instances of the same record type.
 
117
          </p>
 
118
      </item>
 
119
      <item>
 
120
        <p><c>ram_copies</c> A table can be replicated on a number
 
121
          of Erlang nodes. The <c>ram_copies</c> property specifies a
 
122
          list of Erlang nodes where RAM copies are kept.  These
 
123
          copies can be dumped to disc at regular intervals.  However,
 
124
          updates to these copies are not written to disc on a
 
125
          transaction basis.
 
126
          </p>
 
127
      </item>
 
128
      <item>
 
129
        <p><c>disc_copies</c> The <c>disc_copies</c> property
 
130
          specifies a list of Erlang nodes where the table is kept in
 
131
          RAM as well as on disc. All updates of the table are
 
132
          performed on the actual table and are also logged to disc.
 
133
          If a table is of type <c>disc_copies</c> at a certain node,
 
134
          it means that the entire table is resident in RAM memory as
 
135
          well as on disc. Each transaction performed on the table is
 
136
          appended to a LOG file as well as written into the RAM
 
137
          table.
 
138
          </p>
 
139
      </item>
 
140
      <item>
 
141
        <p><c>disc_only_copies</c> Some, or all, table replicas
 
142
          can be kept on disc only. These replicas are considerably
 
143
          slower than the RAM based replicas.
 
144
          </p>
 
145
      </item>
 
146
      <item>
 
147
        <p><c>index</c> This is a list of attribute names, or
 
148
          integers, which specify the tuple positions on which
 
149
          Mnesia shall build and maintain an extra index table.
 
150
          </p>
 
151
      </item>
 
152
      <item>
 
153
        <p><c>local_content</c> When an application requires 
 
154
          tables whose contents is local to each node,
 
155
          <c>local_content</c> tables may be used. The name of the
 
156
          table is known to all Mnesia nodes, but its contents is
 
157
          unique on each node. This means that access to such a table
 
158
          must be done locally.  Set the <c>local_content</c> field to
 
159
          <c>true</c> if you want to enable the <c>local_content</c>
 
160
          behavior. The default is <c>false</c>.
 
161
          </p>
 
162
      </item>
 
163
      <item>
 
164
        <p><c>snmp</c> Each (set based) Mnesia table can be
 
165
          automatically turned into an SNMP ordered table as well.
 
166
          This property specifies the types of the SNMP keys.
 
167
          </p>
 
168
      </item>
 
169
      <item>
 
170
        <p><c>attributes</c>. The names of the attributes for the
 
171
          records that are inserted in the table.
 
172
          </p>
 
173
      </item>
 
174
    </list>
 
175
    <p>See <c>mnesia:create_table/2</c> about the complete set of
 
176
      table properties and their details.
 
177
      </p>
 
178
    <p>This document uses a table of persons to illustrate various
 
179
      examples. The following record definition is assumed:
 
180
      </p>
 
181
    <code type="none">
 
182
-record(person, {name,
 
183
                 age = 0,
 
184
                 address = unknown,
 
185
                 salary = 0,
 
186
                 children = []}),
 
187
    </code>
 
188
    <p>The first attribute of the record is the primary key, or key
 
189
      for short.
 
190
      </p>
 
191
    <p>The function descriptions are sorted in alphabetic order. <em>Hint:</em>
 
192
      start to read about <c>mnesia:create_table/2</c>,
 
193
      <c>mnesia:lock/2</c> and <c>mnesia:activity/4</c> before you continue on
 
194
      and learn about the rest.
 
195
      </p>
 
196
    <p>Writing or deleting in transaction context creates a local copy
 
197
      of each modified record during the transaction. During iteration,
 
198
      i.e. <c>mnesia:fold[lr]/4</c> <c>mnesia:next/2</c> <c>mnesia:prev/2</c> 
 
199
      <c>mnesia:snmp_get_next_index/2</c>, mnesia will compensate for 
 
200
      every written or deleted record, which may reduce the
 
201
      performance. If possible avoid writing or deleting records in
 
202
      the same transaction before iterating over the table.
 
203
    </p>
 
204
  </description>
 
205
  <funcs>
 
206
    <func>
 
207
      <name>abort(Reason) -> transaction abort </name>
 
208
      <fsummary>Abort the current transaction.</fsummary>
 
209
      <desc>
 
210
        <p>Makes the transaction silently 
 
211
          return the tuple <c>{aborted, Reason}</c>.
 
212
          The abortion of a Mnesia transaction means that
 
213
          an exception will be thrown to an enclosing <c>catch</c>.
 
214
          Thus, the expression <c>catch mnesia:abort(x)</c> does
 
215
          not abort the transaction. </p>
 
216
      </desc>
 
217
    </func>
 
218
    <func>
 
219
      <name>activate_checkpoint(Args) -> {ok,Name,Nodes} | {error,Reason}</name>
 
220
      <fsummary>Activate a checkpoint.</fsummary>
 
221
      <desc>
 
222
        <p>A checkpoint is a consistent view of the system. 
 
223
          A checkpoint can be activated on a set of tables.
 
224
          This checkpoint can then be traversed and will
 
225
          present a view of the system as it existed at the time when
 
226
          the checkpoint was activated,  even if the tables are being or have been
 
227
          manipulated. 
 
228
          </p>
 
229
        <p><c>Args</c> is a list of the following tuples: 
 
230
          </p>
 
231
        <list type="bulleted">
 
232
          <item>
 
233
            <p><c>{name,Name}</c>. <c>Name</c> of checkpoint. Each
 
234
              checkpoint must have a name which is unique to the
 
235
              associated nodes. The name can be reused only once the
 
236
              checkpoint has been deactivated. By default, a name
 
237
              which is probably unique is generated.
 
238
              </p>
 
239
          </item>
 
240
          <item>
 
241
            <p><c>{max,MaxTabs}</c><c>MaxTabs</c> is a list of
 
242
              tables that should be included in the checkpoint. The
 
243
              default is []. For these tables, the redundancy will be
 
244
              maximized and checkpoint information will be retained together
 
245
              with all replicas. The checkpoint becomes more fault
 
246
              tolerant if the tables have several replicas. When a new
 
247
              replica is added by means of the schema manipulation
 
248
              function <c>mnesia:add_table_copy/3</c>, a retainer will 
 
249
              also be attached automatically.
 
250
              </p>
 
251
          </item>
 
252
          <item>
 
253
            <p><c>{min,MinTabs}</c>. <c>MinTabs</c> is a list of
 
254
              tables that should be included in the checkpoint. The
 
255
              default is []. For these tables, the redundancy will be
 
256
              minimized and the checkpoint information will only be retained
 
257
              with one replica, preferably on the local node.
 
258
              </p>
 
259
          </item>
 
260
          <item>
 
261
            <p><c>{allow_remote,Bool}</c>. <c>false</c> means that
 
262
              all retainers must be local. The checkpoint cannot be
 
263
              activated if a table does not reside locally.
 
264
              <c>true</c> allows retainers to be allocated on any
 
265
              node. Default is set to <c>true</c>.
 
266
              </p>
 
267
          </item>
 
268
          <item>
 
269
            <p><c>{ram_overrides_dump,Bool} </c> Only applicable
 
270
              for <c>ram_copies</c>.  <c>Bool</c> allows you to choose
 
271
              to backup the table state as it is in RAM, or as it is on
 
272
              disc. <c>true</c> means that the latest committed
 
273
              records in RAM should be included in the checkpoint.
 
274
              These are the  records that the application accesses.
 
275
              <c>false</c> means that the records dumped to DAT files
 
276
              should be included in the checkpoint. These are the
 
277
              records that will be loaded at startup. Default is
 
278
              <c>false</c>.   
 
279
              </p>
 
280
          </item>
 
281
        </list>
 
282
        <p>Returns <c>{ok,Name,Nodes}</c> or <c>{error,Reason}</c>.
 
283
          <c>Name</c> is the (possibly generated) name of the
 
284
          checkpoint. <c>Nodes</c> are the nodes that
 
285
          are involved in the checkpoint. Only nodes that keep a
 
286
          checkpoint retainer know about the checkpoint.
 
287
          </p>
 
288
      </desc>
 
289
    </func>
 
290
    <func>
 
291
      <name>activity(AccessContext, Fun [, Args]) -> ResultOfFun | exit(Reason)</name>
 
292
      <fsummary>Execute <c>Fun</c>in <c>AccessContext</c>.</fsummary>
 
293
      <desc>
 
294
        <p>Invokes <c>mnesia:activity(AccessContext, Fun, Args, AccessMod)</c> where <c>AccessMod</c> is the default
 
295
          access callback module obtained by
 
296
          <c>mnesia:system_info(access_module)</c>. <c>Args</c>
 
297
          defaults to the empty list <c>[]</c>.</p>
 
298
      </desc>
 
299
    </func>
 
300
    <func>
 
301
      <name>activity(AccessContext, Fun, Args, AccessMod) -> ResultOfFun | exit(Reason)</name>
 
302
      <fsummary>Execute <c>Fun</c>in <c>AccessContext</c>.</fsummary>
 
303
      <desc>
 
304
        <p>This function executes the functional object <c>Fun</c>
 
305
          with the arguments <c>Args</c>. 
 
306
          </p>
 
307
        <p>The code which executes inside the activity can
 
308
          consist of a series of table manipulation functions, which is
 
309
          performed in a <c>AccessContext</c>. Currently, the following
 
310
          access contexts are supported:
 
311
          </p>
 
312
        <taglist>
 
313
          <tag><c>transaction</c></tag>
 
314
          <item>
 
315
            <p>Short for <c>{transaction, infinity}</c></p>
 
316
          </item>
 
317
          <tag><c>{transaction, Retries}</c></tag>
 
318
          <item>
 
319
            <p>Invokes <c>mnesia:transaction(Fun, Args, Retries)</c>. Note that the result from the <c>Fun</c> is
 
320
              returned if the transaction was successful (atomic),
 
321
              otherwise the function exits with an abort reason.
 
322
              </p>
 
323
          </item>
 
324
          <tag><c>sync_transaction</c></tag>
 
325
          <item>
 
326
            <p>Short for <c>{sync_transaction, infinity}</c></p>
 
327
          </item>
 
328
          <tag><c>{sync_transaction, Retries}</c></tag>
 
329
          <item>
 
330
            <p>Invokes <c>mnesia:sync_transaction(Fun, Args, Retries)</c>. Note that the result from the <c>Fun</c> is
 
331
              returned if the transaction was successful (atomic),
 
332
              otherwise the function exits with an abort reason.
 
333
              </p>
 
334
          </item>
 
335
          <tag><c>async_dirty</c></tag>
 
336
          <item>
 
337
            <p>Invokes <c>mnesia:async_dirty(Fun, Args)</c>.
 
338
              </p>
 
339
          </item>
 
340
          <tag><c>sync_dirty</c></tag>
 
341
          <item>
 
342
            <p>Invokes <c>mnesia:sync_dirty(Fun, Args)</c>.
 
343
              </p>
 
344
          </item>
 
345
          <tag><c>ets</c></tag>
 
346
          <item>
 
347
            <p>Invokes <c>mnesia:ets(Fun, Args)</c>.
 
348
              </p>
 
349
          </item>
 
350
        </taglist>
 
351
        <p>This function (<c>mnesia:activity/4</c>) differs in an
 
352
          important aspect from the <c>mnesia:transaction</c>,
 
353
          <c>mnesia:sync_transaction</c>,
 
354
          <c>mnesia:async_dirty</c>, <c>mnesia:sync_dirty</c> and
 
355
          <c>mnesia:ets</c> functions. The <c>AccessMod</c> argument
 
356
          is the name of a callback module which implements the
 
357
          <c>mnesia_access</c> behavior.
 
358
          </p>
 
359
        <p>Mnesia will forward calls to the following functions:
 
360
          </p>
 
361
        <list type="bulleted">
 
362
          <item>
 
363
            <p>mnesia:write/3 (write/1, s_write/1)</p>
 
364
          </item>
 
365
          <item>
 
366
            <p>mnesia:delete/3 (delete/1, s_delete/1)</p>
 
367
          </item>
 
368
          <item>
 
369
            <p>mnesia:delete_object/3 (delete_object/1, s_delete_object/1)</p>
 
370
          </item>
 
371
          <item>
 
372
            <p>mnesia:read/3 (read/1, wread/1)</p>
 
373
          </item>
 
374
          <item>
 
375
            <p>mnesia:match_object/3 (match_object/1)</p>
 
376
          </item>
 
377
          <item>
 
378
            <p>mnesia:all_keys/1</p>
 
379
          </item>
 
380
          <item>
 
381
            <p>mnesia:first/1</p>
 
382
          </item>
 
383
          <item>
 
384
            <p>mnesia:last/1</p>
 
385
          </item>
 
386
          <item>
 
387
            <p>mnesia:prev/2</p>
 
388
          </item>
 
389
          <item>
 
390
            <p>mnesia:next/2</p>
 
391
          </item>
 
392
          <item>
 
393
            <p>mnesia:index_match_object/4 (index_match_object/2)</p>
 
394
          </item>
 
395
          <item>
 
396
            <p>mnesia:index_read/3</p>
 
397
          </item>
 
398
          <item>
 
399
            <p>mnesia:lock/2 (read_lock_table/1, write_lock_table/1)</p>
 
400
          </item>
 
401
          <item>
 
402
            <p>mnesia:table_info/2</p>
 
403
          </item>
 
404
        </list>
 
405
        <p>to the corresponding:
 
406
          </p>
 
407
        <list type="bulleted">
 
408
          <item>
 
409
            <p>AccessMod:lock(ActivityId, Opaque, LockItem, LockKind)</p>
 
410
          </item>
 
411
          <item>
 
412
            <p>AccessMod:write(ActivityId, Opaque, Tab, Rec, LockKind)</p>
 
413
          </item>
 
414
          <item>
 
415
            <p>AccessMod:delete(ActivityId, Opaque, Tab, Key, LockKind)</p>
 
416
          </item>
 
417
          <item>
 
418
            <p>AccessMod:delete_object(ActivityId, Opaque, Tab, RecXS, LockKind)</p>
 
419
          </item>
 
420
          <item>
 
421
            <p>AccessMod:read(ActivityId, Opaque, Tab, Key, LockKind)</p>
 
422
          </item>
 
423
          <item>
 
424
            <p>AccessMod:match_object(ActivityId, Opaque, Tab, Pattern, LockKind)</p>
 
425
          </item>
 
426
          <item>
 
427
            <p>AccessMod:all_keys(ActivityId, Opaque, Tab, LockKind)</p>
 
428
          </item>
 
429
          <item>
 
430
            <p>AccessMod:first(ActivityId, Opaque, Tab)</p>
 
431
          </item>
 
432
          <item>
 
433
            <p>AccessMod:last(ActivityId, Opaque, Tab)</p>
 
434
          </item>
 
435
          <item>
 
436
            <p>AccessMod:prev(ActivityId, Opaque, Tab, Key)</p>
 
437
          </item>
 
438
          <item>
 
439
            <p>AccessMod:next(ActivityId, Opaque, Tab, Key)</p>
 
440
          </item>
 
441
          <item>
 
442
            <p>AccessMod:index_match_object(ActivityId, Opaque, Tab, Pattern, Attr, LockKind)</p>
 
443
          </item>
 
444
          <item>
 
445
            <p>AccessMod:index_read(ActivityId, Opaque, Tab, SecondaryKey, Attr, LockKind)</p>
 
446
          </item>
 
447
          <item>
 
448
            <p>AccessMod:table_info(ActivityId, Opaque, Tab, InfoItem)</p>
 
449
          </item>
 
450
        </list>
 
451
        <p>where <c>ActivityId</c> is a record which represents the
 
452
          identity of the enclosing Mnesia activity. The first field
 
453
          (obtained with <c>element(1, ActivityId)</c> contains an
 
454
          atom which may be interpreted as the type of the activity:
 
455
          <c>'ets'</c>, <c>'async_dirty'</c>, <c>'sync_dirty'</c> or
 
456
          <c>'tid'</c>. <c>'tid'</c> means that the activity is a
 
457
          transaction. The structure of the rest of the identity
 
458
          record is internal to Mnesia.
 
459
          </p>
 
460
        <p><c>Opaque</c> is an opaque data structure which is internal
 
461
          to Mnesia.</p>
 
462
      </desc>
 
463
    </func>
 
464
    <func>
 
465
      <name>add_table_copy(Tab, Node, Type) -> {aborted, R} | {atomic, ok}</name>
 
466
      <fsummary>Copy a table to a remote node.</fsummary>
 
467
      <desc>
 
468
        <p>This function makes another copy of a table  at the
 
469
          node <c>Node</c>. The <c>Type</c> argument must be
 
470
          either of the atoms <c>ram_copies</c>, <c>disc_copies</c>,
 
471
          or
 
472
          <c>disc_only_copies</c>. For example, the following call
 
473
          ensures that a disc replica of the <c>person</c> table  also
 
474
          exists at node <c>Node</c>.</p>
 
475
        <code type="none">
 
476
mnesia:add_table_copy(person, Node, disc_copies)
 
477
        </code>
 
478
        <p>This function can also be used to add a replica of the
 
479
          table named <c>schema</c>.</p>
 
480
      </desc>
 
481
    </func>
 
482
    <func>
 
483
      <name>add_table_index(Tab, AttrName) -> {aborted, R} | {atomic, ok}</name>
 
484
      <fsummary>Create an index for a table. </fsummary>
 
485
      <desc>
 
486
        <p>Table indices can and should be used whenever the user
 
487
          wants to frequently use some other field than the key field
 
488
          to look up records. If this other field has an index
 
489
          associated with it, these lookups can occur in constant time
 
490
          and space.  For example, if our application wishes to use
 
491
          the age field of persons to efficiently find all person with
 
492
          a specific age, it might be a good idea to have an index on
 
493
          the age field. This can be accomplished with the following
 
494
          call:</p>
 
495
        <code type="none">
 
496
mnesia:add_table_index(person, age)
 
497
        </code>
 
498
        <p>Indices do not come free, they occupy space which is 
 
499
          proportional to the size of the table. They also cause insertions
 
500
          into the table to execute slightly slower. </p>
 
501
      </desc>
 
502
    </func>
 
503
    <func>
 
504
      <name>all_keys(Tab) -> KeyList | transaction abort</name>
 
505
      <fsummary>Return all keys in a table.</fsummary>
 
506
      <desc>
 
507
        <p>This function returns a list of all keys in the table
 
508
          named <c>Tab</c>. The semantics of this function is context
 
509
          sensitive. See <c>mnesia:activity/4</c> for more information. In
 
510
          transaction context it acquires a read lock on the entire
 
511
          table.</p>
 
512
      </desc>
 
513
    </func>
 
514
    <func>
 
515
      <name>async_dirty(Fun, [, Args])  -> ResultOfFun | exit(Reason)</name>
 
516
      <fsummary>Call the Fun in a context which is not protected by a transaction.</fsummary>
 
517
      <desc>
 
518
        <p>Call the <c>Fun</c> in a context which is not protected
 
519
          by a transaction. The Mnesia function calls performed in the
 
520
          <c>Fun</c> are mapped to the corresponding dirty
 
521
          functions. This still involves logging, replication and
 
522
          subscriptions, but there is no locking, local transaction
 
523
          storage, or commit protocols involved. Checkpoint retainers
 
524
          and indices are updated, but they will be updated dirty. As
 
525
          for normal mnesia:dirty_* operations, the operations are
 
526
          performed semi-asynchronously. See
 
527
          <c>mnesia:activity/4</c> and the Mnesia User's Guide for
 
528
          more details.
 
529
          </p>
 
530
        <p>It is possible to manipulate the Mnesia tables without
 
531
          using transactions. This has some serious disadvantages, but
 
532
          is considerably faster since the transaction manager is not
 
533
          involved and no locks are set. A dirty operation does,
 
534
          however, guarantee a certain level of consistency and it is
 
535
          not possible for the dirty operations to return garbled
 
536
          records. All dirty operations provide location transparency
 
537
          to the programmer and a program does not have to be aware of
 
538
          the whereabouts of a certain table in order to function. 
 
539
          </p>
 
540
        <p><em>Note:</em>It is more than 10 times more efficient to read records dirty
 
541
          than within a transaction.
 
542
          </p>
 
543
        <p>Depending on the application, it may be a good idea to use
 
544
          the dirty functions for certain operations. Almost all
 
545
          Mnesia functions which can be called within transactions
 
546
          have a dirty equivalent which is much more
 
547
          efficient. However, it must be noted that it is possible for
 
548
          the database to be left in an inconsistent state if dirty
 
549
          operations are used to update it. Dirty operations should
 
550
          only be used for performance reasons when it is absolutely
 
551
          necessary.  </p>
 
552
        <p><em>Note:</em> Calling (nesting) a <c>mnesia:[a]sync_dirty</c>
 
553
          inside a transaction context will inherit the transaction semantics.
 
554
          </p>
 
555
      </desc>
 
556
    </func>
 
557
    <func>
 
558
      <name>backup(Opaque [, BackupMod]) -> ok | {error,Reason}</name>
 
559
      <fsummary>Back up all tables in the database.</fsummary>
 
560
      <desc>
 
561
        <p>Activates a new checkpoint covering all Mnesia tables,
 
562
          including the schema, with maximum degree of redundancy and
 
563
          performs a backup using <c>backup_checkpoint/2/3</c>.  The
 
564
          default value of the backup callback module <c>BackupMod</c>
 
565
          is obtained by <c>mnesia:system_info(backup_module)</c>.</p>
 
566
      </desc>
 
567
    </func>
 
568
    <func>
 
569
      <name>backup_checkpoint(Name, Opaque [, BackupMod]) ->  ok | {error,Reason}</name>
 
570
      <fsummary>Back up all tables in a checkpoint.</fsummary>
 
571
      <desc>
 
572
        <p>The tables are backed up to external media using the backup
 
573
          module <c>BackupMod</c>. Tables with the local contents
 
574
          property is being backed up as they exist on the current
 
575
          node.  <c>BackupMod</c> is the default backup callback
 
576
          module obtained by
 
577
          <c>mnesia:system_info(backup_module)</c>. See the User's
 
578
          Guide about the exact callback interface (the
 
579
          <c>mnesia_backup behavior</c>).</p>
 
580
      </desc>
 
581
    </func>
 
582
    <func>
 
583
      <name>change_config(Config, Value) -> {error, Reason} | {ok, ReturnValue}</name>
 
584
      <fsummary>Change a configuration parameter.</fsummary>
 
585
      <desc>
 
586
        <p>The <c>Config</c> should be an atom of the following 
 
587
          configuration parameters: </p>
 
588
        <taglist>
 
589
          <tag><c>extra_db_nodes</c></tag>
 
590
          <item>
 
591
            <p><c>Value</c> is a list of nodes which Mnesia should try to connect to.
 
592
              The <c>ReturnValue</c> will be those nodes in 
 
593
              <c>Value</c> that Mnesia are connected to.
 
594
                            <br></br>
 
595
Note: This function shall only be used to connect to newly started ram nodes
 
596
              (N.D.R.S.N.) with an empty schema. If for example it is used after the network 
 
597
              have been partitioned it may lead to inconsistent tables.
 
598
                            <br></br>
 
599
Note: Mnesia may be connected to other nodes than those
 
600
              returned in <c>ReturnValue</c>.</p>
 
601
          </item>
 
602
          <tag><c>dc_dump_limit</c></tag>
 
603
          <item>
 
604
            <p><c>Value</c> is a number. See description in 
 
605
              <c>Configuration Parameters</c> below.
 
606
              The <c>ReturnValue</c> is the new value. Note this configuration parameter
 
607
              is not persistent, it will be lost when mnesia stopped.</p>
 
608
          </item>
 
609
        </taglist>
 
610
      </desc>
 
611
    </func>
 
612
    <func>
 
613
      <name>change_table_access_mode(Tab, AccessMode) -> {aborted, R} | {atomic, ok}</name>
 
614
      <fsummary>Change the access mode for the table.</fsummary>
 
615
      <desc>
 
616
        <p>The <c>AcccessMode</c> is by default the atom
 
617
          <c>read_write</c> but it may also be set to the atom
 
618
          <c>read_only</c>. If the <c>AccessMode</c> is set to
 
619
          <c>read_only</c>, it means that it is not possible to perform
 
620
          updates to the table. At startup Mnesia always loads
 
621
          <c>read_only</c> tables locally regardless of when and if
 
622
          Mnesia was terminated on other nodes.</p>
 
623
      </desc>
 
624
    </func>
 
625
    <func>
 
626
      <name>change_table_copy_type(Tab, Node, To) -> {aborted, R} | {atomic, ok}</name>
 
627
      <fsummary>Change the storage type of a table.</fsummary>
 
628
      <desc>
 
629
        <p>For example:</p>
 
630
        <code type="none">
 
631
mnesia:change_table_copy_type(person, node(), disc_copies)
 
632
        </code>
 
633
        <p>Transforms our <c>person</c> table from a RAM table into
 
634
          a disc based table at <c>Node</c>. 
 
635
          </p>
 
636
        <p>This function can also be used to change the storage type of
 
637
          the table named <c>schema</c>. The schema table can only
 
638
          have <c>ram_copies</c> or <c>disc_copies</c> as the storage type. If the
 
639
          storage type of the schema is <c>ram_copies</c>, no other table
 
640
          can be disc resident on that node.</p>
 
641
      </desc>
 
642
    </func>
 
643
    <func>
 
644
      <name>change_table_load_order(Tab, LoadOrder) -> {aborted, R} | {atomic, ok}</name>
 
645
      <fsummary>Change the load order priority for the table.</fsummary>
 
646
      <desc>
 
647
        <p>The <c>LoadOrder</c> priority is by default <c>0</c> (zero)
 
648
          but may be set to any integer. The tables with the highest
 
649
          <c>LoadOrder</c> priority will be loaded first at startup.</p>
 
650
      </desc>
 
651
    </func>
 
652
    <func>
 
653
      <name>clear_table(Tab) -> {aborted, R} | {atomic, ok}</name>
 
654
      <fsummary>Deletes all entries in a table.</fsummary>
 
655
      <desc>
 
656
        <p>Deletes all entries in the table <c>Tab</c>.</p>
 
657
      </desc>
 
658
    </func>
 
659
    <func>
 
660
      <name>create_schema(DiscNodes) -> ok | {error,Reason}</name>
 
661
      <fsummary>Create a brand new schema on the specified nodes.</fsummary>
 
662
      <desc>
 
663
        <p>Creates a new database on disc. Various files are
 
664
          created in the local Mnesia directory of each node. Note
 
665
          that the directory must be unique for each node. Two nodes
 
666
          may never share the same directory. If possible, use a local
 
667
          disc device in order to improve performance.</p>
 
668
        <p><c>mnesia:create_schema/1</c> fails if any of the
 
669
          Erlang nodes given as <c>DiscNodes</c> are not alive, if
 
670
          Mnesia is running on anyone of the nodes, or if anyone of
 
671
          the nodes already has a schema.  Use
 
672
          <c>mnesia:delete_schema/1</c> to get rid of old faulty
 
673
          schemas.
 
674
          </p>
 
675
        <p><em>Note:</em> Only nodes with disc should be
 
676
          included in <c>DiscNodes</c>. Disc-less nodes, that is nodes
 
677
          where all tables including the schema only resides in RAM,
 
678
          may not be included.</p>
 
679
      </desc>
 
680
    </func>
 
681
    <func>
 
682
      <name>create_table(Name, TabDef) -> {atomic, ok} | {aborted, Reason}</name>
 
683
      <fsummary>Create a Mnesia table called <c>Name</c>with properties as described by the argument <c>TabDef</c>.</fsummary>
 
684
      <desc>
 
685
        <p>This function creates a Mnesia table called <c>Name</c>
 
686
          according to the
 
687
          argument <c>TabDef</c>. This list must be a list of
 
688
          <c>{Item, Value}</c> tuples, where the following values are
 
689
          allowed:</p>
 
690
        <list type="bulleted">
 
691
          <item>
 
692
            <p><c>{access_mode, Atom}</c>.  The access mode  is by
 
693
              default the atom <c>read_write</c> but it may also be
 
694
              set to the atom <c>read_only</c>. If the
 
695
              <c>AccessMode</c> is set to <c>read_only</c>, it means
 
696
              that it is not possible to perform updates to the table.
 
697
              </p>
 
698
            <p>At startup Mnesia always loads <c>read_only</c> tables
 
699
              locally regardless of when and if Mnesia was terminated
 
700
              on other nodes. This argument returns the access mode of
 
701
              the table. The access mode may either be read_only or
 
702
              read_write.
 
703
              </p>
 
704
          </item>
 
705
          <item>
 
706
            <p><c>{attributes, AtomList}</c> a list of the
 
707
              attribute names for the records that are supposed to
 
708
              populate the table. The default value is <c>[key, val]</c>. The table must have at least one extra
 
709
              attribute in addition to the  key.
 
710
              </p>
 
711
            <p>When accessing single attributes in a record, it is not
 
712
              necessary, or even recommended, to hard code any
 
713
              attribute names as atoms. Use the construct
 
714
              <c>record_info(fields, RecordName)</c> instead. It can be
 
715
              used for records of type <c>RecordName</c></p>
 
716
          </item>
 
717
          <item>
 
718
            <p><c>{disc_copies, Nodelist}</c>, where
 
719
              <c>Nodelist</c> is a list of the nodes where this table
 
720
              is supposed to have  disc copies. If a table replica is
 
721
              of type <c>disc_copies</c>, all write operations on this
 
722
              particular replica of the table are written to disc as
 
723
              well as to the RAM copy of the table.
 
724
              </p>
 
725
            <p>It is possible
 
726
              to have a replicated table of type   <c>disc_copies</c>
 
727
              on one node, and another type on another node.  The
 
728
              default value is <c>[]</c></p>
 
729
          </item>
 
730
          <item>
 
731
            <p><c>{disc_only_copies, Nodelist}</c>, where
 
732
              <c>Nodelist</c> is a list of the nodes where this table
 
733
              is supposed to  have <c>disc_only_copies</c>. A disc only
 
734
              table replica is kept on disc  only and unlike the other
 
735
              replica types, the contents of the replica will not
 
736
              reside in RAM. These replicas are considerably slower
 
737
              than replicas held in RAM.
 
738
              </p>
 
739
          </item>
 
740
          <item>
 
741
            <p><c>{index, Intlist}</c>, where
 
742
              <c>Intlist</c> is a list of attribute names (atoms) or
 
743
              record fields for which Mnesia shall build and maintain
 
744
              an extra index table. The <c>qlc</c> query compiler may
 
745
              or may not utilize any additional indices while
 
746
              processing queries on a table. 
 
747
              </p>
 
748
          </item>
 
749
          <item>
 
750
            <p><c>{load_order, Integer}</c>. The load order
 
751
              priority is by default <c>0</c> (zero) but may be set to
 
752
              any integer. The tables with the highest load order
 
753
              priority will be loaded first at startup.
 
754
              </p>
 
755
          </item>
 
756
          <item>
 
757
            <p><c>{ram_copies, Nodelist}</c>, where
 
758
              <c>Nodelist</c> is a list of the nodes where this table
 
759
              is supposed to  have RAM copies. A table replica of type
 
760
              <c>ram_copies</c> is obviously not written to disc on a
 
761
              per transaction basis. It is possible to  dump
 
762
              <c>ram_copies</c> replicas to disc with the function
 
763
              <c>mnesia:dump_tables(Tabs)</c>. The default value for
 
764
              this attribute is <c>[node()]</c>.
 
765
              </p>
 
766
          </item>
 
767
          <item>
 
768
            <p><c>{record_name, Name}</c>, where <c>Name</c> must
 
769
              be an atom.  All records, stored in the table, must have
 
770
              this name as the first element. It defaults to the same
 
771
              name as the name of the table.
 
772
              </p>
 
773
          </item>
 
774
          <item>
 
775
            <p><c>{snmp, SnmpStruct}</c>. See
 
776
              <c>mnesia:snmp_open_table/2</c> for a description of
 
777
              <c>SnmpStruct</c>. If this attribute is present in the
 
778
              <c>ArgList</c> to <c>mnesia:create_table/2</c>, the
 
779
              table is immediately accessible by means of the Simple
 
780
              Network Management  Protocol (SNMP). This means that
 
781
              applications which use SNMP to manipulate and control
 
782
              the system can be designed easily, since Mnesia provides
 
783
              a direct mapping between the logical tables that make up
 
784
              an SNMP control application and the physical data which
 
785
              makes up a Mnesia table.
 
786
              </p>
 
787
          </item>
 
788
          <item>
 
789
            <p><c>{type, Type}</c>, where <c>Type</c> must be
 
790
              either of the atoms <c>set</c>, <c>ordered_set</c> or
 
791
              <c>bag</c>. The default value is <c>set</c>. In a
 
792
              <c>set</c> all records have unique keys and in a
 
793
              <c>bag</c> several records may have the same key, but
 
794
              the record content is unique. If a non-unique record is
 
795
              stored the old, conflicting record(s) will simply be
 
796
              overwritten. Note: currently 'ordered_set' 
 
797
              is not supported for 'disc_only_copies'.
 
798
              </p>
 
799
          </item>
 
800
          <item>
 
801
            <p><c>{local_content, Bool}</c>, where <c>Bool</c> must be
 
802
              either <c>true</c> or <c>false</c>. The default value is <c>false</c>.\011      </p>
 
803
          </item>
 
804
        </list>
 
805
        <p>For example, the following call creates the <c>person</c> table
 
806
          previously defined and replicates it on 2 nodes: 
 
807
          </p>
 
808
        <code type="none">
 
809
mnesia:create_table(person, 
 
810
    [{ram_copies, [N1, N2]},
 
811
     {attributes, record_info(fields,person)}]).
 
812
        </code>
 
813
        <p>If it was required that Mnesia   build and maintain an extra index
 
814
          table on the <c>address</c> attribute of all the <c>person</c>
 
815
          records that are inserted in the table, the following code would be issued:
 
816
          </p>
 
817
        <code type="none">
 
818
mnesia:create_table(person,
 
819
    [{ram_copies, [N1, N2]},
 
820
     {index, [address]},
 
821
     {attributes, record_info(fields,person)}]).
 
822
        </code>
 
823
        <p>The specification of <c>index</c> and <c>attributes</c> may be
 
824
          hard coded as <c>{index, [2]}</c> and 
 
825
          <c>{attributes, [name, age, address, salary, children]}</c> 
 
826
          respectively.
 
827
          </p>
 
828
        <p><c>mnesia:create_table/2</c> writes records into the
 
829
          <c>schema</c> table. This function, as well as all other
 
830
          schema manipulation functions, are implemented with the
 
831
          normal transaction management system. This guarantees that
 
832
          schema updates are performed on all nodes in an atomic
 
833
          manner.</p>
 
834
      </desc>
 
835
    </func>
 
836
    <func>
 
837
      <name>deactivate_checkpoint(Name) -> ok | {error, Reason}</name>
 
838
      <fsummary>Deactivate a checkpoint.</fsummary>
 
839
      <desc>
 
840
        <p>The checkpoint is automatically deactivated when some of
 
841
          the tables involved have no retainer attached to them. This may
 
842
          happen when nodes go down or when a replica is deleted.
 
843
          Checkpoints will also be deactivated with this function.
 
844
          <c>Name</c> is the name of an active checkpoint.</p>
 
845
      </desc>
 
846
    </func>
 
847
    <func>
 
848
      <name>del_table_copy(Tab, Node) -> {aborted, R} | {atomic, ok}</name>
 
849
      <fsummary>Delete the replica of table <c>Tab</c>at node <c>Node</c>.</fsummary>
 
850
      <desc>
 
851
        <p>Deletes the replica of table <c>Tab</c> at node <c>Node</c>.
 
852
          When the last replica is deleted with this
 
853
          function, the table disappears entirely.
 
854
          </p>
 
855
        <p>This function may also be used to delete a replica of
 
856
          the table named <c>schema</c>. Then the mnesia node will be removed.
 
857
          Note: Mnesia must be stopped on the node first.</p>
 
858
      </desc>
 
859
    </func>
 
860
    <func>
 
861
      <name>del_table_index(Tab, AttrName) -> {aborted, R} | {atomic, ok}</name>
 
862
      <fsummary>Delete an index in a table. </fsummary>
 
863
      <desc>
 
864
        <p>This function deletes the index on attribute with name
 
865
          <c>AttrName</c> in a table.</p>
 
866
      </desc>
 
867
    </func>
 
868
    <func>
 
869
      <name>delete({Tab, Key}) -> transaction abort | ok </name>
 
870
      <fsummary>Delete all records in table <c>Tab</c>with the key <c>Key</c>.</fsummary>
 
871
      <desc>
 
872
        <p>Invokes <c>mnesia:delete(Tab, Key, write)</c></p>
 
873
      </desc>
 
874
    </func>
 
875
    <func>
 
876
      <name>delete(Tab, Key, LockKind) -> transaction abort | ok </name>
 
877
      <fsummary>Delete all records in table <c>Tab</c>with the key <c>Key</c>.</fsummary>
 
878
      <desc>
 
879
        <p>Deletes all records in table <c>Tab</c> with the key
 
880
          <c>Key</c>.  
 
881
          </p>
 
882
        <p>The semantics of this function is context sensitive. See
 
883
          <c>mnesia:activity/4</c> for more information. In transaction
 
884
          context it acquires a lock of type <c>LockKind</c> in the
 
885
          record.  Currently the lock types <c>write</c> and
 
886
          <c>sticky_write</c> are supported.</p>
 
887
      </desc>
 
888
    </func>
 
889
    <func>
 
890
      <name>delete_object(Record) -> transaction abort | ok </name>
 
891
      <fsummary>Delete a record</fsummary>
 
892
      <desc>
 
893
        <p>Invokes <c>mnesia:delete_object(Tab, Record, write)</c> where
 
894
          <c>Tab</c> is <c>element(1, Record)</c>.</p>
 
895
      </desc>
 
896
    </func>
 
897
    <func>
 
898
      <name>delete_object(Tab, Record, LockKind) -> transaction abort | ok </name>
 
899
      <fsummary>Delete a record</fsummary>
 
900
      <desc>
 
901
        <p>If a table is of type <c>bag</c>, we may sometimes
 
902
          want to delete only some of the records with a certain
 
903
          key. This can be done with the <c>delete_object/3</c>
 
904
          function.  A complete record must be supplied to this
 
905
          function.  
 
906
          </p>
 
907
        <p>The semantics of this function is context sensitive. See
 
908
          <c>mnesia:activity/4</c> for more information. In transaction
 
909
          context it acquires a lock of type <c>LockKind</c> on the
 
910
          record. Currently the lock types <c>write</c> and
 
911
          <c>sticky_write</c> are supported.</p>
 
912
      </desc>
 
913
    </func>
 
914
    <func>
 
915
      <name>delete_schema(DiscNodes) -> ok | {error,Reason}</name>
 
916
      <fsummary>Delete the schema on the given nodes</fsummary>
 
917
      <desc>
 
918
        <p>Deletes a database created with
 
919
          <c>mnesia:create_schema/1</c>.
 
920
          <c>mnesia:delete_schema/1</c> fails if any of the Erlang
 
921
          nodes given as <c>DiscNodes</c> is not alive, or if Mnesia
 
922
          is running on any of the nodes.
 
923
          </p>
 
924
        <p>After the database has been deleted, it may still be
 
925
          possible to start Mnesia as a disc-less node. This depends on
 
926
          how the configuration parameter <c>schema_location</c> is set.
 
927
          </p>
 
928
        <warning>
 
929
          <p>This function must be used with extreme
 
930
            caution since it makes  existing persistent data
 
931
            obsolete. Think twice before using it.  </p>
 
932
        </warning>
 
933
      </desc>
 
934
    </func>
 
935
    <func>
 
936
      <name>delete_table(Tab) -> {aborted, Reason} | {atomic, ok} </name>
 
937
      <fsummary>Delete permanently all replicas of table <c>Tab</c>.</fsummary>
 
938
      <desc>
 
939
        <p>Permanently deletes all replicas of table <c>Tab</c>.</p>
 
940
      </desc>
 
941
    </func>
 
942
    <func>
 
943
      <name>dirty_all_keys(Tab) -> KeyList | exit({aborted, Reason}).</name>
 
944
      <fsummary>Dirty search for all record keys in table.</fsummary>
 
945
      <desc>
 
946
        <p>This is the dirty equivalent of the
 
947
          <c>mnesia:all_keys/1</c> function.</p>
 
948
      </desc>
 
949
    </func>
 
950
    <func>
 
951
      <name>dirty_delete({Tab, Key}) -> ok | exit({aborted, Reason}) </name>
 
952
      <fsummary>Dirty delete of a record.</fsummary>
 
953
      <desc>
 
954
        <p>Invokes <c>mnesia:dirty_delete(Tab, Key)</c>.</p>
 
955
      </desc>
 
956
    </func>
 
957
    <func>
 
958
      <name>dirty_delete(Tab, Key) -> ok | exit({aborted, Reason}) </name>
 
959
      <fsummary>Dirty delete of a record. </fsummary>
 
960
      <desc>
 
961
        <p>This is the dirty equivalent of the 
 
962
          <c>mnesia:delete/3</c> function.</p>
 
963
      </desc>
 
964
    </func>
 
965
    <func>
 
966
      <name>dirty_delete_object(Record) </name>
 
967
      <fsummary>Dirty delete of a record.</fsummary>
 
968
      <desc>
 
969
        <p>Invokes <c>mnesia:dirty_delete_object(Tab, Record)</c>
 
970
          where <c>Tab</c> is <c>element(1, Record)</c>.</p>
 
971
      </desc>
 
972
    </func>
 
973
    <func>
 
974
      <name>dirty_delete_object(Tab, Record) </name>
 
975
      <fsummary>Dirty delete of a record. </fsummary>
 
976
      <desc>
 
977
        <p>This is the dirty equivalent of the
 
978
          <c>mnesia:delete_object/3</c> function.</p>
 
979
      </desc>
 
980
    </func>
 
981
    <func>
 
982
      <name>dirty_first(Tab) ->  Key | exit({aborted, Reason}) </name>
 
983
      <fsummary>Return the key for the first record in a table.</fsummary>
 
984
      <desc>
 
985
        <p>Records in <c>set</c> or <c>bag</c> tables are not ordered. 
 
986
          However, there 
 
987
          is an ordering of the records which is not known 
 
988
          to the user. Accordingly, it is possible to traverse a table by means
 
989
          of this function in conjunction with the <c>mnesia:dirty_next/2</c> 
 
990
          function.
 
991
          </p>
 
992
        <p>If there are no records at all in the table, this function
 
993
          returns the atom <c>'$end_of_table'</c>. For this reason, it
 
994
          is highly undesirable, but not disallowed, to use this atom
 
995
          as the key for any user records.</p>
 
996
      </desc>
 
997
    </func>
 
998
    <func>
 
999
      <name>dirty_index_match_object(Pattern, Pos)</name>
 
1000
      <fsummary>Dirty pattern match using index.</fsummary>
 
1001
      <desc>
 
1002
        <p>Invokes <c>mnesia:dirty_index_match_object(Tab, Pattern, Pos)</c> where <c>Tab</c> is <c>element(1, Pattern)</c>.</p>
 
1003
      </desc>
 
1004
    </func>
 
1005
    <func>
 
1006
      <name>dirty_index_match_object(Tab, Pattern, Pos)</name>
 
1007
      <fsummary>Dirty pattern match using index.</fsummary>
 
1008
      <desc>
 
1009
        <p>This is the dirty equivalent of the
 
1010
          <c>mnesia:index_match_object/4</c> function.</p>
 
1011
      </desc>
 
1012
    </func>
 
1013
    <func>
 
1014
      <name>dirty_index_read(Tab, SecondaryKey, Pos)</name>
 
1015
      <fsummary>Dirty read using index.</fsummary>
 
1016
      <desc>
 
1017
        <p>This is the dirty equivalent of the
 
1018
          <c>mnesia:index_read/3</c> function.</p>
 
1019
      </desc>
 
1020
    </func>
 
1021
    <func>
 
1022
      <name>dirty_last(Tab) ->  Key | exit({aborted, Reason}) </name>
 
1023
      <fsummary>Return the key for the last record in a table.</fsummary>
 
1024
      <desc>
 
1025
        <p>This function works exactly 
 
1026
          <c>mnesia:dirty_first/1</c> but returns the last object in
 
1027
          Erlang  term  order for the <c>ordered_set</c> table type. For
 
1028
          all other table types, <c>mnesia:dirty_first/1</c> and 
 
1029
          <c>mnesia:dirty_last/1</c> are synonyms.</p>
 
1030
      </desc>
 
1031
    </func>
 
1032
    <func>
 
1033
      <name>dirty_match_object(Pattern) -> RecordList | exit({aborted, Reason}).</name>
 
1034
      <fsummary>Dirty pattern match pattern.</fsummary>
 
1035
      <desc>
 
1036
        <p>Invokes <c>mnesia:dirty_match_object(Tab, Pattern)</c>
 
1037
          where <c>Tab</c> is <c>element(1, Pattern)</c>.</p>
 
1038
      </desc>
 
1039
    </func>
 
1040
    <func>
 
1041
      <name>dirty_match_object(Tab, Pattern) -> RecordList | exit({aborted, Reason}).</name>
 
1042
      <fsummary>Dirty pattern match pattern.</fsummary>
 
1043
      <desc>
 
1044
        <p>This is the dirty equivalent of the
 
1045
          <c>mnesia:match_object/3</c> function.</p>
 
1046
      </desc>
 
1047
    </func>
 
1048
    <func>
 
1049
      <name>dirty_next(Tab, Key) -> Key | exit({aborted, Reason}) </name>
 
1050
      <fsummary>Return the next key in a table. </fsummary>
 
1051
      <desc>
 
1052
        <p>This function makes it possible to traverse a table
 
1053
          and perform operations on all records in the table. When
 
1054
          the end of the table is reached, the special key
 
1055
          <c>'$end_of_table'</c> is returned. Otherwise, the function
 
1056
          returns a key which can be used to read the actual record.The
 
1057
          behavior is undefined if another Erlang process performs write
 
1058
          operations on the table while it is being traversed with the
 
1059
          <c>mnesia:dirty_next/2</c> function.</p>
 
1060
      </desc>
 
1061
    </func>
 
1062
    <func>
 
1063
      <name>dirty_prev(Tab, Key) -> Key | exit({aborted, Reason}) </name>
 
1064
      <fsummary>Return the previous key in a table. </fsummary>
 
1065
      <desc>
 
1066
        <p>This function works exactly 
 
1067
          <c>mnesia:dirty_next/2</c> but returns the previous object in
 
1068
          Erlang term  order for the ordered_set table type. For
 
1069
          all other table types, <c>mnesia:dirty_next/2</c> and 
 
1070
          <c>mnesia:dirty_prev/2</c> are synonyms.\011  </p>
 
1071
      </desc>
 
1072
    </func>
 
1073
    <func>
 
1074
      <name>dirty_read({Tab, Key}) -> ValueList | exit({aborted, Reason}</name>
 
1075
      <fsummary>Dirty read of records.</fsummary>
 
1076
      <desc>
 
1077
        <p>Invokes <c>mnesia:dirty_read(Tab, Key)</c>.</p>
 
1078
      </desc>
 
1079
    </func>
 
1080
    <func>
 
1081
      <name>dirty_read(Tab, Key) -> ValueList | exit({aborted, Reason}</name>
 
1082
      <fsummary>Dirty read of records.</fsummary>
 
1083
      <desc>
 
1084
        <p>This is the dirty equivalent of the
 
1085
          <c>mnesia:read/3</c> function.</p>
 
1086
      </desc>
 
1087
    </func>
 
1088
    <func>
 
1089
      <name>dirty_select(Tab, MatchSpec) -> ValueList | exit({aborted, Reason}</name>
 
1090
      <fsummary>Dirty match the objects in <c>Tab</c>against <c>MatchSpec</c>.</fsummary>
 
1091
      <desc>
 
1092
        <p>This is the dirty equivalent of the
 
1093
          <c>mnesia:select/2</c> function.</p>
 
1094
      </desc>
 
1095
    </func>
 
1096
    <func>
 
1097
      <name>dirty_slot(Tab, Slot) -> RecordList | exit({aborted, Reason})</name>
 
1098
      <fsummary>Return the list of records that are associated with  Slot in a table.</fsummary>
 
1099
      <desc>
 
1100
        <p>This function can be used to traverse a table in a
 
1101
          manner similar to the <c>mnesia:dirty_next/2</c> function.
 
1102
          A table has a number of slots which range from 0 (zero) to some
 
1103
          unknown upper bound.  The function
 
1104
          <c>mnesia:dirty_slot/2</c> returns the special atom
 
1105
          <c>'$end_of_table'</c> when the end of the table is reached.
 
1106
          The behavior of this function is undefined if a write
 
1107
          operation is performed on the table while it is being
 
1108
          traversed.</p>
 
1109
      </desc>
 
1110
    </func>
 
1111
    <func>
 
1112
      <name>dirty_update_counter({Tab, Key}, Incr) -> NewVal | exit({aborted, Reason})</name>
 
1113
      <fsummary>Dirty update of a counter record.</fsummary>
 
1114
      <desc>
 
1115
        <p>Invokes <c>mnesia:dirty_update_counter(Tab, Key, Incr)</c>.</p>
 
1116
      </desc>
 
1117
    </func>
 
1118
    <func>
 
1119
      <name>dirty_update_counter(Tab, Key, Incr) -> NewVal | exit({aborted, Reason})</name>
 
1120
      <fsummary>Dirty update of a counter record.</fsummary>
 
1121
      <desc>
 
1122
        <p>There are no special counter records in Mnesia. However,
 
1123
          records of the form <c>{Tab, Key, Integer}</c> can be used
 
1124
          as (possibly disc resident) counters, when <c>Tab</c> is a
 
1125
          <c>set</c>. This function updates a counter with a
 
1126
          positive or negative number. However, counters can never become less
 
1127
          than zero. There are two significant differences between
 
1128
          this function and the action of first reading the record,
 
1129
          performing the arithmetics, and then writing the record:</p>
 
1130
        <list type="bulleted">
 
1131
          <item>It is much more efficient</item>
 
1132
          <item><c>mnesia:dirty_update_counter/3</c> is
 
1133
           performed as an atomic operation despite the fact that it is not
 
1134
           protected by a transaction.</item>
 
1135
        </list>
 
1136
        <p>If two processes perform <c>mnesia:dirty_update_counter/3</c>
 
1137
          simultaneously, both updates will take effect without the
 
1138
          risk of loosing one of the updates. The new value
 
1139
          <c>NewVal</c> of the counter is returned.</p>
 
1140
        <p>If <c>Key</c> don't exits, a new record is created with the value
 
1141
          <c>Incr</c> if it is larger than 0, otherwise it is set to 0.</p>
 
1142
      </desc>
 
1143
    </func>
 
1144
    <func>
 
1145
      <name>dirty_write(Record) -> ok | exit({aborted, Reason})</name>
 
1146
      <fsummary>Dirty write of a record.</fsummary>
 
1147
      <desc>
 
1148
        <p>Invokes <c>mnesia:dirty_write(Tab, Record)</c>
 
1149
          where <c>Tab</c> is <c>element(1, Record)</c>.</p>
 
1150
      </desc>
 
1151
    </func>
 
1152
    <func>
 
1153
      <name>dirty_write(Tab, Record) -> ok | exit({aborted, Reason})</name>
 
1154
      <fsummary>Dirty write of a record.</fsummary>
 
1155
      <desc>
 
1156
        <p>This is the dirty equivalent of <c>mnesia:write/3</c>.</p>
 
1157
      </desc>
 
1158
    </func>
 
1159
    <func>
 
1160
      <name>dump_log() -> dumped</name>
 
1161
      <fsummary>Perform a user initiated dump of the local log file.</fsummary>
 
1162
      <desc>
 
1163
        <p>Performs a user initiated dump of the local log file.
 
1164
          This is usually not necessary since Mnesia, by default,
 
1165
          manages this automatically.</p>
 
1166
      </desc>
 
1167
    </func>
 
1168
    <func>
 
1169
      <name>dump_tables(TabList) -> {atomic, ok} | {aborted, Reason}</name>
 
1170
      <fsummary>Dump all RAM tables to disc.</fsummary>
 
1171
      <desc>
 
1172
        <p>This function dumps a set of <c>ram_copies</c> tables
 
1173
          to disc. The next time the system is started, these tables
 
1174
          are initiated with the data found in the files that are the
 
1175
          result of this dump. None of the tables may have disc
 
1176
          resident replicas.</p>
 
1177
      </desc>
 
1178
    </func>
 
1179
    <func>
 
1180
      <name>dump_to_textfile(Filename) </name>
 
1181
      <fsummary>Dump local tables into a text file.</fsummary>
 
1182
      <desc>
 
1183
        <p>Dumps all local tables of a mnesia system into a text file
 
1184
          which can then be edited (by means of a normal text editor)
 
1185
          and then later be reloaded with
 
1186
          <c>mnesia:load_textfile/1</c>. Only use this function for
 
1187
          educational purposes. Use other functions to deal with real
 
1188
          backups.</p>
 
1189
      </desc>
 
1190
    </func>
 
1191
    <func>
 
1192
      <name>error_description(Error) -> String </name>
 
1193
      <fsummary>Return a string describing a particular Mnesia error.</fsummary>
 
1194
      <desc>
 
1195
        <p>All Mnesia transactions, including all the schema
 
1196
          update functions, either return the value <c>{atomic, Val}</c> or the tuple <c>{aborted, Reason}</c>. The
 
1197
          <c>Reason</c> can be either of the following atoms. The
 
1198
          <c>error_description/1</c> function returns a descriptive
 
1199
          string which describes the error.
 
1200
          </p>
 
1201
        <list type="bulleted">
 
1202
          <item>
 
1203
            <p><c>nested_transaction</c>. Nested transactions are
 
1204
              not allowed in this context.
 
1205
              </p>
 
1206
          </item>
 
1207
          <item>
 
1208
            <p><c>badarg</c>. Bad or invalid argument, possibly
 
1209
              bad type.
 
1210
              </p>
 
1211
          </item>
 
1212
          <item>
 
1213
            <p><c>no_transaction</c>. Operation not allowed
 
1214
              outside transactions.
 
1215
              </p>
 
1216
          </item>
 
1217
          <item>
 
1218
            <p><c>combine_error</c>. Table options  were illegally
 
1219
              combined.
 
1220
              </p>
 
1221
          </item>
 
1222
          <item>
 
1223
            <p><c>bad_index</c>. Index already exists or was out
 
1224
              of bounds.
 
1225
              </p>
 
1226
          </item>
 
1227
          <item>
 
1228
            <p><c>already_exists</c>. Schema option is already set.
 
1229
              </p>
 
1230
          </item>
 
1231
          <item>
 
1232
            <p><c>index_exists</c>. Some operations cannot  be performed on 
 
1233
              tabs with index.
 
1234
              </p>
 
1235
          </item>
 
1236
          <item>
 
1237
            <p><c>no_exists</c>. Tried to perform operation on
 
1238
              non-existing, or not alive, item.
 
1239
              </p>
 
1240
          </item>
 
1241
          <item>
 
1242
            <p><c>system_limit</c>. Some system_limit was exhausted.
 
1243
              </p>
 
1244
          </item>
 
1245
          <item>
 
1246
            <p><c>mnesia_down</c>.  A transaction involving
 
1247
              records at some remote  node which died while
 
1248
              transaction was executing. Record(s) are no longer
 
1249
              available elsewhere in the network.
 
1250
              </p>
 
1251
          </item>
 
1252
          <item>
 
1253
            <p><c>not_a_db_node</c>. A node which does not exist
 
1254
              in  the schema was mentioned.
 
1255
              </p>
 
1256
          </item>
 
1257
          <item>
 
1258
            <p><c>bad_type</c>. Bad type on some arguments.
 
1259
              </p>
 
1260
          </item>
 
1261
          <item>
 
1262
            <p><c>node_not_running</c>. Node not running.
 
1263
              </p>
 
1264
          </item>
 
1265
          <item>
 
1266
            <p><c>truncated_binary_file</c>. Truncated binary in file.
 
1267
              </p>
 
1268
          </item>
 
1269
          <item>
 
1270
            <p><c>active</c>. Some delete operations require that 
 
1271
              all active records are removed.
 
1272
              </p>
 
1273
          </item>
 
1274
          <item>
 
1275
            <p><c>illegal</c>. Operation not supported on record.
 
1276
              </p>
 
1277
          </item>
 
1278
        </list>
 
1279
        <p>The <c>Error</c> may be <c>Reason</c>,
 
1280
          <c>{error, Reason}</c>, or <c>{aborted, Reason}</c>. The
 
1281
          <c>Reason</c> may be an atom or a tuple with <c>Reason</c>
 
1282
          as an atom in the first field.</p>
 
1283
      </desc>
 
1284
    </func>
 
1285
    <func>
 
1286
      <name>ets(Fun, [, Args]) -> ResultOfFun | exit(Reason)</name>
 
1287
      <fsummary>Call the Fun in a raw context which is not protected by a transaction.</fsummary>
 
1288
      <desc>
 
1289
        <p>Call the <c>Fun</c> in a raw context which is not protected by
 
1290
          a transaction. The Mnesia function call is performed in the
 
1291
          <c>Fun</c> are performed directly on the local <c>ets</c> tables on
 
1292
          the assumption that the local storage type is
 
1293
          <c>ram_copies</c> and the tables are not replicated to other
 
1294
          nodes. Subscriptions are not triggered and checkpoints are
 
1295
          not updated, but it is extremely fast.  This function can
 
1296
          also be applied to <c>disc_copies</c> tables if all
 
1297
          operations are read only.  See <c>mnesia:activity/4</c>
 
1298
          and the Mnesia User's Guide for more details.</p>
 
1299
        <p><em>Note:</em> Calling (nesting) a <c>mnesia:ets</c>
 
1300
          inside a transaction context will inherit the transaction semantics.</p>
 
1301
      </desc>
 
1302
    </func>
 
1303
    <func>
 
1304
      <name>first(Tab) ->  Key | transaction abort </name>
 
1305
      <fsummary>Return the key for the first record in a table.</fsummary>
 
1306
      <desc>
 
1307
        <p>Records in <c>set</c> or <c>bag</c> tables are not ordered. 
 
1308
          However, there 
 
1309
          is an ordering of the records which is not known 
 
1310
          to the user. Accordingly, it is possible to traverse a table by means
 
1311
          of this function in conjunction with the <c>mnesia:next/2</c> 
 
1312
          function.
 
1313
          </p>
 
1314
        <p>If there are no records at all in the table, this function
 
1315
          returns the atom <c>'$end_of_table'</c>. For this reason, it
 
1316
          is highly undesirable, but not disallowed, to use this atom
 
1317
          as the key for any user records.</p>
 
1318
      </desc>
 
1319
    </func>
 
1320
    <func>
 
1321
      <name>foldl(Function, Acc, Table) -> NewAcc | transaction abort </name>
 
1322
      <fsummary>Call Function for each record in Table </fsummary>
 
1323
      <desc>
 
1324
        <p>Iterates over the table <c>Table</c> and calls 
 
1325
          <c>Function(Record, NewAcc)</c> for each <c>Record</c> in the table.
 
1326
          The term returned from <c>Function</c> will be used as the second 
 
1327
          argument in the next call to the <c>Function</c>. 
 
1328
          </p>
 
1329
        <p><c>foldl</c> returns the same term as the last call to 
 
1330
          <c>Function</c> returned.</p>
 
1331
      </desc>
 
1332
    </func>
 
1333
    <func>
 
1334
      <name>foldr(Function, Acc, Table) -> NewAcc | transaction abort </name>
 
1335
      <fsummary>Call Function for each record in Table  </fsummary>
 
1336
      <desc>
 
1337
        <p>This function works exactly as 
 
1338
          <c>foldl/3</c> but iterates the table in the opposite order 
 
1339
          for the <c>ordered_set</c> table type. For
 
1340
          all other table types, <c>foldr/3</c> and 
 
1341
          <c>foldl/3</c> are synonyms.</p>
 
1342
      </desc>
 
1343
    </func>
 
1344
    <func>
 
1345
      <name>force_load_table(Tab) -> yes | ErrorDescription </name>
 
1346
      <fsummary>Force a table to be loaded into the system </fsummary>
 
1347
      <desc>
 
1348
        <p>The Mnesia algorithm for table load might lead to a
 
1349
          situation where a table cannot be loaded. This situation
 
1350
          occurs when a node is started and Mnesia concludes, or
 
1351
          suspects, that another copy of the table was active after
 
1352
          this local copy became inactive due to a system crash.
 
1353
          </p>
 
1354
        <p>If this situation is not acceptable, this function can be
 
1355
          used to override the strategy of the Mnesia table load
 
1356
          algorithm. This could lead to a situation where some
 
1357
          transaction effects are lost with a inconsistent database as
 
1358
          result, but for some applications high availability is more
 
1359
          important than consistent data.</p>
 
1360
      </desc>
 
1361
    </func>
 
1362
    <func>
 
1363
      <name>index_match_object(Pattern, Pos) -> transaction abort | ObjList</name>
 
1364
      <fsummary>Match records and utilizes index information.</fsummary>
 
1365
      <desc>
 
1366
        <p>Invokes <c>mnesia:index_match_object(Tab, Pattern, Pos, read)</c> where <c>Tab</c> is <c>element(1, Pattern)</c>.</p>
 
1367
      </desc>
 
1368
    </func>
 
1369
    <func>
 
1370
      <name>index_match_object(Tab, Pattern, Pos, LockKind) -> transaction abort | ObjList</name>
 
1371
      <fsummary>Match records and utilizes index information.</fsummary>
 
1372
      <desc>
 
1373
        <p>In a manner similar to the <c>mnesia:index_read/3</c>
 
1374
          function, we can also utilize any index information when we
 
1375
          try to match records. This function takes a pattern which
 
1376
          obeys the same rules as the <c>mnesia:match_object/3</c>
 
1377
          function with the exception that this function requires the
 
1378
          following conditions:
 
1379
          </p>
 
1380
        <list type="bulleted">
 
1381
          <item>
 
1382
            <p>The table <c>Tab</c> must have an index on
 
1383
              position <c>Pos</c>.
 
1384
              </p>
 
1385
          </item>
 
1386
          <item>
 
1387
            <p>The element in position <c>Pos</c> in
 
1388
              <c>Pattern</c> must be bound. <c>Pos</c> may either be
 
1389
              an integer (#record.Field), or an attribute name.</p>
 
1390
          </item>
 
1391
        </list>
 
1392
        <p>The two index search functions described here are
 
1393
          automatically invoked when searching tables with <c>qlc</c>
 
1394
          list comprehensions and also when using the low level
 
1395
          <c>mnesia:[dirty_]match_object</c> functions.
 
1396
          </p>
 
1397
        <p></p>
 
1398
        <p>The semantics of this function is context sensitive. See
 
1399
          <c>mnesia:activity/4</c> for more information. In transaction
 
1400
          context it acquires a lock of type <c>LockKind</c> on the
 
1401
          entire table or on a single record. Currently, the lock type
 
1402
          <c>read</c> is supported.
 
1403
          </p>
 
1404
      </desc>
 
1405
    </func>
 
1406
    <func>
 
1407
      <name>index_read(Tab, SecondaryKey, Pos) -> transaction abort | RecordList </name>
 
1408
      <fsummary>Read records via index table. </fsummary>
 
1409
      <desc>
 
1410
        <p>Assume there is an index on position <c>Pos</c> for a
 
1411
          certain record type. This function can be used to read the
 
1412
          records without knowing the actual key for the record. For
 
1413
          example, with an index in position 1 of the <c>person</c>
 
1414
          table, the call <c>mnesia:index_read(person, 36, #person.age)</c> returns a list of all persons with age
 
1415
          equal to 36.  <c>Pos</c> may also be an attribute name
 
1416
          (atom), but if the notation <c>mnesia:index_read(person, 36, age)</c> is used, the field position will be searched for in
 
1417
          runtime, for each call.
 
1418
          </p>
 
1419
        <p>The semantics of this function is context sensitive. See
 
1420
          <c>mnesia:activity/4</c> for more information. In transaction
 
1421
          context it acquires a read lock on the entire table.</p>
 
1422
      </desc>
 
1423
    </func>
 
1424
    <func>
 
1425
      <name>info() -> ok </name>
 
1426
      <fsummary>Print some information about the system on the tty.</fsummary>
 
1427
      <desc>
 
1428
        <p>Prints some information about the system on the tty.
 
1429
          This function may be used even if Mnesia is not started.
 
1430
          However, more information will be displayed if Mnesia is
 
1431
          started.</p>
 
1432
      </desc>
 
1433
    </func>
 
1434
    <func>
 
1435
      <name>install_fallback(Opaque) -> ok | {error,Reason}</name>
 
1436
      <fsummary>Install a backup as fallback.</fsummary>
 
1437
      <desc>
 
1438
        <p>Invokes <c>mnesia:install_fallback(Opaque, Args)</c> where
 
1439
          <c>Args</c> is <c>[{scope, global}]</c>.</p>
 
1440
      </desc>
 
1441
    </func>
 
1442
    <func>
 
1443
      <name>install_fallback(Opaque), BackupMod) -> ok | {error,Reason}</name>
 
1444
      <fsummary>Install a backup as fallback.</fsummary>
 
1445
      <desc>
 
1446
        <p>Invokes <c>mnesia:install_fallback(Opaque, Args)</c> where
 
1447
          <c>Args</c> is <c>[{scope, global}, {module, BackupMod}]</c>.</p>
 
1448
      </desc>
 
1449
    </func>
 
1450
    <func>
 
1451
      <name>install_fallback(Opaque, Args) -> ok | {error,Reason}</name>
 
1452
      <fsummary>Install a backup as fallback.</fsummary>
 
1453
      <desc>
 
1454
        <p>This function is used to install a backup as fallback.  The
 
1455
          fallback will be used to restore the database at the next
 
1456
          start-up. Installation of fallbacks requires Erlang to be up
 
1457
          and running on all the involved nodes, but it does not
 
1458
          matter if Mnesia is running or not. The installation of the
 
1459
          fallback will fail if the local node is not one of the disc
 
1460
          resident nodes in the backup.
 
1461
          </p>
 
1462
        <p><c>Args</c> is a list of the following tuples: 
 
1463
          </p>
 
1464
        <list type="bulleted">
 
1465
          <item>
 
1466
            <p><c>{module, BackupMod}</c>. 
 
1467
              All accesses of the backup media is performed via a
 
1468
              callback module named <c>BackupMod</c>. The
 
1469
              <c>Opaque</c> argument is forwarded to the callback
 
1470
              module which may interpret it as it wish. The default
 
1471
              callback module is called <c>mnesia_backup</c> and it
 
1472
              interprets the <c>Opaque</c> argument as a local
 
1473
              filename. The default for this module is also
 
1474
              configurable via the <c>-mnesia mnesia_backup</c>
 
1475
              configuration parameter.  </p>
 
1476
          </item>
 
1477
          <item>
 
1478
            <p><c>{scope, Scope}</c>
 
1479
              The <c>Scope</c> of a fallback may either be
 
1480
              <c>global</c> for the entire database or <c>local</c>
 
1481
              for one node. By default, the installation of a fallback
 
1482
              is a global operation which either is performed all
 
1483
              nodes with disc resident schema or none. Which nodes
 
1484
              that are disc resident or not, is determined from the
 
1485
              schema info in the backup.</p>
 
1486
            <p>If the <c>Scope</c> of the operation is <c>local</c>
 
1487
              the fallback will only be installed on the local node.</p>
 
1488
          </item>
 
1489
          <item>
 
1490
            <p><c>{mnesia_dir, AlternateDir}</c> 
 
1491
              This argument is only valid if the scope of the
 
1492
              installation is <c>local</c>. Normally the installation
 
1493
              of a fallback is targeted towards the Mnesia directory
 
1494
              as configured with the <c>-mnesia dir</c> configuration
 
1495
              parameter. But by explicitly supplying an
 
1496
              <c>AlternateDir</c> the fallback will be installed there
 
1497
              regardless of the Mnesia directory configuration
 
1498
              parameter setting. After installation of a fallback on
 
1499
              an alternate Mnesia directory that directory is fully
 
1500
              prepared for usage as an active Mnesia directory.
 
1501
              </p>
 
1502
            <p>This is a somewhat dangerous feature which must be
 
1503
              used with care. By unintentional mixing of directories
 
1504
              you may easily end up with a inconsistent database, if
 
1505
              the same backup is installed on more than one directory.</p>
 
1506
          </item>
 
1507
        </list>
 
1508
      </desc>
 
1509
    </func>
 
1510
    <func>
 
1511
      <name>is_transaction() ->  boolean </name>
 
1512
      <fsummary>Check if code is running in a transaction.</fsummary>
 
1513
      <desc>
 
1514
        <p>When this function is executed inside a transaction context
 
1515
          it returns <c>true</c>, otherwise <c>false</c>.</p>
 
1516
      </desc>
 
1517
    </func>
 
1518
    <func>
 
1519
      <name>last(Tab) ->  Key | transaction abort </name>
 
1520
      <fsummary>Return the key for the last record in a table.</fsummary>
 
1521
      <desc>
 
1522
        <p>This function works exactly 
 
1523
          <c>mnesia:first/1</c> but returns the last object in
 
1524
          Erlang  term  order for the <c>ordered_set</c> table type. For
 
1525
          all other table types, <c>mnesia:first/1</c> and 
 
1526
          <c>mnesia:last/1</c> are synonyms.</p>
 
1527
      </desc>
 
1528
    </func>
 
1529
    <func>
 
1530
      <name>load_textfile(Filename)</name>
 
1531
      <fsummary>Load tables from a text file.</fsummary>
 
1532
      <desc>
 
1533
        <p>Loads a series of definitions and data found in the
 
1534
          text file (generated with <c>mnesia:dump_to_textfile/1</c>)
 
1535
          into Mnesia. This function also starts Mnesia and possibly
 
1536
          creates a new schema. This function is intended for
 
1537
          educational purposes only and using other functions to deal
 
1538
          with real backups, is recommended.</p>
 
1539
      </desc>
 
1540
    </func>
 
1541
    <func>
 
1542
      <name>lock(LockItem, LockKind) -> Nodes | ok | transaction abort</name>
 
1543
      <fsummary>Explicit grab lock.</fsummary>
 
1544
      <desc>
 
1545
        <p>Write locks are normally acquired on all nodes where a
 
1546
          replica of the table resides (and is active). Read locks are
 
1547
          acquired on one node (the local node if  a local
 
1548
          replica exists). Most of the context sensitive access functions
 
1549
          acquire an implicit lock if they are invoked in a
 
1550
          transaction context. The granularity of a lock may either
 
1551
          be a single record or an entire table.
 
1552
        </p>
 
1553
        <p>The normal usage is to call the function without checking
 
1554
          the return value since it exits if it fails and the
 
1555
          transaction is restarted by the transaction manager.  It
 
1556
          returns all the locked nodes if a write lock is aquired, and
 
1557
          <c>ok</c> if it was a read lock.
 
1558
        </p>
 
1559
        <p>This function <c>mnesia:lock/2</c> is intended to support
 
1560
          explicit locking on tables but also intended for situations
 
1561
          when locks need to be acquired regardless of how tables are
 
1562
          replicated. Currently, two <c>LockKind</c>'s are supported:
 
1563
          </p>
 
1564
        <taglist>
 
1565
          <tag><c>write</c></tag>
 
1566
          <item>
 
1567
            <p>Write locks are exclusive, which means that if one
 
1568
              transaction manages to acquire a write lock on an item,
 
1569
              no other transaction may acquire any kind of lock on the
 
1570
              same item. 
 
1571
              </p>
 
1572
          </item>
 
1573
          <tag><c>read</c></tag>
 
1574
          <item>
 
1575
            <p>Read locks may be shared, which means that if one
 
1576
              transaction manages to acquire a read lock on an item,
 
1577
              other transactions may also acquire a read lock on the
 
1578
              same item. However, if someone has a read lock no one can
 
1579
              acquire a write lock at the same item. If some one has a
 
1580
              write lock no one can acquire  a read lock nor
 
1581
              a write lock at the same item.</p>
 
1582
          </item>
 
1583
        </taglist>
 
1584
        <p>Conflicting lock requests are automatically queued if there
 
1585
          is no risk of a deadlock. Otherwise the transaction must be
 
1586
          aborted and executed again. Mnesia does this automatically
 
1587
          as long as the upper limit of maximum <c>retries</c> is not
 
1588
          reached. See <c>mnesia:transaction/3</c> for the details.
 
1589
          </p>
 
1590
        <p>For the sake of completeness sticky write locks will also 
 
1591
          be described here even if a sticky write lock is not
 
1592
          supported by this particular function:
 
1593
          </p>
 
1594
        <taglist>
 
1595
          <tag><c>sticky_write</c></tag>
 
1596
          <item>
 
1597
            <p>Sticky write locks are a mechanism which can be used
 
1598
              to optimize write lock acquisition. If your application
 
1599
              uses replicated tables mainly for fault tolerance (as
 
1600
              opposed to read access optimization purpose), sticky
 
1601
              locks may be the best option available. 
 
1602
              </p>
 
1603
            <p>When a sticky write lock is acquired, all nodes will be
 
1604
              informed which node is locked. Subsequently,
 
1605
              sticky lock requests from the same node will be
 
1606
              performed as  a local operation without any
 
1607
              communication with other nodes. The sticky lock
 
1608
              lingers on the node even after the transaction has
 
1609
              ended. See the Mnesia User's Guide for more information.</p>
 
1610
          </item>
 
1611
        </taglist>
 
1612
        <p>Currently, two kinds of <c>LockItem</c>'s are supported by
 
1613
          this function:
 
1614
          </p>
 
1615
        <taglist>
 
1616
          <tag><c>{table, Tab}</c></tag>
 
1617
          <item>
 
1618
            <p>This acquires a lock of type <c>LockKind</c> on the
 
1619
              entire table <c>Tab</c>.
 
1620
              </p>
 
1621
          </item>
 
1622
          <tag><c>{global, GlobalKey, Nodes}</c></tag>
 
1623
          <item>
 
1624
            <p>This acquires a lock of type <c>LockKind</c> on the
 
1625
              global resource <c>GlobalKey</c>. The lock is acquired
 
1626
              on all active nodes in the <c>Nodes</c> list. </p>
 
1627
          </item>
 
1628
        </taglist>
 
1629
        <p>Locks are released when the outermost transaction ends.
 
1630
          </p>
 
1631
        <p>The semantics of this function is context sensitive. See
 
1632
          <c>mnesia:activity/4</c> for more information. In transaction
 
1633
          context it acquires locks otherwise it just ignores the
 
1634
          request.</p>
 
1635
      </desc>
 
1636
    </func>
 
1637
    <func>
 
1638
      <name>match_object(Pattern) ->transaction abort | RecList </name>
 
1639
      <fsummary>Match <c>Pattern</c>for records.   </fsummary>
 
1640
      <desc>
 
1641
        <p>Invokes <c>mnesia:match_object(Tab, Pattern, read)</c> where
 
1642
          <c>Tab</c> is <c>element(1, Pattern)</c>.</p>
 
1643
      </desc>
 
1644
    </func>
 
1645
    <func>
 
1646
      <name>match_object(Tab, Pattern, LockKind) ->transaction abort | RecList </name>
 
1647
      <fsummary>Match <c>Pattern</c>for records. </fsummary>
 
1648
      <desc>
 
1649
        <p>This function takes a pattern with 'don't care' variables
 
1650
          denoted as a '_' parameter.  This function returns a list of
 
1651
          records which matched the pattern.  Since the second element
 
1652
          of a record in a table is considered to be the key for the
 
1653
          record, the performance of this function depends on whether
 
1654
          this key is bound or not. 
 
1655
          </p>
 
1656
        <p>For example, the call <c>mnesia:match_object(person, {person, '_', 36, '_', '_'}, read)</c> returns a list of all person records with an 
 
1657
          age field of thirty-six (36).
 
1658
          </p>
 
1659
        <p>The function <c>mnesia:match_object/3</c>
 
1660
          automatically uses indices if these exist. However, no
 
1661
          heuristics are performed in order to select the best
 
1662
          index.
 
1663
          </p>
 
1664
        <p>The semantics of this function is context sensitive. See
 
1665
          <c>mnesia:activity/4</c> for more information. In transaction
 
1666
          context it acquires a lock of type <c>LockKind</c> on the
 
1667
          entire table or a single record. Currently, the lock type
 
1668
          <c>read</c> is supported.</p>
 
1669
      </desc>
 
1670
    </func>
 
1671
    <func>
 
1672
      <name>move_table_copy(Tab, From, To) -> {aborted, Reason} | {atomic, ok}</name>
 
1673
      <fsummary>Move the copy of table <c>Tab</c>from node<c>From</c>to node <c>To</c>.</fsummary>
 
1674
      <desc>
 
1675
        <p>Moves the copy of table <c>Tab</c> from node
 
1676
          <c>From</c> to node <c>To</c>.
 
1677
          </p>
 
1678
        <p>The storage type is preserved. For example, a RAM table
 
1679
          moved from one node remains a RAM on the new node.  It is
 
1680
          still possible for other transactions to read and write in
 
1681
          the table while it is being moved.
 
1682
          </p>
 
1683
        <p>This function cannot be used on <c>local_content</c> tables.</p>
 
1684
      </desc>
 
1685
    </func>
 
1686
    <func>
 
1687
      <name>next(Tab, Key) -> Key | transaction abort </name>
 
1688
      <fsummary>Return the next key in a table. </fsummary>
 
1689
      <desc>
 
1690
        <p>This function makes it possible to traverse a table
 
1691
          and perform operations on all records in the table. When
 
1692
          the end of the table is reached, the special key
 
1693
          <c>'$end_of_table'</c> is returned. Otherwise, the function
 
1694
          returns a key which can be used to read the actual record.</p>
 
1695
      </desc>
 
1696
    </func>
 
1697
    <func>
 
1698
      <name>prev(Tab, Key) -> Key | transaction abort </name>
 
1699
      <fsummary>Return the previous key in a table. </fsummary>
 
1700
      <desc>
 
1701
        <p>This function works exactly 
 
1702
          <c>mnesia:next/2</c> but returns the previous object in
 
1703
          Erlang term  order for the ordered_set table type. For
 
1704
          all other table types, <c>mnesia:next/2</c> and 
 
1705
          <c>mnesia:prev/2</c> are synonyms.\011  </p>
 
1706
      </desc>
 
1707
    </func>
 
1708
    <func>
 
1709
      <name>read({Tab, Key}) -> transaction abort | RecordList </name>
 
1710
      <fsummary>Read records(s) with a given key. </fsummary>
 
1711
      <desc>
 
1712
        <p>Invokes <c>mnesia:read(Tab, Key, read)</c>.</p>
 
1713
      </desc>
 
1714
    </func>
 
1715
    <func>
 
1716
      <name>read(Tab, Key) -> transaction abort | RecordList </name>
 
1717
      <fsummary>Read records(s) with a given key. </fsummary>
 
1718
      <desc>
 
1719
        <p>Invokes <c>mnesia:read(Tab, Key, read)</c>.</p>
 
1720
      </desc>
 
1721
    </func>
 
1722
    <func>
 
1723
      <name>read(Tab, Key, LockKind) -> transaction abort | RecordList </name>
 
1724
      <fsummary>Read records(s) with a given key. </fsummary>
 
1725
      <desc>
 
1726
        <p>This function reads all records from table <c>Tab</c> with
 
1727
          key <c>Key</c>. This function has the same semantics
 
1728
          regardless of the location of <c>Tab</c>. If the table is
 
1729
          of type <c>bag</c>, the <c>mnesia:read(Tab, Key)</c> can
 
1730
          return an arbitrarily long list. If the table is of type
 
1731
          <c>set</c>, the list is either of length 1, or <c>[]</c>.
 
1732
          </p>
 
1733
        <p>The semantics of this function is context sensitive. See
 
1734
          <c>mnesia:activity/4</c> for more information. In transaction
 
1735
          context it acquires a lock of type
 
1736
          <c>LockKind</c>. Currently, the lock types <c>read</c>,
 
1737
          <c>write</c> and <c>sticky_write</c> are supported.
 
1738
          </p>
 
1739
        <p>If the user wants to update the record it is more efficient to 
 
1740
          use  <c>write/sticky_write</c> as the LockKind.
 
1741
          </p>
 
1742
      </desc>
 
1743
    </func>
 
1744
    <func>
 
1745
      <name>read_lock_table(Tab) -> ok | transaction abort</name>
 
1746
      <fsummary>Set a read lock on an entire table.</fsummary>
 
1747
      <desc>
 
1748
        <p>Invokes <c>mnesia:lock({table, Tab}, read)</c>.</p>
 
1749
      </desc>
 
1750
    </func>
 
1751
    <func>
 
1752
      <name>report_event(Event) -> ok</name>
 
1753
      <fsummary>Report a user event to Mnesia's event handler.</fsummary>
 
1754
      <desc>
 
1755
        <p>When tracing a system of Mnesia applications it is useful
 
1756
          to be able to interleave Mnesia's own events with
 
1757
          application related events that give information about the
 
1758
          application context. 
 
1759
          </p>
 
1760
        <p>Whenever the application begins a
 
1761
          new and demanding Mnesia task, or if it is entering a new
 
1762
          interesting phase in its execution, it may be a good idea to
 
1763
          use <c>mnesia:report_event/1</c>. The <c>Event</c> may be
 
1764
          any term and generates a <c>{mnesia_user, Event}</c> event
 
1765
          for any processes that  subscribe to Mnesia system
 
1766
          events.</p>
 
1767
      </desc>
 
1768
    </func>
 
1769
    <func>
 
1770
      <name>restore(Opaque, Args) -> {atomic, RestoredTabs} |{aborted, Reason}</name>
 
1771
      <fsummary>Online restore of backup.</fsummary>
 
1772
      <desc>
 
1773
        <p>With this function, tables may be restored online from a
 
1774
          backup without restarting Mnesia.  <c>Opaque</c> is forwarded
 
1775
          to the backup module.  <c>Args</c> is a list of the following
 
1776
          tuples:
 
1777
          </p>
 
1778
        <list type="bulleted">
 
1779
          <item>
 
1780
            <p><c>{module,BackupMod}</c> The backup module
 
1781
              <c>BackupMod</c> will be used to access the backup
 
1782
              media. If omitted, the default backup module will be
 
1783
              used. 
 
1784
              </p>
 
1785
          </item>
 
1786
          <item><c>{skip_tables, TabList}</c> Where <c>TabList</c>
 
1787
           is a list of tables which should not be read from the
 
1788
           backup.
 
1789
          </item>
 
1790
          <item><c>{clear_tables, TabList}</c> Where
 
1791
          <c>TabList</c> is a list of tables which should be
 
1792
           cleared, before the records from the backup are inserted,
 
1793
           ie. all records in the tables are deleted before the
 
1794
           tables are restored.  Schema information about the tables
 
1795
           is not cleared or read from backup.
 
1796
          </item>
 
1797
          <item><c>{keep_tables, TabList}</c> Where <c>TabList</c>
 
1798
           is a list of tables which should be not be cleared, before
 
1799
           the records from the backup are inserted, i.e. the records
 
1800
           in the backup will be added to the records in the table.
 
1801
           Schema information about the tables is not cleared or read
 
1802
           from backup.
 
1803
          </item>
 
1804
          <item><c>{recreate_tables, TabList}</c> Where
 
1805
          <c>TabList</c> is a list of tables which should be
 
1806
           re-created, before the records from the backup are
 
1807
           inserted. The tables are first deleted and then created with
 
1808
           the schema information from the backup. All the nodes in the
 
1809
           backup needs to be up and running.
 
1810
          </item>
 
1811
          <item><c>{default_op, Operation}</c> Where <c>Operation</c> is
 
1812
           one of the following operations <c>skip_tables</c>,
 
1813
          <c>clear_tables</c>, <c>keep_tables</c> or
 
1814
          <c>recreate_tables</c>. The default operation specifies
 
1815
           which operation should be used on tables from the backup
 
1816
           which are not specified in any of the lists above.  If
 
1817
           omitted, the operation <c>clear_tables</c> will be used.
 
1818
          </item>
 
1819
        </list>
 
1820
        <p>The affected tables are write locked during the
 
1821
          restoration, but regardless of the lock conflicts caused by
 
1822
          this, the applications can continue to do their work while
 
1823
          the restoration is being performed. The restoration is
 
1824
          performed as one single transaction. 
 
1825
          </p>
 
1826
        <p>If the database is
 
1827
          huge, it may not be possible to restore it online. In such 
 
1828
          cases, the old database must be restored by installing a
 
1829
          fallback and then restart.</p>
 
1830
      </desc>
 
1831
    </func>
 
1832
    <func>
 
1833
      <name>s_delete({Tab, Key}) -> ok | transaction abort </name>
 
1834
      <fsummary>Set sticky lock and delete records.</fsummary>
 
1835
      <desc>
 
1836
        <p>Invokes <c>mnesia:delete(Tab, Key, sticky_write)</c></p>
 
1837
      </desc>
 
1838
    </func>
 
1839
    <func>
 
1840
      <name>s_delete_object(Record) -> ok | transaction abort </name>
 
1841
      <fsummary>Set sticky lock and delete record.</fsummary>
 
1842
      <desc>
 
1843
        <p>Invokes <c>mnesia:delete_object(Tab, Record, sticky_write)</c> where <c>Tab</c> is <c>element(1, Record)</c>.</p>
 
1844
      </desc>
 
1845
    </func>
 
1846
    <func>
 
1847
      <name>s_write(Record) -> ok | transaction abort </name>
 
1848
      <fsummary>Write <c>Record</c>and sets stick lock.</fsummary>
 
1849
      <desc>
 
1850
        <p>Invokes <c>mnesia:write(Tab, Record, sticky_write)</c>
 
1851
          where <c>Tab</c> is <c>element(1, Record)</c>.</p>
 
1852
      </desc>
 
1853
    </func>
 
1854
    <func>
 
1855
      <name>schema() -> ok </name>
 
1856
      <fsummary>Print information about all table definitions on the tty. </fsummary>
 
1857
      <desc>
 
1858
        <p>Prints information about all table definitions on the tty.</p>
 
1859
      </desc>
 
1860
    </func>
 
1861
    <func>
 
1862
      <name>schema(Tab) -> ok </name>
 
1863
      <fsummary>Print information about one table definition on the tty.</fsummary>
 
1864
      <desc>
 
1865
        <p>Prints information about one table definition on the tty.</p>
 
1866
      </desc>
 
1867
    </func>
 
1868
    <func>
 
1869
      <name>select(Tab, MatchSpec [, Lock]) ->  transaction abort | [Object] </name>
 
1870
      <fsummary>Match the objects in <c>Tab</c>against <c>MatchSpec</c>.</fsummary>
 
1871
      <desc>
 
1872
        <p>Matches the objects in the table <c>Tab</c> using a
 
1873
          match_spec as described in the ERTS Users Guide. Optionally a lock
 
1874
          <c>read</c> or <c>write</c> can be given as the third
 
1875
          argument, default is <c>read</c>.  The return value depends
 
1876
          on the <c>MatchSpec</c>.</p>
 
1877
        <p><em>Note:</em> for best performance <c>select</c> should
 
1878
          be used before any modifying operations are done on that table
 
1879
          in the same transaction, i.e. don't use <c>write</c> or <c>delete</c>
 
1880
          before a <c>select</c>.</p>
 
1881
        <p>In its simplest forms the match_spec's look like this:</p>
 
1882
        <list type="bulleted">
 
1883
          <item>MatchSpec = [MatchFunction]</item>
 
1884
          <item>MatchFunction = {MatchHead, [Guard], [Result]}</item>
 
1885
          <item>MatchHead = tuple() | record()</item>
 
1886
          <item>Guard =  {"Guardtest name", ...}</item>
 
1887
          <item>Result = "Term construct"</item>
 
1888
        </list>
 
1889
        <p>See the ERTS Users Guide and <c>ets</c> documentation for a
 
1890
          complete description of the select.</p>
 
1891
        <p>For example to find the names of all male persons with an age over 30 in table
 
1892
          Tab do:</p>
 
1893
        <code type="none">
 
1894
\011  MatchHead = #person{name='$1', sex=male, age='$2', _='_'},
 
1895
\011  Guard = {'>', '$2', 30},
 
1896
\011  Result = '$1',
 
1897
\011  mnesia:select(Tab,[{MatchHead, [Guard], [Result]}]),
 
1898
        </code>
 
1899
      </desc>
 
1900
    </func>
 
1901
    <func>
 
1902
      <name>select(Tab, MatchSpec, NObjects, Lock) ->  transaction abort | {[Object],Cont} | '$end_of_table'</name>
 
1903
      <fsummary>Match the objects in <c>Tab</c>against <c>MatchSpec</c>.</fsummary>
 
1904
      <desc>
 
1905
        <p>Matches the objects in the table <c>Tab</c> using a
 
1906
          match_spec as described in ERTS users guide, and returns
 
1907
          a chunk of terms and a continuation, the wanted number 
 
1908
          of returned terms is specified by the <c>NObjects</c> argument.
 
1909
          The lock argument can be <c>read</c> or <c>write</c>.
 
1910
          The continuation should be used as argument to <c>mnesia:select/1</c>,
 
1911
          if more or all answers are needed.</p>
 
1912
        <p><em>Note:</em> for best performance <c>select</c> should
 
1913
          be used before any modifying operations are done on that
 
1914
          table in the same transaction, i.e. don't use
 
1915
          <c>mnesia:write</c> or <c>mnesia:delete</c> before a
 
1916
          <c>mnesia:select</c>. For efficiency the <c>NObjects</c> is
 
1917
          a recommendation only and the result may contain anything
 
1918
          from an empty list to all available results.  </p>
 
1919
      </desc>
 
1920
    </func>
 
1921
    <func>
 
1922
      <name>select(Cont) ->  transaction abort | {[Object],Cont} | '$end_of_table'</name>
 
1923
      <fsummary>Continues selecting objects.   </fsummary>
 
1924
      <desc>
 
1925
        <p>Selects more objects with the match specification initiated
 
1926
          by <c>mnesia:select/4</c>.
 
1927
          </p>
 
1928
        <p><em>Note:</em> Any modifying operations, i.e. <c>mnesia:write</c>
 
1929
          or <c>mnesia:delete</c>, that are done between the <c>mnesia:select/4</c>
 
1930
          and <c>mnesia:select/1</c> calls will not be visible in the result.</p>
 
1931
      </desc>
 
1932
    </func>
 
1933
    <func>
 
1934
      <name>set_debug_level(Level) -> OldLevel</name>
 
1935
      <fsummary>Change the internal debug level of Mnesia</fsummary>
 
1936
      <desc>
 
1937
        <p>Changes the internal debug level of Mnesia. See the
 
1938
          chapter about configuration parameters for details.</p>
 
1939
      </desc>
 
1940
    </func>
 
1941
    <func>
 
1942
      <name>set_master_nodes(MasterNodes) -> ok | {error, Reason} </name>
 
1943
      <fsummary>Set the master nodes for all tables</fsummary>
 
1944
      <desc>
 
1945
        <p>For each table Mnesia will determine its replica nodes
 
1946
          (<c>TabNodes</c>) and invoke <c>mnesia:set_master_nodes(Tab, TabMasterNodes)</c> where <c>TabMasterNodes</c> is the
 
1947
          intersection of <c>MasterNodes</c> and <c>TabNodes</c>. See
 
1948
          <c>mnesia:set_master_nodes/2</c> about the semantics.</p>
 
1949
      </desc>
 
1950
    </func>
 
1951
    <func>
 
1952
      <name>set_master_nodes(Tab, MasterNodes) -> ok | {error, Reason} </name>
 
1953
      <fsummary>Set the master nodes for a table</fsummary>
 
1954
      <desc>
 
1955
        <p>If the application detects that there has been a
 
1956
          communication failure (in a potentially partitioned network) which
 
1957
          may have caused an inconsistent database, it may use the
 
1958
          function <c>mnesia:set_master_nodes(Tab, MasterNodes)</c> to
 
1959
          define from which nodes  each table will be loaded.
 
1960
          At startup Mnesia's normal table load algorithm will be
 
1961
          bypassed and the table will be loaded from one of the master
 
1962
          nodes defined for the table, regardless of when and if Mnesia
 
1963
          was terminated on other nodes. The <c>MasterNodes</c> may only
 
1964
          contain nodes where the table has a replica and if the
 
1965
          <c>MasterNodes</c> list is empty, the master node recovery
 
1966
          mechanism for the particular table will be reset and the
 
1967
          normal load mechanism will be used at next restart.
 
1968
          </p>
 
1969
        <p>The master node setting is always local and it may be
 
1970
          changed regardless of whether Mnesia is started or not.
 
1971
          </p>
 
1972
        <p>The database may also become inconsistent if the
 
1973
          <c>max_wait_for_decision</c> configuration parameter is used
 
1974
          or if <c>mnesia:force_load_table/1</c> is used.</p>
 
1975
      </desc>
 
1976
    </func>
 
1977
    <func>
 
1978
      <name>snmp_close_table(Tab) -> {aborted, R} | {atomic, ok}</name>
 
1979
      <fsummary>Remove the possibility for SNMP to manipulate the table.</fsummary>
 
1980
      <desc>
 
1981
        <p>Removes the possibility for SNMP to manipulate the
 
1982
          table.</p>
 
1983
      </desc>
 
1984
    </func>
 
1985
    <func>
 
1986
      <name>snmp_get_mnesia_key(Tab, RowIndex) -> {ok, Key} | undefined</name>
 
1987
      <fsummary>Get the corresponding Mnesia key from an SNMP index.</fsummary>
 
1988
      <type>
 
1989
        <v>Tab ::= atom()</v>
 
1990
        <v>RowIndex ::= [integer()]</v>
 
1991
        <v>Key ::= key() | {key(), key(), ...}</v>
 
1992
        <v>key() ::= integer() | string() | [integer()]</v>
 
1993
      </type>
 
1994
      <desc>
 
1995
        <p>Transforms an SNMP index to the corresponding Mnesia key.
 
1996
          If the SNMP table has multiple keys, the key is a tuple of
 
1997
          the key columns.</p>
 
1998
      </desc>
 
1999
    </func>
 
2000
    <func>
 
2001
      <name>snmp_get_next_index(Tab, RowIndex) -> {ok, NextIndex} | endOfTable</name>
 
2002
      <fsummary>Get the index of the next lexicographical row.</fsummary>
 
2003
      <type>
 
2004
        <v>Tab ::= atom()</v>
 
2005
        <v>RowIndex ::= [integer()]</v>
 
2006
        <v>NextIndex ::= [integer()]</v>
 
2007
      </type>
 
2008
      <desc>
 
2009
        <p>The <c>RowIndex</c> may specify a non-existing row.
 
2010
          Specifically, it might be the empty list. Returns the index
 
2011
          of the next lexicographical row. If <c>RowIndex</c> is the
 
2012
          empty list, this function will return the index of the first row
 
2013
          in the table.</p>
 
2014
      </desc>
 
2015
    </func>
 
2016
    <func>
 
2017
      <name>snmp_get_row(Tab, RowIndex) -> {ok, Row} | undefined</name>
 
2018
      <fsummary>Retrieve a row indexed by an SNMP index.</fsummary>
 
2019
      <type>
 
2020
        <v>Tab ::= atom()</v>
 
2021
        <v>RowIndex ::= [integer()]</v>
 
2022
        <v>Row ::= record(Tab)</v>
 
2023
      </type>
 
2024
      <desc>
 
2025
        <p>Makes it possible to read a row by its SNMP index. This
 
2026
          index is specified as an SNMP OBJECT IDENTIFIER, a list of
 
2027
          integers.</p>
 
2028
      </desc>
 
2029
    </func>
 
2030
    <func>
 
2031
      <name>snmp_open_table(Tab, SnmpStruct) -> {aborted, R} | {atomic, ok}</name>
 
2032
      <fsummary>Organize a Mnesia table  as an SNMP table.</fsummary>
 
2033
      <type>
 
2034
        <v>Tab ::= atom()</v>
 
2035
        <v>SnmpStruct ::= [{key, type()}]</v>
 
2036
        <v>type() ::= type_spec() | {type_spec(), type_spec(), ...}</v>
 
2037
        <v>type_spec() ::= fix_string | string | integer</v>
 
2038
      </type>
 
2039
      <desc>
 
2040
        <p>It is possible to establish a direct one to one mapping
 
2041
          between Mnesia tables and SNMP tables. Many
 
2042
          telecommunication applications are controlled and monitored
 
2043
          by the SNMP protocol. This connection between Mnesia and
 
2044
          SNMP makes it simple and convenient to achieve this.
 
2045
          </p>
 
2046
        <p>The <c>SnmpStruct</c> argument is a list of SNMP
 
2047
          information. Currently, the only information needed is
 
2048
          information about the key types in the table.  It is not
 
2049
          possible to handle multiple keys in Mnesia, but many SNMP
 
2050
          tables have multiple keys. Therefore, the following
 
2051
          convention is used: if a table has multiple keys, these must
 
2052
          always be stored as a tuple of the keys.  Information about
 
2053
          the key types is specified as a tuple of atoms describing
 
2054
          the types. The only significant type is
 
2055
          <c>fix_string</c>. This means that a string has fixed
 
2056
          size. For example:
 
2057
          </p>
 
2058
        <code type="none">
 
2059
mnesia:snmp_open_table(person, [{key, string}])
 
2060
        </code>
 
2061
        <p>causes the <c>person</c> table to be ordered as an SNMP
 
2062
          table.
 
2063
          </p>
 
2064
        <p>Consider the following schema for a table of company
 
2065
          employees. Each employee is identified by department number
 
2066
          and name. The other table column stores the telephone number:
 
2067
          </p>
 
2068
        <code type="none">
 
2069
mnesia:create_table(employee,
 
2070
    [{snmp, [{key, {integer, string}}]},
 
2071
     {attributes, record_info(fields, employees)}]),
 
2072
        </code>
 
2073
        <p>The corresponding SNMP table would have three columns;
 
2074
          <c>department</c>, <c>name</c> and <c>telno</c>.
 
2075
          </p>
 
2076
        <p>It is possible to have table columns that are not visible
 
2077
          through the SNMP protocol. These columns must be the last
 
2078
          columns of the table. In the previous example, the SNMP
 
2079
          table could have columns <c>department</c> and <c>name</c>
 
2080
          only. The application could then use the <c>telno</c> column
 
2081
          internally, but it would not be visible to the SNMP
 
2082
          managers.
 
2083
          </p>
 
2084
        <p>In a table monitored by SNMP, all elements must be
 
2085
          integers, strings, or lists of integers.
 
2086
          </p>
 
2087
        <p>When a table is SNMP ordered, modifications are more
 
2088
          expensive than usual, O(logN).  And more memory is used.
 
2089
          </p>
 
2090
        <p><em>Note:</em>Only the lexicographical SNMP ordering is
 
2091
          implemented in Mnesia, not the actual SNMP monitoring.</p>
 
2092
      </desc>
 
2093
    </func>
 
2094
    <func>
 
2095
      <name>start() -> ok | {error, Reason} </name>
 
2096
      <fsummary>Start a local Mnesia system.</fsummary>
 
2097
      <desc>
 
2098
        <p>The start-up procedure for a set of Mnesia nodes is a
 
2099
          fairly complicated operation. A Mnesia system consists of a set
 
2100
          of nodes, with Mnesia  started locally on all
 
2101
          participating nodes. Normally, each node has a directory where
 
2102
          all the Mnesia files are written. This directory will be
 
2103
          referred to as the Mnesia directory. Mnesia may also be
 
2104
          started on disc-less nodes. See <c>mnesia:create_schema/1</c>
 
2105
          and the Mnesia User's Guide for more information about disc-less
 
2106
          nodes.
 
2107
          </p>
 
2108
        <p>The set of nodes which makes up a Mnesia system is kept in
 
2109
          a schema and it is possible to add and remove Mnesia nodes
 
2110
          from the schema. The initial schema is normally created on
 
2111
          disc with the function <c>mnesia:create_schema/1</c>. On
 
2112
          disc-less nodes, a tiny default schema is generated each time
 
2113
          Mnesia is started. During the start-up procedure, Mnesia
 
2114
          will exchange schema information between the nodes in order
 
2115
          to verify that the table definitions are compatible.
 
2116
          </p>
 
2117
        <p>Each schema has a unique cookie which may be regarded as a
 
2118
          unique schema identifier. The cookie must be the same on all
 
2119
          nodes where Mnesia is supposed to run. See the Mnesia
 
2120
          User's Guide for more information about these details.
 
2121
          </p>
 
2122
        <p>The schema file, as well as all other files which Mnesia
 
2123
          needs, are kept in the Mnesia directory. The command line
 
2124
          option <c>-mnesia dir Dir</c> can be used to specify the
 
2125
          location of this directory to the Mnesia system. If no such
 
2126
          command line option is found, the name of the directory
 
2127
          defaults to <c>Mnesia.Node</c>.
 
2128
          </p>
 
2129
        <p><c>application:start(mnesia)</c> may also be used.</p>
 
2130
      </desc>
 
2131
    </func>
 
2132
    <func>
 
2133
      <name>stop() -> stopped </name>
 
2134
      <fsummary>Stop Mnesia locally.</fsummary>
 
2135
      <desc>
 
2136
        <p>Stops Mnesia locally on the current node.
 
2137
          </p>
 
2138
        <p><c>application:stop(mnesia)</c> may also be used.</p>
 
2139
      </desc>
 
2140
    </func>
 
2141
    <func>
 
2142
      <name>subscribe(EventCategory)</name>
 
2143
      <fsummary>Subscribe to events of type <c>EventCategory</c>.</fsummary>
 
2144
      <desc>
 
2145
        <p>Ensures that a copy of all events of type
 
2146
          <c>EventCategory</c> are sent to the caller.  The event
 
2147
          types available are described in the Mnesia User's Guide.</p>
 
2148
      </desc>
 
2149
    </func>
 
2150
    <func>
 
2151
      <name>sync_dirty(Fun, [, Args]) -> ResultOfFun | exit(Reason) </name>
 
2152
      <fsummary>Call the Fun in a context which is not protected by a transaction.</fsummary>
 
2153
      <desc>
 
2154
        <p>Call the <c>Fun</c> in a context which is not protected
 
2155
          by a transaction. The Mnesia function calls performed in the
 
2156
          <c>Fun</c> are mapped to the corresponding dirty functions.
 
2157
          It is performed in almost the same context as
 
2158
          <c>mnesia:async_dirty/1,2</c>. The difference is that the
 
2159
          operations are performed synchronously. The caller waits for
 
2160
          the updates to be performed on all active replicas before
 
2161
          the <c>Fun</c> returns. See <c>mnesia:activity/4</c> and the
 
2162
          Mnesia User's Guide for more details.</p>
 
2163
      </desc>
 
2164
    </func>
 
2165
    <func>
 
2166
      <name>sync_transaction(Fun, [[, Args], Retries]) -> {aborted, Reason} | {atomic, ResultOfFun} </name>
 
2167
      <fsummary>Synchronously execute a transaction.</fsummary>
 
2168
      <desc>
 
2169
        <p>This function waits until data have been committed and
 
2170
          logged to disk (if disk is used) on every involved node before
 
2171
          it returns, otherwise it behaves as 
 
2172
          <c>mnesia:transaction/[1,2,3]</c>.</p>
 
2173
        <p>This functionality can be used to avoid that one process may overload 
 
2174
          a database on another node.</p>
 
2175
      </desc>
 
2176
    </func>
 
2177
    <func>
 
2178
      <name>system_info(InfoKey) -> Info | exit({aborted, Reason})</name>
 
2179
      <fsummary>Return information about the Mnesia system</fsummary>
 
2180
      <desc>
 
2181
        <p>Returns information about the Mnesia system, such as
 
2182
          transaction statistics, db_nodes, and configuration parameters.
 
2183
          Valid keys are:</p>
 
2184
        <list type="bulleted">
 
2185
          <item>
 
2186
            <p><c>all</c>. This argument returns a list of all
 
2187
              local system information. Each element is a
 
2188
              <c>{InfoKey, InfoVal}</c> tuples.<em>Note:</em> New <c>InfoKey</c>'s may
 
2189
              be added and old undocumented <c>InfoKey</c>'s may be removed without 
 
2190
              notice.</p>
 
2191
          </item>
 
2192
          <item>
 
2193
            <p><c>access_module</c>. This argument returns the name of 
 
2194
              the module which is configured to be the activity access
 
2195
              callback module.
 
2196
              </p>
 
2197
          </item>
 
2198
          <item>
 
2199
            <p><c>auto_repair</c>. This argument returns
 
2200
              <c>true</c> or <c>false</c> to indicate if Mnesia is
 
2201
              configured to invoke the auto repair facility on corrupted
 
2202
              disc files. 
 
2203
              </p>
 
2204
          </item>
 
2205
          <item>
 
2206
            <p><c>backup_module</c>. This argument returns the name of 
 
2207
              the module which is configured to be the backup
 
2208
              callback module.
 
2209
              </p>
 
2210
          </item>
 
2211
          <item>
 
2212
            <p><c>checkpoints</c>. This argument
 
2213
              returns a list of the names of the
 
2214
              checkpoints currently active on this node.
 
2215
              </p>
 
2216
          </item>
 
2217
          <item>
 
2218
            <p><c>event_module</c>. This argument returns the name of 
 
2219
              the module which is the event handler callback module.
 
2220
              </p>
 
2221
          </item>
 
2222
          <item>
 
2223
            <p><c>db_nodes</c>. This argument returns
 
2224
              the nodes which make up the persistent database. Disc
 
2225
              less nodes will only be included in the list of nodes if
 
2226
              they explicitly has been added to the schema, e.g. with
 
2227
              <c>mnesia:add_table_copy/3</c>. The function can be
 
2228
              invoked even if Mnesia is not yet running. 
 
2229
              </p>
 
2230
          </item>
 
2231
          <item>
 
2232
            <p><c>debug</c>. This argument returns the current
 
2233
              debug level of Mnesia.  
 
2234
              </p>
 
2235
          </item>
 
2236
          <item>
 
2237
            <p><c>directory</c>. This argument returns the name of
 
2238
              the Mnesia directory. It can be invoked even if Mnesia is
 
2239
              not yet running.
 
2240
              </p>
 
2241
          </item>
 
2242
          <item>
 
2243
            <p><c>dump_log_load_regulation</c>. This argument
 
2244
              returns a boolean which tells whether Mnesia is
 
2245
              configured to load regulate the dumper process or not.
 
2246
              This feature is temporary and will disappear in future
 
2247
              releases.
 
2248
              </p>
 
2249
          </item>
 
2250
          <item>
 
2251
            <p><c>dump_log_time_threshold</c>. This argument
 
2252
              returns the time threshold for transaction log dumps in
 
2253
              milliseconds. 
 
2254
              </p>
 
2255
          </item>
 
2256
          <item>
 
2257
            <p><c>dump_log_update_in_place</c>. This argument
 
2258
              returns a boolean which tells whether Mnesia is
 
2259
              configured to perform the updates in the dets files
 
2260
              directly or if the updates should be performed in a copy
 
2261
              of the dets files.
 
2262
              </p>
 
2263
          </item>
 
2264
          <item>
 
2265
            <p><c>dump_log_write_threshold</c>. This argument
 
2266
              returns the write threshold for transaction log dumps as
 
2267
              the  number of writes to the transaction log.
 
2268
              </p>
 
2269
          </item>
 
2270
          <item>
 
2271
            <p><c>extra_db_nodes</c>. This argument returns a list
 
2272
              of extra db_nodes to be contacted at start-up.
 
2273
              </p>
 
2274
          </item>
 
2275
          <item>
 
2276
            <p><c>fallback_activated</c>. This argument returns
 
2277
              true if a fallback is activated, otherwise false. 
 
2278
              </p>
 
2279
          </item>
 
2280
          <item>
 
2281
            <p><c>held_locks</c>. This argument returns a list of
 
2282
              all locks held by the local Mnesia lock manager.
 
2283
              </p>
 
2284
          </item>
 
2285
          <item>
 
2286
            <p><c>is_running</c>. This argument returns <c>yes</c>
 
2287
              or <c>no</c> to indicate if Mnesia is running. It may
 
2288
              also return <c>starting</c> or <c>stopping</c>.  Can be
 
2289
              invoked even if Mnesia is not yet running.
 
2290
              </p>
 
2291
          </item>
 
2292
          <item>
 
2293
            <p><c>local_tables</c>. This argument returns a list
 
2294
              of all tables which are configured to reside locally.
 
2295
              </p>
 
2296
          </item>
 
2297
          <item>
 
2298
            <p><c>lock_queue</c>. This argument returns a list of
 
2299
              all transactions that are queued for execution by the
 
2300
              local lock manager.
 
2301
              </p>
 
2302
          </item>
 
2303
          <item>
 
2304
            <p><c>log_version</c>. This argument returns the
 
2305
              version number of the Mnesia transaction log format.
 
2306
              </p>
 
2307
          </item>
 
2308
          <item>
 
2309
            <p><c>master_node_tables</c>. This argument returns a
 
2310
              list of all tables with at least one master node.
 
2311
              </p>
 
2312
          </item>
 
2313
          <item>
 
2314
            <p><c>protocol_version</c>. This argument
 
2315
              returns the version number
 
2316
              of the Mnesia inter-process communication protocol.
 
2317
              </p>
 
2318
          </item>
 
2319
          <item>
 
2320
            <p><c>running_db_nodes</c>. This argument returns a
 
2321
              list of nodes where Mnesia currently is running. This
 
2322
              function can be invoked even if Mnesia is not yet
 
2323
              running, but it will then have slightly different
 
2324
              semantics. If Mnesia is down on the local node, the
 
2325
              function will return those other <c>db_nodes</c> and
 
2326
              <c>extra_db_nodes</c> that for the moment are up and
 
2327
              running. If Mnesia is started, the function will return
 
2328
              those nodes that Mnesia on the local node is fully
 
2329
              connected to. Only those nodes that Mnesia has exchanged
 
2330
              schema information with are included as
 
2331
              <c>running_db_nodes</c>. After the merge of schemas, the
 
2332
              local Mnesia system is fully operable and applications
 
2333
              may perform access of remote replicas. Before the schema
 
2334
              merge Mnesia will only operate locally. Sometimes there
 
2335
              may be more nodes included in the
 
2336
              <c>running_db_nodes</c> list than all <c>db_nodes</c>
 
2337
              and <c>extra_db_nodes</c> together.
 
2338
              </p>
 
2339
          </item>
 
2340
          <item>
 
2341
            <p><c>schema_location</c>. This argument returns the
 
2342
              initial schema location.
 
2343
              </p>
 
2344
          </item>
 
2345
          <item>
 
2346
            <p><c>subscribers</c>. This argument returns a list of
 
2347
              local processes currently subscribing to system events.
 
2348
              </p>
 
2349
          </item>
 
2350
          <item>
 
2351
            <p><c>tables</c>. This argument returns a list of all
 
2352
              locally known tables.
 
2353
              </p>
 
2354
          </item>
 
2355
          <item>
 
2356
            <p><c>transactions</c>. This argument returns a list
 
2357
              of all currently active local transactions.
 
2358
              </p>
 
2359
          </item>
 
2360
          <item>
 
2361
            <p><c>transaction_failures</c>. This argument returns
 
2362
              a number which indicates how many transactions have
 
2363
              failed since Mnesia was started.
 
2364
              </p>
 
2365
          </item>
 
2366
          <item>
 
2367
            <p><c>transaction_commits</c>. This argument returns a
 
2368
              number which indicates how many transactions have
 
2369
              terminated successfully since Mnesia was started.
 
2370
              </p>
 
2371
          </item>
 
2372
          <item>
 
2373
            <p><c>transaction_restarts</c>. This argument returns
 
2374
              a number which indicates how many transactions have been
 
2375
              restarted since Mnesia was started.
 
2376
              </p>
 
2377
          </item>
 
2378
          <item>
 
2379
            <p><c>transaction_log_writes</c>. This argument
 
2380
              returns a number which indicates the number of write
 
2381
              operation that have been performed to the transaction
 
2382
              log since start-up.
 
2383
              </p>
 
2384
          </item>
 
2385
          <item>
 
2386
            <p><c>use_dir</c>. This argument returns a boolean
 
2387
              which indicates whether the Mnesia directory is used or
 
2388
              not. Can be invoked even if Mnesia is not yet running.  
 
2389
              </p>
 
2390
          </item>
 
2391
          <item>
 
2392
            <p><c>version</c>. This argument returns the current
 
2393
              version number of Mnesia.
 
2394
              </p>
 
2395
          </item>
 
2396
        </list>
 
2397
      </desc>
 
2398
    </func>
 
2399
    <func>
 
2400
      <name>table(Tab [,[Option]]) -> QueryHandle </name>
 
2401
      <fsummary>Return a QLC query handle.</fsummary>
 
2402
      <desc>
 
2403
        <p>          <marker id="qlc_table"></marker>
 
2404
Returns a QLC (Query List Comprehension) query handle, see
 
2405
          <seealso marker="stdlib:qlc">qlc(3)</seealso>.The module <c>qlc</c> implements a query language, it
 
2406
          can use mnesia tables as sources of data. Calling
 
2407
          <c>mnesia:table/1,2</c> is the means to make the <c>mnesia</c>
 
2408
          table <c>Tab</c> usable to QLC.</p>
 
2409
        <p>The list of Options may contain mnesia options or QLC
 
2410
          options, the following options are recognized by Mnesia:
 
2411
          <c>{traverse, SelectMethod},{lock, Lock},{n_objects,Number}</c>, any other option is forwarded
 
2412
          to QLC. The <c>lock</c> option may be <c>read</c> or
 
2413
          <c>write</c>, default is <c>read</c>.  The option
 
2414
          <c>n_objects</c> specifies (roughly) the number of objects
 
2415
          returned from mnesia to QLC. Queries to remote tables may
 
2416
          need a larger chunks to reduce network overhead, default
 
2417
          <c>100</c> objects at a time are returned.  The option
 
2418
          <c>traverse</c> determines the method to traverse the whole
 
2419
          table (if needed), the default method is <c>select</c>:</p>
 
2420
        <list type="bulleted">
 
2421
          <item>
 
2422
            <p><c>select</c>. The table is traversed by calling
 
2423
              <c>mnesia:select/4</c> and <c>mnesia:select/1</c>. The
 
2424
              match specification (the second argument of <c>select/3</c>) 
 
2425
              is assembled by QLC: simple filters are
 
2426
              translated into equivalent match specifications while
 
2427
              more complicated filters have to be applied to all
 
2428
              objects returned by <c>select/3</c> given a match
 
2429
              specification that matches all objects.</p>
 
2430
          </item>
 
2431
          <item>
 
2432
            <p><c>{select, MatchSpec}</c>. As for <c>select</c>
 
2433
              the table is traversed by calling <c>mnesia:select/3</c> and
 
2434
              <c>mnesia:select/1</c>. The difference is that the match
 
2435
              specification is explicitly given. This is how to state
 
2436
              match specifications that cannot easily be expressed
 
2437
              within the syntax provided by QLC.</p>
 
2438
          </item>
 
2439
        </list>
 
2440
      </desc>
 
2441
    </func>
 
2442
    <func>
 
2443
      <name>table_info(Tab, InfoKey) -> Info | exit({aborted, Reason})</name>
 
2444
      <fsummary>Return local information about table.</fsummary>
 
2445
      <desc>
 
2446
        <p>The <c>table_info/2</c> function takes two arguments.
 
2447
          The first is the name of a Mnesia table, the second is one of
 
2448
          the following keys:
 
2449
          </p>
 
2450
        <list type="bulleted">
 
2451
          <item>
 
2452
            <p><c>all</c>. This argument returns a list of all
 
2453
              local table information. Each element is a <c>{InfoKey, ItemVal}</c> tuples. <em>Note:</em> New <c>InfoItem</c>'s may be
 
2454
              added and old undocumented <c>InfoItem</c>'s may be removed without 
 
2455
              notice.</p>
 
2456
          </item>
 
2457
          <item>
 
2458
            <p><c>access_mode</c>. This argument returns the
 
2459
              access mode of the table. The access mode may either be
 
2460
              read_only or read_write.
 
2461
              </p>
 
2462
          </item>
 
2463
          <item>
 
2464
            <p><c>arity</c>. This argument returns the arity of
 
2465
              records in the table as specified in the schema. 
 
2466
              </p>
 
2467
          </item>
 
2468
          <item>
 
2469
            <p><c>attributes</c>. This argument returns the table
 
2470
              attribute names which are specified in the schema. 
 
2471
              </p>
 
2472
          </item>
 
2473
          <item>
 
2474
            <p><c>checkpoints</c>. This argument returns the names
 
2475
              of the currently active checkpoints which involves this
 
2476
              table on this node.
 
2477
              </p>
 
2478
          </item>
 
2479
          <item>
 
2480
            <p><c>cookie</c>. This argument returns a table cookie
 
2481
              which is a unique system generated identifier for the
 
2482
              table. The cookie is used internally to ensure that two
 
2483
              different table definitions using the same table name
 
2484
              cannot accidentally be intermixed. The cookie is
 
2485
              generated when the table is initially created.
 
2486
              </p>
 
2487
          </item>
 
2488
          <item>
 
2489
            <p><c>disc_copies</c>. This argument returns the nodes
 
2490
              where a disc_copy of the table resides according to the
 
2491
              schema. 
 
2492
              </p>
 
2493
          </item>
 
2494
          <item>
 
2495
            <p><c>disc_only_copies </c>. This argument returns the
 
2496
              nodes where a disc_only_copy of the table resides
 
2497
              according to the schema. 
 
2498
              </p>
 
2499
          </item>
 
2500
          <item>
 
2501
            <p><c>index</c>. This argument returns the list of
 
2502
              index position integers for the table. 
 
2503
              </p>
 
2504
          </item>
 
2505
          <item>
 
2506
            <p><c>load_node</c>. This argument returns the name of
 
2507
              the node that Mnesia loaded the table from. The
 
2508
              structure of the returned value is unspecified but may
 
2509
              be useful for debugging purposes.
 
2510
              </p>
 
2511
          </item>
 
2512
          <item>
 
2513
            <p><c>load_order</c>. This argument returns the load
 
2514
              order priority of the table. It is an integer and
 
2515
              defaults to <c>0</c> (zero).
 
2516
              </p>
 
2517
          </item>
 
2518
          <item>
 
2519
            <p><c>load_reason</c>. This argument returns the
 
2520
              reason of why Mnesia decided to load the table. The
 
2521
              structure of the returned value is unspecified but may
 
2522
              be useful for debugging purposes.
 
2523
              </p>
 
2524
          </item>
 
2525
          <item>
 
2526
            <p><c>local_content</c>. This argument returns
 
2527
              <c>true</c> or <c>false</c> to indicate whether the
 
2528
              table is configured to have locally unique content on
 
2529
              each node. 
 
2530
              </p>
 
2531
          </item>
 
2532
          <item>
 
2533
            <p><c>master_nodes</c>. This argument returns the
 
2534
              master nodes of a table.
 
2535
              </p>
 
2536
          </item>
 
2537
          <item>
 
2538
            <p><c>memory</c>. This argument returns the number of
 
2539
              words allocated to the table on this node. 
 
2540
              </p>
 
2541
          </item>
 
2542
          <item>
 
2543
            <p><c>ram_copies</c>. This argument returns the nodes
 
2544
              where a ram_copy of the table resides according to the
 
2545
              schema. 
 
2546
              </p>
 
2547
          </item>
 
2548
          <item>
 
2549
            <p><c>record_name</c>. This argument returns the
 
2550
              record name, common for all records in the table
 
2551
              </p>
 
2552
          </item>
 
2553
          <item>
 
2554
            <p><c>size</c>. This argument returns the number of
 
2555
              records inserted in the table. 
 
2556
              </p>
 
2557
          </item>
 
2558
          <item>
 
2559
            <p><c>snmp</c>. This argument returns the SNMP struct.
 
2560
              <c>[]</c>meaning that the table currently has no SNMP
 
2561
              properties.
 
2562
              </p>
 
2563
          </item>
 
2564
          <item>
 
2565
            <p><c>storage_type</c>.This argument returns the local
 
2566
              storage type of the table. It can be <c>disc_copies</c>,
 
2567
              <c>ram_copies</c>, <c>disc_only_copies</c>, or the atom
 
2568
              <c>unknown</c>. <c>unknown</c> is returned for all
 
2569
              tables which only reside remotely.
 
2570
              </p>
 
2571
          </item>
 
2572
          <item>
 
2573
            <p><c>subscribers</c>. This argument returns a list
 
2574
              of local processes currently subscribing to local table
 
2575
              events which involve this table on this node.
 
2576
              </p>
 
2577
          </item>
 
2578
          <item>
 
2579
            <p><c>type</c>. This argument returns the table type,
 
2580
              which is either <c>bag</c>, <c>set</c> or <c>ordered_set</c>..
 
2581
              </p>
 
2582
          </item>
 
2583
          <item>
 
2584
            <p><c>user_properties</c>. This argument returns the
 
2585
              user associated table properties of the table. It is a
 
2586
              list of the stored property records.
 
2587
              </p>
 
2588
          </item>
 
2589
          <item>
 
2590
            <p><c>version</c>. This argument returns the current
 
2591
              version of the table definition. The table version is
 
2592
              incremented when the table definition is changed. The
 
2593
              table definition may be incremented directly when the
 
2594
              table definition has been changed in a schema
 
2595
              transaction, or when a committed table definition is
 
2596
              merged with table definitions from other nodes during
 
2597
              start-up.
 
2598
              </p>
 
2599
          </item>
 
2600
          <item>
 
2601
            <p><c>where_to_read</c>.This argument returns the node
 
2602
              where the table can be read. If the value <c>nowhere</c>
 
2603
              is returned, the table is not loaded, or it resides at a
 
2604
              remote node which is not running.             
 
2605
              </p>
 
2606
          </item>
 
2607
          <item>
 
2608
            <p><c>where_to_write</c>. This argument returns a list
 
2609
              of the nodes that currently hold an active replica of
 
2610
              the table. 
 
2611
              </p>
 
2612
          </item>
 
2613
          <item>
 
2614
            <p><c>wild_pattern</c>. This argument returns a
 
2615
              structure which can be given to the various match
 
2616
              functions for a certain table. A record tuple is where all
 
2617
              record fields have the value <c>'_'</c>.
 
2618
              </p>
 
2619
          </item>
 
2620
        </list>
 
2621
      </desc>
 
2622
    </func>
 
2623
    <func>
 
2624
      <name>transaction(Fun [[, Args], Retries]) -> {aborted, Reason} | {atomic, ResultOfFun}</name>
 
2625
      <fsummary>Execute a transaction.</fsummary>
 
2626
      <desc>
 
2627
        <p>This function executes the functional object <c>Fun</c>
 
2628
          with arguments <c>Args</c> as a transaction.
 
2629
          </p>
 
2630
        <p>The code which executes inside the transaction
 
2631
          can consist of a series of table manipulation functions.
 
2632
          If something goes wrong inside the transaction as a result of a
 
2633
          user error or a certain table not being available, the
 
2634
          entire transaction is aborted and the function 
 
2635
          <c>transaction/1</c> returns the tuple 
 
2636
          <c>{aborted, Reason}</c>.
 
2637
          </p>
 
2638
        <p>If all is well, <c>{atomic, ResultOfFun}</c> is returned where
 
2639
          <c>ResultOfFun</c> is the value of the last expression in
 
2640
          <c>Fun</c>.
 
2641
          </p>
 
2642
        <p>A function which adds a family to the database can be
 
2643
          written as follows if we have a structure <c>{family, Father, Mother, ChildrenList}</c>:
 
2644
          </p>
 
2645
        <code type="none">
 
2646
add_family({family, F, M, Children}) ->
 
2647
    ChildOids = lists:map(fun oid/1, Children),
 
2648
    Trans = fun() ->      
 
2649
        mnesia:write(F#person{children = ChildOids}, 
 
2650
        mnesia:write(M#person{children = ChildOids},
 
2651
        Write = fun(Child) -> mnesia:write(Child) end,
 
2652
        lists:foreach(Write, Children)
 
2653
    end,
 
2654
    mnesia:transaction(Trans).
 
2655
 
 
2656
oid(Rec) -> {element(1, Rec), element(2, Rec)}.
 
2657
        </code>
 
2658
        <p>This code adds a set of people to the database. Running this code
 
2659
          within one transaction will ensure that either the whole
 
2660
          family is added to the database, or the  whole transaction
 
2661
          aborts. For example, if the last child is badly formatted,
 
2662
          or the executing process terminates due to an
 
2663
          <c>'EXIT'</c> signal while executing the family code, the
 
2664
          transaction aborts. Accordingly, the situation where half a
 
2665
          family is added can never occur.
 
2666
          </p>
 
2667
        <p>It is also useful to update the database within a transaction
 
2668
          if several processes concurrently update the same records.
 
2669
          For example, the function <c>raise(Name, Amount)</c>, which 
 
2670
          adds <c>Amount</c> to the salary field of a person, should
 
2671
          be implemented as follows:
 
2672
          </p>
 
2673
        <code type="none">
 
2674
raise(Name, Amount) ->
 
2675
    mnesia:transaction(fun() ->
 
2676
        case mnesia:wread({person, Name}) of
 
2677
            [P] ->
 
2678
                Salary = Amount + P#person.salary,
 
2679
                P2 = P#person{salary = Salary},
 
2680
                mnesia:write(P2);
 
2681
            _ ->
 
2682
                mnesia:abort("No such person")
 
2683
        end
 
2684
    end).
 
2685
        </code>
 
2686
        <p>When this function executes within a transaction, 
 
2687
          several processes running on different nodes can concurrently
 
2688
          execute the <c>raise/2</c> function without interfering 
 
2689
          with each other. 
 
2690
          </p>
 
2691
        <p>Since Mnesia detects deadlocks, a transaction can be
 
2692
          restarted any number of times.  This function will attempt a restart as specified in
 
2693
          <c>Retries</c>. <c>Retries</c> must
 
2694
          be an integer greater than 0 or the atom <c>infinity</c>. Default is
 
2695
          <c>infinity</c>.</p>
 
2696
      </desc>
 
2697
    </func>
 
2698
    <func>
 
2699
      <name>transform_table(Tab, Fun, NewAttributeList, NewRecordName) ->  {aborted, R} | {atomic, ok} </name>
 
2700
      <fsummary>Change format on all records in table. <c>Tab</c></fsummary>
 
2701
      <desc>
 
2702
        <p>This function applies the argument <c>Fun</c> to all
 
2703
          records in the table. <c>Fun</c> is a function which takes a
 
2704
          record of the old type and returns a transformed record of the
 
2705
          new type. The <c>Fun</c> argument can also be the atom
 
2706
          <c>ignore</c>, it indicates that only the meta data about the table will
 
2707
          be updated. Usage of <c>ignore</c> is not recommended but included
 
2708
          as a possibility for the user do to his own transform.
 
2709
          <c>NewAttributeList</c> and <c>NewRecordName</c>
 
2710
          specifies the attributes and the new record type of converted
 
2711
          table. Table name will always remain unchanged, if the
 
2712
          record_name is changed only the mnesia functions which
 
2713
          uses table identifiers will work, e.g. <c>mnesia:write/3</c>
 
2714
          will work but <c>mnesia:write/1</c> will not.</p>
 
2715
      </desc>
 
2716
    </func>
 
2717
    <func>
 
2718
      <name>transform_table(Tab, Fun, NewAttributeList) ->  {aborted, R} | {atomic, ok} </name>
 
2719
      <fsummary>Change format on all records in table. <c>Tab</c></fsummary>
 
2720
      <desc>
 
2721
        <p>Invokes <c>mnesia:transform_table(Tab, Fun, NewAttributeList, RecName)</c>
 
2722
          where <c>RecName</c> is <c>mnesia:table_info(Tab, record_name)</c>.</p>
 
2723
      </desc>
 
2724
    </func>
 
2725
    <func>
 
2726
      <name>traverse_backup(Source, [SourceMod,] Target, [TargetMod,] Fun, Acc) -> {ok, LastAcc} | {error, Reason}</name>
 
2727
      <fsummary>Traversal of a backup.</fsummary>
 
2728
      <desc>
 
2729
        <p>With this function it is possible to iterate over a backup,
 
2730
          either for the purpose of transforming it into a new backup,
 
2731
          or just reading it. The arguments are explained briefly
 
2732
          below. See the Mnesia User's Guide for additional
 
2733
          details.
 
2734
          </p>
 
2735
        <list type="bulleted">
 
2736
          <item><c>SourceMod</c> and <c>TargetMod</c> are the names of
 
2737
           the modules which actually access the backup
 
2738
           media.
 
2739
          </item>
 
2740
          <item><c>Source</c> and <c>Target</c> are opaque data used
 
2741
           exclusively by the modules <c>SourceMod</c> and
 
2742
          <c>TargetMod</c> for the purpose of initializing the
 
2743
           backup media. 
 
2744
          </item>
 
2745
          <item><c>Acc</c> is an initial accumulator value.
 
2746
          </item>
 
2747
          <item><c>Fun(BackupItems, Acc)</c> is applied to each item in
 
2748
           the backup. The Fun must return a tuple
 
2749
          <c>{BackupItems,NewAcc}</c>, where <c>BackupItems</c> is
 
2750
           a list of valid backup items, and <c>NewAcc</c> is a new
 
2751
           accumulator value. The returned backup items are written
 
2752
           in the target backup. 
 
2753
          </item>
 
2754
          <item><c>LastAcc</c> is the last accumulator value. This is
 
2755
           the last <c>NewAcc</c> value that was returned by <c>Fun</c>.
 
2756
          </item>
 
2757
        </list>
 
2758
      </desc>
 
2759
    </func>
 
2760
    <func>
 
2761
      <name>uninstall_fallback() -> ok | {error,Reason}</name>
 
2762
      <fsummary>Uninstall a fallback.</fsummary>
 
2763
      <desc>
 
2764
        <p>Invokes <c>mnesia:uninstall_fallback([{scope, global}])</c>.</p>
 
2765
      </desc>
 
2766
    </func>
 
2767
    <func>
 
2768
      <name>uninstall_fallback(Args) -> ok | {error,Reason}</name>
 
2769
      <fsummary>Uninstall a fallback.</fsummary>
 
2770
      <desc>
 
2771
        <p>This function is used to de-install a fallback before it
 
2772
          has been used to restore the database. This is normally a
 
2773
          distributed operation that is either performed on all
 
2774
          nodes with disc resident schema or none.  Uninstallation of
 
2775
          fallbacks requires Erlang to be up and running on all
 
2776
          involved nodes, but it does not matter if Mnesia is running
 
2777
          or not. Which nodes that are considered as disc-resident
 
2778
          nodes is determined from the schema info in the local
 
2779
          fallback.
 
2780
          </p>
 
2781
        <p><c>Args</c> is a list of the following tuples: 
 
2782
          </p>
 
2783
        <list type="bulleted">
 
2784
          <item>
 
2785
            <p><c>{module, BackupMod}</c>. 
 
2786
              See <c>mnesia:install_fallback/2</c> about the
 
2787
              semantics.</p>
 
2788
          </item>
 
2789
          <item>
 
2790
            <p><c>{scope, Scope}</c>
 
2791
              See <c>mnesia:install_fallback/2</c> about the
 
2792
              semantics.</p>
 
2793
          </item>
 
2794
          <item>
 
2795
            <p><c>{mnesia_dir, AlternateDir}</c> 
 
2796
              See <c>mnesia:install_fallback/2</c> about the
 
2797
              semantics.</p>
 
2798
          </item>
 
2799
        </list>
 
2800
      </desc>
 
2801
    </func>
 
2802
    <func>
 
2803
      <name>unsubscribe(EventCategory)</name>
 
2804
      <fsummary>Subscribe to events of type <c>EventCategory</c>.</fsummary>
 
2805
      <desc>
 
2806
        <p>Stops sending events of type
 
2807
          <c>EventCategory</c> to the caller.</p>
 
2808
      </desc>
 
2809
    </func>
 
2810
    <func>
 
2811
      <name>wait_for_tables(TabList,Timeout) -> ok | {timeout, BadTabList} | {error, Reason} </name>
 
2812
      <fsummary>Wait for tables to be accessible.</fsummary>
 
2813
      <desc>
 
2814
        <p>Some applications need to wait for certain tables to
 
2815
          be accessible in order to do useful work.
 
2816
          <c>mnesia:wait_for_tables/2</c> hangs until all tables in the
 
2817
          <c>TabList</c> are accessible, or until <c>timeout</c> is
 
2818
          reached.</p>
 
2819
      </desc>
 
2820
    </func>
 
2821
    <func>
 
2822
      <name>wread({Tab, Key}) -> transaction abort | RecordList </name>
 
2823
      <fsummary>Read records with given key.</fsummary>
 
2824
      <desc>
 
2825
        <p>Invoke <c>mnesia:read(Tab, Key, write)</c>.</p>
 
2826
      </desc>
 
2827
    </func>
 
2828
    <func>
 
2829
      <name>write(Record) -> transaction abort | ok </name>
 
2830
      <fsummary>Writes a record into the database.</fsummary>
 
2831
      <desc>
 
2832
        <p>Invoke <c>mnesia:write(Tab, Record, write)</c> where
 
2833
          <c>Tab</c> is <c>element(1, Record)</c>.</p>
 
2834
      </desc>
 
2835
    </func>
 
2836
    <func>
 
2837
      <name>write(Tab, Record, LockKind) -> transaction abort | ok </name>
 
2838
      <fsummary>Write an record into the database.</fsummary>
 
2839
      <desc>
 
2840
        <p>Writes the record <c>Record</c> to the table <c>Tab</c>.
 
2841
          </p>
 
2842
        <p>The function returns <c>ok</c>, or aborts if an error
 
2843
          occurs. For example, the transaction aborts if no
 
2844
          <c>person</c> table exists.
 
2845
          </p>
 
2846
        <p>The semantics of this function is context sensitive. See
 
2847
          <c>mnesia:activity/4</c> for more information. In transaction
 
2848
          context it acquires a lock of type <c>LockKind</c>. The
 
2849
          following lock types are supported: <c>write</c> and
 
2850
          <c>sticky_write</c>.</p>
 
2851
      </desc>
 
2852
    </func>
 
2853
    <func>
 
2854
      <name>write_lock_table(Tab) -> ok | transaction abort</name>
 
2855
      <fsummary>Set write lock on an entire table.</fsummary>
 
2856
      <desc>
 
2857
        <p>Invokes <c>mnesia:lock({table, Tab}, write)</c>.</p>
 
2858
      </desc>
 
2859
    </func>
 
2860
  </funcs>
 
2861
 
 
2862
  <section>
 
2863
    <title>Configuration Parameters</title>
 
2864
    <p>Mnesia reads the following application configuration
 
2865
      parameters:</p>
 
2866
    <list type="bulleted">
 
2867
      <item>
 
2868
        <p><c>-mnesia access_module Module</c>. The 
 
2869
          name of the Mnesia activity access callback module. The default is
 
2870
          <c>mnesia</c>.
 
2871
          </p>
 
2872
      </item>
 
2873
      <item>
 
2874
        <p><c>-mnesia auto_repair true | false</c>. This flag controls
 
2875
          whether Mnesia will try to automatically repair
 
2876
          files that have not been properly closed. The default is 
 
2877
          <c>true</c>.
 
2878
          </p>
 
2879
      </item>
 
2880
      <item>
 
2881
        <p><c>-mnesia backup_module Module</c>. The 
 
2882
          name of the Mnesia backup callback module. The default is
 
2883
          <c>mnesia_backup</c>.
 
2884
          </p>
 
2885
      </item>
 
2886
      <item>
 
2887
        <p><c>-mnesia debug Level</c>
 
2888
          Controls the debug level of Mnesia.
 
2889
          Possible values are:</p>
 
2890
        <taglist>
 
2891
          <tag><c>none</c></tag>
 
2892
          <item>
 
2893
            <p>No trace outputs at all. This is the default setting.
 
2894
              </p>
 
2895
          </item>
 
2896
          <tag><c>verbose</c></tag>
 
2897
          <item>
 
2898
            <p>Activates tracing of important debug events. These
 
2899
              debug events generate <c>{mnesia_info, Format, Args}</c>
 
2900
              system events. Processes may subscribe to these events with
 
2901
              <c>mnesia:subscribe/1</c>. The events are always sent to Mnesia's
 
2902
              event handler. 
 
2903
              </p>
 
2904
          </item>
 
2905
          <tag><c>debug</c></tag>
 
2906
          <item>
 
2907
            <p>Activates all events at the verbose level plus full
 
2908
              trace of all debug events. These debug events generate
 
2909
              <c>{mnesia_info, Format, Args}</c> system events. Processes may
 
2910
              subscribe to these events with <c>mnesia:subscribe/1</c>. The
 
2911
              events are always sent to the Mnesia event handler. On this
 
2912
              debug level, the Mnesia event handler starts subscribing to
 
2913
              updates in the schema table. 
 
2914
              </p>
 
2915
          </item>
 
2916
          <tag><c>trace</c></tag>
 
2917
          <item>
 
2918
            <p>Activates all events at the level debug. On this
 
2919
              debug level, the Mnesia event handler starts subscribing to
 
2920
              updates on all Mnesia tables. This level is only intended
 
2921
              for debugging  small toy systems since many large
 
2922
              events may be generated.
 
2923
              </p>
 
2924
          </item>
 
2925
          <tag><c>false</c></tag>
 
2926
          <item>
 
2927
            <p>An alias for none.
 
2928
              </p>
 
2929
          </item>
 
2930
          <tag><c>true</c></tag>
 
2931
          <item>
 
2932
            <p>An alias for debug.
 
2933
              </p>
 
2934
          </item>
 
2935
        </taglist>
 
2936
      </item>
 
2937
      <item>
 
2938
        <p><c>-mnesia core_dir Directory</c>. The name of the
 
2939
          directory where Mnesia core files is stored or
 
2940
          false. Setting it implies that also ram only nodes, will
 
2941
          generate a core file if a crash occurs. </p>
 
2942
      </item>
 
2943
      <item>
 
2944
        <p><c>-mnesia dc_dump_limit Number</c>. 
 
2945
          Controls how often <c>disc_copies</c> tables are dumped from memory.
 
2946
          Tables are dumped when 
 
2947
          <c>filesize(Log) > (filesize(Tab)/Dc_dump_limit)</c>.
 
2948
          Lower values reduces cpu overhead but increases disk space and
 
2949
          startup times. The default is 4.</p>
 
2950
      </item>
 
2951
      <item>
 
2952
        <p><c>-mnesia dir Directory</c>. The name of the directory
 
2953
          where all Mnesia data is stored. The name of the directory must
 
2954
          be unique for the current node. Two nodes may, under no
 
2955
          circumstances, share the same Mnesia directory. The results are
 
2956
          totally unpredictable.</p>
 
2957
      </item>
 
2958
      <item>
 
2959
        <p><c>-mnesia dump_log_load_regulation true | false</c>.
 
2960
          Controls if the log dumps should be performed as fast as
 
2961
          possible or if the dumper should do its own load
 
2962
          regulation. This feature is temporary and will disappear in a
 
2963
          future release. The default is <c>false</c>.
 
2964
          </p>
 
2965
      </item>
 
2966
      <item>
 
2967
        <p><c>-mnesia dump_log_update_in_place true | false</c>.
 
2968
          Controls if log dumps are performed on a copy of
 
2969
          the original data file, or if  the log dump is 
 
2970
          performed on the original data file. The default is <c>true</c></p>
 
2971
      </item>
 
2972
      <item>
 
2973
        <p><c>-mnesia dump_log_write_threshold Max</c>, where
 
2974
          <c>Max</c> is an integer which specifies the maximum number of writes
 
2975
          allowed to the transaction log before a new dump of the log
 
2976
          is performed. It defaults to 100 log writes.
 
2977
          </p>
 
2978
      </item>
 
2979
      <item>
 
2980
        <p><c>-mnesia dump_log_time_threshold Max</c>,
 
2981
          where <c>Max</c> is an integer which
 
2982
          specifies the dump log interval in milliseconds. It defaults
 
2983
          to 3 minutes. If a dump has not been performed within
 
2984
          <c>dump_log_time_threshold</c> milliseconds, then a new dump is
 
2985
          performed regardless of how many writes have been
 
2986
          performed. 
 
2987
          </p>
 
2988
      </item>
 
2989
      <item>
 
2990
        <p><c>-mnesia event_module Module</c>. The 
 
2991
          name of the Mnesia event handler callback module. The default is
 
2992
          <c>mnesia_event</c>.
 
2993
          </p>
 
2994
      </item>
 
2995
      <item>
 
2996
        <p><c>-mnesia extra_db_nodes Nodes</c> specifies a list of
 
2997
          nodes, in addition to the ones found in the schema, with which
 
2998
          Mnesia should also establish contact. The default value
 
2999
          is the empty list <c>[]</c>. 
 
3000
          </p>
 
3001
      </item>
 
3002
      <item>
 
3003
        <p><c>-mnesia fallback_error_function {UserModule, UserFunc}</c>
 
3004
          specifies a user supplied callback function
 
3005
          which will be called if a fallback is installed and mnesia 
 
3006
          goes down on another node. Mnesia will call the function
 
3007
          with one argument the name of the dying node, e.g.
 
3008
          <c>UserModule:UserFunc(DyingNode)</c>.
 
3009
          Mnesia should be restarted or else
 
3010
          the database could be inconsistent.
 
3011
          The default behaviour is to terminate mnesia.
 
3012
          </p>
 
3013
      </item>
 
3014
      <item>
 
3015
        <p><c>-mnesia max_wait_for_decision Timeout</c>. Specifies
 
3016
          how long Mnesia will wait for other nodes to share their
 
3017
          knowledge regarding the outcome of an unclear transaction.  By
 
3018
          default the <c>Timeout</c> is set to the atom
 
3019
          <c>infinity</c>, which implies that if Mnesia upon startup
 
3020
          encounters a "heavyweight transaction" whose outcome is
 
3021
          unclear, the local Mnesia will wait until Mnesia is started
 
3022
          on some (in worst cases all) of the other nodes that were
 
3023
          involved in the interrupted transaction. This is a very rare
 
3024
          situation, but when/if it happens, Mnesia does not guess if
 
3025
          the transaction on the other nodes was committed or aborted.
 
3026
          Mnesia will wait until it knows the outcome and then act
 
3027
          accordingly.
 
3028
          </p>
 
3029
        <p>If <c>Timeout</c> is set to an integer value in
 
3030
          milliseconds, Mnesia will force "heavyweight transactions"
 
3031
          to be finished, even if the outcome of the transaction for
 
3032
          the moment is unclear. After <c>Timeout</c> milliseconds,
 
3033
          Mnesia  will commit/abort the transaction and continue with
 
3034
          the startup. This may lead to a situation where the
 
3035
          transaction is committed on some nodes and aborted on other
 
3036
          nodes. If the transaction was a schema transaction, the
 
3037
          inconsistency may be fatal. 
 
3038
          </p>
 
3039
      </item>
 
3040
      <item>
 
3041
        <p><c>-mnesia no_table_loaders NUMBER</c> specifies the number of
 
3042
          parallel table loaders during start. More loaders can be good if the
 
3043
          network latency is high or if many tables contains few records.
 
3044
          The default value is <c>2</c>.
 
3045
          </p>
 
3046
      </item>
 
3047
      <item>
 
3048
        <p><c>-mnesia schema_location Loc</c> controls where
 
3049
          Mnesia will look for its schema. The parameter
 
3050
          <c>Loc</c> may be one of the following atoms: </p>
 
3051
        <taglist>
 
3052
          <tag><c>disc</c></tag>
 
3053
          <item>
 
3054
            <p>Mandatory disc. The schema is assumed to be located
 
3055
              in the Mnesia directory. If the schema cannot be found,
 
3056
              Mnesia refuses to start. This is the old behavior.
 
3057
              </p>
 
3058
          </item>
 
3059
          <tag><c>ram</c></tag>
 
3060
          <item>
 
3061
            <p>Mandatory RAM. The schema resides in RAM
 
3062
              only. At start-up, a tiny new schema is generated. This
 
3063
              default schema just contains the definition of the schema
 
3064
              table and  only resides on the local node. Since no other
 
3065
              nodes are found in the default schema, the configuration
 
3066
              parameter  <c>extra_db_nodes</c> must be used in
 
3067
              order to let the 
 
3068
              node share its table definitions with other nodes. (The
 
3069
              <c>extra_db_nodes</c> parameter may also be used on disc based nodes.)
 
3070
              </p>
 
3071
          </item>
 
3072
          <tag><c>opt_disc</c></tag>
 
3073
          <item>
 
3074
            <p>Optional disc. The schema may reside either on disc
 
3075
              or in RAM. If the schema is found on disc, Mnesia starts as a
 
3076
              disc based node and the storage type of the schema table is
 
3077
              <c>disc_copies</c>. If no schema is found on disc, Mnesia starts
 
3078
              as a disc-less node and the storage type of the schema table is
 
3079
              <c>ram_copies</c>. The default value for the application parameter
 
3080
              is <c>opt_disc</c>.  
 
3081
              </p>
 
3082
          </item>
 
3083
        </taglist>
 
3084
      </item>
 
3085
    </list>
 
3086
    <p>First the SASL application parameters are checked, then
 
3087
      the command line flags are checked, and finally, the default
 
3088
      value is chosen.
 
3089
      </p>
 
3090
  </section>
 
3091
 
 
3092
  <section>
 
3093
    <title>See Also</title>
 
3094
    <p>mnesia_registry(3), mnesia_session(3), qlc(3),
 
3095
      dets(3), ets(3), disk_log(3), application(3) 
 
3096
      </p>
 
3097
  </section>
 
3098
  
 
3099
</erlref>
 
3100