File Coverage

blib/lib/App/Sqitch/Engine/cockroach.pm
Criterion Covered Total %
statement 18 21 85.7
branch 2 2 100.0
condition n/a
subroutine 10 11 90.9
pod 5 5 100.0
total 35 39 89.7


line stmt bran cond sub pod time code
1             package App::Sqitch::Engine::cockroach;
2              
3 3     3   138559 use 5.010;
  3         11  
4 3     3   20 use Moo;
  3         7  
  3         28  
5 3     3   1154 use namespace::autoclean;
  3         6  
  3         33  
6              
7             extends 'App::Sqitch::Engine::pg';
8              
9             our $VERSION = 'v1.4.0'; # VERSION
10              
11 4     4 1 10609 sub key { 'cockroach' }
12 3     3 1 42 sub name { 'CockroachDB' }
13 2     2 1 16 sub driver { 'DBD::Pg 2.0' }
14              
15             sub _ts2char_format {
16 2     2   22 q{experimental_strftime(%s AT TIME ZONE 'UTC', 'year:%%Y:month:%%m:day:%%d:hour:%%H:minute:%%M:second:%%S:time_zone:UTC')};
17             }
18              
19             # Override to avoid locking the changes table, as Cockroach does not support
20             # explicit table locks.
21             sub begin_work {
22 0     0 1 0 my $self = shift;
23 0         0 $self->dbh->begin_work;
24 0         0 return $self;
25             }
26              
27             # Override to return true, as Cockroach does not support advisory locks.
28             sub wait_lock {
29             # Cockroach does not support advisory locks.
30             # https://github.com/cockroachdb/cockroach/issues/13546
31 2     2 1 10 return 1;
32             }
33              
34             sub _no_table_error {
35 6 100   6   14584 $DBI::state && $DBI::state eq '42P01'; # undefined_table
36             }
37              
38             sub _run_registry_file {
39 2     2   70 my ($self, $file) = @_;
40 2         40 my $schema = $self->registry;
41              
42 2         102 $self->_run(
43             '--file' => $file,
44             '--set' => "registry=$schema",
45             );
46              
47 2         16 $self->dbh->do('SET search_path = ?', undef, $schema);
48             }
49              
50             1;
51              
52             __END__
53              
54             =head1 Name
55              
56             App::Sqitch::Engine::cockroach - Sqitch CockroachDB Engine
57              
58             =head1 Synopsis
59              
60             my $pg = App::Sqitch::Engine->load( engine => 'cockroach' );
61              
62             =head1 Description
63              
64             App::Sqitch::Engine::cockroach provides the CockroachDB storage engine for Sqitch. It
65             supports CockroachDB v21 and higher, and relies on the Postgres toolchain (C<psql>
66             client, L<DBD::Pg> database driver, etc.).
67              
68             =head1 Author
69              
70             David E. Wheeler <david@justatheory.com>
71              
72             =head1 License
73              
74             Copyright (c) 2012-2023 iovation Inc., David E. Wheeler
75              
76             Permission is hereby granted, free of charge, to any person obtaining a copy
77             of this software and associated documentation files (the "Software"), to deal
78             in the Software without restriction, including without limitation the rights
79             to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
80             copies of the Software, and to permit persons to whom the Software is
81             furnished to do so, subject to the following conditions:
82              
83             The above copyright notice and this permission notice shall be included in all
84             copies or substantial portions of the Software.
85              
86             THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
87             IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
88             FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
89             AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
90             LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
91             OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
92             SOFTWARE.
93              
94             =cut