Skip to content

Commit fc671e4

Browse files
authored
Merge pull request duckdb#114 from hafenkran/get_table_info
added get_bind_info to scan to extract table info
2 parents 4125f2e + c495b67 commit fc671e4

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/mysql_scanner.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,20 @@ static unique_ptr<FunctionData> MySQLScanDeserialize(Deserializer &deserializer,
179179
throw NotImplementedException("MySQLScanDeserialize");
180180
}
181181

182+
static BindInfo MySQLGetBindInfo(const optional_ptr<FunctionData> bind_data_p) {
183+
auto &bind_data = bind_data_p->Cast<MySQLBindData>();
184+
BindInfo info(ScanType::EXTERNAL);
185+
info.table = bind_data.table;
186+
return info;
187+
}
188+
182189
MySQLScanFunction::MySQLScanFunction()
183190
: TableFunction("mysql_scan", {LogicalType::VARCHAR, LogicalType::VARCHAR, LogicalType::VARCHAR}, MySQLScan,
184191
MySQLBind, MySQLInitGlobalState, MySQLInitLocalState) {
185192
to_string = MySQLScanToString;
186193
serialize = MySQLScanSerialize;
187194
deserialize = MySQLScanDeserialize;
195+
get_bind_info = MySQLGetBindInfo;
188196
projection_pushdown = true;
189197
}
190198

test/sql/attach_constraints.test

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# name: test/sql/attach_constraints.test
2+
# description: Test create table with constraints and use describe
3+
# group: [storage]
4+
5+
require mysql_scanner
6+
7+
require-env MYSQL_TEST_DATABASE_AVAILABLE
8+
9+
statement ok
10+
ATTACH 'host=localhost user=root port=0 database=mysql' AS s1 (TYPE MYSQL_SCANNER)
11+
12+
statement ok
13+
CREATE OR REPLACE TABLE s1.constraints(s STRING NOT NULL, i INTEGER DEFAULT 12);
14+
15+
query IIIIII
16+
DESCRIBE s1.constraints
17+
----
18+
s VARCHAR NO NULL NULL NULL
19+
i INTEGER YES NULL 12 NULL

0 commit comments

Comments
 (0)