Re: [HACKERS] Dumb question: How do I determine programmatically

2004-01-07 Thread Andreas Pflug
Dann Corbit wrote:

What API call can I make to find out if a column is nullable or not?
 
SELECT attnotnull FROM pg_attribute ...
see documentation Internals/System Catalogs
Regards,
Andreas


---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


Re: [HACKERS] Dumb question: How do I determine programmatically if a column is nullable?

2004-01-07 Thread Dann Corbit
 -Original Message-
 From: Andreas Pflug [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, January 07, 2004 11:17 AM
 To: Dann Corbit
 Cc: [EMAIL PROTECTED]
 Subject: Re: [HACKERS] Dumb question: How do I determine 
 programmatically if a column is nullable?
 
 
 Dann Corbit wrote:
 
  What API call can I make to find out if a column is nullable or not?
   
 
 SELECT attnotnull FROM pg_attribute ...
 see documentation Internals/System Catalogs

Is there a way do do it when I have some arbitrary query that returns a
result set?

In other words, I will be passed a SQL query.  I don't want to have to
parse it myself.

Rather, I want to know (for the bound columns) if a column is nullable
or not.

Is the functionality available in [for example] libpq?

---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if your
  joining column's datatypes do not match


Re: [HACKERS] Dumb question: How do I determine programmatically if a column is nullable?

2004-01-07 Thread Tom Lane
Dann Corbit [EMAIL PROTECTED] writes:
 In other words, I will be passed a SQL query.  I don't want to have to
 parse it myself.
 Rather, I want to know (for the bound columns) if a column is nullable
 or not.
 Is the functionality available in [for example] libpq?

As of 7.4, see PQftable() and PQftablecol(), and look into pg_attribute
to see whether the column is marked NOTNULL.

regards, tom lane

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly