>Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im >Auftrag von Keith Medcalf >Betreff: [EXTERNAL] Re: [sqlite] Patch: VTable Column Affinity Question and >Change Request > > >Patch to Fix Column Affinity not applied to Virtual Columns. > >In expr.c function sqlite3ExprCodeGetColumnOfTable At or about line 3555 where >the OP_Column or OP_VColumn opcode is added to the VDBE program, and the >default code is generated, make this: > > sqlite3VdbeAddOp3(v, op, iTabCur, x, regOut); > sqlite3ColumnDefault(v, pTab, iCol, regOut); > >look like this: > > sqlite3VdbeAddOp3(v, op, iTabCur, x, regOut); > if ( IsVirtual(pTab) && pTab->aCol[iCol].affinity > SQLITE_AFF_BLOB) > sqlite3VdbeAddOp4(v, OP_Affinity, regOut, 1, 0, > &(pTab->aCol[iCol].affinity), 1); > sqlite3ColumnDefault(v, pTab, iCol, regOut); > >Of course, it may be that the writer of the VTable should know what they are >doing and generate a VTable definition that is consistent with how their >cursor methods return data, however ... this will omit the OP_Affinity if no >>column type was specified when the VTable was defined and most of the VTable >declarations in the existing code that I looked at do not specify column >affinities in the declarations.
Very nice. but detrimental for our use case. Please refrain from adding this tot he distribution by default. We are almost exclusively using virtual tables to allow queries against our internal data sources, which are C language structs and thus strictly typed. The column affinities provided by the VTab implementations are used for documentation purposes and the xColumn methods always return the same type (calling the "wrong" sqlite3_result function is considered a programming error). Coercing the returned value to the same type would be just a waste of memory and CPU cycles. We do have our own implementation of csv for export/import purposes (which predates the c orresponding SQLite features) that also allow changing the schema by providing default values for new columns. But this is only used in the context of INSERT INTO ... SELECT which applies the affinity of the target table. ___________________________________________ Gunter Hick | Software Engineer | Scientific Games International GmbH | Klitschgasse 2-4, A-1130 Vienna | FN 157284 a, HG Wien, DVR: 0430013 | (O) +43 1 80100 - 0 May be privileged. May be confidential. Please delete if not the addressee. _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users