** Lookup the schema for a table using the information schema. */
| 1059 | ** Lookup the schema for a table using the information schema. |
| 1060 | */ |
| 1061 | static string getTableSchema(duckdb::Connection &con, const char *zTable) { |
| 1062 | string zSchema; |
| 1063 | auto zSql = StringUtil::Format("SELECT table_schema FROM information_schema.tables " |
| 1064 | "WHERE table_name = %s AND table_type='BASE TABLE' " |
| 1065 | "ORDER BY (table_schema='main') DESC LIMIT 1", |
| 1066 | SQLString(zTable)); |
| 1067 | |
| 1068 | auto query_result = con.Query(zSql); |
| 1069 | if (query_result->HasError()) { |
| 1070 | return zSchema; |
| 1071 | } |
| 1072 | for (auto &row : *query_result) { |
| 1073 | zSchema = row.GetValue<string>(0); |
| 1074 | } |
| 1075 | return zSchema; |
| 1076 | } |
| 1077 | |
| 1078 | /* |
| 1079 | ** Build a qualified name: schema.table |
no test coverage detected