Reference by output in : \d <table_name>

From: kenneth d'souza <kd_souza(at)hotmail(dot)com>
To: <pgsql-patches(at)postgresql(dot)org>
Subject: Reference by output in : \d <table_name>
Date: 2008-02-25 06:05:31
Message-ID: BAY116-W2980A8A3B7E64E1F94CB1FED180@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches


Hi,

Refering to this request http://momjian.us/mhonarc/patches_hold/msg00022.htmlI have created a patch. The output doesn't exaclty match with what is stated here http://momjian.us/mhonarc/patches_hold/msg00023.html.
However, it does tell the required details in a similar format.

Comments?


Thanks,
Kenneth
osdb_pgarch=# \d htest Table "public.htest" Column | Type | Modifiers--------------+---------------+----------- new_id | integer | not null test_name | character(20) | test_cust_id | integer |Indexes: "htest_pkey" PRIMARY KEY, btree (new_id)Foreign-key constraints: "htest_test_cust_id_fkey" FOREIGN KEY (test_cust_id) REFERENCES customers(customer_id)Refrenced by : "htest_child_ctest_cust_id_fkey" IN public.htest_child(ctest_cust_id) REFERENCES htest(new_id) "htest_child1_ctest_cust_id_fkey" IN public.htest_child1(ctest_cust_id) REFERENCES htest(new_id)


diff describe.c_orig describe.c1109c1109,1110< *result6 = NULL;---> *result6 = NULL,> *result7 = NULL;1114a1116> refof_count = 0,1247,1248c1249,1265< footers = pg_malloc_zero((index_count + check_count + rule_count + trigger_count + foreignkey_count + inherits_count + 7 + 1)< * sizeof(*footers));---> /* reference_by count */>> printfPQExpBuffer(&buf,"SELECT c.conname,n.nspname,p2.relname,pg_catalog.pg_get_constraintdef(c.oid, true)\n"> "FROM pg_catalog.pg_class p, pg_catalog.pg_constraint c, pg_catalog.pg_class p2 \n"> ",pg_catalog.pg_namespace n WHERE p.oid = '%s' AND c.confrelid = '%s'\n"> "AND c.conrelid = p2.oid AND n.oid =p2.relnamespace", oid,oid);>> result7 = PSQLexec(buf.data, false);> if (!result7)> goto error_return;> else> refof_count = PQntuples(result7);>>> footers = pg_malloc_zero((index_count + check_count + rule_count + trigger_count + foreignkey_count + inherits_count + refof_count + 7 + 1) * sizeof(*footers));>>1483a1501,1526> /* print reference count details */> if (refof_count > 0)> {> printfPQExpBuffer(&buf, _("Refrenced by :"));> footers[count_footers++] = pg_strdup(buf.data);> for (i = 0; i < refof_count; i++)> {> const char *refbydef;> const char *usingpos;> printfPQExpBuffer(&buf, _(" \"%s\" IN %s.%s"),> PQgetvalue(result7,i,0),> PQgetvalue(result7,i,1),> PQgetvalue(result7,i,2));>> /* Everything after "FOREIGN KEY " is echoed verbatim */> refbydef = PQgetvalue(result7, i, 3);> usingpos = strstr(refbydef, "FOREIGN KEY ");> if (usingpos)> refbydef = usingpos + 12;> appendPQExpBuffer(&buf, "%s",refbydef);>> footers[count_footers++] = pg_strdup(buf.data);> }> }>

_________________________________________________________________
Tried the new MSN Messenger? It’s cool! Download now.
http://messenger.msn.com/Download/Default.aspx?mkt=en-in

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Brendan Jurd 2008-02-25 06:23:10 Re: Reference by output in : \d <table_name>
Previous Message Euler Taveira de Oliveira 2008-02-25 04:53:18 lc_time and localized dates