]> granicus.if.org Git - postgresql/commitdiff
Restrict name list len for domain constraints
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Fri, 26 Dec 2014 17:31:37 +0000 (14:31 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Fri, 26 Dec 2014 17:31:37 +0000 (14:31 -0300)
This avoids an ugly-looking "cache lookup failure" message.

Ugliness pointed out by Andres Freund.

src/backend/catalog/objectaddress.c
src/test/regress/expected/object_address.out

index 1f80176cdd8cbf1aa59c1306355d65c03020e081..85079d620eeb989f25f89a4fc0af004f7b9ab3a1 100644 (file)
@@ -1534,6 +1534,12 @@ pg_get_object_address(PG_FUNCTION_ARGS)
         */
        switch (type)
        {
+               case OBJECT_DOMCONSTRAINT:
+                       if (list_length(name) < 2)
+                               ereport(ERROR,
+                                               (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+                                                errmsg("name list length must be at least %d", 2)));
+                       break;
                case OBJECT_LARGEOBJECT:
                        if (list_length(name) != 1)
                                ereport(ERROR,
index b760d357eb381c77aaf79598070db9c390fabe98..ca9a6d6223efd99bc8e45e74e5ec627416c620bc 100644 (file)
@@ -171,8 +171,8 @@ WARNING:  error for table constraint,{addr_nsp,zwei},{}: relation "addr_nsp" doe
 WARNING:  error for table constraint,{addr_nsp,zwei},{integer}: relation "addr_nsp" does not exist
 WARNING:  error for table constraint,{eins,zwei,drei},{}: schema "eins" does not exist
 WARNING:  error for table constraint,{eins,zwei,drei},{integer}: schema "eins" does not exist
-WARNING:  error for domain constraint,{eins},{}: cache lookup failed for type 0
-WARNING:  error for domain constraint,{eins},{integer}: cache lookup failed for type 0
+WARNING:  error for domain constraint,{eins},{}: name list length must be at least 2
+WARNING:  error for domain constraint,{eins},{integer}: name list length must be at least 2
 WARNING:  error for domain constraint,{addr_nsp,zwei},{}: type "addr_nsp" does not exist
 WARNING:  error for domain constraint,{addr_nsp,zwei},{integer}: type "addr_nsp" does not exist
 WARNING:  error for domain constraint,{eins,zwei,drei},{}: schema "eins" does not exist