View Issue Details

IDProjectCategoryView StatusLast Update
0022463FPCDatabasepublic2015-10-10 11:38
ReporterMark Morgan Lloyd Assigned ToLacaK  
Status closedResolutionfixed 
Fixed in Version3.0.0 
Summary0022463: IDE creates a spurious TQuery property when parsing complex SQL
DescriptionAttached project has a moderately complex query embedded in the TQuery object. On Lazarus trunk 36903 this works fine, but at some point after that the query parsing has changed so that it thinks it's seeing a spurious parameter called 00'::interval as well as the correct one (tz). In all cases with FPC 2.7.1, revision appears not to matter as long as the IDE etc. compiles.

I've got this on SPARC (Solaris+Linux), PPC (Linux), x86 (Linux). Not tried ARM or Windows. Project doesn't need to be compiled to see the problem, only opened.
Additional InformationI've tried to simplify the SQL with limited success. At one point I thought I was able to demonstrate the problem with 0000004:0000004 lines of query, but when I restarted the IDE it had gone.
TagsNo tags attached.
Fixed in Revision31155
Attached Files


2012-07-18 18:48


bad_sql_params.tar.gz (129,071 bytes)

Mark Morgan Lloyd

2012-07-19 10:51

reporter   ~0061133

Last edited: 2012-07-19 11:10

I've got this down to six lines of more-or-less-valid SQL:

-- WATCH IT: any columns/fields of a type which aren't understood by
SELECT coalesce(
    (SELECT utc_offset FROM pg_timezone_names WHERE name = :tz),

Lazarus incorrectly parses a parameter 00'::interval out of that, instead of seeing tz. Removing the first comment line or changing the apostrophe in the second appears to fix it.

This might not be the only issue, since removing the comment from the original query or moving it to the end still results in a spurious parameter (i.e. both 00'::interval and tz).


2012-07-19 11:22

reporter   ~0061135

What is stored in LineEnding ? (0000010?)

I try it on Windows with small test program:
with SQLQuery1 do begin
            '-- WATCH IT: any columns/fields of a type which aren''t understood by'+LineEnding+
            'SELECT coalesce((SELECT utc_offset FROM pg_timezone_names WHERE name = :tz),'+LineEnding+

but there is result correct = "tz"

Parsing of SQL text is performed in in Function TParams.ParseSQL, so you can look there to find problem.

Mark Morgan Lloyd

2012-07-19 12:14

reporter   ~0061137

Those "snip" lines were my indication of the start and end of my example: I explicitly said that I'd got it down to SIX lines (but adding them here at design time doesn't change things). Try putting them in the SQL property of the TSQLQuery object (i.e. as in the example project I attached with the original report), this is a design-time issue.

I'll try to look at that function later, thanks for the pointer.


2015-06-25 10:47

reporter   ~0084707

Please move to FPC project as is seems be problem with parameter parsing


2015-06-25 15:07

reporter   ~0084710

Last edited: 2015-06-26 10:05

View 2 revisions

@Mark please retest and if error is still showed, then please let us know (but I was not able reproduce on Windows).

Edit: I am able now reproduce with attached test22463.pas


2015-06-26 10:04


test22463.pas (3,999 bytes)

Mark Morgan Lloyd

2015-10-10 11:38

reporter   ~0086410

Fix confirmed for original app with Lazarus 1.4.2 and FPC 3.0 rc1.

Apologies for the delay testing, but there were other issues in the same app (PostgreSQL LISTEN/NOTIFY).

Issue History

Date Modified Username Field Change
2012-07-18 18:48 Mark Morgan Lloyd New Issue
2012-07-18 18:48 Mark Morgan Lloyd File Added: bad_sql_params.tar.gz
2012-07-18 18:48 Mark Morgan Lloyd Widgetset => GTK 2
2012-07-19 10:51 Mark Morgan Lloyd Note Added: 0061133
2012-07-19 11:10 Mark Morgan Lloyd Note Edited: 0061133
2012-07-19 11:22 LacaK Note Added: 0061135
2012-07-19 12:14 Mark Morgan Lloyd Note Added: 0061137
2015-06-25 10:47 LacaK Note Added: 0084707
2015-06-25 14:04 Maxim Ganetsky Project Lazarus => FPC
2015-06-25 15:07 LacaK Note Added: 0084710
2015-06-25 15:07 LacaK Assigned To => LacaK
2015-06-25 15:07 LacaK Status new => feedback
2015-06-26 10:04 LacaK File Added: test22463.pas
2015-06-26 10:05 LacaK Note Edited: 0084710 View Revisions
2015-06-26 10:07 LacaK Fixed in Revision => 31155
2015-06-26 10:07 LacaK Status feedback => resolved
2015-06-26 10:07 LacaK Fixed in Version => 3.1.1
2015-06-26 10:07 LacaK Resolution open => fixed
2015-08-30 22:44 Joost van der Sluis Fixed in Version 3.1.1 => 3.0.1
2015-10-10 11:38 Mark Morgan Lloyd Note Added: 0086410
2015-10-10 11:38 Mark Morgan Lloyd Status resolved => closed