> I have just rejiggered the int8 support so that it only depends on
> snprintf instead of sprintf and sscanf.  The interesting thing about
> this is that we have our own version of snprintf that we use if the
> platform's C library hasn't got snprintf/vsnprintf --- and our version
> knows about %lld.  So if you have a compiler that offers 
> working 64-bit
> arithmetic, you don't need any help from the C library to 
> make int8 go.

This solution will work also on the Win32 port, beacuse the Cygwin libs
don't have vsscanf that supports 64-bit ints. Great.

			Dan

Sat, 7 Feb 1998 12:23:07 +0100 
Horak Daniel <horak@mmp.plzen-city.cz>
RE: [HACKERS] Re: Postgres for Sunos 4.1.4 
It seems to be snagging on 'char16'.  It says that
postgres.h is included for the declaration, yet,
when I scan the current postgres.h, char16 is 
no where to be found.

My CVS snapshot is from yesterday afternoon.

:) Clark

Fri, 12 Mar 1999 00:05:23 +0000
Clark Evans <clark.evans@manhattanproject.com>
tutorial won't compile in current tree.
Clark Evans <clark.evans@manhattanproject.com> writes:
> It seems to be snagging on 'char16'.

IIRC, char16 was deleted in 6.4 or maybe earlier (along with the other
special "charN" type names).  "char(16)" is the accepted spelling now.

A quick glimpse shows an awful lot of appearances of "char16"
in the contrib area, as well as the tutorial and some residual
uses in the documentation.  Sigh.  I guess that stuff is not
exercised as regularly as it oughta be.

Do you want to contribute a patch to make the tutorial work again?

			regards, tom lane

Fri, 12 Mar 1999 10:46:22 -0500
Tom Lane <tgl@sss.pgh.pa.us>
Re: [HACKERS] tutorial won't compile in current tree. 
> Clark Evans <clark.evans@manhattanproject.com> writes:
> > It seems to be snagging on 'char16'.
> 
> IIRC, char16 was deleted in 6.4 or maybe earlier (along with the other
> special "charN" type names).  "char(16)" is the accepted spelling now.
> 
> A quick glimpse shows an awful lot of appearances of "char16"
> in the contrib area, as well as the tutorial and some residual
> uses in the documentation.  Sigh.  I guess that stuff is not
> exercised as regularly as it oughta be.

It was...I removed all references to the char16 type in the tutorial
and documentation when I removed the type itself.

Did someone accidentally commit it back with some other patch?

Darren

Fri, 12 Mar 1999 18:36:53 -0500
"Stupor Genius" <stuporg@erols.com>
RE: [HACKERS] tutorial won't compile in current tree. 
I was wondering if this function should be
'wrapped up' and put into the SPI interface.
I did some research and think I could pull 
it off.

Currently the tutorial uses this:

> bool
> c_overpaid( TUPLE t,             /* the current instance of EMP */
>            int4 limit)
> {
>     bool        isnull = false;
>     int4        salary;
> 
>     salary = (int4) GetAttributeByName(t, "salary", &isnull);
> 
>     if (isnull)
>         return false;
>     return salary > limit;
> }

And the regression test uses this:

> 
> char
> overpaid(tuple)
> TUPLE       tuple;
> {
>     bool        isnull;
>     long        salary;
> 
>     salary = (long) GetAttributeByName(tuple, "salary", &isnull);
>     return salary > 699;
> }


Here is a proposal:

a) An explanation between a TupleTableSlot
   and a HeapTuple / TupleDesc pair.  (help?)

   Perhaps we call the (TupleTableSlot *) a
   QueryTuple ?  It's called a TUPLE in the
   two above usages, where a TUPLE == (void *)

b) Six more functions (overloaded?)

   Existing:

   Datum SPI_getbinval(HeapTuple, TupleDesc, int, bool *)
   char *SPI_getvalue (HeapTuple, TupleDesc, int)

   Two more by index:

   Datum SPI_getbinval(TupleTableSlot, int, bool *)
   char *SPI_getvalue (TupleTableSlot, int)

   Four more by name:

   Datum SPI_getbinval(HeapTuple, TupleDesc, char *, bool *)
   char *SPI_getvalue (HeapTuple, TupleDesc, char *)
   Datum SPI_getbinval(TupleTableSlot, char *, bool *)
   char *SPI_getvalue (TupleTableSlot, char *)


Hmmm.  Better yet, is there a way to hide 
the difference in the SPI by using a 'smart' 
structure?

Clark

Sat, 13 Mar 1999 01:32:31 +0000
Clark Evans <clark.evans@manhattanproject.com>
GetAttributeByName
I was looking at the tutorial code (funcs.c) a bit more
and it seems that a bulk of the work going on for the
"copytext" and "concat16" (soon to be defunct *smile* )
is converting from string to datum and then back again.

Perhaps if two functions were added to the SPI that 
did this operation...

Datum       SPI_stringtodatum(const char *type, const char *data);
const char *SPI_datumtostring(Datum data);

These two functions would lookup the type in the 
type table, find the input/output functions for
the datatype and make the call.

Thoughts?

Clark

Sat, 13 Mar 1999 02:20:01 +0000
Clark Evans <clark.evans@manhattanproject.com>
SPI_stringtodatum  SPI_datumtostring ?
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> > Clark Evans <clark.evans@manhattanproject.com> writes:
> > > It seems to be snagging on 'char16'.
> > 
> > IIRC, char16 was deleted in 6.4 or maybe earlier (along with the other
> > special "charN" type names).  "char(16)" is the accepted spelling now.
> > 
> > A quick glimpse shows an awful lot of appearances of "char16"
> > in the contrib area, as well as the tutorial and some residual
> > uses in the documentation.  Sigh.  I guess that stuff is not
> > exercised as regularly as it oughta be.
> 
> It was...I removed all references to the char16 type in the tutorial
> and documentation when I removed the type itself.
> 
> Did someone accidentally commit it back with some other patch?

It is the tutorual/func*.* files.

-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  maillist@candle.pha.pa.us            |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Fri, 12 Mar 1999 21:25:42 -0500 (EST)
Bruce Momjian <maillist@candle.pha.pa.us>
Re: [HACKERS] tutorial won't compile in current tree.
Bruce Momjian wrote:
> It is the tutorual/func*.* files.

Yes.

Sat, 13 Mar 1999 03:03:48 +0000
Clark Evans <clark.evans@manhattanproject.com>
Re: [HACKERS] tutorial won't compile in current tree.
Thoughts:

a) In funcs.c, to get it to compile, simply remove
the concat16 function and replace TUPLE with TupleTableSlot .

b) In funcs.c it does not make sense to fix concat16, it
should just be removed.  

First, the fix would make it almost identical to 'text', 
only you truncate and pad extra spaces at the end, thus 
this extra duplication does little for the tutorial.  
I think the tutorial should be modified to use another 
fixed length data type, mabye a square?  This leads to:

Second, from a procedure/trigger builder's perspective,
a SPI_stringtodatum and SPI_datumtostring make more 
sence than having the programmer worry about the
internal representation of the data type, this is what
the conversion functions are for anyway....  thus, I 
even see the 'copytext' code being replaced with
something seperated from the internal structure of the
database executor with these conversion functions.

c) In funcs.source I could not get this function to compile..

| clark=> 
| clark=> CREATE FUNCTION clean_EMP () RETURNS int4                                                     
| clark->    AS 'DELETE FROM EMP WHERE EMP.salary <= 0\;                                                
| clark'>        SELECT 1 AS ignore_this'                                                               
| clark->    LANGUAGE 'sql';                                                                            
| ERROR:  parser: parse error at or near ""

d) I had a weird problem with the columns not showing up..

> [clark@monster clark]$ psql
> Welcome to the POSTGRESQL interactive sql monitor:
>   Please read the file COPYRIGHT for copyright terms of POSTGRESQL
> 
>    type \? for help on slash commands
>    type \q to quit
>    type \g or terminate with semicolon to execute query
>  You are currently connected to the database: clark
> 
> clark=> CREATE TABLE EMP (                                                                            
> clark->     name        text,                                                                         
> clark->     salary      int4,                                                                         
> clark->     age         int4,                                                                         
> clark->     dept        char(16)                                                                      
> clark-> );                                                                                            
> CREATE
> clark=>                                                                                               
> clark=> INSERT INTO EMP VALUES ('Sam', 1200, 16, 'toy');                                              
> INSERT 182188 1
> clark=> INSERT INTO EMP VALUES ('Claire', 5000, 32, 'shoe');                                          
> INSERT 182189 1
> clark=> INSERT INTO EMP VALUES ('Andy', -1000, 2, 'candy');                                           
> INSERT 182190 1
> clark=> INSERT INTO EMP VALUES ('Bill', 4200, 36, 'shoe');                                            
> INSERT 182191 1
> clark=> INSERT INTO EMP VALUES ('Ginger', 4800, 30, 'candy');         
> INSERT 182192 1
> clark=> \d emp
> 
> Table    = emp
> +----------------------------------+----------------------------------+-------+
> |              Field               |              Type                | Length|
> +----------------------------------+----------------------------------+-------+
> | name                             | text                             |   var |
> | dept                             | char()                           |    16 |
> +----------------------------------+----------------------------------+-------+
> clark=> select * from emp;
> name  |salary|age|dept            
> ------+------+---+----------------
> Sam   |  1200| 16|toy             
> Claire|  5000| 32|shoe            
> Andy  | -1000|  2|candy           
> Bill  |  4200| 36|shoe            
> Ginger|  4800| 30|candy           
> (5 rows)
> 


Thomas,

If you still want a patch file, I can work on it Sunday.

:) Clark

Sat, 13 Mar 1999 06:42:34 +0000
Clark Evans <clark.evans@manhattanproject.com>
Re: [HACKERS] tutorial won't compile in current tree.
Can you send me a patch?  It would be easier, and less error-prone.  Thanks.


> Thoughts:
> 
> a) In funcs.c, to get it to compile, simply remove
> the concat16 function and replace TUPLE with TupleTableSlot .
> 
> b) In funcs.c it does not make sense to fix concat16, it
> should just be removed.  
> 
> First, the fix would make it almost identical to 'text', 
> only you truncate and pad extra spaces at the end, thus 
> this extra duplication does little for the tutorial.  
> I think the tutorial should be modified to use another 
> fixed length data type, mabye a square?  This leads to:
> 
> Second, from a procedure/trigger builder's perspective,
> a SPI_stringtodatum and SPI_datumtostring make more 
> sence than having the programmer worry about the
> internal representation of the data type, this is what
> the conversion functions are for anyway....  thus, I 
> even see the 'copytext' code being replaced with
> something seperated from the internal structure of the
> database executor with these conversion functions.
> 
> c) In funcs.source I could not get this function to compile..
> 
> | clark=> 
> | clark=> CREATE FUNCTION clean_EMP () RETURNS int4                                                     
> | clark->    AS 'DELETE FROM EMP WHERE EMP.salary <= 0\;                                                
> | clark'>        SELECT 1 AS ignore_this'                                                               
> | clark->    LANGUAGE 'sql';                                                                            
> | ERROR:  parser: parse error at or near ""
> 
> d) I had a weird problem with the columns not showing up..
> 
> > [clark@monster clark]$ psql
> > Welcome to the POSTGRESQL interactive sql monitor:
> >   Please read the file COPYRIGHT for copyright terms of POSTGRESQL
> > 
> >    type \? for help on slash commands
> >    type \q to quit
> >    type \g or terminate with semicolon to execute query
> >  You are currently connected to the database: clark
> > 
> > clark=> CREATE TABLE EMP (                                                                            
> > clark->     name        text,                                                                         
> > clark->     salary      int4,                                                                         
> > clark->     age         int4,                                                                         
> > clark->     dept        char(16)                                                                      
> > clark-> );                                                                                            
> > CREATE
> > clark=>                                                                                               
> > clark=> INSERT INTO EMP VALUES ('Sam', 1200, 16, 'toy');                                              
> > INSERT 182188 1
> > clark=> INSERT INTO EMP VALUES ('Claire', 5000, 32, 'shoe');                                          
> > INSERT 182189 1
> > clark=> INSERT INTO EMP VALUES ('Andy', -1000, 2, 'candy');                                           
> > INSERT 182190 1
> > clark=> INSERT INTO EMP VALUES ('Bill', 4200, 36, 'shoe');                                            
> > INSERT 182191 1
> > clark=> INSERT INTO EMP VALUES ('Ginger', 4800, 30, 'candy');         
> > INSERT 182192 1
> > clark=> \d emp
> > 
> > Table    = emp
> > +----------------------------------+----------------------------------+-------+
> > |              Field               |              Type                | Length|
> > +----------------------------------+----------------------------------+-------+
> > | name                             | text                             |   var |
> > | dept                             | char()                           |    16 |
> > +----------------------------------+----------------------------------+-------+
> > clark=> select * from emp;
> > name  |salary|age|dept            
> > ------+------+---+----------------
> > Sam   |  1200| 16|toy             
> > Claire|  5000| 32|shoe            
> > Andy  | -1000|  2|candy           
> > Bill  |  4200| 36|shoe            
> > Ginger|  4800| 30|candy           
> > (5 rows)
> > 
> 
> 
> Thomas,
> 
> If you still want a patch file, I can work on it Sunday.
> 
> :) Clark
> 
> 


-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  maillist@candle.pha.pa.us            |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Sat, 13 Mar 1999 21:59:12 -0500 (EST)
Bruce Momjian <maillist@candle.pha.pa.us>
Re: [HACKERS] tutorial won't compile in current tree.