Custom integer-like type

Started by Ivan Vorasover 13 years ago2 messagesgeneral
Jump to latest
#1Ivan Voras
ivoras@freebsd.org

Hello,

I'm creating a new data in C, and everything is proceeding well, except
that the data type should be parsed on input like an integer. Maybe it's
best if I explain it with an example:

Currently, I can do this:

INSERT INTO t(my_data_type) VALUES ('1')

but I cannot do this:

INSERT INTO t(my_data_type) VALUES (1)

My type is defined as:

CREATE TYPE myint (
internallength = variable,
input = encbigint_in,
output = encbigint_out,
alignment = int4,
storage = external
);

(The "variable" length is correct in this case.)

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Ivan Voras (#1)
Re: Custom integer-like type

Ivan Voras <ivoras@freebsd.org> writes:

I'm creating a new data in C, and everything is proceeding well, except
that the data type should be parsed on input like an integer. Maybe it's
best if I explain it with an example:

Currently, I can do this:

INSERT INTO t(my_data_type) VALUES ('1')

but I cannot do this:

INSERT INTO t(my_data_type) VALUES (1)

What you'd need for that is an assignment cast from integer to myint.
Literal 1 is an integer, period; it's not going to get fed to your
type's input routine.

regards, tom lane