Re: [sqlite] RPAD/LPAD

2014-03-08 Thread Max Vlasov
On Sat, Mar 8, 2014 at 10:52 AM, Max Vlasov wrote: > On Fri, Mar 7, 2014 at 11:51 PM, Dominique Devienne > wrote: >> >> basically register_function('rpad', 'x', 'y', 'printf(''%-*s'', y, >> x)') would register a 2-arg function (register_function's

Re: [sqlite] RPAD/LPAD

2014-03-07 Thread Max Vlasov
On Fri, Mar 7, 2014 at 11:51 PM, Dominique Devienne wrote: > > basically register_function('rpad', 'x', 'y', 'printf(''%-*s'', y, > x)') would register a 2-arg function (register_function's argc-2) > named $argv[0], which executes the following statement > > with

Re: [sqlite] RPAD/LPAD

2014-03-07 Thread Max Vlasov
On Sat, Mar 8, 2014 at 2:16 AM, Clemens Ladisch wrote: > Eduardo Morras wrote: >> So, if a webapp that uses SQLite doesn't check it's input, functions that >> renames SQLite internals can be injected >> >> SELECT register_simple_function('MAX', 1, 'DROP TABLE ?'); > > Such a

Re: [sqlite] RPAD/LPAD

2014-03-07 Thread Clemens Ladisch
Dominique Devienne wrote: >> On Fri, Mar 7, 2014 at 6:39 PM, Clemens Ladisch wrote: >>> SELECT register_simple_function('rpad', 2, 'SELECT printf(''%-*s'', ?, ?)'); > > But doesn't the above assume you can bind values inside the select > clause? I thought one couldn't...

Re: [sqlite] RPAD/LPAD

2014-03-07 Thread Clemens Ladisch
Eduardo Morras wrote: > Clemens Ladisch wrote: >> Actually, no change to SQLite itself would be needed. It's possible >> to create an extension that provides a function that allows to >> register another function that executes a custom SQL expression: >> >> SELECT

Re: [sqlite] RPAD/LPAD

2014-03-07 Thread Dominique Devienne
On Fri, Mar 7, 2014 at 10:19 PM, Eduardo Morras wrote: > On Fri, 07 Mar 2014 15:39:57 +0100 > Clemens Ladisch wrote: > >> Actually, no change to SQLite itself would be needed. It's possible >> to create an extension that provides a function that allows to

Re: [sqlite] RPAD/LPAD

2014-03-07 Thread Eduardo Morras
On Fri, 07 Mar 2014 15:39:57 +0100 Clemens Ladisch wrote: > Actually, no change to SQLite itself would be needed. It's possible > to create an extension that provides a function that allows to > register another function that executes a custom SQL expression: > > SELECT

Re: [sqlite] RPAD/LPAD

2014-03-07 Thread Dominique Devienne
On Fri, Mar 7, 2014 at 7:37 PM, Max Vlasov wrote: > On Fri, Mar 7, 2014 at 6:39 PM, Clemens Ladisch wrote: >> Max Vlasov wrote: >>> >>> Nice suggestion. This probably falls into case when a small new part >>> needed on sqlite side >> >> Actually, no

Re: [sqlite] RPAD/LPAD

2014-03-07 Thread Max Vlasov
On Fri, Mar 7, 2014 at 6:39 PM, Clemens Ladisch wrote: > Max Vlasov wrote: >> >> Nice suggestion. This probably falls into case when a small new part >> needed on sqlite side > > Actually, no change to SQLite itself would be needed. It's possible > to create an extension that

Re: [sqlite] RPAD/LPAD

2014-03-07 Thread Dominique Devienne
On Fri, Mar 7, 2014 at 5:27 PM, Eleytherios Stamatogiannakis wrote: > IMHO, SQLite is targeted towards being a relational "core" with very wide > extensibility. Adding specific scripting engines to it is would be > detrimental to its main purpose (being a very good relational

Re: [sqlite] RPAD/LPAD

2014-03-07 Thread Eleytherios Stamatogiannakis
IMHO, SQLite is targeted towards being a relational "core" with very wide extensibility. Adding specific scripting engines to it is would be detrimental to its main purpose (being a very good relational "core"). In our group, we use SQLite + UDFs written in Python. Creating new functions is

Re: [sqlite] RPAD/LPAD

2014-03-07 Thread Dominique Devienne
On Fri, Mar 7, 2014 at 3:39 PM, Clemens Ladisch wrote: > Max Vlasov wrote: >> On Fri, Mar 7, 2014 at 12:49 PM, Dominique Devienne >> wrote: >>> I think what SQLite lacks is a syntax to define custom function like >>> it does for virtual tables. Something

Re: [sqlite] RPAD/LPAD

2014-03-07 Thread Clemens Ladisch
Max Vlasov wrote: > On Fri, Mar 7, 2014 at 12:49 PM, Dominique Devienne > wrote: >> I think what SQLite lacks is a syntax to define custom function like >> it does for virtual tables. Something like: >> >> create function rpad(x, y) using scripty_module as "return >>

Re: [sqlite] RPAD/LPAD

2014-03-07 Thread Dominique Devienne
On Fri, Mar 7, 2014 at 11:29 AM, Max Vlasov wrote: > On Fri, Mar 7, 2014 at 12:49 PM, Dominique Devienne > wrote: >> I think what SQLite lacks is a syntax to define custom function like >> it does for virtual tables. Something like: >> >> create

Re: [sqlite] RPAD/LPAD

2014-03-07 Thread Max Vlasov
On Fri, Mar 7, 2014 at 12:49 PM, Dominique Devienne wrote: > I think what SQLite lacks is a syntax to define custom function like > it does for virtual tables. Something like: > > create function rpad(x, y) using scripty_module as "return > PRINTF('%-*s',y,x)"; > Nice

Re: [sqlite] RPAD/LPAD

2014-03-07 Thread Dominique Devienne
On Fri, Mar 7, 2014 at 10:07 AM, Eduardo Morras wrote: > Creating extensions in SQLite is not difficult nor hard. You can define yours > with this line: It's no hard, no, if you're already a C developer. But it's hardly convenient when you need something quickly. Between

Re: [sqlite] RPAD/LPAD

2014-03-07 Thread Eduardo Morras
On Thu, 6 Mar 2014 22:41:31 -0500 Gabor Grothendieck wrote: > On Thu, Mar 6, 2014 at 8:41 PM, RSmith wrote: > > > > On 2014/03/07 01:59, Gabor Grothendieck wrote: > >> > >> > >>> > > > A small enhancement request: > > > > It would be

Re: [sqlite] RPAD/LPAD

2014-03-07 Thread Dominique Devienne
On Fri, Mar 7, 2014 at 7:38 AM, Zsbán Ambrus wrote: > On 3/7/14, RSmith wrote: >> Add to this the fact that you can - through SQL's ability to add >> user-defined functions (an almost unique ability among SQL engines) > > Is that really so? I thought most

Re: [sqlite] RPAD/LPAD

2014-03-06 Thread Zsbán Ambrus
On 3/7/14, RSmith wrote: > Add to this the fact that you can - through SQL's ability to add > user-defined functions (an almost unique ability among SQL engines) Is that really so? I thought most sql engines had that. You can define functions in at least postgreSQL:

Re: [sqlite] RPAD/LPAD

2014-03-06 Thread Gabor Grothendieck
On Thu, Mar 6, 2014 at 8:41 PM, RSmith wrote: > > On 2014/03/07 01:59, Gabor Grothendieck wrote: >> >> >>> > A small enhancement request: > > It would be great if the RPAD and LPAD functions could be implemented > in > sqlite. > The SQLite you

Re: [sqlite] RPAD/LPAD

2014-03-06 Thread RSmith
On 2014/03/07 01:59, Gabor Grothendieck wrote: A small enhancement request: It would be great if the RPAD and LPAD functions could be implemented in sqlite. The SQLite you can get the effect of RPAD(x,y) using PRINTF('%-*s',y,x). See http://www.sqlite.org/lang_corefunc.html#printf for

Re: [sqlite] RPAD/LPAD

2014-03-06 Thread Gabor Grothendieck
On Thu, Mar 6, 2014 at 6:29 PM, Walter Hurry wrote: > Richard Hipp wrote: > >> On Thu, Mar 6, 2014 at 3:41 PM, Walter Hurry wrote: >> >>> A small enhancement request: >>> >>> It would be great if the RPAD and LPAD functions could be implemented in

Re: [sqlite] RPAD/LPAD

2014-03-06 Thread Walter Hurry
Richard Hipp wrote: > On Thu, Mar 6, 2014 at 3:41 PM, Walter Hurry wrote: > >> A small enhancement request: >> >> It would be great if the RPAD and LPAD functions could be implemented in >> sqlite. >> > > The SQLite you can get the effect of RPAD(x,y) using

Re: [sqlite] RPAD/LPAD

2014-03-06 Thread Richard Hipp
On Thu, Mar 6, 2014 at 3:41 PM, Walter Hurry wrote: > A small enhancement request: > > It would be great if the RPAD and LPAD functions could be implemented in > sqlite. > The SQLite you can get the effect of RPAD(x,y) using PRINTF('%-*s',y,x). See

[sqlite] RPAD/LPAD

2014-03-06 Thread Walter Hurry
A small enhancement request: It would be great if the RPAD and LPAD functions could be implemented in sqlite. I know I can easily achieve the equivalent by concatenating and TRUNCing, but if the functions were available natively it would avoid the need to hack third party SQL scripts. Dr.