[svn-commits] r160 - in branches/advisor/src: back/dmf/dmu back/dmf/hdr back/hdr/hdr back/opf/opj back/opf/opt back/opf/opv back/psf/hdr back/psf/psl back/scf/hdr back/scf/scm front/st/vdba

thial01 at ingres.com thial01 at ingres.com
Wed Jul 16 08:08:25 PDT 2008


Author: thial01
Date: 2008-07-16 08:08:25 -0700 (Wed, 16 Jul 2008)
New Revision: 160

Modified:
   branches/advisor/src/back/dmf/dmu/dm2uind.c
   branches/advisor/src/back/dmf/dmu/dm2uuti.c
   branches/advisor/src/back/dmf/dmu/dmuindex.c
   branches/advisor/src/back/dmf/hdr/dm2u.h
   branches/advisor/src/back/dmf/hdr/dm2umxcb.h
   branches/advisor/src/back/dmf/hdr/dmp.h
   branches/advisor/src/back/hdr/hdr/dmtcb.h
   branches/advisor/src/back/hdr/hdr/dmucb.h
   branches/advisor/src/back/opf/opj/opjjoinop.c
   branches/advisor/src/back/opf/opt/optcotree.c
   branches/advisor/src/back/opf/opv/opvparser.c
   branches/advisor/src/back/psf/hdr/pshparse.h
   branches/advisor/src/back/psf/psl/pslgram.yi
   branches/advisor/src/back/psf/psl/pslindx.c
   branches/advisor/src/back/psf/psl/pslsgram.yi
   branches/advisor/src/back/psf/psl/pslsscan.c
   branches/advisor/src/back/scf/hdr/scmonitor.h
   branches/advisor/src/back/scf/scm/scmonitor.sc
   branches/advisor/src/front/st/vdba/makimau.sql
Log:
Added virtual indexes with changes by ksattler - see #174


Modified: branches/advisor/src/back/dmf/dmu/dm2uind.c
===================================================================
--- branches/advisor/src/back/dmf/dmu/dm2uind.c	2008-07-15 19:25:22 UTC (rev 159)
+++ branches/advisor/src/back/dmf/dmu/dm2uind.c	2008-07-16 15:08:25 UTC (rev 160)
@@ -779,6 +779,12 @@
 **          This reduces deadlock opportunities during index creation
 **          caused by the use of control locks that are not held for
 **          the duration of a transaction (bad locking semantics).
+**      29-Nov-2007 (kus)
+**          Support virtual indexes which are not populated with data and
+**          therefore are useful for the optimizer. Currently, this is done
+**          by avoiding dm2u_load_table for this kind of index. We can
+**          probably avoid other actions, too, e.g. writing the empty index
+**          table to disk, but I don't know how :-(
 */
 DB_STATUS
 dm2u_index(
@@ -1376,6 +1382,7 @@
           index_cb->indxcb_acount = index_cb->indxcb_kcount;
 
         m->mx_structure = index_cb->indxcb_structure;
+        m->mx_virtual = index_cb->indxcb_virtual;
         m->mx_compressed = index_cb->indxcb_compressed;
         m->mx_index_comp = index_cb->indxcb_index_compressed;
         m->mx_comp_katts_count = 0;
@@ -1885,11 +1892,20 @@
 	  }
 
           /*
-          ** Load the index.
+          ** Load the index, but only if its a non-virtual index.
           */
-          status = dm2u_load_table(m, err_code);
-	  if (status != E_DB_OK)
-	    break;
+	  	if (! index_cb->indxcb_virtual) {
+           status = dm2u_load_table(m, err_code);
+           if (status != E_DB_OK)
+        	  break;
+	  	}
+	  	else {
+	  		/* 
+	  		** Don't load the table, we are going to create a virtual index!
+	  		*/
+	  		DM2U_M_CONTEXT    *mct = &m->mx_tpcb_next->tpcb_mct;
+	  		mct->mct_keys = m->mx_ai_count;
+	  	}
 
 	  if (online_index_build)
 	  {

Modified: branches/advisor/src/back/dmf/dmu/dm2uuti.c
===================================================================
--- branches/advisor/src/back/dmf/dmu/dm2uuti.c	2008-07-15 19:25:22 UTC (rev 159)
+++ branches/advisor/src/back/dmf/dmu/dm2uuti.c	2008-07-16 15:08:25 UTC (rev 160)
@@ -4133,6 +4133,9 @@
 **	30-May-2006 (jenjo02)
 **	    DMP_INDEX idom expanded from DB_MAXKEYS to DB_MAXIXATTS to support
 **	    indexes on clustered tables.
+**  29-nov-2007 (kus)
+**      Set the TCB_VIRT_INDEX in relstat if the index is to be
+**      created as virtual index.
 */
 DB_STATUS
 dm2u_update_catalogs(
@@ -4922,6 +4925,9 @@
 		    if ( m->mx_clustered )
 			rel.relstat |= (TCB_CLUSTERED | TCB_UNIQUE);
 
+		    if (m->mx_virtual)
+		    rel.relstat |= TCB_VIRT_INDEX;
+		    
 		    /* Check the altered bit before it gets cleared */
 		    if ( rel.relstat2 & TCB2_ALTERED && 
 			 rel.relstat  & TCB_COMMENT  &&

Modified: branches/advisor/src/back/dmf/dmu/dmuindex.c
===================================================================
--- branches/advisor/src/back/dmf/dmu/dmuindex.c	2008-07-15 19:25:22 UTC (rev 159)
+++ branches/advisor/src/back/dmf/dmu/dmuindex.c	2008-07-16 15:08:25 UTC (rev 160)
@@ -730,6 +730,8 @@
 **	    Carved from duplicate 450 lines of code in dmupindex, dmuindex,
 **	    holy crap.
 **	    Support indexes on Temporary Tables.
+**  29-nov-2007 (kus)
+**      Handle DMU_VIRTUAL for creating virtual indexes
 */
 DB_STATUS
 dmuIndexSetup(
@@ -990,6 +992,10 @@
 		indx_cb->indxcb_unique = (chr[i].char_value == DMU_C_ON);
 		break;
 
+	    case DMU_VIRTUAL:
+	    indx_cb->indxcb_virtual = (chr[i].char_value == DMU_C_ON);
+	    break;
+	    
 	    case DMU_GATEWAY:
 		indx_cb->indxcb_index_flags |= DM2U_GATEWAY;
 		indx_cb->indxcb_gwsource = 

Modified: branches/advisor/src/back/dmf/hdr/dm2u.h
===================================================================
--- branches/advisor/src/back/dmf/hdr/dm2u.h	2008-07-15 19:25:22 UTC (rev 159)
+++ branches/advisor/src/back/dmf/hdr/dm2u.h	2008-07-16 15:08:25 UTC (rev 160)
@@ -194,6 +194,10 @@
 **	    for Indexes on TempTables support.
 **	26-sep-2007 (kibro01) b119080
 **	    Allow modify to nopersistence
+**  29-nov-2007 (kus)
+**      Add indxcb_virtual to _DM2U_INDEX_CB for creating
+**      virtual indexes.
+
 */
 
 /*
@@ -373,6 +377,7 @@
     i4             	indxcb_compressed;
     i4             	indxcb_index_compressed;
     i4             	indxcb_unique;
+    i4				indxcb_virtual;
     i4             	indxcb_dmveredo;
     i4             	indxcb_min_pages;
     i4             	indxcb_max_pages;

Modified: branches/advisor/src/back/dmf/hdr/dm2umxcb.h
===================================================================
--- branches/advisor/src/back/dmf/hdr/dm2umxcb.h	2008-07-15 19:25:22 UTC (rev 159)
+++ branches/advisor/src/back/dmf/hdr/dm2umxcb.h	2008-07-16 15:08:25 UTC (rev 160)
@@ -164,6 +164,9 @@
 **	    mx_idom_map expanded to DB_MAXIXATTS to support
 **	    indexes on clustered tables.
 **	    Add mx_tidsize.
+**  29-nov-2007 (kus)
+**      Add mx_virtual to _DM2U_MXCB for creating
+**      virtual indexes.
 **	   
 */
 struct _DM2U_MXCB
@@ -267,6 +270,7 @@
 					** columns. Same as tcb_comp_katts_count
 					*/
     i4	    	    mx_unique;		/* ALL: Unique key. */
+    i4				mx_virtual;         /* ALL: Virtual index. */
     i4      	    mx_dmveredo;        /* We are in rollforward redo */
     i4         	    mx_truncate;        /* ALL: convert to heap and truncate. */
     i4         	    mx_duplicates;      /* ALL: convert to allow duplicates. */

Modified: branches/advisor/src/back/dmf/hdr/dmp.h
===================================================================
--- branches/advisor/src/back/dmf/hdr/dmp.h	2008-07-15 19:25:22 UTC (rev 159)
+++ branches/advisor/src/back/dmf/hdr/dmp.h	2008-07-16 15:08:25 UTC (rev 160)
@@ -2779,6 +2779,8 @@
 **	    Add RELSTAT, RELSTAT2 defines.
 **      01-may-2008 (horda03) bug 120349
 **          Add TCB_STORAGE define.
+**  29-nov-2007 (kus)
+**      Add TCB_VIRT_INDEX for virtual indexes.
 */
 struct _DMP_TCB
 {
@@ -3213,6 +3215,8 @@
 #define                  TCB_BINARY         0x00000100L
                                             /* Print character domains in
                                             ** binary. -- NO LONGER USED */
+#define                  TCB_VIRT_INDEX     0x00000100L
+                                            /* Table is an virtual index. */
 #define                  TCB_COMPRESSED     0x00000200L
                                             /* Table has compressed records. */
 #define			 TCB_INDEX_COMP	    0x00000400L

Modified: branches/advisor/src/back/hdr/hdr/dmtcb.h
===================================================================
--- branches/advisor/src/back/hdr/hdr/dmtcb.h	2008-07-15 19:25:22 UTC (rev 159)
+++ branches/advisor/src/back/hdr/hdr/dmtcb.h	2008-07-16 15:08:25 UTC (rev 160)
@@ -1171,6 +1171,8 @@
 **	    Add DMT_CLUSTERED to match TCB_CLUSTERED relstat bit.
 **	23-nov-2006 (dougi)
 **	    Return 0x40 bit to DMT_BASE_VIEW.
+**  29-nov-2007 (kus)
+**      Add DMT_VIRT_INDEX for virtual indexes.
 */
 typedef struct _DMT_TBL_ENTRY
 {
@@ -1204,6 +1206,10 @@
 #define		       DMT_BASE_VIEW	    0x000040L
 #define                DMT_IDX              0x000080L
 #define                DMT_BINARY           0x000100L
+#define                DMT_VIRT_INDEX       0x000100L
+                                            /* Reuse DMT_BINARY for virtual
+                                               indexes, because it isn't
+                                               used anymore. */
 #define                DMT_COMPRESSED       0x000200L
 #define		       DMT_INDEX_COMP	    0x000400L
 					    /* DMT_INDEX_COMP is on if the

Modified: branches/advisor/src/back/hdr/hdr/dmucb.h
===================================================================
--- branches/advisor/src/back/hdr/hdr/dmucb.h	2008-07-15 19:25:22 UTC (rev 159)
+++ branches/advisor/src/back/hdr/hdr/dmucb.h	2008-07-16 15:08:25 UTC (rev 160)
@@ -564,6 +564,8 @@
 **	    Added DMU_C_ALTCOL_ALTER for alter table alter column support.
 **	25-Apr-2006 (jenjo02)
 **	    Add DMU_CLUSTERED for Clustered (Btree) primary table.
+**  29-nov-2007 (kus)
+**      Add DMU_VIRTUAL for virtual indexes.
 */
 typedef struct _DMU_CHAR_ENTRY
 {
@@ -637,7 +639,7 @@
 				/* modify to unique_scope=statement */
 #define			DMU_TO_PERSISTS_OVER_MODIFIES 60L 
 				/* modify to persistence */
-
+#define         DMU_VIRTUAL         61L /* Virtual object */
     i4       char_value;               /* Characteristic value. */
 #define                 DMU_C_OFF           0L
 #define                 DMU_C_ON            1L

Modified: branches/advisor/src/back/opf/opj/opjjoinop.c
===================================================================
--- branches/advisor/src/back/opf/opj/opjjoinop.c	2008-07-15 19:25:22 UTC (rev 159)
+++ branches/advisor/src/back/opf/opj/opjjoinop.c	2008-07-16 15:08:25 UTC (rev 160)
@@ -6113,12 +6113,15 @@
 		{
 			RDR_INFO	*rel;
 
-			rel = global->ops_rangetab.opv_base->opv_grv[i]->opv_relation;
-			if (rel == NULL)
+			if (global->ops_rangetab.opv_base->opv_grv[i] == NULL
+					||
+				global->ops_rangetab.opv_base->opv_grv[i]->opv_relation == NULL )
 			{
 				continue;
 			}
 
+			rel = global->ops_rangetab.opv_base->opv_grv[i]->opv_relation;
+
 			/* Check if this is an index */
 			if (rel->rdr_rel->tbl_id.db_tab_index > 0)
 			{

Modified: branches/advisor/src/back/opf/opt/optcotree.c
===================================================================
--- branches/advisor/src/back/opf/opt/optcotree.c	2008-07-15 19:25:22 UTC (rev 159)
+++ branches/advisor/src/back/opf/opt/optcotree.c	2008-07-16 15:08:25 UTC (rev 160)
@@ -1896,6 +1896,7 @@
 ** Inputs:
 **      storage                         dmf storage structure
 **      cflag                           compressed flag
+**      vflag                           virtual flag
 **
 ** Outputs:
 **	Returns:
@@ -1909,12 +1910,16 @@
 ** History:
 **	18-jul-86 (seputis)
 **          initial creation
+**  29-nov-2006 (kus)
+**      Add virtual to the output of virtual indexes, indicated by
+**      the additional vflag parameter.
 [@history_line@]...
 */
 static char *
 opt_relstrct(
 	OPO_STORAGE        storage,
-	bool               cflag)
+	bool               cflag,
+	bool               vflag)
 {
     char  *name;
 
@@ -1926,7 +1931,7 @@
 		name = "cHeap";
 		break;
 	    case DB_ISAM_STORE:
-		name = "cIsam";
+	    name = (vflag ? "Virtual cIsam" : "cIsam");
 		break;
 	    case DB_HASH_STORE:
 		name = "cHashed";
@@ -1935,7 +1940,7 @@
 		name = "cSorted";
 		break;
 	    case DB_BTRE_STORE:
-		name = "cB-Tree";
+	    name = (vflag ? "Virtual cB-Tree" : "cB-Tree");
 		break;
 	    case DB_RTRE_STORE:
 		name = "cR-Tree";
@@ -1953,7 +1958,7 @@
 		name = "Heap";
 		break;
 	    case DB_ISAM_STORE:
-		name = "Isam";
+	    name = (vflag ? "Virtual Isam" : "Isam");
 		break;
 	    case DB_HASH_STORE:
 		name = "Hashed";
@@ -1962,7 +1967,7 @@
 		name = "Sorted";
 		break;
 	    case DB_BTRE_STORE:
-		name = "B-Tree";
+	    name = (vflag ? "Virtual B-Tree" : "B-Tree");
 		break;
 	    case DB_RTRE_STORE:
 		name = "R-Tree";
@@ -2011,7 +2016,7 @@
     TRformat(opt_scc, (i4 *)global,
 	(char *)&global->ops_trace.opt_trformat[0],
 	(i4)sizeof(global->ops_trace.opt_trformat),
-	"%s", opt_relstrct(storage, FALSE));
+	"%s", opt_relstrct(storage, FALSE, FALSE));
 }
 #endif
 
@@ -3068,7 +3073,7 @@
 	    TRformat(opt_scc, (i4 *)global,
 		(char *)&global->ops_trace.opt_trformat[0],
 		(i4)sizeof(global->ops_trace.opt_trformat),
-		" Ordering = %s, ", opt_relstrct(cop->opo_storage,cflag));
+		" Ordering = %s, ", opt_relstrct(cop->opo_storage,cflag,FALSE));
 	else if (cop->opo_ordeqc >= 0)
 	{
 	    OPT_NAME        stoname;	/* name of attribute associated with
@@ -3078,7 +3083,7 @@
 		(char *)&global->ops_trace.opt_trformat[0],
 		(i4)sizeof(global->ops_trace.opt_trformat),
 		" Ordering = %s on Attribute =%s, ",
-		opt_relstrct(cop->opo_storage, cflag), &stoname);
+		opt_relstrct(cop->opo_storage, cflag, FALSE), &stoname);
             if (cop->opo_sjpr == DB_ORIG)
 	    {	/* check for multi-attribute keying and print all attr names
                 ** involved in the key for ORIG node */
@@ -3113,7 +3118,7 @@
 		(char *)&global->ops_trace.opt_trformat[0],
 		(i4)sizeof(global->ops_trace.opt_trformat),
 		 " No Ordering attr, Storage = %s, ",
-		    opt_relstrct(cop->opo_storage, cflag));
+		    opt_relstrct(cop->opo_storage, cflag, FALSE));
 	}
     }
 
@@ -3870,9 +3875,11 @@
     else
     {
 	bool	    cflag;		/* compressed flag */
+	bool        vflag;      /* virtual flag */
 	char	    *structure;		/* ptr to name of storage structure */
 
         cflag = FALSE;
+        vflag = FALSE;
         if (cop->opo_sjpr == DB_ORIG)
 	{   /* set compressed flag */
 	    OPV_GRV		*grv_ptr;   /* ptr to global range variable */
@@ -3886,11 +3893,16 @@
 			    DMT_COMPRESSED
 			) 
 			!= 0;
+		vflag = (   grv_ptr->opv_relation->rdr_rel->tbl_status_mask
+				&
+				DMT_VIRT_INDEX
+			)
+			!= 0;
 		if (grv_ptr->opv_relation->rdr_parts)
 		    nparts = grv_ptr->opv_relation->rdr_parts->nphys_parts;
 	    }
 	}
-	structure = opt_relstrct(cop->opo_storage,cflag);
+	structure = opt_relstrct(cop->opo_storage,cflag,vflag);
 	if (cop->opo_ordeqc >= 0)
 	{
 	    bool	    storage_used; /* TRUE if the storage structure
@@ -4306,7 +4318,7 @@
         tablep->tbl_index_count,
         tablep->tbl_width,
 	opt_relstrct((OPO_STORAGE)tablep->tbl_storage_type,
-                     ((tablep->tbl_status_mask & DMT_COMPRESSED) != 0)),
+                     ((tablep->tbl_status_mask & DMT_COMPRESSED) != 0),FALSE),
 	tablep->tbl_pgsize);
     TRformat(opt_scc, (i4 *)global,
 	(char *)&global->ops_trace.opt_trformat[0],
@@ -4573,7 +4585,7 @@
 	(i4)sizeof(global->ops_trace.opt_trformat),
 	"    index page= %d, storage=%s, ",
 	    (i4)indexp->idx_ipage_count,
-            opt_relstrct((OPO_STORAGE)indexp->idx_storage_type, FALSE));
+            opt_relstrct((OPO_STORAGE)indexp->idx_storage_type, FALSE, FALSE));
 	{
 	    /* print out info on attributes in the indexed table */
 	    i4		keycount;	    /* current key being printed */

Modified: branches/advisor/src/back/opf/opv/opvparser.c
===================================================================
--- branches/advisor/src/back/opf/opv/opvparser.c	2008-07-15 19:25:22 UTC (rev 159)
+++ branches/advisor/src/back/opf/opv/opvparser.c	2008-07-16 15:08:25 UTC (rev 160)
@@ -407,6 +407,8 @@
 **	17-Nov-2005 (schka24)
 **	    Don't propagate RDF invalidates that we cause.  Our RDF cache
 **	    is out of date but that's not other servers' problem.
+**  29-nov-2007 (kus)
+**      Add code for handling virtual indexes to opv_parser
 **	18-april-2008 (dougi)
 **	    Add support for table procedures.
 */
@@ -561,6 +563,67 @@
 				    ** descriptor */
 		}
 	    }
+	    
+	    /* -- Added for handling virtual indexes in optimization -- */
+	    if (grvp->opv_relation->rdr_rel->tbl_status_mask & DMT_VIRT_INDEX) 
+	    {
+	    	/* we are going to use a virtual index ... */
+	    	if (!opt_strace(global->ops_cb, OPT_F032_NOEXECUTE)) {
+	    		gbase->opv_grv[gvar] = NULL; /* deallocate
+	    		 								** variable if index cannot
+	    		 								** be found */
+
+	    		return (TRUE);  /* indicate failure to get RDF
+	    		 				** descriptor */
+	    	}
+	    	
+	    	i4	i;
+	    	for (i = 0; i < gvar; i++) {
+	    		DMT_TBL_ENTRY *tbl = gbase->opv_grv[i]->opv_relation->rdr_rel;
+    			/* 
+    			** We are looking for the corresponding base table
+    			** of the current index.
+    			*/
+	    		if (tbl->tbl_id.db_tab_base == rdfcb->rdf_rb.rdr_tabid.db_tab_base) 
+	    		{
+
+	    			i4 num_rows = tbl->tbl_record_count;
+
+	    			i4 width = gbase->opv_grv[i]->opv_relation->rdr_attr[1]->att_width;
+	    			i4 keys_per_page = grvp->opv_relation->rdr_rel->tbl_kperpage;
+	    			i4 tups_per_page = grvp->opv_relation->rdr_rel->tbl_tperpage;
+	    			i4 keys_per_leaf = grvp->opv_relation->rdr_rel->tbl_kperleaf;
+	    			grvp->opv_relation->rdr_rel->tbl_record_count = num_rows;
+	    			
+	    			grvp->opv_relation->rdr_rel->tbl_i_fill_factor = 80;
+	    			grvp->opv_relation->rdr_rel->tbl_d_fill_factor = 80;
+	    			
+	    			/* NOTE: this holds for B-trees only! */
+	    			i4 leaf_pages = num_rows / keys_per_leaf;
+	    			i4 remainder = num_rows % keys_per_leaf;
+	    			
+	    			i4 data_pages = leaf_pages * keys_per_leaf / tups_per_page;
+	    			if (remainder > 0) {
+	    				leaf_pages++;
+	    				data_pages += remainder / tups_per_page;
+	    			}
+	    			
+	    			i4 sprig_pages = 0;
+	    			if (leaf_pages > keys_per_page)
+	    				sprig_pages = leaf_pages / keys_per_page;
+	    			
+	    			i4 index_pages = 0;
+	    			i4 x = sprig_pages;
+	    			do {
+	    				x /= keys_per_page; index_pages++;
+	    			} while (x > keys_per_page);
+	    			
+	    			grvp->opv_relation->rdr_rel->tbl_page_count =
+	    				data_pages + leaf_pages + sprig_pages + index_pages;
+	    		}
+	    	}
+	    }
+	    
             BTset( (i4)gvar, (char *)&global->ops_rangetab.opv_mrdf); /* indicate
                                             ** that RDF information is fixed */
 

Modified: branches/advisor/src/back/psf/hdr/pshparse.h
===================================================================
--- branches/advisor/src/back/psf/hdr/pshparse.h	2008-07-15 19:25:22 UTC (rev 159)
+++ branches/advisor/src/back/psf/hdr/pshparse.h	2008-07-16 15:08:25 UTC (rev 160)
@@ -4756,6 +4756,8 @@
 **	    Add offset_n for result offset clause.
 **	26-oct-2007 (dougi)
 **	    Add dynqp_comp for cached dynamic query plans.
+**  29-nov-2007 (kus)
+**      Add virtual flag to PSS_YYVARS
 **	8-feb-2008 (dougi)
 **	    Add save_psq_mode for derived table processing.
 **	19-march-2008 (dougi)
@@ -5181,6 +5183,7 @@
 				** saved copy of psq_mode while performing 
 				** constraint with clause processing
 				*/
+    bool		virtual;     /* TRUE - if virtual object */
     bool	   unique;	/* parallel index project */
     bool	    inconstraint; /* TRUE - if compiling constraint def */
     bool	    in_orderby; /* TRUE - compiling order by clause */
@@ -5850,6 +5853,7 @@
 	PSS_SESBLK	*sess_cb,
 	PSS_WITH_CLAUSE *with_clauses,
 	i4		unique,
+	i4		virtual,
 	DB_ERROR	*err_blk);
 FUNC_EXTERN DB_STATUS
 psl_ci2_index_prefix(

Modified: branches/advisor/src/back/psf/psl/pslgram.yi
===================================================================
--- branches/advisor/src/back/psf/psl/pslgram.yi	2008-07-15 19:25:22 UTC (rev 159)
+++ branches/advisor/src/back/psf/psl/pslgram.yi	2008-07-16 15:08:25 UTC (rev 160)
@@ -3994,7 +3994,7 @@
     {
 	DB_STATUS		status;
 
-	status = psl_ci1_create_index(cb, &$Ywith_clauses, $Yunique,
+	status = psl_ci1_create_index(cb, &$Ywith_clauses, $Yunique,FALSE,
 					&psq_cb->psq_error);
 	if (DB_FAILURE_MACRO(status))
 	    return(status);

Modified: branches/advisor/src/back/psf/psl/pslindx.c
===================================================================
--- branches/advisor/src/back/psf/psl/pslindx.c	2008-07-15 19:25:22 UTC (rev 159)
+++ branches/advisor/src/back/psf/psl/pslindx.c	2008-07-16 15:08:25 UTC (rev 160)
@@ -146,6 +146,9 @@
 **	24-Jan-2004 (schka24)
 **	    with compression=(key) can come thru for constraint now too;
 **	    changes for partitioned tables project.
+**  29-nov-2007 (kus)
+**      Modify the psl_ci1_create_index function for taking VIRTUAL
+**      into account.
 */
 		
 static DB_STATUS psl_validate_rtree(
@@ -173,6 +176,8 @@
 **	sess_cb		    ptr to a PSF session CB
 **	    pss_lang	    query language
 **	with_clauses	    map of options specified with this statement
+**  unique              TRUE if the index is unique
+**  virtual             TRUE if the index is only virtual
 **
 ** Outputs:
 **     err_blk		    will be filled in if an error was encountered
@@ -209,12 +214,15 @@
 **	    add that DMU characteristic.
 **	23-Nov-2005 (kschendel)
 **	    Need to validate allocation= since scanning time can't.
+**  29-nov-2007 (kus)
+**      Add the virtual flag for virtual indexes.
 */
 DB_STATUS
 psl_ci1_create_index(
 	PSS_SESBLK	*sess_cb,
 	PSS_WITH_CLAUSE *with_clauses,
 	i4		unique,
+	i4		virtual,
 	DB_ERROR	*err_blk)
 {
     QEU_CB		    *qeu_cb;
@@ -291,6 +299,10 @@
 	}
     }
 
+    chr->char_id = DMU_VIRTUAL;
+    chr->char_value = virtual ? DMU_C_ON : DMU_C_OFF;
+    chr++;
+    
     if (!sstruct && !dcomp && !icomp)
     {
 	i4		compressed;

Modified: branches/advisor/src/back/psf/psl/pslsgram.yi
===================================================================
--- branches/advisor/src/back/psf/psl/pslsgram.yi	2008-07-15 19:25:22 UTC (rev 159)
+++ branches/advisor/src/back/psf/psl/pslsgram.yi	2008-07-16 15:08:25 UTC (rev 160)
@@ -3133,7 +3133,9 @@
 **        error message to say this is not supported.
 **	22-Nov-2007 (smeke01) b110870
 **	    Allow column names that start with 'ii' to be used in internal 
-**	    db procedures built by the system to support constraints. 
+**	    db procedures built by the system to support constraints.
+**  29-nov-2007 (kus)
+**      Add keyword VIRTUAL in support of virtual indexes.
 **	14-dec-2007 (dougi)
 **	    Changes to support parameterized first/offset "n" values.
 **	26-Dec-2007 (kiria01) SIR119658
@@ -4087,7 +4089,7 @@
 
 %token              UNCOMMITTED UNION UNIQUE UNTIL UPDATE USER USING
 
-%token		    VALUES VIEW
+%token		    VALUES VIEW VIRTUAL
 
 %token		    WHEN WHERE WHILE WITH WORK WRITE
 
@@ -4174,7 +4176,7 @@
 %type   <psl_tytype>  in symmetric between setlockkey
 %type   <psl_tytype>  alm_priv_spec tbl_priv_obj_spec user_role_auth_list
 %type	<psl_tytype>  grant_auth_spec rev_auth_spec alm_cond_spec alm_auth_spec
-%type	<psl_tytype>  asc_desc bin_op index_unique m_asc_desc sign_op
+%type	<psl_tytype>  asc_desc bin_op index_unique index_virtual m_asc_desc sign_op
 %type	<psl_tytype>  union cdbp_noise cdbp_parmmode subsel_pred_qualifier
 %type	<psl_tytype>  crl_tbl_when crl_ref_clause crl_tbl_with_clause
 %type	<psl_tytype>  crl_tbl_row_or_stmt
@@ -4846,6 +4848,7 @@
     {
 	DB_STATUS	status;
 	i4		unique = FALSE;
+	i4		virtual = FALSE;
 	i4		err_code;
 
 	/* cannot specify 2 unique options */
@@ -4866,16 +4869,19 @@
 	    unique = TRUE;
 	else
 	    unique = $7;
+	    
+	if ($Yvirtual)
+		virtual = TRUE;
 
 	/* Now dmu_cb char_id must be fixed up for unique indexes */
-	status = psl_ci1_create_index(cb, &$Ywith_clauses, unique,
+	status = psl_ci1_create_index(cb, &$Ywith_clauses, unique, virtual,
 					&psq_cb->psq_error);
 	if (DB_FAILURE_MACRO(status))
 	    return(status);
     }
 ;
 
-index_prefix:	    CREATE index_unique INDEX
+index_prefix:	    CREATE index_virtual index_unique INDEX
     {
 	DB_STATUS		status;
 
@@ -4886,7 +4892,8 @@
 	psq_cb->psq_mode = PSQ_INDEX;
 	cb->pss_object = (PTR) 0;
 	cb->pss_save_qeucb = (PTR) 0;
-	$Yunique = $2;
+	$Yvirtual = $2;
+	$Yunique = $3;
         
 	/*
 	** next we will be parsing the name of the new index; we are trying to
@@ -4897,6 +4904,16 @@
     }
 ;
 
+index_virtual:      VIRTUAL
+    {
+       $$ = TRUE;
+    }
+           |
+    {
+       $$ = FALSE;
+    }
+;
+
 index_unique:	    UNIQUE
     {
 	$$ = TRUE;

Modified: branches/advisor/src/back/psf/psl/pslsscan.c
===================================================================
--- branches/advisor/src/back/psf/psl/pslsscan.c	2008-07-15 19:25:22 UTC (rev 159)
+++ branches/advisor/src/back/psf/psl/pslsscan.c	2008-07-16 15:08:25 UTC (rev 160)
@@ -468,6 +468,8 @@
 **	    Added FREE LOCATOR.
 **	18-july-2007 (dougi)
 **	    Added OFFSET & tidied date/time constants.
+**  29-nov-2007 (kus)
+**      Add VIRTUAL keyword.
 **	21-dec-2007 (dougi)
 **	    Added cache_dynamic to set options.
 **	3-march-2008 (dougi)
@@ -725,10 +727,11 @@
                 131, 'p', 'r', 'i', 'm', 'a', 'r', 'y', 0,
 		177, 'r', 'e', 's', 't', 'a', 'r', 't', 0,
                 125, 's', 'e', 's', 's', 'i', 'o', 'n', 0,
+                204, 'v', 'i', 'r', 't', 'u', 'a', 'l', 0,
 		192, 'w', 'i', 't', 'h', 'o', 'u', 't', 0,
-/* 1033 */         0,
+/* 1042 */         0,
                  /* Keywords of length 8 */
-/* 1034 */       115, 'c', 'a', 'l', 'l', 'p', 'r', 'o', 'c', 0,
+/* 1043 */       115, 'c', 'a', 'l', 'l', 'p', 'r', 'o', 'c', 0,
 		185, 'c', 'o', 'a', 'l', 'e', 's', 'c', 'e', 0,
                  90, 'c', 'o', 'n', 't', 'i', 'n', 'u', 'e', 0,
                  91, 'd', 'e', 's', 'c', 'r', 'i', 'b', 'e', 0,
@@ -744,9 +747,9 @@
 		106, 'r', 'e', 'p', 'e', 'a', 't', 'e', 'd', 0,
                  127,'r', 'e', 's', 't', 'r', 'i', 'c', 't', 0,
                  93, 'r', 'o', 'l', 'l', 'b', 'a', 'c', 'k', 0,
-/* 1194 */         0,
+/* 1203 */         0,
                  /* Keywords of length 9 */
-/* 1195 */      145, 'c', 'o', 'm', 'm', 'i', 't', 't', 'e', 'd', 0,
+/* 1204 */      145, 'c', 'o', 'm', 'm', 'i', 't', 't', 'e', 'd', 0,
                 141, 'c', 'o', 'p', 'y', '_', 'f', 'r', 'o', 'm', 0,
                 142, 'c', 'o', 'p', 'y', '_', 'i', 'n', 't', 'o', 0,
 		158, 'e', 'n', 'd', 'r', 'e', 'p', 'e', 'a', 't', 0,
@@ -761,9 +764,9 @@
 		161, 's', 'u', 'b', 's', 't', 'r', 'i', 'n', 'g', 0,
 		187, 's', 'y', 'm', 'm', 'e', 't', 'r', 'i', 'c', 0,
                 119, 't', 'e', 'm', 'p', 'o', 'r', 'a', 'r', 'y', 0,
-/* 1360 */         0,
+/* 1369 */         0,
                  /* Keywords of length 10 */
-/* 1361 */	188, 'a', 's', 'y', 'm', 'm', 'e', 't', 'r', 'i', 'c', 0,
+/* 1370 */	188, 'a', 's', 'y', 'm', 'm', 'e', 't', 'r', 'i', 'c', 0,
 		134, 'c', 'o', 'n', 's', 't', 'r', 'a', 'i', 'n', 't', 0,
 	        198, 'l', 'o', 'c', 'a', 'l', '_', 't', 'i', 'm', 'e', 0,
 		181, 'n', 'o', 'm', 'a', 'x', 'v', 'a', 'l', 'u', 'e', 0,
@@ -771,33 +774,33 @@
                  95, 'p', 'r', 'i', 'v', 'i', 'l', 'e', 'g', 'e', 's', 0,
                 133, 'r', 'e', 'f', 'e', 'r', 'e', 'n', 'c', 'e', 's', 0,
                 147, 'r', 'e', 'p', 'e', 'a', 't', 'a', 'b', 'l', 'e', 0,
-/* 1457 */       0,
+/* 1466 */       0,
                  /* Keywords of length 11 */
-/* 1458 */      104,'r','e','f','e','r','e','n','c','i','n','g',0,
+/* 1467 */      104,'r','e','f','e','r','e','n','c','i','n','g',0,
                 137,'s','y','s','t','e','m','_','u','s','e','r',0,
                 148,'u','n','c','o','m','m','i','t','t','e','d',0,
-/* 1497 */       0,
+/* 1506 */       0,
                  /* Keywords of length 12 */
-/* 1498 */	195,'c','u','r','r','e','n','t','_','d','a','t','e',0,
+/* 1507 */	195,'c','u','r','r','e','n','t','_','d','a','t','e',0,
 	        196,'c','u','r','r','e','n','t','_','t','i','m','e',0,
 		135,'c','u','r','r','e','n','t','_','u','s','e','r',0,
                 138,'i','n','i','t','i','a','l','_','u','s','e','r',0,
                 149,'s','e','r','i','a','l','i','z','a','b','l','e',0,
                 139,'s','e','s','s','i','o','n','_','u','s','e','r',0,
-/* 1582 */       0,
+/* 1591 */       0,
                  /* Keywords of length 13 */
-/* 1583 */       98, 'a','u','t','h','o','r','i','z','a','t','i','o','n',0,
-/* 1598 */       0,
+/* 1592 */       98, 'a','u','t','h','o','r','i','z','a','t','i','o','n',0,
+/* 1607 */       0,
 		 /* Keywords of length 15 */
-/* 1599 */      199,'l','o','c','a','l','_','t','i','m','e','s','t','a','m',
+/* 1608 */      199,'l','o','c','a','l','_','t','i','m','e','s','t','a','m',
 		    'p',0,
-/* 1616 */	 0,
+/* 1625 */	 0,
 		 /* Keywords of length 17 */
-/* 1617 */      197,'c','u','r','r','e','n','t','_','t','i','m','e','s','t','a',
+/* 1626 */      197,'c','u','r','r','e','n','t','_','t','i','m','e','s','t','a',
 		    'm','p',0,
 		154,'s','y','s','t','e','m','_','m','a','i','n','t','a','i','n',
 		    'e','d',0,
-/* 1655 */	 0
+/* 1664 */	 0
                  };
 
 /*
@@ -818,16 +821,16 @@
                                   &Key_string[305], /* Keywords of length 5 */
                                   &Key_string[537], /* Keywords of length 6 */
                                   &Key_string[826], /* Keywords of length 7 */
-                                  &Key_string[1034],/* Keywords of length 8 */
-                                  &Key_string[1195],/* Keywords of length 9 */
-                                  &Key_string[1361],/* Keywords of length 10 */
-                                  &Key_string[1458],/* Keywords of length 11 */
-                                  &Key_string[1498],/* Keywords of length 12 */
-                                  &Key_string[1583],/* Keywords of length 13 */
+                                  &Key_string[1043],/* Keywords of length 8 */
+                                  &Key_string[1204],/* Keywords of length 9 */
+                                  &Key_string[1370],/* Keywords of length 10 */
+                                  &Key_string[1467],/* Keywords of length 11 */
+                                  &Key_string[1507],/* Keywords of length 12 */
+                                  &Key_string[1592],/* Keywords of length 13 */
                                   &Key_string[0],   /* Keywords of length 14 */
-                                  &Key_string[1599],/* Keywords of length 15 */
+                                  &Key_string[1608],/* Keywords of length 15 */
                                   &Key_string[0],   /* Keywords of length 16 */
-                                  &Key_string[1617],/* Keywords of length 17 */
+                                  &Key_string[1626],/* Keywords of length 17 */
                                   &Key_string[0],   /* Keywords of length 18 */
                                   &Key_string[0],   /* Keywords of length 19 */
                                   &Key_string[0],   /* Keywords of length 20 */
@@ -1545,7 +1548,9 @@
 /* 200 */      	       { INTERVAL,	    0,	0,	(SECONDARY *) NULL   },
 /* 201 */	       { SCROLL,	    0,	0,	(SECONDARY *) NULL   },
 /* 202 */	       {/* FREE */ 	    0,  0,FREESIZE,(SECONDARY*)Freewords},
-/* 203 */	       { OFFSET,	    0,	0,	(SECONDARY *) NULL   }
+/* 203 */	       { OFFSET,	    0,	0,	(SECONDARY *) NULL   },
+/* 204 */             { VIRTUAL,           0,  0,      (SECONDARY *) NULL   }
+
 };
 
 /* Alternate keyword lists for inside WITH parsing (specifically, when

Modified: branches/advisor/src/back/scf/hdr/scmonitor.h
===================================================================
--- branches/advisor/src/back/scf/hdr/scmonitor.h	2008-07-15 19:25:22 UTC (rev 159)
+++ branches/advisor/src/back/scf/hdr/scmonitor.h	2008-07-16 15:08:25 UTC (rev 160)
@@ -103,7 +103,6 @@
 	i4		selects_processed;
 	i4		qsf_memleft;
 	i4		qsf_memtot;
-	i4		time;
 }   ESQL_SCM_STATISTICS;
 
 

Modified: branches/advisor/src/back/scf/scm/scmonitor.sc
===================================================================
--- branches/advisor/src/back/scf/scm/scmonitor.sc	2008-07-15 19:25:22 UTC (rev 159)
+++ branches/advisor/src/back/scf/scm/scmonitor.sc	2008-07-16 15:08:25 UTC (rev 160)
@@ -83,7 +83,7 @@
 /* How long do we sleep between wake-ups? */
 #define		SLEEP		30000
 /* How often do we wake up until we store data in workload DB? */
-#define		ROUNDS		10
+#define		ROUNDS		5
 /* How often do we store until we delete old entries from the workload DB? */
 #define		DELOLD		5
 /* And how old are the entries we delete (in seconds) */
@@ -984,6 +984,10 @@
         if (i == scm->cur_sts_idx - 1) 
         {
         	statistics.current_connections = scm->statistics[i].current_connections;
+        	statistics.total_rows = scm->statistics[i].total_rows;
+        	statistics.selects_processed = scm->statistics[i].selects_processed;
+        	statistics.qsf_memleft = scm->statistics[i].qsf_memleft;
+        	statistics.qsf_memtot = scm->statistics[i].qsf_memtot;
         	STprintf(statistics.server, scm->statistics[i].server);
         }
 	}

Modified: branches/advisor/src/front/st/vdba/makimau.sql
===================================================================
--- branches/advisor/src/front/st/vdba/makimau.sql	2008-07-15 19:25:22 UTC (rev 159)
+++ branches/advisor/src/front/st/vdba/makimau.sql	2008-07-16 15:08:25 UTC (rev 160)
@@ -2478,8 +2478,7 @@
     qsf_memleft integer4 not null not default
         is 'exp.qsf.qsr.qsr_memleft',
     qsf_memtot integer4 not null not default
-        is 'exp.qsf.qsr.qsr_memtot',
-
+        is 'exp.qsf.qsr.qsr_memtot'
 )
 as import from 'tables'
 with dbms = IMA,




More information about the svn-commits mailing list