-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsql.go
46 lines (37 loc) · 1.09 KB
/
sql.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
// #cgo CFLAGS: -g -Wall -I${SRCDIR}/../include
// #cgo LDFLAGS: -L${SRCDIR}/../target/debug -ldatafusion
// #include <stdlib.h>
// #include <dlfcn.h>
// #include <datafusion.h>
import "C"
import (
"fmt"
"unsafe"
)
func main() {
datafusionlib := C.df_session_context_new()
if datafusionlib != nil {
s := C.CString("SELECT 100;")
defer C.free(unsafe.Pointer(s))
var perror unsafe.Pointer
data_frame := C.df_session_context_sql(
datafusionlib, s, (**C.struct_DFError_)(unsafe.Pointer(&perror)))
defer C.free(unsafe.Pointer(data_frame))
x := (*[2]uintptr)(unsafe.Pointer(&perror))
if x[0] != 0 {
message := C.df_error_get_message((*C.struct_DFError_)(perror))
fmt.Println(C.GoString(message))
C.df_error_free((*C.struct_DFError_)(perror))
return
}
C.df_data_frame_show(data_frame, (**C.struct_DFError_)(unsafe.Pointer(&perror)))
y := (*[2]uintptr)(unsafe.Pointer(&perror))
if y[0] != 0 {
message := C.df_error_get_message((*C.struct_DFError_)(perror))
fmt.Println(C.GoString(message))
C.df_error_free((*C.struct_DFError_)(perror))
return
}
}
}