=encoding euc-jp =pod =head1 NAME =begin original DBD::SQLite - Self-contained RDBMS in a DBI Driver =end original DBD::SQLite - DBI ¥É¥é¥¤¥Ð¤Ç¤Î¼«¸Ê´°·ë·¿(Self Contained)RDBMS (ÌõÃí: (TBR)¤¬¤Ä¤¤¤Æ¤¤¤ëÃÊÍî¤Ï¡Ö¤ß¤ó¤Ê¤Î¼«Æ°ËÝÌõ¡÷TexTra¡×¤Ë¤è¤ë µ¡³£ËÝÌõ¤Ç¤¹¡£) =head1 SYNOPSIS use DBI; my $dbh = DBI->connect("dbi:SQLite:dbname=$dbfile","",""); =head1 DESCRIPTION =begin original SQLite is a public domain file-based relational database engine that you can find at L. =end original SQLite ¤Ï¡¢¥Ñ¥Ö¥ê¥Ã¥¯¥É¥á¥¤¥ó¤Î¥Õ¥¡¥¤¥ë¥Ù¡¼¥¹¤Î´Ø·¸¥Ç¡¼¥¿¥Ù¡¼¥¹¥¨¥ó¥¸¥ó¤Ç¡¢ ¤³¤Î URL ¤Ç¸«¤Ä¤±¤ë¤³¤È¤¬½ÐÍè¤Þ¤¹: L =begin original B is a Perl DBI driver for SQLite, that includes the entire thing in the distribution. So in order to get a fast transaction capable RDBMS working for your perl project you simply have to install this module, and B else. =end original B ¤Ï¡¢Á´¤Æ¤Î¤â¤Î¤ò¥Ç¥£¥¹¥È¥ê¥Ó¥å¡¼¥·¥ç¥ó¤Ë´Þ¤ó¤Ç¤¤¤ë¡¢ SQLite ¤Î¤¿¤á¤Î Perl DBI ¥É¥é¥¤¥Ð¤Ç¤¹¡£ ¤½¤Î¤¿¤á¤¢¤Ê¤¿¤Î perl ¥×¥í¥¸¥§¥¯¥È¤Î¤¿¤á¤Ë¡¢¹â®¤Î ¥È¥é¥ó¥¶¥¯¥·¥ç¥ó²Äǽ¤Ê RDBMS ¤òÆ°¤«¤¹¤¿¤á¤Ë¤Ï¡¢Ã±¤Ë¤³¤Î¥â¥¸¥å¡¼¥ë¤ò ¥¤¥ó¥¹¥È¡¼¥ë¤¹¤ë¤³¤È¤À¤±¤¬É¬ÍפǤ¹¡£ ¾¤Ë¤Ï B<²¿¤â¤¢¤ê¤Þ¤»¤ó>¡£ =begin original SQLite supports the following features: =end original SQLite¤Ï°Ê²¼¤Îµ¡Ç½¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Þ¤¹: =over 4 =item Implements a large subset of SQL92 (SQL92 ¤Î¥µ¥Ö¥»¥Ã¥È¤Î¿¤¯¤ò¼ÂÁõ) =begin original See L for details. =end original ¾ÜºÙ¤Ï L ¤ò¤´Í÷¤¯¤À¤µ¤¤¡£ =item A complete DB in a single disk file (ñ°ì¤Î¥Ç¥£¥¹¥¯¥Õ¥¡¥¤¥ë¤Ç¤Î´°Á´¤Ê DB) =begin original Everything for your database is stored in a single disk file, making it easier to move things around than with L. =end original ¤¢¤Ê¤¿¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¤Î¤¿¤á¤ÎÁ´¤Æ¤Ï°ì¤Ä¤Î¥Ç¥£¥¹¥¯¥Õ¥¡¥¤¥ë¤Ë³ÊǼ¤µ¤ì¤Þ¤¹¡£ ¤³¤ì¤Ë¤è¤ê L ¤è¤ê¤â´Êñ¤ËÆ°¤«¤¹¤³¤È¤¬½ÐÍè¤Þ¤¹¡£ =item Atomic commit and rollback (¥¢¥È¥ß¥Ã¥¯¤Ê¥³¥ß¥Ã¥È¤È¥í¡¼¥ë¥Ð¥Ã¥¯) =begin original Yes, B is small and light, but it supports full transactions! =end original ¤½¤¦¤Ç¤¹¡¢B ¤Ï¾®¤µ¤¯¡¢·ÚÎ̤Ǥ¹¤¬¡¢ ´°Á´¤Ê¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò¥µ¥Ý¡¼¥È¤·¤Þ¤¹¡£ =item Extensible =begin original User-defined aggregate or regular functions can be registered with the SQL parser. =end original ¥æ¡¼¥¶¡¼ÄêµÁ¤Î½¸·×´Ø¿ô¤Þ¤¿¤Ïɸ½à´Ø¿ô¤Ï¡¢SQL¥Ñ¡¼¥µ¡¼¤ËÅÐÏ¿¤Ç¤­¤Þ¤¹¡£ (TBR) =back =begin original There's lots more to it, so please refer to the docs on the SQLite web page, listed above, for SQL details. Also refer to L for details on how to use DBI itself. The API works like every DBI module does. However, currently many statement attributes are not implemented or are limited by the typeless nature of the SQLite database. =end original ¤³¤ì°Ê¾å¤Î¤â¤Î¤¬¤¢¤ê¤Þ¤¹¤¬¡¢ ¤½¤Î¤¿¤á SQL ¤Î¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï¡¢¾å¤Ëµó¤²¤¿ SQLite web ¥Ú¡¼¥¸¤Ë¤¢¤ë ¥É¥­¥å¥á¥ó¥È¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ ¤Þ¤¿¡¢DBI ¼«¿È¤Î»È¤¤Êý¤Ë´Ø¤¹¤ë¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï L ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ API ¤Ï¤Û¤Ü³Æ DBI ¥â¥¸¥å¡¼¥ë¤¬¤¹¤ë¤è¤¦¤Ëµ¡Ç½¤·¤Þ¤¹¡£ ¤·¤«¤·¡¢¸½ºß¤Î½ê¿¤¯¤Îʸ°À­¤Ï¡¢Ì¤¼ÂÁõ¤Ç¤¢¤Ã¤¿¤ê¡¢SQLite ¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ë¤Ï ·¿¤¬¤Ê¤¤¤È¤¤¤¦À­¼Á¤«¤éÀ©¸Â¤µ¤ì¤Æ¤¤¤Þ¤¹¡£ =head1 NOTABLE DIFFERENCES FROM OTHER DRIVERS =head2 Database Name Is A File Name =begin original SQLite creates a file per a database. You should pass the C of the database file (with or without a parent directory) in the DBI connection string (as a database C): =end original SQLite¤Ç¤Ï¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¤´¤È¤Ë¥Õ¥¡¥¤¥ë¤¬ºîÀ®¤µ¤ì¤Þ¤¹¡£ ¥Ç¡¼¥¿¥Ù¡¼¥¹¥Õ¥¡¥¤¥ë¤ÎC(¿Æ¥Ç¥£¥ì¥¯¥È¥ê¤Î̵ͭ¤Ë¤«¤«¤ï¤é¤º)¤òDBIÀܳʸ»úÎó¤Ë(¥Ç¡¼¥¿¥Ù¡¼¥¹C¤È¤·¤Æ)ÅϤ¹É¬Íפ¬¤¢¤ê¤Þ¤¹: (TBR) my $dbh = DBI->connect("dbi:SQLite:dbname=$dbfile","",""); =begin original The file is opened in read/write mode, and will be created if it does not exist yet. =end original ¥Õ¥¡¥¤¥ë¤ÏÆɤ߼è¤ê/½ñ¤­¹þ¤ß¥â¡¼¥É¤Ç³«¤«¤ì¡¢¤Þ¤À¸ºß¤·¤Ê¤¤¾ì¹ç¤ÏºîÀ®¤µ¤ì¤Þ¤¹¡£ (TBR) =begin original Although the database is stored in a single file, the directory containing the database file must be writable by SQLite because the library will create several temporary files there. =end original ¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ï1¤Ä¤Î¥Õ¥¡¥¤¥ë¤Ë³ÊǼ¤µ¤ì¤Þ¤¹¤¬¡¢¥é¥¤¥Ö¥é¥ê¤Ë¤è¤Ã¤ÆÊ£¿ô¤Î°ì»þ¥Õ¥¡¥¤¥ë¤¬ºîÀ®¤µ¤ì¤ë¤¿¤á¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¥Õ¥¡¥¤¥ë¤ò´Þ¤à¥Ç¥£¥ì¥¯¥È¥ê¤ÏSQLite¤Ë¤è¤Ã¤Æ½ñ¤­¹þ¤ß²Äǽ¤Ç¤¢¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ (TBR) =begin original If the filename C<$dbfile> is ":memory:", then a private, temporary in-memory database is created for the connection. This in-memory database will vanish when the database connection is closed. It is handy for your library tests. =end original ¥Õ¥¡¥¤¥ë̾C<$dbfile>¤¬":memory:"¤Î¾ì¹ç¡¢ÀܳÍѤ˥ץ饤¥Ù¡¼¥È¤Ê°ì»þŪ¤Ê¥á¥â¥ê¡¼Æâ¥Ç¡¼¥¿¥Ù¡¼¥¹¤¬ºîÀ®¤µ¤ì¤Þ¤¹¡£ ¤³¤Î¥á¥â¥ê¡¼Æâ¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ï¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹Àܳ¤¬ÊĤ¸¤é¤ì¤ë¤È¾Ãµî¤µ¤ì¤Þ¤¹¡£ ¤³¤ì¤Ï¥é¥¤¥Ö¥é¥ê¤Î¥Æ¥¹¥È¤ËÊØÍø¤Ç¤¹¡£ (TBR) =begin original Note that future versions of SQLite might make use of additional special filenames that begin with the ":" character. It is recommended that when a database filename actually does begin with a ":" character you should prefix the filename with a pathname such as "./" to avoid ambiguity. =end original SQLite¤Î¾­Íè¤Î¥Ð¡¼¥¸¥ç¥ó¤Ç¤Ï¡¢¡Ö:¡×ʸ»ú¤Ç»Ï¤Þ¤ëÄɲäÎÆüì¤Ê¥Õ¥¡¥¤¥ë̾¤¬»ÈÍѤµ¤ì¤ë²ÄǽÀ­¤¬¤¢¤ë¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ ¥Ç¡¼¥¿¥Ù¡¼¥¹¥Õ¥¡¥¤¥ë̾¤¬¼ÂºÝ¤Ë¡Ö:¡×ʸ»ú¤Ç»Ï¤Þ¤ë¾ì¹ç¤Ï¡¢¤¢¤¤¤Þ¤¤¤µ¤òÈò¤±¤ë¤¿¤á¤Ë¡¢¥Õ¥¡¥¤¥ë̾¤ÎÁ°¤Ë¡Ö./¡×¤Ê¤É¤Î¥Ñ¥¹Ì¾¤òÉÕ¤±¤ë¤³¤È¤ò¤ªÁ¦¤á¤·¤Þ¤¹¡£ (TBR) =begin original If the filename C<$dbfile> is an empty string, then a private, temporary on-disk database will be created. This private database will be automatically deleted as soon as the database connection is closed. =end original ¥Õ¥¡¥¤¥ë̾C<$dbfile>¤¬¶õ¤Îʸ»úÎó¤Î¾ì¹ç¡¢¥×¥é¥¤¥Ù¡¼¥È¤Ê°ì»þŪ¤Ê¥ª¥ó¥Ç¥£¥¹¥¯¥Ç¡¼¥¿¥Ù¡¼¥¹¤¬ºîÀ®¤µ¤ì¤Þ¤¹¡£ ¤³¤Î¥×¥é¥¤¥Ù¡¼¥È¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ï¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹Àܳ¤¬ÊĤ¸¤é¤ì¤ë¤È¤¹¤°¤Ë¼«Æ°Åª¤Ëºï½ü¤µ¤ì¤Þ¤¹¡£ (TBR) =head2 Accessing A Database With Other Tools =begin original To access the database from the command line, try using C which comes with the L module. Just type: =end original ¥³¥Þ¥ó¥É¥é¥¤¥ó¤«¤é¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ë¥¢¥¯¥»¥¹¤¹¤ë¤¿¤á¤Ë¤Ï¡¢L ¥â¥¸¥å¡¼¥ë¤Ë Æþ¤Ã¤Æ¤¤¤ë C ¤ò»î¤·¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£ °Ê²¼¤Î¤è¤¦¤Ë¥¿¥¤¥×¤·¤Æ: dbish dbi:SQLite:foo.db =begin original On the command line to access the file F. =end original ¥³¥Þ¥ó¥É¥é¥¤¥ó¤Ç¥Õ¥¡¥¤¥ë F ¤Ë¥¢¥¯¥»¥¹¤·¤Þ¤¹¡£ =begin original Alternatively you can install SQLite from the link above without conflicting with B and use the supplied C command line tool. =end original Âå¤ï¤ê¤È¤·¤Æ¡¢¾åµ­¤Î¥ê¥ó¥¯¤«¤é B ¤Ë¤Ö¤Ä¤«¤ë¤³¤È¤Ê¤¯ SQLite ¤ò ¥¤¥ó¥¹¥È¡¼¥ë¤·¡¢Ä󶡤µ¤ì¤ë C ¥³¥Þ¥ó¥É¥é¥¤¥ó¥Ä¡¼¥ë¤ò»È¤¦¤³¤È¤¬ ½ÐÍè¤Þ¤¹¡£ =head2 Blobs =begin original As of version 1.11, blobs should "just work" in SQLite as text columns. However this will cause the data to be treated as a string, so SQL statements such as length(x) will return the length of the column as a NUL terminated string, rather than the size of the blob in bytes. In order to store natively as a BLOB use the following code: =end original ¥Ð¡¼¥¸¥ç¥ó1.11¤Ç¤Ï¡¢blob¤ÏSQLite¤Ç¤Ï¥Æ¥­¥¹¥ÈÎó¤È¤·¤Æ¡ÖÆ°ºî¤¹¤ë¡×¤Ï¤º¤Ç¤¹¡£ ¤¿¤À¤·¡¢¤³¤ì¤Ë¤è¤ê¥Ç¡¼¥¿¤¬Ê¸»úÎó¤È¤·¤Æ°·¤ï¤ì¤ë¤¿¤á¡¢length(x)¤Ê¤É¤ÎSQLʸ¤Ï¡¢¥Ð¥¤¥Èñ°Ì¤Îblob¤Î¥µ¥¤¥º¤Ç¤Ï¤Ê¤¯¡¢NUL¤Ç½ªÎ»¤¹¤ëʸ»úÎó¤È¤·¤ÆÎó¤ÎŤµ¤òÊÖ¤·¤Þ¤¹¡£ BLOB¤È¤·¤Æ¥Í¥¤¥Æ¥£¥Ö¤Ë³ÊǼ¤¹¤ë¤Ë¤Ï¡¢¼¡¤Î¥³¡¼¥É¤ò»ÈÍѤ·¤Þ¤¹: (TBR) use DBI qw(:sql_types); my $dbh = DBI->connect("dbi:SQLite:dbfile","",""); my $blob = `cat foo.jpg`; my $sth = $dbh->prepare("INSERT INTO mytable VALUES (1, ?)"); $sth->bind_param(1, $blob, SQL_BLOB); $sth->execute(); =begin original And then retrieval just works: =end original ¤½¤·¤Æ¸¡º÷¤Ïµ¡Ç½¤·¤Þ¤¹ (TBR) $sth = $dbh->prepare("SELECT * FROM mytable WHERE id = 1"); $sth->execute(); my $row = $sth->fetch; my $blobo = $row->[1]; # now $blobo == $blob =head2 Functions And Bind Parameters =begin original As of this writing, a SQL that compares a return value of a function with a numeric bind value like this doesn't work as you might expect. =end original ¤³¤Îµ­»ö¤ò½ñ¤¤¤Æ¤¤¤ë»þÅÀ¤Ç¤Ï¡¢´Ø¿ô¤ÎÌá¤êÃͤò¿ôÃͥХ¤¥ó¥ÉÃͤÈÈæ³Ó¤¹¤ëSQL¤Ï¡¢´üÂÔ¤·¤¿¤è¤¦¤Ë¤ÏÆ°ºî¤·¤Þ¤»¤ó¡£ (TBR) my $sth = $dbh->prepare(q{ SELECT bar FROM foo GROUP BY bar HAVING count(*) > ?; }); $sth->execute(5); =begin original This is because DBD::SQLite assumes that all the bind values are text (and should be quoted) by default. Thus the above statement becomes like this while executing: =end original ¤³¤ì¤Ï¡¢DBD::SQLite¤Ç¤Ï¡¢¥Ç¥Õ¥©¥ë¥È¤Ç¤¹¤Ù¤Æ¤Î¥Ð¥¤¥ó¥ÉÃͤ¬¥Æ¥­¥¹¥È¤Ç¤¢¤ë(°úÍÑÉä¤Ç°Ï¤àɬÍפ¬¤¢¤ë)¤ÈÁÛÄꤵ¤ì¤Æ¤¤¤ë¤¿¤á¤Ç¤¹¡£ ¤½¤Î¤¿¤á¡¢¾åµ­¤Î¥¹¥Æ¡¼¥È¥á¥ó¥È¤ò¼Â¹Ô¤¹¤ë¤È¡¢¼¡¤Î¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£ (TBR) SELECT bar FROM foo GROUP BY bar HAVING count(*) > "5"; =begin original There are two workarounds for this. =end original ¤³¤ì¤Ë¤Ï¡¢2¤Ä¤Î²óÈòºö¤¬¤¢¤ê¤Þ¤¹¡£ (TBR) =over 4 =item Use bind_param() explicitly =begin original As shown above in the C section, you can always use C to tell the type of a bind value. =end original ¾åµ­¤ÎC¥»¥¯¥·¥ç¥ó¤Ç¼¨¤·¤¿¤è¤¦¤Ë¡¢C¤ò»ÈÍѤ·¤Æ¥Ð¥¤¥ó¥ÉÃͤΥ¿¥¤¥×¤ò»ØÄê¤Ç¤­¤Þ¤¹¡£ (TBR) use DBI qw(:sql_types); # Don't forget this my $sth = $dbh->prepare(q{ SELECT bar FROM foo GROUP BY bar HAVING count(*) > ?; }); $sth->bind_param(1, 5, SQL_INTEGER); $sth->execute(); =item Add zero to make it a number =begin original This is somewhat weird, but works anyway. =end original ¤³¤ì¤Ï¾¯¤·´ñ̯¤Ç¤¹¤¬¡¢¤È¤Ë¤«¤¯µ¡Ç½¤·¤Þ¤¹¡£ (TBR) my $sth = $dbh->prepare(q{ SELECT bar FROM foo GROUP BY bar HAVING count(*) > (? + 0); }); $sth->execute(5); =back =head2 Foreign Keys =begin original B =end original B<³Ð¸ç¤·¤í!¥ª¥ª¥«¥ßÀܶá!> (TBR) =begin original SQLite has started supporting foreign key constraints since 3.6.19 (released on Oct 14, 2009; bundled with DBD::SQLite 1.26_05). To be exact, SQLite has long been able to parse a schema with foreign keys, but the constraints has not been enforced. Now you can issue a pragma actually to enable this feature and enforce the constraints. =end original SQLite¤Ï3.6.19(2009ǯ10·î14Æü¤Ë¥ê¥ê¡¼¥¹¤µ¤ì¡¢DBD::SQLite 1.26_05¤Ë¥Ð¥ó¥É¥ë¤µ¤ì¤Æ¤¤¤ë)¤«¤é³°Éô¥­¡¼À©Ìó¤Î¥µ¥Ý¡¼¥È¤ò³«»Ï¤·¤¿¡£ Àµ³Î¤Ë¤Ï¡¢SQLite¤ÏŤ¤´Ö³°Éô¥­¡¼¤ò»ÈÍѤ·¤Æ¥¹¥­¡¼¥Þ¤ò²òÀϤ¹¤ë¤³¤È¤¬¤Ç¤­¤¿¤¬¡¢À©Ìó¤Ï¶¯À©¤µ¤ì¤Æ¤¤¤Ê¤«¤Ã¤¿¡£ ¤³¤ì¤Ç¡¢¥×¥é¥°¥Þ¤ò¼ÂºÝ¤Ëȯ¹Ô¤·¤Æ¤³¤Îµ¡Ç½¤òÍ­¸ú¤Ë¤·¡¢À©Ìó¤ò¶¯À©¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£ (TBR) =begin original To do this, issue the following pragma (see below), preferably as soon as you connect to a database and you're not in a transaction: =end original ¤³¤ì¤ò¹Ô¤¦¤Ë¤Ï¡¢¼¡¤Î¥×¥é¥°¥Þ(²¼µ­»²¾È)¤òȯ¹Ô¤·¤Þ¤¹¡£ ¥È¥é¥ó¥¶¥¯¥·¥ç¥óÃæ¤Ç¤Ï¤Ê¤¯¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¤ËÀܳ¤·¤¿Ä¾¸å¤Ëȯ¹Ô¤¹¤ë¤³¤È¤ò¤ª´«¤á¤·¤Þ¤¹¡£ (TBR) $dbh->do("PRAGMA foreign_keys = ON"); =begin original And you can explicitly disable the feature whenever you like by turning the pragma off: =end original ¤Þ¤¿¡¢¥×¥é¥°¥Þ¤ò¥ª¥Õ¤Ë¤¹¤ë¤³¤È¤Ç¡¢¤¤¤Ä¤Ç¤â¤³¤Îµ¡Ç½¤òÌÀ¼¨Åª¤Ë̵¸ú¤Ë¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ (TBR) $dbh->do("PRAGMA foreign_keys = OFF"); =begin original As of this writing, this feature is disabled by default by the sqlite team, and by us, to secure backward compatibility, as this feature may break your applications, and actually broke some for us. If you have used a schema with foreign key constraints but haven't cared them much and supposed they're always ignored for SQLite, be prepared, and B. It is very likely that the sqlite team will turn it default-on in the future, and we plan to do it NO LATER THAN they do so. =end original ¤³¤Îµ­»ö¤ò½ñ¤¤¤Æ¤¤¤ë»þÅÀ¤Ç¤Ï¡¢SQLite¥Á¡¼¥à¤È»ä¤¿¤Á¤Ï¡¢¸åÊý¸ß´¹À­¤ò³ÎÊݤ¹¤ë¤¿¤á¤Ë¡¢¤³¤Îµ¡Ç½¤ò¥Ç¥Õ¥©¥ë¥È¤Ç̵¸ú¤Ë¤·¤Æ¤¤¤Þ¤¹¡£ ¤³¤ì¤Ï¡¢¤³¤Îµ¡Ç½¤¬¤¢¤Ê¤¿¤Î¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤òÇ˲õ¤¹¤ë²ÄǽÀ­¤¬¤¢¤ê¡¢¼ÂºÝ¤Ë»ä¤¿¤Á¤Î¤¿¤á¤Ë¤¤¤¯¤Ä¤«Ç˲õ¤·¤¿¤«¤é¤Ç¤¹¡£ ³°Éô¥­¡¼¤ÎÀ©Ìó¤ò»ý¤Ä¥¹¥­¡¼¥Þ¤ò»ÈÍѤ·¤¿¤³¤È¤¬¤¢¤Ã¤Æ¤â¡¢¤½¤ì¤ò¤¢¤Þ¤êµ¤¤Ë¤·¤Æ¤ª¤é¤º¡¢SQLite¤Ç¤Ï¾ï¤Ë̵»ë¤µ¤ì¤ë¤ÈÁÛÄꤷ¤Æ¤¤¤ë¾ì¹ç¤Ï¡¢½àÈ÷¤·¤Æ¡¢B<³°Éô¥­¡¼¤Î¥µ¥Ý¡¼¥È¤¬¥Ç¥Õ¥©¥ë¥È¤ÇÍ­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤ë¾ì¹ç¤Ç¤â¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤¬Æ°ºî¤·Â³¤±¤ë¤³¤È¤òÊݾڤ¹¤ë¤¿¤á¤Ë¡¢¹­ÈϤʥƥ¹¥È¤ò¹Ô¤Ã¤Æ¤¯¤À¤µ¤¤>¡£ SQLite¥Á¡¼¥à¤¬¾­ÍèŪ¤Ë¥Ç¥Õ¥©¥ë¥È¤Ç¥ª¥ó¤Ë¤¹¤ë²ÄǽÀ­¤ÏÈó¾ï¤Ë¹â¤¯¡¢»ä¤¿¤Á¤ÏÈà¤é¤¬¤½¤¦¤¹¤ë¤Þ¤Ç¤Ë¤½¤ì¤ò¹Ô¤¦Í½Äê¤Ç¤¹¡£ (TBR) =begin original See L for details. =end original ¾ÜºÙ¤ÏL¤ò¤´Í÷¤¯¤À¤µ¤¤¡£ (TBR) =head2 Pragma =begin original SQLite has a set of "Pragma"s to modifiy its operation or to query for its internal data. These are specific to SQLite and are not likely to work with other DBD libraries, but you may find some of these are quite useful. DBD::SQLite actually sets some (like C) for you when you connect to a database. See L for details. =end original SQLite¤Ë¤Ï¡¢Áàºî¤òÊѹ¹¤·¤¿¤ê¡¢ÆâÉô¥Ç¡¼¥¿¤ò¾È²ñ¤·¤¿¤ê¤¹¤ë¤¿¤á¤Î¡Ö¥×¥é¥°¥Þ¡×¤Î¥»¥Ã¥È¤¬¤¢¤ê¤Þ¤¹¡£ ¤³¤ì¤é¤ÏSQLite¤Ë¸ÇÍ­¤Î¤â¤Î¤Ç¡¢Â¾¤ÎDBD¥é¥¤¥Ö¥é¥ê¤Ç¤ÏÆ°ºî¤·¤Ê¤¤¤è¤¦¤Ç¤¹¤¬¡¢¤³¤ì¤é¤Î¤¤¤¯¤Ä¤«¤ÏÈó¾ï¤ËÊØÍø¤Ç¤¹¡£ DBD::SQLite¤Ï¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¤ËÀܳ¤¹¤ë¤È¤­¤Ë¡¢¼ÂºÝ¤Ë¤¤¤¯¤Ä¤«(C¤Ê¤É)¤òÀßÄꤷ¤Þ¤¹¡£ ¾ÜºÙ¤ÏL¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ (TBR) =head2 Transactions =begin original DBI/DBD::SQLite's transactions may be a bit confusing. They behave differently according to the status of the C flag: =end original DBI/DBD::SQLite¤Î¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤Ï¾¯¤·º®Í𤷤Ƥ¤¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£ ¤³¤ì¤é¤Ï¡¢C¥Õ¥é¥°¤Î¥¹¥Æ¡¼¥¿¥¹¤Ë±þ¤¸¤ÆÆ°ºî¤¬°Û¤Ê¤ê¤Þ¤¹¡£ (TBR) =over 4 =item When the AutoCommit flag is on =begin original You're supposed to always use the auto-commit mode, except you explicitly begin a transaction, and when the transaction ended, you're supposed to go back to the auto-commit mode. To begin a transaction, call C method, or issue a C statement. To end it, call C methods, or issue the corresponding statements. =end original ¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤òÌÀ¼¨Åª¤Ë³«»Ï¤·¡¢¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤¬½ªÎ»¤·¤¿¤È¤­¤Ë¼«Æ°¥³¥ß¥Ã¥È¥â¡¼¥É¤ËÌá¤ë¾ì¹ç¤ò½ü¤­¡¢¾ï¤Ë¼«Æ°¥³¥ß¥Ã¥È¥â¡¼¥É¤ò»ÈÍѤ¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ ¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò³«»Ï¤¹¤ë¤Ë¤Ï¡¢C¥á¥½¥Ã¥É¤ò¥³¡¼¥ë¤¹¤ë¤«¡¢Cʸ¤òȯ¹Ô¤·¤Þ¤¹¡£ ¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò½ªÎ»¤¹¤ë¤Ë¤Ï¡¢C¥á¥½¥Ã¥É¤ò¥³¡¼¥ë¤¹¤ë¤«¡¢Âбþ¤¹¤ëʸ¤òȯ¹Ô¤·¤Þ¤¹¡£ (TBR) $dbh->{AutoCommit} = 1; $dbh->begin_work; # or $dbh->do('BEGIN TRANSACTION'); # $dbh->{AutoCommit} is turned off temporarily during a transaction; $dbh->commit; # or $dbh->do('COMMIT'); # $dbh->{AutoCommit} is turned on again; =item When the AutoCommit flag is off =begin original You're supposed to always use the transactinal mode, until you explicitly turn on the AutoCommit flag. You can explicitly issue a C statement (only when an actual transaction has not begun yet) but you're not allowed to call C method (if you don't issue a C, it will be issued internally). You can commit or roll it back freely. Another transaction will automatically begins if you execute another statement. =end original AutoCommit¥Õ¥é¥°¤òÌÀ¼¨Åª¤Ë¥ª¥ó¤Ë¤¹¤ë¤Þ¤Ç¤Ï¡¢¾ï¤Ëtransactinal¥â¡¼¥É¤ò»ÈÍѤ¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ Cʸ¤ÏÌÀ¼¨Åª¤Ëȯ¹Ô¤Ç¤­¤Þ¤¹¤¬(¼ÂºÝ¤Î¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤¬¤Þ¤À³«»Ï¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Î¤ß)¡¢C¥á¥½¥Ã¥É¤ò¥³¡¼¥ë¤¹¤ë¤³¤È¤Ï¤Ç¤­¤Þ¤»¤ó(C¤òȯ¹Ô¤·¤Ê¤¤¾ì¹ç¤Ï¡¢ÆâÉôŪ¤Ëȯ¹Ô¤µ¤ì¤Þ¤¹)¡£ ¥³¥ß¥Ã¥È¤Þ¤¿¤Ï¥í¡¼¥ë¥Ð¥Ã¥¯¤Ï¼«Í³¤Ë¼Â¹Ô¤Ç¤­¤Þ¤¹¡£ Ê̤Îʸ¤ò¼Â¹Ô¤¹¤ë¤È¡¢Ê̤Υȥé¥ó¥¶¥¯¥·¥ç¥ó¤¬¼«Æ°Åª¤Ë³«»Ï¤µ¤ì¤Þ¤¹¡£ (TBR) $dbh->{AutoCommit} = 0; # $dbh->do('BEGIN TRANSACTION') is not necessary, but possible ... $dbh->commit; # or $dbh->do('COMMIT'); # $dbh->{AutoCommit} stays intact; $dbh->{AutoCommit} = 1; # ends the transactional mode =back =begin original This C mode is independent from the autocommit mode of the internal SQLite library, which always begins by a C statement, and ends by a C or a . =end original ¤³¤ÎC¥â¡¼¥É¤Ï¡¢ÆâÉôSQLite¥é¥¤¥Ö¥é¥ê¤Î¥ª¡¼¥È¥³¥ß¥Ã¥È¥â¡¼¥É¤«¤éÆÈΩ¤·¤Æ¤¤¤Þ¤¹¡£ ¥ª¡¼¥È¥³¥ß¥Ã¥È¥â¡¼¥É¤Ï¾ï¤ËCʸ¤Ç»Ï¤Þ¤ê¡¢C¤Þ¤¿¤Ï¤Ç½ª¤ï¤ê¤Þ¤¹¡£ (TBR) =head2 Performance (À­Ç½) =begin original SQLite is fast, very fast. Matt processed my 72MB log file with it, inserting the data (400,000+ rows) by using transactions and only committing every 1000 rows (otherwise the insertion is quite slow), and then performing queries on the data. =end original SQLite ¤Ï¹â®¤Ç¤¹¡¢Èó¾ï¤Ë¹â®¤Ç¤¹¡£ Matt ¤Ï¡¢»ä¤Î 72MB ¤Î¥í¥°¥Õ¥¡¥¤¥ë¤ò¤½¤ì¤Ç½èÍý¤·¤Þ¤·¤¿¡£ ñ½ã¤Ë 1000 ¹ÔËè¤Ë¥³¥ß¥Ã¥È¤·¤Ê¤¬¤é(¤½¤¦¤Ç¤Ê¤±¤ì¤ÐÁÞÆþ¤¬¤È¤Æ¤âÃÙ¤¯¤Ê¤ê¤Þ¤¹)¡¢ ¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò»È¤Ã¤Æ¥Ç¡¼¥¿(400,000 °Ê¾å¤Î¹Ô)¤òÁÞÆþ¤·¡¢ ¤½¤Î¥Ç¡¼¥¿¤ËÌ䤤¹ç¤ï¤»¤ò¼Â¹Ô¤·¤Þ¤·¤¿¡£ =begin original Queries like count(*) and avg(bytes) took fractions of a second to return, but what surprised him most of all was: =end original count(*) ¤È avg(bytes) ¤Î¤è¤¦¤ÊÌ䤤¹ç¤ï¤»¤Ï¡¢¤¿¤Á¤Þ¤ÁÊ֤äƤ­¤Þ¤·¤¿¡£ ¤·¤«¤·²¿¤è¤êÈब¶Ã¤¤¤¿¤³¤È¤Ï: SELECT url, count(*) as count FROM access_log GROUP BY url ORDER BY count desc LIMIT 20 =begin original To discover the top 20 hit URLs on the site (L), and it returned within 2 seconds. He was seriously considering switching his log analysis code to use this little speed demon! =end original ¥µ¥¤¥È (L) ¤Ë¥Ò¥Ã¥È¤· ¤¿URL ¤Î¥È¥Ã¥× 20 ¤ò ¸«¤Ä¤±¤ë¤³¤È¤Ç¤·¤¿¡£ ¤³¤ì¤ò 2 ÉðÊÆâ¤ÇÊÖ¤·¤Þ¤·¤¿¡£ Èà¤Ï¿¿·õ¤Ë»ä¤Î¥í¥°²òÀÏ¥³¡¼¥É¤ò¡¢¤³¤Î¾®¤µ¤Ê ¥¹¥Ô¡¼¥É¤ÎËâʪ¤ò»È¤¦¤è¤¦¤ËÊѹ¹¤¹¤ë¤³¤È¤ò¹Í¤¨¤Æ¤¤¤Þ¤¹¡£ =begin original Oh yeah, and that was with no indexes on the table, on a 400MHz PIII. =end original ¤½¤¦¤½¤¦¡¢¥Æ¡¼¥Ö¥ë¤Ë¤Ï¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò¤Ä¤±¤Æ¤¤¤Þ¤»¤ó¤·¡¢400MHz PIII ¤Î¾å¤Ç¤¹¡£ =begin original For best performance be sure to tune your hdparm settings if you are using linux. Also you might want to set: =end original ¥Ñ¥Õ¥©¡¼¥Þ¥ó¥¹¤òºÇ¹â¤Ë¤¹¤ë¤¿¤á¤Ë¤Ï¡¢linux ¤ò»È¤Ã¤Æ¤¤¤ë¤Î¤Ç¤¢¤ì¤Ð¡¢ hdparam ¤Î¥»¥Ã¥Æ¥£¥ó¥°¤ò³Î¼Â¤Ë¥Á¥å¡¼¥ó¤·¤Æ¤¯¤À¤µ¤¤¡£ ¤Þ¤¿¤³¤Î¤è¤¦¤ËÀßÄꤷ¤¿¤¤¤«¤â¤·¤ì¤Þ¤»¤ó: PRAGMA default_synchronous = OFF =begin original Which will prevent sqlite from doing fsync's when writing (which slows down non-transactional writes significantly) at the expense of some peace of mind. Also try playing with the cache_size pragma. =end original ¤³¤ì¤Ï¡¢¤¤¤¯¤é¤«¤Î¿´ÇÛ¤òµ¾À·¤Ë¤¹¤ë¤³¤È¤Ç¡¢¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò»È¤ï¤Ê¤¤ ½ñ¹þ¤ß¤òÈó¾ï¤ËÃÙ¤¯¤·¤Æ¤·¤Þ¤¦ fsync ¤¬¤¹¤ë¤³¤È¤«¤é¡¢sqlite ¤òÊݸ¤Þ¤¹¡£ cache_size pragma ¤Ç¤â³Ú¤·¤ó¤Ç¤ß¤ë¤è¤¦¤Ë¤·¤Æ¤¯¤À¤µ¤¤¡£ =begin original The memory usage of SQLite can also be tuned using the cache_size pragma. =end original SQLite¤Î¥á¥â¥ê»ÈÍÑÎ̤ϡ¢cache_size¥×¥é¥°¥Þ¤ò»ÈÍѤ·¤ÆÄ´À°¤¹¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹¡£ (TBR) $dbh->do("PRAGMA cache_size = 800000"); =begin original The above will allocate 800M for DB cache; the default is 2M. Your sweet spot probably lies somewhere in between. =end original ¾åµ­¤ÏDB¥­¥ã¥Ã¥·¥å¤Ë800M¤ò³ä¤êÅö¤Æ¤Þ¤¹¡£ ¥Ç¥Õ¥©¥ë¥È¤Ï2M¤Ç¤¹¡£ ¤¢¤Ê¤¿¤Î¥¹¥¤¡¼¥È¥¹¥Ý¥Ã¥È¤Ï¤ª¤½¤é¤¯¤½¤Î´Ö¤Î¤É¤³¤«¤Ë¤¢¤ê¤Þ¤¹¡£ (TBR) =head1 DRIVER PRIVATE ATTRIBUTES =head2 Database Handle Attributes =over 4 =item sqlite_version =begin original Returns the version of the SQLite library which B is using, e.g., "2.8.0". Can only be read. =end original B¤¬»ÈÍѤ·¤Æ¤¤¤ëSQLite¥é¥¤¥Ö¥é¥ê¤Î¥Ð¡¼¥¸¥ç¥ó("2.8.0"¤Ê¤É)¤òÊÖ¤·¤Þ¤¹¡£ Æɤ߼è¤êÀìÍѤǤ¹¡£ (TBR) =item sqlite_unicode =begin original If set to a true value, B will turn the UTF-8 flag on for all text strings coming out of the database (this feature is currently disabled for perl < 5.8.5). For more details on the UTF-8 flag see L. The default is for the UTF-8 flag to be turned off. =end original true¤ËÀßÄꤹ¤ë¤È¡¢B¤Ï¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¤«¤é½ÐÎϤµ¤ì¤ë¤¹¤Ù¤Æ¤Î¥Æ¥­¥¹¥Èʸ»úÎó¤ËÂФ·¤ÆUTF-8¥Õ¥é¥°¤ò¥ª¥ó¤Ë¤·¤Þ¤¹(perl<5.8.5¤Ç¤Ï¡¢¤³¤Îµ¡Ç½¤Ï¸½ºß̵¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹)¡£ UTF-8¥Õ¥é¥°¤Î¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï¡¢L¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¢UTF-8¥Õ¥é¥°¤Ï¥ª¥Õ¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£ (TBR) =begin original Also note that due to some bizarreness in SQLite's type system (see L), if you want to retain blob-style behavior for B columns under C<< $dbh->{sqlite_unicode} = 1 >> (say, to store images in the database), you have to state so explicitly using the 3-argument form of L when doing updates: =end original ¤Þ¤¿¡¢SQLite¤Î·¿¥·¥¹¥Æ¥à(L¤ò»²¾È)¤Î¤¤¤¯¤Ä¤«¤Î´ñ̯¤µ¤Î¤¿¤á¤Ë¡¢C<< $dbh->{SQLite_unicode}=1>>¤Î²¼¤ÎBÎó¤Î¥Ö¥í¥Ö¥¹¥¿¥¤¥ë¤ÎÆ°ºî¤òÊÝ»ý¤·¤¿¤¤¾ì¹ç(¤¿¤È¤¨¤Ð¡¢¥¤¥á¡¼¥¸¤ò¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ë³ÊǼ¤¹¤ë¾ì¹ç)¡¢¹¹¿·¤ò¹Ô¤¦¤È¤­¤ËL¤Î3°ú¿ô·Á¼°¤ò»ÈÍѤ·¤ÆÌÀ¼¨Åª¤ËÀë¸À¤¹¤ëɬÍפ¬¤¢¤ë¤³¤È¤Ë¤âÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ (TBR) use DBI qw(:sql_types); $dbh->{sqlite_unicode} = 1; my $sth = $dbh->prepare("INSERT INTO mytable (blobcolumn) VALUES (?)"); # Binary_data will be stored as is. $sth->bind_param(1, $binary_data, SQL_BLOB); =begin original Defining the column type as C in the DDL is B sufficient. =end original DDL¤ÇÎ󥿥¤¥×¤òC¤È¤·¤ÆÄêµÁ¤¹¤ë¤³¤È¤Ï¡¢B¤Ç½½Ê¬¤Ç¤¹¡£ (TBR) =begin original This attribute was originally named as C, and renamed to C for integrity since version 1.26_06. Old C attribute is still accessible but will be deprecated in the near future. =end original ¤³¤Î°À­¤Ï¸µ¡¹C¤È¤¤¤¦Ì¾Á°¤Ç¤·¤¿¤¬¡¢¥Ð¡¼¥¸¥ç¥ó1.26_06¤«¤éÀ°¹çÀ­¤Î¤¿¤á¤ËC¤Ë̾Á°¤¬Êѹ¹¤µ¤ì¤Þ¤·¤¿¡£ ¸Å¤¤C°À­¤Ï¤Þ¤À¥¢¥¯¥»¥¹²Äǽ¤Ç¤¹¤¬¡¢¶á¤¤¾­ÍèÇѻߤµ¤ì¤ëͽÄê¤Ç¤¹¡£ (TBR) =back =head1 METHODS =head2 table_info $sth = $dbh->table_info(undef, $schema, $table, $type, \%attr); =begin original Returns all tables and schemas (databases) as specified in L. The schema and table arguments will do a C search. You can specify an ESCAPE character by including an 'Escape' attribute in \%attr. The C<$type> argument accepts a comma seperated list of the following types 'TABLE', 'VIEW', 'LOCAL TEMPORARY' and 'SYSTEM TABLE' (by default all are returned). Note that a statement handle is returned, and not a direct list of tables. =end original L¤Ç»ØÄꤵ¤ì¤¿¤¹¤Ù¤Æ¤Îɽ¤ª¤è¤Ó¥¹¥­¡¼¥Þ(¥Ç¡¼¥¿¥Ù¡¼¥¹)¤¬Ìᤵ¤ì¤Þ¤¹¡£ ¥¹¥­¡¼¥Þ¤ª¤è¤Óɽ¤Î°ú¿ô¤Ë¤è¤ê¡¢C¸¡º÷¤¬¼Â¹Ô¤µ¤ì¤Þ¤¹¡£ \%attr¤Ë'Escape'°À­¤ò´Þ¤á¤ë¤³¤È¤Ë¤è¤ê¡¢ESCAPEʸ»ú¤ò»ØÄê¤Ç¤­¤Þ¤¹¡£ C<$type>°ú¿ô¤Ë¤Ï¡¢'TABLE'¡¢'VIEW'¡¢'LOCAL TEMPORARY'¡¢¤ª¤è¤Ó'SYSTEM TABLE'¥¿¥¤¥×¤Î¥«¥ó¥Þ¶èÀÚ¤ê¥ê¥¹¥È¤ò»ØÄê¤Ç¤­¤Þ¤¹(¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¤¹¤Ù¤Æ¤¬Ìᤵ¤ì¤Þ¤¹)¡£ ɽ¤ÎľÀܥꥹ¥È¤Ç¤Ï¤Ê¤¯¡¢Ê¸¥Ï¥ó¥É¥ë¤¬Ìᤵ¤ì¤ë¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ (TBR) =begin original The following fields are returned: =end original ¼¡¤Î¥Õ¥£¡¼¥ë¥É¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ (TBR) =begin original B: Always NULL, as SQLite does not have the concept of catalogs. =end original B:SQLite¤Ë¤Ï¥«¥¿¥í¥°¤Î³µÇ°¤¬¤Ê¤¤¤¿¤á¡¢¾ï¤ËNULL¤Ç¤¹¡£ (TBR) =begin original B: The name of the schema (database) that the table or view is in. The default schema is 'main', temporary tables are in 'temp' and other databases will be in the name given when the database was attached. =end original B:ɽ¤Þ¤¿¤Ï¥Ó¥å¡¼¤¬Â¸ºß¤¹¤ë¥¹¥­¡¼¥Þ(¥Ç¡¼¥¿¥Ù¡¼¥¹)¤Î̾Á°¡£ ¥Ç¥Õ¥©¥ë¥È¤Î¥¹¥­¡¼¥Þ¤Ï'main'¡¢°ì»þɽ¤Ï'temp'¡¢¤½¤Î¾¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ï¥Ç¡¼¥¿¥Ù¡¼¥¹¤¬Àܳ¤µ¤ì¤¿¤È¤­¤Ë»ØÄꤵ¤ì¤¿Ì¾Á°¤Ë¤Ê¤ê¤Þ¤¹¡£ (TBR) =begin original B: The name of the table or view. =end original B:¥Æ¡¼¥Ö¥ë¤Þ¤¿¤Ï¥Ó¥å¡¼¤Î̾Á°¡£ (TBR) =begin original B: The type of object returned. Will be one of 'TABLE', 'VIEW', 'LOCAL TEMPORARY' or 'SYSTEM TABLE'. =end original B:Ìᤵ¤ì¤ë¥ª¥Ö¥¸¥§¥¯¥È¤Î¥¿¥¤¥×¡£ 'TABLE'¡¢'VIEW'¡¢'LOCAL TEMPORARY'¡¢¤Þ¤¿¤Ï'SYSTEM TABLE'¤Î¤¤¤º¤ì¤«¤Ç¤¹¡£ (TBR) =head1 DRIVER PRIVATE METHODS =begin original The following methods can be called via the func() method with a little tweak, but the use of func() method is now discouraged by the L author for various reasons (see DBI's document L for details). So, if you're using L >= 1.608, use these C methods. If you need to use an older L, you can call these like this: =end original ¼¡¤Î¥á¥½¥Ã¥É¤Ï¡¢¾¯¤·¤Ò¤Í¤ê¤ò²Ã¤¨¤Æfunc()¥á¥½¥Ã¥É¤ò²ð¤·¤Æ¸Æ¤Ó½Ð¤¹¤³¤È¤¬¤Ç¤­¤Þ¤¹¤¬¡¢L¤ÎºîÀ®¼Ô¤Ï¡¢¤µ¤Þ¤¶¤Þ¤ÊÍýͳ¤«¤éfunc()¥á¥½¥Ã¥É¤Î»ÈÍѤò¿ä¾©¤·¤Æ¤¤¤Þ¤»¤ó(¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï¡¢DBI¤Îʸ½ñL¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤)¡£ ¤·¤¿¤¬¤Ã¤Æ¡¢L>=1.608¤ò»ÈÍѤ·¤Æ¤¤¤ë¾ì¹ç¤Ï¡¢¤³¤ì¤é¤ÎC¥á¥½¥Ã¥É¤ò»ÈÍѤ·¤Þ¤¹¡£ ¸Å¤¤L¤ò»ÈÍѤ¹¤ëɬÍפ¬¤¢¤ë¾ì¹ç¤Ï¡¢¼¡¤Î¤è¤¦¤Ë¸Æ¤Ó½Ð¤¹¤³¤È¤¬¤Ç¤­¤Þ¤¹: (TBR) $dbh->func( ..., "(method name without sqlite_ prefix)" ); =head2 $dbh->sqlite_last_insert_rowid() =begin original This method returns the last inserted rowid. If you specify an INTEGER PRIMARY KEY as the first column in your table, that is the column that is returned. Otherwise, it is the hidden ROWID column. See the sqlite docs for details. =end original ¤³¤Î¥á¥½¥Ã¥É¤ÏºÇ¸å¤ËÁÞÆþ¤µ¤ì¤¿ rowid ¤òÊÖ¤·¤Þ¤¹¡£ ¤â¤· INTEGER PRIMARY KEY ¤ò¤¢¤Ê¤¿¤Î¥Æ¡¼¥Ö¥ë¤Ç¤ÎÀèƬ¥«¥é¥à¤È¤·¤Æ»ØÄꤹ¤ì¤Ð¡¢ ÊÖ¤µ¤ì¤ë¤Î¤Ï¤½¤Î¥«¥é¥à¤Ë¤Ê¤ê¤Þ¤¹¡£ ¤½¤¦¤Ç¤Ê¤±¤ì¤Ð¡¢¤½¤ì¤Ï±£¤µ¤ì¤¿ ROWID ¥«¥é¥à¤Ë¤Ê¤ê¤Þ¤¹¡£ ¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï sqlite ¥É¥­¥å¥á¥ó¥È¤ò¤´Í÷¤¯¤À¤µ¤¤¡£ =begin original Generally you should not be using this method. Use the L last_insert_id method instead. The usage of this is: =end original Ä̾¤³¤Î¥á¥½¥Ã¥É¤Ï»ÈÍѤ·¤Þ¤»¤ó¡£ ¤«¤ï¤ê¤ËLlast_insert_id¥á¥½¥Ã¥É¤ò»ÈÍѤ·¤Þ¤¹¡£ ¤³¤Î¥á¥½¥Ã¥É¤Î»ÈÍÑÊýË¡¤Ï¼¡¤Î¤È¤ª¤ê¤Ç¤¹: (TBR) $h->last_insert_id($catalog, $schema, $table_name, $field_name [, \%attr ]) =begin original Running C<$h-Elast_insert_id("","","","")> is the equivalent of running C<$dbh-Esqlite_last_insert_rowid()> directly. =end original C<$h-Elast_insert_id("","","","")>¤ò¼Â¹Ô¤¹¤ë¤³¤È¤Ï¡¢C<$dbh-Esqlite_last_insert_rowid()>¤òľÀܼ¹Ԥ¹¤ë¤³¤È¤ÈƱ¤¸¤Ç¤¹¡£ (TBR) =head2 $dbh->sqlite_busy_timeout() =begin original Retrieve the current busy timeout. =end original ¸½ºß¤Î¥Ó¥¸¡¼¥¿¥¤¥à¥¢¥¦¥È¤ò¼èÆÀ¤·¤Þ¤¹¡£ (TBR) =head2 $dbh->sqlite_busy_timeout( $ms ) =begin original Set the current busy timeout. The timeout is in milliseconds. =end original ¸½ºß¤Î¥Ó¥¸¡¼¥¿¥¤¥à¥¢¥¦¥È¤òÀßÄꤷ¤Þ¤¹¡£ ¥¿¥¤¥à¥¢¥¦¥È¤Ï¥ß¥êÉÃñ°Ì¤Ç¤¹¡£ (TBR) =head2 $dbh->sqlite_create_function( $name, $argc, $code_ref ) =begin original This method will register a new function which will be useable in an SQL query. The method's parameters are: =end original ¤³¤Î¥á¥½¥Ã¥É¤Ï¡¢SQL¥¯¥¨¥ê¤Ç»ÈÍѤǤ­¤ë¿·¤·¤¤´Ø¿ô¤òÅÐÏ¿¤·¤Þ¤¹¡£ ¥á¥½¥Ã¥É¤Î¥Ñ¥é¥á¡¼¥¿¤Ï¼¡¤Î¤È¤ª¤ê¤Ç¤¹¡£ (TBR) =over =item $name =begin original The name of the function. This is the name of the function as it will be used from SQL. =end original ´Ø¿ô¤Î̾Á°¡£ ¤³¤ì¤ÏSQL¤«¤é»ÈÍѤµ¤ì¤ë´Ø¿ô¤Î̾Á°¤Ç¤¹¡£ (TBR) =item $argc =begin original The number of arguments taken by the function. If this number is -1, the function can take any number of arguments. =end original ´Ø¿ô¤¬¼è¤ë°ú¿ô¤Î¿ô¡£ ¤³¤Î¿ô¤¬-1¤Î¾ì¹ç¡¢´Ø¿ô¤ÏǤ°Õ¤Î¿ô¤Î°ú¿ô¤ò¼è¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ (TBR) =item $code_ref =begin original This should be a reference to the function's implementation. =end original ¤³¤ì¤Ï¡¢´Ø¿ô¤Î¼ÂÁõ¤Ø¤Î»²¾È¤Ç¤¢¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ (TBR) =back =begin original For example, here is how to define a now() function which returns the current number of seconds since the epoch: =end original ¤¿¤È¤¨¤Ð¡¢¥¨¥Ý¥Ã¥¯¤«¤é¤Î¸½ºß¤ÎÉÿô¤òÊÖ¤¹now()´Ø¿ô¤òÄêµÁ¤¹¤ëÊýË¡¤ò¼¡¤Ë¼¨¤·¤Þ¤¹¡£ (TBR) $dbh->sqlite_create_function( 'now', 0, sub { return time } ); =begin original After this, it could be use from SQL as: =end original ¤³¤Î¸å¡¢SQL¤«¤é¼¡¤Î¤è¤¦¤Ë»ÈÍѤǤ­¤Þ¤¹¡£ (TBR) INSERT INTO mytable ( now() ); =head3 REGEXP function =begin original SQLite includes syntactic support for an infix operator 'REGEXP', but without any implementation. The C driver automatically registers an implementation that performs standard perl regular expression matching, using current locale. So for example you can search for words starting with an 'A' with a query like =end original SQLite¤Ë¤Ï¡¢¥¤¥ó¥Õ¥£¥Ã¥¯¥¹±é»»»Ò'REGEXP'¤Î¹½Ê¸¥µ¥Ý¡¼¥È¤¬´Þ¤Þ¤ì¤Æ¤¤¤Þ¤¹¤¬¡¢¼ÂÁõ¤Ï¤¢¤ê¤Þ¤»¤ó¡£ C¥É¥é¥¤¥Ð¤Ï¡¢¸½ºß¤Î¥í¥±¡¼¥ë¤ò»ÈÍѤ·¤Æ¡¢É¸½àŪ¤ÊperlÀµµ¬É½¸½¤Î¾È¹ç¤ò¼Â¹Ô¤¹¤ë¼ÂÁõ¤ò¼«Æ°Åª¤ËÅÐÏ¿¤·¤Þ¤¹¡£ ¤·¤¿¤¬¤Ã¤Æ¡¢¤¿¤È¤¨¤Ð¡¢¼¡¤Î¤è¤¦¤Ê¥¯¥¨¥ê¤ò»ÈÍѤ·¤Æ¡¢'A'¤Ç»Ï¤Þ¤ëñ¸ì¤ò¸¡º÷¤Ç¤­¤Þ¤¹¡£ (TBR) SELECT * from table WHERE column REGEXP '\bA\w+' =begin original If you want case-insensitive searching, use perl regex flags, like this : =end original Âçʸ»ú¤È¾®Ê¸»ú¤ò¶èÊ̤·¤Ê¤¤¸¡º÷¤¬É¬Íפʾì¹ç¤Ï¡¢¼¡¤Î¤è¤¦¤Ëperl regex¥Õ¥é¥°¤ò»ÈÍѤ·¤Þ¤¹¡£ (TBR) SELECT * from table WHERE column REGEXP '(?i:\bA\w+)' =begin original The default REGEXP implementation can be overriden through the C API described above. =end original ¥Ç¥Õ¥©¥ë¥È¤ÎREGEXP¼ÂÁõ¤Ï¡¢Á°½Ò¤ÎCAPI¤ò²ð¤·¤Æ¾å½ñ¤­¤Ç¤­¤Þ¤¹¡£ (TBR) =begin original Note that regexp matching will B use SQLite indices, but will iterate over all rows, so it could be quite costly in terms of performance. =end original Àµµ¬É½¸½¥Þ¥Ã¥Á¥ó¥°¤ÏSQLite¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò»ÈÍÑ<¤·¤Þ¤»¤ó>¤·¤Þ¤¹¤¬¡¢¤¹¤Ù¤Æ¤Î¹Ô¤ËÂФ·¤Æ·«¤êÊÖ¤µ¤ì¤ë¤¿¤á¡¢¥Ñ¥Õ¥©¡¼¥Þ¥ó¥¹¤ÎÅÀ¤ÇÈó¾ï¤Ë¥³¥¹¥È¤¬¤«¤«¤ë²ÄǽÀ­¤¬¤¢¤ë¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ (TBR) =head2 $dbh->sqlite_create_collation( $name, $code_ref ) =begin original This method manually registers a new function which will be useable in an SQL query as a COLLATE option for sorting. Such functions can also be registered automatically on demand: see section L below. =end original ¤³¤Î¥á¥½¥Ã¥É¤Ï¡¢SQL¥¯¥¨¥ê¡¼¤Ç¥½¡¼¥ÈÍѤÎCOLLATE¥ª¥×¥·¥ç¥ó¤È¤·¤Æ»ÈÍѤǤ­¤ë¿·¤·¤¤´Ø¿ô¤ò¼êÆ°¤ÇÅÐÏ¿¤·¤Þ¤¹¡£ ¤³¤Î¤è¤¦¤Ê´Ø¿ô¤Ï¡¢É¬Íפ˱þ¤¸¤Æ¼«Æ°Åª¤ËÅÐÏ¿¤¹¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹¡£ ¸å½Ò¤Î¥»¥¯¥·¥ç¥óL¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ (TBR) =begin original The method's parameters are: =end original ¤³¤Î¥á¥½¥Ã¥É¤Î¥Ñ¥é¥á¡¼¥¿¤Ï¼¡¤Î¤È¤ª¤ê¤Ç¤¹¡£ (TBR) =over =item $name =begin original The name of the function exposed to SQL. =end original SQL¤Ë¸ø³«¤µ¤ì¤Æ¤¤¤ë´Ø¿ô¤Î̾Á°¡£ (TBR) =item $code_ref =begin original Reference to the function's implementation. The driver will check that this is a proper sorting function. =end original ´Ø¿ô¤Î¼ÂÁõ¤Ø¤Î»²¾È¡£ ¥É¥é¥¤¥Ð¤Ï¡¢¤³¤ì¤¬Å¬Àڤʥ½¡¼¥È´Ø¿ô¤Ç¤¢¤ë¤³¤È¤ò³Îǧ¤·¤Þ¤¹¡£ (TBR) =back =head2 $dbh->sqlite_collation_needed( $code_ref ) =begin original This method manually registers a callback function that will be invoked whenever an undefined collation sequence is required from an SQL statement. The callback is invoked as =end original ¤³¤Î¥á¥½¥Ã¥É¤Ï¡¢SQLʸ¤«¤é̤ÄêµÁ¤Î¾È¹ç½ç½ø¤¬Í׵ᤵ¤ì¤ë¤¿¤Ó¤Ëµ¯Æ°¤µ¤ì¤ë¥³¡¼¥ë¥Ð¥Ã¥¯´Ø¿ô¤ò¼êÆ°¤ÇÅÐÏ¿¤·¤Þ¤¹¡£ ¥³¡¼¥ë¥Ð¥Ã¥¯¤Ï¼¡¤Î¤è¤¦¤Ëµ¯Æ°¤µ¤ì¤Þ¤¹¡£ (TBR) $code_ref->($dbh, $collation_name) =begin original and should register the desired collation using L. =end original L¤ò»ÈÍѤ·¤ÆÌÜŪ¤Î¾È¹ç¤òÅÐÏ¿¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ (TBR) =begin original An initial callback is already registered by C, so for most common cases it will be simpler to just add your collation sequences in the C<%DBD::SQLite::COLLATION> hash (see section L below). =end original ºÇ½é¤Î¥³¡¼¥ë¥Ð¥Ã¥¯¤Ï¤¹¤Ç¤ËC¤Ë¤è¤Ã¤ÆÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë¤¿¤á¡¢¤Û¤È¤ó¤É¤Î°ìÈÌŪ¤Ê¥±¡¼¥¹¤Ç¤Ï¡¢C<%DBD::SQLite::COLLATION>¥Ï¥Ã¥·¥å¤Ë¾È¹ç½ç½ø¤òÄɲ乤ëÊý¤¬´Êñ¤Ç¤¹(¸å½Ò¤Î¥»¥¯¥·¥ç¥óL¤ò»²¾È)¡£ (TBR) =head2 $dbh->sqlite_create_aggregate( $name, $argc, $pkg ) =begin original This method will register a new aggregate function which can then be used from SQL. The method's parameters are: =end original ¤³¤Î¥á¥½¥Ã¥É¤Ï¡¢SQL¤«¤é»ÈÍѤǤ­¤ë¿·¤·¤¤½¸·×´Ø¿ô¤òÅÐÏ¿¤·¤Þ¤¹¡£ ¥á¥½¥Ã¥É¤Î¥Ñ¥é¥á¡¼¥¿¤Ï¼¡¤Î¤È¤ª¤ê¤Ç¤¹¡£ (TBR) =over =item $name =begin original The name of the aggregate function, this is the name under which the function will be available from SQL. =end original ½¸Ìó´Ø¿ô¤Î̾Á°¡£ ¤³¤ì¤Ï¡¢SQL¤«¤é»ÈÍѤǤ­¤ë´Ø¿ô¤Î̾Á°¤Ç¤¹¡£ (TBR) =item $argc =begin original This is an integer which tells the SQL parser how many arguments the function takes. If that number is -1, the function can take any number of arguments. =end original ¤³¤ì¤Ï¡¢´Ø¿ô¤¬¼è¤ë°ú¿ô¤Î¿ô¤òSQL¥Ñ¡¼¥µ¡¼¤ËÅÁ¤¨¤ëÀ°¿ô¤Ç¤¹¡£ ¤½¤Î¿ô¤¬-1¤Î¾ì¹ç¡¢´Ø¿ô¤ÏǤ°Õ¤Î¿ô¤Î°ú¿ô¤ò¼è¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ (TBR) =item $pkg =begin original This is the package which implements the aggregator interface. =end original ¤³¤ì¤Ï¡¢¥¢¥°¥ê¥²¡¼¥¿¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤ò¼ÂÁõ¤¹¤ë¥Ñ¥Ã¥±¡¼¥¸¤Ç¤¹¡£ (TBR) =back =begin original The aggregator interface consists of defining three methods: =end original ¥¢¥°¥ê¥²¡¼¥¿¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤Ï¡¢¼¡¤Î3¤Ä¤Î¥á¥½¥Ã¥É¤ÎÄêµÁ¤Ç¹½À®¤µ¤ì¤Æ¤¤¤Þ¤¹¡£ (TBR) =over =item new() =begin original This method will be called once to create an object which should be used to aggregate the rows in a particular group. The step() and finalize() methods will be called upon the reference return by the method. =end original ¤³¤Î¥á¥½¥Ã¥É¤Ï¡¢ÆÃÄê¤Î¥°¥ë¡¼¥×Æâ¤Î¹Ô¤ò½¸·×¤¹¤ë¤¿¤á¤Ë»ÈÍѤ¹¤ë¥ª¥Ö¥¸¥§¥¯¥È¤òºîÀ®¤¹¤ë¤¿¤á¤Ë1²ó¥³¡¼¥ë¤µ¤ì¤Þ¤¹¡£ step()¤ª¤è¤Ófinalize()¥á¥½¥Ã¥É¤Ï¡¢¥á¥½¥Ã¥É¤«¤é¤Î»²¾È¤¬ÊÖ¤µ¤ì¤¿¤È¤­¤Ë¥³¡¼¥ë¤µ¤ì¤Þ¤¹¡£ (TBR) =item step(@_) =begin original This method will be called once for each row in the aggregate. =end original ¤³¤Î¥á¥½¥Ã¥É¤Ï¡¢½¸Ìó¤Î³Æ¹Ô¤ËÂФ·¤Æ1²ó¤º¤Ä¸Æ¤Ó½Ð¤µ¤ì¤Þ¤¹¡£ (TBR) =item finalize() =begin original This method will be called once all rows in the aggregate were processed and it should return the aggregate function's result. When there is no rows in the aggregate, finalize() will be called right after new(). =end original ¤³¤Î¥á¥½¥Ã¥É¤Ï¡¢½¸·×¤Î¤¹¤Ù¤Æ¤Î¹Ô¤¬½èÍý¤µ¤ì¤ë¤È¸Æ¤Ó½Ð¤µ¤ì¡¢½¸·×´Ø¿ô¤Î·ë²Ì¤òÊÖ¤¹É¬Íפ¬¤¢¤ê¤Þ¤¹¡£ ½¸·×¤Ë¹Ô¤¬¤Ê¤¤¾ì¹ç¤Ï¡¢new()¤Îľ¸å¤Ëfinalize()¤¬¸Æ¤Ó½Ð¤µ¤ì¤Þ¤¹¡£ (TBR) =back =begin original Here is a simple aggregate function which returns the variance (example adapted from pysqlite): =end original ¼¡¤Ë¡¢Ê¬»¶¤òÊÖ¤¹Ã±½ã¤Ê½¸Ìó´Ø¿ô¤ò¼¨¤·¤Þ¤¹(pysqlite¤«¤éºÎÍѤµ¤ì¤¿Îã)¡£ (TBR) package variance; sub new { bless [], shift; } sub step { my ( $self, $value ) = @_; push @$self, $value; } sub finalize { my $self = $_[0]; my $n = @$self; # Variance is NULL unless there is more than one row return undef unless $n || $n == 1; my $mu = 0; foreach my $v ( @$self ) { $mu += $v; } $mu /= $n; my $sigma = 0; foreach my $v ( @$self ) { $sigma += ($x - $mu)**2; } $sigma = $sigma / ($n - 1); return $sigma; } $dbh->sqlite_create_aggregate( "variance", 1, 'variance' ); =begin original The aggregate function can then be used as: =end original ½¸Ìó´Ø¿ô¤Ï¡¢¼¡¤Î¤è¤¦¤Ë»ÈÍѤǤ­¤Þ¤¹¡£ (TBR) SELECT group_name, variance(score) FROM results GROUP BY group_name; =begin original For more examples, see the L. =end original ¤½¤Î¾¤ÎÎã¤Ë¤Ä¤¤¤Æ¤Ï¡¢L¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ (TBR) =head2 $dbh->sqlite_progress_handler( $n_opcodes, $code_ref ) =begin original This method registers a handler to be invoked periodically during long running calls to SQLite. =end original ¤³¤Î¥á¥½¥Ã¥É¤Ï¡¢Ä¹»þ´Ö¼Â¹Ô¤µ¤ì¤ëSQLite¤Î¸Æ¤Ó½Ð¤·Ãæ¤ËÄê´üŪ¤Ë¸Æ¤Ó½Ð¤µ¤ì¤ë¥Ï¥ó¥É¥é¤òÅÐÏ¿¤·¤Þ¤¹¡£ (TBR) =begin original An example use for this interface is to keep a GUI updated during a large query. The parameters are: =end original ¤³¤Î¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤Î»ÈÍÑÎã¤È¤·¤Æ¤Ï¡¢Â絬ÌϤʥ¯¥¨¥ê¡¼¤Î¼Â¹ÔÃæ¤ËGUI¤ò¹¹¿·¤·¤Æ¤ª¤¯¤³¤È¤¬µó¤²¤é¤ì¤Þ¤¹¡£ ¥Ñ¥é¥á¡¼¥¿¤Ï¼¡¤Î¤È¤ª¤ê¤Ç¤¹¡£ (TBR) =over =item $n_opcodes =begin original The progress handler is invoked once for every C<$n_opcodes> virtual machine opcodes in SQLite. =end original progress¥Ï¥ó¥É¥é¤Ï¡¢SQLite¤ÎC<$n_opcodes>²¾ÁÛ¥Þ¥·¥ó¤Î¥ª¥Ú¥³¡¼¥É¤´¤È¤Ë1²ó¸Æ¤Ó½Ð¤µ¤ì¤Þ¤¹¡£ (TBR) =item $code_ref =begin original Reference to the handler subroutine. If the progress handler returns non-zero, the SQLite operation is interrupted. This feature can be used to implement a "Cancel" button on a GUI dialog box. =end original ¥Ï¥ó¥É¥é¥µ¥Ö¥ë¡¼¥Á¥ó¤Ø¤Î»²¾È¡£ ¿Ê¹Ô¾õ¶·¥Ï¥ó¥É¥é¤¬¥¼¥í°Ê³°¤òÊÖ¤¹¾ì¹ç¡¢SQLiteÁàºî¤ÏÃæÃǤµ¤ì¤Þ¤¹¡£ ¤³¤Îµ¡Ç½¤ò»ÈÍѤ·¤Æ¡¢GUI¥À¥¤¥¢¥í¥°¥Ü¥Ã¥¯¥¹¤Ë¡Ö¥­¥ã¥ó¥»¥ë¡×¥Ü¥¿¥ó¤ò¼ÂÁõ¤Ç¤­¤Þ¤¹¡£ (TBR) =begin original Set this argument to C if you want to unregister a previous progress handler. =end original °ÊÁ°¤Î¿ÊĽ¥Ï¥ó¥É¥é¤ÎÅÐÏ¿¤ò²ò½ü¤¹¤ë¾ì¹ç¤Ï¡¢¤³¤Î°ú¿ô¤òC¤ËÀßÄꤷ¤Þ¤¹¡£ (TBR) =back =head2 $dbh->sqlite_commit_hook( $code_ref ) =begin original This method registers a callback function to be invoked whenever a transaction is committed. Any callback set by a previous call to C is overridden. A reference to the previous callback (if any) is returned. Registering an C disables the callback. =end original ¤³¤Î¥á¥½¥Ã¥É¤Ï¡¢¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤¬¥³¥ß¥Ã¥È¤µ¤ì¤ë¤¿¤Ó¤Ë¸Æ¤Ó½Ð¤µ¤ì¤ë¥³¡¼¥ë¥Ð¥Ã¥¯´Ø¿ô¤òÅÐÏ¿¤·¤Þ¤¹¡£ °ÊÁ°¤ÎC¤Î¸Æ¤Ó½Ð¤·¤Ë¤è¤Ã¤ÆÀßÄꤵ¤ì¤¿¥³¡¼¥ë¥Ð¥Ã¥¯¤Ï¤¹¤Ù¤Æ¾å½ñ¤­¤µ¤ì¤Þ¤¹¡£ °ÊÁ°¤Î¥³¡¼¥ë¥Ð¥Ã¥¯¤Ø¤Î»²¾È(¸ºß¤¹¤ë¾ì¹ç)¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ C¤òÅÐÏ¿¤¹¤ë¤È¡¢¥³¡¼¥ë¥Ð¥Ã¥¯¤¬Ìµ¸ú¤Ë¤Ê¤ê¤Þ¤¹¡£ (TBR) =begin original When the commit hook callback returns zero, the commit operation is allowed to continue normally. If the callback returns non-zero, then the commit is converted into a rollback (in that case, any attempt to I call C<< $dbh->rollback() >> afterwards would yield an error). =end original ¥³¥ß¥Ã¥È¥Õ¥Ã¥¯¥³¡¼¥ë¥Ð¥Ã¥¯¤¬¥¼¥í¤òÊÖ¤¹¤È¡¢¥³¥ß¥Ã¥ÈÁàºî¤ÏÀµ¾ï¤Ë³¹Ô¤Ç¤­¤Þ¤¹¡£ ¥³¡¼¥ë¥Ð¥Ã¥¯¤¬¥¼¥í°Ê³°¤òÊÖ¤¹¤È¡¢¥³¥ß¥Ã¥È¤Ï¥í¡¼¥ë¥Ð¥Ã¥¯¤ËÊÑ´¹¤µ¤ì¤Þ¤¹(¤½¤Î¾ì¹ç¡¢¸å¤ÇC<< $dbh->rollback()>>¤ò<ÌÀ¼¨Åª¤Ë>¸Æ¤Ó½Ð¤½¤¦¤È¤¹¤ë¤È¡¢¥¨¥é¡¼¤¬È¯À¸¤·¤Þ¤¹)¡£ (TBR) =head2 $dbh->sqlite_rollback_hook( $code_ref ) =begin original This method registers a callback function to be invoked whenever a transaction is rolled back. Any callback set by a previous call to C is overridden. A reference to the previous callback (if any) is returned. Registering an C disables the callback. =end original ¤³¤Î¥á¥½¥Ã¥É¤Ï¡¢¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤¬¥í¡¼¥ë¥Ð¥Ã¥¯¤µ¤ì¤ë¤¿¤Ó¤Ë¸Æ¤Ó½Ð¤µ¤ì¤ë¥³¡¼¥ë¥Ð¥Ã¥¯´Ø¿ô¤òÅÐÏ¿¤·¤Þ¤¹¡£ °ÊÁ°¤ÎC¤Î¸Æ¤Ó½Ð¤·¤Ë¤è¤Ã¤ÆÀßÄꤵ¤ì¤¿¥³¡¼¥ë¥Ð¥Ã¥¯¤Ï¤¹¤Ù¤Æ¾å½ñ¤­¤µ¤ì¤Þ¤¹¡£ °ÊÁ°¤Î¥³¡¼¥ë¥Ð¥Ã¥¯¤Ø¤Î»²¾È(¸ºß¤¹¤ë¾ì¹ç)¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ C¤òÅÐÏ¿¤¹¤ë¤È¡¢¥³¡¼¥ë¥Ð¥Ã¥¯¤¬Ìµ¸ú¤Ë¤Ê¤ê¤Þ¤¹¡£ (TBR) =head2 $dbh->sqlite_update_hook( $code_ref ) =begin original This method registers a callback function to be invoked whenever a row is updated, inserted or deleted. Any callback set by a previous call to C is overridden. A reference to the previous callback (if any) is returned. Registering an C disables the callback. =end original ¤³¤Î¥á¥½¥Ã¥É¤Ï¡¢¹Ô¤¬¹¹¿·¡¢ÁÞÆþ¡¢¤Þ¤¿¤Ïºï½ü¤µ¤ì¤ë¤¿¤Ó¤Ë¸Æ¤Ó½Ð¤µ¤ì¤ë¥³¡¼¥ë¥Ð¥Ã¥¯´Ø¿ô¤òÅÐÏ¿¤·¤Þ¤¹¡£ °ÊÁ°¤ÎC¤Î¸Æ¤Ó½Ð¤·¤Ë¤è¤Ã¤ÆÀßÄꤵ¤ì¤¿¥³¡¼¥ë¥Ð¥Ã¥¯¤Ï¤¹¤Ù¤Æ¾å½ñ¤­¤µ¤ì¤Þ¤¹¡£ °ÊÁ°¤Î¥³¡¼¥ë¥Ð¥Ã¥¯¤Ø¤Î»²¾È(¸ºß¤¹¤ë¾ì¹ç)¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ C¤òÅÐÏ¿¤¹¤ë¤È¡¢¥³¡¼¥ë¥Ð¥Ã¥¯¤¬Ìµ¸ú¤Ë¤Ê¤ê¤Þ¤¹¡£ (TBR) =begin original The callback will be called as =end original ¥³¡¼¥ë¥Ð¥Ã¥¯¤Ï¼¡¤Î¤è¤¦¤Ë¸Æ¤Ó½Ð¤µ¤ì¤Þ¤¹¡£ (TBR) $code_ref->($action_code, $database, $table, $rowid) =begin original where =end original ¤³¤³¤Ç (TBR) =over =item $action_code =begin original is an integer equal to either C, C or C (see L); =end original C¡¢C¡¢¤Þ¤¿¤ÏC(L¤ò»²¾È)¤Î¤¤¤º¤ì¤«¤ÈÅù¤·¤¤À°¿ô¤Ç¤¹¡£ (TBR) =item $database =begin original is the name of the database containing the affected row; =end original ¤Ï¡¢±Æ¶Á¤ò¼õ¤±¤ë¹Ô¤ò´Þ¤à¥Ç¡¼¥¿¥Ù¡¼¥¹¤Î̾Á°¤Ç¤¹¡£ (TBR) =item $table =begin original is the name of the table containing the affected row; =end original ¤Ï¡¢±Æ¶Á¤ò¼õ¤±¤ë¹Ô¤ò´Þ¤à¥Æ¡¼¥Ö¥ë¤Î̾Á°¤Ç¤¹¡£ (TBR) =item $rowid =begin original is the unique 64-bit signed integer key of the affected row within that table. =end original ¤Ï¡¢¤½¤Î¥Æ¡¼¥Ö¥ëÆâ¤Î±Æ¶Á¤ò¼õ¤±¤ë¥í¡¼¤Î°ì°Õ¤Î64¥Ó¥Ã¥ÈÉä¹æÉÕ¤­À°¿ô¥­¡¼¤Ç¤¹¡£ (TBR) =back =head2 $dbh->sqlite_set_authorizer( $code_ref ) =begin original This method registers an authorizer callback to be invoked whenever SQL statements are being compiled by the L method. The authorizer callback should return C to allow the action, C to disallow the specific action but allow the SQL statement to continue to be compiled, or C to cause the entire SQL statement to be rejected with an error. If the authorizer callback returns any other value, then then C call that triggered the authorizer will fail with an error message. =end original ¤³¤Î¥á¥½¥Ã¥É¤Ï¡¢L¥á¥½¥Ã¥É¤Ë¤è¤Ã¤ÆSQLʸ¤¬¥³¥ó¥Ñ¥¤¥ë¤µ¤ì¤ë¤¿¤Ó¤Ë¸Æ¤Ó½Ð¤µ¤ì¤ë¾µÇ§¼Ô¥³¡¼¥ë¥Ð¥Ã¥¯¤òÅÐÏ¿¤·¤Þ¤¹¡£ ¾µÇ§¼Ô¥³¡¼¥ë¥Ð¥Ã¥¯¤Ï¡¢¥¢¥¯¥·¥ç¥ó¤òµö²Ä¤¹¤ë¾ì¹ç¤ÏC¡¢ÆÃÄê¤Î¥¢¥¯¥·¥ç¥ó¤ò¶Ø»ß¤¹¤ë¤¬SQLʸ¤Î¥³¥ó¥Ñ¥¤¥ë¤ò³¹Ô¤¹¤ë¾ì¹ç¤ÏC¡¢¤Þ¤¿¤ÏSQLʸÁ´ÂΤò¥¨¥é¡¼¤ÇµñÈݤ¹¤ë¾ì¹ç¤ÏC¤òÊÖ¤¹É¬Íפ¬¤¢¤ê¤Þ¤¹¡£ ¾µÇ§¼Ô¥³¡¼¥ë¥Ð¥Ã¥¯¤¬¤½¤Î¾¤ÎÃͤòÊÖ¤¹¾ì¹ç¡¢¾µÇ§¼Ô¤ò¥È¥ê¥¬¡¼¤·¤¿C¸Æ¤Ó½Ð¤·¤Ï¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤Ç¼ºÇÔ¤·¤Þ¤¹¡£ (TBR) =begin original An authorizer is used when preparing SQL statements from an untrusted source, to ensure that the SQL statements do not try to access data they are not allowed to see, or that they do not try to execute malicious statements that damage the database. For example, an application may allow a user to enter arbitrary SQL queries for evaluation by a database. But the application does not want the user to be able to make arbitrary changes to the database. An authorizer could then be put in place while the user-entered SQL is being prepared that disallows everything except SELECT statements. =end original ¾µÇ§¼Ô¤Ï¡¢¿®Íê¤Ç¤­¤Ê¤¤¥½¡¼¥¹¤«¤éSQLʸ¤ò½àÈ÷¤¹¤ë¤È¤­¤Ë¡¢SQLʸ¤¬É½¼¨¤òµö²Ä¤µ¤ì¤Æ¤¤¤Ê¤¤¥Ç¡¼¥¿¤Ë¥¢¥¯¥»¥¹¤·¤è¤¦¤È¤·¤¿¤ê¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ë»³²¤òÍ¿¤¨¤ë°­°Õ¤Î¤¢¤ëʸ¤ò¼Â¹Ô¤·¤è¤¦¤È¤·¤¿¤ê¤·¤Ê¤¤¤è¤¦¤Ë¤¹¤ë¤¿¤á¤Ë»ÈÍѤµ¤ì¤Þ¤¹¡£ ¤¿¤È¤¨¤Ð¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç¤Ï¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ë¤è¤ëɾ²Á¤Î¤¿¤á¤Ë¥æ¡¼¥¶¡¼¤¬Ç¤°Õ¤ÎSQLÌä¹ç¤»¤òÆþÎϤǤ­¤ë¤è¤¦¤Ë¤¹¤ë¾ì¹ç¤¬¤¢¤ê¤Þ¤¹¡£ ¤¿¤À¤·¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç¤Ï¡¢¥æ¡¼¥¶¡¼¤¬¥Ç¡¼¥¿¥Ù¡¼¥¹¤ËǤ°Õ¤ÎÊѹ¹¤ò²Ã¤¨¤é¤ì¤Ê¤¤¤è¤¦¤Ë¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ ¾µÇ§¼Ô¤Ï¡¢SELECTʸ°Ê³°¤Î¤¹¤Ù¤Æ¤ò¶Ø»ß¤¹¤ë¥æ¡¼¥¶¡¼ÆþÎÏSQL¤¬½àÈ÷¤µ¤ì¤Æ¤¤¤ë´Ö¤ËÇÛÃ֤Ǥ­¤Þ¤¹¡£ (TBR) =begin original The callback will be called as =end original ¥³¡¼¥ë¥Ð¥Ã¥¯¤Ï¼¡¤Î¤è¤¦¤Ë¸Æ¤Ó½Ð¤µ¤ì¤Þ¤¹¡£ (TBR) $code_ref->($action_code, $string1, $string2, $database, $trigger_or_view) =begin original where =end original ¤³¤³¤Ç (TBR) =over =item $action_code =begin original is an integer that specifies what action is being authorized (see L). =end original ¤Ï¡¢µö²Ä¤µ¤ì¤Æ¤¤¤ë¥¢¥¯¥·¥ç¥ó¤ò»ØÄꤹ¤ëÀ°¿ô¤Ç¤¹(L¤ò»²¾È)¡£ (TBR) =item $string1, $string2 =begin original are strings that depend on the action code (see L). =end original ¤Ï¡¢¥¢¥¯¥·¥ç¥ó¥³¡¼¥É¤Ë°Í¸¤¹¤ëʸ»úÎó¤Ç¤¹(L¤ò»²¾È)¡£ (TBR) =item $database =begin original is the name of the database (C
, C, etc.) if applicable. =end original ¤Ï¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¤Î̾Á°¤Ç¤¹(C
¡¢C¤Ê¤É)¡£ (TBR) =item $trigger_or_view =begin original is the name of the inner-most trigger or view that is responsible for the access attempt, or C if this access attempt is directly from top-level SQL code. =end original ¤Ï¡¢¥¢¥¯¥»¥¹»î¹Ô¤Î¸¶°ø¤È¤Ê¤Ã¤¿ºÇ¤âÆ⦤Υȥꥬ¤Þ¤¿¤Ï¥Ó¥å¡¼¤Î̾Á°¤Ç¤¹¡£ ¥¢¥¯¥»¥¹»î¹Ô¤¬¥È¥Ã¥×¥ì¥Ù¥ë¤ÎSQL¥³¡¼¥É¤«¤éľÀܹԤï¤ì¤¿¾ì¹ç¤Ï¡¢C¤Ç¤¹¡£ (TBR) =back =head2 $dbh->sqlite_backup_from_file( $filename ) =begin original This method accesses the SQLite Online Backup API, and will take a backup of the named database file, copying it to, and overwriting, your current database connection. This can be particularly handy if your current connection is to the special :memory: database, and you wish to populate it from an existing DB. =end original ¤³¤Î¥á¥½¥Ã¥É¤ÏSQLite Online Backup API¤Ë¥¢¥¯¥»¥¹¤·¡¢»ØÄꤵ¤ì¤¿¥Ç¡¼¥¿¥Ù¡¼¥¹¥Õ¥¡¥¤¥ë¤Î¥Ð¥Ã¥¯¥¢¥Ã¥×¤ò¼èÆÀ¤·¡¢¸½ºß¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹Àܳ¤Ë¥³¥Ô¡¼¤·¤Æ¾å½ñ¤­¤·¤Þ¤¹¡£ ¤³¤ì¤Ï¡¢¸½ºß¤ÎÀܳ¤¬ÆÃÊ̤Ê:memory:¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ç¤¢¤ê¡¢´û¸¤ÎDB¤«¤é¥Ç¡¼¥¿¤òÆþÎϤ¹¤ë¾ì¹ç¤ËÆäËÊØÍø¤Ç¤¹¡£ (TBR) =head2 $dbh->sqlite_backup_to_file( $filename ) =begin original This method accesses the SQLite Online Backup API, and will take a backup of the currently connected database, and write it out to the named file. =end original ¤³¤Î¥á¥½¥Ã¥É¤ÏSQLite Online Backup API¤Ë¥¢¥¯¥»¥¹¤·¡¢¸½ºßÀܳ¤µ¤ì¤Æ¤¤¤ë¥Ç¡¼¥¿¥Ù¡¼¥¹¤Î¥Ð¥Ã¥¯¥¢¥Ã¥×¤ò¼èÆÀ¤·¤Æ¡¢»ØÄꤵ¤ì¤¿¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤¹¡£ (TBR) =head2 $dbh->sqlite_enable_load_extension( $bool ) =begin original Calling this method with a true value enables loading (external) sqlite3 extensions. After the call, you can load extensions like this: =end original trueÃͤò»ØÄꤷ¤Æ¤³¤Î¥á¥½¥Ã¥É¤ò¸Æ¤Ó½Ð¤¹¤È¡¢(³°Éô)sqlite3³ÈÄ¥µ¡Ç½¤òÆɤ߹þ¤à¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ ¸Æ¤Ó½Ð¤·¸å¡¢¼¡¤Î¤è¤¦¤Ë³ÈÄ¥µ¡Ç½¤òÆɤ߹þ¤à¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ (TBR) $dbh->sqlite_enable_load_extension(1); $sth = $dbh->prepare("select load_extension('libsqlitefunctions.so')") or die "Cannot prepare: " . $dbh->errstr(); =head1 DRIVER CONSTANTS =begin original A subset of SQLite C constants are made available to Perl, because they may be needed when writing hooks or authorizer callbacks. For accessing such constants, the C module must be explicitly Cd at compile time. For example, an authorizer that forbids any DELETE operation would be written as follows : =end original SQLite CÄê¿ô¤Î¥µ¥Ö¥»¥Ã¥È¤Ï¡¢Perl¤Ç»ÈÍѤǤ­¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£ ¤³¤ì¤Ï¡¢¥Õ¥Ã¥¯¤ä¾µÇ§¥³¡¼¥ë¥Ð¥Ã¥¯¤òºîÀ®¤¹¤ë¤È¤­¤ËɬÍפˤʤë²ÄǽÀ­¤¬¤¢¤ë¤¿¤á¤Ç¤¹¡£ ¤³¤Î¤è¤¦¤ÊÄê¿ô¤Ë¥¢¥¯¥»¥¹¤¹¤ë¤Ë¤Ï¡¢¥³¥ó¥Ñ¥¤¥ë»þ¤ËC¥â¥¸¥å¡¼¥ë¤òÌÀ¼¨Åª¤ËCd¤Ë¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ ¤¿¤È¤¨¤Ð¡¢DELETEÁàºî¤ò¶Ø»ß¤¹¤ë¾µÇ§¤Ï¡¢¼¡¤Î¤è¤¦¤Ëµ­½Ò¤µ¤ì¤Þ¤¹¡£ (TBR) use DBD::SQLite; $dbh->sqlite_set_authorizer(sub { my $action_code = shift; return $action_code == DBD::SQLite::DELETE ? DBD::SQLite::DENY : DBD::SQLite::OK; }); =begin original The list of constants implemented in C is given below; more information can be found ad at L. =end original C¤Ç¼ÂÁõ¤µ¤ì¤Æ¤¤¤ëÄê¿ô¤Î°ìÍ÷¤ò°Ê²¼¤Ë¼¨¤·¤Þ¤¹¡£ ¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï¡¢L¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ (TBR) =head2 Authorizer Return Codes OK DENY IGNORE =head2 Action Codes =begin original The L method registers a callback function that is invoked to authorize certain SQL statement actions. The first parameter to the callback is an integer code that specifies what action is being authorized. The second and third parameters to the callback are strings, the meaning of which varies according to the action code. Below is the list of action codes, together with their associated strings. =end original L¥á¥½¥Ã¥É¤Ï¡¢ÆÃÄê¤ÎSQLʸ¥¢¥¯¥·¥ç¥ó¤ò¾µÇ§¤¹¤ë¤¿¤á¤Ë¸Æ¤Ó½Ð¤µ¤ì¤ë¥³¡¼¥ë¥Ð¥Ã¥¯´Ø¿ô¤òÅÐÏ¿¤·¤Þ¤¹¡£ ¥³¡¼¥ë¥Ð¥Ã¥¯¤ÎºÇ½é¤Î¥Ñ¥é¥á¡¼¥¿¤Ï¡¢¾µÇ§¤µ¤ì¤ë¥¢¥¯¥·¥ç¥ó¤ò»ØÄꤹ¤ëÀ°¿ô¥³¡¼¥É¤Ç¤¹¡£ ¥³¡¼¥ë¥Ð¥Ã¥¯¤Î2ÈÖÌܤÈ3ÈÖÌܤΥѥé¥á¡¼¥¿¤Ïʸ»úÎó¤Ç¡¢¤½¤Î°ÕÌ£¤Ï¥¢¥¯¥·¥ç¥ó¥³¡¼¥É¤Ë¤è¤Ã¤Æ°Û¤Ê¤ê¤Þ¤¹¡£ ¼¡¤Ë¡¢¥¢¥¯¥·¥ç¥ó¥³¡¼¥É¤È¤½¤Î´ØϢʸ»úÎó¤Î¥ê¥¹¥È¤ò¼¨¤·¤Þ¤¹¡£ (TBR) # constant string1 string2 # ======== ======= ======= CREATE_INDEX Index Name Table Name CREATE_TABLE Table Name undef CREATE_TEMP_INDEX Index Name Table Name CREATE_TEMP_TABLE Table Name undef CREATE_TEMP_TRIGGER Trigger Name Table Name CREATE_TEMP_VIEW View Name undef CREATE_TRIGGER Trigger Name Table Name CREATE_VIEW View Name undef DELETE Table Name undef DROP_INDEX Index Name Table Name DROP_TABLE Table Name undef DROP_TEMP_INDEX Index Name Table Name DROP_TEMP_TABLE Table Name undef DROP_TEMP_TRIGGER Trigger Name Table Name DROP_TEMP_VIEW View Name undef DROP_TRIGGER Trigger Name Table Name DROP_VIEW View Name undef INSERT Table Name undef PRAGMA Pragma Name 1st arg or undef READ Table Name Column Name SELECT undef undef TRANSACTION Operation undef UPDATE Table Name Column Name ATTACH Filename undef DETACH Database Name undef ALTER_TABLE Database Name Table Name REINDEX Index Name undef ANALYZE Table Name undef CREATE_VTABLE Table Name Module Name DROP_VTABLE Table Name Module Name FUNCTION undef Function Name SAVEPOINT Operation Savepoint Name =head1 COLLATION FUNCTIONS =head2 Definition =begin original SQLite v3 provides the ability for users to supply arbitrary comparison functions, known as user-defined "collation sequences" or "collating functions", to be used for comparing two text values. L explains how collations are used in various SQL expressions. =end original SQLite v3¤Ï¡¢2¤Ä¤Î¥Æ¥­¥¹¥ÈÃͤòÈæ³Ó¤¹¤ë¤¿¤á¤Ë»ÈÍѤµ¤ì¤ë¡¢¥æ¡¼¥¶ÄêµÁ¤Î¡Ö¾È¹ç¥·¡¼¥±¥ó¥¹¡×¤Þ¤¿¤Ï¡Ö¾È¹ç´Ø¿ô¡×¤È¤·¤ÆÃΤé¤ì¤ëǤ°Õ¤ÎÈæ³Ó´Ø¿ô¤ò¥æ¡¼¥¶¤¬Ä󶡤¹¤ëµ¡Ç½¤òÄ󶡤·¤Þ¤¹¡£ L¤Ï¡¢¤µ¤Þ¤¶¤Þ¤ÊSQL¼°¤Ç¾È¹ç¤¬¤É¤Î¤è¤¦¤Ë»ÈÍѤµ¤ì¤ë¤«¤òÀâÌÀ¤·¤Æ¤¤¤Þ¤¹¡£ (TBR) =head2 Builtin collation sequences =begin original The following collation sequences are builtin within SQLite : =end original SQLite¤Ë¤Ï¡¢¼¡¤Î¾È¹ç½ç½ø¤¬ÁȤ߹þ¤Þ¤ì¤Æ¤¤¤Þ¤¹¡£ (TBR) =over =item B =begin original Compares string data using memcmp(), regardless of text encoding. =end original ¥Æ¥­¥¹¥È¤Î¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤Ë´Ø·¸¤Ê¤¯¡¢memcmp()¤ò»ÈÍѤ·¤Æʸ»úÎó¥Ç¡¼¥¿¤òÈæ³Ó¤·¤Þ¤¹¡£ (TBR) =item B =begin original The same as binary, except the 26 upper case characters of ASCII are folded to their lower case equivalents before the comparison is performed. Note that only ASCII characters are case folded. SQLite does not attempt to do full UTF case folding due to the size of the tables required. =end original ¥Ð¥¤¥Ê¥ê¤ÈƱ¤¸¤Ç¤¹¤¬¡¢Èæ³Ó¤¬¼Â¹Ô¤µ¤ì¤ëÁ°¤Ë¡¢ASCII¤Î26¸Ä¤ÎÂçʸ»ú¤¬Âбþ¤¹¤ë¾®Ê¸»ú¤ËÀޤꤿ¤¿¤Þ¤ì¤Þ¤¹¡£ ASCIIʸ»ú¤Î¤ßÂçʸ»ú¤È¾®Ê¸»ú¤¬Àޤꤿ¤¿¤Þ¤ì¤ë¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ SQLite¤Ç¤Ï¡¢É¬Íפʥơ¼¥Ö¥ë¤Î¥µ¥¤¥º¤Î¤¿¤á¤Ë¡¢UTF¤Î´°Á´¤ÊÂçʸ»ú¤È¾®Ê¸»ú¤ÎÀޤꤿ¤¿¤ß¤Ï¹Ô¤ï¤ì¤Þ¤»¤ó¡£ (TBR) =item B =begin original The same as binary, except that trailing space characters are ignored. =end original ¥Ð¥¤¥Ê¥ê¤ÈƱ¤¸¤Ç¤¹¤¬¡¢ËöÈø¤Î¥¹¥Ú¡¼¥¹Ê¸»ú¤Ï̵»ë¤µ¤ì¤Þ¤¹¡£ (TBR) =back =begin original In addition, C automatically installs the following collation sequences : =end original ¤µ¤é¤Ë¡¢C¤Ï¼¡¤Î¾È¹ç½ç¤ò¼«Æ°Åª¤Ë¥¤¥ó¥¹¥È¡¼¥ë¤·¤Þ¤¹¡£ (TBR) =over =item B =begin original corresponds to the Perl C operator =end original Perl C±é»»»Ò¤ËÂбþ¤·¤Þ¤¹¡£ (TBR) =item B =begin original Perl C operator, in a context where C is activated. =end original Perl C±é»»»Ò¡£ C¤¬¥¢¥¯¥Æ¥£¥Ö¤Ë¤Ê¤Ã¤Æ¤¤¤ë¥³¥ó¥Æ¥­¥¹¥È¤Ç»ÈÍѤ·¤Þ¤¹¡£ (TBR) =back =head2 Usage =begin original You can write for example =end original ¤¿¤È¤¨¤Ð¡¢¼¡¤Î¤è¤¦¤Ëµ­½Ò¤Ç¤­¤Þ¤¹¡£ (TBR) CREATE TABLE foo( txt1 COLLATE perl, txt2 COLLATE perllocale, txt3 COLLATE nocase ) =begin original or =end original ¤Þ¤¿¤Ï (TBR) SELECT * FROM foo ORDER BY name COLLATE perllocale =head2 Unicode handling =begin original If the attribute C<< $dbh->{sqlite_unicode} >> is set, strings coming from the database and passed to the collation function will be properly tagged with the utf8 flag; but this only works if the C attribute is set B the first call to a perl collation sequence . The recommended way to activate unicode is to set the parameter at connection time : =end original °À­C<< $dbh->{sqlite_unicode}>>¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¤«¤éÍè¤Æ¾È¹ç´Ø¿ô¤ËÅϤµ¤ì¤ëʸ»úÎó¤Ï¡¢utf8¥Õ¥é¥°¤ÇŬÀڤ˥¿¥°ÉÕ¤±¤µ¤ì¤Þ¤¹¡£ ¤·¤«¤·¡¢¤³¤ì¤Ïperl¾È¹ç¥·¡¼¥±¥ó¥¹¤ÎºÇ½é¤Î¸Æ¤Ó½Ð¤·¤Ç¡¢C°À­¤¬B¤ËÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Î¤ßÆ°ºî¤·¤Þ¤¹¡£ ¥æ¥Ë¥³¡¼¥É¤òÍ­¸ú¤Ë¤¹¤ë¤¿¤á¤Î¿ä¾©ÊýË¡¤Ï¡¢Àܳ»þ¤Ë¥Ñ¥é¥á¡¼¥¿¤òÀßÄꤹ¤ë¤³¤È¤Ç¤¹¡£ (TBR) my $dbh = DBI->connect( "dbi:SQLite:dbname=foo", "", "", { RaiseError => 1, sqlite_unicode => 1, } ); =head2 Adding user-defined collations =begin original The native SQLite API for adding user-defined collations is exposed through methods L and L. =end original ¥æ¡¼¥¶ÄêµÁ¤Î¾È¹ç¤òÄɲ乤뤿¤á¤Î¥Í¥¤¥Æ¥£¥ÖSQLite API¤Ï¡¢¥á¥½¥Ã¥ÉL¤ª¤è¤ÓL¤ò²ð¤·¤Æ¸ø³«¤µ¤ì¤Þ¤¹¡£ (TBR) =begin original To avoid calling these functions every time a C<$dbh> handle is created, C offers a simpler interface through the C<%DBD::SQLite::COLLATION> hash : just insert your own collation functions in that hash, and whenever an unknown collation name is encountered in SQL, the appropriate collation function will be loaded on demand from the hash. For example, here is a way to sort text values regardless of their accented characters : =end original C<$dbh>¥Ï¥ó¥É¥ë¤¬ºîÀ®¤µ¤ì¤ë¤¿¤Ó¤Ë¤³¤ì¤é¤Î´Ø¿ô¤ò¸Æ¤Ó½Ð¤¹¤³¤È¤òÈò¤±¤ë¤¿¤á¤Ë¡¢C¤ÏC<%DBD::SQLite::COLLATION>¥Ï¥Ã¥·¥å¤ò²ð¤·¤Æ¤è¤ê´Êñ¤Ê¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤òÄ󶡤·¤Þ¤¹¡£ ¤½¤Î¥Ï¥Ã¥·¥å¤ËÆȼ«¤Î¾È¹ç´Ø¿ô¤òÁÞÆþ¤¹¤ë¤À¤±¤Ç¡¢SQL¤ÇÉÔÌÀ¤Ê¾È¹ç̾¤¬¸¡½Ð¤µ¤ì¤ë¤¿¤Ó¤Ë¡¢Å¬Àڤʾȹç´Ø¿ô¤¬¥Ï¥Ã¥·¥å¤«¤é¥ª¥ó¥Ç¥Þ¥ó¥É¤Ç¥í¡¼¥É¤µ¤ì¤Þ¤¹¡£ ¤¿¤È¤¨¤Ð¡¢¥¢¥¯¥»¥ó¥Èµ­¹æÉÕ¤­Ê¸»ú¤Ë´Ø·¸¤Ê¤¯¥Æ¥­¥¹¥ÈÃͤò¥½¡¼¥È¤¹¤ëÊýË¡¤ò¼¡¤Ë¼¨¤·¤Þ¤¹¡£ (TBR) use DBD::SQLite; $DBD::SQLite::COLLATION{no_accents} = sub { my ( $a, $b ) = map lc, @_; tr[àâáäåãçðèêéëìîíïñòôóöõøùûúüý] [aaaaaacdeeeeiiiinoooooouuuuy] for $a, $b; $a cmp $b; }; my $dbh = DBI->connect("dbi:SQLite:dbname=dbfile"); my $sql = "SELECT ... FROM ... ORDER BY ... COLLATE no_accents"); my $rows = $dbh->selectall_arrayref($sql); =begin original The builtin C or C collations are predefined in that same hash. =end original ÁȤ߹þ¤ß¤ÎC¤Þ¤¿¤ÏC¾È¹ç¤Ï¡¢Æ±¤¸¥Ï¥Ã¥·¥å¤Ç»öÁ°¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£ (TBR) =begin original The COLLATION hash is a global registry within the current process; hence there is a risk of undesired side-effects. Therefore, to prevent action at distance, the hash is implemented as a "write-only" hash, that will happily accept new entries, but will raise an exception if any attempt is made to override or delete a existing entry (including the builtin C and C). =end original COLLATION¥Ï¥Ã¥·¥å¤Ï¡¢¸½ºß¤Î¥×¥í¥»¥¹Æâ¤Î¥°¥í¡¼¥Ð¥ë¥ì¥¸¥¹¥È¥ê¤Ç¤¢¤ë¤¿¤á¡¢Ë¾¤Þ¤·¤¯¤Ê¤¤ÉûºîÍѤΥꥹ¥¯¤¬¤¢¤ê¤Þ¤¹¡£ ¤·¤¿¤¬¤Ã¤Æ¡¢±óµ÷Î¥¤Ç¤Î¥¢¥¯¥·¥ç¥ó¤òËɤ°¤¿¤á¤Ë¡¢¥Ï¥Ã¥·¥å¤Ï¡Ö½ñ¤­¹þ¤ßÀìÍѡץϥå·¥å¤È¤·¤Æ¼ÂÁõ¤µ¤ì¡¢¿·¤·¤¤¥¨¥ó¥È¥ê¤ò¼õ¤±Æþ¤ì¤Þ¤¹¤¬¡¢´û¸¤Î¥¨¥ó¥È¥ê(ÁȤ߹þ¤ß¤ÎC¤ª¤è¤ÓC¤ò´Þ¤à)¤ò¾å½ñ¤­¤Þ¤¿¤Ïºï½ü¤·¤è¤¦¤È¤¹¤ë¤ÈÎã³°¤¬È¯À¸¤·¤Þ¤¹¡£ (TBR) =begin original If you really, really need to change or delete an entry, you can always grab the tied object underneath C<%DBD::SQLite::COLLATION> --- but don't do that unless you really know what you are doing. Also observe that changes in the global hash will not modify existing collations in existing database handles: it will only affect new I for collations. In other words, if you want to change the behaviour of a collation within an existing C<$dbh>, you need to call the L method directly. =end original ËÜÅö¤ËËÜÅö¤Ë¥¨¥ó¥È¥ê¤òÊѹ¹¤Þ¤¿¤Ïºï½ü¤¹¤ëɬÍפ¬¤¢¤ë¾ì¹ç¤Ï¡¢C<%DBD::SQLite::COLLATION>¤Î²¼¤Ë¤¢¤ë¥¿¥¤¥ª¥Ö¥¸¥§¥¯¥È¤ò¤¤¤Ä¤Ç¤â¼èÆÀ¤Ç¤­¤Þ¤¹¤¬¡¢¼«Ê¬¤¬²¿¤ò¤·¤Æ¤¤¤ë¤Î¤«¤òËÜÅö¤ËÃΤäƤ¤¤ë¾ì¹ç°Ê³°¤Ï¼èÆÀ¤·¤Ê¤¤¤Ç¤¯¤À¤µ¤¤¡£ ¤Þ¤¿¡¢¥°¥í¡¼¥Ð¥ë¥Ï¥Ã¥·¥å¤òÊѹ¹¤·¤Æ¤â¡¢´û¸¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ëÆâ¤Î´û¸¤Î¾È¹ç¤ÏÊѹ¹¤µ¤ì¤Þ¤»¤ó¡£ ¾È¹ç¤Î¿·¤·¤¤I¤Ë¤Î¤ß±Æ¶Á¤·¤Þ¤¹¡£ ¤Ä¤Þ¤ê¡¢´û¸¤ÎC<$dbh>Æâ¤Î¾È¹ç¤ÎÆ°ºî¤òÊѹ¹¤¹¤ë¾ì¹ç¤Ï¡¢L¥á¥½¥Ã¥É¤òľÀܸƤӽФ¹É¬Íפ¬¤¢¤ê¤Þ¤¹¡£ (TBR) =head1 TO DO =begin original The following items remain to be done. =end original ¼¡¤Î¹àÌܤò¼Â¹Ô¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ (TBR) =head2 Warnings Upgrade =begin original We currently use a horridly hacky method to issue and suppress warnings. It suffices for now, but just barely. =end original »ä¤¿¤Á¤Ï¸½ºß¡¢·Ù¹ð¤òȯ¤·¤ÆÍÞÀ©¤¹¤ë¤¿¤á¤Ë¡¢¤ª¤¾¤Þ¤·¤¤¤Û¤É¹ªÌ¯¤ÊÊýË¡¤ò»ÈÍѤ·¤Æ¤¤¤Þ¤¹¡£ º£¤Î¤È¤³¤í¤Ï¤½¤ì¤Ç½½Ê¬¤Ç¤¹¤¬¡¢¤«¤í¤¦¤¸¤Æ¤Ç¤¹¡£ (TBR) =begin original Migrate all of the warning code to use the recommended L warnings. =end original ¤¹¤Ù¤Æ¤Î·Ù¹ð¥³¡¼¥É¤ò°Ü¹Ô¤·¤Æ¡¢¿ä¾©¤µ¤ì¤ëL·Ù¹ð¤ò»ÈÍѤ·¤Þ¤¹¡£ (TBR) =head2 Leak Detection =begin original Implement one or more leak detection tests that only run during AUTOMATED_TESTING and RELEASE_TESTING and validate that none of the C code we work with leaks. =end original AUTOMATED_TESTING¤ª¤è¤ÓRELEASE_TESTINGÃæ¤Ë¤Î¤ß¼Â¹Ô¤µ¤ì¤ë¥ê¡¼¥¯¸¡½Ð¥Æ¥¹¥È¤ò1¤Ä°Ê¾å¼ÂÁõ¤·¡¢¥ê¡¼¥¯¤ò½èÍý¤¹¤ëC¥³¡¼¥É¤¬¤Ê¤¤¤³¤È¤ò¸¡¾Ú¤·¤Þ¤¹¡£ (TBR) =head2 Stream API for Blobs =begin original Reading/writing into blobs using C / C. =end original C/C¤ò»ÈÍѤ·¤¿BLOB¤ÎÆɤ߹þ¤ß/½ñ¤­¹þ¤ß¡£ (TBR) =head2 Flags for sqlite3_open_v2 =begin original Support the full API of sqlite3_open_v2 (flags for opening the file). =end original sqlite3_open_v2¤Î´°Á´¤ÊAPI(¥Õ¥¡¥¤¥ë¤ò³«¤¯¤¿¤á¤Î¥Õ¥é¥°)¤ò¥µ¥Ý¡¼¥È¤·¤Þ¤¹¡£ (TBR) =head1 SUPPORT =begin original Bugs should be reported via the CPAN bug tracker at =end original ¥Ð¥°¤Ï¡¢¼¡¤Î¾ì½ê¤Ë¤¢¤ëCPAN¥Ð¥°¥È¥é¥Ã¥«¤ò²ð¤·¤ÆÊó¹ð¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ (TBR) =begin original L =end original L (TBT) =begin original Note that bugs of bundled sqlite library (i.e. bugs in C) should be reported to the sqlite developers at sqlite.org via their bug tracker or via their mailing list. =end original ¥Ð¥ó¥É¥ë¤µ¤ì¤Æ¤¤¤ësqlite¥é¥¤¥Ö¥é¥ê¤Î¥Ð¥°(C¤Î¥Ð¥°¤Ê¤É)¤Ï¡¢sqlite.org¤Îsqlite³«È¯¼Ô¤Ë¥Ð¥°¥È¥é¥Ã¥«¡¼¤Þ¤¿¤Ï¥á¡¼¥ê¥ó¥°¥ê¥¹¥È¤òÄ̤¸¤ÆÊó¹ð¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ (TBR) =head1 AUTHORS =begin original Matt Sergeant Ematt@sergeant.orgE =end original Matt Sergeant Ematt@sergeant.orgE (TBT) =begin original Francis J. Lacoste Eflacoste@logreport.orgE =end original Francis J. Lacoste Eflacoste@logreport.orgE (TBT) =begin original Wolfgang Sourdeau Ewolfgang@logreport.orgE =end original Wolfgang Sourdeau Ewolfgang@logreport.orgE (TBT) =begin original Adam Kennedy Eadamk@cpan.orgE =end original Adam Kennedy Eadamk@cpan.orgE (TBT) =begin original Max Maischein Ecorion@cpan.orgE =end original Max Maischein Ecorion@cpan.orgE (TBT) =begin original Laurent Dami Edami@cpan.orgE =end original Laurent Dami Edami@cpan.orgE (TBT) =begin original Kenichi Ishigaki Eishigaki@cpan.orgE =end original Kenichi Ishigaki Eishigaki@cpan.orgE (TBT) =head1 COPYRIGHT =begin original The bundled SQLite code in this distribution is Public Domain. =end original The bundled SQLite code in this distribution is Public Domain. (TBT) =begin original DBD::SQLite is copyright 2002 - 2007 Matt Sergeant. =end original DBD::SQLite is copyright 2002 - 2007 Matt Sergeant. (TBT) =begin original Some parts copyright 2008 Francis J. Lacoste. =end original Some parts copyright 2008 Francis J. Lacoste. (TBT) =begin original Some parts copyright 2008 Wolfgang Sourdeau. =end original Some parts copyright 2008 Wolfgang Sourdeau. (TBT) =begin original Some parts copyright 2008 - 2010 Adam Kennedy. =end original Some parts copyright 2008 - 2010 Adam Kennedy. (TBT) =begin original Some parts derived from L copyright 2008 Audrey Tang. =end original Some parts derived from L copyright 2008 Audrey Tang. (TBT) =begin original This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =end original This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. (TBT) =begin original The full text of the license can be found in the LICENSE file included with this module. =end original The full text of the license can be found in the LICENSE file included with this module. (TBT) =cut =begin meta Translated: Àî¹ç¹§Åµ (0.19) Updated: SHIRAKATA Kentaro (1.29) Status: in progress =end meta