GRASS 8 Programmer's Manual 8.6.0dev(2026)-1d1e47ad9d
Loading...
Searching...
No Matches
rewind_pg.c
Go to the documentation of this file.
1/*!
2 \file lib/vector/Vlib/rewind_pg.c
3
4 \brief Vector library - rewind data (PostGIS layers)
5
6 Higher level functions for reading/writing/manipulating vectors.
7
8 (C) 2011-2012 by the GRASS Development Team
9
10 This program is free software under the GNU General Public License
11 (>=v2). Read the file COPYING that comes with GRASS for details.
12
13 \author Martin Landa <landa.martin gmail.com>
14 */
15
16#include <grass/vector.h>
17#include <grass/glocale.h>
18
19#include "local_proto.h"
20
21#ifdef HAVE_POSTGRES
22#include "pg_local_proto.h"
23#endif
24
25/*!
26 \brief Rewind vector map (PostGIS layer) to cause reads to start
27 at beginning (level 1)
28
29 \param Map pointer to Map_info structure
30
31 \return 0 on success
32 \return -1 on error
33 */
35{
36 G_debug(2, "V1_rewind_pg(): name = %s", Map->name);
37
38#ifdef HAVE_POSTGRES
39 struct Format_info_pg *pg_info;
40
41 pg_info = &(Map->fInfo.pg);
42
43 /* reset reading */
44 pg_info->next_line = 0;
45
46 /* reset cache */
47 if (pg_info->cache.ctype != CACHE_MAP) {
48 pg_info->cache.lines_num = 0;
49 pg_info->cache.fid = -1;
50 }
51 pg_info->cache.lines_next = 0;
52
53 /* close DB cursor if necessary */
55#else
56 G_fatal_error(_("GRASS is not compiled with PostgreSQL support"));
57 return -1;
58#endif
59}
60
61/*!
62 \brief Rewind vector map (PostGIS layer) to cause reads to start
63 at beginning on topological level (level 2)
64
65 \param Map pointer to Map_info structure
66
67 \return 0 on success
68 \return -1 on error
69 */
71{
72 G_debug(2, "V2_rewind_pg(): name = %s", Map->name);
73#ifdef HAVE_POSTGRES
74 /* reset reading */
75 Map->next_line = 1;
76
78
79 return 0;
80#else
81 G_fatal_error(_("GRASS is not compiled with PostgreSQL support"));
82 return -1;
83#endif
84}
AMI_err name(char **stream_name)
Definition ami_stream.h:426
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
int G_debug(int, const char *,...) __attribute__((format(printf
#define _(str)
Definition glocale.h:10
int Vect__close_cursor_pg(struct Format_info_pg *pg_info)
Close select cursor.
Definition read_pg.c:1454
int V1_rewind_pg(struct Map_info *Map)
Rewind vector map (PostGIS layer) to cause reads to start at beginning (level 1)
Definition rewind_pg.c:34
int V2_rewind_pg(struct Map_info *Map)
Rewind vector map (PostGIS layer) to cause reads to start at beginning on topological level (level 2)
Definition rewind_pg.c:70
Non-native format info (PostGIS)
Vector map info.