Hello,

I was looking at putting the code for this in copy.c
CopyReadLineFunction.

If I do a printf at point A it compiles, installs, runs, doesn't display
any data after running initdb and returns a result when a COPY FROM is
executed in psql.

If I do a printf at point B it compiles, installs, and then crashes when
executing initdb.


loading pg_description ... initdb: child process exited with exit code
139
initdb: failed


Thoughts on why A is ok but B is not?

I don't really want to send any results to the screen if it is called
when first creating a database.  I have looked for something like
CMD_SELECT to identify when Initdb is executed.

Is their an existing variable I can check that I have not found?

Index: copy.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/backend/commands/copy.c,v
retrieving revision 1.218
diff -b -B -r1.218 copy.c
107c108
< 
---
> int             co_rows_inserted = 0;
1448a1451,1452
>         /*my code*/
>         co_rows_inserted = 0;
1782a1787
>               /*this is being called during database creation!!*/
1786a1792,1818
>                         co_rows_inserted = copy_lineno;
>                         char *buf = " ";
> 
>                         gcvt(co_rows_inserted, 10, buf);
>                         printf("%i   %s\n",co_rows_inserted, buf);/*ok here point A*/
> 
> 	            if (co_rows_inserted > 0)
> 		    {
>                       printf("%i   %s\n",co_rows_inserted, buf);/*not ok here point B*/
>                       /*
>                       StringInfoData msgbuf;
>                       pq_beginmessage(&msgbuf, ' ');
>                       pq_sendstring(&msgbuf, gettext(buf) );
>                       pq_endmessage(&msgbuf);
>                        */
>                      }           
>                     else if (co_rows_inserted == 0)
>                        {
>                            ereport(WARNING,(errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
>                                             errmsg ("File used to import data is empty."),
>                                             errhint("Double check file name used")));
>                        }else if (co_rows_inserted < 0)
>                                 {
>                                     ereport(ERROR,
>                                            (errcode(ERRCODE_BAD_COPY_FILE_FORMAT),                                                                                       errmsg("Rows copied were less than zero.  Copy function has been broken"),
>                                             errhint("File a bug please")));
>                                 }

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to