@@ -354,6 +354,14 @@ def test_foreign_table(self):
354
354
master .start ()
355
355
master .psql ('postgres' , 'create extension pg_pathman' )
356
356
master .psql ('postgres' , 'create extension postgres_fdw' )
357
+
358
+ # RANGE partitioning test with FDW:
359
+ # - create range partitioned table in master
360
+ # - create foreign server
361
+ # - create foreign table and insert some data into it
362
+ # - attach foreign table to partitioned one
363
+ # - try inserting data into foreign partition via parent
364
+ # - drop partitions
357
365
master .psql (
358
366
'postgres' ,
359
367
'''create table abc(id serial, name text);
@@ -406,6 +414,34 @@ def test_foreign_table(self):
406
414
# Testing drop partitions (including foreign partitions)
407
415
master .safe_psql ('postgres' , 'select drop_partitions(\' abc\' )' )
408
416
417
+ # HASH partitioning with FDW:
418
+ # - create hash partitioned table in master
419
+ # - create foreign table
420
+ # - replace local partition with foreign one
421
+ # - insert data
422
+ # - drop partitions
423
+ master .psql (
424
+ 'postgres' ,
425
+ '''create table hash_test(id serial, name text);
426
+ select create_hash_partitions('hash_test', 'id', 2)''' )
427
+ fserv .safe_psql ('postgres' , 'create table f_hash_test(id serial, name text)' )
428
+
429
+ master .safe_psql (
430
+ 'postgres' ,
431
+ '''import foreign schema public limit to (f_hash_test)
432
+ from server fserv into public'''
433
+ )
434
+ master .safe_psql (
435
+ 'postgres' ,
436
+ 'select replace_hash_partition(\' hash_test_1\' , \' f_hash_test\' )' )
437
+ master .safe_psql ('postgres' , 'insert into hash_test select generate_series(1,10)' )
438
+
439
+ self .assertEqual (
440
+ master .safe_psql ('postgres' , 'select * from hash_test' ),
441
+ '1|\n 2|\n 5|\n 6|\n 8|\n 9|\n 3|\n 4|\n 7|\n 10|\n '
442
+ )
443
+ master .safe_psql ('postgres' , 'select drop_partitions(\' hash_test\' )' )
444
+
409
445
410
446
if __name__ == "__main__" :
411
447
unittest .main ()
0 commit comments