Commits

Tuukka Norri committed 0f545b5

Not trying to set regex_flavor when server has PostgreSQL 9.0 or newer

Comments (0)

Files changed (1)

Sources/PGTSConnection.mm

 		"SET standard_conforming_strings TO true",
 		"SET datestyle TO 'ISO, YMD'",
 		"SET timezone TO 'UTC'",
-		"SET transaction_isolation TO 'read committed'",
-		"SET regex_flavor TO 'advanced'"
+		"SET transaction_isolation TO 'read committed'"
 	};
 	for (int i = 0, count = BXArraySize (queries); i < count; i++)
 	{
 			[mConnector setConnectionError: error];
 		}
 	}
+	
+	int const serverVersion = PQserverVersion (connection);
+	if (serverVersion < 90000)
+	{
+		PGresult* res = [self execQuery: "SET regex_flavor TO 'advanced'"];
+		if (PGRES_COMMAND_OK != PQresultStatus (res))
+		{
+			shouldContinue = NO;
+			BXLogError (@"Expected setting run-time parameters for connection to succeed. Error:\n%s",
+						PQresultErrorMessage (res) ?: "<no error message>");
+			
+			PGTSResultSet* result = [[[PGTSResultSet alloc] initWithPGResult: res connection: self] autorelease];
+			NSError* error = [result error];
+			[mConnector setConnectionError: error];
+		}
+	}
 
 	if (shouldContinue)
 	{