Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit221d729

Browse files
committed
Here is a bug fix and some spelling changes for the complex number tutorial
code. I have also written a complete complex number package based on thistutorial; I will submit this as a contribution soon. Is there a particularformat for contributed tar files? I have a C source file, two SQL files, and aMakefile.Thomas Lockhart
1 parentcb6cb77 commit221d729

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

‎src/tutorial/C-code/complex.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ int4
113113
complex_abs_cmp(Complex*a,Complex*b)
114114
{
115115
doubleamag=Mag(a),bmag=Mag(b);
116-
if (a<b)
116+
if (amag<bmag)
117117
return-1;
118-
elseif (a>b)
118+
elseif (amag>bmag)
119119
return1;
120120
else
121121
return0;

‎src/tutorial/complex.source

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
--
33
-- complex.sql-
44
-- This file shows how to create a new user-defined type and how to
5-
-- usethem.
5+
-- usethis new type.
66
--
77
--
88
-- Copyright (c) 1994, Regents of the University of California
99
--
10-
-- $Id: complex.source,v 1.1.1.1 1996/07/09 06:22:34 scrappy Exp $
10+
-- $Id: complex.source,v 1.2 1996/12/28 02:22:07 momjian Exp $
1111
--
1212
---------------------------------------------------------------------------
1313

@@ -105,7 +105,7 @@ SELECT a + '(1.0,1.0)'::complex AS aa,
105105

106106
-----------------------------
107107
-- Creating aggregate functions
108-
--you can also define aggregate functions. The syntax issome what
108+
--you can also define aggregate functions. The syntax issomewhat
109109
--cryptic but the idea is to express the aggregate in terms of state
110110
--transition functions.
111111
-----------------------------
@@ -122,8 +122,8 @@ SELECT complex_sum(a) FROM test_complex;
122122

123123
-------------------------------------------------------------------------------
124124
-- ATTENTION! ATTENTION! ATTENTION! --
125-
-- YOU MAY SKIP THE SECTION BELOW ON INTERFACING WITHINDICIES. YOU DON'T --
126-
-- NEED THE FOLLOWING IF YOU DON'T USEINDICIES WITH NEW DATA TYPES. --
125+
-- YOU MAY SKIP THE SECTION BELOW ON INTERFACING WITHINDICES. YOU DON'T --
126+
-- NEED THE FOLLOWING IF YOU DON'T USEINDICES WITH NEW DATA TYPES. --
127127
-------------------------------------------------------------------------------
128128

129129
SELECT 'READ ABOVE!' AS STOP;
@@ -239,7 +239,8 @@ INSERT INTO pg_amproc (amid, amopclaid, amproc, amprocnum)
239239
and proname = 'complex_abs_cmp';
240240

241241
-- now, we can define a btree index on complex types. First, let's populate
242-
-- the table (THIS DOESN'T ACTUALLY WORK. YOU NEED MANY MORE TUPLES.)
242+
-- the table. Note that postgres needs many more tuples to start using the
243+
-- btree index during selects.
243244
INSERT INTO test_complex VALUES ('(56.0,-22.5)', '(-43.2,-0.07)')
244245
INSERT INTO test_complex VALUES ('(-91.9,33.6)', '(8.6,3.0)');
245246

@@ -248,4 +249,4 @@ CREATE INDEX test_cplx_ind ON test_complex
248249

249250
SELECT * from test_complex where a = '(56.0,-22.5)';
250251
SELECT * from test_complex where a < '(56.0,-22.5)';
251-
SELECT * from test_complex where a > '(56.0,-22.5)';
252+
SELECT * from test_complex where a > '(56.0,-22.5)';

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp