1 | #include "duckdb/main/extension_helper.hpp" |
2 | |
3 | namespace duckdb { |
4 | |
5 | static ExtensionAlias internal_aliases[] = {{.alias: "http" , .extension: "httpfs" }, // httpfs |
6 | {.alias: "https" , .extension: "httpfs" }, |
7 | {.alias: "md" , .extension: "motherduck" }, // motherduck |
8 | {.alias: "s3" , .extension: "httpfs" }, |
9 | {.alias: "postgres" , .extension: "postgres_scanner" }, // postgres |
10 | {.alias: "sqlite" , .extension: "sqlite_scanner" }, // sqlite |
11 | {.alias: "sqlite3" , .extension: "sqlite_scanner" }, |
12 | {.alias: nullptr, .extension: nullptr}}; |
13 | |
14 | idx_t ExtensionHelper::ExtensionAliasCount() { |
15 | idx_t index; |
16 | for (index = 0; internal_aliases[index].alias != nullptr; index++) { |
17 | } |
18 | return index; |
19 | } |
20 | |
21 | ExtensionAlias ExtensionHelper::GetExtensionAlias(idx_t index) { |
22 | D_ASSERT(index < ExtensionAliasCount()); |
23 | return internal_aliases[index]; |
24 | } |
25 | |
26 | string ExtensionHelper::ApplyExtensionAlias(string extension_name) { |
27 | auto lname = StringUtil::Lower(str: extension_name); |
28 | for (idx_t index = 0; internal_aliases[index].alias; index++) { |
29 | if (lname == internal_aliases[index].alias) { |
30 | return internal_aliases[index].extension; |
31 | } |
32 | } |
33 | return extension_name; |
34 | } |
35 | |
36 | } // namespace duckdb |
37 | |