本文整理汇总了C++中PQserverVersion函数的典型用法代码示例。如果您正苦于以下问题:C++ PQserverVersion函数的具体用法?C++ PQserverVersion怎么用?C++ PQserverVersion使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PQserverVersion函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: c_psql_check_connection
static int c_psql_check_connection (c_psql_database_t *db)
{
_Bool init = 0;
if (! db->conn) {
init = 1;
/* trigger c_release() */
if (0 == db->conn_complaint.interval)
db->conn_complaint.interval = 1;
c_psql_connect (db);
}
/* "ping" */
PQclear (PQexec (db->conn, "SELECT 42;"));
if (CONNECTION_OK != PQstatus (db->conn)) {
PQreset (db->conn);
/* trigger c_release() */
if (0 == db->conn_complaint.interval)
db->conn_complaint.interval = 1;
if (CONNECTION_OK != PQstatus (db->conn)) {
c_complain (LOG_ERR, &db->conn_complaint,
"Failed to connect to database %s (%s): %s",
db->database, db->instance,
PQerrorMessage (db->conn));
return -1;
}
db->proto_version = PQprotocolVersion (db->conn);
}
db->server_version = PQserverVersion (db->conn);
if (c_would_release (&db->conn_complaint)) {
char *server_host;
int server_version;
server_host = PQhost (db->conn);
server_version = PQserverVersion (db->conn);
c_do_release (LOG_INFO, &db->conn_complaint,
"Successfully %sconnected to database %s (user %s) "
"at server %s%s%s (server version: %d.%d.%d, "
"protocol version: %d, pid: %d)", init ? "" : "re",
PQdb (db->conn), PQuser (db->conn),
C_PSQL_SOCKET3 (server_host, PQport (db->conn)),
C_PSQL_SERVER_VERSION3 (server_version),
db->proto_version, PQbackendPID (db->conn));
if (3 > db->proto_version)
log_warn ("Protocol version %d does not support parameters.",
db->proto_version);
}
return 0;
} /* c_psql_check_connection */
开发者ID:clopez,项目名称:collectd,代码行数:59,代码来源:postgresql.c
示例2: getExtensions
PQLExtension *
getExtensions(PGconn *c, int *n)
{
PQLExtension *e;
PGresult *res;
int i;
logNoise("extension: server version: %d", PQserverVersion(c));
/* bail out if we do not support it */
if (PQserverVersion(c) < 90100)
{
logWarning("ignoring extensions because server does not support it");
return NULL;
}
res = PQexec(c,
"SELECT e.oid, extname AS extensionname, nspname, extversion AS version, extrelocatable, obj_description(e.oid, 'pg_extension') AS description FROM pg_extension e LEFT JOIN pg_namespace n ON (e.extnamespace = n.oid) ORDER BY extname");
if (PQresultStatus(res) != PGRES_TUPLES_OK)
{
logError("query failed: %s", PQresultErrorMessage(res));
PQclear(res);
PQfinish(c);
/* XXX leak another connection? */
exit(EXIT_FAILURE);
}
*n = PQntuples(res);
if (*n > 0)
e = (PQLExtension *) malloc(*n * sizeof(PQLExtension));
else
e = NULL;
logDebug("number of extensions in server: %d", *n);
for (i = 0; i < *n; i++)
{
e[i].oid = strtoul(PQgetvalue(res, i, PQfnumber(res, "oid")), NULL, 10);
e[i].extensionname = strdup(PQgetvalue(res, i, PQfnumber(res,
"extensionname")));
e[i].schemaname = strdup(PQgetvalue(res, i, PQfnumber(res, "nspname")));
e[i].version = strdup(PQgetvalue(res, i, PQfnumber(res, "version")));
e[i].relocatable = (PQgetvalue(res, i, PQfnumber(res,
"extrelocatable"))[0] == 't');
if (PQgetisnull(res, i, PQfnumber(res, "description")))
e[i].comment = NULL;
else
e[i].comment = strdup(PQgetvalue(res, i, PQfnumber(res, "description")));
logDebug("extension \"%s\"", e[i].extensionname);
}
PQclear(res);
return e;
}
开发者ID:eulerto,项目名称:pgquarrel,代码行数:57,代码来源:extension.c
示例3: _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
示例4: DropBlobIfExists
void
DropBlobIfExists(ArchiveHandle *AH, Oid oid)
{
/*
* If we are not restoring to a direct database connection, we have to
* guess about how to detect whether the blob exists. Assume new-style.
*/
if (AH->connection == NULL ||
PQserverVersion(AH->connection) >= 90000)
{
ahprintf(AH,
"SELECT pg_catalog.lo_unlink(oid) "
"FROM pg_catalog.pg_largeobject_metadata "
"WHERE oid = '%u';\n",
oid);
}
else
{
/* Restoring to pre-9.0 server, so do it the old way */
ahprintf(AH,
"SELECT CASE WHEN EXISTS("
"SELECT 1 FROM pg_catalog.pg_largeobject WHERE loid = '%u'"
") THEN pg_catalog.lo_unlink('%u') END;\n",
oid, oid);
}
}
开发者ID:jarulraj,项目名称:postgres-cpp,代码行数:26,代码来源:pg_backup_db.c
示例5: PQconnectdb
void Database_PostgreSQL::connectToDatabase()
{
m_conn = PQconnectdb(m_connect_string.c_str());
if (PQstatus(m_conn) != CONNECTION_OK) {
throw DatabaseException(std::string(
"PostgreSQL database error: ") +
PQerrorMessage(m_conn));
}
m_pgversion = PQserverVersion(m_conn);
/*
* We are using UPSERT feature from PostgreSQL 9.5
* to have the better performance where possible.
*/
if (m_pgversion < 90500) {
warningstream << "Your PostgreSQL server lacks UPSERT "
<< "support. Use version 9.5 or better if possible."
<< std::endl;
}
infostream << "PostgreSQL Database: Version " << m_pgversion
<< " Connection made." << std::endl;
createDatabase();
initStatements();
}
开发者ID:Gael-de-Sailly,项目名称:minetest,代码行数:28,代码来源:database-postgresql.cpp
示例6: configure_remote_session
/*
* Issue SET commands to make sure remote session is configured properly.
*
* We do this just once at connection, assuming nothing will change the
* values later. Since we'll never send volatile function calls to the
* remote, there shouldn't be any way to break this assumption from our end.
* It's possible to think of ways to break it at the remote end, eg making
* a foreign table point to a view that includes a set_config call ---
* but once you admit the possibility of a malicious view definition,
* there are any number of ways to break things.
*/
static void
configure_remote_session(PGconn *conn)
{
int remoteversion = PQserverVersion(conn);
/* Force the search path to contain only pg_catalog (see deparse.c) */
do_sql_command(conn, "SET search_path = pg_catalog");
/*
* Set remote timezone; this is basically just cosmetic, since all
* transmitted and returned timestamptzs should specify a zone explicitly
* anyway. However it makes the regression test outputs more predictable.
*
* We don't risk setting remote zone equal to ours, since the remote
* server might use a different timezone database. Instead, use UTC
* (quoted, because very old servers are picky about case).
*/
do_sql_command(conn, "SET timezone = 'UTC'");
/*
* Set values needed to ensure unambiguous data output from remote. (This
* logic should match what pg_dump does. See also set_transmission_modes
* in postgres_fdw.c.)
*/
do_sql_command(conn, "SET datestyle = ISO");
if (remoteversion >= 80400)
do_sql_command(conn, "SET intervalstyle = postgres");
if (remoteversion >= 90000)
do_sql_command(conn, "SET extra_float_digits = 3");
else
do_sql_command(conn, "SET extra_float_digits = 2");
}
开发者ID:42penguins,项目名称:postgres,代码行数:43,代码来源:connection.c
示例7: SMSDPgSQL_Connect
/* [Re]connects to database */
static GSM_Error SMSDPgSQL_Connect(GSM_SMSDConfig * Config)
{
unsigned char buf[400];
PGresult *Res;
unsigned int port = 5432;
char *pport;
pport = strstr(Config->host, ":");
if (pport) {
*pport++ = '\0';
port = atoi(pport);
}
sprintf(buf, "host = '%s' user = '%s' password = '%s' dbname = '%s' port = %d", Config->host, Config->user, Config->password, Config->database, port);
SMSDPgSQL_Free(Config);
Config->conn.pg = PQconnectdb(buf);
if (PQstatus(Config->conn.pg) != CONNECTION_OK) {
SMSD_Log(DEBUG_ERROR, Config, "Error connecting to database: %s", PQerrorMessage(Config->conn.pg));
PQfinish(Config->conn.pg);
return ERR_DB_CONNECT;
}
Res = PQexec(Config->conn.pg, "SET NAMES UTF8");
PQclear(Res);
SMSD_Log(DEBUG_INFO, Config, "Connected to database: %s on %s. Server version: %d Protocol: %d",
PQdb(Config->conn.pg), PQhost(Config->conn.pg), PQserverVersion(Config->conn.pg), PQprotocolVersion(Config->conn.pg));
return ERR_NONE;
}
开发者ID:AndyLavr,项目名称:gammu,代码行数:32,代码来源:pgsql.c
示例8: c_psql_check_connection
static int c_psql_check_connection (c_psql_database_t *db)
{
/* "ping" */
PQclear (PQexec (db->conn, "SELECT 42;"));
if (CONNECTION_OK != PQstatus (db->conn)) {
PQreset (db->conn);
/* trigger c_release() */
if (0 == db->conn_complaint.interval)
db->conn_complaint.interval = 1;
if (CONNECTION_OK != PQstatus (db->conn)) {
c_complain (LOG_ERR, &db->conn_complaint,
"Failed to connect to database %s: %s",
db->database, PQerrorMessage (db->conn));
return -1;
}
db->proto_version = PQprotocolVersion (db->conn);
if (3 > db->proto_version)
log_warn ("Protocol version %d does not support parameters.",
db->proto_version);
}
db->server_version = PQserverVersion (db->conn);
c_release (LOG_INFO, &db->conn_complaint,
"Successfully reconnected to database %s", PQdb (db->conn));
return 0;
} /* c_psql_check_connection */
开发者ID:absperf,项目名称:collectd,代码行数:31,代码来源:postgresql.c
示例9: appendStringLiteralConn
/*
* Convert a string value to an SQL string literal and append it to
* the given buffer. Encoding and string syntax rules are as indicated
* by current settings of the PGconn.
*/
void
appendStringLiteralConn(PQExpBuffer buf, const char *str, PGconn *conn)
{
size_t length = strlen(str);
/*
* XXX This is a kluge to silence escape_string_warning in our utility
* programs. It should go away someday.
*/
if (strchr(str, '\\') != NULL && PQserverVersion(conn) >= 80100)
{
/* ensure we are not adjacent to an identifier */
if (buf->len > 0 && buf->data[buf->len - 1] != ' ')
appendPQExpBufferChar(buf, ' ');
appendPQExpBufferChar(buf, ESCAPE_STRING_SYNTAX);
appendStringLiteral(buf, str, PQclientEncoding(conn), false);
return;
}
/* XXX end kluge */
if (!enlargePQExpBuffer(buf, 2 * length + 2))
return;
appendPQExpBufferChar(buf, '\'');
buf->len += PQescapeStringConn(conn, buf->data + buf->len,
str, length, NULL);
appendPQExpBufferChar(buf, '\'');
}
开发者ID:denishpatel,项目名称:postgres,代码行数:32,代码来源:dumputils.c
示例10: getSequences
PQLSequence *
getSequences(PGconn *c, int *n)
{
PQLSequence *s;
PGresult *res;
int i;
logNoise("sequence: server version: %d", PQserverVersion(c));
res = PQexec(c,
"SELECT c.oid, n.nspname, c.relname, obj_description(c.oid, 'pg_class') AS description, pg_get_userbyid(c.relowner) AS relowner, relacl FROM pg_class c INNER JOIN pg_namespace n ON (c.relnamespace = n.oid) WHERE relkind = 'S' AND nspname !~ '^pg_' AND nspname <> 'information_schema' ORDER BY nspname, relname");
if (PQresultStatus(res) != PGRES_TUPLES_OK)
{
logError("query failed: %s", PQresultErrorMessage(res));
PQclear(res);
PQfinish(c);
/* XXX leak another connection? */
exit(EXIT_FAILURE);
}
*n = PQntuples(res);
if (*n > 0)
s = (PQLSequence *) malloc(*n * sizeof(PQLSequence));
else
s = NULL;
logDebug("number of sequences in server: %d", *n);
for (i = 0; i < *n; i++)
{
s[i].obj.oid = strtoul(PQgetvalue(res, i, PQfnumber(res, "oid")), NULL, 10);
s[i].obj.schemaname = strdup(PQgetvalue(res, i, PQfnumber(res, "nspname")));
s[i].obj.objectname = strdup(PQgetvalue(res, i, PQfnumber(res, "relname")));
if (PQgetisnull(res, i, PQfnumber(res, "description")))
s[i].comment = NULL;
else
s[i].comment = strdup(PQgetvalue(res, i, PQfnumber(res, "description")));
if (PQgetisnull(res, i, PQfnumber(res, "description")))
s[i].comment = NULL;
else
s[i].comment = strdup(PQgetvalue(res, i, PQfnumber(res, "description")));
s[i].owner = strdup(PQgetvalue(res, i, PQfnumber(res, "relowner")));
if (PQgetisnull(res, i, PQfnumber(res, "relacl")))
s[i].acl = NULL;
else
s[i].acl = strdup(PQgetvalue(res, i, PQfnumber(res, "relacl")));
logDebug("sequence %s.%s", formatObjectIdentifier(s[i].obj.schemaname),
formatObjectIdentifier(s[i].obj.objectname));
}
PQclear(res);
return s;
}
开发者ID:fabriziomello,项目名称:pgquarrel,代码行数:57,代码来源:sequence.c
示例11: PQserverVersion
int toQPSqlConnectionSub::nativeVersion()
{
QVariant v = Connection.driver()->handle();
if (v.isValid() && v.typeName() == QString("PGconn*"))
{
#ifdef HAVE_POSTGRESQL_LIBPQ_FE_H
PGconn *handle = *static_cast<PGconn **>(v.data());
if (handle)
return PQserverVersion(handle);
#endif
}
return 0;
}
开发者ID:ShadowKyogre,项目名称:tora,代码行数:13,代码来源:toqpsqlconnection.cpp
示例12: InitDelayThread
bool DatabasePostgre::Initialize(const char *infoString)
{
if(!Database::Initialize(infoString))
return false;
tranThread = NULL;
InitDelayThread();
Tokens tokens = StrSplit(infoString, ";");
Tokens::iterator iter;
std::string host, port_or_socket_dir, user, password, database;
iter = tokens.begin();
if(iter != tokens.end())
host = *iter++;
if(iter != tokens.end())
port_or_socket_dir = *iter++;
if(iter != tokens.end())
user = *iter++;
if(iter != tokens.end())
password = *iter++;
if(iter != tokens.end())
database = *iter++;
if (host == ".")
mPGconn = PQsetdbLogin(NULL, port_or_socket_dir == "." ? NULL : port_or_socket_dir.c_str(), NULL, NULL, database.c_str(), user.c_str(), password.c_str());
else
mPGconn = PQsetdbLogin(host.c_str(), port_or_socket_dir.c_str(), NULL, NULL, database.c_str(), user.c_str(), password.c_str());
/* check to see that the backend connection was successfully made */
if (PQstatus(mPGconn) != CONNECTION_OK)
{
sLog.outError( "Could not connect to Postgre database at %s: %s",
host.c_str(), PQerrorMessage(mPGconn));
PQfinish(mPGconn);
mPGconn = NULL;
return false;
}
else
{
sLog.outDetail( "Connected to Postgre database at %s",
host.c_str());
sLog.outString( "PostgreSQL server ver: %d",PQserverVersion(mPGconn));
return true;
}
}
开发者ID:Scergo,项目名称:zero,代码行数:51,代码来源:DatabasePostgre.cpp
示例13: Exception
QString DBConnection::getDBMSVersion(void)
{
QString version;
if(!connection)
throw Exception(ERR_OPR_NOT_ALOC_CONN, __PRETTY_FUNCTION__, __FILE__, __LINE__);
version=QString("%1").arg(PQserverVersion(connection));
return(QString("%1.%2.%3")
.arg(version.mid(0,2).toInt()/10)
.arg(version.mid(2,2).toInt()/10)
.arg(version.mid(4,1).toInt()));
}
开发者ID:K-Lean,项目名称:pgmodeler,代码行数:14,代码来源:dbconnection.cpp
示例14: Excecao
//-----------------------------------------------------------
QString ConexaoBD::obterVersaoSGBD(void)
{
QString versao;
if(!conexao)
throw Excecao(ERR_CONEXBD_OPRCONEXNAOALOC, __PRETTY_FUNCTION__, __FILE__, __LINE__);
versao=QString("%1").arg(PQserverVersion(conexao));
return(QString("%1.%2.%3")
.arg(versao.mid(0,2).toInt()/10)
.arg(versao.mid(2,2).toInt()/10)
.arg(versao.mid(4,1).toInt()));
}
开发者ID:spanc29,项目名称:pgmodeler,代码行数:15,代码来源:conexaobd.cpp
示例15: sql_init_socket
/*************************************************************************
*
* Function: sql_create_socket
*
* Purpose: Establish connection to the db
*
*************************************************************************/
static int sql_init_socket(rlm_sql_handle_t *handle, rlm_sql_config_t *config) {
char *dbstring;
rlm_sql_postgres_conn_t *conn;
#ifdef HAVE_OPENSSL_CRYPTO_H
static bool ssl_init = false;
if (!ssl_init) {
PQinitOpenSSL(0, 0);
ssl_init = true;
}
#endif
MEM(conn = handle->conn = talloc_zero(handle, rlm_sql_postgres_conn_t));
talloc_set_destructor(conn, _sql_socket_destructor);
dbstring = strchr(config->sql_db, '=') ?
talloc_strdup(conn, config->sql_db) :
talloc_asprintf(conn, "dbname='%s'", config->sql_db);
if (config->sql_server[0] != '\0') {
dbstring = talloc_asprintf_append(dbstring, " host='%s'", config->sql_server);
}
if (config->sql_port[0] != '\0') {
dbstring = talloc_asprintf_append(dbstring, " port=%s", config->sql_port);
}
if (config->sql_login[0] != '\0') {
dbstring = talloc_asprintf_append(dbstring, " user='%s'", config->sql_login);
}
if (config->sql_password[0] != '\0') {
dbstring = talloc_asprintf_append(dbstring, " password='%s'", config->sql_password);
}
conn->dbstring = dbstring;
conn->db = PQconnectdb(dbstring);
DEBUG2("rlm_sql_postgresql: Connecting using parameters: %s", dbstring);
if (!conn->db || (PQstatus(conn->db) != CONNECTION_OK)) {
ERROR("rlm_sql_postgresql: Connection failed: %s", PQerrorMessage(conn->db));
return -1;
}
DEBUG2("Connected to database '%s' on '%s' server version %i, protocol version %i, backend PID %i ",
PQdb(conn->db), PQhost(conn->db), PQserverVersion(conn->db), PQprotocolVersion(conn->db),
PQbackendPID(conn->db));
return 0;
}
开发者ID:AlainRomeyer,项目名称:freeradius-server,代码行数:56,代码来源:rlm_sql_postgresql.c
示例16: getTriggers
PQLTrigger *
getTriggers(PGconn *c, int *n)
{
PQLTrigger *t;
PGresult *res;
int i;
logNoise("trigger: server version: %d", PQserverVersion(c));
res = PQexec(c,
"SELECT t.oid, t.tgname AS trgname, n.nspname AS nspname, c.relname AS relname, pg_get_triggerdef(t.oid, false) AS trgdef, obj_description(t.oid, 'pg_rewrite') AS description FROM pg_trigger t INNER JOIN pg_class c ON (t.tgrelid = c.oid) INNER JOIN pg_namespace n ON (c.relnamespace = n.oid) WHERE NOT tgisinternal");
if (PQresultStatus(res) != PGRES_TUPLES_OK)
{
logError("query failed: %s", PQresultErrorMessage(res));
PQclear(res);
PQfinish(c);
/* XXX leak another connection? */
exit(EXIT_FAILURE);
}
*n = PQntuples(res);
if (*n > 0)
t = (PQLTrigger *) malloc(*n * sizeof(PQLTrigger));
else
t = NULL;
logDebug("number of triggers in server: %d", *n);
for (i = 0; i < *n; i++)
{
t[i].oid = strtoul(PQgetvalue(res, i, PQfnumber(res, "oid")), NULL, 10);
t[i].trgname = strdup(PQgetvalue(res, i, PQfnumber(res, "tgname")));
t[i].table.schemaname = strdup(PQgetvalue(res, i, PQfnumber(res, "nspname")));
t[i].table.objectname = strdup(PQgetvalue(res, i, PQfnumber(res, "relname")));
t[i].trgdef = strdup(PQgetvalue(res, i, PQfnumber(res, "trgdef")));
if (PQgetisnull(res, i, PQfnumber(res, "description")))
t[i].comment = NULL;
else
t[i].comment = strdup(PQgetvalue(res, i, PQfnumber(res, "description")));
logDebug("trigger \"%s\" on \"%s\".\"%s\"", t[i].trgname, t[i].table.schemaname, t[i].table.objectname);
}
PQclear(res);
return t;
}
开发者ID:eulerto,项目名称:pgquarrel,代码行数:48,代码来源:trigger.c
示例17: 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
示例18: do_pg_serverversion
static awk_value_t *
do_pg_serverversion(int nargs, awk_value_t *result)
{
PGconn *conn;
int version;
if (do_lint && (nargs > 1))
lintwarn(ext_id, _("pg_serverversion: called with too many arguments"));
if (!(conn = find_handle(conns, 0))) {
set_ERRNO(_("pg_serverversion called with unknown connection handle"));
RET_NUM(0);
}
if (!(version = PQserverVersion(conn)))
set_ERRNO(PQerrorMessage(conn));
RET_NUM(version);
}
开发者ID:gvlx,项目名称:gawkextlib,代码行数:17,代码来源:pgsql.c
示例19: SyncVariables
/*
* SyncVariables
*
* Make psql's internal variables agree with connection state upon
* establishing a new connection.
*/
void
SyncVariables(void)
{
/* get stuff from connection */
pset.encoding = PQclientEncoding(pset.db);
pset.popt.topt.encoding = pset.encoding;
pset.sversion = PQserverVersion(pset.db);
SetVariable(pset.vars, "DBNAME", PQdb(pset.db));
SetVariable(pset.vars, "USER", PQuser(pset.db));
SetVariable(pset.vars, "HOST", PQhost(pset.db));
SetVariable(pset.vars, "PORT", PQport(pset.db));
SetVariable(pset.vars, "ENCODING", pg_encoding_to_char(pset.encoding));
/* send stuff to it, too */
PQsetErrorVerbosity(pset.db, pset.verbosity);
}
开发者ID:50wu,项目名称:gpdb,代码行数:23,代码来源:command.c
示例20: getRules
PQLRule *
getRules(PGconn *c, int *n)
{
PQLRule *r;
PGresult *res;
int i;
logNoise("rule: server version: %d", PQserverVersion(c));
res = PQexec(c,
"SELECT n.nspname AS schemaname, c.relname AS tablename, r.rulename, pg_get_ruledef(r.oid) AS definition, obj_description(r.oid, 'pg_rewrite') AS description FROM pg_rewrite r INNER JOIN pg_class c ON (c.oid = r.ev_class) INNER JOIN pg_namespace n ON (n.oid = c.relnamespace) WHERE r.rulename <> '_RETURN'::name AND n.nspname !~ '^pg_' AND n.nspname <> 'information_schema' ORDER BY n.nspname, c.relname, r.rulename");
if (PQresultStatus(res) != PGRES_TUPLES_OK)
{
logError("query failed: %s", PQresultErrorMessage(res));
PQclear(res);
PQfinish(c);
/* XXX leak another connection? */
exit(EXIT_FAILURE);
}
*n = PQntuples(res);
if (*n > 0)
r = (PQLRule *) malloc(*n * sizeof(PQLRule));
else
r = NULL;
logDebug("number of rules in server: %d", *n);
for (i = 0; i < *n; i++)
{
r[i].table.schemaname = strdup(PQgetvalue(res, i, PQfnumber(res, "schemaname")));
r[i].table.objectname = strdup(PQgetvalue(res, i, PQfnumber(res, "tablename")));
r[i].rulename = strdup(PQgetvalue(res, i, PQfnumber(res, "rulename")));
r[i].ruledef = strdup(PQgetvalue(res, i, PQfnumber(res, "definition")));
if (PQgetisnull(res, i, PQfnumber(res, "description")))
r[i].comment = NULL;
else
r[i].comment = strdup(PQgetvalue(res, i, PQfnumber(res, "description")));
logDebug("rule %s on %s.%s", formatObjectIdentifier(r[i].rulename), formatObjectIdentifier(r[i].table.schemaname), formatObjectIdentifier(r[i].table.objectname));
}
PQclear(res);
return r;
}
开发者ID:fabriziomello,项目名称:pgquarrel,代码行数:46,代码来源:rule.c
注:本文中的PQserverVersion函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论