Changeset 17906 in project


Ignore:
Timestamp:
04/25/10 13:17:33 (9 years ago)
Author:
sjamaan
Message:

Update documentation for the new version (3.5)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/4/postgresql

    r17735 r17906  
    682682  ("float8" . ,numeric-parser)
    683683  ("numeric" . ,numeric-parser)
    684   ("oid" . ,numeric-parser))
     684  ("oid" . ,numeric-parser)
     685  ("record" . ,(make-composite-parser (circular-list identity))))
    685686</enscript>
    686687
     
    688689found, the value is returned verbatim (which is always a string, or a
    689690blob in case of binary data).
     691
     692Array and composite (row) types are automatically handled; unless a
     693type-specific parser is defined, a parser is automatically created by
     694combining the parsers for their constituent elements.
    690695
    691696<procedure>(update-type-parsers! CONN [TYPE-PARSERS])</procedure>
     
    722727If {{STR}} could not be converted to a number, raises an error.
    723728
     729<procedure>(make-array-parser SUBPARSER [DELIMITER])</procedure>
     730
     731Returns a procedure that can be used to parse arrays containing
     732elements that {{SUBPARSER}} parses.  It will split the elements using
     733the {{DELIMITER}} character, which defaults to {{#\,}}.
     734
     735For example, to create a parser for arrays of integers, use
     736{{(make-array-parser numeric-parser)}}.
     737
     738<procedure>(make-composite-parser SUBPARSERS)</procedure>
     739
     740Returns a procedure that can be used to parse composite values (aka
     741"row values").  It will use the list of {{SUBPARSERS}} to parse each
     742element in the row by looking up the parser at the matching position
     743in the list.  For example, to create a parser for rows containing an
     744integer and a boolean, use
     745{{(make-composite-parser (list numeric-parser bool-parser))}}.
     746
    724747===== Unparsers
    725748
     
    736759procedures which accept a scheme object and return a true value if the
    737760object is of the type for which the unparser is intended.  Unparsers
    738 are procedures which accept a scheme object and return either a
    739 string, a blob or an sql-null object to be used in the query.
     761are procedures which accept two arguments; the connection object and
     762the scheme object to unparse.  Unparsers return either a string, a blob
     763or an sql-null object to be used in the query.
    740764
    741765It is not necessary to reload type unparsers after defining a new data
     
    751775
    752776<enscript highlight=scheme>
    753 `((,string? . ,identity)
    754   (,u8vector? . ,u8vector->blob/shared)
    755   (,char? . ,string)
     777`((,string? . ,(lambda (conn s) s))
     778  (,u8vector? . ,(lambda (conn v) (u8vector->blob/shared v)))
     779  (,char? . ,(lambda (conn c) (string c)))
    756780  (,boolean? . ,bool-unparser)
    757   (,number? . ,number->string))
     781  (,number? . ,(lambda (conn n) (number->string n)))
     782  (,vector? . ,vector-unparser)
     783  (,pair? . ,list-unparser))
    758784</enscript>
    759785
    760 <procedure>(bool-unparser B)</procedure>
     786<procedure>(bool-unparser CONN B)</procedure>
    761787
    762788Returns {{"TRUE"}} for true values and {{"FALSE"}} for {{#f}}.
    763789
     790<procedure>(vector-unparser CONN V)</procedure>
     791
     792Returns a string representing an array containing the objects in the
     793vector {{V}}.  The elements of {{V}} are unparsed recursively by their
     794respective subparsers.  It is the responsibility of the program to use
     795correct values for an array; the elements should all be of the same
     796type and, if they are vectors themselves, all vectors should have the
     797same length and recursive vector depth.  Otherwise, you will get an
     798error from postgresql.
     799
     800<procedure>(list-unparser CONN L)</procedure>
     801
     802Returns a string representing a composite object (aka row value)
     803containing the objects in the list {{L}}.  The elements of {{L}} are
     804unparsed recursively by their respective subparsers.
     805
     806
    764807=== Changelog
    765808
    766 * trunk Add support for composite and array types.  Change semantics of 'raw' option to {{query*}} procedure.
     809* 3.5 Add support for composite and array types.  Change semantics of 'raw' option to {{query*}} procedure. Backwards incompatible change; pass connection to all type unparsers.
    767810* 3.4.1 Improve COPY interface
    768811* 3.4 Add "raw" option to row-alist for consistency. Fix library flags in setup script [Thanks to Felix]. Add {{COPY}} support. Remove {{multi-query}}.
Note: See TracChangeset for help on using the changeset viewer.