libgda-4.0, gedit-2.20: Fix gedit typo and GdaXaTransactionId.data
[vala-lang.git] / vapi / libpq.vapi
blobdbdc96f36ee17f629d4550603739f907117e7eaa
1 /* libpq.vapi
2  *
3  * Copyright (C) 2009 Jukka-Pekka Iivonen
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
18  *
19  * Author:
20  *      Jukka-Pekka Iivonen <jp0409@jippii.fi>
21  */
23 [CCode (cprefix = "PQ", cheader_filename = "postgresql/libpq-fe.h")]
24 namespace Postgres {
26         [CCode (cname = "ConnStatusType", cprefix = "CONNECTION_")]
27         public enum ConnectionStatus {
28                 OK,
29                 BAD,
30                 STARTED,
31                 MADE,
32                 AWAITING_RESPONSE,
33                 AUTH_OK,
34                 SETENV,
35                 SSL_STARTUP,
36                 NEEDED
37         }
39         [CCode (cname = "PostgresPollingStatusType", cprefix = "PGRES_POLLING_")]
40         public enum PollingStatus {
41                 FAILED,
42                 READING,
43                 WRITING,
44                 OK,
45                 ACTIVE
46         }
48         [CCode (cname = "ExecStatusType", cprefix = "PGRES_")]
49         public enum ExecStatus {
50                 EMPTY_QUERY,
51                 COMMAND_OK,
52                 TUPLES_OK,
53                 COPY_OUT,
54                 COPY_IN,
55                 BAD_RESPONSE,
56                 NONFATAL_ERROR,
57                 FATAL_ERROR
58         }
60         [CCode (cname = "PGTransactionStatusType", cprefix = "PQTRANS_")]
61         public enum TransactionStatus {
62                 IDLE,
63                 ACTIVE,
64                 INTRANS,
65                 INERROR,
66                 UNKNOWN
67         }
69         [CCode (cname = "PGVerbosity", cprefix = "PQERRORS_")]
70         public enum Verbosity {
71                 TERSE,
72                 DEFAULT,
73                 VERBOSE
74         }
76         [CCode (cname = "int", cprefix = "PG_DIAG_", has_type_id = false)]
77         public enum FieldCode {
78                 SEVERITY,
79                 SQLSTATE,
80                 MESSAGE_PRIMARY,
81                 MESSAGE_DETAIL,
82                 MESSAGE_HINT,
83                 STATEMENT_POSITION,
84                 INTERNAL_POSITION,
85                 INTERNAL_QUERY,
86                 CONTEXT,
87                 SOURCE_FILE,
88                 SOURCE_LINE,
89                 SOURCE_FUNCTION
90         }
92         [CCode (cname = "PGnotify")]
93         public struct Notify {
94                 public string relname;
95                 public int    be_pid;
96                 public string extra;
97         }
99         [CCode (cname = "PQnoticeReceiver")]
100         public delegate void NoticeReceiverFunc (void* arg, Result res);
102         [CCode (cname = "PQnoticeProcessor")]
103         public delegate void NoticeProcessorFunc (void* arg, string message);
105         [CCode (cname = "PQprintOpt")]
106         public struct PrintOpt {
107                 public bool     header;
108                 public bool     align;
109                 public bool     standard;
110                 public bool     html3;
111                 public bool     expanded;
112                 public bool     pager;
113                 public string   fieldSep;
114                 public string   tableOpt;
115                 public string   caption;
116                 public string[] fieldName;
117         }
119         [Compact]
120         [CCode (free_function = "PQconninfoFree", cname = "PQconninfoOption")]
121         public class ConnectionOptions {
122                 public string keyword;
123                 public string envvar;
124                 public string compiled;
125                 public string val;
126                 public string label;
127                 public string dispchar;
128                 public int    dispsize;
129         }
131         [CCode (cname = "PQArgBlock")]
132         public struct ArgBlock {
133                 public int len;
134                 public int isint;
135         }
137         [SimpleType]
138         [CCode (cname = "uint", default_value = "0U", type_signature = "u")]
139         public struct Oid {
140         }
142         [CCode (cname = "InvalidOid")]
143         public const uint InvalidOid;
145         [CCode (cname = "PQconnectStart")]
146         public Database connect_start (string conninfo);
148         [CCode (cname = "PQconnectdb")]
149         public Database connect_db (string conninfo);
151         [CCode (cname = "PQsetdbLogin")]
152         public Database set_db_login (string host, string port, string options, string gtty, string db_name, string login, string pwd);
154         [CCode (cname = "PQsetdb")]
155         public Database set_db (string host, string port, string options, string gtty, string db_name);
157         [CCode (cname = "PQconndefaults")]
158         public ConnectionOptions get_default_options ();
160         [CCode (cname = "PQinitSSL")]
161         public void init_ssl (int do_init);
163         [CCode (cname = "PQisthreadsafe")]
164         public int is_thread_safe ();
166         [CCode (cname = "PQresStatus")]
167         public unowned string result_status (ExecStatus status);
169         [Compact]
170         [CCode (free_function = "PQfreeCancel", cname = "PGcancel", cprefix = "PQ")]
171         public class Cancel {
172                 [CCode (cname = "PQcancel")]
173                 public bool cancel (char[] errbuf, int errbufsize);
174         }
176         /* Database Connection Handle */
177         [Compact]
178         [CCode (free_function = "PQfinish", cname = "PGconn", cprefix = "PQ")]
179         public class Database {
180                 [CCode (cname = "PQconnectPoll")]
181                 public PollingStatus connect_poll ();
183                 [CCode (cname = "PQresetStart")]
184                 public int reset_start ();
186                 [CCode (cname = "PQresetPoll")]
187                 public PollingStatus reset_poll ();
189                 [CCode (cname = "PQreset")]
190                 public void reset ();
192                 [CCode (cname = "PQgetCancel")]
193                 public Cancel get_cancel ();
195                 [CCode (cname = "PQrequestCancel")]
196                 public int request_cancel ();
198                 [CCode (cname = "PQdb")]
199                 public unowned string get_db ();
201                 [CCode (cname = "PQuser")]
202                 public unowned string get_user ();
204                 [CCode (cname = "PQpass")]
205                 public unowned string get_passwd ();
207                 [CCode (cname = "PQhost")]
208                 public unowned string get_host ();
210                 [CCode (cname = "PQport")]
211                 public unowned string get_port ();
213                 [CCode (cname = "PQtty")]
214                 public unowned string get_tty ();
216                 [CCode (cname = "PQoptions")]
217                 public unowned string get_options ();
219                 [CCode (cname = "PQstatus")]
220                 public ConnectionStatus get_status ();
222                 [CCode (cname = "PQtransactionStatus")]
223                 public TransactionStatus get_transaction_status ();
225                 [CCode (cname = "PQparameterStatus")]
226                 public unowned string get_parameter_status (string param_name);
228                 [CCode (cname = "PQprotocolVersion")]
229                 public int get_protocol_Version ();
231                 [CCode (cname = "PQserverVersion")]
232                 public int get_server_version ();
234                 [CCode (cname = "PQerrorMessage")]
235                 public unowned string get_error_message ();
237                 [CCode (cname = "PQsocket")]
238                 public int get_socket ();
240                 [CCode (cname = "PQbackendPID")]
241                 public int get_backend_pid ();
243                 [CCode (cname = "PQconnectionNeedsPassword")]
244                 public int connection_needs_password ();
246                 [CCode (cname = "PQconnectionUsedPassword")]
247                 public int connection_used_password ();
249                 [CCode (cname = "PQclientEncoding")]
250                 public int get_client_encoding ();
252                 [CCode (cname = "PQsetClientEncoding")]
253                 public int set_client_encoding (string encoding);
255                 [CCode (cname = "PQgetssl")]
256                 public void* get_ssl ();
258                 [CCode (cname = "PQsetErrorVerbosity")]
259                 public Verbosity set_error_verbosity (Verbosity verbosity);
261                 [CCode (cname = "PQtrace")]
262                 public void trace (GLib.FileStream debug_port);
264                 [CCode (cname = "PQuntrace")]
265                 public void untrace ();
267                 [CCode (cname = "PQsetNoticeReceiver")]
268                 public NoticeReceiverFunc set_notice_receiver (NoticeReceiverFunc proc_func, void* arg);
270                 [CCode (cname = "PQsetNoticeProcessor")]
271                 public NoticeProcessorFunc set_notice_processor (NoticeProcessorFunc proc_func, void* arg);
273                 [CCode (cname = "PQexec")]
274                 public Result exec (string query);
276                 [CCode (cname = "PQexecParams", array_length = false, array_null_terminated = false)]
277                 public Result exec_params (string command, int nParams, Oid[] paramTypes, string[] paramValues, int[] paramLengths,
278                                            int[] paramFormats, int resultFormat);
280                 [CCode (cname = "PQprepare", array_length = false, array_null_terminated = false)]
281                 public Result prepare (string stmtName, string query, int nParams, Oid[] paramTypes);
283                 [CCode (cname = "PQexecPrepared", array_length = false, array_null_terminated = false)]
284                 public Result exec_prepared (string stmtName, int nParams, string[] paramValues, int[] paramLengths,
285                                              int[] paramFormats, int resultFormat);
287                 [CCode (cname = "PQsendQuery")]
288                 public int send_query (string query);
290                 [CCode (cname = "PQsendQueryParams", array_length = false, array_null_terminated = false)]
291                 public int send_query_params (string command, int nParams, Oid[] paramTypes, string[] paramValues,
292                                               int[] paramLengths, int[] paramFormats, int resultFormat);
294                 [CCode (cname = "PQsendPrepare", array_length = false, array_null_terminated = false)]
295                 public int send_prepare (string stmtName, string query, int nParams, Oid[] paramTypes);
297                 [CCode (cname = "PQsendQueryPrepared", array_length = false, array_null_terminated = false)]
298                 public int send_query_prepared (string stmtName, int nParams, string[] paramValues, int[] paramLengths, 
299                                                 int[] paramFormats, int resultFormat);
301                 [CCode (cname = "PQgetResult")]
302                 public Result get_result ();
304                 [CCode (cname = "PQisBusy")]
305                 public int is_busy ();
307                 [CCode (cname = "PQconsumeInput")]
308                 public int consume_input ();
310                 [CCode (cname = "PQnotifies")]
311                 public Notify get_notifies ();
313                 [CCode (cname = "PQputCopyData")]
314                 public int put_copy_data (string buffer, int nbytes);
316                 [CCode (cname = "PQputCopyEnd")]
317                 public int put_copy_end (string error_msg);
319                 [CCode (cname = "PQgetCopyData")]
320                 public int get_copy_data (string[] buffer, int async);
322                 [CCode (cname = "PQsetnonblocking")]
323                 public int set_non_blocking (int arg);
325                 [CCode (cname = "PQisnonblocking")]
326                 public int is_non_blocking ();
328                 [CCode (cname = "PQflush")]
329                 public int flush ();
331                 [CCode (cname = "PQfn")]
332                 public Result fn (int fnid, int[] result_buf, out int result_len, int result_is_int, ArgBlock args, int nargs);
334                 [CCode (cname = "PQdescribePrepared")]
335                 public Result describe_prepared (string stmt);
337                 [CCode (cname = "PQdescribePortal")]
338                 public Result describe_portal (string portal);
340                 [CCode (cname = "PQsendDescribePrepared")]
341                 public int send_describe_prepared (string stmt);
343                 [CCode (cname = "PQsendDescribePortal")]
344                 public int send_describe_portal (string portal);
346                 [CCode (cname = "PQmakeEmptyPGresult")]
347                 public Result make_empty_result (ExecStatus status);
349                 [CCode (cname = "PQescapeStringConn")]
350                 public size_t escape_string_conn (string to, string from, size_t length, out int error);
352                 [CCode (cname = "PQescapeByteaConn")]
353                 public uchar[] escape_bytea_conn (string from, size_t from_length, out size_t to_length);
355                 [CCode (cname = "lo_open")]
356                 public int lo_open (int lobj_id, int mode);
358                 [CCode (cname = "lo_close")]
359                 public int lo_close (int fd);
361                 [CCode (cname = "lo_read")]
362                 public int lo_read (int fd, string buf, size_t len);
364                 [CCode (cname = "lo_write")]
365                 public int lo_write (int fd, string buf, size_t len);
367                 [CCode (cname = "lo_lseek")]
368                 public int lo_lseek (int fd, int offset, int whence);
370                 [CCode (cname = "lo_creat")]
371                 public int lo_creat (int mode);
373                 [CCode (cname = "lo_create")]
374                 public int lo_create (int lobj_id);
376                 [CCode (cname = "lo_tell")]
377                 public int lo_tell (int fd);
379                 [CCode (cname = "lo_truncate")]
380                 public int lo_truncate (int fd, size_t len);
382                 [CCode (cname = "lo_unlink")]
383                 public int lo_unlink (int lobj_id);
385                 [CCode (cname = "lo_import")]
386                 public int lo_import (string filename);
388                 [CCode (cname = "lo_export")]
389                 public int lo_export (int lobj_id, string filename);
390         }
392         [CCode (cname = "pgthreadlock_t")]
393         public delegate void ThreadLockFunc (int acquire);
395         [CCode (cname = "PQregisterThreadLock")]
396         public ThreadLockFunc register_thread_lock (ThreadLockFunc newhandler);
398         [CCode (cname = "PQunescapeBytea")]
399         public uchar[] unescape_bytea (uchar[] strtext, out size_t retbuflen);
401         [Compact]
402         [CCode (free_function = "PQclear", cname = "PGresult", cprefix = "PQ")]
403         public class Result {
404                 [CCode (cname = "PQresultStatus")]
405                 public ExecStatus get_status ();
407                 [CCode (cname = "PQresultErrorMessage")]
408                 public unowned string get_error_message ();
410                 [CCode (cname = "PQresultErrorField")]
411                 public unowned string get_error_field (FieldCode field_code);
413                 [CCode (cname = "PQntuples")]
414                 public int get_n_tuples ();
416                 [CCode (cname = "PQnfields")]
417                 public int get_n_fields ();
419                 [CCode (cname = "PQbinaryTuples")]
420                 public bool is_binary_tuples ();
422                 [CCode (cname = "PQfname")]
423                 public unowned string get_field_name (int field_num);
425                 [CCode (cname = "PQfnumber")]
426                 public int get_field_number (string field_name);
428                 [CCode (cname = "PQftable")]
429                 public Oid get_field_table (int field_num);
431                 [CCode (cname = "PQftablecol")]
432                 public int get_field_table_col (int field_num);
434                 [CCode (cname = "PQfformat")]
435                 public int get_field_format (int field_num);
437                 [CCode (cname = "PQftype")]
438                 public Oid get_field_type (int field_num);
440                 [CCode (cname = "PQfsize")]
441                 public int get_fsize (int field_num);
443                 [CCode (cname = "PQfmod")]
444                 public int get_field_mod (int field_num);
446                 [CCode (cname = "PQcmdStatus")]
447                 public unowned string get_cmd_status ();
449                 [CCode (cname = "PQoidValue")]
450                 public Oid get_oid_value ();
452                 [CCode (cname = "PQcmdTuples")]
453                 public unowned string get_cmd_tuples ();
455                 [CCode (cname = "PQgetvalue")]
456                 public unowned string get_value (int tup_num, int field_num);
458                 [CCode (cname = "PQgetlength")]
459                 public int get_length (int tup_num, int field_num);
461                 [CCode (cname = "PQgetisnull")]
462                 public bool is_null (int tup_num, int field_num);
464                 [CCode (cname = "PQnparams")]
465                 public int get_n_params ();
467                 [CCode (cname = "PQparamtype")]
468                 public int get_param_type (int param_num);
469         }
471         [CCode (cname = "PQfreemem")]
472         public void free_mem (void* ptr);
474         [CCode (cname = "PQprint")]
475         public void print (GLib.FileStream fout, Result res, PrintOpt ps);
477         [CCode (cname = "PQmblen")]
478         public int mb_len (string s, int encoding);
480         [CCode (cname = "PQdsplen")]
481         public int dsp_len (string s, int encoding);
483         [CCode (cname = "PQenv2encoding")]
484         public int env2encoding ();
486         [CCode (cname = "PQencryptPassword")]
487         public unowned string encrypt_password (string passwd, string user);
489         [CCode (cname = "pg_char_to_encoding")]
490         public int char_to_encoding (string name);
492         [CCode (cname = "pg_encoding_to_char")]
493         public unowned string encoding_to_char (int encoding);
495         [CCode (cname = "pg_valid_server_encoding_id")]
496         public int valid_server_encoding_id (int encoding);