Below is the file 'debian/patches/demo_warnings.patch' from this revision. You can also download the file.
Fix compiler warnings in demo code.
Improve odbc demo output format.
Improve sqlite3 demo.
Index: gnade-1.6.2/samples/odbc/demo.gpb
===================================================================
--- gnade-1.6.2.orig/samples/odbc/demo.gpb 2009-10-05 02:20:57.000000000 -0400
+++ gnade-1.6.2/samples/odbc/demo.gpb 2009-10-05 02:21:00.000000000 -0400
@@ -37,7 +37,6 @@
with Ada.Command_Line;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Ada.Text_IO; use Ada.Text_IO;
-with Ada.Exceptions; use Ada.Exceptions;
with GNU.DB.SQLCLI; use GNU.DB.SQLCLI;
with GNU.DB.SQLCLI.Bind;
@@ -72,9 +71,9 @@
EnvironmentHandle : SQLHENV;
ConnectionHandle : SQLHDBC;
- ServerName : String := String'($DBSOURCE);
- UserName : String := String'($DBUSER);
- Authentication : String := String'($DBPASSWD);
+ ServerName : constant String := String'($DBSOURCE);
+ UserName : constant String := String'($DBUSER);
+ Authentication : constant String := String'($DBPASSWD);
Quoting_Character : Character := Character'Val (34);
@@ -178,7 +177,9 @@
end if;
if Do_All or else Do_Dump_Sources then
+ Header ("ODBC Data Sources");
Dump_Sources;
+ Header;
end if;
SQLAllocHandle (SQL_HANDLE_DBC, EnvironmentHandle, ConnectionHandle);
@@ -285,7 +286,7 @@
SQLFreeHandle (SQL_HANDLE_ENV, EnvironmentHandle);
#if addr2lines'Defined then
-
+
exception
when Event : others =>
declare
Index: gnade-1.6.2/samples/sample_db/gnade.mysql.sql
===================================================================
--- gnade-1.6.2.orig/samples/sample_db/gnade.mysql.sql 2009-10-05 02:20:57.000000000 -0400
+++ gnade-1.6.2/samples/sample_db/gnade.mysql.sql 2009-10-05 03:07:58.000000000 -0400
@@ -4,7 +4,7 @@
-- --
-- Filename : $Source: /cvsroot/gnade/gnade/samples/sample_db/gnade.mysql.sql,v $
-- Description : Makefile for the PostgreSQL sample database
--- Author : Michael Erdmann <michael.erdmann@snafu.de>
+-- Author : Michael Erdmann <michael.erdmann@snafu.de>
-- Created On : 02-April-2001
-- Last Modified By: $Author: merdmann $
-- Last Modified On: $Date: 2002/01/23 20:07:01 $
@@ -38,23 +38,24 @@
-- GNADE is implemented to work with GNAT, the GNU Ada compiler. --
-- --
-- ----------------------------------------------------------------------------
--- Functional Description
--- ======================
--- This SQL Script generates the test data base as it is used by
--- the code in the ./samples directory. The demo user has username="gnade"
--- and password="gnade".
---
---
--- Restrictions
--- ============
+-- Functional Description
+-- ======================
+-- This SQL Script generates the test data base as it is used by
+-- the code in the ./samples directory. The demo user has username="gnade"
+-- and password="gnade".
+--
+--
+-- Restrictions
+-- ============
-- This script is intended for use with MySQL.
---
--- References
--- ==========
---
+--
+-- References
+-- ==========
+--
--- build the test data base and store some tupples in it
+-- build the test data base and store some tupples in it
+use gnade;
CREATE TABLE EMPLOYEES (
empno int4 NOT NULL,
@@ -72,49 +73,49 @@
deptno int4 NOT NULL,
name character(20) NOT NULL,
location character(20)
-);
+);
---- Testdata
-insert into EMPLOYEES values
-( 1, 'Erdmann', 'Michael', 1001, '1999-12-31', 2, 'Coding Monkey', 'T', 200.1234 );
-insert into EMPLOYEES values
-( 2, 'Massalski', 'Marina', 1000, '2000-01-09', null, 'Supervisor', 'F', 200.00 );
-insert into EMPLOYEES values
-( 3, 'Tully', 'Noel', 1001, '1959-01-23', 2, 'Supervisor', 'T', 200.00 );
-insert into EMPLOYEES values
-( 4, 'Pfeifer', 'Jürgen', 1001, '2001-01-01', 2, 'Designer', 'T', 200.00 );
-insert into EMPLOYEES values
-( 5, 'Smith', 'John', 1000, '1980-06-11', 3, 'Coding Monkey', 'T', 250.00 );
-insert into EMPLOYEES values
-( 6, 'Smith', 'John', 1001, '1972-06-11', 3, 'Designer', 'T', 820.00 );
-insert into EMPLOYEES values
-( 50, 'Simpson', 'Bud', 1003, '1980-06-11', 3, 'Clerk', 'F', 20.00 );
-insert into EMPLOYEES values
-( 51, 'Bundy', 'Al', 1003, '1980-06-11', 3, 'Clerk', 'F', 10.00 );
-insert into EMPLOYEES values
-( 52, 'Bundy', 'Peggy', 1003, '1988-06-15', 3, null, 'F', -10.00 );
-insert into EMPLOYEES values
-( 53, 'Simpson', 'Kelly', 1003, '1995-09-11', 3, 'Secretary', 'F', 20.00 );
-insert into EMPLOYEES values
-(500, 'Rutherford', 'Ernest', 2000, '1930-05-30', 3, 'Genius', 'T',1200.00 );
-insert into EMPLOYEES values
-(501, 'Fermi', null, 2000, '1940-07-29', 3, 'Genius', 'T',1200.00 );
-insert into EMPLOYEES values
-(502, 'Einstein', 'Albert', 2000, '1941-04-30', 2, 'Genius', 'T',1200.00 );
-insert into EMPLOYEES values
-(503, 'Fermi', null, 2000, '1020-08-15', 2, 'Genius', 'T',1200.99 );
+-- Testdata
+insert into EMPLOYEES values
+( 1, 'Erdmann', 'Michael', 1001, '1999-12-31', 2, 'Coding Monkey', 1, 200.1234 );
+insert into EMPLOYEES values
+( 2, 'Massalski', 'Marina', 1000, '2000-01-09', null, 'Supervisor', 0, 200.00 );
+insert into EMPLOYEES values
+( 3, 'Tully', 'Noel', 1001, '1959-01-23', 2, 'Supervisor', 1, 200.00 );
+insert into EMPLOYEES values
+( 4, 'Pfeifer', 'Jürgen', 1001, '2001-01-01', 2, 'Designer', 1, 200.00 );
+insert into EMPLOYEES values
+( 5, 'Smith', 'John', 1000, '1980-06-11', 3, 'Coding Monkey', 1, 250.00 );
+insert into EMPLOYEES values
+( 6, 'Smith', 'John', 1001, '1972-06-11', 3, 'Designer', 1, 820.00 );
+insert into EMPLOYEES values
+( 50, 'Simpson', 'Bud', 1003, '1980-06-11', 3, 'Clerk', 0, 20.00 );
+insert into EMPLOYEES values
+( 51, 'Bundy', 'Al', 1003, '1980-06-11', 3, 'Clerk', 0, 10.00 );
+insert into EMPLOYEES values
+( 52, 'Bundy', 'Peggy', 1003, '1988-06-15', 3, null, 0, -10.00 );
+insert into EMPLOYEES values
+( 53, 'Simpson', 'Kelly', 1003, '1995-09-11', 3, 'Secretary', 0, 20.00 );
+insert into EMPLOYEES values
+(500, 'Rutherford', 'Ernest', 2000, '1930-05-30', 3, 'Genius', 1, 1200.00 );
+insert into EMPLOYEES values
+(501, 'Fermi', null, 2000, '1940-07-29', 3, 'Genius', 1, 1200.00 );
+insert into EMPLOYEES values
+(502, 'Einstein', 'Albert', 2000, '1941-04-30', 2, 'Genius', 1, 1200.00 );
+insert into EMPLOYEES values
+(503, 'Fermi', null, 2000, '1020-08-15', 2, 'Genius', 1, 1200.99 );
-insert into DEPARTMENTS
+insert into DEPARTMENTS
values( 1001, 'Sales', 'Berlin' );
-insert into DEPARTMENTS
+insert into DEPARTMENTS
values( 1000, 'Developement', 'Stuttgart' );
-insert into DEPARTMENTS
+insert into DEPARTMENTS
values( 1002, 'CM and Production', 'Bonn' );
-insert into DEPARTMENTS
+insert into DEPARTMENTS
values( 1003, 'Support', 'Chicago' );
-insert into DEPARTMENTS
- values( 2000, 'Masterminds', null );
+insert into DEPARTMENTS
+ values( 2000, 'Masterminds', null );
CREATE TABLE LOCATIONS (
@@ -123,14 +124,14 @@
STREET VARCHAR(80),
NO CHARACTER(5),
ZIPCODE INT
-) ;
+) ;
insert into LOCATIONS
- values( 'Berlin', 'Berlin','Siemensdamm', '50a', 10243 );
+ values( 'Berlin', 'Berlin','Siemensdamm', '50a', 10243 );
insert into LOCATIONS
- values( 'Bonn', 'Bonn','Oberkasselerstrasse', '8', 47112 );
+ values( 'Bonn', 'Bonn','Oberkasselerstrasse', '8', 47112 );
insert into LOCATIONS
- values( 'Stuttgart', 'Stuttgart','Lorenzweg', '1', 60001 );
+ values( 'Stuttgart', 'Stuttgart','Lorenzweg', '1', 60001 );
insert into LOCATIONS
- values( 'Chicage', 'Chicago','Bundy Stree', '9996', 70001 );
+ values( 'Chicage', 'Chicago','Bundy Stree', '9996', 70001 );
Index: gnade-1.6.2/samples/sqlite3/demo.adb
===================================================================
--- gnade-1.6.2.orig/samples/sqlite3/demo.adb 2009-10-05 02:20:57.000000000 -0400
+++ gnade-1.6.2/samples/sqlite3/demo.adb 2009-10-05 03:21:45.000000000 -0400
@@ -1,18 +1,26 @@
-with Ada.Text_IO; use Ada.Text_IO;
-
-with GNU.DB.SQLite3; use GNU.DB.SQLite3;
-
+with Ada.Command_Line; use Ada.Command_Line;
+with Ada.Directories;
+with Ada.Text_IO; use Ada.Text_IO;
+with GNU.DB.SQLite3; use GNU.DB.SQLite3;
+with GNU.DB.Support.String_Tables;
+with GNU.DB.Support.String_Vectors;
procedure Demo
is
- --Version : constant String := "$Id: demo.adb,v 1.2 2007/08/24 21:22:42 persan Exp $";
+ use GNU.DB.Support;
function List
(Argc : Integer;
Argv : String_Vectors.Vector;
ColumnNames : String_Vectors.Vector)
- return Return_Value is
- begin
- for I in Natural'(0) .. Natural (Argc - 1) loop
+ return Return_Value;
+
+ function List
+ (Argc : Integer;
+ Argv : String_Vectors.Vector;
+ ColumnNames : String_Vectors.Vector)
+ return Return_Value
+ is begin
+ for I in Natural'(0) .. Natural (Argc) loop
Put_Line (ColumnNames.Element (I) & ": " & Argv.Element (I));
end loop;
@@ -21,14 +29,38 @@
Db : aliased GNU.DB.SQLite3.Object;
- Table : Table_Reference := new String_Tables.Vector;
- Result : Return_Value;
- pragma Warnings (Off, Table);
- pragma Warnings (Off, Result);
-begin
- Put_Line ("Opening the file example.db");
+ Table : constant Table_Reference := new String_Tables.Vector;
+ Row_Cur : String_Tables.Cursor;
+ Col_Cur : String_Vectors.Cursor;
+
+ Result : Return_Value;
+
+ procedure Recreate_Db (File_Name : in String);
+ procedure Recreate_Db (File_Name : in String)
+ is
+ use Ada.Directories;
+ begin
+ if Exists (File_Name) then
+ Delete_File (File_Name);
+ end if;
+
+ Put_Line ("Opening database " & File_Name);
+ Result := Db.Open (File_Name);
+ end Recreate_Db;
- Result := Db.Open ("demo.db");
+ use type String_Tables.Cursor;
+begin
+ if Argument_Count = 0 then
+ Recreate_Db ("demo.db");
+ else
+ Recreate_Db (Argument (1));
+ end if;
+
+ if Result /= SQLITE_OK then
+ Put_Line ("error opening database");
+ Set_Exit_Status (Failure);
+ return;
+ end if;
Put_Line ("Create a table called DEMO with fields bla, ble and blo");
@@ -36,7 +68,7 @@
Db.Exec ("CREATE TABLE tare(Name String, Time Float, Data BLOB);");
New_Line;
- Put_Line ("Insert 10 rows with (100, 200, 300)");
+ Put_Line ("Insert 10 rows with (<n>, 200, 300)");
for I in 1 .. 10 loop
Db.Exec ("INSERT INTO demo VALUES(" & I'Img & ", 200, 300);");
@@ -50,23 +82,30 @@
Result := Db.Get_Table ("SELECT * FROM demo;", Table);
-
--- for I in Table.Table'Range loop
--- for J in Table.Table (I)'Range loop
--- Put (To_String (Table.Table (I) (J)));
--- Put (" ");
--- end loop;
---
--- New_Line;
--- end loop;
+ Row_Cur := Table.First;
+ loop
+ exit when Row_Cur = String_Tables.No_Element;
+ declare
+ Row : String_Vectors.Vector renames
+ Table.Element (String_Tables.To_Index (Row_Cur));
+ use type String_Vectors.Cursor;
+ begin
+ Col_Cur := String_Vectors.First (Row);
+ loop
+ exit when Col_Cur = String_Vectors.No_Element;
+ Put (Row.Element (String_Vectors.To_Index (Col_Cur)));
+ Put (", ");
+ String_Vectors.Next (Col_Cur);
+ end loop;
+ end;
+ New_Line;
+ String_Tables.Next (Row_Cur);
+ end loop;
New_Line;
- Put_Line ("2: Using exec_with_callback");
+ Put_Line ("2: Using exec_with_callback; bla > 4");
Db.Exec ("SELECT * FROM demo where bla > 4;", List'Unrestricted_Access);
New_Line;
- Put_Line ("Drop table DEMO");
-
- Result := Db.Exec ("DROP TABLE demo;");
Db.Close;
end Demo;