Skip to content

Commit 6c863e3

Browse files
committed
testgres test for foreign hash partitions added
1 parent 0dead52 commit 6c863e3

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/partitioning_test.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,14 @@ def test_foreign_table(self):
354354
master.start()
355355
master.psql('postgres', 'create extension pg_pathman')
356356
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
357365
master.psql(
358366
'postgres',
359367
'''create table abc(id serial, name text);
@@ -406,6 +414,34 @@ def test_foreign_table(self):
406414
# Testing drop partitions (including foreign partitions)
407415
master.safe_psql('postgres', 'select drop_partitions(\'abc\')')
408416

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|\n2|\n5|\n6|\n8|\n9|\n3|\n4|\n7|\n10|\n'
442+
)
443+
master.safe_psql('postgres', 'select drop_partitions(\'hash_test\')')
444+
409445

410446
if __name__ == "__main__":
411447
unittest.main()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy