agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: David Binney <donkeysoft@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Re: Query about foreign key details for php framework
Date: Thu, 3 Mar 2016 06:17:58 -0800
Message-ID: <56D84796.9070104@aklaver.com> (raw)
In-Reply-To: <CAN123gkeQX03CXonj7OTyW4cSB4W73kLTQC9K4zWyV2sMgmr2g@mail.gmail.com>
References: <CAN123gmPUc2vutkE+H0FyPJSyf+xkHam2yuiGC2U8BTin6kaOA@mail.gmail.com>
	<56CFA136.4000508@aklaver.com>
	<CAN123gnvg5fC-SOBRwYT+eK6AOzfNU2+K4+AqjqJgPi9-Kh8Pw@mail.gmail.com>
	<56CFA4E1.8040204@aklaver.com>
	<CAN123gn7AL2mSpZitFb5bvF7VCbn0fVVv4qenyQj472P4AxdpQ@mail.gmail.com>
	<56CFC24A.6030508@aklaver.com>
	<CAN123g=5BbeEUz=q7w3_KdYZgirSxBL57V45sh4Aa5E3HCZ+Aw@mail.gmail.com>
	<56D06C02.5040107@aklaver.com>
	<CAN123gkwOujiAO3pwLqtouitTi0ai1J75iF1tNgfx6Hrrxh-=w@mail.gmail.com>
	<56D0C4B8.7020200@aklaver.com>
	<CAN123gkXG6eMuAUnGzJiTzHO7J-PLUACR=pP2xd3bD-d5r_8jw@mail.gmail.com>
	<56D1BEA6.5020707@aklaver.com>
	<CAN123gkuC7AwEqa2+xCEViAFF58J18YeZDJfingx6a7Sf5L3eg@mail.gmail.com>
	<56D45C99.4060008@aklaver.com>
	<CAN123gmFAMdSVggkdg2-XMss6qmAALfhuMS8wdMqM4mpK7408A@mail.gmail.com>
	<56D6FF29.1000309@aklaver.com>
	<CAN123g=c--WL3e8G+ZaATuJusGvDa38Jwu2NMRWJx_vBg24SOQ@mail.gmail.com>
	<56D77B18.9080008@aklaver.com>
	<CAN123gkeQX03CXonj7OTyW4cSB4W73kLTQC9K4zWyV2sMgmr2g@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>

On 03/02/2016 05:59 PM, David Binney wrote:
> Hey Adrian,
>
> Dude you are a legend. I have attempted to mod the query to use just
> those tables and i think its ok just need confirmation. It would be nice
> if it had the full text descriptors but I can always use a case to fix
> it up if necessary.

I can confirm it works and returns values. Since I am not entirely sure 
what the framework needs I cannot go any further then that.

>
> SELECT  c.conrelid::regclass::text AS table_name,
>          c.contype AS constraint_type, --c = check constraint, f =
> foreign key constraint, p = primary key constraint, u = unique
> constraint, t = constraint trigger, x = exclusion constraint
>          a.attname AS column_name,
>          c.confmatchtype AS match_type, --f = full, p = partial, s = simple
>          c.confupdtype AS on_update, --a = no action, r = restrict, c =
> cascade, n = set null, d = set default
>          c.confdeltype AS on_delete,  --a = no action, r = restrict, c =
> cascade, n = set null, d = set default
>          c.confrelid::regclass AS references_table,
>          ab.attname AS references_field
> FROM pg_catalog.pg_constraint c, pg_catalog.pg_attribute a,
> pg_catalog.pg_attribute ab
> WHERE conrelid::regclass = a.attrelid::regclass
> AND conkey[1] = a.attnum
> AND a.attrelid = ab.attrelid
> AND a.attnum = ab.attnum
> AND c.conrelid = 'products'::regclass
> AND c.contype='f';
>
>
>
> On Thu, 3 Mar 2016 at 09:46 Adrian Klaver <adrian.klaver@aklaver.com
> <mailto:adrian.klaver@aklaver.com>> wrote:
>
>     On 03/02/2016 03:42 PM, David Binney wrote:
>      > Nice find dude and that should work joined to the other tables
>     ;). Once
>      > more thing, is there a matching conversion table for the human
>     readable
>      > result "a = no action" or will i have to "case" that stuff?
>
>     Not that I know of.
>
>
>
>
>     --
>     Adrian Klaver
>     adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>
>
> --
> Cheers David Binney


-- 
Adrian Klaver
adrian.klaver@aklaver.com


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



view thread (30+ messages)

Message-ID: <56D84796.9070104@aklaver.com>
Permalink:  ../56D84796.9070104@aklaver.com/
Also on:    postgresql.org/message-id/56D84796.9070104@aklaver.com

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: adrian.klaver@aklaver.com, donkeysoft@gmail.com
  Subject: Re: Query about foreign key details for php framework
  In-Reply-To: <56D84796.9070104@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox