Re: what's the error meaning? on mast/slavery replication .

2018-05-06 Thread Laurenz Albe
林晓东 wrote:
> 
>  hi,all
>I got this when setup two replication server:
>   
>  致命错误:  在主用服务器和备用服务器之间,数据库系统标识符是不一样的。
>  详细信息:  主用服务器的标识符是6551342231479624101,备用服务器的标识符是6551367700460643417。
>   ---fatal erro: in main and backup server ,the database 's system id is not 
> same...
>  what's mean of this ,how to deal with ?

You need to start the standby with a physical backup of the database,
e.g. using pg_basebackup.
You cannot restore a database dump taken with pg_dump to start
streaming replication, because that is a logical backup (there is
no guarantee that the same data are in the same block of the same file).

Yours,
Laurenz Albe

-- 
+43-670-6056265
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26, A-2700 Wiener Neustadt
Web: https://www.cybertec-postgresql.com



Re: Known Bugs on Postgres 9.5

2018-05-06 Thread Vick Khera
On Sat, May 5, 2018 at 7:49 PM, David G. Johnston <
david.g.johns...@gmail.com> wrote:

> If you want an opinion, opting for more than one release behind current on
> fear grounds is an ultra-conservative position - you might as well minimize
> the pain and go recent and keep it longer.  At this point I'd be asking
> myself whether 9.6 or 10 is the better choice.  Though with a third-party
> application that runs on top of it I'd probably limit myself to the highest
> release they purport to support.
>
>
Precisely why I suggest 9.6


User defined functions in Postgresql, troubles with the c code

2018-05-06 Thread Christof Priller
Hi,
I'm searching somebody who has experience with C user defined functions in 
PostgreSQL.

Testing out a simple program which includes the postgres.h file does not work 
and gives me the following error code in Eclipse.

C:\Program Files\PostgreSQL\10\include\server/c.h:99:21: fatal error: 
libintl.h: No such file or directory

I wrote the following source:


#include 
#include 
#include "postgres.h"
//#include "fmgr.h"

int main(void) {
  puts("Hello World");
  return EXIT_SUCCESS;
}

Should I include the linbintl.h file in the source code or what should I Do?



Re: User defined functions in Postgresql, troubles with the c code

2018-05-06 Thread Adrian Klaver

On 05/05/2018 06:58 AM, Christof Priller wrote:

Hi,
I'm searching somebody who has experience with C user defined functions 
in PostgreSQL.


Testing out a simple program which includes the postgres.h file does not 
work and gives me the following error code in Eclipse.


C:\Program Files\PostgreSQL\10\include\server/c.h:99:21: fatal error: 
libintl.h: No such file or directory


I wrote the following source:

#include 
#include 
#include "postgres.h"
//#include "fmgr.h"

int main(void) {
       puts("Hello World");
       return EXIT_SUCCESS;
}

Should I include the linbintl.h file in the source code or what should I Do?


I see you are on Windows.

How did you install Postgres?








--
Adrian Klaver
adrian.kla...@aklaver.com



Re: CSVQL? CSV SQL? tab-separated table I/O? RENAME COLUMN

2018-05-06 Thread Ken Tanzer
On Fri, May 4, 2018 at 1:03 PM, George Neuner  wrote:

> On Thu, 3 May 2018 11:02:00 -0700, Adrian Klaver
>  wrote:
>
> >On 05/03/2018 09:47 AM, George Neuner wrote:
> >>
> >> ..., I would not discount the possibility that Microsoft really
> >> has patented some variation of CSV.  They absolutely did *try* to
> >> copyright the use of + and - symbols for specifying addition and
> >> subtraction operations in VisualBASIC.
> >
> >Not seeing it:
> >
> >http://patft.uspto.gov/netacgi/nph-Parser?Sect1=PTO2&Sect2=HITOFF&p=1&u=%
> 2Fnetahtml%2FPTO%2Fsearch-bool.html&r=0&f=S&l=50&TERM1=
> microsoft&FIELD1=AANM&co1=AND&TERM2=csv&FIELD2=&d=PTXT
>
>
> That's the patent database.  Microsoft tried to get a *copyright*.  I
> don't recall whether it was granted [I don't believe it was], and this
> would have been circa ~1990, so it's hard to search for in any case.
> Unlike the patent database, the copyright database does not contain
> the protected material - it only gives archival references to it.
>
> It generated quite a bit of negative press coverage at the time.  The
> basis of Microsoft's argument was that "x + y" was a unique and
> protectable expression of the addition concept because it could have
> been done in other ways, e.g., by "add(x,y)".
>
>
>
I don't think in general you can copyright a file format.  You can
copyright things you create, and you can try to keep secret the information
about how they work.  People can't steal your code to create CSV files, but
you can't tell people they can't string a bunch of values together with
commas in between if they can figure out how to do so all by themselves.
Plus it's hard to see how "fair use" wouldn't protect something as short as
"x+y", or ",".

FWIW, Wikipedia includes CSV in its list of open formats.  The article
linked below also says no, although it seems UK-based, not U.S.

Cheers,
Ken

https://en.wikipedia.org/wiki/List_of_open_formats
http://www.blplaw.com/expert-legal-insights/articles/copyright-protect-data-file-formats

>
>
>


-- 
AGENCY Software
A Free Software data system
By and for non-profits
*http://agency-software.org/ *
*https://demo.agency-software.org/client
*
ken.tan...@agency-software.org
(253) 245-3801

Subscribe to the mailing list
 to
learn more about AGENCY or
follow the discussion.


Re: pg_stat_statements : how to catch non successfully finished statements ?

2018-05-06 Thread legrand legrand
Progress report on this subject:

1/ Some clarifications: 

What is expected here is to update pgss counters for ALL the queries that
have been executed,
taking into account queries finished in SUCCESS and thoses finised with
ERROR.

Main interest here is to catch queries that are cancelled or interrupted
by a timeout after a long running period, that could be hours in BI
reporting environments.

Errors during parsing are not catched, because there is no hook available
before parsing 
and because witout parse tree available, QueryId can not be calculated. 
This is not a problem yet because the objective is not to count errors.

There was a remark off-list saying that cummulating SUCCESS and ERROR
counters
for the same query, could be a problem for thoses monitoring AVG indicators 
(becomming smaller than the SUCCESS ones).

One proposal is to add a Boolean flag (success) in the key of pgss:

dbid, userid, queryid, success, calls, total_time, ...
1 1   123  t100  100 000
1 1   123  f 101 000 000

  

2/ Modifying pgss_ExecutorRun (as suggested by Tom Lane) with:


PG_CATCH();
{
/* Added part to get counters on errors */
EState   *estate;
if (queryDesc->totaltime && pgss_enabled())
{
estate = queryDesc->estate;
InstrStopNode(queryDesc->totaltime, 
estate->es_processed);
InstrEndLoop(queryDesc->totaltime);

pgss_store(queryDesc->sourceText,
   queryDesc->plannedstmt->queryId,
   queryDesc->plannedstmt->stmt_location,
   queryDesc->plannedstmt->stmt_len,
   queryDesc->totaltime->total * 1000.0,
/* convert to msec */
   queryDesc->estate->es_processed,
   &queryDesc->totaltime->bufusage,
   NULL);
}

nested_level--;
PG_RE_THROW();
}
PG_END_TRY();


permits to catch simple queries in pgss (to be enhanced for utility
statements, pl/pgsql, 
parallel queries, ...).
Would such a code have a chance to be validated ?

Feedback is welcome.
Regards
PAscal



--
Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html



Add schema to the query

2018-05-06 Thread Igor Korot
Hi, ALL,

Is there an easy way to add the schema to the following query:

SELECT u.usename FROM pg_class c, pg_user u WHERE u.usesysid =
c.relowner AND relname = ?

Thank you.



Re: Add schema to the query

2018-05-06 Thread Melvin Davidson
On Sun, May 6, 2018 at 10:19 PM, Igor Korot  wrote:

> Hi, ALL,
>
> Is there an easy way to add the schema to the following query:
>
> SELECT u.usename FROM pg_class c, pg_user u WHERE u.usesysid =
> c.relowner AND relname = ?
>
> Thank you.
>
>
>Is there an easy way to add the schema to the following query:

You mean like this?
SELECT u.usename,
   *n.nspname AS schema*
  FROM pg_class c
*JOIN pg_namespace n ON n.oid = c.relnamespace,*
   pg_user u
 WHERE u.usesysid = c.relowner
   AND relname = ?


-- 
*Melvin Davidson*
*Maj. Database & Exploration Specialist*
*Universe Exploration Command – UXC*
Employment by invitation only!


Re: Add schema to the query

2018-05-06 Thread Melvin Davidson
On Sun, May 6, 2018 at 10:33 PM, Melvin Davidson 
wrote:

>
>
> On Sun, May 6, 2018 at 10:19 PM, Igor Korot  wrote:
>
>> Hi, ALL,
>>
>> Is there an easy way to add the schema to the following query:
>>
>> SELECT u.usename FROM pg_class c, pg_user u WHERE u.usesysid =
>> c.relowner AND relname = ?
>>
>> Thank you.
>>
>>
> >Is there an easy way to add the schema to the following query:
>
> You mean like this?
> SELECT u.usename,
>*n.nspname AS schema*
>   FROM pg_class c
> *JOIN pg_namespace n ON n.oid = c.relnamespace,*
>pg_user u
>  WHERE u.usesysid = c.relowner
>AND relname = ?
>
>
> --
> *Melvin Davidson*
> *Maj. Database & Exploration Specialist*
> *Universe Exploration Command – UXC*
> Employment by invitation only!
>

OR do you mean like this?
SELECT u.usename
  FROM pg_class c
*JOIN pg_namespace n ON n.oid = c.relnamespace, *
   pg_user u
 WHERE u.usesysid = c.relowner
   AND relname = ?


* AND n.nspname = 'public'*

-- 
*Melvin Davidson*
*Maj. Database & Exploration Specialist*
*Universe Exploration Command – UXC*
Employment by invitation only!


psycopg2.DataError: invalid input syntax for integer: ""

2018-05-06 Thread tango ward
Good day to all,

I need advice on how to solve this problem. I am new to this kind of task.
I want to insert data into my PostgreSQL DB. The field that I will store
data is a textfield but I am getting an error  invalid input syntax for
integer: ""

My code so far is this:

cur_p.execute("""
INSERT INTO a_recipient (created, mod, agreed, address, honor,)
VALUES (%s, %s)""", (current_timestamp,
current_timestamp, current_timestamp, '', ''))


If I remove the agreed and the last current_timestamp, it works fine as
well if I remove the honor which is a textfield and leave the 3
current_timestamp. I don't know if it is the date field with time and
timezone or the textfield which is having an issue.

I've read some related threads in SO but the ones I saw were either related
to CSV or Flask related.

Any suggestions please?


Thanks,
J


Re: psycopg2.DataError: invalid input syntax for integer: ""

2018-05-06 Thread David G. Johnston
On Sunday, May 6, 2018, tango ward  wrote:

> cur_p.execute("""
>
> INSERT INTO a_recipient (created, mod, agreed, address, 
> honor,)
> VALUES (%s, %s)""", (current_timestamp, current_timestamp, 
> current_timestamp, '', ''))
>
>
That code doesn't even run (extra comma after honor, not enough columns in
values).  Provide working code and the definition of a_recipient.

In short, you've passed an empty string to an integer column, which doesn't
work.  Supply null or pass a number.

David J.


Re: Add schema to the query

2018-05-06 Thread Igor Korot
Hi, Melvin,

On Sun, May 6, 2018 at 9:37 PM, Melvin Davidson  wrote:
>
>
> On Sun, May 6, 2018 at 10:33 PM, Melvin Davidson 
> wrote:
>>
>>
>>
>> On Sun, May 6, 2018 at 10:19 PM, Igor Korot  wrote:
>>>
>>> Hi, ALL,
>>>
>>> Is there an easy way to add the schema to the following query:
>>>
>>> SELECT u.usename FROM pg_class c, pg_user u WHERE u.usesysid =
>>> c.relowner AND relname = ?
>>>
>>> Thank you.
>>>
>>
>> >Is there an easy way to add the schema to the following query:
>>
>> You mean like this?
>> SELECT u.usename,
>>n.nspname AS schema
>>   FROM pg_class c
>> JOIN pg_namespace n ON n.oid = c.relnamespace,
>>pg_user u
>>  WHERE u.usesysid = c.relowner
>>AND relname = ?
>>
>>
>> --
>> Melvin Davidson
>> Maj. Database & Exploration Specialist
>> Universe Exploration Command – UXC
>> Employment by invitation only!
>
>
> OR do you mean like this?
> SELECT u.usename
>   FROM pg_class c
> JOIN pg_namespace n ON n.oid = c.relnamespace,
>pg_user u
>  WHERE u.usesysid = c.relowner
>AND relname = ?
>AND n.nspname = 'public'

Sorry needed to filter on the schema + table.

So, thank you.

>
>
> --
> Melvin Davidson
> Maj. Database & Exploration Specialist
> Universe Exploration Command – UXC
> Employment by invitation only!



Re: Add schema to the query

2018-05-06 Thread Rob Sargent


> On May 6, 2018, at 8:19 PM, Igor Korot  wrote:
> 
> Hi, ALL,
> 
> Is there an easy way to add the schema to the following query:
> 
> SELECT u.usename FROM pg_class c, pg_user u WHERE u.usesysid =
> c.relowner AND relname = ?
> 
> Thank you.
> 
Are you looking for the owner of a particular schema.tablename?



Re: CSVQL? CSV SQL? tab-separated table I/O? RENAME COLUMN

2018-05-06 Thread George Neuner
On Sun, 6 May 2018 15:26:22 -0700, Ken Tanzer 
wrote:

>On Fri, May 4, 2018 at 1:03 PM, George Neuner  wrote:
>
>> On Thu, 3 May 2018 11:02:00 -0700, Adrian Klaver
>>  wrote:
>>
>> >On 05/03/2018 09:47 AM, George Neuner wrote:
>> >>
>> >> ..., I would not discount the possibility that Microsoft really
>> >> has patented some variation of CSV.  They absolutely did *try* to
>> >> copyright the use of + and - symbols for specifying addition and
>> >> subtraction operations in VisualBASIC.
>> >
>> >Not seeing it:
>> >
>> >http://patft.uspto.gov/netacgi/nph-Parser?Sect1=PTO2&Sect2=HITOFF&p=1&u=%
>> 2Fnetahtml%2FPTO%2Fsearch-bool.html&r=0&f=S&l=50&TERM1=
>> microsoft&FIELD1=AANM&co1=AND&TERM2=csv&FIELD2=&d=PTXT
>>
>>
>> That's the patent database.  Microsoft tried to get a *copyright*.  I
>> don't recall whether it was granted [I don't believe it was], and this
>> would have been circa ~1990, so it's hard to search for in any case.
>> Unlike the patent database, the copyright database does not contain
>> the protected material - it only gives archival references to it.
>>
>> It generated quite a bit of negative press coverage at the time.  The
>> basis of Microsoft's argument was that "x + y" was a unique and
>> protectable expression of the addition concept because it could have
>> been done in other ways, e.g., by "add(x,y)".
>>
>>
>>
>I don't think in general you can copyright a file format. 

CSV is deliberately public domain, but I'm not at all certain that it
could not be copyrighted otherwise.  And I _am_ certain that a more
restricted derivative could be copyrighted. [more below]


You can copyright damn near anything.  Under the Berne convention, the
simple fact of authorship conveys certain rights even if the "work" is
a verbatim copy of something else.

The only rules - at least in the US - are that your expression of the
idea is not known to be common usage, and that it is neither a
verbatim copy, nor a derivative of a previously *registered* work.  

There are 3 kinds of copyrights: registered, explicit, and implicit.
The US recognizes registered and explicit copyrights, but protection
is available only for registered copyrights.
The US does not follow the Berne convention wrt implicit or explicit
copyrights.  Explicit copyrights carry no legal weight in the US, but
they *may* influence the court in case of a dispute because they do
represent a claim of the work.  The US does not recognize implicit
copyrights at all.


Checking that something is a verbatim copy of an existing work is not
that easy ... every registered work is archived in the Library of
Congress (LoC), but much of the LoC *still* is not electronically
searchable.  Determining whether something is or is not derivative of
something else is not even within the US Copyright Office's mandate
... they leave that to the courts.




>You can copyright things you create, 

Including data formats ... 

>and you can try to keep secret the information about how they work.  

Trade secret has nothing whatsoever to do with IP law.  Secrets convey
no legal protection, and a secret may still be an infringement on a
protected, publicly available work.

It might be hard to figure out that a secret is infringing ...


>People can't steal your code to create CSV files, but
>you can't tell people they can't string a bunch of values together with
>commas in between if they can figure out how to do so all by themselves.

>Plus it's hard to see how "fair use" wouldn't protect something as short as
>"x+y", or ",".

"Fair Use" has no effect on whether the work is copyrightable.  It
applies only after the fact as a possible defense against
infringement.

It doesn't even apply here.  Fair Use is not a general exception to
infringement under the law - it is in fact specifically limited to
educational and historical use.

Fair Use does not prescribe any minimum length "sampling" of the work.
It describes that there is a maximum length "sampling" that should be
permitted to be copied verbatim into a new work.  But, even there, the
allowable sample size is not fixed under the law: it is ad hoc, per
work, and decided after the fact by a court in the event of a dispute.

Note that some countries do not recognize the concept of Fair Use.


Punctuation alone is not copyrightable by law - the "work" is required
to be intelligible [for some definition - computer binaries can be
copyrighted].  The issue for a legitimate work would be whether it is
either in the public domain, or otherwise is a common usage not
deserving of a copyright.

In many cases, the Copyright Office is not equipped to determine
either status.  There is a database of registered copyrights, but the
"material" that was copyrighted is NOT in that database.  There is
just an LoC reference to it.  There is no database of public domain
works. Nor is there a database of failed applications.  There would be
archived examiner notes on failed applications, but who knows if they
are searchable?


>FWIW, Wikiped

Re: psycopg2.DataError: invalid input syntax for integer: ""

2018-05-06 Thread tango ward
Yes, my apologies.

May I also ask if there's a limitation for the number of timestamp with
timezone fields in a table?

On Mon, May 7, 2018 at 1:37 PM, David G. Johnston <
david.g.johns...@gmail.com> wrote:

> Please keep replies on-list, don't top-post, and double-check that the
> database table doesn't somehow have an integer column where you think its
> text.
>
>
> On Sunday, May 6, 2018, tango ward  wrote:
>
>> Yeah, the error doesn't really explain much. I have tried putting the
>> string formatter in ' ', still no good.
>>
>> On Mon, May 7, 2018 at 12:14 PM, David G. Johnston <
>> david.g.johns...@gmail.com> wrote:
>>
>>> On Sunday, May 6, 2018, tango ward  wrote:
>>>
 Hi,

 There's a mistake in the code, my bad.

 I updated the code into

 cur_p.execute("""
 INSERT INTO a_recipient (created, mod, agreed, address, 
 honor)
 VALUES (current_timestamp, current_timestamp, 
 current_timestamp, %s, %s)""", ('', ''))



 The code still won't work. The address and honor fields are textfields
 in Django models.py.

>>>
>>> Not sure but I'm thinking you at least need to add single quotes around
>>> the %s symbols.  That doesn't really explain the integer input error though
>>> I'm not familiar with the exact features of the execute method in Python.
>>>
>>> David J.
>>>
>>>
>>


Re: psycopg2.DataError: invalid input syntax for integer: ""

2018-05-06 Thread David G. Johnston
On Sunday, May 6, 2018, tango ward  wrote:

> Yes, my apologies.
>
> May I also ask if there's a limitation for the number of timestamp with
> timezone fields in a table?
>

Not one that is likely to matter in practice.  There's a page discussing
limitations on the website/docs somewhere if you wish to find out more.

David J.


Re: CSVQL? CSV SQL? tab-separated table I/O? RENAME COLUMN

2018-05-06 Thread Ken Tanzer
On Sun, May 6, 2018 at 10:22 PM, George Neuner  wrote:


> >> That's the patent database.  Microsoft tried to get a *copyright*.  I
>

>I don't think in general you can copyright a file format.
>
> And you absolutely can *patent* use of any data format for a given
> purpose [assuming the purpose itself is patentable].


Yes, I wasn't addressing patents, just addressing the issue of copyright
that you raised.


You can copyright damn near anything.  Under the Berne convention, the
> simple fact of authorship conveys certain rights even if the "work" is
> a verbatim copy of something else.
>
> The only rules - at least in the US - are that your expression of the
> idea is not known to be common usage, and that it is neither a
> verbatim copy, nor a derivative of a previously *registered* work.
>
>
That is patently untrue.  And really you don't have to be a lawyer to form
an opinion about this.

>From the US Copyright Office:

To be copyrightable, a work must qualify as an original work of authorship,
meaning that it must have been created independently and contain a
sufficient amount of creativity.

Copyright law expressly excludes copyright protection for “any idea,
procedure, process, system, method of operation, concept, principle, or
discovery, regardless of the form in which it is described, explained,
illustrated, or embodied.”

A recipe is a statement of the ingredients and procedure required for
making a dish of food. A mere listing of ingredients or contents, or a
simple set of directions, is uncopyrightable.

https://www.copyright.gov/circs/circ33.pdf

Cheers,
Ken

-- 
AGENCY Software
A Free Software data system
By and for non-profits
*http://agency-software.org/ *
*https://demo.agency-software.org/client
*
ken.tan...@agency-software.org
(253) 245-3801

Subscribe to the mailing list
 to
learn more about AGENCY or
follow the discussion.