| -- |
| -- Try and fail to import all system collations |
| -- |
| -- Simulate a locale missing on one segment at collation creation. If this |
| -- happens, we expect that 2PC will prevent this collation from being created. |
| -- |
| SELECT gp_inject_fault('collate_locale_os_lookup', 'error', dbid) |
| from gp_segment_configuration where content = 0 and role = 'p'; |
| |
| -- The fault injector should prevent all collations from being created by |
| -- pg_import_system_collations(). |
| create schema import_collation_schema; |
| select pg_import_system_collations( (select oid from pg_namespace where nspname = 'import_collation_schema') ); |
| |
| -- Count the number of collations in import_collation_schema. It should be |
| -- zero because one of the segments failed to create a collation. |
| select count(*) from pg_collation where collnamespace = (select oid from pg_namespace where nspname = 'import_collation_schema'); |
| |
| SELECT gp_inject_fault('collate_locale_os_lookup', 'reset', dbid) |
| from gp_segment_configuration where content = 0 and role = 'p'; |
| |
| -- |
| -- Import all system collations. |
| -- |
| select pg_import_system_collations( (select oid from pg_namespace where nspname = 'import_collation_schema') ) > 0 as collations_imported; |
| |
| -- |
| -- Create a collation from an on-disk locale |
| -- |
| select gp_segment_id, collname from pg_collation where collname='collation_from_disk'; |
| create collation "collation_from_disk" (locale="@gp_syslocale@"); |
| select gp_segment_id, collname from pg_collation where collname='collation_from_disk'; |
| select gp_segment_id, collname from gp_dist_random('pg_collation') where oid=(select oid from pg_collation where collname='collation_from_disk'); |
| select count(distinct oid) from gp_dist_random('pg_collation') where oid=(select oid from pg_collation where collname='collation_from_disk'); |
| |
| -- |
| -- Drop the collation, and confirm it is actually gone |
| -- |
| drop collation "collation_from_disk"; |
| select gp_segment_id, collname from pg_collation where collname='collation_from_disk'; |
| select gp_segment_id, collname from gp_dist_random('pg_collation') where oid=(select oid from pg_collation where collname='collation_from_disk'); |
| |
| |
| -- |
| -- Create a collation from an existing collation |
| -- |
| select gp_segment_id, collname from pg_collation where collname='collation_from_db'; |
| create collation "collation_from_db" from "POSIX"; |
| select gp_segment_id, collname from pg_collation where collname='collation_from_db'; |
| select gp_segment_id, collname from gp_dist_random('pg_collation') where oid=(select oid from pg_collation where collname='collation_from_db'); |
| select count(distinct oid) from gp_dist_random('pg_collation') where oid=(select oid from pg_collation where collname='collation_from_db'); |
| |
| -- |
| -- Confirm that collation creation is protected from errors by 2PC. |
| -- In other words if one segment throws an error, the collation |
| -- should not be created on any segment. |
| -- |
| create collation "missing_on_one_segment" from "C"; |
| -- Drop collation from one segment |
| 2U: drop collation "missing_on_one_segment"; |
| select gp_segment_id, collname from gp_dist_random('pg_collation') where oid=(select oid from pg_collation where collname='missing_on_one_segment'); |
| -- Because we dropped missing_on_one_segment from content 2, it |
| -- will fail to create the collation. |
| create collation "collation_create_fails" from "missing_on_one_segment"; |
| -- Confirm 'collation_create_fails' is missing from all segments. |
| select gp_segment_id, collname from pg_collation where collname='collation_create_fails'; |
| select gp_segment_id, collname from gp_dist_random('pg_collation') where collname='collation_create_fails'; |
| |
| -- Clean up table missing_on_one_segement |
| -1U: drop collation "missing_on_one_segment"; |
| 0U: drop collation "missing_on_one_segment"; |
| 1U: drop collation "missing_on_one_segment"; |
| |
| -- |
| -- Simulate a locale missing on one segment at collation creation. If this |
| -- happens, we expect that 2PC will prevent this collation from being created. |
| -- |
| SELECT gp_inject_fault('collate_locale_os_lookup', 'error', dbid) |
| from gp_segment_configuration where content = 0 and role = 'p'; |
| |
| select gp_segment_id, collname from gp_dist_random('pg_collation') where oid=(select oid from pg_collation where collname='locale_missing_on_one_segment'); |
| -- The fault injector should simulate a collation being missing on this segment |
| create collation "locale_missing_on_one_segment" (locale="@gp_syslocale@"); |
| -- Confirm 'collation_create_fails' is missing from all segments. |
| select gp_segment_id, collname from pg_collation where collname='locale_missing_on_one_segment'; |
| select gp_segment_id, collname from gp_dist_random('pg_collation') where collname='locale_missing_on_one_segment'; |
| |
| SELECT gp_inject_fault('collate_locale_os_lookup', 'reset', dbid) |
| from gp_segment_configuration where content = 0 and role = 'p'; |
| |
| |
| -- |
| -- If, for whatever reason a collation was created for a locale that is no |
| -- longer available on a segment, we expect that a query using that collation |
| -- will throw an error. |
| -- |
| select gp_segment_id, collname from pg_collation where collname='locale_missing_on_one_segment'; |
| create collation "locale_missing_on_one_segment" (locale="@gp_syslocale@"); |
| -- Confirm is on all segments. |
| select gp_segment_id, collname from pg_collation where collname='locale_missing_on_one_segment'; |
| select gp_segment_id, collname from gp_dist_random('pg_collation') where collname='locale_missing_on_one_segment'; |
| |
| create table uses_collation (a text collate locale_missing_on_one_segment); |
| -- The case here aims to insert two tuples to seg0. |
| -- Under jump consistent hash, ('abc'), ('012') goes to seg0. |
| insert into uses_collation values ('abc'), ('012'); |
| |
| SELECT gp_inject_fault('collate_locale_os_lookup', 'error', dbid) |
| from gp_segment_configuration where content = 0 and role = 'p'; |
| |
| -- This should error out |
| SELECT a FROM uses_collation ORDER BY a; |
| |
| SELECT gp_inject_fault('collate_locale_os_lookup', 'reset', dbid) |
| from gp_segment_configuration where content = 0 and role = 'p'; |
| |