This repository was archived by the owner on Apr 8, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpgada-thin.ads
More file actions
200 lines (166 loc) · 7.8 KB
/
Copy pathpgada-thin.ads
File metadata and controls
200 lines (166 loc) · 7.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
------------------------------------------------------------------------------
-- --
-- P G A D A . T H I N --
-- --
-- S p e c --
-- --
-- Copyright (c) coreland 2009 --
-- Copyright (c) Samuel Tardieu 2000 --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of Samuel Tardieu nor the names of its contributors --
-- may be used to endorse or promote products derived from this --
-- software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY SAMUEL TARDIEU AND CONTRIBUTORS ``AS --
-- IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS --
-- FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SAMUEL --
-- TARDIEU OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, --
-- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES --
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR --
-- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) --
-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN --
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR --
-- OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, --
-- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Interfaces.C.Strings;
with Interfaces.C;
package PGAda.Thin is
pragma Preelaborate;
package C renames Interfaces.C;
package CS renames Interfaces.C.Strings;
type Conn_Status_t is (CONNECTION_OK, CONNECTION_BAD);
for Conn_Status_t'Size use C.int'Size;
pragma Convention (C, Conn_Status_t);
type Exec_Status_t is
(PGRES_EMPTY_QUERY,
PGRES_COMMAND_OK,
PGRES_TUPLES_OK,
PGRES_COPY_OUT,
PGRES_COPY_IN,
PGRES_BAD_RESPONSE,
PGRES_NONFATAL_ERROR,
PGRES_FATAL_ERROR);
for Exec_Status_t'Size use C.int'Size;
pragma Convention (C, Exec_Status_t);
type PG_Conn is null record;
type PG_Conn_Access_t is access PG_Conn;
pragma Convention (C, PG_Conn_Access_t);
type PG_Result is null record;
type PG_Result_Access_t is access PG_Result;
pragma Convention (C, PG_Result_Access_t);
type Oid is new C.unsigned;
type Error_Field is
(PG_DIAG_SQLSTATE,
PG_DIAG_MESSAGE_DETAIL,
PG_DIAG_SOURCE_FILE,
PG_DIAG_MESSAGE_HINT,
PG_DIAG_SOURCE_LINE,
PG_DIAG_MESSAGE_PRIMARY,
PG_DIAG_STATEMENT_POSITION,
PG_DIAG_SOURCE_FUNCTION,
PG_DIAG_SEVERITY,
PG_DIAG_CONTEXT,
PG_DIAG_INTERNAL_POSITION,
PG_DIAG_INTERNAL_QUERY);
for Error_Field use
(PG_DIAG_SQLSTATE => 67,
PG_DIAG_MESSAGE_DETAIL => 68,
PG_DIAG_SOURCE_FILE => 70,
PG_DIAG_MESSAGE_HINT => 72,
PG_DIAG_SOURCE_LINE => 76,
PG_DIAG_MESSAGE_PRIMARY => 77,
PG_DIAG_STATEMENT_POSITION => 80,
PG_DIAG_SOURCE_FUNCTION => 82,
PG_DIAG_SEVERITY => 83,
PG_DIAG_CONTEXT => 87,
PG_DIAG_INTERNAL_POSITION => 112,
PG_DIAG_INTERNAL_QUERY => 113);
for Error_Field'Size use C.int'Size;
function PQ_Set_Db_Login
(PG_Host : CS.chars_ptr;
PG_Port : CS.chars_ptr;
PG_Options : CS.chars_ptr;
PG_TTY : CS.chars_ptr;
Db_Name : CS.chars_ptr;
Login : CS.chars_ptr;
Password : CS.chars_ptr) return PG_Conn_Access_t;
pragma Import (C, PQ_Set_Db_Login, "PQsetdbLogin");
function PQ_Db (Conn : PG_Conn_Access_t) return CS.chars_ptr;
pragma Import (C, PQ_Db, "PQdb");
function PQ_Host (Conn : PG_Conn_Access_t) return CS.chars_ptr;
pragma Import (C, PQ_Host, "PQhost");
function PQ_Port (Conn : PG_Conn_Access_t) return CS.chars_ptr;
pragma Import (C, PQ_Port, "PQport");
function PQ_Options (Conn : PG_Conn_Access_t) return CS.chars_ptr;
pragma Import (C, PQ_Options, "PQoptions");
function PQ_Status (Conn : PG_Conn_Access_t) return Conn_Status_t;
pragma Import (C, PQ_Status, "PQstatus");
function PQ_Error_Message (Conn : PG_Conn_Access_t) return CS.chars_ptr;
pragma Import (C, PQ_Error_Message, "PQerrorMessage");
procedure PQ_Finish (Conn : in PG_Conn_Access_t);
pragma Import (C, PQ_Finish, "PQfinish");
procedure PQ_Reset (Conn : in PG_Conn_Access_t);
pragma Import (C, PQ_Reset, "PQreset");
function PQ_Exec
(Conn : PG_Conn_Access_t;
Query : CS.chars_ptr) return PG_Result_Access_t;
pragma Import (C, PQ_Exec, "PQexec");
function PQ_Result_Status (Res : PG_Result_Access_t) return Exec_Status_t;
pragma Import (C, PQ_Result_Status, "PQresultStatus");
function PQ_N_Tuples (Res : PG_Result_Access_t) return C.int;
pragma Import (C, PQ_N_Tuples, "PQntuples");
function PQ_N_Fields (Res : PG_Result_Access_t) return C.int;
pragma Import (C, PQ_N_Fields, "PQnfields");
function PQ_F_Name
(Res : PG_Result_Access_t;
Field_Index : C.int) return CS.chars_ptr;
pragma Import (C, PQ_F_Name, "PQfname");
function PQ_F_Number
(Res : PG_Result_Access_t;
Field_Index : CS.chars_ptr) return C.int;
pragma Import (C, PQ_F_Number, "PQfnumber");
function PQ_F_Type
(Res : PG_Result_Access_t;
Field_Index : C.int) return Oid;
pragma Import (C, PQ_F_Type, "PQftype");
function PQ_Get_Value
(Res : PG_Result_Access_t;
Tup_Num : C.int;
Field_Num : C.int) return CS.chars_ptr;
pragma Import (C, PQ_Get_Value, "PQgetvalue");
function PQ_Get_Length
(Res : PG_Result_Access_t;
Tup_Num : C.int;
Field_Num : C.int) return C.int;
pragma Import (C, PQ_Get_Length, "PQgetlength");
function PQ_Get_Is_Null
(Res : PG_Result_Access_t;
Tup_Num : C.int;
Field_Num : C.int) return C.int;
pragma Import (C, PQ_Get_Is_Null, "PQgetisnull");
function PQ_Cmd_Tuples (Res : PG_Result_Access_t) return CS.chars_ptr;
pragma Import (C, PQ_Cmd_Tuples, "PQcmdTuples");
function PQ_Cmd_Status (Res : PG_Result_Access_t) return CS.chars_ptr;
pragma Import (C, PQ_Cmd_Status, "PQcmdStatus");
function PQ_Oid_Status (Res : PG_Result_Access_t) return CS.chars_ptr;
pragma Import (C, PQ_Oid_Status, "PQoidStatus");
procedure PQ_Clear (Res : in PG_Result_Access_t);
pragma Import (C, PQ_Clear, "PQclear");
function PQ_Result_Error_Field
(Res : PG_Result_Access_t;
Field : Error_Field) return CS.chars_ptr;
pragma Import (C, PQ_Result_Error_Field, "PQresultErrorField");
end PGAda.Thin;