GRASS 8 Programmer's Manual 8.6.0dev(2026)-1878fdfec5
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 SPDX-FileCopyrightText: 2011-2012 GRASS Development Team
9 SPDX-License-Identifier: GPL-2.0-or-later
10
11 \author Martin Landa <landa.martin gmail.com>
12 */
13
14#include <grass/vector.h>
15#include <grass/glocale.h>
16
17#include "local_proto.h"
18
19#ifdef HAVE_POSTGRES
20#include "pg_local_proto.h"
21#endif
22
23/*!
24 \brief Rewind vector map (PostGIS layer) to cause reads to start
25 at beginning (level 1)
26
27 \param Map pointer to Map_info structure
28
29 \return 0 on success
30 \return -1 on error
31 */
33{
34 G_debug(2, "V1_rewind_pg(): name = %s", Map->name);
35
36#ifdef HAVE_POSTGRES
37 struct Format_info_pg *pg_info;
38
39 pg_info = &(Map->fInfo.pg);
40
41 /* reset reading */
42 pg_info->next_line = 0;
43
44 /* reset cache */
45 if (pg_info->cache.ctype != CACHE_MAP) {
46 pg_info->cache.lines_num = 0;
47 pg_info->cache.fid = -1;
48 }
49 pg_info->cache.lines_next = 0;
50
51 /* close DB cursor if necessary */
53#else
54 G_fatal_error(_("GRASS is not compiled with PostgreSQL support"));
55 return -1;
56#endif
57}
58
59/*!
60 \brief Rewind vector map (PostGIS layer) to cause reads to start
61 at beginning on topological level (level 2)
62
63 \param Map pointer to Map_info structure
64
65 \return 0 on success
66 \return -1 on error
67 */
69{
70 G_debug(2, "V2_rewind_pg(): name = %s", Map->name);
71#ifdef HAVE_POSTGRES
72 /* reset reading */
73 Map->next_line = 1;
74
76
77 return 0;
78#else
79 G_fatal_error(_("GRASS is not compiled with PostgreSQL support"));
80 return -1;
81#endif
82}
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:1452
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:32
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:68
Non-native format info (PostGIS)
Vector map info.