-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.
-- See www.xtuple.com/CPAL for the full text of the software license.
BEGIN
- PERFORM pg_advisory_unlock(datid::integer, procpid)
+ IF (compareversion('9.2.0') <= 0)
+ THEN
+ PERFORM pg_advisory_unlock(datid::integer, pid)
FROM pg_stat_activity
- WHERE(procpid = pg_backend_pid());
+ WHERE(pid = pg_backend_pid());
+ ELSE
+ PERFORM pg_advisory_unlock(datid::integer, procpid)
+ FROM pg_stat_activity
+ WHERE(procpid = pg_backend_pid());
+ END IF;
RETURN 0;
END;
return ret;
},
+ /**
+ * Get the current database server version.
+ * If the optional precision argument is passed, return the first prec
+ * fields of the full version number.
+ *
+ * @example
+ * var x = getPgVersion(1), // '9'
+ * xy = getPgVersion(2), // '9.1'
+ * xyz = getPgVersion(3), // '9.1.3'
+ * all = getPgVersion(); // '9.1.3'
+ *
+ * @param {Number} proc - optional precision
+ * @returns {String} X[.Y[.Z]]
+ */
+ getPgVersion: function (prec) {
+ var q = plv8.execute("select setting from pg_settings " +
+ "where name='server_version';"),
+ ret;
+ ret = q[0].setting;
+ if (typeof prec === 'number') {
+ ret = ret.split(".").slice(0,prec).join(".");
+ }
+ return ret;
+ },
+
/**
* Get the oid for a given table name.
*
lockExp,
oid,
pcheck,
+ pgver = 0 + XT.Data.getPgVersion(2),
pid = options.pid || null,
- pidSql = "select usename, procpid " +
+ pidcol = (pgver < 9.2) ? "procpid" : "pid",
+ pidSql = "select usename, {pidcol} " +
"from pg_stat_activity " +
"where datname=current_database() " +
" and usename=$1 " +
- " and procpid=$2;",
+ " and {pidcol}=$2;",
query,
selectSql = "select * " +
"from xt.lock " +
" and lock_record_id = $2;",
username = XT.username;
+ pidSql = pidSql.replace(/{pidcol}/g, pidcol);
+
/* If passed a table name, look up the oid. */
oid = typeof table === "string" ? this.getTableOid(table) : table;
"author": "xTuple <dev@xtuple.com>",
"name": "xtuple",
"description": "xTuple Enterprise Resource Planning Mobile-Web client",
- "version": "4.6.0",
+ "version": "4.6.1",
"repository": {
"type": "git",
"url": "https://github.com/xtuple/xtuple.git"
sudo add-apt-repository -y "deb http://apt.postgresql.org/pub/repos/apt/ ${DEBDIST}-pgdg main"
sudo wget -qO- https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get -qq update 2>&1 | tee -a $LOG_FILE
- sudo apt-get -q -y install curl build-essential libssl-dev postgresql-9.1 postgresql-server-dev-9.1 postgresql-contrib-9.1 postgresql-9.1-plv8 2>&1 | tee -a $LOG_FILE
+ sudo apt-get -q -y install curl build-essential libssl-dev \
+ postgresql-${PG_VERSION} postgresql-server-dev-${PG_VERSION} \
+ postgresql-contrib-${PG_VERSION} postgresql-${PG_VERSION}-plv8 2>&1 \
+ | tee -a $LOG_FILE
if [ ! -d "/usr/local/nvm" ]; then
sudo rm -f /usr/local/bin/nvm
return 1
fi
- PGDIR=/etc/postgresql/9.1/main
+ PGDIR=/etc/postgresql/${PG_VERSION}/main
log "copying configs..."
sudo cp $PGDIR/postgresql.conf $PGDIR/postgresql.conf.default
return memo + script;
}, "");
- // Without this, when we delegate to exec psql the err var will not be set even
- // on the case of error.
- allSql = "\\set ON_ERROR_STOP TRUE;\n" + allSql;
+ // Without this, psql runs all input and returns success even if errors occurred
+ allSql = "\\set ON_ERROR_STOP TRUE\n" + allSql;
if (spec.wasInitialized && !_.isEqual(extensions, ["foundation-database"])) {
// give the admin user every extension by default