Re: [HACKERS] bogus tsdict, tsparser, etc object identities

2014-04-16 Thread Alvaro Herrera
Alvaro Herrera wrote:

> This problem is new in 9.3, so backpatching to that.  Prior to that we
> didn't have object identities.

Done.

-- 
Álvaro Herrerahttp://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


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


[HACKERS] bogus tsdict, tsparser, etc object identities

2014-04-09 Thread Alvaro Herrera
I noticed that pg_identify_object() gives a bogus answer for the text
search object types: it is failing to schema-qualify the objects.  I
guess at the time I thought that those object types were global, not
contained within schemas (as seems reasonable.  Who would want to have
different text search parsers in different schemas anyway?)

alvherre=# CREATE TEXT SEARCH DICTIONARY alt_ts_dict1 (template=simple);
CREATE TEXT SEARCH DICTIONARY
alvherre=# create schema foo;
CREATE SCHEMA
alvherre=# CREATE TEXT SEARCH DICTIONARY foo.alt_ts_dict1 (template=simple);
CREATE TEXT SEARCH DICTIONARY

Before patch,

alvherre=# select identity.* from pg_ts_dict, 
pg_identify_object('pg_ts_dict'::regclass, oid, 0) identity where schema <> 
'pg_catalog';
  type  | schema | name |   identity
++--+--
 text search dictionary | public | alt_ts_dict1 | alt_ts_dict1
 text search dictionary | foo| alt_ts_dict1 | alt_ts_dict1
(2 filas)

After patch,

alvherre=# select identity.* from pg_ts_dict, 
pg_identify_object('pg_ts_dict'::regclass, oid, 0) identity where schema <> 
'pg_catalog';
  type  | schema | name |  identity   
++--+-
 text search dictionary | public | alt_ts_dict1 | public.alt_ts_dict1
 text search dictionary | foo| alt_ts_dict1 | foo.alt_ts_dict1
(2 filas)

This problem is new in 9.3, so backpatching to that.  Prior to that we
didn't have object identities.

The attached patch demonstrates the fix for tsdict only, but as I said
above all text search object types are affected, so I'm going to
backpatch for all of them.

-- 
Álvaro Herrerahttp://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
*** a/src/backend/catalog/objectaddress.c
--- b/src/backend/catalog/objectaddress.c
***
*** 3095,3100  getObjectIdentity(const ObjectAddress *object)
--- 3095,3101 
  			{
  HeapTuple	tup;
  Form_pg_ts_dict formDict;
+ char	   *schema;
  
  tup = SearchSysCache1(TSDICTOID,
  	  ObjectIdGetDatum(object->objectId));
***
*** 3102,3109  getObjectIdentity(const ObjectAddress *object)
  	elog(ERROR, "cache lookup failed for text search dictionary %u",
  		 object->objectId);
  formDict = (Form_pg_ts_dict) GETSTRUCT(tup);
  appendStringInfoString(&buffer,
! 			  quote_identifier(NameStr(formDict->dictname)));
  ReleaseSysCache(tup);
  break;
  			}
--- 3103,3112 
  	elog(ERROR, "cache lookup failed for text search dictionary %u",
  		 object->objectId);
  formDict = (Form_pg_ts_dict) GETSTRUCT(tup);
+ schema = get_namespace_name(formDict->dictnamespace);
  appendStringInfoString(&buffer,
! 			  quote_qualified_identifier(schema,
! 		 NameStr(formDict->dictname)));
  ReleaseSysCache(tup);
  break;
  			}

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