Changeset: 8a4c4fdeaef8 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8a4c4fdeaef8 Added Files: sql/test/BugTracker-2020/Tests/url-nulls.Bug-6845.sql sql/test/BugTracker-2020/Tests/url-nulls.Bug-6845.stable.err sql/test/BugTracker-2020/Tests/url-nulls.Bug-6845.stable.out Modified Files: monetdb5/modules/atoms/url.c sql/backends/monet5/rel_bin.c sql/backends/monet5/sql_statement.c sql/server/sql_atom.c sql/server/sql_atom.h sql/test/BugDay_2005-10-06_2.9.3/Tests/UNION_JOIN_vs_plain_set_UNION-2.SF-920585.stable.out sql/test/BugTracker-2020/Tests/All sql/test/SQLancer/Tests/sqlancer01.sql sql/test/SQLancer/Tests/sqlancer01.stable.out sql/test/pg_regress/Tests/strings.stable.out sql/test/pg_regress/Tests/strings_cast.stable.out Branch: default Log Message:
Merged with Jun2020 diffs (truncated from 863 to 300 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 @@ -339,15 +339,21 @@ URLgetAnchor(str *retval, url *val) if (val == NULL || *val == NULL) throw(ILLARG, "url.getAnchor", "url missing"); - if ((s = skip_scheme(*val)) == NULL || - (s = skip_authority(s, NULL, NULL, NULL, NULL)) == NULL || - (s = skip_path(s, NULL, NULL)) == NULL || - (s = skip_search(s)) == NULL) - throw(ILLARG, "url.getAnchor", "bad url"); - if (*s == '#') - s++; - else + + if (strNil(*val)) { s = str_nil; + } else { + if ((s = skip_scheme(*val)) == NULL || + (s = skip_authority(s, NULL, NULL, NULL, NULL)) == NULL || + (s = skip_path(s, NULL, NULL)) == NULL || + (s = skip_search(s)) == NULL) + throw(ILLARG, "url.getAnchor", "bad url"); + if (*s == '#') + s++; + else + s = str_nil; + } + if ((*retval = GDKstrdup(s)) == NULL) throw(MAL, "url.getAnchor", SQLSTATE(HY013) MAL_MALLOC_FAIL); return MAL_SUCCEED; @@ -365,24 +371,30 @@ URLgetBasename(str *retval, url *val) if (val == NULL || *val == NULL) throw(ILLARG, "url.getBasename", "url missing"); - if ((s = skip_scheme(*val)) == NULL || - (s = skip_authority(s, NULL, NULL, NULL, NULL)) == NULL || - (s = skip_path(s, &b, &e)) == NULL) - throw(ILLARG, "url.getBasename", "bad url"); - if (b == NULL) { + + if (strNil(*val)) { *retval = GDKstrdup(str_nil); } else { - size_t l; - - if (e != NULL) { - l = e - b; + if ((s = skip_scheme(*val)) == NULL || + (s = skip_authority(s, NULL, NULL, NULL, NULL)) == NULL || + (s = skip_path(s, &b, &e)) == NULL) + throw(ILLARG, "url.getBasename", "bad url"); + if (b == NULL) { + *retval = GDKstrdup(str_nil); } else { - l = s - b; - } - if ((*retval = GDKmalloc(l + 1)) != NULL) { - strcpy_len(*retval, b, l + 1); + size_t l; + + if (e != NULL) { + l = e - b; + } else { + l = s - b; + } + if ((*retval = GDKmalloc(l + 1)) != NULL) { + strcpy_len(*retval, b, l + 1); + } } } + if (*retval == NULL) throw(MAL, "url.getBasename", SQLSTATE(HY013) MAL_MALLOC_FAIL); return MAL_SUCCEED; @@ -398,15 +410,21 @@ URLgetContext(str *retval, url *val) if (val == NULL || *val == NULL) throw(ILLARG, "url.getContext", "url missing"); - if ((s = skip_scheme(*val)) == NULL || - (p = skip_authority(s, NULL, NULL, NULL, NULL)) == NULL || - (s = skip_path(p, NULL, NULL)) == NULL) - throw(ILLARG, "url.getContext", "bad url"); - if (p == s) { + + if (strNil(*val)) { *retval = GDKstrdup(str_nil); - } else if ((*retval = GDKmalloc(s - p + 1)) != NULL) { - strcpy_len(*retval, p, s - p + 1); + } else { + if ((s = skip_scheme(*val)) == NULL || + (p = skip_authority(s, NULL, NULL, NULL, NULL)) == NULL || + (s = skip_path(p, NULL, NULL)) == NULL) + throw(ILLARG, "url.getContext", "bad url"); + if (p == s) { + *retval = GDKstrdup(str_nil); + } else if ((*retval = GDKmalloc(s - p + 1)) != NULL) { + strcpy_len(*retval, p, s - p + 1); + } } + if (*retval == NULL) throw(MAL, "url.getContext", SQLSTATE(HY013) MAL_MALLOC_FAIL); return MAL_SUCCEED; @@ -422,20 +440,26 @@ URLgetExtension(str *retval, url *val) if (val == NULL || *val == NULL) throw(ILLARG, "url.getExtension", "url missing"); - if ((s = skip_scheme(*val)) == NULL || - (s = skip_authority(s, NULL, NULL, NULL, NULL)) == NULL || - (s = skip_path(s, NULL, &e)) == NULL) - throw(ILLARG, "url.getExtension", "bad url"); - if (e == NULL) { + + if (strNil(*val)) { *retval = GDKstrdup(str_nil); } else { - size_t l = s - e; + if ((s = skip_scheme(*val)) == NULL || + (s = skip_authority(s, NULL, NULL, NULL, NULL)) == NULL || + (s = skip_path(s, NULL, &e)) == NULL) + throw(ILLARG, "url.getExtension", "bad url"); + if (e == NULL) { + *retval = GDKstrdup(str_nil); + } else { + size_t l = s - e; - assert(*e == '.'); - if ((*retval = GDKmalloc(l)) != NULL) { - strcpy_len(*retval, e + 1, l); + assert(*e == '.'); + if ((*retval = GDKmalloc(l)) != NULL) { + strcpy_len(*retval, e + 1, l); + } } } + if (*retval == NULL) throw(MAL, "url.getExtension", SQLSTATE(HY013) MAL_MALLOC_FAIL); return MAL_SUCCEED; @@ -451,20 +475,26 @@ URLgetFile(str *retval, url *val) if (val == NULL || *val == NULL) throw(ILLARG, "url.getFile", "url missing"); - if ((s = skip_scheme(*val)) == NULL || - (s = skip_authority(s, NULL, NULL, NULL, NULL)) == NULL || - (s = skip_path(s, &b, NULL)) == NULL) - throw(ILLARG, "url.getFile", "bad url"); - if (b == NULL) { + + if (strNil(*val)) { *retval = GDKstrdup(str_nil); } else { - size_t l; + if ((s = skip_scheme(*val)) == NULL || + (s = skip_authority(s, NULL, NULL, NULL, NULL)) == NULL || + (s = skip_path(s, &b, NULL)) == NULL) + throw(ILLARG, "url.getFile", "bad url"); + if (b == NULL) { + *retval = GDKstrdup(str_nil); + } else { + size_t l; - l = s - b; - if ((*retval = GDKmalloc(l + 1)) != NULL) { - strcpy_len(*retval, b, l + 1); + l = s - b; + if ((*retval = GDKmalloc(l + 1)) != NULL) { + strcpy_len(*retval, b, l + 1); + } } } + if (*retval == NULL) throw(MAL, "url.getFile", SQLSTATE(HY013) MAL_MALLOC_FAIL); return MAL_SUCCEED; @@ -481,23 +511,29 @@ URLgetHost(str *retval, url *val) if (val == NULL || *val == NULL) throw(ILLARG, "url.getHost", "url missing"); - if ((s = skip_scheme(*val)) == NULL || - (s = skip_authority(s, NULL, NULL, &h, &p)) == NULL) - throw(ILLARG, "url.getHost", "bad url"); - if (h == NULL) { + + if (strNil(*val)) { *retval = GDKstrdup(str_nil); } else { - size_t l; - - if (p != NULL) { - l = p - h - 1; + if ((s = skip_scheme(*val)) == NULL || + (s = skip_authority(s, NULL, NULL, &h, &p)) == NULL) + throw(ILLARG, "url.getHost", "bad url"); + if (h == NULL) { + *retval = GDKstrdup(str_nil); } else { - l = s - h; - } - if ((*retval = GDKmalloc(l + 1)) != NULL) { - strcpy_len(*retval, h, l + 1); + size_t l; + + if (p != NULL) { + l = p - h - 1; + } else { + l = s - h; + } + if ((*retval = GDKmalloc(l + 1)) != NULL) { + strcpy_len(*retval, h, l + 1); + } } } + if (*retval == NULL) throw(MAL, "url.getHost", SQLSTATE(HY013) MAL_MALLOC_FAIL); return MAL_SUCCEED; @@ -514,27 +550,33 @@ URLgetDomain(str *retval, url *val) if (val == NULL || *val == NULL) throw(ILLARG, "url.getDomain", "url missing"); - if ((s = skip_scheme(*val)) == NULL || - (s = skip_authority(s, NULL, NULL, &h, &p)) == NULL) - throw(ILLARG, "url.getDomain", "bad url"); - if (h == NULL) { + + if (strNil(*val)) { *retval = GDKstrdup(str_nil); } else { - size_t l; + if ((s = skip_scheme(*val)) == NULL || + (s = skip_authority(s, NULL, NULL, &h, &p)) == NULL) + throw(ILLARG, "url.getDomain", "bad url"); + if (h == NULL) { + *retval = GDKstrdup(str_nil); + } else { + size_t l; - if (p != NULL) - p--; - else - p = s; - l = 0; - while (p > h && p[-1] != '.') { - p--; - l++; - } - if ((*retval = GDKmalloc(l + 1)) != NULL) { - strcpy_len(*retval, p, l + 1); + if (p != NULL) + p--; + else + p = s; + l = 0; + while (p > h && p[-1] != '.') { + p--; + l++; + } + if ((*retval = GDKmalloc(l + 1)) != NULL) { + strcpy_len(*retval, p, l + 1); + } } } + if (*retval == NULL) throw(MAL, "url.getDomain", SQLSTATE(HY013) MAL_MALLOC_FAIL); return MAL_SUCCEED; @@ -550,18 +592,24 @@ URLgetPort(str *retval, url *val) if (val == NULL || *val == NULL) throw(ILLARG, "url.getPort", "url missing"); - if ((s = skip_scheme(*val)) == NULL || - (s = skip_authority(s, NULL, NULL, NULL, &p)) == NULL) - throw(ILLARG, "url.getPort", "bad url"); - if (p == NULL) { + + if (strNil(*val)) { *retval = GDKstrdup(str_nil); } else { - size_t l = s - p; + if ((s = skip_scheme(*val)) == NULL || + (s = skip_authority(s, NULL, NULL, NULL, &p)) == NULL) + throw(ILLARG, "url.getPort", "bad url"); + if (p == NULL) { + *retval = GDKstrdup(str_nil); + } else { + size_t l = s - p; - if ((*retval = GDKmalloc(l + 1)) != NULL) { - strcpy_len(*retval, p, l + 1); + if ((*retval = GDKmalloc(l + 1)) != NULL) { + strcpy_len(*retval, p, l + 1); + } } } + if (*retval == NULL) _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list