markokr · GitHub

Yes, missing partition not checked directly, but it still checked by old code:

    if (!check_valid_partcount(part_count))
        plproxy_error(func, "invalid partition count");

and

        if (!check_valid_partcount(part_count))
            ereport(ERROR,
                    (errcode(ERRCODE_SYNTAX_ERROR),
                     errmsg("Pl/Proxy: invalid number of partitions"),
                     errhint("the number of partitions in a cluster must be power of 2 (attempted %d)", part_count)));

and new code:

            if (part_num < 0 || part_num >= part_count)
                ereport(ERROR,
                        (errcode(ERRCODE_SYNTAX_ERROR),
                         errmsg("Pl/Proxy: wrong partitions number - %d", part_num),
                         errhint("the partitions number in a cluster must be >= 0 and < %d (attempted %d)", part_count, part_num)));

and

        if (part_num < 0 || part_num >= part_count)
            plproxy_error(func, "wrong partitions number, must be >= 0 and < %d", part_count);

so you cannot create something like:

CREATE SERVER my_cluster_test FOREIGN DATA WRAPPER plproxy OPTIONS (
    p0 'host=localhost port=6432 dbname=my_db_01',
    p1 'host=localhost port=6432 dbname=my_db_03',
    p4 'host=localhost port=6432 dbname=my_db_03',
    p5 'host=localhost port=6432 dbname=my_db_04'
);
ERROR:  Pl/Proxy: wrong partitions number - 4
ПОДСКАЗКА:  the partitions number in a cluster must be >= 0 and < 4 (attempted 4)

or

CREATE SERVER my_cluster_test FOREIGN DATA WRAPPER plproxy OPTIONS (
    p0 'host=localhost port=6432 dbname=my_db_01',
    p2 'host=localhost port=6432 dbname=my_db_03',
    p3 'host=localhost port=6432 dbname=my_db_04'
);
ERROR:  Pl/Proxy: invalid number of partitions
ПОДСКАЗКА:  the number of partitions in a cluster must be power of 2 (attempted 3)

or

CREATE SERVER my_cluster_test FOREIGN DATA WRAPPER plproxy OPTIONS (
    p0 'host=localhost port=6432 dbname=my_db_01',
    p1 'host=localhost port=6432 dbname=my_db_03',
    p3 'host=localhost port=6432 dbname=my_db_03',
    p4 'host=localhost port=6432 dbname=my_db_04'
);
ERROR:  Pl/Proxy: wrong partitions number - 4
ПОДСКАЗКА:  the partitions number in a cluster must be >= 0 and < 4 (attempted 4)

Do I still need direct checking missed partition?

Read the original on github.com ↗