Selaa lähdekoodia

added the multiStatements param to the dsn parameter

Badoet Endoet 10 vuotta sitten
vanhempi
commit
1bdf5bdf85
2 muutettua tiedostoa jossa 13 lisäystä ja 0 poistoa
  1. 9 0
      dsn.go
  2. 4 0
      packets.go

+ 9 - 0
dsn.go

@@ -46,6 +46,7 @@ type Config struct {
 	ClientFoundRows         bool // Return number of matching rows instead of rows changed
 	ColumnsWithAlias        bool // Prepend table alias to column names
 	InterpolateParams       bool // Interpolate placeholders into query string
+	MultiStatements         bool // Allow multiple statements in one query
 	ParseTime               bool // Parse time values to time.Time
 	Strict                  bool // Return warnings as errors
 }
@@ -235,6 +236,14 @@ func parseDSNParams(cfg *Config, params string) (err error) {
 				return
 			}
 
+		// multiple statements in one query
+		case "multiStatements":
+			var isBool bool
+			cfg.MultiStatements, isBool = readBool(value)
+			if !isBool {
+				return errors.New("invalid bool value: " + value)
+			}
+
 		// time.Time parsing
 		case "parseTime":
 			var isBool bool

+ 4 - 0
packets.go

@@ -236,6 +236,10 @@ func (mc *mysqlConn) writeAuthPacket(cipher []byte) error {
 		clientFlags |= clientSSL
 	}
 
+	if mc.cfg.MultiStatements {
+		clientFlags |= clientMultiStatements
+	}
+
 	// User Password
 	scrambleBuff := scramblePassword(cipher, []byte(mc.cfg.Passwd))