/ Check-in [4bf925fc]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add the sqlite3_value_*() access functions. (CVS 1447)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:4bf925fcfccb18e66be031f8a234f370d581e9ea
User & Date: danielk1977 2004-05-24 09:10:11
Context
2004-05-24
09:15
Fix typo in vdbe.c from previous commit. (CVS 1448) check-in: a554bf6c user: danielk1977 tags: trunk
09:10
Add the sqlite3_value_*() access functions. (CVS 1447) check-in: 4bf925fc user: danielk1977 tags: trunk
07:34
Fix for retrieving UTF-16 little-endian text from a big-endian database. (CVS 1446) check-in: 8104baf2 user: danielk1977 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/sqlite.h.in.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
....
1338
1339
1340
1341
1342
1343
1344





1345




1346
1347







1348


















1349


















1350












1351
1352
1353
1354
1355
1356
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** 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 $
*/
#ifndef _SQLITE_H_
#define _SQLITE_H_
#include <stdarg.h>     /* Needed for the definition of va_list */

/*
** Make sure we can call this stuff from C++.
................................................................................
** SQLITE3_TEXT      Real number conversion of string, or 0.0
** SQLITE3_BLOB      0.0
*/
double sqlite3_column_float(sqlite3_stmt*,int);

typedef struct Mem sqlite3_value;






int sqlite3_value_type(sqlite3_value*);




int sqlite3_value_bytes(sqlite3_value*);
int sqlite3_value_bytes16(sqlite3_value*);







const unsigned char *sqlite3_value_data(sqlite3_value*);


















const void *sqlite3_value_data16(sqlite3_value*);


















long long int sqlite3_value_int(sqlite3_value*);












double sqlite3_value_float(sqlite3_value*);

#ifdef __cplusplus
}  /* End of the 'extern "C"' block */
#endif
#endif







|







 







>
>
>
>
>

>
>
>
>
|
<
>
>
>
>
>
>
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

>
>
>
>
>
>
>
>
>
>
>
>






8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
....
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355

1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This header file defines the interface that the SQLite library
** presents to client programs.
**
** @(#) $Id: sqlite.h.in,v 1.72 2004/05/24 09:10:11 danielk1977 Exp $
*/
#ifndef _SQLITE_H_
#define _SQLITE_H_
#include <stdarg.h>     /* Needed for the definition of va_list */

/*
** Make sure we can call this stuff from C++.
................................................................................
** SQLITE3_TEXT      Real number conversion of string, or 0.0
** SQLITE3_BLOB      0.0
*/
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*);

/*
** 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
}  /* End of the 'extern "C"' block */
#endif
#endif

Changes to src/vdbe.c.

39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
...
625
626
627
628
629
630
631










































632
633
634
635
636
637
638
...
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
...
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
...
708
709
710
711
712
713
714























715
716
717
718
719
720
721
**
** Various scripts scan this source file in order to generate HTML
** documentation, headers files, or other derived files.  The formatting
** of the code in this file is, therefore, important.  See other comments
** 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 $
*/
#include "sqliteInt.h"
#include "os.h"
#include <ctype.h>
#include "vdbeInt.h"

/*
................................................................................
  }else if( !(pVal->flags&MEM_Blob) ){
    /* Otherwise, unless this is a blob, convert it to a UTF-16 string */
    Stringify(pVal, TEXT_Utf16);
  }

  return (const void *)(pVal->z);
}











































/*
** Return the number of bytes of data that will be returned by the
** equivalent sqlite3_column_data() call.
*/
int sqlite3_column_bytes(sqlite3_stmt *pStmt, int i){
  Vdbe *pVm = (Vdbe *)pStmt;
................................................................................
  vals = sqlite3_data_count(pStmt);
  if( i>=vals || i<0 ){
    sqlite3Error(pVm->db, SQLITE_RANGE, 0);
    return 0;
  }

  pVal = &pVm->pTos[(1-vals)+i];
  Integerify(pVal, pVm->db->enc);
  return pVal->i;
}

/*
** Return the value of the 'i'th column of the current row of the currently
** executing statement pStmt.
*/
double sqlite3_column_float(sqlite3_stmt *pStmt, int i){
................................................................................

  vals = sqlite3_data_count(pStmt);
  if( i>=vals || i<0 ){
    sqlite3Error(pVm->db, SQLITE_RANGE, 0);
    return 0;
  }

  pVal = &pVm->pTos[(1-vals)+i];
  Realify(pVal, pVm->db->enc);
  return pVal->r;
}

/*
** Return the name of the Nth column of the result set returned by SQL
** statement pStmt.
*/
const char *sqlite3_column_name(sqlite3_stmt *pStmt, int N){
................................................................................
  if( N>=sqlite3_column_count(pStmt) || N<0 ){
    sqlite3Error(p->db, SQLITE_RANGE, 0);
    return 0;
  }

  return p->azColName[N];
}
























/*
** Return the type of the 'i'th column of the current row of the currently
** executing statement pStmt.
*/
int sqlite3_column_type(sqlite3_stmt *pStmt, int i){
  int vals;







|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|
<







 







|
<
<







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
...
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
...
712
713
714
715
716
717
718
719

720
721
722
723
724
725
726
...
730
731
732
733
734
735
736
737


738
739
740
741
742
743
744
...
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
**
** Various scripts scan this source file in order to generate HTML
** documentation, headers files, or other derived files.  The formatting
** of the code in this file is, therefore, important.  See other comments
** 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.324 2004/05/24 09:10:11 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "os.h"
#include <ctype.h>
#include "vdbeInt.h"

/*
................................................................................
  }else if( !(pVal->flags&MEM_Blob) ){
    /* Otherwise, unless this is a blob, convert it to a UTF-16 string */
    Stringify(pVal, TEXT_Utf16);
  }

  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.
*/
int sqlite3_column_bytes(sqlite3_stmt *pStmt, int i){
  Vdbe *pVm = (Vdbe *)pStmt;
................................................................................
  vals = sqlite3_data_count(pStmt);
  if( i>=vals || i<0 ){
    sqlite3Error(pVm->db, SQLITE_RANGE, 0);
    return 0;
  }

  pVal = &pVm->pTos[(1-vals)+i];
  return sqlite3_value_int(pVal);

}

/*
** Return the value of the 'i'th column of the current row of the currently
** executing statement pStmt.
*/
double sqlite3_column_float(sqlite3_stmt *pStmt, int i){
................................................................................

  vals = sqlite3_data_count(pStmt);
  if( i>=vals || i<0 ){
    sqlite3Error(pVm->db, SQLITE_RANGE, 0);
    return 0;
  }

  return sqlite3_value_float(pVal);


}

/*
** Return the name of the Nth column of the result set returned by SQL
** statement pStmt.
*/
const char *sqlite3_column_name(sqlite3_stmt *pStmt, int N){
................................................................................
  if( N>=sqlite3_column_count(pStmt) || N<0 ){
    sqlite3Error(p->db, SQLITE_RANGE, 0);
    return 0;
  }

  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.
*/
int sqlite3_column_type(sqlite3_stmt *pStmt, int i){
  int vals;