summaryrefslogtreecommitdiff
path: root/pgsql.c
diff options
context:
space:
mode:
authorAndreas Baumann <abaumann@yahoo.com>2012-04-19 11:14:33 +0200
committerAndreas Baumann <abaumann@yahoo.com>2012-04-19 11:14:33 +0200
commita5923caf474983e14477498117fabb041805fd04 (patch)
treee6a40a174d064acb2c7ab5a3b1e6366193b8b7d8 /pgsql.c
parent4a88c817b17498e72a95589f887197ab43edc491 (diff)
downloadpgfuse-a5923caf474983e14477498117fabb041805fd04.tar.gz
pgfuse-a5923caf474983e14477498117fabb041805fd04.tar.bz2
added first simple transaction policy (per FUSE operation)
Diffstat (limited to 'pgsql.c')
-rw-r--r--pgsql.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/pgsql.c b/pgsql.c
index 696e705..3667af7 100644
--- a/pgsql.c
+++ b/pgsql.c
@@ -641,3 +641,51 @@ int psql_truncate( PGconn *conn, const int id, const char *path, const off_t off
return 0;
}
+
+int psql_begin( PGconn *conn )
+{
+ PGresult *res;
+
+ res = PQexec( conn, "BEGIN" );
+
+ if( PQresultStatus( res ) != PGRES_COMMAND_OK ) {
+ syslog( LOG_ERR, "Begin of transaction failed!!" );
+ return -EIO;
+ }
+
+ PQclear( res );
+
+ return 0;
+}
+
+int psql_commit( PGconn *conn )
+{
+ PGresult *res;
+
+ res = PQexec( conn, "COMMIT" );
+
+ if( PQresultStatus( res ) != PGRES_COMMAND_OK ) {
+ syslog( LOG_ERR, "Commit of transaction failed!!" );
+ return -EIO;
+ }
+
+ PQclear( res );
+
+ return 0;
+}
+
+int psql_rollback( PGconn *conn )
+{
+ PGresult *res;
+
+ res = PQexec( conn, "ROLLBACK" );
+
+ if( PQresultStatus( res ) != PGRES_COMMAND_OK ) {
+ syslog( LOG_ERR, "Rollback of transaction failed!!" );
+ return -EIO;
+ }
+
+ PQclear( res );
+
+ return 0;
+}