PostgreSQL Source Code  git master
dropcmds.c File Reference
#include "postgres.h"
#include "access/htup_details.h"
#include "access/table.h"
#include "access/xact.h"
#include "catalog/dependency.h"
#include "catalog/namespace.h"
#include "catalog/objectaddress.h"
#include "catalog/pg_class.h"
#include "catalog/pg_namespace.h"
#include "catalog/pg_proc.h"
#include "commands/defrem.h"
#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "parser/parse_type.h"
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/lsyscache.h"
#include "utils/syscache.h"
Include dependency graph for dropcmds.c:

Go to the source code of this file.

Functions

static void does_not_exist_skipping (ObjectType objtype, Node *object)
 
static bool owningrel_does_not_exist_skipping (List *object, const char **msg, char **name)
 
static bool schema_does_not_exist_skipping (List *object, const char **msg, char **name)
 
static bool type_in_list_does_not_exist_skipping (List *typenames, const char **msg, char **name)
 
void RemoveObjects (DropStmt *stmt)
 

Function Documentation

◆ does_not_exist_skipping()

static void does_not_exist_skipping ( ObjectType  objtype,
Node object 
)
static

Definition at line 248 of file dropcmds.c.

249 {
250  const char *msg = NULL;
251  char *name = NULL;
252  char *args = NULL;
253 
254  switch (objtype)
255  {
257  msg = gettext_noop("access method \"%s\" does not exist, skipping");
258  name = strVal(object);
259  break;
260  case OBJECT_TYPE:
261  case OBJECT_DOMAIN:
262  {
263  TypeName *typ = castNode(TypeName, object);
264 
265  if (!schema_does_not_exist_skipping(typ->names, &msg, &name))
266  {
267  msg = gettext_noop("type \"%s\" does not exist, skipping");
268  name = TypeNameToString(typ);
269  }
270  }
271  break;
272  case OBJECT_COLLATION:
273  if (!schema_does_not_exist_skipping(castNode(List, object), &msg, &name))
274  {
275  msg = gettext_noop("collation \"%s\" does not exist, skipping");
276  name = NameListToString(castNode(List, object));
277  }
278  break;
279  case OBJECT_CONVERSION:
280  if (!schema_does_not_exist_skipping(castNode(List, object), &msg, &name))
281  {
282  msg = gettext_noop("conversion \"%s\" does not exist, skipping");
283  name = NameListToString(castNode(List, object));
284  }
285  break;
286  case OBJECT_SCHEMA:
287  msg = gettext_noop("schema \"%s\" does not exist, skipping");
288  name = strVal(object);
289  break;
291  if (!schema_does_not_exist_skipping(castNode(List, object), &msg, &name))
292  {
293  msg = gettext_noop("statistics object \"%s\" does not exist, skipping");
294  name = NameListToString(castNode(List, object));
295  }
296  break;
297  case OBJECT_TSPARSER:
298  if (!schema_does_not_exist_skipping(castNode(List, object), &msg, &name))
299  {
300  msg = gettext_noop("text search parser \"%s\" does not exist, skipping");
301  name = NameListToString(castNode(List, object));
302  }
303  break;
304  case OBJECT_TSDICTIONARY:
305  if (!schema_does_not_exist_skipping(castNode(List, object), &msg, &name))
306  {
307  msg = gettext_noop("text search dictionary \"%s\" does not exist, skipping");
308  name = NameListToString(castNode(List, object));
309  }
310  break;
311  case OBJECT_TSTEMPLATE:
312  if (!schema_does_not_exist_skipping(castNode(List, object), &msg, &name))
313  {
314  msg = gettext_noop("text search template \"%s\" does not exist, skipping");
315  name = NameListToString(castNode(List, object));
316  }
317  break;
319  if (!schema_does_not_exist_skipping(castNode(List, object), &msg, &name))
320  {
321  msg = gettext_noop("text search configuration \"%s\" does not exist, skipping");
322  name = NameListToString(castNode(List, object));
323  }
324  break;
325  case OBJECT_EXTENSION:
326  msg = gettext_noop("extension \"%s\" does not exist, skipping");
327  name = strVal(object);
328  break;
329  case OBJECT_FUNCTION:
330  {
331  ObjectWithArgs *owa = castNode(ObjectWithArgs, object);
332 
333  if (!schema_does_not_exist_skipping(owa->objname, &msg, &name) &&
335  {
336  msg = gettext_noop("function %s(%s) does not exist, skipping");
337  name = NameListToString(owa->objname);
339  }
340  break;
341  }
342  case OBJECT_PROCEDURE:
343  {
344  ObjectWithArgs *owa = castNode(ObjectWithArgs, object);
345 
346  if (!schema_does_not_exist_skipping(owa->objname, &msg, &name) &&
348  {
349  msg = gettext_noop("procedure %s(%s) does not exist, skipping");
350  name = NameListToString(owa->objname);
352  }
353  break;
354  }
355  case OBJECT_ROUTINE:
356  {
357  ObjectWithArgs *owa = castNode(ObjectWithArgs, object);
358 
359  if (!schema_does_not_exist_skipping(owa->objname, &msg, &name) &&
361  {
362  msg = gettext_noop("routine %s(%s) does not exist, skipping");
363  name = NameListToString(owa->objname);
365  }
366  break;
367  }
368  case OBJECT_AGGREGATE:
369  {
370  ObjectWithArgs *owa = castNode(ObjectWithArgs, object);
371 
372  if (!schema_does_not_exist_skipping(owa->objname, &msg, &name) &&
374  {
375  msg = gettext_noop("aggregate %s(%s) does not exist, skipping");
376  name = NameListToString(owa->objname);
378  }
379  break;
380  }
381  case OBJECT_OPERATOR:
382  {
383  ObjectWithArgs *owa = castNode(ObjectWithArgs, object);
384 
385  if (!schema_does_not_exist_skipping(owa->objname, &msg, &name) &&
387  {
388  msg = gettext_noop("operator %s does not exist, skipping");
389  name = NameListToString(owa->objname);
390  }
391  break;
392  }
393  case OBJECT_LANGUAGE:
394  msg = gettext_noop("language \"%s\" does not exist, skipping");
395  name = strVal(object);
396  break;
397  case OBJECT_CAST:
398  {
401  {
402  /* XXX quote or no quote? */
403  msg = gettext_noop("cast from type %s to type %s does not exist, skipping");
406  }
407  }
408  break;
409  case OBJECT_TRANSFORM:
411  {
412  msg = gettext_noop("transform for type %s language \"%s\" does not exist, skipping");
414  args = strVal(lsecond(castNode(List, object)));
415  }
416  break;
417  case OBJECT_TRIGGER:
418  if (!owningrel_does_not_exist_skipping(castNode(List, object), &msg, &name))
419  {
420  msg = gettext_noop("trigger \"%s\" for relation \"%s\" does not exist, skipping");
421  name = strVal(llast(castNode(List, object)));
423  list_length(castNode(List, object)) - 1));
424  }
425  break;
426  case OBJECT_POLICY:
427  if (!owningrel_does_not_exist_skipping(castNode(List, object), &msg, &name))
428  {
429  msg = gettext_noop("policy \"%s\" for relation \"%s\" does not exist, skipping");
430  name = strVal(llast(castNode(List, object)));
432  list_length(castNode(List, object)) - 1));
433  }
434  break;
436  msg = gettext_noop("event trigger \"%s\" does not exist, skipping");
437  name = strVal(object);
438  break;
439  case OBJECT_RULE:
440  if (!owningrel_does_not_exist_skipping(castNode(List, object), &msg, &name))
441  {
442  msg = gettext_noop("rule \"%s\" for relation \"%s\" does not exist, skipping");
443  name = strVal(llast(castNode(List, object)));
445  list_length(castNode(List, object)) - 1));
446  }
447  break;
448  case OBJECT_FDW:
449  msg = gettext_noop("foreign-data wrapper \"%s\" does not exist, skipping");
450  name = strVal(object);
451  break;
453  msg = gettext_noop("server \"%s\" does not exist, skipping");
454  name = strVal(object);
455  break;
456  case OBJECT_OPCLASS:
457  {
458  List *opcname = list_copy_tail(castNode(List, object), 1);
459 
460  if (!schema_does_not_exist_skipping(opcname, &msg, &name))
461  {
462  msg = gettext_noop("operator class \"%s\" does not exist for access method \"%s\", skipping");
463  name = NameListToString(opcname);
464  args = strVal(linitial(castNode(List, object)));
465  }
466  }
467  break;
468  case OBJECT_OPFAMILY:
469  {
470  List *opfname = list_copy_tail(castNode(List, object), 1);
471 
472  if (!schema_does_not_exist_skipping(opfname, &msg, &name))
473  {
474  msg = gettext_noop("operator family \"%s\" does not exist for access method \"%s\", skipping");
475  name = NameListToString(opfname);
476  args = strVal(linitial(castNode(List, object)));
477  }
478  }
479  break;
480  case OBJECT_PUBLICATION:
481  msg = gettext_noop("publication \"%s\" does not exist, skipping");
482  name = strVal(object);
483  break;
484 
485  case OBJECT_COLUMN:
486  case OBJECT_DATABASE:
488  case OBJECT_INDEX:
489  case OBJECT_MATVIEW:
490  case OBJECT_ROLE:
491  case OBJECT_SEQUENCE:
492  case OBJECT_SUBSCRIPTION:
493  case OBJECT_TABLE:
494  case OBJECT_TABLESPACE:
495  case OBJECT_VIEW:
496  /*
497  * These are handled elsewhere, so if someone gets here the code
498  * is probably wrong or should be revisited.
499  */
500  elog(ERROR, "unsupported object type: %d", (int) objtype);
501  break;
502 
503  case OBJECT_AMOP:
504  case OBJECT_AMPROC:
505  case OBJECT_ATTRIBUTE:
506  case OBJECT_DEFAULT:
507  case OBJECT_DEFACL:
509  case OBJECT_LARGEOBJECT:
514  case OBJECT_USER_MAPPING:
515  /* These are currently not used or needed. */
516  elog(ERROR, "unsupported object type: %d", (int) objtype);
517  break;
518 
519  /* no default, to let compiler warn about missing case */
520  }
521  if (!msg)
522  elog(ERROR, "unrecognized object type: %d", (int) objtype);
523 
524  if (!args)
525  ereport(NOTICE, (errmsg(msg, name)));
526  else
527  ereport(NOTICE, (errmsg(msg, name, args)));
528 }
#define gettext_noop(x)
Definition: c.h:1135
static bool type_in_list_does_not_exist_skipping(List *typenames, const char **msg, char **name)
Definition: dropcmds.c:211
static bool owningrel_does_not_exist_skipping(List *object, const char **msg, char **name)
Definition: dropcmds.c:144
static bool schema_does_not_exist_skipping(List *object, const char **msg, char **name)
Definition: dropcmds.c:179
int errmsg(const char *fmt,...)
Definition: elog.c:906
#define ERROR
Definition: elog.h:35
#define NOTICE
Definition: elog.h:31
#define ereport(elevel,...)
Definition: elog.h:145
const char * name
Definition: encode.c:561
List * list_copy_head(const List *oldlist, int len)
Definition: list.c:1592
List * list_copy_tail(const List *oldlist, int nskip)
Definition: list.c:1612
char * NameListToString(List *names)
Definition: namespace.c:3145
#define castNode(_type_, nodeptr)
Definition: nodes.h:186
char * TypeNameListToString(List *typenames)
Definition: parse_type.c:492
char * TypeNameToString(const TypeName *typeName)
Definition: parse_type.c:478
@ OBJECT_EVENT_TRIGGER
Definition: parsenodes.h:1876
@ OBJECT_FDW
Definition: parsenodes.h:1878
@ OBJECT_TSPARSER
Definition: parsenodes.h:1909
@ OBJECT_COLLATION
Definition: parsenodes.h:1869
@ OBJECT_USER_MAPPING
Definition: parsenodes.h:1912
@ OBJECT_ACCESS_METHOD
Definition: parsenodes.h:1862
@ OBJECT_OPCLASS
Definition: parsenodes.h:1886
@ OBJECT_DEFACL
Definition: parsenodes.h:1873
@ OBJECT_AGGREGATE
Definition: parsenodes.h:1863
@ OBJECT_MATVIEW
Definition: parsenodes.h:1885
@ OBJECT_SCHEMA
Definition: parsenodes.h:1898
@ OBJECT_POLICY
Definition: parsenodes.h:1890
@ OBJECT_OPERATOR
Definition: parsenodes.h:1887
@ OBJECT_FOREIGN_TABLE
Definition: parsenodes.h:1880
@ OBJECT_TSCONFIGURATION
Definition: parsenodes.h:1907
@ OBJECT_OPFAMILY
Definition: parsenodes.h:1888
@ OBJECT_DOMAIN
Definition: parsenodes.h:1874
@ OBJECT_COLUMN
Definition: parsenodes.h:1868
@ OBJECT_TABLESPACE
Definition: parsenodes.h:1904
@ OBJECT_ROLE
Definition: parsenodes.h:1895
@ OBJECT_ROUTINE
Definition: parsenodes.h:1896
@ OBJECT_LARGEOBJECT
Definition: parsenodes.h:1884
@ OBJECT_PUBLICATION_NAMESPACE
Definition: parsenodes.h:1893
@ OBJECT_PROCEDURE
Definition: parsenodes.h:1891
@ OBJECT_EXTENSION
Definition: parsenodes.h:1877
@ OBJECT_INDEX
Definition: parsenodes.h:1882
@ OBJECT_DEFAULT
Definition: parsenodes.h:1872
@ OBJECT_DATABASE
Definition: parsenodes.h:1871
@ OBJECT_SEQUENCE
Definition: parsenodes.h:1899
@ OBJECT_TSTEMPLATE
Definition: parsenodes.h:1910
@ OBJECT_LANGUAGE
Definition: parsenodes.h:1883
@ OBJECT_AMOP
Definition: parsenodes.h:1864
@ OBJECT_PUBLICATION_REL
Definition: parsenodes.h:1894
@ OBJECT_FOREIGN_SERVER
Definition: parsenodes.h:1879
@ OBJECT_TSDICTIONARY
Definition: parsenodes.h:1908
@ OBJECT_ATTRIBUTE
Definition: parsenodes.h:1866
@ OBJECT_PUBLICATION
Definition: parsenodes.h:1892
@ OBJECT_RULE
Definition: parsenodes.h:1897
@ OBJECT_CONVERSION
Definition: parsenodes.h:1870
@ OBJECT_AMPROC
Definition: parsenodes.h:1865
@ OBJECT_TABLE
Definition: parsenodes.h:1903
@ OBJECT_VIEW
Definition: parsenodes.h:1913
@ OBJECT_PARAMETER_ACL
Definition: parsenodes.h:1889
@ OBJECT_TYPE
Definition: parsenodes.h:1911
@ OBJECT_FUNCTION
Definition: parsenodes.h:1881
@ OBJECT_TABCONSTRAINT
Definition: parsenodes.h:1902
@ OBJECT_DOMCONSTRAINT
Definition: parsenodes.h:1875
@ OBJECT_SUBSCRIPTION
Definition: parsenodes.h:1900
@ OBJECT_STATISTIC_EXT
Definition: parsenodes.h:1901
@ OBJECT_CAST
Definition: parsenodes.h:1867
@ OBJECT_TRIGGER
Definition: parsenodes.h:1906
@ OBJECT_TRANSFORM
Definition: parsenodes.h:1905
#define llast(l)
Definition: pg_list.h:196
static int list_length(const List *l)
Definition: pg_list.h:150
#define linitial_node(type, l)
Definition: pg_list.h:179
#define lsecond_node(type, l)
Definition: pg_list.h:184
#define list_make1(x1)
Definition: pg_list.h:210
#define linitial(l)
Definition: pg_list.h:176
#define lsecond(l)
Definition: pg_list.h:181
Definition: pg_list.h:52
List * names
Definition: parsenodes.h:233
#define strVal(v)
Definition: value.h:82

References generate_unaccent_rules::args, castNode, elog(), ereport, errmsg(), ERROR, gettext_noop, linitial, linitial_node, list_copy_head(), list_copy_tail(), list_length(), list_make1, llast, lsecond, lsecond_node, name, NameListToString(), TypeName::names, NOTICE, ObjectWithArgs::objargs, OBJECT_ACCESS_METHOD, OBJECT_AGGREGATE, OBJECT_AMOP, OBJECT_AMPROC, OBJECT_ATTRIBUTE, OBJECT_CAST, OBJECT_COLLATION, OBJECT_COLUMN, OBJECT_CONVERSION, OBJECT_DATABASE, OBJECT_DEFACL, OBJECT_DEFAULT, OBJECT_DOMAIN, OBJECT_DOMCONSTRAINT, OBJECT_EVENT_TRIGGER, OBJECT_EXTENSION, OBJECT_FDW, OBJECT_FOREIGN_SERVER, OBJECT_FOREIGN_TABLE, OBJECT_FUNCTION, OBJECT_INDEX, OBJECT_LANGUAGE, OBJECT_LARGEOBJECT, OBJECT_MATVIEW, OBJECT_OPCLASS, OBJECT_OPERATOR, OBJECT_OPFAMILY, OBJECT_PARAMETER_ACL, OBJECT_POLICY, OBJECT_PROCEDURE, OBJECT_PUBLICATION, OBJECT_PUBLICATION_NAMESPACE, OBJECT_PUBLICATION_REL, OBJECT_ROLE, OBJECT_ROUTINE, OBJECT_RULE, OBJECT_SCHEMA, OBJECT_SEQUENCE, OBJECT_STATISTIC_EXT, OBJECT_SUBSCRIPTION, OBJECT_TABCONSTRAINT, OBJECT_TABLE, OBJECT_TABLESPACE, OBJECT_TRANSFORM, OBJECT_TRIGGER, OBJECT_TSCONFIGURATION, OBJECT_TSDICTIONARY, OBJECT_TSPARSER, OBJECT_TSTEMPLATE, OBJECT_TYPE, OBJECT_USER_MAPPING, OBJECT_VIEW, ObjectWithArgs::objname, owningrel_does_not_exist_skipping(), schema_does_not_exist_skipping(), strVal, type_in_list_does_not_exist_skipping(), TypeNameListToString(), and TypeNameToString().

Referenced by RemoveObjects().

◆ owningrel_does_not_exist_skipping()

static bool owningrel_does_not_exist_skipping ( List object,
const char **  msg,
char **  name 
)
static

Definition at line 144 of file dropcmds.c.

145 {
146  List *parent_object;
147  RangeVar *parent_rel;
148 
149  parent_object = list_copy_head(object, list_length(object) - 1);
150 
151  if (schema_does_not_exist_skipping(parent_object, msg, name))
152  return true;
153 
154  parent_rel = makeRangeVarFromNameList(parent_object);
155 
156  if (!OidIsValid(RangeVarGetRelid(parent_rel, NoLock, true)))
157  {
158  *msg = gettext_noop("relation \"%s\" does not exist, skipping");
159  *name = NameListToString(parent_object);
160 
161  return true;
162  }
163 
164  return false;
165 }
#define OidIsValid(objectId)
Definition: c.h:711
#define NoLock
Definition: lockdefs.h:34
RangeVar * makeRangeVarFromNameList(List *names)
Definition: namespace.c:3105
#define RangeVarGetRelid(relation, lockmode, missing_ok)
Definition: namespace.h:79

References gettext_noop, list_copy_head(), list_length(), makeRangeVarFromNameList(), name, NameListToString(), NoLock, OidIsValid, RangeVarGetRelid, and schema_does_not_exist_skipping().

Referenced by does_not_exist_skipping().

◆ RemoveObjects()

void RemoveObjects ( DropStmt stmt)

Definition at line 58 of file dropcmds.c.

59 {
60  ObjectAddresses *objects;
61  ListCell *cell1;
62 
63  objects = new_object_addresses();
64 
65  foreach(cell1, stmt->objects)
66  {
67  ObjectAddress address;
68  Node *object = lfirst(cell1);
69  Relation relation = NULL;
70  Oid namespaceId;
71 
72  /* Get an ObjectAddress for the object. */
73  address = get_object_address(stmt->removeType,
74  object,
75  &relation,
77  stmt->missing_ok);
78 
79  /*
80  * Issue NOTICE if supplied object was not found. Note this is only
81  * relevant in the missing_ok case, because otherwise
82  * get_object_address would have thrown an error.
83  */
84  if (!OidIsValid(address.objectId))
85  {
86  Assert(stmt->missing_ok);
87  does_not_exist_skipping(stmt->removeType, object);
88  continue;
89  }
90 
91  /*
92  * Although COMMENT ON FUNCTION, SECURITY LABEL ON FUNCTION, etc. are
93  * happy to operate on an aggregate as on any other function, we have
94  * historically not allowed this for DROP FUNCTION.
95  */
96  if (stmt->removeType == OBJECT_FUNCTION)
97  {
98  if (get_func_prokind(address.objectId) == PROKIND_AGGREGATE)
99  ereport(ERROR,
100  (errcode(ERRCODE_WRONG_OBJECT_TYPE),
101  errmsg("\"%s\" is an aggregate function",
102  NameListToString(castNode(ObjectWithArgs, object)->objname)),
103  errhint("Use DROP AGGREGATE to drop aggregate functions.")));
104  }
105 
106  /* Check permissions. */
107  namespaceId = get_object_namespace(&address);
108  if (!OidIsValid(namespaceId) ||
109  !object_ownercheck(NamespaceRelationId, namespaceId, GetUserId()))
110  check_object_ownership(GetUserId(), stmt->removeType, address,
111  object, relation);
112 
113  /*
114  * Make note if a temporary namespace has been accessed in this
115  * transaction.
116  */
117  if (OidIsValid(namespaceId) && isTempNamespace(namespaceId))
119 
120  /* Release any relcache reference count, but keep lock until commit. */
121  if (relation)
122  table_close(relation, NoLock);
123 
124  add_exact_object_address(&address, objects);
125  }
126 
127  /* Here we really delete them. */
128  performMultipleDeletions(objects, stmt->behavior, 0);
129 
130  free_object_addresses(objects);
131 }
bool object_ownercheck(Oid classid, Oid objectid, Oid roleid)
Definition: aclchk.c:4799
void performMultipleDeletions(const ObjectAddresses *objects, DropBehavior behavior, int flags)
Definition: dependency.c:381
ObjectAddresses * new_object_addresses(void)
Definition: dependency.c:2526
void add_exact_object_address(const ObjectAddress *object, ObjectAddresses *addrs)
Definition: dependency.c:2581
void free_object_addresses(ObjectAddresses *addrs)
Definition: dependency.c:2821
static void does_not_exist_skipping(ObjectType objtype, Node *object)
Definition: dropcmds.c:248
int errhint(const char *fmt,...)
Definition: elog.c:1153
int errcode(int sqlerrcode)
Definition: elog.c:695
Assert(fmt[strlen(fmt) - 1] !='\n')
#define AccessExclusiveLock
Definition: lockdefs.h:43
char get_func_prokind(Oid funcid)
Definition: lsyscache.c:1800
Oid GetUserId(void)
Definition: miscinit.c:497
bool isTempNamespace(Oid namespaceId)
Definition: namespace.c:3200
void check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address, Node *object, Relation relation)
ObjectAddress get_object_address(ObjectType objtype, Node *object, Relation *relp, LOCKMODE lockmode, bool missing_ok)
Oid get_object_namespace(const ObjectAddress *address)
#define lfirst(lc)
Definition: pg_list.h:170
unsigned int Oid
Definition: postgres_ext.h:31
bool missing_ok
Definition: parsenodes.h:2849
List * objects
Definition: parsenodes.h:2846
ObjectType removeType
Definition: parsenodes.h:2847
DropBehavior behavior
Definition: parsenodes.h:2848
Definition: nodes.h:118
void table_close(Relation relation, LOCKMODE lockmode)
Definition: table.c:126
int MyXactFlags
Definition: xact.c:135
#define XACT_FLAGS_ACCESSEDTEMPNAMESPACE
Definition: xact.h:102

References AccessExclusiveLock, add_exact_object_address(), Assert(), DropStmt::behavior, castNode, check_object_ownership(), does_not_exist_skipping(), ereport, errcode(), errhint(), errmsg(), ERROR, free_object_addresses(), get_func_prokind(), get_object_address(), get_object_namespace(), GetUserId(), isTempNamespace(), lfirst, DropStmt::missing_ok, MyXactFlags, NameListToString(), new_object_addresses(), NoLock, OBJECT_FUNCTION, object_ownercheck(), ObjectAddress::objectId, DropStmt::objects, OidIsValid, performMultipleDeletions(), DropStmt::removeType, table_close(), and XACT_FLAGS_ACCESSEDTEMPNAMESPACE.

Referenced by ExecDropStmt().

◆ schema_does_not_exist_skipping()

static bool schema_does_not_exist_skipping ( List object,
const char **  msg,
char **  name 
)
static

Definition at line 179 of file dropcmds.c.

180 {
181  RangeVar *rel;
182 
183  rel = makeRangeVarFromNameList(object);
184 
185  if (rel->schemaname != NULL &&
187  {
188  *msg = gettext_noop("schema \"%s\" does not exist, skipping");
189  *name = rel->schemaname;
190 
191  return true;
192  }
193 
194  return false;
195 }
Oid LookupNamespaceNoError(const char *nspname)
Definition: namespace.c:2906
char * schemaname
Definition: primnodes.h:74

References gettext_noop, LookupNamespaceNoError(), makeRangeVarFromNameList(), name, OidIsValid, and RangeVar::schemaname.

Referenced by does_not_exist_skipping(), owningrel_does_not_exist_skipping(), and type_in_list_does_not_exist_skipping().

◆ type_in_list_does_not_exist_skipping()

static bool type_in_list_does_not_exist_skipping ( List typenames,
const char **  msg,
char **  name 
)
static

Definition at line 211 of file dropcmds.c.

213 {
214  ListCell *l;
215 
216  foreach(l, typenames)
217  {
218  TypeName *typeName = lfirst_node(TypeName, l);
219 
220  if (typeName != NULL)
221  {
222  if (!OidIsValid(LookupTypeNameOid(NULL, typeName, true)))
223  {
224  /* type doesn't exist, try to find why */
225  if (schema_does_not_exist_skipping(typeName->names, msg, name))
226  return true;
227 
228  *msg = gettext_noop("type \"%s\" does not exist, skipping");
229  *name = TypeNameToString(typeName);
230 
231  return true;
232  }
233  }
234  }
235 
236  return false;
237 }
Oid LookupTypeNameOid(ParseState *pstate, const TypeName *typeName, bool missing_ok)
Definition: parse_type.c:232
#define lfirst_node(type, lc)
Definition: pg_list.h:174

References gettext_noop, lfirst_node, LookupTypeNameOid(), name, TypeName::names, OidIsValid, schema_does_not_exist_skipping(), and TypeNameToString().

Referenced by does_not_exist_skipping().