½Ó¿Ú
Postgres ÌṩµÄÓÃÓÚ·ÃÎÊ´ó¶ÔÏóµÄ»úÖÆ£¬°üÀ¨×÷ΪÓû§¶¨Ò庯ÊýµÄºó¶ËµÄÒ»²¿·Ö»òÕß×÷ΪʹÓýӿڵÄÇ°¶ËÓ¦ÓõÄÒ»²¿·Ö£¬¶¼ÔÚÏÂÃæÃèÊö£®¶ÔÓÚÊìϤ
Postgres
4.2 µÄÓû§£¬
PostgreSQL ÓÐÒ»Ì×еĺ¯ÊýÌṩ¸üÁ¬¹áµÄ½Ó¿Ú£®
×¢Ò⣺ËùÓдó¶ÔÏóµÄ²Ù×÷¶¼±ØÐëÔÚÒ»¸öSQLÊÂÎñÀïʵÏÖ¡£ÕâÔÚ
Postgres v6.5 ÀïÓÐÑϸñµÄÒªÇ󣬾¡¹ÜÔÚÒÔÇ°µÄ°æ±¾Àï¾ÍÒþº¬ÕâÑùµÄÒªÇó£¬Èç¹ûºöÂÔÕâÒ»µã»áµ¼Ö´íÎóµÄ±íÏÖ¡£
Postgres ´ó¶ÔÏó½Ó¿ÚÊǶÔ
UNIX
ÎļþϵͳµÄÄ£·Â£¬ÓзÂÕæµÄ
open(2)£¬read(2)£¬write(2)£¬lseek(2)£¬µÈ£®Óû§º¯Êýµ÷ÓÃÕâЩ·¾¶´ÓÒ»¸ö´ó¶ÔÏóÖмìË÷ËýÃǸÐÐËȤµÄÊý¾Ý£®ÀýÈ磬Èç¹ûÒ»¸öÃûΪ
mugshot µÄ´ó¶ÔÏóÀàÐÍ´æÔÚ£¬ÔÚÆäÖб£´æÃæ¿×µÄͼÏó£¬ÄÇô¿ÉÒÔÔÚ mugshot Êý¾ÝÉ϶¨ÒåÒ»¸ö½Ð
beard £¨ºú×Ó£©µÄº¯Êý£®Beard £¨ºú×Óº¯Êý£©»á¼ì²éͼƬµÄÏÂÈý·ÖÖ®Ò»ÇøÓò£¬²¢ÇÒÈç¹û´æÔÚºú×ӵĻ°ÅжϺú×ÓµÄÑÕÉ«£®Õû¸ö´ó¶ÔÏóµÄÖµ²»ÐèÒª±»
brard º¯Êý»º´æÆðÀ´»òÕßÉõÖÁÊÇ×÷Щ¼ì²é£®´ó¶ÔÏó¿ÉÒÔ´Ó¶¯Ì¬×°ÔصÄ
C
º¯Êý»òÕßÊÇÁ´½Ó¸Ã¿âµÄÊý¾Ý¿â¿Í»§³ÌÐò·ÃÎÊ£®
Postgres
ÌṩһÌ×¹ý³ÌÖ§³Ö¶Ô´ó¶ÔÏóµÄ´ò¿ª£¬¶Á£¬Ð´£¬¹Ø±ÕºÍËÑË÷¡£
´´½¨´ó¶ÔÏó
¹ý³Ì
Oid lo_creat(PGconn *conn, int mode)
´´½¨Ò»¸öеĴó¶ÔÏó£®
mode ÊÇÒ»¸öλÑÚÂ룬ÃèÊöжÔÏóµÄ²»Í¬ÊôÐÔ£®ÕâÀïÁгöµÄ·ûºÅ³£Á¿ÔÚ
$PGROOT/src/backend/libpq/libpq-fs.h£®·ÃÎÊÀàÐÍ£¨¶Á£¬Ð´»òÕßÁ½Õߣ©ÊǶÔλ
INV_READ
ºÍ
INV_WRITE½øÐÐ OR £¨»ò£©²Ù×÷¹¹³ÉµÄ£®Èç¹û´ó¶ÔÏóÓ¦±»¹éµµ--Ò²¾ÍÊÇ˵£¬Èç¹ûÒòÀúÊ·ÔÒòËüÓ¦¸Ã±»ÖÜÆÚµØÒƵ½Ò»¸öÌØÊâµÄ¹éµµ¹Øϵ£¨±í£©ÖÐ--ÄÇô¾ÍÒªÉèÖÃ
INV_ARCHIVE
λ£®ÑÚÂëµÄµÍÊ®ÁùλÊÇ´ó¶ÔÏóÒª´æ·ÅÓÚÄڵĴ洢¹ÜÀíÆ÷ºÅ£®¶ÔÓÚ³ý Berkeley £¨²®¿ËÀû£©ÒÔÍâµÄ½Úµã£¬ÕâЩλ¶¼Ó¦×ÜÊÇÁ㣮ÏÂÃæµÄÃüÁî´´½¨Ò»¸ö
£¨µ¹×ªµÄ£©´ó¶ÔÏó£º
inv_oid = lo_creat(INV_READ|INV_WRITE|INV_ARCHIVE);
ÊäÈë´ó¶ÔÏó
Òª°ÑÒ»¸ö
UNIX ÎļþÊäÈë³ÉΪ´ó¶ÔÏ󣬵÷ÓÃ
Oid lo_import(PGconn *conn, const char *filename)
filename ²ÎÊýÖ¸Ã÷Òª±»ÊäÈë³ÉΪ´ó¶ÔÏóµÄ
UNIX
Îļþ·¾¶Ãû£®
Êä³ö´ó¶ÔÏó
Òª°ÑÒ»¸ö´ó¶ÔÏóÊä³öΪ
UNIX Îļþ£¬µ÷ÓÃ
int lo_export(PGconn *conn, Oid lobjId, const char *filename)
lobjId ²ÎÊýÖ¸Ã÷ÒªÊä³öµÄ´ó¶ÔÏó Oid£¬filename ²ÎÊýÖ¸Ã÷
UNIX
ÎļþµÄ·¾¶Ãû£®
´ò¿ªÒ»¸öÏÖÓеĴó¶ÔÏó
Òª´ò¿ªÒ»¸öÏÖ´æµÄ´ó¶ÔÏ󣬵÷ÓÃ
int lo_open(PGconn *conn, Oid lobjId, int mode)
²ÎÊý lobjId Ö¸Ã÷Òª´ò¿ªµÄ´ó¶ÔÏóµÄ Oid £¨¶ÔÏó±êʶ£©£®mode λ¿ØÖƸöÔÏóÊÇÓÃÓÚ¶Á
£¨INV_READ£©£¬Ð´»¹ÊǶÁд£®Ò»¸ö´ó¶ÔÏóÔÚÆä´´½¨Ö®Ç°²»Äܱ»´ò¿ª£®
lo_open
·µ»ØÒ»¸ö´ó¶ÔÏó±êʶÓÃÓÚÒÔºóµÄ
lo_read£¬
lo_write£¬
lo_lseek£¬
lo_tell£¬and
lo_close¡£
Ïò´ó¶ÔÏóÖÐдÊý¾Ý
¹ý³Ì
int lo_write(PGconn *conn, int fd, const char *buf, size_t len)
´Ó buf ÖÐÏò´ó¶ÔÏó fd ÖÐд len ×Ö½Ú£®²ÎÊý fd ±ØÐëÊÇÇ°ÃæÒ»¸ö
lo_open
µÄ·µ»Ø£®·µ»Øʵ¼ÊдµÄ×Ö½ÚÊý£®³ö´íʱ·µ»Ø¸ºÊý£®
´Ó´ó¶ÔÏóÖжÁÈ¡Êý¾Ý
¹ý³Ì
int lo_read(PGconn *conn, int fd, char *buf, size_t len)
´Ó´ó¶ÔÏóÖжÁÈ¡ len ×Ö½ÚÊý¾Ýµ½ buf ÖС£fd ²ÎÊý±ØÐëÊÇÇ°ÃæµÄÒ»¸ö
lo_open
µ÷Óõķµ»Ø¡£·µ»Øʵ¼Ê¶ÁÈ¡µÄ×Ö½ÚÊý¡£³ö´íʱ£¬·µ»ØÒ»¸ö¸ºÊý¡£
¶Ô´ó¶ÔÏóÖÐÊý¾ÝµÄ²éÕÒ
Òª¸Ä±äµ±Ç°´ó¶ÔÏóµÄ¶Á»òдλÖ㬵÷ÓÃ
int lo_lseek(PGconn *conn, int fd, int offset, int whence)
Õâ¸ö¹ý³Ì°Ñµ±Ç° fd ´ú±íµÄ´ó¶ÔÏóλÖÃÖ¸ÕëÒƶ¯µ½ offset Ö¸Ã÷µÄеÄλÖ㮲ÎÊý
whence µÄºÏ·¨µÄÈ¡ÖµÊÇ SEEK_SET SEEK_CUR ºÍ SEEK_END£®
¹Ø±ÕÒ»¸ö´ó¶ÔÏóÃèÊö·û
¿ÉÒÔͨ¹ýµ÷ÓÃ
int lo_close(PGconn *conn, int fd)
¹Ø±ÕÒ»¸ö´ó¶ÔÏó£¬ÕâÀï fd ÊÇ
lo_open ·µ»ØµÄ´ó¶ÔÏóµÄÃèÊö·û£®³É¹¦Ê±£¬
lo_close
·µ»ØÁ㣮´íÎóʱ£¬·µ»ØÖµÊǸºÊý£®
´