LCOV - differential code coverage report
Current view: top level - src/backend/commands - dropcmds.c (source / functions) Coverage Total Hit UBC CBC
Current: Differential Code Coverage 16@8cea358b128 vs 17@8cea358b128 Lines: 83.5 % 230 192 38 192
Current Date: 2024-04-14 14:21:10 Functions: 100.0 % 5 5 5
Baseline: 16@8cea358b128 Branches: 76.2 % 143 109 34 109
Baseline Date: 2024-04-14 14:21:09 Line coverage date bins:
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed (240..) days: 83.5 % 230 192 38 192
Function coverage date bins:
(240..) days: 100.0 % 5 5 5
Branch coverage date bins:
(240..) days: 76.2 % 143 109 34 109

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : /*-------------------------------------------------------------------------
                                  2                 :                :  *
                                  3                 :                :  * dropcmds.c
                                  4                 :                :  *    handle various "DROP" operations
                                  5                 :                :  *
                                  6                 :                :  * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
                                  7                 :                :  * Portions Copyright (c) 1994, Regents of the University of California
                                  8                 :                :  *
                                  9                 :                :  *
                                 10                 :                :  * IDENTIFICATION
                                 11                 :                :  *    src/backend/commands/dropcmds.c
                                 12                 :                :  *
                                 13                 :                :  *-------------------------------------------------------------------------
                                 14                 :                :  */
                                 15                 :                : #include "postgres.h"
                                 16                 :                : 
                                 17                 :                : #include "access/table.h"
                                 18                 :                : #include "access/xact.h"
                                 19                 :                : #include "catalog/dependency.h"
                                 20                 :                : #include "catalog/namespace.h"
                                 21                 :                : #include "catalog/objectaddress.h"
                                 22                 :                : #include "catalog/pg_namespace.h"
                                 23                 :                : #include "catalog/pg_proc.h"
                                 24                 :                : #include "commands/defrem.h"
                                 25                 :                : #include "miscadmin.h"
                                 26                 :                : #include "parser/parse_type.h"
                                 27                 :                : #include "utils/acl.h"
                                 28                 :                : #include "utils/lsyscache.h"
                                 29                 :                : 
                                 30                 :                : 
                                 31                 :                : static void does_not_exist_skipping(ObjectType objtype,
                                 32                 :                :                                     Node *object);
                                 33                 :                : static bool owningrel_does_not_exist_skipping(List *object,
                                 34                 :                :                                               const char **msg, char **name);
                                 35                 :                : static bool schema_does_not_exist_skipping(List *object,
                                 36                 :                :                                            const char **msg, char **name);
                                 37                 :                : static bool type_in_list_does_not_exist_skipping(List *typenames,
                                 38                 :                :                                                  const char **msg, char **name);
                                 39                 :                : 
                                 40                 :                : 
                                 41                 :                : /*
                                 42                 :                :  * Drop one or more objects.
                                 43                 :                :  *
                                 44                 :                :  * We don't currently handle all object types here.  Relations, for example,
                                 45                 :                :  * require special handling, because (for example) indexes have additional
                                 46                 :                :  * locking requirements.
                                 47                 :                :  *
                                 48                 :                :  * We look up all the objects first, and then delete them in a single
                                 49                 :                :  * performMultipleDeletions() call.  This avoids unnecessary DROP RESTRICT
                                 50                 :                :  * errors if there are dependencies between them.
                                 51                 :                :  */
                                 52                 :                : void
 4561 rhaas@postgresql.org       53                 :CBC        4057 : RemoveObjects(DropStmt *stmt)
                                 54                 :                : {
                                 55                 :                :     ObjectAddresses *objects;
                                 56                 :                :     ListCell   *cell1;
                                 57                 :                : 
                                 58                 :           4057 :     objects = new_object_addresses();
                                 59                 :                : 
                                 60   [ +  -  +  +  :           8002 :     foreach(cell1, stmt->objects)
                                              +  + ]
                                 61                 :                :     {
                                 62                 :                :         ObjectAddress address;
 2710 peter_e@gmx.net            63                 :           4199 :         Node       *object = lfirst(cell1);
 4561 rhaas@postgresql.org       64                 :           4199 :         Relation    relation = NULL;
                                 65                 :                :         Oid         namespaceId;
                                 66                 :                : 
                                 67                 :                :         /* Get an ObjectAddress for the object. */
                                 68                 :           4199 :         address = get_object_address(stmt->removeType,
                                 69                 :                :                                      object,
                                 70                 :                :                                      &relation,
                                 71                 :                :                                      AccessExclusiveLock,
                                 72                 :           4199 :                                      stmt->missing_ok);
                                 73                 :                : 
                                 74                 :                :         /*
                                 75                 :                :          * Issue NOTICE if supplied object was not found.  Note this is only
                                 76                 :                :          * relevant in the missing_ok case, because otherwise
                                 77                 :                :          * get_object_address would have thrown an error.
                                 78                 :                :          */
                                 79         [ +  + ]:           3984 :         if (!OidIsValid(address.objectId))
                                 80                 :                :         {
 3734 alvherre@alvh.no-ip.       81         [ -  + ]:            192 :             Assert(stmt->missing_ok);
 2710 peter_e@gmx.net            82                 :            192 :             does_not_exist_skipping(stmt->removeType, object);
 4561 rhaas@postgresql.org       83                 :            192 :             continue;
                                 84                 :                :         }
                                 85                 :                : 
                                 86                 :                :         /*
                                 87                 :                :          * Although COMMENT ON FUNCTION, SECURITY LABEL ON FUNCTION, etc. are
                                 88                 :                :          * happy to operate on an aggregate as on any other function, we have
                                 89                 :                :          * historically not allowed this for DROP FUNCTION.
                                 90                 :                :          */
 4532                            91         [ +  + ]:           3792 :         if (stmt->removeType == OBJECT_FUNCTION)
                                 92                 :                :         {
 2235 peter_e@gmx.net            93         [ -  + ]:           1651 :             if (get_func_prokind(address.objectId) == PROKIND_AGGREGATE)
 4532 rhaas@postgresql.org       94         [ #  # ]:UBC           0 :                 ereport(ERROR,
                                 95                 :                :                         (errcode(ERRCODE_WRONG_OBJECT_TYPE),
                                 96                 :                :                          errmsg("\"%s\" is an aggregate function",
                                 97                 :                :                                 NameListToString(castNode(ObjectWithArgs, object)->objname)),
                                 98                 :                :                          errhint("Use DROP AGGREGATE to drop aggregate functions.")));
                                 99                 :                :         }
                                100                 :                : 
                                101                 :                :         /* Check permissions. */
 4561 rhaas@postgresql.org      102                 :CBC        3792 :         namespaceId = get_object_namespace(&address);
                                103         [ +  + ]:           3792 :         if (!OidIsValid(namespaceId) ||
  518 peter@eisentraut.org      104         [ +  + ]:           2608 :             !object_ownercheck(NamespaceRelationId, namespaceId, GetUserId()))
 4561 rhaas@postgresql.org      105                 :           1262 :             check_object_ownership(GetUserId(), stmt->removeType, address,
                                106                 :                :                                    object, relation);
                                107                 :                : 
                                108                 :                :         /*
                                109                 :                :          * Make note if a temporary namespace has been accessed in this
                                110                 :                :          * transaction.
                                111                 :                :          */
 1913 michael@paquier.xyz       112   [ +  +  +  + ]:           3753 :         if (OidIsValid(namespaceId) && isTempNamespace(namespaceId))
                                113                 :            128 :             MyXactFlags |= XACT_FLAGS_ACCESSEDTEMPNAMESPACE;
                                114                 :                : 
                                115                 :                :         /* Release any relcache reference count, but keep lock until commit. */
 4561 rhaas@postgresql.org      116         [ +  + ]:           3753 :         if (relation)
 1910 andres@anarazel.de        117                 :            497 :             table_close(relation, NoLock);
                                118                 :                : 
 4561 rhaas@postgresql.org      119                 :           3753 :         add_exact_object_address(&address, objects);
                                120                 :                :     }
                                121                 :                : 
                                122                 :                :     /* Here we really delete them. */
 4462                           123                 :           3803 :     performMultipleDeletions(objects, stmt->behavior, 0);
                                124                 :                : 
 4561                           125                 :           3728 :     free_object_addresses(objects);
                                126                 :           3728 : }
                                127                 :                : 
                                128                 :                : /*
                                129                 :                :  * owningrel_does_not_exist_skipping
                                130                 :                :  *      Subroutine for RemoveObjects
                                131                 :                :  *
                                132                 :                :  * After determining that a specification for a rule or trigger returns that
                                133                 :                :  * the specified object does not exist, test whether its owning relation, and
                                134                 :                :  * its schema, exist or not; if they do, return false --- the trigger or rule
                                135                 :                :  * itself is missing instead.  If the owning relation or its schema do not
                                136                 :                :  * exist, fill the error message format string and name, and return true.
                                137                 :                :  */
                                138                 :                : static bool
 2710 peter_e@gmx.net           139                 :             24 : owningrel_does_not_exist_skipping(List *object, const char **msg, char **name)
                                140                 :                : {
                                141                 :                :     List       *parent_object;
                                142                 :                :     RangeVar   *parent_rel;
                                143                 :                : 
  641 drowley@postgresql.o      144                 :             24 :     parent_object = list_copy_head(object, list_length(object) - 1);
                                145                 :                : 
 2710 peter_e@gmx.net           146         [ +  + ]:             24 :     if (schema_does_not_exist_skipping(parent_object, msg, name))
 3734 alvherre@alvh.no-ip.      147                 :             12 :         return true;
                                148                 :                : 
 2710 peter_e@gmx.net           149                 :             12 :     parent_rel = makeRangeVarFromNameList(parent_object);
                                150                 :                : 
 3734 alvherre@alvh.no-ip.      151         [ +  + ]:             12 :     if (!OidIsValid(RangeVarGetRelid(parent_rel, NoLock, true)))
                                152                 :                :     {
                                153                 :              6 :         *msg = gettext_noop("relation \"%s\" does not exist, skipping");
 2710 peter_e@gmx.net           154                 :              6 :         *name = NameListToString(parent_object);
                                155                 :                : 
 3734 alvherre@alvh.no-ip.      156                 :              6 :         return true;
                                157                 :                :     }
                                158                 :                : 
                                159                 :              6 :     return false;
                                160                 :                : }
                                161                 :                : 
                                162                 :                : /*
                                163                 :                :  * schema_does_not_exist_skipping
                                164                 :                :  *      Subroutine for RemoveObjects
                                165                 :                :  *
                                166                 :                :  * After determining that a specification for a schema-qualifiable object
                                167                 :                :  * refers to an object that does not exist, test whether the specified schema
                                168                 :                :  * exists or not.  If no schema was specified, or if the schema does exist,
                                169                 :                :  * return false -- the object itself is missing instead.  If the specified
                                170                 :                :  * schema does not exist, fill the error message format string and the
                                171                 :                :  * specified schema name, and return true.
                                172                 :                :  */
                                173                 :                : static bool
 2710 peter_e@gmx.net           174                 :            175 : schema_does_not_exist_skipping(List *object, const char **msg, char **name)
                                175                 :                : {
                                176                 :                :     RangeVar   *rel;
                                177                 :                : 
                                178                 :            175 :     rel = makeRangeVarFromNameList(object);
                                179                 :                : 
 3734 alvherre@alvh.no-ip.      180   [ +  +  +  - ]:            244 :     if (rel->schemaname != NULL &&
                                181                 :             69 :         !OidIsValid(LookupNamespaceNoError(rel->schemaname)))
                                182                 :                :     {
                                183                 :             69 :         *msg = gettext_noop("schema \"%s\" does not exist, skipping");
                                184                 :             69 :         *name = rel->schemaname;
                                185                 :                : 
                                186                 :             69 :         return true;
                                187                 :                :     }
                                188                 :                : 
                                189                 :            106 :     return false;
                                190                 :                : }
                                191                 :                : 
                                192                 :                : /*
                                193                 :                :  * type_in_list_does_not_exist_skipping
                                194                 :                :  *      Subroutine for RemoveObjects
                                195                 :                :  *
                                196                 :                :  * After determining that a specification for a function, cast, aggregate or
                                197                 :                :  * operator returns that the specified object does not exist, test whether the
                                198                 :                :  * involved datatypes, and their schemas, exist or not; if they do, return
                                199                 :                :  * false --- the original object itself is missing instead.  If the datatypes
                                200                 :                :  * or schemas do not exist, fill the error message format string and the
                                201                 :                :  * missing name, and return true.
                                202                 :                :  *
                                203                 :                :  * First parameter is a list of TypeNames.
                                204                 :                :  */
                                205                 :                : static bool
                                206                 :             71 : type_in_list_does_not_exist_skipping(List *typenames, const char **msg,
                                207                 :                :                                      char **name)
                                208                 :                : {
                                209                 :                :     ListCell   *l;
                                210                 :                : 
                                211   [ +  +  +  +  :            106 :     foreach(l, typenames)
                                              +  + ]
                                212                 :                :     {
 2561 tgl@sss.pgh.pa.us         213                 :             69 :         TypeName   *typeName = lfirst_node(TypeName, l);
                                214                 :                : 
 3734 alvherre@alvh.no-ip.      215         [ +  + ]:             69 :         if (typeName != NULL)
                                216                 :                :         {
                                217         [ +  + ]:             66 :             if (!OidIsValid(LookupTypeNameOid(NULL, typeName, true)))
                                218                 :                :             {
                                219                 :                :                 /* type doesn't exist, try to find why */
                                220         [ +  + ]:             34 :                 if (schema_does_not_exist_skipping(typeName->names, msg, name))
                                221                 :             34 :                     return true;
                                222                 :                : 
                                223                 :             16 :                 *msg = gettext_noop("type \"%s\" does not exist, skipping");
                                224                 :             16 :                 *name = TypeNameToString(typeName);
                                225                 :                : 
                                226                 :             16 :                 return true;
                                227                 :                :             }
                                228                 :                :         }
                                229                 :                :     }
                                230                 :                : 
                                231                 :             37 :     return false;
                                232                 :                : }
                                233                 :                : 
                                234                 :                : /*
                                235                 :                :  * does_not_exist_skipping
                                236                 :                :  *      Subroutine for RemoveObjects
                                237                 :                :  *
                                238                 :                :  * Generate a NOTICE stating that the named object was not found, and is
                                239                 :                :  * being skipped.  This is only relevant when "IF EXISTS" is used; otherwise,
                                240                 :                :  * get_object_address() in RemoveObjects would have thrown an ERROR.
                                241                 :                :  */
                                242                 :                : static void
 2710 peter_e@gmx.net           243                 :            192 : does_not_exist_skipping(ObjectType objtype, Node *object)
                                244                 :                : {
 4561 rhaas@postgresql.org      245                 :            192 :     const char *msg = NULL;
                                246                 :            192 :     char       *name = NULL;
 4532                           247                 :            192 :     char       *args = NULL;
                                248                 :                : 
 4561                           249   [ +  +  +  +  :            192 :     switch (objtype)
                                     +  -  +  +  +  
                                     +  +  +  -  -  
                                     +  +  +  +  +  
                                     +  -  +  +  +  
                                     +  +  +  -  -  
                                              -  - ]
                                250                 :                :     {
 2879 tgl@sss.pgh.pa.us         251                 :              3 :         case OBJECT_ACCESS_METHOD:
                                252                 :              3 :             msg = gettext_noop("access method \"%s\" does not exist, skipping");
  948 peter@eisentraut.org      253                 :              3 :             name = strVal(object);
 2879 tgl@sss.pgh.pa.us         254                 :              3 :             break;
 4561 rhaas@postgresql.org      255                 :             13 :         case OBJECT_TYPE:
                                256                 :                :         case OBJECT_DOMAIN:
                                257                 :                :             {
 2710 peter_e@gmx.net           258                 :             13 :                 TypeName   *typ = castNode(TypeName, object);
                                259                 :                : 
 3393 alvherre@alvh.no-ip.      260         [ +  + ]:             13 :                 if (!schema_does_not_exist_skipping(typ->names, &msg, &name))
                                261                 :                :                 {
                                262                 :              7 :                     msg = gettext_noop("type \"%s\" does not exist, skipping");
                                263                 :              7 :                     name = TypeNameToString(typ);
                                264                 :                :                 }
                                265                 :                :             }
 4561 rhaas@postgresql.org      266                 :             13 :             break;
                                267                 :              9 :         case OBJECT_COLLATION:
 2710 peter_e@gmx.net           268         [ +  + ]:              9 :             if (!schema_does_not_exist_skipping(castNode(List, object), &msg, &name))
                                269                 :                :             {
 3734 alvherre@alvh.no-ip.      270                 :              6 :                 msg = gettext_noop("collation \"%s\" does not exist, skipping");
 2710 peter_e@gmx.net           271                 :              6 :                 name = NameListToString(castNode(List, object));
                                272                 :                :             }
 4561 rhaas@postgresql.org      273                 :              9 :             break;
                                274                 :              6 :         case OBJECT_CONVERSION:
 2710 peter_e@gmx.net           275         [ +  + ]:              6 :             if (!schema_does_not_exist_skipping(castNode(List, object), &msg, &name))
                                276                 :                :             {
 3734 alvherre@alvh.no-ip.      277                 :              3 :                 msg = gettext_noop("conversion \"%s\" does not exist, skipping");
 2710 peter_e@gmx.net           278                 :              3 :                 name = NameListToString(castNode(List, object));
                                279                 :                :             }
 4561 rhaas@postgresql.org      280                 :              6 :             break;
                                281                 :              6 :         case OBJECT_SCHEMA:
                                282                 :              6 :             msg = gettext_noop("schema \"%s\" does not exist, skipping");
  948 peter@eisentraut.org      283                 :              6 :             name = strVal(object);
 4561 rhaas@postgresql.org      284                 :              6 :             break;
 2578 alvherre@alvh.no-ip.      285                 :UBC           0 :         case OBJECT_STATISTIC_EXT:
                                286         [ #  # ]:              0 :             if (!schema_does_not_exist_skipping(castNode(List, object), &msg, &name))
                                287                 :                :             {
 2527 tgl@sss.pgh.pa.us         288                 :              0 :                 msg = gettext_noop("statistics object \"%s\" does not exist, skipping");
 2578 alvherre@alvh.no-ip.      289                 :              0 :                 name = NameListToString(castNode(List, object));
                                290                 :                :             }
                                291                 :              0 :             break;
 4561 rhaas@postgresql.org      292                 :CBC           6 :         case OBJECT_TSPARSER:
 2710 peter_e@gmx.net           293         [ +  + ]:              6 :             if (!schema_does_not_exist_skipping(castNode(List, object), &msg, &name))
                                294                 :                :             {
 3734 alvherre@alvh.no-ip.      295                 :              3 :                 msg = gettext_noop("text search parser \"%s\" does not exist, skipping");
 2710 peter_e@gmx.net           296                 :              3 :                 name = NameListToString(castNode(List, object));
                                297                 :                :             }
 4561 rhaas@postgresql.org      298                 :              6 :             break;
                                299                 :              6 :         case OBJECT_TSDICTIONARY:
 2710 peter_e@gmx.net           300         [ +  + ]:              6 :             if (!schema_does_not_exist_skipping(castNode(List, object), &msg, &name))
                                301                 :                :             {
 3734 alvherre@alvh.no-ip.      302                 :              3 :                 msg = gettext_noop("text search dictionary \"%s\" does not exist, skipping");
 2710 peter_e@gmx.net           303                 :              3 :                 name = NameListToString(castNode(List, object));
                                304                 :                :             }
 4561 rhaas@postgresql.org      305                 :              6 :             break;
                                306                 :              6 :         case OBJECT_TSTEMPLATE:
 2710 peter_e@gmx.net           307         [ +  + ]:              6 :             if (!schema_does_not_exist_skipping(castNode(List, object), &msg, &name))
                                308                 :                :             {
 3734 alvherre@alvh.no-ip.      309                 :              3 :                 msg = gettext_noop("text search template \"%s\" does not exist, skipping");
 2710 peter_e@gmx.net           310                 :              3 :                 name = NameListToString(castNode(List, object));
                                311                 :                :             }
 4561 rhaas@postgresql.org      312                 :              6 :             break;
                                313                 :              6 :         case OBJECT_TSCONFIGURATION:
 2710 peter_e@gmx.net           314         [ +  + ]:              6 :             if (!schema_does_not_exist_skipping(castNode(List, object), &msg, &name))
                                315                 :                :             {
 3734 alvherre@alvh.no-ip.      316                 :              3 :                 msg = gettext_noop("text search configuration \"%s\" does not exist, skipping");
 2710 peter_e@gmx.net           317                 :              3 :                 name = NameListToString(castNode(List, object));
                                318                 :                :             }
 4561 rhaas@postgresql.org      319                 :              6 :             break;
                                320                 :              6 :         case OBJECT_EXTENSION:
                                321                 :              6 :             msg = gettext_noop("extension \"%s\" does not exist, skipping");
  948 peter@eisentraut.org      322                 :              6 :             name = strVal(object);
 4561 rhaas@postgresql.org      323                 :              6 :             break;
 4532                           324                 :             23 :         case OBJECT_FUNCTION:
                                325                 :                :             {
 2710 peter_e@gmx.net           326                 :             23 :                 ObjectWithArgs *owa = castNode(ObjectWithArgs, object);
                                327                 :                : 
                                328         [ +  + ]:             23 :                 if (!schema_does_not_exist_skipping(owa->objname, &msg, &name) &&
                                329         [ +  + ]:             20 :                     !type_in_list_does_not_exist_skipping(owa->objargs, &msg, &name))
                                330                 :                :                 {
                                331                 :             14 :                     msg = gettext_noop("function %s(%s) does not exist, skipping");
                                332                 :             14 :                     name = NameListToString(owa->objname);
                                333                 :             14 :                     args = TypeNameListToString(owa->objargs);
                                334                 :                :                 }
                                335                 :             23 :                 break;
                                336                 :                :             }
 2327 peter_e@gmx.net           337                 :UBC           0 :         case OBJECT_PROCEDURE:
                                338                 :                :             {
                                339                 :              0 :                 ObjectWithArgs *owa = castNode(ObjectWithArgs, object);
                                340                 :                : 
                                341         [ #  # ]:              0 :                 if (!schema_does_not_exist_skipping(owa->objname, &msg, &name) &&
                                342         [ #  # ]:              0 :                     !type_in_list_does_not_exist_skipping(owa->objargs, &msg, &name))
                                343                 :                :                 {
                                344                 :              0 :                     msg = gettext_noop("procedure %s(%s) does not exist, skipping");
                                345                 :              0 :                     name = NameListToString(owa->objname);
                                346                 :              0 :                     args = TypeNameListToString(owa->objargs);
                                347                 :                :                 }
                                348                 :              0 :                 break;
                                349                 :                :             }
                                350                 :              0 :         case OBJECT_ROUTINE:
                                351                 :                :             {
                                352                 :              0 :                 ObjectWithArgs *owa = castNode(ObjectWithArgs, object);
                                353                 :                : 
                                354         [ #  # ]:              0 :                 if (!schema_does_not_exist_skipping(owa->objname, &msg, &name) &&
                                355         [ #  # ]:              0 :                     !type_in_list_does_not_exist_skipping(owa->objargs, &msg, &name))
                                356                 :                :                 {
                                357                 :              0 :                     msg = gettext_noop("routine %s(%s) does not exist, skipping");
                                358                 :              0 :                     name = NameListToString(owa->objname);
                                359                 :              0 :                     args = TypeNameListToString(owa->objargs);
                                360                 :                :                 }
                                361                 :              0 :                 break;
                                362                 :                :             }
 4532 rhaas@postgresql.org      363                 :CBC          15 :         case OBJECT_AGGREGATE:
                                364                 :                :             {
 2710 peter_e@gmx.net           365                 :             15 :                 ObjectWithArgs *owa = castNode(ObjectWithArgs, object);
                                366                 :                : 
                                367         [ +  + ]:             15 :                 if (!schema_does_not_exist_skipping(owa->objname, &msg, &name) &&
                                368         [ +  + ]:             12 :                     !type_in_list_does_not_exist_skipping(owa->objargs, &msg, &name))
                                369                 :                :                 {
                                370                 :              6 :                     msg = gettext_noop("aggregate %s(%s) does not exist, skipping");
                                371                 :              6 :                     name = NameListToString(owa->objname);
                                372                 :              6 :                     args = TypeNameListToString(owa->objargs);
                                373                 :                :                 }
                                374                 :             15 :                 break;
                                375                 :                :             }
 4532 rhaas@postgresql.org      376                 :             15 :         case OBJECT_OPERATOR:
                                377                 :                :             {
 2710 peter_e@gmx.net           378                 :             15 :                 ObjectWithArgs *owa = castNode(ObjectWithArgs, object);
                                379                 :                : 
                                380         [ +  + ]:             15 :                 if (!schema_does_not_exist_skipping(owa->objname, &msg, &name) &&
                                381         [ +  + ]:             12 :                     !type_in_list_does_not_exist_skipping(owa->objargs, &msg, &name))
                                382                 :                :                 {
                                383                 :              3 :                     msg = gettext_noop("operator %s does not exist, skipping");
                                384                 :              3 :                     name = NameListToString(owa->objname);
                                385                 :                :                 }
                                386                 :             15 :                 break;
                                387                 :                :             }
 4532 rhaas@postgresql.org      388                 :              3 :         case OBJECT_LANGUAGE:
                                389                 :              3 :             msg = gettext_noop("language \"%s\" does not exist, skipping");
  948 peter@eisentraut.org      390                 :              3 :             name = strVal(object);
 4532 rhaas@postgresql.org      391                 :              3 :             break;
                                392                 :             15 :         case OBJECT_CAST:
                                393                 :                :             {
 2710 peter_e@gmx.net           394         [ +  + ]:             15 :                 if (!type_in_list_does_not_exist_skipping(list_make1(linitial(castNode(List, object))), &msg, &name) &&
                                395         [ +  + ]:              9 :                     !type_in_list_does_not_exist_skipping(list_make1(lsecond(castNode(List, object))), &msg, &name))
                                396                 :                :                 {
                                397                 :                :                     /* XXX quote or no quote? */
 3734 alvherre@alvh.no-ip.      398                 :              3 :                     msg = gettext_noop("cast from type %s to type %s does not exist, skipping");
 2561 tgl@sss.pgh.pa.us         399                 :              3 :                     name = TypeNameToString(linitial_node(TypeName, castNode(List, object)));
                                400                 :              3 :                     args = TypeNameToString(lsecond_node(TypeName, castNode(List, object)));
                                401                 :                :                 }
                                402                 :                :             }
 4532 rhaas@postgresql.org      403                 :             15 :             break;
 3276 peter_e@gmx.net           404                 :              3 :         case OBJECT_TRANSFORM:
 2710                           405         [ +  + ]:              3 :             if (!type_in_list_does_not_exist_skipping(list_make1(linitial(castNode(List, object))), &msg, &name))
                                406                 :                :             {
 3254                           407                 :              2 :                 msg = gettext_noop("transform for type %s language \"%s\" does not exist, skipping");
 2561 tgl@sss.pgh.pa.us         408                 :              2 :                 name = TypeNameToString(linitial_node(TypeName, castNode(List, object)));
 2710 peter_e@gmx.net           409                 :              2 :                 args = strVal(lsecond(castNode(List, object)));
                                410                 :                :             }
 3276                           411                 :              3 :             break;
 4532 rhaas@postgresql.org      412                 :             12 :         case OBJECT_TRIGGER:
 2710 peter_e@gmx.net           413         [ +  + ]:             12 :             if (!owningrel_does_not_exist_skipping(castNode(List, object), &msg, &name))
                                414                 :                :             {
 3734 alvherre@alvh.no-ip.      415                 :              3 :                 msg = gettext_noop("trigger \"%s\" for relation \"%s\" does not exist, skipping");
 2710 peter_e@gmx.net           416                 :              3 :                 name = strVal(llast(castNode(List, object)));
  641 drowley@postgresql.o      417                 :              3 :                 args = NameListToString(list_copy_head(castNode(List, object),
                                418                 :              3 :                                                        list_length(castNode(List, object)) - 1));
                                419                 :                :             }
 4532 rhaas@postgresql.org      420                 :             12 :             break;
 3495 sfrost@snowman.net        421                 :UBC           0 :         case OBJECT_POLICY:
 2710 peter_e@gmx.net           422         [ #  # ]:              0 :             if (!owningrel_does_not_exist_skipping(castNode(List, object), &msg, &name))
                                423                 :                :             {
 3495 sfrost@snowman.net        424                 :              0 :                 msg = gettext_noop("policy \"%s\" for relation \"%s\" does not exist, skipping");
 2710 peter_e@gmx.net           425                 :              0 :                 name = strVal(llast(castNode(List, object)));
  641 drowley@postgresql.o      426                 :              0 :                 args = NameListToString(list_copy_head(castNode(List, object),
                                427                 :              0 :                                                        list_length(castNode(List, object)) - 1));
                                428                 :                :             }
 3495 sfrost@snowman.net        429                 :              0 :             break;
 4288 rhaas@postgresql.org      430                 :CBC           3 :         case OBJECT_EVENT_TRIGGER:
                                431                 :              3 :             msg = gettext_noop("event trigger \"%s\" does not exist, skipping");
  948 peter@eisentraut.org      432                 :              3 :             name = strVal(object);
 4288 rhaas@postgresql.org      433                 :              3 :             break;
 4532                           434                 :             12 :         case OBJECT_RULE:
 2710 peter_e@gmx.net           435         [ +  + ]:             12 :             if (!owningrel_does_not_exist_skipping(castNode(List, object), &msg, &name))
                                436                 :                :             {
 3734 alvherre@alvh.no-ip.      437                 :              3 :                 msg = gettext_noop("rule \"%s\" for relation \"%s\" does not exist, skipping");
 2710 peter_e@gmx.net           438                 :              3 :                 name = strVal(llast(castNode(List, object)));
  641 drowley@postgresql.o      439                 :              3 :                 args = NameListToString(list_copy_head(castNode(List, object),
                                440                 :              3 :                                                        list_length(castNode(List, object)) - 1));
                                441                 :                :             }
 4532 rhaas@postgresql.org      442                 :             12 :             break;
                                443                 :              6 :         case OBJECT_FDW:
                                444                 :              6 :             msg = gettext_noop("foreign-data wrapper \"%s\" does not exist, skipping");
  948 peter@eisentraut.org      445                 :              6 :             name = strVal(object);
 4532 rhaas@postgresql.org      446                 :              6 :             break;
                                447                 :              6 :         case OBJECT_FOREIGN_SERVER:
                                448                 :              6 :             msg = gettext_noop("server \"%s\" does not exist, skipping");
  948 peter@eisentraut.org      449                 :              6 :             name = strVal(object);
 4532 rhaas@postgresql.org      450                 :              6 :             break;
                                451                 :              6 :         case OBJECT_OPCLASS:
                                452                 :                :             {
 2710 peter_e@gmx.net           453                 :              6 :                 List       *opcname = list_copy_tail(castNode(List, object), 1);
                                454                 :                : 
 3317 alvherre@alvh.no-ip.      455         [ +  + ]:              6 :                 if (!schema_does_not_exist_skipping(opcname, &msg, &name))
                                456                 :                :                 {
                                457                 :              3 :                     msg = gettext_noop("operator class \"%s\" does not exist for access method \"%s\", skipping");
                                458                 :              3 :                     name = NameListToString(opcname);
 2710 peter_e@gmx.net           459                 :              3 :                     args = strVal(linitial(castNode(List, object)));
                                460                 :                :                 }
                                461                 :                :             }
 4532 rhaas@postgresql.org      462                 :              6 :             break;
                                463                 :              6 :         case OBJECT_OPFAMILY:
                                464                 :                :             {
 2710 peter_e@gmx.net           465                 :              6 :                 List       *opfname = list_copy_tail(castNode(List, object), 1);
                                466                 :                : 
 3317 alvherre@alvh.no-ip.      467         [ +  + ]:              6 :                 if (!schema_does_not_exist_skipping(opfname, &msg, &name))
                                468                 :                :                 {
                                469                 :              3 :                     msg = gettext_noop("operator family \"%s\" does not exist for access method \"%s\", skipping");
                                470                 :              3 :                     name = NameListToString(opfname);
 2710 peter_e@gmx.net           471                 :              3 :                     args = strVal(linitial(castNode(List, object)));
                                472                 :                :                 }
                                473                 :                :             }
 4532 rhaas@postgresql.org      474                 :              6 :             break;
 2642 peter_e@gmx.net           475                 :UBC           0 :         case OBJECT_PUBLICATION:
                                476                 :              0 :             msg = gettext_noop("publication \"%s\" does not exist, skipping");
  948 peter@eisentraut.org      477                 :              0 :             name = strVal(object);
 2642 peter_e@gmx.net           478                 :              0 :             break;
                                479                 :                : 
  514 peter@eisentraut.org      480                 :              0 :         case OBJECT_COLUMN:
                                481                 :                :         case OBJECT_DATABASE:
                                482                 :                :         case OBJECT_FOREIGN_TABLE:
                                483                 :                :         case OBJECT_INDEX:
                                484                 :                :         case OBJECT_MATVIEW:
                                485                 :                :         case OBJECT_ROLE:
                                486                 :                :         case OBJECT_SEQUENCE:
                                487                 :                :         case OBJECT_SUBSCRIPTION:
                                488                 :                :         case OBJECT_TABLE:
                                489                 :                :         case OBJECT_TABLESPACE:
                                490                 :                :         case OBJECT_VIEW:
                                491                 :                : 
                                492                 :                :             /*
                                493                 :                :              * These are handled elsewhere, so if someone gets here the code
                                494                 :                :              * is probably wrong or should be revisited.
                                495                 :                :              */
                                496         [ #  # ]:              0 :             elog(ERROR, "unsupported object type: %d", (int) objtype);
                                497                 :                :             break;
                                498                 :                : 
                                499                 :              0 :         case OBJECT_AMOP:
                                500                 :                :         case OBJECT_AMPROC:
                                501                 :                :         case OBJECT_ATTRIBUTE:
                                502                 :                :         case OBJECT_DEFAULT:
                                503                 :                :         case OBJECT_DEFACL:
                                504                 :                :         case OBJECT_DOMCONSTRAINT:
                                505                 :                :         case OBJECT_LARGEOBJECT:
                                506                 :                :         case OBJECT_PARAMETER_ACL:
                                507                 :                :         case OBJECT_PUBLICATION_NAMESPACE:
                                508                 :                :         case OBJECT_PUBLICATION_REL:
                                509                 :                :         case OBJECT_TABCONSTRAINT:
                                510                 :                :         case OBJECT_USER_MAPPING:
                                511                 :                :             /* These are currently not used or needed. */
                                512         [ #  # ]:              0 :             elog(ERROR, "unsupported object type: %d", (int) objtype);
                                513                 :                :             break;
                                514                 :                : 
                                515                 :                :             /* no default, to let compiler warn about missing case */
                                516                 :                :     }
  514 peter@eisentraut.org      517         [ -  + ]:CBC         192 :     if (!msg)
  514 peter@eisentraut.org      518         [ #  # ]:UBC           0 :         elog(ERROR, "unrecognized object type: %d", (int) objtype);
                                519                 :                : 
 4532 rhaas@postgresql.org      520         [ +  + ]:CBC         192 :     if (!args)
                                521         [ +  + ]:            155 :         ereport(NOTICE, (errmsg(msg, name)));
                                522                 :                :     else
                                523         [ +  - ]:             37 :         ereport(NOTICE, (errmsg(msg, name, args)));
 4561                           524                 :            192 : }
        

Generated by: LCOV version 2.1-beta2-3-g6141622