@@ -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,
@@ -219,24 +222,43 @@ SELECT drop_partitions('calamity.part_test', true);
219
222
220
223
DELETE FROM calamity.part_test;
221
224
/* check function build_range_condition() */
222
- SELECT build_range_condition('calamity.part_test', 'val', 10, 20);
225
+ SELECT build_range_condition(NULL, 'val', 10, 20); /* not ok */
226
+ ERROR: 'partition_relid' should not be NULL
227
+ SELECT build_range_condition('calamity.part_test', NULL, 10, 20); /* not ok */
228
+ ERROR: 'expression' should not be NULL
229
+ SELECT build_range_condition('calamity.part_test', 'val', 10, 20); /* OK */
223
230
build_range_condition
224
231
------------------------------
225
232
((val >= 10) AND (val < 20))
226
233
(1 row)
227
234
228
- SELECT build_range_condition('calamity.part_test', 'val', 10, NULL);
235
+ SELECT build_range_condition('calamity.part_test', 'val', 10, NULL); /* OK */
229
236
build_range_condition
230
237
-----------------------
231
238
((val >= 10))
232
239
(1 row)
233
240
234
- SELECT build_range_condition('calamity.part_test', 'val', NULL, 10);
241
+ SELECT build_range_condition('calamity.part_test', 'val', NULL, 10); /* OK */
235
242
build_range_condition
236
243
-----------------------
237
244
((val < 10))
238
245
(1 row)
239
246
247
+ /* check function validate_interval_value() */
248
+ SELECT validate_interval_value(NULL, 2, '1 mon'); /* not ok */
249
+ ERROR: 'atttype' should not be NULL
250
+ SELECT validate_interval_value(1186, NULL, '1 mon'); /* not ok */
251
+ ERROR: 'parttype' should not be NULL
252
+ SELECT validate_interval_value(23, 2, '1 mon'); /* not ok */
253
+ ERROR: invalid input syntax for integer: "1 mon"
254
+ SELECT validate_interval_value(1186, 1, '1 mon'); /* not ok */
255
+ ERROR: interval should be NULL for HASH partitioned table
256
+ SELECT validate_interval_value(1186, 2, NULL); /* OK */
257
+ validate_interval_value
258
+ -------------------------
259
+ t
260
+ (1 row)
261
+
240
262
/* check function validate_relname() */
241
263
SELECT validate_relname('calamity.part_test');
242
264
validate_relname
@@ -302,49 +324,79 @@ SELECT get_partition_key_type(NULL) IS NULL;
302
324
(1 row)
303
325
304
326
/* check function build_check_constraint_name() */
305
- SELECT build_check_constraint_name('calamity.part_test');
327
+ SELECT build_check_constraint_name('calamity.part_test'); /* OK */
306
328
build_check_constraint_name
307
329
-----------------------------
308
330
pathman_part_test_check
309
331
(1 row)
310
332
333
+ SELECT build_check_constraint_name(0::REGCLASS); /* not ok */
334
+ ERROR: relation "0" does not exist
311
335
SELECT build_check_constraint_name(NULL) IS NULL;
312
336
?column?
313
337
----------
314
338
t
315
339
(1 row)
316
340
317
341
/* check function build_update_trigger_name() */
318
- SELECT build_update_trigger_name('calamity.part_test');
342
+ SELECT build_update_trigger_name('calamity.part_test'); /* OK */
319
343
build_update_trigger_name
320
344
---------------------------
321
345
part_test_upd_trig
322
346
(1 row)
323
347
348
+ SELECT build_update_trigger_name(0::REGCLASS); /* not ok */
349
+ ERROR: relation "0" does not exist
324
350
SELECT build_update_trigger_name(NULL) IS NULL;
325
351
?column?
326
352
----------
327
353
t
328
354
(1 row)
329
355
330
356
/* check function build_update_trigger_func_name() */
331
- SELECT build_update_trigger_func_name('calamity.part_test');
357
+ SELECT build_update_trigger_func_name('calamity.part_test'); /* OK */
332
358
build_update_trigger_func_name
333
359
----------------------------------
334
360
calamity.part_test_upd_trig_func
335
361
(1 row)
336
362
363
+ SELECT build_update_trigger_func_name(0::REGCLASS); /* not ok */
364
+ ERROR: relation "0" does not exist
337
365
SELECT build_update_trigger_func_name(NULL) IS NULL;
338
366
?column?
339
367
----------
340
368
t
341
369
(1 row)
342
370
371
+ /* check function build_sequence_name() */
372
+ SELECT build_sequence_name('calamity.part_test'); /* OK */
373
+ build_sequence_name
374
+ ------------------------
375
+ calamity.part_test_seq
376
+ (1 row)
377
+
378
+ SELECT build_sequence_name(1::REGCLASS); /* not ok */
379
+ ERROR: relation "1" does not exist
380
+ SELECT build_sequence_name(NULL) IS NULL;
381
+ ?column?
382
+ ----------
383
+ t
384
+ (1 row)
385
+
386
+ /* check function partition_table_concurrently() */
387
+ SELECT partition_table_concurrently(1::REGCLASS); /* not ok */
388
+ ERROR: relation "1" has no partitions
389
+ SELECT partition_table_concurrently('pg_class', 0); /* not ok */
390
+ ERROR: 'batch_size' should not be less than 1 or greater than 10000
391
+ SELECT partition_table_concurrently('pg_class', 1, 1E-5); /* not ok */
392
+ ERROR: 'sleep_time' should not be less than 0.5
393
+ SELECT partition_table_concurrently('pg_class'); /* not ok */
394
+ ERROR: relation "pg_class" has no partitions
343
395
/* check function stop_concurrent_part_task() */
344
- SELECT stop_concurrent_part_task(1::regclass);
396
+ SELECT stop_concurrent_part_task(1::REGCLASS); /* not ok */
345
397
ERROR: cannot find worker for relation "1"
346
398
/* check function drop_range_partition_expand_next() */
347
- SELECT drop_range_partition_expand_next('pg_class');
399
+ SELECT drop_range_partition_expand_next('pg_class'); /* not ok */
348
400
ERROR: relation "pg_class" is not a partition
349
401
SELECT drop_range_partition_expand_next(NULL) IS NULL;
350
402
?column?
@@ -391,6 +443,23 @@ SELECT generate_range_bounds('1-jan-2017'::DATE,
391
443
{01-01-2017,01-02-2017,01-03-2017,01-04-2017,01-05-2017}
392
444
(1 row)
393
445
446
+ SELECT check_range_available(NULL, NULL::INT4, NULL); /* not ok */
447
+ ERROR: 'parent_relid' should not be NULL
448
+ SELECT check_range_available('pg_class', 1, 10); /* OK (not partitioned) */
449
+ WARNING: relation "pg_class" is not partitioned
450
+ check_range_available
451
+ -----------------------
452
+
453
+ (1 row)
454
+
455
+ SELECT has_update_trigger(NULL);
456
+ has_update_trigger
457
+ --------------------
458
+
459
+ (1 row)
460
+
461
+ SELECT has_update_trigger(0::REGCLASS); /* not ok */
462
+ ERROR: relation "0" does not exist
394
463
/* check invoke_on_partition_created_callback() */
395
464
CREATE FUNCTION calamity.dummy_cb(arg jsonb) RETURNS void AS $$
396
465
begin
@@ -401,7 +470,7 @@ $$ LANGUAGE plpgsql;
401
470
SELECT invoke_on_partition_created_callback(NULL, 'calamity.part_test', 1);
402
471
ERROR: 'parent_relid' should not be NULL
403
472
SELECT invoke_on_partition_created_callback('calamity.part_test', NULL, 1);
404
- ERROR: 'partition ' should not be NULL
473
+ ERROR: 'partition_relid ' should not be NULL
405
474
SELECT invoke_on_partition_created_callback('calamity.part_test', 'calamity.part_test', 0);
406
475
invoke_on_partition_created_callback
407
476
--------------------------------------
@@ -457,6 +526,8 @@ DROP FUNCTION calamity.dummy_cb(arg jsonb);
457
526
/* check function add_to_pathman_config() -- PHASE #1 */
458
527
SELECT add_to_pathman_config(NULL, 'val'); /* no table */
459
528
ERROR: 'parent_relid' should not be NULL
529
+ SELECT add_to_pathman_config(0::REGCLASS, 'val'); /* no table (oid) */
530
+ ERROR: relation "0" does not exist
460
531
SELECT add_to_pathman_config('calamity.part_test', NULL); /* no column */
461
532
ERROR: 'expression' should not be NULL
462
533
SELECT add_to_pathman_config('calamity.part_test', 'V_A_L'); /* wrong column */
0 commit comments