Re: [PATCHES] lo_truncate
Patch applied. Thanks. --- Kris Jurka wrote: On Wed, 28 Feb 2007, Bruce Momjian wrote: Your patch has been added to the PostgreSQL unapplied patches list at: http://momjian.postgresql.org/cgi-bin/pgpatches It will be applied as soon as one of the PostgreSQL committers reviews and approves it. Here's a patch that works with the new varlena API. Kris Jurka Content-Description: [ Attachment, skipping... ] ---(end of broadcast)--- TIP 5: don't forget to increase your free space map settings -- Bruce Momjian [EMAIL PROTECTED] http://momjian.us EnterpriseDB http://www.enterprisedb.com + If your life is a hard drive, Christ can be your backup. + ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster
Re: [PATCHES] lo_truncate
Your patch has been added to the PostgreSQL unapplied patches list at: http://momjian.postgresql.org/cgi-bin/pgpatches It will be applied as soon as one of the PostgreSQL committers reviews and approves it. --- Kris Jurka wrote: On Wed, 28 Feb 2007, Bruce Momjian wrote: Your patch has been added to the PostgreSQL unapplied patches list at: http://momjian.postgresql.org/cgi-bin/pgpatches It will be applied as soon as one of the PostgreSQL committers reviews and approves it. Here's a patch that works with the new varlena API. Kris Jurka Content-Description: [ Attachment, skipping... ] ---(end of broadcast)--- TIP 5: don't forget to increase your free space map settings -- Bruce Momjian [EMAIL PROTECTED] http://momjian.us EnterpriseDB http://www.enterprisedb.com + If your life is a hard drive, Christ can be your backup. + ---(end of broadcast)--- TIP 7: You can help support the PostgreSQL project by donating at http://www.postgresql.org/about/donate
Re: [PATCHES] lo_truncate
Your patch has been added to the PostgreSQL unapplied patches list at: http://momjian.postgresql.org/cgi-bin/pgpatches It will be applied as soon as one of the PostgreSQL committers reviews and approves it. --- Kris Jurka wrote: The attached patch implements lo_truncate for truncating large objects to a given length. This is required for implementing Blob.truncate in the JDBC driver[1] and rounds out filesystem like functionality for large objects. Kris Jurka [1] http://java.sun.com/javase/6/docs/api/java/sql/Blob.html#truncate(long) Content-Description: [ Attachment, skipping... ] ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match -- Bruce Momjian [EMAIL PROTECTED] http://momjian.us EnterpriseDB http://www.enterprisedb.com + If your life is a hard drive, Christ can be your backup. + ---(end of broadcast)--- TIP 7: You can help support the PostgreSQL project by donating at http://www.postgresql.org/about/donate
Re: [PATCHES] lo_truncate
On Wed, 28 Feb 2007, Bruce Momjian wrote: Your patch has been added to the PostgreSQL unapplied patches list at: http://momjian.postgresql.org/cgi-bin/pgpatches It will be applied as soon as one of the PostgreSQL committers reviews and approves it. Here's a patch that works with the new varlena API. Kris JurkaIndex: doc/src/sgml/lobj.sgml === RCS file: /projects/cvsroot/pgsql/doc/src/sgml/lobj.sgml,v retrieving revision 1.44 diff -c -r1.44 lobj.sgml *** doc/src/sgml/lobj.sgml 1 Feb 2007 19:10:24 - 1.44 --- doc/src/sgml/lobj.sgml 1 Mar 2007 03:57:20 - *** *** 302,307 --- 302,338 /sect2 sect2 + titleTruncating a Large Object/title + + para + To truncate a large object to a given length, call + synopsis + int lo_truncate(PGcon *conn, int fd, size_t len); + /synopsis + indextermprimarylo_truncate// truncates the large object + descriptor parameterfd/ to length parameterlen/. The + parameterfd/parameter argument must have been returned by a + previous functionlo_open/function. If parameterlen/ is + greater than the current large object length, the large object + is extended with null bytes ('\0'). + /para + + para + The file offset is not changed. + /para + + para + On success functionlo_truncate/function returns + zero. On error, the return value is negative. + /para + + para + functionlo_truncate/ is new as of productnamePostgreSQL/productname + 8.3; if this function is run against an older server version, it will + fail and return a negative value. + /para + + sect2 titleClosing a Large Object Descriptor/title para Index: src/backend/libpq/be-fsstubs.c === RCS file: /projects/cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v retrieving revision 1.85 diff -c -r1.85 be-fsstubs.c *** src/backend/libpq/be-fsstubs.c 27 Feb 2007 23:48:07 - 1.85 --- src/backend/libpq/be-fsstubs.c 1 Mar 2007 03:57:20 - *** *** 120,131 int32 fd = PG_GETARG_INT32(0); if (fd 0 || fd = cookies_size || cookies[fd] == NULL) - { ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg(invalid large-object descriptor: %d, fd))); ! PG_RETURN_INT32(-1); ! } #if FSDB elog(DEBUG4, lo_close(%d), fd); #endif --- 120,129 int32 fd = PG_GETARG_INT32(0); if (fd 0 || fd = cookies_size || cookies[fd] == NULL) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg(invalid large-object descriptor: %d, fd))); ! #if FSDB elog(DEBUG4, lo_close(%d), fd); #endif *** *** 152,163 int status; if (fd 0 || fd = cookies_size || cookies[fd] == NULL) - { ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg(invalid large-object descriptor: %d, fd))); - return -1; - } status = inv_read(cookies[fd], buf, len); --- 150,158 *** *** 170,181 int status; if (fd 0 || fd = cookies_size || cookies[fd] == NULL) - { ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg(invalid large-object descriptor: %d, fd))); - return -1; - } if ((cookies[fd]-flags IFS_WRLOCK) == 0) ereport(ERROR, --- 165,173 *** *** 198,209 int status; if (fd 0 || fd = cookies_size || cookies[fd] == NULL) - { ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg(invalid large-object descriptor: %d, fd))); - PG_RETURN_INT32(-1); - } status = inv_seek(cookies[fd], offset, whence); --- 190,198 *** *** 248,259 int32 fd = PG_GETARG_INT32(0); if (fd 0 || fd = cookies_size || cookies[fd] == NULL) - { ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg(invalid large-object descriptor: %d, fd))); - PG_RETURN_INT32(-1); - } PG_RETURN_INT32(inv_tell(cookies[fd])); } --- 237,245 *** *** 468,473 --- 454,479 } /* + * lo_truncate - + * truncate a large object to a specified length + */ + Datum + lo_truncate(PG_FUNCTION_ARGS) + { + int32
[PATCHES] lo_truncate
The attached patch implements lo_truncate for truncating large objects to a given length. This is required for implementing Blob.truncate in the JDBC driver[1] and rounds out filesystem like functionality for large objects. Kris Jurka [1] http://java.sun.com/javase/6/docs/api/java/sql/Blob.html#truncate(long)Index: doc/src/sgml/lobj.sgml === RCS file: /projects/cvsroot/pgsql/doc/src/sgml/lobj.sgml,v retrieving revision 1.44 diff -c -r1.44 lobj.sgml *** doc/src/sgml/lobj.sgml 1 Feb 2007 19:10:24 - 1.44 --- doc/src/sgml/lobj.sgml 22 Feb 2007 20:43:16 - *** *** 302,307 --- 302,338 /sect2 sect2 + titleTruncating a Large Object/title + + para + To truncate a large object to a given length, call + synopsis + int lo_truncate(PGcon *conn, int fd, size_t len); + /synopsis + indextermprimarylo_truncate// truncates the large object + descriptor parameterfd/ to length parameterlen/. The + parameterfd/parameter argument must have been returned by a + previous functionlo_open/function. If parameterlen/ is + greater than the current large object length, the large object + is extended with null bytes ('\0'). + /para + + para + The file offset is not changed. + /para + + para + On success functionlo_truncate/function returns + zero. On error, the return value is negative. + /para + + para + functionlo_truncate/ is new as of productnamePostgreSQL/productname + 8.3; if this function is run against an older server version, it will + fail and return a negative value. + /para + + sect2 titleClosing a Large Object Descriptor/title para Index: src/backend/libpq/be-fsstubs.c === RCS file: /projects/cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v retrieving revision 1.84 diff -c -r1.84 be-fsstubs.c *** src/backend/libpq/be-fsstubs.c 5 Jan 2007 22:19:29 - 1.84 --- src/backend/libpq/be-fsstubs.c 22 Feb 2007 20:43:17 - *** *** 120,131 int32 fd = PG_GETARG_INT32(0); if (fd 0 || fd = cookies_size || cookies[fd] == NULL) - { ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg(invalid large-object descriptor: %d, fd))); ! PG_RETURN_INT32(-1); ! } #if FSDB elog(DEBUG4, lo_close(%d), fd); #endif --- 120,129 int32 fd = PG_GETARG_INT32(0); if (fd 0 || fd = cookies_size || cookies[fd] == NULL) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg(invalid large-object descriptor: %d, fd))); ! #if FSDB elog(DEBUG4, lo_close(%d), fd); #endif *** *** 152,163 int status; if (fd 0 || fd = cookies_size || cookies[fd] == NULL) - { ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg(invalid large-object descriptor: %d, fd))); - return -1; - } status = inv_read(cookies[fd], buf, len); --- 150,158 *** *** 170,181 int status; if (fd 0 || fd = cookies_size || cookies[fd] == NULL) - { ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg(invalid large-object descriptor: %d, fd))); - return -1; - } if ((cookies[fd]-flags IFS_WRLOCK) == 0) ereport(ERROR, --- 165,173 *** *** 198,209 int status; if (fd 0 || fd = cookies_size || cookies[fd] == NULL) - { ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg(invalid large-object descriptor: %d, fd))); - PG_RETURN_INT32(-1); - } status = inv_seek(cookies[fd], offset, whence); --- 190,198 *** *** 248,259 int32 fd = PG_GETARG_INT32(0); if (fd 0 || fd = cookies_size || cookies[fd] == NULL) - { ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg(invalid large-object descriptor: %d, fd))); - PG_RETURN_INT32(-1); - } PG_RETURN_INT32(inv_tell(cookies[fd])); } --- 237,245 *** *** 468,473 --- 454,479 } /* + * lo_truncate - + * truncate a large object to a specified length + */ + Datum + lo_truncate(PG_FUNCTION_ARGS) + { + int32 fd =