2

The Postgres documentation frequently uses the term "object". For instance, the descriptions of various \d commands at https://www.postgresql.org/docs/current/app-psql.html (like \dt for listing tables or \da for listing aggregate functions) use a phrase like:

By default, only user-created objects are shown; supply a pattern or the S modifier to include system objects.

From this, I can infer that at least the specific things listed by each of those commands - like aggregate functions, tables, character set encodings, schemas, and a whole bunch of other stuff - are "objects" in Postgres's nomenclature. I can also make a decent guess that some of the things that can be listed with \d commands, like roles, are not objects, given that in their descriptions the word "object" has been avoided.

But what exactly does that mean? Presently I wouldn't be able to tell whether any particular thing (like a table row, or a table column, or a role) is properly considered to be an "object" except by happening across a spot in the Postgres documentation in which it's referred to as such. What's the underlying definition that the docs are using?

  • I might be wrong, but I don't think there is a definition. Object here means everything that is - well, an object. The usage is very close to the everyday language in this sense. BTW, why is it important to you? – dezso Jan 17 '19 at 14:31
  • @dezso "why is it important to you?" - sometimes I want to do something like "list everything in schema X" or "delete everything in schema X" for some (maybe not-yet-clear-to-me) notion of "everything". When faced with such a task, it's useful to formally and unambiguously put it into words - in order, for instance, to better document the code that does it, or to Google for approaches to it, or to ask for advice on how to do it. It's conceivable that something like "list all objects in schema X" might be such a formalisation... but to know that, I must first know what "objects" means. – Mark Amery Jan 17 '19 at 14:43
  • I would see anything that is created using CREATE ... as "an object". – a_horse_with_no_name Jan 17 '19 at 15:00
5

I can also make a decent guess that some of the things that can be listed with \d commands, like roles, are not objects, given that in their descriptions the word "object" has been avoided.

No, because roles are also refered to as objects in certain parts of the documentation. For instance: https://www.postgresql.org/docs/current/catalog-pg-shdepend.html:

The catalog pg_shdepend records the dependency relationships between database objects and shared objects, such as roles. This information allows PostgreSQL to ensure that those objects are unreferenced before attempting to delete them.

(shared in this context means shared across databases).

I would suggest as a baseline that everything in Postgres that must have an OID can be qualified as an object, and everything that doesn't have an OID is probably not an object. On top of that, some exceptions may exist: for example, it might be argued whether a database can be called an "object", depending on the context, although a database has an OID.

The oid is part of the system columns. It used to be present in older versions in every table and even every row, but this usage has been deprecated. This deprecation is an ongoing process: the next version of Postgres will transform the oid columns in the catalogs into normal columns.

Just like the use of oid is evolving , what can be qualified as an object is evolving too because new kinds of objects are added to Postgres in pretty much every new version, which concur to the lack of a formal definition.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.