PostgreSQL Source Code: src/backend/commands/amcmds.c File Reference (original) (raw)
Go to the source code of this file.
Functions | |
---|---|
static Oid | lookup_am_handler_func (List *handler_name, char amtype) |
static const char * | get_am_type_string (char amtype) |
ObjectAddress | CreateAccessMethod (CreateAmStmt *stmt) |
static Oid | get_am_type_oid (const char *amname, char amtype, bool missing_ok) |
Oid | get_index_am_oid (const char *amname, bool missing_ok) |
Oid | get_table_am_oid (const char *amname, bool missing_ok) |
Oid | get_am_oid (const char *amname, bool missing_ok) |
char * | get_am_name (Oid amOid) |
◆ CreateAccessMethod()
Definition at line 43 of file amcmds.c.
44{
48 Oid amoid;
49 Oid amhandler;
50 bool nulls[Natts_pg_am];
53
55
56
59 (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
60 errmsg("permission denied to create access method \"%s\"",
61 stmt->amname),
62 errhint("Must be superuser to create an access method.")));
63
64
68 {
71 errmsg("access method \"%s\" already exists",
72 stmt->amname)));
73 }
74
75
76
77
79
80
81
82
84 memset(nulls, false, sizeof(nulls));
85
88 values[Anum_pg_am_amname - 1] =
92
94
97
98 myself.classId = AccessMethodRelationId;
101
102
103 referenced.classId = ProcedureRelationId;
104 referenced.objectId = amhandler;
106
108
110
112
114
115 return myself;
116}
static Oid lookup_am_handler_func(List *handler_name, char amtype)
static Datum values[MAXATTR]
#define OidIsValid(objectId)
Oid GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#define DirectFunctionCall1(func, arg1)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
void heap_freetuple(HeapTuple htup)
void CatalogTupleInsert(Relation heapRel, HeapTuple tup)
Datum namein(PG_FUNCTION_ARGS)
#define InvokeObjectPostCreateHook(classId, objectId, subId)
void recordDependencyOn(const ObjectAddress *depender, const ObjectAddress *referenced, DependencyType behavior)
void recordDependencyOnCurrentExtension(const ObjectAddress *object, bool isReplace)
static Datum ObjectIdGetDatum(Oid X)
static Datum CStringGetDatum(const char *X)
static Datum CharGetDatum(char X)
#define RelationGetDescr(relation)
#define ERRCODE_DUPLICATE_OBJECT
#define GetSysCacheOid1(cacheId, oidcol, key1)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
References CatalogTupleInsert(), CharGetDatum(), ObjectAddress::classId, CStringGetDatum(), DEPENDENCY_NORMAL, DirectFunctionCall1, ereport, errcode(), ERRCODE_DUPLICATE_OBJECT, errhint(), errmsg(), ERROR, GetNewOidWithIndex(), GetSysCacheOid1, heap_form_tuple(), heap_freetuple(), InvokeObjectPostCreateHook, lookup_am_handler_func(), namein(), ObjectAddress::objectId, ObjectIdGetDatum(), ObjectAddress::objectSubId, OidIsValid, recordDependencyOn(), recordDependencyOnCurrentExtension(), RelationGetDescr, RowExclusiveLock, stmt, superuser(), table_close(), table_open(), and values.
Referenced by ProcessUtilitySlow().
◆ get_am_name()
char * get_am_name | ( | Oid | amOid | ) |
---|
Definition at line 192 of file amcmds.c.
193{
195 char *result = NULL;
196
199 {
201
204 }
205 return result;
206}
#define HeapTupleIsValid(tuple)
static void * GETSTRUCT(const HeapTupleData *tuple)
char * pstrdup(const char *in)
FormData_pg_am * Form_pg_am
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
References GETSTRUCT(), HeapTupleIsValid, NameStr, ObjectIdGetDatum(), pstrdup(), ReleaseSysCache(), and SearchSysCache1().
Referenced by assignOperTypes(), ATAddForeignKeyConstraint(), DefineIndex(), getObjectIdentityParts(), GetOperatorFromCompareType(), IsThereOpClassInNamespace(), and IsThereOpFamilyInNamespace().
◆ get_am_oid()
Oid get_am_oid | ( | const char * | amname, |
---|---|---|---|
bool | missing_ok | ||
) |
◆ get_am_type_oid()
static Oid get_am_type_oid ( const char * amname, char amtype, bool missing_ok ) | static |
---|
Definition at line 129 of file amcmds.c.
130{
133
136 {
138
139 if (amtype != '\0' &&
140 amform->amtype != amtype)
142 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
143 errmsg("access method \"%s\" is not of type %s",
146
147 oid = amform->oid;
149 }
150
153 (errcode(ERRCODE_UNDEFINED_OBJECT),
154 errmsg("access method \"%s\" does not exist", amname)));
155 return oid;
156}
static const char * get_am_type_string(char amtype)
References CStringGetDatum(), ereport, errcode(), errmsg(), ERROR, get_am_type_string(), GETSTRUCT(), HeapTupleIsValid, InvalidOid, NameStr, OidIsValid, ReleaseSysCache(), and SearchSysCache1().
Referenced by get_am_oid(), get_index_am_oid(), and get_table_am_oid().
◆ get_am_type_string()
static const char * get_am_type_string ( char amtype) | static |
---|
Definition at line 212 of file amcmds.c.
213{
214 switch (amtype)
215 {
216 case AMTYPE_INDEX:
217 return "INDEX";
218 case AMTYPE_TABLE:
219 return "TABLE";
220 default:
221
222 elog(ERROR, "invalid access method type '%c'", amtype);
223 return NULL;
224 }
225}
Referenced by get_am_type_oid().
◆ get_index_am_oid()
Oid get_index_am_oid | ( | const char * | amname, |
---|---|---|---|
bool | missing_ok | ||
) |
◆ get_table_am_oid()
Oid get_table_am_oid | ( | const char * | amname, |
---|---|---|---|
bool | missing_ok | ||
) |
◆ lookup_am_handler_func()
static Oid lookup_am_handler_func ( List * handler_name, char amtype ) | static |
---|
Definition at line 234 of file amcmds.c.
235{
236 Oid handlerOid;
237 Oid funcargtypes[1] = {INTERNALOID};
239
240 if (handler_name == NIL)
242 (errcode(ERRCODE_UNDEFINED_FUNCTION),
243 errmsg("handler function is not specified")));
244
245
246 handlerOid = LookupFuncName(handler_name, 1, funcargtypes, false);
247
248
249 switch (amtype)
250 {
251 case AMTYPE_INDEX:
252 expectedType = INDEX_AM_HANDLEROID;
253 break;
254 case AMTYPE_TABLE:
255 expectedType = TABLE_AM_HANDLEROID;
256 break;
257 default:
258 elog(ERROR, "unrecognized access method type \"%c\"", amtype);
259 }
260
263 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
264 errmsg("function %s must return type %s",
267
268 return handlerOid;
269}
char * format_type_extended(Oid type_oid, int32 typemod, bits16 flags)
char * get_func_name(Oid funcid)
Oid get_func_rettype(Oid funcid)
Oid LookupFuncName(List *funcname, int nargs, const Oid *argtypes, bool missing_ok)
References elog, ereport, errcode(), errmsg(), ERROR, format_type_extended(), get_func_name(), get_func_rettype(), InvalidOid, LookupFuncName(), and NIL.
Referenced by CreateAccessMethod().