Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Real Users are afraid they'll break the machine -- but they're never afraid to break your face.


devel / comp.lang.tcl / Re: Substituting variable

SubjectAuthor
* Substituting variableCecil Westerhof
+- Substituting variableRich
+- Substituting variableheinrichmartin
+* Substituting variableAlan Grunwald
|`* Substituting variableCecil Westerhof
| +* Substituting variableRich
| |+- Substituting variableCecil Westerhof
| |`* Substituting variableRalf Fassel
| | +* Substituting variablegreg
| | |`- Substituting variablegreg
| | +* Substituting variableCecil Westerhof
| | |`* Substituting variableRich
| | | `- Substituting variablegreg
| | `* Substituting variableSchelte
| |  `* Substituting variableCecil Westerhof
| |   +* Substituting variableSchelte
| |   |`* Substituting variableCecil Westerhof
| |   | `- Substituting variableSchelte
| |   `* Substituting variableRolf Ade
| |    +- Substituting variablegreg
| |    `* Substituting variableCecil Westerhof
| |     `- Substituting variableRalf Fassel
| `* Substituting variableAlan Grunwald
|  `- Substituting variableCecil Westerhof
`* Substituting variableMole Cool
 +* Substituting variableHarald Oehlmann
 |`* Substituting variableMole Cool
 | `* Substituting variableRich
 |  `* Substituting variableMole Cool
 |   `- Substituting variableRich
 `* Substituting variableCecil Westerhof
  `* Substituting variablerene
   `- Substituting variableCecil Westerhof

Pages:12
Re: Substituting variable

<875y2tfqdn.fsf@munus.decebal.nl>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12332&group=comp.lang.tcl#12332

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Cec...@decebal.nl (Cecil Westerhof)
Newsgroups: comp.lang.tcl
Subject: Re: Substituting variable
Date: Thu, 26 Oct 2023 15:46:28 +0200
Organization: Decebal Computing
Lines: 58
Message-ID: <875y2tfqdn.fsf@munus.decebal.nl>
References: <87bkcpgi1k.fsf@munus.decebal.nl> <uh8a7p$3rmmh$1@dont-email.me>
<877cncgl6r.fsf@munus.decebal.nl> <uh8sem$2h6g$1@dont-email.me>
<yga4jie7nxv.fsf@panther.akutech-local.de>
<nnd$7fcbe8cf$2c865a41@696810f06d9d5f9b> <87h6mefhv9.fsf@munus.decebal.nl>
<87r0li87i0.fsf@pointsman.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="a8a6a3348a36ae84d8a380c80d6127c3";
logging-data="1726721"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19OcZcfqwuIr+3Z8CknGyusFc4hGxaaStA="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:Q404UaplBiuVUvmVT5CLKVZ7E/Q=
sha1:Tr6YCQvWf77tK4mTVua8AAFDb8g=
 by: Cecil Westerhof - Thu, 26 Oct 2023 13:46 UTC

Rolf Ade <rolf@pointsman.de> writes:

> Cecil Westerhof <Cecil@decebal.nl> writes:
>> Schelte <nospam@wanadoo.nl> writes:
>>
>>> On 25/10/2023 16:54, Ralf Fassel wrote:
>>>> These docs state that db1 eval {INSERT INTO t1 VALUES(5,:bigstring)}
>>>> and db1 eval {INSERT INTO t1 VALUES(5,$bigstring)} are equivalent, so
>>>> I wonder why the original approach did not work?
>>>
>>> Because the OP insists on writing his variables as ${startWeek} etc. Had
>>> he used $startWeek, it would have worked.
>>
>> You do not know what you are talking about, that is completely b***t.
>> You may not like how I write my variables, but that does not mean it
>> is wrong.
>
> No reason for strong words.

You are completely right: I should not have let my annoyment let get
the better of me. 😢

When I rewrite the set to:
set selectWeek {
SELECT strftime('%W', dayDate, '+1 day') AS WeekNo
, COUNT(*) AS Days
, SUM(dayViews) AS WeekTotals
FROM dayViews
WHERE WeekNo >= $startWeek
AND WeekNo <= $endWeek
GROUP BY WeekNo
ORDER BY WeekNo
}

Then the following works without a hitch:
db eval ${selectWeek} {

I prefer :startWeek instead of $startWeek, but that is my quirk.

It is no excuse for my reaction, but I was annoyed by for example that
I was told that I should have used:
set selectWeek "
instead of:
set selectWeek {

Which is really wrong.
Once I wrote several posts in which I shared code and someone changed
all my posts from ${variable} to $variable (without changing anything
else). Which I really did not appreciate.

But two wrongs do not make a right.
Next time I need to count to ten, or twenty-five, or …

--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

Re: Substituting variable

<uheujc$1tg2u$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12342&group=comp.lang.tcl#12342

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ric...@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: Substituting variable
Date: Fri, 27 Oct 2023 00:00:44 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <uheujc$1tg2u$1@dont-email.me>
References: <87bkcpgi1k.fsf@munus.decebal.nl> <uh8a7p$3rmmh$1@dont-email.me> <877cncgl6r.fsf@munus.decebal.nl> <uh8sem$2h6g$1@dont-email.me> <yga4jie7nxv.fsf@panther.akutech-local.de> <87ttqefydl.fsf@munus.decebal.nl>
Injection-Date: Fri, 27 Oct 2023 00:00:44 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b6a3fc44c5c433a7daa596b0156ede9";
logging-data="2015326"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX199BlgJqeOm2lY3t7sJjZwI"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.117 (x86_64))
Cancel-Lock: sha1:kIkAX2mom+Wz6eVw8+irV2uyGvw=
 by: Rich - Fri, 27 Oct 2023 00:00 UTC

Cecil Westerhof <Cecil@decebal.nl> wrote:
>
> Because I do not use a 'local' list, but a 'global' string variable:
> db1 eval ${commandStr}

{} around a variable name does not mean a global variable. Using {}
around the name is just escaping the characters of the name such that
any Tcl metacharacters in the name are not interpreted by the Tcl
interpreter.

Re: Substituting variable

<708d933f-ccaf-4bc4-a8bb-4bb9b98cc02an@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12343&group=comp.lang.tcl#12343

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:622a:7606:b0:41c:b480:df9b with SMTP id kg6-20020a05622a760600b0041cb480df9bmr27406qtb.7.1698383148962;
Thu, 26 Oct 2023 22:05:48 -0700 (PDT)
X-Received: by 2002:a05:6808:182a:b0:3b2:f40e:9493 with SMTP id
bh42-20020a056808182a00b003b2f40e9493mr445950oib.6.1698383148607; Thu, 26 Oct
2023 22:05:48 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!border-2.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Thu, 26 Oct 2023 22:05:48 -0700 (PDT)
In-Reply-To: <uheujc$1tg2u$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=185.250.212.6; posting-account=99ziWAoAAADLScDbI_CyfIcpa_gFZ0zh
NNTP-Posting-Host: 185.250.212.6
References: <87bkcpgi1k.fsf@munus.decebal.nl> <uh8a7p$3rmmh$1@dont-email.me>
<877cncgl6r.fsf@munus.decebal.nl> <uh8sem$2h6g$1@dont-email.me>
<yga4jie7nxv.fsf@panther.akutech-local.de> <87ttqefydl.fsf@munus.decebal.nl> <uheujc$1tg2u$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <708d933f-ccaf-4bc4-a8bb-4bb9b98cc02an@googlegroups.com>
Subject: Re: Substituting variable
From: gregor.e...@googlemail.com (greg)
Injection-Date: Fri, 27 Oct 2023 05:05:48 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 57
 by: greg - Fri, 27 Oct 2023 05:05 UTC

Variable
TCL
https://www.tcl.tk/man/tcl/TclCmd/Tcl.html#M12

$name variable substitution yes
${name) variable substitution yes
:name variable substitution no
no difference by $name and ${name}
and
:name is not recognized as a variable

SQLITE
https://www.sqlite.org/draft/tokenreq.html
https://www.sqlite.org/tclsqlite.html

$name variable substitution yes
${name) variable substitution no
:name variable substitution yes
@name variable substitution (yes)
and
difference by $name and ${name}
${name} is not recognized as a variable
:name is recognized as variable

####

Processing
TCL parsed statement to tclstmt => SQLITE parsed tclstmt to sqlitestmt

""
statement in "stmt" then in tclstmt with variablevalue
${name) is by TCL interpreted as variablevalue

{}
statement in {stmt} then in tclstmt with variablename
${name} is not recognized as a variable by SQLITE

#####
Solution:
statement in "stmt" and variable in ''

package require sqlite3
sqlite3 db :memory:
db eval {
CREATE TABLE something(key text, value text);
INSERT INTO something(key, value)
VALUES('foo', 'foovalue');
INSERT INTO something(key, value)
VALUES('bar', 'barvalue')
} set thiskey "bar"

puts [db eval "
SELECT value FROM something
WHERE key = '${thiskey}'
"]

Re: Substituting variable

<ygajzr5a2s0.fsf@panther.akutech-local.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12367&group=comp.lang.tcl#12367

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: ralf...@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.tcl
Subject: Re: Substituting variable
Date: Sun, 29 Oct 2023 16:04:15 +0100
Lines: 8
Message-ID: <ygajzr5a2s0.fsf@panther.akutech-local.de>
References: <87bkcpgi1k.fsf@munus.decebal.nl> <uh8a7p$3rmmh$1@dont-email.me>
<877cncgl6r.fsf@munus.decebal.nl> <uh8sem$2h6g$1@dont-email.me>
<yga4jie7nxv.fsf@panther.akutech-local.de>
<nnd$7fcbe8cf$2c865a41@696810f06d9d5f9b>
<87h6mefhv9.fsf@munus.decebal.nl> <87r0li87i0.fsf@pointsman.de>
<875y2tfqdn.fsf@munus.decebal.nl>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net 4xhIN9eFUzzNGdB5ojLfIwtnldoVGT4/2mxTWnG/bC5Gx9aoc=
Cancel-Lock: sha1:cf4F5B79kFevAScnH8t3DYSxkj4= sha1:/MhlKSNGED4YADccb60Ywi1ZarY= sha256:iWNb/nZ70yxYueramfqAZRdIJRDwSnlxOt7YMJKs8OI=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
 by: Ralf Fassel - Sun, 29 Oct 2023 15:04 UTC

* Cecil Westerhof <Cecil@decebal.nl>
| I prefer :startWeek instead of $startWeek, but that is my quirk.

Not your quirk, IMHO, since in *this* context, :startWeek is actually
to be preferred, since it avoids the evaluation of the variable by TCL
for sure (if for example later edits change the surrounding {} to "").

R'

Re: Substituting variable

<9a01b8de-360a-43d6-a6be-157c5aa15ad3n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12410&group=comp.lang.tcl#12410

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:ac8:5045:0:b0:412:1974:9730 with SMTP id h5-20020ac85045000000b0041219749730mr85495qtm.5.1700392105677;
Sun, 19 Nov 2023 03:08:25 -0800 (PST)
X-Received: by 2002:a17:90a:b106:b0:27d:3819:8129 with SMTP id
z6-20020a17090ab10600b0027d38198129mr1154429pjq.5.1700392105351; Sun, 19 Nov
2023 03:08:25 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Sun, 19 Nov 2023 03:08:24 -0800 (PST)
In-Reply-To: <uhafkd$jht1$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2003:ee:970b:c00:fce0:1983:7346:c735;
posting-account=IpC1pwoAAACCAmF-qbg4PWxvUAd-j7Tc
NNTP-Posting-Host: 2003:ee:970b:c00:fce0:1983:7346:c735
References: <87bkcpgi1k.fsf@munus.decebal.nl> <c29c7452-0398-48a1-bc2c-7044c1454800n@googlegroups.com>
<uhafkd$jht1$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <9a01b8de-360a-43d6-a6be-157c5aa15ad3n@googlegroups.com>
Subject: Re: Substituting variable
From: molecool...@googlemail.com (Mole Cool)
Injection-Date: Sun, 19 Nov 2023 11:08:25 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 1413
 by: Mole Cool - Sun, 19 Nov 2023 11:08 UTC

I don’t get your point, if it gets substituted then there is no different if you use $CustId or :CustId because your data contains an sql statement.

Re: Substituting variable

<ujdi4f$3t69p$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12413&group=comp.lang.tcl#12413

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!nntp.comgw.net!paganini.bofh.team!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ric...@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: Substituting variable
Date: Sun, 19 Nov 2023 17:54:23 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 57
Message-ID: <ujdi4f$3t69p$1@dont-email.me>
References: <87bkcpgi1k.fsf@munus.decebal.nl> <c29c7452-0398-48a1-bc2c-7044c1454800n@googlegroups.com> <uhafkd$jht1$1@dont-email.me> <9a01b8de-360a-43d6-a6be-157c5aa15ad3n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 19 Nov 2023 17:54:23 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c00e3f692bf33595523a3a3e1996f721";
logging-data="4102457"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18cJAe+LP7nc1tGzSAVrcay"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.117 (x86_64))
Cancel-Lock: sha1:SAetIJHFahTse3KschKpvXutADQ=
 by: Rich - Sun, 19 Nov 2023 17:54 UTC

Quoting a bit of the prior article to add context helps everyone
understand what you are referencing. I added back some of Harold's
text below.

Mole Cool <molecool1058@googlemail.com> wrote:
>Harald Oehlmann <wortkarg3@yahoo.com> wrote:
>> If your variable data contains quotes, it must be handled.
>> That is, how SQL Injection attacks work.
>> ...
>> To avoid this, use the ":" syntax. It cares about correct quoting.
>
> I don’t get your point, if it gets substituted then there is no
> different if you use $CustId or :CustId because your data contains an
> sql statement.

The point is that it gets substituted in a different way.

If one does string substitution, i.e.:

set var "purple"
set sql "select item from things where color = '$var';"

Then one has set themselves up for possible SQL Injection attacks. If
the contents of "var" are controllable by someone other than you, the
programmer, then for the above code they could do:

set var "purple'; drop table things;"

And then the substitution would do:

set sql "select item from things where color = '$var';"

producing

select item from things where color = 'purple'; drop table things;

And when the above is sent to your database server it will dutifully
run those two statements, and your "things" table would be gone.

Alternately, using the : syntax, the substitution is not actually
performed as a string substitution. What does to the DB server (or
sqlite driver) is a special sql statement that includes "placeholders"
and separate arguments for each placeholder. So using the : syntax,
the server gets this statement:

select item from things where color = :var

and separately a data item that say ":var" contains "purple'; drop table
things;"

And it executes the statement without string substituting it, so it in
effect runs:

select item from things where color = 'purple''; drop table things;';

And as you likely don't have a color named "purple'; drop table things;"
zero rows return instead of your things table being deleted.

Re: Substituting variable

<4cb5f99f-e0c1-4d5a-b85a-b4a0ea915bfan@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12416&group=comp.lang.tcl#12416

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:ac8:7609:0:b0:421:ac6c:c5c7 with SMTP id t9-20020ac87609000000b00421ac6cc5c7mr173246qtq.9.1700483311056;
Mon, 20 Nov 2023 04:28:31 -0800 (PST)
X-Received: by 2002:a63:b4f:0:b0:59c:fc70:1ca0 with SMTP id
a15-20020a630b4f000000b0059cfc701ca0mr1552272pgl.10.1700483310783; Mon, 20
Nov 2023 04:28:30 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Mon, 20 Nov 2023 04:28:30 -0800 (PST)
In-Reply-To: <ujdi4f$3t69p$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2003:ee:970b:c00:31d0:73b3:57f3:d9a3;
posting-account=IpC1pwoAAACCAmF-qbg4PWxvUAd-j7Tc
NNTP-Posting-Host: 2003:ee:970b:c00:31d0:73b3:57f3:d9a3
References: <87bkcpgi1k.fsf@munus.decebal.nl> <c29c7452-0398-48a1-bc2c-7044c1454800n@googlegroups.com>
<uhafkd$jht1$1@dont-email.me> <9a01b8de-360a-43d6-a6be-157c5aa15ad3n@googlegroups.com>
<ujdi4f$3t69p$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4cb5f99f-e0c1-4d5a-b85a-b4a0ea915bfan@googlegroups.com>
Subject: Re: Substituting variable
From: molecool...@googlemail.com (Mole Cool)
Injection-Date: Mon, 20 Nov 2023 12:28:31 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1738
 by: Mole Cool - Mon, 20 Nov 2023 12:28 UTC

The whole text has a couple of errors and misleading statements!

For example:
select item from things where color = 'purple''; drop table things;';

The statement above will search for "purple'; drop table things;" and will NOT drop the table!

.... where color = :var -- where are the single quotes surrounding :var
Correct subs with ':var' ... where color = 'purple'; drop table things;'

You will get an unrecognized token: !

Re: Substituting variable

<ujfuns$c7hr$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12418&group=comp.lang.tcl#12418

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!paganini.bofh.team!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ric...@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: Substituting variable
Date: Mon, 20 Nov 2023 15:41:48 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 61
Message-ID: <ujfuns$c7hr$1@dont-email.me>
References: <87bkcpgi1k.fsf@munus.decebal.nl> <c29c7452-0398-48a1-bc2c-7044c1454800n@googlegroups.com> <uhafkd$jht1$1@dont-email.me> <9a01b8de-360a-43d6-a6be-157c5aa15ad3n@googlegroups.com> <ujdi4f$3t69p$1@dont-email.me> <4cb5f99f-e0c1-4d5a-b85a-b4a0ea915bfan@googlegroups.com>
Injection-Date: Mon, 20 Nov 2023 15:41:48 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b132caf9042c68abae35a68807001fd8";
logging-data="400955"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Q7ydjxQtUuhxE2yzwF/Cw"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.117 (x86_64))
Cancel-Lock: sha1:/4Wx5Dcgqs1RMRJ77+5MOzudItA=
 by: Rich - Mon, 20 Nov 2023 15:41 UTC

Quoting part of the prior reply helps everyone. Please do so instead
of removing all the quoted material.

Mole Cool <molecool1058@googlemail.com> wrote:
>
> The whole text has a couple of errors and misleading statements!

Only due to your missunderstandings. Otherwise it is correct.

> For example:
> select item from things where color = 'purple''; drop table things;';
>
> The statement above will search for "purple'; drop table things;" and
> will NOT drop the table!

Correct, which is *exactly* what I said in the previous article:

> select item from things where color = 'purple''; drop table things;';
>
> And as you likely don't have a color named "purple'; drop table things;"
> zero rows return instead of your things table being deleted.

Note the next sentence which you omitted from your reply, and which
ends with "instead of your things table being deleted" -- the meaning
of that ending is exactly the same as: "will NOT drop the table".

> ... where color = :var -- where are the single quotes surrounding :var

They are not needed when using the special substitution rules, because
the substitution does not occur by string interpolation

The :var method is sqlite's variant of the simiar method used by the Postgresql
Tcl api:

https://wiki.tcl-lang.org/page/Quick%2Dstart+guide+to+use+of+PostgreSQL+with+Tcl

Recent version of Pgtcl running with fairly recent version of
PostgreSQL can do variable substitutions, which are pretty cool, and
require less quoting and stuff. Observe...

set statement {insert into peopletable values ($1, $2, $3, $4, $5);}

set result [pg_exec $conn $statement $name $address $city $state $zip]

Note how the SQL statement has no single quotes, and not how the
variables are passed separated to pg_exec as additional arguments.
Sqlite just shortcuts things a little by making their : variant reach
into the Tcl interpreter and retreive the variable instead of making
the programmer write the variables out as extra arguments.

> Correct subs with ':var' ... where color = 'purple'; drop table things;'
> You will get an unrecognized token: !

If you put quotes around :var then you don't invoke Sqlite's special
"reach into the Tcl interpreter and retreive the contents of this
variable" mode, and you query for the literal string ":var", which
would search for the literal string ":var". To invoke the special,
sql-injection safe mode, you don't surround the :var or @var strings
with quotes.

Pages:12
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor