Re: [Firebird-devel] where is ':' valid in Firebird SQL?

2018-01-03 Thread Lionel Elie Mamane
On Wed, Jan 03, 2018 at 06:57:21AM +0100, Lionel Elie Mamane wrote:

> Where is ':' a valid character in Firebird SQL? In particular, is it
> ever valid outside of "-delimited identifiers and '-delimited
> strings?

Thanks everybody for your help. I see my idea was not realistic. After
sleeping on it, I realised I could reengineer some part of LibreOffice
to make this unnecessary, and fix other bugs than the one I was
chasing at the same time.

Best Regards,

Lionel

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel


[Firebird-devel] [FB-Tracker] Created: (CORE-5693) EXTRACT(QUARTER FROM )

2018-01-03 Thread Kovalenko Dmitry (JIRA)
EXTRACT(QUARTER FROM )
--

 Key: CORE-5693
 URL: http://tracker.firebirdsql.org/browse/CORE-5693
 Project: Firebird Core
  Issue Type: New Feature
  Components: Engine
Affects Versions: 3.0.3
Reporter: Kovalenko Dmitry


I'm surprised that Firebird (v3) still not support QUARTER in EXTRACT statement.

It has a serious reason?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://tracker.firebirdsql.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira



--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel


Re: [Firebird-devel] where is ':' valid in Firebird SQL?

2018-01-03 Thread Vlad Khorsun via Firebird-devel

03.01.2018 7:57, Lionel Elie Mamane wrote:


I'd like to avoid completely parsing the SQL statement for that,
mainly so that the SQL statement is not modified by the LibreOffice
SQL parser (and in particular quoting keywords it doesn't know as
identifiers). So I'm hoping to simply go through the string, keep
track of single and double quotes, and replace any word (outside of
quotes) that starts with ':' by '?'. 


  You also need to track mapping between parameters names and
parameters numbers. You may look at EDS::Statement::preprocess()
for example (see at \src\jrd\extds\ExtDS.cpp)

Hope it helps,
Vlad

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel


Re: [Firebird-devel] where is ':' valid in Firebird SQL?

2018-01-03 Thread Dmitry Yemanov

03.01.2018 08:57, Lionel Elie Mamane wrote:


I'd like to avoid completely parsing the SQL statement for that,
mainly so that the SQL statement is not modified by the LibreOffice
SQL parser (and in particular quoting keywords it doesn't know as
identifiers). So I'm hoping to simply go through the string, keep
track of single and double quotes, and replace any word (outside of
quotes) that starts with ':' by '?'.


You will need to track comments (both block and single-line) as well.


Dmitry

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel


Re: [Firebird-devel] where is ':' valid in Firebird SQL?

2018-01-03 Thread Adriano dos Santos Fernandes
On 03/01/2018 03:57, Lionel Elie Mamane wrote:
> Hi,
>
> Where is ':' a valid character in Firebird SQL? In particular, is it
> ever valid outside of "-delimited identifiers and '-delimited strings?
>
> Context: In the LibreOffice integration of Firebird, we would like to
> allow users to use named parameters, that is things like ':foo' instead
> of '?' (without the single quotes). E.g.
>
>  SELECT foo, bar FROM qux WHERE item_year = :year
>
> instead of
>
>  SELECT foo, bar FROM qux WHERE item_year = ?
>
> Which means we have to go through the SQL statement passed by the user
> and replace such ':foo' parameters by '?' before giving the SQL
> statement to Firebird.
>
> I'd like to avoid completely parsing the SQL statement for that,
> mainly so that the SQL statement is not modified by the LibreOffice
> SQL parser (and in particular quoting keywords it doesn't know as
> identifiers). So I'm hoping to simply go through the string, keep
> track of single and double quotes, and replace any word (outside of
> quotes) that starts with ':' by '?'. This wouldn't work for
> e.g. PostgreSQL because of its cast syntax (namely 'data::type'), but
> is it OK for Firebird?
>
>
:foo is a valid syntax in Firebird inside PSQL code, i.e., stored
procedures, triggers, execute block.

Example:

execute block returns (foo integer)
as
begin
    select 1 from rdb$database into :foo;
    suspend;
end

It's also valid for input parameters:

execute block (bar integer = ?) returns (foo integer)
as
begin
    select 1 from rdb$database where 1 = :bar into :foo;
    suspend;
end


Adriano


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel