{"action":"opened","issue":{"url":"https://api.github.com/repos/lfittl/libpg_query/issues/48","repository_url":"https://api.github.com/repos/lfittl/libpg_query","labels_url":"https://api.github.com/repos/lfittl/libpg_query/issues/48/labels{/name}","comments_url":"https://api.github.com/repos/lfittl/libpg_query/issues/48/comments","events_url":"https://api.github.com/repos/lfittl/libpg_query/issues/48/events","html_url":"https://github.com/lfittl/libpg_query/issues/48","id":349339296,"node_id":"MDU6SXNzdWUzNDkzMzkyOTY=","number":48,"title":"determining enum constants mapping","user":{"login":"pyramation","id":545047,"node_id":"MDQ6VXNlcjU0NTA0Nw==","avatar_url":"https://avatars1.githubusercontent.com/u/545047?v=4","gravatar_id":"","url":"https://api.github.com/users/pyramation","html_url":"https://github.com/pyramation","followers_url":"https://api.github.com/users/pyramation/followers","following_url":"https://api.github.com/users/pyramation/following{/other_user}","gists_url":"https://api.github.com/users/pyramation/gists{/gist_id}","starred_url":"https://api.github.com/users/pyramation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pyramation/subscriptions","organizations_url":"https://api.github.com/users/pyramation/orgs","repos_url":"https://api.github.com/users/pyramation/repos","events_url":"https://api.github.com/users/pyramation/events{/privacy}","received_events_url":"https://api.github.com/users/pyramation/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-08-10T00:50:19Z","updated_at":"2018-08-10T00:50:19Z","closed_at":null,"author_association":"NONE","body":"When I upgraded to the latest version many of the `objtype` numbers changed on nodes. \r\n\r\nI'm trying to find a programatic way to determine the mapping so I can go back and forth between representations. Currently it seems that some of the objtype numbers are coming from the `ObjectType` enum data structure in the original source, but some are not. \r\n\r\nFor example, take these two statements as an example:\r\n\r\n```\r\nCOMMENT ON CAST (text AS int4) IS 'Allow casts from text to int4';\r\nCOMMENT ON TABLE my_schema.my_table IS 'Employee Information';\r\n```\r\n\r\nthe `CommentStmt` empirically yields an`OBJECT_CAST` since the node has `objtype=5`, which is correct! The other node yields `OBJECT_STATISTIC_EXT` instead, however, because `objtype=37`, although we know it is actually supposed to be `OBJECT_TABLE`.\r\n\r\nif you look below in the source, that's not exactly the order of the enums. Any idea why this is the case? I'm not sure if the node type would change the objtype, as I imagine they are shared throughout the source.\r\n\r\ninside of `src/include/nodes/parsenodes.h`\r\nhttps://doxygen.postgresql.org/parsenodes_8h.html#a842c5e2e69277690b064bf363c017980\r\n\r\n```c\r\n{\r\n     OBJECT_ACCESS_METHOD,\r\n     OBJECT_AGGREGATE,\r\n     OBJECT_AMOP,\r\n     OBJECT_AMPROC,\r\n     OBJECT_ATTRIBUTE,           /* type's attribute, when distinct from column */\r\n     OBJECT_CAST,\r\n     OBJECT_COLUMN,\r\n     OBJECT_COLLATION,\r\n     OBJECT_CONVERSION,\r\n     OBJECT_DATABASE,\r\n     OBJECT_DEFAULT,\r\n     OBJECT_DEFACL,\r\n     OBJECT_DOMAIN,\r\n     OBJECT_DOMCONSTRAINT,\r\n     OBJECT_EVENT_TRIGGER,\r\n     OBJECT_EXTENSION,\r\n     OBJECT_FDW,\r\n     OBJECT_FOREIGN_SERVER,\r\n     OBJECT_FOREIGN_TABLE,\r\n     OBJECT_FUNCTION,\r\n     OBJECT_INDEX,\r\n     OBJECT_LANGUAGE,\r\n     OBJECT_LARGEOBJECT,\r\n     OBJECT_MATVIEW,\r\n     OBJECT_OPCLASS,\r\n     OBJECT_OPERATOR,\r\n     OBJECT_OPFAMILY,\r\n     OBJECT_POLICY,\r\n     OBJECT_PROCEDURE,\r\n     OBJECT_PUBLICATION,\r\n     OBJECT_PUBLICATION_REL,\r\n     OBJECT_ROLE,\r\n     OBJECT_ROUTINE,\r\n     OBJECT_RULE,\r\n     OBJECT_SCHEMA,\r\n     OBJECT_SEQUENCE,\r\n     OBJECT_SUBSCRIPTION,\r\n     OBJECT_STATISTIC_EXT,\r\n     OBJECT_TABCONSTRAINT,\r\n     OBJECT_TABLE,\r\n     OBJECT_TABLESPACE,\r\n     OBJECT_TRANSFORM,\r\n     OBJECT_TRIGGER,\r\n     OBJECT_TSCONFIGURATION,\r\n     OBJECT_TSDICTIONARY,\r\n     OBJECT_TSPARSER,\r\n     OBJECT_TSTEMPLATE,\r\n     OBJECT_TYPE,\r\n     OBJECT_USER_MAPPING,\r\n     OBJECT_VIEW\r\n } ObjectType;\r\n```\r\nIs this where the `objtype`s are even coming from?\r\n\r\nany help is appreciated! Currently I'm thinking to manually write test cases for each `objtype` and empirically discover them all at this point."}}
{"actor":{"display_login":"pyramation"}}