problem with arrays

Started by Massimo Dal Zottoabout 27 years ago2 messages
#1Massimo Dal Zotto
dz@cs.unitn.it

Hi,

I'm trying to convert some tables from version 6.2 to 6.4.2 but I have
problems with arrays. The old table definition was:

create table a (
x int4,
y char8,
z char8[]
);

Now, because the char8 datatype has been removed from postgres, I suppose
I should use char(8) or varchar(8):

create table a (
x int4,
y char(8),
z char(8)[]
);

or

create table a (
x int4,
y varchar(8),
z varchar(8)[]
);

but when I try the above definitions I get the following errors:

dz=> create table a (
dz-> x int4,
dz-> y char(8),
dz-> z char(8)[]
dz-> );
ERROR: type name lookup of _bpchar failed

dz=> create table a (
dz-> x int4,
dz-> y varchar(8),
dz-> z varchar(8)[]
dz-> );
ERROR: type name lookup of _varchar failed

Also trying to define the _varchar or _bpchar types fails, so it seems that
the conversion from 6.2 to 6.4 is not possible for many data types.
Any suggestion?

--
Massimo Dal Zotto

+----------------------------------------------------------------------+
|  Massimo Dal Zotto               email: dz@cs.unitn.it               |
|  Via Marconi, 141                phone: ++39-0461534251              |
|  38057 Pergine Valsugana (TN)      www: http://www.cs.unitn.it/~dz/  |
|  Italy                             pgp: finger dz@tango.cs.unitn.it  |
+----------------------------------------------------------------------+
#2Thomas G. Lockhart
lockhart@alumni.caltech.edu
In reply to: Massimo Dal Zotto (#1)
Re: [HACKERS] problem with arrays

Also trying to define the _varchar or _bpchar types fails, so it seems
that the conversion from 6.2 to 6.4 is not possible for many data
types. Any suggestion?

That sucks. afaik the only data types affected are the fixed-maximum
with variable-length strings. There was a comment in gram.y from Jolly
regarding the possibility for allowing bpchar and varchar into arrays,
though she explicitly disallowed it. I had thought that this code is
still in effect.

I'm not certain how much you have looked at this, but the leading
underscore is a Postgres convention for array data types. The trick to
allowing bpchar, varchar, and perhaps numeric types into arrays is
passing along the element dimensions. I haven't looked at whether that
already happens.

In the meantime, you can try using the text type instead. I know it
doesn't have an 8-byte maximum length, but it is allowed in arrays...

- Tom