--- bin/named/dlz_postgres_driver.c_ORIG	2005-03-25 20:16:37.000000000 +0100
+++ bin/named/dlz_postgres_driver.c	2005-03-25 20:21:07.000000000 +0100
@@ -339,6 +339,12 @@
 	unsigned int i = 0;
 	unsigned int j = 0;
 
+    /* Extended Patch for Zone Extended Tag */
+	char *n_zone_domain;
+	char *n_zone_tld;
+	char n_buffer[strlen(zone)+1];
+
+	
 //** temporarily get a unique thread #
 unsigned int dlz_thread_num = 1+(int) (1000.0*rand()/(RAND_MAX+1.0)); 
 
@@ -433,10 +439,27 @@
 		// was a zone string passed?  If so, make it safe for use in queries.
 	if(zone != NULL){
 		dbi->zone = postgres_escape_string(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 = postgres_escape_string(n_zone_domain);
+		dbi->zone_tld    = postgres_escape_string(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;
 	}
@@ -570,6 +593,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);
