mirror of https://github.com/postgres/postgres
Implementation of SQL property graph queries, according to SQL/PGQ standard (ISO/IEC 9075-16:2023). This adds: - GRAPH_TABLE table function for graph pattern matching - DDL commands CREATE/ALTER/DROP PROPERTY GRAPH - several new system catalogs and information schema views - psql \dG command - pg_get_propgraphdef() function for pg_dump and psql A property graph is a relation with a new relkind RELKIND_PROPGRAPH. It acts like a view in many ways. It is rewritten to a standard relational query in the rewriter. Access privileges act similar to a security invoker view. (The security definer variant is not currently implemented.) Starting documentation can be found in doc/src/sgml/ddl.sgml and doc/src/sgml/queries.sgml. Author: Peter Eisentraut <peter@eisentraut.org> Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> Reviewed-by: Junwang Zhao <zhjwpku@gmail.com> Reviewed-by: Ajay Pal <ajay.pal.k@gmail.com> Reviewed-by: Henson Choi <assam258@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/a855795d-e697-4fa5-8698-d20122126567@eisentraut.orgmaster
parent
fd6ecbfa75
commit
2f094e7ac6
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,27 @@ |
||||
ACYCLIC |
||||
BINDINGS |
||||
BOUND |
||||
DESTINATION |
||||
DIFFERENT |
||||
DIRECTED |
||||
EDGE |
||||
EDGES |
||||
ELEMENTS |
||||
LABEL |
||||
LABELED |
||||
NODE |
||||
PATHS |
||||
PROPERTIES |
||||
PROPERTY |
||||
PROPERTY_GRAPH_CATALOG |
||||
PROPERTY_GRAPH_NAME |
||||
PROPERTY_GRAPH_SCHEMA |
||||
RELATIONSHIP |
||||
RELATIONSHIPS |
||||
SHORTEST |
||||
SINGLETONS |
||||
STEP |
||||
TABLES |
||||
TRAIL |
||||
VERTEX |
||||
WALK |
||||
@ -0,0 +1,12 @@ |
||||
ALL_DIFFERENT |
||||
BINDING_COUNT |
||||
ELEMENT_ID |
||||
ELEMENT_NUMBER |
||||
EXPORT |
||||
GRAPH |
||||
GRAPH_TABLE |
||||
MATCHNUM |
||||
PATH_LENGTH |
||||
PATH_NAME |
||||
PROPERTY_EXISTS |
||||
SAME |
||||
@ -0,0 +1,299 @@ |
||||
<!-- |
||||
doc/src/sgml/ref/alter_property_graph.sgml |
||||
PostgreSQL documentation |
||||
--> |
||||
|
||||
<refentry id="sql-alter-property-graph"> |
||||
<indexterm zone="sql-alter-property-graph"> |
||||
<primary>ALTER PROPERTY GRAPH</primary> |
||||
</indexterm> |
||||
|
||||
<refmeta> |
||||
<refentrytitle>ALTER PROPERTY GRAPH</refentrytitle> |
||||
<manvolnum>7</manvolnum> |
||||
<refmiscinfo>SQL - Language Statements</refmiscinfo> |
||||
</refmeta> |
||||
|
||||
<refnamediv> |
||||
<refname>ALTER PROPERTY GRAPH</refname> |
||||
<refpurpose>change the definition of an SQL-property graph</refpurpose> |
||||
</refnamediv> |
||||
|
||||
<refsynopsisdiv> |
||||
<synopsis> |
||||
ALTER PROPERTY GRAPH <replaceable class="parameter">name</replaceable> ADD |
||||
[ {VERTEX|NODE} TABLES ( <replaceable class="parameter">vertex_table_definition</replaceable> [, ...] ) ] |
||||
[ {EDGE|RELATIONSHIP} TABLES ( <replaceable class="parameter">edge_table_definition</replaceable> [, ...] ) ] |
||||
|
||||
ALTER PROPERTY GRAPH <replaceable class="parameter">name</replaceable> DROP |
||||
{VERTEX|NODE} TABLES ( <replaceable class="parameter">vertex_table_alias</replaceable> [, ...] ) [ CASCADE | RESTRICT ] |
||||
|
||||
ALTER PROPERTY GRAPH <replaceable class="parameter">name</replaceable> DROP |
||||
{EDGE|RELATIONSHIP} TABLES ( <replaceable class="parameter">edge_table_alias</replaceable> [, ...] ) [ CASCADE | RESTRICT ] |
||||
|
||||
ALTER PROPERTY GRAPH <replaceable class="parameter">name</replaceable> ALTER |
||||
{VERTEX|NODE|EDGE|RELATIONSHIP} TABLE <replaceable class="parameter">element_table_alias</replaceable> |
||||
{ ADD LABEL <replaceable class="parameter">label_name</replaceable> [ NO PROPERTIES | PROPERTIES ALL COLUMNS | PROPERTIES ( { <replaceable class="parameter">expression</replaceable> [ AS <replaceable class="parameter">property_name</replaceable> ] } [, ...] ) ] } [ ... ] |
||||
|
||||
ALTER PROPERTY GRAPH <replaceable class="parameter">name</replaceable> ALTER |
||||
{VERTEX|NODE|EDGE|RELATIONSHIP} TABLE <replaceable class="parameter">element_table_alias</replaceable> |
||||
DROP LABEL <replaceable class="parameter">label_name</replaceable> [ CASCADE | RESTRICT ] |
||||
|
||||
ALTER PROPERTY GRAPH <replaceable class="parameter">name</replaceable> ALTER |
||||
{VERTEX|NODE|EDGE|RELATIONSHIP} TABLE <replaceable class="parameter">element_table_alias</replaceable> |
||||
ALTER LABEL <replaceable class="parameter">label_name</replaceable> ADD PROPERTIES ( { <replaceable class="parameter">expression</replaceable> [ AS <replaceable class="parameter">property_name</replaceable> ] } [, ...] ) |
||||
|
||||
ALTER PROPERTY GRAPH <replaceable class="parameter">name</replaceable> ALTER |
||||
{VERTEX|NODE|EDGE|RELATIONSHIP} TABLE <replaceable class="parameter">element_table_alias</replaceable> |
||||
ALTER LABEL <replaceable class="parameter">label_name</replaceable> DROP PROPERTIES ( <replaceable class="parameter">property_name</replaceable> [, ...] ) [ CASCADE | RESTRICT ] |
||||
|
||||
ALTER PROPERTY GRAPH <replaceable class="parameter">name</replaceable> OWNER TO { <replaceable class="parameter">new_owner</replaceable> | CURRENT_USER | SESSION_USER } |
||||
ALTER PROPERTY GRAPH <replaceable class="parameter">name</replaceable> RENAME TO <replaceable class="parameter">new_name</replaceable> |
||||
ALTER PROPERTY GRAPH [ IF EXISTS ] <replaceable class="parameter">name</replaceable> SET SCHEMA <replaceable class="parameter">new_schema</replaceable> |
||||
</synopsis> |
||||
</refsynopsisdiv> |
||||
|
||||
<refsect1> |
||||
<title>Description</title> |
||||
|
||||
<para> |
||||
<command>ALTER PROPERTY GRAPH</command> changes the definition of an |
||||
existing property graph. There are several subforms: |
||||
|
||||
<variablelist> |
||||
<varlistentry> |
||||
<term><literal>ADD {VERTEX|NODE|EDGE|RELATIONSHIP} TABLES</literal></term> |
||||
<listitem> |
||||
<para> |
||||
This form adds new vertex or edge tables to the property graph, using the |
||||
same syntax as <link linkend="sql-create-property-graph"><command>CREATE |
||||
PROPERTY GRAPH</command></link>. |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
|
||||
<varlistentry> |
||||
<term><literal>DROP {VERTEX|NODE|EDGE|RELATIONSHIP} TABLES</literal></term> |
||||
<listitem> |
||||
<para> |
||||
This form removes vertex or edge tables from the property graph. (Only |
||||
the association of the tables with the graph is removed. The tables |
||||
themself are not dropped.) |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
|
||||
<varlistentry> |
||||
<term><literal>ALTER {VERTEX|NODE|EDGE|RELATIONSHIP} TABLE ... ADD LABEL</literal></term> |
||||
<listitem> |
||||
<para> |
||||
This form adds a new label to an existing vertex or edge table, using |
||||
the same syntax as <link |
||||
linkend="sql-create-property-graph"><command>CREATE PROPERTY |
||||
GRAPH</command></link>. |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
|
||||
<varlistentry> |
||||
<term><literal>ALTER {VERTEX|NODE|EDGE|RELATIONSHIP} TABLE ... DROP LABEL</literal></term> |
||||
<listitem> |
||||
<para> |
||||
This form removes a label from an existing vertex or edge table. |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
|
||||
<varlistentry> |
||||
<term><literal>ALTER {VERTEX|NODE|EDGE|RELATIONSHIP} TABLE ... ALTER LABEL ... ADD PROPERTIES</literal></term> |
||||
<listitem> |
||||
<para> |
||||
This form adds new properties to an existing label on an existing |
||||
vertex or edge table. |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
|
||||
<varlistentry> |
||||
<term><literal>ALTER {VERTEX|NODE|EDGE|RELATIONSHIP} TABLE ... ALTER LABEL ... DROP PROPERTIES</literal></term> |
||||
<listitem> |
||||
<para> |
||||
This form removes properties from an existing label on an existing |
||||
vertex or edge table. |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
|
||||
<varlistentry> |
||||
<term><literal>OWNER</literal></term> |
||||
<listitem> |
||||
<para> |
||||
This form changes the owner of the property graph to the specified user. |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
|
||||
<varlistentry> |
||||
<term><literal>RENAME</literal></term> |
||||
<listitem> |
||||
<para> |
||||
This form changes the name of a property graph. |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
|
||||
<varlistentry> |
||||
<term><literal>SET SCHEMA</literal></term> |
||||
<listitem> |
||||
<para> |
||||
This form moves the property graph into another schema. |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
</variablelist> |
||||
</para> |
||||
|
||||
<para> |
||||
You must own the property graph to use <command>ALTER PROPERTY |
||||
GRAPH</command>. To change a property graph's schema, you must also have |
||||
<literal>CREATE</literal> privilege on the new schema. To alter the owner, |
||||
you must be able to <literal>SET ROLE</literal> to the new owning role, and |
||||
that role must have <literal>CREATE</literal> privilege on the property |
||||
graph's schema. (These restrictions enforce that altering the owner |
||||
doesn't do anything you couldn't do by dropping and recreating the property |
||||
graph. However, a superuser can alter ownership of any property graph |
||||
anyway.) |
||||
</para> |
||||
</refsect1> |
||||
|
||||
<refsect1> |
||||
<title>Parameters</title> |
||||
|
||||
<variablelist> |
||||
<varlistentry> |
||||
<term><replaceable class="parameter">name</replaceable></term> |
||||
<listitem> |
||||
<para> |
||||
The name (optionally schema-qualified) of a property graph to be altered. |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
|
||||
<varlistentry> |
||||
<term><literal>IF EXISTS</literal></term> |
||||
<listitem> |
||||
<para> |
||||
Do not throw an error if the property graph does not exist. A notice is |
||||
issued in this case. |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
|
||||
<varlistentry> |
||||
<term><replaceable class="parameter">vertex_table_definition</replaceable></term> |
||||
<term><replaceable class="parameter">edge_table_definition</replaceable></term> |
||||
<listitem> |
||||
<para> |
||||
See <link linkend="sql-create-property-graph"><command>CREATE PROPERTY |
||||
GRAPH</command></link>. |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
|
||||
<varlistentry> |
||||
<term><replaceable class="parameter">vertex_table_alias</replaceable></term> |
||||
<term><replaceable class="parameter">edge_table_alias</replaceable></term> |
||||
<listitem> |
||||
<para> |
||||
The alias of an existing vertex or edge table to operate on. (Note that |
||||
the alias is potentially different from the name of the underlying |
||||
table, if the vertex or edge table was created with <literal>AS |
||||
<replaceable class="parameter">alias</replaceable></literal>.) |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
|
||||
<varlistentry> |
||||
<term><replaceable class="parameter">label_name</replaceable></term> |
||||
<term><replaceable class="parameter">property_name</replaceable></term> |
||||
<term><replaceable class="parameter">expression</replaceable></term> |
||||
<listitem> |
||||
<para> |
||||
See <link linkend="sql-create-property-graph"><command>CREATE PROPERTY |
||||
GRAPH</command></link>. |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
|
||||
<varlistentry> |
||||
<term><replaceable class="parameter">new_owner</replaceable></term> |
||||
<listitem> |
||||
<para> |
||||
The user name of the new owner of the property graph. |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
|
||||
<varlistentry> |
||||
<term><replaceable class="parameter">new_name</replaceable></term> |
||||
<listitem> |
||||
<para> |
||||
The new name for the property graph. |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
|
||||
<varlistentry> |
||||
<term><replaceable class="parameter">new_schema</replaceable></term> |
||||
<listitem> |
||||
<para> |
||||
The new schema for the property graph. |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
</variablelist> |
||||
</refsect1> |
||||
|
||||
<refsect1> |
||||
<title>Notes</title> |
||||
|
||||
<para> |
||||
The consistency checks on a property graph described at <xref |
||||
linkend="sql-create-property-graph-notes"/> must be maintained by |
||||
<command>ALTER PROPERTY GRAPH</command> operations. In some cases, it |
||||
might be necessary to make multiple alterations in a single command to |
||||
satisfy the checks. |
||||
</para> |
||||
</refsect1> |
||||
|
||||
<refsect1> |
||||
<title>Examples</title> |
||||
|
||||
<para> |
||||
<programlisting> |
||||
ALTER PROPERTY GRAPH g1 ADD VERTEX TABLES (v2); |
||||
|
||||
ALTER PROPERTY GRAPH g1 ALTER VERTEX TABLE v1 DROP LABEL foo; |
||||
|
||||
ALTER PROPERTY GRAPH g1 RENAME TO g2; |
||||
</programlisting></para> |
||||
</refsect1> |
||||
|
||||
<refsect1> |
||||
<title>Compatibility</title> |
||||
|
||||
<para> |
||||
<command>ALTER PROPERTY GRAPH</command> conforms to ISO/IEC 9075-16 |
||||
(SQL/PGQ). |
||||
</para> |
||||
</refsect1> |
||||
|
||||
<refsect1> |
||||
<title>See Also</title> |
||||
|
||||
<simplelist type="inline"> |
||||
<member><xref linkend="sql-create-property-graph"/></member> |
||||
<member><xref linkend="sql-drop-property-graph"/></member> |
||||
</simplelist> |
||||
</refsect1> |
||||
</refentry> |
||||
@ -0,0 +1,318 @@ |
||||
<!-- |
||||
doc/src/sgml/ref/create_property_graph.sgml |
||||
PostgreSQL documentation |
||||
--> |
||||
|
||||
<refentry id="sql-create-property-graph"> |
||||
<indexterm zone="sql-create-property-graph"> |
||||
<primary>CREATE PROPERTY GRAPH</primary> |
||||
</indexterm> |
||||
|
||||
<refmeta> |
||||
<refentrytitle>CREATE PROPERTY GRAPH</refentrytitle> |
||||
<manvolnum>7</manvolnum> |
||||
<refmiscinfo>SQL - Language Statements</refmiscinfo> |
||||
</refmeta> |
||||
|
||||
<refnamediv> |
||||
<refname>CREATE PROPERTY GRAPH</refname> |
||||
<refpurpose>define an SQL-property graph</refpurpose> |
||||
</refnamediv> |
||||
|
||||
<refsynopsisdiv> |
||||
<synopsis> |
||||
CREATE [ TEMP | TEMPORARY ] PROPERTY GRAPH <replaceable class="parameter">name</replaceable> |
||||
[ {VERTEX|NODE} TABLES ( <replaceable class="parameter">vertex_table_definition</replaceable> [, ...] ) ] |
||||
[ {EDGE|RELATIONSHIP} TABLES ( <replaceable class="parameter">edge_table_definition</replaceable> [, ...] ) ] |
||||
|
||||
<phrase>where <replaceable class="parameter">vertex_table_definition</replaceable> is:</phrase> |
||||
|
||||
<replaceable class="parameter">vertex_table_name</replaceable> [ AS <replaceable class="parameter">alias</replaceable> ] [ KEY ( <replaceable class="parameter">column_name</replaceable> [, ...] ) ] [ <replaceable class="parameter">element_table_label_and_properties</replaceable> ] |
||||
|
||||
<phrase>and <replaceable class="parameter">edge_table_definition</replaceable> is:</phrase> |
||||
|
||||
<replaceable class="parameter">edge_table_name</replaceable> [ AS <replaceable class="parameter">alias</replaceable> ] [ KEY ( <replaceable class="parameter">column_name</replaceable> [, ...] ) ] |
||||
SOURCE [ KEY ( <replaceable class="parameter">column_name</replaceable> [, ...] ) REFERENCES ] <replaceable class="parameter">source_table</replaceable> [ ( <replaceable class="parameter">column_name</replaceable> [, ...] ) ] |
||||
DESTINATION [ KEY ( <replaceable class="parameter">column_name</replaceable> [, ...] ) REFERENCES ] <replaceable class="parameter">dest_table</replaceable> [ ( <replaceable class="parameter">column_name</replaceable> [, ...] ) ] |
||||
[ <replaceable class="parameter">element_table_label_and_properties</replaceable> ] |
||||
|
||||
<phrase>and <replaceable class="parameter">element_table_label_and_properties</replaceable> is either:</phrase> |
||||
|
||||
NO PROPERTIES | PROPERTIES ALL COLUMNS | PROPERTIES ( { <replaceable class="parameter">expression</replaceable> [ AS <replaceable class="parameter">property_name</replaceable> ] } [, ...] ) |
||||
|
||||
<phrase>or:</phrase> |
||||
|
||||
{ { LABEL <replaceable class="parameter">label_name</replaceable> | DEFAULT LABEL } [ NO PROPERTIES | PROPERTIES ALL COLUMNS | PROPERTIES ( { <replaceable class="parameter">expression</replaceable> [ AS <replaceable class="parameter">property_name</replaceable> ] } [, ...] ) ] } [...] |
||||
</synopsis> |
||||
</refsynopsisdiv> |
||||
|
||||
<refsect1> |
||||
<title>Description</title> |
||||
|
||||
<para> |
||||
<command>CREATE PROPERTY GRAPH</command> defines a property graph. A |
||||
property graph consists of vertices and edges, together called elements, |
||||
each with associated labels and properties, and can be queried using the |
||||
<literal>GRAPH_TABLE</literal> clause of <xref linkend="sql-select"/> with |
||||
a special path matching syntax. The data in the graph is stored in regular |
||||
tables (or views, foreign tables, etc.). Each vertex or edge corresponds |
||||
to a table. The property graph definition links these tables together into |
||||
a graph structure that can be queried using graph query techniques. |
||||
</para> |
||||
|
||||
<para> |
||||
<command>CREATE PROPERTY GRAPH</command> does not physically materialize a |
||||
graph. It is thus similar to <command>CREATE VIEW</command> in that it |
||||
records a structure that is used only when the defined object is queried. |
||||
</para> |
||||
|
||||
<para> |
||||
If a schema name is given (for example, <literal>CREATE PROPERTY GRAPH |
||||
myschema.mygraph ...</literal>) then the property graph is created in the |
||||
specified schema. Otherwise it is created in the current schema. |
||||
Temporary property graphs exist in a special schema, so a schema name |
||||
cannot be given when creating a temporary property graph. Property graphs |
||||
share a namespace with tables and other relation types, so the name of the |
||||
property graph must be distinct from the name of any other relation (table, |
||||
sequence, index, view, materialized view, or foreign table) in the same |
||||
schema. |
||||
</para> |
||||
</refsect1> |
||||
|
||||
<refsect1> |
||||
<title>Parameters</title> |
||||
|
||||
<variablelist> |
||||
<varlistentry> |
||||
<term><replaceable class="parameter">name</replaceable></term> |
||||
<listitem> |
||||
<para> |
||||
The name (optionally schema-qualified) of the new property graph. |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
|
||||
<varlistentry> |
||||
<term><literal>VERTEX</literal>/<literal>NODE</literal></term> |
||||
<term><literal>EDGE</literal>/<literal>RELATIONSHIP</literal></term> |
||||
<listitem> |
||||
<para> |
||||
These keywords are synonyms, respectively. |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
|
||||
<varlistentry> |
||||
<term><replaceable class="parameter">vertex_table_name</replaceable></term> |
||||
<listitem> |
||||
<para> |
||||
The name of a table that will contain vertices in the new property |
||||
graph. |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
|
||||
<varlistentry> |
||||
<term><replaceable class="parameter">edge_table_name</replaceable></term> |
||||
<listitem> |
||||
<para> |
||||
The name of a table that will contain edges in the new property graph. |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
|
||||
<varlistentry> |
||||
<term><replaceable class="parameter">alias</replaceable></term> |
||||
<listitem> |
||||
<para> |
||||
A unique identifier for the vertex or edge table. This defaults to the |
||||
name of the table. Aliases must be unique in a property graph |
||||
definition (across all vertex table and edge table definitions). |
||||
(Therefore, if a table is used more than once as a vertex or edge table, |
||||
then an explicit alias must be specified for at least one of them to |
||||
distinguish them.) |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
|
||||
<varlistentry> |
||||
<term><literal>KEY ( <replaceable class="parameter">column_name</replaceable> [, ...] )</literal></term> |
||||
<listitem> |
||||
<para> |
||||
A set of columns that uniquely identifies a row in the vertex or edge |
||||
table. Defaults to the primary key. |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
|
||||
<varlistentry> |
||||
<term><replaceable class="parameter">source_table</replaceable></term> |
||||
<term><replaceable class="parameter">dest_table</replaceable></term> |
||||
<listitem> |
||||
<para> |
||||
The vertex tables that the edge table is linked to. These refer to the |
||||
aliases of the source and destination vertex tables respectively. |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
|
||||
<varlistentry> |
||||
<term><literal>KEY ( <replaceable class="parameter">column_name</replaceable> [, ...] ) REFERENCES ... ( <replaceable class="parameter">column_name</replaceable> [, ...] )</literal></term> |
||||
<listitem> |
||||
<para> |
||||
Two sets of columns that connect the edge table and the source or |
||||
destination vertex table, like in a foreign-key relationship. If a |
||||
foreign-key constraint between the two tables exists, it is used by |
||||
default. |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
|
||||
<varlistentry> |
||||
<term><replaceable class="parameter">element_table_label_and_properties</replaceable></term> |
||||
<listitem> |
||||
<para> |
||||
Defines the labels and properties for the element (vertex or edge) |
||||
table. Each element has at least one label. By default, the label is |
||||
the same as the element table alias. This can be specified explicitly |
||||
as <literal>DEFAULT LABEL</literal>. Alternatively, one or more freely |
||||
chosen label names can be specified. (Label names do not have to be |
||||
unique across a property graph. It can be useful to assign the same |
||||
label to different elements.) Each label has a list (possibly empty) of |
||||
properties. By default, all columns of a table are automatically |
||||
exposed as properties. This can be specified explicitly as |
||||
<literal>PROPERTIES ALL COLUMNS</literal>. Alternatively, a list of |
||||
expressions, which can refer to the columns of the underlying table, can |
||||
be specified as properties. If the expressions are not a plain column |
||||
reference, then an explicit property name must also be specified. |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
</variablelist> |
||||
</refsect1> |
||||
|
||||
<refsect1 id="sql-create-property-graph-notes"> |
||||
<title>Notes</title> |
||||
|
||||
<para> |
||||
The following consistency checks must be satisfied by a property graph definition: |
||||
|
||||
<itemizedlist> |
||||
<listitem> |
||||
<para> |
||||
In a property graph, labels with the same name applied to different |
||||
property graph elements must have the same number of properties and |
||||
those properties must have the same names. For example, the following |
||||
would be allowed: |
||||
<programlisting> |
||||
CREATE PROPERTY GRAPH g1 |
||||
VERTEX TABLES ( |
||||
v1 LABEL foo PROPERTIES (x, y), |
||||
v2 LABEL foo PROPERTIES (x, y) |
||||
) ... |
||||
</programlisting> |
||||
but this would not: |
||||
<programlisting> |
||||
CREATE PROPERTY GRAPH g1 |
||||
VERTEX TABLES ( |
||||
v1 LABEL foo PROPERTIES (x, y), |
||||
v2 LABEL foo PROPERTIES (z) |
||||
) ... |
||||
</programlisting></para> |
||||
</listitem> |
||||
|
||||
<listitem> |
||||
<para> |
||||
In a property graph, all properties with the same name must have the |
||||
same data type, independent of which label they are on. For example, |
||||
this would be allowed: |
||||
<programlisting> |
||||
CREATE TABLE v1 (a int, b int); |
||||
CREATE TABLE v2 (a int, b int); |
||||
|
||||
CREATE PROPERTY GRAPH g1 |
||||
VERTEX TABLES ( |
||||
v1 LABEL foo PROPERTIES (a, b), |
||||
v2 LABEL bar PROPERTIES (a, b) |
||||
) ... |
||||
</programlisting> |
||||
but this would not: |
||||
<programlisting> |
||||
CREATE TABLE v1 (a int, b int); |
||||
CREATE TABLE v2 (a int, b varchar); |
||||
|
||||
CREATE PROPERTY GRAPH g1 |
||||
VERTEX TABLES ( |
||||
v1 LABEL foo PROPERTIES (a, b), |
||||
v2 LABEL bar PROPERTIES (a, b) |
||||
) ... |
||||
</programlisting></para> |
||||
</listitem> |
||||
|
||||
<listitem> |
||||
<para> |
||||
For each property graph element, all properties with the same name must |
||||
have the same expression for each label. For example, this would be |
||||
allowed: |
||||
<programlisting> |
||||
CREATE PROPERTY GRAPH g1 |
||||
VERTEX TABLES ( |
||||
v1 LABEL foo PROPERTIES (a * 2 AS x) LABEL bar PROPERTIES (a * 2 AS x) |
||||
) ... |
||||
</programlisting> |
||||
but this would not: |
||||
<programlisting> |
||||
CREATE PROPERTY GRAPH g1 |
||||
VERTEX TABLES ( |
||||
v1 LABEL foo PROPERTIES (a * 2 AS x) LABEL bar PROPERTIES (a * 10 AS x) |
||||
) ... |
||||
</programlisting></para> |
||||
</listitem> |
||||
|
||||
</itemizedlist> |
||||
</para> |
||||
|
||||
<para> |
||||
Property graphs are queried using the <literal>GRAPH_TABLE</literal> clause |
||||
of <xref linkend="sql-select"/>. |
||||
</para> |
||||
|
||||
<para> |
||||
Access to the base relations underlying the <literal>GRAPH_TABLE</literal> |
||||
clause is determined by the permissions of the user executing the query, |
||||
rather than the property graph owner. Thus, the user of a property graph must |
||||
have the relevant permissions on the property graph and base relations |
||||
underlying the <literal>GRAPH_TABLE</literal> clause. |
||||
</para> |
||||
</refsect1> |
||||
|
||||
<refsect1> |
||||
<title>Examples</title> |
||||
|
||||
<para> |
||||
<programlisting> |
||||
CREATE PROPERTY GRAPH g1 |
||||
VERTEX TABLES (v1, v2, v3) |
||||
EDGE TABLES (e1 SOURCE v1 DESTINATION v2, |
||||
e2 SOURCE v1 DESTINATION v3); |
||||
</programlisting></para> |
||||
</refsect1> |
||||
|
||||
<refsect1> |
||||
<title>Compatibility</title> |
||||
|
||||
<para> |
||||
<command>CREATE PROPERTY GRAPH</command> conforms to ISO/IEC 9075-16 |
||||
(SQL/PGQ). |
||||
</para> |
||||
</refsect1> |
||||
|
||||
<refsect1> |
||||
<title>See Also</title> |
||||
|
||||
<simplelist type="inline"> |
||||
<member><xref linkend="sql-alter-property-graph"/></member> |
||||
<member><xref linkend="sql-drop-property-graph"/></member> |
||||
</simplelist> |
||||
</refsect1> |
||||
</refentry> |
||||
@ -0,0 +1,111 @@ |
||||
<!-- |
||||
doc/src/sgml/ref/drop_property_graph.sgml |
||||
PostgreSQL documentation |
||||
--> |
||||
|
||||
<refentry id="sql-drop-property-graph"> |
||||
<indexterm zone="sql-drop-property-graph"> |
||||
<primary>DROP PROPERTY GRAPH</primary> |
||||
</indexterm> |
||||
|
||||
<refmeta> |
||||
<refentrytitle>DROP PROPERTY GRAPH</refentrytitle> |
||||
<manvolnum>7</manvolnum> |
||||
<refmiscinfo>SQL - Language Statements</refmiscinfo> |
||||
</refmeta> |
||||
|
||||
<refnamediv> |
||||
<refname>DROP PROPERTY GRAPH</refname> |
||||
<refpurpose>remove an SQL-property graph</refpurpose> |
||||
</refnamediv> |
||||
|
||||
<refsynopsisdiv> |
||||
<synopsis> |
||||
DROP PROPERTY GRAPH [ IF EXISTS ] <replaceable class="parameter">name</replaceable> [, ...] [ CASCADE | RESTRICT ] |
||||
</synopsis> |
||||
</refsynopsisdiv> |
||||
|
||||
<refsect1> |
||||
<title>Description</title> |
||||
|
||||
<para> |
||||
<command>DROP PROPERTY GRAPH</command> drops an existing property graph. |
||||
To execute this command you must be the owner of the property graph. |
||||
</para> |
||||
</refsect1> |
||||
|
||||
<refsect1> |
||||
<title>Parameters</title> |
||||
|
||||
<variablelist> |
||||
<varlistentry> |
||||
<term><literal>IF EXISTS</literal></term> |
||||
<listitem> |
||||
<para> |
||||
Do not throw an error if the property graph does not exist. A notice is |
||||
issued in this case. |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
|
||||
<varlistentry> |
||||
<term><replaceable class="parameter">name</replaceable></term> |
||||
<listitem> |
||||
<para> |
||||
The name (optionally schema-qualified) of the property graph to remove. |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
|
||||
<varlistentry> |
||||
<term><literal>CASCADE</literal></term> |
||||
<listitem> |
||||
<para> |
||||
Automatically drop objects that depend on the property graph, and in |
||||
turn all objects that depend on those objects (see <xref |
||||
linkend="ddl-depend"/>). |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
|
||||
<varlistentry> |
||||
<term><literal>RESTRICT</literal></term> |
||||
<listitem> |
||||
<para> |
||||
Refuse to drop the property graph if any objects depend on it. This is |
||||
the default. |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
</variablelist> |
||||
</refsect1> |
||||
|
||||
<refsect1> |
||||
<title>Examples</title> |
||||
|
||||
<para> |
||||
<programlisting> |
||||
DROP PROPERTY GRAPH g1; |
||||
</programlisting></para> |
||||
</refsect1> |
||||
|
||||
<refsect1> |
||||
<title>Compatibility</title> |
||||
|
||||
<para> |
||||
<command>DROP PROPERTY GRAPH</command> conforms to ISO/IEC 9075-16 |
||||
(SQL/PGQ), except that the standard only allows one property graph to be |
||||
dropped per command, and apart from the <literal>IF EXISTS</literal> |
||||
option, which is a <productname>PostgreSQL</productname> extension. |
||||
</para> |
||||
</refsect1> |
||||
|
||||
<refsect1> |
||||
<title>See Also</title> |
||||
|
||||
<simplelist type="inline"> |
||||
<member><xref linkend="sql-create-property-graph"/></member> |
||||
<member><xref linkend="sql-alter-property-graph"/></member> |
||||
</simplelist> |
||||
</refsect1> |
||||
</refentry> |
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,309 @@ |
||||
/*-------------------------------------------------------------------------
|
||||
* |
||||
* parse_graphtable.c |
||||
* parsing of GRAPH_TABLE |
||||
* |
||||
* Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group |
||||
* Portions Copyright (c) 1994, Regents of the University of California |
||||
* |
||||
* |
||||
* IDENTIFICATION |
||||
* src/backend/parser/parse_graphtable.c |
||||
* |
||||
*------------------------------------------------------------------------- |
||||
*/ |
||||
|
||||
#include "postgres.h" |
||||
|
||||
#include "access/genam.h" |
||||
#include "access/htup_details.h" |
||||
#include "access/table.h" |
||||
#include "catalog/pg_propgraph_label.h" |
||||
#include "catalog/pg_propgraph_property.h" |
||||
#include "miscadmin.h" |
||||
#include "nodes/makefuncs.h" |
||||
#include "parser/parse_collate.h" |
||||
#include "parser/parse_expr.h" |
||||
#include "parser/parse_graphtable.h" |
||||
#include "parser/parse_node.h" |
||||
#include "utils/fmgroids.h" |
||||
#include "utils/lsyscache.h" |
||||
#include "utils/relcache.h" |
||||
#include "utils/syscache.h" |
||||
|
||||
|
||||
/*
|
||||
* Return human-readable name of the type of graph element pattern in |
||||
* GRAPH_TABLE clause, usually for error message purpose. |
||||
*/ |
||||
static const char * |
||||
get_gep_kind_name(GraphElementPatternKind gepkind) |
||||
{ |
||||
switch (gepkind) |
||||
{ |
||||
case VERTEX_PATTERN: |
||||
return "vertex"; |
||||
case EDGE_PATTERN_LEFT: |
||||
return "edge pointing left"; |
||||
case EDGE_PATTERN_RIGHT: |
||||
return "edge pointing right"; |
||||
case EDGE_PATTERN_ANY: |
||||
return "edge pointing any direction"; |
||||
case PAREN_EXPR: |
||||
return "nested path pattern"; |
||||
} |
||||
|
||||
/*
|
||||
* When a GraphElementPattern is constructed by the parser, it will set a |
||||
* value from the GraphElementPatternKind enum. But we may get here if the |
||||
* GraphElementPatternKind value stored in a catalog is corrupted. |
||||
*/ |
||||
return "unknown"; |
||||
} |
||||
|
||||
/*
|
||||
* Transform a property reference. |
||||
* |
||||
* A property reference is parsed as a ColumnRef of the form: |
||||
* <variable>.<property>. If <variable> is one of the variables bound to an |
||||
* element pattern in the graph pattern and <property> can be resolved as a |
||||
* property of the property graph, then we return a GraphPropertyRef node |
||||
* representing the property reference. If the <variable> exists in the graph |
||||
* pattern but <property> does not exist in the property graph, we raise an |
||||
* error. However, if <variable> does not exist in the graph pattern, we return |
||||
* NULL to let the caller handle it as some other kind of ColumnRef. The |
||||
* variables bound to the element patterns in the graph pattern are expected to |
||||
* be collected in the GraphTableParseState. |
||||
*/ |
||||
Node * |
||||
transformGraphTablePropertyRef(ParseState *pstate, ColumnRef *cref) |
||||
{ |
||||
GraphTableParseState *gpstate = pstate->p_graph_table_pstate; |
||||
|
||||
if (!gpstate) |
||||
return NULL; |
||||
|
||||
if (list_length(cref->fields) == 2) |
||||
{ |
||||
Node *field1 = linitial(cref->fields); |
||||
Node *field2 = lsecond(cref->fields); |
||||
char *elvarname; |
||||
char *propname; |
||||
|
||||
if (IsA(field1, A_Star) || IsA(field2, A_Star)) |
||||
{ |
||||
if (pstate->p_expr_kind == EXPR_KIND_SELECT_TARGET) |
||||
ereport(ERROR, |
||||
errcode(ERRCODE_FEATURE_NOT_SUPPORTED), |
||||
errmsg("\"*\" is not supported here"), |
||||
parser_errposition(pstate, cref->location)); |
||||
else |
||||
ereport(ERROR, |
||||
errcode(ERRCODE_SYNTAX_ERROR), |
||||
errmsg("\"*\" not allowed here"), |
||||
parser_errposition(pstate, cref->location)); |
||||
} |
||||
|
||||
elvarname = strVal(field1); |
||||
propname = strVal(field2); |
||||
|
||||
if (list_member(gpstate->variables, field1)) |
||||
{ |
||||
GraphPropertyRef *gpr = makeNode(GraphPropertyRef); |
||||
HeapTuple pgptup; |
||||
Form_pg_propgraph_property pgpform; |
||||
|
||||
pgptup = SearchSysCache2(PROPGRAPHPROPNAME, ObjectIdGetDatum(gpstate->graphid), CStringGetDatum(propname)); |
||||
if (!HeapTupleIsValid(pgptup)) |
||||
ereport(ERROR, |
||||
errcode(ERRCODE_SYNTAX_ERROR), |
||||
errmsg("property \"%s\" does not exist", propname)); |
||||
pgpform = (Form_pg_propgraph_property) GETSTRUCT(pgptup); |
||||
|
||||
gpr->location = cref->location; |
||||
gpr->elvarname = elvarname; |
||||
gpr->propid = pgpform->oid; |
||||
gpr->typeId = pgpform->pgptypid; |
||||
gpr->typmod = pgpform->pgptypmod; |
||||
gpr->collation = pgpform->pgpcollation; |
||||
|
||||
ReleaseSysCache(pgptup); |
||||
|
||||
return (Node *) gpr; |
||||
} |
||||
} |
||||
|
||||
return NULL; |
||||
} |
||||
|
||||
/*
|
||||
* Transform a label expression. |
||||
* |
||||
* A label expression is parsed as either a ColumnRef with a single field or a |
||||
* label expression like label disjunction. The single field in the ColumnRef is |
||||
* treated as a label name and transformed to a GraphLabelRef node. The label |
||||
* expression is recursively transformed into an expression tree containg |
||||
* GraphLabelRef nodes corresponding to the names of the labels appearing in the |
||||
* expression. If any label name cannot be resolved to a label in the property |
||||
* graph, an error is raised. |
||||
*/ |
||||
static Node * |
||||
transformLabelExpr(GraphTableParseState *gpstate, Node *labelexpr) |
||||
{ |
||||
Node *result; |
||||
|
||||
if (labelexpr == NULL) |
||||
return NULL; |
||||
|
||||
check_stack_depth(); |
||||
|
||||
switch (nodeTag(labelexpr)) |
||||
{ |
||||
case T_ColumnRef: |
||||
{ |
||||
ColumnRef *cref = (ColumnRef *) labelexpr; |
||||
const char *labelname; |
||||
Oid labelid; |
||||
GraphLabelRef *lref; |
||||
|
||||
Assert(list_length(cref->fields) == 1); |
||||
labelname = strVal(linitial(cref->fields)); |
||||
|
||||
labelid = GetSysCacheOid2(PROPGRAPHLABELNAME, Anum_pg_propgraph_label_oid, ObjectIdGetDatum(gpstate->graphid), CStringGetDatum(labelname)); |
||||
if (!labelid) |
||||
ereport(ERROR, |
||||
errcode(ERRCODE_UNDEFINED_OBJECT), |
||||
errmsg("label \"%s\" does not exist in property graph \"%s\"", labelname, get_rel_name(gpstate->graphid))); |
||||
|
||||
lref = makeNode(GraphLabelRef); |
||||
lref->labelid = labelid; |
||||
lref->location = cref->location; |
||||
|
||||
result = (Node *) lref; |
||||
break; |
||||
} |
||||
|
||||
case T_BoolExpr: |
||||
{ |
||||
BoolExpr *be = (BoolExpr *) labelexpr; |
||||
ListCell *lc; |
||||
List *args = NIL; |
||||
|
||||
foreach(lc, be->args) |
||||
{ |
||||
Node *arg = (Node *) lfirst(lc); |
||||
|
||||
arg = transformLabelExpr(gpstate, arg); |
||||
args = lappend(args, arg); |
||||
} |
||||
|
||||
result = (Node *) makeBoolExpr(be->boolop, args, be->location); |
||||
break; |
||||
} |
||||
|
||||
default: |
||||
/* should not reach here */ |
||||
elog(ERROR, "unsupported label expression node: %d", (int) nodeTag(labelexpr)); |
||||
result = NULL; /* keep compiler quiet */ |
||||
break; |
||||
} |
||||
|
||||
return result; |
||||
} |
||||
|
||||
/*
|
||||
* Transform a GraphElementPattern. |
||||
* |
||||
* Transform the label expression and the where clause in the element pattern |
||||
* given by GraphElementPattern. The variable name in the GraphElementPattern is |
||||
* added to the list of variables in the GraphTableParseState which is used to |
||||
* resolve property references in this element pattern or elsewhere in the |
||||
* GRAPH_TABLE. |
||||
*/ |
||||
static Node * |
||||
transformGraphElementPattern(ParseState *pstate, GraphElementPattern *gep) |
||||
{ |
||||
GraphTableParseState *gpstate = pstate->p_graph_table_pstate; |
||||
|
||||
if (gep->kind != VERTEX_PATTERN && !IS_EDGE_PATTERN(gep->kind)) |
||||
ereport(ERROR, |
||||
errcode(ERRCODE_FEATURE_NOT_SUPPORTED), |
||||
errmsg("unsupported element pattern kind: \"%s\"", get_gep_kind_name(gep->kind))); |
||||
|
||||
if (gep->quantifier) |
||||
ereport(ERROR, |
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), |
||||
errmsg("element pattern quantifier is not supported"))); |
||||
|
||||
if (gep->variable) |
||||
gpstate->variables = lappend(gpstate->variables, makeString(pstrdup(gep->variable))); |
||||
|
||||
gep->labelexpr = transformLabelExpr(gpstate, gep->labelexpr); |
||||
|
||||
gep->whereClause = transformExpr(pstate, gep->whereClause, EXPR_KIND_WHERE); |
||||
assign_expr_collations(pstate, gep->whereClause); |
||||
|
||||
return (Node *) gep; |
||||
} |
||||
|
||||
/*
|
||||
* Transform a path term (list of GraphElementPattern's). |
||||
*/ |
||||
static Node * |
||||
transformPathTerm(ParseState *pstate, List *path_term) |
||||
{ |
||||
List *result = NIL; |
||||
|
||||
foreach_node(GraphElementPattern, gep, path_term) |
||||
result = lappend(result, |
||||
transformGraphElementPattern(pstate, gep)); |
||||
|
||||
return (Node *) result; |
||||
} |
||||
|
||||
/*
|
||||
* Transform a path pattern list (list of path terms). |
||||
*/ |
||||
static Node * |
||||
transformPathPatternList(ParseState *pstate, List *path_pattern) |
||||
{ |
||||
List *result = NIL; |
||||
|
||||
/* Grammar doesn't allow empty path pattern list */ |
||||
Assert(list_length(path_pattern) > 0); |
||||
|
||||
/*
|
||||
* We do not support multiple path patterns in one GRAPH_TABLE clause |
||||
* right now. But we may do so in future. |
||||
*/ |
||||
if (list_length(path_pattern) != 1) |
||||
ereport(ERROR, |
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), |
||||
errmsg("multiple path patterns in one GRAPH_TABLE clause not supported"))); |
||||
|
||||
foreach_node(List, path_term, path_pattern) |
||||
result = lappend(result, transformPathTerm(pstate, path_term)); |
||||
|
||||
return (Node *) result; |
||||
} |
||||
|
||||
/*
|
||||
* Transform a GraphPattern. |
||||
* |
||||
* A GraphPattern consists of a list of one or more path patterns and an |
||||
* optional where clause. Transform them. We use the previously constructure |
||||
* list of variables in the GraphTableParseState to resolve property references |
||||
* in the WHERE clause. |
||||
*/ |
||||
Node * |
||||
transformGraphPattern(ParseState *pstate, GraphPattern *graph_pattern) |
||||
{ |
||||
List *path_pattern_list = castNode(List, |
||||
transformPathPatternList(pstate, graph_pattern->path_pattern_list)); |
||||
|
||||
graph_pattern->path_pattern_list = path_pattern_list; |
||||
graph_pattern->whereClause = transformExpr(pstate, graph_pattern->whereClause, EXPR_KIND_WHERE); |
||||
assign_expr_collations(pstate, graph_pattern->whereClause); |
||||
|
||||
return (Node *) graph_pattern; |
||||
} |
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,118 @@ |
||||
/*-------------------------------------------------------------------------
|
||||
* |
||||
* pg_propgraph_element.h |
||||
* definition of the "property graph elements" system catalog (pg_propgraph_element) |
||||
* |
||||
* Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group |
||||
* Portions Copyright (c) 1994, Regents of the University of California |
||||
* |
||||
* src/include/catalog/pg_propgraph_element.h |
||||
* |
||||
* NOTES |
||||
* The Catalog.pm module reads this file and derives schema |
||||
* information. |
||||
* |
||||
*------------------------------------------------------------------------- |
||||
*/ |
||||
#ifndef PG_PROPGRAPH_ELEMENT_H |
||||
#define PG_PROPGRAPH_ELEMENT_H |
||||
|
||||
#include "catalog/genbki.h" |
||||
#include "catalog/pg_propgraph_element_d.h" |
||||
|
||||
/* ----------------
|
||||
* pg_propgraph_element definition. cpp turns this into |
||||
* typedef struct FormData_pg_propgraph_element |
||||
* ---------------- |
||||
*/ |
||||
BEGIN_CATALOG_STRUCT |
||||
|
||||
CATALOG(pg_propgraph_element,8299,PropgraphElementRelationId) |
||||
{ |
||||
Oid oid; |
||||
|
||||
/* OID of the property graph relation */ |
||||
Oid pgepgid BKI_LOOKUP(pg_class); |
||||
|
||||
/* OID of the element table */ |
||||
Oid pgerelid BKI_LOOKUP(pg_class); |
||||
|
||||
/* element alias */ |
||||
NameData pgealias; |
||||
|
||||
/* vertex or edge? -- see PGEKIND_* below */ |
||||
char pgekind; |
||||
|
||||
/* for edges: source vertex */ |
||||
Oid pgesrcvertexid BKI_LOOKUP_OPT(pg_propgraph_element); |
||||
|
||||
/* for edges: destination vertex */ |
||||
Oid pgedestvertexid BKI_LOOKUP_OPT(pg_propgraph_element); |
||||
|
||||
#ifdef CATALOG_VARLEN /* variable-length fields start here */ |
||||
/* element key (column numbers in pgerelid relation) */ |
||||
int16 pgekey[1] BKI_FORCE_NOT_NULL; |
||||
|
||||
/*
|
||||
* for edges: source vertex key (column numbers in pgerelid relation) |
||||
*/ |
||||
int16 pgesrckey[1]; |
||||
|
||||
/*
|
||||
* for edges: source vertex table referenced columns (column numbers in |
||||
* relation reached via pgesrcvertexid) |
||||
*/ |
||||
int16 pgesrcref[1]; |
||||
|
||||
/*
|
||||
* for edges: Oids of the equality operators for comparing source keys |
||||
*/ |
||||
Oid pgesrceqop[1]; |
||||
|
||||
/*
|
||||
* for edges: destination vertex key (column numbers in pgerelid relation) |
||||
*/ |
||||
int16 pgedestkey[1]; |
||||
|
||||
/*
|
||||
* for edges: destination vertex table referenced columns (column numbers |
||||
* in relation reached via pgedestvertexid) |
||||
*/ |
||||
int16 pgedestref[1]; |
||||
|
||||
/*
|
||||
* for edges: Oids of the equality operators for comparing destination |
||||
* keys |
||||
*/ |
||||
Oid pgedesteqop[1]; |
||||
#endif |
||||
} FormData_pg_propgraph_element; |
||||
|
||||
END_CATALOG_STRUCT |
||||
|
||||
/* ----------------
|
||||
* Form_pg_propgraph_element corresponds to a pointer to a tuple with |
||||
* the format of pg_propgraph_element relation. |
||||
* ---------------- |
||||
*/ |
||||
typedef FormData_pg_propgraph_element *Form_pg_propgraph_element; |
||||
|
||||
DECLARE_TOAST(pg_propgraph_element, 8315, 8316); |
||||
|
||||
DECLARE_UNIQUE_INDEX_PKEY(pg_propgraph_element_oid_index, 8300, PropgraphElementObjectIndexId, pg_propgraph_element, btree(oid oid_ops)); |
||||
DECLARE_UNIQUE_INDEX(pg_propgraph_element_alias_index, 8301, PropgraphElementAliasIndexId, pg_propgraph_element, btree(pgepgid oid_ops, pgealias name_ops)); |
||||
|
||||
MAKE_SYSCACHE(PROPGRAPHELOID, pg_propgraph_element_oid_index, 128); |
||||
MAKE_SYSCACHE(PROPGRAPHELALIAS, pg_propgraph_element_alias_index, 128); |
||||
|
||||
#ifdef EXPOSE_TO_CLIENT_CODE |
||||
|
||||
/*
|
||||
* Symbolic values for pgekind column |
||||
*/ |
||||
#define PGEKIND_VERTEX 'v' |
||||
#define PGEKIND_EDGE 'e' |
||||
|
||||
#endif /* EXPOSE_TO_CLIENT_CODE */ |
||||
|
||||
#endif /* PG_PROPGRAPH_ELEMENT_H */ |
||||
@ -0,0 +1,55 @@ |
||||
/*-------------------------------------------------------------------------
|
||||
* |
||||
* pg_propgraph_element_label.h |
||||
* |
||||
* Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group |
||||
* Portions Copyright (c) 1994, Regents of the University of California |
||||
* |
||||
* src/include/catalog/pg_propgraph_element_label.h |
||||
* |
||||
* NOTES |
||||
* The Catalog.pm module reads this file and derives schema |
||||
* information. |
||||
* |
||||
*------------------------------------------------------------------------- |
||||
*/ |
||||
#ifndef PG_PROPGRAPH_ELEMENT_LABEL_H |
||||
#define PG_PROPGRAPH_ELEMENT_LABEL_H |
||||
|
||||
#include "catalog/genbki.h" |
||||
#include "catalog/pg_propgraph_element_label_d.h" |
||||
|
||||
/* ----------------
|
||||
* pg_propgraph_element_label definition. cpp turns this into |
||||
* typedef struct FormData_pg_propgraph_element_label |
||||
* ---------------- |
||||
*/ |
||||
BEGIN_CATALOG_STRUCT |
||||
|
||||
CATALOG(pg_propgraph_element_label,8305,PropgraphElementLabelRelationId) |
||||
{ |
||||
Oid oid; |
||||
|
||||
/* OID of the label */ |
||||
Oid pgellabelid BKI_LOOKUP(pg_propgraph_label); |
||||
|
||||
/* OID of the property graph element */ |
||||
Oid pgelelid BKI_LOOKUP(pg_propgraph_element); |
||||
} FormData_pg_propgraph_element_label; |
||||
|
||||
END_CATALOG_STRUCT |
||||
|
||||
/* ----------------
|
||||
* Form_pg_propgraph_element_label corresponds to a pointer to a tuple with |
||||
* the format of pg_propgraph_element_label relation. |
||||
* ---------------- |
||||
*/ |
||||
typedef FormData_pg_propgraph_element_label *Form_pg_propgraph_element_label; |
||||
|
||||
DECLARE_UNIQUE_INDEX_PKEY(pg_propgraph_element_label_oid_index, 8312, PropgraphElementLabelObjectIndexId, pg_propgraph_element_label, btree(oid oid_ops)); |
||||
DECLARE_UNIQUE_INDEX(pg_propgraph_element_label_element_label_index, 8313, PropgraphElementLabelElementLabelIndexId, pg_propgraph_element_label, btree(pgelelid oid_ops, pgellabelid oid_ops)); |
||||
DECLARE_INDEX(pg_propgraph_element_label_label_index, 8317, PropgraphElementLabelLabelIndexId, pg_propgraph_element_label, btree(pgellabelid oid_ops)); |
||||
|
||||
MAKE_SYSCACHE(PROPGRAPHELEMENTLABELELEMENTLABEL, pg_propgraph_element_label_element_label_index, 128); |
||||
|
||||
#endif /* PG_PROPGRAPH_ELEMENT_LABEL_H */ |
||||
@ -0,0 +1,55 @@ |
||||
/*-------------------------------------------------------------------------
|
||||
* |
||||
* pg_propgraph_label.h |
||||
* |
||||
* Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group |
||||
* Portions Copyright (c) 1994, Regents of the University of California |
||||
* |
||||
* src/include/catalog/pg_propgraph_label.h |
||||
* |
||||
* NOTES |
||||
* The Catalog.pm module reads this file and derives schema |
||||
* information. |
||||
* |
||||
*------------------------------------------------------------------------- |
||||
*/ |
||||
#ifndef PG_PROPGRAPH_LABEL_H |
||||
#define PG_PROPGRAPH_LABEL_H |
||||
|
||||
#include "catalog/genbki.h" |
||||
#include "catalog/pg_propgraph_label_d.h" |
||||
|
||||
/* ----------------
|
||||
* pg_propgraph_label definition. cpp turns this into |
||||
* typedef struct FormData_pg_propgraph_label |
||||
* ---------------- |
||||
*/ |
||||
BEGIN_CATALOG_STRUCT |
||||
|
||||
CATALOG(pg_propgraph_label,8303,PropgraphLabelRelationId) |
||||
{ |
||||
Oid oid; |
||||
|
||||
/* OID of the property graph relation */ |
||||
Oid pglpgid BKI_LOOKUP(pg_class); |
||||
|
||||
/* label name */ |
||||
NameData pgllabel; |
||||
} FormData_pg_propgraph_label; |
||||
|
||||
END_CATALOG_STRUCT |
||||
|
||||
/* ----------------
|
||||
* Form_pg_propgraph_label corresponds to a pointer to a tuple with |
||||
* the format of pg_propgraph_label relation. |
||||
* ---------------- |
||||
*/ |
||||
typedef FormData_pg_propgraph_label *Form_pg_propgraph_label; |
||||
|
||||
DECLARE_UNIQUE_INDEX_PKEY(pg_propgraph_label_oid_index, 8304, PropgraphLabelObjectIndexId, pg_propgraph_label, btree(oid oid_ops)); |
||||
DECLARE_UNIQUE_INDEX(pg_propgraph_label_graph_name_index, 8314, PropgraphLabelGraphNameIndexId, pg_propgraph_label, btree(pglpgid oid_ops, pgllabel name_ops)); |
||||
|
||||
MAKE_SYSCACHE(PROPGRAPHLABELOID, pg_propgraph_label_oid_index, 128); |
||||
MAKE_SYSCACHE(PROPGRAPHLABELNAME, pg_propgraph_label_graph_name_index, 128); |
||||
|
||||
#endif /* PG_PROPGRAPH_LABEL_H */ |
||||
@ -0,0 +1,63 @@ |
||||
/*-------------------------------------------------------------------------
|
||||
* |
||||
* pg_propgraph_label_property.h |
||||
* |
||||
* Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group |
||||
* Portions Copyright (c) 1994, Regents of the University of California |
||||
* |
||||
* src/include/catalog/pg_propgraph_label_property.h |
||||
* |
||||
* NOTES |
||||
* The Catalog.pm module reads this file and derives schema |
||||
* information. |
||||
* |
||||
*------------------------------------------------------------------------- |
||||
*/ |
||||
#ifndef PG_PROPGRAPH_LABEL_PROPERTY_H |
||||
#define PG_PROPGRAPH_LABEL_PROPERTY_H |
||||
|
||||
#include "catalog/genbki.h" |
||||
#include "catalog/pg_propgraph_label_property_d.h" |
||||
|
||||
/* ----------------
|
||||
* pg_propgraph_label_property definition. cpp turns this into |
||||
* typedef struct FormData_pg_propgraph_label_property |
||||
* ---------------- |
||||
*/ |
||||
BEGIN_CATALOG_STRUCT |
||||
|
||||
CATALOG(pg_propgraph_label_property,8318,PropgraphLabelPropertyRelationId) |
||||
{ |
||||
Oid oid; |
||||
|
||||
/* OID of the property */ |
||||
Oid plppropid BKI_LOOKUP(pg_propgraph_property); |
||||
|
||||
/* OID of the element label */ |
||||
Oid plpellabelid BKI_LOOKUP(pg_propgraph_element_label); |
||||
|
||||
#ifdef CATALOG_VARLEN /* variable-length fields start here */ |
||||
|
||||
/* property expression */ |
||||
pg_node_tree plpexpr BKI_FORCE_NOT_NULL; |
||||
|
||||
#endif |
||||
} FormData_pg_propgraph_label_property; |
||||
|
||||
END_CATALOG_STRUCT |
||||
|
||||
/* ----------------
|
||||
* Form_pg_propgraph_label_property corresponds to a pointer to a tuple with |
||||
* the format of pg_propgraph_label_property relation. |
||||
* ---------------- |
||||
*/ |
||||
typedef FormData_pg_propgraph_label_property *Form_pg_propgraph_label_property; |
||||
|
||||
DECLARE_TOAST(pg_propgraph_label_property, 8319, 8320); |
||||
|
||||
DECLARE_UNIQUE_INDEX_PKEY(pg_propgraph_label_property_oid_index, 8328, PropgraphLabelPropertyObjectIndexId, pg_propgraph_label_property, btree(oid oid_ops)); |
||||
DECLARE_UNIQUE_INDEX(pg_propgraph_label_property_label_prop_index, 8329, PropgraphLabelPropertyLabelPropIndexId, pg_propgraph_label_property, btree(plpellabelid oid_ops, plppropid oid_ops)); |
||||
|
||||
MAKE_SYSCACHE(PROPGRAPHLABELPROP, pg_propgraph_label_property_label_prop_index, 128); |
||||
|
||||
#endif /* PG_PROPGRAPH_LABEL_PROPERTY_H */ |
||||
@ -0,0 +1,64 @@ |
||||
/*-------------------------------------------------------------------------
|
||||
* |
||||
* pg_propgraph_property.h |
||||
* |
||||
* Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group |
||||
* Portions Copyright (c) 1994, Regents of the University of California |
||||
* |
||||
* src/include/catalog/pg_propgraph_property.h |
||||
* |
||||
* NOTES |
||||
* The Catalog.pm module reads this file and derives schema |
||||
* information. |
||||
* |
||||
*------------------------------------------------------------------------- |
||||
*/ |
||||
#ifndef PG_PROPGRAPH_PROPERTY_H |
||||
#define PG_PROPGRAPH_PROPERTY_H |
||||
|
||||
#include "catalog/genbki.h" |
||||
#include "catalog/pg_propgraph_property_d.h" |
||||
|
||||
/* ----------------
|
||||
* pg_propgraph_property definition. cpp turns this into |
||||
* typedef struct FormData_pg_propgraph_property |
||||
* ---------------- |
||||
*/ |
||||
BEGIN_CATALOG_STRUCT |
||||
|
||||
CATALOG(pg_propgraph_property,8306,PropgraphPropertyRelationId) |
||||
{ |
||||
Oid oid; |
||||
|
||||
/* OID of the property graph relation */ |
||||
Oid pgppgid BKI_LOOKUP(pg_class); |
||||
|
||||
/* property name */ |
||||
NameData pgpname; |
||||
|
||||
/* data type of the property */ |
||||
Oid pgptypid BKI_LOOKUP_OPT(pg_type); |
||||
|
||||
/* typemod of the property */ |
||||
int32 pgptypmod; |
||||
|
||||
/* collation of the property */ |
||||
Oid pgpcollation BKI_LOOKUP_OPT(pg_collation); |
||||
} FormData_pg_propgraph_property; |
||||
|
||||
END_CATALOG_STRUCT |
||||
|
||||
/* ----------------
|
||||
* Form_pg_propgraph_property corresponds to a pointer to a tuple with |
||||
* the format of pg_propgraph_property relation. |
||||
* ---------------- |
||||
*/ |
||||
typedef FormData_pg_propgraph_property *Form_pg_propgraph_property; |
||||
|
||||
DECLARE_UNIQUE_INDEX_PKEY(pg_propgraph_property_oid_index, 8307, PropgraphPropertyObjectIndexId, pg_propgraph_property, btree(oid oid_ops)); |
||||
DECLARE_UNIQUE_INDEX(pg_propgraph_property_name_index, 8308, PropgraphPropertyNameIndexId, pg_propgraph_property, btree(pgppgid oid_ops, pgpname name_ops)); |
||||
|
||||
MAKE_SYSCACHE(PROPGRAPHPROPOID, pg_propgraph_property_oid_index, 128); |
||||
MAKE_SYSCACHE(PROPGRAPHPROPNAME, pg_propgraph_property_name_index, 128); |
||||
|
||||
#endif /* PG_PROPGRAPH_PROPERTY_H */ |
||||
@ -0,0 +1,23 @@ |
||||
/*-------------------------------------------------------------------------
|
||||
* |
||||
* propgraphcmds.h |
||||
* prototypes for propgraphcmds.c. |
||||
* |
||||
* Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group |
||||
* Portions Copyright (c) 1994, Regents of the University of California |
||||
* |
||||
* src/include/commands/propgraphcmds.h |
||||
* |
||||
*------------------------------------------------------------------------- |
||||
*/ |
||||
|
||||
#ifndef PROPGRAPHCMDS_H |
||||
#define PROPGRAPHCMDS_H |
||||
|
||||
#include "catalog/objectaddress.h" |
||||
#include "parser/parse_node.h" |
||||
|
||||
extern ObjectAddress CreatePropGraph(ParseState *pstate, const CreatePropGraphStmt *stmt); |
||||
extern ObjectAddress AlterPropGraph(ParseState *pstate, const AlterPropGraphStmt *stmt); |
||||
|
||||
#endif /* PROPGRAPHCMDS_H */ |
||||
@ -0,0 +1,24 @@ |
||||
/*-------------------------------------------------------------------------
|
||||
* |
||||
* parse_graphtable.h |
||||
* parsing of GRAPH_TABLE |
||||
* |
||||
* |
||||
* Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group |
||||
* Portions Copyright (c) 1994, Regents of the University of California |
||||
* |
||||
* src/include/parser/parse_graphtable.h |
||||
* |
||||
*------------------------------------------------------------------------- |
||||
*/ |
||||
#ifndef PARSE_GRAPHTABLE_H |
||||
#define PARSE_GRAPHTABLE_H |
||||
|
||||
#include "nodes/pg_list.h" |
||||
#include "parser/parse_node.h" |
||||
|
||||
extern Node *transformGraphTablePropertyRef(ParseState *pstate, ColumnRef *cref); |
||||
|
||||
extern Node *transformGraphPattern(ParseState *pstate, GraphPattern *graph_pattern); |
||||
|
||||
#endif /* PARSE_GRAPHTABLE_H */ |
||||
@ -0,0 +1,21 @@ |
||||
/*-------------------------------------------------------------------------
|
||||
* |
||||
* rewriteGraphTable.h |
||||
* Support for rewriting GRAPH_TABLE clauses. |
||||
* |
||||
* |
||||
* Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group |
||||
* Portions Copyright (c) 1994, Regents of the University of California |
||||
* |
||||
* src/include/rewrite/rewriteGraphTable.h |
||||
* |
||||
*------------------------------------------------------------------------- |
||||
*/ |
||||
#ifndef REWRITEGRAPHTABLE_H |
||||
#define REWRITEGRAPHTABLE_H |
||||
|
||||
#include "nodes/parsenodes.h" |
||||
|
||||
extern Query *rewriteGraphTable(Query *parsetree, int rt_index); |
||||
|
||||
#endif /* REWRITEGRAPHTABLE_H */ |
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue