SCM

[#1010187] Problem with parsing parameters and "<" or ">" operator with Prepare()

View Trackers | Bugs | Download .csv | Monitor

Date:
2007-11-15 16:09
Priority:
3
State:
Open
Submitted by:
Hubert FONGARNAND (hubertf)
Assigned to:
Nobody (None)
Npgsql Version:
None
Category:
Group:
Resolution:
None
Summary:
Problem with parsing parameters and "<" or ">" operator with Prepare()

Detailed description
Try this code :
NpgsqlConnection cnx = new NpgsqlConnection(cnxString);
cnx.Open();
NpgsqlCommand cmd=cnx.CreateCommand();
(cmd.Parameters.Add(":ppwd",NpgsqlDbType.Text)).Value = "bla";
cmd.CommandText="select * from intra_utilisateur where mot_de_passe >:ppwd";
cmd.Prepare();
cmd.ExecuteNonQuery();
cnx.Close();

This fails with:
Unhandled Exception: System.IndexOutOfRangeException: Parameter :ppwd not found in query.
at Npgsql.NpgsqlCommand.ReplaceParameterValue (System.String result, System.String parameterName, System.String paramVal) [0x00179] in /home/hubert/mono/mcs/class/Npgsql/Npgsql/NpgsqlCommand.cs:1416
at Npgsql.NpgsqlCommand.GetParseCommandText () [0x000d3] in /home/hubert/mono/mcs/class/Npgsql/Npgsql/NpgsqlCommand.cs:1271
at Npgsql.NpgsqlCommand.Prepare () [0x000a4] in /home/hubert/mono/mcs/class/Npgsql/Npgsql/NpgsqlCommand.cs:76

if you had a space after ">" in the CommandText, it would have worked...

It seems to be a problem with the parameter parsing regexp when using prepared statement

Followup

Message
Date: 2007-11-15 16:18
Sender: Hubert FONGARNAND

patch to fix the problem
Index: Npgsql/NpgsqlCommand.cs
===================================================================
--- Npgsql/NpgsqlCommand.cs (révision 89671)
+++ Npgsql/NpgsqlCommand.cs (copie de travail)

@@ -1373,7 +1374,7 @@
{

String quote_pattern = @"['][^']*[']";
- String pattern = "[- |\n\r\t,)(;=+/]" +
parameterName + "([- |\n\r\t,)(;=+/]|$)";
+ String pattern = "[- |\n\r\t,)(;=+/<>]" +
parameterName + "([- |\n\r\t,)(;=+/<>]|$)";
Int32 start, end;
String withoutquote = result;
Boolean found = false;

Attached Files:

Changes:

Field Old Value Date By
summaryProblem with parsing parameters and "<" or ">" operator with Prepare()2007-11-15 16:18hubertf
Powered By FusionForge