mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-11 01:42:22 +03:00
Add the sqlite3_value_*() access functions. (CVS 1447)
FossilOrigin-Name: 4bf925fcfccb18e66be031f8a234f370d581e9ea
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
** This header file defines the interface that the SQLite library
|
||||
** presents to client programs.
|
||||
**
|
||||
** @(#) $Id: sqlite.h.in,v 1.71 2004/05/23 13:30:58 danielk1977 Exp $
|
||||
** @(#) $Id: sqlite.h.in,v 1.72 2004/05/24 09:10:11 danielk1977 Exp $
|
||||
*/
|
||||
#ifndef _SQLITE_H_
|
||||
#define _SQLITE_H_
|
||||
@@ -1342,12 +1342,75 @@ double sqlite3_column_float(sqlite3_stmt*,int);
|
||||
|
||||
typedef struct Mem sqlite3_value;
|
||||
|
||||
/*
|
||||
** Return the type of the sqlite3_value* passed as the first argument.
|
||||
** The type is one of SQLITE3_NULL, SQLITE3_INTEGER, SQLITE3_FLOAT,
|
||||
** SQLITE3_TEXT or SQLITE3_BLOB.
|
||||
*/
|
||||
int sqlite3_value_type(sqlite3_value*);
|
||||
int sqlite3_value_bytes(sqlite3_value*);
|
||||
int sqlite3_value_bytes16(sqlite3_value*);
|
||||
|
||||
/*
|
||||
** Return the value of the sqlite3_value* passed as the first argument.
|
||||
** The value returned depends on the type of the value, as returned by
|
||||
** sqlite3_value_type():
|
||||
**
|
||||
** SQLITE3_NULL A Null pointer.
|
||||
** SQLITE3_INTEGER String representation of the integer, UTF-8 encoded.
|
||||
** SQLITE3_FLOAT String representation of the real, UTF-8 encoded.
|
||||
** SQLITE3_TEXT The string UTF-8 encoded.
|
||||
** SQLITE3_BLOB A pointer to the blob of data.
|
||||
*/
|
||||
const unsigned char *sqlite3_value_data(sqlite3_value*);
|
||||
|
||||
/*
|
||||
** Return the number of bytes in the string or blob returned by a call
|
||||
** to sqlite3_value_data() on the same sqlite3_value* object.
|
||||
*/
|
||||
int sqlite3_value_bytes(sqlite3_value*);
|
||||
|
||||
/*
|
||||
** Return the value of the sqlite3_value* passed as the first argument.
|
||||
** The value returned depends on the type of the value, as returned by
|
||||
** sqlite3_value_type():
|
||||
**
|
||||
** SQLITE3_NULL A Null pointer.
|
||||
** SQLITE3_INTEGER String representation of the integer, UTF-16 encoded.
|
||||
** SQLITE3_FLOAT String representation of the real, UTF-16 encoded.
|
||||
** SQLITE3_TEXT The string UTF-16 encoded.
|
||||
** SQLITE3_BLOB A pointer to the blob of data.
|
||||
*/
|
||||
const void *sqlite3_value_data16(sqlite3_value*);
|
||||
|
||||
/*
|
||||
** Return the number of bytes in the string or blob returned by a call
|
||||
** to sqlite3_value_data16() on the same sqlite3_value* object.
|
||||
*/
|
||||
int sqlite3_value_bytes16(sqlite3_value*);
|
||||
|
||||
/*
|
||||
** Return the value of the sqlite3_value* passed as the first argument.
|
||||
** The value returned depends on the type of the value, as returned by
|
||||
** sqlite3_value_type():
|
||||
**
|
||||
** SQLITE3_NULL 0
|
||||
** SQLITE3_INTEGER The integer value.
|
||||
** SQLITE3_FLOAT The integer component of the real (2^63 if too large)
|
||||
** SQLITE3_TEXT Integer conversion of string, or 0
|
||||
** SQLITE3_BLOB 0
|
||||
*/
|
||||
long long int sqlite3_value_int(sqlite3_value*);
|
||||
|
||||
/*
|
||||
** Return the value of the sqlite3_value* passed as the first argument.
|
||||
** The value returned depends on the type of the value, as returned by
|
||||
** sqlite3_value_type():
|
||||
**
|
||||
** SQLITE3_NULL 0.0
|
||||
** SQLITE3_INTEGER The value of the integer. Some rounding may occur.
|
||||
** SQLITE3_FLOAT The value of the float.
|
||||
** SQLITE3_TEXT Real number conversion of string, or 0.0
|
||||
** SQLITE3_BLOB 0.0
|
||||
*/
|
||||
double sqlite3_value_float(sqlite3_value*);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
74
src/vdbe.c
74
src/vdbe.c
@@ -43,7 +43,7 @@
|
||||
** in this file for details. If in doubt, do not deviate from existing
|
||||
** commenting and indentation practices when changing or adding code.
|
||||
**
|
||||
** $Id: vdbe.c,v 1.323 2004/05/24 07:34:48 danielk1977 Exp $
|
||||
** $Id: vdbe.c,v 1.324 2004/05/24 09:10:11 danielk1977 Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include "os.h"
|
||||
@@ -630,6 +630,48 @@ const void *sqlite3_value_data16(sqlite3_value* pVal){
|
||||
return (const void *)(pVal->z);
|
||||
}
|
||||
|
||||
/*
|
||||
** Return the number of bytes of data that will be returned by the
|
||||
** equivalent sqlite3_value_data() call.
|
||||
*/
|
||||
int sqlite3_value_bytes(sqlite3_value *pVal){
|
||||
if( sqlite3_value_data(pVal) ){
|
||||
return ((Mem *)pVal)->n;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** Return the number of bytes of data that will be returned by the
|
||||
** equivalent sqlite3_value_data16() call.
|
||||
*/
|
||||
int sqlite3_value_bytes(sqlite3_value *pVal){
|
||||
if( sqlite3_value_data16(pVal) ){
|
||||
return ((Mem *)pVal)->n;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** Return the value of the sqlite_value* argument coerced to a 64-bit
|
||||
** integer.
|
||||
*/
|
||||
long long int sqlite3_value_int(sqlite3_value *pVal){
|
||||
Mem *pMem = (Mem *)pVal;
|
||||
Integerify(pMem, flagsToEnc(pMem->flags));
|
||||
return pVal->i;
|
||||
}
|
||||
|
||||
/*
|
||||
** Return the value of the sqlite_value* argument coerced to a 64-bit
|
||||
** IEEE float.
|
||||
*/
|
||||
double sqlite3_value_float(sqlite3_value*){
|
||||
pVal = &pVm->pTos[(1-vals)+i];
|
||||
Realify(pVal, flagsToEnc(pMem->flags));
|
||||
return pVal->r;
|
||||
}
|
||||
|
||||
/*
|
||||
** Return the number of bytes of data that will be returned by the
|
||||
** equivalent sqlite3_column_data() call.
|
||||
@@ -674,8 +716,7 @@ long long int sqlite3_column_int(sqlite3_stmt *pStmt, int i){
|
||||
}
|
||||
|
||||
pVal = &pVm->pTos[(1-vals)+i];
|
||||
Integerify(pVal, pVm->db->enc);
|
||||
return pVal->i;
|
||||
return sqlite3_value_int(pVal);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -693,9 +734,7 @@ double sqlite3_column_float(sqlite3_stmt *pStmt, int i){
|
||||
return 0;
|
||||
}
|
||||
|
||||
pVal = &pVm->pTos[(1-vals)+i];
|
||||
Realify(pVal, pVm->db->enc);
|
||||
return pVal->r;
|
||||
return sqlite3_value_float(pVal);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -713,6 +752,29 @@ const char *sqlite3_column_name(sqlite3_stmt *pStmt, int N){
|
||||
return p->azColName[N];
|
||||
}
|
||||
|
||||
/*
|
||||
** Return the type of the value stored in the sqlite_value* object.
|
||||
*/
|
||||
int sqlite3_value_type(sqlite3_value* pVal){
|
||||
int f = ((Mem *)pVal)->flags;
|
||||
if( f&MEM_Null ){
|
||||
return SQLITE3_NULL;
|
||||
}
|
||||
if( f&MEM_Int ){
|
||||
return SQLITE3_INTEGER;
|
||||
}
|
||||
if( f&MEM_Real ){
|
||||
return SQLITE3_FLOAT;
|
||||
}
|
||||
if( f&MEM_Str ){
|
||||
return SQLITE3_TEXT;
|
||||
}
|
||||
if( f&MEM_Blob ){
|
||||
return SQLITE3_BLOB;
|
||||
}
|
||||
assert(0);
|
||||
}
|
||||
|
||||
/*
|
||||
** Return the type of the 'i'th column of the current row of the currently
|
||||
** executing statement pStmt.
|
||||
|
||||
Reference in New Issue
Block a user