Changeset: 12df086e82fc for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/12df086e82fc
Modified Files:
        monetdb5/modules/atoms/url.c
        sql/test/BugTracker-2023/Tests/newurl-issue-7417.test
Branch: Dec2023
Log Message:

Added some more tests for newurl() with NULL values. When port is NULL then we 
use now 0 instead of -2**31.


diffs (50 lines):

diff --git a/monetdb5/modules/atoms/url.c b/monetdb5/modules/atoms/url.c
--- a/monetdb5/modules/atoms/url.c
+++ b/monetdb5/modules/atoms/url.c
@@ -808,6 +808,7 @@ URLnew4(url *u, str *protocol, str *serv
 {
        str Protocol = *protocol;
        str Server = *server;
+       int Port = *port;
        str File = *file;
        size_t l;
 
@@ -817,13 +818,15 @@ URLnew4(url *u, str *protocol, str *serv
                File++;
        if (strNil(Server))
                Server = "";
+       if (is_int_nil(Port))
+               Port = 0;
        if (strNil(Protocol))
                Protocol = "";
        l = strlen(File) + strlen(Server) + strlen(Protocol) + 20;
        *u = GDKmalloc(l);
        if (*u == NULL)
                throw(MAL, "url.newurl", SQLSTATE(HY013) MAL_MALLOC_FAIL);
-       snprintf(*u, l, "%s://%s:%d/%s", Protocol, Server, *port, File);
+       snprintf(*u, l, "%s://%s:%d/%s", Protocol, Server, Port, File);
        return MAL_SUCCEED;
 }
 
diff --git a/sql/test/BugTracker-2023/Tests/newurl-issue-7417.test 
b/sql/test/BugTracker-2023/Tests/newurl-issue-7417.test
--- a/sql/test/BugTracker-2023/Tests/newurl-issue-7417.test
+++ b/sql/test/BugTracker-2023/Tests/newurl-issue-7417.test
@@ -22,3 +22,18 @@ query T
 SELECT TRIM(newurl(1,1,NULL), newurl(1,1,NULL))
 ----
 (empty)
+
+query T
+SELECT newurl(NULL,1,NULL)
+----
+://1/
+
+query T
+SELECT newurl(NULL,NULL,NULL)
+----
+:///
+
+query T
+SELECT newurl(NULL,NULL,NULL,NULL)
+----
+://:0/
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to