Return-Path: pg_adm@postgres.berkeley.edu
Received: by postgres.Berkeley.EDU (5.61/1.29)
	id AA13085; Mon, 28 Sep 92 10:30:18 -0700
Date: Mon, 28 Sep 92 10:30:18 -0700
Message-Id: <9209281730.AA13085@postgres.Berkeley.EDU>
From: Philip Bailey <pbailey@ceci.mit.edu>
Subject: Retrieving multiple types of instances ??
To: postgres@postgres.berkeley.edu
Sender: pg_adm@postgres.berkeley.edu


I am trying to retrieve multiple types of instances from a Postgres
database (4.0.1).  The following leads me to believe it can be done,
but when I run a query only the 'base class' attributes are returned.

>From the LIBPQ section -- Portal Functions

" A single retrieve command can return multiple types of instances.
This can happen if a POSTGRES function is executed in the evaluation
of a query or if the query returns multiple instance types from an
inheritance hierarchy. ... "

These are my classes, PPM & VDISC are both derived from the VISUAL class,
for example:
  'create PPM (path = text) inherits VISUAL'

Class VISUAL
-----------------------------------
| name    | comment | m_type      |
-----------------------------------
  text      text      int4


Class PPM
-------------------------------------------------
| comment | name    | path        | m_type      |
-------------------------------------------------
  text      text      text          int4


Class VDISC
----------------------------------------------------------------------------
| comment | name    | start_frame | end_frame | volume | channel | m_type  |
----------------------------------------------------------------------------
  text      text      int4          int4        text     int2      int4


My test database has:
	 zero VISUAL instances
	  4   PPM    instances
          6   VDISC  instances
Note: currently no values are assigned to the m_type field.


Using the sample program 'testlibpq.c' from the ref.doc the following retrieve
is specified:
	"retrieve portal eportal (v.oid,v.all) from v in VISUAL *"

And the the actual code is as follows:

  PQexec("begin");
  PQexec("retrieve portal eportal (v.oid,v.all) from v in VISUAL *"); 
  PQexec("fetch all in eportal"); 
  p = PQparray("eportal"); 
  numt = PQntuples(p);
  g = PQngroups(p); 
  printf("Number Tuples = %d number groups = %d\n",numt,g);
  t = 0; 
  for (k=0;k<g;k++){
    printf("\nA new Instance group:\n");
    n= PQntuplesGroup(p,k);
    m = PQnfieldsGroup (p,k);
    for (i=0;i<m;i++)
      printf(" %-15s", PQfnameGroup(p,k,i));
    printf("\n");
    for (i=0;i<n;i++){   
      for (j=0;j<m;j++)
        printf(" %-15s", PQgetvalue(p,t+i,j));
      printf("\n");                     }        
    t += n;             }
  PQexec("close eportal");
  PQexec("end");


I expected to get 2 groups with different numbers of fields and attributes,
instead this is the result:

Number Tuples = 10 number groups = 1

A new Instance group:
 oid      name            	comment         m_type         
 19936    Bowl with Rabbit 	12th AD NW Iran ceramic (null)         
 19937    Lion Censer 	 	11-12th AD Iran, cast bronze (null)         
 19938    Bowl with Parrots 	Iran 12-13th AD, ceramic (null)         
 19939 	  Hippopotamus Vase 	Nagada, 4000 BC, limestone (null)
 19940    Sarcophagus of Imeneminet Egypt, 800 BC, pastboard (null)         
 19968    Winged Victory  	marble          (null)         
 20053    Trinity 64      	close-up exterior (null)         
 20054    Trinity Construction  B&W photo (null)         
 20055    Trinity 1920     	B&W photo long-shot (null)         
 20056    Trinity Inside   	B&W photo long-shot interior (null)         

Note: the 4 'Trinity' entries are the PPM instances

My questions are:

How do I get all of the attribute fields for the various derived classes? 

Is the specified functionality is implimented in this version of the code?  
	
Must I write functions to support multiple instance types?

Where would I look in the code to find this functionality, & is it possible to
make use of the 'Fast Path' features to perform these features.


Thanks,
	Phil Bailey

---- insert Standard Disclaimer ----------------------------------------------
name:    Philip H. Bailey	| Center for Educational Computing Initiatives
e-mail:  pbailey@ceci.mit.edu	| Massachusetts Institute of Technology
phone:   (617) 253-0163		| Building E40-381, 1 Amherst Street
FAX:     (617) 258-8736		| Cambridge, MA 02139-4307

	
	
