<!-- 
RSS generated by JIRA (8.3.4#803005-sha1:1f96e09b3c60279a408a2ae47be3c745f571388b) at Sat Feb 10 16:21:48 JST 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>PFS-JIRA</title>
    <link>https://pfspipe.ipmu.jp/jira</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>8.3.4</version>
        <build-number>803005</build-number>
        <build-date>13-09-2019</build-date>
    </build-info>


<item>
            <title>[INSTRM-125] Archiver dies when table does not have any row</title>
                <link>https://pfspipe.ipmu.jp/jira/browse/INSTRM-125</link>
                <project id="10300" key="INSTRM">Instrument control development</project>
                    <description>&lt;p&gt;pfs@ics-arch:/simdata/ics-arch-201701/products/Linux64/ics_archiver/master-ga619cf6fd9$ ./bin/archiveServer.py &lt;br/&gt;
Running ./bin/archiveServer.py as PID 22621&lt;br/&gt;
Starting archive server with output to /simdata/ics-arch-201701//logs/actors/archiver/archiver-22621&lt;br/&gt;
importing postgres dbapi module psycopg2&lt;br/&gt;
reply_raw&lt;br/&gt;
Traceback (most recent call last):&lt;br/&gt;
  File &quot;./bin/archiveServer.py&quot;, line 196, in &amp;lt;module&amp;gt;&lt;br/&gt;
    main()&lt;br/&gt;
  File &quot;./bin/archiveServer.py&quot;, line 193, in main&lt;br/&gt;
    startServer(options)&lt;br/&gt;
  File &quot;./bin/archiveServer.py&quot;, line 69, in startServer&lt;br/&gt;
    archiver.database.init(options)&lt;br/&gt;
  File &quot;/simdata/ics-arch-201701/products/Linux64/ics_archiver/master-ga619cf6fd9/python/archiver/database.py&quot;, line 105, in init&lt;br/&gt;
    print &quot;database: table %s contains %d rows&quot; % (tableName,tableRows)&lt;br/&gt;
TypeError: %d format: a number is required, not NoneType&lt;/p&gt;

&lt;p&gt;max() will return null value but not 0 for no row inserted. need to add handler when no row exists.&lt;/p&gt;</description>
                <environment></environment>
        <key id="11648">INSTRM-125</key>
            <summary>Archiver dies when table does not have any row</summary>
                <type id="1" iconUrl="https://pfspipe.ipmu.jp/jira/secure/viewavatar?size=xsmall&amp;avatarId=10503&amp;avatarType=issuetype">Bug</type>
                                            <priority id="3" iconUrl="https://pfspipe.ipmu.jp/jira/images/icons/priorities/major.svg">Major</priority>
                        <status id="10002" iconUrl="https://pfspipe.ipmu.jp/jira/images/icons/statuses/generic.png" description="The issue is resolved, reviewed, and merged">Done</status>
                    <statusCategory id="3" key="done" colorName="green"/>
                                    <resolution id="10000">Done</resolution>
                                        <assignee username="cloomis">cloomis</assignee>
                                    <reporter username="atsushi.shimono">shimono</reporter>
                        <labels>
                    </labels>
                <created>Thu, 15 Jun 2017 08:13:18 +0000</created>
                <updated>Wed, 21 Jun 2017 13:18:28 +0000</updated>
                            <resolved>Wed, 21 Jun 2017 13:18:28 +0000</resolved>
                                                                    <component>ics_archiver</component>
                        <due></due>
                            <votes>0</votes>
                                    <watches>3</watches>
                                                                <comments>
                            <comment id="12266" author="arnaud.lefur" created="Fri, 16 Jun 2017 08:36:23 +0000"  >&lt;p&gt;Sorry for that, I&apos;ve been a bit careless. &lt;br/&gt;
I&apos;ve looked at your commit on github:&lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;tableRows = cursor.fetchone()[0]
+        if tableRows is None:
+            tableRows = 0
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;


&lt;p&gt;If you do that you&apos;ll still have a &lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt; TypeError: &apos;NoneType&apos; object has no attribute &apos;__getitem__&apos; &lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;


&lt;p&gt;because it&apos;s cursor.fetchone() which return None, I suggest this if you don&apos;t mind.&lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;tableRows = cursor.fetchone()
tableRows = tableRows[0] if tableRows is not None else 0
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

</comment>
                            <comment id="12278" author="atsushi.shimono" created="Mon, 19 Jun 2017 05:05:47 +0000"  >&lt;p&gt;This sounds somehow strange to me. Since SQL is max&lt;img class=&quot;emoticon&quot; src=&quot;https://pfspipe.ipmu.jp/jira/images/icons/emoticons/star_yellow.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;, it shall return at least one row, and fetchone() shall return that value. If no, there could be another error such as connection or table definition.&lt;/p&gt;</comment>
                            <comment id="12279" author="cloomis" created="Mon, 19 Jun 2017 05:23:57 +0000"  >&lt;p&gt;&lt;tt&gt;MAX()&lt;/tt&gt; will return NULL on empty tables. I think a standard fix is to use &lt;tt&gt;COALESCE(MAX(...), 0)&lt;/tt&gt;, where &lt;tt&gt;COALESCE&lt;/tt&gt; returns the first non-NULL value in its arguments.&lt;/p&gt;</comment>
                            <comment id="12280" author="atsushi.shimono" created="Mon, 19 Jun 2017 07:39:48 +0000"  >&lt;p&gt;If we want to go SQL, I want to point we would better to use NULLIF...&lt;/p&gt;</comment>
                            <comment id="12281" author="arnaud.lefur" created="Mon, 19 Jun 2017 09:00:23 +0000"  >&lt;p&gt;Yes, in fact I was wrong. &lt;br/&gt;
COALESCE seems fine, I&apos;ve just tested it. &lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;cursor.execute(&quot;select COALESCE(MAX(%s),0) from %s&quot; % (idLab, tableName))
tableRows = cursor.fetchone()
tableRows = tableRows[0] if tableRows is not None else 0
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Should we merge and close that issue ?&lt;/p&gt;</comment>
                            <comment id="12282" author="atsushi.shimono" created="Mon, 19 Jun 2017 09:45:04 +0000"  >&lt;p&gt;I posted a wrong comment sorry. NULLIF is the opposite operation.&lt;/p&gt;

&lt;p&gt;For fix, if we put null validation code in SQL, I&apos;d rather propose to arise exception (but not by print) than handling None for fetchone(), since the error shall be invoked or injected well before the SQL just executed. So, I&apos;d propose&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-python&quot;&gt;
cursor.execute(&lt;span class=&quot;code-quote&quot;&gt;&quot;select COALESCE(MAX(%s),0) &lt;span class=&quot;code-keyword&quot;&gt;from&lt;/span&gt; %s&quot;&lt;/span&gt; % (idLab, tableName))
tableRows = cursor.fetchone()
&lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; tableRows &lt;span class=&quot;code-keyword&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;&lt;span class=&quot;code-object&quot;&gt;None&lt;/span&gt;&lt;/span&gt;:
    &lt;span class=&quot;code-keyword&quot;&gt;raise&lt;/span&gt; &lt;span class=&quot;code-object&quot;&gt;ValueError&lt;/span&gt;(&lt;span class=&quot;code-quote&quot;&gt;&apos;Could &lt;span class=&quot;code-keyword&quot;&gt;not&lt;/span&gt; get MAX(%s) &lt;span class=&quot;code-keyword&quot;&gt;from&lt;/span&gt; %s&apos;&lt;/span&gt; % (idLab, tableName))
&lt;span class=&quot;code-keyword&quot;&gt;else&lt;/span&gt;:
    tableRows = tableRows[0]
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;or similar.&lt;/p&gt;</comment>
                            <comment id="12287" author="atsushi.shimono" created="Wed, 21 Jun 2017 13:18:28 +0000"  >&lt;p&gt;merged.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10500" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                            <customfield id="customfield_10010" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>0|ii0273:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10100" key="com.atlassian.jira.plugin.system.customfieldtypes:userpicker">
                        <customfieldname>Reviewers</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>arnaud.lefur</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                </customfields>
    </item>
</channel>
</rss>