当前位置: 首页>>代码示例>>C++>>正文


C++ PQparameterStatus函数代码示例

本文整理汇总了C++中PQparameterStatus函数的典型用法代码示例。如果您正苦于以下问题:C++ PQparameterStatus函数的具体用法?C++ PQparameterStatus怎么用?C++ PQparameterStatus使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了PQparameterStatus函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _check_database_version

static void
_check_database_version(ArchiveHandle *AH)
{
	const char *remoteversion_str;
	int			remoteversion;

	remoteversion_str = PQparameterStatus(AH->connection, "server_version");
	remoteversion = PQserverVersion(AH->connection);
	if (remoteversion == 0 || !remoteversion_str)
		exit_horribly(modulename, "could not get server_version from libpq\n");

	AH->public__.remoteVersionStr = pg_strdup(remoteversion_str);
	AH->public__.remoteVersion = remoteversion;
	if (!AH->archiveRemoteVersion)
		AH->archiveRemoteVersion = AH->public__.remoteVersionStr;

	if (remoteversion != PG_VERSION_NUM
		&& (remoteversion < AH->public__.minRemoteVersion ||
			remoteversion > AH->public__.maxRemoteVersion))
	{
		write_msg(NULL, "server version: %s; %s version: %s\n",
				  remoteversion_str, progname, PG_VERSION);
		exit_horribly(NULL, "aborting because of server version mismatch\n");
	}
}
开发者ID:jarulraj,项目名称:postgres-cpp,代码行数:25,代码来源:pg_backup_db.c

示例2: conn_get_standard_conforming_strings

int
conn_get_standard_conforming_strings(PGconn *pgconn)
{
    int equote;
    const char *scs;
    /*
     * The presence of the 'standard_conforming_strings' parameter
     * means that the server _accepts_ the E'' quote.
     *
     * If the parameter is off, the PQescapeByteaConn returns
     * backslash escaped strings (e.g. '\001' -> "\\001"),
     * so the E'' quotes are required to avoid warnings
     * if 'escape_string_warning' is set.
     *
     * If the parameter is on, the PQescapeByteaConn returns
     * not escaped strings (e.g. '\001' -> "\001"), relying on the
     * fact that the '\' will pass untouched the string parser.
     * In this case the E'' quotes are NOT to be used.
     */
    scs = PQparameterStatus(pgconn, "standard_conforming_strings");
    Dprintf("conn_connect: server standard_conforming_strings parameter: %s",
        scs ? scs : "unavailable");

    equote = (scs && (0 == strcmp("off", scs)));
    Dprintf("conn_connect: server requires E'' quotes: %s",
            equote ? "YES" : "NO");

    return equote;
}
开发者ID:psycopg,项目名称:psycopg2,代码行数:29,代码来源:connection_int.c

示例3: pqt_getfmtinfo

void
pqt_getfmtinfo(const PGconn *conn, PGtypeFormatInfo *info)
{
	const char *value;

	memset(info, 0, sizeof(PGtypeFormatInfo));

	if ((value = PQparameterStatus(conn, "DateStyle")))
		pqt_strcpy(info->datestyle, sizeof(info->datestyle), value);

	if ((value = PQparameterStatus(conn, "integer_datetimes")))
		info->integer_datetimes = strcmp(value, "on")==0 ? TRUE : FALSE;

	info->sversion = PQserverVersion(conn);
	info->pversion = PQprotocolVersion(conn);
}
开发者ID:KingDuckZ,项目名称:dindexer,代码行数:16,代码来源:handler.c

示例4: session_username

/*
 * Return the session user of the current connection.
 *
 * Note: this will correctly detect the session user only with a
 * protocol-3.0 or newer backend; otherwise it will return the
 * connection user.
 */
const char *
session_username(void)
{
	const char *val;

	if (!pset.db)
		return NULL;

	val = PQparameterStatus(pset.db, "session_authorization");
	if (val)
		return val;
	else
		return PQuser(pset.db);
}
开发者ID:GisKook,项目名称:Gis,代码行数:21,代码来源:common.c

示例5: is_superuser

/*
 * Test if the current user is a database superuser.
 *
 * Note: this will correctly detect superuserness only with a protocol-3.0
 * or newer backend; otherwise it will always say "false".
 */
bool
is_superuser(void)
{
	const char *val;

	if (!pset.db)
		return false;

	val = PQparameterStatus(pset.db, "is_superuser");

	if (val && strcmp(val, "on") == 0)
		return true;

	return false;
}
开发者ID:GisKook,项目名称:Gis,代码行数:21,代码来源:common.c

示例6: standard_strings

/*
 * Test if the current session uses standard string literals.
 *
 * Note: With a pre-protocol-3.0 connection this will always say "false",
 * which should be the right answer.
 */
bool
standard_strings(void)
{
	const char *val;

	if (!pset.db)
		return false;

	val = PQparameterStatus(pset.db, "standard_conforming_strings");

	if (val && strcmp(val, "on") == 0)
		return true;

	return false;
}
开发者ID:GisKook,项目名称:Gis,代码行数:21,代码来源:common.c

示例7: conn_is_datestyle_ok

/* Return 1 if the server datestyle allows us to work without problems,
   0 if it needs to be set to something better, e.g. ISO. */
static int
conn_is_datestyle_ok(PGconn *pgconn)
{
    const char *ds;

    ds = PQparameterStatus(pgconn, "DateStyle");
    Dprintf("conn_connect: DateStyle %s", ds);

    /* pgbouncer does not pass on DateStyle */
    if (ds == NULL)
      return 0;

    /* Return true if ds starts with "ISO"
     * e.g. "ISO, DMY" is fine, "German" not. */
    return (ds[0] == 'I' && ds[1] == 'S' && ds[2] == 'O');
}
开发者ID:psycopg,项目名称:psycopg2,代码行数:18,代码来源:connection_int.c

示例8: psyco_conn_get_parameter_status

static PyObject *
psyco_conn_get_parameter_status(connectionObject *self, PyObject *args)
{
    const char *param = NULL;
    const char *val = NULL;

    EXC_IF_CONN_CLOSED(self);

    if (!PyArg_ParseTuple(args, "s", &param)) return NULL;

    val = PQparameterStatus(self->pgconn, param);
    if (!val) {
        Py_RETURN_NONE;
    }
    return conn_text_from_chars(self, val);
}
开发者ID:gencer,项目名称:psycopg2,代码行数:16,代码来源:connection_type.c

示例9: psyco_conn_get_parameter_status

static PyObject *
psyco_conn_get_parameter_status(connectionObject *self, PyObject *args)
{
    const char *param = NULL;
    const char *val = NULL;

    EXC_IF_CONN_CLOSED(self);

    if (!PyArg_ParseTuple(args, "s", &param)) return NULL;

    val = PQparameterStatus(self->pgconn, param);
    if (!val) {
        Py_INCREF(Py_None);
        return Py_None;
    }
    return PyString_FromString(val);
}
开发者ID:amrik,项目名称:pyvertica,代码行数:17,代码来源:connection_type.c

示例10: connection_warnings

void
connection_warnings(bool in_startup)
{
	if (!pset.quiet && !pset.notty)
	{
		int			client_ver = parse_version(PG_VERSION);

		if (pset.sversion != client_ver)
		{
			const char *server_version;
			char		server_ver_str[16];

			/* Try to get full text form, might include "devel" etc */
			server_version = PQparameterStatus(pset.db, "server_version");
			if (!server_version)
			{
				snprintf(server_ver_str, sizeof(server_ver_str),
						 "%d.%d.%d",
						 pset.sversion / 10000,
						 (pset.sversion / 100) % 100,
						 pset.sversion % 100);
				server_version = server_ver_str;
			}

			printf(_("%s (%s, server %s)\n"),
				   pset.progname, PG_VERSION, server_version);
		}
		/* For version match, only print psql banner on startup. */
		else if (in_startup)
			printf("%s (%s)\n", pset.progname, PG_VERSION);

		if (pset.sversion / 100 != client_ver / 100)
			printf(_("WARNING: %s version %d.%d, server version %d.%d.\n"
					 "         Some psql features might not work.\n"),
				 pset.progname, client_ver / 10000, (client_ver / 100) % 100,
				   pset.sversion / 10000, (pset.sversion / 100) % 100);

#ifdef WIN32
		checkWin32Codepage();
#endif
		printSSLInfo();
	}
}
开发者ID:50wu,项目名称:gpdb,代码行数:43,代码来源:command.c

示例11: pgsql_session_open

gboolean
pgsql_session_open (GSQLEPGSQLSession *spec_session, 
		    gchar *username,
		    gchar *password,
		    gchar *database,
		    gchar *hostname,
		    gchar *port)
{
	GSQL_TRACE_FUNC;
	
	gchar *conninfo = g_strdup_printf ("host = '%s' port='%s' "\
					   "dbname = '%s' " \
					   "user = '%s' password = '%s' " \
					   "connect_timeout = '10'",
					   hostname, port, database, username,
					   password);
  

	spec_session->pgconn = PQconnectdb ( conninfo );
  
	if (! spec_session->pgconn || 
	    PQstatus(spec_session->pgconn) != CONNECTION_OK) 
	  {
		GSQL_DEBUG ("Connection failed");
		g_free ( conninfo );
		return FALSE;
	  }

	spec_session->hash_conns = g_hash_table_new (g_str_hash, g_str_equal);
	g_hash_table_insert(spec_session->hash_conns, g_strdup(database),
			    spec_session->pgconn);

	spec_session->server_version = 
	  (gchar *) PQparameterStatus (spec_session->pgconn, "server_version");
	spec_session->use = TRUE;
	g_free ( conninfo );

	if ( ! PQexec(spec_session->pgconn, "BEGIN;") ) {
		GSQL_DEBUG ("Trans: Transaction Not Started!!!");
	}

	return TRUE;
}
开发者ID:antono,项目名称:gsql,代码行数:43,代码来源:pgsql.c

示例12: conn_read_encoding

/* Read the client encoding from the connection.
 *
 * Store the encoding in the pgconn->encoding field and the name of the
 * matching python codec in codec. The buffers are allocated on the Python
 * heap.
 *
 * Return 0 on success, else nonzero.
 */
RAISES_NEG static int
conn_read_encoding(connectionObject *self, PGconn *pgconn)
{
    char *enc = NULL, *codec = NULL;
    const char *tmp;
    int rv = -1;

    tmp = PQparameterStatus(pgconn, "client_encoding");
    Dprintf("conn_connect: client encoding: %s", tmp ? tmp : "(none)");
    if (!tmp) {
        PyErr_SetString(OperationalError,
            "server didn't return client encoding");
        goto exit;
    }

    if (0 > clear_encoding_name(tmp, &enc)) {
        goto exit;
    }

    /* Look for this encoding in Python codecs. */
    if (0 > conn_encoding_to_codec(enc, &codec)) {
        goto exit;
    }

    /* Good, success: store the encoding/codec in the connection. */
    PyMem_Free(self->encoding);
    self->encoding = enc;
    enc = NULL;

    PyMem_Free(self->codec);
    self->codec = codec;
    codec = NULL;

    rv = 0;

exit:
    PyMem_Free(enc);
    PyMem_Free(codec);
    return rv;
}
开发者ID:YellowDinar,项目名称:HashTags,代码行数:48,代码来源:connection_int.c

示例13: conn_read_encoding

/* Read the client encoding from the backend and store it in the connection.
 *
 * Return 0 on success, else -1.
 */
RAISES_NEG static int
conn_read_encoding(connectionObject *self, PGconn *pgconn)
{
    const char *encoding;
    int rv = -1;

    encoding = PQparameterStatus(pgconn, "client_encoding");
    Dprintf("conn_connect: client encoding: %s", encoding ? encoding : "(none)");
    if (!encoding) {
        PyErr_SetString(OperationalError,
            "server didn't return client encoding");
        goto exit;
    }

    if (0 > conn_store_encoding(self, encoding)) {
        goto exit;
    }

    rv = 0;

exit:
    return rv;
}
开发者ID:psycopg,项目名称:psycopg2,代码行数:27,代码来源:connection_int.c

示例14: StreamLog

/*
 * Start the log streaming
 */
static void
StreamLog(void)
{
	PGresult   *res;
	uint32		timeline;
	XLogRecPtr	startpos;
	int			minServerMajor,
				maxServerMajor;
	int			serverMajor;

	/*
	 * Connect in replication mode to the server
	 */
	conn = GetConnection();
	if (!conn)
		/* Error message already written in GetConnection() */
		return;

	/*
	 * Check server version. IDENTIFY_SYSTEM didn't return the current xlog
	 * position before 9.1, so we can't work with servers older than 9.1. And
	 * we don't support servers newer than the client.
	 */
	minServerMajor = 901;
	maxServerMajor = PG_VERSION_NUM / 100;
	serverMajor = PQserverVersion(conn) / 100;
	if (serverMajor < minServerMajor || serverMajor > maxServerMajor)
	{
		fprintf(stderr, _("%s: unsupported server version %s\n"),
				progname, PQparameterStatus(conn, "server_version"));
		disconnect_and_exit(1);
	}

	/*
	 * Run IDENTIFY_SYSTEM so we can get the timeline and current xlog
	 * position.
	 */
	res = PQexec(conn, "IDENTIFY_SYSTEM");
	if (PQresultStatus(res) != PGRES_TUPLES_OK)
	{
		fprintf(stderr, _("%s: could not send replication command \"%s\": %s"),
				progname, "IDENTIFY_SYSTEM", PQerrorMessage(conn));

		disconnect_and_exit(1);
	}
	if (PQntuples(res) != 1 || PQnfields(res) != 3)
	{
		fprintf(stderr,
				_("%s: could not identify system: got %d rows and %d fields, expected %d rows and %d fields\n"),
				progname, PQntuples(res), PQnfields(res), 1, 3);

		disconnect_and_exit(1);
	}
	timeline = atoi(PQgetvalue(res, 0, 1));
	if (sscanf(PQgetvalue(res, 0, 2), "%X/%X", &startpos.xlogid, &startpos.xrecoff) != 2)
	{
		fprintf(stderr,
				_("%s: could not parse transaction log location \"%s\"\n"),
				progname, PQgetvalue(res, 0, 2));
		disconnect_and_exit(1);
	}
	PQclear(res);

	/*
	 * Figure out where to start streaming.
	 */
	startpos = FindStreamingStart(startpos, timeline);

	/*
	 * Always start streaming at the beginning of a segment
	 */
	startpos.xrecoff -= startpos.xrecoff % XLOG_SEG_SIZE;

	/*
	 * Start the replication
	 */
	if (verbose)
		fprintf(stderr,
				_("%s: starting log streaming at %X/%X (timeline %u)\n"),
				progname, startpos.xlogid, startpos.xrecoff, timeline);

	ReceiveXlogStream(conn, startpos, timeline, NULL, basedir,
					  stop_streaming, standby_message_timeout, false);

	PQfinish(conn);
}
开发者ID:mikanradojevic,项目名称:sdkpub,代码行数:89,代码来源:pg_receivexlog.c

示例15: BaseBackup

static void
BaseBackup(void)
{
	PGresult   *res;
	char	   *sysidentifier;
	uint32		latesttli;
	uint32		starttli;
	char		current_path[MAXPGPATH];
	char		escaped_label[MAXPGPATH];
	int			i;
	char		xlogstart[64];
	char		xlogend[64];
	int			minServerMajor,
				maxServerMajor;
	int			serverMajor;

	/*
	 * Connect in replication mode to the server
	 */
	conn = GetConnection();
	if (!conn)
		/* Error message already written in GetConnection() */
		exit(1);

	/*
	 * Check server version. BASE_BACKUP command was introduced in 9.1, so we
	 * can't work with servers older than 9.1.
	 */
	minServerMajor = 901;
	maxServerMajor = PG_VERSION_NUM / 100;
	serverMajor = PQserverVersion(conn) / 100;
	if (serverMajor < minServerMajor || serverMajor > maxServerMajor)
	{
		const char *serverver = PQparameterStatus(conn, "server_version");

		fprintf(stderr, _("%s: incompatible server version %s\n"),
				progname, serverver ? serverver : "'unknown'");
		disconnect_and_exit(1);
	}

	/*
	 * If WAL streaming was requested, also check that the server is new
	 * enough for that.
	 */
	if (streamwal && !CheckServerVersionForStreaming(conn))
	{
		/* Error message already written in CheckServerVersionForStreaming() */
		disconnect_and_exit(1);
	}

	/*
	 * Build contents of recovery.conf if requested
	 */
	if (writerecoveryconf)
		GenerateRecoveryConf(conn);

	/*
	 * Run IDENTIFY_SYSTEM so we can get the timeline
	 */
	res = PQexec(conn, "IDENTIFY_SYSTEM");
	if (PQresultStatus(res) != PGRES_TUPLES_OK)
	{
		fprintf(stderr, _("%s: could not send replication command \"%s\": %s"),
				progname, "IDENTIFY_SYSTEM", PQerrorMessage(conn));
		disconnect_and_exit(1);
	}
	if (PQntuples(res) != 1 || PQnfields(res) != 3)
	{
		fprintf(stderr,
				_("%s: could not identify system: got %d rows and %d fields, expected %d rows and %d fields\n"),
				progname, PQntuples(res), PQnfields(res), 1, 3);
		disconnect_and_exit(1);
	}
	sysidentifier = pg_strdup(PQgetvalue(res, 0, 0));
	latesttli = atoi(PQgetvalue(res, 0, 1));
	PQclear(res);

	/*
	 * Start the actual backup
	 */
	PQescapeStringConn(conn, escaped_label, label, sizeof(escaped_label), &i);
	snprintf(current_path, sizeof(current_path),
			 "BASE_BACKUP LABEL '%s' %s %s %s %s",
			 escaped_label,
			 showprogress ? "PROGRESS" : "",
			 includewal && !streamwal ? "WAL" : "",
			 fastcheckpoint ? "FAST" : "",
			 includewal ? "NOWAIT" : "");

	if (PQsendQuery(conn, current_path) == 0)
	{
		fprintf(stderr, _("%s: could not send replication command \"%s\": %s"),
				progname, "BASE_BACKUP", PQerrorMessage(conn));
		disconnect_and_exit(1);
	}

	/*
	 * Get the starting xlog position
	 */
	res = PQgetResult(conn);
//.........这里部分代码省略.........
开发者ID:42penguins,项目名称:postgres,代码行数:101,代码来源:pg_basebackup.c


注:本文中的PQparameterStatus函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。