Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | opening a connection to the Postgres backend only while processing some query |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
5e528edfeada65659ed545bc1d9cea43 |
User & Date: | sandro 2018-08-18 13:08:32 |
Context
2020-08-02
| ||
10:34 | releasing version 2.0.0 stable check-in: b1a0c7ada7 user: sandro tags: trunk | |
2018-08-18
| ||
13:08 | opening a connection to the Postgres backend only while processing some query check-in: 5e528edfea user: sandro tags: trunk | |
2018-08-02
| ||
08:26 | adding a missing file check-in: 97be4cb834 user: sandro tags: trunk | |
Changes
Changes to configure.
1 2 3 4 5 6 7 8 9 10 ... 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 .... 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 .... 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 .... 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 .... 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 .... 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 ..... 17819 17820 17821 17822 17823 17824 17825 17826 17827 17828 17829 17830 17831 17832 17833 ..... 17885 17886 17887 17888 17889 17890 17891 17892 17893 17894 17895 17896 17897 17898 17899 |
#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for virtualpg 2.0.0-RC0. # # Report bugs to <a.furieri@lqt.it>. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # ................................................................................ subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='virtualpg' PACKAGE_TARNAME='virtualpg' PACKAGE_VERSION='2.0.0-RC0' PACKAGE_STRING='virtualpg 2.0.0-RC0' PACKAGE_BUGREPORT='a.furieri@lqt.it' PACKAGE_URL='' # Factoring default headers for most tests. ac_includes_default="\ #include <stdio.h> #ifdef HAVE_SYS_TYPES_H ................................................................................ # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures virtualpg 2.0.0-RC0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. ................................................................................ --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of virtualpg 2.0.0-RC0:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] ................................................................................ cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF virtualpg configure 2.0.0-RC0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit ................................................................................ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_type cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by virtualpg $as_me 2.0.0-RC0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { ................................................................................ CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE='virtualpg' VERSION='2.0.0-RC0' cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF ................................................................................ test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by virtualpg $as_me 2.0.0-RC0, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ ................................................................................ Report bugs to <a.furieri@lqt.it>." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ virtualpg config.status 2.0.0-RC0 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." |
| | | | | | | | | | |
1 2 3 4 5 6 7 8 9 10 ... 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 .... 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 .... 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 .... 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 .... 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 .... 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 ..... 17819 17820 17821 17822 17823 17824 17825 17826 17827 17828 17829 17830 17831 17832 17833 ..... 17885 17886 17887 17888 17889 17890 17891 17892 17893 17894 17895 17896 17897 17898 17899 |
#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for virtualpg 2.0.0-RC1. # # Report bugs to <a.furieri@lqt.it>. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # ................................................................................ subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='virtualpg' PACKAGE_TARNAME='virtualpg' PACKAGE_VERSION='2.0.0-RC1' PACKAGE_STRING='virtualpg 2.0.0-RC1' PACKAGE_BUGREPORT='a.furieri@lqt.it' PACKAGE_URL='' # Factoring default headers for most tests. ac_includes_default="\ #include <stdio.h> #ifdef HAVE_SYS_TYPES_H ................................................................................ # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures virtualpg 2.0.0-RC1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. ................................................................................ --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of virtualpg 2.0.0-RC1:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] ................................................................................ cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF virtualpg configure 2.0.0-RC1 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit ................................................................................ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_type cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by virtualpg $as_me 2.0.0-RC1, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { ................................................................................ CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE='virtualpg' VERSION='2.0.0-RC1' cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF ................................................................................ test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by virtualpg $as_me 2.0.0-RC1, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ ................................................................................ Report bugs to <a.furieri@lqt.it>." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ virtualpg config.status 2.0.0-RC1 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." |
Changes to configure.ac.
1 2 3 4 5 6 7 8 9 10 11 12 |
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61)
AC_INIT(virtualpg, 2.0.0-RC0, a.furieri@lqt.it)
AC_LANG(C)
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([foreign])
AM_MAINTAINER_MODE
AM_CONFIG_HEADER(config.h)
|
| |
1 2 3 4 5 6 7 8 9 10 11 12 |
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61)
AC_INIT(virtualpg, 2.0.0-RC1, a.furieri@lqt.it)
AC_LANG(C)
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([foreign])
AM_MAINTAINER_MODE
AM_CONFIG_HEADER(config.h)
|
Changes to virtualpg.c.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 .... 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 .... 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 .... 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 .... 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 .... 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 .... 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 .... 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 |
typedef struct VirtualPgStruct { /* extends the sqlite3_vtab struct */ const sqlite3_module *pModule; /* ptr to sqlite module: USED INTERNALLY BY SQLITE */ int nRef; /* # references: USED INTERNALLY BY SQLITE */ char *zErrMsg; /* error message: USE INTERNALLY BY SQLITE */ sqlite3 *db; /* the sqlite db holding the virtual table */ PGconn *pg_conn; /* Postgres connection handle */ char *pg_schema; /* the Postgres schema name */ char *pg_table; /* the Postgres table name */ int isView; /* is a Postgres View or not */ int nColumns; /* number of columns into the table */ char **Column; /* the name for each column */ char **Type; /* the Postgres datatype for each column */ ................................................................................ nFields = vpgPQnfields (res); if (nRows > 0 && nFields == 4) { p_vt = (VirtualPgPtr) sqlite3_malloc (sizeof (VirtualPg)); if (!p_vt) return SQLITE_NOMEM; p_vt->db = db; p_vt->isView = 0; p_vt->readOnly = readOnly; p_vt->pendingTransaction = 0; p_vt->julianNumbers = julianNumbers; p_vt->pg_conn = pg_conn; p_vt->nRef = 0; p_vt->zErrMsg = NULL; ................................................................................ } vpgMemBufferReset (&sql_statement); } else goto error; *ppVTab = (sqlite3_vtab *) p_vt; free (vtable); free (conninfo); vpgCheckView (pg_conn, pg_schema, pg_table, p_vt); free (pg_schema); free (pg_table); return SQLITE_OK; create_emergency_default: /* preparing a fake VIRTUAL TABLE */ xname = vpgDoubleQuoted (vtable); sql = sqlite3_mprintf ("CREATE TABLE %s (dummy integer)", xname); free (xname); ................................................................................ } sqlite3_free (sql); nRows = 1; p_vt = (VirtualPgPtr) sqlite3_malloc (sizeof (VirtualPg)); if (!p_vt) return SQLITE_NOMEM; p_vt->db = db; p_vt->isView = 0; p_vt->readOnly = 1; p_vt->pendingTransaction = 0; p_vt->julianNumbers = 0; p_vt->pg_conn = NULL; p_vt->nRef = 0; p_vt->zErrMsg = NULL; ................................................................................ strcpy (*(p_vt->Type + r), col_type); *(p_vt->Mapping + r) = vpgMapType (col_type); *(p_vt->MaxSize + r) = max_size; *(p_vt->NotNull + r) = not_null; } *ppVTab = (sqlite3_vtab *) p_vt; free (vtable); free (conninfo); free (pg_schema); free (pg_table); return SQLITE_OK; illegal: /* something has gone the wrong way */ if (res != NULL) vpgPQclear (res); *pzErr = sqlite3_mprintf ("[VirtualPostgres] '%s'.'%s' isn't a valid Postgres table\n", pg_schema, pg_table); error: if (vtable != NULL) free (vtable); if (conninfo != NULL) free (conninfo); if (pg_schema) ................................................................................ } static int vpg_disconnect (sqlite3_vtab * pVTab) { /* disconnects the virtual table */ VirtualPgPtr p_vt = (VirtualPgPtr) pVTab; vpgFreeTable (p_vt); return SQLITE_OK; } static int vpg_destroy (sqlite3_vtab * pVTab) { ................................................................................ /* opening a new cursor */ int c; char *xname; PGresult *res; int nRows; int nFields; int first = 1; vpgMemBuffer sql_statement; VirtualPgCursorPtr cursor = NULL; VirtualPgPtr p_vt = (VirtualPgPtr) pVTab; /* preparing the PostgreSQL query */ vpgMemBufferInitialize (&sql_statement); vpgMemBufferAppend (&sql_statement, "SELECT"); for (c = 0; c < p_vt->nColumns; c++) { xname = vpgDoubleQuoted (*(p_vt->Column + c)); ................................................................................ static int vpg_close (sqlite3_vtab_cursor * pCursor) { /* closing the cursor */ int c; VirtualPgCursorPtr cursor = (VirtualPgCursorPtr) pCursor; for (c = 0; c < cursor->nColumns; c++) vpgFreeValue (*(cursor->Values + c)); sqlite3_free (cursor->Values); vpgPQclear (cursor->resultSet); sqlite3_free (pCursor); return SQLITE_OK; } |
> > < > > > < > > > > > > > > > > > > > > > > > > > > |
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 .... 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 .... 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 .... 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 .... 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 .... 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 .... 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 .... 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 |
typedef struct VirtualPgStruct { /* extends the sqlite3_vtab struct */ const sqlite3_module *pModule; /* ptr to sqlite module: USED INTERNALLY BY SQLITE */ int nRef; /* # references: USED INTERNALLY BY SQLITE */ char *zErrMsg; /* error message: USE INTERNALLY BY SQLITE */ sqlite3 *db; /* the sqlite db holding the virtual table */ char *ConnInfo; /* PQ ConnInfo string */ PGconn *pg_conn; /* Postgres connection handle */ char *pg_schema; /* the Postgres schema name */ char *pg_table; /* the Postgres table name */ int isView; /* is a Postgres View or not */ int nColumns; /* number of columns into the table */ char **Column; /* the name for each column */ char **Type; /* the Postgres datatype for each column */ ................................................................................ nFields = vpgPQnfields (res); if (nRows > 0 && nFields == 4) { p_vt = (VirtualPgPtr) sqlite3_malloc (sizeof (VirtualPg)); if (!p_vt) return SQLITE_NOMEM; p_vt->db = db; p_vt->ConnInfo = conninfo; p_vt->isView = 0; p_vt->readOnly = readOnly; p_vt->pendingTransaction = 0; p_vt->julianNumbers = julianNumbers; p_vt->pg_conn = pg_conn; p_vt->nRef = 0; p_vt->zErrMsg = NULL; ................................................................................ } vpgMemBufferReset (&sql_statement); } else goto error; *ppVTab = (sqlite3_vtab *) p_vt; free (vtable); vpgCheckView (pg_conn, pg_schema, pg_table, p_vt); free (pg_schema); free (pg_table); vpgPQfinish (pg_conn); p_vt->pg_conn = NULL; return SQLITE_OK; create_emergency_default: /* preparing a fake VIRTUAL TABLE */ xname = vpgDoubleQuoted (vtable); sql = sqlite3_mprintf ("CREATE TABLE %s (dummy integer)", xname); free (xname); ................................................................................ } sqlite3_free (sql); nRows = 1; p_vt = (VirtualPgPtr) sqlite3_malloc (sizeof (VirtualPg)); if (!p_vt) return SQLITE_NOMEM; p_vt->db = db; p_vt->ConnInfo = conninfo; p_vt->isView = 0; p_vt->readOnly = 1; p_vt->pendingTransaction = 0; p_vt->julianNumbers = 0; p_vt->pg_conn = NULL; p_vt->nRef = 0; p_vt->zErrMsg = NULL; ................................................................................ strcpy (*(p_vt->Type + r), col_type); *(p_vt->Mapping + r) = vpgMapType (col_type); *(p_vt->MaxSize + r) = max_size; *(p_vt->NotNull + r) = not_null; } *ppVTab = (sqlite3_vtab *) p_vt; free (vtable); free (pg_schema); free (pg_table); return SQLITE_OK; illegal: /* something has gone the wrong way */ if (res != NULL) vpgPQclear (res); *pzErr = sqlite3_mprintf ("[VirtualPostgres] '%s'.'%s' isn't a valid Postgres table\n", pg_schema, pg_table); vpgPQfinish (pg_conn); p_vt->pg_conn = NULL; p_vt->ConnInfo = conninfo; conninfo = NULL; error: if (vtable != NULL) free (vtable); if (conninfo != NULL) free (conninfo); if (pg_schema) ................................................................................ } static int vpg_disconnect (sqlite3_vtab * pVTab) { /* disconnects the virtual table */ VirtualPgPtr p_vt = (VirtualPgPtr) pVTab; if (p_vt->ConnInfo != NULL) free (p_vt->ConnInfo); vpgFreeTable (p_vt); return SQLITE_OK; } static int vpg_destroy (sqlite3_vtab * pVTab) { ................................................................................ /* opening a new cursor */ int c; char *xname; PGresult *res; int nRows; int nFields; int first = 1; char *emsg; vpgMemBuffer sql_statement; VirtualPgCursorPtr cursor = NULL; VirtualPgPtr p_vt = (VirtualPgPtr) pVTab; p_vt->pg_conn = vpgPQconnectdb (p_vt->ConnInfo); if (vpgPQstatus (p_vt->pg_conn) != CONNECTION_OK) { emsg = sqlite3_mprintf ("Connection to Postgres failed:\n%s", vpgPQerrorMessage (p_vt->pg_conn)); vpgReportError (p_vt->db, emsg); sqlite3_free (emsg); vpgPQfinish (p_vt->pg_conn); p_vt->pg_conn = NULL; } /* preparing the PostgreSQL query */ vpgMemBufferInitialize (&sql_statement); vpgMemBufferAppend (&sql_statement, "SELECT"); for (c = 0; c < p_vt->nColumns; c++) { xname = vpgDoubleQuoted (*(p_vt->Column + c)); ................................................................................ static int vpg_close (sqlite3_vtab_cursor * pCursor) { /* closing the cursor */ int c; VirtualPgCursorPtr cursor = (VirtualPgCursorPtr) pCursor; vpgPQfinish (cursor->pVtab->pg_conn); cursor->pVtab->pg_conn = NULL; for (c = 0; c < cursor->nColumns; c++) vpgFreeValue (*(cursor->Values + c)); sqlite3_free (cursor->Values); vpgPQclear (cursor->resultSet); sqlite3_free (pCursor); return SQLITE_OK; } |