@@ -102,23 +102,26 @@ SELECT count(*) FROM calamity.part_test;
102
102
(1 row)
103
103
104
104
DELETE FROM calamity.part_test;
105
+ /* test function create_single_range_partition() */
106
+ SELECT create_single_range_partition(NULL, NULL::INT4, NULL); /* not ok */
107
+ ERROR: 'parent_relid' should not be NULL
105
108
/* test function create_range_partitions_internal() */
106
- SELECT create_range_partitions_internal(NULL, '{}'::INT[], NULL, NULL); /* not ok */
109
+ SELECT create_range_partitions_internal(NULL, '{}'::INT[], NULL, NULL); /* not ok */
107
110
ERROR: 'parent_relid' should not be NULL
108
111
SELECT create_range_partitions_internal('calamity.part_test',
109
- NULL::INT[], NULL, NULL); /* not ok */
112
+ NULL::INT[], NULL, NULL); /* not ok */
110
113
ERROR: 'bounds' should not be NULL
111
114
SELECT create_range_partitions_internal('calamity.part_test', '{1}'::INT[],
112
- '{part_1}'::TEXT[], NULL); /* not ok */
115
+ '{part_1}'::TEXT[], NULL); /* not ok */
113
116
ERROR: wrong length of 'partition_names' array
114
117
SELECT create_range_partitions_internal('calamity.part_test', '{1}'::INT[],
115
- NULL, '{tblspc_1}'::TEXT[]); /* not ok */
118
+ NULL, '{tblspc_1}'::TEXT[]); /* not ok */
116
119
ERROR: wrong length of 'tablespaces' array
117
120
SELECT create_range_partitions_internal('calamity.part_test',
118
- '{1, NULL}'::INT[], NULL, NULL); /* not ok */
121
+ '{1, NULL}'::INT[], NULL, NULL); /* not ok */
119
122
ERROR: only first bound can be NULL
120
123
SELECT create_range_partitions_internal('calamity.part_test',
121
- '{2, 1}'::INT[], NULL, NULL); /* not ok */
124
+ '{2, 1}'::INT[], NULL, NULL); /* not ok */
122
125
ERROR: 'bounds' array must be ascending
123
126
/* test function create_hash_partitions() */
124
127
SELECT create_hash_partitions('calamity.part_test', 'val', 2,
@@ -244,24 +247,45 @@ SELECT build_hash_condition('text', 'val', 10, NULL) IS NULL;
244
247
SELECT build_hash_condition('calamity.part_test', 'val', 10, 1);
245
248
ERROR: no hash function for type calamity.part_test
246
249
/* check function build_range_condition() */
247
- SELECT build_range_condition('calamity.part_test', 'val', 10, 20);
250
+ SELECT build_range_condition(NULL, 'val', 10, 20); /* not ok */
251
+ ERROR: 'partition_relid' should not be NULL
252
+ SELECT build_range_condition('calamity.part_test', NULL, 10, 20); /* not ok */
253
+ ERROR: 'attribute' should not be NULL
254
+ SELECT build_range_condition('calamity.part_test', 'val', 10, 20); /* OK */
248
255
build_range_condition
249
256
------------------------------
250
257
((val >= 10) AND (val < 20))
251
258
(1 row)
252
259
253
- SELECT build_range_condition('calamity.part_test', 'val', 10, NULL);
260
+ SELECT build_range_condition('calamity.part_test', 'val', 10, NULL); /* OK */
254
261
build_range_condition
255
262
-----------------------
256
263
((val >= 10))
257
264
(1 row)
258
265
259
- SELECT build_range_condition('calamity.part_test', 'val', NULL, 10);
266
+ SELECT build_range_condition('calamity.part_test', 'val', NULL, 10); /* OK */
260
267
build_range_condition
261
268
-----------------------
262
269
((val < 10))
263
270
(1 row)
264
271
272
+ /* check function validate_interval_value() */
273
+ SELECT validate_interval_value(NULL, 'val', 2, '1 mon'); /* not ok */
274
+ ERROR: 'partrel' should not be NULL
275
+ SELECT validate_interval_value('calamity.part_test', NULL, 2, '1 mon'); /* not ok */
276
+ ERROR: 'attname' should not be NULL
277
+ SELECT validate_interval_value('calamity.part_test', 'val', NULL, '1 mon'); /* not ok */
278
+ ERROR: 'parttype' should not be NULL
279
+ SELECT validate_interval_value('calamity.part_test', 'val', 2, '1 mon'); /* not ok */
280
+ ERROR: invalid input syntax for integer: "1 mon"
281
+ SELECT validate_interval_value('calamity.part_test', 'val', 1, '1 mon'); /* not ok */
282
+ ERROR: interval should be NULL for HASH partitioned table
283
+ SELECT validate_interval_value('calamity.part_test', 'val', 2, NULL); /* OK */
284
+ validate_interval_value
285
+ -------------------------
286
+ t
287
+ (1 row)
288
+
265
289
/* check function validate_relname() */
266
290
SELECT validate_relname('calamity.part_test');
267
291
validate_relname
@@ -327,12 +351,16 @@ SELECT get_partition_key_type(NULL) IS NULL;
327
351
(1 row)
328
352
329
353
/* check function build_check_constraint_name_attnum() */
330
- SELECT build_check_constraint_name('calamity.part_test', 1::int2);
354
+ SELECT build_check_constraint_name('calamity.part_test', 1::int2); /* OK */
331
355
build_check_constraint_name
332
356
-----------------------------
333
357
pathman_part_test_1_check
334
358
(1 row)
335
359
360
+ SELECT build_check_constraint_name(0::REGCLASS, 1::int2); /* not ok */
361
+ ERROR: relation "0" does not exist
362
+ SELECT build_check_constraint_name('calamity.part_test', -1::int2); /* not ok */
363
+ ERROR: invalid attribute number -1
336
364
SELECT build_check_constraint_name('calamity.part_test', NULL::int2) IS NULL;
337
365
?column?
338
366
----------
@@ -352,12 +380,16 @@ SELECT build_check_constraint_name(NULL, NULL::int2) IS NULL;
352
380
(1 row)
353
381
354
382
/* check function build_check_constraint_name_attname() */
355
- SELECT build_check_constraint_name('calamity.part_test', 'val');
383
+ SELECT build_check_constraint_name('calamity.part_test', 'val'); /* OK */
356
384
build_check_constraint_name
357
385
-----------------------------
358
386
pathman_part_test_1_check
359
387
(1 row)
360
388
389
+ SELECT build_check_constraint_name(0::REGCLASS, 'val'); /* not ok */
390
+ ERROR: relation "0" does not exist
391
+ SELECT build_check_constraint_name('calamity.part_test', 'nocol'); /* not ok */
392
+ ERROR: relation "part_test" has no column "nocol"
361
393
SELECT build_check_constraint_name('calamity.part_test', NULL::text) IS NULL;
362
394
?column?
363
395
----------
@@ -377,36 +409,64 @@ SELECT build_check_constraint_name(NULL, NULL::text) IS NULL;
377
409
(1 row)
378
410
379
411
/* check function build_update_trigger_name() */
380
- SELECT build_update_trigger_name('calamity.part_test');
412
+ SELECT build_update_trigger_name('calamity.part_test'); /* OK */
381
413
build_update_trigger_name
382
414
---------------------------
383
415
part_test_upd_trig
384
416
(1 row)
385
417
418
+ SELECT build_update_trigger_name(0::REGCLASS); /* not ok */
419
+ ERROR: relation "0" does not exist
386
420
SELECT build_update_trigger_name(NULL) IS NULL;
387
421
?column?
388
422
----------
389
423
t
390
424
(1 row)
391
425
392
426
/* check function build_update_trigger_func_name() */
393
- SELECT build_update_trigger_func_name('calamity.part_test');
427
+ SELECT build_update_trigger_func_name('calamity.part_test'); /* OK */
394
428
build_update_trigger_func_name
395
429
----------------------------------
396
430
calamity.part_test_upd_trig_func
397
431
(1 row)
398
432
433
+ SELECT build_update_trigger_func_name(0::REGCLASS); /* not ok */
434
+ ERROR: relation "0" does not exist
399
435
SELECT build_update_trigger_func_name(NULL) IS NULL;
400
436
?column?
401
437
----------
402
438
t
403
439
(1 row)
404
440
441
+ /* check function build_sequence_name() */
442
+ SELECT build_sequence_name('calamity.part_test'); /* OK */
443
+ build_sequence_name
444
+ ------------------------
445
+ calamity.part_test_seq
446
+ (1 row)
447
+
448
+ SELECT build_sequence_name(1::REGCLASS); /* not ok */
449
+ ERROR: relation "1" does not exist
450
+ SELECT build_sequence_name(NULL) IS NULL;
451
+ ?column?
452
+ ----------
453
+ t
454
+ (1 row)
455
+
456
+ /* check function partition_table_concurrently() */
457
+ SELECT partition_table_concurrently(1::REGCLASS); /* not ok */
458
+ ERROR: relation "1" has no partitions
459
+ SELECT partition_table_concurrently('pg_class', 0); /* not ok */
460
+ ERROR: 'batch_size' should not be less than 1 or greater than 10000
461
+ SELECT partition_table_concurrently('pg_class', 1, 1E-5); /* not ok */
462
+ ERROR: 'sleep_time' should not be less than 0.5
463
+ SELECT partition_table_concurrently('pg_class'); /* not ok */
464
+ ERROR: relation "pg_class" has no partitions
405
465
/* check function stop_concurrent_part_task() */
406
- SELECT stop_concurrent_part_task(1::regclass);
466
+ SELECT stop_concurrent_part_task(1::REGCLASS); /* not ok */
407
467
ERROR: cannot find worker for relation "1"
408
468
/* check function drop_range_partition_expand_next() */
409
- SELECT drop_range_partition_expand_next('pg_class');
469
+ SELECT drop_range_partition_expand_next('pg_class'); /* not ok */
410
470
ERROR: relation "pg_class" is not a partition
411
471
SELECT drop_range_partition_expand_next(NULL) IS NULL;
412
472
?column?
@@ -453,6 +513,23 @@ SELECT generate_range_bounds('1-jan-2017'::DATE,
453
513
{01-01-2017,01-02-2017,01-03-2017,01-04-2017,01-05-2017}
454
514
(1 row)
455
515
516
+ SELECT check_range_available(NULL, NULL::INT4, NULL); /* not ok */
517
+ ERROR: 'parent_relid' should not be NULL
518
+ SELECT check_range_available('pg_class', 1, 10); /* OK (not partitioned) */
519
+ WARNING: relation "pg_class" is not partitioned
520
+ check_range_available
521
+ -----------------------
522
+
523
+ (1 row)
524
+
525
+ SELECT has_update_trigger(NULL);
526
+ has_update_trigger
527
+ --------------------
528
+
529
+ (1 row)
530
+
531
+ SELECT has_update_trigger(0::REGCLASS); /* not ok */
532
+ ERROR: relation "0" does not exist
456
533
/* check invoke_on_partition_created_callback() */
457
534
CREATE FUNCTION calamity.dummy_cb(arg jsonb) RETURNS void AS $$
458
535
begin
@@ -463,7 +540,7 @@ $$ LANGUAGE plpgsql;
463
540
SELECT invoke_on_partition_created_callback(NULL, 'calamity.part_test', 1);
464
541
ERROR: 'parent_relid' should not be NULL
465
542
SELECT invoke_on_partition_created_callback('calamity.part_test', NULL, 1);
466
- ERROR: 'partition ' should not be NULL
543
+ ERROR: 'partition_relid ' should not be NULL
467
544
SELECT invoke_on_partition_created_callback('calamity.part_test', 'calamity.part_test', 0);
468
545
invoke_on_partition_created_callback
469
546
--------------------------------------
@@ -519,6 +596,8 @@ DROP FUNCTION calamity.dummy_cb(arg jsonb);
519
596
/* check function add_to_pathman_config() -- PHASE #1 */
520
597
SELECT add_to_pathman_config(NULL, 'val'); /* no table */
521
598
ERROR: 'parent_relid' should not be NULL
599
+ SELECT add_to_pathman_config(0::REGCLASS, 'val'); /* no table (oid) */
600
+ ERROR: relation "0" does not exist
522
601
SELECT add_to_pathman_config('calamity.part_test', NULL); /* no column */
523
602
ERROR: 'attname' should not be NULL
524
603
SELECT add_to_pathman_config('calamity.part_test', 'V_A_L'); /* wrong column */
0 commit comments