You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudberry.apache.org by ch...@apache.org on 2025/10/16 01:52:47 UTC

(cloudberry) branch cbdb-postgres-merge updated: Load plpgsql on initdb

This is an automated email from the ASF dual-hosted git repository.

chenjinbao1989 pushed a commit to branch cbdb-postgres-merge
in repository https://gitbox.apache.org/repos/asf/cloudberry.git


The following commit(s) were added to refs/heads/cbdb-postgres-merge by this push:
     new f089097b3fa Load plpgsql on initdb
f089097b3fa is described below

commit f089097b3fa24dfc6e7b7cd7ca3d0e274501b89b
Author: Jinbao Chen <ch...@gmail.com>
AuthorDate: Thu Oct 16 09:52:32 2025 +0800

    Load plpgsql on initdb
---
 src/backend/catalog/cdb_schema.sql | 44 +++++++++++++++++++-------------------
 src/bin/initdb/initdb.c            | 14 ++++++------
 2 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/src/backend/catalog/cdb_schema.sql b/src/backend/catalog/cdb_schema.sql
index 505ae2166f1..180895513e8 100644
--- a/src/backend/catalog/cdb_schema.sql
+++ b/src/backend/catalog/cdb_schema.sql
@@ -46,29 +46,29 @@ GRANT SELECT ON pg_catalog.gp_distributed_log TO PUBLIC;
 
 
 -- pg_tablespace_location wrapper functions to see Greenplum cluster-wide tablespace locations
--- CREATE FUNCTION gp_tablespace_segment_location (IN tblspc_oid oid, OUT gp_segment_id int, OUT tblspc_loc text)
--- RETURNS SETOF RECORD AS
--- $$
--- DECLARE
---   seg_id int;
--- BEGIN
---   EXECUTE 'select pg_catalog.gp_execution_segment()' INTO seg_id;
---   -- check if execute in entrydb QE to prevent giving wrong results
---   IF seg_id = -1 THEN
---     RAISE EXCEPTION 'Cannot execute in entrydb, this query is not currently supported by GPDB.';
---   END IF;
---   RETURN QUERY SELECT pg_catalog.gp_execution_segment() as gp_segment_id, *
---     FROM pg_catalog.pg_tablespace_location($1);
--- END;
--- $$ LANGUAGE plpgsql EXECUTE ON ALL SEGMENTS;
+CREATE FUNCTION gp_tablespace_segment_location (IN tblspc_oid oid, OUT gp_segment_id int, OUT tblspc_loc text)
+RETURNS SETOF RECORD AS
+$$
+DECLARE
+  seg_id int;
+BEGIN
+  EXECUTE 'select pg_catalog.gp_execution_segment()' INTO seg_id;
+  -- check if execute in entrydb QE to prevent giving wrong results
+  IF seg_id = -1 THEN
+    RAISE EXCEPTION 'Cannot execute in entrydb, this query is not currently supported by GPDB.';
+  END IF;
+  RETURN QUERY SELECT pg_catalog.gp_execution_segment() as gp_segment_id, *
+    FROM pg_catalog.pg_tablespace_location($1);
+END;
+$$ LANGUAGE plpgsql EXECUTE ON ALL SEGMENTS;
 
 
--- CREATE FUNCTION gp_tablespace_location (IN tblspc_oid oid, OUT gp_segment_id int, OUT tblspc_loc text)
--- RETURNS SETOF RECORD
--- AS
---   'SELECT * FROM pg_catalog.gp_tablespace_segment_location($1)
---    UNION ALL
---    SELECT pg_catalog.gp_execution_segment() as gp_segment_id, * FROM pg_catalog.pg_tablespace_location($1)'
--- LANGUAGE SQL EXECUTE ON COORDINATOR;
+CREATE FUNCTION gp_tablespace_location (IN tblspc_oid oid, OUT gp_segment_id int, OUT tblspc_loc text)
+RETURNS SETOF RECORD
+AS
+  'SELECT * FROM pg_catalog.gp_tablespace_segment_location($1)
+   UNION ALL
+   SELECT pg_catalog.gp_execution_segment() as gp_segment_id, * FROM pg_catalog.pg_tablespace_location($1)'
+LANGUAGE SQL EXECUTE ON COORDINATOR;
 
 RESET log_min_messages;
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index e360e2d91c2..be32382932f 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -2152,11 +2152,11 @@ setup_cdb_schema(FILE *cmdfd)
 /*
  * load PL/pgSQL server-side language
  */
-//static void
-//load_plpgsql(FILE *cmdfd)
-//{
-//	PG_CMD_PUTS("CREATE EXTENSION plpgsql;\n\n");
-//}
+static void
+load_plpgsql(FILE *cmdfd)
+{
+	PG_CMD_PUTS("CREATE EXTENSION plpgsql;\n\n");
+}
 
 /*
  * GPDB: load external table support
@@ -3412,8 +3412,8 @@ initialize_data_directory(void)
 
 	setup_schema(cmdfd);
 
-//	load_plpgsql(cmdfd);
-//
+	load_plpgsql(cmdfd);
+
 //	load_exttable(cmdfd);
 
 	/* sets up the Apache Cloudberry admin schema */


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org