head	1.16;
access;
symbols
	REL7_4_29:1.9
	REL8_0_25:1.12
	REL8_1_21:1.13
	REL7_4_28:1.9
	REL8_0_24:1.12
	REL8_1_20:1.13
	REL7_4_27:1.9
	REL8_0_23:1.12
	REL8_1_19:1.13
	REL7_4_26:1.9
	REL8_0_22:1.12
	REL8_1_18:1.13
	REL7_4_25:1.9
	REL8_0_21:1.12
	REL8_1_17:1.13
	REL7_4_24:1.9
	REL8_0_20:1.12
	REL8_1_16:1.13
	REL7_4_23:1.9
	REL8_0_19:1.12
	REL8_1_15:1.13
	REL7_4_22:1.9
	REL8_0_18:1.12
	REL8_1_14:1.13
	REL7_4_21:1.9
	REL8_0_17:1.12
	REL8_1_13:1.13
	REL7_4_20:1.9
	REL8_0_16:1.12
	REL8_1_12:1.13
	REL7_3_21:1.8
	REL7_4_19:1.9
	REL8_0_15:1.12
	REL8_1_11:1.13
	REL7_3_20:1.8
	REL7_4_18:1.9
	REL8_0_14:1.12
	REL8_1_10:1.13
	REL7_3_19:1.8
	REL7_4_17:1.9
	REL8_0_13:1.12
	REL8_1_9:1.13
	REL8_0_12:1.12
	REL8_1_8:1.13
	REL7_3_18:1.8
	REL7_4_16:1.9
	REL8_0_11:1.12
	REL8_1_7:1.13
	REL8_0_10:1.12
	REL8_1_6:1.13
	REL7_4_15:1.9
	REL7_3_17:1.8
	REL8_1_5:1.13
	REL8_0_9:1.12
	REL7_4_14:1.9
	REL7_3_16:1.8
	REL7_3_15:1.8
	REL7_4_13:1.9
	REL8_0_8:1.12
	REL8_1_4:1.13
	REL7_3_14:1.8
	REL7_4_12:1.9
	REL8_0_7:1.12
	REL8_1_3:1.13
	REL7_3_13:1.8
	REL7_4_11:1.9
	REL8_0_6:1.12
	REL8_1_2:1.13
	REL7_3_12:1.8
	REL7_4_10:1.9
	REL8_0_5:1.12
	REL8_1_1:1.13
	REL8_1_STABLE:1.13.0.2
	REL8_1_0:1.13
	REL8_1_0RC1:1.13
	REL8_1_0BETA4:1.13
	REL8_1_0BETA3:1.12
	REL7_3_11:1.8
	REL7_4_9:1.9
	REL8_0_4:1.12
	REL8_1_0BETA2:1.12
	REL8_1_0BETA1:1.12
	REL7_2_8:1.7
	REL7_3_10:1.8
	REL7_4_8:1.9
	REL8_0_3:1.12
	REL8_0_2:1.12
	REL7_2_7:1.7
	REL7_3_9:1.8
	REL7_4_7:1.9
	REL8_0_1:1.12
	REL8_0_STABLE:1.12.0.4
	REL8_0_0:1.12.0.2
	REL8_0_0RC5:1.12
	REL8_0_0RC4:1.12
	REL8_0_0RC3:1.12
	REL8_0_0RC2:1.11
	REL8_0_0RC1:1.11
	REL8_0_0BETA5:1.11
	REL8_0_0BETA4:1.11
	REL7_4_6:1.9
	REL7_3_8:1.8
	REL7_2_6:1.7
	REL8_0_0BETA3:1.11
	REL8_0_0BETA2:1.11
	REL7_2_5:1.7
	REL7_4_5:1.9
	REL7_3_7:1.8
	REL7_4_4:1.9
	REL8_0_0BETA1:1.10
	REL7_4_3:1.9
	REL7_4_2:1.9
	REL7_3_6:1.8
	REL7_4_1:1.9
	REL7_3_5:1.8
	REL7_4:1.9
	REL7_4_RC2:1.9
	REL7_4_STABLE:1.9.0.4
	REL7_4_RC1:1.9
	REL7_4_BETA5:1.9
	REL7_4_BETA4:1.9
	REL7_4_BETA3:1.9
	REL7_4_BETA2:1.9
	WIN32_DEV:1.9.0.2
	REL7_4_BETA1:1.9
	REL7_3_4:1.8
	REL7_3_2:1.8
	REL7_2_4:1.7
	REL7_3_STABLE:1.8.0.2
	REL7_2_3:1.7
	REL7_2_STABLE:1.7.0.2
	REL7_2:1.7
	REL7_2_RC2:1.7
	REL7_2_RC1:1.7
	REL7_2_BETA5:1.7
	REL7_2_BETA4:1.7
	REL7_2_BETA3:1.7
	REL7_2_BETA2:1.7
	REL7_2_BETA1:1.6
	REL7_1_2:1.6
	REL7_1_STABLE:1.6.0.2
	REL7_1_BETA:1.4
	REL7_1_BETA3:1.4
	REL7_1_BETA2:1.4
	REL7_1:1.6
	REL7_0_PATCHES:1.3.0.2
	REL7_0:1.3
	REL6_5_PATCHES:1.2.0.2
	REL6_5:1.2
	REL6_4:1.1.0.2
	release-6-3:1.1;
locks; strict;
comment	@ * @;


1.16
date	2006.06.05.21.16.32;	author tgl;	state dead;
branches;
next	1.15;

1.15
date	2006.03.05.15.59.11;	author momjian;	state Exp;
branches;
next	1.14;

1.14
date	2006.03.01.06.30.32;	author neilc;	state Exp;
branches;
next	1.13;

1.13
date	2005.10.15.02.49.52;	author momjian;	state Exp;
branches;
next	1.12;

1.12
date	2004.12.31.22.04.05;	author pgsql;	state Exp;
branches;
next	1.11;

1.11
date	2004.08.29.04.13.13;	author momjian;	state Exp;
branches;
next	1.10;

1.10
date	2003.11.29.19.52.14;	author pgsql;	state Exp;
branches;
next	1.9;

1.9
date	2003.08.04.02.40.20;	author momjian;	state Exp;
branches;
next	1.8;

1.8
date	2002.06.20.20.29.54;	author momjian;	state Exp;
branches;
next	1.7;

1.7
date	2001.11.05.17.46.40;	author momjian;	state Exp;
branches;
next	1.6;

1.6
date	2001.03.22.04.01.45;	author momjian;	state Exp;
branches;
next	1.5;

1.5
date	2001.01.24.19.43.32;	author momjian;	state Exp;
branches;
next	1.4;

1.4
date	2000.06.09.01.11.16;	author tgl;	state Exp;
branches;
next	1.3;

1.3
date	2000.01.26.05.58.51;	author momjian;	state Exp;
branches;
next	1.2;

1.2
date	99.02.13.23.22.47;	author momjian;	state Exp;
branches;
next	1.1;

1.1
date	98.03.01.04.51.01;	author scrappy;	state Exp;
branches;
next	;


desc
@@


1.16
log
@Remove extremely old, incomplete, broken example code.
Per my proposal a few days ago.
@
text
@/*-------------------------------------------------------------------------
 *
 * beard.c
 *	  sample routines to use large objects
 *
 * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
 * Portions Copyright (c) 1994, Regents of the University of California
 *
 *
 * IDENTIFICATION
 *	  $PostgreSQL: pgsql/src/tutorial/beard.c,v 1.15 2006/03/05 15:59:11 momjian Exp $
 *
 *-------------------------------------------------------------------------
 */

typedef struct ImageHdr
{
	int			size;
}	ImageHdr;

#define BUFSIZE 10

/*
 * beard -
 *	 clips lower 1/3 of picture and return as large object
 */
Oid
beard(Oid picture)
{
	Oid			beard;
	int			pic_fd,
				beard_fd;
	ImageHdr	ihdr;
	char		buf[BUFSIZE];
	int			cc;

	pic_fd = DatumGetInt32(DirectFunctionCall2(lo_open,
											   ObjectIdGetDatum(picture),
											   Int32GetDatum(INV_READ)));
	if (pic_fd < 0)
		elog(ERROR, "could not access picture large object");

	if (lo_read(pic_fd, (char *) &ihdr, sizeof(ihdr)) != sizeof(ihdr))
		elog(ERROR, "picture large object corrupted");

	beardOffset = (ihdr.size / 3) * 2;

	/*
	 * new large object
	 */
	beard = DatumGetObjectId(DirectFunctionCall1(lo_creat,
												 Int32GetDatum(INV_MD)));
	if (beard == InvalidOid)
		elog(ERROR, "could not create new large object");

	beard_fd = DatumGetInt32(DirectFunctionCall2(lo_open,
												 ObjectIdGetDatum(beard),
												 Int32GetDatum(INV_WRITE)));
	if (beard_fd < 0)
		elog(ERROR, "could not access beard large object");

	if (DatumGetInt32(DirectFunctionCall3(lo_lseek,
										  Int32GetDatum(pic_fd),
										  Int32GetDatum(beardOffset),
										  Int32GetDatum(SEEK_SET))) < 0)
		elog(ERROR, "could not seek in picture large object");

	while ((cc = lo_read(pic_fd, buf, BUFSIZE)) > 0)
	{
		if (lo_write(beard_fd, buf, cc) != cc)
			elog(ERROR, "error while writing large object");
	}

	DirectFunctionCall1(lo_close, Int32GetDatum(pic_fd));
	DirectFunctionCall1(lo_close, Int32GetDatum(beard_fd));

	return beard;
}
@


1.15
log
@Update copyright for 2006.  Update scripts.
@
text
@d11 1
a11 1
 *	  $PostgreSQL: pgsql/src/tutorial/beard.c,v 1.14 2006/03/01 06:30:32 neilc Exp $
@


1.14
log
@This patch makes the error message strings throughout the backend
more compliant with the error message style guide. In particular,
errdetail should begin with a capital letter and end with a period,
whereas errmsg should not. I also fixed a few related issues in
passing, such as fixing the repeated misspelling of "lexeme" in
contrib/tsearch2 (per Tom's suggestion).
@
text
@d6 1
a6 1
 * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
d11 1
a11 1
 *	  $PostgreSQL: pgsql/src/tutorial/beard.c,v 1.13 2005/10/15 02:49:52 momjian Exp $
@


1.13
log
@Standard pgindent run for 8.1.
@
text
@d11 1
a11 1
 *	  $PostgreSQL: pgsql/src/tutorial/beard.c,v 1.12 2004/12/31 22:04:05 pgsql Exp $
d41 1
a41 1
		elog(ERROR, "Cannot access picture large object");
d44 1
a44 1
		elog(ERROR, "Picture large object corrupted");
d54 1
a54 1
		elog(ERROR, "Cannot create new large object");
d60 1
a60 1
		elog(ERROR, "Cannot access beard large object");
d66 1
a66 1
		elog(ERROR, "Cannot seek in picture large object");
@


1.12
log
@
Tag appropriate files for rc3

Also performed an initial run through of upgrading our Copyright date to
extend to 2005 ... first run here was very simple ... change everything
where: grep 1996-2004 && the word 'Copyright' ... scanned through the
generated list with 'less' first, and after, to make sure that I only
picked up the right entries ...
@
text
@d11 1
a11 1
 *	  $PostgreSQL: pgsql/src/tutorial/beard.c,v 1.11 2004/08/29 04:13:13 momjian Exp $
d58 1
a58 1
											  Int32GetDatum(INV_WRITE)));
@


1.11
log
@Update copyright to 2004.
@
text
@d6 1
a6 1
 * Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
d11 1
a11 1
 *	  $PostgreSQL: pgsql-server/src/tutorial/beard.c,v 1.10 2003/11/29 19:52:14 pgsql Exp $
@


1.10
log
@
$Header: -> $PostgreSQL Changes ...
@
text
@d6 1
a6 1
 * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
d11 1
a11 1
 *	  $PostgreSQL: /cvsroot/pgsql-server/src/tutorial/beard.c,v 1.9 2003/08/04 02:40:20 momjian Exp $
@


1.9
log
@Update copyrights to 2003.
@
text
@d11 1
a11 1
 *	  $Header: /cvsroot/pgsql-server/src/tutorial/beard.c,v 1.8 2002/06/20 20:29:54 momjian Exp $
@


1.8
log
@Update copyright to 2002.
@
text
@d6 1
a6 1
 * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
d11 1
a11 1
 *	  $Header: /cvsroot/pgsql/src/tutorial/beard.c,v 1.7 2001/11/05 17:46:40 momjian Exp $
@


1.7
log
@New pgindent run with fixes suggested by Tom.  Patch manually reviewed,
initdb/regression tests pass.
@
text
@d6 1
a6 1
 * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
d11 1
a11 1
 *	  $Header: /cvsroot/pgsql/src/tutorial/beard.c,v 1.6 2001/03/22 04:01:45 momjian Exp $
@


1.6
log
@pgindent run.  Make it all clean.
@
text
@d11 1
a11 1
 *	  $Header: /home/projects/pgsql/cvsroot/pgsql/src/tutorial/beard.c,v 1.5 2001/01/24 19:43:32 momjian Exp $
d19 1
a19 1
}			ImageHdr;
@


1.5
log
@Change Copyright from PostgreSQL, Inc to PostgreSQL Global Development Group.
@
text
@d11 1
a11 1
 *	  $Header: /home/projects/pgsql/cvsroot/pgsql/src/tutorial/beard.c,v 1.4 2000/06/09 01:11:16 tgl Exp $
d58 1
a58 1
												 Int32GetDatum(INV_WRITE)));
@


1.4
log
@Another round of updates for new fmgr, mostly in the datetime code.
@
text
@d6 1
a6 1
 * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
d11 1
a11 1
 *	  $Header: /home/projects/pgsql/cvsroot/pgsql/src/tutorial/beard.c,v 1.3 2000/01/26 05:58:51 momjian Exp $
@


1.3
log
@Add:

  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc

to all files copyright Regents of Berkeley.  Man, that's a lot of files.
@
text
@d11 1
a11 1
 *	  $Header: /usr/local/cvsroot/pgsql/src/tutorial/beard.c,v 1.2 1999/02/13 23:22:47 momjian Exp $
d37 4
a40 1
	if ((pic_fd = lo_open(picture, INV_READ)) == -1)
d51 3
a53 1
	if ((beard = lo_creat(INV_MD)) == 0)		/* ?? is this right? */
d56 4
a59 1
	if ((beard_fd = lo_open(beard, INV_WRITE)) == -1)
d62 6
a67 1
	lo_lseek(pic_fd, beardOffset, SET_CUR);
d74 2
a75 2
	lo_close(pic_fd);
	lo_close(beard_fd);
@


1.2
log
@Change my-function-name-- to my_function_name, and optimizer renames.
@
text
@d6 2
a7 1
 * Copyright (c) 1994, Regents of the University of California
d11 1
a11 1
 *	  $Header: /usr/local/cvsroot/pgsql/src/tutorial/beard.c,v 1.1 1998/03/01 04:51:01 scrappy Exp $
@


1.1
log
@Move around files before applying Darren's second patch
@
text
@d3 1
a3 1
 * beard.c--
d10 1
a10 1
 *	  $Header: /usr/local/cvsroot/pgsql/src/tutorial/C-code/beard.c,v 1.5 1998/01/07 21:07:03 momjian Exp $
@
