<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Sat May 18 20:30:09 UTC 2013

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 add field=key&field=summary to the URL of your request.
For example:
http://www.doctrine-project.org/jira/si/jira.issueviews:issue-xml/DBAL-124/DBAL-124.xml?field=key&field=summary
-->
<rss version="0.92" >
<channel>
    <title>Doctrine Project</title>
    <link>http://www.doctrine-project.org/jira</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>5.2.7</version>
        <build-number>850</build-number>
        <build-date>21-02-2013</build-date>
    </build-info>

<item>
            <title>[DBAL-124] OCI8 Adapter (convertPositionalToNamedPlaceholders) Statemachine doesn&apos;t consider comments and strings</title>
                <link>http://www.doctrine-project.org/jira/browse/DBAL-124</link>
                <project id="10040" key="DBAL">Doctrine DBAL</project>
                        <description>&lt;p&gt;SQL statements may contain question marks in strings, inline comments or comment blocks. The current implementation of the method &quot;convertPositionalToNamedPlaceholders()&quot; doesn&apos;t consider these implications and falsely replaces them by named bind variables.&lt;/p&gt;

&lt;p&gt;Replacement code with example:&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-java&quot;&gt;&amp;lt;?php
$s = &apos;-- Testkomm?ntar
	select	/* ? *&lt;span class=&quot;code-comment&quot;&gt;//* ??? */ ?||\&apos;H&lt;span class=&quot;code-quote&quot;&gt;&quot;al?l&quot;&lt;/span&gt;o?\&apos; as &lt;span class=&quot;code-quote&quot;&gt;&quot;h?&quot;&lt;/span&gt;&lt;span class=&quot;code-quote&quot;&gt;&quot;llo&quot;&lt;/span&gt; union /* &lt;span class=&quot;code-quote&quot;&gt;&quot;? Kommentar&quot;&lt;/span&gt; \&apos; */
&lt;/span&gt;	/* ?&quot; */ select \&apos;/*Hallo\&apos;||to_char( ? ) union select \&apos;--Welt\&apos;
	union--
	select ?&apos;;

echo &apos;In: &apos; . $s . PHP_EOL;

$bind = 0;
$skip = array( &apos;--&apos; =&amp;gt; PHP_EOL, &apos;/*&apos; =&amp;gt; &apos;*/&apos;, &apos;&lt;span class=&quot;code-quote&quot;&gt;&quot;&apos; =&amp;gt; &apos;&quot;&lt;/span&gt;&apos;, &lt;span class=&quot;code-quote&quot;&gt;&quot;&apos;&quot;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&quot;&apos;&quot;&lt;/span&gt; );
&lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt;( $i = 0; $i &amp;lt; strlen( $s ) /* size of string might change! */; /* yes, no increment here! */ )
{
	&lt;span class=&quot;code-comment&quot;&gt;// Skipping comments and literals
&lt;/span&gt;	foreach( $skip as $begin =&amp;gt; $end )
	{
		$matches = substr_compare( $s, $begin, $i, strlen( $begin ) );
		&lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt;( $matches !== &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt; &amp;amp;&amp;amp; $matches == 0 )
		{
			$pos = strpos( $s, $end, $i+strlen( $begin ) );
			&lt;span class=&quot;code-comment&quot;&gt;// echo &lt;span class=&quot;code-quote&quot;&gt;&quot;Found $begin, skipping at $i to $end at $pos&quot;&lt;/span&gt; . PHP_EOL;
&lt;/span&gt;			&lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt;( $pos === &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt; )
			{
				&lt;span class=&quot;code-comment&quot;&gt;// No more data or illegal statement - anyway: no more replacements!
&lt;/span&gt;				&lt;span class=&quot;code-comment&quot;&gt;// echo &lt;span class=&quot;code-quote&quot;&gt;&quot;EOD&quot;&lt;/span&gt; . PHP_EOL;
&lt;/span&gt;				&lt;span class=&quot;code-keyword&quot;&gt;break&lt;/span&gt; 2;
			}
			$i = $pos + strlen( $end );
			&lt;span class=&quot;code-keyword&quot;&gt;continue&lt;/span&gt; 2; &lt;span class=&quot;code-comment&quot;&gt;// Ensure we match /*..*//*..*/, &apos;&apos;&apos;&apos; or &quot;&quot;&quot;&quot; - that&apos;s why we don&apos;t ++$i in the &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt;-loop!
&lt;/span&gt;		}
	}
	&lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt;( $s[$i] == &lt;span class=&quot;code-quote&quot;&gt;&quot;?&quot;&lt;/span&gt; )
	{
		&lt;span class=&quot;code-comment&quot;&gt;// Positional to named
&lt;/span&gt;		&lt;span class=&quot;code-comment&quot;&gt;// echo &lt;span class=&quot;code-quote&quot;&gt;&quot;Replace $bind&quot;&lt;/span&gt; . PHP_EOL;
&lt;/span&gt;		$r = &apos;:name&apos; . ++$bind;
		$s = substr_replace( $s, $r, $i, 1 );
		$i += strlen( $r );
	}
	++$i;
}

echo &apos;Out: &apos; . $s . PHP_EOL;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</description>
                <environment></environment>
            <key id="12654">DBAL-124</key>
            <summary>OCI8 Adapter (convertPositionalToNamedPlaceholders) Statemachine doesn&apos;t consider comments and strings</summary>
                <type id="4" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/improvement.png">Improvement</type>
                                <priority id="3" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/major.png">Major</priority>
                    <status id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="beberlei">Benjamin Eberlei</assignee>
                                <reporter username="chetzel">Carsten Hetzel</reporter>
                        <labels>
                    </labels>
                <created>Fri, 20 May 2011 16:46:25 +0000</created>
                <updated>Tue, 28 Jun 2011 12:45:29 +0000</updated>
                                    <version>2.0.5</version>
                                                <component>Drivers</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                        <comments>
                    <comment id="16024" author="beberlei" created="Sun, 19 Jun 2011 09:06:33 +0000"  >&lt;p&gt;This algorithmus is painfully slow. There has to be something better, why do you need to foreach the loop inside the for?&lt;/p&gt;</comment>
                    <comment id="16088" author="chetzel" created="Tue, 28 Jun 2011 12:41:55 +0000"  >&lt;p&gt;Ok, sent you a PM but I&apos;ll put my response here, too:&lt;/p&gt;

&lt;p&gt;&quot;Painfully slow&quot; at what circumstances? Benchmarks?&lt;/p&gt;

&lt;p&gt;This was meant as an example implementation to show the problems of the current implementation - there&apos;s always room for improvement.&lt;/p&gt;

&lt;p&gt;And never forget: Premature optimization is the root of all evil! ;-p&lt;/p&gt;

&lt;p&gt;You want speed - try this one:&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-java&quot;&gt;&amp;lt;?php
$sql = &apos;-- Testkomm?ntar
        select  /* ? *&lt;span class=&quot;code-comment&quot;&gt;//* ??? */ ?||\&apos;H&lt;span class=&quot;code-quote&quot;&gt;&quot;al?l&quot;&lt;/span&gt;o?\&apos; as &lt;span class=&quot;code-quote&quot;&gt;&quot;h?&quot;&lt;/span&gt;&lt;span class=&quot;code-quote&quot;&gt;&quot;llo&quot;&lt;/span&gt; union /* &lt;span class=&quot;code-quote&quot;&gt;&quot;? Kommentar&quot;&lt;/span&gt; \&apos; */
&lt;/span&gt;        /* ?&quot; */ select \&apos;/*Hallo\&apos;||to_char( ? ) union select \&apos;--Welt\&apos;
        union--
        select ?&apos;;

echo &apos;In: &apos; . $sql . PHP_EOL;

$map = array();
&lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt;( $cnt = 0; $cnt &amp;lt; 1000; ++$cnt )
{
        $bind = 0;
        $s = $sql;

        &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt;( isset( $map[$s] ) )
                &lt;span class=&quot;code-keyword&quot;&gt;continue&lt;/span&gt;;

        $strlen = strlen( $s );
        &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt;( $i = 0; $i &amp;lt; $strlen /* size of string might change! */; /* yes, no increment here! */ )
        {
                $c1 = $s[$i];
                $c2 = isset( $s[$i+1] ) ? $s[$i+1] : &apos;&apos;;
                &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt;( $c1 == &apos;-&apos; &amp;amp;&amp;amp; $c2 == &apos;-&apos;)
                {
                        $pos = strpos( $s, PHP_EOL, $i+2 );
                        &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt;( $pos === &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt; )
                        {
                                &lt;span class=&quot;code-keyword&quot;&gt;break&lt;/span&gt; 2;
                        }
                        $i = $pos + 2;
                }
                elseif( $c1 == &apos;/&apos; &amp;amp;&amp;amp; $c2 == &apos;*&apos; )
                {
                        $pos = strpos( $s, &apos;*/&apos;, $i+2 );
                        &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt;( $pos === &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt; )
                        {
                                &lt;span class=&quot;code-keyword&quot;&gt;break&lt;/span&gt; 2;
                        }
                        $i = $pos + 2;
                }
                elseif( $c1 == &apos;&quot;&apos; )
                {
                        $pos = strpos( $s, &apos;&quot;&apos;, $i+1 );
                        &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt;( $pos === &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt; )
                        {
                                &lt;span class=&quot;code-keyword&quot;&gt;break&lt;/span&gt; 2;
                        }
                        $i = $pos + 1;
                }
                elseif( $c1 == &lt;span class=&quot;code-quote&quot;&gt;&quot;&apos;&quot;&lt;/span&gt; )
                {
                        $pos = strpos( $s, &lt;span class=&quot;code-quote&quot;&gt;&quot;&apos;&quot;&lt;/span&gt;, $i+1 );
                        &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt;( $pos === &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt; )
                        {
                                &lt;span class=&quot;code-keyword&quot;&gt;break&lt;/span&gt; 2;
                        }
                        $i = $pos + 1;
                }
                elseif( $c1 == &lt;span class=&quot;code-quote&quot;&gt;&quot;?&quot;&lt;/span&gt; )
                {
                        &lt;span class=&quot;code-comment&quot;&gt;// Positional to named
&lt;/span&gt;                        &lt;span class=&quot;code-comment&quot;&gt;// echo &lt;span class=&quot;code-quote&quot;&gt;&quot;Replace $bind&quot;&lt;/span&gt; . PHP_EOL;
&lt;/span&gt;                        $r = &apos;:name&apos; . ++$bind;
                        $s = substr_replace( $s, $r, $i, 1 );
                        $rLen = strlen( $r );
                        $i += $rLen;
                        $strlen += $rLen - 1;
                }
                &lt;span class=&quot;code-keyword&quot;&gt;else&lt;/span&gt;
                        ++$i;
        }
        $map[$sql] = $s;
}
echo &apos;Out: &apos; . $map[$sql] . PHP_EOL;

&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;ATTENTION: Each &quot;break 2;&quot; means, you have an invalid statement! Do, whatever the statement class is supposed to do in this case!&lt;/p&gt;

&lt;p&gt;Regards, Carsten&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>