* return the number of total segments for current snapshot of * segments info */
| 1917 | * segments info |
| 1918 | */ |
| 1919 | int |
| 1920 | getgpsegmentCount(void) |
| 1921 | { |
| 1922 | /* 1 represents a singleton postgresql in utility mode */ |
| 1923 | int32 numsegments = 1; |
| 1924 | |
| 1925 | if (Gp_role == GP_ROLE_DISPATCH) |
| 1926 | numsegments = cdbcomponent_getCdbComponents()->total_segments; |
| 1927 | else if (Gp_role == GP_ROLE_EXECUTE) |
| 1928 | numsegments = numsegmentsFromQD; |
| 1929 | /* |
| 1930 | * If we are in 'Utility & Binary Upgrade' mode, it must be launched |
| 1931 | * by the pg_upgrade, so we give it an correct numsegments to make |
| 1932 | * sure the pg_upgrade can run normally. |
| 1933 | * Only Utility QD process have the entire information in the |
| 1934 | * gp_segment_configuration, so we count the segments count in this |
| 1935 | * process. |
| 1936 | */ |
| 1937 | else if (Gp_role == GP_ROLE_UTILITY && |
| 1938 | IsBinaryUpgrade && |
| 1939 | IS_QUERY_DISPATCHER()) |
| 1940 | { |
| 1941 | /* |
| 1942 | * While upgrading in single node mode, we will get zero total |
| 1943 | * segment count, which will cause assertion error in makeGpPolicy. |
| 1944 | * |
| 1945 | * Segment number should be set to a value not less than 1 anyway. |
| 1946 | */ |
| 1947 | numsegments = Max(cdbcomponent_getCdbComponents()->total_segments, 1); |
| 1948 | } |
| 1949 | |
| 1950 | return numsegments; |
| 1951 | } |
| 1952 | |
| 1953 | /* |
| 1954 | * IsOnConflictUpdate |
no test coverage detected