@@ -102,23 +102,26 @@ SELECT count(*) FROM calamity.part_test;
102102(1 row)
103103
104104DELETE 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
105108/* 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 */
107110ERROR: 'parent_relid' should not be NULL
108111SELECT create_range_partitions_internal('calamity.part_test',
109- NULL::INT[], NULL, NULL); /* not ok */
112+ NULL::INT[], NULL, NULL); /* not ok */
110113ERROR: 'bounds' should not be NULL
111114SELECT create_range_partitions_internal('calamity.part_test', '{1}'::INT[],
112- '{part_1}'::TEXT[], NULL); /* not ok */
115+ '{part_1}'::TEXT[], NULL); /* not ok */
113116ERROR: wrong length of 'partition_names' array
114117SELECT create_range_partitions_internal('calamity.part_test', '{1}'::INT[],
115- NULL, '{tblspc_1}'::TEXT[]); /* not ok */
118+ NULL, '{tblspc_1}'::TEXT[]); /* not ok */
116119ERROR: wrong length of 'tablespaces' array
117120SELECT create_range_partitions_internal('calamity.part_test',
118- '{1, NULL}'::INT[], NULL, NULL); /* not ok */
121+ '{1, NULL}'::INT[], NULL, NULL); /* not ok */
119122ERROR: only first bound can be NULL
120123SELECT create_range_partitions_internal('calamity.part_test',
121- '{2, 1}'::INT[], NULL, NULL); /* not ok */
124+ '{2, 1}'::INT[], NULL, NULL); /* not ok */
122125ERROR: 'bounds' array must be ascending
123126/* test function create_hash_partitions() */
124127SELECT create_hash_partitions('calamity.part_test', 'val', 2,
@@ -244,24 +247,45 @@ SELECT build_hash_condition('text', 'val', 10, NULL) IS NULL;
244247SELECT build_hash_condition('calamity.part_test', 'val', 10, 1);
245248ERROR: no hash function for type calamity.part_test
246249/* 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 */
248255 build_range_condition
249256------------------------------
250257 ((val >= 10) AND (val < 20))
251258(1 row)
252259
253- SELECT build_range_condition('calamity.part_test', 'val', 10, NULL);
260+ SELECT build_range_condition('calamity.part_test', 'val', 10, NULL); /* OK */
254261 build_range_condition
255262-----------------------
256263 ((val >= 10))
257264(1 row)
258265
259- SELECT build_range_condition('calamity.part_test', 'val', NULL, 10);
266+ SELECT build_range_condition('calamity.part_test', 'val', NULL, 10); /* OK */
260267 build_range_condition
261268-----------------------
262269 ((val < 10))
263270(1 row)
264271
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+
265289/* check function validate_relname() */
266290SELECT validate_relname('calamity.part_test');
267291 validate_relname
@@ -327,12 +351,16 @@ SELECT get_partition_key_type(NULL) IS NULL;
327351(1 row)
328352
329353/* 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 */
331355 build_check_constraint_name
332356-----------------------------
333357 pathman_part_test_1_check
334358(1 row)
335359
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
336364SELECT build_check_constraint_name('calamity.part_test', NULL::int2) IS NULL;
337365 ?column?
338366----------
@@ -352,12 +380,16 @@ SELECT build_check_constraint_name(NULL, NULL::int2) IS NULL;
352380(1 row)
353381
354382/* 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 */
356384 build_check_constraint_name
357385-----------------------------
358386 pathman_part_test_1_check
359387(1 row)
360388
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"
361393SELECT build_check_constraint_name('calamity.part_test', NULL::text) IS NULL;
362394 ?column?
363395----------
@@ -377,36 +409,64 @@ SELECT build_check_constraint_name(NULL, NULL::text) IS NULL;
377409(1 row)
378410
379411/* 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 */
381413 build_update_trigger_name
382414---------------------------
383415 part_test_upd_trig
384416(1 row)
385417
418+ SELECT build_update_trigger_name(0::REGCLASS); /* not ok */
419+ ERROR: relation "0" does not exist
386420SELECT build_update_trigger_name(NULL) IS NULL;
387421 ?column?
388422----------
389423 t
390424(1 row)
391425
392426/* 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 */
394428 build_update_trigger_func_name
395429----------------------------------
396430 calamity.part_test_upd_trig_func
397431(1 row)
398432
433+ SELECT build_update_trigger_func_name(0::REGCLASS); /* not ok */
434+ ERROR: relation "0" does not exist
399435SELECT build_update_trigger_func_name(NULL) IS NULL;
400436 ?column?
401437----------
402438 t
403439(1 row)
404440
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
405465/* check function stop_concurrent_part_task() */
406- SELECT stop_concurrent_part_task(1::regclass);
466+ SELECT stop_concurrent_part_task(1::REGCLASS); /* not ok */
407467ERROR: cannot find worker for relation "1"
408468/* 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 */
410470ERROR: relation "pg_class" is not a partition
411471SELECT drop_range_partition_expand_next(NULL) IS NULL;
412472 ?column?
@@ -453,6 +513,23 @@ SELECT generate_range_bounds('1-jan-2017'::DATE,
453513 {01-01-2017,01-02-2017,01-03-2017,01-04-2017,01-05-2017}
454514(1 row)
455515
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
456533/* check invoke_on_partition_created_callback() */
457534CREATE FUNCTION calamity.dummy_cb(arg jsonb) RETURNS void AS $$
458535 begin
@@ -463,7 +540,7 @@ $$ LANGUAGE plpgsql;
463540SELECT invoke_on_partition_created_callback(NULL, 'calamity.part_test', 1);
464541ERROR: 'parent_relid' should not be NULL
465542SELECT 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
467544SELECT invoke_on_partition_created_callback('calamity.part_test', 'calamity.part_test', 0);
468545 invoke_on_partition_created_callback
469546--------------------------------------
@@ -519,6 +596,8 @@ DROP FUNCTION calamity.dummy_cb(arg jsonb);
519596/* check function add_to_pathman_config() -- PHASE #1 */
520597SELECT add_to_pathman_config(NULL, 'val'); /* no table */
521598ERROR: '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
522601SELECT add_to_pathman_config('calamity.part_test', NULL); /* no column */
523602ERROR: 'attname' should not be NULL
524603SELECT add_to_pathman_config('calamity.part_test', 'V_A_L'); /* wrong column */
0 commit comments