teradata-cli 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d7a7d94a1cee28f0f0133744e9fa79df82fc8d11
4
- data.tar.gz: 8faec4003d79efbe6c84a8bd1ec47f90b3e0c7c2
3
+ metadata.gz: cbeb4f03192e75727273c03be15c6851fbeff13f
4
+ data.tar.gz: 12df4d4b28d4ae8a4c1dd2f79f44d95314294006
5
5
  SHA512:
6
- metadata.gz: 75f1ea62636b79a0e845091d7652e66b461e915393225bba37010f1fadbbfde41d71f266d94eb8bd77356beb86c7216651c08c63c6be1c0116ffa66c3e033ddb
7
- data.tar.gz: feefc9306ef18f93486c6d493291c2683995171bc5529494ee4c0e74f21d4c95af240968a819f6d377fb8b59de042f825c2477764c3716cb6deffa1dcf698878
6
+ metadata.gz: 10990b74d136b6efe3cca3a88df2959c3af15235f80390d5c15d62a17636ded6098d2769b512755d459f31502497ebcdbdd45100041d69cf0bfd7fb07d551b49
7
+ data.tar.gz: bc0649c40af5e20fb5029c7b2c806c58c107243d81aca892737507025686a93234f48e3dfce98cb80ba536dc8f54134ad3302a28af291bd55a49a4b838b1371a
data/examples/query.rb CHANGED
@@ -7,7 +7,7 @@
7
7
  # $ ruby example/query.rb 'SELECT * FROM x'
8
8
  #
9
9
 
10
- require 'teradata'
10
+ require 'teradata-cli'
11
11
  require 'logger'
12
12
  require 'pp'
13
13
 
@@ -26,7 +26,7 @@ end
26
26
  log = Logger.new($stderr)
27
27
  log.sev_threshold = $DEBUG ? Logger::DEBUG : Logger::INFO
28
28
 
29
- Teradata.connect(logon_string, :logger => log) {|conn|
29
+ TeradataCli.connect(logon_string, :logger => log) {|conn|
30
30
  conn.query(sql) {|result_sets|
31
31
  result_sets.each_result_set do |rs|
32
32
  pp rs
@@ -7,7 +7,7 @@
7
7
  # $ ruby example/show-queryband.rb
8
8
  #
9
9
 
10
- require 'teradata'
10
+ require 'teradata-cli'
11
11
 
12
12
  logon_string = ENV['LOGON_STRING']
13
13
  unless logon_string
@@ -15,7 +15,7 @@ unless logon_string
15
15
  exit 1
16
16
  end
17
17
 
18
- Teradata.connect(logon_string) {|conn|
18
+ TeradataCli.connect(logon_string) {|conn|
19
19
  conn.query("SELECT * FROM dbc.sessionInfo") {|rs|
20
20
  rs.each do |rec|
21
21
  user = rec[:UserName].strip
@@ -1,7 +1,7 @@
1
1
  require 'excel'
2
2
  require 'fileutils'
3
3
  require 'pp'
4
- require 'teradata'
4
+ require 'teradata-cli'
5
5
 
6
6
  def main
7
7
  logon_string, template, output = ARGV
@@ -44,7 +44,7 @@ def fill_sheet(sheet, logon_string)
44
44
  y = value_cell.row + 1
45
45
 
46
46
  # Execute SQL and fill cells by data
47
- Teradata.connect(logon_string) {|conn|
47
+ TeradataCli.connect(logon_string) {|conn|
48
48
  conn.query(sql) {|rs|
49
49
  rs.each do |rec|
50
50
  pp rec
@@ -1,5 +1,5 @@
1
- require 'teradata'
2
- Teradata.connect(ENV['LOGON_STRING']) {|conn|
1
+ require 'teradata-cli'
2
+ TeradataCli.connect(ENV['LOGON_STRING']) {|conn|
3
3
  conn.tables("tudemo").
4
4
  select {|table| /_bak$/ =~ table.name }.
5
5
  each {|table| conn.drop table }
@@ -1,5 +1,5 @@
1
- require 'teradata'
2
- Teradata.connect(ENV['LOGON_STRING']) {|conn|
1
+ require 'teradata-cli'
2
+ TeradataCli.connect(ENV['LOGON_STRING']) {|conn|
3
3
  conn.tables("tudemo").
4
4
  sort_by {|table| -table.size }.
5
5
  first(5).
@@ -1,8 +1,8 @@
1
1
  # $Id: bitdao.rb 184 2009-08-12 08:46:22Z aamine $
2
2
 
3
- require 'teradata'
3
+ require 'teradata-cli'
4
4
 
5
- module Teradata
5
+ module TeradataCli
6
6
  class Error
7
7
  include ::BitDAO::Error
8
8
  end
@@ -56,14 +56,14 @@ class BitDAO
56
56
  exec_sql "BEGIN TRANSACTION;"
57
57
  begin
58
58
  yield
59
- rescue Teradata::CLI::UserAbort => err
59
+ rescue TeradataCli::CLI::UserAbort => err
60
60
  aborting = true
61
61
  raise err
62
62
  ensure
63
63
  if $@
64
64
  begin
65
65
  abort unless aborting
66
- rescue Teradata::CLI::UserAbort # do not override original exception
66
+ rescue TeradataCli::CLI::UserAbort # do not override original exception
67
67
  end
68
68
  else
69
69
  exec_sql "END TRANSACTION;"
@@ -9,7 +9,7 @@ $KCODE = 'UTF-8' unless defined?(Encoding)
9
9
  $LOAD_PATH.push '.' unless $LOAD_PATH.include?('.')
10
10
 
11
11
  require 'tdwalker'
12
- require 'teradata'
12
+ require 'teradata-cli'
13
13
  require 'bitweb'
14
14
  require 'bitdao'
15
15
  require 'bitdao/teradata'
@@ -85,7 +85,7 @@ def request_handler
85
85
  TDWalker::Models.new(
86
86
  TDWalker::DAO.new(
87
87
  log,
88
- Teradata.connect(@logon_string)
88
+ TeradataCli.connect(@logon_string)
89
89
  )
90
90
  )
91
91
  )
data/examples/update.rb CHANGED
@@ -7,7 +7,7 @@
7
7
  # $ ruby example/update.rb 'CREATE TABLE x (x INTEGER)'
8
8
  #
9
9
 
10
- require 'teradata'
10
+ require 'teradata-cli'
11
11
  require 'logger'
12
12
  require 'pp'
13
13
 
@@ -26,6 +26,6 @@ end
26
26
  log = Logger.new($stderr)
27
27
  log.sev_threshold = $DEBUG ? Logger::DEBUG : Logger::INFO
28
28
 
29
- Teradata.connect(logon_string, :logger => log) {|conn|
29
+ TeradataCli.connect(logon_string, :logger => log) {|conn|
30
30
  pp conn.update(sql)
31
31
  }
@@ -341,7 +341,7 @@ Init_cli(void)
341
341
  {
342
342
  VALUE Teradata, Teradata_Error;
343
343
 
344
- Teradata = rb_define_module("Teradata");
344
+ Teradata = rb_define_module("TeradataCli");
345
345
  Teradata_Error = rb_const_get(Teradata, rb_intern("Error"));
346
346
 
347
347
  CLI = rb_define_class_under(Teradata, "CLI", rb_cObject);
@@ -4,7 +4,7 @@ def extconf_main
4
4
  $objs = %w(cli.o)
5
5
  dir_config 'cli'
6
6
  if have_library cliv2_libname
7
- create_makefile 'teradata/cli'
7
+ create_makefile 'teradata-cli/cli'
8
8
  end
9
9
  end
10
10
 
@@ -0,0 +1,57 @@
1
+ have_library: checking for main() in -lcliv2... -------------------- yes
2
+
3
+ "gcc -o conftest -I/home/jc34/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/i686-linux -I/home/jc34/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/ruby/backward -I/home/jc34/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0 -I. -D_FILE_OFFSET_BITS=64 -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -fPIC conftest.c -L. -L/home/jc34/.rvm/rubies/ruby-2.0.0-p247/lib -Wl,-R/home/jc34/.rvm/rubies/ruby-2.0.0-p247/lib -L. -fstack-protector -rdynamic -Wl,-export-dynamic '-Wl,-rpath,/../lib' -Wl,-R -Wl,/home/jc34/.rvm/rubies/ruby-2.0.0-p247/lib -L/home/jc34/.rvm/rubies/ruby-2.0.0-p247/lib -lruby -lpthread -lrt -ldl -lcrypt -lm -lc"
4
+ checked program was:
5
+ /* begin */
6
+ 1: #include "ruby.h"
7
+ 2:
8
+ 3: int main(int argc, char **argv)
9
+ 4: {
10
+ 5: return 0;
11
+ 6: }
12
+ /* end */
13
+
14
+ "gcc -o conftest -I/home/jc34/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/i686-linux -I/home/jc34/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/ruby/backward -I/home/jc34/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0 -I. -D_FILE_OFFSET_BITS=64 -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -fPIC conftest.c -L. -L/home/jc34/.rvm/rubies/ruby-2.0.0-p247/lib -Wl,-R/home/jc34/.rvm/rubies/ruby-2.0.0-p247/lib -L. -fstack-protector -rdynamic -Wl,-export-dynamic '-Wl,-rpath,/../lib' -Wl,-R -Wl,/home/jc34/.rvm/rubies/ruby-2.0.0-p247/lib -L/home/jc34/.rvm/rubies/ruby-2.0.0-p247/lib -lruby -lcliv2 -lpthread -lrt -ldl -lcrypt -lm -lc"
15
+ conftest.c: In function ‘t’:
16
+ conftest.c:5:57: error: ‘main’ undeclared (first use in this function)
17
+ conftest.c:5:57: note: each undeclared identifier is reported only once for each function it appears in
18
+ conftest.c:5:32: warning: variable ‘p’ set but not used [-Wunused-but-set-variable]
19
+ checked program was:
20
+ /* begin */
21
+ 1: #include "ruby.h"
22
+ 2:
23
+ 3: /*top*/
24
+ 4: extern int t(void);
25
+ 5: int t(void) { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
26
+ 6: int main(int argc, char **argv)
27
+ 7: {
28
+ 8: if (argc > 1000000) {
29
+ 9: printf("%p", &t);
30
+ 10: }
31
+ 11:
32
+ 12: return 0;
33
+ 13: }
34
+ /* end */
35
+
36
+ "gcc -o conftest -I/home/jc34/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/i686-linux -I/home/jc34/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/ruby/backward -I/home/jc34/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0 -I. -D_FILE_OFFSET_BITS=64 -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -fPIC conftest.c -L. -L/home/jc34/.rvm/rubies/ruby-2.0.0-p247/lib -Wl,-R/home/jc34/.rvm/rubies/ruby-2.0.0-p247/lib -L. -fstack-protector -rdynamic -Wl,-export-dynamic '-Wl,-rpath,/../lib' -Wl,-R -Wl,/home/jc34/.rvm/rubies/ruby-2.0.0-p247/lib -L/home/jc34/.rvm/rubies/ruby-2.0.0-p247/lib -lruby -lcliv2 -lpthread -lrt -ldl -lcrypt -lm -lc"
37
+ conftest.c: In function ‘t’:
38
+ conftest.c:5:1: warning: implicit declaration of function ‘main’ [-Wimplicit-function-declaration]
39
+ checked program was:
40
+ /* begin */
41
+ 1: #include "ruby.h"
42
+ 2:
43
+ 3: /*top*/
44
+ 4: extern int t(void);
45
+ 5: int t(void) { main(); return 0; }
46
+ 6: int main(int argc, char **argv)
47
+ 7: {
48
+ 8: if (argc > 1000000) {
49
+ 9: printf("%p", &t);
50
+ 10: }
51
+ 11:
52
+ 12: return 0;
53
+ 13: }
54
+ /* end */
55
+
56
+ --------------------
57
+
@@ -0,0 +1,4 @@
1
+ # cli.so requires Teradata::Error, load teradata/exception first.
2
+ require "teradata-cli/version"
3
+ require 'teradata-cli/exception'
4
+ require 'teradata-cli/cli.so'
@@ -8,13 +8,13 @@
8
8
  # the GNU LGPL2, Lesser General Public License version 2.
9
9
  #
10
10
 
11
- require 'teradata/cli'
12
- require 'teradata/utils'
13
- require 'teradata/exception'
11
+ require 'teradata-cli/cli'
12
+ require 'teradata-cli/utils'
13
+ require 'teradata-cli/exception'
14
14
  require 'forwardable'
15
15
  require 'stringio'
16
16
 
17
- module Teradata
17
+ module TeradataCli
18
18
 
19
19
  class ConnectionError < CLIError; end
20
20
  class MetaDataFormatError < CLIError; end
@@ -32,7 +32,7 @@ module Teradata
32
32
 
33
33
  class UserAbort < SQLError; end
34
34
 
35
- def Teradata.connect(*args, &block)
35
+ def TeradataCli.connect(*args, &block)
36
36
  Connection.open(*args, &block)
37
37
  end
38
38
 
@@ -43,15 +43,15 @@ module Teradata
43
43
  end
44
44
 
45
45
  def Connection.default_session_charset
46
- Teradata::SessionCharset.new('UTF8')
46
+ TeradataCli::SessionCharset.new('UTF8')
47
47
  end
48
48
 
49
49
  def initialize(logon_string, options = {})
50
50
  session_charset = options[:session_charset] || Connection.default_session_charset
51
51
  internal_encoding = options[:internal_encoding] || default_internal_encoding()
52
52
  @logger = options[:logger] || NullLogger.new
53
- @logon_string = Teradata::LogonString.intern(logon_string)
54
- @session_charset = Teradata::SessionCharset.intern(session_charset)
53
+ @logon_string = TeradataCli::LogonString.intern(logon_string)
54
+ @session_charset = TeradataCli::SessionCharset.intern(session_charset)
55
55
  @external_encoding = @session_charset.encoding
56
56
  @internal_encoding = internal_encoding
57
57
  ex = StringExtractor.get(@external_encoding, @internal_encoding)
@@ -265,7 +265,7 @@ module Teradata
265
265
  end
266
266
 
267
267
  def id_string
268
- "Teradata::Connection:#{'%x' % object_id}"
268
+ "TeradataCli::Connection:#{'%x' % object_id}"
269
269
  end
270
270
  end
271
271
 
@@ -400,11 +400,11 @@ module Teradata
400
400
  private
401
401
 
402
402
  def warn(&block)
403
- @logger.warn { "Teradata::CLI:#{'%x' % object_id}: #{yield}" }
403
+ @logger.warn { "TeradataCli::CLI:#{'%x' % object_id}: #{yield}" }
404
404
  end
405
405
 
406
406
  def debug(&block)
407
- @logger.debug { "Teradata::CLI:#{'%x' % object_id}: #{yield}" }
407
+ @logger.debug { "TeradataCli::CLI:#{'%x' % object_id}: #{yield}" }
408
408
  end
409
409
 
410
410
  end
@@ -8,11 +8,11 @@
8
8
  # the GNU LGPL2, Lesser General Public License version 2.
9
9
  #
10
10
 
11
- require 'teradata/utils'
12
- require 'teradata/connection'
13
- require 'teradata/exception'
11
+ require 'teradata-cli/utils'
12
+ require 'teradata-cli/connection'
13
+ require 'teradata-cli/exception'
14
14
 
15
- module Teradata
15
+ module TeradataCli
16
16
 
17
17
  class ObjectError < Error; end
18
18
 
@@ -161,7 +161,7 @@ module Teradata
161
161
  WHERE databaseName = #{sql_string database}
162
162
  GROUP BY tableName
163
163
  EndSQL
164
- c = ::Teradata::Table
164
+ c = ::TeradataCli::Table
165
165
  recs.map {|rec|
166
166
  name, curr, peak = *rec.to_a
167
167
  c.new(database, name, curr.to_i, peak.to_i)
@@ -169,7 +169,7 @@ module Teradata
169
169
  end
170
170
 
171
171
  def views(database)
172
- fetch_objects(database, ::Teradata::View)
172
+ fetch_objects(database, ::TeradataCli::View)
173
173
  end
174
174
 
175
175
  def fetch_objects(database, obj_class)
@@ -182,7 +182,7 @@ module Teradata
182
182
 
183
183
  def objects(database)
184
184
  entries("HELP DATABASE #{database}").map {|rec|
185
- ::Teradata::DBObject.create(rec[1].strip, database, rec[0].strip)
185
+ ::TeradataCli::DBObject.create(rec[1].strip, database, rec[0].strip)
186
186
  }
187
187
  end
188
188
 
@@ -8,7 +8,7 @@
8
8
  # the GNU LGPL2, Lesser General Public License version 2.
9
9
  #
10
10
 
11
- module Teradata
11
+ module TeradataCli
12
12
 
13
13
  class Error < StandardError; end
14
14
 
@@ -8,9 +8,9 @@
8
8
  # the GNU LGPL2, Lesser General Public License version 2.
9
9
  #
10
10
 
11
- require 'teradata/exception'
11
+ require 'teradata-cli/exception'
12
12
 
13
- module Teradata
13
+ module TeradataCli
14
14
 
15
15
  class BadLogonString < Error; end
16
16
 
@@ -0,0 +1,3 @@
1
+ module TeradataCli
2
+ VERSION = "0.0.3"
3
+ end
@@ -0,0 +1,14 @@
1
+ #
2
+ # $Id: teradata-cli.rb 7 2010-03-04 16:54:09Z tdaoki $
3
+ #
4
+ # Copyright (C) 2009,2010 teradata Japan, LTD.
5
+ #
6
+ # This program is free software.
7
+ # You can distribute/modify this program under the terms of
8
+ # the GNU LGPL2, Lesser General Public License version 2.
9
+ #
10
+
11
+ require 'teradata-cli/connection'
12
+ require 'teradata-cli/dbobject'
13
+ require 'teradata-cli/utils'
14
+ require 'teradata-cli/exception'
data/teradata-cli.gemspec CHANGED
@@ -1,11 +1,11 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'teradata/cli/version'
4
+ require 'teradata-cli/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "teradata-cli"
8
- spec.version = Teradata::Cli::VERSION
8
+ spec.version = TeradataCli::VERSION
9
9
  spec.authors = ["Giuseppe Privitera"]
10
10
  spec.email = ["priviterag@gmail.com"]
11
11
  spec.description = %q{ruby extension for Teradata Cliv2}
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.extensions = ["ext/teradata/cli/extconf.rb"]
18
+ spec.extensions = ["ext/teradata-cli/cli/extconf.rb"]
19
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
20
  spec.require_paths = ["lib"]
21
21
 
@@ -2,7 +2,7 @@ module RubyCLITestUtils
2
2
 
3
3
  def logon_string
4
4
  s = ENV['TEST_LOGON_STRING'] or raise ArgumentError, "environ TEST_LOGON_STRING not given"
5
- Teradata::LogonString.parse(s)
5
+ TeradataCli::LogonString.parse(s)
6
6
  end
7
7
 
8
8
  def playpen_string
@@ -26,7 +26,7 @@ module RubyCLITestUtils
26
26
  options[:session_charset] = charset if charset
27
27
  options[:internal_encoding] = internal if internal
28
28
  end
29
- Teradata::Connection.open(logon_string, options) {|conn|
29
+ TeradataCli::Connection.open(logon_string, options) {|conn|
30
30
  begin
31
31
  @conn = conn
32
32
  yield conn
@@ -72,7 +72,7 @@ module RubyCLITestUtils
72
72
 
73
73
  def drop_table_force(name, conn = @conn)
74
74
  drop_table name, conn
75
- rescue Teradata::SQLError => err
75
+ rescue TeradataCli::SQLError => err
76
76
  raise err unless err.code == ERR_OBJECT_NOT_EXIST
77
77
  end
78
78
 
@@ -1,4 +1,4 @@
1
- require 'teradata'
1
+ require 'teradata-cli'
2
2
  require 'test/unit'
3
3
  libdir = File.dirname(__FILE__)
4
4
  $LOAD_PATH.unshift libdir unless $LOAD_PATH.include?(libdir)
@@ -10,8 +10,8 @@ class Test_Connection < Test::Unit::TestCase
10
10
 
11
11
  def test_s_open
12
12
  begin
13
- conn = Teradata::Connection.open(logon_string)
14
- assert_instance_of Teradata::Connection, conn
13
+ conn = TeradataCli::Connection.open(logon_string)
14
+ assert_instance_of TeradataCli::Connection, conn
15
15
  assert_equal false, conn.closed?
16
16
  ensure
17
17
  begin
@@ -21,7 +21,7 @@ class Test_Connection < Test::Unit::TestCase
21
21
  assert_equal true, conn.closed?
22
22
  end
23
23
 
24
- Teradata::Connection.open(logon_string) {|c| assert_instance_of(Teradata::Connection, c); assert_equal(false, c.closed?)}
24
+ TeradataCli::Connection.open(logon_string) {|c| assert_instance_of(TeradataCli::Connection, c); assert_equal(false, c.closed?)}
25
25
  assert_equal true, conn.closed?
26
26
  end
27
27
 
@@ -29,7 +29,7 @@ class Test_Connection < Test::Unit::TestCase
29
29
  connect {
30
30
  drop_table_force "#{get_table_name('t')}"
31
31
  x = @conn.execute_update("CREATE TABLE #{get_table_name('t')} (x INTEGER);")
32
- assert_instance_of Teradata::ResultSet, x
32
+ assert_instance_of TeradataCli::ResultSet, x
33
33
  assert_equal true, x.closed?
34
34
  }
35
35
  end
@@ -47,7 +47,7 @@ class Test_Connection < Test::Unit::TestCase
47
47
  @conn.execute_update "BEGIN TRANSACTION;"
48
48
  @conn.execute_update "DELETE FROM #{name};"
49
49
  @conn.execute_update "ABORT;"
50
- rescue Teradata::UserAbort
50
+ rescue TeradataCli::UserAbort
51
51
  end
52
52
  recs = @conn.entries("SELECT * FROM #{name} ORDER BY 1;")
53
53
  assert_equal 2, recs.size
@@ -66,19 +66,19 @@ class Test_Connection < Test::Unit::TestCase
66
66
  def _test_single_rs(name, conn)
67
67
  buf = []
68
68
  conn.execute_query("SELECT * FROM #{name} ORDER BY 1") {|rs|
69
- assert_instance_of Teradata::ResultSet, rs
69
+ assert_instance_of TeradataCli::ResultSet, rs
70
70
  rs.each do |rec|
71
71
  buf.push rec
72
72
  end
73
73
  }
74
74
  assert_equal 3, buf.size
75
- assert_instance_of Teradata::Record, buf[0]
75
+ assert_instance_of TeradataCli::Record, buf[0]
76
76
  assert_equal 1, buf[0][:x]
77
77
  assert_equal 2, buf[0][:y]
78
- assert_instance_of Teradata::Record, buf[1]
78
+ assert_instance_of TeradataCli::Record, buf[1]
79
79
  assert_equal 3, buf[1][:x]
80
80
  assert_equal 4, buf[1][:y]
81
- assert_instance_of Teradata::Record, buf[2]
81
+ assert_instance_of TeradataCli::Record, buf[2]
82
82
  assert_equal 5, buf[2][:x]
83
83
  assert_equal 6, buf[2][:y]
84
84
  end
@@ -87,10 +87,10 @@ class Test_Connection < Test::Unit::TestCase
87
87
  buf = []
88
88
  num_rs = 0
89
89
  conn.execute_query("SELECT * FROM #{name} ORDER BY 1") {|sets|
90
- assert_instance_of Teradata::ResultSet, sets
90
+ assert_instance_of TeradataCli::ResultSet, sets
91
91
  sets.each_result_set do |rs|
92
92
  num_rs += 1
93
- assert_instance_of Teradata::ResultSet, rs
93
+ assert_instance_of TeradataCli::ResultSet, rs
94
94
  rs.each do |rec|
95
95
  buf.push rec
96
96
  end
@@ -99,7 +99,7 @@ class Test_Connection < Test::Unit::TestCase
99
99
  assert_equal 1, num_rs
100
100
  assert_equal 3, buf.size
101
101
  buf.each do |r|
102
- assert_instance_of Teradata::Record, r
102
+ assert_instance_of TeradataCli::Record, r
103
103
  end
104
104
  assert_equal [1,2], [buf[0][:x], buf[0][:y]]
105
105
  assert_equal [3,4], [buf[1][:x], buf[1][:y]]
@@ -112,10 +112,10 @@ class Test_Connection < Test::Unit::TestCase
112
112
  conn.execute_query(
113
113
  "SELECT * FROM #{name} ORDER BY 1;
114
114
  SELECT * FROM #{name} ORDER BY 1 DESC;") {|sets|
115
- assert_instance_of Teradata::ResultSet, sets
115
+ assert_instance_of TeradataCli::ResultSet, sets
116
116
  sets.each_result_set do |rs|
117
117
  num_rs += 1
118
- assert_instance_of Teradata::ResultSet, rs
118
+ assert_instance_of TeradataCli::ResultSet, rs
119
119
  rs.each do |rec|
120
120
  buf.push rec
121
121
  end
@@ -124,7 +124,7 @@ class Test_Connection < Test::Unit::TestCase
124
124
  assert_equal 2, num_rs
125
125
  assert_equal 6, buf.size
126
126
  buf.each do |r|
127
- assert_instance_of Teradata::Record, r
127
+ assert_instance_of TeradataCli::Record, r
128
128
  end
129
129
  assert_equal [1,2], [buf[0][:x], buf[0][:y]]
130
130
  assert_equal [3,4], [buf[1][:x], buf[1][:y]]
@@ -198,8 +198,8 @@ class Test_Connection < Test::Unit::TestCase
198
198
  using_test_table(get_table_name('t1')) {
199
199
  using_test_table(get_table_name('t2')) {
200
200
  list = @conn.tables(db)
201
- assert(list.include? Teradata::Table.new(db, 't1'))
202
- assert(list.include? Teradata::Table.new(db, 't2'))
201
+ assert(list.include? TeradataCli::Table.new(db, 't1'))
202
+ assert(list.include? TeradataCli::Table.new(db, 't2'))
203
203
  }}
204
204
  }
205
205
  end
@@ -208,7 +208,7 @@ class Test_Connection < Test::Unit::TestCase
208
208
  db = playpen_string
209
209
  using_test_table do
210
210
  using_view("#{get_table_name('v')}", 'select 1 as i') do
211
- assert(@conn.views(db).include? Teradata::View.new(db, 'v'))
211
+ assert(@conn.views(db).include? TeradataCli::View.new(db, 'v'))
212
212
  end
213
213
  end
214
214
  end
@@ -220,8 +220,8 @@ class Test_Connection < Test::Unit::TestCase
220
220
  using_test_table(get_table_name('t')) do
221
221
  using_view("#{get_table_name('v')}", 'select 1 as i') do
222
222
  objects = @conn.objects(db)
223
- assert(objects.include? Teradata::Table.new(db, 't'))
224
- assert(objects.include? Teradata::View.new(db, 'v'))
223
+ assert(objects.include? TeradataCli::Table.new(db, 't'))
224
+ assert(objects.include? TeradataCli::View.new(db, 'v'))
225
225
  end
226
226
  end
227
227
  end
@@ -239,13 +239,13 @@ class Test_Connection < Test::Unit::TestCase
239
239
 
240
240
  def drop_view_force(name, conn = @conn)
241
241
  conn.execute_update "DROP VIEW #{name}"
242
- rescue Teradata::SQLError
242
+ rescue TeradataCli::SQLError
243
243
  end
244
244
 
245
245
  def test_info
246
246
  connect {
247
247
  info = @conn.info
248
- assert_instance_of Teradata::SessionInfo, info
248
+ assert_instance_of TeradataCli::SessionInfo, info
249
249
  assert_equal logon_string.user.downcase, info.user_name.downcase
250
250
  }
251
251
  end
@@ -253,8 +253,8 @@ class Test_Connection < Test::Unit::TestCase
253
253
  def test_column
254
254
  db = playpen_string
255
255
  using_table("#{get_table_name('t')}", "x INTEGER, y INTEGER") do
256
- col = @conn.column(Teradata::Table.new(db, 't'), 'x')
257
- assert_instance_of Teradata::Column, col
256
+ col = @conn.column(TeradataCli::Table.new(db, 't'), 'x')
257
+ assert_instance_of TeradataCli::Column, col
258
258
  assert_equal 'x', col.column_name.strip.downcase
259
259
  end
260
260
  end
@@ -274,7 +274,7 @@ class Test_Connection < Test::Unit::TestCase
274
274
  assert_equal n_records, count(table, conn)
275
275
 
276
276
  # transaction fails #2
277
- assert_raise(Teradata::UserAbort) {
277
+ assert_raise(TeradataCli::UserAbort) {
278
278
  conn.transaction {
279
279
  conn.query "DELETE FROM #{table}"
280
280
  conn.abort
@@ -1,4 +1,4 @@
1
- require 'teradata'
1
+ require 'teradata-cli'
2
2
  require 'test/unit'
3
3
  libdir = File.dirname(__FILE__)
4
4
  $LOAD_PATH.unshift libdir unless $LOAD_PATH.include?(libdir)
@@ -9,99 +9,99 @@ class Test_Teradata_DBObject < Test::Unit::TestCase
9
9
  include RubyCLITestUtils
10
10
 
11
11
  def test_s_intern_string
12
- t = Teradata::Table.intern('db.tab')
13
- assert_instance_of Teradata::Table, t
12
+ t = TeradataCli::Table.intern('db.tab')
13
+ assert_instance_of TeradataCli::Table, t
14
14
  assert_equal 'db.tab', t.name
15
15
  end
16
16
 
17
17
  def test_s_intern_class
18
- t0 = Teradata::Table.new('db', 'tab')
19
- t = Teradata::Table.intern(t0)
20
- assert_instance_of Teradata::Table, t
18
+ t0 = TeradataCli::Table.new('db', 'tab')
19
+ t = TeradataCli::Table.intern(t0)
20
+ assert_instance_of TeradataCli::Table, t
21
21
  assert_equal t0, t
22
22
  assert_equal 'db.tab', t.name
23
23
  end
24
24
 
25
25
  def test_names_qualified
26
- t = Teradata::Table.new('bwtest', 'tab')
26
+ t = TeradataCli::Table.new('bwtest', 'tab')
27
27
  assert_equal 'bwtest', t.database
28
28
  assert_equal 'bwtest.tab', t.name
29
29
  assert_equal 'tab', t.unqualified_name
30
30
  end
31
31
 
32
32
  def test_names_unqualified
33
- t = Teradata::Table.new('tab')
33
+ t = TeradataCli::Table.new('tab')
34
34
  assert_nil t.database
35
35
  assert_equal 'tab', t.name
36
36
  assert_equal 'tab', t.unqualified_name
37
37
  end
38
38
 
39
39
  def test_to_s
40
- assert_equal 'db.tab', Teradata::Table.new('db', 'tab').to_s
41
- assert_equal 'bwtest.tab', Teradata::Table.new('bwtest', 'tab').to_s
42
- assert_equal 'tab', Teradata::Table.new('tab').to_s
40
+ assert_equal 'db.tab', TeradataCli::Table.new('db', 'tab').to_s
41
+ assert_equal 'bwtest.tab', TeradataCli::Table.new('bwtest', 'tab').to_s
42
+ assert_equal 'tab', TeradataCli::Table.new('tab').to_s
43
43
  end
44
44
 
45
45
  def test_EQ
46
- a = Teradata::Table.new('db', 'tab')
47
- b = Teradata::Table.new('db', 'tab')
46
+ a = TeradataCli::Table.new('db', 'tab')
47
+ b = TeradataCli::Table.new('db', 'tab')
48
48
  assert_equal a, a
49
49
  assert_equal a, b
50
50
  assert_equal b, a
51
51
 
52
52
  # object name is different
53
- c = Teradata::Table.new('db', 'other')
53
+ c = TeradataCli::Table.new('db', 'other')
54
54
  assert_not_equal a, c
55
55
  assert_not_equal c, a
56
56
 
57
57
  # database name is different
58
- d = Teradata::Table.new('other', 'tab')
58
+ d = TeradataCli::Table.new('other', 'tab')
59
59
  assert_not_equal a, d
60
60
  assert_not_equal d, a
61
61
 
62
62
  # database name is missing
63
- e = Teradata::Table.new('tab')
63
+ e = TeradataCli::Table.new('tab')
64
64
  assert_not_equal a, e
65
65
  assert_not_equal e, a
66
66
 
67
67
  # same name, but different type
68
- v = Teradata::View.new('db', 'tab')
68
+ v = TeradataCli::View.new('db', 'tab')
69
69
  assert_not_equal a, v
70
70
  assert_not_equal v, a
71
71
  end
72
72
 
73
73
  def test_type_char
74
- assert_equal 'T', Teradata::Table.type_char
75
- assert_equal 'V', Teradata::View.type_char
76
- assert_equal 'M', Teradata::Macro.type_char
77
- assert_equal 'N', Teradata::HashIndex.type_char
74
+ assert_equal 'T', TeradataCli::Table.type_char
75
+ assert_equal 'V', TeradataCli::View.type_char
76
+ assert_equal 'M', TeradataCli::Macro.type_char
77
+ assert_equal 'N', TeradataCli::HashIndex.type_char
78
78
  end
79
79
 
80
80
  def test_type_name
81
- assert_equal 'TABLE', Teradata::Table.type_name
82
- assert_equal 'VIEW', Teradata::View.type_name
83
- assert_equal 'MACRO', Teradata::Macro.type_name
84
- assert_equal 'JOIN INDEX', Teradata::JoinIndex.type_name
85
- assert_equal 'HASH INDEX', Teradata::HashIndex.type_name
86
- assert_equal 'PROCEDURE', Teradata::Procedure.type_name
81
+ assert_equal 'TABLE', TeradataCli::Table.type_name
82
+ assert_equal 'VIEW', TeradataCli::View.type_name
83
+ assert_equal 'MACRO', TeradataCli::Macro.type_name
84
+ assert_equal 'JOIN INDEX', TeradataCli::JoinIndex.type_name
85
+ assert_equal 'HASH INDEX', TeradataCli::HashIndex.type_name
86
+ assert_equal 'PROCEDURE', TeradataCli::Procedure.type_name
87
87
  end
88
88
 
89
89
  def test_table_size
90
- t = Teradata::Table.new('db', 'tbl', 17, 39)
90
+ t = TeradataCli::Table.new('db', 'tbl', 17, 39)
91
91
  assert_equal 17, t.size
92
92
  assert_equal 17, t.current_perm
93
93
  assert_equal 39, t.peak_perm
94
94
  end
95
95
 
96
96
  def test_table_no_peak
97
- t = Teradata::Table.new('db', 'tbl', 17)
97
+ t = TeradataCli::Table.new('db', 'tbl', 17)
98
98
  assert_equal 17, t.size
99
99
  assert_equal 17, t.current_perm
100
100
  assert_nil t.peak_perm
101
101
  end
102
102
 
103
103
  def test_table_size_none
104
- t = Teradata::Table.new('db', 'tbl')
104
+ t = TeradataCli::Table.new('db', 'tbl')
105
105
  assert_nil t.size
106
106
  assert_nil t.current_perm
107
107
  assert_nil t.peak_perm
@@ -110,8 +110,8 @@ class Test_Teradata_DBObject < Test::Unit::TestCase
110
110
  def test_root_database
111
111
  connect {|conn|
112
112
  dbc = conn.root_database
113
- assert_kind_of Teradata::Database, dbc
114
- assert_instance_of Teradata::User, dbc
113
+ assert_kind_of TeradataCli::Database, dbc
114
+ assert_instance_of TeradataCli::User, dbc
115
115
  assert_equal 'dbc', dbc.name.downcase
116
116
  assert_equal true, dbc.user?
117
117
  }
@@ -120,7 +120,7 @@ class Test_Teradata_DBObject < Test::Unit::TestCase
120
120
  def test_database
121
121
  connect {|conn|
122
122
  dbc = conn.database('dbc')
123
- assert_instance_of Teradata::User, dbc
123
+ assert_instance_of TeradataCli::User, dbc
124
124
  assert_equal 'dbc', dbc.name.downcase
125
125
  assert_equal true, dbc.user?
126
126
  }
@@ -134,19 +134,19 @@ class Test_Teradata_DBObject < Test::Unit::TestCase
134
134
 
135
135
  cs = dbc.children
136
136
  assert_equal true, (cs.size > 0)
137
- assert_kind_of Teradata::Database, cs.first
138
- assert_kind_of Teradata::Database, cs.first.owner
137
+ assert_kind_of TeradataCli::Database, cs.first
138
+ assert_kind_of TeradataCli::Database, cs.first.owner
139
139
  assert_equal 'dbc', cs.first.owner.name.downcase
140
140
 
141
141
  sysdba = cs.detect {|c| c.name.downcase == 'sysdba' }
142
- assert_instance_of Teradata::User, sysdba
142
+ assert_instance_of TeradataCli::User, sysdba
143
143
  assert_equal true, sysdba.user?
144
- assert_instance_of Teradata::User, sysdba.parent
144
+ assert_instance_of TeradataCli::User, sysdba.parent
145
145
 
146
146
  syslib = cs.detect {|c| c.name.downcase == 'syslib' }
147
- assert_instance_of Teradata::Database, syslib
147
+ assert_instance_of TeradataCli::Database, syslib
148
148
  assert_equal false, syslib.user?
149
- assert_instance_of Teradata::User, syslib.parent
149
+ assert_instance_of TeradataCli::User, syslib.parent
150
150
  }
151
151
  end
152
152
 
data/test/test_record.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'teradata'
1
+ require 'teradata-cli'
2
2
  require 'test/unit'
3
3
  libdir = File.dirname(__FILE__)
4
4
  $LOAD_PATH.unshift libdir unless $LOAD_PATH.include?(libdir)
@@ -55,7 +55,7 @@ class Test_Record < Test::Unit::TestCase
55
55
  }
56
56
  end
57
57
 
58
- # TODO Teradata::CLIError: CLI error: [EM_227] MTDP: EM_CHARNAME(227): invalid character set name specified.
58
+ # TODO TeradataCli::CLIError: CLI error: [EM_227] MTDP: EM_CHARNAME(227): invalid character set name specified.
59
59
  #def test_session_charset_EUC
60
60
  # connect('KANJIEUC_0U') {
61
61
  # using_table(get_table_name('strs'), 'c CHAR(1) CHARACTER SET UNICODE, vc VARCHAR(1) CHARACTER SET UNICODE') {|name|
@@ -68,7 +68,7 @@ class Test_Record < Test::Unit::TestCase
68
68
  # }
69
69
  #end
70
70
 
71
- # TODO Teradata::CLIError: CLI error: [EM_227] MTDP: EM_CHARNAME(227): invalid character set name specified.
71
+ # TODO TeradataCli::CLIError: CLI error: [EM_227] MTDP: EM_CHARNAME(227): invalid character set name specified.
72
72
  #def test_session_charset_SJIS
73
73
  # connect('KANJISJIS_0S') {
74
74
  # using_table(get_table_name('strs'), 'c CHAR(1) CHARACTER SET UNICODE, vc VARCHAR(1) CHARACTER SET UNICODE') {|name|
@@ -170,9 +170,9 @@ class Test_Record < Test::Unit::TestCase
170
170
  insert name, '1,2,NULL'
171
171
  rec = select(name).first
172
172
  assert_equal 3, rec.size
173
- assert_instance_of Teradata::Field, rec.field(:x)
174
- assert_instance_of Teradata::Field, rec.field(:y)
175
- assert_instance_of Teradata::Field, rec.field(:z)
173
+ assert_instance_of TeradataCli::Field, rec.field(:x)
174
+ assert_instance_of TeradataCli::Field, rec.field(:y)
175
+ assert_instance_of TeradataCli::Field, rec.field(:z)
176
176
  assert_equal 1, rec.field(:x).value
177
177
  assert_equal 2, rec.field(:y).value
178
178
  assert_equal nil, rec.field(:z).value
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teradata-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Giuseppe Privitera
@@ -43,7 +43,7 @@ email:
43
43
  - priviterag@gmail.com
44
44
  executables: []
45
45
  extensions:
46
- - ext/teradata/cli/extconf.rb
46
+ - ext/teradata-cli/cli/extconf.rb
47
47
  extra_rdoc_files: []
48
48
  files:
49
49
  - .gitignore
@@ -68,15 +68,16 @@ files:
68
68
  - examples/tu/web/template/footer
69
69
  - examples/tu/web/template/header
70
70
  - examples/update.rb
71
- - ext/teradata/cli/cli.c
72
- - ext/teradata/cli/extconf.rb
73
- - lib/teradata.rb
74
- - lib/teradata/cli.rb
75
- - lib/teradata/cli/version.rb
76
- - lib/teradata/connection.rb
77
- - lib/teradata/dbobject.rb
78
- - lib/teradata/exception.rb
79
- - lib/teradata/utils.rb
71
+ - ext/teradata-cli/cli/cli.c
72
+ - ext/teradata-cli/cli/extconf.rb
73
+ - ext/teradata-cli/cli/mkmf.log
74
+ - lib/teradata-cli.rb
75
+ - lib/teradata-cli/cli.rb
76
+ - lib/teradata-cli/connection.rb
77
+ - lib/teradata-cli/dbobject.rb
78
+ - lib/teradata-cli/exception.rb
79
+ - lib/teradata-cli/utils.rb
80
+ - lib/teradata-cli/version.rb
80
81
  - teradata-cli.gemspec
81
82
  - test/all
82
83
  - test/rubyclitestutils.rb
@@ -1,5 +0,0 @@
1
- module Teradata
2
- module Cli
3
- VERSION = "0.0.1"
4
- end
5
- end
data/lib/teradata/cli.rb DELETED
@@ -1,4 +0,0 @@
1
- # cli.so requires Teradata::Error, load teradata/exception first.
2
- require "teradata/cli/version"
3
- require 'teradata/exception'
4
- require 'teradata/cli.so'
data/lib/teradata.rb DELETED
@@ -1,14 +0,0 @@
1
- #
2
- # $Id: teradata.rb 7 2010-03-04 16:54:09Z tdaoki $
3
- #
4
- # Copyright (C) 2009,2010 Teradata Japan, LTD.
5
- #
6
- # This program is free software.
7
- # You can distribute/modify this program under the terms of
8
- # the GNU LGPL2, Lesser General Public License version 2.
9
- #
10
-
11
- require 'teradata/connection'
12
- require 'teradata/dbobject'
13
- require 'teradata/utils'
14
- require 'teradata/exception'