!6258 opengauss支持chparser插件

Merge pull request !6258 from 胡淳滔/chparser
This commit is contained in:
opengauss_bot
2024-10-10 07:47:41 +00:00
committed by Gitee
19 changed files with 164 additions and 43 deletions

View File

@ -108,6 +108,13 @@ install:
@if test -d contrib/gms_profiler; then $(MAKE) -C contrib/gms_profiler $@; fi
@if test -d contrib/gms_output; then $(MAKE) -C contrib/gms_output $@; fi
@if test -d contrib/timescaledb; then (./contrib/timescaledb/run_to_build.sh && $(MAKE) -C contrib/timescaledb/build $@); fi
@if test -d contrib/chparser; then \
if command -v scws &> /dev/null; then \
$(MAKE) -C contrib/chparser $@; \
else \
echo "SCWS is not installed, skipping chparser build."; \
fi \
fi
+@echo "openGauss installation complete."
endif
endif

View File

@ -99,6 +99,8 @@
./share/postgresql/extension/age.control
./share/postgresql/extension/datavec--1.0.sql
./share/postgresql/extension/datavec.control
./share/postgresql/extension/chparser--1.0.sql
./share/postgresql/extension/chparser.control
./share/postgresql/extension/assessment--1.0.sql
./share/postgresql/extension/assessment.control
./share/postgresql/extension/file_fdw--1.0.sql
@ -737,6 +739,7 @@
./share/postgresql/tsearch_data/swedish.stop
./share/postgresql/tsearch_data/ispell_sample.dict
./share/postgresql/tsearch_data/italian.stop
./share/postgresql/tsearch_data/dict.utf8.xdb
./share/postgresql/information_schema.sql
./share/postgresql/timezonesets/Antarctica.txt
./share/postgresql/timezonesets/Australia.txt
@ -816,6 +819,7 @@
./lib/postgresql/dolphin.so
./lib/postgresql/age.so
./lib/postgresql/datavec.so
./lib/postgresql/chparser.so
./lib/postgresql/pg_upgrade_support.so
./lib/postgresql/java/pljava.jar
./lib/postgresql/postgres_fdw.so

View File

@ -84,6 +84,8 @@
./share/postgresql/extension/age.control
./share/postgresql/extension/datavec--1.0.sql
./share/postgresql/extension/datavec.control
./share/postgresql/extension/chparser--1.0.sql
./share/postgresql/extension/chparser.control
./share/postgresql/extension/file_fdw--1.0.sql
./share/postgresql/extension/plpgsql.control
./share/postgresql/extension/dist_fdw.control
@ -724,6 +726,7 @@
./share/postgresql/tsearch_data/swedish.stop
./share/postgresql/tsearch_data/ispell_sample.dict
./share/postgresql/tsearch_data/italian.stop
./share/postgresql/tsearch_data/dict.utf8.xdb
./share/postgresql/information_schema.sql
./share/postgresql/timezonesets/Antarctica.txt
./share/postgresql/timezonesets/Australia.txt
@ -788,6 +791,7 @@
./lib/postgresql/dolphin.so
./lib/postgresql/age.so
./lib/postgresql/datavec.so
./lib/postgresql/chparser.so
./lib/postgresql/pg_upgrade_support.so
./lib/postgresql/java/pljava.jar
./lib/postgresql/postgres_fdw.so

View File

@ -99,6 +99,8 @@
./share/postgresql/extension/timescaledb--1.7.4.sql
./share/postgresql/extension/datavec--1.0.sql
./share/postgresql/extension/datavec.control
./share/postgresql/extension/chparser--1.0.sql
./share/postgresql/extension/chparser.control
./share/postgresql/extension/assessment--1.0.sql
./share/postgresql/extension/assessment.control
./share/postgresql/extension/file_fdw--1.0.sql
@ -737,6 +739,7 @@
./share/postgresql/tsearch_data/swedish.stop
./share/postgresql/tsearch_data/ispell_sample.dict
./share/postgresql/tsearch_data/italian.stop
./share/postgresql/tsearch_data/dict.utf8.xdb
./share/postgresql/information_schema.sql
./share/postgresql/timezonesets/Antarctica.txt
./share/postgresql/timezonesets/Australia.txt
@ -816,6 +819,7 @@
./lib/postgresql/dolphin.so
./lib/postgresql/age.so
./lib/postgresql/datavec.so
./lib/postgresql/chparser.so
./lib/postgresql/pg_upgrade_support.so
./lib/postgresql/java/pljava.jar
./lib/postgresql/postgres_fdw.so

View File

@ -26,6 +26,7 @@ set(CMAKE_MODULE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/ndpplugin
${CMAKE_CURRENT_SOURCE_DIR}/spq_plugin
${CMAKE_CURRENT_SOURCE_DIR}/datavec
${CMAKE_CURRENT_SOURCE_DIR}/chparser
${CMAKE_CURRENT_SOURCE_DIR}/gms_stats
${CMAKE_CURRENT_SOURCE_DIR}/gms_profiler
)
@ -57,4 +58,7 @@ endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/datavec)
add_subdirectory(datavec)
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/chparser)
add_subdirectory(chparser)
endif()
add_subdirectory(gms_profiler)

View File

@ -23030,14 +23030,6 @@ InsertStmt: opt_with_clause INSERT hint_string INTO insert_target insert_rest re
}
| opt_with_clause INSERT hint_string INTO insert_target insert_rest upsert_clause returning_clause
{
if ($8 != NIL) {
const char* message = "RETURNING clause is not yet supported whithin INSERT ON DUPLICATE KEY UPDATE statement.";
InsertErrorMessage(message, u_sess->plsql_cxt.plpgsql_yylloc);
ereport(errstate,
(errmodule(MOD_PARSER),
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("RETURNING clause is not yet supported whithin INSERT ON DUPLICATE KEY UPDATE statement.")));
}
if ($1 != NULL) {
const char* message = "WITH clause is not yet supported whithin INSERT ON DUPLICATE KEY UPDATE statement.";
InsertErrorMessage(message, u_sess->plsql_cxt.plpgsql_yylloc);

View File

@ -80,6 +80,7 @@ static void DropExtensionInListIsSupported(List* objname)
"packages",
"ndpplugin",
"datavec",
"chparser",
#ifndef ENABLE_MULTIPLE_NODES
"mysql_fdw",
"oracle_fdw",

View File

@ -6734,7 +6734,7 @@ ProcessUtilitySlow(Node *parse_tree,
break;
case OBJECT_TSPARSER:
#ifdef PGXC
if (!IsInitdb) {
if (!IsInitdb && !u_sess->attr.attr_common.IsInplaceUpgrade && !u_sess->exec_cxt.extension_is_valid) {
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("user-defined text search parser is not yet supported.")));

View File

@ -260,9 +260,6 @@ WITH RECURSIVE rq AS
)
INSERT INTO t03 SELECT * FROM rq ON DUPLICATE KEY UPDATE col1 = rq.col1;
ERROR: WITH clause is not yet supported whithin INSERT ON DUPLICATE KEY UPDATE statement.
--- error: test returning clause
INSERT INTO t01 VALUES (1) ON DUPLICATE KEY UPDATE col1 = 1 RETURNING NOT(1::bool);
ERROR: RETURNING clause is not yet supported whithin INSERT ON DUPLICATE KEY UPDATE statement.
--- error: distribute key are not allowed to UPDATE
CREATE TABLE t04 (col1 INT, col2 INT) with(storage_type=ustore);
INSERT INTO t04 VALUES (1) ON DUPLICATE KEY UPDATE col1 = 5;

View File

@ -279,9 +279,6 @@ WITH RECURSIVE rq AS
)
INSERT INTO t03 SELECT * FROM rq ON DUPLICATE KEY UPDATE col1 = rq.col1;
ERROR: WITH clause is not yet supported whithin INSERT ON DUPLICATE KEY UPDATE statement.
--- error: test returning clause
INSERT INTO t01 VALUES (1) ON DUPLICATE KEY UPDATE col1 = 1 RETURNING NOT(1::bool);
ERROR: RETURNING clause is not yet supported whithin INSERT ON DUPLICATE KEY UPDATE statement.
--- error: distribute key are not allowed to UPDATE
CREATE TABLE t04 (col1 INT, col2 INT) ;
INSERT INTO t04 VALUES (1) ON DUPLICATE KEY UPDATE col1 = 5;

View File

@ -9,7 +9,6 @@
index
DEFERABLE index
insert stmt
returning
with
with recur
update stmt
@ -55,9 +54,6 @@ ERROR: INSERT ON DUPLICATE KEY UPDATE does not support deferrable unique constr
insert into up_neg_03 values(1) on duplicate key update c1 = 1;
ERROR: INSERT ON DUPLICATE KEY UPDATE does not support deferrable unique constraints/exclusion constraints.
-- insert stmt
----returning
insert into up_neg_04 values(1,1,1) on duplicate key update c1 = 1 returning c1;
ERROR: RETURNING clause is not yet supported whithin INSERT ON DUPLICATE KEY UPDATE statement.
----with
with sub as (select *from up_neg_04)
insert into up_neg_04 select *from sub on duplicate key update c1 =1;
@ -66,9 +62,6 @@ ERROR: WITH clause is not yet supported whithin INSERT ON DUPLICATE KEY UPDATE
with RECURSIVE sub as (select *from up_neg_04)
insert into up_neg_04 select *from sub on duplicate key update c1 =1;
ERROR: WITH clause is not yet supported whithin INSERT ON DUPLICATE KEY UPDATE statement.
with sub as (select *from up_neg_04)
insert into up_neg_04 select *from sub on duplicate key update c1 =1 returning c1;
ERROR: RETURNING clause is not yet supported whithin INSERT ON DUPLICATE KEY UPDATE statement.
-- update stmt
---- VALUES with expr
insert into up_neg_05 values(1,1,1,1) on duplicate key update c3 = values(1+100);

View File

@ -0,0 +1,99 @@
DROP SCHEMA test_upsert_returning CASCADE;
ERROR: schema "test_upsert_returning" does not exist
CREATE SCHEMA test_upsert_returning;
CREATE SCHEMA
SET CURRENT_SCHEMA TO test_upsert_returning;
CREATE TEMP TABLE foo (f1 int unique, f2 text, f3 int default 42);
NOTICE: CREATE TABLE / UNIQUE will create implicit index "foo_f1_key" for table "foo"
CREATE TEMP TABLE foo_2 (a int, b int);
INSERT INTO foo_2 select generate_series(1, 5), generate_series(1, 2);
INSERT INTO foo (f1, f2, f3)
VALUES (1, 'test', DEFAULT), (2, 'More', 11), (3, upper('more'), 7+9) ON DUPLICATE KEY UPDATE f3 = f3+1
RETURNING *, f1+f3 AS sum;
f1 | f2 | f3 | sum
----+------+----+-----
1 | test | 42 | 43
2 | More | 11 | 13
3 | MORE | 16 | 19
(3 rows)
SELECT * FROM foo ORDER BY f1;
f1 | f2 | f3
----+------+----
1 | test | 42
2 | More | 11
3 | MORE | 16
(3 rows)
with t as
(
INSERT INTO foo SELECT f1+1, f2, f3+2 FROM foo order by f3 on ON DUPLICATE KEY UPDATE f3 = f3+10 RETURNING foo.*, '1'
)
select * from t;
f1 | f2 | f3 | ?column?
----+------+----+----------
3 | MORE | 26 | 1
4 | MORE | 18 | 1
2 | More | 21 | 1
(3 rows)
-- error
INSERT INTO foo SELECT f1+1, f2, f3+2 FROM foo order by f3 ON DUPLICATE KEY UPDATE f1 = f1+1 RETURNING f3, f2, f1, least(f1,f3);
ERROR: INSERT ON DUPLICATE KEY UPDATE don't allow update on primary key or unique key.
INSERT INTO foo SELECT f1+1, f2, f3+2 FROM foo order by f3 ON DUPLICATE KEY UPDATE f3 = f3+1 RETURNING f3, f2, f1, least(f1,f3);
f3 | f2 | f1 | least
----+------+----+-------
20 | MORE | 5 | 5
27 | MORE | 3 | 3
19 | MORE | 4 | 4
22 | More | 2 | 2
(4 rows)
-- update nothing
INSERT INTO foo SELECT f1+1, f2, f3+2 FROM foo order by f3 ON DUPLICATE KEY UPDATE f3 = f3 RETURNING f3, f2, f1, least(f1,f3);
f3 | f2 | f1 | least
----+------+----+-------
20 | MORE | 5 | 5
22 | MORE | 6 | 6
27 | MORE | 3 | 3
19 | MORE | 4 | 4
22 | More | 2 | 2
(5 rows)
SELECT * FROM foo ORDER BY f1;
f1 | f2 | f3
----+------+----
1 | test | 42
2 | More | 22
3 | MORE | 27
4 | MORE | 19
5 | MORE | 20
6 | MORE | 22
(6 rows)
-- Subplans and initplans in the RETURNING list
INSERT INTO foo SELECT f1+1, f2, f3+99 FROM foo order by 1, 2, 3 ON DUPLICATE KEY UPDATE f3 =f3+10 RETURNING *, f1 - 3 IN
(SELECT b FROM foo_2) AS subplan, EXISTS(SELECT * FROM foo_2) AS initplan;
f1 | f2 | f3 | subplan | initplan
----+------+-----+---------+----------
2 | More | 32 | f | t
3 | MORE | 37 | f | t
4 | MORE | 29 | t | t
5 | MORE | 30 | t | t
6 | MORE | 32 | f | t
7 | MORE | 121 | f | t
(6 rows)
SELECT * FROM foo order by 1,2,3;
f1 | f2 | f3
----+------+-----
1 | test | 42
2 | More | 32
3 | MORE | 37
4 | MORE | 29
5 | MORE | 30
6 | MORE | 32
7 | MORE | 121
(7 rows)
DROP SCHEMA test_upsert_returning CASCADE;

View File

@ -145,9 +145,6 @@ WITH RECURSIVE rq AS
)
INSERT INTO t03 SELECT * FROM rq ON DUPLICATE KEY UPDATE col1 = rq.col1;
--- error: test returning clause
INSERT INTO t01 VALUES (1) ON DUPLICATE KEY UPDATE col1 = 1 RETURNING NOT(1::bool);
--- error: distribute key are not allowed to UPDATE
CREATE TABLE t04 (col1 INT, col2 INT) ;
INSERT INTO t04 VALUES (1) ON DUPLICATE KEY UPDATE col1 = 5;

View File

@ -9,7 +9,6 @@
index
DEFERABLE index
insert stmt
returning
with
with recur
update stmt
@ -55,8 +54,6 @@ insert into up_neg_03 values(1,2,3) on duplicate key update c1 = 1;
insert into up_neg_03 values(1) on duplicate key update c1 = 1;
-- insert stmt
----returning
insert into up_neg_04 values(1,1,1) on duplicate key update c1 = 1 returning c1;
----with
with sub as (select *from up_neg_04)
insert into up_neg_04 select *from sub on duplicate key update c1 =1;
@ -65,9 +62,6 @@ insert into up_neg_04 select *from sub on duplicate key update c1 =1;
with RECURSIVE sub as (select *from up_neg_04)
insert into up_neg_04 select *from sub on duplicate key update c1 =1;
with sub as (select *from up_neg_04)
insert into up_neg_04 select *from sub on duplicate key update c1 =1 returning c1;
-- update stmt
---- VALUES with expr
insert into up_neg_05 values(1,1,1,1) on duplicate key update c3 = values(1+100);

View File

@ -0,0 +1,40 @@
DROP SCHEMA test_upsert_returning CASCADE;
CREATE SCHEMA test_upsert_returning;
SET CURRENT_SCHEMA TO test_upsert_returning;
CREATE TEMP TABLE foo (f1 int unique, f2 text, f3 int default 42);
CREATE TEMP TABLE foo_2 (a int, b int);
INSERT INTO foo_2 select generate_series(1, 5), generate_series(1, 2);
INSERT INTO foo (f1, f2, f3)
VALUES (1, 'test', DEFAULT), (2, 'More', 11), (3, upper('more'), 7+9) ON DUPLICATE KEY UPDATE f3 = f3+1
RETURNING *, f1+f3 AS sum;
SELECT * FROM foo ORDER BY f1;
with t as
(
INSERT INTO foo SELECT f1+1, f2, f3+2 FROM foo order by f3 ON DUPLICATE KEY UPDATE f3 = f3+10 RETURNING foo.*, '1'
)
select * from t;
-- error
INSERT INTO foo SELECT f1+1, f2, f3+2 FROM foo order by f3 ON DUPLICATE KEY UPDATE f1 = f1+1 RETURNING f3, f2, f1, least(f1,f3);
INSERT INTO foo SELECT f1+1, f2, f3+2 FROM foo order by f3 ON DUPLICATE KEY UPDATE f3 = f3+1 RETURNING f3, f2, f1, least(f1,f3);
-- update nothing
INSERT INTO foo SELECT f1+1, f2, f3+2 FROM foo order by f3 ON DUPLICATE KEY UPDATE f3 = f3 RETURNING f3, f2, f1, least(f1,f3);
SELECT * FROM foo ORDER BY f1;
-- Subplans and initplans in the RETURNING list
INSERT INTO foo SELECT f1+1, f2, f3+99 FROM foo order by 1, 2, 3 ON DUPLICATE KEY UPDATE f3 =f3+10 RETURNING *, f1 - 3 IN
(SELECT b FROM foo_2) AS subplan, EXISTS(SELECT * FROM foo_2) AS initplan;
SELECT * FROM foo order by 1,2,3;
DROP SCHEMA test_upsert_returning CASCADE;

View File

@ -271,9 +271,6 @@ WITH RECURSIVE rq AS
)
INSERT INTO t03 SELECT * FROM rq ON DUPLICATE KEY UPDATE col1 = rq.col1;
ERROR: WITH clause is not yet supported whithin INSERT ON DUPLICATE KEY UPDATE statement.
--- error: test returning clause
INSERT INTO t01 VALUES (1) ON DUPLICATE KEY UPDATE col1 = 1 RETURNING NOT(1::bool);
ERROR: RETURNING clause is not yet supported whithin INSERT ON DUPLICATE KEY UPDATE statement.
--- error: distribute key are not allowed to UPDATE
CREATE TABLE t04 (col1 INT, col2 INT) ;
INSERT INTO t04 VALUES (1) ON DUPLICATE KEY UPDATE col1 = 5;

View File

@ -252,9 +252,6 @@ WITH RECURSIVE rq AS
)
INSERT INTO t03 SELECT * FROM rq ON DUPLICATE KEY UPDATE col1 = rq.col1;
ERROR: WITH clause is not yet supported whithin INSERT ON DUPLICATE KEY UPDATE statement.
--- error: test returning clause
INSERT INTO t01 VALUES (1) ON DUPLICATE KEY UPDATE col1 = 1 RETURNING NOT(1::bool);
ERROR: RETURNING clause is not yet supported whithin INSERT ON DUPLICATE KEY UPDATE statement.
--- error: distribute key are not allowed to UPDATE
CREATE TABLE t04 (col1 INT, col2 INT) with(storage_type=ustore);
INSERT INTO t04 VALUES (1) ON DUPLICATE KEY UPDATE col1 = 5;

View File

@ -150,9 +150,6 @@ WITH RECURSIVE rq AS
)
INSERT INTO t03 SELECT * FROM rq ON DUPLICATE KEY UPDATE col1 = rq.col1;
--- error: test returning clause
INSERT INTO t01 VALUES (1) ON DUPLICATE KEY UPDATE col1 = 1 RETURNING NOT(1::bool);
--- error: distribute key are not allowed to UPDATE
CREATE TABLE t04 (col1 INT, col2 INT) ;
INSERT INTO t04 VALUES (1) ON DUPLICATE KEY UPDATE col1 = 5;

View File

@ -146,9 +146,6 @@ WITH RECURSIVE rq AS
)
INSERT INTO t03 SELECT * FROM rq ON DUPLICATE KEY UPDATE col1 = rq.col1;
--- error: test returning clause
INSERT INTO t01 VALUES (1) ON DUPLICATE KEY UPDATE col1 = 1 RETURNING NOT(1::bool);
--- error: distribute key are not allowed to UPDATE
CREATE TABLE t04 (col1 INT, col2 INT) with(storage_type=ustore);
INSERT INTO t04 VALUES (1) ON DUPLICATE KEY UPDATE col1 = 5;