SQL Relay C++ API
sqlrclient.h
1 // Copyright (c) 1999-2001 David Muse
2 // See the file COPYING for more information.
3 
4 #ifndef SQLRCLIENT_H
5 #define SQLRCLIENT_H
6 
7 #include <sqlrelay/private/sqlrincludes.h>
8 
9 class SQLRCLIENT_DLLSPEC sqlrconnection {
10  public:
26  sqlrconnection(const char *server, uint16_t port,
27  const char *socket,
28  const char *user, const char *password,
29  int32_t retrytime, int32_t tries);
30 
31 
34  ~sqlrconnection();
35 
36 
37 
42  void setConnectTimeout(int32_t timeoutsec,
43  int32_t timeoutusec);
44 
49  void setAuthenticationTimeout(int32_t timeoutsec,
50  int32_t timeoutusec);
51 
57  void setResponseTimeout(int32_t timeoutsec,
58  int32_t timeoutusec);
59 
61  void endSession();
62 
67  bool suspendSession();
68 
75  uint16_t getConnectionPort();
76 
83  const char *getConnectionSocket();
84 
88  bool resumeSession(uint16_t port, const char *socket);
89 
90 
91 
94  bool ping();
95 
98  const char *identify();
99 
101  const char *dbVersion();
102 
104  const char *dbHostName();
105 
107  const char *dbIpAddress();
108 
110  const char *serverVersion();
111 
113  const char *clientVersion();
114 
117  const char *bindFormat();
118 
119 
120 
122  bool selectDatabase(const char *database);
123 
125  const char *getCurrentDatabase();
126 
127 
128 
131  uint64_t getLastInsertId();
132 
133 
134 
137  bool autoCommitOn();
138 
141  bool autoCommitOff();
142 
143 
150  bool begin();
151 
154  bool commit();
155 
158  bool rollback();
159 
160 
161 
166  const char *errorMessage();
167 
172  int64_t errorNumber();
173 
174 
175 
181  void debugOn();
182 
184  void debugOff();
185 
188  bool getDebug();
189 
190 
191 
196  void debugPrintFunction(int (*printfunction)
197  (const char *,...));
198 
202  void setDebugFile(const char *filename);
203 
204 
209  void setClientInfo(const char *clientinfo);
210 
212  const char *getClientInfo() const;
213 
214  #include <sqlrelay/private/sqlrconnection.h>
215 };
216 
217 
218 class SQLRCLIENT_DLLSPEC sqlrcursor {
219  public:
222  sqlrcursor(sqlrconnection *sqlrc);
223 
226  ~sqlrcursor();
227 
228 
229 
233  void setResultSetBufferSize(uint64_t rows);
234 
238  uint64_t getResultSetBufferSize();
239 
240 
241 
246  void dontGetColumnInfo();
247 
249  void getColumnInfo();
250 
251 
255  void mixedCaseColumnNames();
256 
258  void upperCaseColumnNames();
259 
261  void lowerCaseColumnNames();
262 
263 
264 
277  void cacheToFile(const char *filename);
278 
284  void setCacheTtl(uint32_t ttl);
285 
288  const char *getCacheFileName();
289 
291  void cacheOff();
292 
293 
294 
299  bool getDatabaseList(const char *wild);
300 
304  bool getTableList(const char *wild);
305 
310  bool getColumnList(const char *table, const char *wild);
311 
312 
313 
315  bool sendQuery(const char *query);
316 
320  bool sendQuery(const char *query, uint32_t length);
321 
324  bool sendFileQuery(const char *path, const char *filename);
325 
326 
327 
329  void prepareQuery(const char *query);
330 
334  void prepareQuery(const char *query, uint32_t length);
335 
339  bool prepareFileQuery(const char *path,
340  const char *filename);
341 
342 
343 
345  void substitution(const char *variable, const char *value);
346 
348  void substitution(const char *variable, int64_t value);
349 
351  void substitution(const char *variable, double value,
352  uint32_t precision,
353  uint32_t scale);
354 
356  void substitutions(const char **variables,
357  const char **values);
358 
360  void substitutions(const char **variables,
361  const int64_t *values);
362 
364  void substitutions(const char **variables,
365  const double *values,
366  const uint32_t *precisions,
367  const uint32_t *scales);
368 
369 
370 
372  void inputBind(const char *variable, const char *value);
373 
375  void inputBind(const char *variable, const char *value,
376  uint32_t valuelength);
377 
379  void inputBind(const char *variable, int64_t value);
380 
386  void inputBind(const char *variable, double value,
387  uint32_t precision,
388  uint32_t scale);
389 
393  void inputBind(const char *variable,
394  int16_t year, int16_t month, int16_t day,
395  int16_t hour, int16_t minute, int16_t second,
396  int32_t microsecond, const char *tz);
397 
399  void inputBindBlob(const char *variable,
400  const char *value,
401  uint32_t size);
402 
404  void inputBindClob(const char *variable,
405  const char *value,
406  uint32_t size);
407 
409  void inputBinds(const char **variables, const char **values);
410 
412  void inputBinds(const char **variables,
413  const int64_t *values);
414 
416  void inputBinds(const char **variables,
417  const double *values,
418  const uint32_t *precisions,
419  const uint32_t *scales);
420 
421 
422 
426  void defineOutputBindString(const char *variable,
427  uint32_t bufferlength);
428 
430  void defineOutputBindInteger(const char *variable);
431 
433  void defineOutputBindDouble(const char *variable);
434 
436  void defineOutputBindDate(const char *variable);
437 
439  void defineOutputBindBlob(const char *variable);
440 
442  void defineOutputBindClob(const char *variable);
443 
445  void defineOutputBindCursor(const char *variable);
446 
447 
448 
450  void clearBinds();
451 
455  uint16_t countBindVariables() const;
456 
463  void validateBinds();
464 
467  bool validBind(const char *variable);
468 
469 
470 
473  bool executeQuery();
474 
477  bool fetchFromBindCursor();
478 
479 
480 
483  const char *getOutputBindString(const char *variable);
484 
487  int64_t getOutputBindInteger(const char *variable);
488 
491  double getOutputBindDouble(const char *variable);
492 
495  bool getOutputBindDate(const char *variable,
496  int16_t *year,
497  int16_t *month,
498  int16_t *day,
499  int16_t *hour,
500  int16_t *minute,
501  int16_t *second,
502  int32_t *microsecond,
503  const char **tz);
504 
507  const char *getOutputBindBlob(const char *variable);
508 
511  const char *getOutputBindClob(const char *variable);
512 
515  uint32_t getOutputBindLength(const char *variable);
516 
519  sqlrcursor *getOutputBindCursor(const char *variable);
520 
521 
522 
525  bool openCachedResultSet(const char *filename);
526 
527 
528 
531  uint32_t colCount();
532 
537  uint64_t rowCount();
538 
545  uint64_t totalRows();
546 
554  uint64_t affectedRows();
555 
559  uint64_t firstRowIndex();
560 
566  bool endOfResultSet();
567 
568 
569 
574  const char *errorMessage();
575 
580  int64_t errorNumber();
581 
582 
583 
587  void getNullsAsEmptyStrings();
588 
592  void getNullsAsNulls();
593 
594 
595 
597  const char *getField(uint64_t row, uint32_t col);
598 
600  const char *getField(uint64_t row, const char *col);
601 
603  int64_t getFieldAsInteger(uint64_t row, uint32_t col);
604 
606  int64_t getFieldAsInteger(uint64_t row, const char *col);
607 
609  double getFieldAsDouble(uint64_t row, uint32_t col);
610 
612  double getFieldAsDouble(uint64_t row, const char *col);
613 
614 
615 
617  uint32_t getFieldLength(uint64_t row, uint32_t col);
618 
620  uint32_t getFieldLength(uint64_t row, const char *col);
621 
622 
623 
626  const char * const *getRow(uint64_t row);
627 
630  uint32_t *getRowLengths(uint64_t row);
631 
634  const char * const *getColumnNames();
635 
637  const char *getColumnName(uint32_t col);
638 
640  const char *getColumnType(uint32_t col);
641 
643  const char *getColumnType(const char *col);
644 
647  uint32_t getColumnLength(uint32_t col);
648 
651  uint32_t getColumnLength(const char *col);
652 
659  uint32_t getColumnPrecision(uint32_t col);
660 
667  uint32_t getColumnPrecision(const char *col);
668 
673  uint32_t getColumnScale(uint32_t col);
674 
679  uint32_t getColumnScale(const char *col);
680 
683  bool getColumnIsNullable(uint32_t col);
684 
687  bool getColumnIsNullable(const char *col);
688 
691  bool getColumnIsPrimaryKey(uint32_t col);
692 
695  bool getColumnIsPrimaryKey(const char *col);
696 
699  bool getColumnIsUnique(uint32_t col);
700 
703  bool getColumnIsUnique(const char *col);
704 
707  bool getColumnIsPartOfKey(uint32_t col);
708 
711  bool getColumnIsPartOfKey(const char *col);
712 
715  bool getColumnIsUnsigned(uint32_t col);
716 
719  bool getColumnIsUnsigned(const char *col);
720 
724  bool getColumnIsZeroFilled(uint32_t col);
725 
729  bool getColumnIsZeroFilled(const char *col);
730 
734  bool getColumnIsBinary(uint32_t col);
735 
739  bool getColumnIsBinary(const char *col);
740 
743  bool getColumnIsAutoIncrement(uint32_t col);
744 
747  bool getColumnIsAutoIncrement(const char *col);
748 
751  uint32_t getLongest(uint32_t col);
752 
755  uint32_t getLongest(const char *col);
756 
757 
758 
764  void suspendResultSet();
765 
772  uint16_t getResultSetId();
773 
777  bool resumeResultSet(uint16_t id);
778 
783  bool resumeCachedResultSet(uint16_t id,
784  const char *filename);
785 
790  void closeResultSet();
791 
792  #include <sqlrelay/private/sqlrcursor.h>
793 };
794 
795 #endif
Definition: sqlrclient.h:9
Definition: sqlrclient.h:218