@@ -6,7 +6,7 @@ use 5.006;
6
6
use strict;
7
7
use warnings;
8
8
use Data::Dumper;
9
- use Test::More tests => 12 ;
9
+ use Test::More tests => 14 ;
10
10
use lib ' t' ,' .' ;
11
11
use CP_Testing;
12
12
@@ -43,9 +43,11 @@ if ($ver < 80100) {
43
43
44
44
45
45
my $seqname = ' cp_test_sequence' ;
46
+ my $testtbl = ' sequence_test' ;
46
47
$cp -> drop_sequence_if_exists($seqname );
47
48
$cp -> drop_sequence_if_exists(" ${seqname} 2" );
48
49
$cp -> drop_sequence_if_exists(" ${seqname} '\" evil" );
50
+ $cp -> drop_table_if_exists(" $testtbl " );
49
51
50
52
$t =qq{ $S works when no sequences exist} ;
51
53
like ($cp -> run(' ' ), qr { OK:.+No sequences found} , $t );
@@ -96,4 +98,28 @@ $dbh->commit();
96
98
$t =qq{ $S handles SQL quoting} ;
97
99
like ($cp -> run(' ' ), qr { OK:.+'public."${seqname} ''""evil"'} , $t ); # extra " and ' because name is both identifier+literal quoted
98
100
101
+ $dbh -> do(" DROP SEQUENCE ${seqname} " );
102
+ $dbh -> do(" DROP SEQUENCE ${seqname} 2" );
103
+ $dbh -> do(qq{ DROP SEQUENCE "${seqname} '""evil"} );
104
+
105
+ # test integer column where the datatype range is smaller than the serial range
106
+ $dbh -> do(" CREATE TABLE $testtbl (id serial)" );
107
+ $dbh -> do(" SELECT setval('${testtbl} _id_seq',2000000000)" );
108
+ $dbh -> commit;
109
+ $t =qq{ $S handles "serial" column} ;
110
+ like ($cp -> run(' ' ), qr { WARNING:.+public.sequence_test_id_seq=93% \( calls left=147483647\) } , $t );
111
+
112
+ if ($ver >= 90200) {
113
+ # test smallint column where the datatype range is even smaller (and while we are at it, test --exclude)
114
+ $dbh -> do(" ALTER TABLE $testtbl ADD COLUMN smallid smallserial" );
115
+ $dbh -> do(" SELECT setval('${testtbl} _smallid_seq',30000)" );
116
+ $dbh -> commit;
117
+ $t =qq{ $S handles "smallserial" column} ;
118
+ like ($cp -> run(' --exclude=sequence_test_id_seq' ), qr { WARNING:.+public.sequence_test_smallid_seq=92% \( calls left=2767\) } , $t );
119
+ } else {
120
+ SKIP: {
121
+ skip ' "smallserial" needs PostgreSQL 9.2 or later' , 2;
122
+ }
123
+ }
124
+
99
125
exit ;
0 commit comments