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