pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kurt Seel <kseel@utcorp.com>
To: pgsql-interfaces@postgresql.org
Subject: Problem: TCL with Large Objects
Date: Tue, 14 Jul 1998 10:14:46 -0400
Message-ID: <35AB67D6.2C67412E@utcorp.com> (raw)

I am working with Large Objects in TCL. How can you expand a LO
after it's been written? Example code follows. I am working with 
TCL 8.0 p2, PostgreSQL 6.3.2 on BSDI 3.0. 

#!/usr/local/pgsql/bin/pgtclsh

	set CONN [pg_connect nccbor]
	
	puts "begin : [pg_exec $CONN BEGIN;]"
	puts "create : [set LOID [pg_lo_creat $CONN "INV_READ|INV_WRITE"]]"
	puts "end : [pg_exec $CONN END;]"
#
# Open and write some data into blob
#
	puts "begin : [pg_exec $CONN BEGIN;]"

	puts "open (w): [set LOFD [pg_lo_open $CONN $LOID w]]"
	set STR1 "sdlfkjhlskdjfh lakjdhfljkadsfhlkjas"
	set SIZ1 [string length $STR1]
	puts "write : [pg_lo_write $CONN $LOFD $STR1 $SIZ1]"
	puts "close : [pg_lo_close $CONN $LOFD]"

	puts "end : [pg_exec $CONN END;]"
#
# Open and read the data from blob
#
	puts "begin : [pg_exec $CONN BEGIN;]"

	puts "open (r): [set LOFD [pg_lo_open $CONN $LOID r]]"
	puts "read : [pg_lo_read $CONN $LOFD STR 10240]"
	puts $STR
	puts "close : [pg_lo_close $CONN $LOFD]"

	puts "end : [pg_exec $CONN END;]"
#
# Now attempt to over-write the blob
#
	puts "begin : [pg_exec $CONN BEGIN;]"
		
	puts "open (w): [set LOFD [pg_lo_open $CONN $LOID w]]"
	set STR2 "New Data -----------------------------------------"
	set SIZ2 [string length $STR2]
	puts "pos : [pg_lo_tell $CONN $LOFD]"
	puts "write : [pg_lo_write $CONN $LOFD $STR2 $SIZ2]"
	puts "pos : [pg_lo_tell $CONN $LOFD]"
	puts "close : [pg_lo_close $CONN $LOFD]"

	puts "end : [pg_exec $CONN END;]"
#
# Open and read again
#
	puts "begin : [pg_exec $CONN BEGIN;]"

	puts "open (r): [set LOFD [pg_lo_open $CONN $LOID r]]"
	puts "read : [pg_lo_read $CONN $LOFD STR 10240]"
	puts $STR
	puts "close : [pg_lo_close $CONN $LOFD]"

	puts "end : [pg_exec $CONN END;]"
	pg_disconnect $CONN

 When run this produces :

begin : pgsql3.0
create : 27873
end : pgsql3.1
begin : pgsql3.2
open (w): 0
write : 35
close : 0
end : pgsql3.3
begin : pgsql3.4
open (r): 0
read : 35
sdlfkjhlskdjfh lakjdhfljkadsfhlkjas
close : 0
end : pgsql3.5
begin : pgsql3.6
open (w): 0
pos : 0
write : 50
pos : 50
close : 0
end : pgsql3.7
begin : pgsql3.8
open (r): 0
read : 50
sdlfkjhlskdjfh lakjdhfljkadsfhlkjas---------------
close : 0
end : pgsql3.9

 The question is this: why doesn't it over-write the old data. Also
if I don't enclose _every_ little code block in a begin/end pair I 
get a core dump (SIGSEV) or weird error from the parser.
I am trying to save TCL arrays to LO's, I have used files in the 
past, are LO's stable enough for this purpose?

-- 
Kurt Seel, Systems Engineer
Unified Technologies Corp.
Phone : 610 964 8200
Email : kseel@ut{anti-spam]corp.com

 To send me email, remove the {anti-spam] from the above address.



Message-ID: <35AB67D6.2C67412E@utcorp.com>
Permalink:  ../35AB67D6.2C67412E@utcorp.com/
Also on:    postgresql.org/message-id/35AB67D6.2C67412E@utcorp.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: kseel@utcorp.com
  Subject: Re: Problem: TCL with Large Objects
  In-Reply-To: <35AB67D6.2C67412E@utcorp.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox