produce_diff_sql(): list context
[dbsrgits/SQL-Translator.git] / t / 47postgres-producer.t
CommitLineData
8c4efd11 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More;
7use Test::Exception;
8use Test::SQL::Translator qw(maybe_plan);
5f31ed66 9use SQL::Translator::Schema::Constants;
8c4efd11 10use Data::Dumper;
11use FindBin qw/$Bin/;
12
13# Testing 1,2,3,4...
14#=============================================================================
15
16BEGIN {
2230ed2a 17 maybe_plan(53,
8c4efd11 18 'SQL::Translator::Producer::PostgreSQL',
19 'Test::Differences',
20 )
21}
22use Test::Differences;
23use SQL::Translator;
24
bc8e2aa1 25my $PRODUCER = \&SQL::Translator::Producer::PostgreSQL::create_field;
8c4efd11 26
2230ed2a 27{
28 my $table = SQL::Translator::Schema::Table->new( name => 'foo.bar' );
29 my $field = SQL::Translator::Schema::Field->new( name => 'baz',
30 table => $table,
31 data_type => 'VARCHAR',
32 size => 10,
33 default_value => 'quux',
34 is_auto_increment => 0,
35 is_nullable => 0,
36 is_foreign_key => 0,
37 is_unique => 0 );
38 $table->add_field($field);
39 my ($create, $fks) = SQL::Translator::Producer::PostgreSQL::create_table($table, { quote_table_names => q{"} });
40 is($table->name, 'foo.bar');
41
42 my $expected = "--\n-- Table: foo.bar\n--\nCREATE TABLE \"foo\".\"bar\" (\n \"baz\" character varying(10) DEFAULT 'quux' NOT NULL\n)";
43 is($create, $expected);
44}
45
8c4efd11 46my $table = SQL::Translator::Schema::Table->new( name => 'mytable');
47
48my $field1 = SQL::Translator::Schema::Field->new( name => 'myfield',
49 table => $table,
50 data_type => 'VARCHAR',
51 size => 10,
52 default_value => undef,
53 is_auto_increment => 0,
54 is_nullable => 1,
55 is_foreign_key => 0,
56 is_unique => 0 );
57
58my $field1_sql = SQL::Translator::Producer::PostgreSQL::create_field($field1);
59
60is($field1_sql, 'myfield character varying(10)', 'Create field works');
61
aacb3187 62my $field_array = SQL::Translator::Schema::Field->new( name => 'myfield',
63 table => $table,
64 data_type => 'character varying[]',
65 size => 10,
66 default_value => undef,
67 is_auto_increment => 0,
68 is_nullable => 1,
69 is_foreign_key => 0,
70 is_unique => 0 );
71
72my $field_array_sql = SQL::Translator::Producer::PostgreSQL::create_field($field_array);
73
74is($field_array_sql, 'myfield character varying(10)[]', 'Create field works');
75
8c4efd11 76my $field2 = SQL::Translator::Schema::Field->new( name => 'myfield',
77 table => $table,
78 data_type => 'VARCHAR',
79 size => 25,
80 default_value => undef,
81 is_auto_increment => 0,
82 is_nullable => 0,
83 is_foreign_key => 0,
84 is_unique => 0 );
85
c50d1a0a 86my $pk_constraint = SQL::Translator::Schema::Constraint->new(
87 table => $table,
88 name => 'foo',
89 fields => [qw(myfield)],
90 type => 'PRIMARY_KEY',
91);
92
93my ($pk_constraint_def_ref, $pk_constraint_fk_ref ) = SQL::Translator::Producer::PostgreSQL::create_constraint($pk_constraint);
94ok(@{$pk_constraint_def_ref} == 1 && @{$pk_constraint_fk_ref} == 0, 'precheck of create_Primary Key constraint');
95is($pk_constraint_def_ref->[0], 'CONSTRAINT foo PRIMARY KEY (myfield)', 'Create Primary Key Constraint works');
96
97my $alter_pk_constraint = SQL::Translator::Producer::PostgreSQL::alter_drop_constraint($pk_constraint);
98is($alter_pk_constraint, 'ALTER TABLE mytable DROP CONSTRAINT foo', 'Alter drop Primary Key constraint works');
99
100my $table2 = SQL::Translator::Schema::Table->new( name => 'mytable2');
101
102my $field1_2 = SQL::Translator::Schema::Field->new( name => 'myfield_2',
103 table => $table,
104 data_type => 'VARCHAR',
105 size => 10,
106 default_value => undef,
107 is_auto_increment => 0,
108 is_nullable => 1,
109 is_foreign_key => 0,
110 is_unique => 0 );
111
681dc480 112# check named, and unnamed foreign keys
113for my $name ( 'foo', undef ) {
114 my $fk_constraint = SQL::Translator::Schema::Constraint->new(
115 table => $table,
116 name => $name,
117 fields => [qw(myfield)],
118 type => 'FOREIGN_KEY',
119 reference_table => $table2,
120 reference_fields => [qw(myfield_2)],
121 );
122 my $fk_constraint_2 = SQL::Translator::Schema::Constraint->new(
123 table => $table,
124 name => $name,
125 fields => [qw(myfield)],
126 type => 'FOREIGN_KEY',
127 reference_table => $table2,
128 reference_fields => [qw(myfield_2)],
129 );
130
131 my ($fk_constraint_def_ref, $fk_constraint_fk_ref ) = SQL::Translator::Producer::PostgreSQL::create_constraint($fk_constraint);
132
133 ok(@{$fk_constraint_def_ref} == 0 && @{$fk_constraint_fk_ref} == 1, 'precheck of create_Foreign Key constraint');
134
135 if ( $name ) {
136 is($fk_constraint_fk_ref->[0], "ALTER TABLE mytable ADD CONSTRAINT $name FOREIGN KEY (myfield)
137 REFERENCES mytable2 (myfield_2) DEFERRABLE", 'Create Foreign Key Constraint works');
138
139 # ToDo: may we should check if the constraint name was valid, or if next
140 # unused_name created has choosen a different one
141 my $alter_fk_constraint = SQL::Translator::Producer::PostgreSQL::alter_drop_constraint($fk_constraint);
142 is($alter_fk_constraint, "ALTER TABLE mytable DROP CONSTRAINT $name", 'Alter drop Foreign Key constraint works');
143 }
144 else {
145 is($fk_constraint_fk_ref->[0], 'ALTER TABLE mytable ADD FOREIGN KEY (myfield)
146 REFERENCES mytable2 (myfield_2) DEFERRABLE', 'Create named Foreign Key Constraint works');
147
148 my $alter_fk_constraint = SQL::Translator::Producer::PostgreSQL::alter_drop_constraint($fk_constraint);
149 is($alter_fk_constraint, 'ALTER TABLE mytable DROP CONSTRAINT mytable_myfield_fkey', 'Alter drop named Foreign Key constraint works');
150 }
151}
c50d1a0a 152
c50d1a0a 153
8c4efd11 154my $alter_field = SQL::Translator::Producer::PostgreSQL::alter_field($field1,
155 $field2);
c50d1a0a 156is($alter_field, qq[ALTER TABLE mytable ALTER COLUMN myfield SET NOT NULL;
3406fd5b 157ALTER TABLE mytable ALTER COLUMN myfield TYPE character varying(25)],
8c4efd11 158 'Alter field works');
159
c50d1a0a 160my $field1_complex = SQL::Translator::Schema::Field->new(
161 name => 'my_complex_field',
162 table => $table,
163 data_type => 'VARCHAR',
164 size => 10,
165 default_value => undef,
166 is_auto_increment => 0,
167 is_nullable => 1,
168 is_foreign_key => 0,
169 is_unique => 0
170);
171
172my $field2_complex = SQL::Translator::Schema::Field->new(
173 name => 'my_altered_field',
174 table => $table,
175 data_type => 'VARCHAR',
176 size => 60,
177 default_value => 'whatever',
178 is_auto_increment => 0,
179 is_nullable => 1,
180 is_foreign_key => 0,
181 is_unique => 0
182);
183
184my $alter_field_complex = SQL::Translator::Producer::PostgreSQL::alter_field($field1_complex, $field2_complex);
185is(
186 $alter_field_complex,
187 q{ALTER TABLE mytable RENAME COLUMN my_complex_field TO my_altered_field;
188ALTER TABLE mytable ALTER COLUMN my_altered_field TYPE character varying(60);
189ALTER TABLE mytable ALTER COLUMN my_altered_field SET DEFAULT 'whatever'},
190 'Complex Alter field works'
191);
192
8c4efd11 193$field1->name('field3');
194my $add_field = SQL::Translator::Producer::PostgreSQL::add_field($field1);
195
3406fd5b 196is($add_field, 'ALTER TABLE mytable ADD COLUMN field3 character varying(10)', 'Add field works');
8c4efd11 197
198my $drop_field = SQL::Translator::Producer::PostgreSQL::drop_field($field2);
3406fd5b 199is($drop_field, 'ALTER TABLE mytable DROP COLUMN myfield', 'Drop field works');
8c4efd11 200
e56dabb7 201my $field3 = SQL::Translator::Schema::Field->new( name => 'time_field',
202 table => $table,
203 data_type => 'TIME',
204 default_value => undef,
205 is_auto_increment => 0,
206 is_nullable => 0,
207 is_foreign_key => 0,
208 is_unique => 0 );
209
210my $field3_sql = SQL::Translator::Producer::PostgreSQL::create_field($field3);
211
212is($field3_sql, 'time_field time NOT NULL', 'Create time field works');
213
621cb859 214my $field3_datetime_with_TZ = SQL::Translator::Schema::Field->new(
215 name => 'datetime_with_TZ',
216 table => $table,
217 data_type => 'timestamp with time zone',
218 size => 7,
219);
220
aee4b66e 221my $field3_datetime_with_TZ_sql =
621cb859 222 SQL::Translator::Producer::PostgreSQL::create_field(
223 $field3_datetime_with_TZ
224 );
225
226is(
aee4b66e 227 $field3_datetime_with_TZ_sql,
228 'datetime_with_TZ timestamp(6) with time zone',
621cb859 229 'Create time field with time zone and size, works'
230);
231
232my $field3_time_without_TZ = SQL::Translator::Schema::Field->new(
233 name => 'time_without_TZ',
234 table => $table,
235 data_type => 'time without time zone',
236 size => 2,
237);
238
aee4b66e 239my $field3_time_without_TZ_sql
621cb859 240 = SQL::Translator::Producer::PostgreSQL::create_field(
241 $field3_time_without_TZ
242 );
243
244is(
aee4b66e 245 $field3_time_without_TZ_sql,
246 'time_without_TZ time(2) without time zone',
621cb859 247 'Create time field without time zone but with size, works'
248);
249
c3bddac9 250my $field_num = SQL::Translator::Schema::Field->new( name => 'num',
251 table => $table,
252 data_type => 'numeric',
253 size => [10,2],
254 );
255my $fieldnum_sql = SQL::Translator::Producer::PostgreSQL::create_field($field_num);
256
257is($fieldnum_sql, 'num numeric(10,2)', 'Create numeric field works');
258
259
e56dabb7 260my $field4 = SQL::Translator::Schema::Field->new( name => 'bytea_field',
261 table => $table,
262 data_type => 'bytea',
263 size => '16777215',
264 default_value => undef,
265 is_auto_increment => 0,
266 is_nullable => 0,
267 is_foreign_key => 0,
268 is_unique => 0 );
269
270my $field4_sql = SQL::Translator::Producer::PostgreSQL::create_field($field4);
8c4efd11 271
e56dabb7 272is($field4_sql, 'bytea_field bytea NOT NULL', 'Create bytea field works');
5342f5c1 273
274my $field5 = SQL::Translator::Schema::Field->new( name => 'enum_field',
275 table => $table,
276 data_type => 'enum',
277 extra => { list => [ 'Foo', 'Bar' ] },
278 is_auto_increment => 0,
279 is_nullable => 0,
280 is_foreign_key => 0,
281 is_unique => 0 );
282
283my $field5_sql = SQL::Translator::Producer::PostgreSQL::create_field($field5,{ postgres_version => 8.3 });
284
285is($field5_sql, 'enum_field mytable_enum_field_type NOT NULL', 'Create real enum field works');
286
90726ffd 287
288
289
290my $field6 = SQL::Translator::Schema::Field->new(
291 name => 'character',
292 table => $table,
293 data_type => 'character',
294 size => '123',
295 default_value => 'foobar',
296 is_auto_increment => 0,
297 is_nullable => 0,
298 is_foreign_key => 0,
299 is_unique => 0);
300
301my $field7 = SQL::Translator::Schema::Field->new(
302 name => 'character',
303 table => $table,
304 data_type => 'character',
305 size => '123',
306 default_value => undef,
307 is_auto_increment => 0,
308 is_nullable => 0,
309 is_foreign_key => 0,
310 is_unique => 0);
311
312$alter_field = SQL::Translator::Producer::PostgreSQL::alter_field($field6,
313 $field7);
314
315is($alter_field, q(ALTER TABLE mytable ALTER COLUMN character DROP DEFAULT), 'DROP DEFAULT');
316
317$field7->default_value(q(foo'bar'));
318
319$alter_field = SQL::Translator::Producer::PostgreSQL::alter_field($field6,
320 $field7);
321
322is($alter_field, q(ALTER TABLE mytable ALTER COLUMN character SET DEFAULT 'foo''bar'''), 'DEFAULT with escaping');
323
324$field7->default_value(\q(foobar));
325
326$alter_field = SQL::Translator::Producer::PostgreSQL::alter_field($field6,
327 $field7);
328
329is($alter_field, q(ALTER TABLE mytable ALTER COLUMN character SET DEFAULT foobar), 'DEFAULT unescaped if scalarref');
330
331$field7->is_nullable(1);
332$field7->default_value(q(foobar));
333
334$alter_field = SQL::Translator::Producer::PostgreSQL::alter_field($field6,
335 $field7);
336
337is($alter_field, q(ALTER TABLE mytable ALTER COLUMN character DROP NOT NULL), 'DROP NOT NULL');
338
ad258776 339my $field8 = SQL::Translator::Schema::Field->new( name => 'ts_field',
340 table => $table,
341 data_type => 'timestamp with time zone',
342 size => 6,
343 is_auto_increment => 0,
344 is_nullable => 0,
345 is_foreign_key => 0,
346 is_unique => 0 );
347
348my $field8_sql = SQL::Translator::Producer::PostgreSQL::create_field($field8,{ postgres_version => 8.3 });
349
350is($field8_sql, 'ts_field timestamp(6) with time zone NOT NULL', 'timestamp with precision');
351
352my $field9 = SQL::Translator::Schema::Field->new( name => 'time_field',
353 table => $table,
354 data_type => 'time with time zone',
355 size => 6,
356 is_auto_increment => 0,
357 is_nullable => 0,
358 is_foreign_key => 0,
359 is_unique => 0 );
360
361my $field9_sql = SQL::Translator::Producer::PostgreSQL::create_field($field9,{ postgres_version => 8.3 });
362
363is($field9_sql, 'time_field time(6) with time zone NOT NULL', 'time with precision');
364
365my $field10 = SQL::Translator::Schema::Field->new( name => 'interval_field',
366 table => $table,
367 data_type => 'interval',
368 size => 6,
369 is_auto_increment => 0,
370 is_nullable => 0,
371 is_foreign_key => 0,
372 is_unique => 0 );
373
374my $field10_sql = SQL::Translator::Producer::PostgreSQL::create_field($field10,{ postgres_version => 8.3 });
375
376is($field10_sql, 'interval_field interval(6) NOT NULL', 'time with precision');
377
378
379my $field11 = SQL::Translator::Schema::Field->new( name => 'time_field',
380 table => $table,
381 data_type => 'time without time zone',
382 size => 6,
383 is_auto_increment => 0,
384 is_nullable => 0,
385 is_foreign_key => 0,
386 is_unique => 0 );
387
388my $field11_sql = SQL::Translator::Producer::PostgreSQL::create_field($field11,{ postgres_version => 8.3 });
389
390is($field11_sql, 'time_field time(6) without time zone NOT NULL', 'time with precision');
391
392
393
394my $field12 = SQL::Translator::Schema::Field->new( name => 'time_field',
395 table => $table,
396 data_type => 'timestamp',
397 is_auto_increment => 0,
398 is_nullable => 0,
399 is_foreign_key => 0,
400 is_unique => 0 );
401
402my $field12_sql = SQL::Translator::Producer::PostgreSQL::create_field($field12,{ postgres_version => 8.3 });
403
404is($field12_sql, 'time_field timestamp NOT NULL', 'time with precision');
405
79f55d7e 406my $field13 = SQL::Translator::Schema::Field->new( name => 'enum_field_with_type_name',
407 table => $table,
408 data_type => 'enum',
409 extra => { list => [ 'Foo', 'Bar' ],
410 custom_type_name => 'real_enum_type' },
411 is_auto_increment => 0,
412 is_nullable => 0,
413 is_foreign_key => 0,
414 is_unique => 0 );
415
416my $field13_sql = SQL::Translator::Producer::PostgreSQL::create_field($field13,{ postgres_version => 8.3 });
417
418is($field13_sql, 'enum_field_with_type_name real_enum_type NOT NULL', 'Create real enum field works');
419
90726ffd 420
bc8e2aa1 421{
422 # let's test default values! -- rjbs, 2008-09-30
423 my %field = (
424 table => $table,
425 data_type => 'VARCHAR',
426 size => 10,
427 is_auto_increment => 0,
428 is_nullable => 1,
429 is_foreign_key => 0,
430 is_unique => 0,
431 );
432
433 {
434 my $simple_default = SQL::Translator::Schema::Field->new(
435 %field,
436 name => 'str_default',
437 default_value => 'foo',
438 );
439
440 is(
441 $PRODUCER->($simple_default),
442 q{str_default character varying(10) DEFAULT 'foo'},
443 'default str',
444 );
445 }
446
447 {
448 my $null_default = SQL::Translator::Schema::Field->new(
449 %field,
450 name => 'null_default',
451 default_value => \'NULL',
452 );
453
454 is(
455 $PRODUCER->($null_default),
456 q{null_default character varying(10) DEFAULT NULL},
457 'default null',
458 );
459 }
460
461 {
462 my $null_default = SQL::Translator::Schema::Field->new(
463 %field,
464 name => 'null_default_2',
465 default_value => 'NULL', # XXX: this should go away
466 );
467
468 is(
469 $PRODUCER->($null_default),
470 q{null_default_2 character varying(10) DEFAULT NULL},
471 'default null from special cased string',
472 );
473 }
474
475 {
476 my $func_default = SQL::Translator::Schema::Field->new(
477 %field,
478 name => 'func_default',
479 default_value => \'func(funky)',
480 );
481
482 is(
483 $PRODUCER->($func_default),
484 q{func_default character varying(10) DEFAULT func(funky)},
485 'unquoted default from scalar ref',
486 );
487 }
488}
489
490
296c2701 491my $view1 = SQL::Translator::Schema::View->new(
492 name => 'view_foo',
493 fields => [qw/id name/],
494 sql => 'SELECT id, name FROM thing',
495);
496my $create_opts = { add_replace_view => 1, no_comments => 1 };
497my $view1_sql1 = SQL::Translator::Producer::PostgreSQL::create_view($view1, $create_opts);
498
f59b2c0e 499my $view_sql_replace = "CREATE VIEW view_foo ( id, name ) AS
296c2701 500 SELECT id, name FROM thing
f59b2c0e 501";
296c2701 502is($view1_sql1, $view_sql_replace, 'correct "CREATE OR REPLACE VIEW" SQL');
503
504my $view2 = SQL::Translator::Schema::View->new(
505 name => 'view_foo2',
506 sql => 'SELECT id, name FROM thing',
507 extra => {
508 'temporary' => '1',
509 'check_option' => 'cascaded',
510 },
511);
512my $create2_opts = { add_replace_view => 1, no_comments => 1 };
513my $view2_sql1 = SQL::Translator::Producer::PostgreSQL::create_view($view2, $create2_opts);
514
f59b2c0e 515my $view2_sql_replace = "CREATE TEMPORARY VIEW view_foo2 AS
296c2701 516 SELECT id, name FROM thing
f59b2c0e 517 WITH CASCADED CHECK OPTION";
296c2701 518is($view2_sql1, $view2_sql_replace, 'correct "CREATE OR REPLACE VIEW" SQL 2');
5f31ed66 519
520{
521 my $table = SQL::Translator::Schema::Table->new( name => 'foobar', fields => [qw( foo bar )] );
522 my $quote = { quote_table_names => '"', quote_field_names => '"' };
523
524 {
525 my $index = $table->add_index(name => 'myindex', fields => ['foo']);
526 my ($def) = SQL::Translator::Producer::PostgreSQL::create_index($index);
527 is($def, "CREATE INDEX myindex on foobar (foo)", 'index created');
528 ($def) = SQL::Translator::Producer::PostgreSQL::create_index($index, $quote);
529 is($def, 'CREATE INDEX "myindex" on "foobar" ("foo")', 'index created w/ quotes');
530 }
531
532 {
533 my $index = $table->add_index(name => 'myindex', fields => ['lower(foo)']);
534 my ($def) = SQL::Translator::Producer::PostgreSQL::create_index($index);
535 is($def, "CREATE INDEX myindex on foobar (lower(foo))", 'index created');
536 ($def) = SQL::Translator::Producer::PostgreSQL::create_index($index, $quote);
537 is($def, 'CREATE INDEX "myindex" on "foobar" (lower(foo))', 'index created w/ quotes');
538 }
539
540 {
541 my $index = $table->add_index(name => 'myindex', fields => ['bar', 'lower(foo)']);
542 my ($def) = SQL::Translator::Producer::PostgreSQL::create_index($index);
543 is($def, "CREATE INDEX myindex on foobar (bar, lower(foo))", 'index created');
544 ($def) = SQL::Translator::Producer::PostgreSQL::create_index($index, $quote);
545 is($def, 'CREATE INDEX "myindex" on "foobar" ("bar", lower(foo))', 'index created w/ quotes');
546 }
547
548 {
549 my $constr = $table->add_constraint(name => 'constr', type => UNIQUE, fields => ['foo']);
550 my ($def) = SQL::Translator::Producer::PostgreSQL::create_constraint($constr);
551 is($def->[0], 'CONSTRAINT constr UNIQUE (foo)', 'constraint created');
552 ($def) = SQL::Translator::Producer::PostgreSQL::create_constraint($constr, $quote);
553 is($def->[0], 'CONSTRAINT "constr" UNIQUE ("foo")', 'constraint created w/ quotes');
554 }
555
556 {
557 my $constr = $table->add_constraint(name => 'constr', type => UNIQUE, fields => ['lower(foo)']);
558 my ($def) = SQL::Translator::Producer::PostgreSQL::create_constraint($constr);
559 is($def->[0], 'CONSTRAINT constr UNIQUE (lower(foo))', 'constraint created');
560 ($def) = SQL::Translator::Producer::PostgreSQL::create_constraint($constr, $quote);
561 is($def->[0], 'CONSTRAINT "constr" UNIQUE (lower(foo))', 'constraint created w/ quotes');
562 }
563
564 {
565 my $constr = $table->add_constraint(name => 'constr', type => UNIQUE, fields => ['bar', 'lower(foo)']);
566 my ($def) = SQL::Translator::Producer::PostgreSQL::create_constraint($constr);
567 is($def->[0], 'CONSTRAINT constr UNIQUE (bar, lower(foo))', 'constraint created');
568 ($def) = SQL::Translator::Producer::PostgreSQL::create_constraint($constr, $quote);
569 is($def->[0], 'CONSTRAINT "constr" UNIQUE ("bar", lower(foo))', 'constraint created w/ quotes');
570 }
571}
25c74c43 572
573my $drop_view_opts1 = { add_drop_view => 1, no_comments => 1, postgres_version => 8.001 };
574my $drop_view_8_1_produced = SQL::Translator::Producer::PostgreSQL::create_view($view1, $drop_view_opts1);
575
576my $drop_view_8_1_expected = "DROP VIEW view_foo;
577CREATE VIEW view_foo ( id, name ) AS
578 SELECT id, name FROM thing
579";
aee4b66e 580
25c74c43 581is($drop_view_8_1_produced, $drop_view_8_1_expected, "My DROP VIEW statement for 8.1 is correct");
582
583my $drop_view_opts2 = { add_drop_view => 1, no_comments => 1, postgres_version => 9.001 };
584my $drop_view_9_1_produced = SQL::Translator::Producer::PostgreSQL::create_view($view1, $drop_view_opts2);
585
586my $drop_view_9_1_expected = "DROP VIEW IF EXISTS view_foo;
587CREATE VIEW view_foo ( id, name ) AS
588 SELECT id, name FROM thing
589";
aee4b66e 590
25c74c43 591is($drop_view_9_1_produced, $drop_view_9_1_expected, "My DROP VIEW statement for 9.1 is correct");