Home | History | Annotate | Line # | Download | only in html
sqlite_table.5.html revision 1.1.1.4
      1 <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"
      2         "http://www.w3.org/TR/html4/loose.dtd">
      3 <html> <head>
      4 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
      5 <title> Postfix manual - sqlite_table(5) </title>
      6 </head> <body> <pre>
      7 SQLITE_TABLE(5)                                                SQLITE_TABLE(5)
      8 
      9 <b>NAME</b>
     10        sqlite_table - Postfix SQLite configuration
     11 
     12 <b>SYNOPSIS</b>
     13        <b>postmap -q "</b><i>string</i><b>" <a href="sqlite_table.5.html">sqlite</a>:/etc/postfix/</b><i>filename</i>
     14 
     15        <b>postmap -q - <a href="sqlite_table.5.html">sqlite</a>:/etc/postfix/</b><i>filename</i> &lt;<i>inputfile</i>
     16 
     17 <b>DESCRIPTION</b>
     18        The  Postfix  mail system uses optional tables for address rewriting or
     19        mail routing. These tables are usually in <b>dbm</b> or <b>db</b> format.
     20 
     21        Alternatively, lookup tables can be specified as SQLite databases.   In
     22        order  to use SQLite lookups, define an SQLite source as a lookup table
     23        in <a href="postconf.5.html">main.cf</a>, for example:
     24            <a href="postconf.5.html#alias_maps">alias_maps</a> = <a href="sqlite_table.5.html">sqlite</a>:/etc/sqlite-aliases.cf
     25 
     26        The file /etc/postfix/sqlite-aliases.cf has  the  same  format  as  the
     27        Postfix <a href="postconf.5.html">main.cf</a> file, and can specify the parameters described below.
     28 
     29 <b>LIST MEMBERSHIP</b>
     30        When  using  SQL  to  store  lists such as $<a href="postconf.5.html#mynetworks">mynetworks</a>, $<a href="postconf.5.html#mydestination">mydestination</a>,
     31        $<a href="postconf.5.html#relay_domains">relay_domains</a>, $<a href="postconf.5.html#local_recipient_maps">local_recipient_maps</a>, etc., it is important to  under-
     32        stand that the table must store each list member as a separate key. The
     33        table lookup verifies the *existence* of the key.  See  "Postfix  lists
     34        versus tables" in the <a href="DATABASE_README.html">DATABASE_README</a> document for a discussion.
     35 
     36        Do  NOT create tables that return the full list of domains in $<a href="postconf.5.html#mydestination">mydesti</a>-
     37        <a href="postconf.5.html#mydestination">nation</a> or $<a href="postconf.5.html#relay_domains">relay_domains</a> etc., or IP addresses in $<a href="postconf.5.html#mynetworks">mynetworks</a>.
     38 
     39        DO create tables with each matching item as a key and with an arbitrary
     40        value.  With  SQL databases it is not uncommon to return the key itself
     41        or a constant value.
     42 
     43 <b>SQLITE PARAMETERS</b>
     44        <b>dbpath</b> The SQLite database file location. Example:
     45                   dbpath = customer_database
     46 
     47        <b>query</b>  The SQL query template used to search the database, where <b>%s</b>  is
     48               a  substitute for the address Postfix is trying to resolve, e.g.
     49                   query = SELECT replacement FROM aliases WHERE mailbox = '%s'
     50 
     51               This parameter supports the following '%' expansions:
     52 
     53               <b>%%</b>     This is replaced by a literal '%' character.
     54 
     55               <b>%s</b>     This is replaced by the input key.  SQL quoting  is  used
     56                      to  make  sure that the input key does not add unexpected
     57                      metacharacters.
     58 
     59               <b>%u</b>     When the input key is an address of the form user@domain,
     60                      <b>%u</b>  is  replaced  by  the  SQL  quoted  local part of the
     61                      address.  Otherwise, <b>%u</b> is replaced by the entire  search
     62                      string.   If  the  localpart  is empty, the query is sup-
     63                      pressed and returns no results.
     64 
     65               <b>%d</b>     When the input key is an address of the form user@domain,
     66                      <b>%d</b>  is  replaced  by  the  SQL  quoted domain part of the
     67                      address.  Otherwise, the query is suppressed and  returns
     68                      no results.
     69 
     70               <b>%[SUD]</b> The upper-case equivalents of the above expansions behave
     71                      in the <b>query</b> parameter identically  to  their  lower-case
     72                      counter-parts.   With  the  <b>result_format</b>  parameter (see
     73                      below), they expand the input key rather than the  result
     74                      value.
     75 
     76               <b>%[1-9]</b> The  patterns  %1,  %2, ... %9 are replaced by the corre-
     77                      sponding most significant component of  the  input  key's
     78                      domain.  If  the input key is <i>user (a] mail.example.com</i>, then
     79                      %1 is <b>com</b>, %2 is <b>example</b> and %3 is <b>mail</b>. If the input key
     80                      is  unqualified or does not have enough domain components
     81                      to satisfy all the specified patterns, the query is  sup-
     82                      pressed and returns no results.
     83 
     84               The  <b>domain</b>  parameter  described below limits the input keys to
     85               addresses in matching domains.  When  the  <b>domain</b>  parameter  is
     86               non-empty, SQL queries for unqualified addresses or addresses in
     87               non-matching domains are suppressed and return no results.
     88 
     89               This parameter is available with Postfix 2.2. In prior  releases
     90               the   SQL   query   was  built  from  the  separate  parameters:
     91               <b>select_field</b>, <b>table</b>, <b>where_field</b> and <b>additional_conditions</b>.  The
     92               mapping from the old parameters to the equivalent query is:
     93 
     94                   SELECT [<b>select_field</b>]
     95                   FROM [<b>table</b>]
     96                   WHERE [<b>where_field</b>] = '%s'
     97                         [<b>additional_conditions</b>]
     98 
     99               The  '%s'  in  the  <b>WHERE</b>  clause  expands to the escaped search
    100               string.  With Postfix 2.2 these legacy parameters  are  used  if
    101               the <b>query</b> parameter is not specified.
    102 
    103               NOTE: DO NOT put quotes around the query parameter.
    104 
    105        <b>result_format (default: %s</b>)
    106               Format template applied to result attributes. Most commonly used
    107               to append (or prepend) text to the result. This  parameter  sup-
    108               ports the following '%' expansions:
    109 
    110               <b>%%</b>     This is replaced by a literal '%' character.
    111 
    112               <b>%s</b>     This  is  replaced  by the value of the result attribute.
    113                      When result is empty it is skipped.
    114 
    115               <b>%u</b>     When the result attribute value is an address of the form
    116                      user@domain,  <b>%u</b>  is  replaced  by  the local part of the
    117                      address. When the result has an  empty  localpart  it  is
    118                      skipped.
    119 
    120               <b>%d</b>     When  a  result attribute value is an address of the form
    121                      user@domain, <b>%d</b> is replaced by the  domain  part  of  the
    122                      attribute  value.  When  the  result is unqualified it is
    123                      skipped.
    124 
    125               <b>%[SUD1-9]</b>
    126                      The upper-case and decimal digit  expansions  interpolate
    127                      the  parts of the input key rather than the result. Their
    128                      behavior is identical to that described with  <b>query</b>,  and
    129                      in  fact  because  the  input  key  is  known in advance,
    130                      queries whose key does not contain  all  the  information
    131                      specified  in  the  result  template  are  suppressed and
    132                      return no results.
    133 
    134               For example, using "result_format = <a href="smtp.8.html">smtp</a>:[%s]" allows one to use
    135               a mailHost attribute as the basis of a <a href="transport.5.html">transport(5)</a> table. After
    136               applying the result format, multiple values are concatenated  as
    137               comma  separated  strings.  The  expansion_limit  and  parameter
    138               explained below allows one to restrict the number of  values  in
    139               the result, which is especially useful for maps that must return
    140               at most one value.
    141 
    142               The default value <b>%s</b> specifies that each result value should  be
    143               used as is.
    144 
    145               This parameter is available with Postfix 2.2 and later.
    146 
    147               NOTE: DO NOT put quotes around the result format!
    148 
    149        <b>domain (default: no domain list)</b>
    150               This is a list of domain names, paths to files, or dictionaries.
    151               When  specified,  only  fully  qualified  search  keys  with   a
    152               *non-empty*  localpart  and  a  matching domain are eligible for
    153               lookup:  'user'  lookups,  bare  domain  lookups  and  "@domain"
    154               lookups  are  not  performed.  This can significantly reduce the
    155               query load on the SQLite server.
    156                   domain = postfix.org, <a href="DATABASE_README.html#types">hash</a>:/etc/postfix/searchdomains
    157 
    158               It is best not to use SQL to store the domains eligible for  SQL
    159               lookups.
    160 
    161               This parameter is available with Postfix 2.2 and later.
    162 
    163               NOTE: DO NOT define this parameter for <a href="local.8.html">local(8)</a> aliases, because
    164               the input keys are always unqualified.
    165 
    166        <b>expansion_limit (default: 0)</b>
    167               A limit on the total number of result elements  returned  (as  a
    168               comma separated list) by a lookup against the map.  A setting of
    169               zero disables the limit. Lookups fail with a temporary error  if
    170               the  limit  is  exceeded.   Setting  the limit to 1 ensures that
    171               lookups do not return multiple values.
    172 
    173 <b>OBSOLETE MAIN.CF PARAMETERS</b>
    174        For compatibility with other Postfix lookup tables,  SQLite  parameters
    175        can also be defined in <a href="postconf.5.html">main.cf</a>.  In order to do that, specify as SQLite
    176        source a name that doesn't begin with a slash or  a  dot.   The  SQLite
    177        parameters  will then be accessible as the name you've given the source
    178        in its definition, an underscore, and the name of the  parameter.   For
    179        example,  if the map is specified as "<a href="sqlite_table.5.html">sqlite</a>:<i>sqlitename</i>", the parameter
    180        "query" would be defined in <a href="postconf.5.html">main.cf</a> as "<i>sqlitename</i>_query".
    181 
    182 <b>OBSOLETE QUERY INTERFACE</b>
    183        This section describes an interface that is deprecated  as  of  Postfix
    184        2.2.  It  is  replaced  by  the  more general <b>query</b> interface described
    185        above.  If the  <b>query</b>  parameter  is  defined,  the  legacy  parameters
    186        described  here  ignored.   Please  migrate to the new interface as the
    187        legacy interface may be removed in a future release.
    188 
    189        The following parameters can be used  to  fill  in  a  SELECT  template
    190        statement of the form:
    191 
    192            SELECT [<b>select_field</b>]
    193            FROM [<b>table</b>]
    194            WHERE [<b>where_field</b>] = '%s'
    195                  [<b>additional_conditions</b>]
    196 
    197        The specifier %s is replaced by the search string, and is escaped so if
    198        it contains single quotes or other odd characters, it will not cause  a
    199        parse error, or worse, a security problem.
    200 
    201        <b>select_field</b>
    202               The SQL "select" parameter. Example:
    203                   <b>select_field</b> = forw_addr
    204 
    205        <b>table</b>  The SQL "select .. from" table name. Example:
    206                   <b>table</b> = mxaliases
    207 
    208        <b>where_field</b>
    209               The SQL "select .. where" parameter. Example:
    210                   <b>where_field</b> = alias
    211 
    212        <b>additional_conditions</b>
    213               Additional conditions to the SQL query. Example:
    214                   <b>additional_conditions</b> = AND status = 'paid'
    215 
    216 <b>SEE ALSO</b>
    217        <a href="postmap.1.html">postmap(1)</a>, Postfix lookup table maintenance
    218        <a href="postconf.5.html">postconf(5)</a>, configuration parameters
    219        <a href="ldap_table.5.html">ldap_table(5)</a>, LDAP lookup tables
    220        <a href="mysql_table.5.html">mysql_table(5)</a>, MySQL lookup tables
    221        <a href="pgsql_table.5.html">pgsql_table(5)</a>, PostgreSQL lookup tables
    222 
    223 <b>README FILES</b>
    224        <a href="DATABASE_README.html">DATABASE_README</a>, Postfix lookup table overview
    225        <a href="SQLITE_README.html">SQLITE_README</a>, Postfix SQLITE howto
    226 
    227 <b>LICENSE</b>
    228        The Secure Mailer license must be distributed with this software.
    229 
    230 <b>HISTORY</b>
    231        SQLite support was introduced with Postfix version 2.8.
    232 
    233 <b>AUTHOR(S)</b>
    234        Original implementation by:
    235        Axel Steiner
    236 
    237                                                                SQLITE_TABLE(5)
    238 </pre> </body> </html>
    239