You can subscribe to this list here.
| 2002 |
Jan
|
Feb
(3) |
Mar
|
Apr
(12) |
May
(11) |
Jun
(2) |
Jul
(37) |
Aug
(3) |
Sep
(24) |
Oct
(31) |
Nov
|
Dec
(4) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(3) |
Feb
(7) |
Mar
|
Apr
(11) |
May
(15) |
Jun
(7) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(4) |
Dec
|
| 2004 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Michael N. <mne...@us...> - 2002-12-20 10:07:35
|
Update of /cvsroot/ruby-dbi/subprojects/ruby-db2/samples
In directory sc8-pr-cvs1:/tmp/cvs-serv5135
Modified Files:
db2.rb
Log Message:
added Songsu Yun's patch
Index: db2.rb
===================================================================
RCS file: /cvsroot/ruby-dbi/subprojects/ruby-db2/samples/db2.rb,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- db2.rb 5 Sep 2002 09:57:14 -0000 1.1
+++ db2.rb 20 Dec 2002 10:07:31 -0000 1.2
@@ -3,87 +3,54 @@
module DB2
- FINALIZE_INFO = {}
- FINALIZE_PROC = proc do |id|
- info = FINALIZE_INFO[id]
- if $DEBUG then
- $stderr.puts "freeing handle <#{info[1]}> (#{info[0]})"
- end
- DB2CLI::SQLFreeHandle(info[0], info[1])
- end
-
-
- class CLIError < Exception
- attr_reader :sql_state, :native_error, :message_text
-
- def initialize(sql_state, native_error, message_text)
- @sql_state = sql_state
- @native_error = native_error
- @message_text = message_text
- end
-
- def message
- @message_text
- end
- end
-
- class Handle
+ module DB2Util
include DB2CLI
- def initialize(handle_type, parent_handle)
- @handle_type = handle_type
- @handle = parent_handle
-
- rc, handle = SQLAllocHandle(@handle_type, @handle)
- check_rc(rc)
- @handle = handle
- add_finalizer
- end
-
def free
- rc = SQLFreeHandle(@handle_type, @handle)
- check_rc(rc)
+ SQLFreeHandle(@handle_type, @handle)
end
def handle
@handle
end
- private
-
- def add_finalizer
- DB2::FINALIZE_INFO[self.id] = [@handle_type.dup, @handle.dup]
- ObjectSpace.define_finalizer(self, DB2::FINALIZE_PROC)
- end
-
def check_rc(rc)
- if rc != SQL_SUCCESS and rc != SQL_SUCCESS_WITH_INFO then
- err = SQLGetDiagRec(@handle_type, @handle, 1, 1024)
- raise CLIError.new(err[1], err[2], err[3])
+ if rc != SQL_SUCCESS and rc != SQL_SUCCESS_WITH_INFO
+ case rc
+ when SQL_NEED_DATA
+ rcText = 'SQL_NEED_DATA'
+ when SQL_NO_DATA_FOUND
+ rcText = 'SQL_NO_DATA'
+ when SQL_STILL_EXECUTING
+ rcText = 'SQL_STILL_EXECUTING'
+ when SQL_ERROR
+ rcText = 'SQL_ERROR'
+ when SQL_INVALID_HANDLE
+ rcText = 'SQL_INVALID_HANDLE'
+ end
+ puts "DB2 return code is #{rcText}"
+ rec = 1
+ loop do
+ a = SQLGetDiagRec(@handle_type, @handle, rec, 500)
+ break if a[0] != SQL_SUCCESS
+ puts a[3] if a[3] != nil and a[3] != '' #display message
+ rec += 1
+ end
+ raise "ERROR From DB2"
end
end
- end # class Handle
-
+ end # module DB2Util
- class Environment < Handle
+ class Environment
+ include DB2Util
def initialize
- super(SQL_HANDLE_ENV, SQL_NULL_HANDLE)
- end
-
- def dataSources
- data_sources_buffer
- end
-
-
- def createConnection(*a)
- Connection.new(self, *a)
+ @handle_type = SQL_HANDLE_ENV
+ rc, @handle = SQLAllocHandle(@handle_type, SQL_NULL_HANDLE)
+ check_rc(rc)
end
-
- private
-
- def data_sources_buffer(buffer_length = 1024)
+ def data_sources(buffer_length = 1024)
retval = []
max_buffer_length = buffer_length
@@ -97,44 +64,58 @@
retval << [a[1], a[3]]
max_buffer_length = [max_buffer_length, a[4]].max
- end
-
+ end
+
if max_buffer_length > buffer_length then
- data_sources_buffer(max_buffer_length)
+ get_data_sources(max_buffer_length)
else
retval
end
end
-
end # class Environment
+ class Connection
+ include DB2Util
- class Connection < Handle
-
- def initialize(environment, *conn_params)
+ def initialize(environment)
@env = environment
+ @handle_type = SQL_HANDLE_DBC
+ rc, @handle = SQLAllocHandle(@handle_type, @env.handle)
+ check_rc(rc)
+ end
- super(SQL_HANDLE_DBC, @env.handle)
+ def connect(server_name, user_name="", auth="")
+ rc = SQLConnect(@handle, server_name, user_name, auth)
+ check_rc(rc)
+ end
- @connected = false
+ def set_auto_commit(switch)
+ switch.upcase!
+ if switch != 'ON' and switch != 'OFF'
+ raise 'set_auto_commit: Specify either "ON" or "OFF"'
+ end
- unless conn_params.empty?
- connect(*conn_params)
+ if switch == 'ON'
+ rc = SQLSetConnectAttr(@handle, SQL_ATTR_AUTOCOMMIT, SQL_AUTOCOMMIT_ON)
+ else
+ rc = SQLSetConnectAttr(@handle, SQL_ATTR_AUTOCOMMIT, SQL_AUTOCOMMIT_OFF)
end
+ check_rc(rc)
end
- def connect(server_name, user_name="", auth="")
- rc = SQLConnect(@handle, server_name, user_name, auth)
+ def set_connect_attr(attr, value)
+ if value.type == String
+ value += "\0"
+ end
+ rc = SQLSetConnectAttr(@handle, attr, value)
check_rc(rc)
- @connected = true
end
def disconnect
rc = SQLDisconnect(@handle)
check_rc(rc)
- @connected = false
end
def rollback
@@ -147,109 +128,270 @@
check_rc(rc)
end
- def createStatement
- Statement.new(self)
- end
end # class Connection
- class Statement < Handle
+ class Statement
+ include DB2Util
def initialize(connection)
@conn = connection
- super(SQL_HANDLE_STMT, @conn.handle)
+ @handle_type = SQL_HANDLE_STMT
+ @parms = [] #yun
+ @sql = '' #yun
+ @numParms = 0 #yun
+ @prepared = false #yun
+ @parmArray = [] #yun. attributes of the parameter markers
+ rc, @handle = SQLAllocHandle(@handle_type, @conn.handle)
+ check_rc(rc)
end
def prepare(sql)
+ @sql = sql
rc = SQLPrepare(@handle, sql)
check_rc(rc)
+ rc, @numParms = SQLNumParams(@handle) #number of question marks
+ check_rc(rc)
+ #--------------------------------------------------------------------------
+ # parameter attributes are stored in instance variable @parmArray so that
+ # they are available when execute method is called.
+ #--------------------------------------------------------------------------
+ if @numParms > 0 #get parameter marker attributes
+ 1.upto(@numParms) do #parameter number starts from 1
+ | i |
+ rc, type, size, decimalDigits = SQLDescribeParam(@handle, i)
+ check_rc(rc)
+ @parmArray << Parameter.new(type, size, decimalDigits)
+ end
+ end
+ @prepared = true;
self
end
- def freeStmt(options)
- rc = SQLFreeStmt(@handle, options)
- ckeck_rc(rc)
- end
+ def execute(*parms)
+ if @prepared == false
+ raise "The statement was not prepared"
+ end
+
+ if parms.size == 1 and parms[0].type == Array
+ parms = parms[0]
+ end
+
+ if (@numParms != parms.size)
+ raise "Number of parameters supplied does not match with the SQL statement"
+ end
+
+ if @numParms > 0 #need to bind parameters
+ #--------------------------------------------------------------------
+ #calling bindParms may not be safe. Look comment below.
+ #--------------------------------------------------------------------
+ #bindParms(parms) #may not be safe
+
+ valueArray = []
+ 1.upto(@numParms) do #parameter number starts from 1
+ | i |
+ type = @parmArray[i - 1].type
+ size = @parmArray[i - 1].size
+ decimalDigits = @parmArray[i - 1].decimalDigits
+
+ if parms[i - 1].type == String
+ valueArray << parms[i - 1]
+ else
+ valueArray << parms[i - 1].to_s
+ end
+
+ rc = SQLBindParameter(@handle, i, type, size, decimalDigits, valueArray[i - 1])
+ check_rc(rc)
+ end
+ end
- def execute
rc = SQLExecute(@handle)
check_rc(rc)
+
+ if @numParms != 0
+ SQLFreeStmt(@handle, SQL_RESET_PARAMS) #reset parameters
+ check_rc(rc)
+ end
+
self
end
- def execDirect(sql)
+ #-------------------------------------------------------------------------------
+ # The last argument(value) to SQLBindParameter is a deferred argument, that is,
+ # it should be available when SQLExecute is called. Even though "value" is
+ # local to bindParms method, it seems that it is available when SQLExecute
+ # is called. I am not sure whether it would still work if garbage collection
+ # is done between bindParms call and SQLExecute call inside the execute method
+ # above.
+ #-------------------------------------------------------------------------------
+ def bindParms(parms) #This is the real thing. It uses SQLBindParms
+ 1.upto(@numParms) do #parameter number starts from 1
+ | i |
+ rc, dataType, parmSize, decimalDigits = SQLDescribeParam(@handle, i)
+ check_rc(rc)
+ if parms[i - 1].type == String
+ value = parms[i - 1]
+ else
+ value = parms[i - 1].to_s
+ end
+ rc = SQLBindParameter(@handle, i, dataType, parmSize, decimalDigits, value)
+ check_rc(rc)
+ end
+ end
+
+ #------------------------------------------------------------------------------
+ # bind method does not use DB2's SQLBindParams, but replaces "?" in the
+ # SQL statement with the value before passing the SQL statement to DB2.
+ # It is not efficient and can handle only strings since it puts everything in
+ # quotes.
+ #------------------------------------------------------------------------------
+ def bind(sql, args) #does not use SQLBindParams
+ arg_index = 0
+ result = ""
+ tokens(sql).each { |part|
+ case part
+ when '?'
+ result << "'" + (args[arg_index]) + "'" #put it into quotes
+ arg_index += 1
+ when '??'
+ result << "?"
+ else
+ result << part
+ end
+ }
+ if arg_index < args.size
+ raise "Too many SQL parameters"
+ elsif arg_index > args.size
+ raise "Not enough SQL parameters"
+ end
+ result
+ end
+
+ ## Break the sql string into parts.
+ #
+ # This is NOT a full lexer for SQL. It just breaks up the SQL
+ # string enough so that question marks, double question marks and
+ # quoted strings are separated. This is used when binding
+ # arguments to "?" in the SQL string. Note: comments are not
+ # handled.
+ #
+ def tokens(sql)
+ toks = sql.scan(/('([^'\\]|''|\\.)*'|"([^"\\]|""|\\.)*"|\?\??|[^'"?]+)/)
+ toks.collect {|t| t[0]}
+ end
+
+
+ def exec_direct(sql)
rc = SQLExecDirect(@handle, sql)
check_rc(rc)
self
end
- def tables(schema_name="%", table_name="%", table_type="TABLE")
- rc = SQLTables(@handle, "", schema_name, table_name, table_type)
+
+ def set_cursor_name(name)
+ rc = SQLSetCursorName(@handle, name)
+ check_rc(rc)
+ self
+ end
+
+ def get_cursor_name
+ rc, name = SQLGetCursorName(@handle)
check_rc(rc)
- self
+ name
end
- def rowCount
+ def row_count
rc, rowcount = SQLRowCount(@handle)
check_rc(rc)
rowcount
end
- def numResultCols
+ def num_result_cols
rc, cols = SQLNumResultCols(@handle)
check_rc(rc)
cols
end
- def colNames
- rc, nr_cols = SQLNumResultCols(@handle)
-
- (1..nr_cols).collect do |c|
- rc, name, bl, type, col_sz = SQLDescribeCol(@handle, c, 1024)
- name
- end
- end
-
- def fetchAll
+ def fetch_all
if block_given?
- while (row=fetchRow) do
+ while (row=fetch) do
yield row
end
else
res = []
- while (row=fetchRow) do
+ while (row=fetch) do
res << row
end
res
end
end
- def fetchRow(orientation=SQL_FETCH_NEXT, offset=0)
+
+ def fetch
rc, nr_cols = SQLNumResultCols(@handle)
-
- cols = (1..nr_cols).collect do |c|
+
+ cols = (1..nr_cols).collect do |c|
rc, name, bl, type, col_sz = SQLDescribeCol(@handle, c, 1024)
[name, type, col_sz]
- end
+ end
- rc = SQLFetchScroll(@handle, orientation, offset)
+ rc = SQLFetch(@handle)
- return nil if rc == SQL_NO_DATA_FOUND
- raise "ERROR" unless rc == SQL_SUCCESS
-
- retval = []
+ if rc == SQL_NO_DATA_FOUND
+ #SQLCloseCursor(@handle)
+ SQLFreeStmt(@handle, SQL_CLOSE) #close cursor
+ return nil
+ end
+
+ raise "ERROR" unless rc == SQL_SUCCESS
+
+ retval = []
cols.each_with_index do |c, i|
- rc, content = SQLGetData(@handle, i+1, c[1], c[2])
+ rc, content = SQLGetData(@handle, i+1, c[1], c[2] + 1) #yun added 1 to c[2]
retval << content
- end
+ end
return retval
end
- alias :fetch :fetchRow
+ def fetch_as_hash
+ rc, nr_cols = SQLNumResultCols(@handle)
+
+ cols = (1..nr_cols).collect do |c|
+ rc, name, bl, type, col_sz = SQLDescribeCol(@handle, c, 1024)
+ [name, type, col_sz]
+ end
+
+ rc = SQLFetch(@handle)
+
+ if rc == SQL_NO_DATA_FOUND
+ #SQLCloseCursor(@handle)
+ SQLFreeStmt(@handle, SQL_CLOSE) #close cursor
+ SQLFreeStmt(@handle, SQL_RESET_PARAMS) #reset parameters
+ return nil
+ end
+
+ raise "ERROR" unless rc == SQL_SUCCESS
+
+ retval = {}
+ cols.each_with_index do |c, i|
+ rc, content = SQLGetData(@handle, i+1, c[1], c[2] + 1) #yun added 1 to c[2]
+ retval[c[0]] = content
+ end
+
+ return retval
+ end
end # class Statement
+ class Parameter
+ attr_reader :type, :size, :decimalDigits
+ def initialize(type, size, decimalDigits)
+ @type = type
+ @size = size
+ @decimalDigits = decimalDigits
+ end
+ end
end # module DB2
|
|
From: Michael N. <mne...@us...> - 2002-12-20 10:05:01
|
Update of /cvsroot/ruby-dbi/subprojects/ruby-db2/ext/db2
In directory sc8-pr-cvs1:/tmp/cvs-serv4329
Modified Files:
db2cli.c
Log Message:
added Songsu Yun's patch
Index: db2cli.c
===================================================================
RCS file: /cvsroot/ruby-dbi/subprojects/ruby-db2/ext/db2/db2cli.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- db2cli.c 5 Sep 2002 09:57:13 -0000 1.1
+++ db2cli.c 20 Dec 2002 10:04:58 -0000 1.2
@@ -1,13 +1,21 @@
/*
* IBM DB2 CLI 5.0 (Call Level Interface) Module for Ruby
*
- * file: db2cli.c
- * author: Michael Neumann (ne...@s-...)
- * id: $Id$
- *
- * Copyright (C) 2001 by Michael Neumann.
+ * File: db2cli.c
+ *
+ * Author: Michael Neumann (mne...@fa...)
[...973 lines suppressed...]
+ rb_define_module_function(mDB2CLI, "SQLColAttribute", db2_SQLColAttribute, 4);
+ rb_define_module_function(mDB2CLI, "SQLExecDirect", db2_SQLExecDirect, 2);
+ rb_define_module_function(mDB2CLI, "SQLExecute", db2_SQLExecute, 1);
+ rb_define_module_function(mDB2CLI, "SQLCloseCursor", db2_SQLCloseCursor, 1);
+ rb_define_module_function(mDB2CLI, "SQLFreeStmt", db2_SQLFreeStmt, 2);
+ rb_define_module_function(mDB2CLI, "SQLRowCount", db2_SQLRowCount, 1);
+ rb_define_module_function(mDB2CLI, "SQLFetch", db2_SQLFetch, 1);
+ rb_define_module_function(mDB2CLI, "SQLFetchScroll", db2_SQLFetchScroll, 3);
rb_define_module_function(mDB2CLI, "SQLGetData", db2_SQLGetData, -1); /* 3-4 */
rb_define_module_function(mDB2CLI, "SQLEndTran", db2_SQLEndTran, 3);
rb_define_module_function(mDB2CLI, "SQLGetDiagRec", db2_SQLGetDiagRec, 4);
rb_define_module_function(mDB2CLI, "SQLTables", db2_SQLTables, 5);
+ rb_define_module_function(mDB2CLI, "SQLBindParameter", db2_SQLBindParameter, 6);
+ rb_define_module_function(mDB2CLI, "SQLSetCursorName", db2_SQLSetCursorName, 2);
+ rb_define_module_function(mDB2CLI, "SQLGetCursorName", db2_SQLGetCursorName, 1);
/* Datatype classes or objects */
cDate = rb_eval_string("DB2CLI::Date");
|
|
From: Michael N. <mne...@us...> - 2002-10-28 11:18:55
|
Update of /cvsroot/ruby-dbi/src/build In directory usw-pr-cvs1:/tmp/cvs-serv5198 Modified Files: package.sh Log Message: # Removed the removing of empty dirs. Use cvs -P option (implicit) instead. Index: package.sh =================================================================== RCS file: /cvsroot/ruby-dbi/src/build/package.sh,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- package.sh 28 Oct 2002 11:05:48 -0000 1.4 +++ package.sh 28 Oct 2002 11:18:50 -0000 1.5 @@ -45,9 +45,6 @@ # remove all CVS directories find . -name "CVS" -print | xargs rm -rf -# remove all superfluous directories (that are empty but cannot removed from CVS) -rm -rf lib/dbi/doc - # upload HTML pages and CSS cd doc/html for i in *.html *.css ; |
|
From: Michael N. <mne...@us...> - 2002-10-28 11:05:51
|
Update of /cvsroot/ruby-dbi/src/build
In directory usw-pr-cvs1:/tmp/cvs-serv1759
Modified Files:
Makefile package.sh
Log Message:
*
Index: Makefile
===================================================================
RCS file: /cvsroot/ruby-dbi/src/build/Makefile,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Makefile 2 Oct 2002 18:49:30 -0000 1.3
+++ Makefile 28 Oct 2002 11:05:48 -0000 1.4
@@ -10,4 +10,4 @@
./create_html
clean:
- rm ../ChangeLog ../doc/html/ChangeLog.html ../doc/html/ToDo.html ../doc/html/DBD_SPEC.html ../doc/html/DBI_SPEC.html ../doc/html/index.html
+ rm -f ../ChangeLog ../doc/html/ChangeLog.html ../doc/html/ToDo.html ../doc/html/DBD_SPEC.html ../doc/html/DBI_SPEC.html ../doc/html/index.html
Index: package.sh
===================================================================
RCS file: /cvsroot/ruby-dbi/src/build/package.sh,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- package.sh 3 Oct 2002 10:21:19 -0000 1.3
+++ package.sh 28 Oct 2002 11:05:48 -0000 1.4
@@ -63,7 +63,7 @@
tar -cvzf ${FILE} ruby-dbi-all
# upload tar.gz
-echo "cd incoming\nbinary\nput ${FILE}\nbye\n" | ftp -a upload.sourceforge.net
+echo "cd incoming\nbinary\nput ${FILE}\nbye\n" | /usr/bin/ftp -a upload.sourceforge.net
dialog --msgbox "Now log into SourceForge Admin page and make a release. Release is named like '0.0.17'; platform independent, source .gz." 8 40
links http://www.sourceforge.net/account/login.php
|
|
From: Michael N. <mne...@us...> - 2002-10-25 17:35:24
|
Update of /cvsroot/ruby-dbi/src/lib/dbd_pg
In directory usw-pr-cvs1:/tmp/cvs-serv5573
Modified Files:
Pg.rb
Log Message:
rollback transactions on disconnect
Index: Pg.rb
===================================================================
RCS file: /cvsroot/ruby-dbi/src/lib/dbd_pg/Pg.rb,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- Pg.rb 22 Oct 2002 14:53:07 -0000 1.29
+++ Pg.rb 25 Oct 2002 12:48:37 -0000 1.30
@@ -114,7 +114,7 @@
def disconnect
if not @attr['AutoCommit'] and @in_transaction
- @connection.exec("COMMIT") # commit outstanding transactions
+ @connection.exec("ROLLBACK") # rollback outstanding transactions
end
@connection.close
end
|
|
From: Sean C. <se...@ch...> - 2002-10-22 17:13:25
|
> Modified Files:
> Pg.rb
> Log Message:
> reverted to old transaction handling schema; removed usage of SET AUTOCOMMIT TO ON|OFF.
Thank you.
> @@ -109,8 +113,8 @@
> # DBD Protocol -----------------------------------------------
>
> def disconnect
> - unless @attr['AutoCommit']
> - @connection.exec("ROLLBACK") # rollback outstanding transactions
> + if not @attr['AutoCommit'] and @in_transaction
> + @connection.exec("COMMIT") # commit outstanding transactions
> end
> @connection.close
> end
This is really troublesome. If you're in a transaction when you
disconnect, and haven't explicitly committed, then I think you should
rollback. This is what every other DB lib does, including psql. -sc
--
Sean Chittenden
|
|
From: Michael N. <mne...@us...> - 2002-10-22 15:28:19
|
Update of /cvsroot/ruby-dbi/src/build In directory usw-pr-cvs1:/tmp/cvs-serv11189 Modified Files: DBI-VERSIONS Log Message: * Index: DBI-VERSIONS =================================================================== RCS file: /cvsroot/ruby-dbi/src/build/DBI-VERSIONS,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- DBI-VERSIONS 3 Oct 2002 09:54:51 -0000 1.2 +++ DBI-VERSIONS 22 Oct 2002 15:28:15 -0000 1.3 @@ -1,4 +1,5 @@ # All times are in UCT +dbi-0-0-18 2002-10-22 23:00 UTC dbi-0-0-17 2002-10-03 10:00 UTC dbi-0-0-16 2002-07-03 20:10 UTC dbi-0-0-15 2002-05-21 21:59 UTC |
|
From: Michael N. <mne...@us...> - 2002-10-22 15:27:04
|
Update of /cvsroot/ruby-dbi/src/lib/dbi In directory usw-pr-cvs1:/tmp/cvs-serv9945 Modified Files: version.rb Log Message: Index: version.rb =================================================================== RCS file: /cvsroot/ruby-dbi/src/lib/dbi/version.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- version.rb 3 Oct 2002 09:53:13 -0000 1.3 +++ version.rb 22 Oct 2002 15:27:01 -0000 1.4 @@ -4,6 +4,6 @@ module DBI -VERSION = "0.0.17" +VERSION = "0.0.18" end |
|
From: Michael N. <mne...@us...> - 2002-10-22 15:25:42
|
Update of /cvsroot/ruby-dbi/src/doc In directory usw-pr-cvs1:/tmp/cvs-serv8489 Modified Files: index.rd Log Message: contributor added Index: index.rd =================================================================== RCS file: /cvsroot/ruby-dbi/src/doc/index.rd,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- index.rd 3 Oct 2002 09:33:35 -0000 1.25 +++ index.rd 22 Oct 2002 15:25:38 -0000 1.26 @@ -70,6 +70,8 @@ Column coercing patch for DBD Mysql. : Sean Chittenden Submitted several patches and helped with lots of comments; Co-owner of the project. +: MoonWolf + quote/escape_bytea patch for DBD Pg. == Database Drivers (DBDs) |
|
From: Michael N. <mne...@us...> - 2002-10-22 15:15:46
|
Update of /cvsroot/ruby-dbi/src/lib/dbi
In directory usw-pr-cvs1:/tmp/cvs-serv30931
Modified Files:
trace.rb
Log Message:
remove warnings
Index: trace.rb
===================================================================
RCS file: /cvsroot/ruby-dbi/src/lib/dbi/trace.rb,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- trace.rb 11 Jun 2001 12:58:18 -0000 1.2
+++ trace.rb 22 Oct 2002 15:15:43 -0000 1.3
@@ -28,6 +28,7 @@
class HandleTracer < AspectR::Aspect
def initialize(klass)
+ @never_wrap = /^__|^send$|^id$|^class$|^$ /
self.wrap(klass, :pre, :post, methods(klass))
end
|
|
From: Michael N. <mne...@us...> - 2002-10-22 15:06:08
|
Update of /cvsroot/ruby-dbi/src/lib/dbi
In directory usw-pr-cvs1:/tmp/cvs-serv21166
Modified Files:
dbi.rb
Log Message:
Driver URLs are now case-sensitive when in SAFE mode >= 1. This prevent a security error.
Index: dbi.rb
===================================================================
RCS file: /cvsroot/ruby-dbi/src/lib/dbi/dbi.rb,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- dbi.rb 1 Aug 2002 19:00:20 -0000 1.34
+++ dbi.rb 22 Oct 2002 15:06:04 -0000 1.35
@@ -439,18 +439,23 @@
found = @@driver_map.keys.find {|key| key.downcase == dc}
return found if found
- # try a quick load and then a caseless scan
- begin
+ if $SAFE >= 1
+ # case-sensitive in safe mode
require "#{DBD::DIR}/#{driver_name}/#{driver_name}"
- rescue LoadError
- $:.each do |dir|
- path = "#{dir}/#{DBD::DIR}"
- next unless FileTest.directory?(path)
- found = Dir.entries(path).find {|e| e.downcase == dc}
- next unless found
+ else
+ # try a quick load and then a caseless scan
+ begin
+ require "#{DBD::DIR}/#{driver_name}/#{driver_name}"
+ rescue LoadError
+ $:.each do |dir|
+ path = "#{dir}/#{DBD::DIR}"
+ next unless FileTest.directory?(path)
+ found = Dir.entries(path).find {|e| e.downcase == dc}
+ next unless found
- require "#{DBD::DIR}/#{found}/#{found}"
- break
+ require "#{DBD::DIR}/#{found}/#{found}"
+ break
+ end
end
end
@@ -466,7 +471,11 @@
return driver_name
end
rescue LoadError, NameError
- raise InterfaceError, "Could not load driver (#{$!.message})"
+ if $SAFE >= 1
+ raise InterfaceError, "Could not load driver (#{$!.message}). Note that in SAFE mode >= 1, driver URLs have to be case sensitive!"
+ else
+ raise InterfaceError, "Could not load driver (#{$!.message})"
+ end
end
def parse_url(driver_url)
|
|
From: Michael N. <mne...@us...> - 2002-10-22 14:53:11
|
Update of /cvsroot/ruby-dbi/src/lib/dbd_pg
In directory usw-pr-cvs1:/tmp/cvs-serv9172
Modified Files:
Pg.rb
Log Message:
reverted to old transaction handling schema; removed usage of SET AUTOCOMMIT TO ON|OFF.
Index: Pg.rb
===================================================================
RCS file: /cvsroot/ruby-dbi/src/lib/dbd_pg/Pg.rb,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- Pg.rb 22 Oct 2002 14:00:16 -0000 1.28
+++ Pg.rb 22 Oct 2002 14:53:07 -0000 1.29
@@ -102,6 +102,10 @@
@attr.each { |k,v| self[k] = v}
load_type_map
+
+ @in_transaction = false
+ self['AutoCommit'] = true # Postgres starts in unchained mode (AutoCommit=on) by default
+
rescue PGError => err
raise DBI::OperationalError.new(err.message)
end
@@ -109,8 +113,8 @@
# DBD Protocol -----------------------------------------------
def disconnect
- unless @attr['AutoCommit']
- @connection.exec("ROLLBACK") # rollback outstanding transactions
+ if not @attr['AutoCommit'] and @in_transaction
+ @connection.exec("COMMIT") # commit outstanding transactions
end
@connection.close
end
@@ -236,7 +240,6 @@
Statement.new(self, statement)
end
- # Note: 'AutoCommit' returns nil <=> Postgres' default mode
def [](attr)
case attr
when 'pg_client_encoding'
@@ -249,8 +252,18 @@
def []=(attr, value)
case attr
when 'AutoCommit'
- # TODO: Are outstanding transactions committed?
- @connection.exec("SET AUTOCOMMIT TO " + (value ? "ON" : "OFF"))
+ if @attr['AutoCommit'] != value then
+ if value # turn AutoCommit ON
+ if @in_transaction
+ # TODO: commit outstanding transactions?
+ @connection.exec("COMMIT")
+ @in_transaction = false
+ end
+ else # turn AutoCommit OFF
+ @in_transaction = false
+ end
+ end
+ # value is assigned below
when 'pg_client_encoding'
@connection.set_client_encoding(value)
else
@@ -264,13 +277,21 @@
end
def commit
- # TODO: what if in autocommit mode?
- @connection.exec("COMMIT")
+ if @in_transaction
+ @connection.exec("COMMIT")
+ @in_transaction = false
+ else
+ # TODO: Warn?
+ end
end
def rollback
- # TODO: what if in autocommit mode?
- @connection.exec("ROLLBACK")
+ if @in_transaction
+ @connection.exec("ROLLBACK")
+ @in_transaction = false
+ else
+ # TODO: Warn?
+ end
end
# Other Public Methods ---------------------------------------
@@ -282,6 +303,15 @@
@coerce.coerce(converter, obj)
end
+ def in_transaction?
+ @in_transaction
+ end
+
+ def start_transaction
+ @connection.exec("BEGIN")
+ @in_transaction = true
+ end
+
if PGconn.respond_to?(:quote)
def quote(value)
@@ -342,36 +372,63 @@
public
def __blob_import(file)
+ start_transaction unless @in_transaction
@connection.lo_import(file)
+ #if @attr['AutoCommit']
+ # @connection.exec("COMMIT")
+ # @in_transaction = false
+ #end
rescue PGError => err
raise DBI::DatabaseError.new(err.message)
end
def __blob_export(oid, file)
+ start_transaction unless @in_transaction
@connection.lo_export(oid.to_i, file)
+ #if @attr['AutoCommit']
+ # @connection.exec("COMMIT")
+ # @in_transaction = false
+ #end
rescue PGError => err
raise DBI::DatabaseError.new(err.message)
end
def __blob_create(mode=PGlarge::INV_READ)
+ start_transaction unless @in_transaction
@connection.lo_create(mode)
+ #if @attr['AutoCommit']
+ # @connection.exec("COMMIT")
+ # @in_transaction = false
+ #end
rescue PGError => err
raise DBI::DatabaseError.new(err.message)
end
def __blob_open(oid, mode=PGlarge::INV_READ)
+ start_transaction unless @in_transaction
@connection.lo_open(oid.to_i, mode)
+ #if @attr['AutoCommit']
+ # @connection.exec("COMMIT")
+ # @in_transaction = false
+ #end
rescue PGError => err
raise DBI::DatabaseError.new(err.message)
end
def __blob_unlink(oid)
+ start_transaction unless @in_transaction
@connection.lo_unlink(oid.to_i)
+ #if @attr['AutoCommit']
+ # @connection.exec("COMMIT")
+ # @in_transaction = false
+ #end
rescue PGError => err
raise DBI::DatabaseError.new(err.message)
end
def __blob_read(oid, length=nil)
+ # TODO: do we really nead an open transaction for reading?
+ start_transaction unless @in_transaction
blob = @connection.lo_open(oid.to_i, PGlarge::INV_READ)
blob.open
if length.nil?
@@ -444,6 +501,9 @@
boundsql = @prep_sql.bind(@bindvars)
+ if not SQL.query?(boundsql) and not @db['AutoCommit'] then
+ @db.start_transaction unless @db.in_transaction?
+ end
pg_result = @db.connection.exec(boundsql)
@result = Tuples.new(@db, pg_result)
|
|
From: Michael N. <mne...@us...> - 2002-10-22 14:00:21
|
Update of /cvsroot/ruby-dbi/src/lib/dbd_pg
In directory usw-pr-cvs1:/tmp/cvs-serv20317
Modified Files:
Pg.rb
Log Message:
Use PostgreSQL specific quoting function (PGconn.quote) instead of default if available.
Use PGconn.escape_bytea instead of own __escape_bytea function if available.
Index: Pg.rb
===================================================================
RCS file: /cvsroot/ruby-dbi/src/lib/dbd_pg/Pg.rb,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- Pg.rb 26 Sep 2002 13:40:32 -0000 1.27
+++ Pg.rb 22 Oct 2002 14:00:16 -0000 1.28
@@ -282,16 +282,32 @@
@coerce.coerce(converter, obj)
end
+ if PGconn.respond_to?(:quote)
+
+ def quote(value)
+ PGconn.quote(value) {|value|
+ case value
+ when DBI::Date, DBI::Time, DBI::Timestamp, ::Date, ::Time
+ "'#{value.to_s}'"
+ else
+ value.to_s
+ end
+ }
+ end
+
+ else
+
def quote(value)
- # TODO: new quote function of Pg driver
case value
when String
- "'#{ value.gsub(/\\/){ '\\\\' }.gsub(/'/){ '\\\'' } }'"
+ "'#{ value.gsub(/\\/){ '\\\\' }.gsub(/'/){ '\\\'' } }'"
else
- super
+ super
end
end
-
+
+ end
+
private # ----------------------------------------------------
@@ -369,7 +385,15 @@
raise DBI::DatabaseError.new(err.message)
end
- #
+ if PGconn.respond_to?(:escape_bytea)
+
+ def __encode_bytea(str)
+ PGconn.escape_bytea(str)
+ end
+
+ else
+
+ ##
# encodes a string as bytea value.
#
# for encoding rules see:
@@ -384,6 +408,8 @@
}
a.join("\\\\") # \ => \\
end
+
+ end
end # Database
|
|
From: Michael N. <mne...@us...> - 2002-10-03 10:27:12
|
Update of /cvsroot/ruby-dbi/maintaining In directory usw-pr-cvs1:/tmp/cvs-serv17648 Removed Files: DBI-VERSIONS Makefile USER cl2html.sh create_changelog.rb cvs2cl Log Message: moved into repository src/build --- DBI-VERSIONS DELETED --- --- Makefile DELETED --- --- USER DELETED --- --- cl2html.sh DELETED --- --- create_changelog.rb DELETED --- --- cvs2cl DELETED --- |
|
From: Michael N. <mne...@us...> - 2002-10-03 10:21:22
|
Update of /cvsroot/ruby-dbi/src/build
In directory usw-pr-cvs1:/tmp/cvs-serv15262
Modified Files:
package.sh
Log Message:
fixed bug
Index: package.sh
===================================================================
RCS file: /cvsroot/ruby-dbi/src/build/package.sh,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- package.sh 3 Oct 2002 09:52:02 -0000 1.2
+++ package.sh 3 Oct 2002 10:21:19 -0000 1.3
@@ -1,6 +1,6 @@
#!/bin/sh
-# works only for tags above 0.0.16
+# works only for tags above 0.0.17
export CVS_RSH=ssh
@@ -63,7 +63,7 @@
tar -cvzf ${FILE} ruby-dbi-all
# upload tar.gz
-echo "cd incoming\nbinary\nput ${FILE}\nbye\n" ftp -a upload.sourceforge.net
+echo "cd incoming\nbinary\nput ${FILE}\nbye\n" | ftp -a upload.sourceforge.net
dialog --msgbox "Now log into SourceForge Admin page and make a release. Release is named like '0.0.17'; platform independent, source .gz." 8 40
links http://www.sourceforge.net/account/login.php
|
|
From: Michael N. <mne...@us...> - 2002-10-03 09:54:55
|
Update of /cvsroot/ruby-dbi/src/build In directory usw-pr-cvs1:/tmp/cvs-serv2938 Modified Files: DBI-VERSIONS Log Message: Index: DBI-VERSIONS =================================================================== RCS file: /cvsroot/ruby-dbi/src/build/DBI-VERSIONS,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- DBI-VERSIONS 2 Oct 2002 18:04:09 -0000 1.1 +++ DBI-VERSIONS 3 Oct 2002 09:54:51 -0000 1.2 @@ -1,5 +1,5 @@ # All times are in UCT -dbi-0-0-17 +dbi-0-0-17 2002-10-03 10:00 UTC dbi-0-0-16 2002-07-03 20:10 UTC dbi-0-0-15 2002-05-21 21:59 UTC dbi-0-0-14 2002-05-14 18:16 UTC |
|
From: Michael N. <mne...@us...> - 2002-10-03 09:53:16
|
Update of /cvsroot/ruby-dbi/src/lib/dbi In directory usw-pr-cvs1:/tmp/cvs-serv2084 Modified Files: version.rb Log Message: new version Index: version.rb =================================================================== RCS file: /cvsroot/ruby-dbi/src/lib/dbi/version.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- version.rb 3 Jul 2002 20:09:04 -0000 1.2 +++ version.rb 3 Oct 2002 09:53:13 -0000 1.3 @@ -4,6 +4,6 @@ module DBI -VERSION = "0.0.16" +VERSION = "0.0.17" end |
|
From: Michael N. <mne...@us...> - 2002-10-03 09:52:05
|
Update of /cvsroot/ruby-dbi/src/build In directory usw-pr-cvs1:/tmp/cvs-serv1400 Modified Files: package.sh Log Message: Index: package.sh =================================================================== RCS file: /cvsroot/ruby-dbi/src/build/package.sh,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- package.sh 3 Oct 2002 09:49:48 -0000 1.1 +++ package.sh 3 Oct 2002 09:52:02 -0000 1.2 @@ -10,18 +10,22 @@ dialog --yesno "Modified lib/dbi/version.rb?" 8 40 if [ $? != 0 ]; then dialog --msgbox "Exiting! Please modify lib/dbi/version.rb appropriately, before trying again." 8 40 + rm -rf work/ exit 1 fi dialog --yesno "Added release date of new version in build/DBI-VERSIONS?" 8 40 if [ $? != 0 ]; then dialog --msgbox "Exiting! Please modify build/DBI-VERSIONS appropriately, before trying again." 8 40 + rm -rf work/ exit 1 fi + dialog --inputbox "Tagged repository (e.g. cvs tag dbi-0-0-17)? Enter tag (without preceeding 'dbi-') below or choose 'Cancel'" 12 40 "0-0-" 2> work/VERSION if [ $? != 0 ]; then dialog --msgbox "Exiting! Please tag repository, before trying again." 8 40 + rm -rf work/ exit 1 fi VERSION=`cat work/VERSION` |
|
From: Michael N. <mne...@us...> - 2002-10-03 09:49:51
|
Update of /cvsroot/ruby-dbi/src/build
In directory usw-pr-cvs1:/tmp/cvs-serv32549
Added Files:
package.sh
Log Message:
initial creation; handles all release steps
--- NEW FILE: package.sh ---
#!/bin/sh
# works only for tags above 0.0.16
export CVS_RSH=ssh
rm -rf work/
mkdir work
dialog --yesno "Modified lib/dbi/version.rb?" 8 40
if [ $? != 0 ]; then
dialog --msgbox "Exiting! Please modify lib/dbi/version.rb appropriately, before trying again." 8 40
exit 1
fi
dialog --yesno "Added release date of new version in build/DBI-VERSIONS?" 8 40
if [ $? != 0 ]; then
dialog --msgbox "Exiting! Please modify build/DBI-VERSIONS appropriately, before trying again." 8 40
exit 1
fi
dialog --inputbox "Tagged repository (e.g. cvs tag dbi-0-0-17)? Enter tag (without preceeding 'dbi-') below or choose 'Cancel'" 12 40 "0-0-" 2> work/VERSION
if [ $? != 0 ]; then
dialog --msgbox "Exiting! Please tag repository, before trying again." 8 40
exit 1
fi
VERSION=`cat work/VERSION`
DOT_VERSION=`sed -e 's/-/./g' work/VERSION`
TAG=dbi-${VERSION}
# checkout sources
cd work
cvs -z3 -d:ext:mne...@cv...:/cvsroot/ruby-dbi co -r ${TAG} src
cd src
# make documentation and ChangeLog
cd build
make all
cd ..
# remove all CVS directories
find . -name "CVS" -print | xargs rm -rf
# remove all superfluous directories (that are empty but cannot removed from CVS)
rm -rf lib/dbi/doc
# upload HTML pages and CSS
cd doc/html
for i in *.html *.css ;
do scp $i mne...@sh...:/home/groups/r/ru/ruby-dbi/htdocs/$i
done
cd ../..
# create tar.gz
FILE=ruby-dbi-all-${DOT_VERSION}.tar.gz
cd ..
mv src ruby-dbi-all
tar -cvzf ${FILE} ruby-dbi-all
# upload tar.gz
echo "cd incoming\nbinary\nput ${FILE}\nbye\n" ftp -a upload.sourceforge.net
dialog --msgbox "Now log into SourceForge Admin page and make a release. Release is named like '0.0.17'; platform independent, source .gz." 8 40
links http://www.sourceforge.net/account/login.php
dialog --msgbox "Finally, update the page at the RAA." 8 40
w3m "http://www.ruby-lang.org/en/raa-update.rhtml?name=Ruby%2FDBI"
# remove work
cd ..
rm -rf work
|
|
From: Michael N. <mne...@us...> - 2002-10-03 09:33:38
|
Update of /cvsroot/ruby-dbi/src/doc In directory usw-pr-cvs1:/tmp/cvs-serv17215 Modified Files: index.rd Log Message: Index: index.rd =================================================================== RCS file: /cvsroot/ruby-dbi/src/doc/index.rd,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- index.rd 26 Sep 2002 18:41:59 -0000 1.24 +++ index.rd 3 Oct 2002 09:33:35 -0000 1.25 @@ -68,6 +68,8 @@ contrib/dbrc : Brad Hilton Column coercing patch for DBD Mysql. +: Sean Chittenden + Submitted several patches and helped with lots of comments; Co-owner of the project. == Database Drivers (DBDs) |
|
From: Michael N. <mne...@us...> - 2002-10-02 18:56:43
|
Update of /cvsroot/ruby-dbi/src/doc In directory usw-pr-cvs1:/tmp/cvs-serv32429 Removed Files: create_html Log Message: removed --- create_html DELETED --- |
|
From: Michael N. <mne...@us...> - 2002-10-02 18:49:33
|
Update of /cvsroot/ruby-dbi/src/build
In directory usw-pr-cvs1:/tmp/cvs-serv29783
Modified Files:
Makefile cl2html.sh create_changelog.rb create_html
Log Message:
Index: Makefile
===================================================================
RCS file: /cvsroot/ruby-dbi/src/build/Makefile,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Makefile 2 Oct 2002 18:30:38 -0000 1.2
+++ Makefile 2 Oct 2002 18:49:30 -0000 1.3
@@ -1,13 +1,13 @@
-all: doc ChangeLog.html
-
-ChangeLog:
- ruby create_changelog.rb
+all: ChangeLog.html doc
ChangeLog.html: ChangeLog
./cl2html.sh
+ChangeLog:
+ ruby create_changelog.rb
+
doc:
./create_html
clean:
- rm ChangeLog ChangeLog.html
+ rm ../ChangeLog ../doc/html/ChangeLog.html ../doc/html/ToDo.html ../doc/html/DBD_SPEC.html ../doc/html/DBI_SPEC.html ../doc/html/index.html
Index: cl2html.sh
===================================================================
RCS file: /cvsroot/ruby-dbi/src/build/cl2html.sh,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- cl2html.sh 2 Oct 2002 18:04:09 -0000 1.1
+++ cl2html.sh 2 Oct 2002 18:49:30 -0000 1.2
@@ -2,4 +2,4 @@
VIM="/usr/local/bin/gvim -f"
-${VIM} +"syn on" +"set nonumber" +"run! syntax/2html.vim" +"w! ChangeLog.html" +"q!" +"q!" ChangeLog
+${VIM} +"syn on" +"set nonumber" +"run! syntax/2html.vim" +"w! ../doc/html/ChangeLog.html" +"q!" +"q!" ../ChangeLog
Index: create_changelog.rb
===================================================================
RCS file: /cvsroot/ruby-dbi/src/build/create_changelog.rb,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- create_changelog.rb 2 Oct 2002 18:04:09 -0000 1.1
+++ create_changelog.rb 2 Oct 2002 18:49:30 -0000 1.2
@@ -1,3 +1,5 @@
+#!/usr/bin/env ruby
+
require "date"
Dir.chdir ".." # This script should be executed from directory src/ (of ruby-dbi cvs repository)
Index: create_html
===================================================================
RCS file: /cvsroot/ruby-dbi/src/build/create_html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- create_html 2 Oct 2002 18:30:38 -0000 1.1
+++ create_html 2 Oct 2002 18:49:30 -0000 1.2
@@ -5,8 +5,8 @@
subst2="'$_.gsub!(/&<var>lt<\/var>;/, %q|<var><</var>|)'"
RD="rd2 -r rd/rd2html-lib --with-css=rubyStyle.css"
-$RD --html-title="ToDo List for DBI" ToDo | $RUBY "$subst" | $RUBY "$subst2" > ../doc/html/ToDo.html
-$RD --html-title="DBD Specification Version 0.1 (Draft)" DBD_SPEC | $RUBY "$subst" | $RUBY "$subst2" > ../doc/html/DBD_SPEC.html
-$RD --html-title="DBI Specification Version 0.5 (Draft)" DBI_SPEC | $RUBY "$subst" | $RUBY "$subst2" > ../doc/html/DBI_SPEC.html
-$RD --html-title="Homepage of Ruby's DBI" index.rd > ../doc/html/index.html
+$RD --html-title="ToDo List for DBI" ../doc/ToDo | $RUBY "$subst" | $RUBY "$subst2" > ../doc/html/ToDo.html
+$RD --html-title="DBD Specification Version 0.1 (Draft)" ../doc/DBD_SPEC | $RUBY "$subst" | $RUBY "$subst2" > ../doc/html/DBD_SPEC.html
+$RD --html-title="DBI Specification Version 0.5 (Draft)" ../doc/DBI_SPEC | $RUBY "$subst" | $RUBY "$subst2" > ../doc/html/DBI_SPEC.html
+$RD --html-title="Homepage of Ruby's DBI" ../doc/index.rd > ../doc/html/index.html
|
|
From: Michael N. <mne...@us...> - 2002-10-02 18:30:42
|
Update of /cvsroot/ruby-dbi/src/build In directory usw-pr-cvs1:/tmp/cvs-serv22570 Modified Files: Makefile Added Files: create_html Log Message: --- NEW FILE: create_html --- #!/bin/sh RUBY="/usr/bin/env ruby -p -e" subst="'$_.gsub!(/&<var>amp<\/var>;/, %q|<var>&</var>|)'" subst2="'$_.gsub!(/&<var>lt<\/var>;/, %q|<var><</var>|)'" RD="rd2 -r rd/rd2html-lib --with-css=rubyStyle.css" $RD --html-title="ToDo List for DBI" ToDo | $RUBY "$subst" | $RUBY "$subst2" > ../doc/html/ToDo.html $RD --html-title="DBD Specification Version 0.1 (Draft)" DBD_SPEC | $RUBY "$subst" | $RUBY "$subst2" > ../doc/html/DBD_SPEC.html $RD --html-title="DBI Specification Version 0.5 (Draft)" DBI_SPEC | $RUBY "$subst" | $RUBY "$subst2" > ../doc/html/DBI_SPEC.html $RD --html-title="Homepage of Ruby's DBI" index.rd > ../doc/html/index.html Index: Makefile =================================================================== RCS file: /cvsroot/ruby-dbi/src/build/Makefile,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Makefile 2 Oct 2002 18:04:09 -0000 1.1 +++ Makefile 2 Oct 2002 18:30:38 -0000 1.2 @@ -1,10 +1,13 @@ -all: ChangeLog.html +all: doc ChangeLog.html ChangeLog: ruby create_changelog.rb ChangeLog.html: ChangeLog ./cl2html.sh + +doc: + ./create_html clean: rm ChangeLog ChangeLog.html |
|
From: Michael N. <mne...@us...> - 2002-10-02 18:26:43
|
Update of /cvsroot/ruby-dbi/src/doc/html In directory usw-pr-cvs1:/tmp/cvs-serv21173 Removed Files: index.html Log Message: removed --- index.html DELETED --- |
|
From: Michael N. <mne...@us...> - 2002-10-02 18:10:40
|
Update of /cvsroot/ruby-dbi/src/doc
In directory usw-pr-cvs1:/tmp/cvs-serv15432
Added Files:
DBD_SPEC DBI_SPEC ToDo
Log Message:
moved from ../lib/dbi/doc
--- NEW FILE: DBD_SPEC ---
=begin
= DBD Specification Version 0.2.2 (Draft)
by Michael Neumann (ne...@s-...)
$Id: DBD_SPEC,v 1.1 2002/10/02 18:10:37 mneumann Exp $
== DBD Directory Layout
The directory layout is the following:
DBD/
DBD/Driver1
DBD/Driver1/Driver1.rb
DBD/Driver1/helper.rb
.
.
DBD/Driver2
.
.
.
Where "Driver1" and "Driver2" are the names of DBD driver.
For example if you have two drivers installed, "Oracle" and
"Sybase" it would look like:
DBD/
DBD/Oracle
DBD/Oracle/Oracle.rb # <== this is the main driver
DBD/Oracle/oracle.so # <== is used by Oracle.rb
DBD/Sybase/Sybase.so # <== this is the main driver
# has no helper files
When DBI loads a DBD driver it search all "DBD" directories in Ruby's
LOAD_PATH ($:).
Database dependent functions, that should be callable with DBI::func, must
use the prefix "__" before their method names, to prevent nameclashes with
further versions of Ruby/DBI!
== Driver Name
The DBD driver is simply named after the Database, e.g. Oracle, DB2 etc.
The suffix will normally be ".rb" but can be any other valid suffix,
which Ruby is possible to load, e.g. ".so", ".sl" or ".dll", and depends
for non-Ruby DBD driver on the underlying operating system.
When I refer to the driver name, then I speak of the filename without
the suffix, e.g. Oracle or DB2.
The name specified in the DSN ((-Data Source Name, e.g. "dbi:Oracle:oracle.neumann"-))
must be the same as the driver name.
== Classes provided by a DBD
A DBD driver has to provide three classes in the namespace
(({DBI::DBD::}))((*DriverName*)) where ((*DriverName*)) is the name of the
driver, e.g. Oracle or DB2.
The three classes must be named (({Driver})), (({Database})) and (({Statement})).
== Class Driver
This class must inherit from (({DBI::BaseDriver})).
=== Methods which must be provided by (({Driver}))
--- connect( dbname, user, auth, attr )
Connect to a database and return a newly created (({Database})) object.
=== Optional methods which can be specified by (({Driver}))
--- default_user
Return an array of the form (({['username', 'password']})) which represent
the default user when no user and password was specified.
Defaults to (({['', '']})) if not implemented.
--- default_attributes
Return a (({Hash})) containing the default attributes which are used
in (({connect})) additional to the ones the user specify.
Defaults to (({{}})) (empty hash) if not implemented.
--- data_sources
Return an array of all valid DSN this driver can access.
Defaults to (({[]})) (empty array) if not implemented.
--- disconnect_all
Disconnect all connections made with this driver.
Defaults to raise a NotImplementedError.
== Class Database
This class must inherit from (({DBI::BaseDatabase})).
=== Methods which must be provided by (({Database}))
--- disconnect
Disconnect from database.
But before you have to rollback all outstanding transactions, so
all changes not yet commited get lost.
--- prepare( statement )
Prepare the SQL ((*statement*)) and return an object of class (({Statement})).
--- ping
Ping the database, and check if the connection is alive.
This can be implemented by executing a SQL statement like
"SELECT 1 FROM DUAL" for Oracle database, or for other databases
this should be query on a table which normally always exists.
Return (({true})) if the connection is alive, otherwise (({false})).
=== Optional methods which can be specified by (({Database}))
--- commit
--- rollback
Commit or roll back the current transaction.
Defauls to raise a NotSupportedError, so if the database do not implement
transactions (mSQL, mySQL, CSV) do not overwrite this method.
--- tables
Return an Array of all tables and views.
Defaults to return the empty Array [].
--- columns( table )
Return more information about the columns of table ((*table*)).
Return an Array of Hashes, like Statement#column_info do.
Defaults to return an empty Array [].
--- execute( statement, *bindvars )
Immediate execution (without preparation) of SQL ((*statement*))
with binding of placeholders to values given in ((*bindvars*)) before.
Return a (({Statement})) object.
Defaults to the call sequence of Database#prepare(), Statement#bind_params() and
Statement#execute().
--- do( statement, *bindvars )
Execution of SQL ((*statement*)) with binding of placeholders to values given
in ((*bindvars*)) before, but without returning a (({Statement})) object.
So this is used for 'INSERT', 'UPDATE', 'DELETE' as well as for DCL, which
do not return a result-set.
Return the RPC (Row Processed Count) or (({nil})) if no RPC is available.
Defaults to Database#execute() and Statement#rows() followed by Statement#finish().
--- quote( value )
Quote the given value ((*value*)) database specific and return the result.
NOTE: This method is not really useful, because of Statement#bind_param.
--- []( attr )
Return value of attribute ((*attr*)).
Defauls to return the value of (({@attr[attr]})).
--- []=( attr, value )
Set value of attribute ((*attr*)) to ((*value*)).
An attribute is e.g. "AutoCommit".
Raise a NotSupportedError, if the database do not support an attribute.
The default implementation is to raise a NotSupportedError.
== Class Statement
This class must inherit from (({DBI::BaseStatement})).
=== Methods which must be provided by (({Statement}))
--- bind_param( param, value, attribs )
Bind ((|param|)) which is either a (({String})) which is then the name of the
placeholder used in the SQL statement (e.g. Oracle: "SELECT * FROM EMP WHERE ENAME = :ename")
or it is a (({Fixnum})) which is then the number of the placeholder where counting starts at 1.
((|value|)) is the value which is bound to the placeholder.
If ((|value|)) is a (({String})), then the default SQL type is (({VARCHAR})) or (({CHAR})).
If ((|value|)) is a (({Fixnum})) or (({Bignum})), the default SQL type is (({INT})).
If ((|value|)) is a (({Float})), the default SQL type is (({FLOAT})).
((*attribs*)) is not yet used in this version but could be a hash containing more information
like parameter type etc.
--- execute
Execute the statement.
--- finish
Free all the resources for the statement.
After calling (({finish})) no other operation on this
statement is valid.
--- fetch
Fetch the current row.
Return a (({Array})) containing all column-data or (({nil})) if
the last column has been read.
Note: This method should return not a newly created object on each call,
instead you should return one and the same Array object but with
changed data.
--- column_info
Return an (({Array})) of (({Hash}))'s, one for each column.
Each (({Hash})) object must have at least one key 'name' which
value is the name of that column.
Further possible values are 'sql_type' (integer, e.g. DBI::SQL_INT),
'type_name' (string), 'precision' (= column size), 'scale' (= decimal digits),
'default', 'nullable', 'indexed', 'primary' and 'unique'.
--- rows
Return the RPC (Row Processed Count) of the last executed statement, or
(({nil})) if no such exist.
=== Optional methods which can be specified by (({Statement}))
--- bind_params( *bindvars )
Binds the placeholders in the statement to the values of ((|bindvars|)).
Defaults to calling ((<bind_param>)) for each value, with ((*param*)) starting
from 1 increasingly.
--- cancel
Free any result set resources which were made after a call to (({execute})).
After calling this method, a call to one of the ((*fetch*)) methods is no more valid.
Defaults to do nothing.
--- fetch_scroll( direction, offset )
((*direction*)) is one of the following constants:
* SQL_FETCH_NEXT
* SQL_FETCH_PRIOR
* SQL_FETCH_FIRST
* SQL_FETCH_LAST
* SQL_FETCH_ABSOLUTE
* SQL_FETCH_RELATIVE
((*offset*)) is a positive or negativ number (only when SQL_FETCH_RELATIVE is used).
By default only SQL_FETCH_NEXT, SQL_FETCH_LAST, SQL_FETCH_RELATIVE (if positive) are
implemented, otherwise it raises NotSupportedError.
Note: This method should return not a newly created object on each call,
instead you should return one and the same Array object but with
changed data.
--- fetch_many( cnt )
Return an (({Array})) of the next ((*cnt*)) rows, where a row is itself an (({Array})).
Note: Unlike (({fetch})), this method should return a new Array object.
If there are no more ((*cnt*)) rows available return the rest.
Return (({nil})) if no rows are available.
Defaults to multiple calls to (({fetch})).
--- fetch_all
Return an (({Array})) of all rows which have not yet been fetched, where a row is
itself an (({Array})) (see Statement#fetch_many).
Note: Unlike (({fetch})), this method should return a new Array object.
Return (({nil})) if no rows are available.
Defaults to multiple calls to (({fetch})).
--- []( attr )
Return value of attribute ((*attr*)).
Defauls to return the value of (({@attr[attr]})).
--- []=( attr, value )
Set value of attribute ((*attr*)) to ((*value*)).
Raise a NotSupportedError, if the database do not support an attribute.
The default implementation is to raise a NotSupportedError.
=end
--- NEW FILE: DBI_SPEC ---
=begin
= DBI Interface Specification Version 0.2.2 (Draft)
by Michael Neumann (ne...@s-...)
$Id: DBI_SPEC,v 1.1 2002/10/02 18:10:37 mneumann Exp $
== Module DBD
=== Constants
--- API_VERSION
Use this in your DBD driver to ensure it is used with the correct DBD API-Version
== Module DBI
=== Constants
--- VERSION
Version of the DBI Interface
--- SQL_FETCH_NEXT
--- SQL_FETCH_PRIOR
--- SQL_FETCH_FIRST
--- SQL_FETCH_LAST
--- SQL_FETCH_ABSOLUTE
Constants for (({StatementHandle#fetch_scroll})).
--- SQL_BIT
--- SQL_TINYINT
--- SQL_SMALLINT
--- SQL_INTEGER
--- SQL_BIGINT
--- SQL_FLOAT
--- SQL_REAL
--- SQL_DOUBLE
--- SQL_NUMERIC
--- SQL_DECIMAL
--- SQL_CHAR
--- SQL_VARCHAR
--- SQL_LONGVARCHAR
--- SQL_DATE
--- SQL_TIME
--- SQL_TIMESTAMP
--- SQL_BINARY
--- SQL_VARBINARY
--- SQL_LONGVARBINARY
--- SQL_OTHER
Constant representing SQL types.
=== Exceptions
Exception classes were "borrowed" from Python API 2.0.
--- Warning < RuntimeError
For important warnings like data truncation etc.
--- Error < RuntimeError
Base class of all other error exceptions.
Use this to catch all errors.
--- InterfaceError < Error
Exception for errors related to the DBI interface rather
than the database itself.
--- NotImplementedError < InterfaceError
Exception raised if the DBD driver has not specified
a mandantory method (not in Python API 2.0).
--- DatabaseError < Error
Exception for errors related to the database.
Has three attributes ((|err|)), ((|errstr|)) and ((|state|)).
--- DataError < DatabaseError
Exception for errors due to problems with the processed
data like division by zero, numeric value out of range etc.
--- OperationalError < DatabaseError
Exception for errors related to the database's operation which
are not necessarily under the control of the programmer like
unexpected disconnect, datasource name not found, transaction
could not be processed, a memory allocation error occured during
processing etc.
--- IntegrityError < DatabaseError
Exception raised when the relational integrity of the database
is affected, e.g. a foreign key check fails
--- InternalError < DatabaseError
Exception raised when the database encounters an internal error,
e.g. the cursor is not valid anymore, the transaction is out of sync.
--- ProgrammingError < DatabaseError
Exception raised for programming errors, e.g. table not found
or already exists, syntax error in SQL statement, wrong number
of parameters specified, etc.
--- NotSupportedError < DatabaseError
Raised if e.g. commit() is called for a database which do not
support transactions.
=== Module functions
--- DBI.connect( driver_url, user=nil, auth=nil, params=nil )
Connect to the database specified by ((*driver_url*)), which may
look like "dbi:Oracle:oracle.neumann".
Returns an (({DBI::DatabaseHandle})) object, or if called with code-block,
calls this block with the new (({DBI::DatabaseHandle})) as parameter and
calls (({disconnect})) after calling the block if it was not yet disconnected by
the user.
--- DBI.available_drivers
Returns an (({Array})) of all available DBD driver.
The strings which represent a DBD driver are partial DSN's
(e.g. "dbi:Oracle:").
--- DBI.data_sources( driver )
Returns all available DSN's for the ((*driver*)), which
is a partial DSN (e.g. "dbi:Oracle:").
--- DBI.disconnect_all( driver=nil )
Disconnects all active connections of ((*driver*)) or
all drivers if ((*driver*)) is (({nil})).
--- DBI.trace(mode=nil, output=nil)
Set the trace mode for all following created Handles to these values.
If a parameter is (({nil})) the value is not changed.
((|mode|)) defaults to 2 if it is (({nil})), and ((|output|)) to (({STDERR})) if a value was not
set before.
For ((|mode|)) the values 0, 1, 2 or 3 are allowed.
Note: Tracing is only activated, if you load the module "dbi/trace", because tracing currently
depends on AspectR > 0.3.3.
== Class DBI::Handle
Abstract base class for all "Handles" (DriverHandle, DatabaseHandle, StatementHandle).
=== Instance Methods
--- func( function, *values )
Calls the driver specific extension function named by
((|function|)) with ((|values|)) as parameters.
--- trace(mode=nil, output=nil)
Set the trace mode for this handle as well as for all sub-handles (in the case of DriverHandle and
DatabaseHandle).
If a parameter is (({nil})) the value is not changed.
((|mode|)) defaults to 2 if it is (({nil})), and ((|output|)) to (({STDERR})) if a value was not
set before.
For ((|mode|)) the values 0, 1, 2 or 3 are allowed.
Note: Tracing is only activated, if you load the module "dbi/trace", because tracing currently
depends on AspectR > 0.3.3.
== Class DBI::DatabaseHandle
=== Superclass
--- DBI::Handle
=== Instance Methods
--- connected?
Returns (({true})) if the connection was not yet disconnected
by calling ((<disconnect>)), otherwise (({false})).
--- disconnect
Disconnects the connection.
--- prepare( stmt )
--- prepare( stmt ) {|statement_handle| aBlock}
Prepare the SQL statement ((|stmt|)) and return a
(({DBI::StatementHandle})) or if called with a code-block
calls the block with the handle as parameter and after that
calls (({#finish})) onto the handle to free all resources
--- execute( stmt, *bindvars )
--- execute( stmt, *bindvars ) {|statement_handle| aBlock}
Executes immediately the SQL statement ((*stmt*)) with binding
the placeholders with values given in ((*bindvars*)) before.
Returns a (({DBI::StatementHandle})) or if called with code-block
calls the block with the handle as parameter and after that
calls (({#finish})) onto the handle to free all resources.
--- do( stmt, *bindvars )
Same as ((<execute>)) only that no (({DBI::StatementHandle})) is
returned but the RPC (Row Processed Count).
--- select_one( stmt, *bindvars)
Executes the statement with binding the values to the parameters and returns the
first row as a reference to a Row object.
--- select_all( stmt, *bindvars)
Executes the statement with binding the values to the parameters and returns all
resulting rows.
If called as iterator the passed (({DBI::Row})) objects are only references.
--- tables
Returns a list of all tables and views.
--- columns( table )
Get more information about the columns of table ((|table|)).
Returns an array containing for each column one (({DBI::ColumnInfo})) object.
--- ping
Returns (({true})) if the connection is active, otherwise (({false})).
In contranst to ((<connected?>)), ((<ping>)) tests if the connection is
still active by executing some SQL or doing something else.
--- quote( value )
Quotes the given value ((*value*)) database specific and returns the result.
--- commit
Commits current transaction.
--- rollback
Rolls the current transaction back.
--- transaction {|database_handle| aBlock}
First commits the current transaction, then
executes the given block where the parameter is
the object itself (the database handle). If the
block raises an exception, then it rolls the transaction
back otherwise commits it.
--- [](attr)
--- []=(attr)
Sets or gets the attribute ((*attr*)).
An attribute can for example be "AutoCommit", which can be set to
(({true})) or (({false})). Attributes are database dependant.
== Class DBI::StatementHandle
=== Superclass
--- DBI::Handle
=== Mixins
--- Enumerable
=== Instance Methods
--- bind_param( param, value, attribs=nil )
Bind ((*param*)) which is either a (({String})) which is then the name of the
placeholder used in the SQL statement (e.g. Oracle: "SELECT * FROM EMP WHERE ENAME = :ename")
or it is an integer which is then the number of the placeholder where counting starts at 1.
((*value*)) is the value which is bound to the placeholder.
((*attribs*)) is not yet used in this version, but could later be a hash containing more information
like parameter type etc..
--- execute( *bindvars )
Execute the statement but before binds the placeholders with ((*bindvars*)).
--- finish
Frees the resources for the statement.
After calling ((<finish>)) no other operation on this
statement is valid.
--- cancel
Frees any result set resources which were made after a call
to (({execute})).
After calling this method, a call to one of the ((*fetch*)) methods
is no more valid.
--- column_names
Returns an (({Array})) of all column names.
--- column_info
Returns an (({Array})) containing fore each column one (({DBI::ColumnInfo})) object.
--- rows
Returns the RPC (Row Processed Count) of the last executed statement, or
(({nil})) if no such exist.
--- fetchable?
Returns true if you can fetch rows using fetch etc..
--- fetch
Returns a (({DBI::Row})) object, or (({nil})) if there are
no more rows to fetch.
When called as iterator, the block is called for each row
until no more row is available. Each row is passed to the
block as (({DBI::Row})) object.
Note that the returned or passed (({DBI::Row})) object is only a reference and
should be copied (dup) if it is store elsewhere.
--- each {|row| aBlock }
Same as ((<fetch>)) called as iterator.
--- fetch_array
Returns the current row as (({Array})) or nil if no more
row is available.
Can be also called as iterator.
--- fetch_hash
Returns the current row as (({Hash})) or nil if no more
row is available.
Can be also called as iterator.
--- fetch_many( cnt )
Returns an (({Array})) of the next ((*cnt*)) rows, which are
stored as (({DBI::Row})) objects.
Returns the empty array (({[]})) if there are no more rows.
--- fetch_all
Same as ((<fetch_many>)) only that all rows are returned.
--- fetch_scroll( direction, offset=1 )
((*direction*)) is one of the following constants:
* SQL_FETCH_NEXT
* SQL_FETCH_PRIOR
* SQL_FETCH_FIRST
* SQL_FETCH_LAST
* SQL_FETCH_ABSOLUTE
* SQL_FETCH_RELATIVE
((*offset*)) is a positive or negativ number (only when SQL_FETCH_RELATIVE is used).
((<fetch_scroll>)) do not automatically free the result set if no more rows are available
if e.g. you get the last row.
Returns a (({DBI::Row})) object, if not possible, returns (({nil})).
Note that the returned (({DBI::Row})) object is only a reference and
should be copied (dup) if it is stored elsewhere.
--- [](attr)
--- []=(attr)
Sets or gets the attribute ((*attr*)).
=end
--- NEW FILE: ToDo ---
=begin
= ToDo
* SQL statement parser like Perl's SQL::Statement
* LDAP DBD
* column_info: precision == column_size or == column_size - scale ???
* fetch_many callable as iterator
* make SQL::bind preparable (parse SQL statement before)
* columns / column_info with more DBDs (DB2, Oracle, Interbase, ODBC)
* Tainting
* table_info
* bind_param_inout
* type_info / type_info_all
* bind_col ?
* Rewrite DBI-dispatching in C?
* warn if commit/rollback and AutoCommit is on
* bind_out_param/bind_inout_param
* tracing/logging for DBDs by calling log(...)
* define exact behaviour of fetch_scroll
* define exact behaviour of exception classes
* do not pass *args paramters to DBD (it's harder for C-extensions to handle them)
* thead safety ?
* asynchronous execution
= Done
* version.rb; don't update everytime dbi.rb when version changes
* fetch_all should always return an array, as well as select_all etc., fetch_many always []
* get a Driver object, call methods on it
* blob_import etc. for DBD::Pg
* parameter markers in DB2
=end
|