Changeset: 4c6a1fa57bcd for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/4c6a1fa57bcd
Modified Files:
sql/scripts/52_describe.sql
sql/test/Tests/All
sql/test/Tests/comment-dump.test
Branch: Sep2022
Log Message:
Fix regexp so that the correct part of the query gets replaced.
diffs (55 lines):
diff --git a/sql/scripts/52_describe.sql b/sql/scripts/52_describe.sql
--- a/sql/scripts/52_describe.sql
+++ b/sql/scripts/52_describe.sql
@@ -149,11 +149,16 @@ CREATE FUNCTION sys.SQ (s STRING) RETURN
CREATE FUNCTION sys.DQ (s STRING) RETURNS STRING BEGIN RETURN '"' ||
sys.replace(s,'"','""') || '"'; END; --TODO: Figure out why this breaks with
the space
CREATE FUNCTION sys.FQN(s STRING, t STRING) RETURNS STRING BEGIN RETURN '"' ||
sys.replace(s,'"','""') || '"."' || sys.replace(t,'"','""') || '"'; END;
---We need pcre to implement a header guard which means adding the schema of an
object explicitely to its identifier.
+--We need pcre to implement a header guard which means adding the schema
+--of an object explicitly to its identifier.
+--Note that we don't do a case insensitive match: the SQL layer has
+--converted all unquoted tokens to lower case, so it there is an upper
+--case value, it must have been quoted, and it should still be quoted in
+--the saved query, so that would be the only match we find.
CREATE FUNCTION sys.replace_first(ori STRING, pat STRING, rep STRING, flg
STRING) RETURNS STRING EXTERNAL NAME "pcre"."replace_first";
CREATE FUNCTION sys.schema_guard(sch STRING, nme STRING, stmt STRING) RETURNS
STRING BEGIN
RETURN
- SELECT sys.replace_first(stmt, '(\\s*"?' || sch || '"?\\s*\\.|)\\s*"?'
|| nme || '"?\\s*', ' ' || sys.FQN(sch, nme) || ' ', 'imsx');
+ SELECT sys.replace_first(stmt, r'(((?<!")\b' || sch || r'\b(?!"))|"' ||
sch || r'"\s*\.\s*)?(((?<!")\b' || nme || r'\b(?!"))|"' || nme || '")',
sys.FQN(sch, nme), '');
END;
CREATE VIEW sys.describe_constraints AS
diff --git a/sql/test/Tests/All b/sql/test/Tests/All
--- a/sql/test/Tests/All
+++ b/sql/test/Tests/All
@@ -1,6 +1,6 @@
# Run these first so comment-dump doesn't encounter
# leftovers from other tests
-HAVE_LIBPCRE&KNOWNFAIL?comment-dump
+HAVE_LIBPCRE?comment-dump
comment-on
comment-auth-1
USER=user_a&PASSWD=user_a?comment-auth-2
diff --git a/sql/test/Tests/comment-dump.test b/sql/test/Tests/comment-dump.test
--- a/sql/test/Tests/comment-dump.test
+++ b/sql/test/Tests/comment-dump.test
@@ -80,12 +80,12 @@ CREATE SEQUENCE "foo"."counter" AS BIGIN
CREATE TABLE "foo"."tab" ("i" INTEGER, "j" DECIMAL(4,2));
create view "foo"."sel" as select * from foo."tab";
create view "foo"."SEL" as select * from sel;
-create function "foo"."f" () returns int begin return 42; end;
-create function "foo"."f" (i int) returns int begin return 43; end;
-create function "foo"."f" (i int, j int) returns int begin return 44; end;
-create function "foo"."f" (i int, j int, k int) returns int begin return 45;
end;
-create function "foo"."f" (i int, j int, k int, l int) returns int begin
return 45; end;
-create procedure "foo"."g" () begin delete from tab where false; end;
+create function "foo"."f"() returns int begin return 42; end;
+create function "foo"."f"(i int) returns int begin return 43; end;
+create function "foo"."f"(i int, j int) returns int begin return 44; end;
+create function "foo"."f"(i int, j int, k int) returns int begin return 45;
end;
+create function "foo"."f"(i int, j int, k int, l int) returns int begin return
45; end;
+create procedure "foo"."g"() begin delete from tab where false; end;
ALTER SEQUENCE "foo"."counter" RESTART WITH 1 NO CYCLE;
CREATE INDEX "idx" ON "foo"."tab"(j,i);
COMMENT ON COLUMN "foo"."tab"."i" IS 'ii';
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]