From 2e08a1a58c72a635ee70808f48d0fb6bd25f8dbf Mon Sep 17 00:00:00 2001 From: himmel Date: Mon, 13 Apr 2026 09:53:19 +0800 Subject: [PATCH 1/2] docs: add Apache AGE documentation --- CN/modules/ROOT/nav.adoc | 3 +- .../master/ecosystem_components/age.adoc | 290 ++++++++++++++++++ .../ecosystem_overview.adoc | 3 +- .../ecosystem_components/pgbouncer.adoc | 5 +- EN/modules/ROOT/nav.adoc | 1 + .../master/ecosystem_components/age.adoc | 290 ++++++++++++++++++ .../ecosystem_overview.adoc | 3 +- .../ecosystem_components/pgbouncer.adoc | 5 +- 8 files changed, 593 insertions(+), 7 deletions(-) create mode 100644 CN/modules/ROOT/pages/master/ecosystem_components/age.adoc create mode 100644 EN/modules/ROOT/pages/master/ecosystem_components/age.adoc diff --git a/CN/modules/ROOT/nav.adoc b/CN/modules/ROOT/nav.adoc index d93018d..b0c064a 100644 --- a/CN/modules/ROOT/nav.adoc +++ b/CN/modules/ROOT/nav.adoc @@ -55,10 +55,11 @@ *** xref:master/ecosystem_components/pg_ai_query.adoc[pg_ai_query] *** xref:master/ecosystem_components/pg_partman.adoc[pg_partman] *** xref:master/ecosystem_components/pgbouncer.adoc[pgbouncer] +*** xref:master/ecosystem_components/age.adoc[AGE] *** xref:master/ecosystem_components/pg_curl.adoc[pg_curl] *** xref:master/ecosystem_components/pg_textsearch.adoc[pg_textsearch] *** xref:master/ecosystem_components/pg_hint_plan.adoc[pg_hint_plan] -*** xref:master/ecosystem_components/redis_fdw.adoc[redis_fdw] +*** xref:master/ecosystem_components/redis_fdw.adoc[redis_fdw] * 监控运维 ** xref:master/getting-started/daily_monitoring.adoc[日常监控] ** xref:master/getting-started/daily_maintenance.adoc[日常维护] diff --git a/CN/modules/ROOT/pages/master/ecosystem_components/age.adoc b/CN/modules/ROOT/pages/master/ecosystem_components/age.adoc new file mode 100644 index 0000000..5885af5 --- /dev/null +++ b/CN/modules/ROOT/pages/master/ecosystem_components/age.adoc @@ -0,0 +1,290 @@ +:sectnums: +:sectnumlevels: 5 + += Apache AGE + +== 概述 + +Apache AGE 是一个 PostgreSQL 扩展,为关系型数据库提供图数据库处理能力。AGE 代表 *Adaptive Graph Engine*(自适应图引擎),它将图数据库的功能引入 PostgreSQL,允许用户在同一数据库中同时使用关系模型和图模型。 + +Apache AGE 是 Apache 软件基金会的顶级项目,完全兼容 openCypher 查询语言(Neo4j 使用的图查询语言)。 + +*核心特性:* + +[cols="1,2"] +|=== +| 特性 | 描述 + +| openCypher 支持 +| 完整支持 openCypher 查询语言,行业标准的图查询语言 + +| 混合数据库 +| 在同一数据库中同时使用关系型和图数据模型 + +| ACID 事务 +| 继承 PostgreSQL 的完整 ACID 事务支持 + +| SQL 集成 +| 可将 Cypher 图查询与 SQL 查询无缝集成 + +| 属性图模型 +| 支持带有属性的顶点和边的属性图模型 + +| 图遍历 +| 高效的图遍历和模式匹配能力 + +| 免费开源 +| Apache 2.0 许可证,完全开源 +|=== + +== 应用场景 + +* 社交网络分析(好友关系、关注关系、影响力分析) +* 知识图谱构建与推理 +* 欺诈检测(金融交易网络分析) +* 推荐系统(基于关系链的推荐) +* 网络与 IT 基础设施管理 +* 路径规划与物流优化 +* 访问控制与权限管理 + +== 安装 + +[TIP] +源码测试安装环境为 Ubuntu 24.04。 + +=== 依赖 + +[literal] +---- +# Ubuntu / Debian +sudo apt install build-essential libreadline-dev zlib1g-dev flex bison libxml2-dev libxslt-dev libssl-dev libxml2-utils xsltproc ccache libssl-dev pkg-config + +# 安装 AGE 依赖 +sudo apt install python3 python3-pip python3-dev +pip3 install antlr4-runtime4 +---- + +=== 从源码安装 + +[literal] +---- +# 下载 Apache AGE 1.7.0 源码包 +wget https://github.com/apache/age/releases/download/PG18%2Fv1.7.0-rc0/apache-age-1.7.0-src.tar.gz + +# 解压 +tar -xzf apache-age-1.7.0-src.tar.gz +cd apache-age-1.7.0-src + +# 编译安装 +make install + +# 或指定 IvorySQL 安装路径 +make install PG_CONFIG=/usr/ivory-5/bin/pg_config +---- + +=== 验证安装 + +[literal] +---- +# 检查 AGE 扩展 +ls /usr/ivory-5/lib/age--*.so +---- + +== 配置 + +=== 修改 IvorySQL 配置 + +编辑 `postgresql.conf` 或 `ivorysql.conf`: + +[literal] +---- +# 预加载 AGE 扩展(推荐) +shared_preload_libraries = 'age' + +# 或者在数据库级别加载(不需要重启) +# shared_preload_libraries = '' +---- + +[literal] +---- +# 重启 IvorySQL 使配置生效 +# 使用 systemd +sudo systemctl restart ivorysql-5 + +# 或手动重启 +pg_ctl restart -D /usr/ivory-5/data +---- + +=== 创建扩展 + +连接到 IvorySQL 并创建 AGE 扩展: + +[literal] +---- +# 连接到数据库 +psql -U postgres -d postgres + +# 创建 AGE 扩展 +CREATE EXTENSION age; + +# 验证安装 +SELECT * FROM pg_extension WHERE extname = 'age'; +---- + +== 使用 + +=== 创建图数据库 + +[literal] +---- +-- 加载 AGE 语言 +LOAD 'age'; + +-- 加载 Cypher 函数 +SET search_path = ag_catalog, "$user", public; + +-- 创建图(graph) +SELECT create_graph('graph_name'); +---- + +=== 创建顶点 + +创建带标签和属性的单个顶点: + +[literal] +---- +SELECT * +FROM cypher('graph_name', $$ + CREATE (:label {property:"Node A"}) +$$) as (v agtype); +---- + +[literal] +---- +SELECT * +FROM cypher('graph_name', $$ + CREATE (:label {property:"Node B"}) +$$) as (v agtype); +---- + +=== 创建边 + +在两个节点之间创建边并设置属性: + +[literal] +---- +SELECT * +FROM cypher('graph_name', $$ + MATCH (a:label), (b:label) + WHERE a.property = 'Node A' AND b.property = 'Node B' + CREATE (a)-[e:RELTYPE {property:a.property + '<->' + b.property}]->(b) + RETURN e +$$) as (e agtype); +---- + +=== 查询图数据 + +查询连接的节点: + +[literal] +---- +SELECT * from cypher('graph_name', $$ + MATCH (V)-[R]-(V2) + RETURN V,R,V2 +$$) as (V agtype, R agtype, V2 agtype); +---- + +=== 基本查询示例 + +[literal] +---- +-- 查询所有节点 +SELECT * FROM cypher('graph_name', $$ + MATCH (V) + RETURN V +$$) as (V agtype); + +-- 查询特定标签的节点 +SELECT * FROM cypher('graph_name', $$ + MATCH (V:label) + RETURN V +$$) as (V agtype); + +-- 查询特定属性的节点 +SELECT * FROM cypher('graph_name', $$ + MATCH (V:label {property: "Node A"}) + RETURN V +$$) as (V agtype); + +-- 查询所有边 +SELECT * FROM cypher('graph_name', $$ + MATCH ()-[R]->() + RETURN R +$$) as (R agtype); + +-- 查询特定类型的边 +SELECT * FROM cypher('graph_name', $$ + MATCH ()-[R:RELTYPE]->() + RETURN R +$$) as (R agtype); +---- + +=== 更新和删除 + +[literal] +---- +-- 更新节点属性 +SELECT * FROM cypher('graph_name', $$ + MATCH (V:label {property: "Node A"}) + SET V.property = "Updated Node A" + RETURN V +$$) as (V agtype); + +-- 删除边 +SELECT * FROM cypher('graph_name', $$ + MATCH (a:label {property: "Node A"})-[r:RELTYPE]->(b:label {property: "Node B"}) + DELETE r +$$) as (r agtype); + +-- 删除节点(必须先删除相关的边) +SELECT * FROM cypher('graph_name', $$ + MATCH (V:label {property: "Node B"}) + DETACH DELETE V +$$) as (V agtype); +---- + +=== 与 SQL 结合使用 + +[literal] +---- +-- 将图查询结果用于关系表查询 +SELECT * FROM cypher('graph_name', $$ + MATCH (V:label) + RETURN V.property AS name +$$) as (name text) +WHERE name IS NOT NULL; + +-- 统计节点数量 +SELECT count(*) FROM cypher('graph_name', $$ + MATCH (V) + RETURN V +$$) as (V agtype); +---- + +== 管理命令 + +[literal] +---- +-- 列出所有图 +SELECT * FROM ag_graph; + +-- 删除图(删除所有相关顶点和边) +SELECT drop_graph('graph_name', true); + +-- 查看图统计信息 +SELECT + graph_name, + (SELECT count(*) FROM ag_vertex WHERE graph_id = ag_graph.graph_id) AS vertex_count, + (SELECT count(*) FROM ag_edge WHERE graph_id = ag_graph.graph_id) AS edge_count +FROM ag_graph; +---- diff --git a/CN/modules/ROOT/pages/master/ecosystem_components/ecosystem_overview.adoc b/CN/modules/ROOT/pages/master/ecosystem_components/ecosystem_overview.adoc index ecf722e..2d63964 100644 --- a/CN/modules/ROOT/pages/master/ecosystem_components/ecosystem_overview.adoc +++ b/CN/modules/ROOT/pages/master/ecosystem_components/ecosystem_overview.adoc @@ -25,11 +25,12 @@ IvorySQL 作为一款兼容 Oracle 且基于 PostgreSQL 的高级开源数据库 | 12 | xref:master/ecosystem_components/pg_stat_monitor.adoc[pg_stat_monitor] | 2.3.1 | 收集性能统计数据,并通过统一视图和直方图形式直观展示查询性能指标。 | 性能监控 | 13 | xref:master/ecosystem_components/pg_ai_query.adoc[pg_ai_query] | 0.1.1 | AI驱动的自然语言转SQL扩展,支持多种大语言模型 | AI辅助查询、自然语言数据库交互 | 14 | xref:master/ecosystem_components/pg_partman.adoc[pg_partman] | 5.2 | 辅助管理原生分区表,自动创建、维护、清理分区子表 | 海量数据存储管理 -| 15 | xref:master/ecosystem_components/pgbouncer.adoc[pgbouncer] | x.x | | +| 15 | xref:master/ecosystem_components/pgbouncer.adoc[pgbouncer] | 1.25.1 | PostgreSQL 轻量级连接池,提供连接复用和高效连接管理 | 高并发连接管理、连接复用、减少数据库连接开销 | 16 | xref:master/ecosystem_components/pg_curl.adoc[pg_curl] | 2.4 | 基于 libcurl 的网络传输扩展,支持 HTTP/HTTPS、FTP、SMTP、IMAP 等二十余种协议,可在 SQL 中完成各类网络数据传输操作 | REST API 集成、邮件发送、文件传输、外部系统通知 | 17 | xref:master/ecosystem_components/pg_textsearch.adoc[pg_textsearch] | 0.6.1 | 提供全文检索能力,支持文本分词、索引构建与高效全文查询 | 文档检索与内容搜索 | 18 | xref:master/ecosystem_components/pg_hint_plan.adoc[pg_hint_plan] | PG18 | 通过SQL注释中的hints控制执行计划,在不修改SQL逻辑的情况下优化查询性能 | 查询性能优化、执行计划调优、数据库性能分析 | 19 | xref:master/ecosystem_components/redis_fdw.adoc[redis_fdw] | PG18 | 将 Redis 数据映射为 PostgreSQL 外部表,支持通过标准 SELECT/INSERT/UPDATE/DELETE 语句读写 Redis | 统一 SQL 查询、轻量级数据同步、透明化缓存读写及跨库数据分析 +| 20 | xref:master/ecosystem_components/age.adoc[Apache AGE] | 1.7.0 | 为 IvorySQL 提供图数据库处理能力,支持 openCypher 查询语言,实现关系型与图数据库的混合使用 | 社交网络分析、知识图谱、欺诈检测、推荐系统、路径规划 |==== 这些插件均经过 IvorySQL 团队的测试和适配,确保在 IvorySQL 环境下稳定运行。用户可以根据业务需求选择合适的插件,进一步提升数据库系统的能力和灵活性。 diff --git a/CN/modules/ROOT/pages/master/ecosystem_components/pgbouncer.adoc b/CN/modules/ROOT/pages/master/ecosystem_components/pgbouncer.adoc index 64dae0b..0973b42 100644 --- a/CN/modules/ROOT/pages/master/ecosystem_components/pgbouncer.adoc +++ b/CN/modules/ROOT/pages/master/ecosystem_components/pgbouncer.adoc @@ -48,8 +48,9 @@ sudo dnf install libevent-devel openssl-devel pkgconfig [literal] ---- -git clone https://github.com/pgbouncer/pgbouncer.git -cd pgbouncer +wget https://github.com/pgbouncer/pgbouncer/archive/refs/tags/pgbouncer_1_25_1.zip +unzip pgbouncer_1_25_1.zip +cd pgbouncer_1_25_1 ./autogen.sh diff --git a/EN/modules/ROOT/nav.adoc b/EN/modules/ROOT/nav.adoc index 3281b1f..0a1b752 100644 --- a/EN/modules/ROOT/nav.adoc +++ b/EN/modules/ROOT/nav.adoc @@ -55,6 +55,7 @@ *** xref:master/ecosystem_components/pg_stat_monitor.adoc[pg_stat_monitor] *** xref:master/ecosystem_components/pg_partman.adoc[pg_partman] *** xref:master/ecosystem_components/pgbouncer.adoc[pgbouncer] +*** xref:master/ecosystem_components/age.adoc[AGE] *** xref:master/ecosystem_components/pg_curl.adoc[pg_curl] *** xref:master/ecosystem_components/pg_textsearch.adoc[pg_textsearch] *** xref:master/ecosystem_components/pg_hint_plan.adoc[pg_hint_plan] diff --git a/EN/modules/ROOT/pages/master/ecosystem_components/age.adoc b/EN/modules/ROOT/pages/master/ecosystem_components/age.adoc new file mode 100644 index 0000000..275d607 --- /dev/null +++ b/EN/modules/ROOT/pages/master/ecosystem_components/age.adoc @@ -0,0 +1,290 @@ +:sectnums: +:sectnumlevels: 5 + += Apache AGE + +== Overview + +Apache AGE is a PostgreSQL extension that provides graph database capabilities to relational databases. AGE stands for *Adaptive Graph Engine*, which brings graph database functionality to PostgreSQL, allowing users to use both relational and graph models in the same database. + +Apache AGE is a top-level project of the Apache Software Foundation and fully supports the openCypher query language (the graph query language used by Neo4j). + +*Core Features:* + +[cols="1,2"] +|=== +| Feature | Description + +| openCypher Support +| Full support for openCypher query language, the industry standard for graph queries + +| Hybrid Database +| Use both relational and graph data models in the same database + +| ACID Transactions +| Full ACID transaction support inherited from PostgreSQL + +| SQL Integration +| Seamless integration of Cypher graph queries with SQL queries + +| Property Graph Model +| Support for property graphs with vertices and edges with attributes + +| Graph Traversal +| Efficient graph traversal and pattern matching capabilities + +| Free and Open Source +| Apache 2.0 License, fully open source +|=== + +== Use Cases + +* Social network analysis (friend relationships, follower relationships, influence analysis) +* Knowledge graph construction and reasoning +* Fraud detection (financial transaction network analysis) +* Recommendation systems (relationship chain-based recommendations) +* Network and IT infrastructure management +* Route planning and logistics optimization +* Access control and permission management + +== Installation + +[TIP] +Source installation was tested on Ubuntu 24.04. + +=== Dependencies + +[literal] +---- +# Ubuntu / Debian +sudo apt install build-essential libreadline-dev zlib1g-dev flex bison libxml2-dev libxslt-dev libssl-dev libxml2-utils xsltproc ccache libssl-dev pkg-config + +# Install AGE dependencies +sudo apt install python3 python3-pip python3-dev +pip3 install antlr4-runtime4 +---- + +=== Install from Source + +[literal] +---- +# Download Apache AGE 1.7.0 source package +wget https://github.com/apache/age/releases/download/PG18%2Fv1.7.0-rc0/apache-age-1.7.0-src.tar.gz + +# Extract +tar -xzf apache-age-1.7.0-src.tar.gz +cd apache-age-1.7.0-src + +# Compile and install +make install + +# Or specify IvorySQL installation path +make install PG_CONFIG=/usr/ivory-5/bin/pg_config +---- + +=== Verify Installation + +[literal] +---- +# Check AGE extension +ls /usr/ivory-5/lib/age--*.so +---- + +== Configuration + +=== Modify IvorySQL Configuration + +Edit `postgresql.conf` or `ivorysql.conf`: + +[literal] +---- +# Preload AGE extension (recommended) +shared_preload_libraries = 'age' + +# Or load at database level (no restart required) +# shared_preload_libraries = '' +---- + +[literal] +---- +# Restart IvorySQL for configuration to take effect +# Using systemd +sudo systemctl restart ivorysql-5 + +# Or manually restart +pg_ctl restart -D /usr/ivory-5/data +---- + +=== Create Extension + +Connect to IvorySQL and create the AGE extension: + +[literal] +---- +# Connect to database +psql -U postgres -d postgres + +# Create AGE extension +CREATE EXTENSION age; + +# Verify installation +SELECT * FROM pg_extension WHERE extname = 'age'; +---- + +== Usage + +=== Create a Graph Database + +[literal] +---- +-- Load AGE language +LOAD 'age'; + +-- Load Cypher functions +SET search_path = ag_catalog, "$user", public; + +-- Create a graph +SELECT create_graph('graph_name'); +---- + +=== Create Vertices + +To create a single vertex with label and properties: + +[literal] +---- +SELECT * +FROM cypher('graph_name', $$ + CREATE (:label {property:"Node A"}) +$$) as (v agtype); +---- + +[literal] +---- +SELECT * +FROM cypher('graph_name', $$ + CREATE (:label {property:"Node B"}) +$$) as (v agtype); +---- + +=== Create Edges + +To create an edge between two nodes and set its properties: + +[literal] +---- +SELECT * +FROM cypher('graph_name', $$ + MATCH (a:label), (b:label) + WHERE a.property = 'Node A' AND b.property = 'Node B' + CREATE (a)-[e:RELTYPE {property:a.property + '<->' + b.property}]->(b) + RETURN e +$$) as (e agtype); +---- + +=== Query Graph Data + +And to query the connected nodes: + +[literal] +---- +SELECT * from cypher('graph_name', $$ + MATCH (V)-[R]-(V2) + RETURN V,R,V2 +$$) as (V agtype, R agtype, V2 agtype); +---- + +=== Basic Query Examples + +[literal] +---- +-- Query all vertices +SELECT * FROM cypher('graph_name', $$ + MATCH (V) + RETURN V +$$) as (V agtype); + +-- Query vertices with specific label +SELECT * FROM cypher('graph_name', $$ + MATCH (V:label) + RETURN V +$$) as (V agtype); + +-- Query vertices with specific property +SELECT * FROM cypher('graph_name', $$ + MATCH (V:label {property: "Node A"}) + RETURN V +$$) as (V agtype); + +-- Query all edges +SELECT * FROM cypher('graph_name', $$ + MATCH ()-[R]->() + RETURN R +$$) as (R agtype); + +-- Query edges by type +SELECT * FROM cypher('graph_name', $$ + MATCH ()-[R:RELTYPE]->() + RETURN R +$$) as (R agtype); +---- + +=== Update and Delete + +[literal] +---- +-- Update vertex properties +SELECT * FROM cypher('graph_name', $$ + MATCH (V:label {property: "Node A"}) + SET V.property = "Updated Node A" + RETURN V +$$) as (V agtype); + +-- Delete edge +SELECT * FROM cypher('graph_name', $$ + MATCH (a:label {property: "Node A"})-[r:RELTYPE]->(b:label {property: "Node B"}) + DELETE r +$$) as (r agtype); + +-- Delete vertex (must delete related edges first) +SELECT * FROM cypher('graph_name', $$ + MATCH (V:label {property: "Node B"}) + DETACH DELETE V +$$) as (V agtype); +---- + +=== Combining with SQL + +[literal] +---- +-- Use graph query results in relational queries +SELECT * FROM cypher('graph_name', $$ + MATCH (V:label) + RETURN V.property AS name +$$) as (name text) +WHERE name IS NOT NULL; + +-- Count vertices +SELECT count(*) FROM cypher('graph_name', $$ + MATCH (V) + RETURN V +$$) as (V agtype); +---- + +== Management Commands + +[literal] +---- +-- List all graphs +SELECT * FROM ag_graph; + +-- Delete graph (deletes all related vertices and edges) +SELECT drop_graph('graph_name', true); + +-- View graph statistics +SELECT + graph_name, + (SELECT count(*) FROM ag_vertex WHERE graph_id = ag_graph.graph_id) AS vertex_count, + (SELECT count(*) FROM ag_edge WHERE graph_id = ag_graph.graph_id) AS edge_count +FROM ag_graph; +---- diff --git a/EN/modules/ROOT/pages/master/ecosystem_components/ecosystem_overview.adoc b/EN/modules/ROOT/pages/master/ecosystem_components/ecosystem_overview.adoc index a1c3d7c..3b22770 100644 --- a/EN/modules/ROOT/pages/master/ecosystem_components/ecosystem_overview.adoc +++ b/EN/modules/ROOT/pages/master/ecosystem_components/ecosystem_overview.adoc @@ -26,11 +26,12 @@ IvorySQL, as an advanced open-source database compatible with Oracle and based o |*12*| xref:master/ecosystem_components/pg_stat_monitor.adoc[pg_stat_monitor] | 2.3.1 | Collects performance statistics and provides query performance insights in a single view and graphically in histogram. | Performance monitoring |*13*| xref:master/ecosystem_components/pg_ai_query.adoc[pg_ai_query] | 0.1.1 | AI-driven natural language to SQL extension supporting multiple LLMs | AI-assisted querying, natural language database interaction |*14*| xref:master/ecosystem_components/pg_partman.adoc[pg_partman] | 5.2 | Automates the creation, maintenance, and cleanup of native partition subtables. | Large-Scale Data Storage Management -|*15*| xref:master/ecosystem_components/pgbouncer.adoc[pgbouncer] | x.x | | +|*15*| xref:master/ecosystem_components/pgbouncer.adoc[pgbouncer] | 1.25.1 | Lightweight connection pooler for PostgreSQL | High-concurrency connection management, connection reuse, reduced database connection overhead |*16*| xref:master/ecosystem_components/pg_curl.adoc[pg_curl] | 2.4 | A libcurl-based network transfer extension supporting HTTP/HTTPS, FTP, SMTP, IMAP, and 20+ other protocols, enabling network data transfer operations directly in SQL | REST API integration, email sending, file transfer, external system notifications |*17*| xref:master/ecosystem_components/pg_textsearch.adoc[pg_textsearch] | 0.6.1 | enhances PostgreSQL with full-text search capabilities, enabling fast text indexing, tokenization, and efficient full-text querying | document and content retrieval |*18*| xref:master/ecosystem_components/pg_hint_plan.adoc[pg_hint_plan] | PG18 | Controls execution plans via SQL comment hints, optimizing query performance without modifying SQL logic | Query performance optimization, execution plan tuning, database performance analysis |*19*| xref:master/ecosystem_components/redis_fdw.adoc[redis_fdw] | PG18 | connects PostgreSQL with Redis, supporting standard SQL operations including SELECT, INSERT, UPDATE, and DELETE | unified SQL querying, lightweight data synchronization, transparent cache access, and cross-database data analysis +|*20*| xref:master/ecosystem_components/age.adoc[Apache AGE] | 1.7.0 | Provides graph database capabilities to IvorySQL, supports openCypher query language, enabling hybrid use of relational and graph databases | Social network analysis, knowledge graphs, fraud detection, recommendation systems, route planning |==== These plugins have all been tested and adapted by the IvorySQL team to ensure stable operation in the IvorySQL environment. Users can select appropriate plugins based on business needs to further enhance the capabilities and flexibility of the database system. diff --git a/EN/modules/ROOT/pages/master/ecosystem_components/pgbouncer.adoc b/EN/modules/ROOT/pages/master/ecosystem_components/pgbouncer.adoc index 15a58dd..4a923bc 100644 --- a/EN/modules/ROOT/pages/master/ecosystem_components/pgbouncer.adoc +++ b/EN/modules/ROOT/pages/master/ecosystem_components/pgbouncer.adoc @@ -48,8 +48,9 @@ sudo dnf install libevent-devel openssl-devel pkgconfig [literal] ---- -git clone https://github.com/pgbouncer/pgbouncer.git -cd pgbouncer +wget https://github.com/pgbouncer/pgbouncer/archive/refs/tags/pgbouncer_1_25_1.zip +unzip pgbouncer_1_25_1.zip +cd pgbouncer_1_25_1 ./autogen.sh From d81f7e49d1da9753365940536a2a6b4477a6a70f Mon Sep 17 00:00:00 2001 From: himmel Date: Mon, 13 Apr 2026 10:09:43 +0800 Subject: [PATCH 2/2] fix: standardize casing for AGE references in navigation and documentation --- CN/modules/ROOT/nav.adoc | 2 +- .../master/ecosystem_components/age.adoc | 111 +-------------- EN/modules/ROOT/nav.adoc | 2 +- .../master/ecosystem_components/age.adoc | 132 +----------------- 4 files changed, 14 insertions(+), 233 deletions(-) diff --git a/CN/modules/ROOT/nav.adoc b/CN/modules/ROOT/nav.adoc index b0c064a..73f872e 100644 --- a/CN/modules/ROOT/nav.adoc +++ b/CN/modules/ROOT/nav.adoc @@ -55,7 +55,7 @@ *** xref:master/ecosystem_components/pg_ai_query.adoc[pg_ai_query] *** xref:master/ecosystem_components/pg_partman.adoc[pg_partman] *** xref:master/ecosystem_components/pgbouncer.adoc[pgbouncer] -*** xref:master/ecosystem_components/age.adoc[AGE] +*** xref:master/ecosystem_components/age.adoc[age] *** xref:master/ecosystem_components/pg_curl.adoc[pg_curl] *** xref:master/ecosystem_components/pg_textsearch.adoc[pg_textsearch] *** xref:master/ecosystem_components/pg_hint_plan.adoc[pg_hint_plan] diff --git a/CN/modules/ROOT/pages/master/ecosystem_components/age.adoc b/CN/modules/ROOT/pages/master/ecosystem_components/age.adoc index 5885af5..e9c34e6 100644 --- a/CN/modules/ROOT/pages/master/ecosystem_components/age.adoc +++ b/CN/modules/ROOT/pages/master/ecosystem_components/age.adoc @@ -133,46 +133,26 @@ SELECT * FROM pg_extension WHERE extname = 'age'; == 使用 -=== 创建图数据库 - [literal] ---- --- 加载 AGE 语言 -LOAD 'age'; - --- 加载 Cypher 函数 -SET search_path = ag_catalog, "$user", public; +要创建图,使用位于 ag_catalog 命名空间中的 create_graph 函数。 --- 创建图(graph) SELECT create_graph('graph_name'); ----- - -=== 创建顶点 -创建带标签和属性的单个顶点: +要创建带有标签和属性的单个顶点,使用 CREATE 子句。 -[literal] ----- SELECT * FROM cypher('graph_name', $$ CREATE (:label {property:"Node A"}) $$) as (v agtype); ----- -[literal] ----- SELECT * FROM cypher('graph_name', $$ CREATE (:label {property:"Node B"}) $$) as (v agtype); ----- -=== 创建边 +要在两个节点之间创建边并设置其属性: -在两个节点之间创建边并设置属性: - -[literal] ----- SELECT * FROM cypher('graph_name', $$ MATCH (a:label), (b:label) @@ -180,95 +160,14 @@ FROM cypher('graph_name', $$ CREATE (a)-[e:RELTYPE {property:a.property + '<->' + b.property}]->(b) RETURN e $$) as (e agtype); ----- - -=== 查询图数据 查询连接的节点: -[literal] ----- SELECT * from cypher('graph_name', $$ - MATCH (V)-[R]-(V2) - RETURN V,R,V2 + MATCH (V)-[R]-(V2) + RETURN V,R,V2 $$) as (V agtype, R agtype, V2 agtype); ----- - -=== 基本查询示例 - -[literal] ----- --- 查询所有节点 -SELECT * FROM cypher('graph_name', $$ - MATCH (V) - RETURN V -$$) as (V agtype); - --- 查询特定标签的节点 -SELECT * FROM cypher('graph_name', $$ - MATCH (V:label) - RETURN V -$$) as (V agtype); - --- 查询特定属性的节点 -SELECT * FROM cypher('graph_name', $$ - MATCH (V:label {property: "Node A"}) - RETURN V -$$) as (V agtype); - --- 查询所有边 -SELECT * FROM cypher('graph_name', $$ - MATCH ()-[R]->() - RETURN R -$$) as (R agtype); - --- 查询特定类型的边 -SELECT * FROM cypher('graph_name', $$ - MATCH ()-[R:RELTYPE]->() - RETURN R -$$) as (R agtype); ----- - -=== 更新和删除 -[literal] ----- --- 更新节点属性 -SELECT * FROM cypher('graph_name', $$ - MATCH (V:label {property: "Node A"}) - SET V.property = "Updated Node A" - RETURN V -$$) as (V agtype); - --- 删除边 -SELECT * FROM cypher('graph_name', $$ - MATCH (a:label {property: "Node A"})-[r:RELTYPE]->(b:label {property: "Node B"}) - DELETE r -$$) as (r agtype); - --- 删除节点(必须先删除相关的边) -SELECT * FROM cypher('graph_name', $$ - MATCH (V:label {property: "Node B"}) - DETACH DELETE V -$$) as (V agtype); ----- - -=== 与 SQL 结合使用 - -[literal] ----- --- 将图查询结果用于关系表查询 -SELECT * FROM cypher('graph_name', $$ - MATCH (V:label) - RETURN V.property AS name -$$) as (name text) -WHERE name IS NOT NULL; - --- 统计节点数量 -SELECT count(*) FROM cypher('graph_name', $$ - MATCH (V) - RETURN V -$$) as (V agtype); ---- == 管理命令 diff --git a/EN/modules/ROOT/nav.adoc b/EN/modules/ROOT/nav.adoc index 0a1b752..6444f5f 100644 --- a/EN/modules/ROOT/nav.adoc +++ b/EN/modules/ROOT/nav.adoc @@ -55,7 +55,7 @@ *** xref:master/ecosystem_components/pg_stat_monitor.adoc[pg_stat_monitor] *** xref:master/ecosystem_components/pg_partman.adoc[pg_partman] *** xref:master/ecosystem_components/pgbouncer.adoc[pgbouncer] -*** xref:master/ecosystem_components/age.adoc[AGE] +*** xref:master/ecosystem_components/age.adoc[age] *** xref:master/ecosystem_components/pg_curl.adoc[pg_curl] *** xref:master/ecosystem_components/pg_textsearch.adoc[pg_textsearch] *** xref:master/ecosystem_components/pg_hint_plan.adoc[pg_hint_plan] diff --git a/EN/modules/ROOT/pages/master/ecosystem_components/age.adoc b/EN/modules/ROOT/pages/master/ecosystem_components/age.adoc index 275d607..3897317 100644 --- a/EN/modules/ROOT/pages/master/ecosystem_components/age.adoc +++ b/EN/modules/ROOT/pages/master/ecosystem_components/age.adoc @@ -133,158 +133,40 @@ SELECT * FROM pg_extension WHERE extname = 'age'; == Usage -=== Create a Graph Database - [literal] ---- --- Load AGE language -LOAD 'age'; - --- Load Cypher functions -SET search_path = ag_catalog, "$user", public; +To create a graph, use the create_graph function located in the ag_catalog namespace. --- Create a graph SELECT create_graph('graph_name'); ----- -=== Create Vertices +To create a single vertex with label and properties, use the CREATE clause. -To create a single vertex with label and properties: - -[literal] ----- -SELECT * +SELECT * FROM cypher('graph_name', $$ CREATE (:label {property:"Node A"}) $$) as (v agtype); ----- -[literal] ----- -SELECT * +SELECT * FROM cypher('graph_name', $$ CREATE (:label {property:"Node B"}) $$) as (v agtype); ----- - -=== Create Edges To create an edge between two nodes and set its properties: -[literal] ----- -SELECT * +SELECT * FROM cypher('graph_name', $$ MATCH (a:label), (b:label) WHERE a.property = 'Node A' AND b.property = 'Node B' CREATE (a)-[e:RELTYPE {property:a.property + '<->' + b.property}]->(b) RETURN e $$) as (e agtype); ----- - -=== Query Graph Data And to query the connected nodes: -[literal] ----- SELECT * from cypher('graph_name', $$ - MATCH (V)-[R]-(V2) - RETURN V,R,V2 + MATCH (V)-[R]-(V2) + RETURN V,R,V2 $$) as (V agtype, R agtype, V2 agtype); ----- -=== Basic Query Examples - -[literal] ----- --- Query all vertices -SELECT * FROM cypher('graph_name', $$ - MATCH (V) - RETURN V -$$) as (V agtype); - --- Query vertices with specific label -SELECT * FROM cypher('graph_name', $$ - MATCH (V:label) - RETURN V -$$) as (V agtype); - --- Query vertices with specific property -SELECT * FROM cypher('graph_name', $$ - MATCH (V:label {property: "Node A"}) - RETURN V -$$) as (V agtype); - --- Query all edges -SELECT * FROM cypher('graph_name', $$ - MATCH ()-[R]->() - RETURN R -$$) as (R agtype); - --- Query edges by type -SELECT * FROM cypher('graph_name', $$ - MATCH ()-[R:RELTYPE]->() - RETURN R -$$) as (R agtype); ---- -=== Update and Delete - -[literal] ----- --- Update vertex properties -SELECT * FROM cypher('graph_name', $$ - MATCH (V:label {property: "Node A"}) - SET V.property = "Updated Node A" - RETURN V -$$) as (V agtype); - --- Delete edge -SELECT * FROM cypher('graph_name', $$ - MATCH (a:label {property: "Node A"})-[r:RELTYPE]->(b:label {property: "Node B"}) - DELETE r -$$) as (r agtype); - --- Delete vertex (must delete related edges first) -SELECT * FROM cypher('graph_name', $$ - MATCH (V:label {property: "Node B"}) - DETACH DELETE V -$$) as (V agtype); ----- - -=== Combining with SQL - -[literal] ----- --- Use graph query results in relational queries -SELECT * FROM cypher('graph_name', $$ - MATCH (V:label) - RETURN V.property AS name -$$) as (name text) -WHERE name IS NOT NULL; - --- Count vertices -SELECT count(*) FROM cypher('graph_name', $$ - MATCH (V) - RETURN V -$$) as (V agtype); ----- - -== Management Commands - -[literal] ----- --- List all graphs -SELECT * FROM ag_graph; - --- Delete graph (deletes all related vertices and edges) -SELECT drop_graph('graph_name', true); - --- View graph statistics -SELECT - graph_name, - (SELECT count(*) FROM ag_vertex WHERE graph_id = ag_graph.graph_id) AS vertex_count, - (SELECT count(*) FROM ag_edge WHERE graph_id = ag_graph.graph_id) AS edge_count -FROM ag_graph; -----