1
0
mirror of https://github.com/sqlite/sqlite.git synced 2026-01-06 08:01:16 +03:00

Add a symbol P3_TRANSIENT to pass to VdbeSetColName() to make it copy the string parameter up to the first 0 byte. (CVS 3070)

FossilOrigin-Name: 6ebb8f9bb2f6a3f7fde19267727aa4e2d878a416
This commit is contained in:
danielk1977
2006-02-10 03:06:10 +00:00
parent 955de52c9c
commit 4b1ae99d01
8 changed files with 41 additions and 35 deletions

View File

@@ -1,5 +1,5 @@
C Add\sthe\scolumn_origin_name()\setc.\sAPIs.\s(CVS\s3069)
D 2006-02-10T02:27:42
C Add\sa\ssymbol\sP3_TRANSIENT\sto\spass\sto\sVdbeSetColName()\sto\smake\sit\scopy\sthe\sstring\sparameter\sup\sto\sthe\sfirst\s0\sbyte.\s(CVS\s3070)
D 2006-02-10T03:06:10
F Makefile.in 5d8dff443383918b700e495de42ec65bc1c8865b
F Makefile.linux-gcc 74ba0eadf88748a9ce3fd03d2a3ede2e6715baec
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -66,14 +66,14 @@ F src/pragma.c 8e135979702f249dd5877402056df0a336ea5a12
F src/prepare.c cf0fc8ebaf94409955ecb09ffeb0099c9ef44693
F src/printf.c c7d6ad9efb71c466305297a448308f467b6e2b6e
F src/random.c d40f8d356cecbd351ccfab6eaedd7ec1b54f5261
F src/select.c ace67e13cd1344aa8de552c8eab9bce58f97ec24
F src/select.c 7ed6f28cdcf7c317de317f6ce51c28c667d76e24
F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
F src/shell.c 738f55ed75fb36731e764bfdb40756ac43b90b08
F src/sqlite.h.in 7a76811fe3743522b531994dfbf90f24b2333f71
F src/sqlite.h.in bc78a247fd9f294b30a4c03894f93fcb1e166410
F src/sqliteInt.h 0121298397ac14eb468ab1ba9d488ac7ed7d88a1
F src/table.c 486dcfce532685b53b5a2b5da8bba0ded6fb2316
F src/tclsqlite.c d9c26374b52cd47233ae0620d0a858a59b601f89
F src/test1.c 58ab748e96754f2e05c85282ac47f81f7b8c44a3
F src/test1.c ca8cb34747c53479e0748c11d1a10cc07d582bb8
F src/test2.c ca74a1d8aeb7d9606e8f6b762c5daf85c1a3f92b
F src/test3.c 86e99724ee898b119ed575ef9f98618afe7e5e5d
F src/test4.c ff4e9406b3d2809966d8f0e82468ac5508be9f56
@@ -90,9 +90,9 @@ F src/utf.c 1199766bbb0157931a83aa6eede6b6381177be64
F src/util.c 405f46fef062b476826d2c171ec21def29563b75
F src/vacuum.c 3865673cc66acd0717ecd517f6b8fdb2a5e7924b
F src/vdbe.c c92d7a4d3476136b8ab440f1e0547fab24112b34
F src/vdbe.h 12e2326f256db62352f10764d1a3940d914ded59
F src/vdbe.h 80ba1c391ec28180dd07a630577f50b22c2062da
F src/vdbeInt.h eb3f86ab08ef11635bc78eb88c3ff13f923c233b
F src/vdbeapi.c 72569c560acfba3e961b3cc9245a79647ea7c5ea
F src/vdbeapi.c 7dc662e7c905ce666bb506dced932e0307115cbf
F src/vdbeaux.c 95f4ed0bc8ed45f16823d84504310495b5dc587d
F src/vdbefifo.c 9efb94c8c3f4c979ebd0028219483f88e57584f5
F src/vdbemem.c 2034e93b32c14bda6e306bb54e3a8e930b963027
@@ -131,7 +131,7 @@ F test/btree6.test a5ede6bfbbb2ec8b27e62813612c0f28e8f3e027
F test/btree7.test a6d3b842db22af97dd14b989e90a2fd96066b72f
F test/btree8.test fadc112bcbd6a0c622d34c813fc8a648eacf8804
F test/busy.test 0271c854738e23ad76e10d4096a698e5af29d211
F test/capi2.test ca76487c525b4e6085b9766cc02bcfcc53835f73
F test/capi2.test fe07532d7595cd2cc0423f8537a1cbb831bd8607
F test/capi3.test e26c09ec40c5dddf215c5dd359b4989a53dde876
F test/capi3b.test 5f0bc94b104e11086b1103b20277e1910f59c7f4
F test/cast.test aabdcb3873bb2f40d855bf63950f6d99a5a196c7
@@ -351,7 +351,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
P d54d3b82c468b7e6dd39aac6aac56b26b3918c37
R 0b8bfdc13fc109c03d9eefa67aff0e14
P 82f502cdc1fead3bf7e3190d5c9db3aee6919ed4
R e8ab349255445085d0fedc02cdd56499
U danielk1977
Z a17c7aa8ab9c9bcf9b5fa8f511de465d
Z 91cde64b2b17550c6eb4505abb4035ed

View File

@@ -1 +1 @@
82f502cdc1fead3bf7e3190d5c9db3aee6919ed4
6ebb8f9bb2f6a3f7fde19267727aa4e2d878a416

View File

@@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
**
** $Id: select.c,v 1.302 2006/02/10 02:27:43 danielk1977 Exp $
** $Id: select.c,v 1.303 2006/02/10 03:06:10 danielk1977 Exp $
*/
#include "sqliteInt.h"
@@ -920,19 +920,14 @@ static void generateColumnTypes(
const char *zOrigCol = 0;
const char *zType = columnType(&sNC, p, &zOrigDb, &zOrigTab, &zOrigCol);
/* The vdbe must make it's own copy of the column-type, in case the
** schema is reset before this virtual machine is deleted.
**
** TODO: Create some symbol that is better than "-20" to pass to
** sqlite3VdbeSetColName(). As is this is a ticking bomb. An alternative
** is to pass the length of the string, but that means calling strlen()
** here which consumes code space. By passing a negative value that is
** not P3_DYNAMIC or P3_STATIC, strlen() is called by VdbeSetColName().
/* The vdbe must make it's own copy of the column-type and other
** column specific strings, in case the schema is reset before this
** virtual machine is deleted.
*/
sqlite3VdbeSetColName(v, i, COLNAME_DECLTYPE, zType, -20);
sqlite3VdbeSetColName(v, i, COLNAME_DATABASE, zOrigDb, -20);
sqlite3VdbeSetColName(v, i, COLNAME_TABLE, zOrigTab, -20);
sqlite3VdbeSetColName(v, i, COLNAME_COLUMN, zOrigCol, -20);
sqlite3VdbeSetColName(v, i, COLNAME_DECLTYPE, zType, P3_TRANSIENT);
sqlite3VdbeSetColName(v, i, COLNAME_DATABASE, zOrigDb, P3_TRANSIENT);
sqlite3VdbeSetColName(v, i, COLNAME_TABLE, zOrigTab, P3_TRANSIENT);
sqlite3VdbeSetColName(v, i, COLNAME_COLUMN, zOrigCol, P3_TRANSIENT);
}
}

View File

@@ -12,7 +12,7 @@
** This header file defines the interface that the SQLite library
** presents to client programs.
**
** @(#) $Id: sqlite.h.in,v 1.161 2006/02/10 02:27:43 danielk1977 Exp $
** @(#) $Id: sqlite.h.in,v 1.162 2006/02/10 03:06:10 danielk1977 Exp $
*/
#ifndef _SQLITE3_H_
#define _SQLITE3_H_
@@ -738,6 +738,9 @@ const void *sqlite3_column_name16(sqlite3_stmt*,int);
** As with all other SQLite APIs, those postfixed with "16" return UTF-16
** encoded strings, the other functions return UTF-8. The memory containing
** the returned strings is valid until the statement handle is finalized().
**
** These APIs are only available if the library was compiled with the
** SQLITE_ENABLE_COLUMN_METADATA preprocessor symbol defined.
*/
const char *sqlite3_column_database_name(sqlite3_stmt*,int);
const void *sqlite3_column_database_name16(sqlite3_stmt*,int);
@@ -1445,6 +1448,9 @@ void sqlite3_thread_cleanup(void);
** error occurs during this process, or if the requested table or column
** cannot be found, an SQLITE error code is returned and an error message
** left in the database handle (to be retrieved using sqlite3_errmsg()).
**
** This API is only available if the library was compiled with the
** SQLITE_ENABLE_COLUMN_METADATA preprocessor symbol defined.
*/
int sqlite3_table_column_metadata(
sqlite3 *db, /* Connection handle */

View File

@@ -13,7 +13,7 @@
** is not included in the SQLite library. It is used for automated
** testing of the SQLite library.
**
** $Id: test1.c,v 1.205 2006/02/10 02:27:43 danielk1977 Exp $
** $Id: test1.c,v 1.206 2006/02/10 03:06:10 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
@@ -3571,19 +3571,23 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
{ "sqlite3_column_name", test_stmt_utf8, sqlite3_column_name },
{ "sqlite3_column_int", test_stmt_int, sqlite3_column_int },
{ "sqlite3_column_bytes", test_stmt_int, sqlite3_column_bytes },
#ifdef SQLITE_ENABLE_COLUMN_METADATA
{ "sqlite3_column_database_name", test_stmt_utf8, sqlite3_column_database_name},
{ "sqlite3_column_table_name", test_stmt_utf8, sqlite3_column_table_name},
{ "sqlite3_column_origin_name", test_stmt_utf8, sqlite3_column_origin_name},
#endif
#ifndef SQLITE_OMIT_UTF16
{ "sqlite3_column_bytes16", test_stmt_int, sqlite3_column_bytes16 },
{ "sqlite3_column_text16", test_stmt_utf16, sqlite3_column_text16 },
{ "sqlite3_column_decltype16", test_stmt_utf16, sqlite3_column_decltype16},
{ "sqlite3_column_name16", test_stmt_utf16, sqlite3_column_name16 },
#ifdef SQLITE_ENABLE_COLUMN_METADATA
{"sqlite3_column_database_name16",
test_stmt_utf16, sqlite3_column_database_name16},
{"sqlite3_column_table_name16", test_stmt_utf16, sqlite3_column_table_name16},
{"sqlite3_column_origin_name16", test_stmt_utf16, sqlite3_column_origin_name16},
#endif
#endif
{ "sqlite3_global_recover", test_global_recover, 0 },

View File

@@ -15,7 +15,7 @@
** or VDBE. The VDBE implements an abstract machine that runs a
** simple program to access and modify the underlying database.
**
** $Id: vdbe.h,v 1.100 2006/02/10 02:27:44 danielk1977 Exp $
** $Id: vdbe.h,v 1.101 2006/02/10 03:06:10 danielk1977 Exp $
*/
#ifndef _SQLITE_VDBE_H_
#define _SQLITE_VDBE_H_
@@ -69,6 +69,7 @@ typedef struct VdbeOpList VdbeOpList;
#define P3_KEYINFO (-6) /* P3 is a pointer to a KeyInfo structure */
#define P3_VDBEFUNC (-7) /* P3 is a pointer to a VdbeFunc structure */
#define P3_MEM (-8) /* P3 is a pointer to a Mem* structure */
#define P3_TRANSIENT (-9) /* P3 is a pointer to a transient string */
/* When adding a P3 argument using P3_KEYINFO, a copy of the KeyInfo structure
** is made. That copy is freed when the Vdbe is finalized. But if the

View File

@@ -546,7 +546,7 @@ const void *sqlite3_column_decltype16(sqlite3_stmt *pStmt, int N){
}
#endif /* SQLITE_OMIT_UTF16 */
#if !defined(SQLITE_OMIT_ORIGIN_NAMES)
#ifdef SQLITE_ENABLE_COLUMN_METADATA
/*
** Return the name of the database from which a result column derives.
** NULL is returned if the result column is an expression or constant or
@@ -594,9 +594,7 @@ const void *sqlite3_column_origin_name16(sqlite3_stmt *pStmt, int N){
pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_COLUMN);
}
#endif /* SQLITE_OMIT_UTF16 */
#endif /* SQLITE_OMIT_ORIGIN_NAMES */
#endif /* SQLITE_ENABLE_COLUMN_METADATA */
/******************************* sqlite3_bind_ ***************************

View File

@@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this script testing the callback-free C/C++ API.
#
# $Id: capi2.test,v 1.28 2006/02/10 02:27:47 danielk1977 Exp $
# $Id: capi2.test,v 1.29 2006/02/10 03:06:10 danielk1977 Exp $
#
set testdir [file dirname $argv0]
@@ -655,6 +655,8 @@ do_test capi2-10.2 {
# sqlite3_column_table_name()
#
ifcapable columnmetadata {
# This proc uses the database handle $::DB to compile the SQL statement passed
# as a parameter. The return value of this procedure is a list with one
# element for each column returned by the compiled statement. Each element of
@@ -706,7 +708,6 @@ do_test capi2-12.1 {
}
} {}
do_test capi2-12.2 {
breakpoint
check_origins {SELECT col2, col1 FROM view1}
} [list {main tab1 col2} {main tab1 col1}]
do_test capi2-12.3 {
@@ -721,7 +722,8 @@ do_test capi2-12.5 {
do_test capi2-12.6 {
check_origins {SELECT (SELECT col2), (SELECT col1) FROM view1}
} [list {main tab1 col2} {main tab1 col1}]
db2 close
} ;# ifcapable columnmetadata
finish_test