pax_global_header00006660000000000000000000000064144514613070014517gustar00rootroot0000000000000052 comment=fe24cb2464ee2f8cb4bf789740b99041b5701588 libdbd-cassandra-perl-0.57/000077500000000000000000000000001445146130700155675ustar00rootroot00000000000000libdbd-cassandra-perl-0.57/Changes000066400000000000000000000110651445146130700170650ustar00rootroot00000000000000Revision history for DBD-Cassandra 0.57 unreleased * Documentation and unit test changes * Deal with unhandled error while disconnecting a dbh during global destruction 0.56 2017/05/06 * Unbreak bind_param 0.55 2017/03/06 * Very basic TLS support 0.54 2017/01/30 * Require a newer version of Cassandra::Client 0.53 2016/10/25 * No more Perl 5.8 support -- 5.10 is now required * Fix a corner case where DBI didn't like the output of a 'LIST PERMISSIONS' with zero rows 0.52 2016/09/26 * Attempt to support older Perl versions, from 5.08 and up 0.51 2016/08/23 * Splits Cassandra-specific code into Cassandra::Client. DBD::Cassandra is now a wrapper providing a DBI interface 0.25 2016/03/17 * Fix encoding and decoding of floats and doubles. If you were using these prior to 0.25, please read the upgrade notice in the DBD::Cassandra pod. 0.24 2016/01/25 * Drop the Authen::SASL dependency, which was (sort of) incompatible with Cassandra's SASL 0.23 2015/10/13 * Revert a change from 0.21 (finishing handles earlier) which caused compat issues with DBD::mysql * Support for the map<..,..> data type 0.22 2015/10/08 * Fix an issue where an "insert into .. if not exists update .." would cause warnings * Add support for list<..> and set<..> data types 0.21 2015/09/17 * Finish the st handle slightly earlier: when we actually read the last row * Add a very basic readline-based plcqlsh implementation for machines without Java * Support for the 'counter' data type 0.20 2015/09/14 * Timeuuid/uuid support 0.19 2015/09/09 * Performance improvements 0.18 2015/09/07 * Fix an issue where executing more than 32767 queries may break the driver 0.17 2015/09/07 * Support for asynchronous queries * Drop 'retries' which was a bad idea 0.16 2015/09/03 * When running with "perl -l", the driver now actually works 0.15 2015/08/11 * Support for pagination through result sets * careful: Timestamps are now in msec accuracy instead of having them as floating points * Enable TCP keepalive on sockets 0.14 2015/05/19 * Resolve an old bug where connecting to CQL3 might cause compilation errors * Fix an issue where the consistency ONE was treated as LOCAL_ONE 0.13 2015/05/06 * Avoid uninitialized value warnings when the connection goes away * Fix an issue where data was corrupted during reading 0.12 2015/04/30 * Support for read/write/connect timeouts 0.11 2015/04/28 * Patch a DBI warning that occurs when we drop an implicitly disconnected handle * Allow automatically retrying in case of timeouts (opt-in) 0.10 2015/04/22 * Disable Nagle's algorithm, for a nice performance boost * Implement ping() to check whether we're still connected 0.09 2015/04/20 * Avoid double-encoding UTF-8 strings when passed in without the right flags * Automatically prune the prepare() cache to avoid memory leaks * Add support for the 'TIMESTAMP' type * Boolean types are now actually inserted as booleans 0.08 2015/04/17 * Avoid causing trouble when disconnecting an inactive handle * Cache any prepare()'d statement for 60 seconds * Don't consider a disconnected handle as active 0.07 2015/04/05 * Authentication support through Authen::SASL * Allow setting a default consistency level for all queries 0.06 2015/04/02 * Automatically utf8::decode VARCHAR/TEXT columns * Automatically pick the best compression and CQL version settings * Allow setting consistency levels on queries 0.05 2015/04/02 * Fix Makefile.PL to properly list the dependencies added in 0.04 0.04 2015/04/02 * Bugfix: refuse to connect if the keyspace doesn't exist * Refactor some network code * Compression support through Compress:LZ4 and Compress::Snappy * Allow selecting a CQL version for the connection 0.03 2015/04/01 * Add some documentation to the main module. Mostly for CPAN * Make keyspace an optional part of the connection's dsn * Add some new test cases for better coverage * Better error handling when the server misbehaves * Some performance improvements * Remove dependency on Protocol::CassandraCQL 0.02 2015/04/01 * Better utf8 support for queries (not result sets) 0.01 2015/03/31 * Needed something to reach Cassandra from Perl. Wrote something for it. libdbd-cassandra-perl-0.57/LICENSE000066400000000000000000000436771445146130700166150ustar00rootroot00000000000000This software is copyright (c) 2017 by Tom van der Woerdt. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2017 by Tom van der Woerdt. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2017 by Tom van der Woerdt. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End libdbd-cassandra-perl-0.57/MANIFEST000066400000000000000000000006721445146130700167250ustar00rootroot00000000000000# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.010. Changes LICENSE MANIFEST META.json META.yml Makefile.PL README dist.ini lib/DBD/Cassandra.pm lib/DBD/Cassandra/db.pm lib/DBD/Cassandra/dr.pm lib/DBD/Cassandra/st.pm t/00-load.t t/01-connect.t t/05-compress.t t/06-cql-version.t t/10-crud.t t/15-batch.t t/20-utf8.t t/30-types.t t/40-paging.t t/50-async.t t/60-bind.t t/60-hash.t t/author-pod-syntax.t weaver.ini libdbd-cassandra-perl-0.57/META.json000066400000000000000000000026131445146130700172120ustar00rootroot00000000000000{ "abstract" : "DBI database backend for Cassandra", "author" : [ "Tom van der Woerdt " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 6.010, CPAN::Meta::Converter version 2.150005", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "DBD-Cassandra", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "develop" : { "requires" : { "Test::Pod" : "1.41" } }, "runtime" : { "requires" : { "Cassandra::Client" : "0.10", "DBI" : "1.621", "Devel::GlobalDestruction" : "0", "perl" : "5.010", "strict" : "0", "warnings" : "0" } }, "test" : { "requires" : { "Ref::Util" : "0", "Test::More" : "0", "utf8" : "0" } } }, "release_status" : "stable", "resources" : { "repository" : { "type" : "git", "url" : "https://github.com/tvdw/perl-dbd-cassandra.git", "web" : "https://github.com/tvdw/perl-dbd-cassandra" } }, "version" : "0.57", "x_authority" : "cpan:TVDW", "x_serialization_backend" : "Cpanel::JSON::XS version 3.0213" } libdbd-cassandra-perl-0.57/META.yml000066400000000000000000000013301445146130700170350ustar00rootroot00000000000000--- abstract: 'DBI database backend for Cassandra' author: - 'Tom van der Woerdt ' build_requires: Ref::Util: '0' Test::More: '0' utf8: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 0 generated_by: 'Dist::Zilla version 6.010, CPAN::Meta::Converter version 2.150005' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: DBD-Cassandra requires: Cassandra::Client: '0.10' DBI: '1.621' Devel::GlobalDestruction: '0' perl: '5.010' strict: '0' warnings: '0' resources: repository: https://github.com/tvdw/perl-dbd-cassandra.git version: '0.57' x_authority: cpan:TVDW x_serialization_backend: 'YAML::Tiny version 1.69' libdbd-cassandra-perl-0.57/Makefile.PL000066400000000000000000000024571445146130700175510ustar00rootroot00000000000000# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.010. use strict; use warnings; use 5.010; use ExtUtils::MakeMaker; my %WriteMakefileArgs = ( "ABSTRACT" => "DBI database backend for Cassandra", "AUTHOR" => "Tom van der Woerdt ", "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => 0 }, "DISTNAME" => "DBD-Cassandra", "LICENSE" => "perl", "MIN_PERL_VERSION" => "5.010", "NAME" => "DBD::Cassandra", "PREREQ_PM" => { "Cassandra::Client" => "0.10", "DBI" => "1.621", "Devel::GlobalDestruction" => 0, "strict" => 0, "warnings" => 0 }, "TEST_REQUIRES" => { "Ref::Util" => 0, "Test::More" => 0, "utf8" => 0 }, "VERSION" => "0.57", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "Cassandra::Client" => "0.10", "DBI" => "1.621", "Devel::GlobalDestruction" => 0, "Ref::Util" => 0, "Test::More" => 0, "strict" => 0, "utf8" => 0, "warnings" => 0 ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); libdbd-cassandra-perl-0.57/README000066400000000000000000000005711445146130700164520ustar00rootroot00000000000000 This archive contains the distribution DBD-Cassandra, version 0.57: DBI database backend for Cassandra This software is copyright (c) 2017 by Tom van der Woerdt. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. This README file was generated by Dist::Zilla::Plugin::Readme v6.010. libdbd-cassandra-perl-0.57/dist.ini000066400000000000000000000007331445146130700172360ustar00rootroot00000000000000name = DBD-Cassandra author = Tom van der Woerdt license = Perl_5 copyright_holder = Tom van der Woerdt copyright_year = 2017 version = 0.57 [@Basic] [MetaJSON] [PkgVersion] [Authority] authority = cpan:TVDW [PodWeaver] [PodSyntaxTests] [MetaResources] repository.url = https://github.com/tvdw/perl-dbd-cassandra.git repository.web = https://github.com/tvdw/perl-dbd-cassandra repository.type = git [AutoPrereqs] libdbd-cassandra-perl-0.57/lib/000077500000000000000000000000001445146130700163355ustar00rootroot00000000000000libdbd-cassandra-perl-0.57/lib/DBD/000077500000000000000000000000001445146130700167265ustar00rootroot00000000000000libdbd-cassandra-perl-0.57/lib/DBD/Cassandra.pm000066400000000000000000000221451445146130700211670ustar00rootroot00000000000000package DBD::Cassandra; our $AUTHORITY = 'cpan:TVDW'; $DBD::Cassandra::VERSION = '0.57'; # ABSTRACT: DBI database backend for Cassandra use 5.010; use strict; use warnings; use DBI 1.621; use DBD::Cassandra::dr; use DBD::Cassandra::db; use DBD::Cassandra::st; our $drh= undef; sub driver { return $drh if $drh; DBD::Cassandra::st->install_method('x_finish_async'); DBD::Cassandra::db->install_method('x_wait_for_schema_agreement'); my ($class, $attr)= @_; $drh = DBI::_new_drh($class."::dr", { 'Name' => 'Cassandra', 'Version' => $DBD::Cassandra::VERSION, 'Attribution' => 'DBD::Cassandra by Tom van der Woerdt', }) or return undef; return $drh; } sub CLONE { undef $drh; } 1; __END__ =pod =head1 NAME DBD::Cassandra - DBI database backend for Cassandra =head1 VERSION version 0.57 =head1 DESCRIPTION B is a Perl5 Database Interface driver for Cassandra, using the CQL3 query language. =head1 EXAMPLE use DBI; my $dbh = DBI->connect("dbi:Cassandra:host=localhost;keyspace=test", $user, $password, { RaiseError => 1 }); my $rows = $dbh->selectall_arrayref("SELECT id, field_one, field_two FROM some_table"); for my $row (@$rows) { # Do something with your row } $dbh->do("INSERT INTO some_table (id, field_one, field_two) VALUES (?, ?, ?)", { Consistency => "quorum" }, 1, "String value", 38962986 ); $dbh->disconnect; =head2 Configuration =over =item Database handles use DBI; $dsn = "dbi:Cassandra:database=$database"; $dsn = "dbi:Cassandra:keyspace=$keyspace;host=$hostname;port=$port"; $dsn = "dbi:Cassandra:keyspace=$keyspace;consistency=local_quorum"; my $dbh = DBI->connect($dsn, $username, $password); =over =item keyspace =item database =item db Optionally, a keyspace to use by default. If this is not specified, all queries must include the keyspace name. =item hostname =item hosts Hostname to initially connect to. Defaults to C. Can be comma-separated to specify multiple hosts. =item port Port number to connect to. Defaults to C<9042> =item compression The compression method we should use for the connection. Currently Cassandra allows C and C. Defaults to the algorithm with the best compression ratio, if the server supports it. Compression can be disabled by setting C. Only used for data frames longer than 512 bytes, smaller frames get sent uncompressed. =item cql_version There are several versions of the CQL language and this option lets you pick one. Defaults to the highest available version. Consult your Cassandra manual to see which versions your database supports. =item consistency See the chapter on consistency levels =item request_timeout Maximum amount of time (in seconds) to wait for a Cassandra network operation to finish. =item read_timeout =item write_timeout B. These two are summed and used as C. =item tls Boolean (1|0); whether to use TLS. Defaults to off. =back =item Statement handles my $sth= $dbh->prepare('SELECT "id", "field1", "field2" FROM table_name WHERE id=?', { Consistency => 'one' }); =over =item async See "asynchronous queries". =item consistency See "consistency levels". =item per_page Cassandra supports pagination through result sets, to avoid having the entire result set in memory. my $sth = $dbh->prepare('SELECT id FROM tablename', { PerPage => 1000 }); $sth->execute; while (my $row = $sth->fetchrow_arrayref()) { print "$row->[0]\n"; } It is important to keep in mind that this mode can cause errors while fetching rows, as extra queries may be executed by the driver internally. =back =back =head1 COLLECTION TYPES Cassandra supports collection types natively, eg. C and C. B translates them to native Perl types, eg. hashes and arrays. When doing queries, placeholders can be substituted by these collections. For example, inserting a map into a table is done by passing a Perl hash. my $sth= $dbh->prepare('INSERT INTO some_table (id, value) VALUES (?,?);'); $sth->execute(5, { days => 15 }); This will also work for C queries, which accept an array. my $sth= $dbh->prepare('SELECT id, value FROM some_table WHERE id IN ?'); $sth->execute([1, 2, 3]); my $rows= $sth->fetchall_arrayref(); =head1 ASYNCHRONOUS QUERIES my $sth= $dbh->prepare("SELECT id FROM some_table WHERE x=?", { async => 1 }); $sth->execute(5); some_other_function(); while (my $row = $sth->fetchrow_arrayref()) { print "$row->[0]\n"; } B supports asynchronous queries in an easy to use form. When C 1> is passed to C, any subsequent executes on the handle are not read back immediately. Instead, these are delayed until the result is actually needed. For inserts and other writes, a convenience method C is provided, which returns an approximation to what C would have returned in an non-asynchronous context. This method also raises errors, if needed. my $sth= $dbh->prepare("INSERT INTO table (a, b) VALUES (?, ?)", { async => 1 }); $sth->execute(5, 6); some_other_function_that_takes_a_while(); $sth->x_finish_async; =head2 Performance considerations When using asynchronous queries, some previously premature optimizations become relevant. For example, it is very helpful to re-use statement handles in large volumes of inserts : my @dataset_to_insert= ([1, 2, 3, 4], [5, 6, 7, 8]); my (@pending, @reusable); while (my $row= shift @dataset_to_insert) { my $sth= (shift @reusable) || $dbh->prepare( "INSERT INTO some_table (a, b, c, d) VALUES (?, ?, ?, ?)" ); $sth->execute(@$row); push @pending, $sth; if (@pending > 500) { # Tune this number! my $pending_sth= shift @pending; $pending_sth->x_finish_async; push @reusable, $pending_sth; } } $_->x_finish_async for @pending; =head1 CONSISTENCY LEVELS $dbh->do("INSERT INTO some_table (id, field_name) VALUES (?, ?)", { Consistency => "quorum" }, @values ); B accepts a I attribute for statements. Supported consistency levels are C, C, C, C, C, C, C, C, C, C and C. This attribute is ignored on statements that do not support it, such as C. A global consistency level can be defined as part of the DSN. =head1 CAVEATS, BUGS, TODO =over =item * There is currently no support for transactions. C will die if you try to use it. =item * Thread support is untested. Use at your own risk. =item * The C format is implemented naively by returning milliseconds since the UNIX epoch. In Perl you get this number through C. Trying to save times as C objects or strings will not work, and will likely result in warnings and unexpected behavior. =item * When using asynchronous queries, more functions than just execute() may throw errors. It is recommended that you enable RaiseError. If this is not possible, it should also suffice to call C<$sth->x_finish_async> and check its return value before reading any data from the handle. =item * Cassandra/CQL3 is strict about the queries you write. When switching from other databases, such as MySQL, this may come as a surprise. This module supports C, but try to use prepared statements instead. They will save you a lot of trouble. =back =head1 UPGRADING =head2 From versions 0.25 and lower As of C 0.51, this module uses C internally. The unit tests from the previous release all still pass, but there are subtle changes : =over =item read_timeout/write_timeout are deprecated, use request_timeout instead =item the driver now manages a pool of connections internally Instead of only connecting to the one specified host, multiple hosts can be passed as seed-hosts. These are then used to bootstrap the actual internal pool of connections. =back =head2 From versions 0.24 and lower Prior to version 0.25 there was a bug corrupting float and double values as they were stored in the database. The endianness on these values was wrong, which only shows when reading stored data back in an application written using a different driver. If you were writing float or double values using a DBD::Cassandra prior to 0.25, please be careful with this upgrade. A way to rewrite your values between the two formats is : my $good_float = unpack('f>', pack('f', $bad_float)); my $good_double= unpack('d>', pack('d', $bad_double)); If you never used a DBD::Cassandra version prior to 0.25, or do not use floats or doubles, this bug does not affect you and upgrading to 0.25 is safe. =head1 AUTHOR Tom van der Woerdt =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2017 by Tom van der Woerdt. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut libdbd-cassandra-perl-0.57/lib/DBD/Cassandra/000077500000000000000000000000001445146130700206255ustar00rootroot00000000000000libdbd-cassandra-perl-0.57/lib/DBD/Cassandra/db.pm000066400000000000000000000051351445146130700215540ustar00rootroot00000000000000package DBD::Cassandra::db; our $AUTHORITY = 'cpan:TVDW'; $DBD::Cassandra::db::VERSION = '0.57'; # ABSTRACT: DBD::Cassandra database handle use 5.010; use strict; use warnings; use Devel::GlobalDestruction; # This cargocult comes straight from DBI::DBD docs. No idea what it does. $DBD::Cassandra::db::imp_data_size = 0; sub prepare { my ($dbh, $statement, $attribs)= @_; if ($attribs->{server_side_prepare}) { my $client= $dbh->{cass_client}; my ($error)= $client->call_prepare($statement); if ($error) { return $dbh->set_err($DBI::stderr, $error); } } my ($outer, $sth)= DBI::_new_sth($dbh, { Statement => $statement }); $sth->{cass_consistency}= $attribs->{consistency} || $attribs->{Consistency}; $sth->{cass_page_size}= $attribs->{perpage} || $attribs->{PerPage} || $attribs->{per_page}; $sth->{cass_async}= $attribs->{async}; return $outer; } sub commit { my ($dbh)= @_; if ($dbh->FETCH('Warn')) { warn "Commit ineffective while AutoCommit is on"; } 0; } sub rollback { my ($dbh)= @_; if ($dbh->FETCH('Warn')) { warn "Rollback ineffective while AutoCommit is on"; } 0; } sub STORE { my ($dbh, $attr, $val)= @_; if ($attr eq 'AutoCommit') { if (!$val) { die "DBD::Cassandra does not support transactions"; } return 1; } if ($attr =~ m/\Acass_/) { $dbh->{$attr}= $val; return 1; } return $dbh->SUPER::STORE($attr, $val); } sub FETCH { my ($dbh, $attr)= @_; return 1 if $attr eq 'AutoCommit'; return $dbh->{$attr} if $attr =~ m/\Acass_/; # Sort of a workaround for unrecoverable errors in st.pm if ($attr eq 'Active') { return $dbh->{cass_client}->is_active; } return $dbh->SUPER::FETCH($attr); } sub disconnect { my ($dbh)= @_; $dbh->STORE('Active', 0); return if in_global_destruction; $dbh->{cass_client}->shutdown; } sub ping { my ($dbh)= @_; return $dbh->FETCH('Active'); } sub x_wait_for_schema_agreement { my ($dbh)= @_; my ($error)= $dbh->{cass_client}->call_wait_for_schema_agreement; if ($error) { return $dbh->set_err($DBI::stderr, $error); } return 1; } 1; __END__ =pod =head1 NAME DBD::Cassandra::db - DBD::Cassandra database handle =head1 VERSION version 0.57 =head1 AUTHOR Tom van der Woerdt =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2017 by Tom van der Woerdt. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut libdbd-cassandra-perl-0.57/lib/DBD/Cassandra/dr.pm000066400000000000000000000061571445146130700216010ustar00rootroot00000000000000package DBD::Cassandra::dr; our $AUTHORITY = 'cpan:TVDW'; $DBD::Cassandra::dr::VERSION = '0.57'; # ABSTRACT: DBD::Cassandra driver handle use 5.010; use strict; use warnings; use Cassandra::Client 0.10; # "*FIX ME* Explain what the imp_data_size is, so that implementors aren't # practicing cargo-cult programming" - DBI::DBD docs $DBD::Cassandra::dr::imp_data_size = 0; sub connect { my ($drh, $dr_dsn, $user, $auth, $attr)= @_; # Iterate through the DSN, write to $attr my $driver_prefix= 'cass_'; for my $var (split /;/, $dr_dsn) { my ($attr_name, $attr_val)= split '=', $var, 2; return $drh->set_err($DBI::stderr, "Can't parse DSN part '$var'") unless defined $attr_val; $attr_name= "cass_$attr_name" unless $attr_name =~ /\A$driver_prefix/o; $attr->{$attr_name}= $attr_val; } my $keyspace= delete $attr->{cass_database} || delete $attr->{cass_db} || delete $attr->{cass_keyspace}; my $host= delete $attr->{cass_host} || delete $attr->{cass_hostname} || delete $attr->{cass_hosts} || delete $attr->{cass_hostnames} || 'localhost'; my $hosts= [ grep $_, split /,/, $host ]; my $port= delete $attr->{cass_port} || 9042; my $global_consistency= delete $attr->{cass_consistency}; my $compression= delete $attr->{cass_compression}; my $cql_version= delete $attr->{cass_cql_version}; my $read_timeout= delete $attr->{cass_read_timeout}; my $write_timeout= delete $attr->{cass_write_timeout}; my $connect_timeout= delete $attr->{cass_connect_timeout}; #XXX my $request_timeout= delete $attr->{cass_request_timeout}; my $tls= delete $attr->{cass_tls}; if ($read_timeout || $write_timeout) { if ($request_timeout) { warn 'Ignoring read_timeout and write_timeout settings, as request_timeout is passed'; } else { $request_timeout= ($read_timeout || 6) + ($write_timeout || 6); } } my $client= Cassandra::Client->new( contact_points => $hosts, port => $port, username => $user, password => $auth, keyspace => $keyspace, compression => $compression, default_consistency => $global_consistency, cql_version => $cql_version, request_timeout => $request_timeout, anyevent => 0, tls => $tls, ); my ($error)= $client->call_connect; return $drh->set_err($DBI::stderr, "Can't connect to $dr_dsn: $error") if $error; my ($outer, $dbh)= DBI::_new_dbh($drh, { Name => $dr_dsn }); $dbh->STORE('Active', 1); $dbh->{cass_client}= $client; return $outer; } sub data_sources { my ($drh, $attr)= @_; my @array= (qw/dbi:Cassandra/); return @array; } sub disconnect_all { # TODO: not needed? } 1; __END__ =pod =head1 NAME DBD::Cassandra::dr - DBD::Cassandra driver handle =head1 VERSION version 0.57 =head1 AUTHOR Tom van der Woerdt =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2017 by Tom van der Woerdt. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut libdbd-cassandra-perl-0.57/lib/DBD/Cassandra/st.pm000066400000000000000000000064751445146130700216250ustar00rootroot00000000000000package DBD::Cassandra::st; our $AUTHORITY = 'cpan:TVDW'; $DBD::Cassandra::st::VERSION = '0.57'; # ABSTRACT: DBD::Cassandra statement handle use 5.010; use strict; use warnings; # Documentation-driven cargocult $DBD::Cassandra::st::imp_data_size = 0; sub bind_param { my ($sth, $pNum, $val, $attr)= @_; my $params= ($sth->{cass_params} ||= []); $params->[$pNum-1] = $val; 1; } sub execute { my ($sth, @bind_values)= @_; $sth->{cass_bind}= (@bind_values ? \@bind_values : $sth->{cass_params}); &start_async; $sth->STORE('Active', 1); if (!$sth->{cass_async}) { return &x_finish_async; } return '0E0'; } sub start_async { my ($sth)= @_; $sth->{cass_future}= $sth->{Database}{cass_client}->future_call_execute($sth->{Statement}, $sth->{cass_bind}, { consistency => $sth->{cass_consistency}, page_size => $sth->{cass_page_size}, page => $sth->{cass_next_page}, }); } sub x_finish_async { my ($sth)= @_; my $future= delete $sth->{cass_future}; if (!$future) { return '0E0'; } my ($error, $result)= $future->(); if ($error) { $sth->STORE('Active', 0); return $sth->set_err($DBI::stderr, $error); } my $rows= ($result && $result->rows) || []; my $names= ($result && $result->column_names) || []; my $page= ($result && $result->next_page); $sth->{rows}= $rows; $sth->{row_count}= 0+@$rows; if (!@$rows && !@$names) { # This is a weird Cassandra corner-case, triggered by doing 'list permissions' etc when there are none. # Our code is fine with it, but DBI wants to have at least one column. So let's give it one. @$names= ('no_column_names_returned_by_cassandra'); } $sth->STORE('NUM_OF_FIELDS', 0+@$names); $sth->{NAME}= $names; $sth->{cass_next_page}= $page; return ((0+@$rows) || '0E0'); } sub execute_for_fetch { die 'Not implemented'; #TODO } sub bind_param_array { die 'Not implemented'; #TODO } sub fetchrow_arrayref { my ($sth)= @_; if ($sth->{cass_future}) { return undef unless &x_finish_async; } my $row= shift @{$sth->{rows}}; if (!$row && $sth->{cass_next_page}) { &start_async; if (!&x_finish_async) { return undef; } $row= shift @{$sth->{rows}}; } if ($row) { if ($sth->FETCH('ChopBlanks')) { map { $_ =~ s/\s+$//; } @$row; } return $sth->_set_fbav($row); } $sth->STORE('Active', 0); return undef; } *fetch = \&fetchrow_arrayref; sub rows { my $sth= shift; if ($sth->{cass_future}) { return undef unless &x_finish_async; } return $sth->{row_count}; } sub FETCH { my ($sth, $attr)= @_; if ($attr =~ /\A(?:NAME|NUM_OF_FIELDS)\z/ && $sth->{cass_future}) { return undef unless &x_finish_async; return $sth->{$attr} if $attr eq 'NAME'; } return $sth->SUPER::FETCH($attr); } 1; __END__ =pod =head1 NAME DBD::Cassandra::st - DBD::Cassandra statement handle =head1 VERSION version 0.57 =head1 AUTHOR Tom van der Woerdt =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2017 by Tom van der Woerdt. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut libdbd-cassandra-perl-0.57/t/000077500000000000000000000000001445146130700160325ustar00rootroot00000000000000libdbd-cassandra-perl-0.57/t/00-load.t000066400000000000000000000003541445146130700173550ustar00rootroot00000000000000#!perl -T use 5.006; use strict; use warnings FATAL => 'all'; use Test::More; plan tests => 1; BEGIN { use_ok( 'DBD::Cassandra' ) || print "Bail out!\n"; } diag( "Testing DBD::Cassandra $DBD::Cassandra::VERSION, Perl $], $^X" ); libdbd-cassandra-perl-0.57/t/01-connect.t000066400000000000000000000010141445146130700200620ustar00rootroot00000000000000use 5.010; use warnings; use strict; use Test::More; # Fake running under 'perl -l' $\= "\n"; unless ($ENV{CASSANDRA_HOST}) { plan skip_all => "CASSANDRA_HOST not set"; } plan tests => 3; use DBI; my $tls= $ENV{CASSANDRA_TLS} // ''; my $port= $ENV{CASSANDRA_PORT} ? ";port=$ENV{CASSANDRA_PORT}" : ""; my $dbh= DBI->connect("dbi:Cassandra:host=$ENV{CASSANDRA_HOST};tls=$tls$port", $ENV{CASSANDRA_USER}, $ENV{CASSANDRA_AUTH}, {RaiseError => 1}); ok($dbh); is($dbh->ping(), 1); $dbh->disconnect; is($dbh->ping(), 0); libdbd-cassandra-perl-0.57/t/05-compress.t000066400000000000000000000020621445146130700202740ustar00rootroot00000000000000use 5.010; use warnings; use strict; use DBI; use Test::More; unless ($ENV{CASSANDRA_HOST}) { plan skip_all => "CASSANDRA_HOST not set"; } plan tests => 6; my $keyspace= "dbd_cassandra_tests"; for my $compression (qw/lz4 snappy none/) { my $tls= $ENV{CASSANDRA_TLS} // ''; my $port= $ENV{CASSANDRA_PORT} ? ";port=$ENV{CASSANDRA_PORT}" : ""; my $dbh= DBI->connect("dbi:Cassandra:host=$ENV{CASSANDRA_HOST};compression=$compression;tls=$tls$port", $ENV{CASSANDRA_USER}, $ENV{CASSANDRA_AUTH}, {RaiseError => 1}); ok($dbh); $dbh->do("drop keyspace if exists $keyspace"); $dbh->do("create keyspace $keyspace with replication={'class': 'SimpleStrategy', 'replication_factor': 1}"); $dbh->do("create table $keyspace.test (id bigint primary key, b blob)"); my $original= '0' x 1000000; my $sth= $dbh->prepare("insert into $keyspace.test (id, b) values (?, ?)"); $sth->execute(1, $original); my $row= $dbh->selectrow_arrayref("select b from $keyspace.test where id=1"); ok($row->[0] eq $original); $dbh->disconnect; } libdbd-cassandra-perl-0.57/t/06-cql-version.t000066400000000000000000000015271445146130700207110ustar00rootroot00000000000000use 5.010; use warnings; use strict; use DBI; use Test::More; unless ($ENV{CASSANDRA_HOST}) { plan skip_all => "CASSANDRA_HOST not set"; } plan tests => 2; my $keyspace= "dbd_cassandra_tests"; { my $tls= $ENV{CASSANDRA_TLS} // ''; my $port= $ENV{CASSANDRA_PORT} ? ";port=$ENV{CASSANDRA_PORT}" : ""; my $dbh= DBI->connect("dbi:Cassandra:host=$ENV{CASSANDRA_HOST};tls=$tls$port", $ENV{CASSANDRA_USER}, $ENV{CASSANDRA_AUTH}, {RaiseError => 1}); ok($dbh); $dbh->disconnect; } { eval { my $tls= $ENV{CASSANDRA_TLS} // ''; my $port= $ENV{CASSANDRA_PORT} ? ";port=$ENV{CASSANDRA_PORT}" : ""; my $dbh= DBI->connect("dbi:Cassandra:host=$ENV{CASSANDRA_HOST};cql_version=1.2.3;tls=$tls$port", $ENV{CASSANDRA_USER}, $ENV{CASSANDRA_AUTH}, {RaiseError => 1}); ok(0); } or do { ok(1); }; } libdbd-cassandra-perl-0.57/t/10-crud.t000066400000000000000000000034211445146130700173720ustar00rootroot00000000000000use 5.010; use warnings; use strict; use Test::More; unless ($ENV{CASSANDRA_HOST}) { plan skip_all => "CASSANDRA_HOST not set"; } plan tests => 9; use DBI; my $tls= $ENV{CASSANDRA_TLS} // ''; my $port= $ENV{CASSANDRA_PORT} ? ";port=$ENV{CASSANDRA_PORT}" : ""; my $dbh= DBI->connect("dbi:Cassandra:host=$ENV{CASSANDRA_HOST};tls=$tls$port", $ENV{CASSANDRA_USER}, $ENV{CASSANDRA_AUTH}, {RaiseError => 1, Warn => 1, PrintWarn => 0, PrintError => 0}); ok($dbh); my $keyspace= "dbd_cassandra_tests"; ok(!eval { # Invalid: can't use prepared statements here $dbh->do('drop keyspace if exists ?', undef, $keyspace); }); $dbh->do("drop keyspace if exists $keyspace"); $dbh->do("create keyspace $keyspace with replication={'class': 'SimpleStrategy', 'replication_factor': 1}"); ok(!eval { # Invalid: no keyspace selected $dbh->do("create table test_int (id bigint primary key)"); }); $dbh->do("create table $keyspace.test_int (id bigint primary key)"); my $last_res; for (1..5) { $last_res= $dbh->do("insert into $keyspace.test_int (id) values (?)", undef, $_); } is($last_res, '0E0'); for my $row (@{ $dbh->selectall_arrayref("select count(*) from $keyspace.test_int") }) { is($row->[0], 5); } ok(!eval { # Can't have a string in an integer $dbh->do("insert into $keyspace.test_int (id) values 'test'"); }); $dbh->do("delete from $keyspace.test_int where id in (?,?,3)", undef, 1, 2); for my $row (@{ $dbh->selectall_arrayref("select count(*) from $keyspace.test_int") }) { is($row->[0], 2); } ok($dbh->do("insert into $keyspace.test_int (id) values (6)", { Consistency => 'any' })); ok(!eval { # We have replication_factor=1, 'two' shouldn't work $dbh->do("insert into $keyspace.test_int (id) values (5)", { Consistency => 'two' }); }); $dbh->disconnect; libdbd-cassandra-perl-0.57/t/15-batch.t000066400000000000000000000017311445146130700175250ustar00rootroot00000000000000use 5.010; use warnings; use strict; use DBI; use Test::More; unless ($ENV{CASSANDRA_HOST}) { plan skip_all => "CASSANDRA_HOST not set"; } plan tests => 2; my $tls= $ENV{CASSANDRA_TLS} // ''; my $port= $ENV{CASSANDRA_PORT} ? ";port=$ENV{CASSANDRA_PORT}" : ""; my $dbh= DBI->connect("dbi:Cassandra:host=$ENV{CASSANDRA_HOST};keyspace=dbd_cassandra_tests;read_timeout=5;connect_timeout=5;write_timeout=5;tls=$tls$port", $ENV{CASSANDRA_USER}, $ENV{CASSANDRA_AUTH}, {RaiseError => 1}); ok($dbh); $dbh->do('drop table if exists test_batch'); ok($dbh->do("create table test_batch ( pk int, value int, primary key ( pk ) )")); SCOPED: { local $SIG{__WARN__}= sub { ok(0); print STDERR @_; }; my $sth= $dbh->prepare("BEGIN BATCH INSERT INTO test_batch (pk, value) VALUES (?, ?) IF NOT EXISTS UPDATE test_batch SET value = 5 WHERE pk = ? APPLY BATCH;", ); $sth->execute(1, 2, 1); } $dbh->disconnect; libdbd-cassandra-perl-0.57/t/20-utf8.t000066400000000000000000000016151445146130700173270ustar00rootroot00000000000000use 5.010; use warnings; use strict; use DBI; use Test::More; unless ($ENV{CASSANDRA_HOST}) { plan skip_all => "CASSANDRA_HOST not set"; } plan tests => 2; my $tls= $ENV{CASSANDRA_TLS} // ''; my $port= $ENV{CASSANDRA_PORT} ? ";port=$ENV{CASSANDRA_PORT}" : ""; my $dbh= DBI->connect("dbi:Cassandra:host=$ENV{CASSANDRA_HOST};keyspace=dbd_cassandra_tests;read_timeout=1;connect_timeout=1;write_timeout=1;tls=$tls$port", $ENV{CASSANDRA_USER}, $ENV{CASSANDRA_AUTH}, {RaiseError => 1}); ok($dbh); $dbh->do('create table if not exists test_utf8 (id bigint primary key, str varchar)'); my $test_string= ""; utf8::decode($test_string); for (1..100) { $test_string .= chr(int(rand(30000)+1000)); } $dbh->do("insert into test_utf8 (id, str) values (?,?)", undef, 1, $test_string); my $row= $dbh->selectrow_arrayref('select str from test_utf8 where id=1'); ok($row->[0] eq $test_string); $dbh->disconnect; libdbd-cassandra-perl-0.57/t/30-types.t000066400000000000000000000152631445146130700176120ustar00rootroot00000000000000use 5.010; use warnings; use strict; use DBI; use Test::More; use utf8; use Ref::Util qw/is_ref/; my $input= "__as__input"; my $warn= "__warn"; my $type_table= [ # Type name, test input, test output (undef for error, $input for copying the input, $warn if we expect a perl warning) ['ascii', 'asd', $input], ['ascii', '∫∫', undef], ['bigint', 5, $input], ['bigint', 'asd', $warn], ['blob', 'asd', $input], ['boolean', 1, !!1], ['boolean', 0, !1], ['boolean', 2, !!1], ['boolean', 'asd', !!1], ['double', 0.15, $input], ['float', 0.2, 0.200000002980232], # Yeah. ['int', 5, $input], ['text', '∫∫', $input], ['timestamp', time(), $input], ['varchar', '∫∫', $input], ['uuid', '34945442-c1d4-47db-bddd-5d2138b42cbc', $input], ['uuid', '34945442-c1d4-47db-bddd-5d2138b42cbc-abcdef', '34945442-c1d4-47db-bddd-5d2138b42cbc'], ['uuid', 'bad16', 'bad16000-0000-0000-0000-000000000000'], ['timeuuid', '34945442-c1d4-47db-bddd-5d2138b42cbc', undef], # that's not a valid timeuuid ['timeuuid', '568ef050-5aca-11e5-9c6b-eb15c19b7bc8', $input], ['timeuuid', 'bad16', undef], ['tinyint', 127, $input], ['tinyint', 0, $input], ['tinyint', -128, $input], ['tinyint', -129, $warn], ['smallint', 32767, $input], ['smallint', 0, $input], ['smallint', -32768, $input], ['smallint', -32769, 32767], ['time', '12:00', '12:00:00'], ['time', '24:00', '0:00:00'], ['time', '13:30:54.234', $input], ['time', '14', '14:00:00'], # Why would someone want that? ['tuple', [ 1, 2 ], $input], ['tuple>>', [ "test string", 15, [ 1, 2 ] ], $input], ['frozen
', { street => "abc", city => "def", zip_code => 1234 }, $input ], ['map>', { tom => { street => "abc", zip_code => 5, city => "abc" }, someone_else => { street => "def", city => 15, zip_code => 15 } }, $input], # List types... ['list', [1, 2], $input], ['list', ['∫∫', 'test string'], $input], ['set', ['test string', '∫∫'], $input], ['frozen>', ['test string', '∫∫'], $input], ['map', {test => 5, asd => 1}, $input], ['map>>', { test => [1, 3, 5], foo => [2, 4, 6] }, $input], ['list>>', [ { 1 => !!0, 2 => !0 }, { 3 => !0, 4 => !!0 } ], $input], ['set>>', [ { 1 => !!0, 2 => !0 }, { 3 => !0, 4 => !!0 } ], $input], ['map>>', { 1 => [2, 3], 4 => [5, 6] }, $input], # Date is probably our only non-trivial implementation. Test it a bit harder. ['date', '2000-01-01', $input], ['date', '2000-01-02', $input], ['date', '2000-02-28', $input], ['date', '2000-02-29', $input], ['date', '2000-03-01', $input], ['date', '2001-01-01', $input], ['date', '2101-01-01', $input], ['date', '2401-01-01', $input], ['date', '2400-01-01', $input], ['date', '2800-01-01', $input], ['date', '1600-01-01', $input], ['date', '2100-01-01', $input], ['date', '2200-01-01', $input], ['date', '2300-01-01', $input], ['date', '1900-01-01', $input], ['date', '1800-01-01', $input], ['date', '2016-01-01', $input], ['date', '2016-02-29', $input], ['date', '2016-03-01', $input], ['date', '1970-01-01', $input], ['date', '1969-12-31', $input], ['date', '100000-12-31', $input], ['date', '1970-01-11', $input], ['date', '0001-01-01', '1-01-01'], ['date', '0000-01-01', '0-01-01'], ['date', '-0001-01-01', '-1-01-01'], ['date', '275760-09-13', $input], ['date', '2015-02-29', '2015-03-01'], ['date', '2015-12-32', '2016-01-01'], ['date', '5881580-07-11', $input], ['date', '-5877641-06-23', $input], ]; my %udt= ( address => 'street text, city text, zip_code int', ); unless ($ENV{CASSANDRA_HOST}) { plan skip_all => "CASSANDRA_HOST not set"; } plan tests => 2+@$type_table; my $tls= $ENV{CASSANDRA_TLS} // ''; my $port= $ENV{CASSANDRA_PORT} ? ";port=$ENV{CASSANDRA_PORT}" : ""; my $dbh= DBI->connect("dbi:Cassandra:host=$ENV{CASSANDRA_HOST};keyspace=dbd_cassandra_tests;tls=$tls$port", $ENV{CASSANDRA_USER}, $ENV{CASSANDRA_AUTH}, {RaiseError => 1}); ok($dbh); for my $udt_name (keys %udt) { $dbh->do('create type if not exists '.$udt_name.' ('.$udt{$udt_name}.')'); } my $i= 0; for my $type (@$type_table) { my ($typename, $test_val, $output_val)= @$type; my $tablename= $typename; $tablename =~ s/\W/_/g; $dbh->do("create table if not exists test_type_$tablename (id bigint primary key, test $typename)"); my $random_id= ++$i; eval { my $did_warn; local $SIG{__WARN__}= sub { my $warn= shift; $did_warn= $warn || 1; }; $dbh->do("insert into test_type_$tablename (id, test) values (?, ?)", undef, $random_id, $test_val); my $row= $dbh->selectrow_arrayref("select test from test_type_$tablename where id=$random_id", { async => 1 }); if (!defined $output_val) { ok(0, "defined $typename"); } elsif (!is_ref($output_val) && $output_val eq $warn) { ok($did_warn, "warned $typename"); } elsif (!is_ref($output_val) && $output_val eq $input) { is_deeply([$row->[0]], [$test_val], "input match $typename"); } else { is_deeply([$row->[0]], [$output_val], "perfect match $typename"); } if ($did_warn && !is_ref($output_val) && defined($output_val) && $output_val ne $warn) { diag("Warning: $did_warn (input: $test_val)"); } 1; } or do { if (!defined $output_val) { ok(1, "$typename raise error"); } else { warn $@; ok(0, "$typename raised error"); } }; } # Counter needs special testing COUNTER: { $dbh->do("create table if not exists test_type_counter (id bigint primary key, test counter)"); my $random_id= sprintf '%.f', rand(10000); eval { $dbh->do("update test_type_counter set test=test+5 where id=?", undef, $random_id); my $row= $dbh->selectrow_arrayref("select test from test_type_counter where id=$random_id"); ok($row->[0] == 5); 1; } or do { ok(0); }; } $dbh->disconnect; libdbd-cassandra-perl-0.57/t/40-paging.t000066400000000000000000000020521445146130700177040ustar00rootroot00000000000000use 5.010; use warnings; use strict; use Test::More; unless ($ENV{CASSANDRA_HOST}) { plan skip_all => "CASSANDRA_HOST not set"; } plan tests => 101; use DBI; my $tls= $ENV{CASSANDRA_TLS} // ''; my $port= $ENV{CASSANDRA_PORT} ? ";port=$ENV{CASSANDRA_PORT}" : ""; my $dbh= DBI->connect("dbi:Cassandra:host=$ENV{CASSANDRA_HOST};tls=$tls$port", $ENV{CASSANDRA_USER}, $ENV{CASSANDRA_AUTH}, {RaiseError => 1, Warn => 1, PrintWarn => 0, PrintError => 0}); ok($dbh); my $keyspace= "dbd_cassandra_tests"; $dbh->do("drop keyspace if exists $keyspace"); $dbh->do("create keyspace $keyspace with replication={'class': 'SimpleStrategy', 'replication_factor': 1}"); $dbh->do("create table $keyspace.test_int (id bigint primary key)"); for (1..50) { is($dbh->do("insert into $keyspace.test_int (id) values (?)", undef, $_), '0E0'); } my %seen; my $sth= $dbh->prepare("select * from $keyspace.test_int", { PerPage => 5 }); $sth->execute; while (my $row= $sth->fetchrow_arrayref()) { $seen{$row->[0]}= 1; } for (1..50) { is($seen{$_}, 1); } $dbh->disconnect; libdbd-cassandra-perl-0.57/t/50-async.t000066400000000000000000000022721445146130700175610ustar00rootroot00000000000000use 5.010; use warnings; use strict; use DBI; use Test::More; unless ($ENV{CASSANDRA_HOST}) { plan skip_all => "CASSANDRA_HOST not set"; } plan tests => 3; my $tls= $ENV{CASSANDRA_TLS} // ''; my $port= $ENV{CASSANDRA_PORT} ? ";port=$ENV{CASSANDRA_PORT}" : ""; my $dbh= DBI->connect("dbi:Cassandra:host=$ENV{CASSANDRA_HOST};keyspace=dbd_cassandra_tests;read_timeout=5;connect_timeout=5;write_timeout=5;tls=$tls$port", $ENV{CASSANDRA_USER}, $ENV{CASSANDRA_AUTH}, {RaiseError => 1}); ok($dbh); $dbh->do('create table if not exists test_async (id bigint primary key)'); $dbh->do('truncate test_async'); my $count= 100000; my (@pending, @reusable); for my $i (1..$count) { my $sth= (shift @reusable) || $dbh->prepare("insert into test_async (id) values (?)", {async => 1}); $sth->execute($i); push @pending, $sth; if (@pending > 5000) { my $pending_sth= shift @pending; $pending_sth->x_finish_async; push @reusable, $pending_sth; } } my $ok= 1; $ok &&= $_->x_finish_async for reverse @pending; ok($ok); my $rows= $dbh->selectall_arrayref('select * from test_async'); ok(0+@$rows == $count) or diag("Expected $count rows, got ".(0+@$rows)); $dbh->disconnect; libdbd-cassandra-perl-0.57/t/60-bind.t000066400000000000000000000023721445146130700173620ustar00rootroot00000000000000use 5.010; use warnings; use strict; use Test::More; unless ($ENV{CASSANDRA_HOST}) { plan skip_all => "CASSANDRA_HOST not set"; } plan tests => 2; use DBI; my $tls= $ENV{CASSANDRA_TLS} // ''; my $port= $ENV{CASSANDRA_PORT} ? ";port=$ENV{CASSANDRA_PORT}" : ""; my $dbh= DBI->connect("dbi:Cassandra:host=$ENV{CASSANDRA_HOST};consistency=quorum;tls=$tls$port", $ENV{CASSANDRA_USER}, $ENV{CASSANDRA_AUTH}, {RaiseError => 1, Warn => 1, PrintWarn => 0, PrintError => 0}); ok($dbh); my $keyspace= "dbd_cassandra_tests"; $dbh->do("drop keyspace if exists $keyspace"); $dbh->do("create keyspace $keyspace with replication={'class': 'SimpleStrategy', 'replication_factor': 1}"); $dbh->do("create table $keyspace.test_int (id bigint primary key, val text, id2 uuid)"); my $sth1= $dbh->prepare("insert into $keyspace.test_int (id, val, id2) values (?, ?, ?)"); $sth1->bind_param(1, 1); $sth1->bind_param(2, "test"); $sth1->bind_param(3, "12345678-1234-1234-1234-123412341234"); $sth1->execute; my $sth2= $dbh->prepare("select id, val, id2 from $keyspace.test_int where id=?", {async=>1}); $sth2->bind_param(1, 1); $sth2->execute; my $row= $sth2->fetchall_arrayref()->[0]; is_deeply($row, [ 1, "test", "12345678-1234-1234-1234-123412341234", ]); $dbh->disconnect; libdbd-cassandra-perl-0.57/t/60-hash.t000066400000000000000000000027061445146130700173720ustar00rootroot00000000000000use 5.010; use warnings; use strict; use Test::More; unless ($ENV{CASSANDRA_HOST}) { plan skip_all => "CASSANDRA_HOST not set"; } plan tests => 4; use DBI; my $tls= $ENV{CASSANDRA_TLS} // ''; my $port= $ENV{CASSANDRA_PORT} ? ";port=$ENV{CASSANDRA_PORT}" : ""; my $dbh= DBI->connect("dbi:Cassandra:host=$ENV{CASSANDRA_HOST};consistency=quorum;tls=$tls$port", $ENV{CASSANDRA_USER}, $ENV{CASSANDRA_AUTH}, {RaiseError => 1, Warn => 1, PrintWarn => 0, PrintError => 0}); ok($dbh); my $keyspace= "dbd_cassandra_tests"; ok(!eval { # Invalid: can't use prepared statements here $dbh->do('drop keyspace if exists ?', undef, $keyspace); }); $dbh->do("drop keyspace if exists $keyspace"); $dbh->do("create keyspace $keyspace with replication={'class': 'SimpleStrategy', 'replication_factor': 1}"); $dbh->do("create table $keyspace.test_int (id bigint primary key, val text, id2 uuid)"); $dbh->do("insert into $keyspace.test_int (id, val, id2) values (?, ?, ?)", undef, 1, "test", "12345678-1234-1234-1234-123412341234"); my $row= $dbh->selectall_arrayref("select id, val, id2 from $keyspace.test_int where id=?", {Slice=>{},async=>1}, 1)->[0]; is_deeply($row, { id => 1, val => "test", id2 => "12345678-1234-1234-1234-123412341234", }); SKIP: { skip "Authentication not configured", 1 unless $ENV{CASSANDRA_USER}; ok($dbh->selectall_arrayref("list authorize permission on keyspace system of $ENV{CASSANDRA_USER}", {Slice=>{}})); } $dbh->disconnect; libdbd-cassandra-perl-0.57/t/author-pod-syntax.t000066400000000000000000000004541445146130700216300ustar00rootroot00000000000000#!perl BEGIN { unless ($ENV{AUTHOR_TESTING}) { print qq{1..0 # SKIP these tests are for testing by the author\n}; exit } } # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use strict; use warnings; use Test::More; use Test::Pod 1.41; all_pod_files_ok(); libdbd-cassandra-perl-0.57/weaver.ini000066400000000000000000000003711445146130700175620ustar00rootroot00000000000000[@CorePrep] [Name] [Version] [Region / prelude] [Generic / SYNOPSIS] [Generic / DESCRIPTION] [Generic / OVERVIEW] [Collect / ATTRIBUTES] command = attr [Collect / METHODS] command = method [Leftovers] [Region / postlude] [Authors] [Legal]