Show the CREATE VIEW code for a view in PostgreSQL?

Kept having to return here to look up pg_get_viewdef (how to remember that!!), so searched for a more memorable command… and got it: \d+ viewname You can see similar sorts of commands by typing \? at the pgsql command line. Bonus tip: The emacs command sql-postgres makes pgsql a lot more pleasant (edit, copy, paste, … Read more

Why does initializing an extern variable inside a function give an error?

The reason defining an external variable inside a function does not make sense is the following: When you declare a symbol extern, you are telling the compiler to link all such occurrences of this value into the same symbol. Any occurences of extern int i; in your program would link to the externally defined i. … Read more

How to define an array of functions in C

I have a struct that contains a declaration like this one: No you don’t. That’s a syntax error. You’re looking for: void (*functions[256])(); Which is an array of function pointers. Note, however, that void func() isn’t a “function that takes no arguments and returns nothing.” It is a function that takes unspecified numbers or types … Read more

Is Ruby a scripting language or an interpreted language?

Things aren’t just black and white. At the very least, they’re also big and small, loud and quiet, blue and orange, grey and gray, long and short, right and wrong, etc. Interpreted/compiled is just one way to categorize languages, and it’s completely independent from (among countless other things) whether you call the same language a … Read more

What’s the technical definition for “routine”?

The term routine derives from subroutine, which is a more common term in languages like BASIC where one actually creates SUBroutines. (BASIC actually had a difference between a SUBroutine and a FUNCTION, but nevertheless…) From the Wikipedia entry: In computer science, a subroutine (also called procedure, function, routine, method, or subprogram) is a portion of … Read more

Weird undefined symbols of static constants inside a struct/class

Definition needed The code you have provided is non-standard. While you can provide initializers for const static int members directly in the class, you still need to provide separate definitions. It is weird, a kind of unexpected, but you are expected to write it like this: #include <algorithm> struct Foo { static const int A … Read more

Asynchronous and Synchronous Terms

Indeed, it’s one of these cases, where original meaning of the word was subverted and means something different than in popular usage. ‘Synchronisation’ in telecommunication means that receiver signals whenever it is ready to receive messages, and only after this signal the transmitter will start transmitting. When the transmitter is done with the message, it … Read more

What is the One-Definition Rule?

The truth is in the standard (3.2 One definition rule) : No translation unit shall contain more than one definition of any variable, function, class type, enumeration type or template. […] Every program shall contain exactly one definition of every non-inline function or object that is used in that program; no diagnostic required. The definition … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)