Skip to content
Snippets Groups Projects
Select Git revision
  • 97c4ee94adf15f7a0a39cbb5549159e2aa0679d1
  • master default
  • benchmark-tools
  • postgres-lambda
  • REL9_4_25
  • REL9_5_20
  • REL9_6_16
  • REL_10_11
  • REL_11_6
  • REL_12_1
  • REL_12_0
  • REL_12_RC1
  • REL_12_BETA4
  • REL9_4_24
  • REL9_5_19
  • REL9_6_15
  • REL_10_10
  • REL_11_5
  • REL_12_BETA3
  • REL9_4_23
  • REL9_5_18
  • REL9_6_14
  • REL_10_9
  • REL_11_4
24 results

user.c

Blame
  • comment.c 12.64 KiB
    /*-------------------------------------------------------------------------
     *
     * comment.c
     *
     * PostgreSQL object comments utility code.
     *
     * Copyright (c) 1996-2013, PostgreSQL Global Development Group
     *
     * IDENTIFICATION
     *	  src/backend/commands/comment.c
     *
     *-------------------------------------------------------------------------
     */
    
    #include "postgres.h"
    
    #include "access/genam.h"
    #include "access/heapam.h"
    #include "access/htup_details.h"
    #include "catalog/indexing.h"
    #include "catalog/objectaddress.h"
    #include "catalog/pg_description.h"
    #include "catalog/pg_shdescription.h"
    #include "commands/comment.h"
    #include "commands/dbcommands.h"
    #include "miscadmin.h"
    #include "utils/builtins.h"
    #include "utils/fmgroids.h"
    #include "utils/rel.h"
    #include "utils/tqual.h"
    
    
    /*
     * CommentObject --
     *
     * This routine is used to add the associated comment into
     * pg_description for the object specified by the given SQL command.
     */
    Oid
    CommentObject(CommentStmt *stmt)
    {
    	ObjectAddress address;
    	Relation	relation;
    
    	/*
    	 * When loading a dump, we may see a COMMENT ON DATABASE for the old name
    	 * of the database.  Erroring out would prevent pg_restore from completing
    	 * (which is really pg_restore's fault, but for now we will work around
    	 * the problem here).  Consensus is that the best fix is to treat wrong
    	 * database name as a WARNING not an ERROR; hence, the following special
    	 * case.  (If the length of stmt->objname is not 1, get_object_address
    	 * will throw an error below; that's OK.)
    	 */
    	if (stmt->objtype == OBJECT_DATABASE && list_length(stmt->objname) == 1)
    	{
    		char	   *database = strVal(linitial(stmt->objname));
    
    		if (!OidIsValid(get_database_oid(database, true)))
    		{
    			ereport(WARNING,
    					(errcode(ERRCODE_UNDEFINED_DATABASE),
    					 errmsg("database \"%s\" does not exist", database)));
    			return InvalidOid;
    		}
    	}
    
    	/*
    	 * Translate the parser representation that identifies this object into an
    	 * ObjectAddress.  get_object_address() will throw an error if the object
    	 * does not exist, and will also acquire a lock on the target to guard