File: build_unix_sql.html

package info (click to toggle)
db5.3 5.3.28%2Bdfsg2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 158,500 kB
  • sloc: ansic: 448,411; java: 111,824; tcl: 80,544; sh: 44,264; cs: 33,697; cpp: 21,604; perl: 14,557; xml: 10,799; makefile: 4,077; javascript: 1,998; yacc: 1,003; awk: 965; sql: 801; erlang: 342; python: 216; php: 24; asm: 14
file content (703 lines) | stat: -rw-r--r-- 30,687 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Configuring the SQL Interface</title>
    <link rel="stylesheet" href="gettingStarted.css" type="text/css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
    <link rel="start" href="index.html" title="Berkeley DB Installation and Build Guide" />
    <link rel="up" href="build_unix.html" title="Chapter 7.  Building Berkeley DB for UNIX/POSIX" />
    <link rel="prev" href="build_unix_conf.html" title="Configuring Berkeley DB" />
    <link rel="next" href="build_unix_small.html" title="Building a small memory footprint library" />
  </head>
  <body>
    <div xmlns="" class="navheader">
      <div class="libver">
        <p>Library Version 11.2.5.3</p>
      </div>
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">Configuring the SQL Interface</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="build_unix_conf.html">Prev</a> </td>
          <th width="60%" align="center">Chapter 7. 
		Building Berkeley DB for UNIX/POSIX
        </th>
          <td width="20%" align="right"> <a accesskey="n" href="build_unix_small.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="sect1" lang="en" xml:lang="en">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title" style="clear: both"><a id="build_unix_sql"></a>Configuring the SQL Interface</h2>
          </div>
        </div>
      </div>
      <div class="toc">
        <dl>
          <dt>
            <span class="sect2">
              <a href="build_unix_sql.html#config_sql">Changing Compile Options</a>
            </span>
          </dt>
          <dt>
            <span class="sect2">
              <a href="build_unix_sql.html#idp500824">Enabling Extensions</a>
            </span>
          </dt>
          <dt>
            <span class="sect2">
              <a href="build_unix_sql.html#build_unix_jdbc">Building the JDBC Driver</a>
            </span>
          </dt>
          <dt>
            <span class="sect2">
              <a href="build_unix_sql.html#idp571856">Using the JDBC Driver</a>
            </span>
          </dt>
          <dt>
            <span class="sect2">
              <a href="build_unix_sql.html#idp593744">Building the ODBC Driver</a>
            </span>
          </dt>
          <dt>
            <span class="sect2">
              <a href="build_unix_sql.html#bfile">Building the BFILE extension</a>
            </span>
          </dt>
        </dl>
      </div>
      <p>
    There are a set of options you can provide to
    <span class="command"><strong>configure</strong></span> in order to control how the Berkeley DB
    SQL interface is built. These configuration options include: 
</p>
      <div class="variablelist">
        <dl>
          <dt>
            <span class="term">--disable-log-checksum</span>
          </dt>
          <dd>
            Disables checksums in log records.  This provides a boost to
            performance at the risk of log files having undetectable
            corruption that could prevent proper data recovery in case of
            database corruption.
        <p>
                Note that while this option is meant for use with the SQL
                interface, it will also disable checksum for the non-SQL
                interfaces.
            </p></dd>
          <dt>
            <span class="term">--enable-sql</span>
          </dt>
          <dd>
            Causes the <span class="command"><strong>dbsql</strong></span> command line interpreter to
            be built. Along with <span class="command"><strong>dbsql</strong></span>, this argument
            also builds the libdb_sqlXX.{so|la} library, a C API library
            that mirrors the SQLite C API.
        </dd>
          <dt>
            <span class="term">--enable-sql_compat</span>
          </dt>
          <dd>
            <p>
                Causes the <span class="command"><strong>sqlite3</strong></span> command line tool to
                be built. This tool is identical to the
                <span class="command"><strong>dbsql</strong></span> command line tool, except that it
                has the same name as the command line tool that comes with
                standard SQLite.
            </p>
            <p>
                In addition, the libsqlite3.{so|la} C API library is built
                if this option is specified. This library is identical to
                the libdb_sqlXX.{so|la} library that is normally built for Berkeley
                DB's sql interface, except that it has the same name as the
                library which is built for standard SQLite.
            </p>
            <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
              <h3 class="title">Warning</h3>
              <p>
                    Use this compatibility option with
                    <span class="emphasis"><em>extreme</em></span> care. Standard SQLite is
                    used by many programs and utilities on many different
                    platforms. Some platforms, such as Mac OS X, come with
                    standard SQLite built in because default applications for the
                    platform use that library. 
                </p>
              <p>
                    <span class="bold"><strong>Use of this option on platforms where standard SQLite
                    is in production use can cause unexpected runtime
                    errors either for your own application, or for 
                    applications and utilities commonly found on the
                    platform, depending on which library is found first
                    in the platform's library search path.</strong></span>
                </p>
              <p>
                    Use this option <span class="emphasis"><em>only</em></span> if you know
                    exactly what you are doing.
                </p>
            </div>
            <p>
                This option is provided so that there is an easy upgrade
                path for legacy SQLite tools and scripts that want to use
                BDB SQL without rewriting the tool or script. However,
                data contained in standard SQLite databases must be
                manually migrated from the old database to your BDB SQL
                database even if you use this option. See the 
                <em class="citetitle">Berkeley DB Getting Started with the SQL APIs</em> guide for information on 
                migrating data from standard SQLite to BDB SQL databases.
            </p>
            <p>
                Note that in addition to the renamed command line tool and
                library, this option also causes versions of the command
                line tool and library to be built that use the normal BDB
                SQLite names (<span class="command"><strong>dbsql</strong></span> and libdb_sqlXX.{so|la}).
            </p>
          </dd>
          <dt>
            <span class="term">--enable-test</span>
          </dt>
          <dd>
            Cause the Berkeley DB SQL interface test suite to be built.
            This argument can also be used with either
            <code class="literal">--enable-sql</code> or
            <code class="literal">--enable-sql_compat</code> to build the SQLite Tcl
            test runner. 
        </dd>
          <dt>
            <span class="term">--enable-jdbc</span>
          </dt>
          <dd>
            <p>
                Causes the JDBC driver to be built. Setting this option
                implies that <code class="literal">--enable-sql</code> is set, which
                means that the Berkeley DB SQL API will be built too.
            </p>
          </dd>
        </dl>
      </div>
      <p>
    The following configuration options are useful when debugging applications:
</p>
      <div class="variablelist">
        <dl>
          <dt>
            <span class="term">
            <a class="link" href="build_unix_conf.html#build_unix_conf.--enable-debug">--enable-debug</a>
        </span>
          </dt>
          <dd>
            Builds the Berkeley DB SQL interface with debug symbols.
        </dd>
          <dt>
            <span class="term">
            <a class="link" href="build_unix_conf.html#build_unix_conf.--enable-diagnostic">--enable-diagnostic</a>
        </span>
          </dt>
          <dd>
            Builds the Berkeley DB SQL interface with run-time debugging checks.
        </dd>
        </dl>
      </div>
      <p>
    Any arguments that you can provide to the standard SQLite configure
    script can also be supplied when configuring Berkeley DB SQL interface.
</p>
      <div class="sect2" lang="en" xml:lang="en">
        <div class="titlepage">
          <div>
            <div>
              <h3 class="title"><a id="config_sql"></a>Changing Compile Options</h3>
            </div>
          </div>
        </div>
        <p>There are several configuration options you can specify as an argument to the configure script using the standard environment variable, CFLAGS.</p>
        <div class="variablelist">
          <dl>
            <dt>
              <span class="term">BDBSQL_DEFAULT_PAGE_SIZE</span>
            </dt>
            <dd>
To set the default page size when you create a database, specify the BDBSQL_DEFAULT_PAGE_SIZE flag.
The value assigned must be a 0, 512, 1024, 2048, 4096, 8192 16384, 32768, or 65536. The default value is 4096.
If the value is set to zero, Berkeley DB queries the file system to determine the best page size, 
and the value of SQLITE_DEFAULT_PAGE_SIZE is used to calculate the cache size, as the cache size is specified as a number of pages.
</dd>
            <dt>
              <span class="term">BDBSQL_FILE_PER_TABLE</span>
            </dt>
            <dd>
To generate each table in a separate file, rather than as subdatabases in a single file, specify the BDBSQL_FILE_PER_TABLE flag. 
When this option is enabled, the SQL database name is used as a directory name. This directory contains one file for the metadata and one file each for every table created by the SQL API.
Note that adding or deleting files from the database directory may corrupt your database.
To backup the metadata (schema), make a copy of the <code class="literal">metadata</code> and <code class="literal">table00001</code> files from the database directory. 
Make a new copy whenever the schema is changed. 
</dd>
            <dt>
              <span class="term">BDBSQL_LOG_REGIONMAX</span>
            </dt>
            <dd>
To configure the log region size for the underlying storage engine, specify the BDBSQL_LOG_REGIONMAX flag. For more information, see 
<a href="../api_reference/C/envget_lg_regionmax.html" class="olink">DB_ENV-&gt;get_lg_regionmax()</a>.

</dd>
            <dt>
              <span class="term">BDBSQL_OMIT_LEAKCHECK
</span>
            </dt>
            <dd>For Berkeley DB to use the default system allocation routines rather than the SQLite allocation routines, specify the BDBSQL_OMIT_LEAKCHECK flag.
</dd>
            <dt>
              <span class="term">BDBSQL_OMIT_LOG_REMOVE
</span>
            </dt>
            <dd>Berkeley DB automatically removes log files that are not required any more, that is, files that are older than the most recent checkpoint. To disable this functionality, specify the BDBSQL_OMIT_LOG_REMOVE flag. It is necessary to provide this flag if you are using replication with Berkeley DB SQL.
</dd>
            <dt>
              <span class="term">BDBSQL_OMIT_SHARING
</span>
            </dt>
            <dd>To create a private environment rather than a shared environment, specify the BDBSQL_OMIT_SHARING flag. That is, the cache and other region files will be created in memory rather than using file backed shared memory. For more information, see the DB_PRIVATE flag of <a href="../api_reference/C/envopen.html" class="olink">DB_ENV-&gt;open()</a>. 
</dd>
            <dt>
              <span class="term">BDBSQL_SINGLE_THREAD
</span>
            </dt>
            <dd>To disable locking and thread safe connections, specify the BDBSQL_SINGLE_THREAD flag. If an application is going to use Berkeley DB from a single thread and a single process, enabling this flag can deliver significant performance advantages.
</dd>
            <dt>
              <span class="term">SQLITE_DEFAULT_CACHE_SIZE
</span>
            </dt>
            <dd>SQLite provides an in-memory cache which you size according to the maximum number of
			database pages that you want to hold in memory at any given time.
			Berkeley DB's in-memory cache feature performs the same function as SQLite. 
			To specify the suggested maximum number of pages of disk cache that will be allocated per open database file specify the SQLITE_DEFAULT_CACHE_SIZE flag. Default value is 2000 pages.
			For more information, see the SQLite documentation on <a class="ulink" href="http://www.sqlite.org/pragma.html#pragma_default_cache_size" target="_top">PRAGMA default_cache_size</a>.
</dd>
            <dt>
              <span class="term">SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT
</span>
            </dt>
            <dd>
For SQLite, this pragma identifies the maximum size that the journal file is allowed
to be. Berkeley DB does not have a journal file, but it writes and uses log files. A new log file is
created when the current log file has reached the defined maximum size.
To define this maximum size for a log file, specify the SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT flag. 
Default value is 10 MB for the Berkeley DB SQL interface.
</dd>
          </dl>
        </div>
      </div>
      <div class="sect2" lang="en" xml:lang="en">
        <div class="titlepage">
          <div>
            <div>
              <h3 class="title"><a id="idp500824"></a>Enabling Extensions</h3>
            </div>
          </div>
        </div>
        <p>
            The Berkeley DB SQL API provides extensions such as full text
            search and R-Tree index. By default, these extensions are
            disabled. To enable an extension in the Berkeley DB SQL interface,
            specify the related option as an argument to the configure script
            using the standard environment variable, CPPFLAGS. 
        </p>
        <p></p>
        <div class="variablelist">
          <dl>
            <dt>
              <span class="term">SQLITE_ENABLE_FTS3</span>
            </dt>
            <dd>
                    Enable building the Berkeley DB full text search layer
                </dd>
            <dt>
              <span class="term">SQLITE_ENABLE_RTREE</span>
            </dt>
            <dd>
                    Enables the Berkeley DB R-Tree layer.
                </dd>
          </dl>
        </div>
        <p> 
            See the SQLite Documentation for more information on 
            <a class="ulink" href="http://www.sqlite.org/fts3.html" target="_top">full text search</a>
            and <a class="ulink" href="http://www.sqlite.org/rtree.html" target="_top">R-Tree</a>.
        </p>
      </div>
      <div class="sect2" lang="en" xml:lang="en">
        <div class="titlepage">
          <div>
            <div>
              <h3 class="title"><a id="build_unix_jdbc"></a>Building the JDBC Driver</h3>
            </div>
          </div>
        </div>
        <p>
            This section describes how to build the JDBC driver code using
            <code class="literal">autoconf</code>, which is the only method supported and
            tested by the Berkeley DB team.
        </p>
        <p>
            To build the JDBC driver, you must have Sun Java Development Kit
            1.1 or above installed.
        </p>
        <pre class="programlisting">cd build_unix
    ../dist/configure --enable-jdbc --prefix=&lt;install path&gt;
    make install</pre>
        <p>
            You can test the build by entering the following commands from the
            <code class="literal">build_unix/jdbc</code> directory:
        </p>
        <table class="simplelist" border="0" summary="Simple list">
          <tr>
            <td>javac -classpath ./sqlite.jar test3.java</td>
          </tr>
          <tr>
            <td>java -Djava.library.path=./.libs -classpath ./sqlite.jar:. test3 </td>
          </tr>
        </table>
      </div>
      <div class="sect2" lang="en" xml:lang="en">
        <div class="titlepage">
          <div>
            <div>
              <h3 class="title"><a id="idp571856"></a>Using the JDBC Driver</h3>
            </div>
          </div>
        </div>
        <p>
            This section describes how to download, build, and run sample
            programs using the built JDBC driver.
        </p>
        <div class="sect3" lang="en" xml:lang="en">
          <div class="titlepage">
            <div>
              <div>
                <h4 class="title"><a id="idp572352"></a>Downloading JDBC Sample Code</h4>
              </div>
            </div>
          </div>
          <p>
                The download link for JDBC sample code is available on the
                <a class="ulink" href="http://www.oracle.com/technetwork/java/index-139949.html" target="_top">
                    Oracle Technology Network (OTN)
                </a> page.  You can identify the link by the "JDBC
                programming examples from all three editions (ZIP format)" text
                beside it.
            </p>
        </div>
        <div class="sect3" lang="en" xml:lang="en">
          <div class="titlepage">
            <div>
              <div>
                <h4 class="title"><a id="idp552800"></a>Modifying Sample Code</h4>
              </div>
            </div>
          </div>
          <p>
                Before running the example code, do the following:
            </p>
          <div class="orderedlist">
            <ol type="1">
              <li>
                    Unzip the file containing the sample code to a new
                    directory (for example, jdbc_ex).
                </li>
              <li>
                <p>
                        Substitute
                        <code class="literal">jdbc:sqlite:/&lt;db-file-name&gt;</code> for
                        the generic JDBC URL that appears in the code. That is, put
                        <code class="literal">jdbc:sqlite:/&lt;db-file-name&gt;</code>
                        between the quotation marks in the line:
                    </p>
                <p>
                        <code class="literal">String url = "jdbc:mySubprotocol:myDataSource";</code>
                    </p>
                <p>
                        Note: The &lt;db-file-name&gt; can either be an
                        absolute path name like
                        <code class="literal">"/jdbc_ex_db/myDataSource"</code>, or a
                        relative path-file-name like
                        <code class="literal">"../jdbc_ex_db/myDataSource"</code>, or a
                        file name, like <code class="literal">"myDataSource"</code>, in
                        which case the database file will be stored at the current
                        directory.</p>
              </li>
              <li>
                    Substitute <code class="literal">SQLite.JDBCDriver</code> for
                    <code class="literal">myDriver.ClassName</code> in the line:
                    <code class="literal">Class.forName("myDriver.ClassName");</code></li>
              <li>
                <p>
                        Optionally substitute the username and password you use for your
                        database in the following: 
                        <code class="literal">"myLogin", "myPassword"</code>. 
                    </p>
              </li>
              <li>
                    If your JDK version is above 1.5, change the variable name
                    <code class="literal">enum</code> in
                    <code class="literal">OutputApplet.java</code> to some other variable
                    name because, as of JDK release 5 <code class="literal">enum</code>
                    is a keyword and can not be used as an
                    identifier.
                </li>
            </ol>
          </div>
        </div>
        <div class="sect3" lang="en" xml:lang="en">
          <div class="titlepage">
            <div>
              <div>
                <h4 class="title"><a id="idp568208"></a>Building and Running the JDBC Sample code</h4>
              </div>
            </div>
          </div>
          <p>
                See 
                <a class="xref" href="build_unix_sql.html#build_unix_jdbc" title="Building the JDBC Driver">Building the JDBC Driver</a> 
                for instructions on building the JDBC driver.
            </p>
          <p>
                To build and run the JDBC examples do the following:
            </p>
          <div class="orderedlist">
            <ol type="1">
              <li>
                    Copy <code class="literal">build_unix/jdbc/sqlite.jar</code> and
                    <code class="literal">build_unix/jdbc/.libs/libsqlite_jni.so</code>
                    to the <code class="literal">jdbc_ex</code> directory.
                </li>
              <li>
                <p>
                        In the <code class="literal">jdbc_ex</code> directory, run the
                        following commands: 
                    </p>
                <pre class="programlisting">
    $ javac -classpath ./sqlite.jar *.java
    $ java -classpath .:sqlite.jar -Djava.library.path=. \
    &lt;ClassName, eg. CreateCoffees&gt;
    </pre>
              </li>
              <li>
                    After you run the CreateCoffees example, use the
                    <code class="literal">dbsql</code> executable to open the
                    <code class="literal">myDataSource</code> database file and check if
                    the table <code class="literal">COFFEES</code> has been successfully
                    created in the database.
    <pre class="programlisting">
    $ dbsql myDataSourcedbsql&gt; .tables
    COFFEES
    dbsql&gt; .dump
    PRAGMA foreign_keys=OFF;
    BEGIN TRANSACTION;
    CREATE TABLE COFFEES (COF_NAME varchar(32),\
    SUP_ID int, PRICE float, SALES int, TOTAL int);
    COMMIT;
    dbsql&gt;
    </pre></li>
              <li>
                <p>
                        Repeat step 3 to run other examples. 
                    </p>
                <p>
                        Note: Some examples, such as AutoGenKeys, are not yet
                        supported by BDB JDBC driver. The
                        <code class="literal">SQLFeatureNotSupportedException</code> is
                        displayed for those unsupported examples.
                    </p>
              </li>
            </ol>
          </div>
        </div>
      </div>
      <div class="sect2" lang="en" xml:lang="en">
        <div class="titlepage">
          <div>
            <div>
              <h3 class="title"><a id="idp593744"></a>Building the ODBC Driver</h3>
            </div>
          </div>
        </div>
        <p>
            This section describes how to build the ODBC driver.
        </p>
        <div class="sect3" lang="en" xml:lang="en">
          <div class="titlepage">
            <div>
              <div>
                <h4 class="title"><a id="idp587184"></a>Configuring Your System</h4>
              </div>
            </div>
          </div>
          <p>
                To configure your system prior to building the ODBC driver, do
                the following:
            </p>
          <div class="orderedlist">
            <ol type="1">
              <li>
                    Download and install the latest 
                    <a class="ulink" href="http://www.unixodbc.org" target="_top">unixODBC</a> 
                    if ODBC is not already installed on your system.
                </li>
              <li>
                    Configure the ODBC server to work with SQLite databases. Follow 
                    <a class="ulink" href="http://www.ch-werner.de/sqliteodbc/html/index.html" target="_top">these instructions</a> 
                    from Christian Werner.
                </li>
            </ol>
          </div>
        </div>
        <div class="sect3" lang="en" xml:lang="en">
          <div class="titlepage">
            <div>
              <div>
                <h4 class="title"><a id="idp598600"></a>Building the Library</h4>
              </div>
            </div>
          </div>
          <p>
                To build the library, do the following:
            </p>
          <pre class="programlisting">
    $ cd db-5.3.XX/build_unix
    $ CFLAGS="-fPIC" ../dist/configure --enable-sql_compat --disable-shared
    $ make
    $ cd ../lang/sql/odbc
    $ CFLAGS="-DHAVE_ERRNO_H -I../../../build_unix -I../../../src/dbinc \
             -I../sqlite/src" LDFLAGS="../../../build_unix/libdb-5.3.a" \ 
             ./configure --with-sqlite3=../generated
    $ make
    </pre>
          <p>
                The <code class="literal">libsqlite3odbc.so</code> library containing a
                statically linked version of Berkeley DB SQL is now
                built.
            </p>
          <p>
                NOTE: The final <code class="literal">make</code> command above is known
                to generate a warning when using GCC. The warning states:
                <code class="literal">Warning: Linking the shared library libsqlite3odbc.la
                    against the static library ../../build_unix/libdb-5.3.a is
                    not portable!</code>. It is generally safe to ignore the
                warning when using the generated library.
            </p>
        </div>
        <div class="sect3" lang="en" xml:lang="en">
          <div class="titlepage">
            <div>
              <div>
                <h4 class="title"><a id="idp600992"></a>Testing the ODBC Driver</h4>
              </div>
            </div>
          </div>
          <p>
                The steps to verify that the installed driver works are as follows:
            </p>
          <div class="orderedlist">
            <ol type="1">
              <li>
                    Alter the <code class="literal">/etc/odbcinst.ini</code> and
                    <code class="literal">~/.odbc.ini</code> configuration files to refer
                    to the libsqlite3odbc.so file built above.
                </li>
              <li>
                <p>
                        Create a data source, and launch a data source viewer
                        application by doing the following:
                    </p>
                <pre class="programlisting">$ mkdir ~/databases
    $ cd ~/databases
    $ /path/to/Berkeley DB/build_unix/sqlite3 mytest.db
    dbsql&gt; CREATE TABLE t1(x);
    dbsql&gt; .quit;
    $ DataManager </pre>
                <p>
                        The final step opens a GUI application that displays
                        ODBC data sources on a system. You should be able to
                        find the <code class="literal">mytest.db</code> data source just
                        created.
                    </p>
              </li>
            </ol>
          </div>
        </div>
      </div>
      <div class="sect2" lang="en" xml:lang="en">
        <div class="titlepage">
          <div>
            <div>
              <h3 class="title"><a id="bfile"></a>Building the BFILE extension</h3>
            </div>
          </div>
        </div>
        <p>
            The BFILE extension allows you to store binary files outside of
            the database, but still operate upon them as if they were
            stored within the database. To enable this extension, use the 
            <code class="literal">--enable-load-extension</code> configuration flag.
            For example:
        </p>
        <pre class="programlisting">$ cd &lt;db&gt;/build_unix
$ export DBSQL_DIR=$PWD/../install
$ ../dist/configure --enable-sql --enable-load-extension \
     --prefix=$DBSQL_DIR &amp;&amp; make &amp;&amp; make install
$ cd ../lang/sql/sqlite/ext/bfile/build
$ make &amp;&amp; make install</pre>
        <p>
            BFILE extensions are only supported for Unix platforms.
        </p>
        <p>
            Note that the extension support has two
            interfaces: SQL expressions and a C-functions API. By default, 
            the SQL expressions are built when you use
            <code class="literal">--enable-load_extension</code>. To use the
            C-functions API, edit <code class="literal">&lt;db&gt;/lang/sql/ext/bfile/build/Makefile</code>
            and set <code class="literal">ENABLE_BFILE_CAPI</code>
            to <code class="literal">1</code>.
        </p>
        <p>
            Once you have enabled the extension and built the library, you
            can run the included example:
        </p>
        <pre class="programlisting">$ cd lang/sql/sqlite/ext/bfile/build
$ export LD_LIBRARY_PATH=$PWD:$DBSQL_DIR/lib
$ ./bfile_example_sql     # for SQL expressions interface
$ ./bfile_example_capi    # for C-functions API</pre>
        <p>
            For more information on using the BFILE extension, see the 
            <em class="citetitle">Berkeley DB Getting Started with the SQL APIs</em> guide.
        </p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="build_unix_conf.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="build_unix.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="build_unix_small.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">Configuring Berkeley DB </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> Building a small memory footprint library</td>
        </tr>
      </table>
    </div>
  </body>
</html>