src/server/plugins/postgresql/vfs.c

branch
webdav
changeset 289
285d483db2fb
parent 285
96e53bd94958
child 290
efc10acf539f
equal deleted inserted replaced
288:7dd45173f68a 289:285d483db2fb
134 log_ereport(LOG_MISCONFIG, "postgresql vfs: resource pool %s not found", resource_pool); 134 log_ereport(LOG_MISCONFIG, "postgresql vfs: resource pool %s not found", resource_pool);
135 return NULL; 135 return NULL;
136 } 136 }
137 // resdata will be freed automatically when the request is finished 137 // resdata will be freed automatically when the request is finished
138 138
139 return pg_vfs_create_from_resourcedata(sn, rq, resdata);
140 }
141
142 VFS* pg_vfs_create_from_resourcedata(Session *sn, Request *rq, ResourceData *resdata) {
139 // Create a new VFS object and a separate instance object 143 // Create a new VFS object and a separate instance object
140 // VFS contains fptrs that can be copied from pg_vfs_class 144 // VFS contains fptrs that can be copied from pg_vfs_class
141 // instance contains request specific data (PGconn) 145 // instance contains request specific data (PGconn)
142 VFS *vfs = pool_malloc(sn->pool, sizeof(VFS)); 146 VFS *vfs = pool_malloc(sn->pool, sizeof(VFS));
143 if(!vfs) { 147 if(!vfs) {
410 if(!iscollection) { 414 if(!iscollection) {
411 if (PQstatus(pg->connection) != CONNECTION_OK) { 415 if (PQstatus(pg->connection) != CONNECTION_OK) {
412 fd = -2; 416 fd = -2;
413 } 417 }
414 418
415 int lo_mode = INV_READ; // TODO: evaluate oflags 419 int lo_mode = INV_READ;
420 if((oflags & O_RDWR) == O_RDWR) {
421 lo_mode = INV_READ|INV_WRITE;
422 } else if((oflags & O_WRONLY) == O_WRONLY) {
423 lo_mode = INV_WRITE;
424 }
416 fd = lo_open(pg->connection, oid, lo_mode); 425 fd = lo_open(pg->connection, oid, lo_mode);
417 } 426 }
418 427
419 pgfile->iscollection = iscollection; 428 pgfile->iscollection = iscollection;
420 pgfile->resource_id = resource_id; 429 pgfile->resource_id = resource_id;

mercurial