Page 1 of 1

PostgreSQL equivalent for mysql_field_flags

Posted: Thu Aug 09, 2007 6:47 am
by Paw
Hey folks,

I'm looking for a solution to retrieving field flag information for result set fields using PostgreSQL.
There is obviously no function available, which does the same like mysql_field_flags. So I guess a SQL query will be required.

However, I see a problem there, if the SQL query, which produced the previously mentioned result set, contained some attribute renaming:

Code: Select all

SELECT name as X FROM users
so there won't be a way to retrieve the desired field flags in every case, on the workaround route; or am I wrong?
I mainly need to know about a result set field, whether it is a primary key or not.

I hope someone knows a solution for this problem :-/


Thanks in advance!

Posted: Fri Aug 10, 2007 6:10 am
by Paw
Well, I couldn't solve my problem, but at least find information about PostgreSQL's storage locations for table constraints.
So I could create following query:

Code: Select all

SELECT column_name, constraint_type FROM information_schema.constraint_column_usage NATURAL JOIN information_schema.table_constraints WHERE table_name='table'
This returns the constraint type for each column, if a constraint is defined.