On Sat, Apr 02, 2016 at 12:10:31PM +0200, László Böszörményi wrote: > Its first parameter is the function the call and the second is the > expected result[1]. If I use sqlite3 3.11.1, then the function returns > an array, but not [666]. With sqlite3 3.12.0 it returns the expected > [666].
The root cause is that sqlite3_column_decltype() quotes its output in 3.12.0, where previously it didn't. I'm attaching Perl and C test cases for it. With 3.11.1 the output of these test cases is type:json text value:bar and with 3.12.0 we get type:'json text' value:bar So is this an intentional change or a regression? -- Niko Tyni nt...@debian.org
#!/usr/bin/perl -w use DBI; use strict; my $dbh = DBI->connect("dbi:SQLite:dbname=ttt","","", { RaiseError => 1 }); $dbh->do("DROP TABLE IF EXISTS foo"); $dbh->do("CREATE TABLE foo ('value' 'json text')"); $dbh->do("INSERT INTO foo ('value') VALUES ('bar')"); my $sth = $dbh->prepare("SELECT * FROM foo"); $sth->execute; while (my $row = $sth->fetch) { print "type:$sth->{TYPE}[0] value:$row->[0]\n"; }
#include <sqlite3.h> #include <stdio.h> #include <string.h> int main(void) { sqlite3 *db; char *err_msg = 0; sqlite3_stmt *res; int rc = sqlite3_open("ttt", &db); if (rc != SQLITE_OK) { fprintf(stderr, "Cannot open database: %s\n", sqlite3_errmsg(db)); sqlite3_close(db); return 1; } char sql[1024]; strcpy(sql, "DROP TABLE IF EXISTS foo; CREATE TABLE foo ('value' 'json text'); INSERT INTO foo ('value') VALUES ('bar')"); rc = sqlite3_exec(db, sql, NULL, 0, &err_msg); if( rc != SQLITE_OK ){ fprintf(stderr, "Can't select: %s\n", err_msg); return 1; } strcpy(sql, "SELECT * FROM foo"); rc = sqlite3_prepare_v2(db, sql, -1, &res, 0); if (rc != SQLITE_OK) { fprintf(stderr, "Failed to execute statement: %s\n", sqlite3_errmsg(db)); return 1; } int step = sqlite3_step(res); if (step == SQLITE_ROW) { printf("type:%s value:%s\n", sqlite3_column_decltype(res, 0), sqlite3_column_text(res, 0)); } sqlite3_finalize(res); sqlite3_close(db); return 0; }