Documentation Source Text

Check-in [1582bada14]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add documentation for the zipfile() aggregate function.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:1582bada1476c3aa1dcdcacffdbf84890bdc5b50d7c86c6fd8643304ef540059
User & Date: dan 2018-01-29 18:38:50
Context
2018-01-30
17:06
Improved redirect handling in althttpd.c check-in: c4dcea55cd user: drh tags: trunk
2018-01-29
18:38
Add documentation for the zipfile() aggregate function. check-in: 1582bada14 user: dan tags: trunk
17:17
Fix an XSS problem in the search function on the website. check-in: 90f86ae4c5 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to pages/zipfile.in.

41
42
43
44
45
46
47












48
49
50
51
52
53
54
...
254
255
256
257
258
259
260
261









































<p> The first argument passed should be the database handle to register the
extension with. The second and third arguments should both be passed 0.

<p> Zipfile is included in most builds of the [command-line shell].

<h1>Using Zipfile</h1>













<p>The zipfile module provides two similar interfaces for accessing zip
archives. A table-valued function, which provides read-only access to
existing archives, and a virtual table interface, which provides both
read and write access.

<h2>Table-Valued Function (read-only access)</h2>
................................................................................
indicate that the entry is a directory or a file.

<p>It is an error to attempt to set the sz or rawdata field to any value
other than NULL. 

<p>The data and method columns may also be set as described for an INSERT
above.  
















































>
>
>
>
>
>
>
>
>
>
>
>







 








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
...
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313

<p> The first argument passed should be the database handle to register the
extension with. The second and third arguments should both be passed 0.

<p> Zipfile is included in most builds of the [command-line shell].

<h1>Using Zipfile</h1>

<p>The zipfile module provides three similar interfaces for accessing, updating
and creating zip file archives:

<ol>
  <li> A table-valued function, which provides read-only access to existing
       archives, either from the file-system or in-memory.
  <li> A virtual table, which provides read and write access to archives
       stored in the file-system.
  <li> An SQL aggregate function, which can be used to create new archives
       in memory.
</ol>

<p>The zipfile module provides two similar interfaces for accessing zip
archives. A table-valued function, which provides read-only access to
existing archives, and a virtual table interface, which provides both
read and write access.

<h2>Table-Valued Function (read-only access)</h2>
................................................................................
indicate that the entry is a directory or a file.

<p>It is an error to attempt to set the sz or rawdata field to any value
other than NULL. 

<p>The data and method columns may also be set as described for an INSERT
above.  

<h2> The zipfile() Aggregate Function </h2>

<p> New zip archives may be constructed entirely within memory using the
zipfile() aggregate function. Each row visited by the aggregate function
adds an entry to the zip archive. The value returned is a blob containing
the entire archive image.

<p> The zipfile() aggregate function may be called with 2, 4 or 5 
arguments. If it is called with 5 arguments, then the entry added to
the archive is equivalent to inserting the same values into the "name", 
"mode", "mtime", "data" and "method" columns of a zipfile virtual table.

<p> If zipfile() is invoked with 2 arguments, then the entry added to
the archive is equivalent to that added by inserting the same two values into
the "name" and "data" columns of a zipfile virtual table, with all
other values set to NULL. If invoked with 4 arguments, it is equivalent
to inserting the 4 values into the "name", "mode", "mtime" and "data"
columns. In other words, the following pairs of queries are equivalent:

<codeblock>
  SELECT zipfile(name, data) ...
  SELECT zipfile(name, NULL, NULL, data, NULL) ...

  SELECT zipfile(name, mode, mtime, data) ...
  SELECT zipfile(name, mode, mtime, data, NULL) ...
</codeblock>

<p> For example, to create an archive containing two text files, "a.txt" and
"b.txt", containing the text "abc" and "123" respectively:

<codeblock>
  WITH contents(name, data) AS (
    VALUES('a.txt', 'abc') UNION ALL
    VALUES('b.txt', '123')
  )
  SELECT zipfile(name, data) FROM contents;
</codeblock>