Browse Source

INFILE deregister functions

Provide functions to remove ReaderHandler and filepaths from the
registry
Julien Schmidt 12 years ago
parent
commit
e64c57453f
1 changed files with 11 additions and 0 deletions
  1. 11 0
      infile.go

+ 11 - 0
infile.go

@@ -35,6 +35,11 @@ func RegisterLocalFile(filepath string) {
 	fileRegister[strings.Trim(filepath, `"`)] = true
 }
 
+// DeregisterLocalFile removes the given filepath from the whitelist.
+func DeregisterLocalFile(filepath string) {
+	delete(fileRegister, strings.Trim(filepath, `"`))
+}
+
 // RegisterReaderHandler registers a handler function which is used
 // to receive a io.Reader.
 // The Reader can be used by "LOAD DATA LOCAL INFILE Reader::<name>".
@@ -44,6 +49,12 @@ func RegisterReaderHandler(name string, handler func() io.Reader) {
 	readerRegister[name] = handler
 }
 
+// DeregisterReaderHandler removes the ReaderHandler function with
+// the given name from the registry.
+func DeregisterReaderHandler(name string) {
+	delete(readerRegister, name)
+}
+
 func (mc *mysqlConn) handleInFileRequest(name string) (err error) {
 	var rdr io.Reader
 	data := make([]byte, 4+mc.maxWriteSize)