PostgreSQL Source Code: src/interfaces/libpq/libpq-fe.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15#ifndef LIBPQ_FE_H

16#define LIBPQ_FE_H

17

18#ifdef __cplusplus

19extern "C"

20{

21#endif

22

23#include <stdint.h>

24#include <stdio.h>

25

26

27

28

29

31

32

33

34

35

36

37

38#define LIBPQ_HAS_PIPELINING 1

39

40#define LIBPQ_HAS_TRACE_FLAGS 1

41

42

43

44#define LIBPQ_HAS_SSL_LIBRARY_DETECTION 1

45

46

47

48#define LIBPQ_HAS_ASYNC_CANCEL 1

49

50#define LIBPQ_HAS_CHANGE_PASSWORD 1

51

52#define LIBPQ_HAS_CHUNK_MODE 1

53

54#define LIBPQ_HAS_CLOSE_PREPARED 1

55

56#define LIBPQ_HAS_SEND_PIPELINE_SYNC 1

57

58#define LIBPQ_HAS_SOCKET_POLL 1

59

60

61

62#define LIBPQ_HAS_FULL_PROTOCOL_VERSION 1

63

64#define LIBPQ_HAS_PROMPT_OAUTH_DEVICE 1

65

66

67

68

69#define PG_COPYRES_ATTRS 0x01

70#define PG_COPYRES_TUPLES 0x02

71#define PG_COPYRES_EVENTS 0x04

72#define PG_COPYRES_NOTICEHOOKS 0x08

73

74

75

76

77

78

79

80

81

82typedef enum

83{

86

87

88

89

90

91

95

97

105

108

110

112

113typedef enum

114{

121

122typedef enum

123{

126

127

129

130

134

141

144

145typedef enum

146{

153

154typedef enum

155{

161

162typedef enum

163{

168

169

170

171

172

173

174typedef enum

175{

176 PQPING_OK,

177 PQPING_REJECT,

181

182

183

184

185typedef enum

186{

191

192typedef enum

193{

195

198

199

200

201

203

204

205

206

208

209

210

211

212

213

215

216

217

218

219

221

222

223

224

225

226

227

229{

230 char *relname;

231 int be_pid;

232 char *extra;

233

236

237

239

240

242

243

246

247

249

251{

252 pqbool header;

259 char *tableOpt;

261 char **fieldName;

262

264

265

266

267

268

269

270

271

272

273

275{

276 char *keyword;

277 char *envvar;

278 char *compiled;

279 char *val;

280 char *label;

281 char *dispchar;

282

283

284

285

286 int dispsize;

288

289

290

291

292

293typedef struct

294{

297 union

298 {

299 int *ptr;

303

304

305

306

307

309{

310 char *name;

312 int columnid;

313 int format;

316 int atttypmod;

318

319

320

321

322

323

324

325

326

327

330 const char *const *values, int expand_dbname);

332

333

336 const char *const *values, int expand_dbname);

338 const char *pgoptions, const char *pgtty,

340 const char *login, const char *pwd);

341

342#define PQsetdb(M_PGHOST,M_PGPORT,M_PGOPT,M_PGTTY,M_DBNAME) \

343 PQsetdbLogin(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME, NULL, NULL)

344

345

347

348

350

351

353

354

356

357

359

360

361

362

363

364

367

368

370

371

373

374

376

377

379

380

387

388

389

391

392

394

395

396extern int PQcancel(PGcancel *cancel, char *errbuf, int errbufsize);

397

398

400

401

414 const char *paramName);

427

428

433

434

435

437

438

440

441

442extern void PQinitOpenSSL(int do_ssl, int do_crypto);

443

444

446

447

449

450

452

453

456

457

460 void *arg);

463 void *arg);

464

465

466

467

468

469

470

471

473

475

476

479

480

481

482#define PQTRACE_SUPPRESS_TIMESTAMPS (1<<0)

483

484#define PQTRACE_REGRESS_MODE (1<<1)

486

487

488

489

492 const char *command,

493 int nParams,

494 const Oid *paramTypes,

495 const char *const *paramValues,

496 const int *paramLengths,

497 const int *paramFormats,

498 int resultFormat);

500 const char *query, int nParams,

501 const Oid *paramTypes);

503 const char *stmtName,

504 int nParams,

505 const char *const *paramValues,

506 const int *paramLengths,

507 const int *paramFormats,

508 int resultFormat);

509

510

511#define PQ_QUERY_PARAM_MAX_LIMIT 65535

512

515 const char *command,

516 int nParams,

517 const Oid *paramTypes,

518 const char *const *paramValues,

519 const int *paramLengths,

520 const int *paramFormats,

521 int resultFormat);

523 const char *query, int nParams,

524 const Oid *paramTypes);

526 const char *stmtName,

527 int nParams,

528 const char *const *paramValues,

529 const int *paramLengths,

530 const int *paramFormats,

531 int resultFormat);

535

536

539

540

546

547

549

550

554

555

561

562

568 const char *const *values, int expand_dbname);

569

570

572

573

574

575

576

578 int fnid,

579 int *result_buf,

580 int *result_len,

581 int result_is_int,

583 int nargs);

584

585

597extern int PQfnumber(const PGresult *res, const char *field_name);

603extern int PQfmod(const PGresult *res, int field_num);

608extern char *PQgetvalue(const PGresult *res, int tup_num, int field_num);

613

614

619

620

625

626

628

629

631

632

633#define PQfreeNotify(ptr) PQfreemem(ptr)

634

635

636

637#define PQnoPasswordSupplied "fe_sendauth: no password supplied\n"

638

639

646

647

649 char *to, const char *from, size_t length,

654 const unsigned char *from, size_t from_length,

655 size_t *to_length);

656extern unsigned char *PQunescapeBytea(const unsigned char *strtext,

657 size_t *retbuflen);

658

659

660extern size_t PQescapeString(char *to, const char *from, size_t length);

661extern unsigned char *PQescapeBytea(const unsigned char *from, size_t from_length,

662 size_t *to_length);

663

664

665

666

667

668extern void PQprint(FILE *fout,

670 const PQprintOpt *po);

671

672

673

674

676 FILE *fp,

677 int fillAlign,

678 const char *fieldSep,

679 int printHeader,

680 int quiet);

681

683 FILE *fout,

684 int PrintAttNames,

685 int TerseOutput,

686 int colWidth);

687

688

689

690

691

692

709

710

711

712

714

715

716extern int PQsocketPoll(int sock, int forRead, int forWrite,

718

719

721

722

724

725

727

728

730

731

733

734

735

737{

739 const char *user_code;

741

742 int expires_in;

744

745

746#ifdef _WIN32

747#define SOCKTYPE uintptr_t

748#else

749#define SOCKTYPE int

750#endif

751

753{

754

756 const char *scope;

757

758

759

760

761

762

763

764

765

766

767

768

769

770

771

772

773

774

775

779

780

781

782

783

784

785

786

788

789

790

791

792

793

795

796

797

798

799

800

801

804

805#undef SOCKTYPE

806

810

815

816

817

821

822

823

824

829

830#ifdef __cplusplus

831}

832#endif

833

834#endif

static Datum values[MAXATTR]

static PGcancel *volatile cancelConn

int errmsg(const char *fmt,...)

static const JsonPathKeyword keywords[]

@ CONNECTION_AUTHENTICATING

@ CONNECTION_CHECK_STANDBY

@ CONNECTION_AWAITING_RESPONSE

@ CONNECTION_CHECK_WRITABLE

@ CONNECTION_CHECK_TARGET

int PQserverVersion(const PGconn *conn)

char * PQencryptPasswordConn(PGconn *conn, const char *passwd, const char *user, const char *algorithm)

int PQprotocolVersion(const PGconn *conn)

int PQresetStart(PGconn *conn)

int PQsendQueryParams(PGconn *conn, const char *command, int nParams, const Oid *paramTypes, const char *const *paramValues, const int *paramLengths, const int *paramFormats, int resultFormat)

int PQgetlength(const PGresult *res, int tup_num, int field_num)

int PQsetSingleRowMode(PGconn *conn)

void PQsetAuthDataHook(PQauthDataHook_type hook)

char * PQoptions(const PGconn *conn)

int PQbinaryTuples(const PGresult *res)

int PQflush(PGconn *conn)

PGresult * PQcopyResult(const PGresult *src, int flags)

void PQfreemem(void *ptr)

void PQdisplayTuples(const PGresult *res, FILE *fp, int fillAlign, const char *fieldSep, int printHeader, int quiet)

int PQgetline(PGconn *conn, char *buffer, int length)

int(* PQauthDataHook_type)(PGauthData type, PGconn *conn, void *data)

char * PQdb(const PGconn *conn)

void PQinitSSL(int do_init)

Oid PQftype(const PGresult *res, int field_num)

PGresult * PQchangePassword(PGconn *conn, const char *user, const char *passwd)

void(* pgthreadlock_t)(int acquire)

int lo_tell(PGconn *conn, int fd)

void * PQgetssl(PGconn *conn)

char * PQresultVerboseErrorMessage(const PGresult *res, PGVerbosity verbosity, PGContextVisibility show_context)

struct PGoauthBearerRequest PGoauthBearerRequest

PGresult * PQdescribePrepared(PGconn *conn, const char *stmt)

PGresult * PQexecParams(PGconn *conn, const char *command, int nParams, const Oid *paramTypes, const char *const *paramValues, const int *paramLengths, const int *paramFormats, int resultFormat)

int PQexitPipelineMode(PGconn *conn)

PGresult * PQexecPrepared(PGconn *conn, const char *stmtName, int nParams, const char *const *paramValues, const int *paramLengths, const int *paramFormats, int resultFormat)

int PQsendClosePortal(PGconn *conn, const char *portal)

PGcancel * PQgetCancel(PGconn *conn)

int PQsetResultAttrs(PGresult *res, int numAttributes, PGresAttDesc *attDescs)

void PQcancelReset(PGcancelConn *cancelConn)

int lo_close(PGconn *conn, int fd)

struct _PQconninfoOption PQconninfoOption

unsigned char * PQunescapeBytea(const unsigned char *strtext, size_t *retbuflen)

const char * pg_encoding_to_char(int encoding)

PQsslKeyPassHook_OpenSSL_type PQgetSSLKeyPassHook_OpenSSL(void)

void * PQsslStruct(PGconn *conn, const char *struct_name)

int PQfullProtocolVersion(const PGconn *conn)

void PQreset(PGconn *conn)

int PQenterPipelineMode(PGconn *conn)

int PQsocketPoll(int sock, int forRead, int forWrite, pg_usec_time_t end_time)

int lo_truncate64(PGconn *conn, int fd, int64_t len)

size_t PQescapeStringConn(PGconn *conn, char *to, const char *from, size_t length, int *error)

void PQtrace(PGconn *conn, FILE *debug_port)

char * PQport(const PGconn *conn)

PGresult * PQclosePrepared(PGconn *conn, const char *stmt)

PGTransactionStatusType PQtransactionStatus(const PGconn *conn)

PGcancelConn * PQcancelCreate(PGconn *conn)

PQauthDataHook_type PQgetAuthDataHook(void)

char * PQgetvalue(const PGresult *res, int tup_num, int field_num)

void * PQgetgssctx(PGconn *conn)

PGresult * PQclosePortal(PGconn *conn, const char *portal)

PGresult * PQgetResult(PGconn *conn)

ExecStatusType PQresultStatus(const PGresult *res)

Oid PQparamtype(const PGresult *res, int param_num)

PGconn * PQconnectdb(const char *conninfo)

char * PQhost(const PGconn *conn)

int PQnparams(const PGresult *res)

int PQdefaultSSLKeyPassHook_OpenSSL(char *buf, int size, PGconn *conn)

int pg_char_to_encoding(const char *name)

void PQprintTuples(const PGresult *res, FILE *fout, int PrintAttNames, int TerseOutput, int colWidth)

void PQclear(PGresult *res)

int PQsendClosePrepared(PGconn *conn, const char *stmt)

char * PQservice(const PGconn *conn)

char * PQcmdTuples(PGresult *res)

struct _PQprintOpt PQprintOpt

int PQconnectionUsedPassword(const PGconn *conn)

PQconninfoOption * PQconninfo(PGconn *conn)

int PQfformat(const PGresult *res, int field_num)

void(* PQnoticeReceiver)(void *arg, const PGresult *res)

void(* PQnoticeProcessor)(void *arg, const char *message)

int PQendcopy(PGconn *conn)

int PQgssEncInUse(PGconn *conn)

PostgresPollingStatusType PQconnectPoll(PGconn *conn)

int PQdefaultAuthDataHook(PGauthData type, PGconn *conn, void *data)

int PQputCopyEnd(PGconn *conn, const char *errormsg)

void PQconninfoFree(PQconninfoOption *connOptions)

Oid lo_creat(PGconn *conn, int mode)

int PQsendPipelineSync(PGconn *conn)

int(* PQsslKeyPassHook_OpenSSL_type)(char *buf, int size, PGconn *conn)

int lo_read(PGconn *conn, int fd, char *buf, size_t len)

int lo_lseek(PGconn *conn, int fd, int offset, int whence)

int PQntuples(const PGresult *res)

int PQputnbytes(PGconn *conn, const char *buffer, int nbytes)

void PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po)

int pg_valid_server_encoding_id(int encoding)

int PQmblen(const char *s, int encoding)

int PQputline(PGconn *conn, const char *string)

int PQgetlineAsync(PGconn *conn, char *buffer, int bufsize)

int lo_open(PGconn *conn, Oid lobjId, int mode)

PostgresPollingStatusType

char * PQtty(const PGconn *conn)

int PQputCopyData(PGconn *conn, const char *buffer, int nbytes)

PQconninfoOption * PQconninfoParse(const char *conninfo, char **errmsg)

const char * PQparameterStatus(const PGconn *conn, const char *paramName)

PGresult * PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status)

ConnStatusType PQcancelStatus(const PGcancelConn *cancelConn)

int64_t lo_lseek64(PGconn *conn, int fd, int64_t offset, int whence)

PGresult * PQprepare(PGconn *conn, const char *stmtName, const char *query, int nParams, const Oid *paramTypes)

int64_t lo_tell64(PGconn *conn, int fd)

int lo_write(PGconn *conn, int fd, const char *buf, size_t len)

int PQconnectionNeedsPassword(const PGconn *conn)

char * PQresultErrorMessage(const PGresult *res)

char * PQencryptPassword(const char *passwd, const char *user)

char * PQpass(const PGconn *conn)

void PQinitOpenSSL(int do_ssl, int do_crypto)

int PQcancelBlocking(PGcancelConn *cancelConn)

int lo_truncate(PGconn *conn, int fd, size_t len)

int PQsendDescribePrepared(PGconn *conn, const char *stmt)

char * PQfname(const PGresult *res, int field_num)

Oid lo_create(PGconn *conn, Oid lobjId)

PostgresPollingStatusType PQresetPoll(PGconn *conn)

int PQsslInUse(PGconn *conn)

int PQconnectionUsedGSSAPI(const PGconn *conn)

size_t PQescapeString(char *to, const char *from, size_t length)

int PQconsumeInput(PGconn *conn)

int PQcancel(PGcancel *cancel, char *errbuf, int errbufsize)

@ PQAUTHDATA_PROMPT_OAUTH_DEVICE

@ PQAUTHDATA_OAUTH_BEARER_TOKEN

ConnStatusType PQstatus(const PGconn *conn)

PGconn * PQconnectStart(const char *conninfo)

Oid PQftable(const PGresult *res, int field_num)

int PQfnumber(const PGresult *res, const char *field_name)

unsigned char * PQescapeBytea(const unsigned char *from, size_t from_length, size_t *to_length)

int PQsetnonblocking(PGconn *conn, int arg)

int PQclientEncoding(const PGconn *conn)

PGconn * PQconnectStartParams(const char *const *keywords, const char *const *values, int expand_dbname)

char * PQescapeLiteral(PGconn *conn, const char *str, size_t len)

void PQfinish(PGconn *conn)

PGresult * PQfn(PGconn *conn, int fnid, int *result_buf, int *result_len, int result_is_int, const PQArgBlock *args, int nargs)

PGPing PQping(const char *conninfo)

int PQsendPrepare(PGconn *conn, const char *stmtName, const char *query, int nParams, const Oid *paramTypes)

PGresult * PQdescribePortal(PGconn *conn, const char *portal)

int PQfmod(const PGresult *res, int field_num)

PGContextVisibility PQsetErrorContextVisibility(PGconn *conn, PGContextVisibility show_context)

int PQdsplen(const char *s, int encoding)

int PQgetisnull(const PGresult *res, int tup_num, int field_num)

int PQftablecol(const PGresult *res, int field_num)

int PQsetChunkedRowsMode(PGconn *conn, int chunkSize)

const char * PQsslAttribute(PGconn *conn, const char *attribute_name)

char * PQresultErrorField(const PGresult *res, int fieldcode)

int PQsetvalue(PGresult *res, int tup_num, int field_num, char *value, int len)

int PQsendQuery(PGconn *conn, const char *query)

char * PQcmdStatus(PGresult *res)

int PQpipelineSync(PGconn *conn)

PostgresPollingStatusType PQcancelPoll(PGcancelConn *cancelConn)

char * PQoidStatus(const PGresult *res)

PQnoticeReceiver PQsetNoticeReceiver(PGconn *conn, PQnoticeReceiver proc, void *arg)

int PQsendDescribePortal(PGconn *conn, const char *portal)

void PQcancelFinish(PGcancelConn *cancelConn)

PGconn * PQsetdbLogin(const char *pghost, const char *pgport, const char *pgoptions, const char *pgtty, const char *dbName, const char *login, const char *pwd)

struct _PGpromptOAuthDevice PGpromptOAuthDevice

void PQsetTraceFlags(PGconn *conn, int flags)

char * PQhostaddr(const PGconn *conn)

char * PQresStatus(ExecStatusType status)

size_t PQresultMemorySize(const PGresult *res)

int PQbackendPID(const PGconn *conn)

void * PQresultAlloc(PGresult *res, size_t nBytes)

PQconninfoOption * PQconndefaults(void)

int PQisBusy(PGconn *conn)

PGresult * PQexec(PGconn *conn, const char *query)

pg_usec_time_t PQgetCurrentTimeUSec(void)

unsigned char * PQescapeByteaConn(PGconn *conn, const unsigned char *from, size_t from_length, size_t *to_length)

int PQsendQueryPrepared(PGconn *conn, const char *stmtName, int nParams, const char *const *paramValues, const int *paramLengths, const int *paramFormats, int resultFormat)

char * PQescapeIdentifier(PGconn *conn, const char *str, size_t len)

int PQsendFlushRequest(PGconn *conn)

int PQrequestCancel(PGconn *conn)

void PQfreeCancel(PGcancel *cancel)

char * PQuser(const PGconn *conn)

int PQcancelSocket(const PGcancelConn *cancelConn)

PGpipelineStatus PQpipelineStatus(const PGconn *conn)

int lo_unlink(PGconn *conn, Oid lobjId)

int PQisnonblocking(const PGconn *conn)

void PQuntrace(PGconn *conn)

PGVerbosity PQsetErrorVerbosity(PGconn *conn, PGVerbosity verbosity)

PQnoticeProcessor PQsetNoticeProcessor(PGconn *conn, PQnoticeProcessor proc, void *arg)

char * PQcancelErrorMessage(const PGcancelConn *cancelConn)

Oid lo_import(PGconn *conn, const char *filename)

Oid PQoidValue(const PGresult *res)

int PQmblenBounded(const char *s, int encoding)

int lo_export(PGconn *conn, Oid lobjId, const char *filename)

const char *const * PQsslAttributeNames(PGconn *conn)

int PQcancelStart(PGcancelConn *cancelConn)

int PQnfields(const PGresult *res)

char * PQerrorMessage(const PGconn *conn)

Oid lo_import_with_oid(PGconn *conn, const char *filename, Oid lobjId)

void PQsetSSLKeyPassHook_OpenSSL(PQsslKeyPassHook_OpenSSL_type hook)

PGPing PQpingParams(const char *const *keywords, const char *const *values, int expand_dbname)

int PQsocket(const PGconn *conn)

int PQfsize(const PGresult *res, int field_num)

PGnotify * PQnotifies(PGconn *conn)

int PQsetClientEncoding(PGconn *conn, const char *encoding)

PGconn * PQconnectdbParams(const char *const *keywords, const char *const *values, int expand_dbname)

struct pgresAttDesc PGresAttDesc

pgthreadlock_t PQregisterThreadLock(pgthreadlock_t newhandler)

int PQgetCopyData(PGconn *conn, char **buffer, int async)

static PgChecksumMode mode

static void do_init(void)

static const char * pghost

static const char * pgport

static const char * dbName

static int fd(const char *x, int i)

void(* cleanup)(PGconn *conn, struct PGoauthBearerRequest *request)

const char * openid_configuration

PostgresPollingStatusType(* async)(PGconn *conn, struct PGoauthBearerRequest *request, SOCKTYPE *altsock)

const char * verification_uri_complete

const char * verification_uri