|
20 | 20 | JOIN pg_attribute pa |
21 | 21 | ON pa.attrelid = pdp.logicalrelid |
22 | 22 | AND pa.attname = column_to_column_name(pdp.logicalrelid, pdp.partkey) |
23 | | - -- ignore the table if its distribution column collation matches the collation saved for the colocation group |
24 | | - WHERE pdc.distributioncolumncollation != pa.attcollation |
| 23 | + -- column_to_column_name() returns NULL if partkey is NULL, so we're already |
| 24 | + -- implicitly ignoring the tables that don't have a distribution column, such |
| 25 | + -- as reference tables, but let's still explicitly discard such tables below. |
| 26 | + WHERE pdp.partkey IS NOT NULL |
| 27 | + -- ignore the table if its distribution column collation matches the collation saved for the colocation group |
| 28 | + AND pdc.distributioncolumncollation != pa.attcollation |
25 | 29 | ) |
26 | 30 | SELECT |
27 | 31 | colocationid, |
@@ -58,15 +62,15 @@ BEGIN |
58 | 62 | -- but this won't be super easy. Plus, even if we had such a colocation group, the user |
59 | 63 | -- was anyways okay with having this in a different colocation group in the first place. |
60 | 64 |
|
61 | | - RAISE DEBUG 'Moving out table with id % to a new colocation group', v_table_to_move_out; |
| 65 | + RAISE DEBUG 'Moving out table with oid % to a new colocation group', v_table_to_move_out; |
62 | 66 | PERFORM update_distributed_table_colocation(v_table_to_move_out, colocate_with => 'none'); |
63 | 67 |
|
64 | 68 | -- save the first table to colocate the rest of the tables with it |
65 | 69 | v_first_table := v_table_to_move_out; |
66 | 70 | ELSE |
67 | 71 | -- Move the rest of the tables to colocate with the first table. |
68 | 72 |
|
69 | | - RAISE DEBUG 'Moving out table with id % to colocate with table with id %', v_table_to_move_out, v_first_table; |
| 73 | + RAISE DEBUG 'Moving out table with oid % to colocate with table with oid %', v_table_to_move_out, v_first_table; |
70 | 74 | PERFORM update_distributed_table_colocation(v_table_to_move_out, colocate_with => v_first_table::regclass::text); |
71 | 75 | END IF; |
72 | 76 | END LOOP; |
|
0 commit comments