~ubuntu-branches/ubuntu/intrepid/grass/intrepid

« back to all changes in this revision

Viewing changes to db/drivers/sqlite/describe.c

  • Committer: Bazaar Package Importer
  • Author(s): Noèl Köthe
  • Date: 2008-04-06 17:08:21 UTC
  • mfrom: (1.1.5 upstream) (3.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080406170821-7l3d3ulh4g8crwcs
Tags: 6.2.3-2.1
* NMU during credativ BSP 2008
* using patch from Moritz Muehlenhoff <jmm@inutil.org> to fix
  FTBFS with GCC 4.3: missing #includes
  (closes: #461673)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***********************************************************
2
 
*
3
 
* MODULE:       SQLite driver 
4
 
*               
5
 
* AUTHOR(S):    Radim Blazek
6
 
*
7
 
* COPYRIGHT:    (C) 2005 by the GRASS Development Team
8
 
*
9
 
* This program is free software under the GNU General Public
10
 
* License (>=v2). Read the file COPYING that comes with GRASS
11
 
* for details.
12
 
*
13
 
**************************************************************/
 
1
/**
 
2
 * \file describe.c
 
3
 *
 
4
 * \brief Low level SQLite database driver.
 
5
 *
 
6
 * This program is free software under the GNU General Public License
 
7
 * (>=v2). Read the file COPYING that comes with GRASS for details.
 
8
 *
 
9
 * \author Radim Blazek
 
10
 *
 
11
 * \date 2005-2007
 
12
 */
 
13
 
14
14
#include <string.h>
15
15
#include <grass/dbmi.h>
16
16
#include <grass/datetime.h>
 
17
#include <grass/glocale.h>
17
18
#include "globals.h"
18
19
#include "proto.h"
19
 
#include <grass/glocale.h>
 
20
 
 
21
/* function prototypes */
 
22
static int affinity_type (const char *);
 
23
 
 
24
 
 
25
/**
 
26
 * \fn int db__driver_describe_table (dbString *table_name, dbTable **table)
 
27
 *
 
28
 * \brief Low level SQLite describe database table.
 
29
 *
 
30
 * \param[in] table_name
 
31
 * \param[in] table
 
32
 * \return int DB_FAILED on error; DB_OK on success
 
33
 */
20
34
 
21
35
int db__driver_describe_table (dbString *table_name, dbTable **table)
22
 
 
23
36
{
24
37
    dbString sql;
25
38
    sqlite3_stmt *statement;
26
 
    char  *rest;
 
39
    const char *rest;
27
40
    int   ret;
28
41
 
29
42
    db_init_string ( &sql );
35
48
    ret = sqlite3_prepare ( sqlite, db_get_string(&sql), -1,
36
49
                            &statement, &rest );
37
50
 
38
 
 
39
51
    if ( ret != SQLITE_OK )
40
52
    {
41
53
        append_error("Error in sqlite3_prepare():");
42
54
        append_error( db_get_string(&sql) );
43
55
        append_error( "\n" );
44
 
        append_error ( sqlite3_errmsg(sqlite) );
 
56
        append_error ((char *) sqlite3_errmsg (sqlite));
45
57
        report_error( );
46
58
        db_free_string ( &sql );
47
59
        return DB_FAILED;
61
73
    return DB_OK;
62
74
}
63
75
 
64
 
/* describe table, if c is not NULL cur->cols and cur->ncols is also set */
 
76
 
 
77
/**
 
78
 * \fn int describe_table (sqlite3_stmt *statement, dbTable **table, cursor *c)
 
79
 *
 
80
 * \brief SQLite describe table.
 
81
 *
 
82
 * NOTE: If <b>c</b> is not NULL c->cols and c->ncols are also set.
 
83
 *
 
84
 * \param[in] statement
 
85
 * \param[in] table
 
86
 * \param[in] c SQLite cursor. See NOTE.
 
87
 * \return int DB_FAILED on error; DB_OK on success
 
88
 */
 
89
 
65
90
int describe_table( sqlite3_stmt *statement, 
66
91
                        dbTable **table, cursor *c)
67
92
{
195
220
    return DB_OK;
196
221
}
197
222
 
 
223
 
 
224
/**
 
225
 * \fn void get_column_info (sqlite3_stmt *statement, int col, int *litetype, int *sqltype)
 
226
 *
 
227
 * \brief Low level SQLite get column information.
 
228
 *
 
229
 * \param[in] statement
 
230
 * \param[in] col
 
231
 * \param[in,out] litetype
 
232
 * \param[in,out] sqltype
 
233
 */
 
234
 
198
235
void get_column_info ( sqlite3_stmt *statement, int col, 
199
236
                int *litetype, int *sqltype )
200
237
{
257
294
*   4. Otherwise, the affinity is NUMERIC.
258
295
*/
259
296
 
260
 
int affinity_type ( const char *declared )
 
297
static int affinity_type (const char *declared)
261
298
{
262
299
    char *lc;
263
300
    int aff = SQLITE_FLOAT;