1/*-------------------------------------------------------------------------
2 *
3 * defrem.h
4 * POSTGRES define and remove utility definitions.
5 *
6 *
7 * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
9 *
10 * src/include/commands/defrem.h
11 *
12 *-------------------------------------------------------------------------
13 */
14#ifndef DEFREM_H
15#define DEFREM_H
16
17#include "catalog/objectaddress.h"
18#include "nodes/params.h"
19#include "nodes/parsenodes.h"
20#include "tcop/dest.h"
21#include "utils/array.h"
22
23/* commands/dropcmds.c */
24extern void RemoveObjects(DropStmt *stmt);
25
26/* commands/indexcmds.c */
27extern ObjectAddress DefineIndex(Oid relationId,
28 IndexStmt *stmt,
29 Oid indexRelationId,
30 Oid parentIndexId,
31 Oid parentConstraintId,
32 bool is_alter_table,
33 bool check_rights,
34 bool check_not_in_use,
35 bool skip_build,
36 bool quiet);
37extern void ReindexIndex(RangeVar *indexRelation, int options, bool concurrent);
38extern Oid ReindexTable(RangeVar *relation, int options, bool concurrent);
39extern void ReindexMultipleTables(const char *objectName, ReindexObjectType objectKind,
40 int options, bool concurrent);
41extern char *makeObjectName(const char *name1, const char *name2,
42 const char *label);
43extern char *ChooseRelationName(const char *name1, const char *name2,
44 const char *label, Oid namespaceid,
45 bool isconstraint);
46extern bool CheckIndexCompatible(Oid oldId,
47 const char *accessMethodName,
48 List *attributeList,
49 List *exclusionOpNames);
50extern Oid GetDefaultOpClass(Oid type_id, Oid am_id);
51extern Oid ResolveOpClass(List *opclass, Oid attrType,
52 const char *accessMethodName, Oid accessMethodId);
53
54/* commands/functioncmds.c */
55extern ObjectAddress CreateFunction(ParseState *pstate, CreateFunctionStmt *stmt);
56extern void RemoveFunctionById(Oid funcOid);
57extern void SetFunctionReturnType(Oid funcOid, Oid newRetType);
58extern void SetFunctionArgType(Oid funcOid, int argIndex, Oid newArgType);
59extern ObjectAddress AlterFunction(ParseState *pstate, AlterFunctionStmt *stmt);
60extern ObjectAddress CreateCast(CreateCastStmt *stmt);
61extern void DropCastById(Oid castOid);
62extern ObjectAddress CreateTransform(CreateTransformStmt *stmt);
63extern void DropTransformById(Oid transformOid);
64extern void IsThereFunctionInNamespace(const char *proname, int pronargs,
65 oidvector *proargtypes, Oid nspOid);
66extern void ExecuteDoStmt(DoStmt *stmt, bool atomic);
67extern void ExecuteCallStmt(CallStmt *stmt, ParamListInfo params, bool atomic, DestReceiver *dest);
68extern TupleDesc CallStmtResultDesc(CallStmt *stmt);
69extern Oid get_cast_oid(Oid sourcetypeid, Oid targettypeid, bool missing_ok);
70extern Oid get_transform_oid(Oid type_id, Oid lang_id, bool missing_ok);
71extern void interpret_function_parameter_list(ParseState *pstate,
72 List *parameters,
73 Oid languageOid,
74 ObjectType objtype,
75 oidvector **parameterTypes,
76 ArrayType **allParameterTypes,
77 ArrayType **parameterModes,
78 ArrayType **parameterNames,
79 List **parameterDefaults,
80 Oid *variadicArgType,
81 Oid *requiredResultType);
82
83/* commands/operatorcmds.c */
84extern ObjectAddress DefineOperator(List *names, List *parameters);
85extern void RemoveOperatorById(Oid operOid);
86extern ObjectAddress AlterOperator(AlterOperatorStmt *stmt);
87
88/* commands/statscmds.c */
89extern ObjectAddress CreateStatistics(CreateStatsStmt *stmt);
90extern void RemoveStatisticsById(Oid statsOid);
91extern void UpdateStatisticsForTypeChange(Oid statsOid,
92 Oid relationOid, int attnum,
93 Oid oldColumnType, Oid newColumnType);
94
95/* commands/aggregatecmds.c */
96extern ObjectAddress DefineAggregate(ParseState *pstate, List *name, List *args, bool oldstyle,
97 List *parameters, bool replace);
98
99/* commands/opclasscmds.c */
100extern ObjectAddress DefineOpClass(CreateOpClassStmt *stmt);
101extern ObjectAddress DefineOpFamily(CreateOpFamilyStmt *stmt);
102extern Oid AlterOpFamily(AlterOpFamilyStmt *stmt);
103extern void RemoveOpClassById(Oid opclassOid);
104extern void RemoveOpFamilyById(Oid opfamilyOid);
105extern void RemoveAmOpEntryById(Oid entryOid);
106extern void RemoveAmProcEntryById(Oid entryOid);
107extern void IsThereOpClassInNamespace(const char *opcname, Oid opcmethod,
108 Oid opcnamespace);
109extern void IsThereOpFamilyInNamespace(const char *opfname, Oid opfmethod,
110 Oid opfnamespace);
111extern Oid get_opclass_oid(Oid amID, List *opclassname, bool missing_ok);
112extern Oid get_opfamily_oid(Oid amID, List *opfamilyname, bool missing_ok);
113
114/* commands/tsearchcmds.c */
115extern ObjectAddress DefineTSParser(List *names, List *parameters);
116extern void RemoveTSParserById(Oid prsId);
117
118extern ObjectAddress DefineTSDictionary(List *names, List *parameters);
119extern void RemoveTSDictionaryById(Oid dictId);
120extern ObjectAddress AlterTSDictionary(AlterTSDictionaryStmt *stmt);
121
122extern ObjectAddress DefineTSTemplate(List *names, List *parameters);
123extern void RemoveTSTemplateById(Oid tmplId);
124
125extern ObjectAddress DefineTSConfiguration(List *names, List *parameters,
126 ObjectAddress *copied);
127extern void RemoveTSConfigurationById(Oid cfgId);
128extern ObjectAddress AlterTSConfiguration(AlterTSConfigurationStmt *stmt);
129
130extern text *serialize_deflist(List *deflist);
131extern List *deserialize_deflist(Datum txt);
132
133/* commands/foreigncmds.c */
134extern ObjectAddress AlterForeignServerOwner(const char *name, Oid newOwnerId);
135extern void AlterForeignServerOwner_oid(Oid, Oid newOwnerId);
136extern ObjectAddress AlterForeignDataWrapperOwner(const char *name, Oid newOwnerId);
137extern void AlterForeignDataWrapperOwner_oid(Oid fwdId, Oid newOwnerId);
138extern ObjectAddress CreateForeignDataWrapper(CreateFdwStmt *stmt);
139extern ObjectAddress AlterForeignDataWrapper(AlterFdwStmt *stmt);
140extern void RemoveForeignDataWrapperById(Oid fdwId);
141extern ObjectAddress CreateForeignServer(CreateForeignServerStmt *stmt);
142extern ObjectAddress AlterForeignServer(AlterForeignServerStmt *stmt);
143extern void RemoveForeignServerById(Oid srvId);
144extern ObjectAddress CreateUserMapping(CreateUserMappingStmt *stmt);
145extern ObjectAddress AlterUserMapping(AlterUserMappingStmt *stmt);
146extern Oid RemoveUserMapping(DropUserMappingStmt *stmt);
147extern void RemoveUserMappingById(Oid umId);
148extern void CreateForeignTable(CreateForeignTableStmt *stmt, Oid relid);
149extern void ImportForeignSchema(ImportForeignSchemaStmt *stmt);
150extern Datum transformGenericOptions(Oid catalogId,
151 Datum oldOptions,
152 List *options,
153 Oid fdwvalidator);
154
155/* commands/amcmds.c */
156extern ObjectAddress CreateAccessMethod(CreateAmStmt *stmt);
157extern void RemoveAccessMethodById(Oid amOid);
158extern Oid get_index_am_oid(const char *amname, bool missing_ok);
159extern Oid get_table_am_oid(const char *amname, bool missing_ok);
160extern Oid get_am_oid(const char *amname, bool missing_ok);
161extern char *get_am_name(Oid amOid);
162
163/* support routines in commands/define.c */
164
165extern char *defGetString(DefElem *def);
166extern double defGetNumeric(DefElem *def);
167extern bool defGetBoolean(DefElem *def);
168extern int32 defGetInt32(DefElem *def);
169extern int64 defGetInt64(DefElem *def);
170extern List *defGetQualifiedName(DefElem *def);
171extern TypeName *defGetTypeName(DefElem *def);
172extern int defGetTypeLength(DefElem *def);
173extern List *defGetStringList(DefElem *def);
174
175#endif /* DEFREM_H */
176