Dear all,

I'm currently working on my thesis and I chose psql. What I need to do
is defining a new type in psql.

It should be dynamic array.

| 1 | 2 | 3.0 | 4.5 | 2.1 |  . .. . .


// This one is not working
typedef struct Myindex {
	double *indexes;
	int level;
	int size;
} Myindex

Myindex *
Myindex_in {

}

Myindex *
Myindex_out {
	However when I try to get back the data. It seems that the last
	insertion always overwrite other previous insertion.
	In particular, it overwrites all data from 2nd to n-1th record.
	where n is the number of insertion but not the first one.
}


// This one work ok but the idea is to have dynamic array.
// This would defeat the purpose of this new structure.

typedef struct Myindex {
        double indexes[10];
        int level;
        int size;
} Myindex;


Standalone debuging works for both cases.
However psql accepts only the static array.


Could anybody enlight me on this issue, please


regards,
Van


Tue, 10 Sep 2002 12:23:45 +1000 (EST)
Vanmunin Chea <vac@cse.unsw.EDU.AU>
If there a bug in the psql or just a feature . 
Vanmunin Chea <vac@cse.unsw.EDU.AU> writes:
> // This one is not working
> typedef struct Myindex {
> 	double *indexes;
> 	int level;
> 	int size;
> } Myindex

You cannot use a pointer inside a Postgres datatype.  The system will
have no idea that the pointer is there and so will not copy the
pointed-to data, nor update the pointer, when the datum is copied,
stored on disk, etc.

			regards, tom lane

Tue, 10 Sep 2002 11:10:42 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: If there a bug in the psql or just a feature . 
Hey Tom,

	Thanks for the tips, Tom. I have that feeling from the start
(with the two different implementation) but never actually have a chance
to confirm with someone.

1. It there a way to store the dynamic array at all ?


	I notice psql has a similar type - Single Dynamic Dimensional
Array. However there isn't any built in operators(<,<=,==,>,>=) for Array
to do sorting.

2. Can I write one up ?


regards,
Van.



On Tue, 10 Sep 2002, Tom Lane wrote:

> Vanmunin Chea <vac@cse.unsw.EDU.AU> writes:
> > // This one is not working
> > typedef struct Myindex {
> > 	double *indexes;
> > 	int level;
> > 	int size;
> > } Myindex
>
> You cannot use a pointer inside a Postgres datatype.  The system will
> have no idea that the pointer is there and so will not copy the
> pointed-to data, nor update the pointer, when the datum is copied,
> stored on disk, etc.
>
> 			regards, tom lane
>

Vanmunin Chea


Wed, 11 Sep 2002 01:22:40 +1000 (EST)
Vanmunin Chea <vac@cse.unsw.EDU.AU>
Re: If there a bug in the psql or just a feature . 
On Tue, 2002-09-10 at 17:22, Vanmunin Chea wrote:
> Hey Tom,
> 
> 	Thanks for the tips, Tom. I have that feeling from the start
> (with the two different implementation) but never actually have a chance
> to confirm with someone.
> 
> 1. It there a way to store the dynamic array at all ?
> 
> 
> 	I notice psql has a similar type - Single Dynamic Dimensional
> Array. However there isn't any built in operators(<,<=,==,>,>=) for Array
> to do sorting.
> 
> 2. Can I write one up ?

See attachment.

Unfortunately I ran out of time before figuring out how to make btree
index use it ;(

Also, in 7.3 there are a lot more ops for in contrib/intarray than was
in 7.2.

-------------
Hannu
17 Sep 2002 10:16:54 +0200
Hannu Krosing <hannu@tm.ee>
Re: If there a bug in the psql or just a feature .