// Run a prepared query. func (query *Query) Run() (*Docs, error) { docs := &Docs{} query.lock.Lock() defer query.lock.Unlock() if !query.opened { return docs, errqueryclosed } docs.docs = C.c_dbxml_run_query(query.query) if C.c_dbxml_get_query_error(docs.docs) != 0 { defer C.c_dbxml_docs_free(docs.docs) return docs, errors.New(C.GoString(C.c_dbxml_get_query_errstring(docs.docs))) } runtime.SetFinalizer(docs, (*Docs).Close) docs.opened = true return docs, nil }
func (docs *Docs) close() { if docs.opened { C.c_dbxml_docs_free(docs.docs) docs.opened = false } }