24#include "catalog/pg_collation_d.h"
25#include "catalog/pg_operator_d.h"
42#include "utils/fmgroids.h"
77 const char *aliasname,
int location);
80 const char *aliasname,
int location,
const char *
type,
118 errmsg(
"property graphs cannot be unlogged because they do not have storage")));
122 foreach(
lc,
stmt->vertex_tables)
138 if (
vertex->vtable->alias)
139 vinfo->aliasname =
vertex->vtable->alias->aliasname;
146 errmsg(
"alias \"%s\" used more than once as element table",
vinfo->aliasname),
160 foreach(
lc,
stmt->edge_tables)
181 if (
edge->etable->alias)
182 einfo->aliasname =
edge->etable->alias->aliasname;
184 einfo->aliasname =
edge->etable->relname;
189 errmsg(
"alias \"%s\" used more than once as element table",
einfo->aliasname),
215 errmsg(
"source vertex \"%s\" of edge \"%s\" does not exist",
221 errmsg(
"destination vertex \"%s\" of edge \"%s\" does not exist",
229 einfo->aliasname,
edge->location,
"SOURCE",
232 einfo->aliasname,
edge->location,
"DESTINATION",
260 (
errmsg(
"property graph \"%s\" will be temporary",
261 stmt->pgname->relname)));
299 if (
einfo->srcvertexid &&
einfo->destvertexid)
336 errmsg(
"no key specified and no suitable primary key exists for definition of element \"%s\"",
aliasname),
389 errmsg(
"mismatching number of columns in %s vertex definition of edge \"%s\"",
type,
aliasname),
397 for (
int i = 0;
i < nkeys;
i++)
452 errmsg(
"no equality operator exists for %s key comparison of edge \"%s\"",
470 errmsg(
"collation mismatch in %s key of edge \"%s\": %s vs. %s",
487 errmsg(
"more than one suitable foreign key exists for %s key of edge \"%s\"",
type,
aliasname),
496 errmsg(
"no %s key specified and no suitable foreign key exists for definition of edge \"%s\"",
type,
aliasname),
508 for (
int i = 0;
i < nkeys;
i++)
529 foreach(
lc, colnames)
539 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
549 if (attnums[
j] == attnums[k])
552 errmsg(
"graph key columns list must not contain duplicates"),
684 if (
einfo->srcvertexid)
692 if (
einfo->destvertexid)
852 if (
att->attnum <= 0 ||
att->attisdropped)
881 errmsg(
"property name required"),
985 errmsg(
"property \"%s\" data type mismatch: %s vs. %s",
987 errdetail(
"In a property graph, a property of the same name has to have the same data type in each label."));
995 errmsg(
"property \"%s\" collation mismatch: %s vs. %s",
997 errdetail(
"In a property graph, a property of the same name has to have the same collation in each label."));
1121 elog(
ERROR,
"cache lookup failed for property graph element %u",
peoid);
1143 errmsg(
"element \"%s\" property \"%s\" expression mismatch: %s vs. %s",
1145 errdetail(
"In a property graph element, a property of the same name has to have the same expression in each label."));
1209 labelid =
ellabel->pgellabelid;
1305 (
errmsg(
"relation \"%s\" does not exist, skipping",
1306 stmt->pgname->relname)));
1312 foreach(
lc,
stmt->add_vertex_tables)
1329 errmsg(
"cannot add temporary element table to non-temporary property graph"),
1333 if (
vertex->vtable->alias)
1334 vinfo->aliasname =
vertex->vtable->alias->aliasname;
1349 errmsg(
"alias \"%s\" already exists in property graph \"%s\"",
1350 vinfo->aliasname,
stmt->pgname->relname),
1360 foreach(
lc,
stmt->add_edge_tables)
1379 errmsg(
"cannot add temporary element table to non-temporary property graph"),
1383 if (
edge->etable->alias)
1384 einfo->aliasname =
edge->etable->alias->aliasname;
1386 einfo->aliasname =
edge->etable->relname;
1400 einfo->aliasname,
edge->location,
"SOURCE",
1403 einfo->aliasname,
edge->location,
"DESTINATION",
1418 errmsg(
"alias \"%s\" already exists in property graph \"%s\"",
1419 einfo->aliasname,
stmt->pgname->relname),
1429 foreach(
lc,
stmt->drop_vertex_tables)
1440 foreach(
lc,
stmt->drop_edge_tables)
1452 if (
stmt->drop_vertex_tables ||
stmt->drop_edge_tables)
1466 foreach(
lc,
stmt->add_labels)
1490 if (
stmt->drop_label)
1509 errmsg(
"property graph \"%s\" element \"%s\" has no label \"%s\"",
1521 errmsg(
"property graph \"%s\" element \"%s\" has no label \"%s\"",
1536 if (
stmt->add_properties)
1555 errmsg(
"property graph \"%s\" element \"%s\" has no label \"%s\"",
1566 errmsg(
"property graph \"%s\" element \"%s\" has no label \"%s\"",
1579 if (
stmt->drop_properties)
1598 errmsg(
"property graph \"%s\" element \"%s\" has no label \"%s\"",
1610 errmsg(
"property graph \"%s\" element \"%s\" has no label \"%s\"",
1614 foreach(
lc,
stmt->drop_properties)
1627 errmsg(
"property graph \"%s\" element \"%s\" label \"%s\" has no property \"%s\"",
1641 if (
stmt->drop_properties ||
stmt->drop_vertex_tables ||
stmt->drop_edge_tables)
1693 errmsg(
"property graph \"%s\" has no element with alias \"%s\"",
1700 errmsg(
"element \"%s\" of property graph \"%s\" is not a vertex",
1725 errmsg(
"property graph \"%s\" has no element with alias \"%s\"",
1732 errmsg(
"element \"%s\" of property graph \"%s\" is not an edge",
1754 elog(
ERROR,
"cache lookup failed for property graph element %u",
peid);
ArrayType * construct_array_builtin(Datum *elems, int nelems, Oid elmtype)
void deconstruct_array_builtin(const ArrayType *array, Oid elmtype, Datum **elemsp, bool **nullsp, int *nelemsp)
static Datum values[MAXATTR]
#define CStringGetTextDatum(s)
#define TextDatumGetCString(d)
#define Assert(condition)
#define OidIsValid(objectId)
Oid GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn)
void record_object_address_dependencies(const ObjectAddress *depender, ObjectAddresses *referenced, DependencyType behavior)
void performDeletion(const ObjectAddress *object, DropBehavior behavior, int flags)
void recordDependencyOnSingleRelExpr(const ObjectAddress *depender, Node *expr, Oid relId, DependencyType behavior, DependencyType self_behavior, bool reverse_self)
void add_exact_object_address(const ObjectAddress *object, ObjectAddresses *addrs)
ObjectAddresses * new_object_addresses(void)
int errcode(int sqlerrcode)
int errdetail(const char *fmt,...) pg_attribute_printf(1
#define ereport(elevel,...)
bool equal(const void *a, const void *b)
#define palloc_array(type, count)
#define palloc0_object(type)
void systable_endscan(SysScanDesc sysscan)
HeapTuple systable_getnext(SysScanDesc sysscan)
SysScanDesc systable_beginscan(Relation heapRelation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, ScanKey key)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
void heap_freetuple(HeapTuple htup)
#define HeapTupleIsValid(tuple)
static Datum heap_getattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
static void * GETSTRUCT(const HeapTupleData *tuple)
void index_close(Relation relation, LOCKMODE lockmode)
Relation index_open(Oid relationId, LOCKMODE lockmode)
Oid GetDefaultOpClass(Oid type_id, Oid am_id)
void CatalogTupleInsert(Relation heapRel, HeapTuple tup)
void CacheInvalidateRelcacheByRelid(Oid relid)
List * list_difference(const List *list1, const List *list2)
List * lappend(List *list, void *datum)
List * lappend_oid(List *list, Oid datum)
bool list_member(const List *list, const void *datum)
#define ShareRowExclusiveLock
char * get_rel_name(Oid relid)
char * get_propgraph_property_name(Oid propoid)
char get_rel_persistence(Oid relid)
AttrNumber get_attnum(Oid relid, const char *attname)
Oid get_opclass_family(Oid opclass)
char * get_collation_name(Oid colloid)
Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype, int16 strategy)
char * get_propgraph_label_name(Oid labeloid)
void get_atttypetypmodcoll(Oid relid, AttrNumber attnum, Oid *typid, int32 *typmod, Oid *collid)
char * pstrdup(const char *in)
void namestrcpy(Name name, const char *str)
Oid RangeVarGetRelidExtended(const RangeVar *relation, LOCKMODE lockmode, uint32 flags, RangeVarGetRelidCallback callback, void *callback_arg)
Oid exprType(const Node *expr)
int32 exprTypmod(const Node *expr)
Oid exprCollation(const Node *expr)
#define IsA(nodeptr, _type_)
const ObjectAddress InvalidObjectAddress
#define ObjectAddressSet(addr, class_id, object_id)
#define ObjectAddressSubSet(addr, class_id, object_id, object_sub_id)
char * nodeToString(const void *obj)
bool can_coerce_type(int nargs, const Oid *input_typeids, const Oid *target_typeids, CoercionContext ccontext)
void assign_expr_collations(ParseState *pstate, Node *expr)
int parser_errposition(ParseState *pstate, int location)
ParseState * make_parsestate(ParseState *parentParseState)
@ EXPR_KIND_PROPGRAPH_PROPERTY
void addNSItemToQuery(ParseState *pstate, ParseNamespaceItem *nsitem, bool addToJoinList, bool addToRelNameSpace, bool addToVarNameSpace)
ParseNamespaceItem * addRangeTableEntryForRelation(ParseState *pstate, Relation rel, LOCKMODE lockmode, Alias *alias, bool inh, bool inFromCl)
List * transformTargetList(ParseState *pstate, List *targetlist, ParseExprKind exprKind)
@ PROPGRAPH_ELEMENT_KIND_VERTEX
FormData_pg_attribute * Form_pg_attribute
void recordDependencyOn(const ObjectAddress *depender, const ObjectAddress *referenced, DependencyType behavior)
#define lfirst_node(type, lc)
static int list_length(const List *l)
#define forboth(cell1, list1, cell2, list2)
#define foreach_node(type, var, lst)
#define foreach_oid(var, lst)
END_CATALOG_STRUCT typedef FormData_pg_propgraph_element * Form_pg_propgraph_element
END_CATALOG_STRUCT typedef FormData_pg_propgraph_element_label * Form_pg_propgraph_element_label
END_CATALOG_STRUCT typedef FormData_pg_propgraph_label * Form_pg_propgraph_label
END_CATALOG_STRUCT typedef FormData_pg_propgraph_label_property * Form_pg_propgraph_label_property
END_CATALOG_STRUCT typedef FormData_pg_propgraph_property * Form_pg_propgraph_property
static Datum PointerGetDatum(const void *X)
static Oid DatumGetObjectId(Datum X)
static Datum Int16GetDatum(int16 X)
static Datum ObjectIdGetDatum(Oid X)
static Datum NameGetDatum(const NameData *X)
static Datum CStringGetDatum(const char *X)
static Datum Int32GetDatum(int32 X)
static int16 DatumGetInt16(Datum X)
static Datum CharGetDatum(char X)
static void insert_property_record(Oid graphid, Oid ellabeloid, Oid pgerelid, const char *propname, const Expr *expr)
static void check_all_labels_properties(Oid pgrelid)
static Oid get_edge_oid(ParseState *pstate, Oid pgrelid, const char *alias, int location)
static ArrayType * propgraph_element_get_key(ParseState *pstate, const List *keycols, Relation element_rel, const char *aliasname, int location)
static Oid get_element_relid(Oid peid)
static AttrNumber * array_from_column_list(ParseState *pstate, const List *colnames, int location, Relation element_rel)
static Oid get_vertex_oid(ParseState *pstate, Oid pgrelid, const char *alias, int location)
static void insert_property_records(Oid graphid, Oid ellabeloid, Oid pgerelid, const PropGraphProperties *properties)
ObjectAddress AlterPropGraph(ParseState *pstate, const AlterPropGraphStmt *stmt)
static Oid insert_label_record(Oid graphid, Oid peoid, const char *label)
static void check_element_label_properties(Oid ellabeloid)
static List * get_element_label_property_names(Oid ellabeloid)
static List * get_graph_label_ids(Oid graphid)
ObjectAddress CreatePropGraph(ParseState *pstate, const CreatePropGraphStmt *stmt)
static Oid insert_element_record(ObjectAddress pgaddress, struct element_info *einfo)
static List * get_label_element_label_ids(Oid labelid)
static ArrayType * array_from_attnums(int numattrs, const AttrNumber *attnums)
static List * get_graph_property_ids(Oid graphid)
static void array_of_opers_to_objectaddrs(ArrayType *arr, ObjectAddresses *addrs)
static void check_element_properties(Oid peoid)
static void array_of_attnums_to_objectaddrs(Oid relid, ArrayType *arr, ObjectAddresses *addrs)
static void propgraph_edge_get_ref_keys(ParseState *pstate, const List *keycols, const List *refcols, Relation edge_rel, Relation ref_rel, const char *aliasname, int location, const char *type, ArrayType **outkey, ArrayType **outref, ArrayType **outeqop)
void * stringToNode(const char *str)
#define RelationGetRelid(relation)
#define RelationGetDescr(relation)
Oid RelationGetPrimaryKeyIndex(Relation relation, bool deferrable_ok)
List * RelationGetFKeyList(Relation relation)
List * deparse_context_for(const char *aliasname, Oid relid)
char * deparse_expression(Node *expr, List *dpcontext, bool forceprefix, bool showimplicit)
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
#define HTEqualStrategyNumber
#define BTEqualStrategyNumber
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache2(SysCacheIdentifier cacheId, Datum key1, Datum key2)
HeapTuple SearchSysCache1(SysCacheIdentifier cacheId, Datum key1)
#define SearchSysCacheExists2(cacheId, key1, key2)
#define GetSysCacheOid2(cacheId, oidcol, key1, key2)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
ObjectAddress DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId, ObjectAddress *typaddress, const char *queryString)
void RangeVarCallbackOwnsRelation(const RangeVar *relation, Oid relId, Oid oldRelId, void *arg)
String * makeString(char *str)
void CommandCounterIncrement(void)