Example #1
0
    def test_00(self):
        ret = process("foo", """LOG:  duration: 29825.000 ms  execute <unnamed>: SELECT "hierarchy"."id" AS "_C1" FROM "hierarchy" LEFT JOIN "misc" ON "hierarchy"."id" = "misc"."id" LEFT JOIN "dublincore" ON "hierarchy"."id" = "dublincore"."id" LEFT JOIN "versions" ON "hierarchy"."id" = "versions"."id" WHERE "hierarchy"."primarytype" IN ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15) AND (EXISTS (SELECT 1 FROM "dc_contributors" WHERE "hierarchy"."id" = "dc_contributors"."id" AND ("dc_contributors"."item" = $16))) AND ("versions"."id" IS NULL) AND ("misc"."lifecyclestate" <> $17) AND ("hierarchy"."name" <> $18) ORDER BY "dublincore"."modified" DESC 
DETAIL:  parameters: $1 = 'MailMessage', $2 = 'ContextualLink', $3 = 'DocumentLink', $4 = 'Thread', $5 = 'search_results', $6 = 'AdministrativeStatus', $7 = 'Picture', $8 = 'Document', $9 = 'FacetedSearch', $10 = 'File', $11 = 'AdvancedSearch', $12 = 'FacetedSearchDefault', $13 = 'Note', $14 = 'QueryNav', $15 = 'BlogPost', $16 = 'Administrator', $17 = 'deleted', $18 = '/default-domain'""")
        
        self.assertEquals(ret, """DEALLOCATE foo;
PREPARE foo(text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text) AS
SELECT hierarchy.id AS _C1 FROM hierarchy LEFT JOIN misc ON hierarchy.id = misc.id LEFT JOIN dublincore ON hierarchy.id = dublincore.id LEFT JOIN versions ON hierarchy.id = versions.id WHERE hierarchy.primarytype IN ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15) AND (EXISTS (SELECT 1 FROM dc_contributors WHERE hierarchy.id = dc_contributors.id AND (dc_contributors.item = $16))) AND (versions.id IS NULL) AND (misc.lifecyclestate <> $17) AND (hierarchy.name <> $18) ORDER BY dublincore.modified DESC;

EXPLAIN ANALYZE EXECUTE foo('MailMessage', 'ContextualLink', 'DocumentLink', 'Thread', 'search_results', 'AdministrativeStatus', 'Picture', 'Document', 'FacetedSearch', 'File', 'AdvancedSearch', 'FacetedSearchDefault', 'Note', 'QueryNav', 'BlogPost', 'Administrator', 'deleted', '/default-domain');""")
Example #2
0
    def test_01(self):
        ret = process("bar", """LOG:  duration: 351.823 ms  execute <unnamed>: SELECT 
"_C1" FROM (SELECT "hierarchy"."id" AS "_C1", "_F1"."title" AS "_C2" FROM "hierarchy" LEFT JOIN "dublincore" "_F1" ON "hierarchy"."id" = "_F1"."id" JOIN hierarchy_read_acl "_RACL" ON "hierarchy"."id" = "_RACL".id WHERE (("hierarchy"."primarytype" IN ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $40, $41, $42, $43, $44, $45, $46, $47)) AND ("hierarchy"."id" <> $48) AND ("hierarchy"."primarytype" IN ($49, $50, $51, $52, $53, $54, $55, $56, $57, $58, $59, $60, $61, $62, $63, $64, $65, $66, $67, $68, $69, $70, $71, $72, $73, $74, $75, $76, $77, $78)) AND ("hierarchy"."primarytype" IN ($79, $80, $81, $82, $83, $84, $85, $86, $87, $88, $89, $90, $91, $92, $93, $94, $95, $96, $97, $98, $99, $100, $101)) AND ("hierarchy"."isversion" IS NULL)) AND "_RACL".acl_id IN (SELECT * FROM nx_get_read_acls_for($102)) UNION ALL SELECT "_H"."id" AS "_C1", "_F1"."title" AS "_C2" FROM "hierarchy" "_H" JOIN "proxies" ON "_H"."id" = "proxies"."id" JOIN "hierarchy" ON "proxies"."targetid" = "hierarchy"."id" LEFT JOIN "dublincore" "_F1" ON "hierarchy"."id" = "_F1"."id" JOIN hierarchy_read_acl "_RACL" ON "_H"."id" = "_RACL".id WHERE (("hierarchy"."primarytype" IN ($103, $104, $105, $106, $107, $108, $109, $110, $111, $112, $113, $114, $115, $116, $117, $118, $119, $120, $121, $122, $123, $124, $125, $126, $127, $128, $129, $130, $131, $132, $133, $134, $135, $136, $137, $138, $139, $140, $141, $142, $143, $144, $145, $146, $147, $148, $149)) AND ("_H"."id" <> $150) AND ("hierarchy"."primarytype" IN ($151, $152, $153, $154, $155, $156, $157, $158, $159, $160, $161, $162, $163, $164, $165, $166, $167, $168, $169, $170, $171, $172, $173, $174, $175, $176, $177, $178, $179, $180)) AND ("hierarchy"."primarytype" IN ($181, $182, $183, $184, $185, $186, $187, $188, $189, $190, $191, $192, $193, $194, $195, $196, $197, $198, $199, $199, $200, $201, $202, $203)) AND ("_H"."isversion" IS NULL)) AND "_RACL".acl_id IN (SELECT * FROM nx_get_read_acls_for($204))) AS "_T" ORDER BY "_C2"
DETAIL:  parameters: $1 = 'WCOpenSocial', $2 = 'TaskLists', $3 = 'SectionRoot', $4 = 'MailMessage', $5 = 'Workspace', $6 = 'Forum', $7 = 'ContextualLink', $8 = 'PictureBook', $9 = 'RelationSearch', $10 = 'Unit', $11 = 'BlogSite', $12 = 'WCHtml', $13 = 'Post', $14 = 'Tag', $15 = 'ManagementRoot', $16 = 'AdministrativeStatusContainer', $17 = 'Thread', $18 = 'search_results', $19 = 'AdministrativeStatus', $20 = 'Space', $21 = 'UserWorkspacesRoot', $22 = 'Picture', $23 = 'Document', $24 = 'TemplateRoot', $25 = 'Folder', $26 = 'Domain', $27 = 'FacetedSearch', $28 = 'WCPicture', $29 = 'WorkspaceRoot', $30 = 'File', $31 = 'Comment', $32 = 'FacetedSearchDefault', $33 = 'AdvancedSearch', $34 = 'WebSite', $35 = 'Note', $36 = 'Gadget', $37 = 'HiddenFolder', $38 = 'QueryNav', $39 = 'Section', $40 = 'TaskList', $41 = 'WebPage', $42 = 'UserProfile', $43 = 'MailFolder', $44 = 'OrderedFolder', $45 = 'CommentRoot', $46 = 'BasicAuditSearch', $47 = 'BlogPost', $48 = 'SectionRoot', $49 = 'ZZ', $50 = 'Workspace', $51 = 'RelationSearch', $52 = 'BlogSite', $53 = 'Thread', $54 = 'TemplateRoot', $55 = 'Domain', $56 = 'WorkspaceRoot', $57 = 'QueryNav', $58 = 'WebPage', $59 = 'MailMessage', $60 = 'Forum', $61 = 'ContextualLink', $62 = 'PictureBook', $63 = 'Picture', $64 = 'Relation', $65 = 'Document', $66 = 'Folder', $67 = 'FacetedSearch', $68 = 'File', $69 = 'WebSite', $70 = 'AdvancedSearch', $71 = 'FacetedSearchDefault', $72 = 'Note', $73 = 'Section', $74 = 'Root', $75 = 'MailFolder', $76 = 'OrderedFolder', $77 = 'BasicAuditSearch', $78 = 'BlogPost', $79 = 'RelationSearch', $80 = 'Tag', $81 = 'Tagging', $82 = 'Thread', $83 = 'search_results', $84 = 'Comment', $85 = 'QueryNav', $86 = 'TaskList', $87 = 'MailMessage', $88 = 'ContextualLink', $89 = 'Post', $90 = 'AdministrativeStatus', $91 = 'Picture', $92 = 'Relation', $93 = 'Document', $94 = 'FacetedSearch', $95 = 'File', $96 = 'AdvancedSearch', $97 = 'FacetedSearchDefault', $98 = 'Note', $99 = 'AA', $100 = 'BB', $101 = 'BlogPost', $102 = '{members,user4,Everyone}', $103 = 'WCOpenSocial', $104 = 'TaskLists', $105 = 'SectionRoot', $106 = 'MailMessage', $107 = 'Workspace', $108 = 'Forum', $109 = 'ContextualLink', $110 = 'PictureBook', $111 = 'RelationSearch', $112 = 'Unit', $113 = 'BlogSite', $114 = 'WCHtml', $115 = 'Post', $116 = 'Tag', $117 = 'ManagementRoot', $118 = 'AdministrativeStatusContainer', $119 = 'Thread', $120 = 'search_results', $121 = 'AdministrativeStatus', $122 = 'Space', $123 = 'UserWorkspacesRoot', $124 = 'Picture', $125 = 'Document', $126 = 'TemplateRoot', $127 = 'Folder', $128 = 'Domain', $129 = 'FacetedSearch', $130 = 'WCPicture', $131 = 'WorkspaceRoot', $132 = 'File', $133 = 'Comment', $134 = 'FacetedSearchDefault', $135 = 'AdvancedSearch', $136 = 'WebSite', $137 = 'Note', $138 = 'Gadget', $139 = 'HiddenFolder', $140 = 'QueryNav', $141 = 'Section', $142 = 'TaskList', $143 = 'WebPage', $144 = 'UserProfile', $145 = 'MailFolder', $146 = 'OrderedFolder', $147 = 'BasicAuditSearch', $148 = 'CC', $149 = 'BlogPost', $150 = 'ecf991cd-4d1e-4b75-a660-cc359deb930b', $151 = 'SectionRoot', $152 = 'Workspace', $153 = 'RelationSearch', $154 = 'BlogSite', $155 = 'Thread', $156 = 'TemplateRoot', $157 = 'Domain', $158 = 'WorkspaceRoot', $159 = 'QueryNav', $160 = 'WebPage', $161 = 'MailMessage', $162 = 'Forum', $163 = 'ContextualLink', $164 = 'PictureBook', $165 = 'Picture', $166 = 'Relation', $167 = 'Document', $168 = 'Folder', $169 = 'FacetedSearch', $170 = 'File', $171 = 'WebSite', $172 = 'AdvancedSearch', $173 = 'FacetedSearchDefault', $174 = 'Note', $175 = 'Section', $176 = 'Root', $177 = 'MailFolder', $178 = 'OrderedFolder', $179 = 'BasicAuditSearch', $180 = 'BlogPost', $181 = 'RelationSearch', $182 = 'Tag', $183 = 'Tagging', $184 = 'Thread', $185 = 'search_results', $186 = 'Comment', $187 = 'QueryNav', $188 = 'TaskList', $189 = 'MailMessage', $190 = 'ContextualLink', $191 = 'Post', $192 = 'AdministrativeStatus', $193 = 'Picture', $194 = 'Re', $195='EE', $196 = 'FacetedSearch', $197 = 'File', $198 = 'AdvancedSearch', $199 = 'FacetedSearchDefault', $200 = 'Note', $201 = 'UserProfile', $202 = 'BasicAuditSearch', $203 = 'BlogPost', $204 = '{members,user4,Everyone}'""")
        print ret

        self.assertEquals(ret, """DEALLOCATE bar;
PREPARE bar(text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text[], text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text[]) AS
SELECT 
_C1 FROM (SELECT hierarchy.id AS _C1, _F1.title AS _C2 FROM hierarchy LEFT JOIN dublincore _F1 ON hierarchy.id = _F1.id JOIN hierarchy_read_acl _RACL ON hierarchy.id = _RACL.id WHERE ((hierarchy.primarytype IN ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $40, $41, $42, $43, $44, $45, $46, $47)) AND (hierarchy.id <> $48) AND (hierarchy.primarytype IN ($49, $50, $51, $52, $53, $54, $55, $56, $57, $58, $59, $60, $61, $62, $63, $64, $65, $66, $67, $68, $69, $70, $71, $72, $73, $74, $75, $76, $77, $78)) AND (hierarchy.primarytype IN ($79, $80, $81, $82, $83, $84, $85, $86, $87, $88, $89, $90, $91, $92, $93, $94, $95, $96, $97, $98, $99, $100, $101)) AND (hierarchy.isversion IS NULL)) AND _RACL.acl_id IN (SELECT * FROM nx_get_read_acls_for($102)) UNION ALL SELECT _H.id AS _C1, _F1.title AS _C2 FROM hierarchy _H JOIN proxies ON _H.id = proxies.id JOIN hierarchy ON proxies.targetid = hierarchy.id LEFT JOIN dublincore _F1 ON hierarchy.id = _F1.id JOIN hierarchy_read_acl _RACL ON _H.id = _RACL.id WHERE ((hierarchy.primarytype IN ($103, $104, $105, $106, $107, $108, $109, $110, $111, $112, $113, $114, $115, $116, $117, $118, $119, $120, $121, $122, $123, $124, $125, $126, $127, $128, $129, $130, $131, $132, $133, $134, $135, $136, $137, $138, $139, $140, $141, $142, $143, $144, $145, $146, $147, $148, $149)) AND (_H.id <> $150) AND (hierarchy.primarytype IN ($151, $152, $153, $154, $155, $156, $157, $158, $159, $160, $161, $162, $163, $164, $165, $166, $167, $168, $169, $170, $171, $172, $173, $174, $175, $176, $177, $178, $179, $180)) AND (hierarchy.primarytype IN ($181, $182, $183, $184, $185, $186, $187, $188, $189, $190, $191, $192, $193, $194, $195, $196, $197, $198, $199, $199, $200, $201, $202, $203)) AND (_H.isversion IS NULL)) AND _RACL.acl_id IN (SELECT * FROM nx_get_read_acls_for($204))) AS _T ORDER BY _C2;

EXPLAIN ANALYZE EXECUTE bar('WCOpenSocial', 'TaskLists', 'SectionRoot', 'MailMessage', 'Workspace', 'Forum', 'ContextualLink', 'PictureBook', 'RelationSearch', 'Unit', 'BlogSite', 'WCHtml', 'Post', 'Tag', 'ManagementRoot', 'AdministrativeStatusContainer', 'Thread', 'search_results', 'AdministrativeStatus', 'Space', 'UserWorkspacesRoot', 'Picture', 'Document', 'TemplateRoot', 'Folder', 'Domain', 'FacetedSearch', 'WCPicture', 'WorkspaceRoot', 'File', 'Comment', 'FacetedSearchDefault', 'AdvancedSearch', 'WebSite', 'Note', 'Gadget', 'HiddenFolder', 'QueryNav', 'Section', 'TaskList', 'WebPage', 'UserProfile', 'MailFolder', 'OrderedFolder', 'CommentRoot', 'BasicAuditSearch', 'BlogPost', 'SectionRoot', 'ZZ', 'Workspace', 'RelationSearch', 'BlogSite', 'Thread', 'TemplateRoot', 'Domain', 'WorkspaceRoot', 'QueryNav', 'WebPage', 'MailMessage', 'Forum', 'ContextualLink', 'PictureBook', 'Picture', 'Relation', 'Document', 'Folder', 'FacetedSearch', 'File', 'WebSite', 'AdvancedSearch', 'FacetedSearchDefault', 'Note', 'Section', 'Root', 'MailFolder', 'OrderedFolder', 'BasicAuditSearch', 'BlogPost', 'RelationSearch', 'Tag', 'Tagging', 'Thread', 'search_results', 'Comment', 'QueryNav', 'TaskList', 'MailMessage', 'ContextualLink', 'Post', 'AdministrativeStatus', 'Picture', 'Relation', 'Document', 'FacetedSearch', 'File', 'AdvancedSearch', 'FacetedSearchDefault', 'Note', 'AA', 'BB', 'BlogPost', '{members,user4,Everyone}', 'WCOpenSocial', 'TaskLists', 'SectionRoot', 'MailMessage', 'Workspace', 'Forum', 'ContextualLink', 'PictureBook', 'RelationSearch', 'Unit', 'BlogSite', 'WCHtml', 'Post', 'Tag', 'ManagementRoot', 'AdministrativeStatusContainer', 'Thread', 'search_results', 'AdministrativeStatus', 'Space', 'UserWorkspacesRoot', 'Picture', 'Document', 'TemplateRoot', 'Folder', 'Domain', 'FacetedSearch', 'WCPicture', 'WorkspaceRoot', 'File', 'Comment', 'FacetedSearchDefault', 'AdvancedSearch', 'WebSite', 'Note', 'Gadget', 'HiddenFolder', 'QueryNav', 'Section', 'TaskList', 'WebPage', 'UserProfile', 'MailFolder', 'OrderedFolder', 'BasicAuditSearch', 'CC', 'BlogPost', 'ecf991cd-4d1e-4b75-a660-cc359deb930b', 'SectionRoot', 'Workspace', 'RelationSearch', 'BlogSite', 'Thread', 'TemplateRoot', 'Domain', 'WorkspaceRoot', 'QueryNav', 'WebPage', 'MailMessage', 'Forum', 'ContextualLink', 'PictureBook', 'Picture', 'Relation', 'Document', 'Folder', 'FacetedSearch', 'File', 'WebSite', 'AdvancedSearch', 'FacetedSearchDefault', 'Note', 'Section', 'Root', 'MailFolder', 'OrderedFolder', 'BasicAuditSearch', 'BlogPost', 'RelationSearch', 'Tag', 'Tagging', 'Thread', 'search_results', 'Comment', 'QueryNav', 'TaskList', 'MailMessage', 'ContextualLink', 'Post', 'AdministrativeStatus', 'Picture', 'Re', 'EE', 'FacetedSearch', 'File', 'AdvancedSearch', 'FacetedSearchDefault', 'Note', 'UserProfile', 'BasicAuditSearch', 'BlogPost', '{members,user4,Everyone}');""")