qfrjava
2025-04-14 b94d4dd2e6bb5be898cda29c7e8a5356de1e60d7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
 
#ifndef AG_AG_LABEL_H
#define AG_AG_LABEL_H
 
#include "postgres.h"
 
#include "nodes/execnodes.h"
 
#include "catalog/ag_catalog.h"
 
#define Anum_ag_label_vertex_table_id 1
#define Anum_ag_label_vertex_table_properties 2
 
#define Anum_ag_label_edge_table_id 1
#define Anum_ag_label_edge_table_start_id 2
#define Anum_ag_label_edge_table_end_id 3
#define Anum_ag_label_edge_table_properties 4
 
#define vertex_tuple_id Anum_ag_label_vertex_table_id - 1
#define vertex_tuple_properties Anum_ag_label_vertex_table_properties - 1
 
#define edge_tuple_id Anum_ag_label_edge_table_id - 1
#define edge_tuple_start_id Anum_ag_label_edge_table_start_id - 1
#define edge_tuple_end_id Anum_ag_label_edge_table_end_id - 1
#define edge_tuple_properties Anum_ag_label_edge_table_properties - 1
 
 
 
#define Anum_ag_label_name 1
#define Anum_ag_label_graph 2
#define Anum_ag_label_id 3
#define Anum_ag_label_kind 4
#define Anum_ag_label_relation 5
#define Anum_ag_label_seq_name 6
 
 
#define Natts_ag_label 6
 
#define ag_label_relation_id() ag_relation_id("ag_label", "table")
#define ag_label_name_graph_index_id() \
    ag_relation_id("ag_label_name_graph_index", "index")
#define ag_label_graph_oid_index_id() \
    ag_relation_id("ag_label_graph_oid_index", "index")
#define ag_label_relation_index_id() \
    ag_relation_id("ag_label_relation_index", "index")
#define ag_label_seq_name_graph_index_id() \
    ag_relation_id("ag_label_seq_name_graph_index", "index")
 
#define LABEL_ID_SEQ_NAME "_label_id_seq"
 
#define LABEL_KIND_VERTEX 'v'
#define LABEL_KIND_EDGE 'e'
 
void insert_label(const char *label_name, Oid graph_oid, int32 label_id,
                  char label_kind, Oid label_relation, const char *seq_name);
void delete_label(Oid relation);
 
int32 get_label_id(const char *label_name, Oid graph_oid);
Oid get_label_relation(const char *label_name, Oid graph_oid);
char *get_label_relation_name(const char *label_name, Oid graph_oid);
Oid get_label_oid(const char *label_name, Oid label_graph);
char get_label_kind(const char *label_name, Oid label_graph);
 
bool label_id_exists(Oid graph_oid, int32 label_id);
RangeVar *get_label_range_var(char *graph_name, Oid graph_oid,
                              char *label_name);
 
List *get_all_edge_labels_per_graph(EState *estate, Oid graph_oid);
 
#define label_exists(label_name, label_graph) \
    OidIsValid(get_label_id(label_name, label_graph))
 
#endif