| -- Create a new database to be certain that we'll be able to create objects with |
| -- the Oids specified in this test. We have tighter control when we don't have |
| -- to deal with leftover objects in the regression database. |
| DROP DATABASE IF EXISTS oid_wraparound; |
| CREATE DATABASE oid_wraparound; |
| \c oid_wraparound |
| |
| -- Create the functions that we will be using to set and observe the Oid counter |
| -- on the master and the segments. |
| CREATE OR REPLACE FUNCTION gp_set_next_oid_master(new_oid Oid) |
| RETURNS SETOF VOID |
| AS '@abs_builddir@/regress.so', 'gp_set_next_oid' |
| LANGUAGE C EXECUTE ON COORDINATOR; |
| |
| CREATE OR REPLACE FUNCTION gp_set_next_oid_segments(new_oid Oid) |
| RETURNS SETOF VOID |
| AS '@abs_builddir@/regress.so', 'gp_set_next_oid' |
| LANGUAGE C EXECUTE ON ALL SEGMENTS; |
| |
| CREATE OR REPLACE FUNCTION gp_get_next_oid_master() |
| RETURNS SETOF OID |
| AS '@abs_builddir@/regress.so', 'gp_get_next_oid' |
| LANGUAGE C EXECUTE ON COORDINATOR; |
| |
| CREATE OR REPLACE FUNCTION gp_get_next_oid_segments() |
| RETURNS SETOF OID |
| AS '@abs_builddir@/regress.so', 'gp_get_next_oid' |
| LANGUAGE C EXECUTE ON ALL SEGMENTS; |
| |
| -- Scenario 1: QD is at 16384 while QE is at 4 billion |
| SELECT gp_set_next_oid_master(16384); |
| SELECT gp_set_next_oid_segments(4290000000); |
| |
| -- We expect the QE to fast-forward to 16384 |
| SELECT gp_get_next_oid_master(); |
| SELECT gp_get_next_oid_segments(); |
| CREATE TABLE oid_wraparound_table (a int); |
| DROP TABLE oid_wraparound_table; |
| SELECT gp_get_next_oid_master(); |
| SELECT gp_get_next_oid_segments(); |
| |
| -- Scenario 2: QD is at 4 billion while QE is at 16384 |
| SELECT gp_set_next_oid_master(4290000000); |
| SELECT gp_set_next_oid_segments(16384); |
| |
| -- We expect the QE to increment once to 16385 and the QD should |
| -- fast-forward to 16388. The QD could possibly fast-forward to 16389 |
| -- if the pg_type heap page was not pruned for dead pg_type entry for |
| -- oid_wraparound_table relation which will result in Oid 16386 |
| -- collision. |
| SELECT gp_get_next_oid_master(); |
| SELECT gp_get_next_oid_segments(); |
| CREATE TABLE oid_wraparound_table_other AS SELECT 1 AS a; |
| SELECT gp_get_next_oid_master() in (16391, 16392); |
| SELECT gp_get_next_oid_segments(); |