Skip to contentSkip to conversation

libdnf: Use single-quotes around string literals used in SQL statements

PATCH In review Peter Kjellerstedt 2 participants 4 messages May 4, 2020 – May 11, 2020

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 libdnf: Use single-quotes around string literals used in SQL statements

If sqlite is built with -DSQLITE_DQS=0 in accordance with
https://sqlite.org/quirks.html#dblquote, migration to version 1.2 of the history database would fail with:

History database cannot be created: .../var/lib/dnf/history.sqlite.
Error: SQLite error on ":memory:": Executing an SQL statement failed:
no such column: 1.2

---

PATCH v2: Updated the Upstream-Status to Accepted.

 ...s-around-string-literals-used-in-SQL.patch | 36 +++++++++++++++++++
 meta/recipes-devtools/libdnf/libdnf_0.47.0.bb |  1 +
 2 files changed, 37 insertions(+)
 create mode 100644 meta/recipes-devtools/libdnf/libdnf/0001-Use-single-quotes-around-string-literals-used-in-SQL.patch
meta/recipes-devtools/libdnf/libdnf/0001-Use-single-quotes-around-string-literals-used-in-SQL.patch new file +36 -0
new file mode 100644
index 0000000000..293bdcdd24
@@ -0,0 +1,36 @@
+From 96ca7d0049461df2293dd0000edcbc69b64255e0 Mon Sep 17 00:00:00 2001
+From: Peter Kjellerstedt <[email protected]>
+Date: Sun, 3 May 2020 22:40:39 +0200
+Subject: [PATCH] Use single-quotes around string literals used in SQL
+ statements
+
+If sqlite is built with -DSQLITE_DQS=0 in accordance with
+https://sqlite.org/quirks.html#dblquote, migration to version 1.2 of the
+history database would fail with:
+
+  History database cannot be created: /var/lib/dnf/history.sqlite.
+  Error: SQLite error on ":memory:": Executing an SQL statement failed:
+  no such column: 1.2
+
+Upstream-Status: Accepted [https://github.com/rpm-software-management/libdnf/pull/951]
+Signed-off-by: Peter Kjellerstedt <[email protected]>
+---
+ libdnf/transaction/sql/migrate_tables_1_2.sql | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/libdnf/transaction/sql/migrate_tables_1_2.sql b/libdnf/transaction/sql/migrate_tables_1_2.sql
+index 49b75315..f80ad1c4 100644
+--- a/libdnf/transaction/sql/migrate_tables_1_2.sql
++++ b/libdnf/transaction/sql/migrate_tables_1_2.sql
+@@ -1,9 +1,9 @@
+ R"**(
+ BEGIN TRANSACTION;
+     ALTER TABLE trans
+-        ADD comment TEXT DEFAULT "";
++        ADD comment TEXT DEFAULT '';
+     UPDATE config
+-        SET value = "1.2"
++        SET value = '1.2'
+         WHERE key = 'version';
+ COMMIT;
+ )**"
meta/recipes-devtools/libdnf/libdnf_0.47.0.bb +1 -0
index 1b4b7e4233..1b06d66b19 100644
@@ -8,6 +8,7 @@ SRC_URI = "git://github.com/rpm-software-management/libdnf;branch=dnf-4-master \
            file://0001-Get-parameters-for-both-libsolv-and-libsolvext-libdn.patch \
            file://0001-Add-WITH_TESTS-option.patch \
            file://0001-Look-fo-sphinx-only-if-documentation-is-actually-ena.patch \
+           file://0001-Use-single-quotes-around-string-literals-used-in-SQL.patch \
            "
 
 SRCREV = "8330eea6985c4e4b53796f858de5b6b38b1ddf5c"
Signature · 1 line
2.21.1
#1 lore raw

Hi Peter,

Is this patch suitable for inclusion in dunfell lts?

Thanks,

Steve

Quoted 77 lines · Peter Kjellerstedt

If sqlite is built with -DSQLITE_DQS=0 in accordance with
https://sqlite.org/quirks.html#dblquote, migration to version 1.2 of the history database would fail with:

History database cannot be created: .../var/lib/dnf/history.sqlite.
Error: SQLite error on ":memory:": Executing an SQL statement failed:
no such column: 1.2

---

PATCH v2: Updated the Upstream-Status to Accepted.

 ...s-around-string-literals-used-in-SQL.patch | 36 +++++++++++++++++++
 meta/recipes-devtools/libdnf/libdnf_0.47.0.bb |  1 +
 2 files changed, 37 insertions(+)
 create mode 100644 meta/recipes-devtools/libdnf/libdnf/0001-Use-single-quotes-around-string-literals-used-in-SQL.patch
meta/recipes-devtools/libdnf/libdnf/0001-Use-single-quotes-around-string-literals-used-in-SQL.patch new file +36 -0
new file mode 100644
index 0000000000..293bdcdd24
@@ -0,0 +1,36 @@
+From 96ca7d0049461df2293dd0000edcbc69b64255e0 Mon Sep 17 00:00:00 2001
+From: Peter Kjellerstedt <[email protected]>
+Date: Sun, 3 May 2020 22:40:39 +0200
+Subject: [PATCH] Use single-quotes around string literals used in SQL
+ statements
+
+If sqlite is built with -DSQLITE_DQS=0 in accordance with
+https://sqlite.org/quirks.html#dblquote, migration to version 1.2 of the
+history database would fail with:
+
+  History database cannot be created: /var/lib/dnf/history.sqlite.
+  Error: SQLite error on ":memory:": Executing an SQL statement failed:
+  no such column: 1.2
+
+Upstream-Status: Accepted [https://github.com/rpm-software-management/libdnf/pull/951]
+Signed-off-by: Peter Kjellerstedt <[email protected]>
+---
+ libdnf/transaction/sql/migrate_tables_1_2.sql | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/libdnf/transaction/sql/migrate_tables_1_2.sql b/libdnf/transaction/sql/migrate_tables_1_2.sql
+index 49b75315..f80ad1c4 100644
+--- a/libdnf/transaction/sql/migrate_tables_1_2.sql
++++ b/libdnf/transaction/sql/migrate_tables_1_2.sql
+@@ -1,9 +1,9 @@
+ R"**(
+ BEGIN TRANSACTION;
+     ALTER TABLE trans
+-        ADD comment TEXT DEFAULT "";
++        ADD comment TEXT DEFAULT '';
+     UPDATE config
+-        SET value = "1.2"
++        SET value = '1.2'
+         WHERE key = 'version';
+ COMMIT;
+ )**"
meta/recipes-devtools/libdnf/libdnf_0.47.0.bb +1 -1
index 1b4b7e4233..1b06d66b19 100644
@@ -8,6 +8,7 @@ SRC_URI = "git://github.com/rpm-software-management/libdnf;branch=dnf-4-master \
            file://0001-Get-parameters-for-both-libsolv-and-libsolvext-libdn.patch \
            file://0001-Add-WITH_TESTS-option.patch \
            file://0001-Look-fo-sphinx-only-if-documentation-is-actually-ena.patch \
+           file://0001-Use-single-quotes-around-string-literals-used-in-SQL.patch \
            "
 
 SRCREV = "8330eea6985c4e4b53796f858de5b6b38b1ddf5c"
--

2.21.1

#2 lore raw

Yes, I believe it is. If you cherry-pick it from master, then you should change the Upstream-Status as per below to Accepted.

//Peter

Quoted 111 lines

-----Original Message-----
From: Steve Sakoman <[email protected]>
Sent: den 11 maj 2020 16:21
To: Peter Kjellerstedt <[email protected]>
Cc: Patches and discussions about the oe-core layer <openembedded- [email protected]>
Subject: Re: [OE-core] [meta-oe][PATCH v2] libdnf: Use single-quotes around string literals used in SQL statements

Hi Peter,

Is this patch suitable for inclusion in dunfell lts?

Thanks,

Steve

Quoted 3 lines · Peter Kjellerstedt

If sqlite is built with -DSQLITE_DQS=0 in accordance with
https://sqlite.org/quirks.html#dblquote, migration to version 1.2 of

the

Quoted 7 lines

history database would fail with:

History database cannot be created: .../var/lib/dnf/history.sqlite.
Error: SQLite error on ":memory:": Executing an SQL statement failed:
no such column: 1.2

Quoted 8 lines

---

PATCH v2: Updated the Upstream-Status to Accepted.

 ...s-around-string-literals-used-in-SQL.patch | 36 +++++++++++++++++++
 meta/recipes-devtools/libdnf/libdnf_0.47.0.bb |  1 +
 2 files changed, 37 insertions(+)
 create mode 100644 meta/recipes-devtools/libdnf/libdnf/0001-Use-

single-quotes-around-string-literals-used-in-SQL.patch

Review

Quoted 2 lines
(quoted diff) +0 -0

quotes-around-string-literals-used-in-SQL.patch b/meta/recipes- devtools/libdnf/libdnf/0001-Use-single-quotes-around-string-literals- used-in-SQL.patch

meta/recipes-devtools/libdnf/libdnf/0001-Use-single-quotes-

Quoted 4 lines

new file mode 100644
index 0000000000..293bdcdd24

meta/recipes-devtools/libdnf/libdnf/0001-Use-single-quotes- new file +0 -0

around-string-literals-used-in-SQL.patch

meta/recipes-devtools/libdnf/libdnf/0001-Use-single-quotes- line 8

Quoted 9 lines
meta/recipes-devtools/libdnf/libdnf/0001-Use-single-quotes- new file +8 -0
@@ -0,0 +1,36 @@
+From 96ca7d0049461df2293dd0000edcbc69b64255e0 Mon Sep 17 00:00:00 2001
+From: Peter Kjellerstedt <[email protected]>
+Date: Sun, 3 May 2020 22:40:39 +0200
+Subject: [PATCH] Use single-quotes around string literals used in SQL
+ statements
+
+If sqlite is built with -DSQLITE_DQS=0 in accordance with
+https://sqlite.org/quirks.html#dblquote, migration to version 1.2 of

the

meta/recipes-devtools/libdnf/libdnf/0001-Use-single-quotes- line 12

Quoted 4 lines
meta/recipes-devtools/libdnf/libdnf/0001-Use-single-quotes- new file +4 -0
+history database would fail with:
+
+  History database cannot be created: /var/lib/dnf/history.sqlite.
+  Error: SQLite error on ":memory:": Executing an SQL statement

failed:

meta/recipes-devtools/libdnf/libdnf/0001-Use-single-quotes- line 15

Quoted 3 lines
meta/recipes-devtools/libdnf/libdnf/0001-Use-single-quotes- new file +3 -0
+  no such column: 1.2
+
+Upstream-Status: Accepted [https://github.com/rpm-software-

management/libdnf/pull/951]

meta/recipes-devtools/libdnf/libdnf/0001-Use-single-quotes- line 21

Quoted 6 lines
meta/recipes-devtools/libdnf/libdnf/0001-Use-single-quotes- new file +6 -0
+Signed-off-by: Peter Kjellerstedt <[email protected]>
+---
+ libdnf/transaction/sql/migrate_tables_1_2.sql | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/libdnf/transaction/sql/migrate_tables_1_2.sql

b/libdnf/transaction/sql/migrate_tables_1_2.sql

Review

Quoted 16 lines
meta/recipes-devtools/libdnf/libdnf/0001-Use-single-quotes- new file +15 -0
+index 49b75315..f80ad1c4 100644
+--- a/libdnf/transaction/sql/migrate_tables_1_2.sql
++++ b/libdnf/transaction/sql/migrate_tables_1_2.sql
+@@ -1,9 +1,9 @@
+ R"**(
+ BEGIN TRANSACTION;
+     ALTER TABLE trans
+-        ADD comment TEXT DEFAULT "";
++        ADD comment TEXT DEFAULT '';
+     UPDATE config
+-        SET value = "1.2"
++        SET value = '1.2'
+         WHERE key = 'version';
+ COMMIT;
+ )**"
(quoted diff) +0 -0

b/meta/recipes-devtools/libdnf/libdnf_0.47.0.bb

meta/recipes-devtools/libdnf/libdnf_0.47.0.bb SRC_URI = "git://github.com/rpm-software-

Quoted 4 lines

index 1b4b7e4233..1b06d66b19 100644

meta/recipes-devtools/libdnf/libdnf_0.47.0.bb +0 -0
@@ -8,6 +8,7 @@ SRC_URI = "git://github.com/rpm-software-

management/libdnf;branch=dnf-4-master \

meta/recipes-devtools/libdnf/libdnf_0.47.0.bb SRC_URI = "git://github.com/rpm-software- · line 8

Quoted 1 line
meta/recipes-devtools/libdnf/libdnf_0.47.0.bb +0 -0
            file://0001-Get-parameters-for-both-libsolv-and-libsolvext-

libdn.patch \

meta/recipes-devtools/libdnf/libdnf_0.47.0.bb SRC_URI = "git://github.com/rpm-software- · line 10

Quoted 2 lines
meta/recipes-devtools/libdnf/libdnf_0.47.0.bb +0 -0
            file://0001-Add-WITH_TESTS-option.patch \
            file://0001-Look-fo-sphinx-only-if-documentation-is-

actually-ena.patch \

meta/recipes-devtools/libdnf/libdnf_0.47.0.bb SRC_URI = "git://github.com/rpm-software- · line 11

Quoted 1 line
meta/recipes-devtools/libdnf/libdnf_0.47.0.bb +1 -0
+           file://0001-Use-single-quotes-around-string-literals-used-

in-SQL.patch \

Quoted 7 lines
meta/recipes-devtools/libdnf/libdnf_0.47.0.bb +0 -1
            "
 
 SRCREV = "8330eea6985c4e4b53796f858de5b6b38b1ddf5c"
--

2.21.1

#3 lore raw
Quoted 3 lines · Peter Kjellerstedt

Yes, I believe it is. If you cherry-pick it from master, then you should change the Upstream-Status as per below to Accepted.

I just noticed the version of libdnf on the patch! Dunfell is still at 0.28.1 and I'm not going to do a version bump to 0.47.0 without a really good reason.

Sorry I didn't notice that on my first review.

Steve

Quoted 111 lines
Quoted 111 lines

-----Original Message-----
From: Steve Sakoman <[email protected]>
Sent: den 11 maj 2020 16:21
To: Peter Kjellerstedt <[email protected]>
Cc: Patches and discussions about the oe-core layer <openembedded- [email protected]>
Subject: Re: [OE-core] [meta-oe][PATCH v2] libdnf: Use single-quotes around string literals used in SQL statements

Hi Peter,

Is this patch suitable for inclusion in dunfell lts?

Thanks,

Steve

Quoted 3 lines · Peter Kjellerstedt

If sqlite is built with -DSQLITE_DQS=0 in accordance with
https://sqlite.org/quirks.html#dblquote, migration to version 1.2 of

the

Quoted 7 lines

history database would fail with:

History database cannot be created: .../var/lib/dnf/history.sqlite.
Error: SQLite error on ":memory:": Executing an SQL statement failed:
no such column: 1.2

Quoted 8 lines

---

PATCH v2: Updated the Upstream-Status to Accepted.

 ...s-around-string-literals-used-in-SQL.patch | 36 +++++++++++++++++++
 meta/recipes-devtools/libdnf/libdnf_0.47.0.bb |  1 +
 2 files changed, 37 insertions(+)
 create mode 100644 meta/recipes-devtools/libdnf/libdnf/0001-Use-

single-quotes-around-string-literals-used-in-SQL.patch

Review

Quoted 2 lines
(quoted diff) +0 -0

quotes-around-string-literals-used-in-SQL.patch b/meta/recipes- devtools/libdnf/libdnf/0001-Use-single-quotes-around-string-literals- used-in-SQL.patch

meta/recipes-devtools/libdnf/libdnf/0001-Use-single-quotes-

Quoted 4 lines

new file mode 100644
index 0000000000..293bdcdd24

meta/recipes-devtools/libdnf/libdnf/0001-Use-single-quotes- new file +0 -0

around-string-literals-used-in-SQL.patch

meta/recipes-devtools/libdnf/libdnf/0001-Use-single-quotes- line 8

Quoted 9 lines
meta/recipes-devtools/libdnf/libdnf/0001-Use-single-quotes- new file +8 -0
@@ -0,0 +1,36 @@
+From 96ca7d0049461df2293dd0000edcbc69b64255e0 Mon Sep 17 00:00:00 2001
+From: Peter Kjellerstedt <[email protected]>
+Date: Sun, 3 May 2020 22:40:39 +0200
+Subject: [PATCH] Use single-quotes around string literals used in SQL
+ statements
+
+If sqlite is built with -DSQLITE_DQS=0 in accordance with
+https://sqlite.org/quirks.html#dblquote, migration to version 1.2 of

the

meta/recipes-devtools/libdnf/libdnf/0001-Use-single-quotes- line 12

Quoted 4 lines
meta/recipes-devtools/libdnf/libdnf/0001-Use-single-quotes- new file +4 -0
+history database would fail with:
+
+  History database cannot be created: /var/lib/dnf/history.sqlite.
+  Error: SQLite error on ":memory:": Executing an SQL statement

failed:

meta/recipes-devtools/libdnf/libdnf/0001-Use-single-quotes- line 15

Quoted 3 lines
meta/recipes-devtools/libdnf/libdnf/0001-Use-single-quotes- new file +3 -0
+  no such column: 1.2
+
+Upstream-Status: Accepted [https://github.com/rpm-software-

management/libdnf/pull/951]

meta/recipes-devtools/libdnf/libdnf/0001-Use-single-quotes- line 21

Quoted 6 lines
meta/recipes-devtools/libdnf/libdnf/0001-Use-single-quotes- new file +6 -0
+Signed-off-by: Peter Kjellerstedt <[email protected]>
+---
+ libdnf/transaction/sql/migrate_tables_1_2.sql | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/libdnf/transaction/sql/migrate_tables_1_2.sql

b/libdnf/transaction/sql/migrate_tables_1_2.sql

Review

Quoted 16 lines
meta/recipes-devtools/libdnf/libdnf/0001-Use-single-quotes- new file +15 -0
+index 49b75315..f80ad1c4 100644
+--- a/libdnf/transaction/sql/migrate_tables_1_2.sql
++++ b/libdnf/transaction/sql/migrate_tables_1_2.sql
+@@ -1,9 +1,9 @@
+ R"**(
+ BEGIN TRANSACTION;
+     ALTER TABLE trans
+-        ADD comment TEXT DEFAULT "";
++        ADD comment TEXT DEFAULT '';
+     UPDATE config
+-        SET value = "1.2"
++        SET value = '1.2'
+         WHERE key = 'version';
+ COMMIT;
+ )**"
(quoted diff) +0 -0

b/meta/recipes-devtools/libdnf/libdnf_0.47.0.bb

meta/recipes-devtools/libdnf/libdnf_0.47.0.bb SRC_URI = "git://github.com/rpm-software-

Quoted 4 lines

index 1b4b7e4233..1b06d66b19 100644

meta/recipes-devtools/libdnf/libdnf_0.47.0.bb +0 -0
@@ -8,6 +8,7 @@ SRC_URI = "git://github.com/rpm-software-

management/libdnf;branch=dnf-4-master \

meta/recipes-devtools/libdnf/libdnf_0.47.0.bb SRC_URI = "git://github.com/rpm-software- · line 8

Quoted 1 line
meta/recipes-devtools/libdnf/libdnf_0.47.0.bb +0 -0
            file://0001-Get-parameters-for-both-libsolv-and-libsolvext-

libdn.patch \

meta/recipes-devtools/libdnf/libdnf_0.47.0.bb SRC_URI = "git://github.com/rpm-software- · line 10

Quoted 2 lines
meta/recipes-devtools/libdnf/libdnf_0.47.0.bb +0 -0
            file://0001-Add-WITH_TESTS-option.patch \
            file://0001-Look-fo-sphinx-only-if-documentation-is-

actually-ena.patch \

meta/recipes-devtools/libdnf/libdnf_0.47.0.bb SRC_URI = "git://github.com/rpm-software- · line 11

Quoted 1 line
meta/recipes-devtools/libdnf/libdnf_0.47.0.bb +1 -0
+           file://0001-Use-single-quotes-around-string-literals-used-

in-SQL.patch \

Quoted 7 lines
meta/recipes-devtools/libdnf/libdnf_0.47.0.bb +0 -1
            "
 
 SRCREV = "8330eea6985c4e4b53796f858de5b6b38b1ddf5c"
--

2.21.1