Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1abU6E-0004VA-ES for pgsql-sql@arkaria.postgresql.org; Thu, 03 Mar 2016 14:19:30 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1abU6D-00044y-RR for pgsql-sql@arkaria.postgresql.org; Thu, 03 Mar 2016 14:19:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1abU6B-00042t-BH for pgsql-sql@postgresql.org; Thu, 03 Mar 2016 14:19:27 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1abU63-0004C7-UA for pgsql-sql@postgresql.org; Thu, 03 Mar 2016 14:19:26 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id BC9F72200F for ; Thu, 3 Mar 2016 09:19:17 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute6.internal (MEProxy); Thu, 03 Mar 2016 09:19:17 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=aklaver.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=ucraV7S11yMYlp9wWnMjqpUkz+8=; b=c1mwC3 JQT+HZ6U2pXXWBNpujKz14vdx/6fJDLu34pL7WJzPizSYSaGtk4soT1G8yG3ja1B 38FZij91IHcnF94wL2xnjJN7ijtE/JFEwQi1SId0wr+2hH/58aTlnrNZy9ew8tUe th07AW+hGk9ix6Wvtickr2m7L1BbQY06MPvgY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=ucraV7S11yMYlp9 wWnMjqpUkz+8=; b=aclAGn+sSW1abNFXKVykl9ykHeh+88z+DMFzIKeEnKp+2c5 lAkLwLtD51kAgehRl8HI0pgYqG+Nqt8KdH4tNsYbGH6VMbz2Tv5wXj7JRwtRjZM7 jg2FBJ7Qjww+HZJ4Eohx2mhi7PzNwwuAFyUNIGIF8u50QNhjGw0ZoVcIC9lA= X-Sasl-enc: dCVfpR65c1b8+MpwhhRWIusdO70bD4WGs0e8Ba+MpaGg 1457014757 Received: from [192.168.1.2] (174-21-70-246.tukw.qwest.net [174.21.70.246]) by mail.messagingengine.com (Postfix) with ESMTPA id 24095C00016; Thu, 3 Mar 2016 09:19:17 -0500 (EST) Subject: Re: Query about foreign key details for php framework To: David Binney , pgsql-sql@postgresql.org References: <56CFA136.4000508@aklaver.com> <56CFA4E1.8040204@aklaver.com> <56CFC24A.6030508@aklaver.com> <56D06C02.5040107@aklaver.com> <56D0C4B8.7020200@aklaver.com> <56D1BEA6.5020707@aklaver.com> <56D45C99.4060008@aklaver.com> <56D6FF29.1000309@aklaver.com> <56D77B18.9080008@aklaver.com> From: Adrian Klaver Message-ID: <56D84796.9070104@aklaver.com> Date: Thu, 3 Mar 2016 06:17:58 -0800 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org 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 > 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 > > -- > 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