PGROUTING  2.5
postgres_connection.h File Reference
#include <postgres.h>
#include "executor/spi.h"
#include "utils/builtins.h"
#include <funcapi.h>
#include <fmgr.h>
Include dependency graph for postgres_connection.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

char * pgr_cstring2char (const char *inStr)
 
void pgr_send_error (int errcode)
 
void pgr_SPI_connect (void)
 
Portal pgr_SPI_cursor_open (SPIPlanPtr SPIplan)
 
void pgr_SPI_finish (void)
 
SPIPlanPtr pgr_SPI_prepare (char *sql)
 

Function Documentation

char* pgr_cstring2char ( const char *  inStr)

Definition at line 52 of file postgres_connection.c.

Referenced by pgr_error().

52  {
53 
54  if(!inStr) return NULL;
55 
56  char *outStr;
57  outStr = palloc(strlen(inStr));
58  if (!outStr) return NULL;
59 
60  memcpy(outStr, inStr, strlen(inStr));
61 
62  outStr[strlen(inStr)] = '\0';
63 
64  return outStr;
65 }

Here is the caller graph for this function:

void pgr_send_error ( int  errcode)

Definition at line 35 of file postgres_connection.c.

35  {
36  switch (errcode) {
37  case 1:
38  elog(ERROR, "Unexpected point(s) with same pid but different"
39  " edge/fraction/side combination found.");
40  break;
41  case 2:
42  elog(ERROR, "Internal: Unexpected mismatch "
43  "count and sequence number on results");
44  break;
45  default:
46  elog(ERROR, "Unknown exception");
47  }
48 }
void pgr_SPI_connect ( void  )

Definition at line 83 of file postgres_connection.c.

References PGR_DBG.

Referenced by compute(), and process().

83  {
84 #if 0
85  PGR_DBG("Connecting to SPI");
86 #endif
87  int SPIcode;
88  SPIcode = SPI_connect();
89  if (SPIcode != SPI_OK_CONNECT) {
90  elog(ERROR, "Couldn't open a connection to SPI");
91  }
92 }
#define PGR_DBG(...)
Definition: debug_macro.h:34

Here is the caller graph for this function:

Portal pgr_SPI_cursor_open ( SPIPlanPtr  SPIplan)

Definition at line 108 of file postgres_connection.c.

References PGR_DBG.

Referenced by get_edges_5_columns(), get_edges_9_columns(), get_edges_basic(), get_edges_flow(), pgr_get_coordinates(), pgr_get_matrixRows(), pgr_get_pd_orders_general(), pgr_get_points(), pgr_get_restriction_data(), and pgr_get_vehicles_general().

108  {
109 #if 0
110  PGR_DBG("Opening Portal");
111 #endif
112  Portal SPIportal;
113  SPIportal = SPI_cursor_open(NULL, SPIplan, NULL, NULL, true);
114  if (SPIportal == NULL) {
115  elog(ERROR, "SPI_cursor_open returns NULL");
116  }
117  return SPIportal;
118 }
#define PGR_DBG(...)
Definition: debug_macro.h:34

Here is the caller graph for this function:

void pgr_SPI_finish ( void  )

Definition at line 71 of file postgres_connection.c.

References PGR_DBG.

Referenced by compute(), and process().

71  {
72 #if 0
73  PGR_DBG("Disconnecting SPI");
74 #endif
75  int code = SPI_OK_FINISH;
76  code = SPI_finish();
77  if (code != SPI_OK_FINISH) { // SPI_ERROR_UNCONNECTED
78  elog(ERROR, "There was no connection to SPI");
79  }
80 }
#define PGR_DBG(...)
Definition: debug_macro.h:34

Here is the caller graph for this function:

SPIPlanPtr pgr_SPI_prepare ( char *  sql)

Definition at line 95 of file postgres_connection.c.

References PGR_DBG.

Referenced by get_edges_5_columns(), get_edges_9_columns(), get_edges_basic(), get_edges_flow(), pgr_get_coordinates(), pgr_get_matrixRows(), pgr_get_pd_orders_general(), pgr_get_points(), pgr_get_restriction_data(), and pgr_get_vehicles_general().

95  {
96 #if 0
97  PGR_DBG("Preparing Plan");
98 #endif
99  SPIPlanPtr SPIplan;
100  SPIplan = SPI_prepare(sql, 0, NULL);
101  if (SPIplan == NULL) {
102  elog(ERROR, "Couldn't create query plan via SPI: %s", sql);
103  }
104  return SPIplan;
105 }
#define PGR_DBG(...)
Definition: debug_macro.h:34

Here is the caller graph for this function: