| 1881 | |
| 1882 | |
| 1883 | void |
| 1884 | ParseNamespaceName(const char *namespacePath, char **databaseName, char **collectionName) |
| 1885 | { |
| 1886 | StringView strView = CreateStringViewFromString(namespacePath); |
| 1887 | StringView databaseView = StringViewFindPrefix(&strView, '.'); |
| 1888 | if (databaseView.length == 0) |
| 1889 | { |
| 1890 | ereport(ERROR, (errcode(ERRCODE_DOCUMENTDB_BADVALUE), |
| 1891 | errmsg("name needs to be fully qualified <db>.<collection>"))); |
| 1892 | } |
| 1893 | |
| 1894 | if (strView.length < databaseView.length + 2) |
| 1895 | { |
| 1896 | ereport(ERROR, (errcode(ERRCODE_DOCUMENTDB_BADVALUE), |
| 1897 | errmsg("name needs to be fully qualified <db>.<collection>"))); |
| 1898 | } |
| 1899 | |
| 1900 | StringView collectionView = StringViewSubstring(&strView, databaseView.length + 1); |
| 1901 | |
| 1902 | ValidateDatabaseCollection( |
| 1903 | PointerGetDatum(cstring_to_text_with_len(databaseView.string, |
| 1904 | databaseView.length)), |
| 1905 | PointerGetDatum(cstring_to_text_with_len(collectionView.string, |
| 1906 | collectionView.length))); |
| 1907 | |
| 1908 | *databaseName = pnstrdup(databaseView.string, databaseView.length); |
| 1909 | *collectionName = pnstrdup(collectionView.string, collectionView.length); |
| 1910 | } |
| 1911 | |
| 1912 | |
| 1913 | static void |
no test coverage detected