pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedFind out if a parameter/return field is NULLABLE using Describe
3+ messages / 3 participants
[nested] [flat]
* Find out if a parameter/return field is NULLABLE using Describe
@ 2006-01-30 20:38 Richard Jones <rich@annexia.org>
0 siblings, 1 reply; 3+ messages in thread
From: Richard Jones @ 2006-01-30 20:38 UTC (permalink / raw)
To: pgsql-interfaces
It doesn't seem to be possible to find out if a parameter or result
field is nullable using the Describe protocol.
For example if I have this table and statement:
create table employees (
id serial not null primary key,
name text not null,
email text <-- this field
);
insert into employees (name, email) values ($1, $2);
Then the only information I get back about $2 is that it's a TEXT (OID
= 25), when clearly $1 and $2 are different in that one is nullable
and the other isn't.
Similarly,
select name, email from employees;
This time I get more information about the types, including a modifier
and length, but I can't see whether that lets me find out that one
could be NULL and the other can never be.
So is this possible?
Rich.
--
Richard Jones, CTO Merjis Ltd.
Merjis - web marketing and technology - http://merjis.com
Team Notepad - intranets and extranets for business - http://team-notepad.com
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Find out if a parameter/return field is NULLABLE using Describe
@ 2006-01-30 22:11 Tom Lane <tgl@sss.pgh.pa.us>
parent: Richard Jones <rich@annexia.org>
0 siblings, 1 reply; 3+ messages in thread
From: Tom Lane @ 2006-01-30 22:11 UTC (permalink / raw)
To: Richard Jones <rich@annexia.org>; +Cc: pgsql-interfaces
Richard Jones <rich@annexia.org> writes:
> It doesn't seem to be possible to find out if a parameter or result
> field is nullable using the Describe protocol.
This isn't something that the backend tracks at all, so changing the
wire protocol would be the least of your problems in making it happen...
regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Find out if a parameter/return field is NULLABLE
@ 2006-01-30 23:37 Kris Jurka <books@ejurka.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 3+ messages in thread
From: Kris Jurka @ 2006-01-30 23:37 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Richard Jones <rich@annexia.org>; pgsql-interfaces
On Mon, 30 Jan 2006, Tom Lane wrote:
> Richard Jones <rich@annexia.org> writes:
>> It doesn't seem to be possible to find out if a parameter or result
>> field is nullable using the Describe protocol.
>
> This isn't something that the backend tracks at all, so changing the
> wire protocol would be the least of your problems in making it happen...
>
Well, the protocol does attempt to return the resulting columns' source
table and column number which may then be used to determine the
nullability of the field. This won't work in all cases, but for the
simple select example given, it will.
Kris Jurka
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2006-01-30 23:37 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-01-30 20:38 Find out if a parameter/return field is NULLABLE using Describe Richard Jones <rich@annexia.org>
2006-01-30 22:11 ` Tom Lane <tgl@sss.pgh.pa.us>
2006-01-30 23:37 ` Re: Find out if a parameter/return field is NULLABLE Kris Jurka <books@ejurka.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox