--- bin/named/dlz_mysql_driver.c_ORIG	2005-03-25 17:58:33.000000000 +0100
+++ bin/named/dlz_mysql_driver.c	2005-03-25 19:53:44.000000000 +0100
@@ -181,6 +181,11 @@
 	unsigned int j = 0;
 	int qres = 0;
 
+	/* Extended Patch for Zone Extended Tag */
+	char *n_zone_domain;
+	char *n_zone_tld;
+	char n_buffer[strlen(zone)+1];
+	
 	if(query != COUNTZONE)
 		REQUIRE(*rs == NULL);
 	else
@@ -260,10 +265,27 @@
 		// was a zone string passed?  If so, make it safe for use in queries.
 	if(zone != NULL){
 		dbi->zone = mysqldrv_escape_string((MYSQL *) dbi->dbconn, zone);
+
+		// Extended Patch for Zone Extended Tag
+		snprintf(n_buffer, strlen(zone)+1, "%s", zone);
+		n_zone_domain = strtok(n_buffer, ".");
+		n_zone_tld    = strtok(NULL, "");
+		//
+		dbi->zone_domain = mysqldrv_escape_string((MYSQL *) dbi->dbconn, n_zone_domain);
+		dbi->zone_tld    = mysqldrv_escape_string((MYSQL *) dbi->dbconn, n_zone_tld);
+
 		if(dbi->zone == NULL){
 			result = ISC_R_NOMEMORY;
 			goto cleanup;
 		}
+		if(dbi->zone_domain == NULL){
+			result = ISC_R_NOMEMORY;
+			goto cleanup;
+		}
+		if(dbi->zone_tld == NULL){
+			result = ISC_R_NOMEMORY;
+			goto cleanup;
+		}
 	} else {	// no string passed, set the string pointer to NULL
 		dbi->zone = NULL;
 	}
@@ -361,6 +383,14 @@
 	if(dbi->zone != NULL)
 		isc_mem_free(ns_g_mctx, dbi->zone);
 
+		// free dbi->zone_domain string
+	if(dbi->zone_domain != NULL)
+		isc_mem_free(ns_g_mctx, dbi->zone_domain);
+	
+		// free dbi->zone_tld string
+	if(dbi->zone_tld != NULL)
+		isc_mem_free(ns_g_mctx, dbi->zone_tld);
+	
 		// free dbi->record string
 	if(dbi->record != NULL)
 		isc_mem_free(ns_g_mctx, dbi->record);
