<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:p="urn:schemas-microsoft-com:office:powerpoint" xmlns:a="urn:schemas-microsoft-com:office:access" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" xmlns:b="urn:schemas-microsoft-com:office:publisher" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet" xmlns:odc="urn:schemas-microsoft-com:office:odc" xmlns:oa="urn:schemas-microsoft-com:office:activation" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:q="http://schemas.xmlsoap.org/soap/envelope/" xmlns:rtc="http://microsoft.com/officenet/conferencing" xmlns:D="DAV:" xmlns:Repl="http://schemas.microsoft.com/repl/" xmlns:mt="http://schemas.microsoft.com/sharepoint/soap/meetings/" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:ppda="http://www.passport.com/NameSpace.xsd" xmlns:ois="http://schemas.microsoft.com/sharepoint/soap/ois/" xmlns:dir="http://schemas.microsoft.com/sharepoint/soap/directory/" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp" xmlns:udc="http://schemas.microsoft.com/data/udc" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sub="http://schemas.microsoft.com/sharepoint/soap/2002/1/alerts/" xmlns:ec="http://www.w3.org/2001/04/xmlenc#" xmlns:sp="http://schemas.microsoft.com/sharepoint/" xmlns:sps="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:udcs="http://schemas.microsoft.com/data/udc/soap" xmlns:udcxf="http://schemas.microsoft.com/data/udc/xmlfile" xmlns:udcp2p="http://schemas.microsoft.com/data/udc/parttopart" xmlns:wf="http://schemas.microsoft.com/sharepoint/soap/workflow/" xmlns:dsss="http://schemas.microsoft.com/office/2006/digsig-setup" xmlns:dssi="http://schemas.microsoft.com/office/2006/digsig" xmlns:mdssi="http://schemas.openxmlformats.org/package/2006/digital-signature" xmlns:mver="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns:mrels="http://schemas.openxmlformats.org/package/2006/relationships" xmlns:spwp="http://microsoft.com/sharepoint/webpartpages" xmlns:ex12t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:ex12m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:pptsl="http://schemas.microsoft.com/sharepoint/soap/SlideLibrary/" xmlns:spsl="http://microsoft.com/webservices/SharePointPortalServer/PublishedLinksService" xmlns:Z="urn:schemas-microsoft-com:" xmlns:st="" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:"Courier New";}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal>Hi folks,<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal>I'm setting up a new instance of RT 3.8.4 with postgres
8.1.11 on CentOS 5.3, and had some problems trying to implement the
Rtx::S3Invoker plugin to enable simple search to execute saved searches.   I
fixed the problem, but have a couple of questions.  Some background:<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal>After installing, when I tried to do a "do:unowned"
at the simplesearch screen I got an error like this in rt.log:<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas'>[Thu Aug
27 16:44:29 2009] [warning]: DBD::Pg::st execute failed: ERROR:  column
"attributes.description" must appear in the GROUP BY clause or be
used in an aggregate function
(/usr/lib/perl5/site_perl/5.8.8/DBIx/SearchBuilder/Handle.pm:509)<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas'>[Thu Aug
27 16:44:29 2009] [warning]: RT::Handle=HASH(0x2ac0dc7a8be0) couldn't execute
the query 'SELECT COUNT(*) FROM Attributes WHERE Description LIKE '%unowned%'
AND ( (Name='SavedSearch' AND ( (ObjectType='RT::User' AND ObjectId=12)  )
) OR ( ObjectType='RT::System' AND (Name LIKE 'Search - %' OR
Name='SavedSearch') ) ) ORDER BY Description;' at
/usr/lib/perl5/site_perl/5.8.8/DBIx/SearchBuilder/Handle.pm line 522<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas'>       
DBIx::SearchBuilder::Handle::SimpleQuery('RT::Handle=HASH(0x2ac0dc7a8be0)',
'SELECT COUNT(*) FROM Attributes WHERE Description LIKE \'%uno...') called at
/usr/local/rt/plugins/RTx-S3Invoker/html/Search/Invoker line 36<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas'><o:p> </o:p></span></p>

<p class=MsoNormal>A similar error appeared in the browser.  After
contemplating Invoker, I decided to run the query manually against the database
with psql.  I received the same error, so Postgres does not like this
query format for some reason.  Googling turned up this:  <a
href="http://archives.postgresql.org/pgsql-general/2004-02/msg01210.php">http://archives.postgresql.org/pgsql-general/2004-02/msg01210.php</a>
in which the inimitable Tom Lane says:<o:p></o:p></p>

<p class=MsoNormal><i><o:p> </o:p></i></p>

<pre><i>"<span style='color:black'>Postgres currently implements the SQL92 definition, which is<o:p></o:p></span></i></pre>

<p class=MsoNormal><i><span style='font-size:10.0pt;font-family:"Courier New";
color:black'>that you can't refer to an ungrouped column except within an
aggregate<o:p></o:p></span></i></p>

<p class=MsoNormal><i><span style='font-size:10.0pt;font-family:"Courier New";
color:black'>function call.  So you need to call out all the columns to be
referenced<o:p></o:p></span></i></p>

<p class=MsoNormal><i><span style='font-size:10.0pt;font-family:"Courier New";
color:black'>in GROUP BY.”</span></i><span style='font-size:10.0pt;
font-family:"Courier New";color:black'><o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New";
color:black'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='color:black'>So I changed Invoker thusly. 
<o:p></o:p></span></p>

<p class=MsoNormal><span style='color:black'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='color:black'>Before:<o:p></o:p></span></p>

<p class=MsoNormal><span style='color:black'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas;
color:black'>my $WHERE = sprintf("WHERE Description LIKE '%s' AND (
(Name='SavedSearch' AND ( (ObjectType='RT::User' AND ObjectId=%i) %s ) ) OR (
ObjectType='RT::System' AND (Name LIKE 'Search - %' OR Name='SavedSearch') ) )
ORDER BY Description",<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas;
color:black'>                   
"%\Q${do}\E%",<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas;
color:black'>                   
$session{'CurrentUser'}->Id,<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas;
color:black'>                   
scalar @groups ? "OR ( ObjectType='RT::Group' AND ObjectId IN (".
join(',', @groups) .') )' : ''<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas;
color:black'>                  
);<o:p></o:p></span></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal>After:<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas'>my
$WHERE = sprintf("WHERE Description LIKE '%s' AND ( (Name='SavedSearch'
AND ( (ObjectType='RT::User' AND ObjectId=%i) %s ) ) OR (
ObjectType='RT::System' AND (Name LIKE 'Search - %' OR Name='SavedSearch') ) )
GROUP BY Description, Objecttype, objectid, id ORDER BY Description",<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas'>                   
"%\Q${do}\E%",<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas'>                   
$session{'CurrentUser'}->Id,<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas'>                   
scalar @groups ? "OR ( ObjectType='RT::Group' AND ObjectId IN (".
join(',', @groups) .') )' : ''<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas'>                  
);<o:p></o:p></span></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal>This worked!  great.  <o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal>Here are the questions:<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal>1.  It appears that Postgres *may* support SELECT with
undefined GROUP BY in later releases, but I have not been able to test this yet. 
is 8.1.11 modern enough to make this worth filing a bug report?  It's the
default postgres package that comes with CentOS 5.3, so maybe it's not so
ancient.<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal>2.  It doesn't look like calling out a GROUP BY
explicitly like this would work against MySQL installs, but I'm really not
sure.  Would there be a better way of constructing the query than what I
have done here? (SELECT DISTINCT maybe?)<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal>Thanks all for yout time!<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal><span style='color:#1F497D'>Ian Smith</span><span
style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'><o:p></o:p></span></p>

<p class=MsoNormal><span style='color:#1F497D'>Director of Information
Technology</span><span style='font-size:10.0pt;font-family:"Arial","sans-serif";
color:#1F497D'><o:p></o:p></span></p>

<div class=MsoNormal align=center style='text-align:center'><span
style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'>

<hr size=2 width="100%" noshade style='color:#E2164E' align=center>

</span></div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";
color:#1F497D'><br>
<b>Production Resource Group</b></span><span style='font-size:10.0pt;
font-family:"Arial","sans-serif";color:#1F497D'><o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:7.5pt;font-family:"Arial","sans-serif";
color:#1F497D'>201-758-4315 findme<br>
201-868-7195 fax<br>
<a href="mailto:ismith@prg.com"><span style='color:#E2164E'>ismith@prg.com</span></a></span><span
style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'><o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:7.5pt;font-family:"Arial","sans-serif";
color:#1F497D'><a href="http://www.prg.com/"><span style='color:#E2164E'>www.prg.com</span></a>
</span><span style='font-size:10.0pt;font-family:"Arial","sans-serif";
color:#1F497D'><o:p></o:p></span></p>

<p class=MsoNormal><o:p> </o:p></p>

</div>

</body>

</html>